mirror of
https://github.com/e107inc/e107.git
synced 2025-07-29 10:50:25 +02:00
Linkwords - code-clean-up (no functional changes)
Tabs, spacing, readability
This commit is contained in:
@@ -1,209 +1,190 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* e107 website system
|
* e107 website system
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008-2015 e107 Inc (e107.org)
|
* Copyright (C) 2008-2015 e107 Inc (e107.org)
|
||||||
* Released under the terms and conditions of the
|
* Released under the terms and conditions of the
|
||||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
*
|
*
|
||||||
* Linkwords plugin - admin page
|
* Linkwords plugin - admin page
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once('../../class2.php');
|
require_once('../../class2.php');
|
||||||
|
|
||||||
if (!getperms('P') || !e107::isInstalled('linkwords'))
|
if (!getperms('P') || !e107::isInstalled('linkwords'))
|
||||||
{
|
{
|
||||||
e107::redirect('admin');
|
e107::redirect('admin');
|
||||||
exit ;
|
exit ;
|
||||||
}
|
}
|
||||||
|
|
||||||
e107::lan('linkwords', true); // e_PLUGIN.'linkwords/languages/'.e_LANGUAGE.'_admin.php'
|
e107::lan('linkwords', true);
|
||||||
|
|
||||||
define('LW_CACHE_TAG', 'nomd5_linkwords');
|
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')
|
||||||
|
);
|
||||||
|
|
||||||
class linkwords_admin extends e_admin_dispatcher
|
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 = 'linkwords';
|
||||||
|
// 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' => array(), 'left' => 'center', 'thclass' => 'left', ),
|
||||||
|
'linkword_tooltip' => array ( 'title' => LWLAN_50, 'type' => 'textarea', 'data' => 'str', 'width' => 'auto', 'inline' => true, 'help' => '', 'readParms' => '', 'writeParms' => array('size'=>'xxlarge'), 'class' => 'left', 'thclass' => 'left', ),
|
||||||
|
'linkword_limit' => array ( 'title' => "Max. links/tips", 'type' => 'number', 'data' => 'int', 'width' => '10%', 'help' => LWLAN_63, 'readParms' => '', 'writeParms' => array('default'=>3), 'class' => 'right', 'thclass' => 'right', ),
|
||||||
|
'linkword_tip_id' => array ( 'title' => LAN_ID, 'type' => 'number', 'data' => 'int', 'width' => '5%', 'help' => LWLAN_63, 'readParms' => '', 'writeParms' => '', 'class' => 'right', 'thclass' => 'right', ),
|
||||||
|
'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'=>''),
|
||||||
|
// 'lw_max_per_word' => array('title'=> "Maximum links/tips per word", 'type'=>'number', 'data' => 'string','help'=>'If the same word is found multiple times in a piece of text.'),
|
||||||
|
'lw_custom_class' => array('title'=> "Custom CSS Class", 'type'=>'text', 'writeParms'=>array('placeholder'=> LAN_OPTIONAL ), 'data' => 'string','help'=>'Will add this class to all generated links.'),
|
||||||
|
);
|
||||||
|
|
||||||
|
public function init()
|
||||||
{
|
{
|
||||||
|
|
||||||
protected $modes = array(
|
if($this->getAction() == 'list')
|
||||||
|
|
||||||
'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' => array(), 'left' => 'center', 'thclass' => 'left', ),
|
|
||||||
|
|
||||||
'linkword_tooltip' => array ( 'title' => LWLAN_50, 'type' => 'textarea', 'data' => 'str', 'width' => 'auto', 'inline' => true, 'help' => '', 'readParms' => '', 'writeParms' => array('size'=>'xxlarge'), 'class' => 'left', 'thclass' => 'left', ),
|
|
||||||
'linkword_limit' => array ( 'title' => "Max. links/tips", 'type' => 'number', 'data' => 'int', 'width' => '10%', 'help' => LWLAN_63, 'readParms' => '', 'writeParms' => array('default'=>3), 'class' => 'right', 'thclass' => 'right', ),
|
|
||||||
|
|
||||||
'linkword_tip_id' => array ( 'title' => LAN_ID, 'type' => 'number', 'data' => 'int', 'width' => '5%', 'help' => LWLAN_63, 'readParms' => '', 'writeParms' => '', 'class' => 'right', 'thclass' => 'right', ),
|
|
||||||
'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'=>''),
|
|
||||||
// 'lw_max_per_word' => array('title'=> "Maximum links/tips per word", 'type'=>'number', 'data' => 'string','help'=>'If the same word is found multiple times in a piece of text.'),
|
|
||||||
'lw_custom_class' => array('title'=> "Custom CSS Class", 'type'=>'text', 'writeParms'=>array('placeholder'=> LAN_OPTIONAL ), 'data' => 'string','help'=>'Will add this class to all generated links.'),
|
|
||||||
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
public function init()
|
|
||||||
{
|
{
|
||||||
|
$this->fields['linkword_word']['title'] = LWLAN_5;
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
);
|
||||||
|
|
||||||
// ------- Customize Create --------
|
$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
|
||||||
|
);
|
||||||
|
|
||||||
public function beforeCreate($new_data, $old_data)
|
if(!empty($_POST['etrigger_save']))
|
||||||
{
|
|
||||||
return $new_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function afterCreate($new_data, $old_data, $id)
|
|
||||||
{
|
{
|
||||||
e107::getCache()->clear_sys(LW_CACHE_TAG);
|
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);
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ------- Customize Create --------
|
||||||
|
|
||||||
class linkwords_form_ui extends e_admin_form_ui
|
public function beforeCreate($new_data, $old_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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
new linkwords_admin();
|
// ------- Customize Update --------
|
||||||
|
|
||||||
require_once(e_ADMIN."auth.php");
|
public function beforeUpdate($new_data, $old_data, $id)
|
||||||
e107::getAdminUI()->runPage();
|
{
|
||||||
|
return $new_data;
|
||||||
|
}
|
||||||
|
|
||||||
require_once(e_ADMIN."footer.php");
|
public function afterUpdate($new_data, $old_data, $id)
|
||||||
exit;
|
{
|
||||||
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -216,7 +197,7 @@ e107::lan('linkwords', true); // e_PLUGIN.'linkwords/languages/'.e_LANGUAGE.'_ad
|
|||||||
|
|
||||||
define('LW_CACHE_TAG', 'nomd5_linkwords');
|
define('LW_CACHE_TAG', 'nomd5_linkwords');
|
||||||
|
|
||||||
$pref = e107::getConfig()->getPref();
|
$pref = e107::getConfig()->getPref();
|
||||||
|
|
||||||
// print_a($pref['lw_context_visibility']);
|
// print_a($pref['lw_context_visibility']);
|
||||||
|
|
||||||
@@ -226,17 +207,17 @@ $tp = e107::getParser();
|
|||||||
$frm = e107::getForm();
|
$frm = e107::getForm();
|
||||||
|
|
||||||
$lw_context_areas = array(
|
$lw_context_areas = array(
|
||||||
'TITLE' => LWLAN_33,
|
'TITLE' => LWLAN_33,
|
||||||
'SUMMARY' => LWLAN_34,
|
'SUMMARY' => LWLAN_34,
|
||||||
'BODY' => LWLAN_35,
|
'BODY' => LWLAN_35,
|
||||||
'DESCRIPTION' => LWLAN_36,
|
'DESCRIPTION' => LWLAN_36,
|
||||||
'USER_TITLE' => LWLAN_40,
|
'USER_TITLE' => LWLAN_40,
|
||||||
'USER_BODY' => LWLAN_41
|
'USER_BODY' => LWLAN_41
|
||||||
// Don't do the next three - linkwords are meaningless on them
|
// Don't do the next three - linkwords are meaningless on them
|
||||||
// 'olddefault' => LWLAN_37,
|
// 'olddefault' => LWLAN_37,
|
||||||
// 'linktext' => LWLAN_38,
|
// 'linktext' => LWLAN_38,
|
||||||
// 'rawtext' => LWLAN_39'
|
// 'rawtext' => LWLAN_39'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Yes, I know its a silly order - but that's history!
|
// Yes, I know its a silly order - but that's history!
|
||||||
$lwaction_vals = array(1=>LAN_INACTIVE, 0=>LWLAN_52, 2=>LWLAN_53, 3=>LWLAN_54);
|
$lwaction_vals = array(1=>LAN_INACTIVE, 0=>LWLAN_52, 2=>LWLAN_53, 3=>LWLAN_54);
|
||||||
@@ -244,14 +225,14 @@ $frm = e107::getForm();
|
|||||||
// Generate dropdown for possible actions on finding a linkword
|
// Generate dropdown for possible actions on finding a linkword
|
||||||
function lw_act_opts($curval)
|
function lw_act_opts($curval)
|
||||||
{
|
{
|
||||||
global $lwaction_vals;
|
global $lwaction_vals;
|
||||||
$ret = '';
|
$ret = '';
|
||||||
foreach ($lwaction_vals as $opt => $val)
|
foreach ($lwaction_vals as $opt => $val)
|
||||||
{
|
{
|
||||||
$selected = ($curval == $opt ? "selected='selected'" : '');
|
$selected = ($curval == $opt ? "selected='selected'" : '');
|
||||||
$ret .= "<option value='{$opt}' {$selected}>{$val}</option>\n";
|
$ret .= "<option value='{$opt}' {$selected}>{$val}</option>\n";
|
||||||
}
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -259,111 +240,111 @@ $deltest = array_flip($_POST);
|
|||||||
|
|
||||||
if(isset($deltest[LAN_DELETE]))
|
if(isset($deltest[LAN_DELETE]))
|
||||||
{
|
{
|
||||||
$delete_id = intval(str_replace('delete_', '', $deltest[LAN_DELETE]));
|
$delete_id = intval(str_replace('delete_', '', $deltest[LAN_DELETE]));
|
||||||
|
|
||||||
if ($sql->db_Count('linkwords', '(*)', "WHERE linkword_id = ".$delete_id))
|
if ($sql->db_Count('linkwords', '(*)', "WHERE linkword_id = ".$delete_id))
|
||||||
{
|
{
|
||||||
$sql->db_Delete('linkwords', 'linkword_id='.$delete_id);
|
$sql->db_Delete('linkwords', 'linkword_id='.$delete_id);
|
||||||
e107::getLog()->add('LINKWD_03','ID: '.$delete_id,'');
|
e107::getLog()->add('LINKWD_03','ID: '.$delete_id,'');
|
||||||
$e107->ecache->clear_sys(LW_CACHE_TAG);
|
$e107->ecache->clear_sys(LW_CACHE_TAG);
|
||||||
//$message = LWLAN_19;
|
//$message = LWLAN_19;
|
||||||
$mes->addSuccess(LAN_DELETED);
|
$mes->addSuccess(LAN_DELETED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(e_QUERY)
|
if(e_QUERY)
|
||||||
{
|
{
|
||||||
$lw_qs = explode('.', e_QUERY);
|
$lw_qs = explode('.', e_QUERY);
|
||||||
if (!isset($lw_qs[0])) $lw_qs[0] = 'words';
|
if (!isset($lw_qs[0])) $lw_qs[0] = 'words';
|
||||||
if (!isset($lw_qs[1])) $lw_qs[1] = -1;
|
if (!isset($lw_qs[1])) $lw_qs[1] = -1;
|
||||||
$action = $lw_qs[0];
|
$action = $lw_qs[0];
|
||||||
$id = intval($lw_qs[1]);
|
$id = intval($lw_qs[1]);
|
||||||
}
|
}
|
||||||
if (!isset($action)) $action = 'words';
|
if (!isset($action)) $action = 'words';
|
||||||
|
|
||||||
if (isset($_POST['saveopts_linkword']))
|
if (isset($_POST['saveopts_linkword']))
|
||||||
{ // Save options page
|
{ // Save options page
|
||||||
// Array of context flags
|
// Array of context flags
|
||||||
$pref['lw_context_visibility'] = array(
|
$pref['lw_context_visibility'] = array(
|
||||||
'OLDDEFAULT' => FALSE,
|
'OLDDEFAULT' => FALSE,
|
||||||
'TITLE' => FALSE,
|
'TITLE' => FALSE,
|
||||||
'USER_TITLE' => FALSE,
|
'USER_TITLE' => FALSE,
|
||||||
'SUMMARY' => FALSE,
|
'SUMMARY' => FALSE,
|
||||||
'BODY' => FALSE,
|
'BODY' => FALSE,
|
||||||
'USER_BODY' => FALSE,
|
'USER_BODY' => FALSE,
|
||||||
'DESCRIPTION' => FALSE,
|
'DESCRIPTION' => FALSE,
|
||||||
'LINKTEXT' => FALSE,
|
'LINKTEXT' => FALSE,
|
||||||
'RAWTEXT' => FALSE
|
'RAWTEXT' => FALSE
|
||||||
);
|
);
|
||||||
foreach ($_POST['lw_visibility_area'] as $can_see)
|
foreach ($_POST['lw_visibility_area'] as $can_see)
|
||||||
|
{
|
||||||
|
if (key_exists($can_see,$lw_context_areas))
|
||||||
{
|
{
|
||||||
if (key_exists($can_see,$lw_context_areas))
|
$pref['lw_context_visibility'][$can_see] = TRUE;
|
||||||
{
|
|
||||||
$pref['lw_context_visibility'][$can_see] = TRUE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Text area for 'exclude' pages - use same method as for menus
|
}
|
||||||
$pagelist = explode("\r\n", $_POST['linkword_omit_pages']);
|
// Text area for 'exclude' pages - use same method as for menus
|
||||||
for ($i = 0 ; $i < count($pagelist) ; $i++)
|
$pagelist = explode("\r\n", $_POST['linkword_omit_pages']);
|
||||||
{
|
for ($i = 0 ; $i < count($pagelist) ; $i++)
|
||||||
$pagelist[$i] = trim($pagelist[$i]);
|
{
|
||||||
}
|
$pagelist[$i] = trim($pagelist[$i]);
|
||||||
$pref['lw_page_visibility'] = '2-'.implode("|", $pagelist); // '2' for 'hide on specified pages'
|
}
|
||||||
$pref['lw_ajax_enable'] = isset($_POST['lw_ajax_enable']);
|
$pref['lw_page_visibility'] = '2-'.implode("|", $pagelist); // '2' for 'hide on specified pages'
|
||||||
$pref['lw_notsamepage'] = isset($_POST['lw_notsamepage']);
|
$pref['lw_ajax_enable'] = isset($_POST['lw_ajax_enable']);
|
||||||
save_prefs();
|
$pref['lw_notsamepage'] = isset($_POST['lw_notsamepage']);
|
||||||
$logString = implode(', ',$pref['lw_context_visibility']).'[!br!]'.$pref['lw_page_visibility'].'[!br!]'.$pref['lw_ajax_enable'].'[!br!]'.$pref['lw_notsamepage'];
|
save_prefs();
|
||||||
e107::getCache()->clear_sys(LW_CACHE_TAG);
|
$logString = implode(', ',$pref['lw_context_visibility']).'[!br!]'.$pref['lw_page_visibility'].'[!br!]'.$pref['lw_ajax_enable'].'[!br!]'.$pref['lw_notsamepage'];
|
||||||
e107::getLog()->add('LINKWD_04',$logString,'');
|
e107::getCache()->clear_sys(LW_CACHE_TAG);
|
||||||
|
e107::getLog()->add('LINKWD_04',$logString,'');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (isset($_POST['submit_linkword']) || isset($_POST['update_linkword']))
|
if (isset($_POST['submit_linkword']) || isset($_POST['update_linkword']))
|
||||||
{
|
{
|
||||||
if(!$_POST['linkwords_word'] && $_POST['linkwords_url'])
|
if(!$_POST['linkwords_word'] && $_POST['linkwords_url'])
|
||||||
{ // Key fields empty
|
{ // Key fields empty
|
||||||
$mes->addError(LAN_REQUIRED_BLANK);
|
$mes->addError(LAN_REQUIRED_BLANK);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
$data['linkword_word'] = $tp->toDB($_POST['linkword_word']);
|
||||||
|
$data['linkword_link'] = $tp->toDB($_POST['linkword_link']);
|
||||||
|
$data['linkword_tooltip'] = $tp->toDB($_POST['linkword_tooltip']);
|
||||||
|
$data['linkword_tip_id'] = intval($_POST['linkword_tip_id']);
|
||||||
|
$data['linkword_active'] = intval($_POST['linkword_active']);
|
||||||
|
$data['linkword_newwindow'] = isset($_POST['linkword_newwindow']) ? 1 : 0;
|
||||||
|
|
||||||
|
$logString = implode('[!br!]',$data);
|
||||||
|
if (isset($_POST['submit_linkword']))
|
||||||
{
|
{
|
||||||
$data['linkword_word'] = $tp->toDB($_POST['linkword_word']);
|
if ($sql->db_Insert('linkwords', $data))
|
||||||
$data['linkword_link'] = $tp->toDB($_POST['linkword_link']);
|
|
||||||
$data['linkword_tooltip'] = $tp->toDB($_POST['linkword_tooltip']);
|
|
||||||
$data['linkword_tip_id'] = intval($_POST['linkword_tip_id']);
|
|
||||||
$data['linkword_active'] = intval($_POST['linkword_active']);
|
|
||||||
$data['linkword_newwindow'] = isset($_POST['linkword_newwindow']) ? 1 : 0;
|
|
||||||
|
|
||||||
$logString = implode('[!br!]',$data);
|
|
||||||
if (isset($_POST['submit_linkword']))
|
|
||||||
{
|
{
|
||||||
if ($sql->db_Insert('linkwords', $data))
|
e107::getLog()->add('LINKWD_01',$logString,'');
|
||||||
{
|
$mes->addSuccess(LAN_CREATED);
|
||||||
e107::getLog()->add('LINKWD_01',$logString,'');
|
|
||||||
$mes->addSuccess(LAN_CREATED);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//$message = LWLAN_57;
|
|
||||||
$mes->addError(LAN_CREATED_FAILED);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
elseif (isset($_POST['update_linkword']))
|
else
|
||||||
{
|
{
|
||||||
$id = intval(varset($_POST['lw_edit_id'],0));
|
//$message = LWLAN_57;
|
||||||
if (($id > 0) && $sql->db_UpdateArray('linkwords', $data, ' WHERE `linkword_id`='.$id))
|
$mes->addError(LAN_CREATED_FAILED);
|
||||||
{
|
|
||||||
$mes->addSuccess(LAN_UPDATED);
|
|
||||||
$logString = 'ID: '.$id.'[!br!]'.$logString;
|
|
||||||
e107::getLog()->add('LINKWD_02',$logString,'');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$mes->addError(LAN_UPDATED_FAILED);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
e107::getCache()->clear_sys(LW_CACHE_TAG);
|
|
||||||
}
|
}
|
||||||
|
elseif (isset($_POST['update_linkword']))
|
||||||
|
{
|
||||||
|
$id = intval(varset($_POST['lw_edit_id'],0));
|
||||||
|
if (($id > 0) && $sql->db_UpdateArray('linkwords', $data, ' WHERE `linkword_id`='.$id))
|
||||||
|
{
|
||||||
|
$mes->addSuccess(LAN_UPDATED);
|
||||||
|
$logString = 'ID: '.$id.'[!br!]'.$logString;
|
||||||
|
e107::getLog()->add('LINKWD_02',$logString,'');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$mes->addError(LAN_UPDATED_FAILED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
e107::getCache()->clear_sys(LW_CACHE_TAG);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$ns->tablerender($caption, $mes->render() . $text);
|
$ns->tablerender($caption, $mes->render() . $text);
|
||||||
@@ -372,21 +353,21 @@ $ns->tablerender($caption, $mes->render() . $text);
|
|||||||
$chkNewWindow = " checked='checked'"; // Open links in new window by default
|
$chkNewWindow = " checked='checked'"; // Open links in new window by default
|
||||||
if($action == "edit")
|
if($action == "edit")
|
||||||
{
|
{
|
||||||
if($sql -> db_Select("linkwords", "*", "linkword_id=".$id))
|
if($sql -> db_Select("linkwords", "*", "linkword_id=".$id))
|
||||||
{
|
{
|
||||||
$row = $sql -> db_Fetch();
|
$row = $sql -> db_Fetch();
|
||||||
extract($row);
|
extract($row);
|
||||||
$chkNewWindow = $row['linkword_newwindow'] ? " checked='checked'" : ''; // Open links in new window by default
|
$chkNewWindow = $row['linkword_newwindow'] ? " checked='checked'" : ''; // Open links in new window by default
|
||||||
define("LW_EDIT", TRUE);
|
define("LW_EDIT", TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$linkword_word = '';
|
$linkword_word = '';
|
||||||
$linkword_link = '';
|
$linkword_link = '';
|
||||||
$linkword_active = '';
|
$linkword_active = '';
|
||||||
$linkword_tooltip = '';
|
$linkword_tooltip = '';
|
||||||
$linkword_tip_id = '';
|
$linkword_tip_id = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -397,44 +378,44 @@ if (($action == 'words') || ($action == 'edit'))
|
|||||||
$text = "
|
$text = "
|
||||||
<form method='post' action='".e_SELF."?words'>
|
<form method='post' action='".e_SELF."?words'>
|
||||||
<table class='table adminform'>
|
<table class='table adminform'>
|
||||||
<colgroup>
|
<colgroup>
|
||||||
<col class='col-label' />
|
<col class='col-label' />
|
||||||
<col class='col-control' />
|
<col class='col-control' />
|
||||||
</colgroup>
|
</colgroup>
|
||||||
<tr>
|
<tr>
|
||||||
<td>".LWLAN_21."</td>
|
<td>".LWLAN_21."</td>
|
||||||
<td>
|
<td>
|
||||||
<input class='tbox' type='text' name='linkword_word' size='40' value='".$linkword_word."' maxlength='100' />
|
<input class='tbox' type='text' name='linkword_word' size='40' value='".$linkword_word."' maxlength='100' />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>".LWLAN_6."</td>
|
<td>".LWLAN_6."</td>
|
||||||
<td>
|
<td>
|
||||||
<input class='tbox' type='text' name='linkword_link' size='60' value='".$linkword_link."' maxlength='250' /><br />
|
<input class='tbox' type='text' name='linkword_link' size='60' value='".$linkword_link."' maxlength='250' /><br />
|
||||||
<input type='checkbox' name='linkword_newwindow' value='1'{$chkNewWindow} /> ".LWLAN_55."
|
<input type='checkbox' name='linkword_newwindow' value='1'{$chkNewWindow} /> ".LWLAN_55."
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>".LWLAN_50."</td>
|
<td>".LWLAN_50."</td>
|
||||||
<td>
|
<td>
|
||||||
<textarea rows='3' cols='80' class='tbox' name='linkword_tooltip'>".$linkword_tooltip."</textarea>
|
<textarea rows='3' cols='80' class='tbox' name='linkword_tooltip'>".$linkword_tooltip."</textarea>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>".LWLAN_62."</td>
|
<td>".LWLAN_62."</td>
|
||||||
<td>
|
<td>
|
||||||
<input class='tbox' type='text' name='linkword_tip_id' size='10' value='".$linkword_tip_id."' maxlength='10' /><span class='field-help'>".LWLAN_63."</span>
|
<input class='tbox' type='text' name='linkword_tip_id' size='10' value='".$linkword_tip_id."' maxlength='10' /><span class='field-help'>".LWLAN_63."</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>".LWLAN_22."</td>
|
<td>".LWLAN_22."</td>
|
||||||
<td>
|
<td>
|
||||||
<select class='tbox' name='linkword_active'>".lw_act_opts($linkword_active)."</select>
|
<select class='tbox' name='linkword_active'>".lw_act_opts($linkword_active)."</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<div class='buttons-bar center'>
|
<div class='buttons-bar center'>
|
||||||
@@ -451,114 +432,114 @@ if (($action == 'words') || ($action == 'edit'))
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
$text = "<div class='center'>\n";
|
$text = "<div class='center'>\n";
|
||||||
if(!$sql -> db_Select("linkwords"))
|
if(!$sql -> db_Select("linkwords"))
|
||||||
{
|
{
|
||||||
//$text .= LWLAN_4;
|
//$text .= LWLAN_4;
|
||||||
$mes->addInfo(LWLAN_4);
|
$mes->addInfo(LWLAN_4);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$text = "
|
$text = "
|
||||||
<table class='table adminlist'>
|
<table class='table adminlist'>
|
||||||
<colgroup>
|
<colgroup>
|
||||||
<col style='width: 5%; vertical-align:top;' />
|
<col style='width: 5%; vertical-align:top;' />
|
||||||
<col style='width: 15%; vertical-align:top;' />
|
<col style='width: 15%; vertical-align:top;' />
|
||||||
<col style='width: 20%; vertical-align:top;' />
|
<col style='width: 20%; vertical-align:top;' />
|
||||||
<col style='width: 10%; vertical-align:top;' />
|
<col style='width: 10%; vertical-align:top;' />
|
||||||
<col style='width: 25%; vertical-align:top;' />
|
<col style='width: 25%; vertical-align:top;' />
|
||||||
<col style='width: 5%; vertical-align:top;' />
|
<col style='width: 5%; vertical-align:top;' />
|
||||||
<col style='width: 10%; vertical-align:top; text-align: center;' />
|
<col style='width: 10%; vertical-align:top; text-align: center;' />
|
||||||
<col style='width: 15%; vertical-align:top; text-align: center;' />
|
<col style='width: 15%; vertical-align:top; text-align: center;' />
|
||||||
</colgroup>
|
</colgroup>
|
||||||
|
<tr>
|
||||||
|
<td>".LAN_ID."</td>
|
||||||
|
<td>".LWLAN_5."</td>
|
||||||
|
<td>".LWLAN_6."</td>
|
||||||
|
<td>".LWLAN_56."</td>
|
||||||
|
<td>".LWLAN_50."</td>
|
||||||
|
<td>".LWLAN_60."</td>
|
||||||
|
<td>".LWLAN_7."</td>
|
||||||
|
<td>".LAN_OPTIONS."</td>
|
||||||
|
</tr>\n";
|
||||||
|
|
||||||
|
while($row = $sql->db_Fetch())
|
||||||
|
{
|
||||||
|
$text .= "
|
||||||
<tr>
|
<tr>
|
||||||
<td>".LAN_ID."</td>
|
<td>{$row['linkword_id']}</td>
|
||||||
<td>".LWLAN_5."</td>
|
<td>{$row['linkword_word']}</td>
|
||||||
<td>".LWLAN_6."</td>
|
<td>{$row['linkword_link']}</td>
|
||||||
<td>".LWLAN_56."</td>
|
<td>".($row['linkword_newwindow'] ? LAN_YES : LAN_NO)."</td>
|
||||||
<td>".LWLAN_50."</td>
|
<td>{$row['linkword_tooltip']}</td>
|
||||||
<td>".LWLAN_60."</td>
|
<td>".($row['linkword_tip_id'] > 0 ? $row['linkword_tip_id'] : '')."</td>
|
||||||
<td>".LWLAN_7."</td>
|
<td>".$lwaction_vals[$row['linkword_active']]."</td>
|
||||||
<td>".LAN_OPTIONS."</td>
|
<td>
|
||||||
</tr>\n";
|
<form action='".e_SELF."' method='post' id='myform_{$row['linkword_id']}' onsubmit=\"return jsconfirm('".LWLAN_18." [ID: {$row['linkword_id']} ]')\">
|
||||||
|
<div>
|
||||||
|
<input class='btn btn-default button' type='button' onclick=\"document.location='".e_SELF."?edit.{$row['linkword_id']}'\" value='".LAN_EDIT."' id='edit_{$row['linkword_id']}' name='edit_linkword_id' />
|
||||||
|
<input class='btn btn-default button' type='submit' value='".LAN_DELETE."' id='delete_{$row['linkword_id']}' name='delete_{$row['linkword_id']}' />
|
||||||
|
</div>
|
||||||
|
</form>\n
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
$text .= "</table>";
|
||||||
|
}
|
||||||
|
|
||||||
while($row = $sql->db_Fetch())
|
$ns->tablerender(LWLAN_11, $mes->render() . $text);
|
||||||
{
|
|
||||||
$text .= "
|
|
||||||
<tr>
|
|
||||||
<td>{$row['linkword_id']}</td>
|
|
||||||
<td>{$row['linkword_word']}</td>
|
|
||||||
<td>{$row['linkword_link']}</td>
|
|
||||||
<td>".($row['linkword_newwindow'] ? LAN_YES : LAN_NO)."</td>
|
|
||||||
<td>{$row['linkword_tooltip']}</td>
|
|
||||||
<td>".($row['linkword_tip_id'] > 0 ? $row['linkword_tip_id'] : '')."</td>
|
|
||||||
<td>".$lwaction_vals[$row['linkword_active']]."</td>
|
|
||||||
<td>
|
|
||||||
<form action='".e_SELF."' method='post' id='myform_{$row['linkword_id']}' onsubmit=\"return jsconfirm('".LWLAN_18." [ID: {$row['linkword_id']} ]')\">
|
|
||||||
<div>
|
|
||||||
<input class='btn btn-default button' type='button' onclick=\"document.location='".e_SELF."?edit.{$row['linkword_id']}'\" value='".LAN_EDIT."' id='edit_{$row['linkword_id']}' name='edit_linkword_id' />
|
|
||||||
<input class='btn btn-default button' type='submit' value='".LAN_DELETE."' id='delete_{$row['linkword_id']}' name='delete_{$row['linkword_id']}' />
|
|
||||||
</div>
|
|
||||||
</form>\n
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
";
|
|
||||||
}
|
|
||||||
$text .= "</table>";
|
|
||||||
}
|
|
||||||
|
|
||||||
$ns->tablerender(LWLAN_11, $mes->render() . $text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($action=='options')
|
if ($action=='options')
|
||||||
{
|
{
|
||||||
$menu_pages = substr($pref['lw_page_visibility'],2); // Knock off the 'show/hide' flag
|
$menu_pages = substr($pref['lw_page_visibility'],2); // Knock off the 'show/hide' flag
|
||||||
$menu_pages = str_replace("|", "\n", $menu_pages);
|
$menu_pages = str_replace("|", "\n", $menu_pages);
|
||||||
$AjaxEnable = varset($pref['lw_ajax_enable'],0);
|
$AjaxEnable = varset($pref['lw_ajax_enable'],0);
|
||||||
$text = "
|
$text = "
|
||||||
<div>
|
<div>
|
||||||
<form method='post' action='".e_SELF."?options'>
|
<form method='post' action='".e_SELF."?options'>
|
||||||
<table class='table adminform'>
|
<table class='table adminform'>
|
||||||
<colgroup>
|
<colgroup>
|
||||||
<col style='width: 30%; />
|
<col style='width: 30%; />
|
||||||
<col style='width: 70%; />
|
<col style='width: 70%; />
|
||||||
</colgroup>
|
</colgroup>
|
||||||
<tr>
|
<tr>
|
||||||
<td>".LWLAN_26."</td>
|
<td>".LWLAN_26."</td>
|
||||||
<td>";
|
<td>";
|
||||||
foreach ($lw_context_areas as $lw_key=>$lw_desc)
|
foreach ($lw_context_areas as $lw_key=>$lw_desc)
|
||||||
{
|
{
|
||||||
$checked = $pref['lw_context_visibility'][$lw_key] ? "checked='checked'" : '';
|
$checked = $pref['lw_context_visibility'][$lw_key] ? "checked='checked'" : '';
|
||||||
$text .= "<input type='checkbox' name='lw_visibility_area[]' value='{$lw_key}' {$checked} /> {$lw_desc}<br />";
|
$text .= "<input type='checkbox' name='lw_visibility_area[]' value='{$lw_key}' {$checked} /> {$lw_desc}<br />";
|
||||||
}
|
}
|
||||||
$text .= "<span class='field-help'>".LWLAN_27."</span></td>
|
$text .= "<span class='field-help'>".LWLAN_27."</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>".LWLAN_28."</td>
|
<td>".LWLAN_28."</td>
|
||||||
<td><textarea rows='5' cols='60' class='tbox' name='linkword_omit_pages' >".$menu_pages."</textarea><span class='field-help'>".LWLAN_29."</span>
|
<td><textarea rows='5' cols='60' class='tbox' name='linkword_omit_pages' >".$menu_pages."</textarea><span class='field-help'>".LWLAN_29."</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>";
|
</tr>";
|
||||||
|
|
||||||
$checked = varset($pref['lw_ajax_enable'],0) ? 'checked=checked' : '';
|
$checked = varset($pref['lw_ajax_enable'],0) ? 'checked=checked' : '';
|
||||||
$text .= "
|
$text .= "
|
||||||
<tr>
|
<tr>
|
||||||
<td>".LWLAN_59."</td>
|
<td>".LWLAN_59."</td>
|
||||||
<td><input type='checkbox' name='lw_ajax_enable' {$checked} /></td>
|
<td><input type='checkbox' name='lw_ajax_enable' {$checked} /></td>
|
||||||
</tr>";
|
</tr>";
|
||||||
|
|
||||||
$checked = varset($pref['lw_notsamepage'],0) ? 'checked=checked' : '';
|
$checked = varset($pref['lw_notsamepage'],0) ? 'checked=checked' : '';
|
||||||
$text .= "
|
$text .= "
|
||||||
<tr>
|
<tr>
|
||||||
<td>".LWLAN_64."</td>
|
<td>".LWLAN_64."</td>
|
||||||
<td><input type='checkbox' name='lw_notsamepage' {$checked} /><span class='field-help'>".LWLAN_65."</span></td>
|
<td><input type='checkbox' name='lw_notsamepage' {$checked} /><span class='field-help'>".LWLAN_65."</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
<div class='buttons-bar center'>
|
<div class='buttons-bar center'>
|
||||||
".$frm->admin_button('saveopts_linkword','no-value','submit', LAN_UPDATE)."
|
".$frm->admin_button('saveopts_linkword','no-value','submit', LAN_UPDATE)."
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>\n";
|
</div>\n";
|
||||||
@@ -570,22 +551,22 @@ $ns -> tablerender(LAN_OPTIONS, $text);
|
|||||||
|
|
||||||
function admin_config_adminmenu()
|
function admin_config_adminmenu()
|
||||||
{
|
{
|
||||||
if (e_QUERY)
|
if (e_QUERY)
|
||||||
{
|
{
|
||||||
$tmp = explode(".", e_QUERY);
|
$tmp = explode(".", e_QUERY);
|
||||||
$action = $tmp[0];
|
$action = $tmp[0];
|
||||||
}
|
}
|
||||||
if (!isset($action) || ($action == ""))
|
if (!isset($action) || ($action == ""))
|
||||||
{
|
{
|
||||||
$action = "words";
|
$action = "words";
|
||||||
}
|
}
|
||||||
$var['words']['text'] = LWLAN_24;
|
$var['words']['text'] = LWLAN_24;
|
||||||
$var['words']['link'] = "admin_config.php";
|
$var['words']['link'] = "admin_config.php";
|
||||||
|
|
||||||
$var['options']['text'] = LAN_OPTIONS;
|
$var['options']['text'] = LAN_OPTIONS;
|
||||||
$var['options']['link'] ="admin_config.php?options";
|
$var['options']['link'] ="admin_config.php?options";
|
||||||
|
|
||||||
show_admin_menu(LWLAN_23, $action, $var);
|
show_admin_menu(LWLAN_23, $action, $var);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,9 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
if(USER_AREA === true) // Don't include in admin area.
|
if(USER_AREA === true) // Don't include in admin area.
|
||||||
{
|
{
|
||||||
e107::css('linkwords','linkwords.css');
|
e107::css('linkwords', 'linkwords.css');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -6,21 +6,11 @@
|
|||||||
* Released under the terms and conditions of the
|
* Released under the terms and conditions of the
|
||||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_plugins/linkwords/e_tohtml.php,v $
|
|
||||||
* $Revision$
|
|
||||||
* $Date$
|
|
||||||
* $Author$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* e107 Linkword plugin
|
* e107 Linkword plugin
|
||||||
*
|
*
|
||||||
* @package e107_plugins
|
|
||||||
* @subpackage linkwords
|
|
||||||
* @version $Id$;
|
|
||||||
*
|
|
||||||
* 'Hook' page
|
* 'Hook' page
|
||||||
* The class is 'hooked' by the parser, to add linkword capability to any context where its enabled.
|
* The class is 'hooked' by the parser, to add linkword capability to any context where its enabled.
|
||||||
*
|
*
|
||||||
@@ -32,12 +22,12 @@ if (!defined('e107_INIT')) { exit; }
|
|||||||
|
|
||||||
define('LW_CACHE_ENABLE', FALSE);
|
define('LW_CACHE_ENABLE', FALSE);
|
||||||
|
|
||||||
|
|
||||||
class e_tohtml_linkwords
|
class e_tohtml_linkwords
|
||||||
{
|
{
|
||||||
protected $lw_enabled = FALSE; // Default to disabled to start
|
protected $lw_enabled = FALSE; // Default to disabled to start
|
||||||
var $lwAjaxEnabled = FALSE; // Adds in Ajax-compatible links
|
var $lwAjaxEnabled = FALSE; // Adds in Ajax-compatible links
|
||||||
var $utfMode = ''; // Flag to enable utf-8 on regex
|
var $utfMode = ''; // Flag to enable utf-8 on regex
|
||||||
|
|
||||||
protected $word_list = array(); // List of link words/phrases
|
protected $word_list = array(); // List of link words/phrases
|
||||||
var $link_list = array(); // Corresponding list of links to apply
|
var $link_list = array(); // Corresponding list of links to apply
|
||||||
var $ext_list = array(); // Flags to determine 'open in new window' for link
|
var $ext_list = array(); // Flags to determine 'open in new window' for link
|
||||||
@@ -53,14 +43,11 @@ class e_tohtml_linkwords
|
|||||||
protected $word_limit = array();
|
protected $word_limit = array();
|
||||||
// protected $maxPerWord = 3;
|
// protected $maxPerWord = 3;
|
||||||
|
|
||||||
|
|
||||||
public function enable()
|
public function enable()
|
||||||
{
|
{
|
||||||
$this->lw_enabled = true;
|
$this->lw_enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function setWordData($arr = array())
|
public function setWordData($arr = array())
|
||||||
{
|
{
|
||||||
foreach($arr as $val)
|
foreach($arr as $val)
|
||||||
@@ -73,7 +60,6 @@ class e_tohtml_linkwords
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function setAreaOpts($arr = array())
|
public function setAreaOpts($arr = array())
|
||||||
{
|
{
|
||||||
$this->area_opts = $arr;
|
$this->area_opts = $arr;
|
||||||
@@ -89,12 +75,9 @@ class e_tohtml_linkwords
|
|||||||
/* constructor */
|
/* constructor */
|
||||||
function __construct()
|
function __construct()
|
||||||
{
|
{
|
||||||
|
$tp = e107::getParser();
|
||||||
|
$pref = e107::pref('core');
|
||||||
|
$frm = e107::getForm();
|
||||||
$tp = e107::getParser();
|
|
||||||
$pref = e107::pref('core');
|
|
||||||
$frm = e107::getForm();
|
|
||||||
|
|
||||||
// $this->maxPerWord = vartrue($pref['lw_max_per_word'], 25);
|
// $this->maxPerWord = vartrue($pref['lw_max_per_word'], 25);
|
||||||
$this->customClass = vartrue($pref['lw_custom_class'],'');
|
$this->customClass = vartrue($pref['lw_custom_class'],'');
|
||||||
@@ -243,14 +226,13 @@ class e_tohtml_linkwords
|
|||||||
$this->area_opts = array();
|
$this->area_opts = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!$this->lw_enabled || empty($this->area_opts) || !array_key_exists($area,$this->area_opts) || !$this->area_opts[$area])
|
if (!$this->lw_enabled || empty($this->area_opts) || !array_key_exists($area,$this->area_opts) || !$this->area_opts[$area])
|
||||||
{
|
{
|
||||||
// e107::getDebug()->log("Link words skipped on ".substr($text, 0, 50));
|
// e107::getDebug()->log("Link words skipped on ".substr($text, 0, 50));
|
||||||
return $text; // No linkwords in disabled areas
|
return $text; // No linkwords in disabled areas
|
||||||
}
|
}
|
||||||
|
|
||||||
// Split up by HTML tags and process the odd bits here
|
// Split up by HTML tags and process the odd bits here
|
||||||
$ptext = "";
|
$ptext = "";
|
||||||
$lflag = FALSE;
|
$lflag = FALSE;
|
||||||
|
|
||||||
@@ -274,9 +256,10 @@ class e_tohtml_linkwords
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (trim($cont))
|
if (trim($cont))
|
||||||
{ // Some non-white space - worth word matching
|
{
|
||||||
|
// Some non-white space - worth word matching
|
||||||
$ptext .= $this->linksproc($cont,0,count($this->word_list));
|
$ptext .= $this->linksproc($cont,0,count($this->word_list));
|
||||||
// echo "Check linkwords: ".count($this->word_list).'<br />';
|
// echo "Check linkwords: ".count($this->word_list).'<br />';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -304,7 +287,7 @@ class e_tohtml_linkwords
|
|||||||
$doSamePage = !e107::getPref('lw_notsamepage');
|
$doSamePage = !e107::getPref('lw_notsamepage');
|
||||||
|
|
||||||
// Consider next line - stripos is PHP5, and mb_stripos is PHP >= 5.2 - so may well often require handling
|
// Consider next line - stripos is PHP5, and mb_stripos is PHP >= 5.2 - so may well often require handling
|
||||||
// while (($first < $limit) && (stripos($text,$this->word_list[$first]) === FALSE)) { $first++; }; // *utf (stripos is PHP5 - compatibility handler implements)
|
// while (($first < $limit) && (stripos($text,$this->word_list[$first]) === FALSE)) { $first++; }; // *utf (stripos is PHP5 - compatibility handler implements)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -327,13 +310,11 @@ class e_tohtml_linkwords
|
|||||||
$ret = '';
|
$ret = '';
|
||||||
$linkwd = '';
|
$linkwd = '';
|
||||||
$linkrel = array();
|
$linkrel = array();
|
||||||
// $linkwd = "href='#' "; // Not relevant for Prototype, but needed with 'pure' JS to make tooltip stuff work - doesn't find link elements without href
|
// $linkwd = "href='#' "; // Not relevant for Prototype, but needed with 'pure' JS to make tooltip stuff work - doesn't find link elements without href
|
||||||
$lwClass = array();
|
$lwClass = array();
|
||||||
$lw = $this->word_list[$first]; // This is the word we're matching - in lower case in our 'master' list
|
$lw = $this->word_list[$first]; // This is the word we're matching - in lower case in our 'master' list
|
||||||
$tooltip = '';
|
$tooltip = '';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($this->tip_list[$first])
|
if ($this->tip_list[$first])
|
||||||
{ // Got tooltip
|
{ // Got tooltip
|
||||||
if ($this->lwAjaxEnabled)
|
if ($this->lwAjaxEnabled)
|
||||||
@@ -365,8 +346,9 @@ class e_tohtml_linkwords
|
|||||||
|
|
||||||
if (!count($lwClass))
|
if (!count($lwClass))
|
||||||
{
|
{
|
||||||
// return $this->linksproc($sl,$first+1,$limit); // Nothing to do - move on to next word (shouldn't really get here)
|
// return $this->linksproc($sl,$first+1,$limit); // Nothing to do - move on to next word (shouldn't really get here)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($linkrel))
|
if (count($linkrel))
|
||||||
{
|
{
|
||||||
$linkwd .= " rel='".implode(' ',$linkrel)."'";
|
$linkwd .= " rel='".implode(' ',$linkrel)."'";
|
||||||
@@ -374,7 +356,7 @@ class e_tohtml_linkwords
|
|||||||
|
|
||||||
// This splits the text into blocks, some of which will precisely contain a linkword
|
// This splits the text into blocks, some of which will precisely contain a linkword
|
||||||
$split_line = preg_split('#\b('.$lw.')(\s|\b)#i'.$this->utfMode, $text, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE ); // *utf (selected)
|
$split_line = preg_split('#\b('.$lw.')(\s|\b)#i'.$this->utfMode, $text, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE ); // *utf (selected)
|
||||||
// $class = "".implode(' ',$lwClass)."' ";
|
// $class = "".implode(' ',$lwClass)."' ";
|
||||||
$class = implode(' ',$lwClass);
|
$class = implode(' ',$lwClass);
|
||||||
|
|
||||||
$hash = md5($lw);
|
$hash = md5($lw);
|
||||||
@@ -386,10 +368,8 @@ class e_tohtml_linkwords
|
|||||||
|
|
||||||
foreach ($split_line as $count=>$sl)
|
foreach ($split_line as $count=>$sl)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($tp->ustrtolower($sl) == $lw && $this->wordCount[$hash] < (int) $this->word_limit[$first]) // Do linkword replace // We know the linkword is already lower case // *utf
|
if ($tp->ustrtolower($sl) == $lw && $this->wordCount[$hash] < (int) $this->word_limit[$first]) // Do linkword replace // We know the linkword is already lower case // *utf
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->wordCount[$hash]++;
|
$this->wordCount[$hash]++;
|
||||||
|
|
||||||
$classCount = " lw-".$this->wordCount[$hash];
|
$classCount = " lw-".$this->wordCount[$hash];
|
||||||
@@ -417,7 +397,4 @@ class e_tohtml_linkwords
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
@@ -8,7 +8,6 @@
|
|||||||
*
|
*
|
||||||
* Linkwords plugin - language file (only needed for admin)
|
* Linkwords plugin - language file (only needed for admin)
|
||||||
*
|
*
|
||||||
* $Id*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//define("LWLAN_1", "Field(s) left blank.");
|
//define("LWLAN_1", "Field(s) left blank.");
|
||||||
@@ -55,7 +54,6 @@ define("LWLAN_41", "User-entered body text (e.g. forum)");
|
|||||||
// Reserve numbers for further context strings
|
// Reserve numbers for further context strings
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
define("LWLAN_50", "Tooltip");
|
define("LWLAN_50", "Tooltip");
|
||||||
define("LWLAN_51", "Inactive");
|
define("LWLAN_51", "Inactive");
|
||||||
define("LWLAN_52", "Linkword only");
|
define("LWLAN_52", "Linkword only");
|
||||||
@@ -74,14 +72,6 @@ define("LWLAN_64", "Suppress link on current page");
|
|||||||
define("LWLAN_65", "When checked, suppresses clickable link if points to current page");
|
define("LWLAN_65", "When checked, suppresses clickable link if points to current page");
|
||||||
|
|
||||||
|
|
||||||
// Installation-related
|
|
||||||
//define("LWLANINS_1", "Linkwords");
|
|
||||||
//define("LWLANINS_2", "This plugin links specified words with a defined link and/or tooltip");
|
|
||||||
//define("LWLANINS_3", "Configure LinkWords");
|
|
||||||
//define("LWLANINS_4", "To configure please click on the link in the plugins section of the admin front page");
|
|
||||||
//define("LWLANINS_5", "Upgrade complete");
|
|
||||||
|
|
||||||
|
|
||||||
// Help text
|
// Help text
|
||||||
define("LAN_LW_HELP_00","Linkwords Help");
|
define("LAN_LW_HELP_00","Linkwords Help");
|
||||||
define("LAN_LW_HELP_01","
|
define("LAN_LW_HELP_01","
|
||||||
@@ -108,9 +98,3 @@ define("LAN_LW_HELP_02","Define the words which become clickable links, or which
|
|||||||
<b><u>Activate?</u></b><br />
|
<b><u>Activate?</u></b><br />
|
||||||
Defines which options are active.
|
Defines which options are active.
|
||||||
");
|
");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
|
@@ -1,6 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
// Admin log related
|
// Admin log related
|
||||||
define("LAN_AL_LINKWD_00", "Linkword-related message");
|
define("LAN_AL_LINKWD_00", "Linkword-related message");
|
||||||
define("LAN_AL_LINKWD_01", "Linkword Added");
|
define("LAN_AL_LINKWD_01", "Linkword Added");
|
||||||
@@ -9,5 +8,4 @@ define("LAN_AL_LINKWD_03", "Linkword deleted");
|
|||||||
define("LAN_AL_LINKWD_04", "Linkword options updated");
|
define("LAN_AL_LINKWD_04", "Linkword options updated");
|
||||||
define("LAN_AL_LINKWD_05", "Linkwords version update"); // Used in 0.7-compatible stub only
|
define("LAN_AL_LINKWD_05", "Linkwords version update"); // Used in 0.7-compatible stub only
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
@@ -6,25 +6,11 @@
|
|||||||
* Released under the terms and conditions of the
|
* Released under the terms and conditions of the
|
||||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
* $Source: /cvs_backup/e107_0.8/e107_plugins/linkwords/linkwords.php,v $
|
|
||||||
* $Revision$
|
|
||||||
* $Date$
|
|
||||||
* $Author$
|
|
||||||
*/
|
*/
|
||||||
/*
|
|
||||||
|
|
|
||||||
| This is just a stub so that systems migrated from 0.7 don't crash
|
|
||||||
| It auto-updates the prefs so that the newer routine is called in future.
|
|
||||||
|
|
|
||||||
+----------------------------------------------------------------------------+
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!defined('e107_INIT')) { exit; }
|
if (!defined('e107_INIT')) { exit; }
|
||||||
// if (!e107::isInstalled('linkwords')) exit; // This will break a site completely under some circumstance.
|
// if (!e107::isInstalled('linkwords')) exit; // This will break a site completely under some circumstance.
|
||||||
|
|
||||||
|
|
||||||
class e_linkwords
|
class e_linkwords
|
||||||
{
|
{
|
||||||
function e_linkwords()
|
function e_linkwords()
|
||||||
@@ -33,13 +19,15 @@ class e_linkwords
|
|||||||
/* constructor */
|
/* constructor */
|
||||||
// Do an auto-update on the variable used to hook parsers - so we should only be called once
|
// Do an auto-update on the variable used to hook parsers - so we should only be called once
|
||||||
|
|
||||||
e107::lan('linkwords',e_LANGUAGE); // e_PLUGIN."linkwords/languages/".e_LANGUAGE.".php"
|
e107::lan('linkwords', e_LANGUAGE); // e_PLUGIN."linkwords/languages/".e_LANGUAGE.".php"
|
||||||
|
|
||||||
$hooks = explode(",",$pref['tohtml_hook']);
|
$hooks = explode(",", $pref['tohtml_hook']);
|
||||||
if (($key=array_search('linkwords',$hooks)) !== FALSE)
|
|
||||||
|
if(($key=array_search('linkwords',$hooks)) !== FALSE)
|
||||||
{
|
{
|
||||||
unset($hooks[$key]);
|
unset($hooks[$key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($hooks) == 0)
|
if (count($hooks) == 0)
|
||||||
{
|
{
|
||||||
unset($pref['tohtml_hook']);
|
unset($pref['tohtml_hook']);
|
||||||
@@ -48,14 +36,17 @@ class e_linkwords
|
|||||||
{
|
{
|
||||||
$pref['tohtml_hook'] = implode(',',$hooks);
|
$pref['tohtml_hook'] = implode(',',$hooks);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($pref['e_tohtml_list']))
|
if (!isset($pref['e_tohtml_list']))
|
||||||
{
|
{
|
||||||
$pref['e_tohtml_list'] = array();
|
$pref['e_tohtml_list'] = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_array('linkwords',$pref['e_tohtml_list']))
|
if (!in_array('linkwords',$pref['e_tohtml_list']))
|
||||||
{
|
{
|
||||||
$pref['e_tohtml_list'][] = 'linkwords';
|
$pref['e_tohtml_list'][] = 'linkwords';
|
||||||
}
|
}
|
||||||
|
|
||||||
save_prefs();
|
save_prefs();
|
||||||
e107::getLog()->add('LINKWD_05',LWLAN_58.'[!br!]'.$pref['tohtml_hook'],''); // Log that the update was done
|
e107::getLog()->add('LINKWD_05',LWLAN_58.'[!br!]'.$pref['tohtml_hook'],''); // Log that the update was done
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user