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

admin UI: more improvements and bugfixes

This commit is contained in:
secretr
2009-11-18 14:46:28 +00:00
parent 10effc2232
commit 1ad5400d0b
4 changed files with 81 additions and 49 deletions

View File

@@ -9,9 +9,9 @@
* Image Administration Area * Image Administration Area
* *
* $Source: /cvs_backup/e107_0.8/e107_admin/image.php,v $ * $Source: /cvs_backup/e107_0.8/e107_admin/image.php,v $
* $Revision: 1.36 $ * $Revision: 1.37 $
* $Date: 2009-11-18 10:16:50 $ * $Date: 2009-11-18 14:46:28 $
* $Author: e107coders $ * $Author: secretr $
* *
*/ */
require_once("../class2.php"); require_once("../class2.php");
@@ -232,20 +232,20 @@ class media_admin_ui extends e_admin_ui
protected $fields = array( protected $fields = array(
'checkboxes' => array('title'=> '', 'type' => null, 'data'=> null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'), 'checkboxes' => array('title'=> '', 'type' => null, 'data'=> null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'),
'media_id' => array('title'=> LAN_ID, 'type' => 'int', 'data'=> 'int', 'width' =>'5%', 'forced'=> TRUE), 'media_id' => array('title'=> LAN_ID, 'type' => 'number', 'data'=> 'int', 'width' =>'5%', 'forced'=> TRUE),
'media_url' => array('title'=> 'Preview', 'type' => 'image', 'data'=> 'str', 'thclass' => 'center', 'class'=>'center', 'readParms'=>'thumb=100', 'width' => 'auto','readonly'=>TRUE), 'media_url' => array('title'=> 'Preview', 'type' => 'image', 'data'=> 'str', 'thclass' => 'center', 'class'=>'center', 'readParms'=>'thumb=100', 'width' => 'auto','readonly'=>TRUE),
// 'media_preview' => array('title'=> "Preview", 'type' => 'image', 'data'=> null, 'width' => '10%'), // 'media_preview' => array('title'=> "Preview", 'type' => 'image', 'data'=> null, 'width' => '10%'),
'media_upload' => array('title'=> "Upload File", 'type' => 'upload', 'data'=> null, 'readParm' => 'hidden', 'width' => '10%'), 'media_upload' => array('title'=> "Upload File", 'type' => 'upload', 'data'=> false, 'readParm' => 'hidden', 'width' => '10%', 'nolist' => true),
'media_name' => array('title'=> LAN_TITLE, 'type' => 'text', 'data'=> 'str', 'width' => '5%'), 'media_name' => array('title'=> LAN_TITLE, 'type' => 'text', 'data'=> 'str', 'width' => '5%'),
'media_caption' => array('title'=> "Caption", 'type' => 'text', 'data'=> 'str', 'width' => '5%'), 'media_caption' => array('title'=> "Caption", 'type' => 'text', 'data'=> 'str', 'width' => '5%'),
'media_description' => array('title'=> LAN_DESCRIPTION, 'type' => 'textarea', 'data'=> 'str', 'width' => 'auto', 'thclass' => 'left first'), 'media_description' => array('title'=> LAN_DESCRIPTION, 'type' => 'bbarea', 'data'=> 'str', 'width' => 'auto', 'thclass' => 'left first', 'readParms' => 'truncate=100', 'writeParms' => 'counter=0'),
'media_category' => array('title'=> LAN_CATEGORY, 'type' => 'method', 'data'=> 'str', 'width' => '30%', 'filter' => true, 'batch' => true,), 'media_category' => array('title'=> LAN_CATEGORY, 'type' => 'method', 'data'=> 'str', 'width' => '30%', 'filter' => true, 'batch' => true,),
'media_type' => array('title'=> "Mime Type", 'type' => 'text', 'data'=> 'str', 'width' => '5%', 'noedit'=>TRUE), 'media_type' => array('title'=> "Mime Type", 'type' => 'text', 'data'=> 'str', 'width' => '5%', 'noedit'=>TRUE),
// 'media_author' => array('title'=> LAN_AUTHOR, 'type' => 'user', 'data'=> 'int'), // 'media_author' => array('title'=> LAN_AUTHOR, 'type' => 'user', 'data'=> 'int'),
'media_author' => array('title'=> LAN_USER, 'type' => 'user', 'data'=> 'int', 'width' => 'auto', 'thclass' => 'center', 'class'=>'center', 'filter' => true, 'batch' => true, 'noedit'=>TRUE ), 'media_author' => array('title'=> LAN_USER, 'type' => 'user', 'data'=> 'int', 'width' => 'auto', 'thclass' => 'center', 'class'=>'center', 'filter' => true, 'batch' => true, 'noedit'=>TRUE ),
'media_datestamp' => array('title'=> LAN_DATESTAMP, 'type' => 'datestamp', 'data'=> 'int', 'width' => 'auto', 'noedit'=>TRUE), // User date 'media_datestamp' => array('title'=> LAN_DATESTAMP, 'type' => 'datestamp', 'data'=> 'int', 'width' => 'auto', 'noedit'=>TRUE), // User date
'media_size' => array('title'=> "Size", 'type' => 'int', 'data'=> 'int', 'width' => 'auto', 'noedit'=>TRUE), 'media_size' => array('title'=> "Size", 'type' => 'number', 'data'=> 'int', 'width' => 'auto', 'noedit'=>TRUE),
'media_dimensions' => array('title'=> "Dimensions", 'type' => 'text', 'data'=> 'str', 'width' => '5%', 'noedit'=>TRUE), 'media_dimensions' => array('title'=> "Dimensions", 'type' => 'text', 'data'=> 'str', 'width' => '5%', 'noedit'=>TRUE),
'media_userclass' => array('title'=> LAN_USERCLASS, 'type' => 'userclass', 'data'=> 'str', 'width' => '10%', 'thclass' => 'center','filter'=>TRUE,'batch'=>TRUE ), 'media_userclass' => array('title'=> LAN_USERCLASS, 'type' => 'userclass', 'data'=> 'str', 'width' => '10%', 'thclass' => 'center','filter'=>TRUE,'batch'=>TRUE ),
'media_tags' => array('title'=> "Tags/Keywords", 'type' => 'text', 'data'=> 'str', 'width' => '10%', 'filter'=>TRUE,'batch'=>TRUE ), 'media_tags' => array('title'=> "Tags/Keywords", 'type' => 'text', 'data'=> 'str', 'width' => '10%', 'filter'=>TRUE,'batch'=>TRUE ),
@@ -255,7 +255,7 @@ class media_admin_ui extends e_admin_ui
); );
protected $mimePaths = array( protected $mimePaths = array(
"text" => 'files', 'text' => 'files',
'multipart' => 'files', 'multipart' => 'files',
'application' => 'files', 'application' => 'files',
'audio' => 'audio', 'audio' => 'audio',
@@ -288,8 +288,8 @@ class media_admin_ui extends e_admin_ui
{ {
// return data to be merged with posted model data // return data to be merged with posted model data
$this->getRequest()->setPosted('media_upload', null); $this->getRequest()->setPosted('media_upload', null);
$dataFields = $this->getModel()->getDataFields(); //$dataFields = $this->getModel()->getDataFields();
unset($dataFields['media_upload']); //unset($dataFields['media_upload']);
$this->getModel()->setDataFields($dataFields); $this->getModel()->setDataFields($dataFields);
return $this->observeUploaded($new_data); return $this->observeUploaded($new_data);
} }
@@ -301,13 +301,13 @@ class media_admin_ui extends e_admin_ui
public function beforeUpdate($new_data, $old_data, $id) public function beforeUpdate($new_data, $old_data, $id)
{ {
// return data to be merged with posted model data // return data to be merged with posted model data
return $this->observeUploaded(); return $this->observeUploaded($new_data);
} }
// XXX - strict mysql error on Create without UPLOAD!
function observeUploaded($new_data) function observeUploaded($new_data)
{ {
$mes = e107::getMessage(); $mes = e107::getMessage();
$pref['upload_storagetype'] = "1"; $pref['upload_storagetype'] = "1";
require_once(e_HANDLER."upload_handler.php"); //TODO - still not a class! require_once(e_HANDLER."upload_handler.php"); //TODO - still not a class!
@@ -339,6 +339,8 @@ class media_admin_ui extends e_admin_ui
'media_tags' => '' 'media_tags' => ''
); );
//TODO - media_dimensions
if(!varset($new_data['media_name'])) if(!varset($new_data['media_name']))
{ {
$upload_data['media_name'] = $upload['name']; $upload_data['media_name'] = $upload['name'];
@@ -353,7 +355,7 @@ class media_admin_ui extends e_admin_ui
}; };
return $upload_data; return $upload_data;
} }
} }
function beforeDelete($data, $id) // call before 'delete' is executed. - return false to prevent delete execution (e.g. some dependencies check) function beforeDelete($data, $id) // call before 'delete' is executed. - return false to prevent delete execution (e.g. some dependencies check)
@@ -1181,18 +1183,18 @@ function del_pref_val()
* *
* @return string JS source * @return string JS source
*/ */
function headerjs() //function headerjs()
{ //{
require_once(e_HANDLER.'js_helper.php'); // require_once(e_HANDLER.'js_helper.php');
//FIXME - how exactly to auto-call JS lan? This and more should be solved in Stage II. // //FIXME - how exactly to auto-call JS lan? This and more should be solved in Stage II.
$ret = " // $ret = "
<script type='text/javascript'> // <script type='text/javascript'>
//add required core lan - delete confirm message // //add required core lan - delete confirm message
(".e_jshelper::toString(LAN_JSCONFIRM).").addModLan('core', 'delete_confirm'); // (".e_jshelper::toString(LAN_JSCONFIRM).").addModLan('core', 'delete_confirm');
</script> // </script>
<script type='text/javascript' src='".e_FILE_ABS."jslib/core/admin.js'></script> // <script type='text/javascript' src='".e_FILE_ABS."jslib/core/admin.js'></script>
"; // ";
//
return $ret; // return $ret;
} //}
?> ?>

View File

@@ -9,8 +9,8 @@
* Administration UI handlers, admin helper functions * Administration UI handlers, admin helper functions
* *
* $Source: /cvs_backup/e107_0.8/e107_handlers/admin_handler.php,v $ * $Source: /cvs_backup/e107_0.8/e107_handlers/admin_handler.php,v $
* $Revision: 1.32 $ * $Revision: 1.33 $
* $Date: 2009-11-18 09:32:31 $ * $Date: 2009-11-18 14:46:27 $
* $Author: secretr $ * $Author: secretr $
*/ */
@@ -2117,19 +2117,43 @@ class e_admin_controller_ui extends e_admin_controller
* @param string $field * @param string $field
* @param string $key attribute name * @param string $key attribute name
* @param mixed $value default value if not set, default is null * @param mixed $value default value if not set, default is null
* @return mixed FIXME * @return e_admin_controller_ui
*/ */
public function setFieldAttr($field, $key = null, $default = null) public function setFieldAttr($field, $key = null, $value = null)
{ {
if(isset($this->fields[$field])) // add field array
if(is_array($field))
{ {
if(null !== $key) foreach ($field as $f => $atts)
{ {
return isset($this->fields[$field][$key]) ? $this->fields[$field][$key] : $default; $this->setFieldAttr($f, $atts);
} }
return $this->fields[$field]; return $this;
} }
return $default; // remove a field
if(null === $key)
{
unset($this->fields[$field]);
return $this;
}
// add to attribute array of a field
if(is_array($key))
{
foreach ($key as $k => $att)
{
$this->setFieldAttr($field, $k, $att);
}
return $this;
}
// remove attribute from field attribute set
if(null === $value && $key != 'type')
{
unset($this->fields[$field][$key]);
return $this;
}
// set attribute value
$this->fields[$field][$key] = $value;
return $this;
} }
/** /**
@@ -2552,7 +2576,7 @@ class e_admin_controller_ui extends e_admin_controller
* @param string $type current action type - edit, create, list or user defined * @param string $type current action type - edit, create, list or user defined
* @return void * @return void
*/ */
protected function toData(&$data, $type) protected function toData(&$data, $type = '')
{ {
} }
@@ -2597,11 +2621,13 @@ class e_admin_controller_ui extends e_admin_controller
*/ */
protected function renderAjaxFilterResponse($listQry = '') protected function renderAjaxFilterResponse($listQry = '')
{ {
$ret = '<ul>';
$ret .= "<li><span class='informal warning'> clear filter </span></li>";
$srch = $this->getPosted('searchquery'); $srch = $this->getPosted('searchquery');
$this->getRequest()->setQuery('searchquery', $srch); //_modifyListQry() is requiring GET String $this->getRequest()->setQuery('searchquery', $srch); //_modifyListQry() is requiring GET String
$ret = '<ul>';
$ret .= '<li>'.$srch.'<span class="informal warning"> (typed)</span></li>'; // fix Enter - search for typed word only
$reswords = array(); $reswords = array();
if(trim($srch) !== '') if(trim($srch) !== '')
{ {
@@ -2637,6 +2663,7 @@ class e_admin_controller_ui extends e_admin_controller
} }
} }
$ret .= '<li><span class="informal warning"> clear filter </span></li>'; // clear filter option
$ret .= '</ul>'; $ret .= '</ul>';
return $ret; return $ret;
} }
@@ -2881,6 +2908,8 @@ class e_admin_controller_ui extends e_admin_controller
$data = $this->$callbackBefore($_posted, $old_data, $model->getId()); $data = $this->$callbackBefore($_posted, $old_data, $model->getId());
if(false === $data) if(false === $data)
{ {
// we don't wanna loose posted data
$model->setPostedData($_posted, null, false, false);
return false; return false;
} }
if($data && is_array($data)) if($data && is_array($data))
@@ -3394,7 +3423,7 @@ 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['forceSave'])) if((false !== varset($att['data']) && null !== $att['type'] && !vartrue($att['noedit'])) || vartrue($att['forceSave']))
{ {
$this->dataFields[$key] = vartrue($att['data'], 'str'); $this->dataFields[$key] = vartrue($att['data'], 'str');
} }

View File

@@ -9,9 +9,9 @@
* 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.84 $ * $Revision: 1.85 $
* $Date: 2009-11-18 07:16:42 $ * $Date: 2009-11-18 14:46:25 $
* $Author: e107coders $ * $Author: secretr $
* *
*/ */
@@ -1064,9 +1064,10 @@ class e_form
if($attributes['type'] == 'bbarea' && !isset($parms['bb'])) $parms['bb'] = true; //force bb parsing for bbareas if($attributes['type'] == 'bbarea' && !isset($parms['bb'])) $parms['bb'] = true; //force bb parsing for bbareas
$elid = trim(str_replace('_', '-', $field)).'-'.$id; $elid = trim(str_replace('_', '-', $field)).'-'.$id;
if(!vartrue($parms['noparse'])) $value = $tp->toHTML($value, (vartrue($parms['bb']) ? true : false), vartrue($parms['parse'])); if(!vartrue($parms['noparse'])) $value = $tp->toHTML($value, (vartrue($parms['bb']) ? true : false), vartrue($parms['parse']));
if(vartrue($parms['expand'])) if(vartrue($parms['expand']) || vartrue($parms['truncate']) || vartrue($parms['htmltruncate']))
{ {
$expand = '&nbsp;<a href="#'.$elid.'-expand" class="e-show-if-js e-expandit">'.defset($parms['expand'], $parms['expand'])."</a>"; $ttl = vartrue($parms['expand'], '&nbsp;...');
$expand = '&nbsp;<a href="#'.$elid.'-expand" class="e-show-if-js e-expandit">'.defset($ttl, $ttl)."</a>";
} }
$oldval = $value; $oldval = $value;

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.41 $ * $Revision: 1.42 $
* $Date: 2009-11-18 09:32:31 $ * $Date: 2009-11-18 14:46:27 $
* $Author: secretr $ * $Author: secretr $
*/ */
@@ -2003,7 +2003,7 @@ class e_tree_model extends e_model
*/ */
function getTree($force = false) function getTree($force = false)
{ {
return $this->get('__tree'); return $this->get('__tree', array());
} }
/** /**