git-svn-id: https://192.168.0.254/svn/Proyectos.FundacionLQDVI_WebCongresos/trunk@2 94ccb1af-fd9d-d947-8d90-7f70ea60afc8
137 lines
3.8 KiB
PHP
137 lines
3.8 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 Sql2excelModelSection extends JModel
|
|
{
|
|
var $_category = null;
|
|
var $_section = null;
|
|
var $_most_viewed_docs = null;
|
|
var $_category_ordering = null;
|
|
|
|
function __construct() {
|
|
parent::__construct();
|
|
}
|
|
|
|
function getCategoryList($sectionId, $params) {
|
|
$user =& JFactory::getUser();
|
|
$aid = $user->get('aid', 0);
|
|
|
|
if (empty($this->_category)) {
|
|
global $mainframe;
|
|
$user = &JFactory::getUser();
|
|
$aid = $user->get('aid', 0);
|
|
$query = $this->_getCategoryListQuery( $sectionId, $aid, $params );
|
|
$this->_category= $this->_getList( $query );
|
|
}
|
|
return $this->_category;
|
|
}
|
|
|
|
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= ".(int)$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 getSection($sectionId, $params) {
|
|
$user =& JFactory::getUser();
|
|
$aid = $user->get('aid', 0);
|
|
//$wheres[] = " cc.published = 1 ";
|
|
if (empty($this->_category)) {
|
|
global $mainframe;
|
|
$user = &JFactory::getUser();
|
|
$aid = $user->get('aid', 0);
|
|
$query = $this->_getSectionQuery( $sectionId, $aid, $params );
|
|
$this->_section= $this->_getList( $query, 0, 1 );
|
|
}
|
|
return $this->_section;
|
|
}
|
|
|
|
function _getSectionQuery( $sectionId, $aid, $params ) {
|
|
|
|
$wheres[] = " s.id= ".(int)$sectionId;
|
|
if ($aid !== null) {
|
|
$wheres[] = "s.access <= " . (int) $aid;
|
|
}
|
|
$wheres[] = " s.published = 1";
|
|
|
|
$query = " SELECT s.id, s.title, s.description, s.alias"
|
|
. " FROM #__sql2excel_sections AS s"
|
|
. " WHERE " . implode( " AND ", $wheres )
|
|
. " ORDER BY s.ordering";
|
|
return $query;
|
|
}
|
|
|
|
function getMostViewedDocsList($sectionId, $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( $sectionId, $aid, $params );
|
|
$this->_most_viewed_docs = $this->_getList( $query );
|
|
}
|
|
return $this->_most_viewed_docs;
|
|
}
|
|
|
|
|
|
function _getCategoryOrdering() {
|
|
if (empty($this->_category_ordering)) {
|
|
$params = Sql2excelParms::getParms();
|
|
$ordering = Sql2excelParms::get($params,'category_ordering', 1);
|
|
$this->_category_ordering = Sql2excelQuery::getOrderingText($ordering);
|
|
|
|
}
|
|
return $this->_category_ordering;
|
|
}
|
|
}
|
|
?>
|