Your IP : 216.73.216.72


Current Path : /home/azimutno/www/demo/plugins/nextendslidergenerator/joomlacontent/joomlacategory/
Upload File :
Current File : /home/azimutno/www/demo/plugins/nextendslidergenerator/joomlacontent/joomlacategory/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_JoomlaCategory extends NextendGeneratorAbstract {

    function NextendGeneratorJoomlaContent_JoomlaCategory($data) {
        parent::__construct($data);
        $this->_variables = array(
            'id' => 'ID of the category',
            'title' => 'Title of the category',
            'url' => 'Url of the category with list layout',
            'url_blog' => 'Url of the category with blog layout',
            'alias' => 'Alias of the category',
            'description' => 'Description of the category',
            'image' => 'Image of the category',
            'parent_id' => 'ID of the parent category',
            'parent_title' => 'Title of the parent category',
            'parent_url' => 'Url of the parent category with list layout',
            'parent_url_blog' => 'Url of the parent category with blog layout',
        );
    }

    function getData($number) {

        nextendimport('nextend.database.database');
        $db = NextendDatabase::getInstance();

        $data = array();

        $category = array_map('intval', explode('||', $this->_data->get('sourcecategory', '')));

        $query = 'SELECT ';
        $query .= 'cat.id, ';
        $query .= 'cat.title, ';
        $query .= 'cat.alias, ';
        $query .= 'cat.description, ';
        $query .= 'cat.params, ';
        $query .= 'cat_parent.id AS parent_id, ';
        $query .= 'cat_parent.title AS parent_title ';

        $query .= 'FROM #__categories AS cat ';

        $query .= 'LEFT JOIN #__categories AS cat_parent ON cat_parent.id = cat.parent_id ';


        $query .= 'WHERE cat.parent_id IN (' . implode(',', $category) . ') ';

        if ($this->_data->get('sourcepublished', 1)) {
            $query .= 'AND cat.published = 1 ';
        }
        $language = $this->_data->get('sourcelanguage', '*');
        if ($language) {
            $query .= 'AND cat.language = ' . $db->quote($language) . ' ';
        }

        $order = NextendParse::parse($this->_data->get('joomlacartegoryorder1', 'cat.title|*|asc'));
        if ($order[0]) {
            $query .= 'ORDER BY ' . $order[0] . ' ' . $order[1] . ' ';
            $order = NextendParse::parse($this->_data->get('joomlacartegoryorder2', '|*|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=category&id=' . $result[$i]['id']);
            $result[$i]['url_blog'] = JRoute::_('index.php?option=com_content&view=category&layout=blog&id=' . $result[$i]['id']);
            $params = (array)json_decode($result[$i]['params'], true);
            $result[$i]['image'] = isset($params['image']) ? $params['image'] : '';
            if($result[$i]['parent_title'] != 'ROOT'){
                $result[$i]['parent_url'] = JRoute::_('index.php?option=com_content&view=category&id=' . $result[$i]['parent_id']);
                $result[$i]['parent_url_blog'] = JRoute::_('index.php?option=com_content&view=category&layout=blog&id=' . $result[$i]['parent_id']);
            }else{
                $result[$i]['parent_title'] = '';
                $result[$i]['parent_url'] = '';
                $result[$i]['parent_url_blog'] = '';
            }
        }

        return $result;
    }
}