init(); } public function enable() { $this->lw_enabled = true; } public function cache($var) { $this->cache = (bool) $var; } public function setWordData($arr = array()) { foreach($arr as $val) { $this->word_list[] = $val['word']; $this->link_list[] = varset($val['link']); $this->ext_list[] = varset($val['ext']); $this->tip_list[] = varset($val['tip']); $this->word_limit[] = varset($val['limit']); $this->LinkID[] = varset($val['id']); } } public function setAreaOpts($arr = array()) { $this->area_opts = $arr; } public function setLink($arr) { $this->word_list = $arr; } private function loadRow($lw, $row) { $lw = trim($lw); if(empty($lw)) { return; } $frm = e107::getForm(); $this->word_list[] = $lw; $this->word_class[] = 'lw-'.$frm->name2id($lw); $this->word_limit[] = vartrue($row['linkword_limit'],3); $this->link_list[] = $row['linkword_link']; $this->tip_list[] = $row['linkword_tooltip']; $this->ext_list[] = $row['linkword_newwindow']; $this->rel_list[] = str_replace(",", ' ', $row['linkword_rel']); $this->LinkID[] = max($row['linkword_tip_id'], $row['linkword_id']); // If no specific ID defined, use the DB record ID } public function toHTML($text,$area = 'olddefault') { if(is_string($this->area_opts)) { $this->area_opts = e107::unserialize($this->area_opts); } if($this->area_opts === null) { $this->area_opts = array(); } if (!$this->lw_enabled || empty($this->area_opts) || !isset($this->area_opts[$area])) { // e107::getDebug()->log("Link words skipped on ".substr($text, 0, 50)); return $text; // No linkwords in disabled areas } // Split up by HTML tags and process the odd bits here $ptext = ""; $lflag = false; $cflag = false; // commented code prsent. // 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 ); $range = range(1,5); foreach($content as $cont) { if(strpos($cont, '-->') !== false) { $cflag = false; // end of commented code $ptext .= $cont; continue; } if ($cont[0] === "<") // Its some HTML { $ptext .= $cont; if (strpos($cont, "