| Current Path : /home/azimutno/www/demo/plugins/nextendslidergenerator/easyblog/posts/ |
| Current File : /home/azimutno/www/demo/plugins/nextendslidergenerator/easyblog/posts/generator.php |
<?php
/*
# author Roland Soos
# copyright Copyright (C) Nextendweb.com. All Rights Reserved.
# @license - http://www.gnu.org/licenses/gpl-3.0.txt GNU/GPL
*/
defined('_JEXEC') or die('Restricted access'); ?><?php
nextendimport('nextend.smartslider.generator_abstract');
class NextendGeneratorEasyBlog_Posts extends NextendGeneratorAbstract {
var $extraFields;
function NextendGeneratorEasyBlog_Posts($data) {
parent::__construct($data);
$this->_variables = array(
"title" => "The title of the post",
"main_content_of_post" => "The main part of the post. If there is no 'Read more' section, this contains the entire post, otherwise it contains the intro part of it -",
"rest_of_the_post" => "The rest of the post. If the post is divided by a 'Read more' tag, this contains the section placed after it, empty otherwise -",
"blogger" => "Represents the username of the post creator",
"blogger_avatar_picture" => "Contains the URL of the blogger's avatar picture. Suggested to insert as an image item -",
"category_title" => "The title of the EasyBlog category that contains the post -",
"blog_image" => "URL of the image that is associated with your blog post. Suggested to insert as an image item -",
"blog_image_icon" => "URL of the icon of the image that is associated with your blog post. Suggested to insert as an image item -",
"blog_image_thumbnail" => "URL of the thumbnail of image that is associated with your blog post. Suggested to insert as an image item -",
"categoryurl" => "URL of the category. By navigating there, EasyBlog is going to list all the posts this category contains -",
"url" => "URL of the current EasyBlog post -"
);
}
function getData($number) {
nextendimport('nextend.database.database');
$db = NextendDatabase::getInstance();
$data = array();
$category = array_map('intval', explode('||', $this->_data->get('easyblogcategories', '')));
$query = 'SELECT con.*, con.intro as "main_content_of_post", con.content as "rest_of_the_post", usr.nickname as "blogger", usr.avatar as "blogger_avatar_picture", cat.title as cattitle ';
/* id created_by title description alias avatar parent_id private created status published ordering level lft rgt default */
$query .= 'FROM #__easyblog_post con ';
$query .= 'LEFT JOIN #__easyblog_users usr ON usr.id = con.created_by ';
$query .= 'LEFT JOIN #__easyblog_category cat ON cat.id = con.category_id ';
$query .= 'WHERE con.category_id IN (' . implode(',', $category) . ') ';
if ($this->_data->get('easyblogpublished', 1)) {
$jnow = JFactory::getDate();
$now = version_compare(JVERSION,'1.6.0','<') ? $jnow->toMySQL() : $jnow->toSql();
$query .= "AND con.published = 1 AND (con.publish_up = '0000-00-00 00:00:00' OR con.publish_up < '".$now."') AND (con.publish_down = '0000-00-00 00:00:00' OR con.publish_down > '".$now."') ";
}
if ($this->_data->get('easyblogfrontpage', 1)) {
$query .= "AND con.frontpage = ".$this->_data->get('easyblogfrontpage', 1)." ";
}
$sourceuserid = intval($this->_data->get('easybloguserid', ''));
if ($sourceuserid) {
$query .= 'AND con.created_by = ' . $sourceuserid . ' ';
}
$order = NextendParse::parse($this->_data->get('easyblogorder1', 'con.title|*|asc'));
if ($order[0]) {
$query .= 'ORDER BY ' . $order[0] . ' ' . $order[1] . ' ';
$order = NextendParse::parse($this->_data->get('easyblogorder2', 'con.title|*|asc'));
if ($order[0]) {
$query .= ', ' . $order[0] . ' ' . $order[1] . ' ';
}
}
$query .= 'LIMIT 0, ' . $number . ' ';
$db->setQuery($query);
$result = $db->loadAssocList();
for ($i = 0; $i < count($result); $i++) {
$result[$i]['url'] = JRoute::_('index.php?option=com_easyblog&view=entry&id=' . $result[$i]['id']);
$result[$i]['categoryurl'] = JRoute::_('index.php?option=com_easyblog&view=categories&id=' . $result[$i]['category_id']);
$result[$i]['blogger_avatar_picture']=($result[$i]['blogger_avatar_picture']=="default_blogger.png"?"components/com_easyblog/assets/images/".$result[$i]['blogger_avatar_picture']:"images/easyblog/avatar/".$result[$i]['blogger_avatar_picture']);
$img = json_decode($result[$i]["image"], true);
if(is_array($img)){
if(isset($img["url"])){
$result[$i]['blog_image'] = $img["url"];
} else $result[$i]['blog_image'] = "";
if(isset($img["icon"])&&isset($img["icon"]["url"])){
$result[$i]['blog_image_icon'] = $img["icon"]["url"];
} else $result[$i]['blog_image_icon'] = "";
if(isset($img["thumbnail"])&&isset($img["thumbnail"]["url"])){
$result[$i]['blog_image_thumbnail'] = $img["thumbnail"]["url"];
} else $result[$i]['blog_image_thumbnail'] = "";
}
}
return $result;
}
}