mirror of
https://github.com/e107inc/e107.git
synced 2025-04-21 13:11:52 +02:00
extra linkword class methods added to enable easy testing.
This commit is contained in:
parent
1c168aefa1
commit
cc8a4f8cdb
@ -53,11 +53,45 @@ 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)
|
||||
{
|
||||
$this->word_list[] = $val['word'];
|
||||
$this->link_list[] = $val['link'];
|
||||
$this->ext_list[] = $val['ext'];
|
||||
$this->tip_list[] = $val['tip'];
|
||||
$this->word_limit[] = $val['limit'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function setAreaOpts($arr = array())
|
||||
{
|
||||
$this->area_opts = $arr;
|
||||
}
|
||||
|
||||
|
||||
public function setLink($arr)
|
||||
{
|
||||
$this->word_list = $arr;
|
||||
}
|
||||
|
||||
|
||||
/* constructor */
|
||||
function __construct()
|
||||
{
|
||||
|
||||
|
||||
|
||||
$tp = e107::getParser();
|
||||
$pref = e107::pref('core');
|
||||
$frm = e107::getForm();
|
||||
@ -192,12 +226,13 @@ class e_tohtml_linkwords
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function to_html($text,$area = 'olddefault')
|
||||
{
|
||||
|
||||
|
||||
if(is_string($this->area_opts))
|
||||
{
|
||||
$this->area_opts = e107::unserialize($this->area_opts);
|
||||
@ -221,6 +256,7 @@ class e_tohtml_linkwords
|
||||
|
||||
// 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] == "<")
|
||||
@ -296,6 +332,8 @@ 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)
|
||||
@ -305,7 +343,7 @@ class e_tohtml_linkwords
|
||||
}
|
||||
else
|
||||
{
|
||||
$tooltip = " title='{$this->tip_list[$first]}' ";
|
||||
$tooltip = " title=\"{$this->tip_list[$first]}\" ";
|
||||
$lwClass[] = 'lw-tip '.$this->customClass;
|
||||
}
|
||||
}
|
||||
@ -315,7 +353,7 @@ class e_tohtml_linkwords
|
||||
$newLink = $tp->replaceConstants($this->link_list[$first], 'full');
|
||||
if ($doSamePage || ($newLink != e_SELF.'?'.e_QUERY))
|
||||
{
|
||||
$linkwd = " href='".$newLink."' ";
|
||||
$linkwd = " href=\"".$newLink."\" ";
|
||||
if ($this->ext_list[$first]) { $linkrel[] = 'external'; } // Determine external links
|
||||
$lwClass[] = 'lw-link '.$this->customClass;
|
||||
}
|
||||
@ -323,8 +361,6 @@ class e_tohtml_linkwords
|
||||
elseif(!empty($this->word_class[$first]))
|
||||
{
|
||||
$lwClass[] = $this->word_class[$first];
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (!count($lwClass))
|
||||
@ -351,19 +387,20 @@ class e_tohtml_linkwords
|
||||
foreach ($split_line as $count=>$sl)
|
||||
{
|
||||
|
||||
if ($tp->ustrtolower($sl) == $lw && $this->wordCount[$hash] < $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]++;
|
||||
|
||||
$classCount = " lw-".$this->wordCount[$hash];
|
||||
|
||||
if(empty($linkwd))
|
||||
{
|
||||
$ret .= '<span class="'.$class.$classCount.'" '.$tooltip.'>'.$sl.'</span>';
|
||||
$ret .= "<span class=\"".$class.$classCount."\" ".$tooltip.">".$sl."</span>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$ret .= '<a class="'.$class.$classCount.'" '.$linkwd.$tooltip.'>'.$sl.'</a>';
|
||||
$ret .= "<a class=\"".$class.$classCount."\" ".$linkwd.$tooltip.">".$sl."</a>";
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user