<?php
/*
 * @package Joomla 3.0
 * @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 *
 * @component XMovie Component
 * @copyright Copyright (C) Dana Harris optikool.com
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
 */
defined('_JEXEC') or die('Restricted access');
jimport('joomla.application.component.view');

if (!class_exists('JViewLegacy')) {
    class_alias('JView', 'JViewLegacy');
}
    
JTable::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_xmovie'.DS.'tables');
    
class XMovieViewMain extends JViewLegacy
{
    protected $cparams;
    protected $params;
    protected $subcat;
    protected $state;
    protected $items;
    protected $category;
    protected $categories;
    protected $pagination;
    protected $div_width;
    protected $main_itemid;
    
    public function display($tpl = null) 
    {    
        $document             = JFactory::getDocument();
        $app                 = JFactory::getApplication();

        $this->cparams         = $this->get('ConfigParams');
        $this->params        = $app->getParams();
        $this->subcat         = $this->get('SubCategories');
        $this->state        = $this->get('State');
        $this->items        = $this->get('Items');
        $this->category        = $this->get('Category');
        $this->children        = $this->get('Children');
        $this->parent         = $this->get('Parent');
        $this->pagination    = $this->get('Pagination');
        $this->main_itemid    = $this->get('MainItemId');
        
        $levels = JFactory::getUser()->getAuthorisedViewLevels();
                    
        if ($this->category->access && !in_Array($this->category->access, $levels)) {
            
        }
        
        $display_layout = $this->params->get('display_view_main');
        
        $this->div_width_cat = round(12 / intval($this->params->get('cat_num_row', 4)));
        $this->div_width_mov = round(12 / intval($this->params->get('mov_per_row', 4)));

        if ($this->cparams->get('load_css')) {
            $document->addStyleSheet(JURI::base(true).'/components/com_xmovie/css/styles.css');
        }

        if ($this->cparams->get('enable_rss')) {
            $feed = JURI::root()."index.php?option=com_xmovie&view=rss&id=&Itemid={$this->main_itemid}&format=feed";
            $rss = array(
                        'type'     =>  'application/rss+xml',
                        'title'    =>    'RSS 1.0');
        
            $atom = array(
                        'type'     =>  'application/atom+xml',
                        'title'    =>    'Atom');
                
            $document->addHeadLink(JRoute::_($feed.'&type=rss'), 'alternate', 'rel', $rss);
            $document->addHeadLink(JRoute::_($feed.'&type=atom'), 'alternate', 'rel', $atom);
        } 

        parent::display($tpl);
    }
}
