本文整理汇总了PHP中Search::updateIndex方法的典型用法代码示例。如果您正苦于以下问题:PHP Search::updateIndex方法的具体用法?PHP Search::updateIndex怎么用?PHP Search::updateIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Search
的用法示例。
在下文中一共展示了Search::updateIndex方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parsePages
//.........这里部分代码省略.........
$arrElements = explode(',', $intElmntId);
$objElements = Element::selectByPK($arrElements);
$intParent = $objElements->current()->getParentId();
foreach ($objElements as $objElement) {
$objElement->delete();
}
} else {
//*** Single element submitted.
$objElement = Element::selectByPK($intElmntId);
$intParent = $objElement->getParentId();
$objElement->delete();
}
//*** Redirect the page.
$strReturnTo = request('returnTo');
if (empty($strReturnTo)) {
header("Location: " . Request::getUri() . "/?cid=" . request("cid") . "&cmd=" . CMD_LIST . "&eid=" . $intParent);
exit;
} else {
header("Location: " . Request::getURI() . $strReturnTo);
exit;
}
break;
case CMD_DUPLICATE:
if (strpos($intElmntId, ',') !== false) {
//*** Multiple elements submitted.
$arrElements = explode(',', $intElmntId);
$objElements = Element::selectByPK($arrElements);
$intParent = $objElements->current()->getParentId();
foreach ($objElements as $objElement) {
$objElement->setUsername($objLiveUser->getProperty("name"));
$objDuplicate = $objElement->duplicate($objLang->get("copyOf", "label"));
//*** Update the search index.
$objSearch = new Search();
$objSearch->updateIndex($objDuplicate->getId());
}
} else {
//*** Single element submitted.
$objElement = Element::selectByPK($intElmntId);
$intParent = $objElement->getParentId();
$objElement->setUsername($objLiveUser->getProperty("name"));
$objDuplicate = $objElement->duplicate($objLang->get("copyOf", "label"));
//*** Update the search index.
$objSearch = new Search();
$objSearch->updateIndex($objDuplicate->getId());
}
//*** Redirect the page.
$strReturnTo = request('returnTo');
if (empty($strReturnTo)) {
header("Location: " . Request::getURI() . "/?cid=" . request("cid") . "&cmd=" . CMD_LIST . "&eid=" . $intParent);
exit;
} else {
header("Location: " . Request::getURI() . $strReturnTo);
exit;
}
break;
case CMD_ACTIVATE:
case CMD_DEACTIVATE:
if (strpos($intElmntId, ',') !== false) {
//*** Multiple elements submitted.
$arrElements = explode(',', $intElmntId);
$objElements = Element::selectByPK($arrElements);
$intParent = $objElements->current()->getParentId();
foreach ($objElements as $objElement) {
if ($strCommand == CMD_ACTIVATE) {
$objElement->setActive(1);
} else {
示例2: split
* O R T S T E I L S E A R C H
* ********************************************************************* */
$sql = "SELECT ot.id AS id,ot.stadtteil_name AS stadtteil_name,box2d(ot.geom) AS bbox" . ",st_dimension(ot.geom) AS dimension FROM " . SCHEMA . ".standortsuche ot WHERE ot.stadtteil_name IS NOT NULL;";
$result = pg_query($conn, $sql);
$num = 0;
while ($row = pg_fetch_assoc($result)) {
if ($row["bbox"] === null) {
continue;
}
if ($row["dimension"] == 0 and strpos($row["bbox"], "BOX") === 0) {
$tmp = split(",", substr($row["bbox"], 4, -1));
$row["geom"] = "BOX(" . $tmp[0] . "," . $tmp[0] . ")";
} else {
$row["geom"] = $row["bbox"];
}
$search->updateIndex($row["stadtteil_name"], array("type" => "Ortsteil", "stadtteil_name" => $row["stadtteil_name"], "geom" => $row["geom"]));
$num++;
}
echo "<br/><br/>Tables :" . SCHEMA . "standortsuche";
echo "<br/>Rows all :" . pg_num_rows($result);
echo "<br/>Rows accepted :" . $num;
echo "<br/>Last error : " . pg_last_error();
/* * *********************************************************************
* S T R A S S E S E A R C H
* ********************************************************************* */
$sql = "SELECT s.id, s.strasse_name, s.zusatz" . ",box2d(s.geom) AS bbox, st_dimension(s.geom) AS dimension FROM " . SCHEMA . ".standortsuche s WHERE s.strasse_name IS NOT NULL";
$result = pg_query($conn, $sql);
$num = 0;
while ($row = pg_fetch_assoc($result)) {
if ($row["bbox"] === null) {
continue;
示例3: parseSearch
function parseSearch($intElmntId, $strCommand)
{
global $_PATHS, $objLang, $DBAConn;
$objTpl = new HTML_Template_IT($_PATHS['templates']);
$objTpl->loadTemplatefile("search.tpl.htm");
$objTpl->setVariable("TITLE", $objLang->get("pageTitle"));
$objTpl->setVariable("MAINTITLE", $objLang->get("pcmsSearch", "menu"));
$objTpl->setVariable("BUTTON_INDEX_HREF", "?cid=" . NAV_PCMS_SEARCH . "&cmd=" . CMD_BUILD_INDEX);
$objTpl->setVariable("BUTTON_INDEX", $objLang->get("searchIndex", "button"));
$objTpl->setVariable("SEARCH_BUTTON", $objLang->get("search", "button"));
$objTpl->setVariable("SEARCH_ALL", $objLang->get("searchall", "label"));
//*** Perform query if submitted.
$objSearch = new Search();
$strQuery = request('query');
$strExact = request('search_all');
$strCache = request('cache');
$intPosition = request("pos");
$blnExact = false;
$blnCache = false;
if ($strExact == 'on') {
$blnExact = true;
}
if ($strCache == 'true') {
$blnCache = true;
}
if ($strCommand == CMD_BUILD_INDEX) {
//*** Rebuild search index.
set_time_limit(60 * 60);
$objSearch->clearIndex();
$objSearch->updateIndex();
$objTpl->setVariable("SEARCH_DESCRIPTION", $objLang->get("searchIndexed", "form"));
}
if (!empty($strQuery)) {
$objResults = $objSearch->find($strQuery, $blnExact);
//*** Cache results in the current session.
$_SESSION["searchresult"] = serialize($objResults);
} else {
if ($blnCache && isset($_SESSION["searchresult"]) && is_object(unserialize($_SESSION["searchresult"]))) {
$objResults = unserialize($_SESSION["searchresult"]);
}
}
if (isset($objResults) && is_object($objResults)) {
$objTpl->setVariable("RESULT_LABEL", $objLang->get("searchresult", "label"));
$objTpl->setVariable("SEARCH_STRING", $objResults->getQuery());
if ($objResults->count() > 0) {
$listCount = 0;
$intPosition = !empty($intPosition) && is_numeric($intPosition) ? $intPosition : 0;
$intPosition = floor($intPosition / $_SESSION["listCount"]) * $_SESSION["listCount"];
$objResults->seek($intPosition);
//*** Render results.
foreach ($objResults as $objResult) {
$objElement = Element::selectByPK($objResult->id);
if (is_object($objElement)) {
$strPath = "<b>" . $objLang->get("path", "label") . "</b>" . Element::recursivePath($objElement->getParentId());
} else {
$strPath = "";
}
$objTpl->setCurrentBlock("searchresult");
$objTpl->setVariable("EID", $objResult->id);
$objTpl->setVariable("CID", NAV_PCMS_ELEMENTS);
$objTpl->setVariable("CMD", CMD_EDIT);
$objTpl->setVariable("RESULT_NAME", $objResult->name);
$objTpl->setVariable("RESULT_RATIO", $objResult->ratio);
$strValue = strip_tags($objResult->value);
if (!empty($strValue)) {
$objTpl->setVariable("RESULT_VALUE", $strValue);
}
if (!empty($strPath)) {
$objTpl->setVariable("RESULT_PATH", $strPath);
}
$objTpl->parseCurrentBlock();
}
//*** Render page navigation.
$pageCount = ceil($objResults->count() / $_SESSION["listCount"]);
if ($pageCount > 0) {
$currentPage = ceil(($intPosition + 1) / $_SESSION["listCount"]);
$previousPos = $intPosition - $_SESSION["listCount"] > 0 ? $intPosition - $_SESSION["listCount"] : 0;
$nextPos = $intPosition + $_SESSION["listCount"] < $objResults->count() ? $intPosition + $_SESSION["listCount"] : $intPosition;
$objTpl->setVariable("PAGENAV_PAGE", sprintf($objLang->get("pageNavigation", "label"), $currentPage, $pageCount));
$objTpl->setVariable("PAGENAV_PREVIOUS", $objLang->get("previous", "button"));
$objTpl->setVariable("PAGENAV_PREVIOUS_HREF", "?cid=" . NAV_PCMS_SEARCH . "&pos={$previousPos}&cache=true");
$objTpl->setVariable("PAGENAV_NEXT", $objLang->get("next", "button"));
$objTpl->setVariable("PAGENAV_NEXT_HREF", "?cid=" . NAV_PCMS_SEARCH . "&pos={$nextPos}&cache=true");
//*** Bottom page navigation.
for ($intCount = 0; $intCount < $pageCount; $intCount++) {
$objTpl->setCurrentBlock("pagenavitem");
$position = $intCount * $_SESSION["listCount"];
if ($intCount != $intPosition / $_SESSION["listCount"]) {
$objTpl->setVariable("PAGENAV_HREF", "href=\"?cid=" . NAV_PCMS_SEARCH . "&pos={$position}&cache=true\"");
}
$objTpl->setVariable("PAGENAV_VALUE", $intCount + 1);
$objTpl->parseCurrentBlock();
}
}
} else {
$objTpl->setCurrentBlock("searchresult");
$objTpl->setVariable("RESULT_VALUE", $objLang->get("search_noresult", "label"));
$objTpl->parseCurrentBlock();
}
}
//.........这里部分代码省略.........
示例4: importElements
//.........这里部分代码省略.........
$objValue->setCascade($languageNode->getAttribute("cascade"));
$objField->setValueObject($objValue);
$arrActiveLangs[$languageNode->getAttribute("id")] = $languageNode->getAttribute("active");
if (preg_match($strElmntPattern, $languageNode->nodeValue) > 0) {
array_push($arrElementFieldIds["largeText"], $objField->getId());
}
if (preg_match($strStoragePattern, $languageNode->nodeValue) > 0) {
array_push($arrElementFieldIds["largeText"], $objField->getId());
}
}
if (in_array($fieldNode->getAttribute("templateFieldId"), $arrLinkFieldIds)) {
array_push($arrElementFieldIds["link"], $objField->getId());
}
break;
}
}
foreach ($arrActiveLangs as $key => $value) {
$objElement->setLanguageActive($arrLanguageIds[$key], $value);
}
break;
case "feed":
foreach ($subNode->childNodes as $feedFieldNode) {
if ($feedFieldNode->nodeName == "feedfield") {
$objFeedField = new ElementFieldFeed();
$objFeedField->setElementId($objElement->getId());
$objFeedField->setTemplateFieldId($arrTemplateFieldIds[$feedFieldNode->getAttribute("templateFieldId")]);
$objFeedField->setFeedPath($feedFieldNode->getAttribute("feedPath"));
$objFeedField->setXpath($feedFieldNode->getAttribute("xpath"));
$objFeedField->setLanguageId($arrLanguageIds[$feedFieldNode->getAttribute("languageId")]);
$objFeedField->setCascade($feedFieldNode->getAttribute("cascade"));
$objFeedField->setSort($feedFieldNode->getAttribute("sort"));
$objFeedField->save();
}
}
$objFeed = new ElementFeed();
$objFeed->setElementId($objElement->getId());
$objFeed->setFeedId($arrFeedIds[$subNode->getAttribute("feedId")]);
$objFeed->setFeedPath($subNode->getAttribute("feedPath"));
$objFeed->setMaxItems($subNode->getAttribute("maxItems"));
$objFeed->setSortBy($subNode->getAttribute("sortBy"));
$objFeed->setAliasField($subNode->getAttribute("aliasField"));
$objFeed->save();
break;
case "meta":
$arrMetaFields = array("title", "keywords", "description");
foreach ($subNode->childNodes as $metaFieldNode) {
if ($metaFieldNode->nodeName == "language") {
$intLanguageId = $arrLanguageIds[$metaFieldNode->getAttribute("id")];
foreach ($arrMetaFields as $value) {
$objMeta = new ElementMeta();
$objMeta->setName($value);
$objMeta->setValue($metaFieldNode->getAttribute($value));
$objMeta->setLanguageId($intLanguageId);
$objMeta->setCascade(0);
$objElement->setMeta($objMeta);
}
}
}
break;
case "languages":
foreach ($subNode->childNodes as $languageNode) {
$objLanguage = new ElementLanguage();
$objLanguage->setElementId($objElement->getId());
$objLanguage->setLanguageId($arrLanguageIds[$languageNode->getAttribute("id")]);
$objLanguage->setActive($languageNode->getAttribute("active"));
$objLanguage->setCascade($languageNode->getAttribute("cascade"));
$objLanguage->save();
}
break;
case "permissions":
$objUsers = array();
$objTempUsers = explode(",", $subNode->getAttribute("users"));
foreach ($objTempUsers as $value) {
if (array_key_exists($value, $arrUserIds)) {
array_push($objUsers, $arrUserIds[$value]);
}
}
$objGroups = array();
$objTempGroups = explode(",", $subNode->getAttribute("groups"));
foreach ($objTempGroups as $value) {
if (array_key_exists($value, $arrGroupIds)) {
array_push($objGroups, $arrGroupIds[$value]);
}
}
$objPermissions = new ElementPermission();
$objPermissions->setUserId($objUsers);
$objPermissions->setGroupId($objGroups);
$objElement->setPermissions($objPermissions, true);
break;
case "elements":
self::importElements($subNode, $intAccountId, $arrTemplateIds, $arrTemplateFieldIds, $arrElementIds, $arrElementFieldIds, $arrLinkFieldIds, $arrLanguageIds, $arrUserIds, $arrGroupIds, $arrStorageIds, $arrFeedIds, $objElement->getId());
break;
}
}
//*** Update the search index.
$objSearch = new Search();
$objSearch->updateIndex($objElement->getId());
}
}
}