1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-29 19:00:26 +02:00

Linkwords - code-clean-up (no functional changes)

Tabs, spacing, readability
This commit is contained in:
Tijn Kuyper
2019-10-26 18:42:25 +02:00
parent 01adf399bb
commit ab7cd3bb58
7 changed files with 428 additions and 500 deletions

View File

@@ -18,37 +18,28 @@
exit ;
}
e107::lan('linkwords', true); // e_PLUGIN.'linkwords/languages/'.e_LANGUAGE.'_admin.php'
e107::lan('linkwords', true);
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')
);
@@ -60,14 +51,10 @@
}
class linkwords_ui extends e_admin_ui
{
protected $pluginTitle = 'Linkwords';
protected $pluginName = 'core';
protected $pluginName = 'linkwords';
// protected $eventName = 'linkwords-linkwords'; // remove comment to enable event triggers in admin.
protected $table = 'linkwords';
protected $pid = 'linkword_id';
@@ -82,24 +69,21 @@
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', ),
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'=>''),
@@ -107,10 +91,8 @@
'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()
{
@@ -120,8 +102,21 @@
}
// 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);
$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']))
{
@@ -174,18 +169,6 @@
}
/*
// optional - a custom page.
public function customPage()
{
$ns = e107::getRender();
$text = 'Hello World!';
$ns->tablerender('Hello',$text);
}
*/
}
@@ -195,7 +178,6 @@
}
new linkwords_admin();
require_once(e_ADMIN."auth.php");
@@ -206,7 +188,6 @@
/*

View File

@@ -1,9 +1,6 @@
<?php
if(USER_AREA === true) // Don't include in admin area.
{
e107::css('linkwords', 'linkwords.css');
}

View File

@@ -6,21 +6,11 @@
* Released under the terms and conditions of the
* 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
*
* @package e107_plugins
* @subpackage linkwords
* @version $Id$;
*
* 'Hook' page
* 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);
class e_tohtml_linkwords
{
protected $lw_enabled = FALSE; // Default to disabled to start
var $lwAjaxEnabled = FALSE; // Adds in Ajax-compatible links
var $utfMode = ''; // Flag to enable utf-8 on regex
protected $word_list = array(); // List of link words/phrases
var $link_list = array(); // Corresponding list of links to apply
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 $maxPerWord = 3;
public function enable()
{
$this->lw_enabled = true;
}
public function setWordData($arr = array())
{
foreach($arr as $val)
@@ -73,7 +60,6 @@ class e_tohtml_linkwords
}
}
public function setAreaOpts($arr = array())
{
$this->area_opts = $arr;
@@ -89,9 +75,6 @@ class e_tohtml_linkwords
/* constructor */
function __construct()
{
$tp = e107::getParser();
$pref = e107::pref('core');
$frm = e107::getForm();
@@ -243,7 +226,6 @@ class e_tohtml_linkwords
$this->area_opts = array();
}
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));
@@ -274,7 +256,8 @@ class e_tohtml_linkwords
else
{
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));
// echo "Check linkwords: ".count($this->word_list).'<br />';
}
@@ -332,8 +315,6 @@ class e_tohtml_linkwords
$lw = $this->word_list[$first]; // This is the word we're matching - in lower case in our 'master' list
$tooltip = '';
if ($this->tip_list[$first])
{ // Got tooltip
if ($this->lwAjaxEnabled)
@@ -367,6 +348,7 @@ class e_tohtml_linkwords
{
// return $this->linksproc($sl,$first+1,$limit); // Nothing to do - move on to next word (shouldn't really get here)
}
if (count($linkrel))
{
$linkwd .= " rel='".implode(' ',$linkrel)."'";
@@ -386,10 +368,8 @@ class e_tohtml_linkwords
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
{
$this->wordCount[$hash]++;
$classCount = " lw-".$this->wordCount[$hash];
@@ -417,7 +397,4 @@ class e_tohtml_linkwords
}
}
?>

View File

@@ -8,7 +8,6 @@
*
* Linkwords plugin - language file (only needed for admin)
*
* $Id*
*/
//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
define("LWLAN_50", "Tooltip");
define("LWLAN_51", "Inactive");
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");
// 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
define("LAN_LW_HELP_00","Linkwords Help");
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 />
Defines which options are active.
");
?>

View File

@@ -1,6 +1,5 @@
<?php
// Admin log related
define("LAN_AL_LINKWD_00", "Linkword-related message");
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_05", "Linkwords version update"); // Used in 0.7-compatible stub only
?>

View File

@@ -6,25 +6,11 @@
* Released under the terms and conditions of the
* 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 (!e107::isInstalled('linkwords')) exit; // This will break a site completely under some circumstance.
class e_linkwords
{
function e_linkwords()
@@ -36,10 +22,12 @@ class e_linkwords
e107::lan('linkwords', e_LANGUAGE); // e_PLUGIN."linkwords/languages/".e_LANGUAGE.".php"
$hooks = explode(",", $pref['tohtml_hook']);
if(($key=array_search('linkwords',$hooks)) !== FALSE)
{
unset($hooks[$key]);
}
if (count($hooks) == 0)
{
unset($pref['tohtml_hook']);
@@ -48,14 +36,17 @@ class e_linkwords
{
$pref['tohtml_hook'] = implode(',',$hooks);
}
if (!isset($pref['e_tohtml_list']))
{
$pref['e_tohtml_list'] = array();
}
if (!in_array('linkwords',$pref['e_tohtml_list']))
{
$pref['e_tohtml_list'][] = 'linkwords';
}
save_prefs();
e107::getLog()->add('LINKWD_05',LWLAN_58.'[!br!]'.$pref['tohtml_hook'],''); // Log that the update was done
return;