From f8b49748d5bcd3e8415410d47fbe14803e1b01cf Mon Sep 17 00:00:00 2001 From: secretr Date: Wed, 11 Nov 2009 20:57:34 +0000 Subject: [PATCH] admin UI: Filter Ajax autocomplete, filters are now executed via AJAX calls by default, needs cleanup (buggy in some cases); some more UI improvements --- e107_admin/comment.php | 16 +- e107_admin/header.php | 5 +- e107_files/jslib/e107.js.php | 36 +- e107_handlers/admin_handler.php | 533 ++++++++++---------- e107_handlers/form_handler.php | 69 ++- e107_handlers/js_helper.php | 34 +- e107_handlers/php_compatibility_handler.php | 1 + e107_plugins/faqs/admin_config.php | 12 +- e107_plugins/release/includes/admin.php | 6 +- 9 files changed, 381 insertions(+), 331 deletions(-) diff --git a/e107_admin/comment.php b/e107_admin/comment.php index 5dc77bafb..692a22b24 100644 --- a/e107_admin/comment.php +++ b/e107_admin/comment.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_admin/comment.php,v $ -| $Revision: 1.18 $ -| $Date: 2009-11-10 19:13:07 $ +| $Revision: 1.19 $ +| $Date: 2009-11-11 20:57:34 $ | $Author: secretr $ +----------------------------------------------------------------------------+ */ @@ -79,13 +79,13 @@ class comments_admin_ui extends e_admin_ui //TODO - finish 'user' type, set 'data' to all editable fields, set 'noedit' for all non-editable fields protected $fields = array( 'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'), - 'comment_id' => array('title'=> LAN_ID, 'type' => 'int', 'width' =>'5%', 'forced'=> TRUE), - 'comment_item_id' => array('title'=> "item id", 'type' => 'text', 'width' => '5%'), + 'comment_id' => array('title'=> LAN_ID, 'type' => 'number', 'width' =>'5%', 'forced'=> TRUE), + 'comment_item_id' => array('title'=> "item id", 'type' => 'number', 'width' => '5%'), 'comment_subject' => array('title'=> "subject", 'type' => 'text', 'width' => 'auto', 'thclass' => 'left first'), // Display name - 'comment_comment' => array('title'=> "comment", 'type' => 'bbarea', 'width' => '30%', 'readParms' => 'expand=...&truncate=50&bb=1'), // Display name - 'comment_author_id' => array('title'=> "authorID", 'type' => 'user', 'data' => 'int', 'width' => 'auto'), // User id - 'comment_author_name' => array('title'=> "authorName", 'type' => 'text', 'width' => 'auto'), // User name - 'u.user_name' => array('title'=> "System user", 'type' => 'text', 'width' => 'auto', 'noedit' => true), // User name + 'comment_comment' => array('title'=> "comment", 'type' => 'bbarea', 'width' => '30%', 'readParms' => 'expand=...&truncate=50&bb=1'), // Display name + 'comment_author_id' => array('title'=> "author", 'type' => 'user', 'data' => 'int', 'width' => 'auto', 'writeParms' => 'nameField=comment_author_name'), // User id + 'comment_author_name' => array('title'=> "authorName", 'type' => 'user', 'width' => 'auto', 'readParms'=>'idField=comment_author_id&link=1', 'noedit' => true, 'forceSave' => true), // User name + 'u.user_name' => array('title'=> "System user", 'type' => 'user', 'width' => 'auto', 'readParms'=>'idField=comment_author_id&link=1', 'noedit' => true), // User name 'comment_datestamp' => array('title'=> "datestamp", 'type' => 'datestamp', 'width' => 'auto'), // User date 'comment_blocked' => array('title'=> "blocked", 'type' => 'boolean', 'data'=> 'int', 'thclass' => 'center', 'class'=>'center', 'filter' => true, 'batch' => true, 'width' => 'auto'), // Photo 'comment_ip' => array('title'=> "IP", 'type' => 'ip', 'width' => '10%', 'thclass' => 'center' ), // Real name (no real vetting) diff --git a/e107_admin/header.php b/e107_admin/header.php index c82b9cb99..1135c666e 100644 --- a/e107_admin/header.php +++ b/e107_admin/header.php @@ -9,8 +9,8 @@ * Admin Header * * $Source: /cvs_backup/e107_0.8/e107_admin/header.php,v $ - * $Revision: 1.51 $ - * $Date: 2009-11-02 17:45:29 $ + * $Revision: 1.52 $ + * $Date: 2009-11-11 20:57:34 $ * $Author: secretr $ */ @@ -89,6 +89,7 @@ if (!defined('ADMIN_WIDTH')) define('ADMIN_WIDTH', "width: 95%"); } +// FIXME - move to e.g. admin_constants.php if (!defined('ADMIN_TRUE_ICON')) { define("ADMIN_TRUE_ICON", ""); diff --git a/e107_files/jslib/e107.js.php b/e107_files/jslib/e107.js.php index 3ff69cb67..3155aa441 100644 --- a/e107_files/jslib/e107.js.php +++ b/e107_files/jslib/e107.js.php @@ -8,8 +8,8 @@ * e107 Javascript API * * $Source: /cvs_backup/e107_0.8/e107_files/jslib/e107.js.php,v $ - * $Revision: 1.36 $ - * $Date: 2009-11-06 18:37:23 $ + * $Revision: 1.37 $ + * $Date: 2009-11-11 20:57:33 $ * $Author: secretr $ * */ @@ -877,16 +877,24 @@ Object.extend(e107Helper, { * * */ - executeBatch: function(event) { + executeAutoSubmit: function(event) { var element = event.memo['element'] ? $(event.memo.element) : $$('body')[0]; - Element.select(element, 'select.e-execute-batch').invoke('observe', 'change', function(e) { - var frm = e.element().up('form'); - if (frm) { - frm.submit(); - e.stop(); - } + Element.select(element, 'select.e-autosubmit').invoke('observe', 'change', function(e) { + e107Helper.selectAutoSubmit(e.element()); }); }, + + selectAutoSubmit: function(el) { + var frm = el.up('form'); + if (frm) { + if(el.value == '___reset___') { + frm.getInputs('text').each(function(r) { r.value = '' }); + frm.getInputs('password').each(function(r) { r.value = '' }); + el.value = ''; + } + frm.submit(); + } + }, /** * added as Element method below @@ -2518,11 +2526,9 @@ Object.extend(e107Ajax, { if(!opt.parameters) opt.parameters = {}; Object.extend(opt.parameters, parm || {}); - opt.method = 'post'; - - if ($(form).hasAttribute('method') && !opt.method) - opt.method = $(form).method; - + if ($(form).hasAttribute('method') && !opt.method) opt.method = $(form).method; + if(!opt.method) opt.method = 'post'; + if(container) return new e107Ajax.Updater(container, url, opt); @@ -2685,6 +2691,6 @@ function sendInfo(handler, container, form) { /* * Core Auto-load */ -$w('autoExternalLinks autoNoHistory autoHide toggleObserver toggleManyObserver scrollToObserver executeBatch').each( function(f) { +$w('autoExternalLinks autoNoHistory autoHide toggleObserver toggleManyObserver scrollToObserver executeAutoSubmit').each( function(f) { e107.runOnLoad(e107Helper[f], null, true); }); diff --git a/e107_handlers/admin_handler.php b/e107_handlers/admin_handler.php index 1730e35d5..f24ceeb5c 100644 --- a/e107_handlers/admin_handler.php +++ b/e107_handlers/admin_handler.php @@ -1319,6 +1319,7 @@ class e_admin_controller * Currently used core parameters: * - enable_triggers: don't use it direct, see {@link setTriggersEnabled()} * - modes - see dispatcher::$modes + * - ajax_response - text|xml|json - default is 'text'; this should be set by the action method * - TODO - more parameters/add missing to this list * * @param string $key [optional] if null - get whole array @@ -1548,8 +1549,8 @@ class e_admin_controller protected function _preDispatch($action = '') { - if(!$action) $action = $this->getAction(); - $method = $this->toMethodName($action, 'page'); + if(!$action) $action = $this->getRequest()->getActionName(); + $method = $this->toMethodName($action, 'page'); if(!method_exists($this, $method)) { $this->getRequest()->setAction($this->getDefaultAction()); @@ -1670,26 +1671,27 @@ class e_admin_controller $this->setRequest($request); } $response = $this->getResponse(); + $this->_preDispatch($action); - $this->_preDispatch($action); if(null === $action) { $action = $request->getActionName(); } - + // check for observer - $actionName = $this->toMethodName($action, 'page'); + $actionName = $this->toMethodName($action, 'page'); $ret = ''; if(!method_exists($this, $actionName)) // pre dispatch already switched to default action/not found page if needed { e107::getMessage()->add('Action '.$actionName.' no found!', E_MESSAGE_ERROR); return $response; } - + //var_dump(call_user_func(array($this, $actionName)), $this->{$actionName}()); ob_start(); //catch any output - $ret = $this->$actionName(); + $ret = $this->{$actionName}(); - //Ajax XML/JSON communictaion + + //Ajax XML/JSON communication if(e_AJAX_REQUEST && is_array($ret)) { $response_type = $this->getParam('ajax_response', 'xml'); @@ -1697,7 +1699,7 @@ class e_admin_controller $js_helper = $response->getJsHelper(); foreach ($ret as $act => $data) { - $js_helper->addResponseAction($act, $data); + $js_helper->addResponse($data, $act); } $js_helper->sendResponse($response_type); } @@ -1707,8 +1709,9 @@ class e_admin_controller // Ajax text response if(e_AJAX_REQUEST) { - $response_type = $this->getParam('ajax_response', 'text'); - $response->getJsHelper()->addTextResponse($ret)->sendResponse($response_type); + $response_type = 'text'; + $response->getJsHelper()->addResponse($ret)->sendResponse($response_type); + var_dump($response_type, $response->getJsHelper()); } else { @@ -1728,6 +1731,12 @@ class e_admin_controller return '
Requested page was not found!
'; // TODO - lan } + + public function E404AjaxPage() + { + exit; + } + /** * Generic redirect handler, it handles almost everything we would need. * Additionally, it moves currently registered system messages to SESSION message stack @@ -1939,17 +1948,6 @@ class e_admin_ui extends e_admin_controller_ui $this->addTitle($this->pluginTitle, true)->parseAliases(); } - /** - * List action observer - * @return void - */ - public function ListObserver() - { - $this->getTreeModel()->setParam('db_query', $this->_modifyListQry())->load(); - $this->addTitle('List'); // FIXME - get captions from dispatch list - //var_dump($_POST, $this->getParam('enable_triggers')); - } - /** * Catch batch submit * @param string $batch_trigger @@ -2009,6 +2007,16 @@ class e_admin_ui extends e_admin_controller_ui e107::getJs()->headerCore('core/tabs.js') ->headerCore('core/admin.js'); } + + /** + * List action observer + * @return void + */ + public function ListObserver() + { + $this->getTreeModel()->setParam('db_query', $this->_modifyListQry())->load(); + $this->addTitle('List'); // FIXME - get captions from dispatch list + } /** * Generic List action page @@ -2019,6 +2027,70 @@ class e_admin_ui extends e_admin_controller_ui return $this->getUI()->getList(); } + public function FilterAjaxPage() + { + $ret = ''; + return $ret; + } + + /** + * List action observer + * @return void + */ + public function ListAjaxObserver() + { + $this->getTreeModel()->setParam('db_query', $this->_modifyListQry(false, 0))->load(); + } + + /** + * Generic List action page (Ajax) + * @return string + */ + public function ListAjaxPage() + { + return $this->getUI()->getList(true); + } + /** * Generic Edit observer */ @@ -2363,9 +2435,10 @@ class e_admin_ui extends e_admin_controller_ui } } - protected function _modifyListQry() + protected function _modifyListQry($isfilter = false, $forceFrom = false, $forceTo = false) { $searchQry = array(); + $filterFrom = array(); $request = $this->getRequest(); $tp = e107::getParser(); $tablePath = '`#'.$this->table.'`.'; @@ -2381,23 +2454,38 @@ class e_admin_ui extends e_admin_controller_ui $searchQuery = $tp->toDB($request->getQuery('searchquery', '')); list($filterField, $filterValue) = $tp->toDB(explode('__', $request->getQuery('filter_options', ''))); - // TODO - we have var types in current model, use them! + // FIXME - currently broken if($filterField && $filterValue !== '' && isset($this->fields[$filterField])) { $searchQry[] = $this->fields[$filterField]['__tableField']." = '".$filterValue."'"; } + $filter = array(); - foreach($this->fields as $key=>$var) + // Commented for now - we should search in ALL searchable fields, not only currently active. Discuss. + //foreach($this->fieldpref as $key) + foreach($this->fields as $key => $var) { - if(($var['type'] == 'text' || $var['type'] == 'method') && $searchQuery) + //if(!vartrue($this->fields[$key])) continue; + //$var = $this->fields[$key]; + $searchable_types = array('text', 'textearea', 'bbarea', 'user'); //method? + + if(trim($searchQuery) !== '' && !vartrue($var['nolist']) && in_array($var['type'], $searchable_types)) { - //$ftable = vartrue($var['alias'], '#'.$this->getTableName()); - $filter[] = $var['__tableField']."` REGEXP ('".$searchQuery."'))"; + $filter[] = $var['__tableField']." REGEXP ('".$searchQuery."')"; + if($isfilter) + { + $filterFrom[] = $var['__tableField']; + } } } - + if($isfilter) + { + if(!$filterFrom) return false; + $tableSFields = implode(', ', $filterFrom); + } + $jwhere = array(); $joins = array(); if($this->tableJoin) @@ -2406,20 +2494,22 @@ class e_admin_ui extends e_admin_controller_ui foreach ($this->tableJoin as $jtable => $tparams) { // Select fields - $fields = vartrue($tparams['fields']); - if('*' === $fields) + if(!$isfilter) { - $qry .= ", {$tparams['__tablePath']}*"; - } - else - { - $fields = array_map('trim', explode(',', $fields)); - foreach ($fields as $field) + $fields = vartrue($tparams['fields']); + if('*' === $fields) { - $qry .= ", {$tparams['__tablePath']}`{$field}`"; + $qry .= ", {$tparams['__tablePath']}*"; + } + else + { + $fields = explode(',', $fields); + foreach ($fields as $field) + { + $qry .= ", {$tparams['__tablePath']}`".trim($field).'`'; + } } } - // Prepare Joins $joins[] = " ".vartrue($tparams['joinType'], 'LEFT JOIN')." {$tparams['__tableFrom']} ON ".(vartrue($tparams['leftTable']) ? $tparams['leftTable'].'.' : $tablePath)."`".vartrue($tparams['leftField'])."` = {$tparams['__tablePath']}`".vartrue($tparams['rightField'])."`".(vartrue($tparams['whereJoin']) ? ' '.$tparams['whereJoin'] : ''); @@ -2453,7 +2543,7 @@ class e_admin_ui extends e_admin_controller_ui // filter where if(count($filter) > 0) { - $searchQry[] = " (".implode(" OR ",$filter)." )"; + $searchQry[] = " ( ".implode(" OR ",$filter)." ) "; } // where query @@ -2469,11 +2559,11 @@ class e_admin_ui extends e_admin_controller_ui $qry .= ' ORDER BY '.$this->fields[$orderField]['__tableField'].' '.($request->getQuery('asc') == 'desc' ? 'DESC' : 'ASC'); } - if($this->getPerPage()) + if($this->getPerPage() || false !== $forceTo) { - $from = intval($request->getQuery('from', 0)); - //$startfrom = ($from-1) * intval($this->getPerPage()); - $qry .= ' LIMIT '.$from.', '.intval($this->getPerPage()); + $from = false === $forceFrom ? intval($request->getQuery('from', 0)) : intval($forceFrom); + if(false === $forceTo) $forceTo = $this->getPerPage(); + $qry .= ' LIMIT '.$from.', '.intval($forceTo); } return $qry; @@ -2634,7 +2724,7 @@ class e_admin_ui extends e_admin_controller_ui $this->dataFields = array(); foreach ($this->fields as $key => $att) { - if(null !== $att['type'] && !vartrue($att['noedit'])) + if((null !== $att['type'] && !vartrue($att['noedit'])) || vartrue($att['forceSave'])) { $this->dataFields[$key] = vartrue($att['data'], 'str'); } @@ -2815,7 +2905,7 @@ class e_admin_form_ui extends e_form ); $models[] = $controller->getModel(); - return $this->createForm($forms, $models); + return $this->createForm($forms, $models, e_AJAX_REQUEST); } /** @@ -2846,7 +2936,7 @@ class e_admin_form_ui extends e_form ); $models[] = $controller->getConfig(); - return $this->createForm($forms, $models); + return $this->createForm($forms, $models, e_AJAX_REQUEST); } /** @@ -2856,7 +2946,7 @@ class e_admin_form_ui extends e_form * * @return string */ - public function getList() + public function getList($ajax = false) { $tp = e107::getParser(); $controller = $this->getController(); @@ -2871,7 +2961,7 @@ class e_admin_form_ui extends e_form 'head_query' => $request->buildQueryString('field=[FIELD]&asc=[ASC]&from=[FROM]', false), // without field, asc and from vars, REQUIRED 'np_query' => $request->buildQueryString(array(), false, 'from'), // without from var, REQUIRED for next/prev functionality 'legend' => $controller->getPluginTitle(), // hidden by default - 'form_pre' => $this->renderFilter($tp->post_toForm(array($controller->getQuery('searchquery'), $controller->getQuery('filter_options'))), $controller->getMode().'/'.$controller->getAction()), // needs to be visible when a search returns nothing + 'form_pre' => !$ajax ? $this->renderFilter($tp->post_toForm(array($controller->getQuery('searchquery'), $controller->getQuery('filter_options'))), $controller->getMode().'/'.$controller->getAction()) : '', // needs to be visible when a search returns nothing 'form_post' => '', // markup to be added after closing form element 'fields' => $controller->getFields(), // see e_admin_ui::$fields 'fieldpref' => $controller->getFieldPref(), // see e_admin_ui::$fieldpref @@ -2884,7 +2974,7 @@ class e_admin_form_ui extends e_form 'field' => $controller->getQuery('field'), //current order field name, default - primary field 'asc' => $controller->getQuery('asc', 'desc'), //current 'order by' rule, default 'asc' ); - return $this->listForm($options, $tree); + return $this->listForm($options, $tree, $ajax); } function renderFilter($current_query = array(), $location = '', $input_options = array()) @@ -2894,25 +2984,71 @@ class e_admin_form_ui extends e_form { $location = 'main/list'; //default location } - $l = explode('/', $location); - + $l = e107::getParser()->post_toForm(explode('/', $location)); + if(!is_array($input_options)) + { + parse_str($input_options, $input_options); + } + $input_options['id'] = false; + $input_options['class'] = 'tbox input-text filter'; $text = "
Filter
".$this->text('searchquery', $current_query[0], 50, $input_options)." - ".$this->select_open('filter_options', array('class' => 'tbox select e-filter-options', 'id' => false))." + ".$this->select_open('filter_options', array('class' => 'tbox select filter', 'id' => false))." ".$this->option('Display All', '')." + ".$this->option('Clear Filter', '___reset___')." ".$this->renderBatchFilter('filter', $current_query[1])." ".$this->select_close()." +
".$this->hidden('mode', $l[0])." ".$this->hidden('action', $l[1])." - ".$this->admin_button('etrigger_filter', LAN_FILTER)." + ".$this->admin_button('etrigger_filter', 'etrigger_filter', 'filter e-hide-if-js', LAN_FILTER, array('id' => false))." +
"; + + e107::getJs()->requireCoreLib('scriptaculous/controls.js', 2); + //TODO - external JS + e107::getJs()->footerInline(" + //autocomplete fields + \$\$('input[name=searchquery]').each(function(el, cnt) { + if(!cnt) el.focus(); + else return; + new Ajax.Autocompleter(el, el.next('div.e-autocomplete'), '".e_SELF."?mode=".$l[0]."&action=filter', { + paramName: 'searchquery', + minChars: 2, + frequency: 0.5, + afterUpdateElement: function(txt, li) { + var cfrm = el.up('form'), cont = cfrm.next('.e-container'); + if(!cont) { + return; + } + cfrm.submitForm(cont); + }, + indicator: el.next('span.indicator'), + parameters: 'ajax_used=1' + }); + var sel = el.next('select.filter'); + if(sel) { + sel.observe('change', function (e) { + var cfrm = e.element().up('form'), cont = cfrm.next('.e-container'); + if(cfrm && cont && e.element().value != '___reset___') { + e.stop(); + cfrm.submitForm(cont); + return; + } + e107Helper.selectAutoSubmit(e.element()); + }); + } + }); + "); return $text; } @@ -2929,11 +3065,12 @@ class e_admin_form_ui extends e_form $text = "
- ".$this->select_open('etrigger_batch', array('class' => 'tbox select e-execute-batch', 'id' => false))." + ".$this->select_open('etrigger_batch', array('class' => 'tbox select batch e-autosubmit', 'id' => false))." ".$this->option('With selected...', '')." ".($allow_delete ? $this->option('    '.LAN_DELETE, 'delete') : '')." ".$this->renderBatchFilter('batch')." ".$this->select_close()." + ".$this->admin_button('e__execute_batch', 'e__execute_batch', 'batch e-hide-if-js', 'Execute', array('id' => false))."
"; return $text; @@ -3050,225 +3187,95 @@ class e_admin_form_ui extends e_form } } -// One handler to rule them all -// see e107_plugins/release/admin_config.php. -class e_admin_ui_dummy extends e_form -{ - /** - * @var e_admin_ui - */ - protected $_controller = null; - - /** - * Constructor - * @param e_admin_ui $controller - * @return - */ - function __construct($controller) - { - $this->_controller = $controller; - parent::__construct(false); - } - - function init() - { - - global $user_pref; // e107::getConfig('user') ?? - - $this->mode = varset($_GET['mode']) ? $_GET['mode'] : 'list'; - - $column_pref_name = "admin_".$this->table."_columns"; - - if(isset($_POST['submit-e-columns'])) - { - $user_pref[$column_pref_name] = $_POST['e-columns']; - save_prefs('user'); - $this->mode = 'list'; - } - - $this->fieldpref = (varset($user_pref[$column_pref_name])) ? $user_pref[$column_pref_name] : array_keys($this->fields); - - foreach($this->fields as $k=>$v) // Find Primary table ID field (before checkboxes is run. ). - { - if(vartrue($v['primary'])) - { - $this->pid = $k; - } - } - - - if(varset($_POST['execute_batch'])) - { - if(vartrue($_POST['multiselect'])) - { - // $_SESSION[$this->table."_batch"] = $_POST['execute_batch']; // DO we want this to 'stick'? - list($tmp,$field,$value) = explode('__',$_POST['execute_batch']); - $this->processBatch($field,$_POST['multiselect'],$value); - } - $this->mode = 'list'; - } - - if(varset($_POST['execute_filter'])) // Filter the db records. - { - $_SESSION[$this->table."_filter"] = $_POST['filter_options']; - list($tmp,$filterField,$filterValue) = explode('__',$_POST['filter_options']); - $this->modifyListQry($_POST['searchquery'],$filterField,$filterValue); - $this->mode = 'list'; - } - - - if(varset($_POST['update']) || varset($_POST['create'])) - { - - $id = intval($_POST['record_id']); - $this->saveRecord($id); - } - - if(varset($_POST['delete'])) - { - $id = key($_POST['delete']); - $this->deleteRecord($id); - $this->mode = "list"; - } - - if(varset($_POST['saveOptions'])) - { - $this->saveSettings(); - } - - if(varset($_POST['edit'])) - { - $this->mode = 'create'; - } - - - if($this->mode) // Render Page. - { - $method = $this->mode."Page"; - $this->$method(); - } - - } +// FIXME - here because needed on AJAX calls (header.php not loaded), should be moved to separate file! +if (!defined('ADMIN_TRUE_ICON')) +{ + define("ADMIN_TRUE_ICON", ""); + define("ADMIN_TRUE_ICON_PATH", e_IMAGE."admin_images/true_16.png"); +} +if (!defined('ADMIN_FALSE_ICON')) +{ + define("ADMIN_FALSE_ICON", ""); + define("ADMIN_FALSE_ICON_PATH", e_IMAGE."admin_images/false_16.png"); +} - function modifyListQry($search,$filterField,$filterValue) - { - $searchQry = array(); - - if(vartrue($filterField) && vartrue($filterValue)) - { - $searchQry[] = $filterField." = '".$filterValue."'"; - } - - $filter = array(); - - foreach($this->fields as $key=>$var) - { - if(($var['type'] == 'text' || $var['type'] == 'method') && vartrue($search)) - { - $filter[] = "(".$key." REGEXP ('".$search."'))"; - } - } - if(count($filter)>0) - { - $searchQry[] = " (".implode(" OR ",$filter)." )"; - } - if(count($searchQry)>0) - { - $this->listQry .= " WHERE ".implode(" AND ",$searchQry); - } - } +if (!defined('ADMIN_EDIT_ICON')) +{ + define("ADMIN_EDIT_ICON", ""); + define("ADMIN_EDIT_ICON_PATH", e_IMAGE."admin_images/edit_16.png"); +} +if (!defined('ADMIN_DELETE_ICON')) +{ + define("ADMIN_DELETE_ICON", ""); + define("ADMIN_DELETE_ICON_PATH", e_IMAGE."admin_images/delete_16.png"); +} +if (!defined('ADMIN_UP_ICON')) +{ + define("ADMIN_UP_ICON", ""); + define("ADMIN_UP_ICON_PATH", e_IMAGE."admin_images/up_16.png"); +} +if (!defined('ADMIN_DOWN_ICON')) +{ + define("ADMIN_DOWN_ICON", ""); + define("ADMIN_DOWN_ICON_PATH", e_IMAGE."admin_images/down_16.png"); +} - function processBatch($field,$ids,$value) - { - $sql = e107::getDb(); - - if($field == 'delete') - { - return $sql->db_Delete($this->table,$this->pid." IN (".implode(",",$ids).")"); - } - - if(!is_numeric($value)) - { - $value = "'".$value."'"; - } - - $query = $field." = ".$value." WHERE ".$this->pid." IN (".implode(",",$ids).") "; - $count = $sql->db_Update($this->table,$query); - } +if (!defined('ADMIN_WARNING_ICON')) +{ + define("ADMIN_WARNING_ICON", ""); + define("ADMIN_WARNING_ICON_PATH", e_IMAGE."admin_images/warning_16.png"); +} - /** - * Generic Options/Preferences Form. - * @return - */ - function optionsPage() - { - $pref = e107::getConfig()->getPref(); - $frm = e107::getForm(); - $ns = e107::getRender(); - $mes = e107::getMessage(); +if (!defined('ADMIN_INFO_ICON')) +{ + define("ADMIN_INFO_ICON", ""); + define("ADMIN_INFO_ICON_PATH", e_IMAGE."admin_images/info_16.png"); +} - //XXX Lan - Options - $text = " -
-
- ".LAN_OPTIONS." - - - - - - \n"; - - - foreach($this->prefs as $key => $var) - { - $text .= " - - - - \n"; - } - - $text .= " -
".defset($var['title'], $var['title'])." - ".$this->renderElement($key, $pref)." -
-
- ".$frm->admin_button('saveOptions', LAN_SAVE, 'submit')." -
-
-
- "; +if (!defined('ADMIN_CONFIGURE_ICON')) +{ + define("ADMIN_CONFIGURE_ICON", ""); + define("ADMIN_CONFIGURE_ICON_PATH", e_IMAGE."admin_images/configure_16.png"); +} - $ns->tablerender($this->pluginTitle." :: ".LAN_OPTIONS, $mes->render().$text); - } +if (!defined('ADMIN_ADD_ICON')) +{ + define("ADMIN_ADD_ICON", ""); + define("ADMIN_ADD_ICON_PATH", e_IMAGE."admin_images/add_16.png"); +} +if (!defined('ADMIN_VIEW_ICON')) +{ + define("ADMIN_VIEW_ICON", ""); + define("ADMIN_VIEW_ICON_PATH", e_IMAGE."admin_images/admin_images/search_16.png"); +} - function saveSettings() //TODO needs to use native e_model functions, validation etc. - { - global $pref, $admin_log; - - unset($_POST['saveOptions'],$_POST['e-columns']); - - foreach($_POST as $key=>$val) - { - e107::getConfig('core')->set($key,$val); - } - - e107::getConfig('core')->save(); - } - - /** - * @return e_admin_ui - */ - public function getController() - { - return $this->_controller; - } +if (!defined('ADMIN_URL_ICON')) +{ + define("ADMIN_URL_ICON", ""); + define("ADMIN_URL_ICON_PATH", e_IMAGE."admin_images/forums_16.png"); +} + +if (!defined('ADMIN_INSTALLPLUGIN_ICON')) +{ + define("ADMIN_INSTALLPLUGIN_ICON", ""); + define("ADMIN_INSTALLPLUGIN_ICON_PATH", e_IMAGE."admin_images/plugin_install_16.png"); +} + +if (!defined('ADMIN_UNINSTALLPLUGIN_ICON')) +{ + define("ADMIN_UNINSTALLPLUGIN_ICON", ""); + define("ADMIN_UNINSTALLPLUGIN_ICON_PATH", e_IMAGE."admin_images/plugin_unstall_16.png"); +} + +if (!defined('ADMIN_UPGRADEPLUGIN_ICON')) +{ + define("ADMIN_UPGRADEPLUGIN_ICON", ""); + define("ADMIN_UPGRADEPLUGIN_ICON_PATH", e_IMAGE."admin_images/up_16.png"); } /** diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index e67ef77d5..c95f9c65c 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -9,8 +9,8 @@ * Form Handler * * $Source: /cvs_backup/e107_0.8/e107_handlers/form_handler.php,v $ - * $Revision: 1.76 $ - * $Date: 2009-11-10 19:13:06 $ + * $Revision: 1.77 $ + * $Date: 2009-11-11 20:57:33 $ * $Author: secretr $ * */ @@ -191,20 +191,11 @@ class e_form { if(!is_array($options)) parse_str($options, $options); - $reset = ''; - if(vartrue($options['reset'])) - { - $reset = ' - reset - '; - } - //'.$this->text($id_fld, $default_id, 10, array('id' => false, 'readonly'=>true, 'class'=>'tbox number')).' $ret = '
'.$this->text($name_fld, $default_name, 150, array('id' => false, 'readonly' => vartrue($options['readonly']) ? true : false)).' '.$this->hidden($id_fld, $default_id, array('id' => false)).' - '.$reset.' @@ -213,7 +204,7 @@ class e_form '; e107::getJs()->requireCoreLib('scriptaculous/controls.js', 2); - + //TODO - external JS e107::getJs()->footerInline(" //autocomplete fields \$\$('input[name={$name_fld}]').each(function(el) { @@ -229,7 +220,6 @@ class e_form minChars: 2, frequency: 0.5, afterUpdateElement: function(txt, li) { - console.log(\$(li).id, '{$id_fld}'); if(!\$(li)) return; if(\$(li).id) { el.next('input[name={$id_fld}]').value = parseInt(\$(li).id); @@ -535,12 +525,12 @@ class e_form /** * - * @param object $name - * @param object $value - * @param object $action [optional] default is submit - * @param object $label [optional] - * @param object $options [optional] - * @return + * @param string $name + * @param string $value + * @param string $action [optional] default is submit + * @param string $label [optional] + * @param string|array $options [optional] + * @return string */ function admin_button($name, $value, $action = 'submit', $label = '', $options = array()) { @@ -1263,14 +1253,30 @@ class e_form case 'user': //user_id expected // Just temporary solution, could be changed soon + if(!isset($parms['__options'])) $parms['__options'] = array(); + if(!is_array($parms['__options'])) parse_str($parms['__options'], $parms['__options']); + + if((empty($value) && vartrue($parms['currentInit'])) || vartrue($parms['current'])) + { + $value = USERID; + if(vartrue($parms['current'])) + { + $parms['__options']['readonly'] = true; + } + } + if(!is_array($value)) { $value = get_user_data($value); } + + $colname = vartrue($parms['nameType'], 'user_name'); + $parms['__options']['name'] = $colname; + if(!$value) $value = array(); - $uname = varset($value['user_name']); + $uname = varset($value[$colname]); $value = varset($value['user_id'], 0); - return $this->userpicker(vartrue($parms['nameField'] ,$key.'_usersearch'), $key, $uname, $value, $parms); + return $this->userpicker(vartrue($parms['nameField'], $key.'_usersearch'), $key, $uname, $value, vartrue($parms['__options'])); break; case 'boolean': @@ -1320,9 +1326,10 @@ class e_form * * @param array $options * @param e_admin_tree_model $list + * @param boolean $nocontainer don't enclose in div container * @return string */ - public function listForm($options, $list) + public function listForm($options, $list, $nocontainer = false) { $tp = e107::getParser(); $tree = $list->getTree(); @@ -1340,7 +1347,6 @@ class e_form $current_fields = varset($options['fieldpref']) ? $options['fieldpref'] : array_keys($options['fields']); $text = " - ".vartrue($options['form_pre'])."
".vartrue($options['fieldset_pre'])."
@@ -1386,10 +1392,12 @@ class e_form
".vartrue($options['fieldset_post'])."
- ".vartrue($options['form_post'])." "; - - return $text; + if(!$nocontainer) + { + $text = '
'.$text.'
'; + } + return (vartrue($options['form_pre']).$text.vartrue($options['form_post'])); } /** @@ -1426,9 +1434,10 @@ class e_form * * @param array $forms numerical array * @param array $models numerical array with values instance of e_admin_model + * @param boolean $nocontainer don't enclose in div container * @return string */ - function createForm($forms, $models) + function createForm($forms, $models, $nocontainer = false) { $text = ''; foreach ($forms as $fid => $form) @@ -1540,6 +1549,10 @@ class e_form "; } + if(!$nocontainer) + { + $text = '
'.$text.'
'; + } return $text; } @@ -1568,7 +1581,7 @@ class e_form $text = "
- ".$this->select_open('execute_batch', array('class' => 'tbox select e-execute-batch', 'id' => false))." + ".$this->select_open('execute_batch', array('class' => 'tbox select batch e-autosubmit', 'id' => false))." ".$this->option('With selected...', '')." "; diff --git a/e107_handlers/js_helper.php b/e107_handlers/js_helper.php index ff83e3f2e..9f45489df 100644 --- a/e107_handlers/js_helper.php +++ b/e107_handlers/js_helper.php @@ -9,8 +9,8 @@ * Javascript Helper * * $Source: /cvs_backup/e107_0.8/e107_handlers/js_helper.php,v $ - * $Revision: 1.7 $ - * $Date: 2009-10-28 01:32:40 $ + * $Revision: 1.8 $ + * $Date: 2009-11-11 20:57:32 $ * $Author: secretr $ * */ @@ -266,8 +266,8 @@ class e_jshelper * @param string $action optional * @param array $data_array optional */ - function sendTextResponse($data_text) - { + function sendTextResponse($data_text = '') + { header('Content-type: text/html; charset='.CHARSET, true); echo $this->addTextResponse($data_text)->buildTextResponse(); exit; @@ -288,7 +288,7 @@ class e_jshelper //TODO - pref? $response_type = strtolower(ucfirst($this->_prefered_response_type)); } - $method = "send{$response_type}Response"; + $method = "send{$response_type}Response"; if(method_exists($this, $method)) { $this->$method(); @@ -297,6 +297,30 @@ class e_jshelper return false; } + + /** + * Add response by response type + * + * @param mixed $data + * @param string $action 'text' or response action string + * @return e_jshelper + */ + function addResponse($data, $action = '') + { + if(!$action) + { + $action = 'text'; + } + if('text' == $action) + { + $this->addTextResponse($data); + } + else + { + $this->addResponseAction($action, $data); + } + return $this; + } /** * Reset response action array to prevent duplicates diff --git a/e107_handlers/php_compatibility_handler.php b/e107_handlers/php_compatibility_handler.php index 9e0d0e741..cd886233d 100644 --- a/e107_handlers/php_compatibility_handler.php +++ b/e107_handlers/php_compatibility_handler.php @@ -216,6 +216,7 @@ if (!function_exists('strptime')) { $vals['tm_mon'] = $names[substr($vals['tm_mon'], 0, 3)] - 1; } + //$vals['tm_sec'] -= 1; always increasing tm_sec + 1 ?????? #-- calculate wday/yday diff --git a/e107_plugins/faqs/admin_config.php b/e107_plugins/faqs/admin_config.php index 608ac608a..38cc0b7aa 100644 --- a/e107_plugins/faqs/admin_config.php +++ b/e107_plugins/faqs/admin_config.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_plugins/faqs/admin_config.php,v $ -| $Revision: 1.3 $ -| $Date: 2009-11-10 19:13:05 $ +| $Revision: 1.4 $ +| $Date: 2009-11-11 20:57:32 $ | $Author: secretr $ +----------------------------------------------------------------------------+ */ @@ -91,8 +91,8 @@ class faq_main_ui extends e_admin_ui protected $tableJoin = array( 'u.user' => array('leftField' => 'faq_author', 'rightField' => 'user_id', 'fields' => 'user_id,user_loginname,user_name') ); - - protected $listQry = "SELECT * FROM #faqs"; // without any Order or Limit. + // without any Order or Limit. + //protected $listQry = "SELECT * FROM #faqs"; protected $editQry = "SELECT * FROM #faqs WHERE faq_id = {ID}"; @@ -109,7 +109,7 @@ class faq_main_ui extends e_admin_ui 'faq_parent' => array('title'=> "Category", 'type' => 'method', 'data'=> 'int','width' => '5%', 'filter'=>TRUE, 'batch'=>TRUE), 'faq_comment' => array('title'=> "Comment", 'type' => 'userclass', 'data' => 'int', 'width' => 'auto'), // User id 'faq_datestamp' => array('title'=> "datestamp", 'type' => 'datestamp', 'data'=> 'int','width' => 'auto'), // User date - 'faq_author' => array('title'=> LAN_USER, 'type' => 'user', 'data'=> 'int', 'thclass' => 'center', 'class'=>'center', 'filter' => true, 'batch' => true, 'width' => 'auto'), // Photo + 'faq_author' => array('title'=> LAN_USER, 'type' => 'user', 'data'=> 'int', 'width' => 'auto', 'thclass' => 'center', 'class'=>'center', 'writeParms' => 'currentInit=1', 'filter' => true, 'batch' => true, 'nolist' => true ), // Photo 'u.user_name' => array('title'=> "User name", 'type' => 'user', 'width' => 'auto', 'noedit' => true, 'readParms'=>'idField=faq_author&link=1'), // User name 'u.user_loginname' => array('title'=> "User login", 'type' => 'user', 'width' => 'auto', 'noedit' => true, 'readParms'=>'idField=faq_author&link=1'), // User login name 'faq_order' => array('title'=> "Order", 'type' => 'number', 'data'=> 'int','width' => '5%', 'thclass' => 'center' ), // Real name (no real vetting) @@ -199,9 +199,7 @@ class faq_admin_form_ui extends e_admin_form_ui new faq_admin(); - require_once(e_ADMIN."auth.php"); - e107::getAdminUI()->runPage(); require_once(e_ADMIN."footer.php"); diff --git a/e107_plugins/release/includes/admin.php b/e107_plugins/release/includes/admin.php index e88bbd25b..8bfe110a4 100644 --- a/e107_plugins/release/includes/admin.php +++ b/e107_plugins/release/includes/admin.php @@ -9,8 +9,8 @@ * Release Plugin Administration UI * * $Source: /cvs_backup/e107_0.8/e107_plugins/release/includes/admin.php,v $ - * $Revision: 1.8 $ - * $Date: 2009-11-10 19:13:06 $ + * $Revision: 1.9 $ + * $Date: 2009-11-11 20:57:33 $ * $Author: secretr $ */ @@ -178,7 +178,7 @@ class plugin_release_admin_ui extends e_admin_ui * -> write: n/a * * - user -> read: [optional] 'link' => true - create link to user profile, 'idField' => 'author_id' - tells to renderValue() where to search for user id (used when 'link' is true) - * -> write: [optional] 'nameField' => 'comment_author_name' the name of a 'user_name' field; + * -> write: [optional] 'nameField' => 'comment_author_name' the name of a 'user_name' field; 'currentInit' - use currrent user if no data provided; 'current' - use always current user(editor); '__options' e_form::userpickup() options * * - number -> read: (array) [optional] 'point' => '.', [optional] 'sep' => ' ', [optional] 'decimals' => 2, [optional] 'pre' => '€ ', [optional] 'post' => 'LAN_CURRENCY' * -> write: (array) [optional] 'pre' => '€ ', [optional] 'post' => 'LAN_CURRENCY', [optional] 'maxlength' => 50, [optional] '__options' => array(...) see e_form class description for __options format