* @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 6594 $ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ if (!defined('_CAN_LOAD_FILES_')) exit; define('BLOCKTAGS_MAX_LEVEL', 3); class BlockTags extends Module { function __construct() { $this->name = 'blocktags'; $this->tab = 'front_office_features'; $this->version = 1.0; $this->author = 'PrestaShop'; $this->need_instance = 0; parent::__construct(); $this->displayName = $this->l('Tags block'); $this->description = $this->l('Adds a block containing a tag cloud.'); } function install() { if (parent::install() == false OR $this->registerHook('leftColumn') == false OR $this->registerHook('header') == false OR Configuration::updateValue('BLOCKTAGS_NBR', 10) == false) return false; return true; } public function getContent() { $output = '

'.$this->displayName.'

'; if (Tools::isSubmit('submitBlockTags')) { if (!$tagsNbr = Tools::getValue('tagsNbr') OR empty($tagsNbr)) $output .= '
'.$this->l('Please fill in the "tags displayed" field.').'
'; elseif ((int)($tagsNbr) == 0) $output .= '
'.$this->l('Invalid number.').'
'; else { Configuration::updateValue('BLOCKTAGS_NBR', (int)($tagsNbr)); $output .= '
'.$this->l('Confirmation').''.$this->l('Settings updated').'
'; } } return $output.$this->displayForm(); } public function displayForm() { $output = '
'.$this->l('Settings').'

'.$this->l('Set the number of tags to be displayed in this block').'

'; return $output; } /** * Returns module content for left column * * @param array $params Parameters * @return string Content * * @todo Links on tags (dedicated page or search ?) */ function hookLeftColumn($params) { global $smarty; $tags = Tag::getMainTags((int)($params['cookie']->id_lang), (int)(Configuration::get('BLOCKTAGS_NBR'))); if (!sizeof($tags)) return false; foreach ($tags AS &$tag) $tag['class'] = 'tag_level'.($tag['times'] > BLOCKTAGS_MAX_LEVEL ? BLOCKTAGS_MAX_LEVEL : $tag['times']); $smarty->assign('tags', $tags); return $this->display(__FILE__, 'blocktags.tpl'); } function hookRightColumn($params) { return $this->hookLeftColumn($params); } function hookHeader($params) { Tools::addCSS(($this->_path).'blocktags.css', 'all'); } }