1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-01 20:30:39 +02:00

admin UI: templates & layouts field types added, bugfixes and improvements; Featurebox plugin administration ready, front-end in progress

This commit is contained in:
secretr
2009-11-28 15:34:46 +00:00
parent 76ffe278f0
commit 9626059142
9 changed files with 335 additions and 148 deletions

View File

@@ -9,9 +9,9 @@
* Custom Menus/Pages Administration * Custom Menus/Pages Administration
* *
* $Source: /cvs_backup/e107_0.8/e107_admin/cpage.php,v $ * $Source: /cvs_backup/e107_0.8/e107_admin/cpage.php,v $
* $Revision: 1.30 $ * $Revision: 1.31 $
* $Date: 2009-11-26 09:02:29 $ * $Date: 2009-11-28 15:34:45 $
* $Author: e107coders $ * $Author: secretr $
* *
*/ */
@@ -307,7 +307,7 @@ class page
} }
else else
{ {
$templates = e107::getTemplateList('page'); $templates = e107::getLayouts('page');
$text .= " $text .= "
<tr> <tr>

View File

@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_admin/links.php,v $ | $Source: /cvs_backup/e107_0.8/e107_admin/links.php,v $
| $Revision: 1.36 $ | $Revision: 1.37 $
| $Date: 2009-11-26 09:02:32 $ | $Date: 2009-11-28 15:34:45 $
| $Author: e107coders $ | $Author: secretr $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
require_once("../class2.php"); require_once("../class2.php");
@@ -140,7 +140,7 @@ class links_admin_ui extends e_admin_ui
5 => LINKLAN_1 // 5 = miniwindow 800x600 5 => LINKLAN_1 // 5 = miniwindow 800x600
); );
$sitelinksTemplates = e107::getCoreTemplateList('sitelinks'); $sitelinksTemplates = e107::getLayouts(null, 'sitelinks');
//TODO review. //TODO review.
$this->setDropDown('link_parent',$this->linkParent); $this->setDropDown('link_parent',$this->linkParent);

View File

@@ -2380,7 +2380,7 @@ class e_admin_controller_ui extends e_admin_controller
$selected = array_map('intval', $selected); $selected = array_map('intval', $selected);
$trigger = $tp->toDB(explode('__', $batch_trigger)); $trigger = $tp->toDB(explode('__', $batch_trigger));
$this->triggersEnabled(false); //disable further triggering $this->setTriggersEnabled(false); //disable further triggering
switch($trigger[0]) switch($trigger[0])
{ {
@@ -2863,7 +2863,7 @@ class e_admin_controller_ui extends e_admin_controller
* @param string $noredirectAction passed to doAfterSubmit() * @param string $noredirectAction passed to doAfterSubmit()
* @return * @return
*/ */
protected function _manageSubmit($callbackBefore = '', $callbackAfter = '', $noredirectAction = '') protected function _manageSubmit($callbackBefore = '', $callbackAfter = '', $callbackError = '', $noredirectAction = '')
{ {
$model = $this->getModel(); $model = $this->getModel();
$old_data = $model->getData(); $old_data = $model->getData();
@@ -2901,9 +2901,6 @@ class e_admin_controller_ui extends e_admin_controller
// Scenario II - inner model sanitize // Scenario II - inner model sanitize
//$this->getModel()->setPosted($this->convertToData($_POST, null, false, true); //$this->getModel()->setPosted($this->convertToData($_POST, null, false, true);
// Copy model messages to the default message stack
$model->setMessages();
// Take action based on use choice after success // Take action based on use choice after success
if(!$this->getModel()->hasError()) if(!$this->getModel()->hasError())
{ {
@@ -2915,6 +2912,19 @@ class e_admin_controller_ui extends e_admin_controller
$this->doAfterSubmit($model->getId(), $noredirectAction); $this->doAfterSubmit($model->getId(), $noredirectAction);
return true; return true;
} }
elseif($callbackError && method_exists($this, $callbackError))
{
// suppress messages if callback returns TRUE
if(true !== $this->$callbackError($_posted, $old_data, $model->getId()))
{
// Copy model messages to the default message stack
$model->setMessages();
}
return false;
}
// Copy model messages to the default message stack
$model->setMessages();
return false; return false;
} }
} }
@@ -2965,7 +2975,7 @@ class e_admin_ui extends e_admin_controller_ui
*/ */
public function ListEcolumnsTrigger() public function ListEcolumnsTrigger()
{ {
$this->triggersEnabled(false); //disable further triggering $this->setTriggersEnabled(false); //disable further triggering
parent::manageColumns(); parent::manageColumns();
} }
@@ -3074,7 +3084,7 @@ class e_admin_ui extends e_admin_controller_ui
*/ */
public function ListDeleteTrigger($posted) public function ListDeleteTrigger($posted)
{ {
$this->triggersEnabled(false); $this->setTriggersEnabled(false);
$id = intval(array_shift($posted)); $id = intval(array_shift($posted));
$data = array(); $data = array();
$model = $this->getTreeModel()->getNode($id); $model = $this->getTreeModel()->getNode($id);
@@ -3186,7 +3196,7 @@ class e_admin_ui extends e_admin_controller_ui
*/ */
public function EditSubmitTrigger() public function EditSubmitTrigger()
{ {
$this->_manageSubmit('beforeUpdate', 'afterUpdate', 'edit'); $this->_manageSubmit('beforeUpdate', 'afterUpdate', 'onUpdateError', 'edit');
} }
/** /**
@@ -3214,7 +3224,7 @@ class e_admin_ui extends e_admin_controller_ui
*/ */
public function CreateObserver() public function CreateObserver()
{ {
$this->triggersEnabled(true); $this->setTriggersEnabled(true);
$this->addTitle(LAN_CREATE, true); $this->addTitle(LAN_CREATE, true);
} }
@@ -3231,11 +3241,11 @@ class e_admin_ui extends e_admin_controller_ui
*/ */
public function CreateSubmitTrigger() public function CreateSubmitTrigger()
{ {
$this->_manageSubmit('beforeCreate', 'afterCreate'); $this->_manageSubmit('beforeCreate', 'afterCreate', 'onCreateError');
} }
/** /**
* User defined pre-create logic * User defined pre-create logic, return false to prevent DB query execution
*/ */
public function beforeCreate($new_data, $old_data) public function beforeCreate($new_data, $old_data)
{ {
@@ -3249,7 +3259,14 @@ class e_admin_ui extends e_admin_controller_ui
} }
/** /**
* User defined pre-update logic * User defined error handling, return true to suppress model messages
*/
public function onCreateError($new_data, $old_data)
{
}
/**
* User defined pre-update logic, return false to prevent DB query execution
*/ */
public function beforeUpdate($new_data, $old_data, $id) public function beforeUpdate($new_data, $old_data, $id)
{ {
@@ -3262,6 +3279,13 @@ class e_admin_ui extends e_admin_controller_ui
{ {
} }
/**
* User defined error handling, return true to suppress model messages
*/
public function onUpdateError($new_data, $old_data, $id)
{
}
/** /**
* Create - send JS to page Header * Create - send JS to page Header
* @return * @return
@@ -3442,6 +3466,7 @@ class e_admin_ui extends e_admin_controller_ui
->setValidationRules($this->validationRules) ->setValidationRules($this->validationRules)
->setFieldTypes($this->fieldTypes) ->setFieldTypes($this->fieldTypes)
->setDataFields($this->dataFields) ->setDataFields($this->dataFields)
->setMessageStackName('admin_ui_model_'.$this->table)
->setParam('db_query', $this->editQry); ->setParam('db_query', $this->editQry);
return $this; return $this;
@@ -3457,7 +3482,8 @@ class e_admin_ui extends e_admin_controller_ui
$this->_tree_model = new e_admin_tree_model(); $this->_tree_model = new e_admin_tree_model();
$this->_tree_model->setModelTable($this->table) $this->_tree_model->setModelTable($this->table)
->setFieldIdName($this->pid) ->setFieldIdName($this->pid)
->setParams(array('model_class' => 'e_admin_model', 'db_query' => $this->listQry)); ->setMessageStackName('admin_ui_tree_'.$this->table)
->setParams(array('model_class' => 'e_admin_model', 'model_message_stack' => 'admin_ui_model_'.$this->table ,'db_query' => $this->listQry));
return $this; return $this;
} }
@@ -3774,6 +3800,17 @@ class e_admin_form_ui extends e_form
$option['boolreverse__'.$key] = LAN_BOOL_REVERSE; $option['boolreverse__'.$key] = LAN_BOOL_REVERSE;
} }
break; break;
case 'templates':
case 'layouts':
$parms['raw'] = true;
$val['writeParms'] = $parms;
$tmp = $this->renderElement($key, '', $val);
foreach ($tmp as $k => $name)
{
$option[$key.'__'.$k] = $name;
}
break;
case 'dropdown': // use the array $parm; case 'dropdown': // use the array $parm;
unset($parms['__options']); //remove element options if any unset($parms['__options']); //remove element options if any

View File

@@ -9,8 +9,8 @@
* 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.86 $ * $Revision: 1.87 $
* $Date: 2009-11-26 17:14:07 $ * $Date: 2009-11-28 15:34:46 $
* $Author: secretr $ * $Author: secretr $
*/ */
@@ -1060,10 +1060,52 @@ class e107
return FALSE; return FALSE;
} }
/**
* Get theme name or path.
*
* @param mixed $for true (default) - auto-detect (current), admin - admin theme, front - site theme
* @param string $path default empty string (return name only), 'abs' - absolute url path, 'rel' - relative server path
* @return string
*/
public static function getThemeInfo($for = true, $path = '')
{
global $user_pref; // FIXME - user model, kill user_pref global
if(true === $for)
{
$for = e_ADMIN_AREA ? 'admin' : 'front';
}
switch($for )
{
case 'admin':
$for = e107::getPref('admintheme');
break;
case 'front':
$for = isset($user_pref['sitetheme']) ? $user_pref['sitetheme'] : e107::getPref('sitetheme');
break;
}
if(!$path) return $for;
switch($path)
{
case 'abs':
$path = e_THEME_ABS.$for.'/';
break;
case 'rel':
default:
$path = e_THEME.$for.'/';
break;
}
return $path;
}
/** /**
* Retrieve core template path * Retrieve core template path
* Example: <code>echo e107::coreTemplatePath('admin_icons');</code> * Example: <code>echo e107::coreTemplatePath('admin_icons');</code>
* *
* @see getThemeInfo()
* @param string $id part of the path/file name without _template.php part * @param string $id part of the path/file name without _template.php part
* @param boolean $override default true * @param boolean $override default true
* @return string relative path * @return string relative path
@@ -1071,7 +1113,7 @@ class e107
public static function coreTemplatePath($id, $override = true) public static function coreTemplatePath($id, $override = true)
{ {
$id = str_replace('..', '', $id); //simple security, '/' is allowed $id = str_replace('..', '', $id); //simple security, '/' is allowed
$override_path = $override && defined('THEME') ? THEME.'templates/'.$id.'_template.php' : null; $override_path = $override ? self::getThemeInfo($override, 'rel').'templates/'.$id.'_template.php' : null;
$default_path = e_THEME.'templates/'.$id.'_template.php'; $default_path = e_THEME.'templates/'.$id.'_template.php';
return ($override_path && is_readable($override_path) ? $override_path : $default_path); return ($override_path && is_readable($override_path) ? $override_path : $default_path);
@@ -1079,6 +1121,8 @@ class e107
/** /**
* Retrieve plugin template path * Retrieve plugin template path
* Override path could be forced to front- or back-end via
* the $override parameter e.g. <code> e107::templatePath(plug_name, 'my', 'front')</code>
* Example: * Example:
* <code> * <code>
* echo e107::templatePath(plug_name, 'my'); * echo e107::templatePath(plug_name, 'my');
@@ -1088,18 +1132,19 @@ class e107
* // e107_plugins/plug_name/templates/my_template.php * // e107_plugins/plug_name/templates/my_template.php
* </code> * </code>
* *
* @see getThemeInfo()
* @param string $plug_name plugin name * @param string $plug_name plugin name
* @param string $id part of the path/file name without _template.php part * @param string $id part of the path/file name without _template.php part
* @param boolean $override default true * @param boolean|string $override default true
* @return string relative path * @return string relative path
*/ */
public static function templatePath($plug_name, $id, $override = true) public static function templatePath($plug_name, $id, $override = true)
{ {
$id = str_replace('..', '', $id); //simple security, '/' is allowed $id = str_replace('..', '', $id); //simple security, '/' is allowed
$plug_name = preg_replace('#[^a-z0-9_]#i', '', $plug_name); // only latin allowed, so \w not a solution since PHP5.3 $plug_name = preg_replace('#[^a-z0-9_]#i', '', $plug_name); // only latin allowed, so \w not a solution since PHP5.3
$override_path = $override && defined('THEME') ? THEME.'templates/'.$plug_name.'/'.$id.'_template.php' : null; $override_path = $override ? self::getThemeInfo($override, 'rel').'templates/'.$plug_name.'/'.$id.'_template.php' : null;
$default_path = e_PLUGIN.$plug_name.'/templates/'.$id.'_template.php'; $default_path = e_PLUGIN.$plug_name.'/templates/'.$id.'_template.php';
return ($override_path && is_readable($override_path) ? $override_path : $default_path); return ($override_path && is_readable($override_path) ? $override_path : $default_path);
} }
@@ -1123,16 +1168,16 @@ class e107
* *
* @param string $id - file prefix, e.g. user for user_template.php * @param string $id - file prefix, e.g. user for user_template.php
* @param string|null $key * @param string|null $key
* @param boolean $override * @param boolean $override see {@link getThemeInfo())
* *
* @return string|array * @return string|array
*/ */
public static function getCoreTemplate($id, $key = null, $override = true) public static function getCoreTemplate($id, $key = null, $override = true)
{ {
$reg_path = 'core/e107/templates/'.$id.($override ? '/ext' : ''); $reg_path = 'core/e107/templates/'.$id.($override ? '/ext' : '');
$path = e107::coreTemplatePath($id, $override); $path = self::coreTemplatePath($id, $override);
return e107::_getTemplate($id, $key, $reg_path, $path); return self::_getTemplate($id, $key, $reg_path, $path);
} }
/** /**
@@ -1156,59 +1201,70 @@ class e107
* @param string $plug_name * @param string $plug_name
* @param string $id - file prefix, e.g. calendar for calendar_template.php * @param string $id - file prefix, e.g. calendar for calendar_template.php
* @param string|null $key * @param string|null $key
* @param boolean $override * @param boolean $override see {@link getThemeInfo())
* *
* @return string|array * @return string|array
*/ */
public static function getTemplate($plug_name, $id, $key = null, $override = true) public static function getTemplate($plug_name, $id, $key = null, $override = true)
{ {
$reg_path = 'plugin/'.$plug_name.'/templates/'.$id.($override ? '/ext' : ''); $reg_path = 'plugin/'.$plug_name.'/templates/'.$id.($override ? '/ext' : '');
$path = e107::templatePath($plug_name, $id, $override); $path = self::templatePath($plug_name, $id, $override);
return e107::_getTemplate($id, $key, $reg_path, $path); return self::_getTemplate($id, $key, $reg_path, $path);
} }
/** /**
* Return a list of available template IDs (eg. $MYTEMPLATE['id']) * Return a list of available template IDs for a plugin(eg. $MYTEMPLATE['my_id'] -> array('id' => 'My Id'))
* @param str $plugin_name * @param string $plugin_name
* @param str $var [optional] if different from $plugin_name; * @param string $template_id [optional] if different from $plugin_name;
* @param mixed $where true - current theme, 'admin' - admin theme, 'front' (default) - front theme
* @return array * @return array
*/ */
public static function getCoreTemplateList($plugin_name,$var= null) public static function getLayouts($plugin_name, $template_id = '', $where = 'front', $filter_mask = '')
{ {
$id = (!$var) ? $plugin_name : $var; if(!$plugin_name) // Core template
$tmp = e107::getCoreTemplate($plugin_name, $id);
$templates = array();
foreach($tmp as $key=>$val)
{ {
$templates[$key] = $key; //TODO add LANS? $tmp = self::getCoreTemplate($template_id, null, $where);
}
else // Plugin template
{
$id = (!$template_id) ? $plugin_name : $template_id;
$tmp = self::getTemplate($plugin_name, $id, null, $where);
}
$templates = array();
$filter_mask = explode($filter_mask);
foreach($tmp as $key => $val)
{
// Special key INFO in format aray('layout' => array(info))
if($key == '__INFO__')
{
continue;
}
$match = true;
if($filter_mask)
{
$match = false;
foreach ($filter_mask as $mask)
{
if(strpos($key, $mask) === 0) //e.g. retrieve only keys starting with 'layout_'
{
$match = true;
break;
}
}
if(!$match) continue;
}
if(isset($val['__INFO__'][$key]))
{
$templates[$key] = defset($val['__INFO__'][$key]['title'], $val['__INFO__'][$key]['title']);
continue;
}
$templates[$key] = implode(' ', array_map('ucfirst', explode('_', $key))); //TODO add LANS?
} }
return $templates; return $templates;
} }
/**
* Return a list of available template IDs for a plugin(eg. $MYTEMPLATE['id'])
* @param str $plugin_name
* @param str $var [optional] if different from $plugin_name;
* @return array
*/
public static function getTemplateList($plugin_name,$var= '')
{
$id = (!$var) ? $plugin_name : $var;
$tmp = e107::getTemplate($plugin_name, $id);
$templates = array();
foreach($tmp as $key=>$val)
{
$templates[$key] = $key; //TODO add LANS?
}
return $templates;
}
/** /**
* More abstsract template loader, used * More abstsract template loader, used
* internal in {@link getTemplate()} and {@link getCoreTemplate()} methods * internal in {@link getTemplate()} and {@link getCoreTemplate()} methods
@@ -1225,17 +1281,17 @@ class e107
$regPath = $reg_path; $regPath = $reg_path;
$var = strtoupper($id).'_TEMPLATE'; $var = strtoupper($id).'_TEMPLATE';
if(null === e107::getRegistry($regPath)) if(null === self::getRegistry($regPath))
{ {
(deftrue('E107_DEBUG_LEVEL') ? include_once($path) : @include_once($path)); (deftrue('E107_DEBUG_LEVEL') ? include_once($path) : @include_once($path));
e107::setRegistry($regPath, (isset($$var) ? $$var : array())); self::setRegistry($regPath, (isset($$var) ? $$var : array()));
} }
if(!$key) if(!$key)
{ {
return e107::getRegistry($regPath); return self::getRegistry($regPath);
} }
$ret = e107::getRegistry($regPath); $ret = self::getRegistry($regPath);
return ($ret && is_array($ret) && isset($ret[$key]) ? $ret[$key] : $ret); return ($ret && is_array($ret) && isset($ret[$key]) ? $ret[$key] : $ret);
} }
@@ -1635,7 +1691,7 @@ class e107
//global $PLUGINS_DIRECTORY,$ADMIN_DIRECTORY, $eplug_admin; //global $PLUGINS_DIRECTORY,$ADMIN_DIRECTORY, $eplug_admin;
$PLUGINS_DIRECTORY = $this->getFolder('plugins'); $PLUGINS_DIRECTORY = $this->getFolder('plugins');
$ADMIN_DIRECTORY = $this->getFolder('admin'); $ADMIN_DIRECTORY = $this->getFolder('admin');
$eplug_admin = vartrue($GLOBALS['eplug_admin']); $eplug_admin = vartrue($GLOBALS['eplug_admin'], false);
$page = substr(strrchr($_SERVER['PHP_SELF'], '/'), 1); $page = substr(strrchr($_SERVER['PHP_SELF'], '/'), 1);

View File

@@ -9,8 +9,8 @@
* 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.92 $ * $Revision: 1.93 $
* $Date: 2009-11-26 17:14:03 $ * $Date: 2009-11-28 15:34:46 $
* $Author: secretr $ * $Author: secretr $
* *
*/ */
@@ -137,7 +137,7 @@ class e_form
//$parms .= "&click_target=data"; //$parms .= "&click_target=data";
//$parms .= "&click_prefix=[img][[e_IMAGE]]newspost_images/"; //$parms .= "&click_prefix=[img][[e_IMAGE]]newspost_images/";
//$parms .= "&click_postfix=[/img]"; //$parms .= "&click_postfix=[/img]";
$tp = e107::getParser(); $tp = e107::getParser();
$ret = "<div class='field-section'>".$tp->parseTemplate("{IMAGESELECTOR={$parms}&scaction=select}")."</div>"; $ret = "<div class='field-section'>".$tp->parseTemplate("{IMAGESELECTOR={$parms}&scaction=select}")."</div>";
$ret .= "<div class='field-spacer'>".$tp->parseTemplate("{IMAGESELECTOR={$parms}&scaction=preview}")."</div>"; $ret .= "<div class='field-spacer'>".$tp->parseTemplate("{IMAGESELECTOR={$parms}&scaction=preview}")."</div>";
return $ret; return $ret;
@@ -1075,15 +1075,29 @@ class e_form
// else same // else same
break; break;
case 'templates':
case 'layouts':
$pre = vartrue($parms['pre']);
$post = vartrue($parms['post']);
unset($parms['pre'], $parms['post']);
if($parms)
{
$attributes['writeParms'] = $parms;
}
elseif(isset($attributes['writeParms']))
{
if(is_string($attributes['writeParms'])) parse_str($attributes['writeParms'], $attributes['writeParms']);
}
$attributes['writeParms']['raw'] = true;
$tmp = $this->renderElement($key, '', $attributes);
$value = $pre.vartrue($tmp[$value]).$post;
break;
case 'dropdown': case 'dropdown':
if(vartrue($parms) && is_array($parms)) if(vartrue($parms) && is_array($parms))
{ {
$value = vartrue($parms['pre']).vartrue($parms[$value]).vartrue($parms['post']); $value = vartrue($parms['pre']).vartrue($parms[$value]).vartrue($parms['post']);
} }
else
{
$value = vartrue($parms['pre']).$value.vartrue($parms['post']);
}
break; break;
case 'text': case 'text':
@@ -1213,6 +1227,7 @@ class e_form
break; break;
case 'url': case 'url':
if(!$value) break;
$ttl = $value; $ttl = $value;
if(vartrue($parms['truncate'])) if(vartrue($parms['truncate']))
{ {
@@ -1256,9 +1271,9 @@ class e_form
if(vartrue($attributes['readonly'])) // quick fix (maybe 'noedit'=>'readonly'?) if(vartrue($attributes['readonly'])) // quick fix (maybe 'noedit'=>'readonly'?)
{ {
return $this->renderValue($key,$value,$attributes); return $this->renderValue($key, $value, $attributes);
} }
switch($attributes['type']) switch($attributes['type'])
{ {
case 'number': case 'number':
@@ -1306,6 +1321,46 @@ class e_form
return $this->datepicker($key, $value, $parms); return $this->datepicker($key, $value, $parms);
break; break;
case 'layouts': //to do - exclude param (exact match)
$location = varset($parms['plugin']); // empty - core
$ilocation = vartrue($parms['id'], $location); // omit if same as plugin name
$where = vartrue($parms['area'], 'front'); //default is 'front'
$filter = varset($parms['filter']);
$layouts = e107::getLayouts($location, $ilocation, $where, $filter);
if(varset($parms['default']))
{
$layouts = array('default' => $parms['default']) + $layouts;
}
return (vartrue($parms['raw']) ? $layouts : $this->selectbox($key, $layouts, $value));
break;
case 'templates': //to do - exclude param (exact match)
$templates = array();
if(varset($parms['default']))
{
$templates['default'] = defset($parms['default'], $parms['default']);
}
$location = vartrue($parms['plugin']) ? e_PLUGIN.$parms['plugin'].'/' : e_THEME;
$ilocation = vartrue($parms['location']);
$tmp = e107::getFile()->get_files($location.'templates/'.$ilocation, vartrue($parms['fmask'], '_template\.php$'), vartrue($parms['omit'], 'standard'), vartrue($parms['recurse_level'], 0));
foreach($tmp as $files)
{
$k = str_replace('_template.php', '', $files['fname']);
$templates[$k] = implode(' ', array_map('ucfirst', explode('_', $k))); //TODO add LANS?
}
// override
$where = vartrue($parms['area'], 'front');
$location = vartrue($parms['plugin']) ? $parms['plugin'].'/' : '';
$tmp = e107::getFile()->get_files(e107::getThemeInfo($where, 'rel').'templates/'.$location.$ilocation, vartrue($parms['fmask']), vartrue($parms['omit'], 'standard'), vartrue($parms['recurse_level'], 0));
foreach($tmp as $files)
{
$k = str_replace('_template.php', '', $files['fname']);
$templates[$k] = implode(' ', array_map('ucfirst', explode('_', $k))); //TODO add LANS?
}
return (vartrue($parms['raw']) ? $templates : $this->selectbox($key, $templates, $value));
break;
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);

View File

@@ -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.45 $ * $Revision: 1.46 $
* $Date: 2009-11-26 17:14:06 $ * $Date: 2009-11-28 15:34:46 $
* $Author: secretr $ * $Author: secretr $
*/ */
@@ -806,6 +806,26 @@ class e_model
return $this; return $this;
} }
/**
* Set model message stack
* @param string $stack_name
* @return e_model
*/
public function setMessageStackName($stack_name)
{
$this->_message_stack = $stack_name;
return $this;
}
/**
* Get model message stack name
* @return string
*/
public function getMessageStackName()
{
return $this->_message_stack;
}
/** /**
* User defined model validation * User defined model validation
* Awaiting for child class implementation * Awaiting for child class implementation
@@ -2075,7 +2095,7 @@ class e_tree_model extends e_model
if($this->getParam('db_query') && $this->getParam('model_class') && class_exists($this->getParam('model_class'))) if($this->getParam('db_query') && $this->getParam('model_class') && class_exists($this->getParam('model_class')))
{ {
$sql = e107::getDb(); $sql = e107::getDb();
$class_name = $this->getParam('model_class'); $class_name = $this->getParam('model_class', 'e_model');
$this->_total = $sql->total_results = false; $this->_total = $sql->total_results = false;
if($sql->db_Select_gen($this->getParam('db_query'))) if($sql->db_Select_gen($this->getParam('db_query')))
{ {
@@ -2085,6 +2105,10 @@ class e_tree_model extends e_model
while($tmp = $sql->db_Fetch()) while($tmp = $sql->db_Fetch())
{ {
$tmp = new $class_name($tmp); $tmp = new $class_name($tmp);
if($this->getParam('model_message_stack'))
{
$tmp->setMessageStackName($this->getParam('model_message_stack'));
}
$this->setNode($tmp->get($this->getFieldIdName()), $tmp); $this->setNode($tmp->get($this->getFieldIdName()), $tmp);
} }

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_plugins/featurebox/admin_config.php,v $ | $Source: /cvs_backup/e107_0.8/e107_plugins/featurebox/admin_config.php,v $
| $Revision: 1.10 $ | $Revision: 1.11 $
| $Date: 2009-11-26 17:15:46 $ | $Date: 2009-11-28 15:34:46 $
| $Author: secretr $ | $Author: secretr $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -69,43 +69,19 @@ class fb_category_ui extends e_admin_ui
protected $perPage = 0; //no limit protected $perPage = 0; //no limit
protected $fields = array( protected $fields = array(
'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'), 'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center first'),
'fb_category_id' => array('title'=> LAN_ID, 'type' => 'number', 'data' => 'int', 'width' =>'5%', 'forced'=> TRUE), 'fb_category_id' => array('title'=> LAN_ID, 'type' => 'number', 'data' => 'int', 'width' =>'5%', 'forced'=> TRUE),
'fb_category_title' => array('title'=> LAN_TITLE, 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'validate' => 'str', 'rule' => '1-200', 'error' => 'String between 1-200 characters expected', 'help' => 'up to 200 characters', 'thclass' => 'left'), 'fb_category_icon' => array('title'=> LAN_ICON, 'type' => 'icon', 'data' => 'str', 'width' => '5%', 'thclass' => 'center', 'class'=>'center'),
'fb_category_layout' => array('title'=> 'Layout', 'type' => 'dropdown', 'data' => 'str', 'width' => 'auto', 'thclass' => 'left', 'batch' => true, 'filter' => true), 'fb_category_title' => array('title'=> LAN_TITLE, 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'validate' => 'str', 'rule' => '1-200', 'error' => 'String between 1-200 characters expected', 'help' => 'up to 200 characters', 'thclass' => 'left'),
'fb_category_layout' => array('title'=> 'Render type', 'type' => 'templates', 'data' => 'str', 'width' => 'auto', 'thclass' => 'left', 'writeParms' => 'plugin=featurebox&location=layout&default=Default', 'filter' => true),
'fb_category_random' => array('title'=> 'Random', 'type' => 'boolean', 'data' => 'int', 'width' => '5%', 'thclass' => 'center', 'class' => 'center', 'batch' => true, 'filter' => true), 'fb_category_random' => array('title'=> 'Random', 'type' => 'boolean', 'data' => 'int', 'width' => '5%', 'thclass' => 'center', 'class' => 'center', 'batch' => true, 'filter' => true),
'fb_category_class' => array('title'=> LAN_VISIBILITY, 'type' => 'userclass', 'data' => 'int', 'width' => 'auto'), 'fb_category_class' => array('title'=> LAN_VISIBILITY, 'type' => 'userclass', 'data' => 'int', 'width' => 'auto'),
'fb_category_limit' => array('title'=> 'Limit', 'type' => 'number', 'data' => 'int', 'width' => '5%', 'thclass' => 'left', 'help' => 'number of items to be shown'), 'fb_category_limit' => array('title'=> 'Limit', 'type' => 'number', 'data' => 'int', 'width' => '5%', 'thclass' => 'left', 'help' => 'number of items to be shown, 0 - show all'),
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'width' => '10%', 'forced'=>TRUE, 'thclass' => 'center last', 'class' => 'center') 'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'width' => '10%', 'forced'=>TRUE, 'thclass' => 'center last', 'class' => 'center')
); );
function init()
{
// build layout dropdown params
$templates = array();
$templates['default'] = 'Default';
$tmp = e107::getFile()->get_files(e_PLUGIN.'featurebox/templates/layout');
foreach($tmp as $files)
{
$key = str_replace('_template.php', '', $files['fname']);
$templates[$key] = implode(' ', array_map('ucfirst', explode('_', $key))); //TODO add LANS?
}
// TODO we need something like getFrontTheme()/getAdminTheme() - this will fail on user theme!
$tmp = e107::getFile()->get_files(e_THEME.e107::getPref('sitetheme').'/featurebox/templates/layout');
foreach($tmp as $files)
{
$key = str_replace('_template.php', '', $files['fname']);
$templates[$key] = implode(' ', array_map('ucfirst', explode('_', $key))); //TODO add LANS?
}
$this->fields['fb_category_layout']['readParms'] = $templates;
$this->fields['fb_category_layout']['writeParms'] = $templates;
}
/** /**
* User defined pre-delete logic * Prevent deletion of categories in use
*/ */
public function beforeDelete($data, $id) public function beforeDelete($data, $id)
{ {
@@ -116,6 +92,55 @@ class fb_category_ui extends e_admin_ui
} }
return true; return true;
} }
/**
* Some default values
* TODO - 'default' fields attribute (default value on init)
*/
public function beforeCreate($new_data)
{
if(!is_numeric($new_data['fb_category_limit']))
{
$new_data['fb_category_limit'] = 1;
}
return $new_data;
}
/**
* Create error callback
*/
public function onCreateError($new_data, $old_data)
{
return $this->_handleUnique($new_data, 'create');
}
/**
* Create error callback
*/
public function onUpdateError($new_data, $old_data, $id)
{
return $this->_handleUnique($new_data, 'update');
}
/**
* Provide user friendly message on mysql duplicate entry error #1062
* No need of beforeCreate callback and additional SQL query - mysql error number give us
* enough info
* @return boolean true - suppress model errors
*/
protected function _handleUnique($new_data, $mod)
{
if($this->getModel()->getSqlErrorNumber() == 1062)
{
$templates = $this->getFieldAttr('fb_category_layout', 'writeParms', array());
$msg = e107::getMessage();
$msg->error('Layout <strong>'.vartrue($templates[$new_data['fb_category_layout']], 'n/a').'</strong> is in use by another category. Layout should be unique per category. ');
$msg->error($mod == 'create' ? LAN_CREATED_FAILED : LAN_UPDATED_FAILED);
return (!E107_DEBUG_LEVEL); // suppress messages (TRUE) only when not in debug mod
}
return false;
}
} }
/*class fb_cat_form_ui extends e_admin_form_ui /*class fb_cat_form_ui extends e_admin_form_ui
@@ -133,19 +158,18 @@ class fb_main_ui extends e_admin_ui
protected $batchDelete = true; protected $batchDelete = true;
protected $fields = array( protected $fields = array(
'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'), 'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center first', 'class'=>'center'),
'fb_id' => array('title'=> LAN_ID, 'type' => 'int', 'width' =>'5%', 'forced'=> TRUE), 'fb_id' => array('title'=> LAN_ID, 'type' => 'number', 'data'=> 'int', 'width' =>'5%', 'forced'=> TRUE),
'fb_title' => array('title'=> LAN_TITLE, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left first'), 'fb_category' => array('title'=> LAN_CATEGORY, 'type' => 'dropdown', 'data'=> 'int', 'width' => '5%', 'filter'=>TRUE, 'batch'=>TRUE),
'fb_title' => array('title'=> LAN_TITLE, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left'),
'fb_text' => array('title'=> "Message Text", 'type' => 'bbarea', 'width' => '30%', 'readParms' => 'expand=...&truncate=50&bb=1'), // Display name 'fb_text' => array('title'=> "Message Text", 'type' => 'bbarea', 'width' => '30%', 'readParms' => 'expand=...&truncate=50&bb=1'), // Display name
'fb_image' => array('title'=> "Image", 'type' => 'image', 'width' => 'auto', 'thclass' => 'left first'), //DEPRECATED 'fb_mode' => array('title'=> FBLAN_12, 'type' => 'dropdown', 'data'=> 'int', 'width' => '5%', 'filter'=>TRUE, 'batch'=>TRUE),
'fb_imageurl' => array('title'=> "Image Link", 'type' => 'url', 'width' => 'auto', 'thclass' => 'left first'), //DEPRECATED 'fb_rendertype' => array('title'=> FBLAN_22, 'type' => 'dropdown', 'data'=> 'int', 'width' => 'auto', 'noedit' => TRUE),
'fb_mode' => array('title'=> FBLAN_12, 'type' => 'dropdown', 'data'=> 'int', 'width' => '5%', 'filter'=>TRUE, 'batch'=>TRUE), 'fb_template' => array('title'=> FBLAN_25, 'type' => 'layouts', 'data'=> 'str', 'width' => 'auto', 'thclass' => 'center', 'class'=>'center', 'writeParms' => 'plugin=featurebox', 'filter' => true, 'batch' => true), // Photo
'fb_image' => array('title'=> "Image", 'type' => 'image', 'width' => 'auto', 'thclass' => 'left first'),
'fb_imageurl' => array('title'=> "Image Link", 'type' => 'url', 'width' => 'auto', 'thclass' => 'left first'),
'fb_class' => array('title'=> LAN_VISIBILITY, 'type' => 'userclass', 'data' => 'int', 'width' => 'auto'), // User id 'fb_class' => array('title'=> LAN_VISIBILITY, 'type' => 'userclass', 'data' => 'int', 'width' => 'auto'), // User id
'fb_rendertype' => array('title'=> FBLAN_22, 'type' => 'dropdown', 'data'=> 'int', 'width' => 'auto', 'noedit' => TRUE), 'fb_order' => array('title'=> LAN_ORDER, 'type' => 'number', 'data'=> 'int','width' => '5%', 'thclass' => 'center' ),
'fb_template' => array('title'=> FBLAN_25, 'type' => 'dropdown', 'data'=> 'str', 'width' => 'auto', 'thclass' => 'center', 'class'=>'center', 'writeParms' => '', 'filter' => true, 'batch' => true), // Photo
'fb_category' => array('title'=> LAN_CATEGORY, 'type' => 'dropdown', 'data'=> 'int', 'width' => '5%', 'filter'=>TRUE, 'batch'=>TRUE),
'fb_order' => array('title'=> LAN_ORDER, 'type' => 'number', 'data'=> 'int','width' => '5%', 'thclass' => 'center' ),
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center') 'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center')
); );
@@ -161,18 +185,7 @@ class fb_main_ui extends e_admin_ui
function init() function init()
{ {
$templates = array();
$categories = array(); $categories = array();
$tmp = e107::getTemplate('featurebox', 'featurebox');
foreach($tmp as $key=>$val)
{
$templates[$key] = $key; //TODO add LANS?
}
if(e107::getDb()->db_Select('featurebox_category')) if(e107::getDb()->db_Select('featurebox_category'))
{ {
$categories[0] = LAN_SELECT; $categories[0] = LAN_SELECT;
@@ -182,16 +195,16 @@ class fb_main_ui extends e_admin_ui
$categories[$id] = $row['fb_category_title']; $categories[$id] = $row['fb_category_title'];
} }
} }
$this->fields['fb_category']['writeParms'] = $categories; $this->fields['fb_category']['writeParms'] = $categories;
$this->fields['fb_template']['writeParms'] = $templates; // DEPRECATED
$this->fields['fb_rendertype']['writeParms'] = array(FBLAN_23,FBLAN_24); //$this->fields['fb_rendertype']['writeParms'] = array(FBLAN_23,FBLAN_24);
$this->fields['fb_mode']['writeParms'] = array(FBLAN_13,FBLAN_14); //$this->fields['fb_mode']['writeParms'] = array(FBLAN_13,FBLAN_14);
$this->fields['fb_category']['readParms'] = $categories; $this->fields['fb_category']['readParms'] = $categories;
$this->fields['fb_template']['readParms'] = $templates; // DEPRECATED
$this->fields['fb_rendertype']['readParms'] = array(FBLAN_23,FBLAN_24); //$this->fields['fb_rendertype']['readParms'] = array(FBLAN_23,FBLAN_24);
$this->fields['fb_mode']['readParms'] = array(FBLAN_13,FBLAN_14); //$this->fields['fb_mode']['readParms'] = array(FBLAN_13,FBLAN_14);
} }

View File

@@ -17,9 +17,11 @@ CREATE TABLE featurebox (
CREATE TABLE featurebox_category ( CREATE TABLE featurebox_category (
`fb_category_id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, `fb_category_id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
`fb_category_title` varchar(200) NOT NULL DEFAULT '', `fb_category_title` varchar(200) NOT NULL DEFAULT '',
`fb_category_icon` varchar(255) NOT NULL DEFAULT '',
`fb_category_layout` varchar(50) NOT NULL DEFAULT 'default', `fb_category_layout` varchar(50) NOT NULL DEFAULT 'default',
`fb_category_random` tinyint(1) unsigned NOT NULL DEFAULT '0', `fb_category_random` tinyint(1) unsigned NOT NULL DEFAULT '0',
`fb_category_class` smallint(5) unsigned NOT NULL DEFAULT '0', `fb_category_class` smallint(5) unsigned NOT NULL DEFAULT '0',
`fb_category_limit` tinyint(3) unsigned NOT NULL DEFAULT '0', `fb_category_limit` tinyint(3) unsigned NOT NULL DEFAULT '1',
PRIMARY KEY (`fb_category_id`) PRIMARY KEY (`fb_category_id`),
UNIQUE KEY `fb_category_layout` (`fb_category_layout`)
) TYPE=MyISAM; ) TYPE=MyISAM;

View File

@@ -9,8 +9,8 @@
* Release Plugin Administration UI * Release Plugin Administration UI
* *
* $Source: /cvs_backup/e107_0.8/e107_plugins/release/includes/admin.php,v $ * $Source: /cvs_backup/e107_0.8/e107_plugins/release/includes/admin.php,v $
* $Revision: 1.12 $ * $Revision: 1.13 $
* $Date: 2009-11-18 19:57:06 $ * $Date: 2009-11-28 15:34:46 $
* $Author: secretr $ * $Author: secretr $
*/ */
@@ -161,7 +161,7 @@ class plugin_release_admin_ui extends e_admin_ui
* *
* - validate (boolean|string) any of accepted validation types (see e_validator::$_required_rules), true == 'required' * - validate (boolean|string) any of accepted validation types (see e_validator::$_required_rules), true == 'required'
* - rule (string) condition for chosen above validation type (see e_validator::$_required_rules), not required for all types * - rule (string) condition for chosen above validation type (see e_validator::$_required_rules), not required for all types
* - error (string) Human readable error message (validation failure), constant name will be accpeted as well, optional * - error (string) Human readable error message (validation failure), constant name will be accepted as well, optional
* *
* - batch (boolean) list table - add current field to batch actions, in use only for boolean, dropdown, datestamp, userclass, method field types * - batch (boolean) list table - add current field to batch actions, in use only for boolean, dropdown, datestamp, userclass, method field types
* NOTE: batch may accept string values in the future... * NOTE: batch may accept string values in the future...