mirror of
https://github.com/e107inc/e107.git
synced 2025-01-29 10:38:08 +01:00
Admin tools - more work
This commit is contained in:
parent
f7d22f782b
commit
7f15da0b74
@ -9,9 +9,9 @@
|
||||
* News Administration
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_admin/newspost.php,v $
|
||||
* $Revision: 1.61 $
|
||||
* $Date: 2009-10-26 07:26:47 $
|
||||
* $Author: e107coders $
|
||||
* $Revision: 1.62 $
|
||||
* $Date: 2009-10-30 17:59:32 $
|
||||
* $Author: secretr $
|
||||
*/
|
||||
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_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),
|
||||
'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),
|
||||
'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),
|
||||
@ -1143,7 +1143,7 @@ class admin_newspost
|
||||
}
|
||||
|
||||
// AUTO RENDER
|
||||
$text .= $frm->trow($this, $row);
|
||||
$text .= $frm->trow($this->fields, $this->fieldpref, $row, 'news_id');
|
||||
}
|
||||
|
||||
$text .= "
|
||||
@ -1207,7 +1207,7 @@ class admin_newspost
|
||||
'comments' => array('Modify Comments', $comments_array),
|
||||
'__check_class' => array('category' => $news_manage)
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'userclass' => array('Assign Visibility...',$classes),
|
||||
)
|
||||
);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,18 @@
|
||||
<?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
|
||||
* Distributed as part of "The Coolest DHTML Calendar"
|
||||
@ -9,38 +23,37 @@
|
||||
* calendar by instantiating and calling a PHP object.
|
||||
*/
|
||||
|
||||
define('NEWLINE', "\n");
|
||||
|
||||
class DHTML_Calendar
|
||||
{
|
||||
var $calendar_file;
|
||||
var $calendar_lang_file;
|
||||
var $calendar_setup_file;
|
||||
var $calendar_theme_file;
|
||||
var $calendar_options;
|
||||
var $calendar_img;
|
||||
public static $NEWLINE = "\n";
|
||||
public $calendar_file;
|
||||
public $calendar_lang_file;
|
||||
public $calendar_setup_file;
|
||||
public $calendar_theme_file;
|
||||
public $calendar_options;
|
||||
public $calendar_img;
|
||||
|
||||
function DHTML_Calendar($stripped = true)
|
||||
{
|
||||
if ($stripped)
|
||||
{
|
||||
$this->calendar_file = e_HANDLER.'calendar/calendar_stripped.js';
|
||||
$this->calendar_setup_file = e_HANDLER.'calendar/calendar-setup_stripped.js';
|
||||
$this->calendar_file = e_HANDLER_ABS.'calendar/calendar_stripped.js';
|
||||
$this->calendar_setup_file = e_HANDLER_ABS.'calendar/calendar-setup_stripped.js';
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->calendar_file = e_HANDLER.'calendar/calendar.js';
|
||||
$this->calendar_setup_file = e_HANDLER.'calendar/calendar-setup.js';
|
||||
$this->calendar_file = e_HANDLER_ABS.'calendar/calendar.js';
|
||||
$this->calendar_setup_file = e_HANDLER_ABS.'calendar/calendar-setup.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
|
||||
{
|
||||
$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'))
|
||||
@ -49,16 +62,16 @@ class DHTML_Calendar
|
||||
}
|
||||
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"))
|
||||
{
|
||||
$this->calendar_theme_file = THEME."calendar.css";
|
||||
$this->calendar_theme_file = THEME_ABS."calendar.css";
|
||||
}
|
||||
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');
|
||||
@ -73,16 +86,16 @@ class DHTML_Calendar
|
||||
}
|
||||
|
||||
function get_load_files_code() {
|
||||
$code = ( '<link rel="stylesheet" type="text/css" media="all" href="' . $this->calendar_theme_file . '" />' . NEWLINE );
|
||||
$code .= ( '<script type="text/javascript" src="'.$this->calendar_file.'"></script>' . NEWLINE );
|
||||
$code .= ( '<script type="text/javascript" src="'.$this->calendar_setup_file.'"></script>' . NEWLINE );
|
||||
$code .= ( '<script type="text/javascript" src="'.$this->calendar_lang_file.'"></script>' . 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>' . self::$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>' . self::$NEWLINE );
|
||||
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));
|
||||
$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;
|
||||
}
|
||||
|
||||
@ -90,11 +103,11 @@ class DHTML_Calendar
|
||||
{
|
||||
$ret = "";
|
||||
$id = $this->_gen_id();
|
||||
$attrstr = $this->_make_html_attr(array_merge($field_attributes, array('id' => $this->_field_id($id), 'type' => 'text')));
|
||||
$attrstr = $this->_make_html_attr(array_merge($field_attributes, array('id' => $this->_field_id($id), 'type' => 'text')));
|
||||
$ret .= '<input ' . $attrstr .'/> ';
|
||||
$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)));
|
||||
$ret .= $this->_make_calendar($options);
|
||||
e107::getJs()->footerInline($this->_make_calendar($options, false)); //FIXME - get_load_files_code() to use JS Manager
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
@ -1,21 +1,16 @@
|
||||
<?php
|
||||
/*
|
||||
+ ----------------------------------------------------------------------------+
|
||||
| e107 website system
|
||||
|
|
||||
| ©Steve Dunstan 2001-2002
|
||||
| http://e107.org
|
||||
| jalist@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/date_handler.php,v $
|
||||
| $Revision: 1.8 $
|
||||
| $Date: 2009-10-23 13:06:21 $
|
||||
| $Author: secretr $
|
||||
|
|
||||
+----------------------------------------------------------------------------+
|
||||
* 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/date_handler.php,v $
|
||||
* $Revision: 1.9 $
|
||||
* $Date: 2009-10-30 17:59:32 $
|
||||
* $Author: secretr $
|
||||
*
|
||||
*/
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
@ -48,6 +43,10 @@ class convert
|
||||
$mask = e107::getPref('shortdate');
|
||||
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
|
||||
default:
|
||||
//BC - old 'forum' call
|
||||
@ -61,6 +60,12 @@ class convert
|
||||
$datestamp += TIMEOFFSET;
|
||||
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')
|
||||
{ /*
|
||||
|
@ -9,9 +9,9 @@
|
||||
* e107 Main
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/e107_class.php,v $
|
||||
* $Revision: 1.60 $
|
||||
* $Date: 2009-10-28 14:13:44 $
|
||||
* $Author: marj_nl_fr $
|
||||
* $Revision: 1.61 $
|
||||
* $Date: 2009-10-30 17:59:31 $
|
||||
* $Author: secretr $
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
@ -114,7 +114,6 @@ class e107
|
||||
'e_news_tree' => '{e_HANDLER}news_class.php',
|
||||
'news' => '{e_HANDLER}news_class.php',
|
||||
'e_form' => '{e_HANDLER}form_handler.php',
|
||||
//'e_fieldset' => '{e_HANDLER}form_handler.php',
|
||||
'e_upgrade' => '{e_HANDLER}e_upgrade_class.php',
|
||||
'e_jshelper' => '{e_HANDLER}js_helper.php',
|
||||
'e_menu' => '{e_HANDLER}menu_class.php',
|
||||
@ -126,6 +125,7 @@ class e107
|
||||
'themeHandler' => '{e_HANDLER}theme_handler.php',
|
||||
'e_model' => '{e_HANDLER}model_class.php',
|
||||
'e_admin_model' => '{e_HANDLER}model_class.php',
|
||||
'DHTML_Calendar'=> '{e_HANDLER}calendar/calendar_class.php',
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -9,8 +9,8 @@
|
||||
* Form Handler
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/form_handler.php,v $
|
||||
* $Revision: 1.60 $
|
||||
* $Date: 2009-10-28 17:05:34 $
|
||||
* $Revision: 1.61 $
|
||||
* $Date: 2009-10-30 17:59:30 $
|
||||
* $Author: secretr $
|
||||
*
|
||||
*/
|
||||
@ -99,7 +99,7 @@ class e_form
|
||||
// The button itself could be replaced with an icon just for this purpose.
|
||||
|
||||
|
||||
$e107 = &e107::getInstance();
|
||||
$e107 = e107::getInstance();
|
||||
$id = $this->name2id($name);
|
||||
$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')";
|
||||
@ -116,35 +116,64 @@ class e_form
|
||||
|
||||
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]";
|
||||
|
||||
/**
|
||||
* Date field with popup calendar
|
||||
* @param name => string - the name of the field
|
||||
* @param datestamp => UNIX timestamp - default value of the field
|
||||
**/
|
||||
function datepicker($name, $datestamp=false)
|
||||
{
|
||||
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_options['showsTime'] = false;
|
||||
$cal_options['showOthers'] = false;
|
||||
$cal_options['weekNumbers'] = false;
|
||||
//TODO use $prefs values for format?
|
||||
$cal_options['ifFormat'] = $pref['inputdate'];
|
||||
$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
|
||||
* @param string $name the name of the field
|
||||
* @param integer $datestamp UNIX timestamp - default value of the field
|
||||
* @param array $options calendar options
|
||||
*/
|
||||
function datepicker($name, $datestamp = false, $options = array())
|
||||
{
|
||||
$cal = new DHTML_Calendar(true);
|
||||
$cal_options['showsTime'] = varset($options['time'], true);
|
||||
$cal_options['showOthers'] = varset($options['others'], false);
|
||||
$cal_options['weekNumbers'] = varset($options['weeks'], false);
|
||||
$cal_options['ifFormat'] = e107::getPref('inputdate', '%d/%m/%Y %H:%M:%S');
|
||||
$cal_options['timeFormat'] = "24";
|
||||
$cal_attrib['class'] = "tbox";
|
||||
$cal_attrib['size'] = "12";
|
||||
$cal_attrib['class'] = "tbox date";
|
||||
$cal_attrib['size'] = varset($options['size'], 25);
|
||||
$cal_attrib['name'] = $name;
|
||||
if ($datestamp)
|
||||
{
|
||||
//TODO use $prefs values for format?
|
||||
$cal_attrib['value'] = date("d/m/Y H:i:s", $datestamp);
|
||||
$cal_attrib['value'] = date("d/m/Y", $datestamp);
|
||||
$cal_attrib['value'] = e107::getDateConvert()->convert_date($datestamp, 'input'); //date("d/m/Y H:i:s", $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);
|
||||
}
|
||||
}
|
||||
|
||||
function user($name, $default_id, $options = array())
|
||||
{
|
||||
return 'User auto-complete search - under development';
|
||||
}
|
||||
|
||||
function file($name, $options = array())
|
||||
{
|
||||
@ -833,38 +862,59 @@ class e_form
|
||||
}
|
||||
|
||||
$tdclass = vartrue($data['class']);
|
||||
if($tdclass)
|
||||
{
|
||||
$tdclass = ' class="'.$tdclass.'"';
|
||||
}
|
||||
|
||||
$value = $fieldvalues[$field];
|
||||
|
||||
|
||||
$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']);
|
||||
$parms = $data['colparms'];
|
||||
if(!is_array($data['parms'])) parse_str($data['parms'], $data['parms']);
|
||||
$parms = $data['parms'];
|
||||
}
|
||||
|
||||
switch($field) // special fields
|
||||
{
|
||||
case 'options':
|
||||
$value = "<input type='image' class='action edit' name='edit[{$fieldvalues[$pid]}]' src='".ADMIN_EDIT_ICON_PATH."' title='".LAN_EDIT."' />";
|
||||
$value .= "<input type='image' class='action delete' name='delete[{$fieldvalues[$pid]}]' src='".ADMIN_DELETE_ICON_PATH."' title='".LAN_DELETE." [ ID: {$fieldvalues[$pid]} ]' />";
|
||||
if(!$value)
|
||||
{
|
||||
parse_str(str_replace('&', '&', 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> ";
|
||||
$value .= $this->submit_image('delete['.$fieldvalues[$pid].']', $fieldvalues[$pid], 'delete', LAN_DELETE.' [ ID: '.$fieldvalues[$pid].' ]');
|
||||
}
|
||||
$data['type'] = 'text';
|
||||
break;
|
||||
|
||||
case 'checkboxes':
|
||||
$value = $this->checkbox(vartrue($data['toggle'], 'multiselect').'['.$fieldvalues[$pid].']', $fieldvalues[$pid]);
|
||||
$data['type'] = 'text';
|
||||
$tdclass = $tdclass ? $tdclass.' autocheck e-pointer' : 'autocheck e-pointer';
|
||||
break;
|
||||
}
|
||||
|
||||
switch($data['type'])
|
||||
{
|
||||
case 'text':
|
||||
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...
|
||||
//same
|
||||
break;
|
||||
@ -891,6 +941,10 @@ class e_form
|
||||
{
|
||||
$value = 'not found';
|
||||
}
|
||||
if(vartrue($parms['truncate']))
|
||||
{
|
||||
$value = e107::getParser()->text_truncate($value, $parms['truncate'], '...');
|
||||
}
|
||||
break;
|
||||
|
||||
case 'boolean':
|
||||
@ -898,12 +952,17 @@ class e_form
|
||||
break;
|
||||
|
||||
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;
|
||||
|
||||
case 'method': // Custom Function
|
||||
$meth = $field;
|
||||
$value = $obj->$meth($value,$obj->mode);
|
||||
$method = $field;
|
||||
$value = call_user_func_array(array($this, $method), array($value, 'list'));
|
||||
break;
|
||||
|
||||
//TODO - form_userclass, order,... and maybe more types
|
||||
@ -912,17 +971,11 @@ class e_form
|
||||
continue; //unknown type
|
||||
break;
|
||||
}
|
||||
|
||||
//TODO - this should be done per type!
|
||||
if(vartrue($parms['truncate']))
|
||||
|
||||
if($tdclass)
|
||||
{
|
||||
$value = e107::getParser()->text_truncate($value, $parms['truncate'], '...');
|
||||
$tdclass = ' class="'.$tdclass.'"';
|
||||
}
|
||||
elseif(vartrue($parms['htmltruncate']))
|
||||
{
|
||||
$value = e107::getParser()->html_truncate($value, $parms['htmltruncate'], '...');
|
||||
}
|
||||
|
||||
$ret .= '
|
||||
<td'.$tdclass.'>
|
||||
'.$value.'
|
||||
@ -940,74 +993,75 @@ class e_form
|
||||
'.$ret.'
|
||||
</tr>
|
||||
';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
// The 2 functions below are for demonstration purposes only, and may be moved/modified before release.
|
||||
function filterType($fieldarray)
|
||||
return '';
|
||||
}
|
||||
|
||||
// The 2 functions below are for demonstration purposes only, and may be moved/modified before release.
|
||||
function filterType($fieldarray)
|
||||
{
|
||||
return " frm-> filterType() is Deprecated ";
|
||||
define("e_AJAX_REQUEST", TRUE);
|
||||
$text = "<select name='search_filter[]' style='margin:2px' onchange='UpdateForm(this.options[selectedIndex].value)'>";
|
||||
foreach ($fieldarray as $key=>$val)
|
||||
{
|
||||
return " frm-> filterType() is Deprecated ";
|
||||
define("e_AJAX_REQUEST", TRUE);
|
||||
$text = "<select name='search_filter[]' style='margin:2px' onchange='UpdateForm(this.options[selectedIndex].value)'>";
|
||||
foreach ($fieldarray as $key=>$val)
|
||||
$text .= varset($val['type']) ? "<option value='$key'>".$val['title']."</option>\n" : "";
|
||||
|
||||
}
|
||||
$text .= "</select>";
|
||||
return $text;
|
||||
}
|
||||
|
||||
function filterValue($type = '', $fields = '')
|
||||
{
|
||||
return " frm-> filterValue() is Deprecated. ";
|
||||
|
||||
if($type)
|
||||
{
|
||||
|
||||
switch($fields[$type]['type'])
|
||||
{
|
||||
$text .= varset($val['type']) ? "<option value='$key'>".$val['title']."</option>\n" : "";
|
||||
case "datestamp":
|
||||
return "[date field]";
|
||||
break;
|
||||
|
||||
}
|
||||
$text .= "</select>";
|
||||
return $text;
|
||||
}
|
||||
|
||||
function filterValue($type = '', $fields = '')
|
||||
{
|
||||
return " frm-> filterValue() is Deprecated. ";
|
||||
|
||||
if($type)
|
||||
{
|
||||
|
||||
switch($fields[$type]['type'])
|
||||
{
|
||||
case "datestamp":
|
||||
return "[date field]";
|
||||
break;
|
||||
|
||||
case "boolean":
|
||||
|
||||
return "<select name='searchquery'><option value='1'>".LAN_YES."</option>\n
|
||||
<option value='0'>".LAN_NO."</option>
|
||||
</select>";
|
||||
break;
|
||||
|
||||
case "user":
|
||||
return "<select name='searchquery'><option value='1'>User One</option><option value='2'>User Two</option></select>";
|
||||
break;
|
||||
case "boolean":
|
||||
|
||||
return "<select name='searchquery'><option value='1'>".LAN_YES."</option>\n
|
||||
<option value='0'>".LAN_NO."</option>
|
||||
</select>";
|
||||
break;
|
||||
|
||||
case "user":
|
||||
return "<select name='searchquery'><option value='1'>User One</option><option value='2'>User Two</option></select>";
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
|
||||
return $this->text('searchquery', '', 50);
|
||||
|
||||
default:
|
||||
|
||||
return $this->text('searchquery', '', 50);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->text('searchquery', '', 50);
|
||||
}
|
||||
// This needs to be dynamic for the various form types, and be loaded via ajax.
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a batch options select component
|
||||
* This component is generally associated with a table of items where one or more rows in the table can be selected (using checkboxes).
|
||||
* The list options determine some processing that wil lbe applied to all checked rows when the form is submitted.
|
||||
*
|
||||
* @param array $options associative array of option elements, keyed on the option value
|
||||
* @param array ucOptions [optional] associative array of userclass option groups to display, keyed on the option value prefix
|
||||
* @return string the HTML for the form component
|
||||
*/
|
||||
function batchoptions($options, $ucOptions = null)
|
||||
else
|
||||
{
|
||||
return $this->text('searchquery', '', 50);
|
||||
}
|
||||
// This needs to be dynamic for the various form types, and be loaded via ajax.
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a batch options select component
|
||||
* This component is generally associated with a table of items where one or more rows in the table can be selected (using checkboxes).
|
||||
* The list options determine some processing that wil lbe applied to all checked rows when the form is submitted.
|
||||
*
|
||||
* @param array $options associative array of option elements, keyed on the option value
|
||||
* @param array ucOptions [optional] associative array of userclass option groups to display, keyed on the option value prefix
|
||||
* @return string the HTML for the form component
|
||||
*/
|
||||
function batchoptions($options, $ucOptions = null)
|
||||
{
|
||||
$text = "
|
||||
<div class='f-left'>
|
||||
<img src='".e_IMAGE_ABS."generic/branchbottom.gif' alt='' class='icon action' />
|
||||
@ -1076,7 +1130,7 @@ class e_form
|
||||
$text .= "
|
||||
".$this->select_close()."
|
||||
".$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;
|
||||
|
@ -7,8 +7,8 @@
|
||||
* GNU General Public License (http://gnu.org).
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/js_manager.php,v $
|
||||
* $Revision: 1.5 $
|
||||
* $Date: 2009-10-07 11:05:55 $
|
||||
* $Revision: 1.6 $
|
||||
* $Date: 2009-10-30 17:59:32 $
|
||||
* $Author: secretr $
|
||||
*
|
||||
*/
|
||||
@ -52,6 +52,20 @@ class e_jsmanager
|
||||
*/
|
||||
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
|
||||
*
|
||||
@ -292,7 +306,7 @@ class e_jsmanager
|
||||
* @param integer $zone 1-5 (see header.php)
|
||||
* @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);
|
||||
return $this;
|
||||
|
@ -9,8 +9,8 @@
|
||||
* Message Handler
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/message_handler.php,v $
|
||||
* $Revision: 1.22 $
|
||||
* $Date: 2009-10-22 14:18:18 $
|
||||
* $Revision: 1.23 $
|
||||
* $Date: 2009-10-30 17:59:32 $
|
||||
* $Author: secretr $
|
||||
*
|
||||
*/
|
||||
@ -511,20 +511,22 @@ class eMessage
|
||||
*/
|
||||
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)
|
||||
{
|
||||
if($type && $type !== $_type)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(isset($stacks[$from_stack]))
|
||||
{
|
||||
if(!isset($this->_sysmsg[$_type][$to_stack]))
|
||||
{
|
||||
$this->_sysmsg[$_type][$to_stack] = array();
|
||||
}
|
||||
array_merge($this->_sysmsg[$_type][$from_stack], $this->_sysmsg[$_type][$to_stack]);
|
||||
unset($this->_sysmsg[$_type][$to_stack]);
|
||||
$this->_sysmsg[$_type][$to_stack] = array_merge($this->_sysmsg[$_type][$to_stack], $this->_sysmsg[$_type][$from_stack]);
|
||||
unset($this->_sysmsg[$_type][$from_stack]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -544,6 +546,7 @@ class eMessage
|
||||
*/
|
||||
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)
|
||||
{
|
||||
if($type && $type !== $_type)
|
||||
@ -554,10 +557,10 @@ class eMessage
|
||||
{
|
||||
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]);
|
||||
unset($_SESSION[$this->_session_id][$_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][$from_stack]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,8 +9,8 @@
|
||||
* e107 Base Model
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/model_class.php,v $
|
||||
* $Revision: 1.26 $
|
||||
* $Date: 2009-10-28 17:05:34 $
|
||||
* $Revision: 1.27 $
|
||||
* $Date: 2009-10-30 17:59:31 $
|
||||
* $Author: secretr $
|
||||
*/
|
||||
|
||||
@ -44,6 +44,15 @@ class e_model
|
||||
* @var 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
|
||||
@ -74,8 +83,14 @@ class e_model
|
||||
* @var string
|
||||
*/
|
||||
protected $_message_stack = 'default';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Model parameters passed mostly from external sources
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_params = array();
|
||||
|
||||
/**
|
||||
* Constructor - set data on initialization
|
||||
*
|
||||
@ -86,6 +101,27 @@ class e_model
|
||||
$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
|
||||
* @return array
|
||||
@ -427,7 +463,7 @@ class e_model
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->$data_src = $key;
|
||||
$this->${data_src} = $key;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -765,13 +801,33 @@ class e_model
|
||||
}
|
||||
|
||||
/**
|
||||
* Load data from DB
|
||||
* Awaiting for child class implementation
|
||||
*
|
||||
* Generic load data from DB
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save data to DB
|
||||
@ -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
|
||||
* Shoud fix locale related troubles
|
||||
@ -863,6 +986,16 @@ class e_model
|
||||
{
|
||||
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
|
||||
@ -895,15 +1028,6 @@ class 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
|
||||
* Back-end related
|
||||
@ -926,7 +1050,7 @@ class e_admin_model extends e_model
|
||||
* Validation structure - see {@link e_validator::$_required_rules} for
|
||||
* more information about the array format.
|
||||
* Used in {@link validate()} method.
|
||||
*
|
||||
* TODO - check_rules (see e_validator::$_optional_rules)
|
||||
* This can/should be overwritten by extending the class.
|
||||
*
|
||||
* @var array
|
||||
@ -945,17 +1069,6 @@ class e_admin_model extends e_model
|
||||
*/
|
||||
protected $_validator = null;
|
||||
|
||||
public function setModelTable($table)
|
||||
{
|
||||
$this->_db_table = $table;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getModelTable()
|
||||
{
|
||||
return $this->_db_table;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
@ -1449,12 +1562,30 @@ class e_admin_model extends e_model
|
||||
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
|
||||
*
|
||||
* @param boolen $from_post
|
||||
*/
|
||||
public function save($from_post = true)
|
||||
public function save($from_post = true, $force = false, $session_messages = false)
|
||||
{
|
||||
if(!$this->getFieldIdName())
|
||||
{
|
||||
@ -1469,11 +1600,24 @@ class e_admin_model extends e_model
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert data to DB
|
||||
@ -1484,7 +1628,7 @@ class e_admin_model extends e_model
|
||||
public function dbInsert($force = false, $session_messages = false)
|
||||
{
|
||||
$this->_db_errno = 0;
|
||||
if(!$this->data_has_changed && !$force)
|
||||
if($this->hasError() || (!$this->data_has_changed && !$force))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -1509,7 +1653,7 @@ class e_admin_model extends e_model
|
||||
public function dbReplace($force = false, $session_messages = false)
|
||||
{
|
||||
$this->_db_errno = 0;
|
||||
if(!$this->data_has_changed && !$force)
|
||||
if($this->hasError() || (!$this->data_has_changed && !$force))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -1537,6 +1681,10 @@ class e_admin_model extends e_model
|
||||
public function dbUpdate($force = false, $session_messages = false)
|
||||
{
|
||||
$this->_db_errno = 0;
|
||||
if($this->hasError() || (!$this->data_has_changed && !$force))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
$res = e107::getDb()->db_Update($this->getModelTable(), $this->toSqlQuery('update'));
|
||||
if(!$res)
|
||||
{
|
||||
@ -1560,6 +1708,11 @@ class e_admin_model extends e_model
|
||||
public function dbDelete($session_messages = false)
|
||||
{
|
||||
$this->_db_errno = 0;
|
||||
if($this->hasError())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(!$this->getId())
|
||||
{
|
||||
$this->addMessageError('Record not found', $session_messages); //TODO - Lan
|
||||
@ -1587,20 +1740,33 @@ class e_admin_model extends e_model
|
||||
*/
|
||||
public function toSqlQuery($force = '')
|
||||
{
|
||||
$fields = array_keys($this->_data_fields);
|
||||
$qry = array();
|
||||
|
||||
$action = $this->getId() ? 'update' : 'create';
|
||||
if($force)
|
||||
{
|
||||
$action = $force;
|
||||
}
|
||||
|
||||
foreach ($fields as $key => $value)
|
||||
else
|
||||
{
|
||||
$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['_FIELD_TYPES'] = $this->_FIELD_TYPES;
|
||||
|
||||
switch($action)
|
||||
{
|
||||
@ -1690,6 +1856,17 @@ class e_admin_model extends e_model
|
||||
|
||||
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
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $_params = array();
|
||||
|
||||
/**
|
||||
* Current model DB table, used in all db calls
|
||||
* This can/should be overwritten by extending the class
|
||||
@ -1717,9 +1889,21 @@ class e_tree_model extends e_model
|
||||
*/
|
||||
protected $_total = 0;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
*/
|
||||
function __construct($tree_data = array())
|
||||
{
|
||||
if($tree_data)
|
||||
{
|
||||
$this->setTree($tree_data);
|
||||
}
|
||||
}
|
||||
|
||||
public function getTotal()
|
||||
{
|
||||
return $this->_total;
|
||||
return $this->_total;
|
||||
}
|
||||
|
||||
public function setTotal($num)
|
||||
@ -1748,18 +1932,6 @@ class e_tree_model extends e_model
|
||||
return $this->_db_table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
*/
|
||||
function __construct($tree_data = array())
|
||||
{
|
||||
if($tree_data)
|
||||
{
|
||||
$this->setTree($tree_data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set array of models
|
||||
* @return array
|
||||
@ -1788,8 +1960,14 @@ class e_tree_model extends e_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')))
|
||||
{
|
||||
$sql = e107::getDb();
|
||||
@ -1797,11 +1975,18 @@ class e_tree_model extends e_model
|
||||
if($sql->db_Select_gen($this->getParam('db_query')))
|
||||
{
|
||||
$this->_total = $sql->total_results; //requires SQL_CALC_FOUND_ROWS in query - see db handler
|
||||
|
||||
while($tmp = $sql->db_Fetch())
|
||||
{
|
||||
$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);
|
||||
}
|
||||
}
|
||||
@ -1866,57 +2051,7 @@ class e_tree_model extends e_model
|
||||
*/
|
||||
function isEmpty()
|
||||
{
|
||||
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);
|
||||
return (!$this->has('__tree'));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1931,11 +2066,11 @@ class e_admin_tree_model extends e_tree_model
|
||||
*/
|
||||
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);
|
||||
$sql = e107::getDb();
|
||||
$res = $sql->db_Delete($this->getModelTable(), $this->getFieldIdName().' IN ('.$ids.')');
|
||||
@ -1949,10 +2084,19 @@ class e_admin_tree_model extends e_tree_model
|
||||
}
|
||||
elseif($destroy)
|
||||
{
|
||||
if(is_string($ids))
|
||||
{
|
||||
$ids = explode(',', $ids);
|
||||
}
|
||||
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
call_user_func(array($this->getNode($id), 'destroy')); // first call model destroy method if any
|
||||
$this->setNode($id, null);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,8 +9,8 @@
|
||||
* Handler - general purpose validation functions
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/validator_class.php,v $
|
||||
* $Revision: 1.12 $
|
||||
* $Date: 2009-10-20 16:05:02 $
|
||||
* $Revision: 1.13 $
|
||||
* $Date: 2009-10-30 17:59:31 $
|
||||
* $Author: secretr $
|
||||
*
|
||||
*/
|
||||
@ -218,7 +218,7 @@ class e_validator
|
||||
*/
|
||||
public function setMessageStack($mstack)
|
||||
{
|
||||
if($mstack) $mstack = 'validator';
|
||||
if(!$mstack) $mstack = 'validator';
|
||||
$this->_message_stack = $mstack;
|
||||
return $this;
|
||||
}
|
||||
|
@ -9,8 +9,8 @@
|
||||
* e107 Release Plugin
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_plugins/release/admin_config.php,v $
|
||||
* $Revision: 1.10 $
|
||||
* $Date: 2009-10-28 17:05:35 $
|
||||
* $Revision: 1.11 $
|
||||
* $Date: 2009-10-30 17:59:32 $
|
||||
* $Author: secretr $
|
||||
*
|
||||
*/
|
||||
@ -64,29 +64,32 @@ class plugin_release_admin_controller_main extends e_admin_controller_main
|
||||
|
||||
// optional
|
||||
protected $perPage = 20;
|
||||
|
||||
// default - true
|
||||
protected $batchDelete = true;
|
||||
|
||||
//TODO change the release_url type back to URL before release.
|
||||
// required
|
||||
protected $fields = array(
|
||||
'checkboxes' => array('title'=> '', 'type' => '', 'width'=>'5%', 'thclass' =>'center', 'forced'=> TRUE, 'class'=>'center'),
|
||||
'release_id' => array('title'=> ID, 'type' => '', 'width'=>'5%', 'thclass' => '', 'forced'=> TRUE, 'primary'=>TRUE),
|
||||
'release_type' => array('title'=> 'Type', 'type' => 'method', 'width'=>'auto', 'thclass' => '', 'batch' => TRUE, 'filter'=>TRUE),
|
||||
'release_folder' => array('title'=> 'Folder', 'type' => 'text', 'width' => 'auto', 'thclass' => ''),
|
||||
'release_name' => array('title'=> 'Name', 'type' => 'text', 'width' => 'auto', 'thclass' => ''),
|
||||
'release_version' => array('title'=> 'Version', 'type' => 'text', 'width' => 'auto', 'thclass' => ''),
|
||||
'release_author' => array('title'=> LAN_AUTHOR, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left'),
|
||||
'release_authorURL' => array('title'=> LAN_AUTHOR_URL, 'type' => 'url', 'width' => 'auto', 'thclass' => 'left'),
|
||||
'release_date' => array('title'=> LAN_DATE, 'type' => 'text', 'width' => 'auto', 'thclass' => ''),
|
||||
'release_compatibility' => array('title'=> 'compatib', 'type' => 'text', 'width' => '10%', 'thclass' => 'center' ),
|
||||
'release_url' => array('title'=> 'Userclass', 'type' => 'userclass', 'width' => '10%', 'thclass' => 'center', 'batch' => TRUE, 'filter'=>TRUE),
|
||||
'options' => array('title'=> LAN_OPTIONS, 'type' => '', 'width' => '10%', 'thclass' => 'center last', 'class' => 'center last', 'forced'=>TRUE)
|
||||
'checkboxes' => array('title'=> '', 'type' => null, 'data' => null, 'width'=>'5%', 'thclass' =>'center', 'forced'=> TRUE, 'class'=>'center', 'toggle' => 'e-multiselect'),
|
||||
'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', 'data' => 'str', 'width'=>'auto', 'thclass' => '', 'batch' => TRUE, 'filter'=>TRUE),
|
||||
'release_folder' => array('title'=> 'Folder', 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'thclass' => ''),
|
||||
'release_name' => array('title'=> 'Name', 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'thclass' => ''),
|
||||
'release_version' => array('title'=> 'Version', 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'thclass' => ''),
|
||||
'release_author' => array('title'=> LAN_AUTHOR, 'type' => 'text', 'data' => 'str', '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' => 'datestamp', 'data' => 'int', 'width' => 'auto', 'thclass' => ''),
|
||||
'release_compatibility' => array('title'=> 'compatib', 'type' => 'text', 'data' => 'str', 'width' => '10%', 'thclass' => 'center' ),
|
||||
'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' => null, 'data' => null, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center last', 'forced'=>TRUE)
|
||||
);
|
||||
|
||||
//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()
|
||||
protected $dataFields = array(
|
||||
// optional if fields 'data' attribute is set or if custom model is set in init()
|
||||
/*protected $dataFields = array(
|
||||
'release_id' => 'int',
|
||||
'release_type' => 'str',
|
||||
'release_folder' => 'str',
|
||||
@ -97,10 +100,12 @@ class plugin_release_admin_controller_main extends e_admin_controller_main
|
||||
'release_date' => 'int',
|
||||
'release_compatibility' => 'str',
|
||||
'release_url' => 'str',
|
||||
);
|
||||
);*/
|
||||
|
||||
// optional
|
||||
protected $validationRules = array();
|
||||
// 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(
|
||||
'release_url' => array('required', '', 'Release URL', 'Help text', 'not valid error message')
|
||||
);*/
|
||||
|
||||
// optional
|
||||
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')
|
||||
);
|
||||
|
||||
// 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.
|
||||
|
||||
// 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}";
|
||||
|
||||
// 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->runObservers(true);
|
||||
e107::setRegistry('admin/release_dispatcher', $dispatcher);
|
||||
|
@ -6,7 +6,7 @@ CREATE TABLE release (
|
||||
`release_version` varchar(5) NOT NULL,
|
||||
`release_author` varchar(50) 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_url` varchar(255) NOT NULL,
|
||||
PRIMARY KEY (`release_id`)
|
||||
|
Loading…
x
Reference in New Issue
Block a user