Skip to content

Commit

Permalink
Merge pull request #71 from Raihan-SDS/1.6.1.x
Browse files Browse the repository at this point in the history
Many improvement for 1.6.1.x and add rss feed
  • Loading branch information
smartdatasoft authored Jan 18, 2018
2 parents 955091c + 67f5319 commit eccb6fc
Show file tree
Hide file tree
Showing 74 changed files with 2,096 additions and 39 deletions.
53 changes: 42 additions & 11 deletions classes/SmartBlogLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,12 @@ public function __construct($protocol_link = null, $protocol_content = null)
*/
public function getImageLink($name, $ids, $type = null)
{


if(Configuration::get('smartshownoimg')){

}
$not_default = false;

// Check if module is installed, enabled, customer is logged in and watermark logged option is on
/* if (Configuration::get('WATERMARK_LOGGED') && (Module::isInstalled('watermark') && Module::isEnabled('watermark')) && isset(Context::getContext()->customer->id)) {
$type .= '-'.Configuration::get('WATERMARK_HASH');
}
*/
// legacy mode or default image
$theme = ((Shop::isFeatureActive() && file_exists(_MODULE_SMARTBLOG_DIR_ . $ids . ($type ? '-' . $type : '') . '-' . (int) Context::getContext()->shop->id_theme . '.jpg')) ? '-' . Context::getContext()->shop->id_theme : '');
if ((Configuration::get('PS_LEGACY_IMAGES') && (file_exists(_MODULE_SMARTBLOG_DIR_ . $ids . ($type ? '-' . $type : '') . $theme . '.jpg'))) || ($not_default = strpos($ids, 'default') !== false)) {
Expand All @@ -99,14 +97,47 @@ public function getImageLink($name, $ids, $type = null)

}
}

// echo $this->protocol_content . Tools::getMediaServer($uri_path) . $uri_path.'<br>';
if (@getimagesize($this->protocol_content . Tools::getMediaServer($uri_path) . $uri_path)) {
return $this->protocol_content . Tools::getMediaServer($uri_path) . $uri_path;
$return_val = $this->protocol_content . Tools::getMediaServer($uri_path) . $uri_path;
} else {
if(Configuration::get('smartshownoimg'))
return __PS_BASE_URI__ . 'modules/smartblog/images/no-single-default.jpg';
return "false";
$split_ids = explode('-', $ids);
$id_image = (isset($split_ids[1]) ? $split_ids[1] : $split_ids[0]);

$tmp_main_img = __PS_BASE_URI__ . 'modules/smartblog/images/'.$id_image.'.jpg';
if(@getimagesize($this->protocol_content . Tools::getMediaServer($tmp_main_img) . $tmp_main_img)){
$posts_types = BlogImageType::GetImageAllType('post');
foreach ($posts_types as $image_type) {
if(stripslashes($image_type['type_name']) == $type){
ImageManager::resize(__DIR__."/../images/".$id_image.".jpg", _PS_MODULE_DIR_ . 'smartblog/images/'.$id_image.'-' . stripslashes($image_type['type_name']) . '.jpg', (int) $image_type['width'], (int) $image_type['height']);
}
}
} else {
if(Configuration::get('smartshownoimg')){
$no_img = __PS_BASE_URI__ . 'modules/smartblog/images/no.jpg';
if ($this->allow == 1) {
$return_val = __PS_BASE_URI__ . 'blog/' . 'no' . ($type ? '-' . $type : '') . '/' . $name . '.jpg';;
} else {
$return_val = __PS_BASE_URI__ . 'modules/smartblog/images/no' . ($type ? '-' . $type : '') . '.jpg';
}
$return_val = $this->protocol_content . Tools::getMediaServer($return_val) . $return_val;
if (!@getimagesize($return_val) AND @getimagesize($this->protocol_content . Tools::getMediaServer($no_img) . $no_img)) {
$posts_types = BlogImageType::GetImageAllType('post');

foreach ($posts_types as $image_type) {
if(stripslashes($image_type['type_name']) == $type){
ImageManager::resize(__DIR__."/../images/no.jpg", _PS_MODULE_DIR_ . 'smartblog/images/no-' . stripslashes($image_type['type_name']) . '.jpg', (int) $image_type['width'], (int) $image_type['height']);

}
}
}
} else {
$return_val = "false";
}
}
}

return (isset($return_val))? $return_val : '';
}

public function getSmartBlogPostLink($blogpost, $alias = null, $ssl = null, $id_lang = null, $id_shop = null, $relative_protocol= false)
Expand Down
4 changes: 3 additions & 1 deletion classes/SmartBlogPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,9 @@ public static function addTags($id_lang = null, $id_post, $tag_list, $separator
INSERT INTO `' . _DB_PREFIX_ . 'smart_blog_post_tag` (`id_tag`, `id_post`)
VALUES ' . $data);
}

public static function subStr($string, $length){
return strlen($string) > $length ? substr($string,0,$length)."..." : $string;
}
public function add($autodate = true, $null_values = false)
{
if (!parent::add($autodate, $null_values))
Expand Down
2 changes: 1 addition & 1 deletion config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<module>
<name>smartblog</name>
<displayName><![CDATA[Smart Blog]]></displayName>
<version><![CDATA[3.0.0]]></version>
<version><![CDATA[2.0.3]]></version>
<description><![CDATA[The Most Powerfull Prestashop Blog Module - by smartdatasoft]]></description>
<author><![CDATA[SmartDataSoft]]></author>
<tab><![CDATA[front_office_features]]></tab>
Expand Down
17 changes: 16 additions & 1 deletion controllers/admin/AdminBlogPostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,23 @@ protected function postImage($id) {
}

$posts_types = BlogImageType::GetImageAllType('post');
$langs = Language::getLanguages();
foreach ($posts_types as $image_type) {
$dir = _PS_MODULE_DIR_ . 'smartblog/images/' . $id . '-' . stripslashes($image_type['type_name']) . '.jpg';
$files_to_delete = array();

$files_to_delete[] = _PS_TMP_IMG_DIR_ . 'smart_blog_post_' . $id . '.jpg';
$files_to_delete[] = _PS_TMP_IMG_DIR_ . 'smart_blog_post_mini_' . $id . '.jpg';

foreach ($langs as $l)
{
$files_to_delete[] = _PS_TMP_IMG_DIR_ . 'smart_blog_post_' . $id . '_' . $l['id_lang'] . '.jpg';
$files_to_delete[] = _PS_TMP_IMG_DIR_ . 'smart_blog_post_mini_' . $id . '_' . $l['id_lang'] . '.jpg';
}

$dir = '';
foreach ($files_to_delete as $file)
if (file_exists($file) && !@unlink($file))
$dir = _PS_MODULE_DIR_ . 'smartblog/images/' . $id . '-' . stripslashes($image_type['type_name']) . '.jpg';
if (file_exists($dir))
unlink($dir);
}
Expand Down
Binary file added dummy_data/1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dummy_data/2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dummy_data/3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dummy_data/4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dummy_data/no.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/avatar/avatar-author-default.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/avatar/avatar.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/no-single-default.jpg
Binary file not shown.
Binary file modified logo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 52 additions & 3 deletions smartblog.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class smartblog extends Module
public function __construct(){
$this->name = 'smartblog';
$this->tab = 'front_office_features';
$this->version = '2.0.3';
$this->version = '2.2.0';
$this->author = 'SmartDataSoft';
$this->need_upgrade = true;
// $this->controllers = array('archive', 'category', 'details', 'search', 'tagpost');
Expand Down Expand Up @@ -71,7 +71,7 @@ public function install()
Configuration::updateGlobalValue('smartenableguestcomment', '1');
Configuration::updateGlobalValue('smartcaptchaoption', '1');
Configuration::updateGlobalValue('smartshowviewed', '1');
Configuration::updateGlobalValue('smartshownoimg', '0');
Configuration::updateGlobalValue('smartshownoimg', '1');
Configuration::updateGlobalValue('smartshowcolumn', '3');
Configuration::updateGlobalValue('smartacceptcomment', '1');
Configuration::updateGlobalValue('smartcustomcss', '');
Expand Down Expand Up @@ -121,12 +121,62 @@ public function install()

$this->CreateSmartBlogTabs();
$this->SampleDataInstall();
$this->installDummyData();
$this->SmartHookInsert();
$this->SmartHookRegister();

return true;
}

public function installDummyData(){
$image_types = BlogImageType::GetImageAllType('post');
$id_smart_blog_posts = $this->getAllPost();
$tmp_name = tempnam(_PS_TMP_IMG_DIR_, 'PS');
$langs = Language::getLanguages();

$arrayImg = array();
foreach (scandir(__DIR__.'/dummy_data') as $images) {
if (in_array($images, ['.', '..'])) {
continue;
}
$arrayImg[] = $images;
}
$img_count = 0;
foreach ($id_smart_blog_posts as $id_smart_blog_post) {
$files_to_delete = array();

$files_to_delete[] = _PS_TMP_IMG_DIR_ . 'smart_blog_post_' . $id_smart_blog_post['id_smart_blog_post'] . '.jpg';
$files_to_delete[] = _PS_TMP_IMG_DIR_ . 'smart_blog_post_mini_' . $id_smart_blog_post['id_smart_blog_post'] . '.jpg';

foreach ($langs as $l)
{
$files_to_delete[] = _PS_TMP_IMG_DIR_ . 'smart_blog_post_' . $id_smart_blog_post['id_smart_blog_post'] . '_' . $l['id_lang'] . '.jpg';
$files_to_delete[] = _PS_TMP_IMG_DIR_ . 'smart_blog_post_mini_' . $id_smart_blog_post['id_smart_blog_post'] . '_' . $l['id_lang'] . '.jpg';
}

foreach ($files_to_delete as $file)
if (file_exists($file)) @unlink($file);

Tools::Copy(__DIR__."/dummy_data/".$arrayImg[$img_count], _PS_MODULE_DIR_."/smartblog/images/".$id_smart_blog_post['id_smart_blog_post'].'.jpg');
foreach ($image_types as $image_type) {
ImageManager::resize(__DIR__."/dummy_data/".$arrayImg[$img_count], _PS_MODULE_DIR_ . 'smartblog/images/' . $id_smart_blog_post['id_smart_blog_post'] . '-' . stripslashes($image_type['type_name']) . '.jpg', (int) $image_type['width'], (int) $image_type['height']
);
}
$img_count = (count($arrayImg) > $img_count)? $img_count+1 : 0;
}

}

public static function getAllPost()
{
$sql = 'SELECT p.id_smart_blog_post
FROM `' . _DB_PREFIX_ . 'smart_blog_post_lang` p';

if (!$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql))
return false;
return $result;
}

public function hookactionHtaccessCreate()
{

Expand Down Expand Up @@ -1673,7 +1723,6 @@ public static function slug2id($slug)
}



public function smartblogcategoriesHookLeftColumn($params)
{

Expand Down
File renamed without changes.
12 changes: 12 additions & 0 deletions widgets/smartblogfeed/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<module>
<name>smartblogfeed</name>
<displayName><![CDATA[RSS SmartBlog Feed.]]></displayName>
<version><![CDATA[2]]></version>
<description><![CDATA[Generate an RSS SmartBlog feed.]]></description>
<author><![CDATA[smartdatasoft]]></author>
<tab><![CDATA[front_office_features]]></tab>
<is_configurable>1</is_configurable>
<need_instance>0</need_instance>
<limited_countries></limited_countries>
</module>
35 changes: 35 additions & 0 deletions widgets/smartblogfeed/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/*
* 2007-2012 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 [email protected] 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 <[email protected]>
* @copyright 2007-2012 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 added widgets/smartblogfeed/logo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added widgets/smartblogfeed/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 70 additions & 0 deletions widgets/smartblogfeed/rss.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?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 [email protected] 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 <[email protected]>
* @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
*/
include(dirname(__FILE__).'/../../config/config.inc.php');
require_once(dirname(__FILE__).'/../../init.php');
include(dirname(__FILE__).'/smartblogfeed.php');

$id_category = ((int)(Tools::getValue('id_category')) ? (int)(Tools::getValue('id_category')) : 0);
$allNews = smartblogfeed::getToltalByCategory((int)Context::getContext()->language->id,$id_category);
header("Content-Type:text/xml; charset=utf-8");
echo '<?xml version="1.0" encoding="UTF-8"?>'."\n";

?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
>
<channel>
<title><![CDATA[<?php echo Configuration::get('smartblogmetatitle') ?>]]></title>
<description><![CDATA[<?php echo Configuration::get('smartblogmetadescrip') ?>]]></description>
<link><?php echo _PS_BASE_URL_.__PS_BASE_URI__; ?></link>
<webMaster><?php echo Configuration::get('PS_SHOP_EMAIL') ?></webMaster>
<generator>SmartDataSoft</generator>
<language><?php echo Context::getContext()->language->iso_code; ?></language>
<sy:updatePeriod><?php echo Configuration::get('smart_update_period') ?></sy:updatePeriod>
<sy:updateFrequency><?php echo Configuration::get('smart_update_frequency') ?></sy:updateFrequency>
<?php
if(is_array($allNews)){
foreach($allNews AS $post)
{
$options =array();
echo "\t\t<item>\n";
echo "\t\t\t<title><![CDATA[".$post['meta_title']."]]></title>\n";
echo "\t\t\t<description><![CDATA[";
echo $post['short_description']."]]></description>\n";
$options['id_post'] = $post['id_post'];
$options['slug'] = $post['link_rewrite'];
echo "\t\t\t<link><![CDATA[".$post['blink']."]]></link>\n";
echo "\t\t</item>\n";
}
}
?>
</channel>
</rss>
Loading

0 comments on commit eccb6fc

Please sign in to comment.