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

more Administration work - image & cache ready (new message & form handlers implemented as well)

This commit is contained in:
secretr
2008-12-12 23:29:32 +00:00
parent 865a70f0d1
commit 99501721e4
3 changed files with 53 additions and 43 deletions

View File

@@ -9,8 +9,8 @@
* Cache Administration Area * Cache Administration Area
* *
* $Source: /cvs_backup/e107_0.8/e107_admin/cache.php,v $ * $Source: /cvs_backup/e107_0.8/e107_admin/cache.php,v $
* $Revision: 1.6 $ * $Revision: 1.7 $
* $Date: 2008-12-12 16:36:45 $ * $Date: 2008-12-12 23:29:32 $
* $Author: secretr $ * $Author: secretr $
* *
*/ */
@@ -25,8 +25,11 @@ $e_sub_cat = 'cache';
require_once("auth.php"); require_once("auth.php");
require_once(e_HANDLER."cache_handler.php"); require_once(e_HANDLER."cache_handler.php");
require_once(e_HANDLER."form_handler.php");
require_once(e_HANDLER."message_handler.php"); require_once(e_HANDLER."message_handler.php");
$ec = new ecache; $ec = new ecache;
$frm = new e_form();
$emessage = &eMessage::getInstance(); $emessage = &eMessage::getInstance();
if ($pref['cachestatus'] == '2') if ($pref['cachestatus'] == '2')
@@ -114,10 +117,10 @@ $text = "
<div class='smalltext'>".CACLAN_13."</div> <div class='smalltext'>".CACLAN_13."</div>
</td> </td>
<td class='center middle'> <td class='center middle'>
<input type='radio' id='cachestatus-1a' name='cachestatus' value='1'".($pref['cachestatus'] ? " checked='checked'" : "")." /> ".$frm->radio('cachestatus', 1, ($pref['cachestatus']))."
<label for='cachestatus-1a'>".LAN_ENABLED."</label>&nbsp;&nbsp; ".$frm->label(LAN_ENABLED, 'cachestatus', 1)."&nbsp;&nbsp;
<input type='radio' id='cachestatus-1b' name='cachestatus' value='0'".(!$pref['cachestatus'] ? " checked='checked'" : "")." /> ".$frm->radio('cachestatus', 0, (!$pref['cachestatus']))."
<label for='cachestatus-1b'>".LAN_DISABLED."</label> ".$frm->label(LAN_DISABLED, 'cachestatus', 0)."
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -126,23 +129,23 @@ $text = "
<div class='smalltext'>".CACLAN_14."</div> <div class='smalltext'>".CACLAN_14."</div>
</td> </td>
<td class='center middle'> <td class='center middle'>
<input type='radio' name='syscachestatus' id='syscachestatus-1a' value='1'".($pref['syscachestatus'] ? " checked='checked'" : "")." /> ".$frm->radio('syscachestatus', 1, ($pref['syscachestatus']))."
<label for='syscachestatus-1a'>".LAN_ENABLED."</label>&nbsp;&nbsp; ".$frm->label(LAN_ENABLED, 'syscachestatus', 1)."&nbsp;&nbsp;
<input type='radio' name='syscachestatus' id='syscachestatus-1b' value='0'".(!$pref['syscachestatus'] ? " checked='checked'" : "")." /> ".$frm->radio('syscachestatus', 0, (!$pref['syscachestatus']))."
<label for='syscachestatus-1b'>".LAN_DISABLED."</label> ".$frm->label(LAN_DISABLED, 'syscachestatus', 0)."
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
<div class='buttons-bar left'> <div class='buttons-bar left'>
<button class='submit f-right' type='submit' name='submit_cache'><span>".CACLAN_2."</span></button> ".$frm->admin_button('submit_cache', CACLAN_2, 'update f-right')."
<button class='delete' type='submit' name='empty_cache'><span>".CACLAN_5."</span></button> ".$frm->admin_button('empty_cache', CACLAN_5, 'delete')."
<button class='delete' type='submit' name='empty_syscache'><span>".CACLAN_16."</span></button> ".$frm->admin_button('empty_syscache', CACLAN_16, 'delete')."
</div> </div>
</fieldset> </fieldset>
</form>"; </form>";
$ns->tablerender(CACLAN_3, $text); $ns->tablerender(CACLAN_3, $emessage->render().$text);
require_once("footer.php"); require_once("footer.php");
?> ?>

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.5 $ * $Revision: 1.6 $
* $Date: 2008-12-12 22:39:17 $ * $Date: 2008-12-12 23:29:32 $
* $Author: secretr $ * $Author: secretr $
* *
*/ */
@@ -74,34 +74,33 @@ class e_form
function text($name, $value, $maxlength = 200, $options = array()) function text($name, $value, $maxlength = 200, $options = array())
{ {
$options = $this->format_options('text', $name, $options); $options = $this->format_options('text', $name, $options);
return "<input type='text' name='{$name}' value='{$value}' maxlength='{$maxlength}'".$this->get_attributes($options)." />"; return "<input type='text' name='{$name}' value='{$value}' maxlength='{$maxlength}'".$this->get_attributes($options, $name, $value)." />";
} }
function file($name, $options = array()) function file($name, $options = array())
{ {
$options = $this->format_options('text', $name, $options); $options = $this->format_options('text', $name, $options);
return "<input type='text' name='{$name}'".$this->get_attributes($options)." />"; return "<input type='text' name='{$name}'".$this->get_attributes($options, $name, $value)." />";
} }
function password($name, $maxlength = 50, $options = array()) function password($name, $maxlength = 50, $options = array())
{ {
$options = $this->format_options('text', $name, $options); $options = $this->format_options('text', $name, $options);
return "<input type='password' name='{$name}' value='' maxlength='{$maxlength}'".$this->get_attributes($options)." />"; return "<input type='password' name='{$name}' value='' maxlength='{$maxlength}'".$this->get_attributes($options, $name, $value)." />";
} }
function textarea($name, $value, $rows = 15, $cols = 40, $options = array()) function textarea($name, $value, $rows = 15, $cols = 40, $options = array())
{ {
$options = $this->format_options('textarea', $name, $options); $options = $this->format_options('textarea', $name, $options);
return "<textarea name='{$name}' rows='{$rows}' cols='{$cols}'".$this->get_attributes($options).">{$value}</textarea>"; return "<textarea name='{$name}' rows='{$rows}' cols='{$cols}'".$this->get_attributes($options, $name, $value).">{$value}</textarea>";
} }
function checkbox($name, $value, $checked = false, $options = array()) function checkbox($name, $value, $checked = false, $options = array())
{ {
$options['checked'] = $checked; //comes as separate argument just for convenience $options['checked'] = $checked; //comes as separate argument just for convenience
$options = $this->format_options('checkbox', $name, $options); $options = $this->format_options('checkbox', $name, $options);
return "<input type='checkbox' name='{$name}' value='{$value}'".$this->get_attributes($options)." />"; return "<input type='checkbox' name='{$name}' value='{$value}'".$this->get_attributes($options, $name, $value)." />";
} }
@@ -109,20 +108,20 @@ class e_form
{ {
$options['checked'] = $checked; //comes as separate argument just for convenience $options['checked'] = $checked; //comes as separate argument just for convenience
$options = $this->format_options('radio', $name, $options); $options = $this->format_options('radio', $name, $options);
return "<input type='radio' name='{$name}' value='".$value."'".$this->get_attributes($options)." />"; return "<input type='radio' name='{$name}' value='".$value."'".$this->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); $for_id = $this->_format_id('', $name, $value, 'for');
return "<label for='{$for_id}'>{$text}</label>"; return "<label$for_id>{$text}</label>";
} }
function select_open($name, $options = array()) function select_open($name, $options = array())
{ {
$options = $this->format_options('select', $name, $options); $options = $this->format_options('select', $name, $options);
return "<select name='{$name}'".$this->get_attributes($options).">"; return "<select name='{$name}'".$this->get_attributes($options, $name).">";
} }
function optgroup_open($label, $disabled) function optgroup_open($label, $disabled)
@@ -151,37 +150,37 @@ class e_form
function hidden($name, $value, $options = array()) function hidden($name, $value, $options = array())
{ {
$options = $this->format_options('hidden', $name, $options); $options = $this->format_options('hidden', $name, $options);
return "<input type='hidden' name='{$name}' value='{$value}'".$this->get_attributes($options)." />"; return "<input type='hidden' name='{$name}' value='{$value}'".$this->get_attributes($options, $name, $value)." />";
} }
function submit($name, $value, $options = array()) function submit($name, $value, $options = array())
{ {
$options = $this->format_options('submit', $name, $options); $options = $this->format_options('submit', $name, $options);
return "<input class='button' type='submit' name='{$name}' value='{$value}'".$this->get_attributes($options)." />"; return "<input class='button' type='submit' name='{$name}' value='{$value}'".$this->get_attributes($options, $name, $value)." />";
} }
function submit_image($name, $value, $image, $options = array()) function submit_image($name, $value, $image, $options = array())
{ {
$options = $this->format_options('submit', $name, $options); $options = $this->format_options('submit', $name, $options);
return "<input class='image' type='image' src='{$image}' name='{$name}' value='{$value}'".$this->get_attributes($options)." />"; return "<input class='image' type='image' src='{$image}' name='{$name}' value='{$value}'".$this->get_attributes($options, $name, $value)." />";
} }
function admin_button($name, $value, $action = '', $label = '', $options = array()) 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'; $btype = 'submit';
if($action == 'action') $btype = 'button'; if($action == 'action') $btype = 'button';
$options = $this->format_options('admin_button', $name, $options); $options = $this->format_options('admin_button', $name, $options);
if(empty($label)) $label = $value; if(empty($label)) $label = $value;
return " return "
<button type='{$btype}' name='{$name}' value='{$value}'".$this->get_attributes($options)."> <button type='{$btype}' name='{$name}' value='{$value}'".$this->get_attributes($options, $name).">
<span>{$label}</span> <span>{$label}</span>
</button> </button>
"; ";
} }
function get_attributes($options) function get_attributes($options, $name = '', $value = '')
{ {
$ret = ''; $ret = '';
// //
@@ -190,7 +189,7 @@ class e_form
switch ($option) { switch ($option) {
case 'id': case 'id':
$ret .= $this->_format_id($optval, varset($options['name'])); $ret .= $this->_format_id($optval, $name, $value);
break; break;
case 'class': case 'class':
@@ -236,16 +235,24 @@ class e_form
return $ret; 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 //format the name first
$name = str_replace(array('[]', '[', ']', '_'), array('', '-', '', '-'), $name); $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[]' if(empty($id_value) ) return " {$return_attribute}='{$name}".($value ? "-{$value}" : '')."'";// also useful when name is e.g. name='my_name[some_id]'
elseif(empty($value)) return " id='{$name}'";// 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 " id='{$value}'"; else return " {$return_attribute}='{$id_value}'";
} }

View File

@@ -9,8 +9,8 @@
* Message Handler * Message Handler
* *
* $Source: /cvs_backup/e107_0.8/e107_handlers/message_handler.php,v $ * $Source: /cvs_backup/e107_0.8/e107_handlers/message_handler.php,v $
* $Revision: 1.6 $ * $Revision: 1.7 $
* $Date: 2008-12-12 09:55:33 $ * $Date: 2008-12-12 23:29:32 $
* $Author: secretr $ * $Author: secretr $
* *
*/ */
@@ -164,7 +164,7 @@ class eMessage
* @param bool $session merge with session messages * @param bool $session merge with session messages
* @return array|string messages * @return array|string messages
*/ */
function render($raw = false, $reset = true, $session = true) function render($raw = false, $reset = true, $session = false)
{ {
if($session) if($session)
{ {