diff --git a/e107_plugins/linkwords/admin_config.php b/e107_plugins/linkwords/admin_config.php index 7e011e75c..a837c99b5 100644 --- a/e107_plugins/linkwords/admin_config.php +++ b/e107_plugins/linkwords/admin_config.php @@ -11,32 +11,53 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_plugins/linkwords/admin_config.php,v $ -| $Revision: 1.6 $ -| $Date: 2008-01-11 22:13:43 $ +| $Revision: 1.7 $ +| +| ***** START OF VERSION WHICH ALLOWS TOOLTIPS (also order of forms changed ) +| +| $Date: 2008-12-07 21:55:01 $ | $Author: e107steved $ +----------------------------------------------------------------------------+ */ require_once("../../class2.php"); -if (!getperms("P")) { +if (!plugInstalled('linkwords')) header("Location: ".e_BASE."index.php"); +if (!getperms("P")) +{ header("location:".e_BASE."index.php"); exit ; } require_once(e_ADMIN."auth.php"); -@include_once(e_PLUGIN."linkwords/languages/".e_LANGUAGE.".php"); -@include_once(e_PLUGIN."linkwords/languages/English.php"); +@include_lan(e_PLUGIN."linkwords/languages/".e_LANGUAGE."_admin_linkwords.php"); $lw_context_areas = array( - 'title' => LWLAN_33, - 'summary' => LWLAN_34, - 'body' => LWLAN_35, - 'description' => LWLAN_36, - 'user_title' => LWLAN_40, - 'user_body' => LWLAN_41 + 'TITLE' => LWLAN_33, + 'SUMMARY' => LWLAN_34, + 'BODY' => LWLAN_35, + 'DESCRIPTION' => LWLAN_36, + 'USER_TITLE' => LWLAN_40, + 'USER_BODY' => LWLAN_41 // Don't do the next three - linkwords are meaningless on them // 'olddefault' => LWLAN_37, // 'linktext' => LWLAN_38, // 'rawtext' => LWLAN_39' ); + +// Yes, I know its a silly order - but that's history! +$lwaction_vals = array(1=>LWLAN_51, 0=>LWLAN_52, 2=>LWLAN_53, 3=>LWLAN_54); + +// Generate dropdown for possible actions on finding a linkword +function lw_act_opts($curval) +{ + global $lwaction_vals; + $ret = ''; + foreach ($lwaction_vals as $opt => $val) + { + $selected = ($curval == $opt ? "selected='selected'" : ""); + $ret .= "\n"; + } + return $ret; +} + $deltest = array_flip($_POST); @@ -47,6 +68,7 @@ if(isset($deltest[LWLAN_17])) if ($sql->db_Count("linkwords", "(*)", "WHERE linkword_id = ".$delete_id)) { $sql->db_Delete("linkwords", "linkword_id=".$delete_id); + $admin_log->log_event('LINKWD_03','ID: '.$delete_id,''); $message = LWLAN_19; } } @@ -57,7 +79,7 @@ if(e_QUERY) if (!isset($lw_qs[0])) $lw_qs[0] = 'words'; if (!isset($lw_qs[1])) $lw_qs[1] = -1; $action = $lw_qs[0]; - $id = $lw_qs[1]; + $id = intval($lw_qs[1]); } if (!isset($action)) $action = 'words'; @@ -65,13 +87,15 @@ if (isset($_POST['saveopts_linkword'])) { // Save options page // Array of context flags $pref['lw_context_visibility'] = array( - 'olddefault' => FALSE, - 'title' => FALSE, - 'summary' => FALSE, - 'body' => FALSE, - 'description' => FALSE, - 'linktext' => FALSE, - 'rawtext' => FALSE + 'OLDDEFAULT' => FALSE, + 'TITLE' => FALSE, + 'USER_TITLE' => FALSE, + 'SUMMARY' => FALSE, + 'BODY' => FALSE, + 'USER_BODY' => FALSE, + 'DESCRIPTION' => FALSE, + 'LINKTEXT' => FALSE, + 'RAWTEXT' => FALSE ); foreach ($_POST['lw_visibility_area'] as $can_see) { @@ -87,40 +111,55 @@ if (isset($_POST['saveopts_linkword'])) $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']); save_prefs(); + $logString = implode(', ',$pref['lw_context_visibility']).'[!br!]'.$pref['lw_page_visibility'].'[!br!]'.$pref['lw_ajax_enable']; + $admin_log->log_event('LINKWD_04',$logString,''); } -if (isset($_POST['submit_linkword'])) +if (isset($_POST['submit_linkword']) || isset($_POST['update_linkword'])) { if(!$_POST['linkwords_word'] && $_POST['linkwords_url']) - { + { // Key fields empty $message = LWLAN_1; } else { - $word = $tp -> toDB($_POST['linkword_word']); - $link = $tp -> toDB($_POST['linkword_link']); - $active = intval($_POST['linkword_active']); - $sql -> db_Insert("linkwords", "0, {$active}, '{$word}', '{$link}' "); - $message = LWLAN_2; - } -} + $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; -if (isset($_POST['update_linkword'])) -{ - if(!$_POST['linkwords_word'] && $_POST['linkwords_url']) - { - $message = LWLAN_1; - } - else - { - $id = $_POST['id']; - $word = $tp -> toDB($_POST['linkword_word']); - $link = $tp -> toDB($_POST['linkword_link']); - $active = $_POST['linkword_active']; - $sql -> db_Update("linkwords", "linkword_active=$active, linkword_word='$word', linkword_link='$link' WHERE linkword_id=".$id); - $message = LWLAN_3; + $logString = implode('[!br!]',$data); + if (isset($_POST['submit_linkword'])) + { + if ($sql -> db_Insert('linkwords', $data)) + { + $message = LWLAN_2; + $admin_log->log_event('LINKWD_01',$logString,''); + } + else + { + $message = LWLAN_57; + } + } + 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)) + { + $message = LWLAN_3; + $logString = 'ID: '.$id.'[!br!]'.$logString; + $admin_log->log_event('LINKWD_02',$logString,''); + } + else + { + $message = LWLAN_57; + } + } } } @@ -131,13 +170,14 @@ if (isset($message)) } - +$chkNewWindow = " checked='checked'"; // Open links in new window by default if($action == "edit") { if($sql -> db_Select("linkwords", "*", "linkword_id=".$id)) { $row = $sql -> db_Fetch(); extract($row); + $chkNewWindow = $row['linkword_newwindow'] ? " checked='checked'" : ''; // Open links in new window by default define("LW_EDIT", TRUE); } } @@ -154,45 +194,64 @@ $text = "
+ + + + - - + - - + - - + + + + + + + + + + +
".LWLAN_21." +".LWLAN_21."
".LWLAN_6." - +".LWLAN_6." +
+ ".LWLAN_55."
".LWLAN_22." - ".LWLAN_9."   - ".LWLAN_10." +".LWLAN_50." + +
".LWLAN_62." + ".LWLAN_63." +
".LWLAN_22."
". -(defined("LW_EDIT") ? "" : "")." +(defined("LW_EDIT") ? "" : "")."
\n"; + $ns -> tablerender(LWLAN_31, $text); } - -// Now display existing linkwords if (($action == 'words') || ($action == 'edit')) { + + $text = "
\n"; if(!$sql -> db_Select("linkwords")) { @@ -201,30 +260,49 @@ if (($action == 'words') || ($action == 'edit')) else { $text = " +
- - - - - + + + + + + + + + + + + + + + + + + \n"; while($row = $sql -> db_Fetch()) { - extract($row); $text .= " - - - - - - + + + + + + + - \n"; + "; } $text .= "
".LWLAN_5."".LWLAN_6."".LWLAN_7."".LWLAN_8."
".LWLAN_61."".LWLAN_5."".LWLAN_6."".LWLAN_56."".LWLAN_50."".LWLAN_60."".LWLAN_7."".LWLAN_8."
$linkword_word$linkword_link".(!$linkword_active ? LWLAN_12 : LWLAN_13)." - - + {$row['linkword_id']}{$row['linkword_word']}{$row['linkword_link']}".($row['linkword_newwindow'] ? LAN_YES : LAN_NO)."{$row['linkword_tooltip']}".($row['linkword_tip_id'] > 0 ? $row['linkword_tip_id'] : '')."".$lwaction_vals[$row['linkword_active']]." + +
+ + +
+ \n
"; } @@ -239,6 +317,7 @@ if ($action=='options') { $menu_pages = substr($pref['lw_page_visibility'],2); // Knock off the 'show/hide' flag $menu_pages = str_replace("|", "\n", $menu_pages); + $AjaxEnable = varset($pref['lw_ajax_enable'],0); $text = "
@@ -265,6 +344,15 @@ if ($action=='options') ".LWLAN_29." + "; + + $checked = varset($pref['lw_ajax_enable'],0) ? 'checked=checked' : ''; + $text .= " + + ".LWLAN_59." + + + ".""." diff --git a/e107_plugins/linkwords/e_help.php b/e107_plugins/linkwords/e_help.php new file mode 100644 index 000000000..329dcb802 --- /dev/null +++ b/e107_plugins/linkwords/e_help.php @@ -0,0 +1,38 @@ + tablerender(LAN_LW_HELP_00, $text); +unset($text); +?> \ No newline at end of file diff --git a/e107_plugins/linkwords/e_tohtml.php b/e107_plugins/linkwords/e_tohtml.php index a06e0ebce..00b2da8ec 100755 --- a/e107_plugins/linkwords/e_tohtml.php +++ b/e107_plugins/linkwords/e_tohtml.php @@ -3,7 +3,7 @@ + ----------------------------------------------------------------------------+ | e107 website system | -| Steve Dunstan 2001-2002 +| ©Steve Dunstan 2001-2002 | http://e107.org | jalist@e107.org | @@ -11,149 +11,213 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_plugins/linkwords/e_tohtml.php,v $ -| $Revision: 1.2 $ -| $Date: 2008-02-08 20:09:43 $ -| $Author: mcfly_e107 $ +| $Revision: 1.3 $ +| $Date: 2008-12-07 21:55:01 $ +| $Author: e107steved $ +| +| *utf - flags functions which need utf-8-aware code +TODO: + 1. Add utf-8 aware routines - done, test a bit more + 2. Add special effects for tooltips + 3. Caching? | +----------------------------------------------------------------------------+ */ if (!defined('e107_INIT')) { exit; } +if (!plugInstalled('linkwords')) exit; class e_tohtml_linkwords { var $lw_enabled = FALSE; // Default to disabled to start - var $word_list = array(); // List of link words/phrases - var $link_list = array(); // Corresponding list of links to apply - var $tip_list = array(); - var $area_opts = array(); // Process flags for the various contexts + var $lwAjaxEnabled = FALSE; // Adds in Ajax-compatible links + var $utfMode = ''; // Flag to enable utf-8 on regex + var $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 + var $tip_list = array(); // Store for tooltips + var $area_opts = array(); // Process flags for the various contexts var $block_list = array(); // Array of 'blocked' pages + var $LinkID = array(); // Unique ID for each linkword + - function to_html() + /* constructor */ + function e_tohtml_linkwords() { - global $pref; - /* constructor */ + global $pref, $tp; // See whether they should be active on this page - if not, no point doing anything! if ((strpos(e_SELF, ADMINDIR) !== FALSE) || (strpos(e_PAGE, "admin_") !== FALSE)) return; // No linkwords on admin directories // Now see if disabled on specific pages $check_url = e_SELF.(e_QUERY ? "?".e_QUERY : ''); - $this->block_list = explode("|",substr($pref['lw_page_visibility'],2)); // Knock off the 'show/hide' flag + $this->block_list = explode("|",substr(varset($pref['lw_page_visibility'],''),2)); // Knock off the 'show/hide' flag foreach ($this->block_list as $p) { if ($p=trim($p)) { - if(substr($p, -1) == '!') - { - $p = substr($p, 0, -1); - if(substr($check_url, strlen($p)*-1) == $p) return; - } - else - { - if(strpos($check_url, $p) !== FALSE) return; + if(substr($p, -1) == '!') + { + $p = substr($p, 0, -1); + if(substr($check_url, strlen($p)*-1) == $p) return; + } + else + { + if(strpos($check_url, $p) !== FALSE) return; } } - } + } // Will probably need linkwords on this page - so get the info - $this->lw_enabled = TRUE; $link_sql = new db; - if($link_sql -> db_Select("linkwords", "*", "linkword_active=0")) + if($link_sql -> db_Select("linkwords", "*", "linkword_active!=1")) { + $this->lw_enabled = TRUE; while ($row = $link_sql->db_Fetch()) { - $lw = trim(strtolower($row['linkword_word'])); + extract($row); +// $lw = strtolower($linkword_word); // It was trimmed when saved *utf + $lw = $tp->uStrToLower($linkword_word); // It was trimmed when saved *utf + if ($linkword_active == 2) $linkword_link = ''; // Make sure linkword disabled + if ($linkword_active < 2) $linkword_tooltip = ''; // Make sure tooltip disabled + $lwID = max($row['linkword_tip_id'], $row['linkword_id']); // If no specific ID defined, use the DB record ID if (strpos($lw,',')) { // Several words to same link $lwlist = explode(',',$lw); foreach ($lwlist as $lw) { $this->word_list[] = trim($lw); - $this->link_list[] = $row['linkword_link']; + $this->link_list[] = $linkword_link; + $this->tip_list[] = $linkword_tooltip; + $this->ext_list[] = $linkword_newwindow; + $this->LinkID[] = $lwID; } } else { - $this->word_list[] = $lw; - $this->link_list[] = $row['linkword_link']; + $this->word_list[] = $lw; + $this->link_list[] = $linkword_link; + $this->tip_list[] = $linkword_tooltip; + $this->ext_list[] = $linkword_newwindow; + $this->LinkID[] = $lwID; } } } - if (is_array($pref['lw_context_visibility'])) - { - $this->area_opts = $pref['lw_context_visibility']; - } + $this->area_opts = $pref['lw_context_visibility']; + $this->utfMode = (strtolower(CHARSET) == 'utf-8') ? 'u' : ''; // Flag to enable utf-8 on regex + $this->lwAjaxEnabled = varset($pref['lw_ajax_enable'],0); } - function linkwords($text,$area = 'olddefault') + function to_html($text,$area = 'olddefault') { - if (!$this->lw_enabled || !array_key_exists($area,$this->area_opts) || !$this->area_opts[$area]) return $text; // No linkwords in disabled areas - + if (!$this->lw_enabled || !array_key_exists($area,$this->area_opts) || !$this->area_opts[$area]) return $text; // No linkwords in disabled areas // Split up by HTML tags and process the odd bits here - $ptext = ""; - $lflag = FALSE; + $ptext = ""; + $lflag = FALSE; - $content = preg_split('#(<.*?>)#mis', $text, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE ); - foreach($content as $cont) - { - if (strpos($cont, "<") !== FALSE) - { // Its some HTML - $ptext .= $cont; - if (strpos($cont,"linksproc($cont,0,count($this->word_list)); + // Shouldn't need utf-8 on next line - just looking for HTML tags + $content = preg_split('#(<.*?>)#mis', $text, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE ); + foreach($content as $cont) + { + if ($cont[0] == "<") + { // Its some HTML + $ptext .= $cont; + if (substr($cont,0,2) == "linksproc($cont,0,count($this->word_list)); +// echo "Check linkwords: ".count($this->word_list).'
'; + } + else + { + $ptext .= $cont; + } + } } - else - { - $ptext .= $cont; - } - } } - } - return $ptext; + return $ptext; } function linksproc($text,$first,$limit) { // This function is called recursively - it splits the text up into blocks - some containing a particular linkword - while (($first < $limit) && (stripos($text,$this->word_list[$first]) === FALSE)) { $first++; }; - if ($first == $limit) return $text; // Return if no linkword found - - // There's at least one occurrence of the linkword in the text - $ret = ''; - $lw = $this->word_list[$first]; - // This splits the text into blocks, some of which will precisely contain a linkword - $split_line = preg_split('#\b('.$lw.')\b#i', $text, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE ); - foreach ($split_line AS $sl) - { - if (strcasecmp($sl,$lw) == 0) - { // Do linkword replace - $ret .= " {$sl}"; + global $tp; + + // 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) && (strpos($tp->uStrToLower($text),$this->word_list[$first]) === FALSE)) { $first++; }; // *utf + if ($first == $limit) return $text; // Return if no linkword found + + // There's at least one occurrence of the linkword in the text + // Prepare all info once only + // If supporting Ajax, use the following: + // + // linkwordId::122 is a unique ID + $ret = ''; + $linkwd = ''; + $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 + $lwClass = array(); + $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) + { + $linkrel[] = 'linkwordID::'.$this->LinkID[$first]; + $lwClass[] = 'lw_ajax'; + } + else + { + $tooltip = " title='{$this->tip_list[$first]}' "; + $lwClass[] = 'lw_tip'; + } } - elseif (trim($sl)) - { // Something worthwhile left - look for more linkwords in it - $ret .= $this->linksproc($sl,$first+1,$limit); + if ($this->link_list[$first]) + { // Got link + $linkwd = " href='".$tp->replaceConstants($this->link_list[$first])."' "; + if ($this->ext_list[$first]) { $linkrel[] = 'external'; } // Determine external links + $lwClass[] = 'lw_link'; } - else + if (!count($lwClass)) { - $ret .= $sl; // Probably just some white space + return $this->linksproc($sl,$first+1,$limit); // Nothing to do - move on to next word (shouldn't really get here) } - } - return $ret; - } + if (count($linkrel)) + { + $linkwd .= " rel='".implode(' ',$linkrel)."'"; + } + // This splits the text into blocks, some of which will precisely contain a linkword + $split_line = preg_split('#\b('.$lw.')\b#i'.$this->utfMode, $text, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE ); // *utf (selected) + $class = "class='".implode(' ',$lwClass)."' "; + foreach ($split_line as $sl) + { + if ($tp->uStrToLower($sl) == $lw) // We know the linkword is already lower case // *utf + { // Do linkword replace + $ret .= ' '.$sl.''; + } + elseif (trim($sl)) + { // Something worthwhile left - look for more linkwords in it + $ret .= $this->linksproc($sl,$first+1,$limit); + } + else + { + $ret .= $sl; // Probably just some white space + } + } + return $ret; + } } ?> \ No newline at end of file diff --git a/e107_plugins/linkwords/languages/English.php b/e107_plugins/linkwords/languages/English.php deleted file mode 100644 index c539dc3ae..000000000 --- a/e107_plugins/linkwords/languages/English.php +++ /dev/null @@ -1,68 +0,0 @@ - \ No newline at end of file diff --git a/e107_plugins/linkwords/languages/English_admin_linkwords.php b/e107_plugins/linkwords/languages/English_admin_linkwords.php new file mode 100644 index 000000000..8ba6fa043 --- /dev/null +++ b/e107_plugins/linkwords/languages/English_admin_linkwords.php @@ -0,0 +1,114 @@ +Areas to enable
+ many areas of text have an associated \'context\', and linkwords will only be displayed in areas matching that context.

+ Linkwords Disable
+ Linkwords may be disabled on specific pages, or pages matching a pattern. Enter these here (same syntax as for menus), one pattern per line. + If the pattern ends in \'!\', this corresponds to \'end of query\', and is usually an exact match. Otherwise any URL containing the specified string will match.
+ Note that linkwords are never displayed on admin pages. + Enable Ajax Functionality
+ The tooltips can use Ajax to get information for display. This usually requires some custom coding. + '); +define('LAN_LW_HELP_02','Define the words which become clickable links, or which display text on mouseover, here

+ Word to Link
+ This is case-insensitive. For multiple words mapping to the same links and tooltips, separate them with commas (no spaces)

+ Link
+ Define a clickable link here. If its an external link, it [i]must[/i] begin \'http://\'. If its a link within this site, the normal {e_XXX} constants may be used.

+ Tooltip
+ This defines the text to be displayed when the user\'s mouse passes over the word.

+ LW ID (Tooltip ID)

+ This defines an optional numeric ID to be used with Ajax processing. If blank, the database record number is used.

+ Activate?
+ Defines which options are active. + '); + +// Admin log related +define('LAN_AL_LINKWD_00', 'Linkword-related message'); +define('LAN_AL_LINKWD_01', 'Linkword Added'); +define('LAN_AL_LINKWD_02', 'Linkword Edited'); +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 +define('LAN_AL_LINKWD_06', ''); + + + +?> \ No newline at end of file diff --git a/e107_plugins/linkwords/linkwords.php b/e107_plugins/linkwords/linkwords.php index 9ba0b6d3d..238af781e 100644 --- a/e107_plugins/linkwords/linkwords.php +++ b/e107_plugins/linkwords/linkwords.php @@ -3,7 +3,7 @@ + ----------------------------------------------------------------------------+ | e107 website system | -| Steve Dunstan 2001-2002 +| ©Steve Dunstan 2001-2002 | http://e107.org | jalist@e107.org | @@ -11,149 +11,71 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_plugins/linkwords/linkwords.php,v $ -| $Revision: 1.9 $ -| $Date: 2007-06-21 19:40:38 $ +| $Revision: 1.10 $ +| $Date: 2008-12-07 21:55:01 $ | $Author: e107steved $ | +| 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 (!plugInstalled('linkwords')) exit; class e_linkwords { - var $lw_enabled = FALSE; // Default to disabled to start - var $word_list = array(); // List of link words/phrases - var $link_list = array(); // Corresponding list of links to apply - var $tip_list = array(); - var $area_opts = array(); // Process flags for the various contexts - var $block_list = array(); // Array of 'blocked' pages - function e_linkwords() { - global $pref; + global $pref, $admin_log; /* constructor */ - // See whether they should be active on this page - if not, no point doing anything! - if ((strpos(e_SELF, ADMINDIR) !== FALSE) || (strpos(e_PAGE, "admin_") !== FALSE)) return; // No linkwords on admin directories - -// Now see if disabled on specific pages - $check_url = e_SELF.(e_QUERY ? "?".e_QUERY : ''); - $this->block_list = explode("|",substr($pref['lw_page_visibility'],2)); // Knock off the 'show/hide' flag - foreach ($this->block_list as $p) - { - if ($p=trim($p)) + // Do an auto-update on the variable used to hook parsers - so we should only be called once + @include_lan(e_PLUGIN."linkwords/languages/".e_LANGUAGE.".php"); + $hooks = explode(",",$pref['tohtml_hook']); + if (($key=array_search('linkwords',$hooks)) !== FALSE) { - if(substr($p, -1) == '!') - { - $p = substr($p, 0, -1); - if(substr($check_url, strlen($p)*-1) == $p) return; - } - else - { - if(strpos($check_url, $p) !== FALSE) return; - } + unset($hooks[$key]); } - } + if (count($hooks) == 0) + { + unset($pref['tohtml_hook']); + } + else + { + $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(); + $admin_log->log_event('LINKWD_05',LWLAN_58.'[!br!]'.$pref['tohtml_hook'],''); // Log that the update was done + return; + } - // Will probably need linkwords on this page - so get the info - $this->lw_enabled = TRUE; - $link_sql = new db; - if($link_sql -> db_Select("linkwords", "*", "linkword_active=0")) - { - while ($row = $link_sql->db_Fetch()) - { - $lw = trim(strtolower($row['linkword_word'])); - if (strpos($lw,',')) - { // Several words to same link - $lwlist = explode(',',$lw); - foreach ($lwlist as $lw) - { - $this->word_list[] = trim($lw); - $this->link_list[] = $row['linkword_link']; - } - } - else - { - $this->word_list[] = $lw; - $this->link_list[] = $row['linkword_link']; - } - } - } - if (is_array($pref['lw_context_visibility'])) - { - $this->area_opts = $pref['lw_context_visibility']; - } + + // This avoids confusing the parser! + function to_html($text,$area = 'olddefault') + { + return $text; } function linkwords($text,$area = 'olddefault') { - if (!$this->lw_enabled || !array_key_exists($area,$this->area_opts) || !$this->area_opts[$area]) return $text; // No linkwords in disabled areas - - -// Split up by HTML tags and process the odd bits here - $ptext = ""; - $lflag = FALSE; - - $content = preg_split('#(<.*?>)#mis', $text, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE ); - foreach($content as $cont) - { - if (strpos($cont, "<") !== FALSE) - { // Its some HTML - $ptext .= $cont; - if (strpos($cont,"linksproc($cont,0,count($this->word_list)); - } - else - { - $ptext .= $cont; - } - } - } - } - return $ptext; + return $text; } function linksproc($text,$first,$limit) - { // This function is called recursively - it splits the text up into blocks - some containing a particular linkword - while (($first < $limit) && (stripos($text,$this->word_list[$first]) === FALSE)) { $first++; }; - if ($first == $limit) return $text; // Return if no linkword found - - // There's at least one occurrence of the linkword in the text - $ret = ''; - $lw = $this->word_list[$first]; - // This splits the text into blocks, some of which will precisely contain a linkword - $split_line = preg_split('#\b('.$lw.')\b#i', $text, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE ); - foreach ($split_line AS $sl) - { - if (strcasecmp($sl,$lw) == 0) - { // Do linkword replace - $ret .= " {$sl}"; - } - elseif (trim($sl)) - { // Something worthwhile left - look for more linkwords in it - $ret .= $this->linksproc($sl,$first+1,$limit); - } - else - { - $ret .= $sl; // Probably just some white space - } - } - return $ret; - } + { + return $text; // Shouldn't get called - but just in case + } } ?> \ No newline at end of file diff --git a/e107_plugins/linkwords/linkwords_sql.php b/e107_plugins/linkwords/linkwords_sql.php index e621cb096..84a4eb810 100644 --- a/e107_plugins/linkwords/linkwords_sql.php +++ b/e107_plugins/linkwords/linkwords_sql.php @@ -1,7 +1,10 @@ CREATE TABLE linkwords ( -linkword_id INT(10) UNSIGNED NOT NULL auto_increment, +linkword_id int(10) UNSIGNED NOT NULL auto_increment, linkword_active tinyint(1) unsigned NOT NULL default '0', linkword_word varchar(100) NOT NULL default '', -linkword_link varchar(200) NOT NULL default '', +linkword_link varchar(250) NOT NULL default '', +linkword_tooltip text NOT NULL, +linkword_tip_id int(10) UNSIGNED NOT NULL Default '0', +linkword_newwindow tinyint(1) unsigned NOT NULL default '1', PRIMARY KEY (linkword_id) ) TYPE=MyISAM AUTO_INCREMENT=1; \ No newline at end of file diff --git a/e107_plugins/linkwords/plugin.php b/e107_plugins/linkwords/plugin.php deleted file mode 100644 index b0095ae95..000000000 --- a/e107_plugins/linkwords/plugin.php +++ /dev/null @@ -1,119 +0,0 @@ - 'linkwords' - ); -$eplug_prefs = array( - 'lw_page_visibility'=>'', - 'lw_context_visibility'=>array( - 'olddefault' => FALSE, - 'title' => FALSE, - 'summary' => TRUE, - 'body' => TRUE, - 'description' => TRUE, - 'user_title' => FALSE, - 'user_body' => TRUE, - 'linktext' => FALSE, - 'rawtext' => FALSE - ) - ); - -// List of table names ----------------------------------------------------------------------------------------------- -$eplug_table_names = array( - "linkwords" -); - -// List of sql requests to create tables ----------------------------------------------------------------------------- -$eplug_tables = array( - "CREATE TABLE ".MPREFIX."linkwords ( - linkword_id INT UNSIGNED NOT NULL auto_increment, - linkword_active tinyint(1) unsigned NOT NULL default '0', - linkword_word varchar(100) NOT NULL default '', - linkword_link varchar(150) NOT NULL default '', - PRIMARY KEY ( linkword_id ) - ) TYPE=MyISAM AUTO_INCREMENT=1;" -); - - -// Create a link in main menu (yes=TRUE, no=FALSE) ------------------------------------------------------------- -$eplug_link = FALSE; -$eplug_link_name = ""; -$ec_dir = e_PLUGIN.""; -$eplug_link_url = ""; - - -// Text to display after plugin successfully installed ------------------------------------------------------------------ -$eplug_done = LWLANINS_4; - - -// upgrading ... // - -$upgrade_add_prefs = array( - 'lw_page_visibility'=>'', - 'lw_context_visibility'=>array( - 'olddefault' => FALSE, - 'title' => FALSE, - 'summary' => TRUE, - 'body' => TRUE, - 'description' => TRUE, - 'linktext' => FALSE, - 'rawtext' => FALSE - ) -); - -$upgrade_remove_prefs = ""; - -$upgrade_alter_tables = ""; - -$eplug_upgrade_done = ""; - -?> \ No newline at end of file diff --git a/e107_plugins/linkwords/plugin.xml b/e107_plugins/linkwords/plugin.xml new file mode 100644 index 000000000..87c5cbd4f --- /dev/null +++ b/e107_plugins/linkwords/plugin.xml @@ -0,0 +1,31 @@ + + + + + This plugin will link specified words with a defined link and/or tooltip + linkwords + + + admin_config.php + images/linkwords_32.png + images/linkwords_16.png + Configure LinkWords + To configure please click on the link in the plugins section of the admin front page + + + + + + + + + + + + + + + + + + \ No newline at end of file