Exemple #1
0
    public function getContent()
    {
        global $cookie;
        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_SEARCH', (bool) Tools::getValue('search'));
        }
        if (Tools::isSubmit('submitBlocktopmenuLinks')) {
            if (Tools::getValue('link') == '') {
                $this->_html .= $this->displayError($this->l('Unable to add this link'));
            } else {
                MenuTopLinks::add(Tools::getValue('link'), Tools::getValue('label'), Tools::getValue('new_window', 0));
                $this->_html .= $this->displayConfirmation($this->l('The link has been added'));
            }
        }
        if (Tools::isSubmit('submitBlocktopmenuRemove')) {
            $id_link = Tools::getValue('id_link', 0);
            MenuTopLinks::remove($id_link);
            Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', str_replace(array('LNK' . $id_link . ',', 'LNK' . $id_link), '', Configuration::get('MOD_BLOCKTOPMENU_ITEMS')));
            $this->_html .= $this->displayConfirmation($this->l('The link has been removed'));
        }
        $this->_html .= '
    <fieldset>
      <legend><img src="' . $this->_path . 'logo.gif" alt="" title="" />' . $this->l('Settings') . '</legend>
      <form action="' . $_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="' . Configuration::get('MOD_BLOCKTOPMENU_ITEMS') . '" size="70" />
  			</div>
  			</div>

        <div class="clear">&nbsp;</div>
        <table style="margin-left: 130px;">
          <tbody>
            <tr>
              <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);">' . $this->l('Remove') . ' &gt;&gt;</a>
              </td>
              <td style="padding-left: 20px;">
                <select multiple="multiple" id="availableItems" style="width: 300px; height: 160px;">';
        // BEGIN CMS
        $this->_html .= '<optgroup label="' . $this->l('CMS') . '">';
        $_cms = CMS::listCms($cookie->id_lang);
        foreach ($_cms as $cms) {
            $this->_html .= '<option value="CMS' . $cms['id_cms'] . '" style="margin-left:10px;">' . $cms['meta_title'] . '</option>';
        }
        $this->_html .= '</optgroup>';
        // END CMS
        // BEGIN SUPPLIER
        $this->_html .= '<optgroup label="' . $this->l('Supplier') . '">';
        $suppliers = Supplier::getSuppliers(false, $cookie->id_lang);
        foreach ($suppliers as $supplier) {
            $this->_html .= '<option value="SUP' . $supplier['id_supplier'] . '" style="margin-left:10px;">' . $supplier['name'] . '</option>';
        }
        $this->_html .= '</optgroup>';
        // END SUPPLIER
        // BEGIN Manufacturer
        $this->_html .= '<optgroup label="' . $this->l('Manufacturer') . '">';
        $manufacturers = Manufacturer::getManufacturers(false, $cookie->id_lang);
        foreach ($manufacturers as $manufacturer) {
            $this->_html .= '<option value="MAN' . $manufacturer['id_manufacturer'] . '" style="margin-left:10px;">' . $manufacturer['name'] . '</option>';
        }
        $this->_html .= '</optgroup>';
        // END Manufacturer
        // BEGIN Categories
        $this->_html .= '<optgroup label="' . $this->l('Categories') . '">';
        $this->getCategoryOption(1, $cookie->id_lang);
        $this->_html .= '</optgroup>';
        // END Categories
        // BEGIN Products
        $this->_html .= '<optgroup label="' . $this->l('Products') . '">';
        $this->_html .= '<option value="PRODUCT" style="margin-left:10px;font-style:italic">' . $this->l('Choose ID product') . '</option>';
        $this->_html .= '</optgroup>';
        // END Products
        // BEGIN Menu Top Links
        $this->_html .= '<optgroup label="' . $this->l('Menu Top Links') . '">';
        $links = MenuTopLinks::gets($cookie->id_lang);
        foreach ($links as $link) {
            $this->_html .= '<option value="LNK' . $link['id_link'] . '" style="margin-left:10px;">' . $link['label'] . '</option>';
        }
        $this->_html .= '</optgroup>';
        // END Menu Top Links
        $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);">&lt;&lt; ' . $this->l('Add') . '</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();
              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('Search Bar') . '</label>
        <div class="margin-form">
          <input type="checkbox" name="search" id="s" value="1"' . (Configuration::get('MOD_BLOCKTOPMENU_SEARCH') ? ' checked=""' : '') . '/>
        </div>
        <p class="center">
          <input type="submit" name="submitBlocktopmenu" value="' . $this->l('  Save  ') . '" class="button" />
        </p>
      </form>
    </fieldset><br />';
        $defaultLanguage = intval(Configuration::get('PS_LANG_DEFAULT'));
        $languages = Language::getLanguages();
        $iso = Language::getIsoById($defaultLanguage);
        $divLangName = 'link_label';
        $this->_html .= '
    <fieldset>
      <legend><img src="../img/admin/add.gif" alt="" title="" />' . $this->l('Add Menu Top Link') . '</legend>
      <form action="' . $_SERVER['REQUEST_URI'] . '" method="post" id="form">
  			<label>' . $this->l('Label') . '</label>
        <div class="margin-form">';
        foreach ($languages as $language) {
            $this->_html .= '
					<div id="link_label_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . ';float: left;">
						<input type="text" name="label[' . $language['id_lang'] . ']" id="label_' . $language['id_lang'] . '" size="70" value="" />
					</div>';
        }
        $this->_html .= $this->displayFlags($languages, $defaultLanguage, $divLangName, 'link_label', true);
        $this->_html .= '</div><p class="clear"> </p>
  			<label>' . $this->l('Link') . '</label>
  			<div class="margin-form">
          <input type="text" name="link" value="" size="70" />
  			</div>
  			<label>' . $this->l('New Window') . '</label>
  			<div class="margin-form">
          <input type="checkbox" name="new_window" value="1" />
  			</div>
        <p class="center">
          <input type="submit" name="submitBlocktopmenuLinks" value="' . $this->l('  Add  ') . '" class="button" />
        </p>
  		</form>
    </fieldset><br />';
        $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>
            <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>';
        $links = MenuTopLinks::gets($cookie->id_lang);
        foreach ($links as $link) {
            $this->_html .= '
          <tr>
            <td>' . $link['id_link'] . '</td>
            <td>' . $link['label'] . '</td>
            <td>' . $link['link'] . '</td>
            <td>' . ($link['new_window'] ? $this->l('Yes') : $this->l('No')) . '</td>
            <td>
              <form action="' . $_SERVER['REQUEST_URI'] . '" method="post">
                <input type="hidden" name="id_link" value="' . $link['id_link'] . '" />
          			<input type="submit" name="submitBlocktopmenuRemove" value="' . $this->l('Remove') . '" class="button" />
          		</form>
            </td>
          </tr>';
        }
        $this->_html .= '</tbody>
      </table>
  	</fieldset>';
        echo $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')) {
         $errors_update_shops = array();
         $items = Tools::getValue('items');
         $shops = Shop::getContextListShopID();
         foreach ($shops as $shop_id) {
             $shop_group_id = Shop::getGroupFromShop($shop_id);
             $updated = true;
             if (count($shops) == 1) {
                 if (is_array($items) && count($items)) {
                     $updated = Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', (string) implode(',', $items), false, (int) $shop_group_id, (int) $shop_id);
                 } else {
                     $updated = Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', '', false, (int) $shop_group_id, (int) $shop_id);
                 }
             }
             $updated &= Configuration::updateValue('MOD_BLOCKTOPMENU_SEARCH', (bool) Tools::getValue('search'), false, (int) $shop_group_id, (int) $shop_id);
             if (!$updated) {
                 $shop = new Shop($shop_id);
                 $errors_update_shops[] = $shop->name;
             }
         }
         if (!count($errors_update_shops)) {
             $this->_html .= $this->displayConfirmation($this->l('The settings have been updated.'));
         } else {
             $this->_html .= $this->displayError(sprintf($this->l('Unable to update settings for the following shop(s): %s'), implode(', ', $errors_update_shops)));
         }
         $update_cache = true;
     } else {
         if (Tools::isSubmit('submitBlocktopmenuLinks')) {
             $errors_add_link = array();
             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 {
                     $shops = Shop::getContextListShopID();
                     foreach ($shops as $shop_id) {
                         $added = MenuTopLinks::add($links_label, $labels, Tools::getValue('new_window', 0), (int) $shop_id);
                         if (!$added) {
                             $shop = new Shop($shop_id);
                             $errors_add_link[] = $shop->name;
                         }
                     }
                     if (!count($errors_add_link)) {
                         $this->_html .= $this->displayConfirmation($this->l('The link has been added.'));
                     } else {
                         $this->_html .= $this->displayError(sprintf($this->l('Unable to add link for the following shop(s): %s'), implode(', ', $errors_add_link)));
                     }
                 }
             }
             $update_cache = true;
         } elseif (Tools::isSubmit('deletelinksmenutop')) {
             $errors_delete_link = array();
             $id_linksmenutop = Tools::getValue('id_linksmenutop', 0);
             $shops = Shop::getContextListShopID();
             foreach ($shops as $shop_id) {
                 $deleted = MenuTopLinks::remove($id_linksmenutop, (int) $shop_id);
                 Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', str_replace(array('LNK' . $id_linksmenutop . ',', 'LNK' . $id_linksmenutop), '', Configuration::get('MOD_BLOCKTOPMENU_ITEMS')));
                 if (!$deleted) {
                     $shop = new Shop($shop_id);
                     $errors_delete_link[] = $shop->name;
                 }
             }
             if (!count($errors_delete_link)) {
                 $this->_html .= $this->displayConfirmation($this->l('The link has been removed.'));
             } else {
                 $this->_html .= $this->displayError(sprintf($this->l('Unable to remove link for the following shop(s): %s'), implode(', ', $errors_delete_link)));
             }
             $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::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();
     }
     $shops = Shop::getContextListShopID();
     $links = array();
     if (count($shops) > 1) {
         $this->_html .= $this->getWarningMultishopHtml();
     }
     if (Shop::isFeatureActive()) {
         $this->_html .= $this->getCurrentShopInfoMsg();
     }
     $this->_html .= $this->renderForm() . $this->renderAddForm();
     foreach ($shops as $shop_id) {
         $links = array_merge($links, MenuTopLinks::gets((int) $id_lang, null, (int) $shop_id));
     }
     if (!count($links)) {
         return $this->_html;
     }
     $this->_html .= $this->renderList();
     return $this->_html;
 }
    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('&nbsp;', $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_SEARCH', (bool) Tools::getValue('search'));
            $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::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::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::getLinkLang($id_linksmenutop, $id_shop);
                            $links_label_edit = $tmp['link'];
                            $labels_edit = $tmp['label'];
                            $new_window_edit = $tmp['new_window'];
                        } else {
                            MenuTopLinks::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::gets($id_lang, null, (int) Shop::getContextShopID());
        foreach ($links as $link) {
            if ($link['label'] == '') {
                $link = MenuTopLinks::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('Search Bar') . '</label>
				<div class="margin-form">
					<input type="checkbox" name="search" id="s" value="1"' . (Configuration::get('MOD_BLOCKTOPMENU_SEARCH') ? ' 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::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;
    }