本文整理汇总了PHP中Tree::generate_list方法的典型用法代码示例。如果您正苦于以下问题:PHP Tree::generate_list方法的具体用法?PHP Tree::generate_list怎么用?PHP Tree::generate_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tree
的用法示例。
在下文中一共展示了Tree::generate_list方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Tree
/**
* Get menu from database, and generate html nested list
*
* @param int $group_id
* @param string $attr
* @return string
*/
function popoji_menu($group_id, $attr = '', $attrs = '', $attrss = '', $opt = '')
{
$tree = new Tree();
$sql = sprintf('SELECT * FROM %s WHERE group_id = %s ORDER BY %s, %s', MENU_TABLE, $group_id, MENU_PARENT, MENU_POSITION);
$menu = $this->db->GetAll($sql);
$str = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
$strlink = preg_replace("/\\/index\\.php\$/", "", $str);
foreach ($menu as $row) {
$httpdtc = substr($row[MENU_URL], 0, 7);
$httpdtcs = substr($row[MENU_URL], 0, 8);
if ($row[MENU_PARENT] == 0) {
if ($row[MENU_CLASS] == "") {
if ($httpdtc == "http://" or $httpdtcs == "https://") {
$label = '<a href="' . $row[MENU_URL] . '">';
} else {
$label = '<a href="' . $strlink . '/' . $row[MENU_URL] . '">';
}
} else {
if ($httpdtc == "http://" or $httpdtcs == "https://") {
$label = '<a ' . $attrs . ' href="' . $row[MENU_URL] . '">';
} else {
$label = '<a ' . $attrs . ' href="' . $strlink . '/' . $row[MENU_URL] . '">';
}
}
} else {
if ($row[MENU_CLASS] == "") {
if ($httpdtc == "http://" or $httpdtcs == "https://") {
$label = '<a href="' . $row[MENU_URL] . '">';
} else {
$label = '<a href="' . $strlink . '/' . $row[MENU_URL] . '">';
}
} else {
if ($httpdtc == "http://" or $httpdtcs == "https://") {
$label = '<a ' . $attrs . ' href="' . $row[MENU_URL] . '">';
} else {
$label = '<a ' . $attrs . ' href="' . $strlink . '/' . $row[MENU_URL] . '">';
}
}
}
$label .= $row[MENU_TITLE];
$label .= '</a>';
$li_attr = '';
if ($row[MENU_CLASS]) {
$li_attr = ' class="' . $row[MENU_CLASS] . '"';
}
$tree->add_row($row[MENU_ID], $row[MENU_PARENT], $li_attr, $label);
}
$menu = $tree->generate_list($attr, $attrss, $opt);
return $menu;
}
示例2: menuManager
public function menuManager($id_group = 1)
{
$db = $this->di['db']->sql(DB_DEFAULT);
$sql = sprintf('SELECT * FROM %s WHERE %s = %s ORDER BY %s, %s', MENU_TABLE, MENU_GROUP, $id_group, MENU_PARENT, MENU_POSITION);
$menu = $db->sql_fetch_yield($sql);
$data['menu_ul'] = '<ul id="easymm"></ul>';
if ($menu) {
//include _DOC_ROOT . 'includes/tree.php';
$tree = new Tree();
foreach ($menu as $row) {
$tree->add_row($row[MENU_ID], $row[MENU_PARENT], ' id="menu-' . $row[MENU_ID] . '" class="sortable"', $this->get_label($row));
}
$data['menu_ul'] = $tree->generate_list('id="easymm"');
}
$data['group_id'] = $id_group;
$data['group_title'] = $db->sql_fetch_all(sprintf('SELECT %s FROM %s WHERE %s = %s', MENUGROUP_TITLE, MENUGROUP_TABLE, MENUGROUP_ID, $id_group))[0];
$data['menu_groups'] = $db->sql_fetch_all(sprintf('SELECT %s, %s FROM %s', MENUGROUP_ID, MENUGROUP_TITLE, MENUGROUP_TABLE))[0];
return $data;
}
示例3: menumanager
/**
* Show menu manager
*/
public function menumanager()
{
$group_id = 1;
if (isset($_GET['group_id'])) {
$group_id = (int) $_GET['group_id'];
}
$menu = $this->get_menu($group_id);
$data['menu_ul'] = '<ul id="easymm"></ul>';
if ($menu) {
include '../../po-component/po-menumanager/includes/tree.php';
$tree = new Tree();
foreach ($menu as $row) {
$tree->add_row($row[MENU_ID], $row[MENU_PARENT], ' id="menu-' . $row[MENU_ID] . '" class="sortable"', $this->get_label($row));
}
$data['menu_ul'] = $tree->generate_list('id="easymm"');
}
$data['group_id'] = $group_id;
$data['group_title'] = $this->get_menu_group_title($group_id);
$data['menu_groups'] = $this->get_menu_groups();
$this->view('menu', $data);
}
示例4: actionWebsite
public function actionWebsite()
{
$group_id = 1;
if (isset($_GET['group_id'])) {
$group_id = (int) $_GET['group_id'];
}
$menu = Menu::model()->get_menu($group_id);
$data['menu_ul'] = '<ul id="easymm"></ul>';
if ($menu) {
include 'includes/tree.php';
$tree = new Tree();
foreach ($menu as $row) {
$tree->add_row($row[MENU_ID], $row[MENU_PARENT], ' id="menu-' . $row[MENU_ID] . '" class="sortable"', Menu::model()->get_label($row));
}
$data['menu_ul'] = $tree->generate_list('id="easymm"');
}
$data['group_id'] = $group_id;
$data['group_title'] = Menu::model()->get_menu_group_title($group_id);
$data['menu_groups'] = Menu::model()->get_menu_groups();
//$this->view('menu', $data);
$this->render('website', $data);
}