From 99501721e4570a75c7cc826e004c8f94d941029b Mon Sep 17 00:00:00 2001 From: secretr Date: Fri, 12 Dec 2008 23:29:32 +0000 Subject: [PATCH] more Administration work - image & cache ready (new message & form handlers implemented as well) --- e107_admin/cache.php | 31 ++++++++-------- e107_handlers/form_handler.php | 59 +++++++++++++++++-------------- e107_handlers/message_handler.php | 6 ++-- 3 files changed, 53 insertions(+), 43 deletions(-) diff --git a/e107_admin/cache.php b/e107_admin/cache.php index ab604b8ad..e11e4775e 100644 --- a/e107_admin/cache.php +++ b/e107_admin/cache.php @@ -9,8 +9,8 @@ * Cache Administration Area * * $Source: /cvs_backup/e107_0.8/e107_admin/cache.php,v $ - * $Revision: 1.6 $ - * $Date: 2008-12-12 16:36:45 $ + * $Revision: 1.7 $ + * $Date: 2008-12-12 23:29:32 $ * $Author: secretr $ * */ @@ -25,8 +25,11 @@ $e_sub_cat = 'cache'; require_once("auth.php"); require_once(e_HANDLER."cache_handler.php"); +require_once(e_HANDLER."form_handler.php"); require_once(e_HANDLER."message_handler.php"); $ec = new ecache; +$frm = new e_form(); + $emessage = &eMessage::getInstance(); if ($pref['cachestatus'] == '2') @@ -114,10 +117,10 @@ $text = "
".CACLAN_13."
- -    - - + ".$frm->radio('cachestatus', 1, ($pref['cachestatus']))." + ".$frm->label(LAN_ENABLED, 'cachestatus', 1)."   + ".$frm->radio('cachestatus', 0, (!$pref['cachestatus']))." + ".$frm->label(LAN_DISABLED, 'cachestatus', 0)." @@ -126,23 +129,23 @@ $text = "
".CACLAN_14."
- -    - - + ".$frm->radio('syscachestatus', 1, ($pref['syscachestatus']))." + ".$frm->label(LAN_ENABLED, 'syscachestatus', 1)."   + ".$frm->radio('syscachestatus', 0, (!$pref['syscachestatus']))." + ".$frm->label(LAN_DISABLED, 'syscachestatus', 0)."
- - - + ".$frm->admin_button('submit_cache', CACLAN_2, 'update f-right')." + ".$frm->admin_button('empty_cache', CACLAN_5, 'delete')." + ".$frm->admin_button('empty_syscache', CACLAN_16, 'delete')."
"; -$ns->tablerender(CACLAN_3, $text); +$ns->tablerender(CACLAN_3, $emessage->render().$text); require_once("footer.php"); ?> \ No newline at end of file diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index 659c6b874..77b08be4f 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.5 $ - * $Date: 2008-12-12 22:39:17 $ + * $Revision: 1.6 $ + * $Date: 2008-12-12 23:29:32 $ * $Author: secretr $ * */ @@ -74,34 +74,33 @@ class e_form function text($name, $value, $maxlength = 200, $options = array()) { $options = $this->format_options('text', $name, $options); - return "get_attributes($options)." />"; + return "get_attributes($options, $name, $value)." />"; } function file($name, $options = array()) { $options = $this->format_options('text', $name, $options); - return "get_attributes($options)." />"; + return "get_attributes($options, $name, $value)." />"; } function password($name, $maxlength = 50, $options = array()) { $options = $this->format_options('text', $name, $options); - return "get_attributes($options)." />"; + return "get_attributes($options, $name, $value)." />"; } - function textarea($name, $value, $rows = 15, $cols = 40, $options = array()) { $options = $this->format_options('textarea', $name, $options); - return ""; + return ""; } function checkbox($name, $value, $checked = false, $options = array()) { $options['checked'] = $checked; //comes as separate argument just for convenience $options = $this->format_options('checkbox', $name, $options); - return "get_attributes($options)." />"; + return "get_attributes($options, $name, $value)." />"; } @@ -109,20 +108,20 @@ class e_form { $options['checked'] = $checked; //comes as separate argument just for convenience $options = $this->format_options('radio', $name, $options); - return "get_attributes($options)." />"; + return "get_attributes($options, $name, $value)." />"; } - function label($text, $for_id, $name = '') + function label($text, $name = '', $value = '') { - if($name) $for_id = $this->_format_id($for_id, $name); - return ""; + $for_id = $this->_format_id('', $name, $value, 'for'); + return "{$text}"; } function select_open($name, $options = array()) { $options = $this->format_options('select', $name, $options); - return "get_attributes($options, $name).">"; } function optgroup_open($label, $disabled) @@ -151,37 +150,37 @@ class e_form function hidden($name, $value, $options = array()) { $options = $this->format_options('hidden', $name, $options); - return "get_attributes($options)." />"; + return "get_attributes($options, $name, $value)." />"; } function submit($name, $value, $options = array()) { $options = $this->format_options('submit', $name, $options); - return "get_attributes($options)." />"; + return "get_attributes($options, $name, $value)." />"; } function submit_image($name, $value, $image, $options = array()) { $options = $this->format_options('submit', $name, $options); - return "get_attributes($options)." />"; + return "get_attributes($options, $name, $value)." />"; } function admin_button($name, $value, $action = '', $label = '', $options = array()) { - $options['class'] = $action; //additional classes not allowed + $options['class'] = $action; //additional classes in options not allowed $btype = 'submit'; if($action == 'action') $btype = 'button'; $options = $this->format_options('admin_button', $name, $options); if(empty($label)) $label = $value; return " - "; } - function get_attributes($options) + function get_attributes($options, $name = '', $value = '') { $ret = ''; // @@ -190,7 +189,7 @@ class e_form switch ($option) { case 'id': - $ret .= $this->_format_id($optval, varset($options['name'])); + $ret .= $this->_format_id($optval, $name, $value); break; case 'class': @@ -236,16 +235,24 @@ class e_form return $ret; } - function _format_id($value, $name) + /** + * Auto-build field attribute id + * + * @param string $id_value value for attribute id passed with the option array + * @param string $name the name attribute passed to that field + * @param unknown_type $value the value attribute passed to that field + * @return unknown + */ + function _format_id($id_value, $name, $value = '', $return_attribute = 'id') { - if($value === false) return ''; + if($id_value === false) return ''; //format the name first $name = str_replace(array('[]', '[', ']', '_'), array('', '-', '', '-'), $name); - - if(is_numeric($value) && $name) return " id='{$name}-{$value}'";// also useful when name is e.g. name='my_name[]' - elseif(empty($value)) return " id='{$name}'";// also useful when name is e.g. name='my_name[some_id]' - else return " id='{$value}'"; + + if(empty($id_value) ) return " {$return_attribute}='{$name}".($value ? "-{$value}" : '')."'";// also useful when name is e.g. name='my_name[some_id]' + elseif(is_numeric($id_value) && $name) return " {$return_attribute}='{$name}-{$id_value}'";// also useful when name is e.g. name='my_name[]' + else return " {$return_attribute}='{$id_value}'"; } diff --git a/e107_handlers/message_handler.php b/e107_handlers/message_handler.php index 7cf2efef0..c5c51651c 100644 --- a/e107_handlers/message_handler.php +++ b/e107_handlers/message_handler.php @@ -9,8 +9,8 @@ * Message Handler * * $Source: /cvs_backup/e107_0.8/e107_handlers/message_handler.php,v $ - * $Revision: 1.6 $ - * $Date: 2008-12-12 09:55:33 $ + * $Revision: 1.7 $ + * $Date: 2008-12-12 23:29:32 $ * $Author: secretr $ * */ @@ -164,7 +164,7 @@ class eMessage * @param bool $session merge with session messages * @return array|string messages */ - function render($raw = false, $reset = true, $session = true) + function render($raw = false, $reset = true, $session = false) { if($session) {