mirror of
https://github.com/e107inc/e107.git
synced 2025-03-11 07:59:44 +01:00
Introducing e_model_admin handler: automated tasks as validate, sql queries, handle posted data, more to come (work in progress); Various imporvements/fixes (core handlers)
This commit is contained in:
parent
8d33417a93
commit
ec93404015
@ -9,9 +9,9 @@
|
|||||||
* e107 Main
|
* e107 Main
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/e107_class.php,v $
|
* $Source: /cvs_backup/e107_0.8/e107_handlers/e107_class.php,v $
|
||||||
* $Revision: 1.55 $
|
* $Revision: 1.56 $
|
||||||
* $Date: 2009-10-20 03:49:12 $
|
* $Date: 2009-10-20 16:05:03 $
|
||||||
* $Author: e107coders $
|
* $Author: secretr $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('e107_INIT')) { exit; }
|
if (!defined('e107_INIT')) { exit; }
|
||||||
@ -114,13 +114,15 @@ class e107
|
|||||||
'e_news_tree' => '{e_HANDLER}news_class.php',
|
'e_news_tree' => '{e_HANDLER}news_class.php',
|
||||||
'news' => '{e_HANDLER}news_class.php',
|
'news' => '{e_HANDLER}news_class.php',
|
||||||
'e_form' => '{e_HANDLER}form_handler.php',
|
'e_form' => '{e_HANDLER}form_handler.php',
|
||||||
|
//'e_fieldset' => '{e_HANDLER}form_handler.php',
|
||||||
'e_upgrade' => '{e_HANDLER}e_upgrade_class.php',
|
'e_upgrade' => '{e_HANDLER}e_upgrade_class.php',
|
||||||
'e_jshelper' => '{e_HANDLER}js_helper.php',
|
'e_jshelper' => '{e_HANDLER}js_helper.php',
|
||||||
'e_menu' => '{e_HANDLER}menu_class.php',
|
'e_menu' => '{e_HANDLER}menu_class.php',
|
||||||
'e107plugin' => '{e_HANDLER}plugin_class.php',
|
'e107plugin' => '{e_HANDLER}plugin_class.php',
|
||||||
'xmlClass' => '{e_HANDLER}xml_class.php',
|
'xmlClass' => '{e_HANDLER}xml_class.php',
|
||||||
'e107_traffic' => '{e_HANDLER}traffic_class.php',
|
'e107_traffic' => '{e_HANDLER}traffic_class.php',
|
||||||
'comment' => '{e_HANDLER}comment_class.php'
|
'comment' => '{e_HANDLER}comment_class.php',
|
||||||
|
'e_validator' => '{e_HANDLER}validator_class.php'
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1692,7 +1694,7 @@ class e107
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->$name = $ret;
|
$this->{$name} = $ret;
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,9 @@
|
|||||||
* Form Handler
|
* Form Handler
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/form_handler.php,v $
|
* $Source: /cvs_backup/e107_0.8/e107_handlers/form_handler.php,v $
|
||||||
* $Revision: 1.48 $
|
* $Revision: 1.49 $
|
||||||
* $Date: 2009-10-20 07:39:40 $
|
* $Date: 2009-10-20 16:05:02 $
|
||||||
* $Author: e107coders $
|
* $Author: secretr $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -703,18 +703,17 @@ class e_form
|
|||||||
';
|
';
|
||||||
}
|
}
|
||||||
|
|
||||||
function thead($fieldarray,$columnPref='',$querypattern = '')
|
function thead($fieldarray, $columnPref='', $querypattern = '')
|
||||||
{
|
{
|
||||||
$text = "";
|
$text = "";
|
||||||
|
|
||||||
$tmp = explode(".",e_QUERY);
|
$tmp = explode(".",e_QUERY);
|
||||||
|
|
||||||
$etmp = explode(".",$querypattern);
|
$etmp = explode(".",$querypattern);
|
||||||
|
|
||||||
// Note: this function should probably be adapted to ALSO deal with $_GET. eg. ?mode=main&field=user_name&asc=desc&from=100
|
// Note: this function should probably be adapted to ALSO deal with $_GET. eg. ?mode=main&field=user_name&asc=desc&from=100
|
||||||
// or as a pattern: ?mode=main&field=[FIELD]&asc=[ASC]&from=[FROM]
|
// or as a pattern: ?mode=main&field=[FIELD]&asc=[ASC]&from=[FROM]
|
||||||
|
|
||||||
foreach($etmp as $key=>$val) // I'm sure there's a more efficient way to do this, but too tired to see it right now!.
|
foreach($etmp as $key => $val) // I'm sure there's a more efficient way to do this, but too tired to see it right now!.
|
||||||
{
|
{
|
||||||
|
|
||||||
if($val == "[FIELD]")
|
if($val == "[FIELD]")
|
||||||
@ -755,7 +754,7 @@ class e_form
|
|||||||
$text .= $val['title'];
|
$text .= $val['title'];
|
||||||
$text .= ($val['url']) ? "</a>" : "";
|
$text .= ($val['url']) ? "</a>" : "";
|
||||||
$text .= ($key == "options") ? $this->columnSelector($fieldarray,$columnPref) : "";
|
$text .= ($key == "options") ? $this->columnSelector($fieldarray,$columnPref) : "";
|
||||||
$text .= ($key == "checkboxes") ? $this->checkbox_toggle('e-column-toggle',$val['toggle']) : "";
|
$text .= ($key == "checkboxes") ? $this->checkbox_toggle('e-column-toggle', $val['toggle']) : "";
|
||||||
|
|
||||||
|
|
||||||
$text .= "</th>";
|
$text .= "</th>";
|
||||||
@ -826,14 +825,15 @@ class e_form
|
|||||||
* Generates a batch options select component
|
* 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).
|
* 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.
|
* The list options determine some processing that wil lbe applied to all checked rows when the form is submitted.
|
||||||
* @param options => array - associative array of option elements, keyed on the option value
|
*
|
||||||
* @param ucOptions => array - associative array of userclass option groups to display, keyed on the option value prefix
|
* @param array $options associative array of option elements, keyed on the option value
|
||||||
* @return the HTML for the form component
|
* @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) {
|
function batchoptions($options, $ucOptions=null) {
|
||||||
$text = "
|
$text = "
|
||||||
<div class='f-left'>
|
<div class='f-left'>
|
||||||
<img src='".e_IMAGE."generic/branchbottom.gif' alt='' class='TODO' />
|
<img src='".e_IMAGE_ABS."generic/branchbottom.gif' alt='' class='icon action' />
|
||||||
<select class='tbox e-execute-batch' name='execute_batch'>
|
<select class='tbox e-execute-batch' name='execute_batch'>
|
||||||
<option value=''>With selected...</option>\n";
|
<option value=''>With selected...</option>\n";
|
||||||
|
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
* Message Handler
|
* Message Handler
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/message_handler.php,v $
|
* $Source: /cvs_backup/e107_0.8/e107_handlers/message_handler.php,v $
|
||||||
* $Revision: 1.18 $
|
* $Revision: 1.19 $
|
||||||
* $Date: 2009-09-21 12:52:52 $
|
* $Date: 2009-10-20 16:05:03 $
|
||||||
* $Author: secretr $
|
* $Author: secretr $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -248,6 +248,29 @@ class eMessage
|
|||||||
|
|
||||||
return (true === $raw ? $message : self::formatMessage($mstack, $type, $message));
|
return (true === $raw ? $message : self::formatMessage($mstack, $type, $message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all messages for a stack
|
||||||
|
*
|
||||||
|
* @param string $mstack message stack name
|
||||||
|
* @param bool $raw force array return
|
||||||
|
* @param bool $reset reset message type stack
|
||||||
|
* @return array messages
|
||||||
|
*/
|
||||||
|
public function getAll($mstack = 'default', $raw = false, $reset = true)
|
||||||
|
{
|
||||||
|
$ret = array();
|
||||||
|
foreach ($this->_get_types() as $type)
|
||||||
|
{
|
||||||
|
$message = $this->get($type, $mstack, $raw, $reset);
|
||||||
|
if(!empty($message))
|
||||||
|
{
|
||||||
|
$ret[$type] = $message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Session message getter
|
* Session message getter
|
||||||
@ -265,6 +288,29 @@ class eMessage
|
|||||||
|
|
||||||
return (true === $raw ? $message : self::formatMessage($mstack, $type, $message));
|
return (true === $raw ? $message : self::formatMessage($mstack, $type, $message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all session messages for a stack
|
||||||
|
*
|
||||||
|
* @param string $mstack message stack name
|
||||||
|
* @param bool $raw force array return
|
||||||
|
* @param bool $reset reset message type stack
|
||||||
|
* @return array session messages
|
||||||
|
*/
|
||||||
|
public function getAllSession($mstack = 'default', $raw = false, $reset = true)
|
||||||
|
{
|
||||||
|
$ret = array();
|
||||||
|
foreach ($this->_get_types() as $type)
|
||||||
|
{
|
||||||
|
$message = $this->getSession($type, $mstack, $raw, $reset);
|
||||||
|
if(!empty($message))
|
||||||
|
{
|
||||||
|
$ret[$type] = $message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Output all accumulated messages
|
* Output all accumulated messages
|
||||||
@ -471,9 +517,9 @@ class eMessage
|
|||||||
if(!isset($this->_sysmsg[$_type][$to_stack]))
|
if(!isset($this->_sysmsg[$_type][$to_stack]))
|
||||||
{
|
{
|
||||||
$this->_sysmsg[$_type][$to_stack] = array();
|
$this->_sysmsg[$_type][$to_stack] = array();
|
||||||
array_merge($this->_sysmsg[$_type][$from_stack], $this->_sysmsg[$_type][$to_stack]);
|
|
||||||
unset($this->_sysmsg[$_type][$to_stack]);
|
|
||||||
}
|
}
|
||||||
|
array_merge($this->_sysmsg[$_type][$from_stack], $this->_sysmsg[$_type][$to_stack]);
|
||||||
|
unset($this->_sysmsg[$_type][$to_stack]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -504,9 +550,9 @@ class eMessage
|
|||||||
if(!isset($_SESSION[$this->_session_id][$_type][$to_stack]))
|
if(!isset($_SESSION[$this->_session_id][$_type][$to_stack]))
|
||||||
{
|
{
|
||||||
$this->_sysmsg[$_type][$to_stack] = array();
|
$this->_sysmsg[$_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]);
|
|
||||||
}
|
}
|
||||||
|
array_merge($_SESSION[$this->_session_id][$_type][$from_stack], $this->_sysmsg[$_type][$to_stack]);
|
||||||
|
unset($_SESSION[$this->_session_id][$_type][$to_stack]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -9,9 +9,9 @@
|
|||||||
* mySQL Handler
|
* mySQL Handler
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/mysql_class.php,v $
|
* $Source: /cvs_backup/e107_0.8/e107_handlers/mysql_class.php,v $
|
||||||
* $Revision: 1.56 $
|
* $Revision: 1.57 $
|
||||||
* $Date: 2009-10-03 14:54:46 $
|
* $Date: 2009-10-20 16:05:03 $
|
||||||
* $Author: e107steved $
|
* $Author: secretr $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if(defined('MYSQL_LIGHT'))
|
if(defined('MYSQL_LIGHT'))
|
||||||
@ -49,8 +49,8 @@ $db_ConnectionID = NULL; // Stores ID for the first DB connection used - which s
|
|||||||
*
|
*
|
||||||
* @package e107
|
* @package e107
|
||||||
* @category e107_handlers
|
* @category e107_handlers
|
||||||
* @version $Revision: 1.56 $
|
* @version $Revision: 1.57 $
|
||||||
* @author $Author: e107steved $
|
* @author $Author: secretr $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class e_db_mysql {
|
class e_db_mysql {
|
||||||
@ -63,8 +63,8 @@ class e_db_mysql {
|
|||||||
var $mySQLaccess;
|
var $mySQLaccess;
|
||||||
var $mySQLresult;
|
var $mySQLresult;
|
||||||
var $mySQLrows;
|
var $mySQLrows;
|
||||||
var $mySQLerror; // Error reporting mode - TRUE shows messages
|
var $mySQLerror = ''; // Error reporting mode - TRUE shows messages
|
||||||
var $mySQLlastErrNum; // Number of last error
|
var $mySQLlastErrNum = 0; // Number of last error
|
||||||
var $mySQLlastErrText; // Text of last error (empty string if no error)
|
var $mySQLlastErrText; // Text of last error (empty string if no error)
|
||||||
var $mySQLcurTable;
|
var $mySQLcurTable;
|
||||||
var $mySQLlanguage;
|
var $mySQLlanguage;
|
||||||
@ -574,7 +574,7 @@ class e_db_mysql {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'null':
|
case 'null':
|
||||||
return ($fieldValue ? "'{$fieldValue}'" : 'NULL');
|
return ($fieldValue && $fieldValue !== 'NULL' ? "'{$fieldValue}'" : 'NULL');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'escape':
|
case 'escape':
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
* Handler - general purpose validation functions
|
* Handler - general purpose validation functions
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/validator_class.php,v $
|
* $Source: /cvs_backup/e107_0.8/e107_handlers/validator_class.php,v $
|
||||||
* $Revision: 1.11 $
|
* $Revision: 1.12 $
|
||||||
* $Date: 2009-10-19 16:13:29 $
|
* $Date: 2009-10-20 16:05:02 $
|
||||||
* $Author: secretr $
|
* $Author: secretr $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -205,14 +205,24 @@ class e_validator
|
|||||||
*/
|
*/
|
||||||
public function __construct($message_stack = '', $rules = array(), $optrules = array())
|
public function __construct($message_stack = '', $rules = array(), $optrules = array())
|
||||||
{
|
{
|
||||||
if($message_stack)
|
$this->setMessageStack($message_stack)
|
||||||
{
|
->setRules($rules)
|
||||||
$this->_message_stack = $message_stack;
|
|
||||||
}
|
|
||||||
$this->setRules($rules)
|
|
||||||
->setOptionalRules($optrules);
|
->setOptionalRules($optrules);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set message stack
|
||||||
|
*
|
||||||
|
* @param string $mstack
|
||||||
|
* @return e_validator
|
||||||
|
*/
|
||||||
|
public function setMessageStack($mstack)
|
||||||
|
{
|
||||||
|
if($mstack) $mstack = 'validator';
|
||||||
|
$this->_message_stack = $mstack;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $rules
|
* @param array $rules
|
||||||
* @return e_validator
|
* @return e_validator
|
||||||
@ -265,6 +275,14 @@ class e_validator
|
|||||||
$this->reset();
|
$this->reset();
|
||||||
|
|
||||||
$rules = array_merge(array_keys($this->_required_rules), array_keys($this->_optional_rules));
|
$rules = array_merge(array_keys($this->_required_rules), array_keys($this->_optional_rules));
|
||||||
|
// no rules, no check
|
||||||
|
if(!$rules)
|
||||||
|
{
|
||||||
|
$this->_is_valid_data = true;
|
||||||
|
$this->_valid_data = $data;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($rules as $field_name)
|
foreach ($rules as $field_name)
|
||||||
{
|
{
|
||||||
$value = varset($data[$field_name], null);
|
$value = varset($data[$field_name], null);
|
||||||
@ -597,7 +615,7 @@ class e_validator
|
|||||||
{
|
{
|
||||||
if($custom)
|
if($custom)
|
||||||
{
|
{
|
||||||
e107::getMessage()->addStack(sprintf($err_message, $field_title), $this->_message_stack, (true === $custom ? E_MESSAGE_ERROR : $custom));
|
e107::getMessage()->addStack(sprintf($err_message, $err_code, $field_title), $this->_message_stack, (true === $custom ? E_MESSAGE_ERROR : $custom));
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -643,11 +661,12 @@ class e_validator
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param boolean $session clear session messages as well, default true
|
||||||
* @return e_validator
|
* @return e_validator
|
||||||
*/
|
*/
|
||||||
function clearValidateMessages()
|
function clearValidateMessages($session = true)
|
||||||
{
|
{
|
||||||
$this->_validate_results = array();
|
e107::getMessage()->reset(false, $this->_message_stack, $session);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user