_menu.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. use_javascript('prototype.js');
  3. $menu = array();
  4. if ('katao' == $sf_request->getParameter('module') && in_array($sf_request->getParameter('action'), array('suppliers', 'supplierDetails', 'supplierProducts'))) {
  5. $katao_supplier_url = $sf_request->getParameter('supplier');
  6. $katao_supplier_ids = array();
  7. $katao_product_category_active = true;
  8. foreach (KataoSupplierPeer::getAllVisibleByCategory() as $katao_product_category => $katao_suppliers) {
  9. $katao_product_category_suppliers = array();
  10. foreach ($katao_suppliers as $katao_supplier) {
  11. if (KataoUser::STATUS_ACTIVE == $katao_supplier['status']) {
  12. $katao_product_category_suppliers[] = array('title' => $katao_supplier['name'], 'url' => url_for('@katao_fournisseurs_details?supplier=' . $katao_supplier['url']), 'active' => $katao_supplier_url == $katao_supplier['url']);
  13. $katao_supplier_ids[$katao_supplier['id']] = true;
  14. }
  15. }
  16. if (0 < $katao_product_category_suppliers) {
  17. $active = false;
  18. foreach ($katao_product_category_suppliers as $katao_supplier_data) {
  19. $active |= !empty($katao_supplier_data['active']);
  20. }
  21. $menu[] = array('title' => $katao_product_category, 'url' => false, 'active' => $katao_product_category_active && $active, 'suppliers' => $katao_product_category_suppliers);
  22. if ($katao_product_category_active && $active) {
  23. $katao_product_category_active = false;
  24. }
  25. }
  26. }
  27. foreach (KataoSupplierPeer::getAllVisible() as $katao_supplier) {
  28. if (KataoUser::STATUS_ACTIVE == $katao_supplier['status'] && empty($katao_supplier_ids[$katao_supplier['id']])) {
  29. $menu[] = array('title' => $katao_supplier['name'], 'url' => url_for('@katao_fournisseurs_details?supplier=' . $katao_supplier['url']), 'active' => $katao_supplier_url == $katao_supplier['url']);
  30. }
  31. }
  32. } elseif ('' != $katao_product_category_url = $sf_request->getParameter('category')) {
  33. $katao_product_family_url = $sf_request->getParameter('family');
  34. foreach (KataoProductFamilyPeer::getAllByProductCategoryUrlIdentifier($katao_product_category_url) as $katao_product_family) {
  35. $menu[] = array('title' => $katao_product_family['name'], 'url' => url_for('@katao_boutique_famille?category=' . $katao_product_category_url . '&family=' . $katao_product_family['url']), 'active' => $katao_product_family_url == $katao_product_family['url']);
  36. }
  37. } else {
  38. $CurrentNode = $ContentTree->getCurrentNode();
  39. if ($CurrentNode != $ContentTree->getRoot()) {
  40. while ($CurrentNode && $CurrentNode->parent && $CurrentNode->parent->parent) {
  41. $CurrentNode = $CurrentNode->parent;
  42. }
  43. if ($CurrentNode) {
  44. $secondMenuItems = $CurrentNode->getVisibleChildren();
  45. } else {
  46. $secondMenuItems = array();
  47. }
  48. } else {
  49. $topMenu = $CurrentNode->getVisibleChildren();
  50. if (count($topMenu) > 0) {
  51. $secondMenuItems = $topMenu[0]->getVisibleChildren();
  52. } else {
  53. $secondMenuItems = array();
  54. }
  55. }
  56. if (count($secondMenuItems) > 0) {
  57. foreach ($secondMenuItems as/*(ContentTreeNode)*/ $secondMenuNode) {
  58. $menu[] = array('title' => $secondMenuNode->getMenuTitle(), 'url' => $secondMenuNode->getUrl(), 'active' => $secondMenuNode->isActive());
  59. }
  60. }
  61. }
  62. ?>
  63. <?php if (0 < count($menu)): ?>
  64. <div class="left">
  65. <div class="subnav">
  66. <div class="top"></div>
  67. <div class="center">
  68. <ul>
  69. <?php foreach ($menu as $item_index => $item): ?>
  70. <?php if (empty($item['url']) && !empty($item['suppliers'])): ?>
  71. <li>
  72. <?php printf('<a href="javascript://" title="%s" onclick="bascule(\'sub-menu-%s\'); return false;">%s</a>', $item['title'], $item_index, $item['title']); ?>
  73. <ul id="sub-menu-<?php echo $item_index ?>" style="display:<?php echo !empty($item['active'])?'block':'none' ?>;">
  74. <?php foreach ($item['suppliers'] as $sub_item): ?>
  75. <li class="<?php echo !empty($sub_item['active'])?'active':'' ?>">
  76. <a href="<?php echo $sub_item['url'] ?>" title="<?php echo $sub_item['title'] ?>"><?php echo $sub_item['title'] ?></a>
  77. </li>
  78. <?php endforeach ?>
  79. </ul>
  80. <?php else: ?>
  81. <li class="<?php echo !empty($item['active'])?'active':'' ?>">
  82. <a href="<?php echo $item['url'] ?>" title="<?php echo $item['title'] ?>"><?php echo $item['title'] ?></a>
  83. <?php endif ?>
  84. </li>
  85. <?php endforeach ?>
  86. </ul>
  87. </div>
  88. <div class="bottom"></div>
  89. </div>
  90. </div>
  91. <script language="javascript" type="text/javascript">
  92. function bascule(elem)
  93. {
  94. etat=document.getElementById(elem).style.display;
  95. if(etat=="none"){
  96. document.getElementById(elem).style.display="block";
  97. }
  98. else{
  99. document.getElementById(elem).style.display="none";
  100. }
  101. }
  102. </script>
  103. <?php endif ?>