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

date convert: added generic string to timestamp converter (toTime()); admin UI: textareas autoexpand now available sitewide (back-end), multi table JOIN support, field (db table) aliases support, user auto-complete search should work fine now, example usage added on faqs administration

This commit is contained in:
secretr
2009-11-10 19:13:07 +00:00
parent 735734ebf4
commit 890bd0db44
9 changed files with 483 additions and 188 deletions

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_admin/comment.php,v $ | $Source: /cvs_backup/e107_0.8/e107_admin/comment.php,v $
| $Revision: 1.17 $ | $Revision: 1.18 $
| $Date: 2009-11-09 16:54:30 $ | $Date: 2009-11-10 19:13:07 $
| $Author: secretr $ | $Author: secretr $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -65,7 +65,7 @@ class comments_admin_ui extends e_admin_ui
* @var array [optional] * @var array [optional]
*/ */
protected $tableJoin = array ( protected $tableJoin = array (
'user' => array('leftField' => 'comment_author_id', 'rightField' => 'user_id', 'fields' => '*'/*, 'leftTable' => '', 'joinType' => 'LEFT JOIN', 'whereJoin' => '', 'where' => ''*/) 'u.user' => array('leftField' => 'comment_author_id', 'rightField' => 'user_id', 'fields' => '*'/*, 'leftTable' => '', 'joinType' => 'LEFT JOIN', 'whereJoin' => 'AND u.user_ban=0', 'where' => ''*/)
); );
//protected $listQry = "SELECT SQL_CALC_FOUND_ROWS * FROM #comments"; // without any Order or Limit. //protected $listQry = "SELECT SQL_CALC_FOUND_ROWS * FROM #comments"; // without any Order or Limit.
@@ -85,7 +85,7 @@ class comments_admin_ui extends e_admin_ui
'comment_comment' => array('title'=> "comment", 'type' => 'bbarea', 'width' => '30%', 'readParms' => 'expand=...&truncate=50&bb=1'), // 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_id' => array('title'=> "authorID", 'type' => 'user', 'data' => 'int', 'width' => 'auto'), // User id
'comment_author_name' => array('title'=> "authorName", 'type' => 'text', 'width' => 'auto'), // User name 'comment_author_name' => array('title'=> "authorName", 'type' => 'text', 'width' => 'auto'), // User name
'user_name' => array('title'=> "System user", 'type' => 'text', 'width' => 'auto', 'table' => 'user', 'noedit' => true), // User name 'u.user_name' => array('title'=> "System user", 'type' => 'text', 'width' => 'auto', 'noedit' => true), // User name
'comment_datestamp' => array('title'=> "datestamp", 'type' => 'datestamp', 'width' => 'auto'), // User date '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_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) 'comment_ip' => array('title'=> "IP", 'type' => 'ip', 'width' => '10%', 'thclass' => 'center' ), // Real name (no real vetting)

View File

@@ -8,8 +8,8 @@
* e107 Admin Helper * e107 Admin Helper
* *
* $Source: /cvs_backup/e107_0.8/e107_files/jslib/core/admin.js,v $ * $Source: /cvs_backup/e107_0.8/e107_files/jslib/core/admin.js,v $
* $Revision: 1.22 $ * $Revision: 1.23 $
* $Date: 2009-11-09 16:55:41 $ * $Date: 2009-11-10 19:13:07 $
* $Author: secretr $ * $Author: secretr $
* *
*/ */
@@ -63,6 +63,14 @@ e107Admin.Helper = {
var msg = el.readAttribute('delmsg') || e107.getModLan('delete_confirm'); var msg = el.readAttribute('delmsg') || e107.getModLan('delete_confirm');
if( !e107Helper.confirm(msg) ) e.stop(); if( !e107Helper.confirm(msg) ) e.stop();
}); });
element.select('textarea.e-autoheight').each( function (textarea) {
var options = {}, autoopt = '__' + textarea.name + 'autoheight_opt', autooptel = textarea.next('input[name=' + autoopt + ']');
if(autooptel) {
options['max_length'] = parseInt(autooptel.value);
}
new e107Admin.Nicearea(textarea, options);
});
}, },
/** /**

View File

@@ -1885,6 +1885,7 @@ class e_admin_ui extends e_admin_controller_ui
protected $tableJoin; protected $tableJoin;
protected $editQry; protected $editQry;
protected $table; protected $table;
protected $tableAlias;
protected $pid; protected $pid;
protected $pluginTitle; protected $pluginTitle;
@@ -1935,7 +1936,7 @@ class e_admin_ui extends e_admin_controller_ui
$this->fieldpref = $ufieldpref; $this->fieldpref = $ufieldpref;
} }
$this->addTitle($this->pluginTitle, true); $this->addTitle($this->pluginTitle, true)->parseAliases();
} }
/** /**
@@ -2050,17 +2051,7 @@ class e_admin_ui extends e_admin_controller_ui
function EditHeader() function EditHeader()
{ {
// TODO - make it part of e_from::textarea/bbarea(), invoke it on className (not all textarea elements) // TODO - make it part of e_from::textarea/bbarea(), invoke it on className (not all textarea elements)
e107::getJs()->requireCoreLib('core/admin.js') e107::getJs()->requireCoreLib('core/admin.js');
->footerInline("
\$\$('textarea').each(function(textarea) {
//auto options
var options = {}, autoopt = '__' + textarea.name + '_opt', autooptel = textarea.next('input[name=autoopt]');
if(autooptel) {
options['max_length'] = parseInt(autooptel.value);
}
new e107Admin.Nicearea(textarea, options);
});
");
} }
/** /**
@@ -2121,17 +2112,7 @@ class e_admin_ui extends e_admin_controller_ui
function CreateHeader() function CreateHeader()
{ {
// TODO - make it part of e_from::textarea/bbarea(), invoke it on className (not all textarea elements) // TODO - make it part of e_from::textarea/bbarea(), invoke it on className (not all textarea elements)
e107::getJs()->requireCoreLib('core/admin.js') e107::getJs()->requireCoreLib('core/admin.js');
->footerInline("
\$\$('textarea').each(function(textarea) {
//auto options
var options = {}, autoopt = '__' + textarea.name + '_opt', autooptel = textarea.next('input[name=autoopt]');
if(autooptel) {
options['max_length'] = parseInt(autooptel.value);
}
new e107Admin.Nicearea(textarea, options);
});
");
} }
/** /**
@@ -2241,6 +2222,79 @@ class e_admin_ui extends e_admin_controller_ui
} }
} }
protected function parseAliases()
{
// parse table
if(strpos($this->table, '.') !== false)
{
$tmp = explode('.', $this->table, 2);
$this->table = $tmp[1];
$this->tableAlias = $tmp[0];
unset($tmp);
}
if($this->tableJoin)
{
foreach ($this->tableJoin as $table => $att)
{
if(strpos($table, '.') !== false)
{
$tmp = explode('.', $table, 2);
unset($this->tableJoin[$table]);
$att['alias'] = $tmp[0];
$att['table'] = $tmp[1];
$att['__tablePath'] = $att['alias'].'.';
$att['__tableFrom'] = '`#'.$att['table'].'` AS '.$att['alias'];
$this->tableJoin[$att['alias']] = $att;
unset($tmp);
continue;
}
$this->tableJoin[$table]['table'] = $table;
$this->tableJoin[$table]['alias'] = '';
$this->tableJoin[$table]['__tablePath'] = '`#'.$this->tableJoin[$table]['table'].'`.';
$this->tableJoin[$table]['__tableFrom'] = '`#'.$this->tableJoin[$table]['table'].'`';
}
}
// check for table aliases
$fields = array(); // preserve order
foreach ($this->fields as $field => $att)
{
if(strpos($field, '.') !== false)
{
$tmp = explode('.', $field, 2);
$att['alias'] = $tmp[0];
$fields[$tmp[1]] = $att;
$field = $tmp[1];
unset($tmp);
}
else
{
$att['alias'] = $this->tableAlias;
$fields[$field] = $att;
}
if($fields[$field]['alias'])
{
if($fields[$field]['alias'] == $this->tableAlias)
{
$fields[$field]['__tableField'] = $this->tableAlias.'.'.$field;
}
else
{
$fields[$field]['__tableField'] = $this->tableJoin[$fields[$field]['alias']]['__tablePath'].$field;
}
}
else
{
$fields[$field]['__tableField'] = '`#'.$this->table.'`.'.$field;
}
}
$this->fields = $fields;
return $this;
}
/** /**
* Take approproate action after successfull submit * Take approproate action after successfull submit
* *
@@ -2303,7 +2357,7 @@ class e_admin_ui extends e_admin_controller_ui
{ {
$data[$key] = e107::getInstance()->ipEncode($data[$key]); $data[$key] = e107::getInstance()->ipEncode($data[$key]);
} }
var_dump($data[$key]); break;
//more to come //more to come
} }
} }
@@ -2314,6 +2368,15 @@ class e_admin_ui extends e_admin_controller_ui
$searchQry = array(); $searchQry = array();
$request = $this->getRequest(); $request = $this->getRequest();
$tp = e107::getParser(); $tp = e107::getParser();
$tablePath = '`#'.$this->table.'`.';
$tableFrom = '`#'.$this->table.'`';
$tableSFields = '`#'.$this->table.'`.*';
if($this->tableAlias)
{
$tablePath = $this->tableAlias.'.';
$tableFrom = '`#'.$this->table.'` AS '.$this->tableAlias;
$tableSFields = ''.$this->tableAlias.'.*';
}
$searchQuery = $tp->toDB($request->getQuery('searchquery', '')); $searchQuery = $tp->toDB($request->getQuery('searchquery', ''));
list($filterField, $filterValue) = $tp->toDB(explode('__', $request->getQuery('filter_options', ''))); list($filterField, $filterValue) = $tp->toDB(explode('__', $request->getQuery('filter_options', '')));
@@ -2321,49 +2384,45 @@ class e_admin_ui extends e_admin_controller_ui
// TODO - we have var types in current model, use them! // TODO - we have var types in current model, use them!
if($filterField && $filterValue !== '' && isset($this->fields[$filterField])) if($filterField && $filterValue !== '' && isset($this->fields[$filterField]))
{ {
$ftable = vartrue($this->fields[$filterField]['table'], $this->getTableName()); $searchQry[] = $this->fields[$filterField]['__tableField']." = '".$filterValue."'";
$searchQry[] = "`#{$ftable}`.`$filterField` = '".$filterValue."'";
} }
$filter = array(); $filter = array();
foreach($this->fields as $key=>$var) foreach($this->fields as $key=>$var)
{ {
$ftable = vartrue($var['table'], $this->getTableName());
if(($var['type'] == 'text' || $var['type'] == 'method') && $searchQuery) if(($var['type'] == 'text' || $var['type'] == 'method') && $searchQuery)
{ {
$filter[] = "(`#{$ftable}`.`".$key."` REGEXP ('".$searchQuery."'))"; //$ftable = vartrue($var['alias'], '#'.$this->getTableName());
$filter[] = $var['__tableField']."` REGEXP ('".$searchQuery."'))";
} }
} }
//$qry = $this->listQry;
// We dont need list qry anymore!
$jwhere = array(); $jwhere = array();
$joins = array(); $joins = array();
if($this->tableJoin) if($this->tableJoin)
{ {
$qry = "SELECT `#".$this->getTableName()."`.*"; $qry = "SELECT SQL_CALC_FOUND_ROWS ".$tableSFields;
foreach ($this->tableJoin as $jtable => $tparams) foreach ($this->tableJoin as $jtable => $tparams)
{ {
// Select fields // Select fields
$fields = vartrue($tparams['fields']); $fields = vartrue($tparams['fields']);
if('*' === $fields) if('*' === $fields)
{ {
$qry .= ", `#{$jtable}`.*"; $qry .= ", {$tparams['__tablePath']}*";
} }
else else
{ {
$fields = array_map('trim', explode(',', $fields)); $fields = array_map('trim', explode(',', $fields));
foreach ($fields as $field) foreach ($fields as $field)
{ {
$qry .= ", `#{$jtable}`.`{$field}`"; $qry .= ", {$tparams['__tablePath']}`{$field}`";
} }
} }
// Prepare Joins // Prepare Joins
$joins[] = " $joins[] = "
".vartrue($tparams['joinType'], 'LEFT JOIN')." `#{$jtable}` ON `#".vartrue($tparams['leftTable'], $this->getTableName())."`.`".vartrue($tparams['leftField'])."` = `#{$jtable}`.`".vartrue($tparams['rightField'])."`".(vartrue($tparams['whereJoin']) ? ' '.$tparams['whereJoin'] : ''); ".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'] : '');
// Prepare Where // Prepare Where
if(vartrue($tparams['where'])) if(vartrue($tparams['where']))
@@ -2373,7 +2432,7 @@ class e_admin_ui extends e_admin_controller_ui
} }
//From //From
$qry .= " FROM `#".$this->getTableName()."`"; $qry .= " FROM ".$tableFrom;
// Joins // Joins
if(count($joins) > 0) if(count($joins) > 0)
@@ -2383,7 +2442,7 @@ class e_admin_ui extends e_admin_controller_ui
} }
else else
{ {
$qry = "SELECT `#".$this->getTableName()."`.* FROM `#".$this->getTableName()."`"; $qry = $this->listQry ? $this->listQry : "SELECT SQL_CALC_FOUND_ROWS ".$tableSFields." FROM ".$tableFrom;
} }
// join where // join where
@@ -2406,9 +2465,8 @@ class e_admin_ui extends e_admin_controller_ui
$orderField = $request->getQuery('field', $this->getPrimaryName()); $orderField = $request->getQuery('field', $this->getPrimaryName());
if(isset($this->fields[$orderField])) if(isset($this->fields[$orderField]))
{ {
$ftable = vartrue($this->fields[$orderField]['table'], $this->getTableName());
// no need of sanitize - it's found in field array // no need of sanitize - it's found in field array
$qry .= ' ORDER BY `#'.$ftable.'`.`'.$orderField.'` '.($request->getQuery('asc') == 'desc' ? 'DESC' : 'ASC'); $qry .= ' ORDER BY '.$this->fields[$orderField]['__tableField'].' '.($request->getQuery('asc') == 'desc' ? 'DESC' : 'ASC');
} }
if($this->getPerPage()) if($this->getPerPage())
@@ -2417,6 +2475,7 @@ class e_admin_ui extends e_admin_controller_ui
//$startfrom = ($from-1) * intval($this->getPerPage()); //$startfrom = ($from-1) * intval($this->getPerPage());
$qry .= ' LIMIT '.$from.', '.intval($this->getPerPage()); $qry .= ' LIMIT '.$from.', '.intval($this->getPerPage());
} }
return $qry; return $qry;
} }
@@ -2446,9 +2505,16 @@ class e_admin_ui extends e_admin_controller_ui
return $this->pluginTitle; return $this->pluginTitle;
} }
public function getTableName() public function getTableName($alias = false, $prefix = false)
{ {
return $this->table; if($alias && $this->tableAlias) return $this->tableAlias;
return ($prefix ? '#.' : '').$this->table;
}
public function getJoinTable($alias = false, $prefix = false)
{
if($alias && $this->tableAlias) return $this->tableAlias;
return ($prefix ? '#.' : '').$this->table;
} }
public function getBatchDelete() public function getBatchDelete()
@@ -2568,11 +2634,10 @@ class e_admin_ui extends e_admin_controller_ui
$this->dataFields = array(); $this->dataFields = array();
foreach ($this->fields as $key => $att) foreach ($this->fields as $key => $att)
{ {
if(null === $att['type'] || vartrue($att['noedit']) || !vartrue($att['data'])) if(null !== $att['type'] && !vartrue($att['noedit']))
{ {
continue; $this->dataFields[$key] = vartrue($att['data'], 'str');
} }
$this->dataFields[$key] = $att['data'];
} }
} }
// TODO - do it in one loop, or better - separate method(s) -> convertFields(validate), convertFields(data),... // TODO - do it in one loop, or better - separate method(s) -> convertFields(validate), convertFields(data),...
@@ -2589,10 +2654,10 @@ class e_admin_ui extends e_admin_controller_ui
{ {
$this->validationRules[$key] = array((true === $att['validate'] ? 'required' : $att['validate']), varset($att['rule']), $att['title'], varset($att['error'], $att['help'])); $this->validationRules[$key] = array((true === $att['validate'] ? 'required' : $att['validate']), varset($att['rule']), $att['title'], varset($att['error'], $att['help']));
} }
elseif(vartrue($att['check'])) /*elseif(vartrue($att['check'])) could go?
{ {
$this->checkRules[$key] = array($att['check'], varset($att['rule']), $att['title'], varset($att['error'], $att['help'])); $this->checkRules[$key] = array($att['check'], varset($att['rule']), $att['title'], varset($att['error'], $att['help']));
} }*/
} }
} }
@@ -2681,7 +2746,8 @@ class e_admin_form_ui extends e_form
// protect current methods from conflict. // protect current methods from conflict.
$this->preventConflict(); $this->preventConflict();
// user constructor
$this->init();
} }
protected function preventConflict() protected function preventConflict()
@@ -2930,7 +2996,8 @@ class e_admin_form_ui extends e_form
case 'method': case 'method':
$method = $key; $method = $key;
$list = call_user_func_array(array($this, $method), array('', $type)); $list = call_user_func_array(array($this, $method), array('', $type, $parms));
if(is_array($list)) if(is_array($list))
{ {
//check for single option //check for single option
@@ -3209,17 +3276,18 @@ class e_admin_ui_dummy extends e_form
* 1. move abstract peaces of code to the proper classes * 1. move abstract peaces of code to the proper classes
* 2. remove duplicated code (e_form & e_admin_form_ui), refactoring * 2. remove duplicated code (e_form & e_admin_form_ui), refactoring
* 3. make JS Manager handle Styles (.css files and inline CSS) * 3. make JS Manager handle Styles (.css files and inline CSS)
* 4. e_form is missing some methods used in e_admin_form_ui * 4. [DONE] e_form is missing some methods used in e_admin_form_ui
* 5. date convert needs string-to-datestamp auto parsing, strptime() is the solution but needs support for * 5. [DONE] date convert needs string-to-datestamp auto parsing, strptime() is the solution but needs support for
* Windows and PHP < 5.1.0 - build custom strptime() function (php_compatibility_handler.php) on this - * Windows and PHP < 5.1.0 - build custom strptime() function (php_compatibility_handler.php) on this -
* http://sauron.lionel.free.fr/?page=php_lib_strptime (bad license so no copy/paste is allowed!) * http://sauron.lionel.free.fr/?page=php_lib_strptime (bad license so no copy/paste is allowed!)
* 6. [DONE - read/writeParms introduced ] $fields[parms] mess - fix it, separate list/edit mode parms somehow * 6. [DONE - read/writeParms introduced ] $fields[parms] mess - fix it, separate list/edit mode parms somehow
* 7. clean up/document all object vars (e_admin_ui, e_admin_dispatcher) * 7. clean up/document all object vars (e_admin_ui, e_admin_dispatcher)
* 8. clean up/document all parameters (get/setParm()) in controller and model classes * 8. [DONE hopefully] clean up/document all parameters (get/setParm()) in controller and model classes
* 9. [DONE] 'ip' field type - convert to human readable format while showing/editing record * 9. [DONE] 'ip' field type - convert to human readable format while showing/editing record
* 10. draggable ordering (list view) * 10. draggable ordering (list view)
* 11. realtime search filter (typing text) - like downloads currently * 11. realtime search filter (typing text) - like downloads currently
* 12. autosubmit when 'filter' dropdown is changed (quick fix?) * 12. autosubmit when 'filter' dropdown is changed (quick fix?)
* 13. tablerender captions * 13. tablerender captions
* 14. [ALMOST - see Edit/CreateHeader() comments] textareas auto-height * 14. [DONE] textareas auto-height
* 15. [DONE] multi JOIN table support (optional), aliases
*/ */

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/date_handler.php,v $ * $Source: /cvs_backup/e107_0.8/e107_handlers/date_handler.php,v $
* $Revision: 1.10 $ * $Revision: 1.11 $
* $Date: 2009-11-04 17:29:26 $ * $Date: 2009-11-10 19:13:06 $
* $Author: secretr $ * $Author: secretr $
* *
*/ */
@@ -61,10 +61,48 @@ class convert
return strftime($mask, $datestamp); return strftime($mask, $datestamp);
} }
function toTime($date_string, $mask = '') /**
* Convert date string back to integer (unix timestamp)
* NOTE: after some tests, strptime (compat mode) is adding +1 sec. after parsing to time, investigate!
*
* @param object $date_string
* @param object $mask [optional]
* @return
*/
function toTime($date_string, $mask = 'input')
{ {
//TODO - convert string to datestamp, coming soon switch($mask)
return time(); {
case 'long':
$mask = e107::getPref('longdate');
break;
case 'short':
$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;
}
// see php compat handler
$tdata = strptime($date_string, $mask);
if(empty($tdata))
{
return null;
}
$unxTimestamp = mktime(
$tdata['tm_hour'],
$tdata['tm_min'],
$tdata['tm_sec'],
$tdata['tm_mon'] + 1,
$tdata['tm_mday'],
$tdata['tm_year'] + 1900
);
//var_dump($tdata, $date_string, $this->convert_date($unxTimestamp, $mask), $unxTimestamp);
return $unxTimestamp;
} }
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')

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.75 $ * $Revision: 1.76 $
* $Date: 2009-11-09 16:54:29 $ * $Date: 2009-11-10 19:13:06 $
* $Author: secretr $ * $Author: secretr $
* *
*/ */
@@ -166,6 +166,7 @@ class e_form
if ($datestamp) if ($datestamp)
{ {
$cal_attrib['value'] = e107::getDateConvert()->convert_date($datestamp, 'input'); //date("d/m/Y H:i:s", $datestamp); $cal_attrib['value'] = e107::getDateConvert()->convert_date($datestamp, 'input'); //date("d/m/Y H:i:s", $datestamp);
// var_dump('date picker', $datestamp, $cal_attrib['value'], e107::getDateConvert()->toTime($cal_attrib['value']), e107::getDateConvert()->convert_date(e107::getDateConvert()->toTime($cal_attrib['value']), 'input'));
} }
//JS manager to send JS/CSS to header if possible, if not - footer //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) e107::getJs()// FIXME - no CSS support yet!!! ->tryHeaderFile($cal->calendar_theme_file)
@@ -177,16 +178,16 @@ class e_form
} }
/** /**
* UNDER CONSTRUCTION!!! * User auto-complete search
* *
* @param object $name * @param string $name_fld field name for user name
* @param object $id_fld * @param string $id_fld field name for user id
* @param object $default_name * @param string $default_name default user name value
* @param object $default_id * @param integer $default_id default user id
* @param object $options [optional] * @param array|string $options [optional] 'readonly' (make field read only), 'name' (db field name, default user_name)
* @return * @return
*/ */
function userpicker($name, $id_fld, $default_name, $default_id, $options = array()) function userpicker($name_fld, $id_fld, $default_name, $default_id, $options = array())
{ {
if(!is_array($options)) parse_str($options, $options); if(!is_array($options)) parse_str($options, $options);
@@ -201,7 +202,7 @@ class e_form
//'.$this->text($id_fld, $default_id, 10, array('id' => false, 'readonly'=>true, 'class'=>'tbox number')).' //'.$this->text($id_fld, $default_id, 10, array('id' => false, 'readonly'=>true, 'class'=>'tbox number')).'
$ret = ' $ret = '
<div class="e-autocomplete-c"> <div class="e-autocomplete-c">
'.$this->text($name, $default_name, 150, array('id' => false, 'readonly' => vartrue($options['readonly']) ? true : false)).' '.$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)).' '.$this->hidden($id_fld, $default_id, array('id' => false)).'
'.$reset.' '.$reset.'
<span class="indicator" style="display: none;"> <span class="indicator" style="display: none;">
@@ -215,7 +216,7 @@ class e_form
e107::getJs()->footerInline(" e107::getJs()->footerInline("
//autocomplete fields //autocomplete fields
\$\$('input[name={$name}]').each(function(el) { \$\$('input[name={$name_fld}]').each(function(el) {
if(el.readOnly) { if(el.readOnly) {
el.observe('click', function(ev) { ev.stop(); var el1 = ev.findElement('input'); el1.blur(); } ); el.observe('click', function(ev) { ev.stop(); var el1 = ev.findElement('input'); el1.blur(); } );
@@ -224,7 +225,7 @@ class e_form
return; return;
} }
new Ajax.Autocompleter(el, el.next('div.e-autocomplete'), '".e_FILE_ABS."e_ajax.php', { new Ajax.Autocompleter(el, el.next('div.e-autocomplete'), '".e_FILE_ABS."e_ajax.php', {
paramName: '{$name}', paramName: '{$name_fld}',
minChars: 2, minChars: 2,
frequency: 0.5, frequency: 0.5,
afterUpdateElement: function(txt, li) { afterUpdateElement: function(txt, li) {
@@ -237,7 +238,7 @@ class e_form
} }
}, },
indicator: el.next('span.indicator'), indicator: el.next('span.indicator'),
parameters: 'ajax_used=1&ajax_sc=usersearch=".rawurlencode('searchfld=user--srcfld='.$name)."' parameters: 'ajax_used=1&ajax_sc=usersearch=".rawurlencode('searchfld='.str_replace('user_', '', vartrue($options['name'], 'user_name')).'--srcfld='.$name_fld)."'
}); });
}); });
"); ");
@@ -264,15 +265,22 @@ class e_form
return "<input type='password' name='{$name}' value='' maxlength='{$maxlength}'".$this->get_attributes($options, $name)." />"; return "<input type='password' name='{$name}' value='' maxlength='{$maxlength}'".$this->get_attributes($options, $name)." />";
} }
//TODO make auto-expanding - like facebook. // autoexpand done
function textarea($name, $value, $rows = 10, $cols = 80, $options = array()) function textarea($name, $value, $rows = 10, $cols = 80, $options = array(), $counter = false)
{ {
$options = $this->format_options('textarea', $name, $options); if(is_string($options)) parse_str($options, $options);
//never allow id in format name-value for text fields // auto-height support
return "<textarea name='{$name}' rows='{$rows}' cols='{$cols}'".$this->get_attributes($options, $name).">{$value}</textarea>"; if(!vartrue($options['noresize']))
{
$options['class'] = $options['class'] ? $options['class'].' e-autoheight' : 'tbox textarea e-autoheight';
} }
function bbarea($name, $value, $help_mod = '', $help_tagid='', $size = 'large') $options = $this->format_options('textarea', $name, $options);
//never allow id in format name-value for text fields
return "<textarea name='{$name}' rows='{$rows}' cols='{$cols}'".$this->get_attributes($options, $name).">{$value}</textarea>".(false !== $counter ? $this->hidden('__'.$name.'autoheight_opt', $counter) : '');
}
function bbarea($name, $value, $help_mod = '', $help_tagid='', $size = 'large', $counter = false)
{ {
//size - large|medium|small //size - large|medium|small
//width should be explicit set by current admin theme //width should be explicit set by current admin theme
@@ -292,7 +300,9 @@ class e_form
$size = 'large'; $size = 'large';
break; break;
} }
$options = array('class' => 'tbox'.($size ? ' '.$size : '').' e-wysiwyg');
// auto-height support
$options = array('class' => 'tbox bbarea '.($size ? ' '.$size : '').' e-wysiwyg');
$bbbar = ''; $bbbar = '';
// FIXME - see ren_help.php // FIXME - see ren_help.php
if(!deftrue('e_WYSIWYG')) if(!deftrue('e_WYSIWYG'))
@@ -304,7 +314,7 @@ class e_form
$ret = " $ret = "
<div class='bbarea {$size}'> <div class='bbarea {$size}'>
".$this->textarea($name, $value, $rows, 50, $options)." ".$this->textarea($name, $value, $rows, 50, $options, $counter)."
<div class='field-spacer'><!-- --></div> <div class='field-spacer'><!-- --></div>
{$bbbar} {$bbbar}
</div> </div>
@@ -951,6 +961,15 @@ class e_form
$tdclass = vartrue($data['class']); $tdclass = vartrue($data['class']);
if($field == 'checkboxes') $tdclass = $tdclass ? $tdclass.' autocheck e-pointer' : 'autocheck e-pointer'; if($field == 'checkboxes') $tdclass = $tdclass ? $tdclass.' autocheck e-pointer' : 'autocheck e-pointer';
// there is no other way for now - prepare user data
if('user' == $data['type']/* && isset($data['readParms']['idField'])*/)
{
if(is_string($data['readParms'])) parse_str($data['readParms'], $data['readParms']);
if(isset($data['readParms']['idField']))
{
$data['readParms']['__idval'] = $fieldvalues[$data['readParms']['idField']];
}
}
$value = $this->renderValue($field, varset($fieldvalues[$field]), $data, varset($fieldvalues[$pid])); $value = $this->renderValue($field, varset($fieldvalues[$field]), $data, varset($fieldvalues[$pid]));
if($tdclass) if($tdclass)
@@ -1110,12 +1129,13 @@ class e_form
$value = implode(vartrue($parms['separator']), $pieces); $value = implode(vartrue($parms['separator']), $pieces);
break; break;
case 'user_name': /*case 'user_name':
case 'user_loginname': case 'user_loginname':
case 'user_login': case 'user_login':
case 'user_customtitle': case 'user_customtitle':
case 'user_email': case 'user_email':*/
if(is_numeric($value)) case 'user':
/*if(is_numeric($value))
{ {
$value = get_user_data($value); $value = get_user_data($value);
if($value) if($value)
@@ -1126,6 +1146,11 @@ class e_form
{ {
$value = 'not found'; $value = 'not found';
} }
}*/
// Dirty, but the only way for now
if(vartrue($parms['__idval']) && vartrue($parms['link']))
{
$value = '<a href="'.e107::getUrl()->createCoreUser('func=profile&id='.intval($parms['__idval'])).'" title="Go to user profile">'.$value.'</a>';
} }
break; break;
@@ -1191,11 +1216,11 @@ class e_form
break; break;
case 'textarea': case 'textarea':
return $this->textarea($key, $value, vartrue($parms['rows'], 5), vartrue($parms['cols'], 40), vartrue($parms['__options'])); return $this->textarea($key, $value, vartrue($parms['rows'], 5), vartrue($parms['cols'], 40), vartrue($parms['__options']), vartrue($parms['counter'], false));
break; break;
case 'bbarea': case 'bbarea':
return $this->bbarea($key, $value, vartrue($parms['help']), vartrue($parms['helptag']), vartrue($parms['size'], 'medium')); return $this->bbarea($key, $value, vartrue($parms['help']), vartrue($parms['helptag']), vartrue($parms['size'], 'medium'), vartrue($parms['counter'], false));
break; break;
case 'image': //TODO - thumb, image list shortcode, js tooltip... case 'image': //TODO - thumb, image list shortcode, js tooltip...
@@ -1237,7 +1262,7 @@ class e_form
case 'user_email':*/ case 'user_email':*/
case 'user': case 'user':
//user_id expected //user_id expected
// Just temporary solution, will be changed soon // Just temporary solution, could be changed soon
if(!is_array($value)) if(!is_array($value))
{ {
$value = get_user_data($value); $value = get_user_data($value);
@@ -1245,7 +1270,7 @@ class e_form
if(!$value) $value = array(); if(!$value) $value = array();
$uname = varset($value['user_name']); $uname = varset($value['user_name']);
$value = varset($value['user_id'], 0); $value = varset($value['user_id'], 0);
return $this->userpicker($key.'_usersearch', $key, $uname, $value, $parms); return $this->userpicker(vartrue($parms['nameField'] ,$key.'_usersearch'), $key, $uname, $value, $parms);
break; break;
case 'boolean': case 'boolean':
@@ -1260,7 +1285,7 @@ class e_form
break; break;
default: default:
//unknown type return $value;
break; break;
} }
} }

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.35 $ * $Revision: 1.36 $
* $Date: 2009-11-09 12:21:17 $ * $Date: 2009-11-10 19:13:06 $
* $Author: secretr $ * $Author: secretr $
*/ */
@@ -1701,6 +1701,7 @@ class e_admin_model extends e_model
$this->_db_errno = 0; $this->_db_errno = 0;
if($this->hasError() || (!$this->data_has_changed && !$force)) if($this->hasError() || (!$this->data_has_changed && !$force))
{ {
$this->addMessageInfo(LAN_NO_CHANGE);
return 0; return 0;
} }
$res = e107::getDb()->db_Update($this->getModelTable(), $this->toSqlQuery('update')); $res = e107::getDb()->db_Update($this->getModelTable(), $this->toSqlQuery('update'));
@@ -1713,6 +1714,7 @@ class e_admin_model extends e_model
$this->addMessageDebug('SQL Error #'.$this->_db_errno.': '.e107::getDb()->getLastErrorText()); $this->addMessageDebug('SQL Error #'.$this->_db_errno.': '.e107::getDb()->getLastErrorText());
return false; return false;
} }
$this->addMessageInfo(LAN_NO_CHANGE); $this->addMessageInfo(LAN_NO_CHANGE);
return 0; return 0;
} }

View File

@@ -1,6 +1,8 @@
<?php <?php
if (!defined('e107_INIT'))
if (!defined('e107_INIT')) { exit; } {
exit;
}
// e107 requires PHP > 4.3.0, all functions that are used in e107, introduced in newer // e107 requires PHP > 4.3.0, all functions that are used in e107, introduced in newer
// versions than that should be recreated in here for compatabilty reasons.. // versions than that should be recreated in here for compatabilty reasons..
@@ -22,7 +24,8 @@ if (!function_exists('file_put_contents'))
{ {
return false; return false;
} }
if (is_array($data)) $data = implode($data); if (is_array($data))
$data = implode($data);
if (($bytes = @fwrite($h, $data)) === false) if (($bytes = @fwrite($h, $data)) === false)
{ {
return false; return false;
@@ -32,8 +35,6 @@ if (!function_exists('file_put_contents'))
} }
} }
if (!function_exists('stripos')) if (!function_exists('stripos'))
{ {
function stripos($str, $needle, $offset = 0) function stripos($str, $needle, $offset = 0)
@@ -52,7 +53,9 @@ if(!function_exists('simplexml_load_string'))
var $obj_data; var $obj_data;
var $pointer; var $pointer;
function CXml() { } function CXml()
{
}
function Set_xml_data(&$xml_data) function Set_xml_data(&$xml_data)
{ {
@@ -127,5 +130,103 @@ if(!function_exists('simplexml_load_string'))
return $data; return $data;
} }
}
/*
* This work of Lionel SAURON (http://sauron.lionel.free.fr:80) is licensed under the
* Creative Commons Attribution-Noncommercial-Share Alike 2.0 France License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/2.0/fr/
* or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
*/
/**
* http://snipplr.com/view/4964/emulate-php-5-for-backwards-compatibility/
*
* Parse a date generated with strftime().
* PHP Compatibility *nix v5.1.0+, all $M
*
* This function is the same as the original one defined by PHP (Linux/Unix only),
* but now you can use it on Windows too.
* Limitation : Only this format can be parsed %S, %M, %H, %d, %m, %Y
*
* @author Lionel SAURON
* @version 1.0
* @public
*
* @param string $str date string to parse (e.g. returned from strftime()).
* @param string $sFormat strftime format used to create the date
* @return array Returns an array with the <code>$str</code> parsed, or <code>false</code> on error.
*/
if (!function_exists('strptime'))
{
define('STRPTIME_COMPAT', true);
function strptime($str, $format)
{
static $expand = array('%D'=>'%m/%d/%y', '%T'=>'%H:%M:%S', );
static $map_r = array('%S'=>'tm_sec', '%M'=>'tm_min', '%H'=>'tm_hour', '%d'=>'tm_mday', '%m'=>'tm_mon', '%Y'=>'tm_year', '%y'=>'tm_year', /*'%W'=>'tm_wday', '%D'=>'tm_yday',*/ '%u'=>'unparsed', );
#-- TODO - not so useful, locale is breaking it, so use date() and mktime() to generate the array below
static $names = array('Jan'=>1, 'Feb'=>2, 'Mar'=>3, 'Apr'=>4, 'May'=>5, 'Jun'=>6, 'Jul'=>7, 'Aug'=>8, 'Sep'=>9, 'Oct'=>10, 'Nov'=>11, 'Dec'=>12, 'Sun'=>0, 'Mon'=>1, 'Tue'=>2, 'Wed'=>3, 'Thu'=>4, 'Fri'=>5, 'Sat'=>6 );
#-- transform $format into extraction regex
$format = str_replace(array_keys($expand), array_values($expand), $format);
$preg = preg_replace('/(%\w)/', '(\w+)', preg_quote($format));
#-- record the positions of all STRFCMD-placeholders
preg_match_all('/(%\w)/', $format, $positions);
$positions = $positions[1];
#-- get individual values
if (preg_match("#$preg#", $str, $extracted))
{
#-- get values
foreach ($positions as $pos => $strfc)
{
$v = $extracted[$pos + 1];
#-- add
if (isset($map_r[$strfc]))
{
$n = $map_r[$strfc];
$vals[$n] = ($v > 0) ? (int) $v : $v;
}
else
{
$vals['unparsed'] .= $v.' ';
}
}
#-- fixup some entries
//$vals["tm_wday"] = $names[ substr($vals["tm_wday"], 0, 3) ];
if ($vals['tm_year'] >= 1900)
{
$vals['tm_year'] -= 1900;
}
elseif ($vals['tm_year'] > 0)
{
$vals['tm_year'] += 100;
}
if ($vals['tm_mon'])
{
$vals['tm_mon'] -= 1;
}
else
{
$vals['tm_mon'] = $names[substr($vals['tm_mon'], 0, 3)] - 1;
}
//$vals['tm_sec'] -= 1; always increasing tm_sec + 1 ??????
#-- calculate wday/yday
$unxTimestamp = mktime($vals['tm_hour'], $vals['tm_min'], $vals['tm_sec'], ($vals['tm_mon'] + 1), $vals['tm_mday'], ($vals['tm_year'] + 1900));
$vals['tm_wday'] = (int) strftime('%w', $unxTimestamp); // Days since Sunday (0-6)
$vals['tm_yday'] = (strftime('%j', $unxTimestamp) - 1); // Days since January 1 (0-365)
//var_dump($vals, $str, strftime($format, $unxTimestamp), $unxTimestamp);
}
return isset($vals) ? $vals : false;
}
} }

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_plugins/faqs/admin_config.php,v $ | $Source: /cvs_backup/e107_0.8/e107_plugins/faqs/admin_config.php,v $
| $Revision: 1.2 $ | $Revision: 1.3 $
| $Date: 2009-11-09 16:54:28 $ | $Date: 2009-11-10 19:13:05 $
| $Author: secretr $ | $Author: secretr $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -88,6 +88,10 @@ class faq_main_ui extends e_admin_ui
protected $pluginName = 'faqs'; protected $pluginName = 'faqs';
protected $table = "faqs"; protected $table = "faqs";
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. protected $listQry = "SELECT * FROM #faqs"; // without any Order or Limit.
protected $editQry = "SELECT * FROM #faqs WHERE faq_id = {ID}"; protected $editQry = "SELECT * FROM #faqs WHERE faq_id = {ID}";
@@ -100,14 +104,15 @@ class faq_main_ui extends e_admin_ui
protected $fields = array( protected $fields = array(
'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'), 'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'),
'faq_id' => array('title'=> LAN_ID, 'type' => 'int', 'width' =>'5%', 'forced'=> TRUE), 'faq_id' => array('title'=> LAN_ID, 'type' => 'int', 'width' =>'5%', 'forced'=> TRUE),
'faq_question' => array('title'=> "Question", 'type' => 'text', 'width' => 'auto', 'thclass' => 'left first'), // Display name
'faq_question' => array('title'=> "Question", 'type' => 'text', 'data'=> 'str', 'width' => 'auto', 'thclass' => 'left first'), // Display name 'faq_answer' => array('title'=> "Answer", 'type' => 'bbarea', 'width' => '30%', 'readParms' => 'expand=...&truncate=50&bb=1'), // Display name
'faq_answer' => array('title'=> "Answer", 'type' => 'bbarea', 'data'=> 'str','width' => '30%', 'readParms' => 'expand=...&truncate=50&bb=1'), // Display name
'faq_parent' => array('title'=> "Category", 'type' => 'method', 'data'=> 'int','width' => '5%', 'filter'=>TRUE, 'batch'=>TRUE), '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_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_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', 'thclass' => 'center', 'class'=>'center', 'filter' => true, 'batch' => true, 'width' => 'auto'), // Photo
'faq_order' => array('title'=> "Order", 'type' => 'int', 'data'=> 'int','width' => '5%', 'thclass' => 'center' ), // Real name (no real vetting) '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)
'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center') 'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center')
); );
@@ -121,44 +126,73 @@ class faq_main_ui extends e_admin_ui
'classic_look' => array('title'=> 'Use Classic Layout', 'type'=>'boolean') 'classic_look' => array('title'=> 'Use Classic Layout', 'type'=>'boolean')
); );
} /**
* FAQ categories
* @var array
*/
protected $categories = null;
//TODO Block and Unblock buttons, moderated comments? /**
class faq_admin_form_ui extends e_admin_form_ui * Get FAQ Category data
* @param integer $id [optional] get category title, false - return whole array
* @param object $default [optional] default value if not found (default 'n/a')
* @return
*/
function getFaqCategory($id = false, $default = 'n/a')
{ {
var $categories = array('hello','hello2','hello3');
//FIXME Breaks everything!!! if(null === $this->categories) //auto-retrieve on first call
/*
function __construct()
{ {
$sql = e107::getDb(); $sql = e107::getDb();
$sql->db_Select('faq_info'); if($sql->db_Select('faqs_info'))
{
while ($row = $sql->db_Fetch()) while ($row = $sql->db_Fetch())
{ {
$id = $row['faq_info_id']; $this->categories[$row['faq_info_id']] = $row['faq_info_title'];
$this->categories[$id] = $row['faq_info_title'];
echo "hello";
} }
} }
else
{
$this->categories = array(); //prevent PHP warnings
}
}
if(false === $id)
{
return $this->categories;
}
return vartrue($this->categories[$id], $default);
}
}
class faq_admin_form_ui extends e_admin_form_ui
{
/**
* faq_parent field method
*
* @param integer $curVal
* @param string $mode
* @return mixed
*/ */
function faq_parent($curVal,$mode) function faq_parent($curVal,$mode)
{ {
if($mode == 'read') // Get UI instance
{ $controller = $this->getController();
return $curVal.' (custom!)';
}
if($mode == 'filter') // Custom Filter List for release_type switch($mode)
{ {
return array(1=>'Category 1',2=>'Category 2',3=>'Category 3'); case 'read':
} return e107::getParser()->toHTML($controller->getFaqCategory($curVal), false, 'TITLE');
break;
if($mode == 'batch') case 'write':
{ return $this->selectbox('faq_parent', $controller->getFaqCategory(), $curVal);
break;
case 'filter':
case 'batch':
return $controller->getFaqCategory();
break;
} }
} }
} }

View File

@@ -9,8 +9,8 @@
* Release Plugin Administration UI * Release Plugin Administration UI
* *
* $Source: /cvs_backup/e107_0.8/e107_plugins/release/includes/admin.php,v $ * $Source: /cvs_backup/e107_0.8/e107_plugins/release/includes/admin.php,v $
* $Revision: 1.7 $ * $Revision: 1.8 $
* $Date: 2009-11-09 16:54:28 $ * $Date: 2009-11-10 19:13:06 $
* $Author: secretr $ * $Author: secretr $
*/ */
@@ -70,24 +70,38 @@ class plugin_release_admin_ui extends e_admin_ui
*/ */
protected $pluginName = 'release'; protected $pluginName = 'release';
// required /**
* DB Table, table alias is supported
* Example: 'r.release'
* @var string
*/
protected $table = "release"; protected $table = "release";
/** /**
* If present this array will be used to build your list query * If present this array will be used to build your list query
* You can link fileds from $field array with 'table' parameter, which should equal to a key (table) from this array * You can link fileds from $field array with 'table' parameter, which should equal to a key (table) from this array
* 'leftField', 'rightField' and 'fields' attributes here are required, the rest is optional * 'leftField', 'rightField' and 'fields' attributes here are required, the rest is optional
* Table alias is supported
* Note:
* - 'leftTable' could contain only table alias
* - 'leftField' and 'rightField' shouldn't contain table aliases, they will be auto-added
* - 'whereJoin' and 'where' should contain table aliases e.g. 'whereJoin' => 'AND u.user_ban=0'
* *
* @var array [optional] table_name => array join parameters * @var array [optional] table_name => array join parameters
*/ */
protected $tableJoin = array( protected $tableJoin = array(
//'user' => array('leftField' => 'user_id', 'rightField' => 'comment_author_id', 'fields' => '*'/*, 'joinType' => 'LEFT JOIN', 'whereJoin' => '', 'where' => ''*/) //'u.user' => array('leftField' => 'comment_author_id', 'rightField' => 'user_id', 'fields' => '*'/*, 'leftTable' => '', 'joinType' => 'LEFT JOIN', 'whereJoin' => '', 'where' => ''*/)
); );
// required if no custom tree model is set in init() /**
// NOT NEEDED ANYMORE!!! * This is only needed if you need to JOIN tables AND don't wanna use $tableJoin
//protected $listQry = "SELECT * FROM #release"; * Write your list query without any Order or Limit.
// without any Order or Limit. * NOTE: $tableJoin array is recommended join method
*
* @var string [optional]
*/
protected $listQry = "";
//
// optional - required only in case of e.g. tables JOIN. This also could be done with custom model (set it in init()) // optional - required only in case of e.g. tables JOIN. This also could be done with custom model (set it in init())
// NOT NEEDED ANYMORE!!! // NOT NEEDED ANYMORE!!!
@@ -114,6 +128,9 @@ class plugin_release_admin_ui extends e_admin_ui
* (use this as starting point for wiki documentation) * (use this as starting point for wiki documentation)
* $fields format (string) $field_name => (array) $attributes * $fields format (string) $field_name => (array) $attributes
* *
* $field_name format:
* 'table_alias.field_name' (if JOIN support is needed) OR just 'field_name'
*
* $attributes format: * $attributes format:
* - title (string) Human readable field title, constant name will be accpeted as well (multi-language support * - title (string) Human readable field title, constant name will be accpeted as well (multi-language support
* *
@@ -123,12 +140,11 @@ class plugin_release_admin_ui extends e_admin_ui
* for list of possible read/writeParms per type see below * for list of possible read/writeParms per type see below
* *
* - data (string) Data type, one of the following: int, integer, string, str, float, bool, boolean, model, null * - data (string) Data type, one of the following: int, integer, string, str, float, bool, boolean, model, null
* Default is 'str'
* Used only if $dataFields is not set * Used only if $dataFields is not set
* full/most recent reference list - e_admin_model::sanitize(), db::_getFieldValue() * full/most recent reference list - e_admin_model::sanitize(), db::_getFieldValue()
* - primary (boolean) primary field (obsolete, $pid is now used) * - primary (boolean) primary field (obsolete, $pid is now used)
* *
* - table (string) if there and non-empty - value is coming from another table, which SHOULD be found in $tableJoin (see above)
*
* - help (string) edit/create table - inline help, constant name will be accpeted as well, optional * - help (string) edit/create table - inline help, constant name will be accpeted as well, optional
* - note (string) edit/create table - text shown below the field title (left column), constant name will be accpeted as well, optional * - note (string) edit/create table - text shown below the field title (left column), constant name will be accpeted as well, optional
* *
@@ -161,6 +177,9 @@ class plugin_release_admin_ui extends e_admin_ui
* - null -> read: n/a * - null -> read: n/a
* -> write: n/a * -> 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;
*
* - number -> read: (array) [optional] 'point' => '.', [optional] 'sep' => ' ', [optional] 'decimals' => 2, [optional] 'pre' => '&euro; ', [optional] 'post' => 'LAN_CURRENCY' * - number -> read: (array) [optional] 'point' => '.', [optional] 'sep' => ' ', [optional] 'decimals' => 2, [optional] 'pre' => '&euro; ', [optional] 'post' => 'LAN_CURRENCY'
* -> write: (array) [optional] 'pre' => '&euro; ', [optional] 'post' => 'LAN_CURRENCY', [optional] 'maxlength' => 50, [optional] '__options' => array(...) see e_form class description for __options format * -> write: (array) [optional] 'pre' => '&euro; ', [optional] 'post' => 'LAN_CURRENCY', [optional] 'maxlength' => 50, [optional] '__options' => array(...) see e_form class description for __options format
* *