* @copyright 2007-2014 PrestaShop SA * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ require_once _PS_MODULE_DIR_.'/stblogarchives/classes/StBlogArchivesClass.php'; require_once _PS_MODULE_DIR_.'/stblog/classes/StBlogLoader.php'; include_once _PS_MODULE_DIR_.'/stblog/classes/controller/FrontController.php'; StBlogLoader::load(array('class','ImageClass')); include_once(dirname(__FILE__).'/../../stblogarchives.php'); class StblogArchivesDefaultModuleFrontController extends StblogModuleFrontController { public $nbr_blogs; public $year; public $month; public function initContent() { if (!($m = Tools::getValue('m'))) Tools::redirect('index.php?controller=404'); if(!$this->errors) { $year = substr($m, 0, 4); $month = substr($m, 4, 2); // For RTL time transform. $month2 = $month ? $month : '06'; // Special for Spanish. $date_format = strtolower(Context::getContext()->language->date_format_lite); if (in_array($date_format, array('d/m/y','d-m-y'))) { $date2 = $year.'-'.$month2.'-15'; } else { $date2 = Tools::dateFormat(array('date'=>$year.'-'.$month2.'-15', 'full'=>0), Context::getContext()->smarty); } list($year, $month2) = explode('-', date('Y-F', strtotime($date2))); if (strlen($year) == 4 && strlen($month) == 2) $date = $month2.', '.$year; elseif(strlen($year) == 4) { $date = $year; $month = null; } else { $date = $this->trans('Unknown', array(), 'Shop.Theme.Panda'); $year = $month = null; } $this->year = $year; $this->month = $month; $heading = $this->trans('Archive for', array(), 'Shop.Theme.Panda').' '.$date.' - '; parent::initContent(); $archive = new StBlogArchivesClass(); $this->nbr_blogs = $archive->getBlogs($m, null, null, null, null, null, true); $blogs = $archive->getBlogs($m, $this->context->language->id, (int)$this->page, (int)$this->resultsPerPage); $this->context->smarty->assign(array( 'heading' => $date, 'blogs' => $blogs, 'nbr_blogs' => $this->nbr_blogs, 'pagination' => $this->getTemplateVarPagination($this->nbr_blogs), 'meta_title' => $heading . Configuration::get('ST_BLOG_META_TITLE', $this->context->language->id), 'meta_description' => $heading . Configuration::get('ST_BLOG_META_KEYWORDS', $this->context->language->id), 'meta_keywords' => $heading . Configuration::get('ST_BLOG_META_DESCRIPTION', $this->context->language->id), 'category_layouts' => Configuration::get('ST_BLOG_CATE_LAYOUTS'), 'pro_per_fw' => Configuration::get('STSN_BLOG_PRO_PER_GRID_FW'), 'pro_per_xxl' => Configuration::get('STSN_BLOG_PRO_PER_GRID_XXL'), 'pro_per_xl' => Configuration::get('STSN_BLOG_PRO_PER_GRID_XL'), 'pro_per_lg' => Configuration::get('STSN_BLOG_PRO_PER_GRID_LG'), 'pro_per_md' => Configuration::get('STSN_BLOG_PRO_PER_GRID_MD'), 'pro_per_sm' => Configuration::get('STSN_BLOG_PRO_PER_GRID_SM'), 'pro_per_xs' => Configuration::get('STSN_BLOG_PRO_PER_GRID_XS'), )); } $this->context->smarty->assign('errors', $this->errors); $this->setTemplate('module:stblogarchives/views/templates/front/default.tpl'); } public function getBreadcrumbLinks() { $breadcrumb = parent::getBreadcrumbLinks(); $breadcrumb['links'][] = array( 'title' => $this->trans('Blog', array(), 'Shop.Theme.Panda'), 'url' => $this->context->link->getModuleLink('stblog', 'default'), ); $breadcrumb['links'][] = array( 'title' => $this->year.($this->month ? $this->month : ''), 'url' => $this->context->link->getModuleLink('stblogarchives', 'default', array('m'=>$this->year.($this->month ? $this->month : ''))), ); return $breadcrumb; } public function getCanonicalURL() { return $this->context->link->getModuleLink('stblogarchives', 'default', array('m'=>$this->year.($this->month ? $this->month : ''))); } }