本文整理匯總了PHP中CMenu::IsItemSelected方法的典型用法代碼示例。如果您正苦於以下問題:PHP CMenu::IsItemSelected方法的具體用法?PHP CMenu::IsItemSelected怎麽用?PHP CMenu::IsItemSelected使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CMenu
的用法示例。
在下文中一共展示了CMenu::IsItemSelected方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _SetSelectedItems
function _SetSelectedItems(&$arResult, $bMultiSelect = false)
{
/** @global CMain $APPLICATION */
global $APPLICATION;
$cur_page = $APPLICATION->GetCurPage(true);
$cur_page_no_index = $APPLICATION->GetCurPage(false);
$cur_selected = -1;
$cur_selected_len = -1;
foreach ($arResult as $iMenuItem => $MenuItem) {
$LINK = $MenuItem['LINK'];
$ADDITIONAL_LINKS = $MenuItem['ADDITIONAL_LINKS'];
$SELECTED = false;
$all_links = array();
if (is_array($ADDITIONAL_LINKS)) {
foreach ($ADDITIONAL_LINKS as $link) {
$tested_link = trim($link);
if (strlen($tested_link) > 0) {
$all_links[] = $tested_link;
}
}
}
$all_links[] = $LINK;
if ($MenuItem['PERMISSION'] != 'Z') {
foreach ($all_links as $tested_link) {
if ($tested_link == '') {
continue;
}
$SELECTED = CMenu::IsItemSelected($tested_link, $cur_page, $cur_page_no_index);
if ($SELECTED) {
$arResult[$iMenuItem]['SELECTED'] = true;
break;
}
}
}
if ($SELECTED && !$bMultiSelect) {
/** @noinspection PhpUndefinedVariableInspection */
$new_len = strlen($tested_link);
if ($new_len > $cur_selected_len) {
if ($cur_selected !== -1) {
$arResult[$cur_selected]['SELECTED'] = false;
}
$cur_selected = $iMenuItem;
$cur_selected_len = $new_len;
} elseif ($new_len > 1) {
$arResult[$iMenuItem]['SELECTED'] = false;
}
}
}
}