mirror of
https://github.com/e107inc/e107.git
synced 2025-01-17 12:48:24 +01:00
various handler fixes and improvements
This commit is contained in:
parent
f78445421c
commit
d61aced8d4
@ -2995,25 +2995,27 @@ class e_admin_ui extends e_admin_controller_ui
|
||||
}
|
||||
// delete one by one - more control, less performance
|
||||
// TODO - pass afterDelete() callback to tree delete method?
|
||||
$set_messages = true;
|
||||
foreach ($selected as $id)
|
||||
{
|
||||
if($this->beforeDelete($id))
|
||||
$data = array();
|
||||
$model = $this->getTreeModel()->getNode($id);
|
||||
if($model)
|
||||
{
|
||||
$data = array();
|
||||
$model = $this->getTreeModel()->getNode($id);
|
||||
if($model)
|
||||
$data = $model->getData();
|
||||
if($this->beforeDelete($data, $id))
|
||||
{
|
||||
$data = $model->getData();
|
||||
}
|
||||
if($this->getTreeModel()->delete($id))
|
||||
{
|
||||
$this->afterDelete($data);
|
||||
$check = $this->getTreeModel()->delete($id);
|
||||
if(!$this->afterDelete($data, $id, $check))
|
||||
{
|
||||
$set_messages = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//$this->getTreeModel()->delete($selected);
|
||||
$this->getTreeModel()->setMessages();
|
||||
if($set_messages) $this->getTreeModel()->setMessages();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3079,14 +3081,14 @@ class e_admin_ui extends e_admin_controller_ui
|
||||
if($model)
|
||||
{
|
||||
$data = $model->getData();
|
||||
}
|
||||
if($this->beforeDelete($data, $id))
|
||||
{
|
||||
if($this->getTreeModel()->delete($id))
|
||||
if($this->beforeDelete($data, $id))
|
||||
{
|
||||
$this->afterDelete($data, $id);
|
||||
$check = $this->getTreeModel()->delete($id);
|
||||
if($this->afterDelete($data, $id, $check))
|
||||
{
|
||||
$this->getTreeModel()->setMessages();
|
||||
}
|
||||
}
|
||||
$this->getTreeModel()->setMessages();
|
||||
}
|
||||
}
|
||||
|
||||
@ -3099,10 +3101,11 @@ class e_admin_ui extends e_admin_controller_ui
|
||||
}
|
||||
|
||||
/**
|
||||
* User defined after-create logic
|
||||
* User defined after-delete logic
|
||||
*/
|
||||
public function afterDelete($deleted_data, $id)
|
||||
public function afterDelete($deleted_data, $id, $deleted_check)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -9,9 +9,9 @@
|
||||
* e107 Main
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/e107_class.php,v $
|
||||
* $Revision: 1.85 $
|
||||
* $Date: 2009-11-26 09:02:33 $
|
||||
* $Author: e107coders $
|
||||
* $Revision: 1.86 $
|
||||
* $Date: 2009-11-26 17:14:07 $
|
||||
* $Author: secretr $
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
@ -899,15 +899,19 @@ class e107
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve Xml handler singleton object
|
||||
* @return e_online
|
||||
* Retrieve Xml handler singleton or new instance object
|
||||
* @param mixed $singleton false - new instance, true - singleton from default registry location, 'string' - registry path
|
||||
* @return xmlClass
|
||||
*/
|
||||
public static function getXml()
|
||||
public static function getXml($singleton = true)
|
||||
{
|
||||
return self::getSingleton('xmlClass', true);
|
||||
if($singleton)
|
||||
{
|
||||
return self::getSingleton('xmlClass', true, (true === $singleton ? '' : $singleton));
|
||||
}
|
||||
return self::getObject('xmlClass', null, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve User Extended handler singleton object
|
||||
* @return e107_user_extended
|
||||
|
@ -9,9 +9,9 @@
|
||||
* Form Handler
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/form_handler.php,v $
|
||||
* $Revision: 1.91 $
|
||||
* $Date: 2009-11-24 15:36:12 $
|
||||
* $Author: e107coders $
|
||||
* $Revision: 1.92 $
|
||||
* $Date: 2009-11-26 17:14:03 $
|
||||
* $Author: secretr $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -1309,7 +1309,7 @@ class e_form
|
||||
case 'dropdown':
|
||||
$eloptions = vartrue($parms['__options'], array());
|
||||
if(is_string($eloptions)) parse_str($eloptions);
|
||||
unset($parms['dropdown']);
|
||||
unset($parms['__options']);
|
||||
return $this->selectbox($key, $parms, $value, $eloptions);
|
||||
break;
|
||||
|
||||
|
@ -9,8 +9,8 @@
|
||||
* e107 Base Model
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/model_class.php,v $
|
||||
* $Revision: 1.44 $
|
||||
* $Date: 2009-11-24 16:32:02 $
|
||||
* $Revision: 1.45 $
|
||||
* $Date: 2009-11-26 17:14:06 $
|
||||
* $Author: secretr $
|
||||
*/
|
||||
|
||||
@ -962,12 +962,44 @@ class e_model
|
||||
return (isset($this->_params[$key]) ? $this->_params[$key] : $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render model data, all 'sc_*' methods will be recongnized
|
||||
* as shortcodes.
|
||||
*
|
||||
* @param string $template
|
||||
* @param boolean $parsesc parse external shortcodes, default is true
|
||||
* @return string parsed template
|
||||
*/
|
||||
public function toHTML($template, $parsesc = true)
|
||||
{
|
||||
return e107::getParser()->parseTemplate($template, $parsesc, $this);
|
||||
}
|
||||
|
||||
public function toXML()
|
||||
{
|
||||
$ret = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
|
||||
$ret .= "<e107Export type=\"model\" version=\"1.0\" timestamp=\"".time()."\" >\n";
|
||||
|
||||
$ret .= "\t<data>\n";
|
||||
// TODO - handle multi dimensional arrays (already possible - field1/field2?), method toXMLValue($value, $type)
|
||||
foreach ($this->getDataFields() as $field => $type)
|
||||
{
|
||||
$ret .= "\t\t<field name=\"{$field}\" type=\"{$type}\">";
|
||||
$ret .= $type == 'str' || $type == 'string' ? "<![CDATA[".$this->getData($field)."]]>" : $this->getData($field);
|
||||
$ret .= "</field>\n";
|
||||
}
|
||||
$ret .= "\t</data>\n";
|
||||
|
||||
$ret .= "</e107Export>";
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to convert string to a number
|
||||
* Shoud fix locale related troubles
|
||||
*
|
||||
* @param string $value
|
||||
* @return
|
||||
* @return integer|float
|
||||
*/
|
||||
public function toNumber($value)
|
||||
{
|
||||
|
@ -9,9 +9,9 @@
|
||||
* mySQL Handler
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/mysql_class.php,v $
|
||||
* $Revision: 1.65 $
|
||||
* $Date: 2009-11-26 09:02:34 $
|
||||
* $Author: e107coders $
|
||||
* $Revision: 1.66 $
|
||||
* $Date: 2009-11-26 17:14:07 $
|
||||
* $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.65 $
|
||||
* @author $Author: e107coders $
|
||||
* @version $Revision: 1.66 $
|
||||
* @author $Author: secretr $
|
||||
*
|
||||
*/
|
||||
class e_db_mysql {
|
||||
@ -694,7 +694,7 @@ class e_db_mysql {
|
||||
* @desc Count the number of rows in a select<br />
|
||||
* <br />
|
||||
* Example:<br />
|
||||
* <code>$topics = $sql->db_Count("forum_t", "(*)", " WHERE thread_forum_id='".$forum_id."' AND thread_parent='0' ");</code>
|
||||
* <code>$topics = $sql->db_Count("forum_t", "(*)", "thread_forum_id='".$forum_id."' AND thread_parent='0'");</code>
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
@ -719,6 +719,11 @@ class e_db_mysql {
|
||||
}
|
||||
|
||||
$this->mySQLcurTable = $table;
|
||||
// normalize query arguments - only COUNT expected 'WHERE', not anymore
|
||||
if($arg && stripos(trim($arg), 'WHERE') !== 0)
|
||||
{
|
||||
$arg = 'WHERE '.$arg;
|
||||
}
|
||||
$query='SELECT COUNT'.$fields.' FROM '.$this->mySQLPrefix.$table.' '.$arg;
|
||||
if ($this->mySQLresult = $this->db_Query($query, NULL, 'db_Count', $debug, $log_type, $log_remark))
|
||||
{
|
||||
|
@ -9,9 +9,9 @@
|
||||
* Simple XML Parser
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/xml_class.php,v $
|
||||
* $Revision: 1.37 $
|
||||
* $Date: 2009-11-18 01:04:43 $
|
||||
* $Author: e107coders $
|
||||
* $Revision: 1.38 $
|
||||
* $Date: 2009-11-26 17:14:06 $
|
||||
* $Author: secretr $
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
@ -147,10 +147,6 @@ class xmlClass
|
||||
*/
|
||||
protected $_optValueKey = '@value';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor - set defaults
|
||||
*
|
||||
@ -497,7 +493,7 @@ class xmlClass
|
||||
return ($this->_optForceArray ? array($this->_optValueKey => $ret) : $ret);
|
||||
}
|
||||
|
||||
|
||||
// OLD
|
||||
function xml_convert_to_array($xml, $localFilter = FALSE, $stripComments = TRUE)
|
||||
{
|
||||
if (is_object($xml))
|
||||
@ -603,12 +599,6 @@ class xmlClass
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Load XML file and parse it (optional)
|
||||
@ -720,7 +710,6 @@ class xmlClass
|
||||
*/
|
||||
public function e107Export($xmlprefs, $tables, $debug = FALSE)
|
||||
{
|
||||
|
||||
require_once(e_ADMIN."ver.php");
|
||||
|
||||
$text = "<?xml version='1.0' encoding='utf-8' ?".">\n";
|
||||
@ -799,8 +788,6 @@ class xmlClass
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -812,8 +799,6 @@ class xmlClass
|
||||
*/
|
||||
public function e107ImportPrefs($XMLData, $prefType='core')
|
||||
{
|
||||
|
||||
|
||||
if(!vartrue($XMLData['prefs'][$prefType]))
|
||||
{
|
||||
return;
|
||||
@ -834,11 +819,7 @@ class xmlClass
|
||||
|
||||
return $pref;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Import an e107 XML file into site preferences and DB tables
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user