1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-21 13:11:52 +02:00

Fixes #4704 - "Suppress link on current page" preference was failing.

This commit is contained in:
Cameron 2022-03-15 16:38:31 -07:00
parent 3d3b2ec85d
commit e7839c203c
3 changed files with 12 additions and 11 deletions

View File

@ -86,8 +86,8 @@ class linkwords_ui extends e_admin_ui
protected $prefs = array(
'lw_context_visibility' => array('title' => LWLAN_26, 'type' => 'checkboxes', 'help' => LAN_LW_HELP_01),
'lw_ajax_enable' => array('title' => LWLAN_59, 'type' => 'boolean', 'data' => 'string', 'help' => LAN_LW_HELP_02),
'lw_notsamepage' => array('title' => LWLAN_64, 'type' => 'boolean', 'data' => 'string', 'help' => LAN_LW_HELP_03),
'lw_ajax_enable' => array('title' => LWLAN_59, 'type' => 'boolean', 'data' => 'int', 'help' => LAN_LW_HELP_02),
'lw_notsamepage' => array('title' => LWLAN_64, 'type' => 'boolean', 'data' => 'int', 'help' => LAN_LW_HELP_03),
'linkword_omit_pages' => array('title' => LWLAN_28, 'type' => 'textarea', 'data' => 'string', 'help' => LAN_LW_HELP_04),
'lw_custom_class' => array('title' => LWLAN_66, 'type' => 'text', 'writeParms' => array('placeholder' => LAN_OPTIONAL), 'data' => 'string', 'help' => LAN_LW_HELP_05),

View File

@ -19,6 +19,7 @@ class linkwords_parse
protected $lwAjaxEnabled = FALSE; // Adds in Ajax-compatible links
protected $utfMode = ''; // Flag to enable utf-8 on regex
protected $cache = true;
protected $suppressSamePageLink = false;
protected $word_list = array(); // List of link words/phrases
private $link_list = array(); // Corresponding list of links to apply
@ -82,10 +83,11 @@ class linkwords_parse
$frm = e107::getForm();
// $this->maxPerWord = vartrue($pref['lw_max_per_word'], 25);
$this->customClass = vartrue($pref['lw_custom_class']);
$this->area_opts = (array) varset($pref['lw_context_visibility']);
$this->utfMode = (strtolower(CHARSET) === 'utf-8') ? 'u' : '';
$this->lwAjaxEnabled = varset($pref['lw_ajax_enable'],0);
$this->customClass = vartrue($pref['lw_custom_class']);
$this->area_opts = (array) varset($pref['lw_context_visibility']);
$this->utfMode = (strtolower(CHARSET) === 'utf-8') ? 'u' : '';
$this->lwAjaxEnabled = varset($pref['lw_ajax_enable'],0);
$this->suppressSamePageLink = (bool) vartrue($pref['lw_notsamepage'], false);
// See whether they should be active on this page - if not, no point doing anything!
if(e_ADMIN_AREA === true && empty($_POST['runLinkwordTest']))
@ -232,7 +234,7 @@ class linkwords_parse
// Split up by HTML tags and process the odd bits here
$ptext = "";
$lflag = FALSE;
$lflag = false;
$cflag = false; // commented code prsent.
// Shouldn't need utf-8 on next line - just looking for HTML tags
@ -306,8 +308,6 @@ class linkwords_parse
function linksproc($text,$first,$limit)
{
$tp = e107::getParser();
$doSamePage = !e107::getPref('lw_notsamepage');
for (; $first < $limit; $first ++)
{
@ -351,7 +351,8 @@ class linkwords_parse
if ($this->link_list[$first]) // Got link
{
$newLink = $tp->replaceConstants($this->link_list[$first], 'full');
if ($doSamePage || ($newLink != e_SELF.'?'.e_QUERY))
if (!$this->suppressSamePageLink || (($newLink !== e_REQUEST_URL) && $newLink !== e_REQUEST_URI))
{
$linkwd = " href=\"".$newLink."\" ";

View File

@ -80,7 +80,7 @@ define("LWLAN_67", "Max. links/tips");
// Preferences
define("LAN_LW_HELP_01", "Many areas of text have an associated 'context', and linkwords will only be displayed in areas matching that context.");
define("LAN_LW_HELP_02", "The tooltips can use Ajax to get information for display. This usually requires some custom coding.");
define("LAN_LW_HELP_03", "Usually its pointless for the user to be able to click a link if they're already on the page that it links to. When this option is turned off, the linkwords are not triggered in this case.");
define("LAN_LW_HELP_03", "Usually its pointless for the user to be able to click a link if they're already on the page that it links to. When this option is turned ON, the linkwords are not triggered in this case.");
define("LAN_LW_HELP_04", "Linkwords may be disabled on specific pages, or pages matching a pattern. Enter these here (same syntax as for menu visbility), 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.");
define("LAN_LW_HELP_05", "Will add this class to all generated links.");
// Reserve numbers for further prefences help texts