本文整理汇总了PHP中eZURLAliasML::store方法的典型用法代码示例。如果您正苦于以下问题:PHP eZURLAliasML::store方法的具体用法?PHP eZURLAliasML::store怎么用?PHP eZURLAliasML::store使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZURLAliasML
的用法示例。
在下文中一共展示了eZURLAliasML::store方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: storePath
static function storePath($path, $action, $languageName = false, $linkID = false, $alwaysAvailable = false, $rootID = false, $cleanupElements = true, $autoAdjustName = false, $reportErrors = true, $aliasRedirects = true)
{
$path = eZURLAliasML::cleanURL($path);
if ($languageName === false) {
$languageName = eZContentLanguage::topPriorityLanguage();
}
if (is_object($languageName)) {
$languageObj = $languageName;
$languageID = (int) $languageName->attribute('id');
$languageName = $languageName->attribute('locale');
} else {
$languageObj = eZContentLanguage::fetchByLocale($languageName);
$languageID = (int) $languageObj->attribute('id');
}
$languageMask = $languageID;
if ($alwaysAvailable) {
$languageMask |= 1;
}
$path = eZURLAliasML::cleanURL($path);
$elements = explode('/', $path);
$db = eZDB::instance();
$parentID = 0;
// If the root ID is specified we will start the parent search from that
if ($rootID !== false) {
$parentID = $rootID;
}
$i = 0;
// Top element is handled separately.
$topElement = array_pop($elements);
// Find correct parent, and create missing ones if necessary
$createdPath = array();
foreach ($elements as $element) {
$actionStr = $db->escapeString($action);
if ($cleanupElements) {
$element = eZURLAliasML::convertToAlias($element, 'noname' . (count($createdPath) + 1));
}
$elementStr = $db->escapeString(eZURLAliasML::strtolower($element));
$query = "SELECT * FROM ezurlalias_ml WHERE text_md5 = " . eZURLAliasML::md5($db, $elementStr, false) . " AND parent = {$parentID}";
$rows = $db->arrayQuery($query);
if (count($rows) == 0) {
// Create a fake element to ensure we have a parent
$elementObj = eZURLAliasML::create($element, "nop:", $parentID, 1);
$elementObj->store();
$parentID = (int) $elementObj->attribute('id');
} else {
$parentID = (int) $rows[0]['link'];
}
$createdPath[] = $element;
++$i;
}
if ($parentID != 0) {
$sql = "SELECT text, parent FROM ezurlalias_ml WHERE id = {$parentID}";
$rows = $db->arrayQuery($sql);
if (count($rows) > 0) {
// A special case. If the special entry with empty text is used as parent
// the parent must be adjust to 0 (ie. real top level).
if (strlen($rows[0]['text']) == 0 && $rows[0]['parent'] == 0) {
$createdPath = array();
$parentID = 0;
}
}
}
if (!preg_match("#^(.+):(.+)\$#", $action, $matches)) {
return array('status' => self::ACTION_INVALID, 'error_message' => "The action value " . var_export($action, true) . " is invalid", 'error_number' => self::ACTION_INVALID, 'path' => null, 'element' => null);
}
$actionName = $matches[1];
$actionValue = $matches[2];
$existingElementID = null;
$alwaysMask = $alwaysAvailable ? 1 : 0;
$actionStr = $db->escapeString($action);
$actionTypeStr = $db->escapeString($actionName);
$createdElement = null;
if ($linkID === false) {
if ($cleanupElements) {
$topElement = eZURLAliasML::convertToAlias($topElement, 'noname' . (count($createdPath) + 1));
}
$adjustName = false;
$curElementID = null;
$newElementID = null;
$newText = $topElement;
$uniqueCounter = 0;
// Loop until we a valid entry point, which means:
// 1. The entry does not exist yet, so create a new one
// 2. The entry exists but is re-usable (e.g. nop or same action)
// 3. The entry exists and cannot be re-used, instead the name is adjusted to be unique.
while (true) {
$newText = $topElement;
if ($uniqueCounter > 0) {
$newText .= $uniqueCounter + 1;
}
$textMD5 = eZURLAliasML::md5($db, $newText);
$query = "SELECT * FROM ezurlalias_ml WHERE parent = {$parentID} AND text_md5 = {$textMD5}";
$rows = $db->arrayQuery($query);
if (count($rows) == 0) {
// No such entry, create a new one
break;
}
$row = $rows[0];
$curID = (int) $row['id'];
$curAction = $row['action'];
//.........这里部分代码省略.........