本文整理汇总了PHP中common::Parents方法的典型用法代码示例。如果您正苦于以下问题:PHP common::Parents方法的具体用法?PHP common::Parents怎么用?PHP common::Parents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common
的用法示例。
在下文中一共展示了common::Parents方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check_parent_another
function check_parent_another($menu)
{
global $page;
$title = common::Parents($page->gp_index, $menu);
if (array_key_exists(0, $title)) {
return $title[0];
} else {
return false;
}
}
示例2: IsProtected
function IsProtected($index)
{
global $gp_menu;
if (isset($this->config['pages'][$index])) {
$this->is_protected = true;
return 1;
}
$parents = common::Parents($index, $gp_menu);
foreach ($parents as $parent_index) {
if (isset($this->config['pages'][$parent_index])) {
$this->is_protected = true;
$this->parent_protected = true;
return 2;
}
}
return false;
}
示例3: ParentConfig
/**
* Traverse the main menu upwards looking for a configuration setting for $var
* Start at the title represented by $checkId
* Set $value to the configuration setting if a parent page has the configuration setting
*
* @return bool
*/
static function ParentConfig($checkId, $var, &$value)
{
global $gp_titles, $gp_menu;
$parents = common::Parents($checkId, $gp_menu);
foreach ($parents as $parent_index) {
if (!empty($gp_titles[$parent_index][$var])) {
$value = $gp_titles[$parent_index][$var];
return true;
}
}
return false;
}
示例4: OutputMenu
/**
* Output a navigation menu
* @static
*/
static function OutputMenu($menu, $start_level, $source_menu = false)
{
global $page, $gp_menu, $gp_titles, $GP_MENU_LINKS, $GP_MENU_CLASS, $GP_MENU_CLASSES;
//source menu
if ($source_menu === false) {
$source_menu =& $gp_menu;
}
self::PrepMenuOutput();
$clean_attributes = array('attr' => '', 'class' => array(), 'id' => '');
$clean_attributes_a = array('href' => '', 'attr' => '', 'value' => '', 'title' => '', 'class' => array());
// opening ul
$attributes_ul = $clean_attributes;
$attributes_ul['class']['menu_top'] = $GP_MENU_CLASSES['menu_top'];
if (self::$edit_area_id) {
$attributes_ul['id'] = self::$edit_area_id;
$attributes_ul['class']['editable_area'] = 'editable_area';
}
if (!count($menu)) {
//$attributes_ul['class']['empty_menu'] = 'empty_menu';
//self::FormatMenuElement('div',$attributes_ul).'</div>'; //an empty <ul> is not valid xhtml
return;
}
$prev_level = $start_level;
$page_title_full = common::GetUrl($page->title);
$open = false;
$li_count = array();
//get parent page
$parent_page = false;
$parents = common::Parents($page->gp_index, $source_menu);
if (count($parents)) {
$parent_page = $parents[0];
}
//output
self::FormatMenuElement('ul', $attributes_ul);
$menu = array_keys($menu);
foreach ($menu as $menu_index => $menu_key) {
$menu_info = $source_menu[$menu_key];
$this_level = $menu_info['level'];
//the next entry
$next_info = false;
$next_index = $menu_index + 1;
if (array_key_exists($next_index, $menu)) {
$next_index = $menu[$next_index];
$next_info = $source_menu[$next_index];
}
$attributes_a = $clean_attributes_a;
$attributes_li = $attributes_ul = $clean_attributes;
//ordered or "indexed" classes
if ($page->menu_css_ordered) {
for ($i = $prev_level; $i > $this_level; $i--) {
unset($li_count[$i]);
}
if (!isset($li_count[$this_level])) {
$li_count[$this_level] = 0;
} else {
$li_count[$this_level]++;
}
if (!empty($GP_MENU_CLASSES['li_'])) {
$attributes_li['class']['li_'] = $GP_MENU_CLASSES['li_'] . $li_count[$this_level];
}
}
if ($page->menu_css_indexed && !empty($GP_MENU_CLASSES['li_title_'])) {
$attributes_li['class']['li_title_'] = $GP_MENU_CLASSES['li_title_'] . $menu_key;
}
//selected classes
if ($this_level < $next_info['level']) {
$attributes_a['class']['haschildren'] = $GP_MENU_CLASSES['haschildren'];
$attributes_li['class']['haschildren_li'] = $GP_MENU_CLASSES['haschildren_li'];
}
if (isset($menu_info['url']) && ($menu_info['url'] == $page->title || $menu_info['url'] == $page_title_full)) {
$attributes_a['class']['selected'] = $GP_MENU_CLASSES['selected'];
$attributes_li['class']['selected_li'] = $GP_MENU_CLASSES['selected_li'];
} elseif ($menu_key == $page->gp_index) {
$attributes_a['class']['selected'] = $GP_MENU_CLASSES['selected'];
$attributes_li['class']['selected_li'] = $GP_MENU_CLASSES['selected_li'];
} elseif (in_array($menu_key, $parents)) {
$attributes_a['class']['childselected'] = $GP_MENU_CLASSES['childselected'];
$attributes_li['class']['childselected_li'] = $GP_MENU_CLASSES['childselected_li'];
}
//current is a child of the previous
if ($this_level > $prev_level) {
if ($menu_index === 0) {
//only needed if the menu starts below the start_level
self::FormatMenuElement('li', $attributes_li);
}
if (!empty($GP_MENU_CLASSES['child_ul'])) {
$attributes_ul['class'][] = $GP_MENU_CLASSES['child_ul'];
}
if ($this_level > $prev_level) {
$open_loops = $this_level - $prev_level;
for ($i = 0; $i < $open_loops; $i++) {
self::FormatMenuElement('ul', $attributes_ul);
if ($i < $open_loops - 1) {
echo '<li>';
}
$prev_level++;
//.........这里部分代码省略.........
示例5: OutputMenu
/**
* Output a navigation menu
* @static
*/
function OutputMenu($menu, $start_level, $source_menu = false)
{
global $page, $GP_MENU_LINKS, $GP_MENU_CLASS, $gp_menu, $gp_titles;
if ($source_menu === false) {
$source_menu =& $gp_menu;
}
$search = array('{$href_text}', '{$attr}', '{$label}', '{$title}');
$replace = array();
if (count($menu) == 0) {
echo '<div class="emtpy_menu"></div>';
//an empty <ul> is not valid xhtml
gpOutput::ResetMenuGlobals();
return;
}
//$GP_MENU_LINKS = '<a href="{$href_text}" {$attr}><span class="sub-t">{$label}</span></a>';
//<a href="/rocky/index.php/Misson_&_Principles" title="Misson & Principles" >Misson & Principles</a>
$link_format = '<a href="{$href_text}" title="{$title}"{$attr}>{$label}</a>';
if (!empty($GP_MENU_LINKS)) {
$link_format = $GP_MENU_LINKS;
}
$result = array();
$prev_level = $start_level;
$page_title_full = common::GetUrl($page->title);
$source_keys = array_keys($source_menu);
$source_values = array_values($source_menu);
$open = false;
$li_count = array();
//get parent page
$parent_page = false;
$parents = common::Parents($page->gp_index, $source_menu);
if (count($parents)) {
$parent_page = $parents[0];
}
$class = 'menu_top';
if (!empty($GP_MENU_CLASS)) {
$class = $GP_MENU_CLASS;
}
$result[] = '<ul class="' . $class . '">';
foreach ($source_keys as $source_index => $menu_key) {
$attr = $class = $attr_li = $class_li = '';
$menu_info = $source_values[$source_index];
$this_level = $menu_info['level'];
//the next entry
$next_info = false;
if (isset($source_values[$source_index + 1])) {
$next_info = $source_values[$source_index + 1];
}
//create link if in $menu
if (isset($menu[$menu_key])) {
//ordered or "indexed" classes
if ($page->menu_css_ordered) {
for ($i = $prev_level; $i > $this_level; $i--) {
unset($li_count[$i]);
}
if (!isset($li_count[$this_level])) {
$li_count[$this_level] = 0;
} else {
$li_count[$this_level]++;
}
$class_li = 'li_' . $li_count[$this_level];
}
if ($page->menu_css_indexed) {
$class_li .= ' li_title_' . $menu_key;
}
//selected classes
if ($this_level < $next_info['level']) {
$class .= ' haschildren';
}
if (isset($menu_info['url']) && ($menu_info['url'] == $page->title || $menu_info['url'] == $page_title_full)) {
$class .= ' selected';
$class_li .= ' selected_li';
} elseif ($menu_key == $page->gp_index) {
$class .= ' selected';
$class_li .= ' selected_li';
} elseif (in_array($menu_key, $parents)) {
$class .= ' childselected';
$class_li .= ' childselected_li';
}
if (!empty($class)) {
$attr = ' class="' . trim($class) . '"';
}
if (!empty($class_li)) {
$attr_li = ' class="' . trim($class_li) . '"';
}
//current is a child of the previous
if ($this_level > $prev_level) {
if (!$open) {
$result[] = '<li' . $attr_li . '>';
//only needed if the menu starts below the start_level
}
while ($this_level > $prev_level) {
$result[] = '<ul>';
$result[] = '<li>';
$prev_level++;
}
array_pop($result);
//.........这里部分代码省略.........
示例6: VisibilityClass
/**
* Get the css class representing the current page's visibility
*
*/
function VisibilityClass($class, $index)
{
global $gp_menu, $gp_titles;
if (isset($gp_titles[$index]['vis'])) {
$class .= ' private-list';
return $class;
}
$parents = common::Parents($index, $gp_menu);
foreach ($parents as $parent_index) {
if (isset($gp_titles[$parent_index]['vis'])) {
$class .= ' private-inherited';
break;
}
}
return $class;
}