first commit

This commit is contained in:
2024-12-17 13:43:22 +01:00
commit 8e6cd8b410
21292 changed files with 3514826 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>phblogrecentposts</name>
<displayName><![CDATA[Blog for PrestaShop - Recent posts on the homepage]]></displayName>
<version><![CDATA[2.0.0]]></version>
<description><![CDATA[Widget to display recently added posts to Blog for PrestaShop module]]></description>
<author><![CDATA[PrestaHome]]></author>
<tab><![CDATA[front_office_features]]></tab>
<confirmUninstall><![CDATA[Are you sure you want to delete this module?]]></confirmUninstall>
<is_configurable>1</is_configurable>
<need_instance>0</need_instance>
<limited_countries></limited_countries>
</module>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>phblogrecentposts</name>
<displayName><![CDATA[Blog dla PrestaShop - Najnowsze wpisy na stronie gł&oacute;wnej]]></displayName>
<version><![CDATA[2.0.0]]></version>
<description><![CDATA[Widget do wyświetlania ostatnio dodanych post&oacute;w na blogu dla modułu PrestaShop]]></description>
<author><![CDATA[PrestaHome]]></author>
<tab><![CDATA[front_office_features]]></tab>
<confirmUninstall><![CDATA[Czy na pewno chcesz usunąć ten moduł?]]></confirmUninstall>
<is_configurable>1</is_configurable>
<need_instance>0</need_instance>
<limited_countries></limited_countries>
</module>

View 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;

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

@@ -0,0 +1,388 @@
<?php
/**
* Blog for PrestaShop module by Krystian Podemski from PrestaHome.
*
* @author Krystian Podemski <krystian@prestahome.com>
* @copyright Copyright (c) 2014-2018 Krystian Podemski - www.PrestaHome.com / www.Podemski.info
* @license You only can use module, nothing more!
*/
if (!defined('_PS_VERSION_')) {
exit;
}
class PhBlogRecentPosts extends Module
{
private $_html = '';
public $fields_form;
public $fields_value;
public $validation_errors = array();
public static $cfg_prefix = 'PH_RECENTPOSTS_';
public function __construct()
{
$this->name = 'phblogrecentposts';
$this->tab = 'front_office_features';
$this->version = '2.0.0';
$this->author = 'PrestaHome';
$this->need_instance = 0;
$this->is_configurable = 1;
$this->ps_versions_compliancy['min'] = '1.7.0.0';
$this->ps_versions_compliancy['max'] = _PS_VERSION_;
$this->secure_key = Tools::encrypt($this->name);
$this->bootstrap = true;
if (!Module::isInstalled('ph_simpleblog') || !Module::isEnabled('ph_simpleblog')) {
$this->warning = $this->l('You have to install and activate ph_simpleblog before use PhBlogRecentPosts');
}
parent::__construct();
$this->displayName = $this->l('Blog for PrestaShop - Recent posts on the homepage');
$this->description = $this->l('Widget to display recently added posts to Blog for PrestaShop module');
$this->confirmUninstall = $this->l('Are you sure you want to delete this module?');
}
public function getDefaults()
{
return array(
'LAYOUT' => 'grid',
'GRID_COLUMNS' => 2,
'FROM' => 'recent',
'POSITION' => 'home',
'NB' => 4,
);
}
public function install()
{
// Hooks & Install
return (parent::install()
&& $this->prepareModuleSettings()
&& $this->registerHook('displaySimpleBlogRecentPosts')
&& $this->registerHook('displayHome')
&& $this->registerHook('displayHeader'));
}
public function uninstall()
{
if (!parent::uninstall()) {
return false;
}
foreach ($this->getDefaults() as $key => $value) {
Configuration::deleteByName(self::$cfg_prefix.$key);
}
return true;
}
public function prepareModuleSettings()
{
foreach ($this->getDefaults() as $key => $value) {
Configuration::updateValue(self::$cfg_prefix.$key, $value, true);
}
return true;
}
public function prepareValueForLangs($value)
{
$languages = Language::getLanguages(false);
$output = array();
foreach ($languages as $language) {
$output[$language['id_lang']] = $value;
}
return $output;
}
public function getContent()
{
$id_shop = (int) $this->context->shop->id;
$this->initFieldsForm();
if (isset($_POST['save'.$this->name])) {
$multiLangFields = array();
foreach ($this->getDefaults() as $field_name => $field_value) {
if (is_array($field_value)) {
$multiLangFields[] = self::$cfg_prefix.$field_name;
}
}
foreach ($_POST as $key => $value) {
$fieldName = substr($key, 0, -2);
if (in_array($fieldName, $multiLangFields)) {
$thisFieldValue = array();
foreach (Language::getLanguages(true) as $language) {
if (isset($_POST[$fieldName.'_'.$language['id_lang']])) {
$thisFieldValue[$language['id_lang']] = $_POST[$fieldName.'_'.$language['id_lang']];
}
}
$_POST[$fieldName] = $thisFieldValue;
}
}
foreach ($this->getDefaults() as $field_name => $field_value) {
if (is_array($field_value)) {
Configuration::updateValue($field_name, ${$field_name}, true);
}
}
foreach ($this->fields_form as $form) {
foreach ($form['form']['input'] as $field) {
if (isset($field['validation'])) {
$errors = array();
$value = Tools::getValue($field['name']);
if (isset($field['required']) && $field['required'] && $value == false && (string) $value != '0') {
$errors[] = sprintf(Tools::displayError('Field "%s" is required.'), $field['label']);
} elseif ($value) {
if (!Validate::{$field['validation']}($value)) {
$errors[] = sprintf(Tools::displayError('Field "%s" is invalid.'), $field['label']);
}
}
if ($value === false && isset($field['default_value'])) {
$value = $field['default_value'];
}
if (count($errors)) {
$this->validation_errors = array_merge($this->validation_errors, $errors);
} elseif ($value == false) {
switch ($field['validation']) {
case 'isUnsignedId':
case 'isUnsignedInt':
case 'isInt':
case 'isBool':
$value = 0;
break;
default:
$value = '';
break;
}
Configuration::updateValue($field['name'], $value, true);
} else {
$value = Tools::getValue($field['name']);
Configuration::updateValue($field['name'], $value, true);
}
} else {
$value = Tools::getValue($field['name']);
Configuration::updateValue($field['name'], $value, true);
}
}
}
if (count($this->validation_errors)) {
$this->_html .= $this->displayError(implode('<br/>', $this->validation_errors));
} else {
$this->_html .= Tools::redirectAdmin(AdminController::$currentIndex.'&configure='.$this->name.'&conf=6&token='.Tools::getAdminTokenLite('AdminModules'));
}
}
$helper = $this->initForm();
foreach ($this->getDefaults() as $key => $value) {
if (is_array($value)) {
foreach ($value as $lang => $val) {
$helper->fields_value[self::$cfg_prefix.$key][(int) $lang] = Tools::getValue(self::$cfg_prefix.$key.'_'.(int) $lang, Configuration::get(self::$cfg_prefix.$key, (int) $lang));
}
} else {
$helper->fields_value[self::$cfg_prefix.$key] = Configuration::get(self::$cfg_prefix.$key);
}
}
return $this->_html.$helper->generateForm($this->fields_form);
}
protected function initFieldsForm()
{
$from = array();
$from[] = array('name' => $this->l('Recent posts'), 'id' => 'recent');
$from[] = array('name' => $this->l('Featured posts'), 'id' => 'featured');
$layout = array();
$layout[] = array('name' => $this->l('Grid'), 'id' => 'grid');
$layout[] = array('name' => $this->l('List'), 'id' => 'list');
$available_categories = SimpleBlogCategory::getCategories($this->context->language->id, true, false);
foreach ($available_categories as &$category) {
$category['name'] = 'Category: '.$category['name'];
if ($category['is_child']) {
$category['name'] = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$category['name'];
}
$from[] = array('name' => $category['name'], 'id' => $category['id']);
}
$this->fields_form[0]['form'] = array(
'legend' => array(
'title' => $this->displayName,
),
'input' => array(
array(
'type' => 'select',
'label' => $this->l('Display posts from:'),
'name' => self::$cfg_prefix.'FROM',
'validation' => 'isAnything',
'options' => array(
'query' => $from,
'id' => 'id',
'name' => 'name',
),
),
array(
'type' => 'select',
'name' => self::$cfg_prefix.'LAYOUT',
'label' => $this->l('Recent Posts layout:'),
'options' => array(
'query' => $layout,
'id' => 'id',
'name' => 'name',
),
),
array(
'type' => 'select',
'name' => self::$cfg_prefix.'GRID_COLUMNS',
'label' => $this->l('Grid columns:'),
'desc' => $this->l('Working only with "Recent Posts layout:" setup to "Grid"'),
'options' => array(
'query' => array(
array('name' => 2, 'id' => 2),
array('name' => 4, 'id' => 4),
array('name' => 6, 'id' => 6),
),
'id' => 'id',
'name' => 'name',
),
),
array(
'name' => self::$cfg_prefix.'NB',
'type' => 'text',
'label' => $this->l('Number of posts:'),
'validation' => 'isUnsignedInt',
'desc' => $this->l('Default: 4'),
'class' => 'input-mini',
'size' => 2
),
),
'submit' => array(
'title' => $this->l('Save'),
'class' => 'btn btn-default pull-right',
),
);
}
protected function initForm()
{
$default_lang = (int) Configuration::get('PS_LANG_DEFAULT');
$helper = new HelperForm();
$helper->module = $this;
$helper->name_controller = $this->name;
$helper->identifier = $this->identifier;
$helper->token = Tools::getAdminTokenLite('AdminModules');
foreach (Language::getLanguages(false) as $lang) {
$helper->languages[] = array(
'id_lang' => $lang['id_lang'],
'iso_code' => $lang['iso_code'],
'name' => $lang['name'],
'is_default' => ($default_lang == $lang['id_lang'] ? 1 : 0),
);
}
$helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name;
$helper->default_form_language = $default_lang;
$helper->allow_employee_form_lang = $default_lang;
$helper->toolbar_scroll = true;
$helper->title = $this->displayName;
$helper->submit_action = 'save'.$this->name;
$helper->toolbar_btn = array(
'save' => array(
'desc' => $this->l('Save'),
'href' => AdminController::$currentIndex.'&configure='.$this->name.'&save'.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules'),
),
);
return $helper;
}
public function assignModuleVariables()
{
foreach ($this->getDefaults() as $key => $value) {
if (is_array($value)) {
$this->smarty->assign(strtolower($key), Configuration::get(self::$cfg_prefix.$key, $this->context->language->id));
} else {
$this->smarty->assign(strtolower($key), Configuration::get(self::$cfg_prefix.$key));
}
}
}
public function preparePosts($nb = 6, $from = null)
{
if (!Module::isInstalled('ph_simpleblog') || !Module::isEnabled('ph_simpleblog')) {
return false;
}
require_once _PS_MODULE_DIR_.'ph_simpleblog/classes/BlogPostsFinder.php';
$finder = new BlogPostsFinder;
if ($from == 'featured') {
$finder->setFeatured(true);
} elseif ($from == 'recent') {
// n/a
} else {
$finder->setIdCategory((int) $from);
}
$finder->setLimit((int) $nb);
$posts = $finder->findPosts();
return $posts;
}
public function prepareSimpleBlogPosts()
{
$posts = $this->preparePosts((int) Configuration::get(self::$cfg_prefix.'NB'), Configuration::get(self::$cfg_prefix.'FROM'));
if (!$posts) {
return;
}
$gridColumns = Configuration::get(self::$cfg_prefix.'GRID_COLUMNS');
$blogLayout = Configuration::get(self::$cfg_prefix.'LAYOUT');
$this->context->smarty->assign(array(
'blogLayout' => $blogLayout,
'columns' => $gridColumns,
'gallery_dir' => _MODULE_DIR_.'ph_simpleblog/galleries/',
'recent_posts' => $posts,
'tpl_path' => dirname(__FILE__).'/views/templates/hook/',
'is_category' => false,
'blogLink' => $this->context->link->getModuleLink('ph_simpleblog', 'list')
));
}
public function hookDisplaySimpleBlogRecentPosts($params)
{
header('test12:asdasdas');
$this->prepareSimpleBlogPosts();
if (isset($params['template'])) {
return $this->display(__FILE__, $params['template'].'.tpl');
} else {
return $this->hookDisplayHome($params);
}
}
public function hookDisplayHome($params)
{
$this->prepareSimpleBlogPosts();
return $this->display(__FILE__, 'recent.tpl');
}
}

View 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;

View File

@@ -0,0 +1,21 @@
<?php
global $_MODULE;
$_MODULE = array();
$_MODULE['<{phblogrecentposts}prestashop>phblogrecentposts_94565e117781d75753da348c862c7037'] = 'Musisz zainstalować i aktywować ph_simpleblog przed użyciem PhBlogRecentPosts';
$_MODULE['<{phblogrecentposts}prestashop>phblogrecentposts_3790fdc516513863759dff6ca4e79ead'] = 'Blog dla PrestaShop - Najnowsze wpisy na stronie głównej';
$_MODULE['<{phblogrecentposts}prestashop>phblogrecentposts_5e9d4b26be237e1d59c595a6fc65a453'] = 'Widget do wyświetlania ostatnio dodanych postów na blogu dla modułu PrestaShop';
$_MODULE['<{phblogrecentposts}prestashop>phblogrecentposts_a9828808bf0dcd0b7af8e6f20b80ad85'] = 'Czy na pewno chcesz usunąć ten moduł?';
$_MODULE['<{phblogrecentposts}prestashop>phblogrecentposts_39fd7f2ac3aad9fd0896bfeeb02fb267'] = 'Najnowsze wpisy';
$_MODULE['<{phblogrecentposts}prestashop>phblogrecentposts_17fe63a5060231fe0c7e84a0528bc7fd'] = 'Wyróżnione posty';
$_MODULE['<{phblogrecentposts}prestashop>phblogrecentposts_5174d1309f275ba6f275db3af9eb3e18'] = 'Siatka';
$_MODULE['<{phblogrecentposts}prestashop>phblogrecentposts_4ee29ca12c7d126654bd0e5275de6135'] = 'Lista';
$_MODULE['<{phblogrecentposts}prestashop>phblogrecentposts_6013255adadcc481c5a80569029aa87c'] = 'Wyświetl posty z:';
$_MODULE['<{phblogrecentposts}prestashop>phblogrecentposts_6150b472344875c59f44fed5950fb305'] = 'Układ ostatnich postów:';
$_MODULE['<{phblogrecentposts}prestashop>phblogrecentposts_8b583b389b9c51df6502d9c97e15352c'] = 'Kolumny siatki:';
$_MODULE['<{phblogrecentposts}prestashop>phblogrecentposts_0e9c8e5f92a44b6dd3570a485399e61a'] = 'Praca tylko z układem „Ostatnie posty” ustawionym na „Siatka”';
$_MODULE['<{phblogrecentposts}prestashop>phblogrecentposts_37ee91f1b9858fe716db898d0d61afff'] = 'Liczba postów:';
$_MODULE['<{phblogrecentposts}prestashop>phblogrecentposts_6b972d14078df4fa0653ce7c0e3843b7'] = 'Domyślnie: 4';
$_MODULE['<{phblogrecentposts}prestashop>phblogrecentposts_c9cc8cce247e49bae79f15173ce97354'] = 'Zapisz';
$_MODULE['<{phblogrecentposts}prestashop>recent_be8df1f28c0abc85a0ed0c6860e5d832'] = 'Blog';
$_MODULE['<{phblogrecentposts}prestashop>recent_f4b3a01a574adf5bd1786db82fb60972'] = 'Zobacz wszystkie artykuły';

View 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;

View 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;

View 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;

View File

@@ -0,0 +1,17 @@
{if isset($recent_posts) && count($recent_posts)}
<section class="simpleblog" id="phblogrecentposts" itemscope="itemscope" itemtype="http://schema.org/Blog">
<div class="container">
<div class="row">
<h3 class="h1">
{l s='Blog' mod='phblogrecentposts'}
<a href="{$blogLink}">
{l s='See all articles' mod='phblogrecentposts'}
</a>
</h3>
{foreach from=$recent_posts item=post}
{include file="module:ph_simpleblog/views/templates/front/1.7/_partials/post-miniature.tpl"}
{/foreach}
</div><!-- .row -->
</div><!-- .container -->
</section><!-- .section-news -->
{/if}

View 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;