/** * Function used to render the list to display for this controller */ public function renderList() { $this->addRowAction('edit'); $this->addRowAction('delete'); $this->_defaultOrderBy = 'position'; $this->bulk_actions = array(); $this->fields_list = array('id_opartslideshow_slideshow_image' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'name' => array('title' => $this->l('Name'), 'width' => 'auto'), 'active' => array('title' => $this->l('Displayed'), 'width' => 'auto', 'type' => 'bool', 'active' => 'status'), 'id_opartslideshow_slideshow' => array('title' => $this->l('Slideshow'), 'width' => 230, 'callback' => 'displaySlideshowName', 'callback_object' => $this, 'type' => 'choice')); if (isset($_GET['id_opartslideshow_slideshow']) && is_numeric($_GET['id_opartslideshow_slideshow'])) { $this->fields_list['position'] = array('title' => $this->l('Position'), 'width' => 40, 'filter_key' => 'a!position', 'align' => 'center', 'position' => 'position'); } $content = $header = $this->context->smarty->fetch(parent::getTemplatePath() . 'header.tpl'); $slides = $this->getSlideshows(); if (count($slides) > 0) { $content .= '<fieldset><legend>' . $this->l('Filter by slideshow') . '</legend>'; $content .= '<div class="help">' . $this->l('Choose a slideshow below to filter images') . '</div><br />'; foreach ($slides as $slide) { $selected = isset($_GET['id_opartslideshow_slideshow']) && $_GET['id_opartslideshow_slideshow'] == (int) $slide['key'] ? 'style="color:red; text-decoration:underline;"' : ''; $href = self::$currentIndex . '&id_opartslideshow_slideshow=' . (int) $slide['key'] . '&token=' . $this->token; $content .= '<a href="' . $href . '" ' . $selected . '>' . $slide['name'] . '</a> | '; } $content .= '<br /><br /><a href="index.php?controller=AdminSlideshowImage&token=' . $this->token . '">[ ' . $this->l('reset filter') . ' ]</a>'; $content .= '</fieldset><br />'; $content .= parent::renderList(); } else { $this->errors[] = Tools::displayError($this->l('You must add one or more slideshow before adding images')); } //parent::initToolbar(); $content .= $this->context->smarty->fetch(parent::getTemplatePath() . 'help.tpl'); return $content; }
public function renderForm() { if (!($obj = $this->loadObject(true))) { return; } $products = Product::getProducts((int) $this->context->language->id, 0, 0, 'id_product', 'ASC'); foreach ($products as $product) { $productList[] = array('key' => $product['id_product'], 'name' => '(' . $product['id_product'] . ') ' . $product['name']); } $categories = Category::getSimpleCategories((int) $this->context->language->id); foreach ($categories as $category) { $categoryList[] = array('key' => $category['id_category'], 'name' => '(' . $category['id_category'] . ') ' . $category['name']); } $cmss = CMS::listCms(); foreach ($cmss as $cms) { $cmsList[] = array('key' => $cms['id_cms'], 'name' => '(' . $cms['id_cms'] . ') ' . $cms['meta_title']); } $this->fields_form = array('tinymce' => true, 'legend' => array('title' => $this->l('Slideshow'), 'image' => '../img/admin/cog.gif'), 'input' => array(array('type' => 'text', 'lang' => true, 'label' => $this->l('Name:'), 'name' => 'name', 'size' => 40), array('type' => 'text', 'label' => $this->l('Width:'), 'name' => 'width', 'size' => 10, 'desc' => $this->l('If you change the width of the it will be necessary to upload images again')), array('type' => 'text', 'label' => $this->l('Height:'), 'name' => 'height', 'size' => 10, 'desc' => $this->l('If you change the height of the it will be necessary to upload images again')), array('type' => 'select', 'label' => $this->l('Effect:'), 'name' => 'effect', 'cast' => 'strval', 'identifier' => 'mode', 'options' => array('query' => array(array('key' => 0, 'name' => $this->l('random')), array('key' => 1, 'name' => $this->l('swirl')), array('key' => 2, 'name' => $this->l('rain')), array('key' => 3, 'name' => $this->l('straight'))), 'name' => 'name', 'id' => 'key')), array('type' => 'text', 'label' => $this->l('Squares per width:'), 'name' => 'spw', 'size' => 10, 'desc' => $this->l('large number can cause transitions problems, Example: 7')), array('type' => 'text', 'label' => $this->l('Squares per height:'), 'name' => 'sph', 'size' => 10, 'desc' => $this->l('large number can cause transitions problems, Example: 5')), array('type' => 'text', 'label' => $this->l('Delay:'), 'name' => 'delay', 'size' => 10, 'desc' => $this->l('delay between images in ms, Example: 3000')), array('type' => 'text', 'label' => $this->l('Square delay:'), 'name' => 'sDelay', 'size' => 10, 'desc' => $this->l('delay beetwen squares in ms. Example: 30')), array('type' => 'text', 'label' => $this->l('Opacity:'), 'name' => 'opacity', 'size' => 10, 'desc' => $this->l('opacity of title and navigation. Example: 0.7')), array('type' => 'text', 'label' => $this->l('Title speed:'), 'name' => 'titleSpeed', 'size' => 10, 'desc' => $this->l('speed of title appereance in ms. Example: 500')), array('type' => 'select', 'label' => $this->l('Navigation:'), 'name' => 'navigation', 'cast' => 'strval', 'identifier' => 'mode', 'options' => array('query' => array(array('key' => 0, 'name' => $this->l('no')), array('key' => 1, 'name' => $this->l('yes'))), 'name' => 'name', 'id' => 'key')), array('type' => 'select', 'label' => $this->l('Links:'), 'name' => 'links', 'desc' => $this->l('Enable links.'), 'cast' => 'strval', 'identifier' => 'mode', 'options' => array('query' => array(array('key' => 0, 'name' => $this->l('no')), array('key' => 1, 'name' => $this->l('yes'))), 'name' => 'name', 'id' => 'key')), array('type' => 'select', 'label' => $this->l('Hover pause:'), 'name' => 'hoverpause', 'desc' => $this->l('pause on hover.'), 'cast' => 'strval', 'identifier' => 'mode', 'options' => array('query' => array(array('key' => 0, 'name' => $this->l('no')), array('key' => 1, 'name' => $this->l('yes'))), 'name' => 'name', 'id' => 'key')), array('type' => 'select', 'label' => $this->l('Show on home:'), 'name' => 'home', 'cast' => 'strval', 'identifier' => 'mode', 'options' => array('query' => array(array('key' => 0, 'name' => $this->l('no')), array('key' => 1, 'name' => $this->l('yes'))), 'name' => 'name', 'id' => 'key')), array('type' => 'select', 'label' => $this->l('Show on all category:'), 'name' => 'showOnCat', 'cast' => 'strval', 'identifier' => 'mode', 'options' => array('query' => array(array('key' => 0, 'name' => $this->l('no')), array('key' => 1, 'name' => $this->l('yes'))), 'name' => 'name', 'id' => 'key')), array('type' => 'select', 'label' => $this->l('Categories:'), 'name' => 'categories[]', 'id' => 'categories', 'options' => array('query' => $categoryList, 'name' => 'name', 'id' => 'key'), 'multiple' => true, 'desc' => $this->l('Choose one or several category s page where the slideshow will be displayed.')), array('type' => 'select', 'label' => $this->l('Show on all product:'), 'name' => 'showOnProd', 'cast' => 'strval', 'identifier' => 'mode', 'options' => array('query' => array(array('key' => 0, 'name' => $this->l('no')), array('key' => 1, 'name' => $this->l('yes'))), 'name' => 'name', 'id' => 'key')), array('type' => 'select', 'label' => $this->l('Products:'), 'name' => 'products[]', 'id' => 'products', 'options' => array('query' => $productList, 'name' => 'name', 'id' => 'key'), 'multiple' => true, 'desc' => $this->l('Choose one or several product s page where the slideshow will be displayed.')), array('type' => 'select', 'label' => $this->l('Show on all cms page:'), 'name' => 'showOnCms', 'cast' => 'strval', 'identifier' => 'mode', 'options' => array('query' => array(array('key' => 0, 'name' => $this->l('no')), array('key' => 1, 'name' => $this->l('yes'))), 'name' => 'name', 'id' => 'key')), array('type' => 'select', 'label' => $this->l('Cms:'), 'name' => 'cms[]', 'id' => 'cms', 'options' => array('query' => $cmsList, 'name' => 'name', 'id' => 'key'), 'multiple' => true, 'desc' => $this->l('Choose one or several cms s page where the slideshow will be displayed.')), array('type' => 'select', 'label' => $this->l('Hook:'), 'name' => 'hook', 'cast' => 'strval', 'identifier' => 'mode', 'options' => array('query' => array(array('name' => 'displayTop'), array('name' => 'displayHome'), array('name' => 'displayLeftColumn'), array('name' => 'displayRightColumn'), array('name' => 'displayOpartSlideshowHook')), 'name' => 'name', 'id' => 'name'), 'desc' => $this->l('You must hook the module for display your slideshow on each position. Go to modules/positions menu for setup this')), array('type' => 'select', 'label' => $this->l('Statut:'), 'name' => 'active', 'cast' => 'strval', 'identifier' => 'mode', 'options' => array('query' => array(array('key' => 0, 'name' => $this->l('disable')), array('key' => 1, 'name' => $this->l('enable'))), 'name' => 'name', 'id' => 'key'))), 'submit' => array('title' => $this->l('Save'), 'class' => 'button')); if (is_numeric($obj->id)) { //products value $sql = 'SELECT id_product FROM ' . _DB_PREFIX_ . 'opartslideshow_slideshow_product WHERE id_opartslideshow_slideshow = ' . $obj->id; $array = Db::getInstance()->executeS($sql); if (count($array)) { foreach ($array as $row) { $productValues[] = $row['id_product']; } $this->fields_value['products[]'] = $productValues; } //categories value $sql = 'SELECT id_category FROM ' . _DB_PREFIX_ . 'opartslideshow_slideshow_category WHERE id_opartslideshow_slideshow = ' . $obj->id; $array = Db::getInstance()->executeS($sql); if (count($array)) { foreach ($array as $row) { $categoriesValues[] = $row['id_category']; } $this->fields_value['categories[]'] = $categoriesValues; } //cms value $sql = 'SELECT id_cms FROM ' . _DB_PREFIX_ . 'opartslideshow_slideshow_cms WHERE id_opartslideshow_slideshow = ' . $obj->id; $array = Db::getInstance()->executeS($sql); if (count($array)) { foreach ($array as $row) { $cmsValues[] = $row['id_cms']; } $this->fields_value['cms[]'] = $cmsValues; } } $html = $header = $this->context->smarty->fetch(parent::getTemplatePath() . 'header.tpl'); $html .= parent::renderForm(); return $html; }