getItems() public method

public getItems ( $code, integer $parent_id ) : array | mixed
$code
$parent_id integer
return array | mixed
Example #1
0
    }
});
$app->error(function (\LogicException $logicException) use($app) {
    if ($app['debug']) {
        return;
    } else {
        // Aqui ira la vista error/500.html.twig
        return new Response($logicException->getMessage());
    }
});
$app->error(function (AccessDeniedHttpException $accessDeniedHttpException) use($app) {
    if ($app['debug']) {
        return;
    } else {
        $menuModelo = new Menu($app['db']);
        $menuItems = $menuModelo->getItems();
        // Respuesta en frontend
        $uriActual = $_SERVER['REQUEST_URI'];
        return $app['twig']->render('errors/403.html.twig', array('uri' => $uriActual, 'menu_items' => $menuItems));
    }
});
$app->error(function (NotFoundHttpException $notFoundHttpException) use($app) {
    if ($app['debug']) {
        return;
    } else {
        $uriActual = $_SERVER['REQUEST_URI'];
        return $app['twig']->render('errors/404.html.twig', array('uri' => $uriActual));
    }
});
$app->error(function (MethodNotAllowedHttpException $methodNotAllowedHttpException, $code) use($app) {
    if ($app['debug']) {
    private function _displayItemAdd()
    {
        global $cookie, $currentIndex;
        $id_menu = Tools::isSubmit('edit') ? intVal(Tools::getValue('id_menu')) : 0;
        $menu = new Menu($id_menu);
        $id_lang = $cookie->id_lang;
        $defaultLanguage = intval(Configuration::get('PS_LANG_DEFAULT'));
        $iso = Language::getIsoById(intval($cookie->id_lang));
        $languages = Language::getLanguages();
        $divLangName = 'titleĀ¤link';
        $this->_html .= '
    <script type="text/javascript">id_language = Number(' . $defaultLanguage . ');</script>
    <form action="" method="post" enctype="multipart/form-data">
      <fieldset>
        <legend>
          <img src="' . _MODULE_DIR_ . $this->_module . '/gfx/tab/add.gif" alt="" title="" /> ' . $this->l('Add item') . '
        </legend>
        <label for="type">' . $this->l('Type:') . '</label>
        <div class="margin-form">
          <select name="type" onchange="$(\'.case\').addClass(\'hide\');$(\'.case_\'+$(this).val()).removeClass(\'hide\');">
            <option value="">-- ' . $this->l('Select an item type') . ' --</option>
            <option value="category" ' . ($menu->type == 'category' && Tools::isSubmit('edit') ? 'selected=""' : '') . '>' . $this->l('Categories') . '</option>
            <option value="product"' . ($menu->type == 'product' && Tools::isSubmit('edit') ? 'selected=""' : '') . '>' . $this->l('Products') . '</option>
            <option value="cms"' . ($menu->type == 'cms' && Tools::isSubmit('edit') ? 'selected=""' : '') . '>' . $this->l('CMS') . '</option>
            <option value="manufacturers"' . ($menu->type == 'manufacturers' && Tools::isSubmit('edit') ? 'selected=""' : '') . '>' . $this->l('Manufacturers List') . '</option>
            <option value="manufacturer"' . ($menu->type == 'manufacturer' && Tools::isSubmit('edit') ? 'selected=""' : '') . '>' . $this->l('Manufacturer') . '</option>
            <option value="suppliers"' . ($menu->type == 'suppliers' && Tools::isSubmit('edit') ? 'selected=""' : '') . '>' . $this->l('Suppliers List') . '</option>
            <option value="supplier"' . ($menu->type == 'supplier' && Tools::isSubmit('edit') ? 'selected=""' : '') . '>' . $this->l('Supplier') . '</option>
            <option value="link"' . ($menu->type == 'link' && Tools::isSubmit('edit') ? 'selected=""' : '') . '>' . $this->l('Links') . '</option>
          </select><sup> *</sup>
          <!-- <p class="clear">...</p> -->
        </div>
        <label for="type">' . $this->l('Parent Item:') . '</label>
        <div class="margin-form">
          <select name="id_parent">
            <option value="0">-- ' . $this->l('Choose a parent item') . ' --</option>';
        $items = Menu::getItems($id_lang);
        $this->_html .= $this->_showOption($items, $id_lang, 0, $menu->id_parent, array($menu->id));
        $this->_html .= '
          </select>
        </div>

        <!-- 2010-02-22 12:40:43 -->
        <label for="css">' . $this->l('CSS ID:') . '</label>
        <div class="margin-form">
          <input type="text" name="css" id="css" value="' . (!is_null($menu->id) ? $menu->css : '') . '" />
          <p class="clear">' . $this->l('Use this option to set a CSS ID to this item.') . '</p>
        </div>
        <!-- /2010-02-22 12:40:43 -->

        <!-- INT -->
        <label for="title">' . $this->l('Title:') . '</label>
        <div class="margin-form">';
        foreach ($languages as $language) {
            $this->_html .= '
            <div id="title_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;">
              <input type="text" name="title[' . $language['id_lang'] . ']" value="' . (!is_null($menu->id) ? $menu->title[$language['id_lang']] : '') . '" class="' . ($language['id_lang'] != $defaultLanguage ? 'clone' : 'cloneParent') . '" /><sup class="case case_link hide"> *</sup>
            </div>';
        }
        ob_start();
        $this->displayFlags($languages, $defaultLanguage, $divLangName, 'title');
        $this->_html .= ob_get_contents();
        ob_end_clean();
        $this->_html .= '
          <p class="clear">' . $this->l('If you leave the field blank, the default title will be used.') . '</p>
        </div>
        <!-- INT -->

        <!-- 2009-12-14 09:56:32 -->
        <label for="logged">' . $this->l('Must be logged:') . '</label>
        <div class="margin-form">
          <input type="checkbox" id="logged" name="logged" value="1"' . (!is_null($menu->id) && $menu->logged ? ' checked=""' : '') . '/>
          <p class="clear">' . $this->l('User must be logged.') . '</p>
        </div>
        <!-- /2009-12-14 09:56:32 -->

        <div class="case_category case ' . ($menu->type == 'category' && Tools::isSubmit('edit') ? '' : 'hide') . '">
          <label for="category_level">' . $this->l('Level:') . '</label>
          <div class="margin-form">
            <input type="text" name="category_level" id="category_level" value="' . (!is_null($menu->id) ? $menu->level : '0') . '" size="5" />
            <p class="clear">' . $this->l('Maximum level of unfolding, leave 0 for all.') . '</p>
          </div>
          <label for="id_category">' . $this->l('Category:') . '</label>
          <div class="margin-form">
            <select name="id_category" id="id_category" size="10">';
        $this->_getCategoryOption(1, $cookie->id_lang, true, !is_null($menu->id) ? $menu->id_item : null);
        $this->_html .= '
            </select><sup> *</sup>
            <p class="clear">' . $this->l('Start category') . '</p>
          </div>
          <label for="category_ignore">' . $this->l('Categories to ignore:') . '</label>
          <div class="margin-form">
            <input type="text" name="category_ignore" id="category_ignore" value="' . (!is_null($menu->id) ? $menu->ignore : '') . '" />
            <p class="clear">' . $this->l('Separate with comma. (id1,id2,...)') . '</p>
          </div>
        </div>
        <div class="case_product case ' . ($menu->type == 'product' && Tools::isSubmit('edit') ? '' : 'hide') . '">
          <label for="id_product">' . $this->l('Product ID:') . '</label>
          <div class="margin-form">
            <input type="text" name="id_product" id="id_product" size="6" />
            <!--
            <select name="id_product" id="id_product">';
        $this->_html .= '
            </select><sup> *</sup>
            -->
          </div>
        </div>
        <div class="case_cms case ' . ($menu->type == 'cms' && Tools::isSubmit('edit') ? '' : 'hide') . '">
          <label for="id_cms">' . $this->l('CMS Page:') . '</label>
          <div class="margin-form">
            <select name="id_cms" id="id_cms">';
        $_cms = CMS::listCms($cookie->id_lang);
        foreach ($_cms as $cms) {
            $this->_html .= '<option value="' . $cms['id_cms'] . '" 
              ' . (!is_null($menu->id) && $menu->id_item == $cms['id_cms'] ? 'selected=""' : '') . '
              >' . $cms['meta_title'] . '</option>';
        }
        $this->_html .= '
            </select><sup> *</sup>
          </div>
        </div>
        <div class="case_manufacturer case ' . ($menu->type == 'manufacturer' && Tools::isSubmit('edit') ? '' : 'hide') . '">
          <label for="manufacturer_id">' . $this->l('Manufacturer:') . '</label>
          <div class="margin-form">
            <select name="id_manufacturer" id="id_manufacturer">';
        $manufacturers = Manufacturer::getManufacturers(false, $cookie->id_lang);
        foreach ($manufacturers as $manufacturer) {
            $this->_html .= '<option value="' . $manufacturer['id_manufacturer'] . '" 
              ' . (!is_null($menu->id) && $menu->id_item == $manufacturer['id_manufacturer'] ? 'selected=""' : '') . '
              >' . $manufacturer['name'] . '</option>';
        }
        $this->_html .= '
            </select>
          </div>
        </div>
        <div class="case_supplier case ' . ($menu->type == 'supplier' && Tools::isSubmit('edit') ? '' : 'hide') . '">
          <label for="id_supplier">' . $this->l('Supplier:') . '</label>
          <div class="margin-form">
            <select name="id_supplier" id="id_supplier">';
        $suppliers = Supplier::getSuppliers(false, $cookie->id_lang);
        foreach ($suppliers as $supplier) {
            $this->_html .= '<option value="' . $supplier['id_supplier'] . '" 
              ' . (!is_null($menu->id) && $menu->id_item == $supplier['id_supplier'] ? 'selected=""' : '') . '
              >' . $supplier['name'] . '</option>';
        }
        $this->_html .= '
            </select><sup> *</sup>
          </div>
        </div>
        <div class="case_link case ' . ($menu->type == 'link' && Tools::isSubmit('edit') ? '' : 'hide') . '">

          <label for="link">' . $this->l('URL:') . '</label>
          <div class="margin-form">';
        foreach ($languages as $language) {
            $this->_html .= '
            <div id="link_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;">
              <input type="text" name="link[' . $language['id_lang'] . ']" value="' . (!is_null($menu->id) ? $menu->link[$language['id_lang']] : '') . '" class="' . ($language['id_lang'] != $defaultLanguage ? 'clone' : 'cloneParent') . '" /><sup> *</sup>
            </div>';
        }
        ob_start();
        $this->displayFlags($languages, $defaultLanguage, $divLangName, 'link');
        $this->_html .= ob_get_contents();
        ob_end_clean();
        $this->_html .= '
            <p class="clear">&nbsp;</p>
          </div>
        </div>
        <!-- v5.6.5 -->
        <label for="new_window">' . $this->l('New window:') . '</label>
        <div class="margin-form">
          <input type="checkbox" id="new_window" name="new_window" value="1"' . (!is_null($menu->id) && $menu->new_window ? ' checked=""' : '') . '/>
          <p class="clear">' . $this->l('On click, open link in new window.') . '</p>
        </div>

        <label for="icon">' . $this->l('Icon:') . '</label>
        <div class="margin-form">
          <input type="file" name="icon" id="icon" /><br />';
        $filename = $this->_getFilename($menu->id);
        if ($filename) {
            $this->_html .= '
          <div id="image" style="float: none; width: 100px;">
            <img src="' . $filename . '?refresh=' . rand(1, 10) . '" /> 
            <a href="' . $_SERVER['REQUEST_URI'] . '&deleteIcon"><img src="' . _PS_ADMIN_IMG_ . '/delete.gif" alt="" /></a>
          </div>';
        }
        $this->_html .= '
        </div>

        <div class="clear center">
          <input type="submit" name="submitItem" value="' . $this->l(' Save item ') . '" class="button" />
        </div>
      </fieldset>
    </form>';
    }
Example #3
0
 /**
  * @covers Menu::getItems
  */
 public function testGetItems()
 {
     $this->menu->setMenuSelection("dashboard->sensors");
     $actual = $this->menu->getItems();
     $this->assertContainsOnlyInstancesOf("MenuItem", $actual);
 }