/** * * * @param string $text * @param array $glossaryterms * @param bool $html allow html? * @return string **/ function getLinkedText( $text, $glossaryterms, $html ,$addtext ) { #### matching #### $count = 0; $count = count( $glossaryterms ); if ($count > 0 && is_array($glossaryterms)) { if (!$html) { $text = parent::htmlSpecialChars( $text ); } $q_arr = array(); $parts = array(); $text2 = array(); $text3 = ""; list($spatternf,$spatterne) = explode(",",$this->getModuleConfig("spattern")); $parts = explode(">", $text); foreach($parts as $key=>$part) { for ( $i = 0; $i < $count; $i++ ) { foreach($glossaryterms[$i]['list'] as $md) { $q_arr1 = array(); $q_arr2 = array(); $q_arr3 = array(); $search_term = array(); $replace_term = $pattern = ""; $title = $md['title']; if (!$md['title']) { continue; } if (!$html) { $title = $md['title'] = parent::htmlSpecialChars( $md['title'] ); } if (!$md['image']) { $image_url = XOOPS_URL.'/images/icons/posticon2.gif'; } else { $image_url = XOOPS_URL."/modules/".$glossaryterms[$i]['mod']."/".$md['image']; } $title = '<a href="'.XOOPS_URL.'/modules/'.$glossaryterms[$i]['mod'].'/'.$md['link'].'" title="'.parent::makeTboxData4Show($this->getModuleConfig("linktermstitle")).$glossaryterms[$i]['name'].'"><img src="'.$image_url.'" width="21" height="21" alt="'.parent::makeTboxData4Show($this->getModuleConfig("linktermstitle")).$glossaryterms[$i]['name'].'" />'.$title.'</a>'; $md['title'] = preg_quote($md['title'],"/"); // if (_CHARSET =="EUC-JP") if ($spatternf && $spatterne) { // $search_term[] = $pattern = "/(\xA1[\xAE\xC6\xC8\xCC\xCE\xD0\xD2\xD4\xD6\xD8\xDA])(".$md['title'].")(\xA1[\xAD\xC7\xC9\xCD\xCF\xD1\xD3\xD5\xD7\xD9\xDB])/i"; $search_term[] = $pattern = "/($spatternf)(".$md['title'].")($spatterne)/i"; if (preg_match($pattern,$parts[$key])) { $text2[] = $title; } } if (preg_match('/^[\x20-\x7e]+$/',$md['title'])) { $md['title'] = $md['title']."|".$md['title']."s|".$md['title']."es"; $search_term[] = $pattern = "/([\'\\\"`]|"|')(".$md['title'].")(\\1)/i"; if (preg_match($pattern,$parts[$key])) { $text2[] = $title; } } if ($this->getModuleConfig("linktermsposition")) { // $replace_term = '<a href="'.XOOPS_URL.'/modules/'.$glossaryterms[$i]['mod'].'/'.$md['link'].'"><img src="'.$image_url.'" width="21" height="21" alt="'.parent::makeTboxData4Show($this->getModuleConfig("linktermstitle")).$glossaryterms[$i]['name'].'" /></a>$1$2$3'; $replace_term = '<a href="'.XOOPS_URL.'/modules/'.$glossaryterms[$i]['mod'].'/'.$md['link'].'"><img src="'.$image_url.'" width="21" height="21" alt="'.parent::makeTboxData4Show($this->getModuleConfig("linktermstitle")).$glossaryterms[$i]['name'].'" />$2</a>'; $parts[$key] = preg_replace($search_term, $replace_term, $parts[$key]); } } } } $text = implode(">", $parts); $text2 = array_unique($text2); if ( $addtext ) { $text3 = implode(" ", $text2); $text3 = ( $text3 != "" && !$this->getModuleConfig("linktermsposition")) ? "\n<p style='clear:both;margin:4em 0em 0em 0em;'>".parent::makeTboxData4Show($this->getModuleConfig("linktermstitle")).$text3."</p>" : ""; $text = $text.$text3; } else { $text = implode(" ", $text2); } } elseif ( !$addtext ) { $text = ""; } return $text; }