Пример #1
0
        $i++;
    }
}
/** hiển thị nestable */
function nestable($args_menu, $parent = 0)
{
    foreach ($args_menu as $menu_item) {
        $id = $menu_item->id;
        $menu_name = get_men_val(array('name' => 'menu_name', 'id' => $id));
        $menu_class = get_men_val(array('name' => 'menu_class', 'id' => $id));
        $menu_attr = get_men_val(array('name' => 'menu_attr', 'id' => $id));
        $menu_icon = get_men_val(array('name' => 'menu_icon', 'id' => $id));
        $menu_request_uri = get_men_val(array('name' => 'menu_request_uri', 'id' => $id));
        ?>
	
	<li class="dd-item" data-id="<?php 
        echo $id;
        ?>
">
	
		<div data-id="<?php 
        echo $id;
        ?>
" class="dd-handle">
			<span><?php 
        echo $menu_name;
        ?>
</span>
		</div>
			
		<form data-id="<?php 
        echo $id;
        ?>
" action="?run=menu_ajax.php&id=<?php 
        echo $id;
        ?>
&action=edit_item" method="post" class="ajaxForm ajaxFormmenuEditItem">
			
			<div class="dd-handle-btn" data-id="<?php 
        echo $id;
        ?>
">
				<i class="fa fa-cog"></i>
			</div>
			<div class="dd-option-panel" data-id="<?php 
        echo $id;
        ?>
">
				<div class="row">
					<div class="col-md-6">
						<?php 
        $field_array = array('nice_name' => _('Nhãn Điều Hướng'), 'name' => 'menu_name', 'input_type' => 'text', 'placeholder' => _('Bạn có thể đặt lại tên theo ý mình'), 'default_value' => $menu_name, 'handle' => FALSE);
        build_input_form($field_array);
        ?>
					</div>
					<div class="col-md-6">
						<?php 
        $field_array = array('nice_name' => _('Lớp CSS'), 'name' => 'menu_class', 'input_type' => 'text', 'placeholder' => _('Thêm class CSS để tùy biến tốt hơn'), 'default_value' => $menu_class, 'handle' => FALSE);
        build_input_form($field_array);
        ?>
					</div>
				</div>
				<div class="row">
					<div class="col-md-6">
						<?php 
        $field_array = array('nice_name' => _('Thuộc tính tùy chỉnh'), 'name' => 'menu_attr', 'input_type' => 'text', 'placeholder' => _('Ví dụ : onclick=&quot;dropdown_menu()&quot;'), 'default_value' => $menu_attr, 'handle' => FALSE);
        build_input_form($field_array);
        ?>
					</div>
					<div class="col-md-6">
						<?php 
        $field_array = array('name' => 'menu_icon', 'label' => 'Chọn biểu tượng', 'imageonly' => TRUE);
        media_file_input($field_array);
        ?>
					</div>
					<div class="col-md-12">
						<?php 
        if (is_numeric($menu_request_uri)) {
Пример #2
0
     return $this->get_menu($args);
 }
 /** Hiển thị 1 menu */
 public function get_menu($args = array())
 {
     /** kiếm tra và add giá trị mặc định */
     if (isset($args['parent'])) {
         $parent = $args['parent'];
     } else {
         $parent = FALSE;
     }
     if (isset($args['wrapper'])) {
         $wrapper = $args['wrapper'];
     } else {
         $wrapper = 'ul';
     }
     if (isset($args['wrapper_class'])) {
         $wrapper_class = $args['wrapper_class'];
     } else {
         $wrapper_class = FALSE;
     }
     if (isset($args['wrapper_id'])) {
         $wrapper_id = $args['wrapper_id'];
     } else {
         $wrapper_id = FALSE;
     }
     if (isset($args['item'])) {
         $item = $args['item'];
     } else {
         $item = 'li';
     }
     if (isset($args['item_class'])) {
         $item_class = $args['item_class'];
     } else {
         $item_class = '';
     }
     if (isset($args['item_id'])) {
         $item_id = $args['item_id'];
     } else {
         $item_id = '';
     }
     if (isset($args['permalink_class'])) {
         $permalink_class = $args['permalink_class'];
     } else {
         $permalink_class = '';
     }
     if (isset($args['permalink_attr'])) {
         $permalink_attr = $args['permalink_attr'];
     } else {
         $permalink_attr = '';
     }
     if (isset($args['permalink_before'])) {
         $permalink_before = $args['permalink_before'];
     } else {
         $permalink_before = '';
     }
     if (isset($args['permalink_after'])) {
         $permalink_after = $args['permalink_after'];
     } else {
         $permalink_after = '';
     }
     if (isset($args['echo'])) {
         $echo = $args['echo'];
     } else {
         $echo = TRUE;
     }
     $name = $args['name'];
     if (is_numeric($parent)) {
         $menu_id = $parent;
     } else {
         $menu_id = get_option('section=theme_setting&key=' . $name);
     }
     $output_html = '';
     /** wrapper_class */
     if ($wrapper_class) {
         $wrapper_class = ' class="' . $wrapper_class . '"';
     }
     /** wrapper_id */
     if ($wrapper_id) {
         $wrapper_id = ' id="' . $wrapper_id . '"';
     }
     /** open wrapper */
     $output_html .= '<' . $wrapper . $wrapper_class . $wrapper_id . '>' . "\n";
     /** load menu item */
     $tableName = DB_PREFIX . "object";
     $whereArray = array('parent' => MySQL::SQLValue($menu_id), 'key' => MySQL::SQLValue('menu_item'));
     $this->SelectRows($tableName, $whereArray, NULL, 'order_number', 'ASC');
     while ($row = $this->Row()) {
         $menu_item[] = $row;
     }
     /** menu item */
     foreach ($menu_item as $this_menu_item) {
         $id = $this_menu_item->id;
         $menu_name = get_men_val(array('name' => 'menu_name', 'id' => $id));
         $menu_class = get_men_val(array('name' => 'menu_class', 'id' => $id));
         $menu_attr = get_men_val(array('name' => 'menu_attr', 'id' => $id));
         $menu_icon = get_men_val(array('name' => 'menu_icon', 'id' => $id));
         $menu_request_uri = get_men_val(array('name' => 'menu_request_uri', 'id' => $id));
         if ($menu_attr != '') {
             $menu_attr = ' ' . $menu_attr;
         }
         if ($menu_class != '') {
             $menu_class = ' ' . $menu_class;
         }
         /** item href */
         if (is_numeric($menu_request_uri)) {
             $data_uri = get_uri_data("id={$menu_request_uri}");
             $href = SITE_URL . FOLDER_PATH . $data_uri->uri;
             $object_type = $data_uri->object_type;
             $object_id = $data_uri->object_id;
             $menu_request_uri_html = ' href="' . $href . '"';
             $data_object_html = ' data-' . $object_type . '="' . $object_id . '"';
         } else {
             $menu_request_uri_html = ' href="#"';
             $data_object_html = '';
             $object_type = FALSE;
             $object_id = FALSE;
         }
         /** item_class */
         $in_page_class = '';
         if (is_taxonomy()) {
             $current_uri = get_current_uri();
             $data_current_uri = get_uri_data("uri={$current_uri}");
             $current_object_id = $data_current_uri->object_id;
             if ($object_type == 'taxonomy' and $object_id == $current_object_id) {
                 $in_page_class = ' current_page';
             }
         }
         if ($item_class) {
             $item_class_html = ' class="' . $item_class . $in_page_class . ' menu-' . $id . '"';
         } else {
             $item_class_html = ' class="menu-' . $id . $in_page_class . '"';
         }
         /** item_id */
         if ($item_id) {
             $item_id_html = ' id="' . $item_id . ' menu-' . $id . '"';
         } else {
             $item_id_html = ' id="menu-' . $id . '"';
         }
         /** open item */
         $output_html .= '<' . $item . $item_class_html . $item_id_html . $data_object_html . '>' . "\n";
         /** permalink before */
         $output_html .= $permalink_before;
         /** permalink_class */
         if ($permalink_class) {
             $permalink_class_html = ' class="' . $permalink_class . $menu_class . '"';
         } else {
             $permalink_class_html = '';
         }
         /** permalink */
         $output_html .= '<a' . $menu_request_uri_html . $menu_attr . $permalink_class_html . '>' . $menu_name . '</a>' . "\n";
         /** permalink after */
         $output_html .= $permalink_after;
         /** sub menu */
         if ($this->has_sub_menu($id)) {
             $args['parent'] = $id;
             $args['echo'] = FALSE;
             $args['wrapper_class'] = 'sub-menu';
             $args['wrapper_id'] = '';
             $output_html .= $this->get_menu($args);
         }
         /** close item */
         $output_html .= '</' . $item . '>' . "\n";
     }
     /** close wrapper */
     $output_html .= '</' . $wrapper . '>' . "\n";
     if ($echo == TRUE) {
         echo $output_html;
     } else {
         return $output_html;