1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-03 13:17:24 +02:00

Upgraded linkwords admin area to v2.x specifications.

This commit is contained in:
Cameron
2015-04-04 18:58:43 -07:00
parent f5ea27d637
commit cbdd93d95b
3 changed files with 242 additions and 23 deletions

View File

@@ -1324,10 +1324,24 @@ class e_form
$text = "";
$cname = $name;
foreach($option_array as $k=>$label)
{
$c = in_array($k, $checked) ? true : false;
$text .= $this->checkbox($name, $k, $c, $label);
if(!empty($options['useKeyValues'])) // ie. auto-generated
{
$key = $k;
$c = in_array($k, $checked) ? true : false;
}
else
{
$key = 1;
$cname = str_replace('[]','['.$k.']',$name);
$c = vartrue($checked[$k]);
}
$text .= $this->checkbox($cname, $key, $c, $label);
}
return $text;
@@ -2811,6 +2825,8 @@ class e_form
*/
function renderValue($field, $value, $attributes, $id = 0)
{
$parms = array();
if(isset($attributes['readParms']))
{
@@ -3579,7 +3595,7 @@ class e_form
*/
function renderElement($key, $value, $attributes, $required_data = array(), $id = 0)
{
// return print_a($value,true);
$parms = vartrue($attributes['writeParms'], array());
$tp = e107::getParser();
@@ -3633,7 +3649,7 @@ class e_form
}
// XXX Fixes For the above. - use optArray variable. eg. $field['key']['writeParms']['optArray'] = array('one','two','three');
if(($attributes['type'] == 'dropdown' || $attributes['type'] == 'radio') && !empty($parms['optArray']))
if(($attributes['type'] == 'dropdown' || $attributes['type'] == 'radio' || $attributes['type'] == 'checkboxes') && !empty($parms['optArray']))
{
$fopts = $parms;
$parms = $fopts['optArray'];
@@ -3853,11 +3869,20 @@ class e_form
if(is_array($parms))
{
$eloptions = vartrue($parms['__options'], array());
if(is_string($eloptions)) parse_str($eloptions, $eloptions);
if($attributes['type'] === 'comma') $eloptions['multiple'] = true;
unset($parms['__options']);
if(!is_array($value) && !empty($value))
{
$value = explode(",",$value);
}
$ret = vartrue($eloptions['pre']).$this->checkboxes($key, $parms, $value, $eloptions).vartrue($eloptions['post']);
}
return $ret;
break;

View File

@@ -2,7 +2,7 @@
/*
* e107 website system
*
* Copyright (C) 2008-2013 e107 Inc (e107.org)
* Copyright (C) 2008-2015 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
@@ -10,18 +10,211 @@
*
*/
require_once('../../class2.php');
if (!getperms('P') || !e107::isInstalled('linkwords'))
{
header('location:'.e_BASE.'index.php');
exit ;
}
require_once('../../class2.php');
if (!getperms('P') || !e107::isInstalled('linkwords'))
{
header('location:'.e_BASE.'index.php');
exit ;
}
e107::lan('linkwords', true); // e_PLUGIN.'linkwords/languages/'.e_LANGUAGE.'_admin.php'
define('LW_CACHE_TAG', 'nomd5_linkwords');
class linkwords_admin extends e_admin_dispatcher
{
protected $modes = array(
'main' => array(
'controller' => 'linkwords_ui',
'path' => null,
'ui' => 'linkwords_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 = LAN_PLUGIN_LINKWORDS_NAME;
}
class linkwords_ui extends e_admin_ui
{
protected $pluginTitle = 'Linkwords';
protected $pluginName = 'core';
// protected $eventName = 'linkwords-linkwords'; // remove comment to enable event triggers in admin.
protected $table = 'linkwords';
protected $pid = 'linkword_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 `#tableName` WHERE field != '' "; // Example Custom Query. LEFT JOINS allowed. Should be without any Order or Limit.
protected $listOrder = 'linkword_id DESC';
protected $fields = array ( 'checkboxes' => array ( 'title' => '', 'type' => null, 'data' => null, 'width' => '5%', 'thclass' => 'center', 'forced' => '1', 'class' => 'center', 'toggle' => 'e-multiselect', ),
'linkword_id' => array ( 'title' => LAN_ID, 'data' => 'int', 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
'linkword_word' => array ( 'title' => LWLAN_21, 'type' => 'tags', 'data' => 'str', 'width' => 'auto', 'inline' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
'linkword_link' => array ( 'title' => LWLAN_6, 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'inline' => true, 'help' => '', 'readParms' => '', 'writeParms' => 'size=xxlarge', 'class' => 'left', 'thclass' => 'left', ),
'linkword_active' => array ( 'title' => LAN_ACTIVE, 'type' => 'dropdown', 'data' => 'int', 'width' => 'auto', 'batch' => true, 'filter' => true, 'inline' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'left' => 'center', 'thclass' => 'left', ),
'linkword_tooltip' => array ( 'title' => LWLAN_50, 'type' => 'textarea', 'data' => 'str', 'width' => 'auto', 'inline' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
'linkword_tip_id' => array ( 'title' => LAN_ID, 'type' => 'number', 'data' => 'int', 'width' => '5%', 'help' => LWLAN_63, 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
'linkword_newwindow' => array ( 'title' => LWLAN_55, 'type' => 'boolean', 'data' => 'int', 'width' => 'auto', 'inline' => true, 'help' => '', 'filter'=>true, '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();
protected $prefs = array(
'lw_context_visibility' => array('title'=> LWLAN_26, 'type'=>'checkboxes', 'help'=>''),
'lw_ajax_enable' => array('title'=> LWLAN_59, 'type'=>'boolean', 'data' => 'string','help'=>''),
'lw_notsamepage' => array('title'=> LWLAN_64, 'type'=>'boolean', 'data' => 'string','help'=>LWLAN_65),
'linkword_omit_pages' => array('title'=> LWLAN_28, 'type'=>'textarea', 'data' => 'string','help'=>''),
);
public function init()
{
if($this->getAction() == 'list')
{
$this->fields['linkword_word']['title'] = LWLAN_5;
}
// Set drop-down values (if any).
$this->fields['linkword_active']['writeParms']['optArray'] = array(1=>LAN_INACTIVE, 0=>LWLAN_52, 2=>LWLAN_53, 3=>LWLAN_54);
$this->prefs['lw_context_visibility']['writeParms']['optArray'] = array('TITLE' => LWLAN_33,'SUMMARY' => LWLAN_34, 'BODY' => LWLAN_35, 'DESCRIPTION' => LWLAN_36,'USER_TITLE' => LWLAN_40, 'USER_BODY' => LWLAN_41);
if(!empty($_POST['etrigger_save']))
{
e107::getCache()->clear_sys(LW_CACHE_TAG);
}
}
// ------- Customize Create --------
public function beforeCreate($new_data)
{
return $new_data;
}
public function afterCreate($new_data, $old_data, $id)
{
e107::getCache()->clear_sys(LW_CACHE_TAG);
// do something
}
public function onCreateError($new_data, $old_data)
{
// do something
}
// ------- Customize Update --------
public function beforeUpdate($new_data, $old_data, $id)
{
return $new_data;
}
public function afterUpdate($new_data, $old_data, $id)
{
e107::getCache()->clear_sys(LW_CACHE_TAG);
// do something
}
public function onUpdateError($new_data, $old_data, $id)
{
// do something
}
public function afterDelete($deleted_data, $id, $deleted_check)
{
e107::getCache()->clear_sys(LW_CACHE_TAG);
}
/*
// optional - a custom page.
public function customPage()
{
$ns = e107::getRender();
$text = 'Hello World!';
$ns->tablerender('Hello',$text);
}
*/
}
class linkwords_form_ui extends e_admin_form_ui
{
}
new linkwords_admin();
require_once(e_ADMIN."auth.php");
e107::getAdminUI()->runPage();
require_once(e_ADMIN."footer.php");
exit;
/*
require_once(e_ADMIN.'auth.php');
e107::lan('linkwords', true); // e_PLUGIN.'linkwords/languages/'.e_LANGUAGE.'_admin.php'
define('LW_CACHE_TAG', 'nomd5_linkwords');
$pref = e107::getConfig()->getPref();
// print_a($pref['lw_context_visibility']);
$mes = e107::getMessage();
$tp = e107::getParser();
@@ -122,7 +315,7 @@ if (isset($_POST['saveopts_linkword']))
if (isset($_POST['submit_linkword']) || isset($_POST['update_linkword']))
{
if(!$_POST['linkwords_word'] && $_POST['linkwords_url']) // TODO FIX check is not functional
if(!$_POST['linkwords_word'] && $_POST['linkwords_url'])
{ // Key fields empty
$mes->addError(LAN_REQUIRED_BLANK);
}
@@ -259,7 +452,7 @@ if (($action == 'words') || ($action == 'edit'))
//$text .= LWLAN_4;
$mes->addInfo(LWLAN_4);
}
else // TODO FIX table below needs input button to $frm style
else
{
$text = "
<table class='table adminlist'>
@@ -370,7 +563,7 @@ $ns -> tablerender(LAN_OPTIONS, $text);
function admin_config_adminmenu() // TODO FIX v2 style
function admin_config_adminmenu()
{
if (e_QUERY)
{
@@ -392,4 +585,5 @@ function admin_config_adminmenu() // TODO FIX v2 style
require_once(e_ADMIN."footer.php");
*/
?>

View File

@@ -37,7 +37,7 @@ class siteinfo_shortcodes // must match the folder name of the plugin.
$text = deftrue('SITEDISCLAIMER',$default);
return e107::getParser()->toHtml($text, true, 'constants defs');
return e107::getParser()->toHtml($text, true, 'SUMMARY');
}
function sc_siteurl($parm='')