| Current Path : /home/azimutno/www/demo/plugins/nextendslidergenerator/joomlacontent/joomlacontent/ |
| Current File : /home/azimutno/www/demo/plugins/nextendslidergenerator/joomlacontent/joomlacontent/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 NextendGeneratorJoomlaContent_JoomlaContent extends NextendGeneratorAbstract {
function NextendGeneratorJoomlaContent_JoomlaContent($data) {
parent::__construct($data);
$this->_variables = array(
'id' => 'ID of the article',
'title' => 'Title of the article',
'url' => 'Url of the article',
'alias' => 'Alias of the article',
'introtext' => 'Intro of the article',
'fulltext' => 'Text of the article',
'catid' => 'Id of the article\'s category',
'cat_title' => 'Title of the article\'s category',
'categorylisturl' => 'Url to the article\'s category with list layout',
'categoryblogurl' => 'Url to the article\'s category with blog layout',
'created_by' => 'Id of the article\'s creator',
'created_by_alias' => 'Name of the article\'s creator',
'intro_image' => '',
'fulltext_image' => ''
);
}
function getData($number) {
nextendimport('nextend.database.database');
$db = NextendDatabase::getInstance();
$data = array();
$category = array_map('intval', explode('||', $this->_data->get('sourcecategory', '')));
$query = 'SELECT ';
$query .= 'con.id, ';
$query .= 'con.title, ';
$query .= 'con.alias, ';
$query .= 'con.introtext, ';
$query .= 'con.fulltext, ';
$query .= 'con.catid, ';
$query .= 'cat.title AS cat_title, ';
$query .= 'con.created_by, ';
$query .= 'usr.name AS created_by_alias, ';
$query .= 'con.images ';
$query .= 'FROM #__content AS con ';
$query .= 'LEFT JOIN #__users AS usr ON usr.id = con.created_by ';
$query .= 'LEFT JOIN #__categories AS cat ON cat.id = con.catid ';
$query .= 'WHERE con.catid IN (' . implode(',', $category) . ') ';
$sourceuserid = intval($this->_data->get('sourceuserid', ''));
if ($sourceuserid) {
$query .= 'AND con.created_by = '.$sourceuserid.' ';
}
if ($this->_data->get('sourcepublished', 1)) {
$query .= 'AND con.state = 1 ';
}
if ($this->_data->get('sourcefeatured', 0)) {
$query .= 'AND con.featured = 1 ';
}
$language = $this->_data->get('sourcelanguage', '*');
if ($language) {
$query .= 'AND con.language = ' . $db->quote($language) . ' ';
}
$order = NextendParse::parse($this->_data->get('order1', 'con.title|*|asc'));
if ($order[0]) {
$query .= 'ORDER BY ' . $order[0] . ' ' . $order[1] . ' ';
$order = NextendParse::parse($this->_data->get('order2', '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_content&view=article&id=' . $result[$i]['id']);
$result[$i]['categorylisturl'] = JRoute::_('index.php?option=com_content&view=category&id=' . $result[$i]['catid']);
$result[$i]['categoryblogurl'] = JRoute::_('index.php?option=com_content&view=category&layout=blog&id=' . $result[$i]['catid']);
$images = (array)json_decode($result[$i]['images'], true);
$result[$i]['intro_image'] = isset($images['image_intro']) ? $images['image_intro'] : '';
$result[$i]['fulltext_image'] = isset($images['image_fulltext']) ? $images['image_fulltext'] : '';
unset($result[$i]['images']);
}
return $result;
}
}