From 7db5b5ccb38886374e38199b9802256884248528 Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 3 Feb 2015 12:26:56 -0800 Subject: [PATCH] Fixes #736 - Welcome message admin area rewrite. Finally using Admin-ui. --- e107_admin/wmessage.php | 180 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 170 insertions(+), 10 deletions(-) diff --git a/e107_admin/wmessage.php b/e107_admin/wmessage.php index 613fb699a..89b225685 100644 --- a/e107_admin/wmessage.php +++ b/e107_admin/wmessage.php @@ -15,12 +15,170 @@ if (!getperms("M")) exit; } -// include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_'.e_PAGE); e107::lan('core','wmessage',true); -$e_sub_cat = 'wmessage'; -require_once("auth.php"); +class wmessage_admin extends e_admin_dispatcher +{ + + protected $modes = array( + + 'main' => array( + 'controller' => 'generic_ui', + 'path' => null, + 'ui' => 'generic_form_ui', + 'uipath' => null + ), + + + ); + + + protected $adminMenu = array( + + 'main/list' => array('caption'=> LAN_MANAGE, 'perm' => 'P'), + 'main/create' => array('caption'=> LAN_CREATE, 'perm' => 'P'), + 'main/prefs' => array('caption'=> LAN_PREFS, 'perm' => 'P'), + + // 'main/custom' => array('caption'=> 'Custom Page', 'perm' => 'P') + ); + + protected $adminMenuAliases = array( + 'main/edit' => 'main/list' + ); + + protected $menuTitle = WMLAN_00; +} + + + + + +class generic_ui extends e_admin_ui +{ + + protected $pluginTitle = WMLAN_00; + protected $pluginName = 'core'; + protected $table = 'generic'; + protected $pid = 'gen_id'; + protected $perPage = 10; + protected $batchDelete = true; + protected $batchCopy = true; + // protected $sortField = 'somefield_order'; + // protected $orderStep = 10; + // protected $tabs = array('Tabl 1','Tab 2'); // Use 'tab'=>0 OR 'tab'=>1 in the $fields below to enable. + + protected $listQry = "SELECT * FROM `#generic` WHERE gen_type='wmessage' "; // Example Custom Query. LEFT JOINS allowed. Should be without any Order or Limit. + + protected $listOrder = 'gen_id DESC'; + + protected $fields = array ( + 'checkboxes' => array ( 'title' => '', 'type' => null, 'data' => null, 'width' => '5%', 'thclass' => 'center', 'forced' => '1', 'class' => 'center', 'toggle' => 'e-multiselect', ), + 'gen_id' => array ( 'title' => LAN_ID, 'data' => 'int', 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), + 'gen_type' => array ( 'title' => LAN_TYPE, 'type' => 'hidden', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => 'default=wmessage', 'class' => 'left', 'thclass' => 'left', ), + 'gen_datestamp' => array ( 'title' => LAN_DATESTAMP, 'type' => 'hidden', 'data' => 'int', 'width' => 'auto', 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), + 'gen_user_id' => array ( 'title' => LAN_ID, 'type' => 'hidden', 'data' => 'int', 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), + 'gen_ip' => array ( 'title' => WMLAN_10, 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'inline' => true, 'help' => '', 'readParms' => '', 'writeParms' => 'size=xxlarge', 'class' => 'left', 'thclass' => 'left', ), + 'gen_intdata' => array ( 'title' => LAN_VISIBILITY, 'type' => 'userclass', 'data' => 'int', 'inline'=>true, 'batch'=>true, 'filter'=>true, 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ), + 'gen_chardata' => array ( 'title' => WMLAN_04, 'type' => 'bbarea', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ), + 'options' => array ( 'title' => LAN_OPTIONS, 'type' => null, 'data' => null, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center last', 'forced' => '1', ), + ); + + protected $fieldpref = array('gen_ip', 'gen_intdata'); + + + protected $prefs = array( + 'wm_enclose' => array('title'=> WMLAN_05, 'type'=>'boolean', 'data' => 'int','help'=> WMLAN_06), ); + + + public function init() + { + + + } + + public function beforeCreate($new_data) + { + return $new_data; + } + + public function afterCreate($new_data, $old_data, $id) + { + // do something + } + + public function beforeUpdate($new_data, $old_data, $id) + { + return $new_data; + } + + public function afterUpdate($new_data, $old_data, $id) + { + e107::getCache()->clear("wmessage"); + } + + public function onCreateError($new_data, $old_data) + { + // do something + } + + public function onUpdateError($new_data, $old_data, $id) + { + // do something + } + + + /* + // optional - override edit page. + public function customPage() + { + $ns = e107::getRender(); + $text = 'Hello World!'; + $ns->tablerender('Hello',$text); + + } + */ + +} + + + +class generic_form_ui extends e_admin_form_ui +{ + +} + + +new wmessage_admin(); + +require_once(e_ADMIN."auth.php"); + +e107::getAdminUI()->runPage(); + +require_once(e_ADMIN."footer.php"); +exit; + + + + + + + + + + + + +/* + + + + + + + + + require_once(e_HANDLER.'userclass_class.php'); require_once(e_HANDLER."ren_help.php"); @@ -255,13 +413,13 @@ if ($action == "opt") { ".$frm->radio_switch('wm_enclose', varset($pref['wm_enclose']))."".WMLAN_06." "; - /* DEPRECATED - see header_default.php {WMESSAGE} - $text .= " - - ".WMLAN_07." - ".$frm->checkbox('wmessage_sc', 1, varset($pref['wmessage_sc'],0))." - "; - */ + // DEPRECATED - see header_default.php {WMESSAGE} + // $text .= " + // + // ".WMLAN_07." + // ".$frm->checkbox('wmessage_sc', 1, varset($pref['wmessage_sc'],0))." + // "; + $text .= " @@ -310,4 +468,6 @@ function welcome_adminlog($msg_num='00', $id=0, $woffle='') } e107::getLog()->add('WELCOME_'.$msg_num,$msg,E_LOG_INFORMATIVE,''); } + */ + ?> \ No newline at end of file