first commit
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
|
||||
class AdminBlogForPrestaShopController extends ModuleAdminController
|
||||
{}
|
||||
@@ -0,0 +1,221 @@
|
||||
<?php
|
||||
/**
|
||||
* Blog for PrestaShop module by Krystian Podemski from PrestaHome.
|
||||
*
|
||||
* @author Krystian Podemski <krystian@prestahome.com>
|
||||
* @copyright Copyright (c) 2008-2019 Krystian Podemski - www.PrestaHome.com / www.Podemski.info
|
||||
* @license You only can use module, nothing more!
|
||||
*/
|
||||
require_once _PS_MODULE_DIR_ . 'ph_simpleblog/ph_simpleblog.php';
|
||||
|
||||
class AdminSimpleBlogAuthorsController extends ModuleAdminController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->errors[] = 'Coming SOON';
|
||||
return parent::__construct();
|
||||
|
||||
$this->table = 'simpleblog_author';
|
||||
$this->className = 'SimpleBlogPostAuthor';
|
||||
$this->lang = true;
|
||||
|
||||
$this->addRowAction('edit');
|
||||
$this->addRowAction('delete');
|
||||
|
||||
$this->bootstrap = true;
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
|
||||
|
||||
$this->_select = 'IFNULL(sbp.posts, 0) as number_of_posts';
|
||||
$this->_join = 'LEFT JOIN (SELECT id_simpleblog_author, COUNT(*) as posts FROM '._DB_PREFIX_.'simpleblog_post GROUP BY id_simpleblog_author) sbp ON a.id_simpleblog_author = sbp.id_simpleblog_author';
|
||||
|
||||
$this->fields_list = array(
|
||||
'id_simpleblog_author' => array(
|
||||
'title' => $this->l('ID'),
|
||||
'align' => 'center',
|
||||
'width' => 30
|
||||
),
|
||||
'firstname' => array(
|
||||
'title' => $this->l('Firstname'),
|
||||
'width' => 'auto'
|
||||
),
|
||||
'lastname' => array(
|
||||
'title' => $this->l('Lastname'),
|
||||
'width' => 'auto'
|
||||
),
|
||||
'email' => array(
|
||||
'title' => $this->l('E-mail'),
|
||||
'width' => 'auto'
|
||||
),
|
||||
'number_of_posts' => array(
|
||||
'title' => $this->l('Posts'),
|
||||
'width' => 'auto'
|
||||
),
|
||||
'active' => array(
|
||||
'title' => $this->l('Active'),
|
||||
'width' => 25,
|
||||
'active' => 'status',
|
||||
'align' => 'center',
|
||||
'type' => 'bool',
|
||||
'orderby' => false
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function initFormToolBar()
|
||||
{
|
||||
unset($this->toolbar_btn['back']);
|
||||
$this->toolbar_btn['save-and-stay'] = array(
|
||||
'short' => 'SaveAndStay',
|
||||
'href' => '#',
|
||||
'desc' => $this->l('Save and stay'),
|
||||
);
|
||||
$this->toolbar_btn['back'] = array(
|
||||
'href' => self::$currentIndex.'&token='.Tools::getValue('token'),
|
||||
'desc' => $this->l('Back to list'),
|
||||
);
|
||||
}
|
||||
|
||||
public function renderForm()
|
||||
{
|
||||
$this->initFormToolBar();
|
||||
if (!$this->loadObject(true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
|
||||
$this->fields_form = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('Author'),
|
||||
),
|
||||
'input' => array(
|
||||
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Firstname:'),
|
||||
'name' => 'firstname',
|
||||
'lang' => false,
|
||||
),
|
||||
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Lastname:'),
|
||||
'name' => 'lastname',
|
||||
'lang' => false,
|
||||
),
|
||||
|
||||
array(
|
||||
'type' => 'select_image',
|
||||
'label' => $this->l('Photo:'),
|
||||
'name' => 'photo',
|
||||
'lang' => false,
|
||||
),
|
||||
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'label' => $this->l('Bio:'),
|
||||
'name' => 'bio',
|
||||
'lang' => true,
|
||||
'rows' => 5,
|
||||
'cols' => 40,
|
||||
'autoload_rte' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'label' => $this->l('Additional info:'),
|
||||
'name' => 'additional_info',
|
||||
'lang' => true,
|
||||
'rows' => 5,
|
||||
'cols' => 40,
|
||||
'autoload_rte' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('E-mail:'),
|
||||
'name' => 'email',
|
||||
'lang' => false,
|
||||
),
|
||||
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Phone:'),
|
||||
'name' => 'phone',
|
||||
'lang' => false,
|
||||
),
|
||||
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Facebook:'),
|
||||
'name' => 'facebook',
|
||||
'lang' => false,
|
||||
),
|
||||
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Instagram:'),
|
||||
'name' => 'instagram',
|
||||
'lang' => false,
|
||||
),
|
||||
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Twitter:'),
|
||||
'name' => 'twitter',
|
||||
'lang' => false,
|
||||
),
|
||||
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Google:'),
|
||||
'name' => 'google',
|
||||
'lang' => false,
|
||||
),
|
||||
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('LinkedIn:'),
|
||||
'name' => 'linkedin',
|
||||
'lang' => false,
|
||||
),
|
||||
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('WWW:'),
|
||||
'name' => 'www',
|
||||
'lang' => false,
|
||||
),
|
||||
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Active'),
|
||||
'name' => 'active',
|
||||
'required' => false,
|
||||
'is_bool' => true,
|
||||
'values' => array(
|
||||
array(
|
||||
'id' => 'active_on',
|
||||
'value' => 1,
|
||||
'label' => $this->l('Enabled')
|
||||
),
|
||||
array(
|
||||
'id' => 'active_off',
|
||||
'value' => 0,
|
||||
'label' => $this->l('Disabled')
|
||||
)
|
||||
)
|
||||
),
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
)
|
||||
);
|
||||
|
||||
return parent::renderForm();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,506 @@
|
||||
<?php
|
||||
/**
|
||||
* Blog for PrestaShop module by Krystian Podemski from PrestaHome.
|
||||
*
|
||||
* @author Krystian Podemski <krystian@prestahome.com>
|
||||
* @copyright Copyright (c) 2014-2016 Krystian Podemski - www.PrestaHome.com / www.Podemski.info
|
||||
* @license You only can use module, nothing more!
|
||||
*/
|
||||
require_once _PS_MODULE_DIR_ . 'ph_simpleblog/ph_simpleblog.php';
|
||||
|
||||
class AdminSimpleBlogCategoriesController extends ModuleAdminController
|
||||
{
|
||||
|
||||
protected $position_identifier = 'id_simpleblog_category';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this->table = 'simpleblog_category';
|
||||
$this->className = 'SimpleBlogCategory';
|
||||
$this->lang = true;
|
||||
$this->addRowAction('view');
|
||||
$this->addRowAction('edit');
|
||||
$this->addRowAction('delete');
|
||||
|
||||
$this->bootstrap = true;
|
||||
|
||||
$this->_where = 'AND a.`id_parent` = 0';
|
||||
$this->_orderBy = 'position';
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
|
||||
|
||||
$this->fields_list = array(
|
||||
'id_simpleblog_category' => array(
|
||||
'title' => $this->l('ID'),
|
||||
'align' => 'center',
|
||||
'width' => 30
|
||||
),
|
||||
'name' => array(
|
||||
'title' => $this->l('Name'),
|
||||
'width' => 'auto'
|
||||
),
|
||||
'description' => array(
|
||||
'title' => $this->l('Description'),
|
||||
'width' => 500,
|
||||
'orderby' => false,
|
||||
'callback' => 'getDescriptionClean'
|
||||
),
|
||||
'active' => array(
|
||||
'title' => $this->l('Displayed'),
|
||||
'width' => 25,
|
||||
'active' => 'status',
|
||||
'align' => 'center',
|
||||
'type' => 'bool',
|
||||
'orderby' => false
|
||||
),
|
||||
'position' => array(
|
||||
'title' => $this->l('Position'),
|
||||
'width' => 40,
|
||||
'filter_key' => 'a!position',
|
||||
'position' => 'position'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function renderList()
|
||||
{
|
||||
$this->initToolbar();
|
||||
$this->addRowAction('details');
|
||||
return parent::renderList();
|
||||
}
|
||||
|
||||
public function getDescriptionClean($description, $row)
|
||||
{
|
||||
return strip_tags(stripslashes($description));
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
Shop::addTableAssociation($this->table, array('type' => 'shop'));
|
||||
|
||||
if (Shop::getContext() == Shop::CONTEXT_SHOP) {
|
||||
$this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'simpleblog_category_shop` sa ON (a.`id_simpleblog_category` = sa.`id_simpleblog_category` AND sa.id_shop = '.(int)$this->context->shop->id.') ';
|
||||
}
|
||||
// else
|
||||
// $this->_join .= ' LEFT JOIN `'._DB_PREFIX_.'simpleblog_category_shop` sa ON (a.`simpleblog_category` = sa.`simpleblog_category` AND sa.id_shop = a.id_shop_default) ';
|
||||
|
||||
if (Shop::getContext() == Shop::CONTEXT_SHOP && Shop::isFeatureActive()) {
|
||||
$this->_where = ' AND sa.`id_shop` = '.(int)Context::getContext()->shop->id;
|
||||
}
|
||||
|
||||
if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_SHOP) {
|
||||
unset($this->fields_list['position']);
|
||||
}
|
||||
}
|
||||
|
||||
public function initFormToolBar()
|
||||
{
|
||||
unset($this->toolbar_btn['back']);
|
||||
$this->toolbar_btn['save-and-stay'] = array(
|
||||
'short' => 'SaveAndStay',
|
||||
'href' => '#',
|
||||
'desc' => $this->l('Save and stay'),
|
||||
);
|
||||
$this->toolbar_btn['back'] = array(
|
||||
'href' => self::$currentIndex.'&token='.Tools::getValue('token'),
|
||||
'desc' => $this->l('Back to list'),
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function renderForm()
|
||||
{
|
||||
$this->initFormToolBar();
|
||||
if (!$this->loadObject(true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$cover = false;
|
||||
|
||||
$obj = $this->loadObject(true);
|
||||
|
||||
if (isset($obj->id)) {
|
||||
$this->display = 'edit';
|
||||
|
||||
$cover = ImageManager::thumbnail(_PS_MODULE_DIR_ . 'ph_simpleblog/covers_cat/'.$obj->id.'.'.$obj->cover, 'ph_simpleblog_cat_'.$obj->id.'.'.$obj->cover, 350, $obj->cover, false);
|
||||
} else {
|
||||
$this->display = 'add';
|
||||
}
|
||||
|
||||
$this->fields_value = array(
|
||||
'cover' => $cover ? $cover : false,
|
||||
'cover_size' => $cover ? filesize(_PS_MODULE_DIR_ . 'ph_simpleblog/covers_cat/'.$obj->id.'.'.$obj->cover) / 1000 : false,
|
||||
);
|
||||
|
||||
$categories = SimpleBlogCategory::getCategories($this->context->language->id, true, true);
|
||||
|
||||
array_unshift($categories, array('id' => 0, 'name' => $this->l('No parent')));
|
||||
|
||||
foreach ($categories as $key => $category) {
|
||||
if (isset($obj->id) && $obj->id) {
|
||||
if ($category['id'] == $obj->id_simpleblog_category) {
|
||||
unset($category[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->fields_form = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('Category'),
|
||||
'image' => '../img/admin/tab-categories.gif'
|
||||
),
|
||||
'input' => array(
|
||||
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Parent Category:'),
|
||||
'name' => 'id_parent',
|
||||
'required' => true,
|
||||
'options' => array(
|
||||
'id' => 'id',
|
||||
'query' => $categories,
|
||||
'name' => 'name'
|
||||
)
|
||||
),
|
||||
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Name:'),
|
||||
'name' => 'name',
|
||||
'required' => true,
|
||||
'lang' => true,
|
||||
'class' => 'copy2friendlyUrl',
|
||||
),
|
||||
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'label' => $this->l('Description:'),
|
||||
'name' => 'description',
|
||||
'lang' => true,
|
||||
'rows' => 5,
|
||||
'cols' => 40,
|
||||
'autoload_rte' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Meta title:'),
|
||||
'name' => 'meta_title',
|
||||
'lang' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Meta description:'),
|
||||
'name' => 'meta_description',
|
||||
'lang' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Meta keywords:'),
|
||||
'name' => 'meta_keywords',
|
||||
'lang' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Friendly URL:'),
|
||||
'name' => 'link_rewrite',
|
||||
'required' => true,
|
||||
'lang' => true,
|
||||
),
|
||||
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Displayed'),
|
||||
'name' => 'active',
|
||||
'required' => false,
|
||||
'is_bool' => true,
|
||||
'values' => array(
|
||||
array(
|
||||
'id' => 'active_on',
|
||||
'value' => 1,
|
||||
'label' => $this->l('Enabled')
|
||||
),
|
||||
array(
|
||||
'id' => 'active_off',
|
||||
'value' => 0,
|
||||
'label' => $this->l('Disabled')
|
||||
)
|
||||
)
|
||||
),
|
||||
|
||||
array(
|
||||
'type' => 'file',
|
||||
'label' => $this->l('Category image:'),
|
||||
'display_image' => true,
|
||||
'name' => 'cover',
|
||||
'desc' => $this->l('Upload a image from your computer.')
|
||||
),
|
||||
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
)
|
||||
);
|
||||
|
||||
if (Shop::isFeatureActive()) {
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'shop',
|
||||
'label' => $this->l('Shop association:'),
|
||||
'name' => 'checkBoxShopAsso',
|
||||
);
|
||||
}
|
||||
|
||||
$this->tpl_form_vars['PS_ALLOW_ACCENTED_CHARS_URL'] = (int)Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL');
|
||||
$this->tpl_form_vars['PS_FORCE_FRIENDLY_PRODUCT'] = (int)Configuration::get('PS_FORCE_FRIENDLY_PRODUCT');
|
||||
|
||||
return parent::renderForm();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
"Details" view for PrestaShop 1.6
|
||||
|
||||
**/
|
||||
|
||||
public function renderDetails()
|
||||
{
|
||||
if (($id = Tools::getValue('id_simpleblog_category'))) {
|
||||
$this->lang = false;
|
||||
$this->list_id = 'details';
|
||||
$this->initFormToolBar();
|
||||
$category = $this->loadObject($id);
|
||||
$this->toolbar_title = $this->l('Subcategories of:').' '.$category->name[$this->context->employee->id_lang];
|
||||
|
||||
unset($this->toolbar_btn['save-and-stay']);
|
||||
unset($this->toolbar_btn['new']);
|
||||
if ($this->display == 'details' || $this->display == 'add' || $this->display == 'edit') {
|
||||
$this->toolbar_btn['new'] = array(
|
||||
'href' => Context::getContext()->link->getAdminLink('AdminSimpleBlogCategories').'&addsimpleblog_category&id_parent='.$category->id,
|
||||
'desc' => $this->l('Add new'),
|
||||
);
|
||||
$this->toolbar_btn['back'] = array(
|
||||
'href' => Context::getContext()->link->getAdminLink('AdminSimpleBlogCategories'),
|
||||
'desc' => $this->l('Back to list'),
|
||||
);
|
||||
}
|
||||
|
||||
$this->_select = 'b.*';
|
||||
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'simpleblog_category_lang` b ON (b.`id_simpleblog_category` = a.`id_simpleblog_category` AND b.`id_lang` = '.$this->context->language->id.')';
|
||||
$this->_where = 'AND a.`id_parent` = '.(int)$id;
|
||||
$this->_orderBy = 'position';
|
||||
|
||||
$this->fields_list = array(
|
||||
'id_simpleblog_category' => array(
|
||||
'title' => $this->l('ID'),
|
||||
'align' => 'center',
|
||||
'class' => 'fixed-width-xs',
|
||||
),
|
||||
|
||||
'name' => array(
|
||||
'title' => $this->l('Name'),
|
||||
'width' => 'auto',
|
||||
'filter_key' => 'b!name',
|
||||
),
|
||||
|
||||
'active' => array(
|
||||
'title' => $this->l('Enabled'),
|
||||
'class' => 'fixed-width-xs',
|
||||
'align' => 'center',
|
||||
'active' => 'status',
|
||||
'type' => 'bool',
|
||||
'orderby' => false
|
||||
),
|
||||
|
||||
'position' => array(
|
||||
'title' => $this->l('Position'),
|
||||
'class' => 'fixed-width-md',
|
||||
'filter_key' => 'a!position',
|
||||
'position' => 'position'
|
||||
)
|
||||
);
|
||||
|
||||
self::$currentIndex = self::$currentIndex.'&details'.$this->table;
|
||||
$this->processFilter();
|
||||
return parent::renderList();
|
||||
}
|
||||
}
|
||||
|
||||
public function processDelete()
|
||||
{
|
||||
if ($this->tabAccess['delete'] == '1') {
|
||||
if (SimpleBlogCategory::getNbCats() == 1) {
|
||||
$this->errors[] = $this->l('You cannot remove this category because this is last category already used by module.');
|
||||
} else {
|
||||
return parent::processDelete();
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('You do not have permission to delete this.');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function processAdd()
|
||||
{
|
||||
$object = parent::processAdd();
|
||||
|
||||
// Cover
|
||||
if (isset($_FILES['cover']) && $_FILES['cover']['size'] > 0) {
|
||||
$object->cover = pathinfo($_FILES['cover']['name'], PATHINFO_EXTENSION);
|
||||
$object->update();
|
||||
}
|
||||
|
||||
if (!empty($object->cover)) {
|
||||
$this->createCover($_FILES['cover']['tmp_name'], $object);
|
||||
}
|
||||
|
||||
$this->updateAssoShop($object->id);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function processUpdate()
|
||||
{
|
||||
$object = parent::processUpdate();
|
||||
|
||||
// Cover
|
||||
if (isset($_FILES['cover']) && $_FILES['cover']['size'] > 0) {
|
||||
$object->cover = pathinfo($_FILES['cover']['name'], PATHINFO_EXTENSION);
|
||||
$object->update();
|
||||
}
|
||||
|
||||
if (!empty($object->cover) && isset($_FILES['cover']) && $_FILES['cover']['size'] > 0) {
|
||||
$this->createCover($_FILES['cover']['tmp_name'], $object);
|
||||
}
|
||||
|
||||
$this->updateAssoShop($object->id);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (Tools::isSubmit('viewsimpleblog_category')
|
||||
&& ($id_simpleblog_category = (int)Tools::getValue('id_simpleblog_category'))
|
||||
&& ($SimpleBlogCategory = new SimpleBlogCategory($id_simpleblog_category, (int) $this->context->language->id))
|
||||
&& Validate::isLoadedObject($SimpleBlogCategory)) {
|
||||
Tools::redirectAdmin($SimpleBlogCategory->getObjectLink((int) $this->context->language->id));
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('deleteCover')) {
|
||||
$this->deleteCover((int)Tools::getValue('id_simpleblog_category'));
|
||||
}
|
||||
|
||||
if (($id_simpleblog_category = (int)Tools::getValue('id_simpleblog_category'))
|
||||
&& ($direction = Tools::getValue('move'))
|
||||
&& Validate::isLoadedObject($SimpleBlogCategory = new SimpleBlogCategory($id_simpleblog_category))) {
|
||||
if ($SimpleBlogCategory->move($direction)) {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token);
|
||||
}
|
||||
} elseif (Tools::getValue('position') && !Tools::isSubmit('submitAdd'.$this->table)) {
|
||||
if ($this->tabAccess['edit'] !== '1') {
|
||||
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
|
||||
} elseif (!Validate::isLoadedObject($object = new SimpleBlogCategory((int)Tools::getValue($this->identifier)))) {
|
||||
$this->errors[] = Tools::displayError('An error occurred while updating the status for an object.').
|
||||
' <b>'.$this->table.'</b> '.Tools::displayError('(cannot load object)');
|
||||
}
|
||||
if (!$object->updatePosition((int)Tools::getValue('way'), (int)Tools::getValue('position'))) {
|
||||
$this->errors[] = Tools::displayError('Failed to update the position.');
|
||||
} else {
|
||||
Tools::redirectAdmin(self::$currentIndex.'&conf=5&token='.Tools::getAdminTokenLite('AdminSimpleBlogCategories'));
|
||||
}
|
||||
} else {
|
||||
// Temporary add the position depend of the selection of the parent category
|
||||
if (!Tools::isSubmit('id_simpleblog_category')) {
|
||||
$_POST['position'] = SimpleBlogCategory::getNbCats(Tools::getValue('id_parent'));
|
||||
}
|
||||
}
|
||||
|
||||
return parent::postProcess();
|
||||
}
|
||||
|
||||
public function ajaxProcessUpdatePositions()
|
||||
{
|
||||
$way = (int)(Tools::getValue('way'));
|
||||
$id_simpleblog_category = (int)(Tools::getValue('id'));
|
||||
$positions = Tools::getValue('simpleblog_category');
|
||||
|
||||
foreach ($positions as $position => $value) {
|
||||
$pos = explode('_', $value);
|
||||
|
||||
$id_simpleblog_category = (int)$pos[2];
|
||||
|
||||
if ((int)$id_simpleblog_category > 0) {
|
||||
if ($SimpleBlogCategory = new SimpleBlogCategory($id_simpleblog_category)) {
|
||||
$SimpleBlogCategory->position = $position+1;
|
||||
if ($SimpleBlogCategory->update()) {
|
||||
echo 'ok position '.(int)$position.' for category '.(int)$SimpleBlogCategory->id.'\r\n';
|
||||
}
|
||||
} else {
|
||||
echo '{"hasError" : true, "errors" : "This category ('.(int)$id_simpleblog_category.') cant be loaded"}';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function createCover($img = null, $object = null)
|
||||
{
|
||||
if (!isset($img)) {
|
||||
die('AdminSimpleBlogCategoryController@createCover: No image to process');
|
||||
}
|
||||
|
||||
$categoryImgX = Configuration::get('PH_CATEGORY_IMAGE_X');
|
||||
$categoryImgY = Configuration::get('PH_CATEGORY_IMAGE_Y');
|
||||
|
||||
if (isset($object) && Validate::isLoadedObject($object)) {
|
||||
$fileTmpLoc = $img;
|
||||
$origPath = _PS_MODULE_DIR_ . 'ph_simpleblog/covers_cat/'.$object->id.'.'.$object->cover;
|
||||
|
||||
$tmp_location = _PS_TMP_IMG_DIR_.'ph_simpleblog_cat_'.$object->id.'.'.$object->cover;
|
||||
if (file_exists($tmp_location)) {
|
||||
@unlink($tmp_location);
|
||||
}
|
||||
|
||||
try {
|
||||
$orig = PhpThumbFactory::create($fileTmpLoc);
|
||||
} catch (Exception $e) {
|
||||
echo $e;
|
||||
}
|
||||
|
||||
$orig->adaptiveResize($categoryImgX, $categoryImgY);
|
||||
|
||||
return $orig->save($origPath) && ImageManager::thumbnail(_PS_MODULE_DIR_ . 'ph_simpleblog/covers_cat/'.$object->id.'.'.$object->cover, 'ph_simpleblog_cat_'.$object->id.'.'.$object->cover, 350, $object->cover);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteCover($id)
|
||||
{
|
||||
$object = new SimpleBlogCategory($id, Context::getContext()->language->id);
|
||||
|
||||
$tmp_location = _PS_TMP_IMG_DIR_.'ph_simpleblog_cat_'.$object->id.'.'.$object->cover;
|
||||
if (file_exists($tmp_location)) {
|
||||
@unlink($tmp_location);
|
||||
}
|
||||
|
||||
$orig_location = _PS_MODULE_DIR_ . 'ph_simpleblog/covers_cat/'.$object->id.'.'.$object->cover;
|
||||
|
||||
if (file_exists($orig_location)) {
|
||||
@unlink($orig_location);
|
||||
}
|
||||
|
||||
$object->cover = null;
|
||||
$object->update();
|
||||
|
||||
Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getAdminTokenLite('AdminSimpleBlogCategories').'&conf=7');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
/**
|
||||
* Blog for PrestaShop module by Krystian Podemski from PrestaHome.
|
||||
*
|
||||
* @author Krystian Podemski <krystian@prestahome.com>
|
||||
* @copyright Copyright (c) 2014-2016 Krystian Podemski - www.PrestaHome.com / www.Podemski.info
|
||||
* @license You only can use module, nothing more!
|
||||
*/
|
||||
require_once _PS_MODULE_DIR_ . 'ph_simpleblog/ph_simpleblog.php';
|
||||
|
||||
class AdminSimpleBlogCommentsController extends ModuleAdminController
|
||||
{
|
||||
public $is_16;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this->table = 'simpleblog_comment';
|
||||
$this->className = 'SimpleBlogComment';
|
||||
|
||||
$this->bootstrap = true;
|
||||
|
||||
$this->addRowAction('edit');
|
||||
$this->addRowAction('delete');
|
||||
|
||||
$this->is_16 = (bool)(version_compare(_PS_VERSION_, '1.6.0', '>=') === true);
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->bulk_actions = array(
|
||||
'delete' => array(
|
||||
'text' => $this->l('Delete selected'),
|
||||
'confirm' => $this->l('Delete selected items?')
|
||||
),
|
||||
'enableSelection' => array('text' => $this->l('Enable selection')),
|
||||
'disableSelection' => array('text' => $this->l('Disable selection'))
|
||||
);
|
||||
|
||||
$this->_select = 'sbpl.title AS `post_title`';
|
||||
|
||||
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'simpleblog_post_lang` sbpl ON (sbpl.`id_simpleblog_post` = a.`id_simpleblog_post` AND sbpl.`id_lang` = '.(int)Context::getContext()->language->id.')';
|
||||
|
||||
$this->fields_list = array(
|
||||
'id_simpleblog_comment' => array(
|
||||
'title' => $this->l('ID'),
|
||||
'type' => 'int',
|
||||
'align' => 'center',
|
||||
'width' => 25
|
||||
),
|
||||
'id_simpleblog_post' => array(
|
||||
'title' => $this->l('Post ID'),
|
||||
'type' => 'int',
|
||||
'align' => 'center',
|
||||
'width' => 25
|
||||
),
|
||||
'post_title' => array(
|
||||
'title' => $this->l('Comment for'),
|
||||
'width' => 'auto'
|
||||
),
|
||||
'name' => array(
|
||||
'title' => $this->l('Name'),
|
||||
),
|
||||
'email' => array(
|
||||
'title' => $this->l('E-mail'),
|
||||
),
|
||||
'comment' => array(
|
||||
'title' => $this->l('Comment'),
|
||||
'width' => 'auto'
|
||||
),
|
||||
'active' => array(
|
||||
'title' => $this->l('Status'),
|
||||
'width' => 70,
|
||||
'active' => 'status',
|
||||
'align' => 'center',
|
||||
'type' => 'bool'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function renderForm()
|
||||
{
|
||||
$id_lang = $this->context->language->id;
|
||||
$obj = $this->loadObject(true);
|
||||
|
||||
$this->fields_form[0]['form'] = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('Comment'),
|
||||
),
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'id_simpleblog_post',
|
||||
),
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'id_customer',
|
||||
'label' => $this->l('Customer'),
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'id_simpleblog_post',
|
||||
'label' => $this->l('Post ID'),
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'name',
|
||||
'label' => $this->l('Name'),
|
||||
'required' => false,
|
||||
'lang' => false
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'email',
|
||||
'label' => $this->l('E-mail'),
|
||||
'required' => false,
|
||||
'lang' => false
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'name' => 'ip',
|
||||
'label' => $this->l('IP Address'),
|
||||
'required' => false,
|
||||
'lang' => false
|
||||
),
|
||||
array(
|
||||
'type' => 'textarea',
|
||||
'label' => $this->l('Comment'),
|
||||
'name' => 'comment',
|
||||
'cols' => 75,
|
||||
'rows' => 7,
|
||||
'required' => false,
|
||||
'lang' => false
|
||||
),
|
||||
array(
|
||||
'type' => 'switch',
|
||||
'label' => $this->l('Displayed'),
|
||||
'name' => 'active',
|
||||
'required' => false,
|
||||
'is_bool' => true,
|
||||
'values' => array(
|
||||
array(
|
||||
'id' => 'active_on',
|
||||
'value' => 1,
|
||||
'label' => $this->l('Enabled')
|
||||
),
|
||||
array(
|
||||
'id' => 'active_off',
|
||||
'value' => 0,
|
||||
'label' => $this->l('Disabled')
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
'name' => 'savePostComment'
|
||||
)
|
||||
);
|
||||
|
||||
$this->multiple_fieldsets = true;
|
||||
|
||||
$SimpleBlogPost = new SimpleBlogPost($obj->id_simpleblog_post, $id_lang);
|
||||
|
||||
$this->tpl_form_vars = array(
|
||||
'customerLink' => $this->context->link->getAdminLink('AdminCustomers'),
|
||||
'blogPostLink' => $this->context->link->getAdminLink('AdminSimpleBlogPost'),
|
||||
'blogPostName' => $SimpleBlogPost->meta_title
|
||||
);
|
||||
|
||||
return parent::renderForm();
|
||||
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,924 @@
|
||||
<?php
|
||||
/**
|
||||
* Blog for PrestaShop module by Krystian Podemski from PrestaHome.
|
||||
*
|
||||
* @author Krystian Podemski <krystian@prestahome.com>
|
||||
* @copyright Copyright (c) 2008-2019 Krystian Podemski - www.PrestaHome.com / www.Podemski.info
|
||||
* @license You only can use module, nothing more!
|
||||
*/
|
||||
require_once _PS_MODULE_DIR_.'ph_simpleblog/ph_simpleblog.php';
|
||||
|
||||
class AdminSimpleBlogSettingsController extends ModuleAdminController
|
||||
{
|
||||
public $is_16;
|
||||
public $is_17;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->bootstrap = true;
|
||||
|
||||
$this->initOptions();
|
||||
|
||||
$this->is_16 = (version_compare(_PS_VERSION_, '1.6.0', '>=') === true && version_compare(_PS_VERSION_, '1.7.0', '<') === true) ? true : false;
|
||||
$this->is_17 = (version_compare(_PS_VERSION_, '1.7.0', '>=') === true) ? true : false;
|
||||
}
|
||||
|
||||
public function initOptions()
|
||||
{
|
||||
$this->optionTitle = $this->l('Settings');
|
||||
|
||||
$blogCategories = SimpleBlogCategory::getCategories($this->context->language->id);
|
||||
|
||||
$simpleBlogCategories = array();
|
||||
|
||||
$simpleBlogCategories[0] = $this->l('All categories');
|
||||
$simpleBlogCategories[9999] = $this->l('Featured only');
|
||||
|
||||
foreach ($blogCategories as $key => $category) {
|
||||
$simpleBlogCategories[$category['id']] = $category['name'];
|
||||
}
|
||||
|
||||
$relatedPosts = array();
|
||||
|
||||
if (Module::isInstalled('ph_relatedposts')) {
|
||||
$relatedPosts = array(
|
||||
'related_posts' => array(
|
||||
'submit' => array('title' => $this->l('Update'), 'class' => 'button'),
|
||||
'title' => $this->l('Related Posts widget settings'),
|
||||
'image' => '../img/t/AdminOrderPreferences.gif',
|
||||
'fields' => array(
|
||||
|
||||
'PH_RELATEDPOSTS_GRID_COLUMNS' => array(
|
||||
'title' => $this->l('Grid columns:'),
|
||||
'cast' => 'intval',
|
||||
'desc' => $this->l('Working only with "Recent Posts layout:" setup to "Grid"'),
|
||||
'show' => true,
|
||||
'required' => true,
|
||||
'type' => 'radio',
|
||||
'choices' => array(
|
||||
'2' => $this->l('2 columns'),
|
||||
'3' => $this->l('3 columns'),
|
||||
'4' => $this->l('4 columns'),
|
||||
),
|
||||
), // PH_RELATEDPOSTS_GRID_COLUMNS
|
||||
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$timezones = array(
|
||||
'Pacific/Midway' => '(GMT-11:00) Midway Island',
|
||||
'US/Samoa' => '(GMT-11:00) Samoa',
|
||||
'US/Hawaii' => '(GMT-10:00) Hawaii',
|
||||
'US/Alaska' => '(GMT-09:00) Alaska',
|
||||
'US/Pacific' => '(GMT-08:00) Pacific Time (US & Canada)',
|
||||
'America/Tijuana' => '(GMT-08:00) Tijuana',
|
||||
'US/Arizona' => '(GMT-07:00) Arizona',
|
||||
'US/Mountain' => '(GMT-07:00) Mountain Time (US & Canada)',
|
||||
'America/Chihuahua' => '(GMT-07:00) Chihuahua',
|
||||
'America/Mazatlan' => '(GMT-07:00) Mazatlan',
|
||||
'America/Mexico_City' => '(GMT-06:00) Mexico City',
|
||||
'America/Monterrey' => '(GMT-06:00) Monterrey',
|
||||
'Canada/Saskatchewan' => '(GMT-06:00) Saskatchewan',
|
||||
'US/Central' => '(GMT-06:00) Central Time (US & Canada)',
|
||||
'US/Eastern' => '(GMT-05:00) Eastern Time (US & Canada)',
|
||||
'US/East-Indiana' => '(GMT-05:00) Indiana (East)',
|
||||
'America/Bogota' => '(GMT-05:00) Bogota',
|
||||
'America/Lima' => '(GMT-05:00) Lima',
|
||||
'America/Caracas' => '(GMT-04:30) Caracas',
|
||||
'Canada/Atlantic' => '(GMT-04:00) Atlantic Time (Canada)',
|
||||
'America/La_Paz' => '(GMT-04:00) La Paz',
|
||||
'America/Santiago' => '(GMT-04:00) Santiago',
|
||||
'Canada/Newfoundland' => '(GMT-03:30) Newfoundland',
|
||||
'America/Buenos_Aires' => '(GMT-03:00) Buenos Aires',
|
||||
'Greenland' => '(GMT-03:00) Greenland',
|
||||
'Atlantic/Stanley' => '(GMT-02:00) Stanley',
|
||||
'Atlantic/Azores' => '(GMT-01:00) Azores',
|
||||
'Atlantic/Cape_Verde' => '(GMT-01:00) Cape Verde Is.',
|
||||
'Africa/Casablanca' => '(GMT) Casablanca',
|
||||
'Europe/Dublin' => '(GMT) Dublin',
|
||||
'Europe/Lisbon' => '(GMT) Lisbon',
|
||||
'Europe/London' => '(GMT) London',
|
||||
'Africa/Monrovia' => '(GMT) Monrovia',
|
||||
'Europe/Amsterdam' => '(GMT+01:00) Amsterdam',
|
||||
'Europe/Belgrade' => '(GMT+01:00) Belgrade',
|
||||
'Europe/Berlin' => '(GMT+01:00) Berlin',
|
||||
'Europe/Bratislava' => '(GMT+01:00) Bratislava',
|
||||
'Europe/Brussels' => '(GMT+01:00) Brussels',
|
||||
'Europe/Budapest' => '(GMT+01:00) Budapest',
|
||||
'Europe/Copenhagen' => '(GMT+01:00) Copenhagen',
|
||||
'Europe/Ljubljana' => '(GMT+01:00) Ljubljana',
|
||||
'Europe/Madrid' => '(GMT+01:00) Madrid',
|
||||
'Europe/Paris' => '(GMT+01:00) Paris',
|
||||
'Europe/Prague' => '(GMT+01:00) Prague',
|
||||
'Europe/Rome' => '(GMT+01:00) Rome',
|
||||
'Europe/Sarajevo' => '(GMT+01:00) Sarajevo',
|
||||
'Europe/Skopje' => '(GMT+01:00) Skopje',
|
||||
'Europe/Stockholm' => '(GMT+01:00) Stockholm',
|
||||
'Europe/Vienna' => '(GMT+01:00) Vienna',
|
||||
'Europe/Warsaw' => '(GMT+01:00) Warsaw',
|
||||
'Europe/Zagreb' => '(GMT+01:00) Zagreb',
|
||||
'Europe/Athens' => '(GMT+02:00) Athens',
|
||||
'Europe/Bucharest' => '(GMT+02:00) Bucharest',
|
||||
'Africa/Cairo' => '(GMT+02:00) Cairo',
|
||||
'Africa/Harare' => '(GMT+02:00) Harare',
|
||||
'Europe/Helsinki' => '(GMT+02:00) Helsinki',
|
||||
'Europe/Istanbul' => '(GMT+02:00) Istanbul',
|
||||
'Asia/Jerusalem' => '(GMT+02:00) Jerusalem',
|
||||
'Europe/Kiev' => '(GMT+02:00) Kyiv',
|
||||
'Europe/Minsk' => '(GMT+02:00) Minsk',
|
||||
'Europe/Riga' => '(GMT+02:00) Riga',
|
||||
'Europe/Sofia' => '(GMT+02:00) Sofia',
|
||||
'Europe/Tallinn' => '(GMT+02:00) Tallinn',
|
||||
'Europe/Vilnius' => '(GMT+02:00) Vilnius',
|
||||
'Asia/Baghdad' => '(GMT+03:00) Baghdad',
|
||||
'Asia/Kuwait' => '(GMT+03:00) Kuwait',
|
||||
'Africa/Nairobi' => '(GMT+03:00) Nairobi',
|
||||
'Asia/Riyadh' => '(GMT+03:00) Riyadh',
|
||||
'Asia/Tehran' => '(GMT+03:30) Tehran',
|
||||
'Europe/Moscow' => '(GMT+04:00) Moscow',
|
||||
'Asia/Baku' => '(GMT+04:00) Baku',
|
||||
'Europe/Volgograd' => '(GMT+04:00) Volgograd',
|
||||
'Asia/Muscat' => '(GMT+04:00) Muscat',
|
||||
'Asia/Tbilisi' => '(GMT+04:00) Tbilisi',
|
||||
'Asia/Yerevan' => '(GMT+04:00) Yerevan',
|
||||
'Asia/Kabul' => '(GMT+04:30) Kabul',
|
||||
'Asia/Karachi' => '(GMT+05:00) Karachi',
|
||||
'Asia/Tashkent' => '(GMT+05:00) Tashkent',
|
||||
'Asia/Kolkata' => '(GMT+05:30) Kolkata',
|
||||
'Asia/Kathmandu' => '(GMT+05:45) Kathmandu',
|
||||
'Asia/Yekaterinburg' => '(GMT+06:00) Ekaterinburg',
|
||||
'Asia/Almaty' => '(GMT+06:00) Almaty',
|
||||
'Asia/Dhaka' => '(GMT+06:00) Dhaka',
|
||||
'Asia/Novosibirsk' => '(GMT+07:00) Novosibirsk',
|
||||
'Asia/Bangkok' => '(GMT+07:00) Bangkok',
|
||||
'Asia/Jakarta' => '(GMT+07:00) Jakarta',
|
||||
'Asia/Krasnoyarsk' => '(GMT+08:00) Krasnoyarsk',
|
||||
'Asia/Chongqing' => '(GMT+08:00) Chongqing',
|
||||
'Asia/Hong_Kong' => '(GMT+08:00) Hong Kong',
|
||||
'Asia/Kuala_Lumpur' => '(GMT+08:00) Kuala Lumpur',
|
||||
'Australia/Perth' => '(GMT+08:00) Perth',
|
||||
'Asia/Singapore' => '(GMT+08:00) Singapore',
|
||||
'Asia/Taipei' => '(GMT+08:00) Taipei',
|
||||
'Asia/Ulaanbaatar' => '(GMT+08:00) Ulaan Bataar',
|
||||
'Asia/Urumqi' => '(GMT+08:00) Urumqi',
|
||||
'Asia/Irkutsk' => '(GMT+09:00) Irkutsk',
|
||||
'Asia/Seoul' => '(GMT+09:00) Seoul',
|
||||
'Asia/Tokyo' => '(GMT+09:00) Tokyo',
|
||||
'Australia/Adelaide' => '(GMT+09:30) Adelaide',
|
||||
'Australia/Darwin' => '(GMT+09:30) Darwin',
|
||||
'Asia/Yakutsk' => '(GMT+10:00) Yakutsk',
|
||||
'Australia/Brisbane' => '(GMT+10:00) Brisbane',
|
||||
'Australia/Canberra' => '(GMT+10:00) Canberra',
|
||||
'Pacific/Guam' => '(GMT+10:00) Guam',
|
||||
'Australia/Hobart' => '(GMT+10:00) Hobart',
|
||||
'Australia/Melbourne' => '(GMT+10:00) Melbourne',
|
||||
'Pacific/Port_Moresby' => '(GMT+10:00) Port Moresby',
|
||||
'Australia/Sydney' => '(GMT+10:00) Sydney',
|
||||
'Asia/Vladivostok' => '(GMT+11:00) Vladivostok',
|
||||
'Asia/Magadan' => '(GMT+12:00) Magadan',
|
||||
'Pacific/Auckland' => '(GMT+12:00) Auckland',
|
||||
'Pacific/Fiji' => '(GMT+12:00) Fiji',
|
||||
);
|
||||
|
||||
$timezones_select = array();
|
||||
|
||||
foreach ($timezones as $value => $name) {
|
||||
$timezones_select[] = array('id' => $value, 'name' => $name);
|
||||
}
|
||||
|
||||
$pre_settings_content = '<button type="submit" name="regenerateThumbnails" class="button btn btn-default"><i class="process-icon-cogs"></i>'.$this->l('Regenerate thumbnails').'</button> ';
|
||||
$pre_settings_content .= '<button type="submit" name="submitExportSettings" class="button btn btn-default"><i class="process-icon-export"></i>'.$this->l('Export settings').'</button> ';
|
||||
$pre_settings_content .= '<br /><br />';
|
||||
|
||||
$standard_options = array(
|
||||
'general' => array(
|
||||
'title' => $this->l('Blog for PrestaShop - Settings'),
|
||||
'info' => $pre_settings_content,
|
||||
'fields' => array(
|
||||
|
||||
'PH_BLOG_TIMEZONE' => array(
|
||||
'title' => $this->l('Timezone:'),
|
||||
'desc' => $this->l('If you want to use future post publication date you need to setup your timezone'),
|
||||
'type' => 'select',
|
||||
'list' => $timezones_select,
|
||||
'identifier' => 'id',
|
||||
'required' => true,
|
||||
'validation' => 'isGenericName',
|
||||
), // PH_BLOG_TIMEZONE
|
||||
|
||||
'PH_BLOG_POSTS_PER_PAGE' => array(
|
||||
'title' => $this->l('Posts per page:'),
|
||||
'cast' => 'intval',
|
||||
'desc' => $this->l('Number of blog posts displayed per page. Default is 10.'),
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
'validation' => 'isUnsignedId',
|
||||
), // PH_BLOG_POSTS_PER_PAGE
|
||||
|
||||
'PH_BLOG_SLUG' => array(
|
||||
'title' => $this->l('Blog main URL (by default: blog)'),
|
||||
'validation' => 'isGenericName',
|
||||
'required' => true,
|
||||
'type' => 'text',
|
||||
'size' => 40,
|
||||
), // PH_BLOG_SLUG
|
||||
|
||||
'PH_BLOG_MAIN_TITLE' => array(
|
||||
'title' => $this->l('Blog title:'),
|
||||
'validation' => 'isGenericName',
|
||||
'type' => 'textLang',
|
||||
'size' => 40,
|
||||
'desc' => $this->l('Meta Title for blog homepage'),
|
||||
), // PH_BLOG_MAIN_TITLE
|
||||
|
||||
'PH_BLOG_MAIN_META_DESCRIPTION' => array(
|
||||
'title' => $this->l('Blog description:'),
|
||||
'validation' => 'isGenericName',
|
||||
'type' => 'textLang',
|
||||
'size' => 75,
|
||||
'desc' => $this->l('Meta Description for blog homepage'),
|
||||
), // PH_BLOG_MAIN_META_DESCRIPTION
|
||||
|
||||
'PH_BLOG_DATEFORMAT' => array(
|
||||
'title' => $this->l('Blog default date format:'),
|
||||
'desc' => $this->l('More details: https://www.smarty.net/docsv2/en/language.modifier.date.format.tpl'),
|
||||
'validation' => 'isGenericName',
|
||||
'type' => 'text',
|
||||
'size' => 40,
|
||||
), // PH_BLOG_DATEFORMAT
|
||||
|
||||
'PH_CATEGORY_SORTBY' => array(
|
||||
'title' => $this->l('Sort categories by:'),
|
||||
'desc' => $this->l('Select which method use to sort categories in SimpleBlog Categories Block'),
|
||||
'show' => true,
|
||||
'required' => true,
|
||||
'type' => 'radio',
|
||||
'choices' => array(
|
||||
'position' => $this->l('Position (1-9)'),
|
||||
'name' => $this->l('Name (A-Z)'),
|
||||
'id' => $this->l('ID (1-9)'),
|
||||
),
|
||||
), // PH_CATEGORY_SORTBY
|
||||
|
||||
'PH_BLOG_FB_INIT' => array(
|
||||
'title' => $this->l('Init Facebook?'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'desc' => $this->l('If you already use some Facebook widgets in your theme please select option to "No". If you select "Yes" then SimpleBlog will add facebook connect script on single post page.'),
|
||||
'required' => true,
|
||||
'type' => 'bool',
|
||||
), // PH_BLOG_FB_INIT
|
||||
|
||||
'PH_BLOG_ADVERTISING' => array(
|
||||
'title' => $this->l('Display ads and notifications in back-office?'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'desc' => $this->l('Sometimes you\'ll see notifications about module updates, our new products etc.'),
|
||||
'required' => true,
|
||||
'type' => 'bool',
|
||||
), // PH_BLOG_ADVERTISING
|
||||
|
||||
// @todo - 2.0.0
|
||||
// 'PH_BLOG_LOAD_FA' => array(
|
||||
// 'title' => $this->l('Load FontAwesome?'),
|
||||
// 'validation' => 'isBool',
|
||||
// 'cast' => 'intval',
|
||||
// 'desc' => $this->l('If you already use FontAwesome in your theme please select option to "No".'),
|
||||
// 'required' => true,
|
||||
// 'type' => 'bool'
|
||||
// ), // PH_BLOG_LOAD_FA
|
||||
|
||||
),
|
||||
'submit' => array('title' => $this->l('Update'), 'class' => 'button'),
|
||||
),
|
||||
|
||||
'layout' => array(
|
||||
'submit' => array('title' => $this->l('Update'), 'class' => 'button'),
|
||||
'title' => $this->l('Appearance Settings - General'),
|
||||
'fields' => array(
|
||||
|
||||
'PH_BLOG_DISPLAY_BREADCRUMBS' => array(
|
||||
'title' => $this->l('Display breadcrumbs in center-column?'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'desc' => $this->l('Sometimes you want to remove breadcrumbs from center-column. Option for 1.6 only'),
|
||||
'required' => true,
|
||||
'type' => 'bool',
|
||||
'class' => '',
|
||||
), // PH_BLOG_DISPLAY_BREADCRUMBS
|
||||
|
||||
'PH_BLOG_LIST_LAYOUT' => array(
|
||||
'title' => $this->l('Posts list layout:'),
|
||||
'show' => true,
|
||||
'required' => true,
|
||||
'type' => 'radio',
|
||||
'choices' => array(
|
||||
'full' => $this->l('Full width with large images'),
|
||||
'grid' => $this->l('Grid'),
|
||||
),
|
||||
), // PH_BLOG_LIST_LAYOUT
|
||||
|
||||
'PH_BLOG_GRID_COLUMNS' => array(
|
||||
'title' => $this->l('Grid columns:'),
|
||||
'cast' => 'intval',
|
||||
'desc' => $this->l('Working only with "Posts list layout" setup to "Grid"'),
|
||||
'show' => true,
|
||||
'required' => true,
|
||||
'type' => 'radio',
|
||||
'choices' => array(
|
||||
'2' => $this->l('2 columns'),
|
||||
'3' => $this->l('3 columns'),
|
||||
'4' => $this->l('4 columns'),
|
||||
),
|
||||
), // PH_BLOG_GRID_COLUMNS
|
||||
|
||||
// 'PH_BLOG_MASONRY_LAYOUT' => array(
|
||||
// 'title' => $this->l('Use Masonry layout?'),
|
||||
// 'validation' => 'isBool',
|
||||
// 'cast' => 'intval',
|
||||
// 'desc' => $this->l('You can use masonry layout if you use Grid as a post list layout'),
|
||||
// 'type' => 'bool',
|
||||
// ), // PH_BLOG_MASONRY_LAYOUT
|
||||
|
||||
'PH_BLOG_CSS' => array(
|
||||
'title' => $this->l('Custom CSS'),
|
||||
'show' => true,
|
||||
'required' => false,
|
||||
'type' => 'textarea',
|
||||
'cols' => '70',
|
||||
'rows' => '10',
|
||||
), // PH_BLOG_CSS
|
||||
|
||||
),
|
||||
),
|
||||
|
||||
'single_post' => array(
|
||||
'submit' => array('title' => $this->l('Update'), 'class' => 'button'),
|
||||
'title' => $this->l('Appearance Settings - Single post'),
|
||||
'fields' => array(
|
||||
|
||||
'PH_BLOG_DISPLAY_LIKES' => array(
|
||||
'title' => $this->l('Display "likes"?'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'required' => true,
|
||||
'type' => 'bool',
|
||||
), // PH_BLOG_DISPLAY_LIKES
|
||||
|
||||
'PH_BLOG_DISPLAY_SHARER' => array(
|
||||
'title' => $this->l('Use share icons on single post page?'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'required' => true,
|
||||
'type' => 'bool',
|
||||
), // PH_BLOG_DISPLAY_SHARER
|
||||
|
||||
'PH_BLOG_DISPLAY_AUTHOR' => array(
|
||||
'title' => $this->l('Display post author?'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'required' => true,
|
||||
'type' => 'bool',
|
||||
'desc' => $this->l('This option also applies to the list of posts from the category'),
|
||||
), // PH_BLOG_DISPLAY_AUTHOR
|
||||
|
||||
'PH_BLOG_DISPLAY_DATE' => array(
|
||||
'title' => $this->l('Display post creation date?'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'required' => true,
|
||||
'type' => 'bool',
|
||||
'desc' => $this->l('This option also applies to the list of posts from the category'),
|
||||
), // PH_BLOG_DISPLAY_DATE
|
||||
|
||||
'PH_BLOG_DISPLAY_FEATURED' => array(
|
||||
'title' => $this->l('Display post featured image?'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'required' => true,
|
||||
'type' => 'bool',
|
||||
), // PH_BLOG_DISPLAY_FEATURED
|
||||
|
||||
'PH_BLOG_DISPLAY_CATEGORY' => array(
|
||||
'title' => $this->l('Display post category?'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'required' => true,
|
||||
'type' => 'bool',
|
||||
'desc' => $this->l('This option also applies to the list of posts from the category'),
|
||||
), // PH_BLOG_DISPLAY_CATEGORY
|
||||
|
||||
'PH_BLOG_DISPLAY_TAGS' => array(
|
||||
'title' => $this->l('Display post tags?'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'required' => true,
|
||||
'type' => 'bool',
|
||||
), // PH_BLOG_DISPLAY_TAGS
|
||||
|
||||
'PH_BLOG_DISPLAY_RELATED' => array(
|
||||
'title' => $this->l('Display related products?'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'required' => true,
|
||||
'type' => 'bool',
|
||||
), // PH_BLOG_DISPLAY_RELATED
|
||||
|
||||
),
|
||||
),
|
||||
|
||||
'category_page' => array(
|
||||
'submit' => array('title' => $this->l('Update'), 'class' => 'button'),
|
||||
'title' => $this->l('Appearance Settings - Post lists'),
|
||||
'fields' => array(
|
||||
|
||||
'PH_BLOG_DISPLAY_MORE' => array(
|
||||
'title' => $this->l('Display "Read more"?'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'required' => true,
|
||||
'type' => 'bool',
|
||||
), // PH_BLOG_DISPLAY_MORES
|
||||
|
||||
'PH_BLOG_DISPLAY_THUMBNAIL' => array(
|
||||
'title' => $this->l('Display post thumbnails?'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'required' => true,
|
||||
'type' => 'bool',
|
||||
), // PH_BLOG_DISPLAY_THUMBNAILS
|
||||
|
||||
'PH_BLOG_DISPLAY_DESCRIPTION' => array(
|
||||
'title' => $this->l('Display post short description?'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'required' => true,
|
||||
'type' => 'bool',
|
||||
), // PH_BLOG_DISPLAY_DESCRIPTION
|
||||
|
||||
'PH_BLOG_DISPLAY_CAT_DESC' => array(
|
||||
'title' => $this->l('Display category description on category page?'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'required' => true,
|
||||
'type' => 'bool',
|
||||
), // PH_BLOG_DISPLAY_CAT_DESC
|
||||
|
||||
'PH_BLOG_DISPLAY_CATEGORY_IMAGE' => array(
|
||||
'title' => $this->l('Display category image?'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'required' => true,
|
||||
'type' => 'bool',
|
||||
), // PH_BLOG_DISPLAY_CATEGORY_IMAGE
|
||||
|
||||
'PH_CATEGORY_IMAGE_X' => array(
|
||||
'title' => $this->l('Default category image width (px)'),
|
||||
'cast' => 'intval',
|
||||
'desc' => $this->l('Default: 535 (For PrestaShop 1.5), 870 (For PrestaShop 1.6), 1000 (For PrestaShop 1.7)'),
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
'validation' => 'isUnsignedId',
|
||||
), // PH_CATEGORY_IMAGE_X
|
||||
|
||||
'PH_CATEGORY_IMAGE_Y' => array(
|
||||
'title' => $this->l('Default category image height (px)'),
|
||||
'cast' => 'intval',
|
||||
'desc' => $this->l('Default: 150'),
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
'validation' => 'isUnsignedId',
|
||||
), // PH_CATEGORY_IMAGE_Y
|
||||
|
||||
),
|
||||
),
|
||||
|
||||
'comments' => array(
|
||||
'submit' => array('title' => $this->l('Update'), 'class' => 'button'),
|
||||
'title' => $this->l('Comments'),
|
||||
'fields' => array(
|
||||
|
||||
'PH_BLOG_COMMENTS_SYSTEM' => array(
|
||||
'title' => $this->l('Comments system:'),
|
||||
'desc' => $this->l('What type of comments system do you want to use?'),
|
||||
'show' => true,
|
||||
'required' => true,
|
||||
'type' => 'radio',
|
||||
'choices' => array(
|
||||
'native' => $this->l('Default native comments'),
|
||||
'facebook' => $this->l('Facebook comments'),
|
||||
'disqus' => $this->l('Disqus comments'),
|
||||
),
|
||||
), // PH_BLOG_GRID_COLUMNS
|
||||
|
||||
'PH_BLOG_COMMENT_AUTO_APPROVAL' => array(
|
||||
'title' => $this->l('Automatically approve new comments?'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'required' => true,
|
||||
'type' => 'bool',
|
||||
), // PH_BLOG_COMMENT_AUTO_APPROVAL
|
||||
|
||||
'PH_BLOG_COMMENT_ALLOW' => array(
|
||||
'title' => $this->l('Allow comments?'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'required' => true,
|
||||
'type' => 'bool',
|
||||
), // PH_BLOG_COMMENT_ALLOW
|
||||
|
||||
'PH_BLOG_COMMENT_ALLOW_GUEST' => array(
|
||||
'title' => $this->l('Allow comments for non logged in users?'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'required' => true,
|
||||
'type' => 'bool',
|
||||
), // PH_BLOG_COMMENT_ALLOW_GUEST
|
||||
|
||||
'PH_BLOG_COMMENT_NOTIFICATIONS' => array(
|
||||
'title' => $this->l('Notify about new comments?'),
|
||||
'validation' => 'isBool',
|
||||
'desc' => $this->l('Only for native comment system'),
|
||||
'cast' => 'intval',
|
||||
'required' => true,
|
||||
'type' => 'bool',
|
||||
), // PH_BLOG_COMMENT_NOTIFICATIONS
|
||||
|
||||
'PH_BLOG_COMMENT_NOTIFY_EMAIL' => array(
|
||||
'title' => $this->l('E-mail for notifications'),
|
||||
'type' => 'text',
|
||||
'desc' => $this->l('Only for native comment system'),
|
||||
'size' => 55,
|
||||
'required' => false,
|
||||
), // PH_BLOG_COMMENT_NOTIFY_EMAIL
|
||||
|
||||
),
|
||||
),
|
||||
|
||||
'facebook_comments' => array(
|
||||
'submit' => array('title' => $this->l('Update'), 'class' => 'button'),
|
||||
'title' => $this->l('Facebook comments - settings'),
|
||||
'fields' => array(
|
||||
|
||||
'PH_BLOG_FACEBOOK_MODERATOR' => array(
|
||||
'title' => $this->l('Facebook comments moderator User ID'),
|
||||
'type' => 'text',
|
||||
'size' => 55,
|
||||
), // PH_BLOG_FACEBOOK_MODERATOR
|
||||
|
||||
'PH_BLOG_FACEBOOK_APP_ID' => array(
|
||||
'title' => $this->l('Facebook application ID (may be required for comments moderation)'),
|
||||
'type' => 'text',
|
||||
'size' => 75,
|
||||
), // PH_BLOG_FACEBOOK_APP_ID
|
||||
|
||||
'PH_BLOG_FACEBOOK_COLOR_SCHEME' => array(
|
||||
'title' => $this->l('Faceboook comments color scheme'),
|
||||
'show' => true,
|
||||
'required' => true,
|
||||
'type' => 'radio',
|
||||
'choices' => array(
|
||||
'light' => $this->l('Light'),
|
||||
'dark' => $this->l('Dark'),
|
||||
),
|
||||
), // PH_BLOG_FACEBOOK_COLOR_SCHEME
|
||||
|
||||
),
|
||||
),
|
||||
|
||||
'facebook_share' => array(
|
||||
'submit' => array('title' => $this->l('Update'), 'class' => 'button'),
|
||||
'title' => $this->l('Facebook sharing - settings'),
|
||||
'fields' => array(
|
||||
|
||||
'PH_BLOG_IMAGE_FBSHARE' => array(
|
||||
'title' => $this->l('Which image use as a image shared on Facebook?'),
|
||||
'show' => true,
|
||||
'required' => true,
|
||||
'type' => 'radio',
|
||||
'choices' => array(
|
||||
'featured' => $this->l('Featured'),
|
||||
'thumbnail' => $this->l('Thumbnail'),
|
||||
),
|
||||
), // PH_BLOG_IMAGE_FBSHARE
|
||||
|
||||
),
|
||||
),
|
||||
|
||||
'disqus_comments' => array(
|
||||
'submit' => array('title' => $this->l('Update'), 'class' => 'button'),
|
||||
'title' => $this->l('Disqus comments - settings'),
|
||||
'fields' => array(
|
||||
|
||||
'PH_BLOG_DISQUS_SHORTNAME' => array(
|
||||
'title' => $this->l('Shortname'),
|
||||
'type' => 'text',
|
||||
'size' => 55,
|
||||
), // PH_BLOG_DISQUS_SHORTNAME
|
||||
|
||||
),
|
||||
),
|
||||
|
||||
'comments_spam_protection' => array(
|
||||
'submit' => array('title' => $this->l('Update'), 'class' => 'button'),
|
||||
'title' => $this->l('Comments - Spam Protection for native comments system').' - reCAPTCHA v2, checkbox version',
|
||||
'info' => '<div class="alert alert-info">'.$this->l('Spam protection is provided by Google reCAPTCHA service, to gain keys:').'
|
||||
<ol>
|
||||
<li>'.$this->l('Login to your Google Account and go to this page:').' https://www.google.com/recaptcha/admin</li>
|
||||
<li>'.$this->l('Register a new site').'</li>
|
||||
<li>'.$this->l('Get Site Key and Secret Key and provide these keys here in Settings').'</li>
|
||||
<li>'.$this->l('Remember: if you do not specify the correct keys, the captcha will not work').'</li>
|
||||
</ol>
|
||||
</div>',
|
||||
'fields' => array(
|
||||
|
||||
'PH_BLOG_COMMENTS_RECAPTCHA' => array(
|
||||
'title' => $this->l('Enable spam protection?'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'required' => true,
|
||||
'type' => 'bool',
|
||||
), // PH_BLOG_COMMENTS_RECAPTCHA
|
||||
|
||||
'PH_BLOG_COMMENTS_RECAPTCHA_SITE_KEY' => array(
|
||||
'title' => $this->l('Site key:'),
|
||||
'type' => 'text',
|
||||
'size' => 255,
|
||||
'required' => false,
|
||||
), // PH_BLOG_COMMENTS_RECAPTCHA_SITE_KEY
|
||||
|
||||
'PH_BLOG_COMMENTS_RECAPTCHA_SECRET_KEY' => array(
|
||||
'title' => $this->l('Secret key:'),
|
||||
'type' => 'text',
|
||||
'size' => 255,
|
||||
'required' => false,
|
||||
), // PH_BLOG_COMMENTS_RECAPTCHA_SECRET_KEY
|
||||
|
||||
'PH_BLOG_COMMENTS_RECAPTCHA_THEME' => array(
|
||||
'title' => $this->l('reCAPTCHA color scheme:'),
|
||||
'show' => true,
|
||||
'required' => true,
|
||||
'type' => 'radio',
|
||||
'choices' => array(
|
||||
'light' => $this->l('Light'),
|
||||
'dark' => $this->l('Dark'),
|
||||
),
|
||||
), // PH_BLOG_COMMENTS_RECAPTCHA_THEME
|
||||
|
||||
),
|
||||
),
|
||||
|
||||
'thumbnails' => array(
|
||||
'submit' => array('title' => $this->l('Update'), 'class' => 'button'),
|
||||
'title' => $this->l('Thumbnails Settings'),
|
||||
'info' => '<div class="alert alert-info">'.$this->l('Remember to regenerate thumbnails after doing changes here').'</div>',
|
||||
'fields' => array(
|
||||
|
||||
'PH_BLOG_THUMB_METHOD' => array(
|
||||
'title' => $this->l('Resize method:'),
|
||||
'cast' => 'intval',
|
||||
'desc' => $this->l('Select wich method use to resize thumbnail. Adaptive resize: What it does is resize the image to get as close as possible to the desired dimensions, then crops the image down to the proper size from the center.'),
|
||||
'show' => true,
|
||||
'required' => true,
|
||||
'type' => 'radio',
|
||||
'choices' => array(
|
||||
'1' => $this->l('Adaptive resize (recommended)'),
|
||||
'2' => $this->l('Crop from center'),
|
||||
),
|
||||
), // PH_BLOG_THUMB_METHOD
|
||||
|
||||
'PH_BLOG_THUMB_X' => array(
|
||||
'title' => $this->l('Default thumbnail width (px)'),
|
||||
'cast' => 'intval',
|
||||
'desc' => $this->l('Default: 255 (For PrestaShop 1.5), 420 (For PrestaShop 1.6), 600 (For PrestaShop 1.7)'),
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
'validation' => 'isUnsignedId',
|
||||
), // PH_BLOG_THUMB_X
|
||||
|
||||
'PH_BLOG_THUMB_Y' => array(
|
||||
'title' => $this->l('Default thumbnail height (px)'),
|
||||
'cast' => 'intval',
|
||||
'desc' => $this->l('Default: 200 (For PrestaShop 1.5 and 1.6)'),
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
'validation' => 'isUnsignedId',
|
||||
), // PH_BLOG_THUMB_Y
|
||||
|
||||
'PH_BLOG_THUMB_X_WIDE' => array(
|
||||
'title' => $this->l('Default thumbnail width (wide version) (px)'),
|
||||
'cast' => 'intval',
|
||||
'desc' => $this->l('Default: 535 (For PrestaShop 1.5), 870 (For PrestaShop 1.6), 1000 (For PrestaShop 1.7)'),
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
'validation' => 'isUnsignedId',
|
||||
), // PH_BLOG_THUMB_X_WIDE
|
||||
|
||||
'PH_BLOG_THUMB_Y_WIDE' => array(
|
||||
'title' => $this->l('Default thumbnail height (wide version) (px)'),
|
||||
'cast' => 'intval',
|
||||
'desc' => $this->l('Default: 350 (For PrestaShop 1.5 and 1.6)'),
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
'validation' => 'isUnsignedId',
|
||||
), // PH_BLOG_THUMB_Y_WIDE
|
||||
|
||||
),
|
||||
),
|
||||
|
||||
'troubleshooting' => array(
|
||||
'submit' => array('title' => $this->l('Update'), 'class' => 'button'),
|
||||
'title' => $this->l('Troubleshooting'),
|
||||
'fields' => array(
|
||||
|
||||
'PH_BLOG_RELATED_PRODUCTS_USE_DEFAULT_LIST' => array(
|
||||
'title' => $this->l('Use product list from your theme for related products?'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'required' => true,
|
||||
'desc' => $this->l('By default Blog for PrestaShop uses default-bootstrap product list markup for related products, you can switch this option to load your product-list.tpl instead. In PrestaShop 1.7 we always use theme products list.'),
|
||||
'type' => 'bool',
|
||||
), // PH_BLOG_RELATED_PRODUCTS_USE_DEFAULT_LIST
|
||||
|
||||
'PH_BLOG_LOAD_FONT_AWESOME' => array(
|
||||
'title' => $this->l('Load FontAwesome from module? Only for PS 1.6.'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'required' => true,
|
||||
'desc' => $this->l('Important: Blog for PrestaShop uses fa fa-iconname format instead of icon-iconname format used by default in PrestaShop.'),
|
||||
'type' => 'bool',
|
||||
), // PH_BLOG_LOAD_FONT_AWESOME
|
||||
|
||||
'PH_BLOG_LOAD_BXSLIDER' => array(
|
||||
'title' => $this->l('Load BxSlider from module? Only for PS 1.6.'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'required' => true,
|
||||
'type' => 'bool',
|
||||
), // PH_BLOG_LOAD_BXSLIDER
|
||||
|
||||
// 'PH_BLOG_LOAD_MASONRY' => array(
|
||||
// 'title' => $this->l('Load Masonry from module?'),
|
||||
// 'validation' => 'isBool',
|
||||
// 'cast' => 'intval',
|
||||
// 'required' => true,
|
||||
// 'type' => 'bool',
|
||||
// ), // PH_BLOG_LOAD_MASONRY
|
||||
|
||||
'PH_BLOG_LOAD_FITVIDS' => array(
|
||||
'title' => $this->l('Load FitVids from module?'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'required' => true,
|
||||
'type' => 'bool',
|
||||
), // PH_BLOG_LOAD_FITVIDS
|
||||
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$widgets_options = array();
|
||||
$widgets_options = array_merge($relatedPosts, array());
|
||||
|
||||
$import_settings = array(
|
||||
'import_settings' => array(
|
||||
'submit' => array('title' => $this->l('Import settings'), 'class' => 'button'),
|
||||
'title' => $this->l('Import settings'),
|
||||
'fields' => array(
|
||||
'PH_BLOG_IMPORT_SETTINGS' => array(
|
||||
'title' => $this->l('Paste here content of your settings file to import'),
|
||||
'show' => false,
|
||||
'required' => false,
|
||||
'type' => 'textarea',
|
||||
'cols' => '70',
|
||||
'rows' => '10',
|
||||
), // PH_BLOG_IMPORT_SETTINGS
|
||||
), ),
|
||||
);
|
||||
|
||||
//$this->hide_multishop_checkbox = true;
|
||||
$this->fields_options = array_merge($standard_options, $widgets_options, $import_settings);
|
||||
|
||||
return parent::renderOptions();
|
||||
}
|
||||
|
||||
public static function prepareValueForLangs($value)
|
||||
{
|
||||
$languages = Language::getLanguages(false);
|
||||
|
||||
$output = array();
|
||||
|
||||
foreach ($languages as $lang) {
|
||||
$output[$lang['id_lang']] = $value;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
public static function getValueForLangs($field)
|
||||
{
|
||||
$languages = Language::getLanguages(false);
|
||||
|
||||
$output = array();
|
||||
|
||||
foreach ($languages as $lang) {
|
||||
$output[$lang['id_lang']] = Configuration::get($field, $lang['id_lang']);
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
public function beforeUpdateOptions()
|
||||
{
|
||||
$importSettings = Tools::getValue('PH_BLOG_IMPORT_SETTINGS', false);
|
||||
|
||||
if (trim($importSettings) != '') {
|
||||
if (!is_array(unserialize($importSettings))) {
|
||||
die(Tools::displayError('File with settings is invalid'));
|
||||
}
|
||||
|
||||
$settings = unserialize($importSettings);
|
||||
$simple_fields = array();
|
||||
|
||||
foreach ($this->fields_options as $category_data) {
|
||||
if (!isset($category_data['fields'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($category_data['fields'] as $name => $field) {
|
||||
$simple_fields[$name] = $field;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($settings as $conf_name => $conf_value) {
|
||||
Configuration::deleteByName($conf_name);
|
||||
|
||||
// if($simple_fields[$conf_name]['type'] == 'textLang')
|
||||
// Configuration::updateValue($conf_name, self::prepareValueForLangs($conf_value));
|
||||
// else
|
||||
// Configuration::updateValue($conf_name, $conf_value);
|
||||
Configuration::updateValue($conf_name, $conf_value);
|
||||
}
|
||||
|
||||
Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=6');
|
||||
}
|
||||
|
||||
$customCSS = '/** custom css for SimpleBlog **/'.PHP_EOL;
|
||||
$customCSS .= Tools::getValue('PH_BLOG_CSS', false);
|
||||
|
||||
if ($customCSS) {
|
||||
$handle = _PS_MODULE_DIR_.'ph_simpleblog/css/custom.css';
|
||||
|
||||
if (!file_put_contents($handle, $customCSS)) {
|
||||
die(Tools::displayError('Problem with saving custom CSS, contact with module author'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
$this->multiple_fieldsets = true;
|
||||
|
||||
if (Tools::isSubmit('regenerateThumbnails')) {
|
||||
SimpleBlogPost::regenerateThumbnails();
|
||||
Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=9');
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('submitExportSettings')) {
|
||||
header('Content-type: text/plain');
|
||||
header('Content-Disposition: attachment; filename=ph_simpleblog_configuration_'.date('d-m-Y').'.txt');
|
||||
|
||||
$configs = array();
|
||||
foreach ($this->fields_options as $category_data) {
|
||||
if (!isset($category_data['fields'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$fields = $category_data['fields'];
|
||||
|
||||
foreach ($fields as $field => $values) {
|
||||
if ($values['type'] == 'textLang') {
|
||||
$configs[$field] = self::getValueForLangs($field);
|
||||
} else {
|
||||
$configs[$field] = Configuration::get($field);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo serialize($configs);
|
||||
|
||||
exit();
|
||||
}
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'content' => $this->content,
|
||||
'url_post' => self::$currentIndex.'&token='.$this->token,
|
||||
));
|
||||
|
||||
parent::initContent();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
/**
|
||||
* Blog for PrestaShop module by Krystian Podemski from PrestaHome.
|
||||
*
|
||||
* @author Krystian Podemski <krystian@prestahome.com>
|
||||
* @copyright Copyright (c) 2014-2016 Krystian Podemski - www.PrestaHome.com / www.Podemski.info
|
||||
* @license You only can use module, nothing more!
|
||||
*/
|
||||
require_once _PS_MODULE_DIR_ . 'ph_simpleblog/ph_simpleblog.php';
|
||||
class AdminSimpleBlogTagsController extends ModuleAdminController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'simpleblog_tag';
|
||||
$this->className = 'SimpleBlogTag';
|
||||
|
||||
$this->bootstrap = true;
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->fields_list = array(
|
||||
'id_simpleblog_tag' => array(
|
||||
'title' => $this->l('ID'),
|
||||
'align' => 'center',
|
||||
'width' => 25,
|
||||
),
|
||||
'lang' => array(
|
||||
'title' => $this->l('Language'),
|
||||
'filter_key' => 'l!name',
|
||||
'width' => 100,
|
||||
),
|
||||
'name' => array(
|
||||
'title' => $this->l('Name'),
|
||||
'width' => 'auto',
|
||||
'filter_key' => 'a!name'
|
||||
),
|
||||
'posts' => array(
|
||||
'title' => $this->l('Posts:'),
|
||||
'align' => 'center',
|
||||
'width' => 50,
|
||||
'havingFilter' => true
|
||||
)
|
||||
);
|
||||
|
||||
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
|
||||
}
|
||||
|
||||
public function renderList()
|
||||
{
|
||||
$this->addRowAction('edit');
|
||||
$this->addRowAction('delete');
|
||||
|
||||
$this->_select = 'l.name as lang, COUNT(pt.id_simpleblog_post) as posts';
|
||||
$this->_join = '
|
||||
LEFT JOIN `'._DB_PREFIX_.'simpleblog_post_tag` pt
|
||||
ON (a.`id_simpleblog_tag` = pt.`id_simpleblog_tag`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'lang` l
|
||||
ON (l.`id_lang` = a.`id_lang`)';
|
||||
$this->_group = 'GROUP BY a.name, a.id_lang';
|
||||
|
||||
return parent::renderList();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1' && Tools::getValue('submitAdd'.$this->table)) {
|
||||
if (($id = (int)Tools::getValue($this->identifier)) && ($obj = new $this->className($id)) && Validate::isLoadedObject($obj)) {
|
||||
$previousPosts = $obj->getPosts();
|
||||
$removedPosts = array();
|
||||
|
||||
foreach ($previousPosts as $post) {
|
||||
if (!in_array($post['id_simpleblog_post'], $_POST['posts'])) {
|
||||
$removedPosts[] = $post['id_simpleblog_post'];
|
||||
}
|
||||
}
|
||||
|
||||
$obj->setPosts($_POST['posts']);
|
||||
}
|
||||
}
|
||||
|
||||
return parent::postProcess();
|
||||
}
|
||||
|
||||
public function renderForm()
|
||||
{
|
||||
if (!($obj = $this->loadObject(true))) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fields_form = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('Tag')
|
||||
),
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Name:'),
|
||||
'name' => 'name',
|
||||
'required' => true
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Language:'),
|
||||
'name' => 'id_lang',
|
||||
'required' => true,
|
||||
'options' => array(
|
||||
'query' => Language::getLanguages(false),
|
||||
'id' => 'id_lang',
|
||||
'name' => 'name'
|
||||
)
|
||||
),
|
||||
),
|
||||
'selects' => array(
|
||||
'posts' => $obj->getPosts(true),
|
||||
'posts_unselected' => $obj->getPosts(false)
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l('Save'),
|
||||
'class' => 'button'
|
||||
)
|
||||
);
|
||||
|
||||
return parent::renderForm();
|
||||
}
|
||||
}
|
||||
35
modules/ph_simpleblog/controllers/admin/index.php
Normal file
35
modules/ph_simpleblog/controllers/admin/index.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
62
modules/ph_simpleblog/controllers/front/ajax.php
Normal file
62
modules/ph_simpleblog/controllers/front/ajax.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* Blog for PrestaShop module by Krystian Podemski from PrestaHome.
|
||||
*
|
||||
* @author Krystian Podemski <krystian@prestahome.com>
|
||||
* @copyright Copyright (c) 2008-2019 Krystian Podemski - www.PrestaHome.com / www.Podemski.info
|
||||
* @license You only can use module, nothing more!
|
||||
*/
|
||||
require_once _PS_MODULE_DIR_ . 'ph_simpleblog/ph_simpleblog.php';
|
||||
|
||||
class Ph_SimpleBlogAjaxModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
public $product;
|
||||
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (Module::isEnabled('ph_simpleblog')
|
||||
&& (Tools::getValue('action') == 'addRating' || Tools::getValue('action') == 'removeRating')
|
||||
&& Tools::getValue('secure_key') == $this->module->secure_key) {
|
||||
parent::postProcess();
|
||||
} else {
|
||||
die('Access denied');
|
||||
}
|
||||
}
|
||||
|
||||
public function displayAjaxAddRating()
|
||||
{
|
||||
$id_simpleblog_post = Tools::getValue('id_simpleblog_post');
|
||||
$reply = SimpleBlogPost::changeRating('up', (int) $id_simpleblog_post);
|
||||
$message = $reply[0]['likes'];
|
||||
$this->ajaxDie(
|
||||
json_encode(
|
||||
array(
|
||||
'hasError' => false,
|
||||
'status' => 'success',
|
||||
'message' => $message
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function displayAjaxRemoveRating()
|
||||
{
|
||||
$id_simpleblog_post = Tools::getValue('id_simpleblog_post');
|
||||
$reply = SimpleBlogPost::changeRating('down', (int) $id_simpleblog_post);
|
||||
$message = $reply[0]['likes'];
|
||||
$this->ajaxDie(
|
||||
json_encode(
|
||||
array(
|
||||
'hasError' => false,
|
||||
'status' => 'success',
|
||||
'message' => $message
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
76
modules/ph_simpleblog/controllers/front/author-v16.php
Normal file
76
modules/ph_simpleblog/controllers/front/author-v16.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* Blog for PrestaShop module by Krystian Podemski from PrestaHome.
|
||||
*
|
||||
* @author Krystian Podemski <krystian@prestahome.com>
|
||||
* @copyright Copyright (c) 2008-2019 Krystian Podemski - www.PrestaHome.com / www.Podemski.info
|
||||
* @license You only can use module, nothing more!
|
||||
*/
|
||||
|
||||
class PH_SimpleBlogAuthorModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
protected $SimpleBlogAuthor;
|
||||
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
// Get Post by link_rewrite
|
||||
$id_simpleblog_author = Tools::getValue('author_id');
|
||||
|
||||
|
||||
if ($id_simpleblog_author && Validate::isUnsignedInt($id_simpleblog_author)) {
|
||||
$author = new SimpleBlogPostAuthor($id_simpleblog_author, (int) Context::getContext()->language->id);
|
||||
if (!Validate::isLoadedObject($author)) {
|
||||
Tools::redirect('index.php?controller=404');
|
||||
} else {
|
||||
$this->SimpleBlogAuthor = $author;
|
||||
}
|
||||
} else {
|
||||
die('Blog for PrestaShop: URL is not valid');
|
||||
}
|
||||
|
||||
|
||||
// Assign meta tags
|
||||
$this->assignMetas();
|
||||
}
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
// Assign JS and CSS for single post page
|
||||
$this->addModulePageAssets();
|
||||
|
||||
parent::initContent();
|
||||
|
||||
// Smarty variables
|
||||
$this->context->smarty->assign('is_16', true);
|
||||
$this->context->smarty->assign('author', $this->SimpleBlogAuthor);
|
||||
|
||||
$this->setTemplate('author.tpl');
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign meta tags to single post page.
|
||||
*/
|
||||
protected function assignMetas()
|
||||
{
|
||||
$this->context->smarty->assign('meta_title', sprintf($this->module->l('Posts by %s', 'author-v16'), $this->SimpleBlogAuthor->firstname));
|
||||
}
|
||||
|
||||
/**
|
||||
* CSS, JS and other assets for this page.
|
||||
*/
|
||||
protected function addModulePageAssets()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return SimpleBlogPost object
|
||||
* @return object
|
||||
*/
|
||||
public function getAuthor()
|
||||
{
|
||||
return $this->SimpleBlogAuthor;
|
||||
}
|
||||
}
|
||||
76
modules/ph_simpleblog/controllers/front/author-v17.php
Normal file
76
modules/ph_simpleblog/controllers/front/author-v17.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* Blog for PrestaShop module by Krystian Podemski from PrestaHome.
|
||||
*
|
||||
* @author Krystian Podemski <krystian@prestahome.com>
|
||||
* @copyright Copyright (c) 2008-2019 Krystian Podemski - www.PrestaHome.com / www.Podemski.info
|
||||
* @license You only can use module, nothing more!
|
||||
*/
|
||||
|
||||
class PH_SimpleBlogAuthorModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
protected $SimpleBlogAuthor;
|
||||
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
// Get Post by link_rewrite
|
||||
$id_simpleblog_author = Tools::getValue('author_id');
|
||||
|
||||
|
||||
if ($id_simpleblog_author && Validate::isUnsignedInt($id_simpleblog_author)) {
|
||||
$author = new SimpleBlogPostAuthor($id_simpleblog_author, (int) Context::getContext()->language->id);
|
||||
if (!Validate::isLoadedObject($author)) {
|
||||
Tools::redirect('index.php?controller=404');
|
||||
} else {
|
||||
$this->SimpleBlogAuthor = $author;
|
||||
}
|
||||
} else {
|
||||
die('Blog for PrestaShop: URL is not valid');
|
||||
}
|
||||
|
||||
|
||||
// Assign meta tags
|
||||
$this->assignMetas();
|
||||
}
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
// Assign JS and CSS for single post page
|
||||
$this->addModulePageAssets();
|
||||
|
||||
parent::initContent();
|
||||
|
||||
// Smarty variables
|
||||
$this->context->smarty->assign('is_16', true);
|
||||
$this->context->smarty->assign('author', $this->SimpleBlogAuthor);
|
||||
|
||||
$this->setTemplate('author.tpl');
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign meta tags to single post page.
|
||||
*/
|
||||
protected function assignMetas()
|
||||
{
|
||||
$this->context->smarty->assign('meta_title', sprintf($this->module->l('Posts by %s', 'author-v16'), $this->SimpleBlogAuthor->firstname));
|
||||
}
|
||||
|
||||
/**
|
||||
* CSS, JS and other assets for this page.
|
||||
*/
|
||||
protected function addModulePageAssets()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return SimpleBlogPost object
|
||||
* @return object
|
||||
*/
|
||||
public function getAuthor()
|
||||
{
|
||||
return $this->SimpleBlogAuthor;
|
||||
}
|
||||
}
|
||||
15
modules/ph_simpleblog/controllers/front/author.php
Normal file
15
modules/ph_simpleblog/controllers/front/author.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* Blog for PrestaShop module by Krystian Podemski from PrestaHome.
|
||||
*
|
||||
* @author Krystian Podemski <krystian@prestahome.com>
|
||||
* @copyright Copyright (c) 2008-2019 Krystian Podemski - www.PrestaHome.com / www.Podemski.info
|
||||
* @license You only can use module, nothing more!
|
||||
*/
|
||||
require_once _PS_MODULE_DIR_.'ph_simpleblog/ph_simpleblog.php';
|
||||
|
||||
if (version_compare(_PS_VERSION_, '1.7', '>=')) {
|
||||
include_once _PS_MODULE_DIR_.'ph_simpleblog/controllers/front/author-v17.php';
|
||||
} else {
|
||||
include_once _PS_MODULE_DIR_.'ph_simpleblog/controllers/front/author-v16.php';
|
||||
}
|
||||
52
modules/ph_simpleblog/controllers/front/authorslist-v16.php
Normal file
52
modules/ph_simpleblog/controllers/front/authorslist-v16.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* Blog for PrestaShop module by Krystian Podemski from PrestaHome.
|
||||
*
|
||||
* @author Krystian Podemski <krystian@prestahome.com>
|
||||
* @copyright Copyright (c) 2008-2019 Krystian Podemski - www.PrestaHome.com / www.Podemski.info
|
||||
* @license You only can use module, nothing more!
|
||||
*/
|
||||
|
||||
class PH_SimpleBlogAuthorsListModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
protected $blogAuthors;
|
||||
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
$this->blogAuthors = SimpleBlogPostAuthor::getAll();
|
||||
|
||||
// Assign meta tags
|
||||
$this->assignMetas();
|
||||
}
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
// Assign JS and CSS for single post page
|
||||
$this->addModulePageAssets();
|
||||
|
||||
parent::initContent();
|
||||
|
||||
$this->context->smarty->assign('authors', $this->blogAuthors);
|
||||
|
||||
$this->setTemplate('authors.tpl');
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign meta tags to single post page.
|
||||
*/
|
||||
protected function assignMetas()
|
||||
{
|
||||
$defaultMetaTitleForBlog = Configuration::get('PH_BLOG_MAIN_TITLE', $this->context->language->id);
|
||||
$this->context->smarty->assign('meta_title', $defaultMetaTitleForBlog.' - '.$this->module->l('Authors', 'authorslist-v16'));
|
||||
}
|
||||
|
||||
/**
|
||||
* CSS, JS and other assets for this page.
|
||||
*/
|
||||
protected function addModulePageAssets()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
76
modules/ph_simpleblog/controllers/front/authorslist-v17.php
Normal file
76
modules/ph_simpleblog/controllers/front/authorslist-v17.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* Blog for PrestaShop module by Krystian Podemski from PrestaHome.
|
||||
*
|
||||
* @author Krystian Podemski <krystian@prestahome.com>
|
||||
* @copyright Copyright (c) 2008-2019 Krystian Podemski - www.PrestaHome.com / www.Podemski.info
|
||||
* @license You only can use module, nothing more!
|
||||
*/
|
||||
|
||||
class PH_SimpleBlogAuthorModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
protected $SimpleBlogAuthor;
|
||||
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
// Get Post by link_rewrite
|
||||
$id_simpleblog_author = Tools::getValue('author_id');
|
||||
|
||||
|
||||
if ($id_simpleblog_author && Validate::isUnsignedInt($id_simpleblog_author)) {
|
||||
$author = new SimpleBlogPostAuthor($id_simpleblog_author, (int) Context::getContext()->language->id);
|
||||
if (!Validate::isLoadedObject($author)) {
|
||||
Tools::redirect('index.php?controller=404');
|
||||
} else {
|
||||
$this->SimpleBlogAuthor = $author;
|
||||
}
|
||||
} else {
|
||||
die('Blog for PrestaShop: URL is not valid');
|
||||
}
|
||||
|
||||
|
||||
// Assign meta tags
|
||||
$this->assignMetas();
|
||||
}
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
// Assign JS and CSS for single post page
|
||||
$this->addModulePageAssets();
|
||||
|
||||
parent::initContent();
|
||||
|
||||
// Smarty variables
|
||||
$this->context->smarty->assign('is_16', true);
|
||||
$this->context->smarty->assign('author', $this->SimpleBlogAuthor);
|
||||
|
||||
$this->setTemplate('author.tpl');
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign meta tags to single post page.
|
||||
*/
|
||||
protected function assignMetas()
|
||||
{
|
||||
$this->context->smarty->assign('meta_title', sprintf($this->module->l('Posts by %s', 'author-v16'), $this->SimpleBlogAuthor->firstname));
|
||||
}
|
||||
|
||||
/**
|
||||
* CSS, JS and other assets for this page.
|
||||
*/
|
||||
protected function addModulePageAssets()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return SimpleBlogPost object
|
||||
* @return object
|
||||
*/
|
||||
public function getAuthor()
|
||||
{
|
||||
return $this->SimpleBlogAuthor;
|
||||
}
|
||||
}
|
||||
15
modules/ph_simpleblog/controllers/front/authorslist.php
Normal file
15
modules/ph_simpleblog/controllers/front/authorslist.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* Blog for PrestaShop module by Krystian Podemski from PrestaHome.
|
||||
*
|
||||
* @author Krystian Podemski <krystian@prestahome.com>
|
||||
* @copyright Copyright (c) 2008-2019 Krystian Podemski - www.PrestaHome.com / www.Podemski.info
|
||||
* @license You only can use module, nothing more!
|
||||
*/
|
||||
require_once _PS_MODULE_DIR_.'ph_simpleblog/ph_simpleblog.php';
|
||||
|
||||
if (version_compare(_PS_VERSION_, '1.7', '>=')) {
|
||||
include_once _PS_MODULE_DIR_.'ph_simpleblog/controllers/front/authorslist-v17.php';
|
||||
} else {
|
||||
include_once _PS_MODULE_DIR_.'ph_simpleblog/controllers/front/authorslist-v16.php';
|
||||
}
|
||||
14
modules/ph_simpleblog/controllers/front/category.php
Normal file
14
modules/ph_simpleblog/controllers/front/category.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* Blog for PrestaShop module by Krystian Podemski from PrestaHome.
|
||||
*
|
||||
* @author Krystian Podemski <krystian@prestahome.com>
|
||||
* @copyright Copyright (c) 2014-2017 Krystian Podemski - www.PrestaHome.com / www.Podemski.info
|
||||
* @license You only can use module, nothing more!
|
||||
*/
|
||||
require_once _PS_MODULE_DIR_.'ph_simpleblog/ph_simpleblog.php';
|
||||
require_once _PS_MODULE_DIR_.'ph_simpleblog/controllers/front/list.php';
|
||||
|
||||
class PH_SimpleBlogCategoryModuleFrontController extends ph_simplebloglistModuleFrontController
|
||||
{
|
||||
}
|
||||
23
modules/ph_simpleblog/controllers/front/categorypage.php
Normal file
23
modules/ph_simpleblog/controllers/front/categorypage.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* Blog for PrestaShop module by Krystian Podemski from PrestaHome.
|
||||
*
|
||||
* @author Krystian Podemski <krystian@prestahome.com>
|
||||
* @copyright Copyright (c) 2014-2017 Krystian Podemski - www.PrestaHome.com / www.Podemski.info
|
||||
* @license You only can use module, nothing more!
|
||||
*/
|
||||
require_once _PS_MODULE_DIR_.'ph_simpleblog/ph_simpleblog.php';
|
||||
require_once _PS_MODULE_DIR_.'ph_simpleblog/controllers/front/list.php';
|
||||
|
||||
class PH_SimpleBlogCategoryPageModuleFrontController extends ph_simplebloglistModuleFrontController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
if (!version_compare(_PS_VERSION_, '1.7', '>=')) {
|
||||
$this->display_column_left = (is_object(Context::getContext()->theme) ? Context::getContext()->theme->hasLeftColumn('module-ph_simpleblog-list') : true);
|
||||
$this->display_column_right = (is_object(Context::getContext()->theme) ? Context::getContext()->theme->hasRightColumn('module-ph_simpleblog-list') : true);
|
||||
}
|
||||
}
|
||||
}
|
||||
35
modules/ph_simpleblog/controllers/front/index.php
Normal file
35
modules/ph_simpleblog/controllers/front/index.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2013 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
219
modules/ph_simpleblog/controllers/front/list-v16.php
Normal file
219
modules/ph_simpleblog/controllers/front/list-v16.php
Normal file
@@ -0,0 +1,219 @@
|
||||
<?php
|
||||
/**
|
||||
* Blog for PrestaShop module by Krystian Podemski from PrestaHome.
|
||||
*
|
||||
* @author Krystian Podemski <krystian@prestahome.com>
|
||||
* @copyright Copyright (c) 2008-2019 Krystian Podemski - www.PrestaHome.com / www.Podemski.info
|
||||
* @license You only can use module, nothing more!
|
||||
*/
|
||||
|
||||
class PH_SimpleBlogListModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
public $context;
|
||||
public $sb_category = false;
|
||||
public $simpleblog_search;
|
||||
public $simpleblog_keyword;
|
||||
public $is_search = false;
|
||||
public $is_category = false;
|
||||
|
||||
public $posts_per_page;
|
||||
public $n;
|
||||
public $p;
|
||||
|
||||
private $blogCategory;
|
||||
|
||||
private $listController;
|
||||
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
$sb_category = Tools::getValue('sb_category');
|
||||
$simpleblog_search = Tools::getValue('simpleblog_search');
|
||||
$simpleblog_keyword = Tools::getValue('simpleblog_keyword');
|
||||
$this->listController = Tools::getValue('controller');
|
||||
|
||||
if ($sb_category) {
|
||||
$this->sb_category = $sb_category;
|
||||
$this->is_category = true;
|
||||
}
|
||||
|
||||
if ($this->listController == 'category' && !$this->sb_category) {
|
||||
Tools::redirect($this->context->link->getModuleLink('ph_simpleblog', 'list'));
|
||||
}
|
||||
|
||||
if ($simpleblog_search && $simpleblog_keyword) {
|
||||
$this->simpleblog_search = $simpleblog_search;
|
||||
$this->simpleblog_keyword = $simpleblog_keyword;
|
||||
$this->is_search = true;
|
||||
}
|
||||
|
||||
$this->posts_per_page = Configuration::get('PH_BLOG_POSTS_PER_PAGE');
|
||||
$this->p = (int) Tools::getValue('p', 0);
|
||||
|
||||
$this->context = Context::getContext();
|
||||
}
|
||||
|
||||
public function assignGeneralPurposesVariables()
|
||||
{
|
||||
$gridType = Configuration::get('PH_BLOG_COLUMNS');
|
||||
$gridColumns = Configuration::get('PH_BLOG_GRID_COLUMNS');
|
||||
$blogLayout = Configuration::get('PH_BLOG_LIST_LAYOUT');
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'categories' => SimpleBlogCategory::getCategories((int) $this->context->language->id),
|
||||
'blogMainTitle' => Configuration::get('PH_BLOG_MAIN_TITLE', (int) $this->context->language->id),
|
||||
'grid' => Configuration::get('PH_BLOG_COLUMNS'),
|
||||
'columns' => $gridColumns,
|
||||
'blogLayout' => $blogLayout,
|
||||
'module_dir' => _MODULE_DIR_.'ph_simpleblog/',
|
||||
'tpl_path' => _PS_MODULE_DIR_.'ph_simpleblog/views/templates/front/',
|
||||
'gallery_dir' => _MODULE_DIR_.'ph_simpleblog/galleries/',
|
||||
'is_category' => false,
|
||||
'is_search' => false,
|
||||
'shopLogo' => $this->context->link->getMediaLink(_PS_IMG_.Configuration::get('PS_LOGO')),
|
||||
'shopUrl' => $this->context->shop->getBaseURL(true, false),
|
||||
));
|
||||
}
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
$id_lang = $this->context->language->id;
|
||||
|
||||
parent::initContent();
|
||||
|
||||
$this->context->smarty->assign('is_16', (bool) (version_compare(_PS_VERSION_, '1.6.0', '>=') === true));
|
||||
|
||||
$this->assignGeneralPurposesVariables();
|
||||
|
||||
// Category things
|
||||
if ($this->sb_category != '') {
|
||||
$this->context->smarty->assign('is_category', true);
|
||||
|
||||
$SimpleBlogCategory = SimpleBlogCategory::getByRewrite($this->sb_category, $id_lang);
|
||||
|
||||
// Category not found so now we are looking for categories in same rewrite but other languages and if we found something, then we redirect 301
|
||||
if (!Validate::isLoadedObject($SimpleBlogCategory)) {
|
||||
$SimpleBlogCategory = SimpleBlogCategory::getByRewrite($this->sb_category, false);
|
||||
|
||||
if (Validate::isLoadedObject($SimpleBlogCategory)) {
|
||||
$SimpleBlogCategory = new SimpleBlogCategory($SimpleBlogCategory->id, $id_lang);
|
||||
header('HTTP/1.1 301 Moved Permanently');
|
||||
header('Location: '.SimpleBlogCategory::getLink($SimpleBlogCategory->link_rewrite));
|
||||
} else {
|
||||
header('HTTP/1.1 404 Not Found');
|
||||
header('Status: 404 Not Found');
|
||||
Tools::redirect($this->context->link->getPageLink('404'));
|
||||
}
|
||||
}
|
||||
|
||||
$this->blogCategory = $SimpleBlogCategory;
|
||||
|
||||
if ($SimpleBlogCategory->id_parent > 0) {
|
||||
$parent = new SimpleBlogCategory($SimpleBlogCategory->id_parent, $id_lang);
|
||||
$this->context->smarty->assign('parent_category', $parent);
|
||||
}
|
||||
|
||||
$finder = new BlogPostsFinder();
|
||||
$finder->setIdCategory($SimpleBlogCategory->id);
|
||||
$posts = $finder->findPosts();
|
||||
|
||||
$this->context->smarty->assign('blogCategory', $SimpleBlogCategory);
|
||||
$this->context->smarty->assign('category_rewrite', $SimpleBlogCategory->link_rewrite);
|
||||
} else {
|
||||
$finder = new BlogPostsFinder();
|
||||
$posts = $finder->findPosts();
|
||||
}
|
||||
|
||||
$this->assignPagination($this->posts_per_page, sizeof($posts));
|
||||
$posts = array_splice($posts, $this->p ? ($this->p - 1) * $this->posts_per_page : 0, $this->posts_per_page);
|
||||
|
||||
$this->assignMetas();
|
||||
|
||||
$this->context->smarty->assign('posts', $posts);
|
||||
|
||||
if (version_compare(_PS_VERSION_, '1.7', '>=')) {
|
||||
$this->setTemplate('module:ph_simpleblog/views/templates/front/1.7/list.tpl');
|
||||
} else {
|
||||
$this->setTemplate('list.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
public function assignMetas()
|
||||
{
|
||||
$defaultMetaTitleForBlog = Configuration::get('PH_BLOG_MAIN_TITLE', $this->context->language->id);
|
||||
$defaultMetaDescriptionForBlog = Configuration::get('PH_BLOG_MAIN_META_DESCRIPTION', $this->context->language->id);
|
||||
|
||||
if ($this->sb_category) {
|
||||
$meta_title = $this->blogCategory->name.' - '.Configuration::get('PS_SHOP_NAME');
|
||||
} else {
|
||||
if (empty($defaultMetaTitleForBlog)) {
|
||||
$meta_title = Configuration::get('PS_SHOP_NAME').' - '.$this->module->l('Blog', 'list-v16');
|
||||
} else {
|
||||
$meta_title = $defaultMetaTitleForBlog;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->sb_category) {
|
||||
if (!empty($this->blogCategory->meta_description)) {
|
||||
$meta_description = $this->blogCategory->meta_description;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->p > 1) {
|
||||
$meta_title .= ' ('.$this->p.')';
|
||||
}
|
||||
|
||||
$this->context->smarty->assign('meta_title', $meta_title);
|
||||
|
||||
if (!empty($meta_description)) {
|
||||
$this->context->smarty->assign('meta_description', strip_tags($meta_description));
|
||||
}
|
||||
}
|
||||
|
||||
public function assignPagination($limit, $nbPosts)
|
||||
{
|
||||
$this->n = $limit;
|
||||
$this->p = abs((int) Tools::getValue('p', 1));
|
||||
|
||||
$current_url = tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']);
|
||||
//delete parameter page
|
||||
$current_url = preg_replace('/(\?)?(&)?p=\d+/', '$1', $current_url);
|
||||
|
||||
$range = 2; /* how many pages around page selected */
|
||||
|
||||
if ($this->p < 1) {
|
||||
$this->p = 1;
|
||||
}
|
||||
|
||||
$pages_nb = ceil($nbPosts / (int) $this->n);
|
||||
|
||||
$start = (int) ($this->p - $range);
|
||||
|
||||
if ($start < 1) {
|
||||
$start = 1;
|
||||
}
|
||||
$stop = (int) ($this->p + $range);
|
||||
|
||||
if ($stop > $pages_nb) {
|
||||
$stop = (int) $pages_nb;
|
||||
}
|
||||
$this->context->smarty->assign('nb_posts', $nbPosts);
|
||||
$pagination_infos = array(
|
||||
'products_per_page' => $limit,
|
||||
'pages_nb' => $pages_nb,
|
||||
'p' => $this->p,
|
||||
'n' => $this->n,
|
||||
'range' => $range,
|
||||
'start' => $start,
|
||||
'stop' => $stop,
|
||||
'current_url' => $current_url,
|
||||
);
|
||||
$this->context->smarty->assign($pagination_infos);
|
||||
}
|
||||
|
||||
public function getBlogCategory()
|
||||
{
|
||||
return $this->blogCategory;
|
||||
}
|
||||
}
|
||||
287
modules/ph_simpleblog/controllers/front/list-v17.php
Normal file
287
modules/ph_simpleblog/controllers/front/list-v17.php
Normal file
@@ -0,0 +1,287 @@
|
||||
<?php
|
||||
/**
|
||||
* Blog for PrestaShop module by Krystian Podemski from PrestaHome.
|
||||
*
|
||||
* @author Krystian Podemski <krystian@prestahome.com>
|
||||
* @copyright Copyright (c) 2008-2019 Krystian Podemski - www.PrestaHome.com / www.Podemski.info
|
||||
* @license You only can use module, nothing more!
|
||||
*/
|
||||
|
||||
class PH_SimpleBlogListModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
public $context;
|
||||
public $sb_category = false;
|
||||
public $simpleblog_search;
|
||||
public $simpleblog_keyword;
|
||||
public $is_search = false;
|
||||
public $is_category = false;
|
||||
|
||||
public $posts_per_page;
|
||||
public $n;
|
||||
public $p;
|
||||
|
||||
private $blogCategory;
|
||||
|
||||
private $listController;
|
||||
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
$sb_category = Tools::getValue('sb_category');
|
||||
$module_controller = Tools::getValue('controller');
|
||||
$simpleblog_search = Tools::getValue('simpleblog_search');
|
||||
$simpleblog_keyword = Tools::getValue('simpleblog_keyword');
|
||||
$this->listController = Tools::getValue('controller');
|
||||
|
||||
if ($sb_category) {
|
||||
$this->sb_category = $sb_category;
|
||||
$this->is_category = true;
|
||||
}
|
||||
|
||||
|
||||
if ($this->listController == 'category' && !$this->sb_category) {
|
||||
Tools::redirect($this->context->link->getModuleLink('ph_simpleblog', 'list'));
|
||||
}
|
||||
|
||||
if ($simpleblog_search && $simpleblog_keyword) {
|
||||
$this->simpleblog_search = $simpleblog_search;
|
||||
$this->simpleblog_keyword = $simpleblog_keyword;
|
||||
$this->is_search = true;
|
||||
}
|
||||
|
||||
$this->posts_per_page = Configuration::get('PH_BLOG_POSTS_PER_PAGE');
|
||||
$this->p = (int) Tools::getValue('p', 0);
|
||||
|
||||
$this->context = Context::getContext();
|
||||
}
|
||||
|
||||
public function assignGeneralPurposesVariables()
|
||||
{
|
||||
$gridType = Configuration::get('PH_BLOG_COLUMNS');
|
||||
$gridColumns = Configuration::get('PH_BLOG_GRID_COLUMNS');
|
||||
$blogLayout = Configuration::get('PH_BLOG_LIST_LAYOUT');
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'categories' => SimpleBlogCategory::getCategories((int) $this->context->language->id),
|
||||
'blogMainTitle' => Configuration::get('PH_BLOG_MAIN_TITLE', (int) $this->context->language->id),
|
||||
'grid' => Configuration::get('PH_BLOG_COLUMNS'),
|
||||
'columns' => $gridColumns,
|
||||
'blogLayout' => $blogLayout,
|
||||
'module_dir' => _MODULE_DIR_.'ph_simpleblog/',
|
||||
'tpl_path' => _PS_MODULE_DIR_.'ph_simpleblog/views/templates/front/',
|
||||
'gallery_dir' => _MODULE_DIR_.'ph_simpleblog/galleries/',
|
||||
'is_category' => $this->is_category,
|
||||
'is_search' => $this->is_search,
|
||||
));
|
||||
}
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
$id_lang = $this->context->language->id;
|
||||
|
||||
parent::initContent();
|
||||
|
||||
$this->context->smarty->assign('is_16', (bool) (version_compare(_PS_VERSION_, '1.6.0', '>=') === true));
|
||||
|
||||
$this->assignGeneralPurposesVariables();
|
||||
|
||||
// Category things
|
||||
if ($this->sb_category != '') {
|
||||
$SimpleBlogCategory = SimpleBlogCategory::getByRewrite($this->sb_category, $id_lang);
|
||||
|
||||
// Category not found so now we are looking for categories in same rewrite but other languages and if we found something, then we redirect 301
|
||||
if (!Validate::isLoadedObject($SimpleBlogCategory)) {
|
||||
$SimpleBlogCategory = SimpleBlogCategory::getByRewrite($this->sb_category, false);
|
||||
|
||||
if (Validate::isLoadedObject($SimpleBlogCategory)) {
|
||||
$SimpleBlogCategory = new SimpleBlogCategory($SimpleBlogCategory->id, $id_lang);
|
||||
header('HTTP/1.1 301 Moved Permanently');
|
||||
header('Location: '.SimpleBlogCategory::getLink($SimpleBlogCategory->link_rewrite));
|
||||
} else {
|
||||
header('HTTP/1.1 404 Not Found');
|
||||
header('Status: 404 Not Found');
|
||||
Tools::redirect($this->context->link->getPageLink('404'));
|
||||
}
|
||||
}
|
||||
|
||||
$this->blogCategory = $SimpleBlogCategory;
|
||||
|
||||
if ($SimpleBlogCategory->id_parent > 0) {
|
||||
$parent = new SimpleBlogCategory($SimpleBlogCategory->id_parent, $id_lang);
|
||||
$this->context->smarty->assign('parent_category', $parent);
|
||||
}
|
||||
|
||||
$finder = new BlogPostsFinder();
|
||||
$finder->setIdCategory($SimpleBlogCategory->id);
|
||||
$posts = $finder->findPosts();
|
||||
|
||||
$this->context->smarty->assign('blogCategory', $SimpleBlogCategory);
|
||||
$this->context->smarty->assign('category_rewrite', $SimpleBlogCategory->link_rewrite);
|
||||
} elseif ($this->is_search) {
|
||||
// @todo: complete refactoring "authors" to 2.0.0
|
||||
// Posts by author
|
||||
$this->context->smarty->assign('is_search', true);
|
||||
|
||||
// echo SimpleBlogPost::getSearchLink('author', 'kpodemski', $id_lang);
|
||||
// @todo: meta titles, blog title, specific layout
|
||||
switch ($this->simpleblog_search) {
|
||||
case 'author':
|
||||
break;
|
||||
case 'tag':
|
||||
break;
|
||||
}
|
||||
|
||||
$this->context->smarty->assign('meta_title', $this->l('Posts by', 'list-v17').' '.$this->simpleblog_author.' - '.$this->l('Blog', 'list-v17'));
|
||||
|
||||
$posts = SimpleBlogPost::findPosts($this->simpleblog_search, $this->simpleblog_keyword, $id_lang, $this->posts_per_page, $this->p);
|
||||
|
||||
$this->assignPagination($this->posts_per_page, sizeof(SimpleBlogPost::findPosts($this->simpleblog_search, $this->simpleblog_keyword, $id_lang)));
|
||||
|
||||
$this->context->smarty->assign('posts', $posts);
|
||||
} else {
|
||||
$finder = new BlogPostsFinder();
|
||||
$posts = $finder->findPosts();
|
||||
// if (Tools::getValue('y', 0)) {
|
||||
// // archive
|
||||
// $ids = [];
|
||||
|
||||
// foreach ($posts as $key => $post) {
|
||||
// $dateAdd = strtotime($post['date_add']);
|
||||
// if (date('Y', $dateAdd) != (int) Tools::getValue('y')) {
|
||||
// unset($posts[$key]);
|
||||
// } else {
|
||||
// $ids[] = $post['id_simpleblog_post'];
|
||||
// }
|
||||
// }
|
||||
|
||||
// $posts = SimpleBlogPost::getPosts($id_lang, $this->posts_per_page, null, $this->p, true, false, false, null, false, false, null, 'IN', $ids);
|
||||
// } else {
|
||||
// $posts = SimpleBlogPost::getPosts($id_lang, $this->posts_per_page, null, $this->p);
|
||||
// }
|
||||
}
|
||||
|
||||
$this->assignPagination($this->posts_per_page, sizeof($posts));
|
||||
$posts = array_splice($posts, $this->p ? ($this->p - 1) * $this->posts_per_page : 0, $this->posts_per_page);
|
||||
|
||||
$this->assignMetas();
|
||||
|
||||
$this->context->smarty->assign('posts', $posts);
|
||||
|
||||
if (version_compare(_PS_VERSION_, '1.7', '>=')) {
|
||||
$this->setTemplate('module:ph_simpleblog/views/templates/front/1.7/list.tpl');
|
||||
} else {
|
||||
$this->setTemplate('list.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
public function assignMetas()
|
||||
{
|
||||
$pageVariables = $this->getTemplateVarPage();
|
||||
$defaultMetaTitleForBlog = Configuration::get('PH_BLOG_MAIN_TITLE', $this->context->language->id);
|
||||
$defaultMetaDescriptionForBlog = Configuration::get('PH_BLOG_MAIN_META_DESCRIPTION', $this->context->language->id);
|
||||
|
||||
if ($this->sb_category) {
|
||||
$meta_title = $this->blogCategory->name.' - '.$pageVariables['meta']['title'];
|
||||
if (!empty($this->blogCategory->meta_title)) {
|
||||
$meta_title = $this->blogCategory->meta_title.' - '.$pageVariables['meta']['title'];
|
||||
}
|
||||
} else {
|
||||
if (empty($defaultMetaTitleForBlog)) {
|
||||
$meta_title = $pageVariables['meta']['title'].' '.$this->l('Blog', 'list-v17');
|
||||
} else {
|
||||
$meta_title = $defaultMetaTitleForBlog;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->sb_category) {
|
||||
if (!empty($this->blogCategory->meta_description)) {
|
||||
$meta_description = $this->blogCategory->meta_description;
|
||||
} else {
|
||||
$meta_description = $pageVariables['meta']['description'];
|
||||
}
|
||||
} else {
|
||||
$meta_description = empty($defaultMetaDescriptionForBlog) ? $pageVariables['meta']['description'] : $defaultMetaDescriptionForBlog;
|
||||
}
|
||||
|
||||
if ($this->p > 1) {
|
||||
$meta_title .= ' ('.$this->p.')';
|
||||
}
|
||||
|
||||
$this->context->smarty->assign('meta_title', $meta_title);
|
||||
$this->context->smarty->assign('meta_description', strip_tags($meta_description));
|
||||
}
|
||||
|
||||
public function getBreadcrumbLinks()
|
||||
{
|
||||
$breadcrumb = parent::getBreadcrumbLinks();
|
||||
|
||||
$id_lang = $this->context->language->id;
|
||||
|
||||
$breadcrumb['links'][] = [
|
||||
'title' => $this->l('Blog'),
|
||||
'url' => $this->context->link->getModuleLink('ph_simpleblog', 'list'),
|
||||
];
|
||||
|
||||
if ($this->sb_category != '') {
|
||||
$SimpleBlogCategory = SimpleBlogCategory::getByRewrite($this->sb_category, $id_lang);
|
||||
// Category not found so now we looking for categories in same rewrite but other languages and if we found then we redirect 301
|
||||
if (!Validate::isLoadedObject($SimpleBlogCategory)) {
|
||||
$SimpleBlogCategory = SimpleBlogCategory::getByRewrite($this->sb_category, false);
|
||||
}
|
||||
|
||||
$breadcrumb['links'][] = [
|
||||
'title' => $SimpleBlogCategory->name,
|
||||
'url' => $SimpleBlogCategory->link_rewrite,
|
||||
];
|
||||
}
|
||||
|
||||
return $breadcrumb;
|
||||
}
|
||||
|
||||
public function assignPagination($limit, $nbPosts)
|
||||
{
|
||||
$this->n = $limit;
|
||||
$this->p = abs((int) Tools::getValue('p', 1));
|
||||
|
||||
$current_url = tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']);
|
||||
//delete parameter page
|
||||
$current_url = preg_replace('/(\?)?(&)?p=\d+/', '$1', $current_url);
|
||||
|
||||
$range = 2; /* how many pages around page selected */
|
||||
|
||||
if ($this->p < 1) {
|
||||
$this->p = 1;
|
||||
}
|
||||
|
||||
$pages_nb = ceil($nbPosts / (int) $this->n);
|
||||
|
||||
$start = (int) ($this->p - $range);
|
||||
|
||||
if ($start < 1) {
|
||||
$start = 1;
|
||||
}
|
||||
$stop = (int) ($this->p + $range);
|
||||
|
||||
if ($stop > $pages_nb) {
|
||||
$stop = (int) $pages_nb;
|
||||
}
|
||||
$this->context->smarty->assign('nb_posts', $nbPosts);
|
||||
$pagination_infos = array(
|
||||
'products_per_page' => $limit,
|
||||
'pages_nb' => $pages_nb,
|
||||
'p' => $this->p,
|
||||
'n' => $this->n,
|
||||
'range' => $range,
|
||||
'start' => $start,
|
||||
'stop' => $stop,
|
||||
'current_url' => $current_url,
|
||||
);
|
||||
$this->context->smarty->assign($pagination_infos);
|
||||
}
|
||||
|
||||
public function getBlogCategory()
|
||||
{
|
||||
return $this->blogCategory;
|
||||
}
|
||||
}
|
||||
15
modules/ph_simpleblog/controllers/front/list.php
Normal file
15
modules/ph_simpleblog/controllers/front/list.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* Blog for PrestaShop module by Krystian Podemski from PrestaHome.
|
||||
*
|
||||
* @author Krystian Podemski <krystian@prestahome.com>
|
||||
* @copyright Copyright (c) 2008-2019 Krystian Podemski - www.PrestaHome.com / www.Podemski.info
|
||||
* @license You only can use module, nothing more!
|
||||
*/
|
||||
require_once _PS_MODULE_DIR_.'ph_simpleblog/ph_simpleblog.php';
|
||||
|
||||
if (version_compare(_PS_VERSION_, '1.7', '>=')) {
|
||||
include_once _PS_MODULE_DIR_.'ph_simpleblog/controllers/front/list-v17.php';
|
||||
} else {
|
||||
include_once _PS_MODULE_DIR_.'ph_simpleblog/controllers/front/list-v16.php';
|
||||
}
|
||||
23
modules/ph_simpleblog/controllers/front/page.php
Normal file
23
modules/ph_simpleblog/controllers/front/page.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* Blog for PrestaShop module by Krystian Podemski from PrestaHome.
|
||||
*
|
||||
* @author Krystian Podemski <krystian@prestahome.com>
|
||||
* @copyright Copyright (c) 2014-2017 Krystian Podemski - www.PrestaHome.com / www.Podemski.info
|
||||
* @license You only can use module, nothing more!
|
||||
*/
|
||||
require_once _PS_MODULE_DIR_.'ph_simpleblog/ph_simpleblog.php';
|
||||
require_once _PS_MODULE_DIR_.'ph_simpleblog/controllers/front/list.php';
|
||||
|
||||
class ph_simpleblogpageModuleFrontController extends ph_simplebloglistModuleFrontController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
if (!version_compare(_PS_VERSION_, '1.7', '>=')) {
|
||||
$this->display_column_left = (is_object(Context::getContext()->theme) ? Context::getContext()->theme->hasLeftColumn('module-ph_simpleblog-list') : true);
|
||||
$this->display_column_right = (is_object(Context::getContext()->theme) ? Context::getContext()->theme->hasRightColumn('module-ph_simpleblog-list') : true);
|
||||
}
|
||||
}
|
||||
}
|
||||
301
modules/ph_simpleblog/controllers/front/single-v16.php
Normal file
301
modules/ph_simpleblog/controllers/front/single-v16.php
Normal file
@@ -0,0 +1,301 @@
|
||||
<?php
|
||||
/**
|
||||
* Blog for PrestaShop module by Krystian Podemski from PrestaHome.
|
||||
*
|
||||
* @author Krystian Podemski <krystian@prestahome.com>
|
||||
* @copyright Copyright (c) 2008-2019 Krystian Podemski - www.PrestaHome.com / www.Podemski.info
|
||||
* @license You only can use module, nothing more!
|
||||
*/
|
||||
|
||||
class PH_SimpleBlogSingleModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
protected $SimpleBlogPost;
|
||||
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
// Get Post by link_rewrite
|
||||
$simpleblog_post_rewrite = Tools::getValue('rewrite');
|
||||
|
||||
if ($simpleblog_post_rewrite && Validate::isLinkRewrite($simpleblog_post_rewrite)) {
|
||||
$this->simpleblog_post_rewrite = $simpleblog_post_rewrite;
|
||||
} else {
|
||||
die('Blog for PrestaShop: URL is not valid');
|
||||
}
|
||||
|
||||
$SimpleBlogPost = SimpleBlogPost::getByRewrite($this->simpleblog_post_rewrite, (int) Context::getContext()->language->id);
|
||||
|
||||
// Check for matching current url with post url informations
|
||||
if (!Validate::isLoadedObject($SimpleBlogPost) || Validate::isLoadedObject($SimpleBlogPost) && !$SimpleBlogPost->active) {
|
||||
Tools::redirect('index.php?controller=404');
|
||||
}
|
||||
|
||||
if (Validate::isLoadedObject($SimpleBlogPost)
|
||||
&& $this->simpleblog_post_rewrite != $SimpleBlogPost->link_rewrite
|
||||
|| Tools::getValue('sb_category') != $SimpleBlogPost->category_rewrite) {
|
||||
header('HTTP/1.1 301 Moved Permanently');
|
||||
header('Location: '.SimpleBlogPost::getLink($SimpleBlogPost->link_rewrite, $SimpleBlogPost->category_rewrite));
|
||||
}
|
||||
|
||||
// There you go, our blog post
|
||||
$this->SimpleBlogPost = $SimpleBlogPost;
|
||||
|
||||
// Check access to post
|
||||
if (!$this->SimpleBlogPost->isAccessGranted()) {
|
||||
Tools::redirect('index.php?controller=404');
|
||||
}
|
||||
|
||||
// Assign meta tags
|
||||
$this->assignMetas();
|
||||
}
|
||||
|
||||
public function checkForSmartShortcodeAddons()
|
||||
{
|
||||
$context = Context::getContext();
|
||||
$dir = _PS_MODULE_DIR_.'smartshortcode/addons';
|
||||
|
||||
if (is_dir($dir)) {
|
||||
if ($dh = opendir($dir)) {
|
||||
while (($file = readdir($dh)) !== false) {
|
||||
if ($file != '.' && $file != '..') {
|
||||
if (is_dir("{$dir}/{$file}/front")) {
|
||||
include_once "{$dir}/{$file}/front/shortcode.php";
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
// Assign JS and CSS for single post page
|
||||
$this->addModulePageAssets();
|
||||
|
||||
parent::initContent();
|
||||
|
||||
// Increase post views
|
||||
$this->SimpleBlogPost->increaseViewsNb();
|
||||
|
||||
// Support for SmartShortcode module from CodeCanyon
|
||||
$this->supportThirdPartyPlugins();
|
||||
|
||||
// Smarty variables
|
||||
$this->context->smarty->assign('is_16', true);
|
||||
$this->context->smarty->assign('post', $this->SimpleBlogPost);
|
||||
$this->context->smarty->assign('guest', (int) $this->context->cookie->id_guest);
|
||||
$this->context->smarty->assign('gallery_dir', _MODULE_DIR_.'ph_simpleblog/galleries/');
|
||||
|
||||
// Comments
|
||||
$this->prepareCommentsSection();
|
||||
|
||||
// Related products
|
||||
if (Configuration::get('PH_BLOG_DISPLAY_RELATED')) {
|
||||
$related_products = SimpleBlogPost::getRelatedProducts($this->SimpleBlogPost->id_product);
|
||||
$this->context->smarty->assign('related_products', $related_products);
|
||||
}
|
||||
|
||||
$this->setTemplate('single.tpl');
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
$errors = array();
|
||||
$confirmation = '1';
|
||||
|
||||
if (Tools::isSubmit('submitNewComment') && Tools::getValue('id_simpleblog_post')) {
|
||||
if (Configuration::get('PH_BLOG_COMMENT_ALLOW_GUEST') && Configuration::get('PH_BLOG_COMMENTS_RECAPTCHA')) {
|
||||
if (!class_exists('ReCaptcha') && file_exists(_PS_MODULE_DIR_ . 'ph_simpleblog/assets/recaptchalib.php')) {
|
||||
require_once(_PS_MODULE_DIR_ . 'ph_simpleblog/assets/recaptchalib.php');
|
||||
}
|
||||
|
||||
$secret = Configuration::get('PH_BLOG_COMMENTS_RECAPTCHA_SECRET_KEY');
|
||||
$response = null;
|
||||
|
||||
if (!class_exists('ReCaptcha')) {
|
||||
die('Sorry, you want to use reCAPTCHA but class to handle this doesn\'t exists');
|
||||
}
|
||||
|
||||
$reCaptcha = new ReCaptcha($secret);
|
||||
|
||||
if (Tools::getValue('g-recaptcha-response')) {
|
||||
$response = $reCaptcha->verifyResponse(
|
||||
$_SERVER["REMOTE_ADDR"],
|
||||
Tools::getValue('g-recaptcha-response')
|
||||
);
|
||||
}
|
||||
|
||||
if ($response == null) {
|
||||
$errors[] = $this->module->l('Please provide valid reCAPTCHA value', 'single-v16');
|
||||
}
|
||||
}
|
||||
|
||||
if (Tools::getValue('comment_content') && Validate::isGenericName(Tools::getValue('comment_content'))) {
|
||||
$comment_content = Tools::getValue('comment_content');
|
||||
} else {
|
||||
$errors[] = $this->module->l('Please write something and remember that HTML is not allowed in comment content.', 'single-v16');
|
||||
}
|
||||
|
||||
$customer_name = Tools::getValue('customer_name');
|
||||
|
||||
if (!Validate::isGenericName($customer_name)) {
|
||||
$errors[] = $this->module->l('Please provide valid name', 'single-v16');
|
||||
}
|
||||
|
||||
if (!Validate::isInt(Tools::getValue('id_parent'))) {
|
||||
die('FATAL ERROR [2]');
|
||||
} else {
|
||||
$id_parent = Tools::getValue('id_parent');
|
||||
}
|
||||
|
||||
$ip_address = Tools::getRemoteAddr();
|
||||
|
||||
if (sizeof($errors)) {
|
||||
$this->errors = $errors;
|
||||
} else {
|
||||
$comment = new SimpleBlogComment();
|
||||
$comment->id_simpleblog_post = (int)Tools::getValue('id_simpleblog_post');
|
||||
$comment->id_parent = $id_parent;
|
||||
$comment->id_customer = (int)$this->context->customer->id ? (int)$this->context->customer->id : 0;
|
||||
$comment->id_guest = (int)$this->context->customer->id_guest ? (int)$this->context->customer->id_guest : 0;
|
||||
$comment->name = $customer_name;
|
||||
$comment->email = isset($this->context->customer->email) ? $this->context->customer->email : null;
|
||||
$comment->comment = $comment_content;
|
||||
$comment->active = Configuration::get('PH_BLOG_COMMENT_AUTO_APPROVAL') ? 1 : 0;
|
||||
$comment->ip = Tools::getRemoteAddr();
|
||||
|
||||
if ($comment->add()) {
|
||||
if (!Configuration::get('PH_BLOG_COMMENT_AUTO_APPROVAL')) {
|
||||
$confirmation = '2';
|
||||
}
|
||||
|
||||
$link = $this->context->link->getModuleLink('ph_simpleblog', 'single', array('confirmation' => $confirmation, 'rewrite' => $this->SimpleBlogPost->link_rewrite, 'sb_category' => $this->SimpleBlogPost->category_rewrite));
|
||||
|
||||
if (Configuration::get('PH_BLOG_COMMENT_NOTIFICATIONS')) {
|
||||
$toName = strval(Configuration::get('PS_SHOP_NAME'));
|
||||
$fromName = strval(Configuration::get('PS_SHOP_NAME'));
|
||||
$to = Configuration::get('PH_BLOG_COMMENT_NOTIFY_EMAIL');
|
||||
$from = Configuration::get('PS_SHOP_EMAIL');
|
||||
$customer = $this->context->customer;
|
||||
|
||||
if ($this->context->customer->isLogged()) {
|
||||
$lastname = $this->context->customer->lastname;
|
||||
$firstname = $this->context->customer->firstname;
|
||||
} else {
|
||||
$lastname = '';
|
||||
$firstname = $customer_name;
|
||||
}
|
||||
|
||||
Mail::Send(
|
||||
$this->context->language->id,
|
||||
'new_comment',
|
||||
sprintf(Mail::l('New comment on %1$s blog for article: %2$s', $this->context->language->id), $toName, $this->SimpleBlogPost->title),
|
||||
array(
|
||||
'{lastname}' => $customer->lastname,
|
||||
'{firstname}' => $customer->firstname,
|
||||
'{post_title}' => $this->SimpleBlogPost->title,
|
||||
'{post_link}' => $this->SimpleBlogPost->url,
|
||||
'{comment_content}' => $comment_content,
|
||||
),
|
||||
$to,
|
||||
$toName,
|
||||
$from,
|
||||
$fromName,
|
||||
null,
|
||||
null,
|
||||
_PS_MODULE_DIR_.'ph_simpleblog/mails/'
|
||||
);
|
||||
}
|
||||
|
||||
Tools::redirect($link);
|
||||
} else {
|
||||
$this->errors = $this->module->l('Something went wrong! Comment can not be added!', 'single-v16');
|
||||
}
|
||||
}
|
||||
}
|
||||
return parent::postProcess();
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign meta tags to single post page.
|
||||
*/
|
||||
protected function assignMetas()
|
||||
{
|
||||
if (!empty($this->SimpleBlogPost->meta_title)) {
|
||||
$this->context->smarty->assign('meta_title', $this->SimpleBlogPost->meta_title);
|
||||
} else {
|
||||
$this->context->smarty->assign('meta_title', $this->SimpleBlogPost->title);
|
||||
}
|
||||
|
||||
if (!empty($this->SimpleBlogPost->meta_description)) {
|
||||
$this->context->smarty->assign('meta_description', $this->SimpleBlogPost->meta_description);
|
||||
}
|
||||
|
||||
if (!empty($this->SimpleBlogPost->meta_keywords)) {
|
||||
$this->context->smarty->assign('meta_keywords', $this->SimpleBlogPost->meta_keywords);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare comments section, check for access to add comments etc.
|
||||
*/
|
||||
protected function prepareCommentsSection()
|
||||
{
|
||||
$this->context->smarty->assign('allow_comments', $this->SimpleBlogPost->allowComments());
|
||||
|
||||
if ($this->SimpleBlogPost->allowComments() == true) {
|
||||
$comments = SimpleBlogComment::getComments($this->SimpleBlogPost->id_simpleblog_post);
|
||||
$this->context->smarty->assign('comments', $comments);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* CSS, JS and other assets for this page.
|
||||
*/
|
||||
protected function addModulePageAssets()
|
||||
{
|
||||
$this->context->controller->addJqueryPlugin('cooki-plugin');
|
||||
$this->context->controller->addJqueryPlugin('cookie-plugin');
|
||||
$this->context->controller->addjqueryPlugin('fancybox');
|
||||
|
||||
$this->context->controller->addCSS(array(
|
||||
_THEME_CSS_DIR_.'category.css' => 'all',
|
||||
_THEME_CSS_DIR_.'product_list.css' => 'all',
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* This method check for existing other third party plugins in store
|
||||
* and if such a plugins exists we are preparing them to use.
|
||||
*/
|
||||
protected function supportThirdPartyPlugins()
|
||||
{
|
||||
if (file_exists(_PS_MODULE_DIR_ . 'smartshortcode/smartshortcode.php')) {
|
||||
require_once(_PS_MODULE_DIR_ . 'smartshortcode/smartshortcode.php');
|
||||
}
|
||||
|
||||
if ((bool)Module::isEnabled('jscomposer')) {
|
||||
$this->SimpleBlogPost->content = JsComposer::do_shortcode($this->SimpleBlogPost->content);
|
||||
|
||||
if (vc_mode() === 'page_editable') {
|
||||
$this->SimpleBlogPost->content = call_user_func(JsComposer::$front_editor_actions['vc_content'], $this->SimpleBlogPost->content);
|
||||
}
|
||||
}
|
||||
if ((bool)Module::isEnabled('smartshortcode')) {
|
||||
$smartshortcode = Module::getInstanceByName('smartshortcode');
|
||||
$this->checkForSmartShortcodeAddons();
|
||||
$this->SimpleBlogPost->content = $smartshortcode->parse($this->SimpleBlogPost->content);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return SimpleBlogPost object
|
||||
* @return object
|
||||
*/
|
||||
public function getPost()
|
||||
{
|
||||
return $this->SimpleBlogPost;
|
||||
}
|
||||
}
|
||||
385
modules/ph_simpleblog/controllers/front/single-v17.php
Normal file
385
modules/ph_simpleblog/controllers/front/single-v17.php
Normal file
@@ -0,0 +1,385 @@
|
||||
<?php
|
||||
/**
|
||||
* Blog for PrestaShop module by Krystian Podemski from PrestaHome.
|
||||
*
|
||||
* @author Krystian Podemski <krystian@prestahome.com>
|
||||
* @copyright Copyright (c) 2008-2019 Krystian Podemski - www.PrestaHome.com / www.Podemski.info
|
||||
* @license You only can use module, nothing more!
|
||||
*/
|
||||
|
||||
use PrestaShop\PrestaShop\Adapter\Image\ImageRetriever;
|
||||
use PrestaShop\PrestaShop\Adapter\Product\PriceFormatter;
|
||||
use PrestaShop\PrestaShop\Core\Product\ProductListingPresenter;
|
||||
use PrestaShop\PrestaShop\Adapter\Product\ProductColorsRetriever;
|
||||
|
||||
class PH_SimpleBlogSingleModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
protected $SimpleBlogPost;
|
||||
protected $previousPost = false;
|
||||
protected $nextPost = false;
|
||||
|
||||
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
// Get Post by link_rewrite
|
||||
$simpleblog_post_rewrite = Tools::getValue('rewrite');
|
||||
|
||||
if ($simpleblog_post_rewrite && Validate::isLinkRewrite($simpleblog_post_rewrite)) {
|
||||
$this->simpleblog_post_rewrite = $simpleblog_post_rewrite;
|
||||
} else {
|
||||
die('Blog for PrestaShop: URL is not valid');
|
||||
}
|
||||
|
||||
$SimpleBlogPost = SimpleBlogPost::getByRewrite($this->simpleblog_post_rewrite, (int) Context::getContext()->language->id);
|
||||
|
||||
// Check for matching current url with post url informations
|
||||
if (!Validate::isLoadedObject($SimpleBlogPost) || Validate::isLoadedObject($SimpleBlogPost) && !$SimpleBlogPost->active) {
|
||||
Tools::redirect('index.php?controller=404');
|
||||
}
|
||||
|
||||
if (Validate::isLoadedObject($SimpleBlogPost)
|
||||
&& $this->simpleblog_post_rewrite != $SimpleBlogPost->link_rewrite
|
||||
||
|
||||
Tools::getValue('sb_category') != $SimpleBlogPost->category_rewrite) {
|
||||
header('HTTP/1.1 301 Moved Permanently');
|
||||
header('Location: '.SimpleBlogPost::getLink($SimpleBlogPost->link_rewrite, $SimpleBlogPost->category_rewrite));
|
||||
}
|
||||
|
||||
// There you go, our blog post
|
||||
$this->SimpleBlogPost = $SimpleBlogPost;
|
||||
|
||||
$this->previousPost = $this->SimpleBlogPost->getPreviousPost();
|
||||
$this->nextPost = $this->SimpleBlogPost->getNextPost();
|
||||
|
||||
// Check access to post
|
||||
if (!$this->SimpleBlogPost->isAccessGranted()) {
|
||||
Tools::redirect('index.php?controller=404');
|
||||
}
|
||||
|
||||
// Assign meta tags
|
||||
$this->assignMetas();
|
||||
}
|
||||
|
||||
public function checkForSmartShortcodeAddons()
|
||||
{
|
||||
$context = Context::getContext();
|
||||
$dir = _PS_MODULE_DIR_.'smartshortcode/addons';
|
||||
|
||||
if (is_dir($dir)) {
|
||||
if ($dh = opendir($dir)) {
|
||||
while (($file = readdir($dh)) !== false) {
|
||||
if ($file != '.' && $file != '..') {
|
||||
if (is_dir("{$dir}/{$file}/front")) {
|
||||
include_once "{$dir}/{$file}/front/shortcode.php";
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($dh);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
// Assign JS and CSS for single post page
|
||||
$this->addModulePageAssets();
|
||||
|
||||
parent::initContent();
|
||||
|
||||
// Increase post views
|
||||
$this->SimpleBlogPost->increaseViewsNb();
|
||||
|
||||
// Support for SmartShortcode module from CodeCanyon
|
||||
$this->supportThirdPartyPlugins();
|
||||
|
||||
// Smarty variables
|
||||
$this->context->smarty->assign('is_16', true);
|
||||
$this->context->smarty->assign('post', $this->SimpleBlogPost);
|
||||
$this->context->smarty->assign('guest', (int) $this->context->cookie->id_guest);
|
||||
$this->context->smarty->assign('gallery_dir', _MODULE_DIR_.'ph_simpleblog/galleries/');
|
||||
$this->context->smarty->assign('previousPost', $this->previousPost);
|
||||
$this->context->smarty->assign('nextPost', $this->nextPost);
|
||||
|
||||
Media::addJsDef(
|
||||
array(
|
||||
'ph_simpleblog_ajax' => $this->context->link->getModuleLink('ph_simpleblog', 'ajax'),
|
||||
'ph_simpleblog_token' => $this->module->secure_key,
|
||||
)
|
||||
);
|
||||
|
||||
// Comments
|
||||
$this->prepareCommentsSection();
|
||||
|
||||
// Related products
|
||||
if (Configuration::get('PH_BLOG_DISPLAY_RELATED')) {
|
||||
$related_products = $this->getRelatedProducts();
|
||||
$this->context->smarty->assign('related_products', $related_products);
|
||||
}
|
||||
|
||||
$this->setTemplate('module:ph_simpleblog/views/templates/front/1.7/single.tpl');
|
||||
}
|
||||
|
||||
public function getRelatedProducts()
|
||||
{
|
||||
$products = SimpleBlogPost::getRelatedProducts($this->SimpleBlogPost->id_product);
|
||||
|
||||
$productsArray = array();
|
||||
if ($products) {
|
||||
$assembler = new ProductAssembler($this->context);
|
||||
|
||||
$presenterFactory = new ProductPresenterFactory($this->context);
|
||||
$presentationSettings = $presenterFactory->getPresentationSettings();
|
||||
$presenter = new ProductListingPresenter(
|
||||
new ImageRetriever(
|
||||
$this->context->link
|
||||
),
|
||||
$this->context->link,
|
||||
new PriceFormatter(),
|
||||
new ProductColorsRetriever(),
|
||||
$this->context->getTranslator()
|
||||
);
|
||||
foreach ($products as $rawProduct) {
|
||||
$productInfo = $assembler->assembleProduct($rawProduct);
|
||||
if ($productInfo) {
|
||||
$productsArray[] = $presenter->present(
|
||||
$presentationSettings,
|
||||
$productInfo,
|
||||
$this->context->language
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $productsArray;
|
||||
}
|
||||
|
||||
public function getBreadcrumbLinks()
|
||||
{
|
||||
$breadcrumb = parent::getBreadcrumbLinks();
|
||||
|
||||
$id_lang = Context::getContext()->language->id;
|
||||
$SimpleBlogPost = SimpleBlogPost::getByRewrite($this->simpleblog_post_rewrite, $id_lang);
|
||||
|
||||
$breadcrumb['links'][] = [
|
||||
'title' => $this->l('Blog'),
|
||||
'url' => $this->context->link->getModuleLink('ph_simpleblog', 'list')
|
||||
];
|
||||
|
||||
$breadcrumb['links'][] = [
|
||||
'title' => $SimpleBlogPost->category,
|
||||
'url' => $SimpleBlogPost->category_url
|
||||
];
|
||||
|
||||
$breadcrumb['links'][] = [
|
||||
'title' => $SimpleBlogPost->title,
|
||||
'url' => $SimpleBlogPost->url
|
||||
];
|
||||
return $breadcrumb;
|
||||
}
|
||||
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
$errors = array();
|
||||
$confirmation = '1';
|
||||
|
||||
if (Tools::isSubmit('submitNewComment') && Tools::getValue('id_simpleblog_post')) {
|
||||
if (Configuration::get('PH_BLOG_COMMENT_ALLOW_GUEST') && Configuration::get('PH_BLOG_COMMENTS_RECAPTCHA')) {
|
||||
if (!class_exists('ReCaptcha') && file_exists(_PS_MODULE_DIR_ . 'ph_simpleblog/assets/recaptchalib.php')) {
|
||||
require_once(_PS_MODULE_DIR_ . 'ph_simpleblog/assets/recaptchalib.php');
|
||||
}
|
||||
|
||||
$secret = Configuration::get('PH_BLOG_COMMENTS_RECAPTCHA_SECRET_KEY');
|
||||
$response = null;
|
||||
|
||||
if (!class_exists('ReCaptcha')) {
|
||||
die('Sorry, you want to use reCAPTCHA but class to handle this doesn\'t exists');
|
||||
}
|
||||
|
||||
$reCaptcha = new ReCaptcha($secret);
|
||||
|
||||
if (Tools::getValue('g-recaptcha-response')) {
|
||||
$response = $reCaptcha->verifyResponse(
|
||||
$_SERVER["REMOTE_ADDR"],
|
||||
Tools::getValue('g-recaptcha-response')
|
||||
);
|
||||
}
|
||||
|
||||
if ($response == null) {
|
||||
$errors[] = $this->module->l('Please provide valid reCAPTCHA value', 'single-v17');
|
||||
}
|
||||
}
|
||||
|
||||
if (Tools::getValue('comment_content') && Validate::isGenericName(Tools::getValue('comment_content'))) {
|
||||
$comment_content = Tools::getValue('comment_content');
|
||||
} else {
|
||||
$errors[] = $this->module->l('Please write something and remember that HTML is not allowed in comment content.', 'single-v17');
|
||||
}
|
||||
|
||||
$customer_name = Tools::getValue('customer_name');
|
||||
|
||||
if (!Validate::isGenericName($customer_name)) {
|
||||
$errors[] = $this->module->l('Please provide valid name', 'single-v17');
|
||||
}
|
||||
|
||||
if (!Validate::isInt(Tools::getValue('id_parent'))) {
|
||||
die('FATAL ERROR [2]');
|
||||
} else {
|
||||
$id_parent = Tools::getValue('id_parent');
|
||||
}
|
||||
|
||||
$ip_address = Tools::getRemoteAddr();
|
||||
|
||||
if (sizeof($errors)) {
|
||||
$this->errors = $errors;
|
||||
} else {
|
||||
$comment = new SimpleBlogComment();
|
||||
$comment->id_simpleblog_post = (int)Tools::getValue('id_simpleblog_post');
|
||||
$comment->id_parent = $id_parent;
|
||||
$comment->id_customer = (int)$this->context->customer->id ? (int)$this->context->customer->id : 0;
|
||||
$comment->id_guest = (int)$this->context->customer->id_guest ? (int)$this->context->customer->id_guest : 0;
|
||||
$comment->name = $customer_name;
|
||||
$comment->email = isset($this->context->customer->email) ? $this->context->customer->email : null;
|
||||
$comment->comment = $comment_content;
|
||||
$comment->active = Configuration::get('PH_BLOG_COMMENT_AUTO_APPROVAL') ? 1 : 0;
|
||||
$comment->ip = Tools::getRemoteAddr();
|
||||
|
||||
if ($comment->add()) {
|
||||
if (!Configuration::get('PH_BLOG_COMMENT_AUTO_APPROVAL')) {
|
||||
$confirmation = $this->l('Your comment was sucessfully added but it will be visible after moderator approval.', 'single-v17');
|
||||
} else {
|
||||
$confirmation = $this->l('Your comment was sucessfully added.', 'single-v17');
|
||||
}
|
||||
|
||||
$link = $this->context->link->getModuleLink('ph_simpleblog', 'single', array('rewrite' => $this->SimpleBlogPost->link_rewrite, 'sb_category' => $this->SimpleBlogPost->category_rewrite));
|
||||
|
||||
if (Configuration::get('PH_BLOG_COMMENT_NOTIFICATIONS')) {
|
||||
$toName = strval(Configuration::get('PS_SHOP_NAME'));
|
||||
$fromName = strval(Configuration::get('PS_SHOP_NAME'));
|
||||
$to = Configuration::get('PH_BLOG_COMMENT_NOTIFY_EMAIL');
|
||||
$from = Configuration::get('PS_SHOP_EMAIL');
|
||||
$customer = $this->context->customer;
|
||||
|
||||
if ($this->context->customer->isLogged()) {
|
||||
$lastname = $this->context->customer->lastname;
|
||||
$firstname = $this->context->customer->firstname;
|
||||
} else {
|
||||
$lastname = '';
|
||||
$firstname = $customer_name;
|
||||
}
|
||||
|
||||
Mail::Send(
|
||||
$this->context->language->id,
|
||||
'new_comment',
|
||||
sprintf($this->l('New comment on %1$s blog for article: %2$s', 'single-v17'), $toName, $this->SimpleBlogPost->title),
|
||||
array(
|
||||
'{lastname}' => $customer->lastname,
|
||||
'{firstname}' => $customer->firstname,
|
||||
'{post_title}' => $this->SimpleBlogPost->title,
|
||||
'{post_link}' => $this->SimpleBlogPost->url,
|
||||
'{comment_content}' => $comment_content,
|
||||
),
|
||||
$to,
|
||||
$toName,
|
||||
$from,
|
||||
$fromName,
|
||||
null,
|
||||
null,
|
||||
_PS_MODULE_DIR_.'ph_simpleblog/mails/'
|
||||
);
|
||||
}
|
||||
|
||||
$this->success[] = $confirmation;
|
||||
|
||||
$this->redirectWithNotifications($link);
|
||||
} else {
|
||||
$this->errors = $this->module->l('Something went wrong! Comment can not be added!', 'single-v17');
|
||||
}
|
||||
}
|
||||
}
|
||||
return parent::postProcess();
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign meta tags to single post page.
|
||||
*/
|
||||
protected function assignMetas()
|
||||
{
|
||||
if (!empty($this->SimpleBlogPost->meta_title)) {
|
||||
$this->context->smarty->assign('meta_title', $this->SimpleBlogPost->meta_title);
|
||||
} else {
|
||||
$this->context->smarty->assign('meta_title', $this->SimpleBlogPost->title);
|
||||
}
|
||||
|
||||
if (!empty($this->SimpleBlogPost->meta_description)) {
|
||||
$this->context->smarty->assign('meta_description', $this->SimpleBlogPost->meta_description);
|
||||
}
|
||||
|
||||
if (!empty($this->SimpleBlogPost->meta_keywords)) {
|
||||
$this->context->smarty->assign('meta_keywords', $this->SimpleBlogPost->meta_keywords);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare comments section, check for access to add comments etc.
|
||||
*/
|
||||
protected function prepareCommentsSection()
|
||||
{
|
||||
$this->context->smarty->assign('allow_comments', $this->SimpleBlogPost->allowComments());
|
||||
|
||||
if ($this->SimpleBlogPost->allowComments() == true) {
|
||||
$comments = SimpleBlogComment::getComments($this->SimpleBlogPost->id_simpleblog_post);
|
||||
$this->context->smarty->assign('comments', $comments);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* CSS, JS and other assets for this page.
|
||||
*/
|
||||
protected function addModulePageAssets()
|
||||
{
|
||||
$this->context->controller->addJqueryPlugin('cooki-plugin');
|
||||
$this->context->controller->addJqueryPlugin('cookie-plugin');
|
||||
$this->context->controller->addjqueryPlugin('fancybox');
|
||||
|
||||
$this->context->controller->addCSS(array(
|
||||
_THEME_CSS_DIR_.'category.css' => 'all',
|
||||
_THEME_CSS_DIR_.'product_list.css' => 'all',
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* This method check for existing other third party plugins in store
|
||||
* and if such a plugins exists we are preparing them to use.
|
||||
*/
|
||||
protected function supportThirdPartyPlugins()
|
||||
{
|
||||
if (file_exists(_PS_MODULE_DIR_ . 'smartshortcode/smartshortcode.php')) {
|
||||
require_once(_PS_MODULE_DIR_ . 'smartshortcode/smartshortcode.php');
|
||||
}
|
||||
|
||||
if ((bool)Module::isEnabled('jscomposer')) {
|
||||
$this->SimpleBlogPost->content = JsComposer::do_shortcode($this->SimpleBlogPost->content);
|
||||
|
||||
if (vc_mode() === 'page_editable') {
|
||||
$this->SimpleBlogPost->content = call_user_func(JsComposer::$front_editor_actions['vc_content'], $this->SimpleBlogPost->content);
|
||||
}
|
||||
}
|
||||
if ((bool)Module::isEnabled('smartshortcode')) {
|
||||
$smartshortcode = Module::getInstanceByName('smartshortcode');
|
||||
$this->checkForSmartShortcodeAddons();
|
||||
$this->SimpleBlogPost->content = $smartshortcode->parse($this->SimpleBlogPost->content);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return SimpleBlogPost object
|
||||
* @return object
|
||||
*/
|
||||
public function getPost()
|
||||
{
|
||||
return $this->SimpleBlogPost;
|
||||
}
|
||||
}
|
||||
15
modules/ph_simpleblog/controllers/front/single.php
Normal file
15
modules/ph_simpleblog/controllers/front/single.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* Blog for PrestaShop module by Krystian Podemski from PrestaHome.
|
||||
*
|
||||
* @author Krystian Podemski <krystian@prestahome.com>
|
||||
* @copyright Copyright (c) 2008-2019 Krystian Podemski - www.PrestaHome.com / www.Podemski.info
|
||||
* @license You only can use module, nothing more!
|
||||
*/
|
||||
require_once _PS_MODULE_DIR_.'ph_simpleblog/ph_simpleblog.php';
|
||||
|
||||
if (version_compare(_PS_VERSION_, '1.7', '>=')) {
|
||||
include_once _PS_MODULE_DIR_.'ph_simpleblog/controllers/front/single-v17.php';
|
||||
} else {
|
||||
include_once _PS_MODULE_DIR_.'ph_simpleblog/controllers/front/single-v16.php';
|
||||
}
|
||||
35
modules/ph_simpleblog/controllers/index.php
Normal file
35
modules/ph_simpleblog/controllers/index.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2014 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2014 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
Reference in New Issue
Block a user