當前位置: 首頁>>代碼示例>>PHP>>正文


PHP MyTextSanitizer::htmlSpecialChars方法代碼示例

本文整理匯總了PHP中MyTextSanitizer::htmlSpecialChars方法的典型用法代碼示例。如果您正苦於以下問題:PHP MyTextSanitizer::htmlSpecialChars方法的具體用法?PHP MyTextSanitizer::htmlSpecialChars怎麽用?PHP MyTextSanitizer::htmlSpecialChars使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在MyTextSanitizer的用法示例。


在下文中一共展示了MyTextSanitizer::htmlSpecialChars方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getLinkedText

		/**
		 *
		 *
		 * @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 = "/([\'\\\"`]|&quot;|&#039;)(".$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("&nbsp;&nbsp;", $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("&nbsp;&nbsp;", $text2);
					}
				}
			elseif ( !$addtext )
				{
				$text = "";
				}
//.........這裏部分代碼省略.........
開發者ID:nunoluciano,項目名稱:uxcl,代碼行數:101,代碼來源:xwords.textsanitizer.php


注:本文中的MyTextSanitizer::htmlSpecialChars方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。