예제 #1
0
파일: menu.php 프로젝트: WinGood/24karcher
 /**
  * Возвращает меню в HTML виде.
  * @return type
  */
 public static function getMenu()
 {
     $menuItem = self::getArrayMenu();
     $print = '<ul class="top-menu-list">';
     foreach ($menuItem as $name => $item) {
         if ('Вход' == $item['title'] && '' != $_SESSION['User']) {
             $print .= '<li><a href=' . SITE . '"/enter">' . $_SESSION['User'] . '</a><a class="logOut" href="enter?out=1"><span style="font-size:10px">[ выйти ]</span></a></li>';
         } else {
             $item['title'] = MG::contextEditor('page', $item['title'], $item["id"], 'page');
             $print .= '<li><a href="' . $item['url'] . '">' . $item['title'] . '</a></li>';
         }
     }
     $print .= '</ul>';
     $args = func_get_args();
     return MG::createHook(__CLASS__ . "_" . __FUNCTION__, $print, $args);
 }
예제 #2
0
        ?>
">
                    <?php 
        if (!empty($category['image_url'])) {
            ?>
                      <span class="mg-cat-img">
                        <img src="<?php 
            echo SITE . $category['image_url'];
            ?>
">
                      </span>
                    <?php 
        }
        ?>
                    <?php 
        echo MG::contextEditor('category', $category['title'], $category["id"], "category");
        ?>
                    <?php 
        echo $category['insideProduct'] ? '(' . $category['insideProduct'] . ')' : '';
        ?>
                </a>

                <?php 
        if ($noUl) {
            $slider = '';
            continue;
        }
        /*?>
                        <ul class="submenu">
        
                            <?php foreach ($category['child'] as $categoryLevel1){ ?>
예제 #3
0
 /**
  * Возвращает древовидный список категорий, пригодный для использования в меню.
  *
  * @param int $parent id категории, для которой надо вернуть список.
  * @param int $type тип списка (для публичной части, либо для админки).
  * @param int $recursion использовать рекурсию.
  * @return string
  */
 public function getCategoryListUl($parent = 0, $type = 'public', $recursion = true)
 {
     // получаем данные об открытых категориях из куков
     if (empty($this->openedCategory)) {
         if ('admin' == $type) {
             $this->openedCategory = json_decode($_COOKIE['openedCategoryAdmin']);
         } else {
             $this->openedCategory = json_decode($_COOKIE['openedCategory']);
         }
         if (empty($this->openedCategory)) {
             $this->openedCategory = array();
         }
     }
     $print = '';
     if (empty($this->categories)) {
         $print = '';
     } else {
         $lang = MG::get('lang');
         $categoryArr = $this->categories;
         //для публичной части убираем из меню закрытые категории
         if ('public' == $type) {
             foreach ($categoryArr as $key => $val) {
                 if ($val['invisible'] == 1) {
                     unset($categoryArr[$key]);
                 }
             }
         }
         foreach ($categoryArr as $category) {
             if (!isset($category['id'])) {
                 break;
             }
             //если категории неceotcndetn
             if ($parent == $category['parent']) {
                 $flag = false;
                 $mover = '';
                 if ('admin' == $type) {
                     $class = 'active';
                     $title = $lang['ACT_EXPORT_CAT'];
                     if ($category['export'] == 0) {
                         $class = '';
                         $title = $lang['ACT_NOT_EXPORT_CAT'];
                     }
                     $export = '<div class="export tool-tip-bottom ' . $class . '" title="' . $title . '" data-category-id="' . $category['id'] . '"></div>';
                     $class = 'active';
                     $title = $lang['ACT_V_CAT'];
                     if ($category['invisible'] == 1) {
                         $class = '';
                         $title = $lang['ACT_UNV_CAT'];
                     }
                     $checkbox = '<input type="checkbox" name="category-check">';
                     $mover .= $checkbox . '<div class="mover"></div><div class="link-to-site tool-tip-bottom" title="' . $lang['MOVED_TO_CAT'] . '"  data-href="' . SITE . '/' . $category['parent_url'] . $category['url'] . '"></div>' . $export . '<div class="visible tool-tip-bottom ' . $class . '" title="' . $title . '" data-category-id="' . $category['id'] . '"></div>';
                 }
                 $slider = '>' . $mover . $link;
                 foreach ($this->categories as $sub_category) {
                     if ($category['id'] == $sub_category['parent']) {
                         $slider = ' class="slider">' . $mover . '<div class="slider_btn"></div>';
                         $style = "";
                         $opened = "";
                         if (in_array($category['id'], $this->openedCategory)) {
                             $opened = " opened ";
                             $style = ' style="background-position: 0 0"';
                         }
                         $slider = ' class="slider">' . $mover . '<div class="slider_btn ' . $opened . '" ' . $style . '></div>';
                         $flag = true;
                         break;
                     }
                 }
                 $rate = '';
                 if ($category['rate'] > 0) {
                     $rate = '<div class="sticker-menu discount-rate-up" data-cat-id="' . $category['id'] . '"> ' . $lang['DISCOUNT_UP'] . ' +' . $category['rate'] * 100 . '% <div class="discount-mini-control"><span class="discount-apply-follow tool-tip-bottom"  title="Применить ко всем вложенным категориям" >&darr;&darr;</span> <span class="discount-cansel tool-tip-bottom" title="Отменить">x</span></div></div>';
                 }
                 if ($category['rate'] < 0) {
                     $rate = '<div class="sticker-menu discount-rate-down" data-cat-id="' . $category['id'] . '"> ' . $lang['DISCOUNT_DOWN'] . ' ' . $category['rate'] * 100 . '% <div class="discount-mini-control"><span class="discount-apply-follow tool-tip-bottom"  title="Применить ко всем вложенным категориям">&darr;&darr;</span> <span class="discount-cansel tool-tip-bottom" title="Отменить">x</span></div></div>';
                 }
                 if ('admin' == $type) {
                     $print .= '<li' . $slider . '<a href="javascript:void(0);" onclick="return false;" class="CategoryTree" rel="CategoryTree" id="' . $category['id'] . '" parent_id="' . $category["parent"] . '">' . $category['title'] . '</a>
           ' . $rate;
                 } else {
                     if ($category['invisible'] != 1) {
                         $active = '';
                         if (URL::isSection($category['parent_url'] . $category['url'])) {
                             $active = 'class="active"';
                         }
                         $category['title'] = MG::contextEditor('category', $category['title'], $category["id"], "category");
                         $print .= '<li' . $slider . '<a href="' . SITE . '/' . $category['parent_url'] . $category['url'] . '"><span ' . $active . '>' . $category['title'] . '</span></a>';
                     }
                 }
                 if ($flag) {
                     $display = "display:none";
                     if (in_array($category['id'], $this->openedCategory)) {
                         $display = "display:block";
                     }
                     // если нужно выводить подкатегории то делаем рекурсию
                     if ($recursion) {
                         $sub_menu = '
           <ul class="sub_menu" style="' . $display . '">
             [li]
           </ul>';
                         $li = $this->getCategoryListUl($category['id'], $type);
                         $print .= strlen($li) > 0 ? str_replace('[li]', $li, $sub_menu) : "";
                     }
                     $print .= '</li>';
                 } else {
                     $print .= '</li>';
                 }
             }
         }
     }
     $args = func_get_args();
     $result = $print;
     return MG::createHook(__CLASS__ . "_" . __FUNCTION__, $result, $args);
 }
예제 #4
0
				<?php 
            }
            ?>
		
	      <?php 
        }
        ?>
		  </ul>
	  </li>
	<?php 
    } else {
        ?>
	<li class="<?php 
        echo $active;
        ?>
">
	  <a href="<?php 
        echo $page['link'];
        ?>
">
      <span><?php 
        echo MG::contextEditor('page', $page['title'], $page["id"], "page");
        ?>
</span>
    </a>
	</li>
	<?php 
    }
}
?>
</ul>
예제 #5
0
 /**
  * Возвращает древовидный список страниц, пригодный для использования в футере.
  * Вернет заданное количество списков.
  * @param int $parent id категории, для которой надо вернуть список.
  * @param int $type тип списка (для публичной части, либо для админки).
  * @return string
  */
 public function getFooterPagesUl($type = 'public', $column = 3)
 {
     $print = '';
     if (empty($this->page)) {
         $print = '';
     } else {
         $lang = MG::get('lang');
         $gategoryArr = $this->page;
         //для публичной части убираем из меню закрытые страницы
         foreach ($gategoryArr as $key => $val) {
             if ($val['invisible'] == 1) {
                 unset($gategoryArr[$key]);
             }
         }
         $countPage = 0;
         foreach ($gategoryArr as $page) {
             if ($page['parent'] == 0) {
                 $countPage++;
             }
         }
         if ($countPage > 1) {
             $inColumn = floor($countPage / $column);
         }
         $newColumn = true;
         $i = 0;
         foreach ($gategoryArr as $page) {
             if ($page['parent'] == 0) {
                 if ($newColumn == true) {
                     if ($i > 0) {
                         $i = 0;
                         $print .= "</ul><ul class='footer-column'>";
                     } else {
                         $i = 0;
                         $print .= "<ul class='footer-column'>";
                     }
                 }
                 if ($i < $inColumn) {
                     $newColumn = false;
                     $i++;
                 } else {
                     $newColumn = true;
                 }
                 $hotFix1 = false;
                 if ($page['parent_url'] == "" && ($page['url'] == 'index' || $page['url'] == 'index.html')) {
                     $hotFix1 = true;
                 }
                 if ($page['invisible'] != 1) {
                     $active = '';
                     if (URL::isSection($page['parent_url'] . $page['url'])) {
                         $active = 'class="active"';
                     }
                     $page['title'] = MG::contextEditor('page', $page['title'], $page["id"], "page");
                     if (strpos($page['url'], 'http://') === false) {
                         $url = SITE . '/' . $page['parent_url'] . $page['url'];
                     } else {
                         $url = $page['url'];
                     }
                     if ($hotFix1) {
                         $print .= '<li><a href="' . SITE . '"><span ' . $active . '>' . $page['title'] . '</span></a>';
                     } else {
                         $print .= '<li><a href="' . $url . '"><span ' . $active . '>' . $page['title'] . '</span></a>';
                     }
                 }
             }
         }
         $print .= "</ul>";
     }
     $args = func_get_args();
     $result = $print;
     return MG::createHook(__CLASS__ . "_" . __FUNCTION__, $result, $args);
 }