mirror of
https://github.com/e107inc/e107.git
synced 2025-01-17 12:48:24 +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
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/e107_class.php,v $
|
||||
* $Revision: 1.55 $
|
||||
* $Date: 2009-10-20 03:49:12 $
|
||||
* $Author: e107coders $
|
||||
* $Revision: 1.56 $
|
||||
* $Date: 2009-10-20 16:05:03 $
|
||||
* $Author: secretr $
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
@ -114,13 +114,15 @@ class e107
|
||||
'e_news_tree' => '{e_HANDLER}news_class.php',
|
||||
'news' => '{e_HANDLER}news_class.php',
|
||||
'e_form' => '{e_HANDLER}form_handler.php',
|
||||
//'e_fieldset' => '{e_HANDLER}form_handler.php',
|
||||
'e_upgrade' => '{e_HANDLER}e_upgrade_class.php',
|
||||
'e_jshelper' => '{e_HANDLER}js_helper.php',
|
||||
'e_menu' => '{e_HANDLER}menu_class.php',
|
||||
'e107plugin' => '{e_HANDLER}plugin_class.php',
|
||||
'xmlClass' => '{e_HANDLER}xml_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;
|
||||
}
|
||||
|
||||
$this->$name = $ret;
|
||||
$this->{$name} = $ret;
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
@ -9,9 +9,9 @@
|
||||
* Form Handler
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/form_handler.php,v $
|
||||
* $Revision: 1.48 $
|
||||
* $Date: 2009-10-20 07:39:40 $
|
||||
* $Author: e107coders $
|
||||
* $Revision: 1.49 $
|
||||
* $Date: 2009-10-20 16:05:02 $
|
||||
* $Author: secretr $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -703,18 +703,17 @@ class e_form
|
||||
';
|
||||
}
|
||||
|
||||
function thead($fieldarray,$columnPref='',$querypattern = '')
|
||||
function thead($fieldarray, $columnPref='', $querypattern = '')
|
||||
{
|
||||
$text = "";
|
||||
|
||||
$tmp = explode(".",e_QUERY);
|
||||
|
||||
$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
|
||||
// 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]")
|
||||
@ -755,7 +754,7 @@ class e_form
|
||||
$text .= $val['title'];
|
||||
$text .= ($val['url']) ? "</a>" : "";
|
||||
$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>";
|
||||
@ -826,14 +825,15 @@ class e_form
|
||||
* 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 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
|
||||
* @return the HTML for the form component
|
||||
*
|
||||
* @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 = "
|
||||
<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'>
|
||||
<option value=''>With selected...</option>\n";
|
||||
|
||||
|
@ -9,8 +9,8 @@
|
||||
* Message Handler
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/message_handler.php,v $
|
||||
* $Revision: 1.18 $
|
||||
* $Date: 2009-09-21 12:52:52 $
|
||||
* $Revision: 1.19 $
|
||||
* $Date: 2009-10-20 16:05:03 $
|
||||
* $Author: secretr $
|
||||
*
|
||||
*/
|
||||
@ -249,6 +249,29 @@ class eMessage
|
||||
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
|
||||
*
|
||||
@ -266,6 +289,29 @@ class eMessage
|
||||
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
|
||||
*
|
||||
@ -471,11 +517,11 @@ class eMessage
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($session) $this->moveSessionStack($from_stack, $to_stack, $type);
|
||||
|
||||
@ -504,11 +550,11 @@ class eMessage
|
||||
if(!isset($_SESSION[$this->_session_id][$_type][$to_stack]))
|
||||
{
|
||||
$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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -9,9 +9,9 @@
|
||||
* mySQL Handler
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/mysql_class.php,v $
|
||||
* $Revision: 1.56 $
|
||||
* $Date: 2009-10-03 14:54:46 $
|
||||
* $Author: e107steved $
|
||||
* $Revision: 1.57 $
|
||||
* $Date: 2009-10-20 16:05:03 $
|
||||
* $Author: secretr $
|
||||
*/
|
||||
|
||||
if(defined('MYSQL_LIGHT'))
|
||||
@ -49,8 +49,8 @@ $db_ConnectionID = NULL; // Stores ID for the first DB connection used - which s
|
||||
*
|
||||
* @package e107
|
||||
* @category e107_handlers
|
||||
* @version $Revision: 1.56 $
|
||||
* @author $Author: e107steved $
|
||||
* @version $Revision: 1.57 $
|
||||
* @author $Author: secretr $
|
||||
*
|
||||
*/
|
||||
class e_db_mysql {
|
||||
@ -63,8 +63,8 @@ class e_db_mysql {
|
||||
var $mySQLaccess;
|
||||
var $mySQLresult;
|
||||
var $mySQLrows;
|
||||
var $mySQLerror; // Error reporting mode - TRUE shows messages
|
||||
var $mySQLlastErrNum; // Number of last error
|
||||
var $mySQLerror = ''; // Error reporting mode - TRUE shows messages
|
||||
var $mySQLlastErrNum = 0; // Number of last error
|
||||
var $mySQLlastErrText; // Text of last error (empty string if no error)
|
||||
var $mySQLcurTable;
|
||||
var $mySQLlanguage;
|
||||
@ -574,7 +574,7 @@ class e_db_mysql {
|
||||
break;
|
||||
|
||||
case 'null':
|
||||
return ($fieldValue ? "'{$fieldValue}'" : 'NULL');
|
||||
return ($fieldValue && $fieldValue !== 'NULL' ? "'{$fieldValue}'" : 'NULL');
|
||||
break;
|
||||
|
||||
case 'escape':
|
||||
|
@ -9,8 +9,8 @@
|
||||
* Handler - general purpose validation functions
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/validator_class.php,v $
|
||||
* $Revision: 1.11 $
|
||||
* $Date: 2009-10-19 16:13:29 $
|
||||
* $Revision: 1.12 $
|
||||
* $Date: 2009-10-20 16:05:02 $
|
||||
* $Author: secretr $
|
||||
*
|
||||
*/
|
||||
@ -205,14 +205,24 @@ class e_validator
|
||||
*/
|
||||
public function __construct($message_stack = '', $rules = array(), $optrules = array())
|
||||
{
|
||||
if($message_stack)
|
||||
{
|
||||
$this->_message_stack = $message_stack;
|
||||
}
|
||||
$this->setRules($rules)
|
||||
$this->setMessageStack($message_stack)
|
||||
->setRules($rules)
|
||||
->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
|
||||
* @return e_validator
|
||||
@ -265,6 +275,14 @@ class e_validator
|
||||
$this->reset();
|
||||
|
||||
$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)
|
||||
{
|
||||
$value = varset($data[$field_name], null);
|
||||
@ -597,7 +615,7 @@ class e_validator
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@ -643,11 +661,12 @@ class e_validator
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $session clear session messages as well, default true
|
||||
* @return e_validator
|
||||
*/
|
||||
function clearValidateMessages()
|
||||
function clearValidateMessages($session = true)
|
||||
{
|
||||
$this->_validate_results = array();
|
||||
e107::getMessage()->reset(false, $this->_message_stack, $session);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user