FundacionLQDVI_WebCongresos/www/components/com_sql2excel/models/sections.php

159 lines
4.3 KiB
PHP

<?php
/*
* @component SQL 2 Excel Pro Component
* @copyright Copyright (C) Joomla-R-Us, joomla-r-us.com
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPLv3
*
* Original code by Jan Pavelka (www.phoca.cz)
* Adapted by Joomla-R-Us for SQl 2 Excel Pro
*
*/
/*
* @package Joomla 1.5
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
*
* @component Phoca Component
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die();
jimport('joomla.application.component.model');
require_once( JPATH_COMPONENT.DS.'helpers'.DS.'query.php' );
require_once( JPATH_COMPONENT.DS.'helpers'.DS.'parms.php' );
class Sql2excelModelSections extends JModel
{
var $_section = null;
var $_most_viewed_docs = null;
var $_section_ordering = null;
var $_category_ordering = null;
function __construct() {
parent::__construct();
}
function getSections($params) {
$user =& JFactory::getUser();
$aid = $user->get('aid', 0);
if (empty($this->_section)) {
global $mainframe;
$user = &JFactory::getUser();
$aid = $user->get('aid', 0);
$query = $this->_getSectionListQuery( $aid, $params );
$this->_section = $this->_getList( $query );
if (!empty($this->_section)) {
foreach ($this->_section as $key => $value) {
$query = $this->_getCategoryListQuery( $value->id, $aid, $params );
$this->_section[$key]->categories = $this->_getList( $query );
}
}
}
return $this->_section;
}
function _getSectionListQuery( $aid, $params ) {
// Filter Sections / Categories ?
$paramsC = JComponentHelper::getParams('com_sql2excel');
$section_ids_where = $paramsC->get( 'display_sections', '' );
$section_ids_not_where = $paramsC->get( 'hide_sections', '' );
$category_ids_where = $paramsC->get( 'display_categories', '' );
$category_ids_not_where = $paramsC->get( 'hide_categories', '' );
$orderBy = $this->_getSectionOrdering();
$query = Sql2excelQuery::getBaseQuery( "d.id, d.title, d.alias, '' AS categories, d.ordering, count(distinct e.id) as numcat",
null,
'GROUP BY d.id',
$orderBy,
$section_ids_where,
$section_ids_not_where,
$category_ids_where,
$category_ids_not_where);
return $query;
}
function _getCategoryListQuery( $sectionId, $aid, $params ) {
// Filter Sections / Categories ?
$paramsC = JComponentHelper::getParams('com_sql2excel');
$section_ids_where = $paramsC->get( 'display_sections', '' );
$section_ids_not_where = $paramsC->get( 'hide_sections', '' );
$category_ids_where = $paramsC->get( 'display_categories', '' );
$category_ids_not_where = $paramsC->get( 'hide_categories', '' );
$orderBy = $this->_getCategoryOrdering();
$wheres[]=' a.section=' . $sectionId;
$query = Sql2excelQuery::getBaseQuery( "e.id, e.title ,e.alias, e.ordering, COUNT(distinct a.id) as numdoc",
$wheres,
'GROUP BY e.id',
$orderBy,
$section_ids_where,
$section_ids_not_where,
$category_ids_where,
$category_ids_not_where);
return $query;
}
function getMostViewedDocsList($params) {
$user =& JFactory::getUser();
$aid = $user->get('aid', 0);
if (empty($this->_most_viewed_docs)) {
global $mainframe;
$user = &JFactory::getUser();
$aid = $user->get('aid', 0);
$query = $this->_getMostViewedDocsListQuery( $aid, $params );
$this->_most_viewed_docs = $this->_getList( $query );
}
return $this->_most_viewed_docs;
}
function _getSectionOrdering() {
if (empty($this->_section_ordering)) {
$cmpParms = Sql2excelParms::getParms();
$ordering = Sql2excelParms::get($cmpParms,'section_ordering', 1);
$this->_section_ordering = Sql2excelQuery::getOrderingText($ordering,'d');
}
return $this->_section_ordering;
}
function _getCategoryOrdering() {
if (empty($this->_category_ordering)) {
//global $mainframe;
$params = Sql2excelParms::getParms();
$ordering = Sql2excelParms::get($params,'category_ordering', 1);
$this->_category_ordering = Sql2excelQuery::getOrderingText($ordering, 'e');
}
return $this->_category_ordering;
}
}
?>