public function getContent()
    {
        $id_lang = (int) Context::getContext()->language->id;
        $languages = $this->context->controller->getLanguages();
        $default_language = (int) Configuration::get('PS_LANG_DEFAULT');
        $labels = Tools::getValue('label') ? array_filter(Tools::getValue('label'), 'strlen') : array();
        $links_label = Tools::getValue('link') ? array_filter(Tools::getValue('link'), 'strlen') : array();
        $spacer = str_repeat(' ', $this->spacer_size);
        $divLangName = 'link_label';
        $update_cache = false;
        if (Tools::isSubmit('submitBlocktopmenu')) {
            if (Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', Tools::getValue('items'))) {
                $this->_html .= $this->displayConfirmation($this->l('Settings Updated'));
            } else {
                $this->_html .= $this->displayError($this->l('Unable to update settings'));
            }
            Configuration::updateValue('MOD_BLOCKTOPMENU_HOME', (bool) Tools::getValue('home'));
            $update_cache = true;
        } else {
            if (Tools::isSubmit('submitBlocktopmenuLinks')) {
                if (!count($links_label) && !count($labels)) {
                } else {
                    if (!count($links_label)) {
                        $this->_html .= $this->displayError($this->l('Please, fill the "Link" field'));
                    } else {
                        if (!count($labels)) {
                            $this->_html .= $this->displayError($this->l('Please add a label'));
                        } else {
                            if (!isset($labels[$default_language])) {
                                $this->_html .= $this->displayError($this->l('Please add a label for your default language'));
                            } else {
                                MenuTopLinks_mod::add(Tools::getValue('link'), Tools::getValue('label'), Tools::getValue('new_window', 0), (int) Shop::getContextShopID());
                                $this->_html .= $this->displayConfirmation($this->l('The link has been added'));
                            }
                        }
                    }
                }
                $update_cache = true;
            } else {
                if (Tools::isSubmit('submitBlocktopmenuRemove')) {
                    $id_linksmenutop = Tools::getValue('id_linksmenutop', 0);
                    MenuTopLinks_mod::remove($id_linksmenutop, (int) Shop::getContextShopID());
                    Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', str_replace(array('LNK' . $id_linksmenutop . ',', 'LNK' . $id_linksmenutop), '', Configuration::get('MOD_BLOCKTOPMENU_ITEMS')));
                    $this->_html .= $this->displayConfirmation($this->l('The link has been removed'));
                    $update_cache = true;
                } else {
                    if (Tools::isSubmit('submitBlocktopmenuEdit')) {
                        $id_linksmenutop = (int) Tools::getValue('id_linksmenutop', 0);
                        $id_shop = (int) Shop::getContextShopID();
                        if (!Tools::isSubmit('link')) {
                            $tmp = MenuTopLinks_mod::getLinkLang($id_linksmenutop, $id_shop);
                            $links_label_edit = $tmp['link'];
                            $labels_edit = $tmp['label'];
                            $new_window_edit = $tmp['new_window'];
                        } else {
                            MenuTopLinks_mod::update(Tools::getValue('link'), Tools::getValue('label'), Tools::getValue('new_window', 0), (int) $id_shop, (int) $id_linksmenutop, (int) $id_linksmenutop);
                            $this->_html .= $this->displayConfirmation($this->l('The link has been edited'));
                        }
                        $update_cache = true;
                    }
                }
            }
        }
        if ($update_cache) {
            $this->clearMenuCache();
        }
        $this->_html .= '
        <fieldset>
            <div class="multishop_info">
            ' . $this->l('The modifications will be applied to') . ' ' . (Shop::getContext() == Shop::CONTEXT_SHOP ? $this->l('shop:') . ' ' . $this->context->shop->name : $this->l('all shops')) . '.
            </div>
            <legend><img src="' . $this->_path . 'logo.gif" alt="" title="" />' . $this->l('Settings') . '</legend>
            <form action="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '" method="post" id="form">
                <div style="display: none">
                <label>' . $this->l('Items') . '</label>
                <div class="margin-form">
                    <input type="text" name="items" id="itemsInput" value="' . Tools::safeOutput(Configuration::get('MOD_BLOCKTOPMENU_ITEMS')) . '" size="70" />
                </div>
                </div>

                <div class="clear">&nbsp;</div>
                <table style="margin-left: 130px;">
                    <tbody>
                        <tr>
                            <td style="padding-left: 20px;">
                                <select multiple="multiple" id="availableItems" style="width: 300px; height: 160px;">';
        // BEGIN CMS
        $this->_html .= '<optgroup label="' . $this->l('CMS') . '">';
        $this->getCMSOptions(0, 1, $id_lang);
        $this->_html .= '</optgroup>';
        // BEGIN SUPPLIER
        $this->_html .= '<optgroup label="' . $this->l('Supplier') . '">';
        $suppliers = Supplier::getSuppliers(false, $id_lang);
        foreach ($suppliers as $supplier) {
            $this->_html .= '<option value="SUP' . $supplier['id_supplier'] . '">' . $spacer . $supplier['name'] . '</option>';
        }
        $this->_html .= '</optgroup>';
        // BEGIN Manufacturer
        $this->_html .= '<optgroup label="' . $this->l('Manufacturer') . '">';
        $manufacturers = Manufacturer::getManufacturers(false, $id_lang);
        foreach ($manufacturers as $manufacturer) {
            $this->_html .= '<option value="MAN' . $manufacturer['id_manufacturer'] . '">' . $spacer . $manufacturer['name'] . '</option>';
        }
        $this->_html .= '</optgroup>';
        // BEGIN Categories
        $this->_html .= '<optgroup label="' . $this->l('Categories') . '">';
        $this->getCategoryOption(1, (int) $id_lang, (int) Shop::getContextShopID());
        $this->_html .= '</optgroup>';
        // BEGIN Shops
        if (Shop::isFeatureActive()) {
            $this->_html .= '<optgroup label="' . $this->l('Shops') . '">';
            $shops = Shop::getShopsCollection();
            foreach ($shops as $shop) {
                if (!$shop->setUrl() && !$shop->getBaseURL()) {
                    continue;
                }
                $this->_html .= '<option value="SHOP' . (int) $shop->id . '">' . $spacer . $shop->name . '</option>';
            }
            $this->_html .= '</optgroup>';
        }
        // BEGIN Products
        $this->_html .= '<optgroup label="' . $this->l('Products') . '">';
        $this->_html .= '<option value="PRODUCT" style="font-style:italic">' . $spacer . $this->l('Choose ID product') . '</option>';
        $this->_html .= '</optgroup>';
        // BEGIN Menu Top Links
        $this->_html .= '<optgroup label="' . $this->l('Menu Top Links') . '">';
        $links = MenuTopLinks_mod::gets($id_lang, null, (int) Shop::getContextShopID());
        foreach ($links as $link) {
            if ($link['label'] == '') {
                $link = MenuTopLinks_mod::get($link['id_linksmenutop'], $default_language, (int) Shop::getContextShopID());
                $this->_html .= '<option value="LNK' . (int) $link[0]['id_linksmenutop'] . '">' . $spacer . $link[0]['label'] . '</option>';
            } else {
                $this->_html .= '<option value="LNK' . (int) $link['id_linksmenutop'] . '">' . $spacer . $link['label'] . '</option>';
            }
        }
        $this->_html .= '</optgroup>';
        $this->_html .= '</select><br />
                                <br />
                                <a href="#" id="addItem" style="border: 1px solid rgb(170, 170, 170); margin: 2px; padding: 2px; text-align: center; display: block; text-decoration: none; background-color: rgb(250, 250, 250); color: rgb(18, 52, 86);">' . $this->l('Add') . ' &gt;&gt;</a>
                            </td>
                            <td>
                                <select multiple="multiple" id="items" style="width: 300px; height: 160px;">';
        $this->makeMenuOption();
        $this->_html .= '</select><br/>
                                <br/>
                                <a href="#" id="removeItem" style="border: 1px solid rgb(170, 170, 170); margin: 2px; padding: 2px; text-align: center; display: block; text-decoration: none; background-color: rgb(250, 250, 250); color: rgb(18, 52, 86);">&lt;&lt; ' . $this->l('Remove') . '</a>
                            </td>
                        </tr>
                    </tbody>
                </table>
                <div class="clear">&nbsp;</div>
                <script type="text/javascript">
                $(document).ready(function(){
                    $("#addItem").click(add);
                    $("#availableItems").dblclick(add);
                    $("#removeItem").click(remove);
                    $("#items").dblclick(remove);
                    function add()
                    {
                        $("#availableItems option:selected").each(function(i){
                            var val = $(this).val();
                            var text = $(this).text();
                            text = text.replace(/(^\\s*)|(\\s*$)/gi,"");
                            if (val == "PRODUCT")
                            {
                                val = prompt("' . $this->l('Set ID product') . '");
                                if (val == null || val == "" || isNaN(val))
                                    return;
                                text = "' . $this->l('Product ID') . ' "+val;
                                val = "PRD"+val;
                            }
                            $("#items").append("<option value=\\""+val+"\\">"+text+"</option>");
                        });
                        serialize();
                        return false;
                    }
                    function remove()
                    {
                        $("#items option:selected").each(function(i){
                            $(this).remove();
                        });
                        serialize();
                        return false;
                    }
                    function serialize()
                    {
                        var options = "";
                        $("#items option").each(function(i){
                            options += $(this).val()+",";
                        });
                        $("#itemsInput").val(options.substr(0, options.length - 1));
                    }
                });
                </script>
                <label for="s">' . $this->l('Home Item') . '</label>
                <div class="margin-form">
                    <input type="checkbox" name="home" id="s" value="1"' . (Configuration::get('MOD_BLOCKTOPMENU_HOME') ? ' checked=""' : '') . '/>
                </div>
                <p class="center">
                    <input type="submit" name="submitBlocktopmenu" value="' . $this->l('	Save	') . '" class="button" />
                </p>
            </form>
        </fieldset><br />';
        $this->_html .= '
        <fieldset>
            <legend><img src="../img/admin/add.gif" alt="" title="" />' . $this->l('Add Menu Top Link') . '</legend>
            <form action="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '" method="post" id="form">

                ';
        foreach ($languages as $language) {
            $this->_html .= '
                    <div id="link_label_' . (int) $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $id_lang ? 'block' : 'none') . ';">
                <label>' . $this->l('Label') . '</label>
                <div class="margin-form">
                        <input type="text" name="label[' . (int) $language['id_lang'] . ']" id="label_' . (int) $language['id_lang'] . '" size="70" value="' . (isset($labels_edit[$language['id_lang']]) ? Tools::safeOutput($labels_edit[$language['id_lang']]) : '') . '" />
              </div>
                    ';
            $this->_html .= '
                  <label>' . $this->l('Link') . '</label>
                <div class="margin-form">
                    <input type="text" name="link[' . (int) $language['id_lang'] . ']" id="link_' . (int) $language['id_lang'] . '" value="' . (isset($links_label_edit[$language['id_lang']]) ? Tools::safeOutput($links_label_edit[$language['id_lang']]) : '') . '" size="70" />
                </div>
                </div>';
        }
        $this->_html .= '<label>' . $this->l('Language') . '</label>
                <div class="margin-form">' . $this->displayFlags($languages, (int) $id_lang, $divLangName, 'link_label', true) . '</div><p style="clear: both;"> </p>';
        $this->_html .= '<label style="clear: both;">' . $this->l('New Window') . '</label>
                <div class="margin-form">
                    <input style="clear: both;" type="checkbox" name="new_window" value="1" ' . (isset($new_window_edit) && $new_window_edit ? 'checked' : '') . '/>
                </div>
<div class="margin-form">';
        if (Tools::isSubmit('id_linksmenutop')) {
            $this->_html .= '<input type="hidden" name="id_linksmenutop" value="' . (int) Tools::getValue('id_linksmenutop') . '" />';
        }
        if (Tools::isSubmit('submitBlocktopmenuEdit')) {
            $this->_html .= '<input type="submit" name="submitBlocktopmenuEdit" value="' . $this->l('Edit') . '" class="button" />';
        }
        $this->_html .= '
                    <input type="submit" name="submitBlocktopmenuLinks" value="' . $this->l('	Add	') . '" class="button" />
</div>

            </form>
        </fieldset><br />';
        $links = MenuTopLinks_mod::gets((int) $id_lang, null, (int) Shop::getContextShopID());
        if (!count($links)) {
            return $this->_html;
        }
        $this->_html .= '
        <fieldset>
            <legend><img src="../img/admin/details.gif" alt="" title="" />' . $this->l('List Menu Top Link') . '</legend>
            <table style="width:100%;">
                <thead>
                    <tr style="text-align: left;">
                        <th>' . $this->l('Id Link') . '</th>
                        <th>' . $this->l('Label') . '</th>
                        <th>' . $this->l('Link') . '</th>
                        <th>' . $this->l('New Window') . '</th>
                        <th>' . $this->l('Action') . '</th>
                    </tr>
                </thead>
                <tbody>';
        foreach ($links as $link) {
            $this->_html .= '
                    <tr>
                        <td>' . (int) $link['id_linksmenutop'] . '</td>
                        <td>' . Tools::safeOutput($link['label']) . '</td>
                        <td><a href="' . Tools::safeOutput($link['link']) . '"' . ($link['new_window'] ? ' target="_blank"' : '') . '>' . Tools::safeOutput($link['link']) . '</a></td>
                        <td>' . ($link['new_window'] ? $this->l('Yes') : $this->l('No')) . '</td>
                        <td>
                            <form action="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '" method="post">
                                <input type="hidden" name="id_linksmenutop" value="' . (int) $link['id_linksmenutop'] . '" />
                                <input type="submit" name="submitBlocktopmenuEdit" value="' . $this->l('Edit') . '" class="button" />
                                <input type="submit" name="submitBlocktopmenuRemove" value="' . $this->l('Remove') . '" class="button" />
                            </form>
                        </td>
                    </tr>';
        }
        $this->_html .= '</tbody>
            </table>
        </fieldset>';
        return $this->_html;
    }
 public function getContent()
 {
     $this->context->controller->addjQueryPlugin('hoverIntent');
     $id_lang = (int) Context::getContext()->language->id;
     $languages = $this->context->controller->getLanguages();
     $default_language = (int) Configuration::get('PS_LANG_DEFAULT');
     $labels = Tools::getValue('label') ? array_filter(Tools::getValue('label'), 'strlen') : array();
     $links_label = Tools::getValue('link') ? array_filter(Tools::getValue('link'), 'strlen') : array();
     $spacer = str_repeat('&nbsp;', $this->spacer_size);
     $divLangName = 'link_label';
     $update_cache = false;
     if (Tools::isSubmit('submitBlocktopmenu')) {
         $items = Tools::getValue('items');
         if (is_array($items) && count($items) && Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', (string) implode(',', $items))) {
             $this->_html .= $this->displayConfirmation($this->l('The settings have been updated.'));
         } else {
             $this->_html .= $this->displayError($this->l('Unable to update settings.'));
         }
         Configuration::updateValue('MOD_BLOCKTOPMENU_HOME', (bool) Tools::getValue('home'));
         $update_cache = true;
     } else {
         if (Tools::isSubmit('submitBlocktopmenuLinks')) {
             foreach ($languages as $key => $val) {
                 $links_label[$val['id_lang']] = Tools::getValue('link_' . (int) $val['id_lang']);
                 $labels[$val['id_lang']] = Tools::getValue('label_' . (int) $val['id_lang']);
             }
             $count_links_label = count($links_label);
             $count_label = count($labels);
             if ($count_links_label || $count_label) {
                 if (!$count_links_label) {
                     $this->_html .= $this->displayError($this->l('Please complete the "Link" field.'));
                 } elseif (!$count_label) {
                     $this->_html .= $this->displayError($this->l('Please add a label.'));
                 } elseif (!isset($labels[$default_language])) {
                     $this->_html .= $this->displayError($this->l('Please add a label for your default language.'));
                 } else {
                     MenuTopLinks_mod::add($links_label, $labels, Tools::getValue('new_window', 0), (int) Shop::getContextShopID());
                     $this->_html .= $this->displayConfirmation($this->l('The link has been added.'));
                 }
             }
             $update_cache = true;
         } elseif (Tools::isSubmit('deletelinksmenutop')) {
             $id_linksmenutop = Tools::getValue('id_linksmenutop', 0);
             MenuTopLinks_mod::remove($id_linksmenutop, (int) Shop::getContextShopID());
             Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', str_replace(array('LNK' . $id_linksmenutop . ',', 'LNK' . $id_linksmenutop), '', Configuration::get('MOD_BLOCKTOPMENU_ITEMS')));
             $this->_html .= $this->displayConfirmation($this->l('The link has been removed.'));
             $update_cache = true;
         } elseif (Tools::isSubmit('updatelinksmenutop')) {
             $id_linksmenutop = (int) Tools::getValue('id_linksmenutop', 0);
             $id_shop = (int) Shop::getContextShopID();
             if (Tools::isSubmit('updatelink')) {
                 $link = array();
                 $label = array();
                 $new_window = (int) Tools::getValue('new_window', 0);
                 foreach (Language::getLanguages(false) as $lang) {
                     $link[$lang['id_lang']] = Tools::getValue('link_' . (int) $lang['id_lang']);
                     $label[$lang['id_lang']] = Tools::getValue('label_' . (int) $lang['id_lang']);
                 }
                 MenuTopLinks_mod::update($link, $label, $new_window, (int) $id_shop, (int) $id_linksmenutop, (int) $id_linksmenutop);
                 $this->_html .= $this->displayConfirmation($this->l('The link has been edited.'));
             }
             $update_cache = true;
         }
     }
     if ($update_cache) {
         $this->clearMenuCache();
     }
     $this->_html .= $this->renderForm() . $this->renderAddForm();
     $links = MenuTopLinks_mod::gets((int) $id_lang, null, (int) Shop::getContextShopID());
     if (!count($links)) {
         return $this->_html;
     }
     $this->_html .= $this->renderList();
     return $this->_html;
 }