'.$value.'
@@ -940,74 +993,75 @@ class e_form
'.$ret.'
';
- }
- return '';
}
- // The 2 functions below are for demonstration purposes only, and may be moved/modified before release.
- function filterType($fieldarray)
+ return '';
+ }
+
+ // The 2 functions below are for demonstration purposes only, and may be moved/modified before release.
+ function filterType($fieldarray)
+ {
+ return " frm-> filterType() is Deprecated ";
+ define("e_AJAX_REQUEST", TRUE);
+ $text = "";
- return $text;
- }
-
- function filterValue($type = '', $fields = '')
- {
- return " frm-> filterValue() is Deprecated. ";
-
- if($type)
- {
-
- switch($fields[$type]['type'])
- {
- case "datestamp":
- return "[date field]";
- break;
-
- case "boolean":
-
- return "\n
-
- ";
- break;
-
- case "user":
- return "";
- break;
+ case "boolean":
+
+ return "\n
+
+ ";
+ break;
+
+ case "user":
+ return "";
+ break;
+
+ default:
+
+ return $this->text('searchquery', '', 50);
- default:
-
- return $this->text('searchquery', '', 50);
-
- }
}
- else
- {
- return $this->text('searchquery', '', 50);
- }
- // This needs to be dynamic for the various form types, and be loaded via ajax.
}
-
- /**
- * Generates a batch options select component
- * This component is generally associated with a table of items where one or more rows in the table can be selected (using checkboxes).
- * The list options determine some processing that wil lbe applied to all checked rows when the form is submitted.
- *
- * @param array $options associative array of option elements, keyed on the option value
- * @param array ucOptions [optional] associative array of userclass option groups to display, keyed on the option value prefix
- * @return string the HTML for the form component
- */
- function batchoptions($options, $ucOptions = null)
+ else
{
+ return $this->text('searchquery', '', 50);
+ }
+ // This needs to be dynamic for the various form types, and be loaded via ajax.
+ }
+
+ /**
+ * Generates a batch options select component
+ * This component is generally associated with a table of items where one or more rows in the table can be selected (using checkboxes).
+ * The list options determine some processing that wil lbe applied to all checked rows when the form is submitted.
+ *
+ * @param array $options associative array of option elements, keyed on the option value
+ * @param array ucOptions [optional] associative array of userclass option groups to display, keyed on the option value prefix
+ * @return string the HTML for the form component
+ */
+ function batchoptions($options, $ucOptions = null)
+ {
$text = "
@@ -1076,7 +1130,7 @@ class e_form
$text .= "
".$this->select_close()."
".$this->admin_button('trigger_execute_batch', 'trigger_execute_batch', 'submit multi e-hide-if-js', 'Go')."
-
+
";
return $text;
diff --git a/e107_handlers/js_manager.php b/e107_handlers/js_manager.php
index 7d49d943b..017dbb06d 100644
--- a/e107_handlers/js_manager.php
+++ b/e107_handlers/js_manager.php
@@ -7,8 +7,8 @@
* GNU General Public License (http://gnu.org).
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/js_manager.php,v $
- * $Revision: 1.5 $
- * $Date: 2009-10-07 11:05:55 $
+ * $Revision: 1.6 $
+ * $Date: 2009-10-30 17:59:32 $
* $Author: secretr $
*
*/
@@ -52,6 +52,20 @@ class e_jsmanager
*/
protected $_runtime_header_src = array();
+ /**
+ * Current Header zone (under development)
+ *
+ * @var array
+ */
+ protected $_zone_header = 0;
+
+ /**
+ * Current Footer zone (under development)
+ *
+ * @var array
+ */
+ protected $_zone_footer = 0;
+
/**
* JS files array - loaded in page footer
*
@@ -292,7 +306,7 @@ class e_jsmanager
* @param integer $zone 1-5 (see header.php)
* @return e_jsmanager
*/
- public function headerCore($file_path, $zone = 1)
+ public function headerCore($file_path, $zone = 2)
{
$this->headerFile('{e_FILE}jslib/'.trim($file_path, '/'), $zone);
return $this;
diff --git a/e107_handlers/message_handler.php b/e107_handlers/message_handler.php
index 04fbe8313..59b795077 100644
--- a/e107_handlers/message_handler.php
+++ b/e107_handlers/message_handler.php
@@ -9,8 +9,8 @@
* Message Handler
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/message_handler.php,v $
- * $Revision: 1.22 $
- * $Date: 2009-10-22 14:18:18 $
+ * $Revision: 1.23 $
+ * $Date: 2009-10-30 17:59:32 $
* $Author: secretr $
*
*/
@@ -511,20 +511,22 @@ class eMessage
*/
public function moveStack($from_stack, $to_stack = 'default', $type = false, $session = true)
{
+ if($from_stack == $to_stack) return $this;
foreach ($this->_sysmsg as $_type => $stacks)
{
if($type && $type !== $_type)
{
continue;
}
+
if(isset($stacks[$from_stack]))
{
if(!isset($this->_sysmsg[$_type][$to_stack]))
{
$this->_sysmsg[$_type][$to_stack] = array();
}
- array_merge($this->_sysmsg[$_type][$from_stack], $this->_sysmsg[$_type][$to_stack]);
- unset($this->_sysmsg[$_type][$to_stack]);
+ $this->_sysmsg[$_type][$to_stack] = array_merge($this->_sysmsg[$_type][$to_stack], $this->_sysmsg[$_type][$from_stack]);
+ unset($this->_sysmsg[$_type][$from_stack]);
}
}
@@ -544,6 +546,7 @@ class eMessage
*/
public function moveSessionStack($from_stack, $to_stack = 'default', $type = false)
{
+ if($from_stack == $to_stack) return $this;
foreach ($_SESSION[$this->_session_id] as $_type => $stacks)
{
if($type && $type !== $_type)
@@ -554,10 +557,10 @@ class eMessage
{
if(!isset($_SESSION[$this->_session_id][$_type][$to_stack]))
{
- $this->_sysmsg[$_type][$to_stack] = array();
+ $_SESSION[$this->_session_id][$_type][$to_stack] = array();
}
- array_merge($_SESSION[$this->_session_id][$_type][$from_stack], $this->_sysmsg[$_type][$to_stack]);
- unset($_SESSION[$this->_session_id][$_type][$to_stack]);
+ $_SESSION[$this->_session_id][$_type][$to_stack] = array_merge($_SESSION[$this->_session_id][$_type][$to_stack], $this->_sysmsg[$_type][$from_stack]);
+ unset($_SESSION[$this->_session_id][$_type][$from_stack]);
}
}
diff --git a/e107_handlers/model_class.php b/e107_handlers/model_class.php
index b253027d2..78de0331f 100644
--- a/e107_handlers/model_class.php
+++ b/e107_handlers/model_class.php
@@ -9,8 +9,8 @@
* e107 Base Model
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/model_class.php,v $
- * $Revision: 1.26 $
- * $Date: 2009-10-28 17:05:34 $
+ * $Revision: 1.27 $
+ * $Date: 2009-10-30 17:59:31 $
* $Author: secretr $
*/
@@ -44,6 +44,15 @@ class e_model
* @var array
*/
protected $_data_fields = array();
+
+ /**
+ * Current model DB table, used in all db calls
+ *
+ * This can/should be overwritten/set by extending the class
+ *
+ * @var string
+ */
+ protected $_db_table;
/**
* Runtime cache of parsed from {@link _getData()} keys
@@ -74,8 +83,14 @@ class e_model
* @var string
*/
protected $_message_stack = 'default';
-
-
+
+ /**
+ * Model parameters passed mostly from external sources
+ *
+ * @var array
+ */
+ protected $_params = array();
+
/**
* Constructor - set data on initialization
*
@@ -86,6 +101,27 @@ class e_model
$this->setData($data);
}
+ /**
+ * Optional DB table - used for auto-load data from the DB
+ * @param string $table
+ * @return e_model
+ */
+ public function getModelTable()
+ {
+ return $this->_db_table;
+ }
+
+ /**
+ * Set model DB table
+ * @param string $table
+ * @return e_model
+ */
+ public function setModelTable($table)
+ {
+ $this->_db_table = $table;
+ return $this;
+ }
+
/**
* Get data fields array
* @return array
@@ -427,7 +463,7 @@ class e_model
return $this;
}
- $this->$data_src = $key;
+ $this->${data_src} = $key;
return $this;
}
@@ -765,13 +801,33 @@ class e_model
}
/**
- * Load data from DB
- * Awaiting for child class implementation
- *
+ * Generic load data from DB
+ * @param boolean $force
+ * @return e_admin
*/
- public function load()
- {
- }
+ public function load($id, $force = false)
+ {
+ if($this->hasData() && !$force)
+ {
+ return $this;
+ }
+ $id = intval($id);
+
+ $qry = str_replace('{ID}', $id, $this->getParam('db_query'));
+ if(!$qry)
+ {
+ $qry = '
+ SELECT * FROM #'.$this->getModelTable().' WHERE '.$this->getFieldIdName().'='.$id.'
+ ';
+ }
+ //TODO - error reporting
+ $sql = e107::getDb();
+ if($sql->db_Select_gen($qry))
+ {
+ $this->setData($sql->db_Fetch());
+ }
+ return $this;
+ }
/**
* Save data to DB
@@ -800,6 +856,73 @@ class e_model
{
}
+ /**
+ * Replace DB record
+ * Awaiting for child class implementation
+ * @see e_model_admin
+ */
+ public function dbReplace()
+ {
+ }
+
+ /**
+ * Delete DB data
+ * Awaiting for child class implementation
+ * @see e_model_admin
+ */
+ public function dbDelete()
+ {
+ }
+
+ /**
+ * Set parameter array
+ * Core parameters:
+ * - db_query: string db query to be passed to load() ($sql->db_Select_gen())
+ * - model_class: e_tree_model class - string class name for creating nodes inside default load() method
+ *
+ * @param array $params
+ * @return e_model
+ */
+ public function setParams(array $params)
+ {
+ $this->_params = $params;
+ return $this;
+ }
+
+ /**
+ * Get parameter array
+ *
+ * @return array parameters
+ */
+ public function getParams()
+ {
+ return $this->_params;
+ }
+
+ /**
+ * Set parameter
+ *
+ * @param string $key
+ * @param mixed $value
+ * @return e_model
+ */
+ public function setParam($key, $value)
+ {
+ $this->_params[$key] = $value;
+ return $this;
+ }
+
+ /**
+ * Get parameter
+ *
+ * @param string $key
+ * @param mixed $default
+ */
+ public function getParam($key, $default = null)
+ {
+ return (isset($this->_params[$key]) ? $this->_params[$key] : $default);
+ }
+
/**
* Try to convert string to a number
* Shoud fix locale related troubles
@@ -863,6 +986,16 @@ class e_model
{
return $this->toString((@func_get_arg(0) === true));
}
+
+ public function destroy()
+ {
+ $this->_data = array();
+ $this->_params = array();
+ $this->_data_fields = array();
+ $this->_parsed_keys = array();
+ $this->_db_table = $this->_field_id = '';
+ $this->data_has_changed = false;
+ }
}
//FIXME - move e_model_admin to e_model_admin.php
@@ -895,15 +1028,6 @@ class e_model
*/
class e_admin_model extends e_model
{
- /**
- * Current model DB table, used in all db calls
- *
- * This can/should be overwritten by extending the class
- *
- * @var string
- */
- protected $_db_table;
-
/**
* Posted data
* Back-end related
@@ -926,7 +1050,7 @@ class e_admin_model extends e_model
* Validation structure - see {@link e_validator::$_required_rules} for
* more information about the array format.
* Used in {@link validate()} method.
- *
+ * TODO - check_rules (see e_validator::$_optional_rules)
* This can/should be overwritten by extending the class.
*
* @var array
@@ -945,17 +1069,6 @@ class e_admin_model extends e_model
*/
protected $_validator = null;
- public function setModelTable($table)
- {
- $this->_db_table = $table;
- return $this;
- }
-
- public function getModelTable()
- {
- return $this->_db_table;
- }
-
/**
* @return array
*/
@@ -1449,12 +1562,30 @@ class e_admin_model extends e_model
return ($this->hasValidationError() || $this->hasSqlError());
}
+ /**
+ * Generic load data from DB
+ * @param boolean $force
+ * @return e_admin_model
+ */
+ public function load($id, $force = false)
+ {
+ parent::load($id, $force);
+
+ $this->_db_errno = e107::getDb()->getLastErrorNumber();
+ if($this->_db_errno)
+ {
+ $this->addMessageError('SQL Update Error', $session_messages); //TODO - Lan
+ $this->addMessageDebug('SQL Error #'.$this->_db_errno.': '.e107::getDb()->getLastErrorText());
+ }
+ return $this;
+ }
+
/**
* Save data to DB
*
* @param boolen $from_post
*/
- public function save($from_post = true)
+ public function save($from_post = true, $force = false, $session_messages = false)
{
if(!$this->getFieldIdName())
{
@@ -1469,11 +1600,24 @@ class e_admin_model extends e_model
if($this->getId())
{
- return $this->dbUpdate();
+ return $this->dbUpdate($force, $session_messages);
}
- return $this->dbInsert();
+ return $this->dbInsert($force, $session_messages);
}
+
+ public function delete($destroy = true, $session_messages = false)
+ {
+ $ret = $this->dbDelete();
+ if($ret)
+ {
+ if($destroy)
+ {
+ $this->setMessages(true, $session_messages)->destroy();
+ }
+ }
+ return $ret;
+ }
/**
* Insert data to DB
@@ -1484,7 +1628,7 @@ class e_admin_model extends e_model
public function dbInsert($force = false, $session_messages = false)
{
$this->_db_errno = 0;
- if(!$this->data_has_changed && !$force)
+ if($this->hasError() || (!$this->data_has_changed && !$force))
{
return 0;
}
@@ -1509,7 +1653,7 @@ class e_admin_model extends e_model
public function dbReplace($force = false, $session_messages = false)
{
$this->_db_errno = 0;
- if(!$this->data_has_changed && !$force)
+ if($this->hasError() || (!$this->data_has_changed && !$force))
{
return 0;
}
@@ -1537,6 +1681,10 @@ class e_admin_model extends e_model
public function dbUpdate($force = false, $session_messages = false)
{
$this->_db_errno = 0;
+ if($this->hasError() || (!$this->data_has_changed && !$force))
+ {
+ return 0;
+ }
$res = e107::getDb()->db_Update($this->getModelTable(), $this->toSqlQuery('update'));
if(!$res)
{
@@ -1560,6 +1708,11 @@ class e_admin_model extends e_model
public function dbDelete($session_messages = false)
{
$this->_db_errno = 0;
+ if($this->hasError())
+ {
+ return 0;
+ }
+
if(!$this->getId())
{
$this->addMessageError('Record not found', $session_messages); //TODO - Lan
@@ -1587,20 +1740,33 @@ class e_admin_model extends e_model
*/
public function toSqlQuery($force = '')
{
- $fields = array_keys($this->_data_fields);
$qry = array();
- $action = $this->getId() ? 'update' : 'create';
if($force)
{
$action = $force;
}
-
- foreach ($fields as $key => $value)
+ else
{
+ $action = $this->getId() ? 'update' : 'create';
+ }
+
+ $qry['_FIELD_TYPES'] = $this->_FIELD_TYPES; //DB field types are optional
+ $qry['data'][$this->getFieldIdName()] = $this->getId();
+ $qry['_FIELD_TYPES'][$this->getFieldIdName()] = 'int';
+
+ foreach ($this->_data_fields as $key => $type)
+ {
+ if($key == $this->getFieldIdName())
+ {
+ continue;
+ }
+ if(!isset($qry['_FIELD_TYPES'][$key]))
+ {
+ $qry['_FIELD_TYPES'][$key] = $type; //_FIELD_TYPES much more optional now...
+ }
$qry['data'][$key] = $this->getData($key);
}
- $qry['_FIELD_TYPES'] = $this->_FIELD_TYPES;
switch($action)
{
@@ -1690,6 +1856,17 @@ class e_admin_model extends e_model
return null;
}
+
+ public function destroy()
+ {
+ parent::destroy();
+ $this->_validator = null;
+ $this->_validation_rules = array();
+ $this->_db_errno = null;
+ $this->_posted_data = array();
+ $this->data_has_changed = array();
+ $this->_FIELD_TYPES = array();
+ }
}
/**
@@ -1697,11 +1874,6 @@ class e_admin_model extends e_model
*/
class e_tree_model extends e_model
{
- /**
- * @var array
- */
- protected $_params = array();
-
/**
* Current model DB table, used in all db calls
* This can/should be overwritten by extending the class
@@ -1717,9 +1889,21 @@ class e_tree_model extends e_model
*/
protected $_total = 0;
+ /**
+ * Constructor
+ *
+ */
+ function __construct($tree_data = array())
+ {
+ if($tree_data)
+ {
+ $this->setTree($tree_data);
+ }
+ }
+
public function getTotal()
{
- return $this->_total;
+ return $this->_total;
}
public function setTotal($num)
@@ -1748,18 +1932,6 @@ class e_tree_model extends e_model
return $this->_db_table;
}
- /**
- * Constructor
- *
- */
- function __construct($tree_data = array())
- {
- if($tree_data)
- {
- $this->setTree($tree_data);
- }
- }
-
/**
* Set array of models
* @return array
@@ -1788,8 +1960,14 @@ class e_tree_model extends e_model
*
* @return e_tree_model
*/
- public function load()
+ public function load($force = false)
{
+
+ if(!$this->isEmpty() && !$force)
+ {
+ return $this;
+ }
+
if($this->getParam('db_query') && $this->getParam('model_class') && class_exists($this->getParam('model_class')))
{
$sql = e107::getDb();
@@ -1797,11 +1975,18 @@ class e_tree_model extends e_model
if($sql->db_Select_gen($this->getParam('db_query')))
{
$this->_total = $sql->total_results; //requires SQL_CALC_FOUND_ROWS in query - see db handler
+
while($tmp = $sql->db_Fetch())
{
$tmp = new $class_name($tmp);
- $this->setNode($tmp->getId(), $tmp);
+ $this->setNode($tmp->get($this->getFieldIdName()), $tmp);
}
+ if(!$this->_total && $this->getModelTable())
+ {
+ //SQL_CALC_FOUND_ROWS not found in the query, do one more query
+ $this->_total = e107::getDb()->db_Count($this->getModelTable());
+ }
+
unset($tmp);
}
}
@@ -1866,57 +2051,7 @@ class e_tree_model extends e_model
*/
function isEmpty()
{
- return $this->has('__tree');
- }
-
- /**
- * Set parameter array
- * Core parameters:
- * - db_query: string db query to be passed to $sql->db_Select_gen();
- * - model_class: string class name for creating nodes inside default load() method
- *
- * @param array $params
- * @return e_tree_model
- */
- public function setParams(array $params)
- {
- $this->_params = $params;
- return $this;
- }
-
-
- /**
- * Get parameter array
- *
- * @return array parameters
- */
- public function getParams()
- {
- return $this->_params;
- }
-
- /**
- * Set parameter
- *
- * @param string $key
- * @param mixed $value
- * @return e_tree_model
- */
- public function setParam($key, $value)
- {
- $this->_params[$key] = $value;
- return $this;
- }
-
- /**
- * Get parameter
- *
- * @param string $key
- * @param mixed $default
- */
- public function getParam($key, $default = null)
- {
- return (isset($this->_params[$key]) ? $this->_params[$key] : $default);
+ return (!$this->has('__tree'));
}
}
@@ -1931,11 +2066,11 @@ class e_admin_tree_model extends e_tree_model
*/
public function delete($ids, $destroy = true, $session_messages = false)
{
- if(is_string($ids))
+ if(!$ids) return $this;
+ if(is_array($ids))
{
- $ids = explode(',', $ids);
+ $ids = implode(',', $ids);
}
-
$ids = e107::getParser()->toDB($ids);
$sql = e107::getDb();
$res = $sql->db_Delete($this->getModelTable(), $this->getFieldIdName().' IN ('.$ids.')');
@@ -1949,10 +2084,19 @@ class e_admin_tree_model extends e_tree_model
}
elseif($destroy)
{
+ if(is_string($ids))
+ {
+ $ids = explode(',', $ids);
+ }
+
foreach ($ids as $id)
{
- call_user_func(array($this->getNode($id), 'destroy')); // first call model destroy method if any
- $this->setNode($id, null);
+ if($this->getNode($id))
+ {
+ $this->getNode($id)->setMessages(true, $session_messages);
+ call_user_func(array($this->getNode(trim($id)), 'destroy')); // first call model destroy method if any
+ $this->setNode($id, null);
+ }
}
}
diff --git a/e107_handlers/validator_class.php b/e107_handlers/validator_class.php
index e8e292809..10e1e3d4d 100644
--- a/e107_handlers/validator_class.php
+++ b/e107_handlers/validator_class.php
@@ -9,8 +9,8 @@
* Handler - general purpose validation functions
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/validator_class.php,v $
- * $Revision: 1.12 $
- * $Date: 2009-10-20 16:05:02 $
+ * $Revision: 1.13 $
+ * $Date: 2009-10-30 17:59:31 $
* $Author: secretr $
*
*/
@@ -218,7 +218,7 @@ class e_validator
*/
public function setMessageStack($mstack)
{
- if($mstack) $mstack = 'validator';
+ if(!$mstack) $mstack = 'validator';
$this->_message_stack = $mstack;
return $this;
}
diff --git a/e107_plugins/release/admin_config.php b/e107_plugins/release/admin_config.php
index ca3b9b73f..b6ed6d2af 100644
--- a/e107_plugins/release/admin_config.php
+++ b/e107_plugins/release/admin_config.php
@@ -9,8 +9,8 @@
* e107 Release Plugin
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/release/admin_config.php,v $
- * $Revision: 1.10 $
- * $Date: 2009-10-28 17:05:35 $
+ * $Revision: 1.11 $
+ * $Date: 2009-10-30 17:59:32 $
* $Author: secretr $
*
*/
@@ -64,29 +64,32 @@ class plugin_release_admin_controller_main extends e_admin_controller_main
// optional
protected $perPage = 20;
+
+ // default - true
+ protected $batchDelete = true;
//TODO change the release_url type back to URL before release.
// required
protected $fields = array(
- 'checkboxes' => array('title'=> '', 'type' => '', 'width'=>'5%', 'thclass' =>'center', 'forced'=> TRUE, 'class'=>'center'),
- 'release_id' => array('title'=> ID, 'type' => '', 'width'=>'5%', 'thclass' => '', 'forced'=> TRUE, 'primary'=>TRUE),
- 'release_type' => array('title'=> 'Type', 'type' => 'method', 'width'=>'auto', 'thclass' => '', 'batch' => TRUE, 'filter'=>TRUE),
- 'release_folder' => array('title'=> 'Folder', 'type' => 'text', 'width' => 'auto', 'thclass' => ''),
- 'release_name' => array('title'=> 'Name', 'type' => 'text', 'width' => 'auto', 'thclass' => ''),
- 'release_version' => array('title'=> 'Version', 'type' => 'text', 'width' => 'auto', 'thclass' => ''),
- 'release_author' => array('title'=> LAN_AUTHOR, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left'),
- 'release_authorURL' => array('title'=> LAN_AUTHOR_URL, 'type' => 'url', 'width' => 'auto', 'thclass' => 'left'),
- 'release_date' => array('title'=> LAN_DATE, 'type' => 'text', 'width' => 'auto', 'thclass' => ''),
- 'release_compatibility' => array('title'=> 'compatib', 'type' => 'text', 'width' => '10%', 'thclass' => 'center' ),
- 'release_url' => array('title'=> 'Userclass', 'type' => 'userclass', 'width' => '10%', 'thclass' => 'center', 'batch' => TRUE, 'filter'=>TRUE),
- 'options' => array('title'=> LAN_OPTIONS, 'type' => '', 'width' => '10%', 'thclass' => 'center last', 'class' => 'center last', 'forced'=>TRUE)
+ 'checkboxes' => array('title'=> '', 'type' => null, 'data' => null, 'width'=>'5%', 'thclass' =>'center', 'forced'=> TRUE, 'class'=>'center', 'toggle' => 'e-multiselect'),
+ 'release_id' => array('title'=> ID, 'type' => 'int', 'data' => 'int', 'width'=>'5%', 'thclass' => '', 'forced'=> TRUE, 'primary'=>TRUE/*, 'noedit'=>TRUE*/), //Primary ID is note editable
+ 'release_type' => array('title'=> 'Type', 'type' => 'method', 'data' => 'str', 'width'=>'auto', 'thclass' => '', 'batch' => TRUE, 'filter'=>TRUE),
+ 'release_folder' => array('title'=> 'Folder', 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'thclass' => ''),
+ 'release_name' => array('title'=> 'Name', 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'thclass' => ''),
+ 'release_version' => array('title'=> 'Version', 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'thclass' => ''),
+ 'release_author' => array('title'=> LAN_AUTHOR, 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'thclass' => 'left'),
+ 'release_authorURL' => array('title'=> LAN_AUTHOR_URL, 'type' => 'url', 'data' => 'str', 'width' => 'auto', 'thclass' => 'left'),
+ 'release_date' => array('title'=> LAN_DATE, 'type' => 'datestamp', 'data' => 'int', 'width' => 'auto', 'thclass' => ''),
+ 'release_compatibility' => array('title'=> 'compatib', 'type' => 'text', 'data' => 'str', 'width' => '10%', 'thclass' => 'center' ),
+ 'release_url' => array('title'=> 'release_url', 'type' => 'url', 'data' => 'str', 'width' => '20%', 'thclass' => 'center', 'batch' => TRUE, 'filter'=>TRUE, 'parms' => 'truncate=30', 'validate' => true, 'help' => 'Enter release URL here', 'error' => 'please, ener valid URL'),
+ 'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'data' => null, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center last', 'forced'=>TRUE)
);
//required - default column user prefs
- protected $fieldpref = array('checkboxes', 'release_id', 'release_type', 'release_compatibility', 'options');
+ protected $fieldpref = array('checkboxes', 'release_id', 'release_type', 'release_url', 'release_compatibility', 'options');
- // required if no custom model is set in init()
- protected $dataFields = array(
+ // optional if fields 'data' attribute is set or if custom model is set in init()
+ /*protected $dataFields = array(
'release_id' => 'int',
'release_type' => 'str',
'release_folder' => 'str',
@@ -97,10 +100,12 @@ class plugin_release_admin_controller_main extends e_admin_controller_main
'release_date' => 'int',
'release_compatibility' => 'str',
'release_url' => 'str',
- );
+ );*/
- // optional
- protected $validationRules = array();
+ // optional, could be also set directly from $fields array with attributes 'validate' => true|'rule_name', 'rule' => 'condition_name', 'error' => 'Validation Error message'
+ /*protected $validationRules = array(
+ 'release_url' => array('required', '', 'Release URL', 'Help text', 'not valid error message')
+ );*/
// optional
protected $prefs = array( //TODO add option for core or plugin pref.
@@ -110,10 +115,10 @@ class plugin_release_admin_controller_main extends e_admin_controller_main
'pref_name' => array('title'=> 'name', 'type' => 'text')
);
- // required if no custom model is set in init()
+ // required if no custom tree model is set in init()
protected $listQry = "SELECT * FROM #release"; // without any Order or Limit.
- // required if no custom model is set in init()
+ // optional - required only in case of e.g. tables JOIN. This also could be done with custom model (set it in init())
protected $editQry = "SELECT * FROM #release WHERE release_id = {ID}";
// optional
@@ -122,6 +127,37 @@ class plugin_release_admin_controller_main extends e_admin_controller_main
}
}
+class plugin_release_admin_ui_main extends e_admin_ui
+{
+ function release_type($curVal,$mode) // not really necessary since we can use 'dropdown' - but just an example of a custom function.
+ {
+ if($mode == 'list')
+ {
+ return $curVal.' (custom!)';
+ }
+
+ if($mode == 'batch') // Custom Batch List for release_type
+ {
+ return array('theme'=>"Theme","plugin"=>'Plugin');
+ }
+
+ if($mode == 'filter') // Custom Filter List for release_type
+ {
+ return array('theme'=>"Theme","plugin"=>'Plugin');
+ }
+
+ $types = array("theme","plugin");
+ $text = "";
+ foreach($types as $val)
+ {
+ $selected = ($curVal == $val) ? "selected='selected'" : "";
+ $text .= "\n";
+ }
+ $text .= "";
+ return $text;
+ }
+}
+
$dispatcher = new plugin_release_admin_dispatcher();
$dispatcher->runObservers(true);
e107::setRegistry('admin/release_dispatcher', $dispatcher);
diff --git a/e107_plugins/release/release_sql.php b/e107_plugins/release/release_sql.php
index 80f06f5c2..929d699e5 100644
--- a/e107_plugins/release/release_sql.php
+++ b/e107_plugins/release/release_sql.php
@@ -6,7 +6,7 @@ CREATE TABLE release (
`release_version` varchar(5) NOT NULL,
`release_author` varchar(50) NOT NULL,
`release_authorURL` varchar(255) NOT NULL,
- `release_date` date NOT NULL,
+ `release_date` int(10) NOT NULL,
`release_compatibility` varchar(5) NOT NULL,
`release_url` varchar(255) NOT NULL,
PRIMARY KEY (`release_id`)