| Server IP : 195.130.67.5 / Your IP : 216.73.217.154 Web Server : Microsoft-IIS/10.0 System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586 User : IUSR ( 0) PHP Version : 7.4.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/inetpub/wwwroot/icd/components/com_sectionex/views/category/ |
Upload File : |
<?php
/**
* @package SectionEx
* @copyright Copyright (C) 2008 Robert Kuster. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* @link http://www.stackideas.com
*
* SectionEx is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
defined('_JEXEC') or die('Restricted access');
jimport( 'joomla.application.component.view');
// Component Helper
require_once(JPATH_COMPONENT_SITE.DS.'helpers'.DS.'misc.php');
require_once(JPATH_COMPONENT_SITE.DS.'helpers'.DS.'route.php');
require_once(JPATH_COMPONENT_SITE.DS.'classes'.DS.'theme.php');
/**
* HTML View class for the HelloWorld Component
*
* @package Joomla.Tutorials
* @subpackage Components
*/
class SectionExViewCategory extends JView
{
function display($tpl = null)
{
//initialise section themes
$theme = new seThemes();
$mainframe =& JFactory::getApplication();
$document =& JFactory::getDocument();
if ($this->get( 'IdSection') == 0)
{ // No section was selected for our menu item.. Show an error message and return.
echo "<b>".JText::_("ALERT_SECTION_NOT_SELECTED")."</b>";
return;
}
// Get page/component configuration
$params = &$mainframe->getParams();
$uri =& JFactory::getURI();
//set the params to have proper value incase it is using global.
RkHelper::syncParams($params);
// Get some data from the model
//$model =& $this->getModel();
$sectionList = & $this->get( 'SectionList');
$section = & $this->get( 'Section');
$categories = & $this->get( 'Categories');
$articles = & $this->get( 'Articles');
// ARTICLES -> create URL for each article
// CATEGORIES -> get start index into articles verctor && active articles per category
$this->_init_Additional_Category_And_Article_Data( $categories, $articles );
// -> "pagination" (actually we don't implement real pagination for now.
// we just display a simple listbox to limit the number of articles that is output)
$limit = 0;
$defLimit = $params->get('se_pagination');
$pagination = '';
if ($defLimit != -1)
{ // -> pagination is enabled?
jimport('joomla.html.pagination');
$keyPrefix = RkHelper::getPrefixFoxStateVariables(0);
$limit = $mainframe->getUserStateFromRequest($keyPrefix .'limit', 'limit', $params->def('display_num', $defLimit), 'int');
$limitstart = 0; // JRequest::getVar('limitstart', 0, '', 'int');
$pagination = new JPagination(500, $limitstart, $limit);
}
// -> create select lists
$lists = $this->_buildSortLists();
// add path to load the theme files, to support template override issue
$themepath = '';
jimport( 'joomla.filesystem.folder' );
// check for themes & template override
$user_theme = $theme->getThemes();
// get current joomla template
$template = $mainframe->getTemplate();
// we have override folder in current joomla template
if ( JFolder::exists( JPATH_ROOT . DS . 'templates' . DS . $template . DS . 'html' . DS . 'com_sectionex' ) ) {
if ( $params->get('se_theme_override') ) {
$themepath = rtrim(JURI::root(), '/') . '/templates/' . $template . '/html/com_sectionex';
}
else {
$themepath = rtrim(JURI::root(), '/') . '/components/com_sectionex/themes/' . $user_theme;
}
}
elseif ( JFolder::exists( JPATH_ROOT . DS . 'components' . DS . 'com_sectionex' . DS . 'themes' . DS . $user_theme ) ) {
$themepath = rtrim(JURI::root(), '/') . '/components/com_sectionex/themes/' . $user_theme;
}
else {
$themepath = rtrim(JURI::root(), '/') . '/components/com_sectionex/themes/default';
}
// -> asign refs so we can use the 'variables' in our tmpl files
$this->assignRef('sectionList' , $sectionList);
$this->assignRef('section' , $section);
$this->assignRef('categories' , $categories);
$this->assignRef('articles' , $articles);
$this->assignRef('params' , $params);
$this->assignRef('pagination' , $pagination);
$this->assign('themepath' , $themepath);
$this->assign('numitemlimit' , $limit);
$this->assign('action' , $uri->toString());
$this->assign('lists' , $lists);
jimport('joomla.filesystem.file');
// load common sejax files
$document->addScript( rtrim(JURI::root(),'/') . '/components/com_sectionex/assets/js/jquery-1.4.1.min.js' );
$document->addScript( rtrim(JURI::root(),'/') . '/components/com_sectionex/assets/js/sejax.js' );
if($params->get('se_filters') == 1)
{
// now we check if author filter is enabled or not.
if ( (($params->get('se_show_author') == 1) || ($params->get('se_show_author') == 2)) && ($params->get('se_use_autocomplete') == 1))
{
$document->addScript( rtrim(JURI::root(),'/') . '/components/com_sectionex/assets/js/jquery.autocomplete.js' );
$autoCLink = JURI::root().('index.php?option=com_sectionex&controller=ajax&task=getAuthor&no_html=1&tmpl=component');
$js =<<<SHOW
var author;
jQuery().ready(function(){
var options = {
serviceUrl: '$autoCLink',
minChars:2,
delimiter: /(,|;)\s*/, // regex or character
maxHeight:250,
width:200,
zIndex: 9999,
deferRequestBy: 0, //miliseconds
//params: { country:'Yes' }, //aditional parameters
// callback function:
onSelect: function(value, data){
sej('#sein_auth').val(value);
}
};
author = sej('#sein_auth').autocomplete(options);
});
SHOW;
$document->addScriptDeclaration($js);
}
}
$document->addStylesheet( rtrim(JURI::root(),'/') . '/components/com_sectionex/assets/css/common.css');
// load theme css from template override folder
if ( JFile::exists( JPATH_ROOT . DS . 'templates' . DS . $template . DS . 'html' . DS . 'com_sectionex' . DS . 'css' . DS . 'style.css' ) )
{
if ( $params->get('se_theme_override') ) {
$document->addStylesheet( rtrim(JURI::root(),'/') . '/templates/'.$template.'/html/com_sectionex/css/style.css');
}
else {
$document->addStylesheet( rtrim(JURI::root(),'/') . '/components/com_sectionex/themes/' . $theme->getThemes() . '/css/style.css');
}
}
// load theme css
elseif ( JFile::exists( JPATH_ROOT . DS . 'components' . DS . 'com_sectionex' . DS . 'themes' . DS . $theme->getThemes() . DS . 'css' . DS . 'style.css' ) )
{
$document->addStylesheet( rtrim(JURI::root(),'/') . '/components/com_sectionex/themes/' . $theme->getThemes() . '/css/style.css');
}
if ( (($params->get('se_show_intro_text') == 2) || ($params->get('se_show_intro_text') == 3)) &&
($params->get('se_images_in_intro_text') == 0))
{ // -> this CSS style merely hides images inside article descriptions
$document->addStylesheet(rtrim(JURI::root(),'/') . '/components/com_sectionex/themes/' . $theme->getThemes() . '/css/style_hide_intro_imgs.css');
}
parent::display($tpl);
// Stackideas
echo '<div style="text-align: center; padding: 20px 0;"><a href="http://stackideas.com">Powered by SectionEx for Joomla!</a></div>';
}
// ARTICLES -> create URL for each article
// CATEGORIES -> get start index into articles verctor and active articles per category
function _init_Additional_Category_And_Article_Data(&$categories, &$articles)
{
// for CATEGORIES:
// a) retrieve start index into the article array for each category
// (note that articles have been "ordered" by categories in our SQL statement, thus
// all articles of one categroy are "bundled" together one after the other)
// b) calculate the number of active articles( #actually displayed articles -> this will be a number
// between "0 < activeItems < numitems", depending on the filtering criteriums)
// values needed for generating URLs
$isSefEnabled = $this->_isSef();
$newItemId = "Itemid=" . RkHelper::getIdOfActiveMenu();
// LOOP over all categories
// -> store Idx into "$categories" vector for every catid
for ($i=0; $i < sizeof($categories); $i++)
{
$category = & $categories[$i];
$category->item_startIdx = -1;
$category->numitems_active = 0;
$categoryIdx[$category->id] = $i;
}
// LOOP over all articles
for ($i=0; $i < sizeof($articles); $i++)
{
$article = & $articles[$i];
// skip uncategorized articles for now
if ($article->catid == 0)
continue;
// -> get item_startIdx && refresh numitems_active
$catIdx = $categoryIdx[$article->catid];
$category = & $categories[$catIdx];
if ($category->item_startIdx == -1)
$category->item_startIdx = $i;
$category->numitems_active += 1;
// -> get article's URL
$article->link = $this->_getArticleURL($article, $isSefEnabled, $newItemId);
}
}
function _getArticleURL(&$article, &$isSefEnabled, &$newItemId)
{
global $mainframe;
$params = &$mainframe->getParams();
$link = '';
// -> Fron Page like links?
if ($params->get('se_menu_behavior') == 1)
{
// -> create a link with the functionality provided by Joomla! core
$link = JRoute::_(ContentHelperRouteX::getArticleRoute($article->slug, $article->catslug, $article->sectionid));
return $link;
}
// -> SectionEx like links?
if ($isSefEnabled == true)
{ // -> SEO urls enabled
// manually create a link that links to our component;
// sectionexBuildRoute is called implicitly (by JRoute)
$link = JRoute::_('index.php?view=article&catid='.$article->catslug.'&id='.$article->slug);
return $link;
}
else
{ // -> RAW urls enabled
$link = JRoute::_(ContentHelperRouteX::getArticleRoute($article->slug, $article->catslug, $article->sectionid));
// Is there an Itemid somewhere in the link?
if (preg_match("/Item[Ii]d=[0-9]+/", $link, $oldItemId))
{
// -> replace the existing Itemid with Itdemid="OurMenu".
// This way our menu stays highlihte even though we are displaying content from another component.
$link = str_replace( $oldItemId[0], $newItemId, $link );
return $link;
}
else
{ // If there is no Itemid (no other menu which links to the displayed article) append it.
$link = $link . "&" .$newItemId;
return $link;
}
} // else -> RAW links
// Oops. Should never get here..
return $link;
}
function _isSef()
{
$mainframe =& JFactory::getApplication();
$sef = $mainframe->getCfg('sef');
if ($sef == JROUTER_MODE_SEF)
return true;
return false;
}
function _buildSortLists()
{
global $mainframe;
$params = &$mainframe->getParams();
// Table ordering values -> Get filter data from Reuqest or session
$keyPrefix = RkHelper::getPrefixFoxStateVariables($params->get('se_sort_propagate'));
$filter_order = $mainframe->getUserStateFromRequest($keyPrefix . 'filter_order', 'filter_order', '');
$filter_order_Dir = $mainframe->getUserStateFromRequest($keyPrefix . 'filter_order_Dir', 'filter_order_Dir', '');
$filter_title = JRequest::getString('filter_title', '', 'request');
$filter_author = JRequest::getString('filter_author', '', 'request');
$filter_content = JRequest::getString('filter_content', '', 'request');
$lists['order'] = $filter_order;
$lists['order_Dir'] = $filter_order_Dir;
$lists['title'] = $filter_title;
$lists['author'] = $filter_author;
$lists['content'] = $filter_content;
return $lists;
}
function _getHtmlTocEntry($c)
{
$row = &$this->categories[$c];
$juri = JURI::getInstance();
$str_numitems_active = $this->_is_a_FilterActive() ? ($row->numitems_active . "/") : null;
if ($this->_is_a_FilterActive() && ($row->numitems_active == 0))
{
$strRet = "";
//$strRet .= "<li><span class=\"small\">";
$strRet .= $row->title;
if ($this->params->get('se_toc_show_numitems') == 1)
{
$strRet .= " ( ". $str_numitems_active . $row->numitems ." ". JText::_('ITEMS') ." )";
}
//$strRet .= "</span></li>";
}
else
{
$strRet = "";
$strRet .= "<a href='" . $juri->toString() . "#catid" . $row->id . "'>";
$strRet .= $row->title;
if ($this->params->get('se_toc_show_numitems') == 1)
{
$strRet .= "</a> <span class=\"small\">( ". $str_numitems_active . $row->numitems ." ". JText::_('ITEMS') ." )</span>";
}
else
{
$strRet .= "</a>";
}
}
return $strRet;
}
function _is_a_FilterActive()
{
global $mainframe;
$params = &$mainframe->getParams();
if ($params->get('se_filters'))
{
$filter_title = JRequest::getString('filter_title', '', 'request');
if ($filter_title)
{
return true;
}
$filter_author = JRequest::getString('filter_author', '', 'request');
if ($filter_author)
{
return true;
}
$filter_content = JRequest::getString('filter_content', '', 'request');
if ($filter_content)
{
return true;
}
}
return false;
}
function _writeInlineStyle($style)
{
if ($this->params->get('use_inline_css') == 1)
{
echo "style='" . $style . "'";
}
}
function _formatAndConvertIntroText(&$introtext)
{
if (($this->params->get('se_show_intro_text_short')==1) ||
($this->params->get('se_show_intro_text_short')==2))
{ // show only a short variant of our intro-text (if it is defined in a special hidden <span> tag)
// Look for a string which is defined with the following span (only exact machtes):
// <span style="display: none" class="ShortDescription">.....</span>
$regex_pattern = "/<span style=\"display: none\" class=\"ShortDescription\">(.*)<\/span>/";
if (preg_match($regex_pattern, $introtext, $matches))
{
$introtext = $matches[1];
return;
}
if ($this->params->get('se_show_intro_text_short')==2)
{ // se_show_intro_text_short == 2 == SHORT_ONLY
// We wanted only short introduction textes. If they are not specified then nothing is displayed.
$introtext = "";
return;
}
}
// If we got here then we didn't change the introduction text in any way. The full introduction text will be displayed
// (this is the same text as displayed on the front-page). This applies for one of the following scenarios:
// a) se_show_intro_text_short == 0 (NO)
// b) se_show_intro_text_short == 1 (SHORT_IF_IT_EXISTS), but no short-intro was defined for our article
}
}
?>