mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 20:30:39 +02:00
various handler fixes and improvements
This commit is contained in:
@@ -2995,25 +2995,27 @@ class e_admin_ui extends e_admin_controller_ui
|
|||||||
}
|
}
|
||||||
// delete one by one - more control, less performance
|
// delete one by one - more control, less performance
|
||||||
// TODO - pass afterDelete() callback to tree delete method?
|
// TODO - pass afterDelete() callback to tree delete method?
|
||||||
|
$set_messages = true;
|
||||||
foreach ($selected as $id)
|
foreach ($selected as $id)
|
||||||
{
|
|
||||||
if($this->beforeDelete($id))
|
|
||||||
{
|
{
|
||||||
$data = array();
|
$data = array();
|
||||||
$model = $this->getTreeModel()->getNode($id);
|
$model = $this->getTreeModel()->getNode($id);
|
||||||
if($model)
|
if($model)
|
||||||
{
|
{
|
||||||
$data = $model->getData();
|
$data = $model->getData();
|
||||||
}
|
if($this->beforeDelete($data, $id))
|
||||||
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()->delete($selected);
|
||||||
$this->getTreeModel()->setMessages();
|
if($set_messages) $this->getTreeModel()->setMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -3079,16 +3081,16 @@ class e_admin_ui extends e_admin_controller_ui
|
|||||||
if($model)
|
if($model)
|
||||||
{
|
{
|
||||||
$data = $model->getData();
|
$data = $model->getData();
|
||||||
}
|
|
||||||
if($this->beforeDelete($data, $id))
|
if($this->beforeDelete($data, $id))
|
||||||
{
|
{
|
||||||
if($this->getTreeModel()->delete($id))
|
$check = $this->getTreeModel()->delete($id);
|
||||||
|
if($this->afterDelete($data, $id, $check))
|
||||||
{
|
{
|
||||||
$this->afterDelete($data, $id);
|
|
||||||
}
|
|
||||||
$this->getTreeModel()->setMessages();
|
$this->getTreeModel()->setMessages();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User defined pre-delete logic
|
* User defined pre-delete logic
|
||||||
@@ -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
|
* 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.85 $
|
* $Revision: 1.86 $
|
||||||
* $Date: 2009-11-26 09:02:33 $
|
* $Date: 2009-11-26 17:14:07 $
|
||||||
* $Author: e107coders $
|
* $Author: secretr $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('e107_INIT')) { exit; }
|
if (!defined('e107_INIT')) { exit; }
|
||||||
@@ -899,14 +899,18 @@ class e107
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve Xml handler singleton object
|
* Retrieve Xml handler singleton or new instance object
|
||||||
* @return e_online
|
* @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
|
* Retrieve User Extended handler singleton object
|
||||||
|
@@ -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.91 $
|
* $Revision: 1.92 $
|
||||||
* $Date: 2009-11-24 15:36:12 $
|
* $Date: 2009-11-26 17:14:03 $
|
||||||
* $Author: e107coders $
|
* $Author: secretr $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -1309,7 +1309,7 @@ class e_form
|
|||||||
case 'dropdown':
|
case 'dropdown':
|
||||||
$eloptions = vartrue($parms['__options'], array());
|
$eloptions = vartrue($parms['__options'], array());
|
||||||
if(is_string($eloptions)) parse_str($eloptions);
|
if(is_string($eloptions)) parse_str($eloptions);
|
||||||
unset($parms['dropdown']);
|
unset($parms['__options']);
|
||||||
return $this->selectbox($key, $parms, $value, $eloptions);
|
return $this->selectbox($key, $parms, $value, $eloptions);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@@ -9,8 +9,8 @@
|
|||||||
* e107 Base Model
|
* e107 Base Model
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/model_class.php,v $
|
* $Source: /cvs_backup/e107_0.8/e107_handlers/model_class.php,v $
|
||||||
* $Revision: 1.44 $
|
* $Revision: 1.45 $
|
||||||
* $Date: 2009-11-24 16:32:02 $
|
* $Date: 2009-11-26 17:14:06 $
|
||||||
* $Author: secretr $
|
* $Author: secretr $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -962,12 +962,44 @@ class e_model
|
|||||||
return (isset($this->_params[$key]) ? $this->_params[$key] : $default);
|
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
|
* Try to convert string to a number
|
||||||
* Shoud fix locale related troubles
|
* Shoud fix locale related troubles
|
||||||
*
|
*
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @return
|
* @return integer|float
|
||||||
*/
|
*/
|
||||||
public function toNumber($value)
|
public function toNumber($value)
|
||||||
{
|
{
|
||||||
|
@@ -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.65 $
|
* $Revision: 1.66 $
|
||||||
* $Date: 2009-11-26 09:02:34 $
|
* $Date: 2009-11-26 17:14:07 $
|
||||||
* $Author: e107coders $
|
* $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.65 $
|
* @version $Revision: 1.66 $
|
||||||
* @author $Author: e107coders $
|
* @author $Author: secretr $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class e_db_mysql {
|
class e_db_mysql {
|
||||||
@@ -694,7 +694,7 @@ class e_db_mysql {
|
|||||||
* @desc Count the number of rows in a select<br />
|
* @desc Count the number of rows in a select<br />
|
||||||
* <br />
|
* <br />
|
||||||
* Example:<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
|
* @access public
|
||||||
*/
|
*/
|
||||||
@@ -719,6 +719,11 @@ class e_db_mysql {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->mySQLcurTable = $table;
|
$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;
|
$query='SELECT COUNT'.$fields.' FROM '.$this->mySQLPrefix.$table.' '.$arg;
|
||||||
if ($this->mySQLresult = $this->db_Query($query, NULL, 'db_Count', $debug, $log_type, $log_remark))
|
if ($this->mySQLresult = $this->db_Query($query, NULL, 'db_Count', $debug, $log_type, $log_remark))
|
||||||
{
|
{
|
||||||
|
@@ -9,9 +9,9 @@
|
|||||||
* Simple XML Parser
|
* Simple XML Parser
|
||||||
*
|
*
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/xml_class.php,v $
|
* $Source: /cvs_backup/e107_0.8/e107_handlers/xml_class.php,v $
|
||||||
* $Revision: 1.37 $
|
* $Revision: 1.38 $
|
||||||
* $Date: 2009-11-18 01:04:43 $
|
* $Date: 2009-11-26 17:14:06 $
|
||||||
* $Author: e107coders $
|
* $Author: secretr $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('e107_INIT')) { exit; }
|
if (!defined('e107_INIT')) { exit; }
|
||||||
@@ -147,10 +147,6 @@ class xmlClass
|
|||||||
*/
|
*/
|
||||||
protected $_optValueKey = '@value';
|
protected $_optValueKey = '@value';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor - set defaults
|
* Constructor - set defaults
|
||||||
*
|
*
|
||||||
@@ -497,7 +493,7 @@ class xmlClass
|
|||||||
return ($this->_optForceArray ? array($this->_optValueKey => $ret) : $ret);
|
return ($this->_optForceArray ? array($this->_optValueKey => $ret) : $ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OLD
|
||||||
function xml_convert_to_array($xml, $localFilter = FALSE, $stripComments = TRUE)
|
function xml_convert_to_array($xml, $localFilter = FALSE, $stripComments = TRUE)
|
||||||
{
|
{
|
||||||
if (is_object($xml))
|
if (is_object($xml))
|
||||||
@@ -604,12 +600,6 @@ class xmlClass
|
|||||||
return $vars;
|
return $vars;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load XML file and parse it (optional)
|
* Load XML file and parse it (optional)
|
||||||
*
|
*
|
||||||
@@ -720,7 +710,6 @@ class xmlClass
|
|||||||
*/
|
*/
|
||||||
public function e107Export($xmlprefs, $tables, $debug = FALSE)
|
public function e107Export($xmlprefs, $tables, $debug = FALSE)
|
||||||
{
|
{
|
||||||
|
|
||||||
require_once(e_ADMIN."ver.php");
|
require_once(e_ADMIN."ver.php");
|
||||||
|
|
||||||
$text = "<?xml version='1.0' encoding='utf-8' ?".">\n";
|
$text = "<?xml version='1.0' encoding='utf-8' ?".">\n";
|
||||||
@@ -799,8 +788,6 @@ class xmlClass
|
|||||||
exit;
|
exit;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -812,8 +799,6 @@ class xmlClass
|
|||||||
*/
|
*/
|
||||||
public function e107ImportPrefs($XMLData, $prefType='core')
|
public function e107ImportPrefs($XMLData, $prefType='core')
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if(!vartrue($XMLData['prefs'][$prefType]))
|
if(!vartrue($XMLData['prefs'][$prefType]))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -835,10 +820,6 @@ class xmlClass
|
|||||||
return $pref;
|
return $pref;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Import an e107 XML file into site preferences and DB tables
|
* Import an e107 XML file into site preferences and DB tables
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user