当前位置: 首页>>代码示例>>PHP>>正文


PHP tags_prepare函数代码示例

本文整理汇总了PHP中tags_prepare函数的典型用法代码示例。如果您正苦于以下问题:PHP tags_prepare函数的具体用法?PHP tags_prepare怎么用?PHP tags_prepare使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了tags_prepare函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: CSearchStatistic

 function CSearchStatistic($phrase = "", $tags = "")
 {
     $phrase = ToLower(trim($phrase, " \t\n\r"));
     if ($l = strlen($phrase)) {
         if ($l > 250) {
             $p = strrpos($phrase, ' ');
             if ($p === false) {
                 $this->_phrase = substr($phrase, 0, 250);
             } else {
                 $this->_phrase = substr($phrase, 0, $p);
             }
         } else {
             $this->_phrase = $phrase;
         }
     } else {
         $this->_phrase = false;
     }
     $arTags = tags_prepare($tags);
     if (count($arTags)) {
         asort($arTags);
         $this->_tags = implode(", ", $arTags);
     } else {
         $this->_tags = false;
     }
     $this->_session_id = bitrix_sessid();
     if (isset($_SESSION["SESS_SESSION_ID"])) {
         $this->_stat_sess_id = intval($_SESSION["SESS_SESSION_ID"]);
     }
 }
开发者ID:spas-viktor,项目名称:books,代码行数:29,代码来源:statistic.php

示例2: TagsIndex

 function TagsIndex($arLID, $ID, $sContent)
 {
     $DB = CDatabase::GetModuleConnection('search');
     $ID = intval($ID);
     if (!is_array($arLID)) {
         $arLID = array();
     }
     $sContent = str_replace("", "", $sContent);
     foreach ($arLID as $site_id => $url) {
         $sql_site_id = $DB->ForSQL($site_id);
         $arTags = tags_prepare($sContent, $site_id);
         if (!empty($arTags)) {
             $strSqlPrefix = "\n\t\t\t\t\t\tinsert ignore into b_search_tags\n\t\t\t\t\t\t(SEARCH_CONTENT_ID, SITE_ID, NAME)\n\t\t\t\t\t\tvalues\n\t\t\t\t";
             $maxValuesLen = 2048;
             $strSqlValues = "";
             CSearchTags::CleanCache($arTags);
             foreach ($arTags as $tag) {
                 $strSqlValues .= ",\n(" . $ID . ", '" . $sql_site_id . "', '" . $DB->ForSql($tag, 255) . "')";
                 if (strlen($strSqlValues) > $maxValuesLen) {
                     $DB->Query($strSqlPrefix . substr($strSqlValues, 2), false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
                     $strSqlValues = "";
                 }
             }
             if (strlen($strSqlValues) > 0) {
                 $DB->Query($strSqlPrefix . substr($strSqlValues, 2), false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
                 $strSqlValues = "";
             }
         }
     }
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:30,代码来源:search.php

示例3: CheckFields

 function CheckFields(&$arFields, $ID = false, $bCheckDiskQuota = true)
 {
     global $DB, $APPLICATION, $USER;
     $this->LAST_ERROR = "";
     $APPLICATION->ResetException();
     if ($ID === false) {
         $db_events = GetModuleEvents("iblock", "OnStartIBlockElementAdd", true);
     } else {
         $arFields["ID"] = $ID;
         $db_events = GetModuleEvents("iblock", "OnStartIBlockElementUpdate", true);
     }
     foreach ($db_events as $arEvent) {
         $bEventRes = ExecuteModuleEventEx($arEvent, array(&$arFields));
         if ($bEventRes === false) {
             break;
         }
     }
     if (($ID === false || is_set($arFields, "NAME")) && strlen($arFields["NAME"]) <= 0) {
         $this->LAST_ERROR .= GetMessage("IBLOCK_BAD_ELEMENT_NAME") . "<br>";
     }
     if (isset($arFields["ACTIVE_FROM"]) && $arFields["ACTIVE_FROM"] != '' && !$DB->IsDate($arFields["ACTIVE_FROM"], false, LANG, "FULL")) {
         $this->LAST_ERROR .= GetMessage("IBLOCK_BAD_ACTIVE_FROM") . "<br>";
     }
     if (isset($arFields["ACTIVE_TO"]) && $arFields["ACTIVE_TO"] != '' && !$DB->IsDate($arFields["ACTIVE_TO"], false, LANG, "FULL")) {
         $this->LAST_ERROR .= GetMessage("IBLOCK_BAD_ACTIVE_TO") . "<br>";
     }
     if (is_set($arFields, "PREVIEW_PICTURE")) {
         if (is_array($arFields["PREVIEW_PICTURE"]) && array_key_exists("bucket", $arFields["PREVIEW_PICTURE"]) && is_object($arFields["PREVIEW_PICTURE"]["bucket"])) {
             //This is trusted image from xml import
         } elseif (is_array($arFields["PREVIEW_PICTURE"])) {
             $error = CFile::CheckImageFile($arFields["PREVIEW_PICTURE"]);
             if (strlen($error) > 0) {
                 $this->LAST_ERROR .= $error . "<br>";
             } elseif (($error = CFile::checkForDb($arFields, "PREVIEW_PICTURE")) !== "") {
                 $this->LAST_ERROR .= GetMessage("IBLOCK_ERR_PREVIEW_PICTURE") . "<br>" . $error . "<br>";
             }
         } elseif (intval($arFields["PREVIEW_PICTURE"]) > 0) {
             if (intval($arFields["WF_PARENT_ELEMENT_ID"]) <= 0 || CIBlockElement::DeleteFile($arFields["PREVIEW_PICTURE"], $ID, "PREVIEW", intval($arFields["WF_PARENT_ELEMENT_ID"]), $arFields["IBLOCK_ID"], true) <= 0) {
                 $this->LAST_ERROR .= GetMessage("IBLOCK_ERR_PREVIEW_PICTURE") . "<br>";
             }
         }
     }
     if (is_set($arFields, "DETAIL_PICTURE")) {
         if (is_array($arFields["DETAIL_PICTURE"]) && array_key_exists("bucket", $arFields["DETAIL_PICTURE"]) && is_object($arFields["DETAIL_PICTURE"]["bucket"])) {
             //This is trusted image from xml import
         } elseif (is_array($arFields["DETAIL_PICTURE"])) {
             $error = CFile::CheckImageFile($arFields["DETAIL_PICTURE"]);
             if (strlen($error) > 0) {
                 $this->LAST_ERROR .= $error . "<br>";
             } elseif (($error = CFile::checkForDb($arFields, "DETAIL_PICTURE")) !== "") {
                 $this->LAST_ERROR .= GetMessage("IBLOCK_ERR_DETAIL_PICTURE") . "<br>" . $error . "<br>";
             }
         } elseif (intval($arFields["DETAIL_PICTURE"]) > 0) {
             if (intval($arFields["WF_PARENT_ELEMENT_ID"]) <= 0 || CIBlockElement::DeleteFile($arFields["DETAIL_PICTURE"], $ID, "DETAIL", intval($arFields["WF_PARENT_ELEMENT_ID"]), $arFields["IBLOCK_ID"], true) <= 0) {
                 $this->LAST_ERROR .= GetMessage("IBLOCK_ERR_DETAIL_PICTURE") . "<br>";
             }
         }
     }
     if (array_key_exists("TAGS", $arFields) && CModule::IncludeModule('search')) {
         $arFields["TAGS"] = implode(", ", tags_prepare($arFields["TAGS"]));
     }
     if ($ID === false && !is_set($arFields, "IBLOCK_ID")) {
         $this->LAST_ERROR .= GetMessage("IBLOCK_BAD_BLOCK_ID") . "<br>";
     }
     if ($ID !== false && is_set($arFields, "XML_ID") && strlen($arFields["XML_ID"]) <= 0) {
         $this->LAST_ERROR .= GetMessage("IBLOCK_BAD_EXTERNAL_CODE") . "<br>";
     }
     //Find out IBLOCK_ID from fields or from element
     $IBLOCK_ID = intval($arFields["IBLOCK_ID"]);
     if ($IBLOCK_ID <= 0) {
         $IBLOCK_ID = 0;
         $res = $DB->Query("SELECT IBLOCK_ID FROM b_iblock_element WHERE ID=" . IntVal($ID));
         if ($ar = $res->Fetch()) {
             $IBLOCK_ID = (int) $ar["IBLOCK_ID"];
         }
     }
     //Read iblock metadata
     static $IBLOCK_CACHE = array();
     if (!isset($IBLOCK_CACHE[$IBLOCK_ID])) {
         if ($IBLOCK_ID > 0) {
             $IBLOCK_CACHE[$IBLOCK_ID] = CIBlock::GetArrayByID($IBLOCK_ID);
         } else {
             $IBLOCK_CACHE[$IBLOCK_ID] = false;
         }
     }
     if ($IBLOCK_CACHE[$IBLOCK_ID]) {
         $arFields["IBLOCK_ID"] = $IBLOCK_ID;
     } else {
         $this->LAST_ERROR .= GetMessage("IBLOCK_BAD_BLOCK_ID") . "<br>";
     }
     if (is_set($arFields, 'IBLOCK_SECTION') && !empty($arFields['IBLOCK_SECTION'])) {
         if (!is_array($arFields['IBLOCK_SECTION'])) {
             $arFields['IBLOCK_SECTION'] = array($arFields['IBLOCK_SECTION']);
         }
         $arFields['IBLOCK_SECTION'] = array_filter($arFields['IBLOCK_SECTION']);
     }
     if ($IBLOCK_CACHE[$IBLOCK_ID]) {
         $ar = $IBLOCK_CACHE[$IBLOCK_ID]["FIELDS"];
         if (is_array($ar)) {
             $WF_PARENT_ELEMENT_ID = isset($arFields["WF_PARENT_ELEMENT_ID"]) ? intval($arFields["WF_PARENT_ELEMENT_ID"]) : 0;
//.........这里部分代码省略.........
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:iblockelement.php

示例4: Fetch

	function Fetch()
	{
		static $arSite = array();

		$r = parent::Fetch();

		if ($r && $this->formatter)
		{
			$r = $this->formatter->format($r);
			if (!$r)
				return $this->Fetch();
		}

		if ($r)
		{
			$site_id = $r["SITE_ID"];
			if(!isset($arSite[$site_id]))
			{
				$b = "sort";
				$o = "asc";
				$rsSite = CSite::GetList($b, $o, array("ID"=>$site_id));
				$arSite[$site_id] = $rsSite->Fetch();
			}
			$r["DIR"] = $arSite[$site_id]["DIR"];
			$r["SERVER_NAME"] = $arSite[$site_id]["SERVER_NAME"];

			if(strlen($r["SITE_URL"])>0)
				$r["URL"] = $r["SITE_URL"];

			if(substr($r["URL"], 0, 1)=="=")
			{
				foreach (GetModuleEvents("search", "OnSearchGetURL", true) as $arEvent)
					$r["URL"] = ExecuteModuleEventEx($arEvent, array($r));
			}

			$r["URL"] = str_replace(
				array("#LANG#", "#SITE_DIR#", "#SERVER_NAME#"),
				array($r["DIR"], $r["DIR"], $r["SERVER_NAME"]),
				$r["URL"]
			);
			$r["URL"] = preg_replace("'(?<!:)/+'s", "/", $r["URL"]);
			$r["URL_WO_PARAMS"] = $r["URL"];

			$w = $this->Query->m_words;
			if(count($this->url_add_params))
			{
				$p1 = strpos($r["URL"], "?");
				if($p1 === false)
					$ch = "?";
				else
					$ch = "&";

				$p2 = strpos($r["URL"], "#", $p1);
				if($p2===false)
				{
					$r["URL"] = $r["URL"].$ch.implode("&", $this->url_add_params);
				}
				else
				{
					$r["URL"] = substr($r["URL"], 0, $p2).$ch.implode("&", $this->url_add_params).substr($r["URL"], $p2);
				}
			}

			if (!array_key_exists("TITLE_FORMATED", $r) && array_key_exists("TITLE", $r))
			{
				$r["TITLE_FORMATED"] = $this->PrepareSearchResult(htmlspecialcharsex($r["TITLE"]));
				$r["TITLE_FORMATED_TYPE"] = "html";
				$r["TAGS_FORMATED"] = tags_prepare($r["TAGS"], SITE_ID);
				$r["BODY_FORMATED"] = $this->PrepareSearchResult(htmlspecialcharsex($r["BODY"]));
				$r["BODY_FORMATED_TYPE"] = "html";
			}
		}

		return $r;
	}
开发者ID:nycmic,项目名称:bittest,代码行数:75,代码来源:search.php

示例5: elseif

         if ($arParams["SECTION_ID"] != $_REQUEST["TO_SECTION_ID"]) {
             CIBlockElement::RecalcSections($arParams["SECTION_ID"]);
             CIBlockElement::RecalcSections($_REQUEST["TO_SECTION_ID"]);
         }
         if ($arParams["AJAX_CALL"] != "Y") {
         } elseif ($arParams["SECTION_ID"] != $_REQUEST["TO_SECTION_ID"]) {
             $result = array("SECTION_ID" => intVal($_REQUEST["TO_SECTION_ID"]), "url" => CComponentEngine::MakePathFromTemplate($arParams["~DETAIL_URL"], array("USER_ALIAS" => $arParams["USER_ALIAS"], "SECTION_ID" => $_REQUEST["TO_SECTION_ID"], "ELEMENT_ID" => $arResult["ELEMENT"]["ID"])));
         } else {
             $arSelect = array("ID", "NAME", "DETAIL_TEXT", "DETAIL_TEXT_TYPE", "TAGS", "DATE_CREATE", "CREATED_BY", "PROPERTY_PUBLIC_ELEMENT", "PROPERTY_APPROVE_ELEMENT");
             $db_res = CIBlockElement::GetList(array(), array("ID" => $arParams["ELEMENT_ID"]), false, false, $arSelect);
             if ($db_res && ($res = $db_res->GetNext())) {
                 $result = array("SECTION_ID" => intVal($_REQUEST["TO_SECTION_ID"]), "TAGS" => $res["TAGS"], "TITLE" => $res["NAME"], "DESCRIPTION" => $res["DETAIL_TEXT"], "_DESCRIPTION" => $res["~DETAIL_TEXT"], "PUBLIC" => $res["PROPERTY_PUBLIC_ELEMENT_VALUE"], "APPROVED" => $res["PROPERTY_APPROVE_ELEMENT_VALUE"], "DATE" => $res["DATE_CREATE"], "DATE_STR" => FormatDate('x', MakeTimeStamp($res["DATE_CREATE"], CSite::GetDateFormat())));
                 //TAGS
                 $result["TAGS_LIST"] = array();
                 if (!empty($result["TAGS"]) && $bParseTags) {
                     $ar = tags_prepare($result["TAGS"], SITE_ID);
                     if (!empty($ar)) {
                         foreach ($ar as $name => $tags) {
                             $arr = array("TAG_NAME" => $tags, "TAG_URL" => CComponentEngine::MakePathFromTemplate($arParams["~SEARCH_URL"], array()));
                             $arr["TAG_URL"] .= (strpos($arr["TAG_URL"], "?") === false ? "?" : "&") . "tags=" . $tags;
                             $result["TAGS_LIST"][] = $arr;
                         }
                     }
                 }
             } else {
                 $result = array("SECTION_ID" => intVal($_REQUEST["TO_SECTION_ID"]), "TAGS" => htmlspecialcharsEx($_REQUEST["TAGS"]), "TITLE" => htmlspecialcharsEx($_REQUEST["TITLE"]), "DESCRIPTION" => htmlspecialcharsEx($_REQUEST["DESCRIPTION"]), "_DESCRIPTION" => htmlspecialcharsEx($_REQUEST["DESCRIPTION"]), "DATE_STR" => FormatDate('x', MakeTimeStamp($_REQUEST["DATE_CREATE"], CSite::GetDateFormat())));
             }
         }
         $arResult["URL"] = CComponentEngine::MakePathFromTemplate($arParams["~DETAIL_URL"], array("USER_ALIAS" => $arParams["USER_ALIAS"], "SECTION_ID" => $_REQUEST["TO_SECTION_ID"], "ELEMENT_ID" => $arResult["ELEMENT"]["ID"]));
     }
 }
开发者ID:webgksupport,项目名称:alpina,代码行数:31,代码来源:component.php

示例6: formatRow

	function formatRow($r)
	{
		$DB = CDatabase::GetModuleConnection('search');
		$rs = $DB->Query("
			select
				sc.ID
				,sc.MODULE_ID
				,sc.ITEM_ID
				,sc.TITLE
				,sc.TAGS
				,sc.BODY
				,sc.PARAM1
				,sc.PARAM2
				,sc.UPD
				,sc.DATE_FROM
				,sc.DATE_TO
				,sc.URL
				,sc.CUSTOM_RANK
				,".$DB->DateToCharFunction("sc.DATE_CHANGE")." as FULL_DATE_CHANGE
				,".$DB->DateToCharFunction("sc.DATE_CHANGE", "SHORT")." as DATE_CHANGE
				,scsite.SITE_ID
				,scsite.URL SITE_URL
				".(BX_SEARCH_VERSION > 1? ",sc.USER_ID": "")."
			from b_search_content sc
			INNER JOIN b_search_content_site scsite ON sc.ID=scsite.SEARCH_CONTENT_ID
			where ID = ".$r["id"]."
			and scsite.SITE_ID = '".$DB->ForSql($this->sphinx->SITE_ID)."'
		");
		$r = $rs->Fetch();
		if ($r)
		{
			$r["TITLE_FORMATED"] = $this->buildExcerpts(htmlspecialcharsex($r["TITLE"]));
			$r["TITLE_FORMATED_TYPE"] = "html";
			$r["TAGS_FORMATED"] = tags_prepare($r["TAGS"], SITE_ID);
			$r["BODY_FORMATED"] = $this->buildExcerpts(htmlspecialcharsex($r["BODY"]));
			$r["BODY_FORMATED_TYPE"] = "html";
		}
		return $r;
	}
开发者ID:nycmic,项目名称:bittest,代码行数:39,代码来源:sphinx.php

示例7: GetList


//.........这里部分代码省略.........
                 $arQuerySelect["FULL_DATE_CHANGE"] = $DB->DateToCharFunction("MAX(sc.DATE_CHANGE)", "FULL") . " as FULL_DATE_CHANGE";
                 $arQuerySelect["DATE_CHANGE"] = $DB->DateToCharFunction("MAX(sc.DATE_CHANGE)", "SHORT") . " as DATE_CHANGE";
                 $bJoinSearchContent = true;
                 break;
         }
     }
     $arQueryWhere = array();
     if (!is_array($arFilter)) {
         $arFilter = array("TAG" => $arFilter, "SITE_ID" => array(SITE_ID));
     }
     if (empty($arFilter["SITE_ID"]) && array_key_exists("TAG", $arFilter)) {
         $arFilter["SITE_ID"] = array(SITE_ID);
     }
     if (array_key_exists("SITE_ID", $arFilter) && !is_array($arFilter["SITE_ID"])) {
         $arFilter["SITE_ID"] = array($arFilter["SITE_ID"]);
     }
     $strTag = "";
     foreach ($arFilter as $key => $value) {
         $key = strtoupper($key);
         switch ($key) {
             case "SITE_ID":
                 $arSites = array();
                 foreach ($value as $site_id) {
                     $arSites[$DB->ForSql($site_id, 2)] = true;
                 }
                 $arSites = array_keys($arSites);
                 if (count($arSites) == 1) {
                     $arQueryWhere[] = "stags.SITE_ID = '" . $arSites[0] . "'";
                 } elseif (count($arSites) > 1) {
                     $arQueryWhere[] = "stags.SITE_ID in ('" . implode("', '", $arSites) . "')";
                 }
                 break;
             case "TAG":
                 $arTags = tags_prepare($value, $arFilter["SITE_ID"][0]);
                 if (count($arTags) > 0) {
                     $strTag = array_pop($arTags);
                     $arQueryWhere[] = "UPPER(stags.NAME) LIKE '" . $DB->ForSql(ToUpper($strTag)) . "%'";
                 }
                 break;
             case "MODULE_ID":
             case "PARAM1":
             case "PARAM2":
                 $arQueryWhere[] = "sc." . $key . " ='" . $DB->ForSql($value) . "'";
                 $bJoinSearchContent = true;
                 break;
             case "PARAMS":
                 if (is_array($value)) {
                     foreach ($value as $p_key => $p_val) {
                         if (is_array($p_val)) {
                             foreach ($p_val as $i => $val2) {
                                 $p_val[$i] = $DB->ForSQL($val2);
                             }
                             $p_where = " in ('" . implode("', '", $p_val) . "')";
                         } else {
                             $p_where = " = '" . $DB->ForSQL($p_val) . "'";
                         }
                         $arQueryWhere[] = "EXISTS (SELECT * FROM b_search_content_param WHERE SEARCH_CONTENT_ID = stags.SEARCH_CONTENT_ID AND PARAM_NAME = '" . $DB->ForSQL($p_key) . "' AND PARAM_VALUE " . $p_where . ")";
                     }
                 }
                 break;
             default:
                 if (!is_array($arFilterEvents)) {
                     $arFilterEvents = GetModuleEvents("search", "OnSearchPrepareFilter", true);
                 }
                 //Try to get someone to make the filter sql
                 foreach ($arFilterEvents as $arEvent) {
开发者ID:andy-profi,项目名称:bxApiDocs,代码行数:67,代码来源:tags.php


注:本文中的tags_prepare函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。