本文整理汇总了PHP中eZURLAliasML::generateCond方法的典型用法代码示例。如果您正苦于以下问题:PHP eZURLAliasML::generateCond方法的具体用法?PHP eZURLAliasML::generateCond怎么用?PHP eZURLAliasML::generateCond使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZURLAliasML
的用法示例。
在下文中一共展示了eZURLAliasML::generateCond方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetchByPath
public static function fetchByPath($uriString, $glob = false)
{
$uriString = eZURLAliasML::cleanURL($uriString);
$db = eZDB::instance();
if ($uriString == '' && $glob !== false) {
$elements = array();
} else {
$elements = explode('/', $uriString);
}
$len = count($elements);
$i = 0;
$selects = array();
$tables = array();
$conds = array();
$prevTable = false;
foreach ($elements as $element) {
$table = "e" . $i;
$langMask = trim(eZContentLanguage::languagesSQLFilter($table, 'lang_mask'));
if ($glob === false && $i == $len - 1) {
$selects[] = eZURLAliasML::generateFullSelect($table);
} else {
$selects[] = eZURLAliasML::generateSelect($table, $i, $len);
}
$tables[] = "ezurlalias_ml " . $table;
$conds[] = eZURLAliasML::generateCond($table, $prevTable, $i, $langMask, $element);
$prevTable = $table;
++$i;
}
if ($glob !== false) {
++$len;
$table = "e" . $i;
$langMask = trim(eZContentLanguage::languagesSQLFilter($table, 'lang_mask'));
$selects[] = eZURLAliasML::generateFullSelect($table);
$tables[] = "ezurlalias_ml " . $table;
$conds[] = eZURLAliasML::generateGlobCond($table, $prevTable, $i, $langMask, $glob);
$prevTable = $table;
++$i;
}
$elementOffset = $i - 1;
$query = "SELECT DISTINCT " . join(", ", $selects) . " FROM " . join(", ", $tables) . " WHERE " . join(" AND ", $conds);
$pathRows = $db->arrayQuery($query);
$elements = array();
if (count($pathRows) > 0) {
foreach ($pathRows as $pathRow) {
$redirectLink = false;
$table = "e" . $elementOffset;
$element = array('id' => $pathRow[$table . "_id"], 'parent' => $pathRow[$table . "_parent"], 'lang_mask' => $pathRow[$table . "_lang_mask"], 'text' => $pathRow[$table . "_text"], 'action' => $pathRow[$table . "_action"], 'link' => $pathRow[$table . "_link"]);
$path = array();
$lastID = false;
for ($i = 0; $i < $len; ++$i) {
$table = "e" . $i;
$id = $pathRow[$table . "_id"];
$link = $pathRow[$table . "_link"];
$path[] = $pathRow[$table . "_text"];
if ($link != $id) {
// Mark the redirect link
$redirectLink = $link;
$redirectOffset = $i;
}
$lastID = $link;
}
if ($redirectLink) {
$newLinkID = $redirectLink;
// Resolve new links until a real element is found.
// TODO: Add max redirection count?
while ($newLinkID) {
$query = "SELECT id, parent, lang_mask, text, link FROM ezurlalias_ml WHERE id={$newLinkID}";
$rows = $db->arrayQuery($query);
if (count($rows) == 0) {
return false;
}
$newLinkID = false;
if ($rows[0]['id'] != $rows[0]['link']) {
$newLinkID = (int) $rows[0]['link'];
}
}
$id = (int) $newLinkID;
$path = array();
// Fetch path 'text' elements of correct parent path
while ($id != 0) {
$query = "SELECT parent, lang_mask, text FROM ezurlalias_ml WHERE id={$id}";
$rows = $db->arrayQuery($query);
if (count($rows) == 0) {
break;
}
$result = eZURLAliasML::choosePrioritizedRow($rows);
if (!$result) {
$result = $rows[0];
}
$id = (int) $result['parent'];
array_unshift($path, $result['text']);
}
// Fill in end of path elements
for ($i = $redirectOffset; $i < $len; ++$i) {
$table = "e" . $i;
$path[] = $pathRow[$table . "_text"];
}
}
$element['path'] = implode('/', $path);
$elements[] = $element;
//.........这里部分代码省略.........