public function displayList()
    {
        global $currentIndex, $cookie;
        echo '<br /><a href="' . $currentIndex . '&add' . $this->table . '&token=' . $this->token . '"><img src="../img/admin/add.gif" border="0" /> <b>' . $this->l('Add attributes group') . '</b></a><br />
		<a href="' . $currentIndex . '&addattribute&token=' . $this->token . '"><img src="../img/admin/add.gif" border="0" /> ' . $this->l('Add attribute') . '</a><br /><br />
		' . $this->l('Click on the group name to view its attributes. Click again to hide them.') . '<br /><br />';
        if ($this->_list === false) {
            Tools::displayError('No elements found');
        }
        $this->displayListHeader();
        echo '<input type="hidden" name="groupid" value="0">';
        if (!sizeof($this->_list)) {
            echo '<tr><td class="center" colspan="' . sizeof($this->_list) . '">' . $this->l('No elements found') . '</td></tr>';
        }
        $irow = 0;
        foreach ($this->_list as $tr) {
            $id = (int) $tr['id_' . $this->table];
            echo '
			<tr' . ($irow++ % 2 ? ' class="alt_row"' : '') . '>
				<td style="vertical-align: top; padding: 4px 0 4px 0" class="center"><input type="checkbox" name="' . $this->table . 'Box[]" value="' . $id . '" class="noborder" /></td>
				<td style="width: 140px; vertical-align: top; padding: 4px 0 4px 0; cursor: pointer" onclick="$(\'#attributes_' . $id . '\').slideToggle();">' . $tr['name'] . '</td>
				<td style="vertical-align: top; padding: 4px 0 4px 0; width: 340px">
					<div id="attributes_' . $id . '" style="display: none">
					<table class="table" cellpadding="0" cellspacing="0">
						<tr>
							<th><input type="checkbox" name="checkme" class="noborder" onclick="checkDelBoxes(this.form, \'attribute' . $id . 'Box[]\', this.checked)" /></th>
							<th width="100%">' . $this->l('Attribute') . '</th>
							<th>' . $this->l('Actions') . '</th>
						</tr>';
            $attributes = AttributeGroup::getAttributes((int) $cookie->id_lang, $id);
            foreach ($attributes as $attribute) {
                echo '
						<tr>
							<td class="center"><input type="checkbox" name="attribute' . $id . 'Box[]" value="' . $attribute['id_attribute'] . '" class="noborder" /></td>
							<td>
								' . ($tr['is_color_group'] ? '<div style="float: left; width: 18px; height: 12px; border: 1px solid #996633; background-color: ' . $attribute['color'] . '; margin-right: 4px;"></div>' : '') . $attribute['name'] . '
							</td>
							<td class="center">
								<a href="' . $currentIndex . '&id_attribute=' . $attribute['id_attribute'] . '&updateattribute&token=' . $this->token . '">
								<img src="../img/admin/edit.gif" border="0" alt="' . $this->l('Edit') . '" title="' . $this->l('Edit') . '" /></a>&nbsp;
								<a href="' . $currentIndex . '&id_attribute=' . $attribute['id_attribute'] . '&deleteattribute&token=' . $this->token . '"
								onclick="return confirm(\'' . $this->l('Delete attribute', __CLASS__, true, false) . ' : ' . $attribute['name'] . '?\');">
								<img src="../img/admin/delete.gif" border="0" alt="' . $this->l('Delete') . '" title="' . $this->l('Delete') . '" /></a>
							</td>
						</tr>';
            }
            echo '
					</table>
					<p><input type="Submit" class="button" name="submitDelattribute" value="' . $this->l('Delete selection') . '"
					onclick="changeFormParam(this.form, \'' . $currentIndex . '\', ' . $id . '); return confirm(\'' . $this->l('Delete selected items?', __CLASS__, true, false) . '\');" /></p>
					</div>
					</td>';
            echo '
				<td style="vertical-align: top; padding: 4px 0 4px 0" class="center">
					<a href="' . $currentIndex . '&id_' . $this->table . '=' . $id . '&update' . $this->table . '&token=' . $this->token . '">
					<img src="../img/admin/edit.gif" border="0" alt="' . $this->l('Edit') . '" title="' . $this->l('Edit') . '" /></a>&nbsp;
					<a href="' . $currentIndex . '&id_' . $this->table . '=' . $id . '&delete' . $this->table . '&token=' . $this->token . '" onclick="return confirm(\'' . $this->l('Delete item', __CLASS__, true, false) . ' : ' . $tr['name'] . '?\');">
					<img src="../img/admin/delete.gif" border="0" alt="' . $this->l('Delete') . '" title="' . $this->l('Delete') . '" /></a>
				</td>
			</tr>';
        }
        $this->displayListFooter();
    }
Exemplo n.º 2
0
 function hookTop($params)
 {
     global $cookie;
     global $smarty;
     /* GETTING ATTRIBUTES */
     if (Configuration::get('ADVSEARCH_ATTRIBUTES') == 1) {
         $attributeGroups = AttributeGroup::getAttributesGroups(intval($cookie->id_lang));
         if (!sizeof($attributeGroups) || $attributeGroups === false) {
             $text = '';
         } else {
             $text = '<h2>' . $this->l('ATTRIBUTES') . '</h2>';
             //.md5('TAGS').'<br>'.md5('categories');
             foreach ($attributeGroups as $group) {
                 $attributes = AttributeGroup::getAttributes(intval($cookie->id_lang), $group['id_attribute_group']);
                 if (!sizeof($attributes) || $attributes === false) {
                     continue;
                 }
                 $text = $text . '<div onclick="showAtrybuty(' . $group['id_attribute_group'] . ');" class="dialogOpcjeTitle">' . $group['public_name'] . '</div>';
                 $text .= '<div id="opcje_' . $group['id_attribute_group'] . '" style="display:none;" class="opcjeItem">';
                 $text .= '<table>';
                 foreach ($attributes as $attribute) {
                     $text = $text . '<tr><td><input name="atrybut_opcja[]" value="' . $attribute['id_attribute'] . '" type="checkbox" class="dialoginput"></td><td>&nbsp;&nbsp;' . trim($attribute['name']) . '</td></tr>';
                 }
                 $text .= '</table></div>';
             }
         }
     } else {
         $text = '';
     }
     /* GETTING ATTRIBUTES */
     /* GETTING CATEGORIES */
     if (Configuration::get('ADVSEARCH_CATEGORIES') == 1) {
         $result = Category::getCategories(intval($cookie->id_lang), true, false);
         $resultParents = array();
         $resultIds = array();
         foreach ($result as $row) {
             ${$row}['name'] = Category::hideCategoryPosition($row['name']);
             $resultParents[$row['id_parent']][] = $row;
             $resultIds[$row['id_category']] = $row;
         }
         $blockCategTree = $this->getTree($resultParents, $resultIds);
         $cats = $this->showCats($blockCategTree['children'], 0);
     } else {
         $cats = '';
     }
     /* GETTING CATEGORIES */
     /* GETTING SUPPLIERS */
     if (Configuration::get('ADVSEARCH_SUPPLIERS') == 1) {
         $sup_sel = Supplier::getSuppliers(false, intval($params['cookie']->id_lang), true);
         if (sizeof($sup_sel) > 0) {
             sort($sup_sel);
             $sup_show = 1;
         } else {
             $sup_show = 0;
         }
         if ($sup_show == 1) {
             $var = array();
             foreach ($sup_sel as $sup) {
                 //$sup['nb_products']=$this->CountSupPro($sup['id_supplier']);
                 $var[] = $sup;
             }
             $sup_sel = $var;
         }
         $supl_display = '<h2>' . $this->l('SUPPLIERS') . '</h2>';
         foreach ($sup_sel as $supply) {
             $supl_display .= '<div class="dialogOpcjeTitle"><input type="checkbox" value="' . $supply['id_supplier'] . '" name="supply[]">&nbsp;&nbsp;' . $supply['name'] . '</div>';
         }
     } else {
         $supl_display = '';
     }
     /* GETTING SUPPLIERS */
     /* GETTING MANUFACTURER */
     if (Configuration::get('ADVSEARCH_MANUFACTURERS') == 1) {
         $man_sel = Manufacturer::getManufacturers(true, intval($params['cookie']->id_lang), true);
         $man_display = '<h2>' . $this->l('MANUFACTURER') . '</h2>';
         foreach ($man_sel as $manuf) {
             if ($manuf['nb_products'] > 0) {
                 $man_display .= '<div class="dialogOpcjeTitle"><input type="checkbox" value="' . $manuf['id_manufacturer'] . '" name="manufacturer[]">&nbsp;&nbsp;' . $manuf['name'] . '</div>';
             }
         }
     } else {
         $man_display = '';
     }
     /* GETTING MANUFACTURER */
     /* GETTING TAG CLOUDS */
     if (Configuration::get('ADVSEARCH_TAGS') == 1) {
         $tag_sel = array();
         $tag_sel = Tag::getMainTags(intval($params['cookie']->id_lang), 500);
         if (sizeof($tag_sel)) {
             sort($tag_sel);
         } else {
             $tag_show = 0;
         }
         $tagi = '<h2>' . $this->l('TAGS') . '</h2><div class="dialogOpcjeTitle">';
         for ($i = 0; $i < sizeof($tag_sel); $i++) {
             $tagi .= '<p id="advSearchTags" onclick="parent.location.href=\'modules/yasearch/results.php?tag=' . urlencode($tag_sel[$i]['name']) . '\'">&nbsp;&nbsp;' . ucfirst($tag_sel[$i]['name']) . '</p>';
         }
         $tagi .= '</div>';
     } else {
         $tagi = '';
     }
     /* GETTING TAG CLOUDS */
     $smarty->assign('tagi', $tagi);
     $smarty->assign('text', $text);
     $smarty->assign('cats', $cats);
     $smarty->assign('sup_sel', $supl_display);
     $smarty->assign('man_sel', $man_display);
     $smarty->assign('ENT_QUOTES', ENT_QUOTES);
     $smarty->assign('base_url', _PS_BASE_URL_ . __PS_BASE_URI__);
     return $this->display(__FILE__, 'yasearch-header.tpl');
 }