Example #1
0
 public function install()
 {
     if (!parent::install() || !$this->registerHooks() || !BlockCMSModel::createTables() || !Configuration::updateValue('FOOTER_CMS', '') || !Configuration::updateValue('FOOTER_BLOCK_ACTIVATION', 1) || !Configuration::updateValue('FOOTER_POWEREDBY', 1)) {
         return false;
     }
     // Install fixtures for blockcms
     $default = Db::getInstance()->insert('cms_block', array('id_cms_category' => 1, 'location' => 0, 'position' => 0));
     if (!$default) {
         return false;
     }
     $result = true;
     $id_cms_block = Db::getInstance()->Insert_ID();
     $shops = Shop::getShops(true, null, true);
     foreach ($shops as $shop) {
         $result &= Db::getInstance()->insert('cms_block_shop', array('id_cms_block' => $id_cms_block, 'id_shop' => $shop));
     }
     $languages = Language::getLanguages(false);
     foreach ($languages as $lang) {
         $result &= Db::getInstance()->insert('cms_block_lang', array('id_cms_block' => $id_cms_block, 'id_lang' => $lang['id_lang'], 'name' => $this->l('Information')));
     }
     $pages = CMS::getCMSPages(null, 1);
     foreach ($pages as $cms) {
         $result &= Db::getInstance()->insert('cms_block_page', array('id_cms_block' => $id_cms_block, 'id_cms' => $cms['id_cms'], 'is_category' => 0));
     }
     return $result;
 }
Example #2
0
 public function install()
 {
     if (!parent::install() || !$this->registerHook('leftColumn') || !$this->registerHook('rightColumn') || !$this->registerHook('header') || !$this->registerHook('footer') || !$this->registerHook('actionObjectCmsUpdateAfter') || !$this->registerHook('actionObjectCmsDeleteAfter') || !$this->registerHook('actionShopDataDuplication') || !$this->registerHook('actionAdminStoresControllerUpdate_optionsAfter') || !BlockCMSModel::createTables() || !Configuration::updateValue('FOOTER_CMS', '') || !Configuration::updateValue('FOOTER_BLOCK_ACTIVATION', 1) || !Configuration::updateValue('FOOTER_POWEREDBY', 1) || !Configuration::updateValue('FOOTER_PRICE-DROP', 1) || !Configuration::updateValue('FOOTER_NEW-PRODUCTS', 1) || !Configuration::updateValue('FOOTER_BEST-SALES', 1) || !Configuration::updateValue('FOOTER_CONTACT', 1) || !Configuration::updateValue('FOOTER_SITEMAP', 1)) {
         return false;
     }
     $this->_clearCache('blockcms.tpl');
     // Install fixtures for blockcms
     $default = Db::getInstance()->insert('cms_block', array('id_cms_category' => 1, 'location' => 0, 'position' => 0));
     if (!$default) {
         return false;
     }
     $result = true;
     $id_cms_block = Db::getInstance()->Insert_ID();
     $shops = Shop::getShops(true, null, true);
     foreach ($shops as $shop) {
         $result &= Db::getInstance()->insert('cms_block_shop', array('id_cms_block' => $id_cms_block, 'id_shop' => $shop));
     }
     $languages = Language::getLanguages(false);
     foreach ($languages as $lang) {
         $result &= Db::getInstance()->insert('cms_block_lang', array('id_cms_block' => $id_cms_block, 'id_lang' => $lang['id_lang'], 'name' => $this->l('Information')));
     }
     $pages = CMS::getCMSPages(null, 1);
     foreach ($pages as $cms) {
         $result &= Db::getInstance()->insert('cms_block_page', array('id_cms_block' => $id_cms_block, 'id_cms' => $cms['id_cms'], 'is_category' => 0));
     }
     return $result;
 }
 public function renderForm()
 {
     $fields_form = array('form' => array('legend' => array('title' => $this->l('Homepage categories'), 'icon' => ''), 'input' => array(array('type' => 'cms_choice', 'label' => '', 'name' => 'cats')), 'submit' => array('name' => 'submitBlockshortcms', 'title' => $this->l('Save'))));
     $lang = $this->context->language;
     if ($selectedItems = Configuration::get('MOD_BLOCKHOMECMS_ITEMS')) {
         $selectedItems = explode(',', $selectedItems);
         foreach ($selectedItems as $index => $id_cms) {
             $selectedItems[$index] = new CMS($id_cms, $this->context->language->id);
         }
     } else {
         $selectedItems = null;
     }
     $helper = new HelperForm();
     $helper->show_toolbar = false;
     $helper->default_form_language = $lang->id;
     $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
     $helper->module = $this;
     $helper->identifier = 'id_blocklink';
     $helper->submit_action = 'submit';
     $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false) . '&configure=' . $this->name . '&tab_module=' . $this->tab . '&module_name=' . $this->name;
     $helper->token = Tools::getAdminTokenLite('AdminModules');
     $helper->fields_value = array('text' => 'text');
     $categories = current(CMSCategory::getCategories($this->context->language->id));
     $allCms = CMS::getCMSPages($this->context->language->id);
     $helper->tpl_vars = array('categories' => current(CMSCategory::getCategories($this->context->language->id)), 'allCms' => CMS::getCMSPages($this->context->language->id), 'selectedCms' => $selectedItems);
     return $helper->generateForm(array($fields_form));
 }
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     $parent_cat = new CMSCategory(1, $this->context->language->id);
     $this->context->smarty->assign('id_current_lang', $this->context->language->id);
     $this->context->smarty->assign('home_title', $parent_cat->name);
     $this->context->smarty->assign('cgv_id', Configuration::get('PS_CONDITIONS_CMS_ID'));
     if (isset($this->cms->id_cms_category) && $this->cms->id_cms_category) {
         $path = Tools::getFullPath($this->cms->id_cms_category, $this->cms->meta_title, 'CMS');
     } elseif (isset($this->cms_category->meta_title)) {
         $path = Tools::getFullPath(1, $this->cms_category->meta_title, 'CMS');
     }
     if ($this->assignCase == 1) {
         $this->context->smarty->assign(array('cms' => $this->cms, 'content_only' => (int) Tools::getValue('content_only'), 'path' => $path, 'body_classes' => array($this->php_self . '-' . $this->cms->id, $this->php_self . '-' . $this->cms->link_rewrite)));
         if ($this->cms->indexation == 0) {
             $this->context->smarty->assign('nobots', true);
         }
     } elseif ($this->assignCase == 2) {
         $this->context->smarty->assign(array('category' => $this->cms_category, 'cms_category' => $this->cms_category, 'sub_category' => $this->cms_category->getSubCategories($this->context->language->id), 'cms_pages' => CMS::getCMSPages($this->context->language->id, (int) $this->cms_category->id, true, (int) $this->context->shop->id), 'path' => $this->cms_category->id !== 1 ? Tools::getPath($this->cms_category->id, $this->cms_category->name, false, 'CMS') : '', 'body_classes' => array($this->php_self . '-' . $this->cms_category->id, $this->php_self . '-' . $this->cms_category->link_rewrite)));
     }
     $this->setTemplate(_PS_THEME_DIR_ . 'cms.tpl');
 }
Example #5
0
 public static function list_pages()
 {
     $context = Context::getContext();
     $table = new Cli\Table();
     $table->setHeaders(array('id', 'category', 'position', 'active', 'indexation', 'lang', 'title', 'rewrite', 'keywords'));
     //$pages = CMS::listCms($context->language->id);
     $pages = CMS::getCMSPages($context->language->id, null, false);
     foreach ($pages as $page) {
         $table->addRow(array($page['id_cms'], $page['id_cms_category'], $page['position'], $page['active'], $page['indexation'], Language::getIsoById($page['id_lang']), $page['meta_title'], $page['link_rewrite'], $page['meta_keywords']));
     }
     $table->display();
     return true;
 }
 protected function generateCMSPageData()
 {
     $delimiter = ';';
     $line = array();
     $titles = array();
     $new_path = new Sampledatainstall();
     $id_lang = $this->use_lang;
     $f = fopen($new_path->sendPath() . 'output/cms_pages.vsc', 'w');
     foreach ($this->cms_pages_fields as $field => $array) {
         $titles[] = $array['label'];
     }
     fputcsv($f, $titles, $delimiter, '"');
     $cms_pages = CMS::getCMSPages($id_lang);
     foreach ($cms_pages as $cms_page) {
         $cms_p = new CMS($cms_page['id_cms'], $id_lang);
         foreach ($this->cms_pages_fields as $field => $array) {
             $line[$field] = property_exists('CMS', $field) && !is_array($cms_p->{$field}) && !Tools::isEmpty($cms_p->{$field}) ? $cms_p->{$field} : '';
         }
         if (!$line[$field]) {
             $line[$field] = '';
         }
         fputcsv($f, $line, $delimiter, '"');
     }
     fclose($f);
 }
 public function process()
 {
     parent::process();
     $parent_cat = new CMSCategory(1, (int) self::$cookie->id_lang);
     self::$smarty->assign('id_current_lang', self::$cookie->id_lang);
     self::$smarty->assign('home_title', $parent_cat->name);
     self::$smarty->assign('cgv_id', Configuration::get('PS_CONDITIONS_CMS_ID'));
     if ($this->assignCase == 1) {
         self::$smarty->assign(array('cms' => $this->cms, 'content_only' => (int) Tools::getValue('content_only'), 'path' => (isset($this->cms->id_cms_category) and $this->cms->id_cms_category) ? Tools::getFullPath((int) $this->cms->id_cms_category, $this->cms->meta_title, 'CMS') : Tools::getFullPath(1, $this->cms->meta_title, 'CMS')));
     } elseif ($this->assignCase == 2) {
         self::$smarty->assign(array('category' => $this->cms_category, 'sub_category' => $this->cms_category->getSubCategories((int) self::$cookie->id_lang), 'cms_pages' => CMS::getCMSPages((int) self::$cookie->id_lang, (int) $this->cms_category->id), 'path' => $this->cms_category->id !== 1 ? Tools::getPath((int) $this->cms_category->id, $this->cms_category->name, false, 'CMS') : ''));
     }
 }
Example #8
0
 private function getCMSPages()
 {
     if (empty(self::$_cms_pages)) {
         $result = CMS::getCMSPages($this->default_language_id, null, false);
         self::$_cms_pages[] = array('id_cms' => 0, 'name' => $this->l('-- Please select a CMS page --'));
         foreach ($result as $key => $row) {
             self::$_cms_pages[] = array('id_cms' => $row['id_cms'], 'name' => $row['meta_title']);
         }
     }
     return self::$_cms_pages;
 }
Example #9
0
 public function getTemplateVarCategoryCms()
 {
     $categoryCms = array();
     $categoryCms['cms_category'] = $this->objectPresenter->present($this->cms_category);
     $categoryCms['sub_categories'] = array();
     $categoryCms['cms_pages'] = array();
     foreach ($this->cms_category->getSubCategories($this->context->language->id) as $subCategory) {
         $categoryCms['sub_categories'][$subCategory['id_cms_category']] = $subCategory;
         $categoryCms['sub_categories'][$subCategory['id_cms_category']]['link'] = $this->context->link->getCMSCategoryLink($subCategory['id_cms_category'], $subCategory['link_rewrite']);
     }
     foreach (CMS::getCMSPages($this->context->language->id, (int) $this->cms_category->id, true, (int) $this->context->shop->id) as $cmsPages) {
         $categoryCms['cms_pages'][$cmsPages['id_cms']] = $cmsPages;
         $categoryCms['cms_pages'][$cmsPages['id_cms']]['link'] = $this->context->link->getCMSLink($cmsPages['id_cms'], $cmsPages['link_rewrite']);
     }
     return $categoryCms;
 }