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

Admin tools - more work

This commit is contained in:
secretr
2009-10-30 17:59:32 +00:00
parent f7d22f782b
commit 7f15da0b74
12 changed files with 1120 additions and 537 deletions

View File

@@ -9,9 +9,9 @@
* News Administration * News Administration
* *
* $Source: /cvs_backup/e107_0.8/e107_admin/newspost.php,v $ * $Source: /cvs_backup/e107_0.8/e107_admin/newspost.php,v $
* $Revision: 1.61 $ * $Revision: 1.62 $
* $Date: 2009-10-26 07:26:47 $ * $Date: 2009-10-30 17:59:32 $
* $Author: e107coders $ * $Author: secretr $
*/ */
require_once("../class2.php"); require_once("../class2.php");
@@ -265,7 +265,7 @@ class admin_newspost
'news_title' => array('title' => NWSLAN_40, 'type' => 'text', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false), 'news_title' => array('title' => NWSLAN_40, 'type' => 'text', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
'news_rewrite_string' => array('title' => 'SEF URL', 'type' => 'text', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false), 'news_rewrite_string' => array('title' => 'SEF URL', 'type' => 'text', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
'user_name' => array('title' => LAN_NEWS_50, 'type' => 'text', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false), 'user_name' => array('title' => LAN_NEWS_50, 'type' => 'text', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
'news_datestamp' => array('title' => LAN_NEWS_32, 'type' => 'datestamp', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'colparms' => 'mask=%A %d %B %Y'), 'news_datestamp' => array('title' => LAN_NEWS_32, 'type' => 'datestamp', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false, 'parms' => 'mask=%A %d %B %Y'),
'category_name' => array('title' => NWSLAN_6, 'type' => 'text', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false), 'category_name' => array('title' => NWSLAN_6, 'type' => 'text', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
'news_class' => array('title' => NWSLAN_22, 'type' => 'userclass', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false), 'news_class' => array('title' => NWSLAN_22, 'type' => 'userclass', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
'news_render_type' => array('title' => LAN_NEWS_49, 'type' => 'dropdown', 'width' => 'auto', 'thclass' => 'center', 'class' => null, 'nosort' => false), 'news_render_type' => array('title' => LAN_NEWS_49, 'type' => 'dropdown', 'width' => 'auto', 'thclass' => 'center', 'class' => null, 'nosort' => false),
@@ -1143,7 +1143,7 @@ class admin_newspost
} }
// AUTO RENDER // AUTO RENDER
$text .= $frm->trow($this, $row); $text .= $frm->trow($this->fields, $this->fieldpref, $row, 'news_id');
} }
$text .= " $text .= "

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,18 @@
<?php <?php
/*
* e107 website system
*
* Copyright (c) 2001-2008 e107 Inc. (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://gnu.org).
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/calendar/calendar_class.php,v $
* $Revision: 1.3 $
* $Date: 2009-10-30 17:59:30 $
* $Author: secretr $
*
*/
/** /**
* File: calendar.php | (c) dynarch.com 2004 * File: calendar.php | (c) dynarch.com 2004
* Distributed as part of "The Coolest DHTML Calendar" * Distributed as part of "The Coolest DHTML Calendar"
@@ -9,38 +23,37 @@
* calendar by instantiating and calling a PHP object. * calendar by instantiating and calling a PHP object.
*/ */
define('NEWLINE', "\n");
class DHTML_Calendar class DHTML_Calendar
{ {
var $calendar_file; public static $NEWLINE = "\n";
var $calendar_lang_file; public $calendar_file;
var $calendar_setup_file; public $calendar_lang_file;
var $calendar_theme_file; public $calendar_setup_file;
var $calendar_options; public $calendar_theme_file;
var $calendar_img; public $calendar_options;
public $calendar_img;
function DHTML_Calendar($stripped = true) function DHTML_Calendar($stripped = true)
{ {
if ($stripped) if ($stripped)
{ {
$this->calendar_file = e_HANDLER.'calendar/calendar_stripped.js'; $this->calendar_file = e_HANDLER_ABS.'calendar/calendar_stripped.js';
$this->calendar_setup_file = e_HANDLER.'calendar/calendar-setup_stripped.js'; $this->calendar_setup_file = e_HANDLER_ABS.'calendar/calendar-setup_stripped.js';
} }
else else
{ {
$this->calendar_file = e_HANDLER.'calendar/calendar.js'; $this->calendar_file = e_HANDLER_ABS.'calendar/calendar.js';
$this->calendar_setup_file = e_HANDLER.'calendar/calendar-setup.js'; $this->calendar_setup_file = e_HANDLER_ABS.'calendar/calendar-setup.js';
} }
if(file_exists(e_HANDLER.'calendar/language/'.e_LANGUAGE.'.js')) if(file_exists(e_HANDLER.'calendar/language/'.e_LANGUAGE.'.js'))
{ {
$this->calendar_lang_file = e_HANDLER.'calendar/language/'.e_LANGUAGE.'.js'; $this->calendar_lang_file = e_HANDLER_ABS.'calendar/language/'.e_LANGUAGE.'.js';
} }
else else
{ {
$this->calendar_lang_file = e_HANDLER.'calendar/language/English.js'; $this->calendar_lang_file = e_HANDLER_ABS.'calendar/language/English.js';
} }
if(defined('CALENDAR_IMG')) if(defined('CALENDAR_IMG'))
@@ -49,16 +62,16 @@ class DHTML_Calendar
} }
else else
{ {
$this->calendar_img = "<img style='vertical-align:middle;' src='".e_HANDLER."calendar/cal.gif' alt='' />"; $this->calendar_img = "<img style='vertical-align:middle;' src='".e_HANDLER_ABS."calendar/cal.gif' alt='' />";
} }
if(file_exists(THEME."calendar.css")) if(file_exists(THEME."calendar.css"))
{ {
$this->calendar_theme_file = THEME."calendar.css"; $this->calendar_theme_file = THEME_ABS."calendar.css";
} }
else else
{ {
$this->calendar_theme_file = e_HANDLER."calendar/calendar.css"; $this->calendar_theme_file = e_HANDLER_ABS."calendar/calendar.css";
} }
$this->calendar_options = array('ifFormat' => '%Y/%m/%d', 'daFormat' => '%Y/%m/%d'); $this->calendar_options = array('ifFormat' => '%Y/%m/%d', 'daFormat' => '%Y/%m/%d');
@@ -73,16 +86,16 @@ class DHTML_Calendar
} }
function get_load_files_code() { function get_load_files_code() {
$code = ( '<link rel="stylesheet" type="text/css" media="all" href="' . $this->calendar_theme_file . '" />' . NEWLINE ); $code = ( '<link rel="stylesheet" type="text/css" media="all" href="' . $this->calendar_theme_file . '" />' . self::$NEWLINE );
$code .= ( '<script type="text/javascript" src="'.$this->calendar_file.'"></script>' . NEWLINE ); $code .= ( '<script type="text/javascript" src="'.$this->calendar_file.'"></script>' . self::$NEWLINE );
$code .= ( '<script type="text/javascript" src="'.$this->calendar_setup_file.'"></script>' . NEWLINE ); $code .= ( '<script type="text/javascript" src="'.$this->calendar_setup_file.'"></script>' . self::$NEWLINE );
$code .= ( '<script type="text/javascript" src="'.$this->calendar_lang_file.'"></script>' . NEWLINE ); $code .= ( '<script type="text/javascript" src="'.$this->calendar_lang_file.'"></script>' . self::$NEWLINE );
return $code; return $code;
} }
function _make_calendar($other_options = array()) { function _make_calendar($other_options = array(), $script_tag = true) {
$js_options = $this->_make_js_hash(array_merge($this->calendar_options, $other_options)); $js_options = $this->_make_js_hash(array_merge($this->calendar_options, $other_options));
$code = ( '<script type="text/javascript">Calendar.setup({' . $js_options . '});</script>' ); $code = $script_tag ? ( '<script type="text/javascript">Calendar.setup({' . $js_options . '});</script>' ) : 'Calendar.setup({' . $js_options . '});';
return $code; return $code;
} }
@@ -94,7 +107,7 @@ class DHTML_Calendar
$ret .= '<input ' . $attrstr .'/> '; $ret .= '<input ' . $attrstr .'/> ';
$ret .= "<a href='#' id='".$this->_trigger_id($id)."'>".$this->calendar_img."</a>"; $ret .= "<a href='#' id='".$this->_trigger_id($id)."'>".$this->calendar_img."</a>";
$options = array_merge($cal_options, array('inputField' => $this->_field_id($id), 'button' => $this->_trigger_id($id))); $options = array_merge($cal_options, array('inputField' => $this->_field_id($id), 'button' => $this->_trigger_id($id)));
$ret .= $this->_make_calendar($options); e107::getJs()->footerInline($this->_make_calendar($options, false)); //FIXME - get_load_files_code() to use JS Manager
return $ret; return $ret;
} }

View File

@@ -1,21 +1,16 @@
<?php <?php
/* /*
+ ----------------------------------------------------------------------------+ * e107 website system
| e107 website system *
| * Copyright (c) 2001-2008 e107 Inc. (e107.org)
| <20>Steve Dunstan 2001-2002 * Released under the terms and conditions of the
| http://e107.org * GNU General Public License (http://gnu.org).
| jalist@e107.org *
| * $Source: /cvs_backup/e107_0.8/e107_handlers/date_handler.php,v $
| Released under the terms and conditions of the * $Revision: 1.9 $
| GNU General Public License (http://gnu.org). * $Date: 2009-10-30 17:59:32 $
| * $Author: secretr $
| $Source: /cvs_backup/e107_0.8/e107_handlers/date_handler.php,v $ *
| $Revision: 1.8 $
| $Date: 2009-10-23 13:06:21 $
| $Author: secretr $
|
+----------------------------------------------------------------------------+
*/ */
if (!defined('e107_INIT')) { exit; } if (!defined('e107_INIT')) { exit; }
@@ -48,6 +43,10 @@ class convert
$mask = e107::getPref('shortdate'); $mask = e107::getPref('shortdate');
break; break;
case 'input': //New - use inputdate as mask; FIXME - add inputdate to Date site prefs
$mask = e107::getPref('inputdate', '%d/%m/%Y %H:%M:%S');
break;
case 'forum': // DEPRECATED - temporary here from BC reasons only case 'forum': // DEPRECATED - temporary here from BC reasons only
default: default:
//BC - old 'forum' call //BC - old 'forum' call
@@ -62,6 +61,12 @@ class convert
return strftime($mask, $datestamp); return strftime($mask, $datestamp);
} }
function toDate($date_string, $maks = '')
{
//TODO - convert string to datestamp
return time();
}
function computeLapse($older_date, $newer_date = FALSE, $mode = FALSE, $show_secs = TRUE, $format = 'long') function computeLapse($older_date, $newer_date = FALSE, $mode = FALSE, $show_secs = TRUE, $format = 'long')
{ /* { /*
$mode = TRUE :: return array $mode = TRUE :: return array

View File

@@ -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.60 $ * $Revision: 1.61 $
* $Date: 2009-10-28 14:13:44 $ * $Date: 2009-10-30 17:59:31 $
* $Author: marj_nl_fr $ * $Author: secretr $
*/ */
if (!defined('e107_INIT')) { exit; } if (!defined('e107_INIT')) { exit; }
@@ -114,7 +114,6 @@ 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',
@@ -126,6 +125,7 @@ class e107
'themeHandler' => '{e_HANDLER}theme_handler.php', 'themeHandler' => '{e_HANDLER}theme_handler.php',
'e_model' => '{e_HANDLER}model_class.php', 'e_model' => '{e_HANDLER}model_class.php',
'e_admin_model' => '{e_HANDLER}model_class.php', 'e_admin_model' => '{e_HANDLER}model_class.php',
'DHTML_Calendar'=> '{e_HANDLER}calendar/calendar_class.php',
); );
/** /**

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.60 $ * $Revision: 1.61 $
* $Date: 2009-10-28 17:05:34 $ * $Date: 2009-10-30 17:59:30 $
* $Author: secretr $ * $Author: secretr $
* *
*/ */
@@ -99,7 +99,7 @@ class e_form
// The button itself could be replaced with an icon just for this purpose. // The button itself could be replaced with an icon just for this purpose.
$e107 = &e107::getInstance(); $e107 = e107::getInstance();
$id = $this->name2id($name); $id = $this->name2id($name);
$sc_parameters .= '&id='.$id; $sc_parameters .= '&id='.$id;
$jsfunc = $ajax ? "e107Ajax.toggleUpdate('{$id}-iconpicker', '{$id}-iconpicker-cn', 'sc:iconpicker=".urlencode($sc_parameters)."', '{$id}-iconpicker-ajax', { overlayElement: '{$id}-iconpicker-button' })" : "e107Helper.toggle('{$id}-iconpicker')"; $jsfunc = $ajax ? "e107Ajax.toggleUpdate('{$id}-iconpicker', '{$id}-iconpicker-cn', 'sc:iconpicker=".urlencode($sc_parameters)."', '{$id}-iconpicker-ajax', { overlayElement: '{$id}-iconpicker-button' })" : "e107Helper.toggle('{$id}-iconpicker')";
@@ -117,35 +117,64 @@ class e_form
return $ret; return $ret;
} }
// FIXME - better GUI, {IMAGESELECTOR} rewrite, flexibility, thumbnails, tooltip image preivew, etc.
function imagepicker($name, $default, $label = '', $sc_parameters = '')
{
if(is_string($sc_parameters)) parse_str($sc_parameters, $sc_parameters);
if(!$label) $label = LAN_SELECT;
$parms = "name={$name}";
$parms .= "&path=".urlencode(e107::getParser()->replaceConstants(vartue($sc_parameters['path'], '{e_FILE}images/')));
$parms .= "&filter=0";
$parms .= "&fullpath=1";
$parms .= "&default=".$default;
$parms .= "&multiple=FALSE";
$parms .= "&label=-- ".$label." --";
$parms .= "&subdirs=0";
//$parms .= "&tabindex=".$this->getNext();
//$parms .= "&click_target=data";
//$parms .= "&click_prefix=[img][[e_IMAGE]]newspost_images/";
//$parms .= "&click_postfix=[/img]";
$ret = "<div class='field-section'>".$tp->parseTemplate("{IMAGESELECTOR={$parms}&scaction=select}")."</div>";
$ret = "<div class='field-spacer'>".$tp->parseTemplate("{IMAGESELECTOR={$parms}&scaction=preview}")."</div>";
return $text;
}
/** /**
* Date field with popup calendar * Date field with popup calendar
* @param name => string - the name of the field * @param string $name the name of the field
* @param datestamp => UNIX timestamp - default value of the field * @param integer $datestamp UNIX timestamp - default value of the field
**/ * @param array $options calendar options
function datepicker($name, $datestamp=false) */
function datepicker($name, $datestamp = false, $options = array())
{ {
global $pref;
//TODO can some of these values be set in an admin section somewhere so they are set per site?
//TODO allow time option ?
$cal = new DHTML_Calendar(true); $cal = new DHTML_Calendar(true);
$cal_options['showsTime'] = false; $cal_options['showsTime'] = varset($options['time'], true);
$cal_options['showOthers'] = false; $cal_options['showOthers'] = varset($options['others'], false);
$cal_options['weekNumbers'] = false; $cal_options['weekNumbers'] = varset($options['weeks'], false);
//TODO use $prefs values for format? $cal_options['ifFormat'] = e107::getPref('inputdate', '%d/%m/%Y %H:%M:%S');
$cal_options['ifFormat'] = $pref['inputdate'];
$cal_options['timeFormat'] = "24"; $cal_options['timeFormat'] = "24";
$cal_attrib['class'] = "tbox"; $cal_attrib['class'] = "tbox date";
$cal_attrib['size'] = "12"; $cal_attrib['size'] = varset($options['size'], 25);
$cal_attrib['name'] = $name; $cal_attrib['name'] = $name;
if ($datestamp) if ($datestamp)
{ {
//TODO use $prefs values for format? $cal_attrib['value'] = e107::getDateConvert()->convert_date($datestamp, 'input'); //date("d/m/Y H:i:s", $datestamp);
$cal_attrib['value'] = date("d/m/Y H:i:s", $datestamp);
$cal_attrib['value'] = date("d/m/Y", $datestamp);
} }
//JS manager to send JS/CSS to header if possible, if not - footer
e107::getJs()// FIXME - no CSS support yet!!! ->tryHeaderFile($cal->calendar_theme_file)
->tryHeaderFile($cal->calendar_file)
->tryHeaderFile($cal->calendar_setup_file)
->tryHeaderFile($cal->calendar_lang_file);
return $cal->make_input_field($cal_options, $cal_attrib); return $cal->make_input_field($cal_options, $cal_attrib);
} }
function user($name, $default_id, $options = array())
{
return 'User auto-complete search - under development';
}
function file($name, $options = array()) function file($name, $options = array())
{ {
$options = $this->format_options('file', $name, $options); $options = $this->format_options('file', $name, $options);
@@ -833,38 +862,59 @@ class e_form
} }
$tdclass = vartrue($data['class']); $tdclass = vartrue($data['class']);
if($tdclass)
{
$tdclass = ' class="'.$tdclass.'"';
}
$value = $fieldvalues[$field]; $value = $fieldvalues[$field];
$parms = array(); $parms = array();
if(isset($data['colparms'])) //TODO rename to 'parms'. if(isset($data['parms']))
{ {
if(!is_array($data['colparms'])) parse_str($data['colparms'], $data['colparms']); if(!is_array($data['parms'])) parse_str($data['parms'], $data['parms']);
$parms = $data['colparms']; $parms = $data['parms'];
} }
switch($field) // special fields switch($field) // special fields
{ {
case 'options': case 'options':
$value = "<input type='image' class='action edit' name='edit[{$fieldvalues[$pid]}]' src='".ADMIN_EDIT_ICON_PATH."' title='".LAN_EDIT."' />"; if(!$value)
$value .= "<input type='image' class='action delete' name='delete[{$fieldvalues[$pid]}]' src='".ADMIN_DELETE_ICON_PATH."' title='".LAN_DELETE." [ ID: {$fieldvalues[$pid]} ]' />"; {
parse_str(str_replace('&amp;', '&', e_QUERY), $query);
// keep other vars in tact
$query['action'] = 'edit';
$query['id'] = $fieldvalues[$pid];
//$edit_query = array('mode' => varset($query['mode']), 'action' => varset($query['action']), 'id' => $fieldvalues[$pid]);
$query = http_build_query($query);
$value = "<a href='".e_SELF."?{$query}' title='".LAN_EDIT."'><img class='icon action edit' src='".ADMIN_EDIT_ICON_PATH."' alt='".LAN_EDIT."' /></a>&nbsp;";
$value .= $this->submit_image('delete['.$fieldvalues[$pid].']', $fieldvalues[$pid], 'delete', LAN_DELETE.' [ ID: '.$fieldvalues[$pid].' ]');
}
$data['type'] = 'text'; $data['type'] = 'text';
break; break;
case 'checkboxes': case 'checkboxes':
$value = $this->checkbox(vartrue($data['toggle'], 'multiselect').'['.$fieldvalues[$pid].']', $fieldvalues[$pid]); $value = $this->checkbox(vartrue($data['toggle'], 'multiselect').'['.$fieldvalues[$pid].']', $fieldvalues[$pid]);
$data['type'] = 'text'; $data['type'] = 'text';
$tdclass = $tdclass ? $tdclass.' autocheck e-pointer' : 'autocheck e-pointer';
break; break;
} }
switch($data['type']) switch($data['type'])
{ {
case 'text':
case 'number': case 'number':
// same
break;
case 'text':
if(vartrue($parms['truncate']))
{
$value = e107::getParser()->text_truncate($value, $parms['truncate'], '...');
}
elseif(vartrue($parms['htmltruncate']))
{
$value = e107::getParser()->html_truncate($value, $parms['htmltruncate'], '...');
}
break;
case 'icon':
case 'image': //TODO - thumb, js tooltip... case 'image': //TODO - thumb, js tooltip...
//same //same
break; break;
@@ -891,6 +941,10 @@ class e_form
{ {
$value = 'not found'; $value = 'not found';
} }
if(vartrue($parms['truncate']))
{
$value = e107::getParser()->text_truncate($value, $parms['truncate'], '...');
}
break; break;
case 'boolean': case 'boolean':
@@ -898,12 +952,17 @@ class e_form
break; break;
case 'url': case 'url':
$value = "<a href='".$value ."'>".$value."</a>"; $ttl = $data['title'];
if(vartrue($parms['truncate']))
{
$ttl = e107::getParser()->text_truncate($value, $parms['truncate'], '...');
}
$value = "<a href='".e107::getParser()->replaceConstants($value, 'abs')."' title='{$value}'>".$ttl."</a>";
break; break;
case 'method': // Custom Function case 'method': // Custom Function
$meth = $field; $method = $field;
$value = $obj->$meth($value,$obj->mode); $value = call_user_func_array(array($this, $method), array($value, 'list'));
break; break;
//TODO - form_userclass, order,... and maybe more types //TODO - form_userclass, order,... and maybe more types
@@ -913,16 +972,10 @@ class e_form
break; break;
} }
//TODO - this should be done per type! if($tdclass)
if(vartrue($parms['truncate']))
{ {
$value = e107::getParser()->text_truncate($value, $parms['truncate'], '...'); $tdclass = ' class="'.$tdclass.'"';
} }
elseif(vartrue($parms['htmltruncate']))
{
$value = e107::getParser()->html_truncate($value, $parms['htmltruncate'], '...');
}
$ret .= ' $ret .= '
<td'.$tdclass.'> <td'.$tdclass.'>
'.$value.' '.$value.'
@@ -941,6 +994,7 @@ class e_form
</tr> </tr>
'; ';
} }
return ''; return '';
} }
@@ -1076,7 +1130,7 @@ class e_form
$text .= " $text .= "
".$this->select_close()." ".$this->select_close()."
".$this->admin_button('trigger_execute_batch', 'trigger_execute_batch', 'submit multi e-hide-if-js', 'Go')." ".$this->admin_button('trigger_execute_batch', 'trigger_execute_batch', 'submit multi e-hide-if-js', 'Go')."
</div><span class='clear'></span> </div><div class='clear'></div>
"; ";
return $text; return $text;

View File

@@ -7,8 +7,8 @@
* GNU General Public License (http://gnu.org). * GNU General Public License (http://gnu.org).
* *
* $Source: /cvs_backup/e107_0.8/e107_handlers/js_manager.php,v $ * $Source: /cvs_backup/e107_0.8/e107_handlers/js_manager.php,v $
* $Revision: 1.5 $ * $Revision: 1.6 $
* $Date: 2009-10-07 11:05:55 $ * $Date: 2009-10-30 17:59:32 $
* $Author: secretr $ * $Author: secretr $
* *
*/ */
@@ -52,6 +52,20 @@ class e_jsmanager
*/ */
protected $_runtime_header_src = array(); protected $_runtime_header_src = array();
/**
* Current Header zone (under development)
*
* @var array
*/
protected $_zone_header = 0;
/**
* Current Footer zone (under development)
*
* @var array
*/
protected $_zone_footer = 0;
/** /**
* JS files array - loaded in page footer * JS files array - loaded in page footer
* *
@@ -292,7 +306,7 @@ class e_jsmanager
* @param integer $zone 1-5 (see header.php) * @param integer $zone 1-5 (see header.php)
* @return e_jsmanager * @return e_jsmanager
*/ */
public function headerCore($file_path, $zone = 1) public function headerCore($file_path, $zone = 2)
{ {
$this->headerFile('{e_FILE}jslib/'.trim($file_path, '/'), $zone); $this->headerFile('{e_FILE}jslib/'.trim($file_path, '/'), $zone);
return $this; return $this;

View File

@@ -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.22 $ * $Revision: 1.23 $
* $Date: 2009-10-22 14:18:18 $ * $Date: 2009-10-30 17:59:32 $
* $Author: secretr $ * $Author: secretr $
* *
*/ */
@@ -511,20 +511,22 @@ class eMessage
*/ */
public function moveStack($from_stack, $to_stack = 'default', $type = false, $session = true) public function moveStack($from_stack, $to_stack = 'default', $type = false, $session = true)
{ {
if($from_stack == $to_stack) return $this;
foreach ($this->_sysmsg as $_type => $stacks) foreach ($this->_sysmsg as $_type => $stacks)
{ {
if($type && $type !== $_type) if($type && $type !== $_type)
{ {
continue; continue;
} }
if(isset($stacks[$from_stack])) if(isset($stacks[$from_stack]))
{ {
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]); $this->_sysmsg[$_type][$to_stack] = array_merge($this->_sysmsg[$_type][$to_stack], $this->_sysmsg[$_type][$from_stack]);
unset($this->_sysmsg[$_type][$to_stack]); unset($this->_sysmsg[$_type][$from_stack]);
} }
} }
@@ -544,6 +546,7 @@ class eMessage
*/ */
public function moveSessionStack($from_stack, $to_stack = 'default', $type = false) public function moveSessionStack($from_stack, $to_stack = 'default', $type = false)
{ {
if($from_stack == $to_stack) return $this;
foreach ($_SESSION[$this->_session_id] as $_type => $stacks) foreach ($_SESSION[$this->_session_id] as $_type => $stacks)
{ {
if($type && $type !== $_type) if($type && $type !== $_type)
@@ -554,10 +557,10 @@ 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(); $_SESSION[$this->_session_id][$_type][$to_stack] = array();
} }
array_merge($_SESSION[$this->_session_id][$_type][$from_stack], $this->_sysmsg[$_type][$to_stack]); $_SESSION[$this->_session_id][$_type][$to_stack] = array_merge($_SESSION[$this->_session_id][$_type][$to_stack], $this->_sysmsg[$_type][$from_stack]);
unset($_SESSION[$this->_session_id][$_type][$to_stack]); unset($_SESSION[$this->_session_id][$_type][$from_stack]);
} }
} }

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.26 $ * $Revision: 1.27 $
* $Date: 2009-10-28 17:05:34 $ * $Date: 2009-10-30 17:59:31 $
* $Author: secretr $ * $Author: secretr $
*/ */
@@ -45,6 +45,15 @@ class e_model
*/ */
protected $_data_fields = array(); protected $_data_fields = array();
/**
* Current model DB table, used in all db calls
*
* This can/should be overwritten/set by extending the class
*
* @var string
*/
protected $_db_table;
/** /**
* Runtime cache of parsed from {@link _getData()} keys * Runtime cache of parsed from {@link _getData()} keys
* *
@@ -75,6 +84,12 @@ class e_model
*/ */
protected $_message_stack = 'default'; protected $_message_stack = 'default';
/**
* Model parameters passed mostly from external sources
*
* @var array
*/
protected $_params = array();
/** /**
* Constructor - set data on initialization * Constructor - set data on initialization
@@ -86,6 +101,27 @@ class e_model
$this->setData($data); $this->setData($data);
} }
/**
* Optional DB table - used for auto-load data from the DB
* @param string $table
* @return e_model
*/
public function getModelTable()
{
return $this->_db_table;
}
/**
* Set model DB table
* @param string $table
* @return e_model
*/
public function setModelTable($table)
{
$this->_db_table = $table;
return $this;
}
/** /**
* Get data fields array * Get data fields array
* @return array * @return array
@@ -427,7 +463,7 @@ class e_model
return $this; return $this;
} }
$this->$data_src = $key; $this->${data_src} = $key;
return $this; return $this;
} }
@@ -765,12 +801,32 @@ class e_model
} }
/** /**
* Load data from DB * Generic load data from DB
* Awaiting for child class implementation * @param boolean $force
* * @return e_admin
*/ */
public function load() public function load($id, $force = false)
{ {
if($this->hasData() && !$force)
{
return $this;
}
$id = intval($id);
$qry = str_replace('{ID}', $id, $this->getParam('db_query'));
if(!$qry)
{
$qry = '
SELECT * FROM #'.$this->getModelTable().' WHERE '.$this->getFieldIdName().'='.$id.'
';
}
//TODO - error reporting
$sql = e107::getDb();
if($sql->db_Select_gen($qry))
{
$this->setData($sql->db_Fetch());
}
return $this;
} }
/** /**
@@ -800,6 +856,73 @@ class e_model
{ {
} }
/**
* Replace DB record
* Awaiting for child class implementation
* @see e_model_admin
*/
public function dbReplace()
{
}
/**
* Delete DB data
* Awaiting for child class implementation
* @see e_model_admin
*/
public function dbDelete()
{
}
/**
* Set parameter array
* Core parameters:
* - db_query: string db query to be passed to load() ($sql->db_Select_gen())
* - model_class: e_tree_model class - string class name for creating nodes inside default load() method
*
* @param array $params
* @return e_model
*/
public function setParams(array $params)
{
$this->_params = $params;
return $this;
}
/**
* Get parameter array
*
* @return array parameters
*/
public function getParams()
{
return $this->_params;
}
/**
* Set parameter
*
* @param string $key
* @param mixed $value
* @return e_model
*/
public function setParam($key, $value)
{
$this->_params[$key] = $value;
return $this;
}
/**
* Get parameter
*
* @param string $key
* @param mixed $default
*/
public function getParam($key, $default = null)
{
return (isset($this->_params[$key]) ? $this->_params[$key] : $default);
}
/** /**
* Try to convert string to a number * Try to convert string to a number
* Shoud fix locale related troubles * Shoud fix locale related troubles
@@ -863,6 +986,16 @@ class e_model
{ {
return $this->toString((@func_get_arg(0) === true)); return $this->toString((@func_get_arg(0) === true));
} }
public function destroy()
{
$this->_data = array();
$this->_params = array();
$this->_data_fields = array();
$this->_parsed_keys = array();
$this->_db_table = $this->_field_id = '';
$this->data_has_changed = false;
}
} }
//FIXME - move e_model_admin to e_model_admin.php //FIXME - move e_model_admin to e_model_admin.php
@@ -895,15 +1028,6 @@ class e_model
*/ */
class e_admin_model extends e_model class e_admin_model extends e_model
{ {
/**
* Current model DB table, used in all db calls
*
* This can/should be overwritten by extending the class
*
* @var string
*/
protected $_db_table;
/** /**
* Posted data * Posted data
* Back-end related * Back-end related
@@ -926,7 +1050,7 @@ class e_admin_model extends e_model
* Validation structure - see {@link e_validator::$_required_rules} for * Validation structure - see {@link e_validator::$_required_rules} for
* more information about the array format. * more information about the array format.
* Used in {@link validate()} method. * Used in {@link validate()} method.
* * TODO - check_rules (see e_validator::$_optional_rules)
* This can/should be overwritten by extending the class. * This can/should be overwritten by extending the class.
* *
* @var array * @var array
@@ -945,17 +1069,6 @@ class e_admin_model extends e_model
*/ */
protected $_validator = null; protected $_validator = null;
public function setModelTable($table)
{
$this->_db_table = $table;
return $this;
}
public function getModelTable()
{
return $this->_db_table;
}
/** /**
* @return array * @return array
*/ */
@@ -1449,12 +1562,30 @@ class e_admin_model extends e_model
return ($this->hasValidationError() || $this->hasSqlError()); return ($this->hasValidationError() || $this->hasSqlError());
} }
/**
* Generic load data from DB
* @param boolean $force
* @return e_admin_model
*/
public function load($id, $force = false)
{
parent::load($id, $force);
$this->_db_errno = e107::getDb()->getLastErrorNumber();
if($this->_db_errno)
{
$this->addMessageError('SQL Update Error', $session_messages); //TODO - Lan
$this->addMessageDebug('SQL Error #'.$this->_db_errno.': '.e107::getDb()->getLastErrorText());
}
return $this;
}
/** /**
* Save data to DB * Save data to DB
* *
* @param boolen $from_post * @param boolen $from_post
*/ */
public function save($from_post = true) public function save($from_post = true, $force = false, $session_messages = false)
{ {
if(!$this->getFieldIdName()) if(!$this->getFieldIdName())
{ {
@@ -1469,10 +1600,23 @@ class e_admin_model extends e_model
if($this->getId()) if($this->getId())
{ {
return $this->dbUpdate(); return $this->dbUpdate($force, $session_messages);
} }
return $this->dbInsert(); return $this->dbInsert($force, $session_messages);
}
public function delete($destroy = true, $session_messages = false)
{
$ret = $this->dbDelete();
if($ret)
{
if($destroy)
{
$this->setMessages(true, $session_messages)->destroy();
}
}
return $ret;
} }
/** /**
@@ -1484,7 +1628,7 @@ class e_admin_model extends e_model
public function dbInsert($force = false, $session_messages = false) public function dbInsert($force = false, $session_messages = false)
{ {
$this->_db_errno = 0; $this->_db_errno = 0;
if(!$this->data_has_changed && !$force) if($this->hasError() || (!$this->data_has_changed && !$force))
{ {
return 0; return 0;
} }
@@ -1509,7 +1653,7 @@ class e_admin_model extends e_model
public function dbReplace($force = false, $session_messages = false) public function dbReplace($force = false, $session_messages = false)
{ {
$this->_db_errno = 0; $this->_db_errno = 0;
if(!$this->data_has_changed && !$force) if($this->hasError() || (!$this->data_has_changed && !$force))
{ {
return 0; return 0;
} }
@@ -1537,6 +1681,10 @@ class e_admin_model extends e_model
public function dbUpdate($force = false, $session_messages = false) public function dbUpdate($force = false, $session_messages = false)
{ {
$this->_db_errno = 0; $this->_db_errno = 0;
if($this->hasError() || (!$this->data_has_changed && !$force))
{
return 0;
}
$res = e107::getDb()->db_Update($this->getModelTable(), $this->toSqlQuery('update')); $res = e107::getDb()->db_Update($this->getModelTable(), $this->toSqlQuery('update'));
if(!$res) if(!$res)
{ {
@@ -1560,6 +1708,11 @@ class e_admin_model extends e_model
public function dbDelete($session_messages = false) public function dbDelete($session_messages = false)
{ {
$this->_db_errno = 0; $this->_db_errno = 0;
if($this->hasError())
{
return 0;
}
if(!$this->getId()) if(!$this->getId())
{ {
$this->addMessageError('Record not found', $session_messages); //TODO - Lan $this->addMessageError('Record not found', $session_messages); //TODO - Lan
@@ -1587,20 +1740,33 @@ class e_admin_model extends e_model
*/ */
public function toSqlQuery($force = '') public function toSqlQuery($force = '')
{ {
$fields = array_keys($this->_data_fields);
$qry = array(); $qry = array();
$action = $this->getId() ? 'update' : 'create';
if($force) if($force)
{ {
$action = $force; $action = $force;
} }
else
foreach ($fields as $key => $value)
{ {
$action = $this->getId() ? 'update' : 'create';
}
$qry['_FIELD_TYPES'] = $this->_FIELD_TYPES; //DB field types are optional
$qry['data'][$this->getFieldIdName()] = $this->getId();
$qry['_FIELD_TYPES'][$this->getFieldIdName()] = 'int';
foreach ($this->_data_fields as $key => $type)
{
if($key == $this->getFieldIdName())
{
continue;
}
if(!isset($qry['_FIELD_TYPES'][$key]))
{
$qry['_FIELD_TYPES'][$key] = $type; //_FIELD_TYPES much more optional now...
}
$qry['data'][$key] = $this->getData($key); $qry['data'][$key] = $this->getData($key);
} }
$qry['_FIELD_TYPES'] = $this->_FIELD_TYPES;
switch($action) switch($action)
{ {
@@ -1690,6 +1856,17 @@ class e_admin_model extends e_model
return null; return null;
} }
public function destroy()
{
parent::destroy();
$this->_validator = null;
$this->_validation_rules = array();
$this->_db_errno = null;
$this->_posted_data = array();
$this->data_has_changed = array();
$this->_FIELD_TYPES = array();
}
} }
/** /**
@@ -1697,11 +1874,6 @@ class e_admin_model extends e_model
*/ */
class e_tree_model extends e_model class e_tree_model extends e_model
{ {
/**
* @var array
*/
protected $_params = array();
/** /**
* Current model DB table, used in all db calls * Current model DB table, used in all db calls
* This can/should be overwritten by extending the class * This can/should be overwritten by extending the class
@@ -1717,6 +1889,18 @@ class e_tree_model extends e_model
*/ */
protected $_total = 0; protected $_total = 0;
/**
* Constructor
*
*/
function __construct($tree_data = array())
{
if($tree_data)
{
$this->setTree($tree_data);
}
}
public function getTotal() public function getTotal()
{ {
return $this->_total; return $this->_total;
@@ -1748,18 +1932,6 @@ class e_tree_model extends e_model
return $this->_db_table; return $this->_db_table;
} }
/**
* Constructor
*
*/
function __construct($tree_data = array())
{
if($tree_data)
{
$this->setTree($tree_data);
}
}
/** /**
* Set array of models * Set array of models
* @return array * @return array
@@ -1788,8 +1960,14 @@ class e_tree_model extends e_model
* *
* @return e_tree_model * @return e_tree_model
*/ */
public function load() public function load($force = false)
{ {
if(!$this->isEmpty() && !$force)
{
return $this;
}
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();
@@ -1797,11 +1975,18 @@ class e_tree_model extends e_model
if($sql->db_Select_gen($this->getParam('db_query'))) if($sql->db_Select_gen($this->getParam('db_query')))
{ {
$this->_total = $sql->total_results; //requires SQL_CALC_FOUND_ROWS in query - see db handler $this->_total = $sql->total_results; //requires SQL_CALC_FOUND_ROWS in query - see db handler
while($tmp = $sql->db_Fetch()) while($tmp = $sql->db_Fetch())
{ {
$tmp = new $class_name($tmp); $tmp = new $class_name($tmp);
$this->setNode($tmp->getId(), $tmp); $this->setNode($tmp->get($this->getFieldIdName()), $tmp);
} }
if(!$this->_total && $this->getModelTable())
{
//SQL_CALC_FOUND_ROWS not found in the query, do one more query
$this->_total = e107::getDb()->db_Count($this->getModelTable());
}
unset($tmp); unset($tmp);
} }
} }
@@ -1866,57 +2051,7 @@ class e_tree_model extends e_model
*/ */
function isEmpty() function isEmpty()
{ {
return $this->has('__tree'); return (!$this->has('__tree'));
}
/**
* Set parameter array
* Core parameters:
* - db_query: string db query to be passed to $sql->db_Select_gen();
* - model_class: string class name for creating nodes inside default load() method
*
* @param array $params
* @return e_tree_model
*/
public function setParams(array $params)
{
$this->_params = $params;
return $this;
}
/**
* Get parameter array
*
* @return array parameters
*/
public function getParams()
{
return $this->_params;
}
/**
* Set parameter
*
* @param string $key
* @param mixed $value
* @return e_tree_model
*/
public function setParam($key, $value)
{
$this->_params[$key] = $value;
return $this;
}
/**
* Get parameter
*
* @param string $key
* @param mixed $default
*/
public function getParam($key, $default = null)
{
return (isset($this->_params[$key]) ? $this->_params[$key] : $default);
} }
} }
@@ -1931,11 +2066,11 @@ class e_admin_tree_model extends e_tree_model
*/ */
public function delete($ids, $destroy = true, $session_messages = false) public function delete($ids, $destroy = true, $session_messages = false)
{ {
if(is_string($ids)) if(!$ids) return $this;
if(is_array($ids))
{ {
$ids = explode(',', $ids); $ids = implode(',', $ids);
} }
$ids = e107::getParser()->toDB($ids); $ids = e107::getParser()->toDB($ids);
$sql = e107::getDb(); $sql = e107::getDb();
$res = $sql->db_Delete($this->getModelTable(), $this->getFieldIdName().' IN ('.$ids.')'); $res = $sql->db_Delete($this->getModelTable(), $this->getFieldIdName().' IN ('.$ids.')');
@@ -1949,12 +2084,21 @@ class e_admin_tree_model extends e_tree_model
} }
elseif($destroy) elseif($destroy)
{ {
if(is_string($ids))
{
$ids = explode(',', $ids);
}
foreach ($ids as $id) foreach ($ids as $id)
{ {
call_user_func(array($this->getNode($id), 'destroy')); // first call model destroy method if any if($this->getNode($id))
{
$this->getNode($id)->setMessages(true, $session_messages);
call_user_func(array($this->getNode(trim($id)), 'destroy')); // first call model destroy method if any
$this->setNode($id, null); $this->setNode($id, null);
} }
} }
}
return $res; return $res;
} }

View File

@@ -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.12 $ * $Revision: 1.13 $
* $Date: 2009-10-20 16:05:02 $ * $Date: 2009-10-30 17:59:31 $
* $Author: secretr $ * $Author: secretr $
* *
*/ */
@@ -218,7 +218,7 @@ class e_validator
*/ */
public function setMessageStack($mstack) public function setMessageStack($mstack)
{ {
if($mstack) $mstack = 'validator'; if(!$mstack) $mstack = 'validator';
$this->_message_stack = $mstack; $this->_message_stack = $mstack;
return $this; return $this;
} }

View File

@@ -9,8 +9,8 @@
* e107 Release Plugin * e107 Release Plugin
* *
* $Source: /cvs_backup/e107_0.8/e107_plugins/release/admin_config.php,v $ * $Source: /cvs_backup/e107_0.8/e107_plugins/release/admin_config.php,v $
* $Revision: 1.10 $ * $Revision: 1.11 $
* $Date: 2009-10-28 17:05:35 $ * $Date: 2009-10-30 17:59:32 $
* $Author: secretr $ * $Author: secretr $
* *
*/ */
@@ -65,28 +65,31 @@ class plugin_release_admin_controller_main extends e_admin_controller_main
// optional // optional
protected $perPage = 20; protected $perPage = 20;
// default - true
protected $batchDelete = true;
//TODO change the release_url type back to URL before release. //TODO change the release_url type back to URL before release.
// required // required
protected $fields = array( protected $fields = array(
'checkboxes' => array('title'=> '', 'type' => '', 'width'=>'5%', 'thclass' =>'center', 'forced'=> TRUE, 'class'=>'center'), 'checkboxes' => array('title'=> '', 'type' => null, 'data' => null, 'width'=>'5%', 'thclass' =>'center', 'forced'=> TRUE, 'class'=>'center', 'toggle' => 'e-multiselect'),
'release_id' => array('title'=> ID, 'type' => '', 'width'=>'5%', 'thclass' => '', 'forced'=> TRUE, 'primary'=>TRUE), 'release_id' => array('title'=> ID, 'type' => 'int', 'data' => 'int', 'width'=>'5%', 'thclass' => '', 'forced'=> TRUE, 'primary'=>TRUE/*, 'noedit'=>TRUE*/), //Primary ID is note editable
'release_type' => array('title'=> 'Type', 'type' => 'method', 'width'=>'auto', 'thclass' => '', 'batch' => TRUE, 'filter'=>TRUE), 'release_type' => array('title'=> 'Type', 'type' => 'method', 'data' => 'str', 'width'=>'auto', 'thclass' => '', 'batch' => TRUE, 'filter'=>TRUE),
'release_folder' => array('title'=> 'Folder', 'type' => 'text', 'width' => 'auto', 'thclass' => ''), 'release_folder' => array('title'=> 'Folder', 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'thclass' => ''),
'release_name' => array('title'=> 'Name', 'type' => 'text', 'width' => 'auto', 'thclass' => ''), 'release_name' => array('title'=> 'Name', 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'thclass' => ''),
'release_version' => array('title'=> 'Version', 'type' => 'text', 'width' => 'auto', 'thclass' => ''), 'release_version' => array('title'=> 'Version', 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'thclass' => ''),
'release_author' => array('title'=> LAN_AUTHOR, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left'), 'release_author' => array('title'=> LAN_AUTHOR, 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'thclass' => 'left'),
'release_authorURL' => array('title'=> LAN_AUTHOR_URL, 'type' => 'url', 'width' => 'auto', 'thclass' => 'left'), 'release_authorURL' => array('title'=> LAN_AUTHOR_URL, 'type' => 'url', 'data' => 'str', 'width' => 'auto', 'thclass' => 'left'),
'release_date' => array('title'=> LAN_DATE, 'type' => 'text', 'width' => 'auto', 'thclass' => ''), 'release_date' => array('title'=> LAN_DATE, 'type' => 'datestamp', 'data' => 'int', 'width' => 'auto', 'thclass' => ''),
'release_compatibility' => array('title'=> 'compatib', 'type' => 'text', 'width' => '10%', 'thclass' => 'center' ), 'release_compatibility' => array('title'=> 'compatib', 'type' => 'text', 'data' => 'str', 'width' => '10%', 'thclass' => 'center' ),
'release_url' => array('title'=> 'Userclass', 'type' => 'userclass', 'width' => '10%', 'thclass' => 'center', 'batch' => TRUE, 'filter'=>TRUE), 'release_url' => array('title'=> 'release_url', 'type' => 'url', 'data' => 'str', 'width' => '20%', 'thclass' => 'center', 'batch' => TRUE, 'filter'=>TRUE, 'parms' => 'truncate=30', 'validate' => true, 'help' => 'Enter release URL here', 'error' => 'please, ener valid URL'),
'options' => array('title'=> LAN_OPTIONS, 'type' => '', 'width' => '10%', 'thclass' => 'center last', 'class' => 'center last', 'forced'=>TRUE) 'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'data' => null, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center last', 'forced'=>TRUE)
); );
//required - default column user prefs //required - default column user prefs
protected $fieldpref = array('checkboxes', 'release_id', 'release_type', 'release_compatibility', 'options'); protected $fieldpref = array('checkboxes', 'release_id', 'release_type', 'release_url', 'release_compatibility', 'options');
// required if no custom model is set in init() // optional if fields 'data' attribute is set or if custom model is set in init()
protected $dataFields = array( /*protected $dataFields = array(
'release_id' => 'int', 'release_id' => 'int',
'release_type' => 'str', 'release_type' => 'str',
'release_folder' => 'str', 'release_folder' => 'str',
@@ -97,10 +100,12 @@ class plugin_release_admin_controller_main extends e_admin_controller_main
'release_date' => 'int', 'release_date' => 'int',
'release_compatibility' => 'str', 'release_compatibility' => 'str',
'release_url' => 'str', 'release_url' => 'str',
); );*/
// optional // optional, could be also set directly from $fields array with attributes 'validate' => true|'rule_name', 'rule' => 'condition_name', 'error' => 'Validation Error message'
protected $validationRules = array(); /*protected $validationRules = array(
'release_url' => array('required', '', 'Release URL', 'Help text', 'not valid error message')
);*/
// optional // optional
protected $prefs = array( //TODO add option for core or plugin pref. protected $prefs = array( //TODO add option for core or plugin pref.
@@ -110,10 +115,10 @@ class plugin_release_admin_controller_main extends e_admin_controller_main
'pref_name' => array('title'=> 'name', 'type' => 'text') 'pref_name' => array('title'=> 'name', 'type' => 'text')
); );
// required if no custom model is set in init() // required if no custom tree model is set in init()
protected $listQry = "SELECT * FROM #release"; // without any Order or Limit. protected $listQry = "SELECT * FROM #release"; // without any Order or Limit.
// required if no custom model is set in init() // optional - required only in case of e.g. tables JOIN. This also could be done with custom model (set it in init())
protected $editQry = "SELECT * FROM #release WHERE release_id = {ID}"; protected $editQry = "SELECT * FROM #release WHERE release_id = {ID}";
// optional // optional
@@ -122,6 +127,37 @@ class plugin_release_admin_controller_main extends e_admin_controller_main
} }
} }
class plugin_release_admin_ui_main extends e_admin_ui
{
function release_type($curVal,$mode) // not really necessary since we can use 'dropdown' - but just an example of a custom function.
{
if($mode == 'list')
{
return $curVal.' (custom!)';
}
if($mode == 'batch') // Custom Batch List for release_type
{
return array('theme'=>"Theme","plugin"=>'Plugin');
}
if($mode == 'filter') // Custom Filter List for release_type
{
return array('theme'=>"Theme","plugin"=>'Plugin');
}
$types = array("theme","plugin");
$text = "<select class='tbox' name='release_type' >";
foreach($types as $val)
{
$selected = ($curVal == $val) ? "selected='selected'" : "";
$text .= "<option value='{$val}' {$selected}>".$val."</option>\n";
}
$text .= "</select>";
return $text;
}
}
$dispatcher = new plugin_release_admin_dispatcher(); $dispatcher = new plugin_release_admin_dispatcher();
$dispatcher->runObservers(true); $dispatcher->runObservers(true);
e107::setRegistry('admin/release_dispatcher', $dispatcher); e107::setRegistry('admin/release_dispatcher', $dispatcher);

View File

@@ -6,7 +6,7 @@ CREATE TABLE release (
`release_version` varchar(5) NOT NULL, `release_version` varchar(5) NOT NULL,
`release_author` varchar(50) NOT NULL, `release_author` varchar(50) NOT NULL,
`release_authorURL` varchar(255) NOT NULL, `release_authorURL` varchar(255) NOT NULL,
`release_date` date NOT NULL, `release_date` int(10) NOT NULL,
`release_compatibility` varchar(5) NOT NULL, `release_compatibility` varchar(5) NOT NULL,
`release_url` varchar(255) NOT NULL, `release_url` varchar(255) NOT NULL,
PRIMARY KEY (`release_id`) PRIMARY KEY (`release_id`)