/components/com_content/content.php
PHP | 1539 lines | 1071 code | 228 blank | 240 comment | 195 complexity | bfde6f6cb5eaa5d3e57176234e2dc28f MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
- <?php
- /**
- * @version $Id: content.php 6019 2006-12-18 19:50:34Z friesengeist $
- * @package Joomla
- * @subpackage Content
- * @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
- * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
- * Joomla! 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.
- */
- // no direct access
- defined( '_VALID_MOS' ) or die( 'Restricted access' );
- require_once( $mainframe->getPath( 'front_html', 'com_content' ) );
- $id = intval( mosGetParam( $_REQUEST, 'id', 0 ) );
- $sectionid = intval( mosGetParam( $_REQUEST, 'sectionid', 0 ) );
- $pop = intval( mosGetParam( $_REQUEST, 'pop', 0 ) );
- $limit = intval( mosGetParam( $_REQUEST, 'limit', 0 ) );
- $limitstart = intval( mosGetParam( $_REQUEST, 'limitstart', 0 ) );
- $year = intval( mosGetParam( $_REQUEST, 'year', date( 'Y' ) ) );
- $month = intval( mosGetParam( $_REQUEST, 'month', date( 'm' ) ) );
- $module = intval( mosGetParam( $_REQUEST, 'module', 0 ) );
- // Editor usertype check
- $access = new stdClass();
- $access->canEdit = $acl->acl_check( 'action', 'edit', 'users', $my->usertype, 'content', 'all' );
- $access->canEditOwn = $acl->acl_check( 'action', 'edit', 'users', $my->usertype, 'content', 'own' );
- $access->canPublish = $acl->acl_check( 'action', 'publish', 'users', $my->usertype, 'content', 'all' );
- // cache activation
- $cache =& mosCache::getCache( 'com_content' );
- // loads function for frontpage component
- if ( $option == 'com_frontpage' ) {
- $cache->call( 'frontpage', $gid, $access, $pop, 0, $limit, $limitstart );
- return;
- }
- switch ( $task ) {
- case 'findkey':
- findKeyItem( $gid, $access, $pop, $option, 0 );
- break;
- case 'view':
- if ($mosConfig_enable_stats) {
- showItem( $id, $gid, $access, $pop, $option, 0 );
- } else {
- $cache->call( 'showItem', $id, $gid, $access, $pop, $option, 0, $limit, $limitstart );
- }
- break;
- case 'section':
- $cache->call( 'showSection', $id, $gid, $access, 0 );
- break;
- case 'category':
- $selected = strval( mosGetParam( $_REQUEST, 'order', '' ) );
- $filter = stripslashes( strval( mosGetParam( $_REQUEST, 'filter', '' ) ) );
- $cache->call( 'showCategory', $id, $gid, $access, $sectionid, $limit, NULL, $limitstart, 0, $selected, $filter );
- break;
- case 'blogsection':
- // Itemid is a dummy value to cater for caching
- $cache->call('showBlogSection', $id, $gid, $access, $pop, $Itemid, $limit, $limitstart );
- break;
- case 'blogcategorymulti':
- case 'blogcategory':
- // Itemid is a dummy value to cater for caching
- $cache->call( 'showBlogCategory', $id, $gid, $access, $pop, $Itemid, $limit, $limitstart );
- break;
- case 'archivesection':
- // Itemid is a dummy value to cater for caching
- $cache->call( 'showArchiveSection', $id, $gid, $access, $pop, $option, $year, $month, $limit, $limitstart, $Itemid );
- break;
- case 'archivecategory':
- // Itemid is a dummy value to cater for caching
- $cache->call( 'showArchiveCategory', $id, $gid, $access, $pop, $option, $year, $month, $module, $limit, $limitstart, $Itemid );
- break;
- case 'edit':
- editItem( $id, $gid, $access, 0, $task, $Itemid );
- break;
- case 'new':
- editItem( 0, $gid, $access, $sectionid, $task, $Itemid );
- break;
- case 'save':
- case 'apply':
- case 'apply_new':
- mosCache::cleanCache( 'com_content' );
- saveContent( $access, $task );
- break;
- case 'cancel':
- cancelContent( $access );
- break;
- case 'emailform':
- emailContentForm( $id, $gid );
- // ------------------------ A8E fix ------------------------
- if(basename($_SERVER['PHP_SELF']) == 'index.php') showItem( $id, $gid, $access, $pop, $option, $now );
- break;
- case 'emailsend':
- emailContentSend( $id, $gid );
- // ------------------------ A8E fix ------------------------
- if(basename($_SERVER['PHP_SELF']) == 'index.php') showItem( $id, $gid, $access, $pop, $option, $now );
- break;
- case 'vote':
- recordVote ();
- break;
- default:
- header("HTTP/1.0 404 Not Found");
- echo _NOT_EXIST;
- break;
- }
- /**
- * Searches for an item by a key parameter
- * @param int The user access level
- * @param object Actions this user can perform
- * @param int
- * @param string The url option
- * @param string A timestamp
- */
- function findKeyItem( $gid, $access, $pop, $option, $now ) {
- global $database;
- $keyref = stripslashes( strval( mosGetParam( $_REQUEST, 'keyref', '' ) ) );
- $query = "SELECT id"
- . "\n FROM #__content"
- . "\n WHERE attribs LIKE '%keyref=" . $database->getEscaped( $keyref ) . "%'"
- ;
- $database->setQuery( $query );
- $id = $database->loadResult();
- if ($id > 0) {
- showItem( $id, $gid, $access, $pop, $option, 0 );
- } else {
- echo _KEY_NOT_FOUND;
- }
- }
- function frontpage( $gid, &$access, $pop, $now, $limit, $limitstart ) {
- global $database, $mainframe;
- $now = _CURRENT_SERVER_TIME;
- $nullDate = $database->getNullDate();
- $noauth = !$mainframe->getCfg( 'shownoauth' );
- // Parameters
- $menu = $mainframe->get( 'menu' );
- $params = new mosParameters( $menu->params );
- // Ordering control
- $orderby_sec = $params->def( 'orderby_sec', '' );
- $orderby_pri = $params->def( 'orderby_pri', '' );
- $order_sec = _orderby_sec( $orderby_sec );
- $order_pri = _orderby_pri( $orderby_pri );
- // voting control
- $voting = $params->def( 'rating', '' );
- $voting = votingQuery($voting);
- $where = _where( 1, $access, $noauth, $gid, 0, $now, NULL, NULL, $params );
- //Cater for static content
- $static = array('a.sectionid = 0');
- foreach(_where( 1, $access, $noauth, $gid, 0, $now, NULL, NULL, $params ) as $x){
-
- $exclude = array("s.published = 1","cc.published = 1", "s.access <= " . (int) $gid, "cc.access <= " . (int) $gid);
- if(!in_array($x, $exclude)){
- $static[] = $x;
- }
- }
- $where = ( count( $where ) ? "\n WHERE (". implode( "\n AND ", $where ).') OR ('.implode("\n AND ", $static).') ' : '' );
- // Limit & limitstart
- $intro = $params->def( 'intro', $GLOBALS['mosConfig_blog_intro'] );
- $leading = $params->def( 'leading', $GLOBALS['mosConfig_blog_leading'] );
- $links = $params->def( 'link', $GLOBALS['mosConfig_blog_links'] );
- $limit = $intro + $leading + $links;
- // query to determine total number of records
- $query = "SELECT COUNT(a.id)"
- . "\n FROM #__content AS a"
- . "\n INNER JOIN #__content_frontpage AS f ON f.content_id = a.id"
- . "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid"
- . "\n LEFT JOIN #__sections AS s ON s.id = a.sectionid"
- . "\n LEFT JOIN #__users AS u ON u.id = a.created_by"
- . "\n LEFT JOIN #__groups AS g ON a.access = g.id"
- . $where
- ;
- $database->setQuery( $query );
- $total = $database->loadResult();
- if ( $total <= $limit ) {
- $limitstart = 0;
- }
- // query records
- $query = "SELECT a.id, a.title, a.title_alias, a.introtext, a.sectionid, a.state, a.catid, a.created, a.created_by, a.created_by_alias, a.modified, a.modified_by,"
- . "\n a.checked_out, a.checked_out_time, a.publish_up, a.publish_down, a.images, a.urls, a.ordering, a.metakey, a.metadesc, a.access, a.hits,"
- . "\n CHAR_LENGTH( a.fulltext ) AS readmore, u.name AS author, u.usertype, s.name AS section, cc.name AS category, g.name AS groups"
- . "\n, s.id AS sec_id, cc.id as cat_id"
- . $voting['select']
- . "\n FROM #__content AS a"
- . "\n INNER JOIN #__content_frontpage AS f ON f.content_id = a.id"
- . "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid"
- . "\n LEFT JOIN #__sections AS s ON s.id = a.sectionid"
- . "\n LEFT JOIN #__users AS u ON u.id = a.created_by"
- . "\n LEFT JOIN #__groups AS g ON a.access = g.id"
- . $voting['join']
- . $where
- . "\n ORDER BY $order_pri $order_sec"
- ;
- $database->setQuery( $query, $limitstart, $limit );
-
- $rows = $database->loadObjectList();
- // Dynamic Page Title
- $mainframe->SetPageTitle( $menu->name );
- $mainframe->addMetaTag( 'description', $params->get('metadesc','') );
- $mainframe->addMetaTag( 'keywords', $params->get('metakey','') );
- BlogOutput( $rows, $params, $gid, $access, $pop, $menu, $limitstart, $limit, $total );
- }
- function showSection( $id, $gid, &$access, $now ) {
- global $database, $mainframe, $Itemid;
- $section = new mosSection( $database );
- $section->load( (int)$id );
- /*
- Check if section is published
- */
- if(!$section->published) {
- mosNotAuth();
- return;
- }
- /*
- * check whether section access level allows access
- */
- if( $section->access > $gid ) {
- mosNotAuth();
- return;
- }
- $now = _CURRENT_SERVER_TIME;
- $nullDate = $database->getNullDate();
- $noauth = !$mainframe->getCfg( 'shownoauth' );
- // Paramters
- $params = new stdClass();
- if ( $Itemid ) {
- $menu = $mainframe->get( 'menu' );
- $params = new mosParameters( $menu->params );
- } else {
- $menu = '';
- $params = new mosEmpty();
- }
- $orderby = $params->get( 'orderby', '' );
- $params->set( 'type', 'section' );
- $params->def( 'page_title', 1 );
- $params->def( 'pageclass_sfx', '' );
- $params->def( 'description_sec', 1 );
- $params->def( 'description_sec_image', 1 );
- $params->def( 'other_cat_section', 1 );
- $params->def( 'empty_cat_section', 0 );
- $params->def( 'other_cat', 1 );
- $params->def( 'empty_cat', 0 );
- $params->def( 'cat_items', 1 );
- $params->def( 'cat_description', 1 );
- $params->def( 'back_button', $mainframe->getCfg( 'back_button' ) );
- $params->def( 'pageclass_sfx', '' );
- // param controls whether unpublished items visible to publishers and above
- $params->def( 'unpublished', 1 );
- // Ordering control
- $orderby = _orderby_sec( $orderby );
- // Description & Description Image control
- $params->def( 'description', $params->get( 'description_sec' ) );
- $params->def( 'description_image', $params->get( 'description_sec_image' ) );
- if ( $access->canEdit ) {
- $xwhere = '';
- if ( $params->get( 'unpublished' ) ) {
- // shows unpublished items for publishers and above
- $xwhere2 = "\n AND (b.state >= 0 or b.state is null)";
- } else {
- // unpublished items NOT shown for publishers and above
- $xwhere2 = "\n AND (b.state = 1 or b.state is null)";
- }
- } else {
- $xwhere = "\n AND a.published = 1";
- $xwhere2 = "\n AND b.state = 1"
- . "\n AND ( b.publish_up = " . $database->Quote( $nullDate ) . " OR b.publish_up <= " . $database->Quote( $now ) . " )"
- . "\n AND ( b.publish_down = " . $database->Quote( $nullDate ) . " OR b.publish_down >= " . $database->Quote( $now ) . " )"
- ;
- }
- $empty = '';
- $empty_sec = '';
- if ( $params->get( 'type' ) == 'category' ) {
- // show/hide empty categories
- if ( !$params->get( 'empty_cat' ) ) {
- $empty = "\n HAVING numitems > 0";
- }
- }
- if ( $params->get( 'type' ) == 'section' ) {
- // show/hide empty categories in section
- if ( !$params->get( 'empty_cat_section' ) ) {
- $empty_sec = "\n HAVING numitems > 0";
- }
- }
- $access_check = '';
- $access_check_content = '';
- if ($noauth) {
- $access_check = "\n AND a.access <= " . (int) $gid;
- $access_check_content = "\n AND b.access <= " . (int) $gid;
- }
- // Query of categories within section
- $query = "SELECT a.*, COUNT( b.id ) AS numitems"
- . "\n FROM #__categories AS a"
- . "\n LEFT JOIN #__content AS b ON b.catid = a.id"
- . $xwhere2
- . "\n WHERE a.section = '" . (int) $section->id . "'"
- . $xwhere
- . $access_check
- . $access_check_content
- . "\n GROUP BY a.id"
- . $empty
- . $empty_sec
- . "\n ORDER BY $orderby"
- ;
- $database->setQuery( $query );
- $categories = $database->loadObjectList();
- // If categories exist, the "new content" icon may be displayed
- $categories_exist = false;
- if ( $access->canEdit ) {
- $query = "SELECT count(*) as numCategories"
- . "\n FROM #__categories as a"
- . "\n WHERE a.section = '" . (int) $section->id . "'"
- . $access_check;
- $database->setQuery ( $query );
- $categories_exist = ($database->loadResult()) > 0;
- }
- // remove slashes
- $section->name = stripslashes($section->name);
- // Dynamic Page Title
- $mainframe->SetPageTitle( $menu->name );
- $null = null;
- HTML_content::showContentList( $section, $null, $access, $id, $null, $gid, $params, $null, $categories, $null, $null, $categories_exist );
- }
- /**
- * @param int The category id
- * @param int The group id of the user
- * @param int The access level of the user
- * @param int The section id
- * @param int The number of items to dislpay
- * @param int The offset for pagination
- */
- function showCategory( $id, $gid, &$access, $sectionid, $limit, $selected, $limitstart, $now, $selected, $filter ) {
- global $database, $mainframe, $Itemid, $mosConfig_list_limit;
- $category = new mosCategory( $database );
- $category->load( (int)$id );
- /*
- Check if category is published
- */
- if(!$category->published) {
- mosNotAuth();
- return;
- }
- /*
- * check whether category access level allows access
- */
- if( $category->access > $gid ) {
- mosNotAuth();
- return;
- }
- $section = new mosSection( $database );
- $section->load( $category->section );
- /*
- Check if category is published
- */
- if(!$section->published) {
- mosNotAuth();
- return;
- }
- /*
- * check whether section access level allows access
- */
- if( $section->access > $gid ) {
- mosNotAuth();
- return;
- }
- $now = _CURRENT_SERVER_TIME;
- $nullDate = $database->getNullDate();
- $noauth = !$mainframe->getCfg( 'shownoauth' );
- // Paramters
- $params = new stdClass();
- if ( $Itemid ) {
- $menu = $mainframe->get( 'menu' );
- $params = new mosParameters( $menu->params );
- } else {
- $menu = '';
- $params = new mosParameters( '' );
- }
- $lists['order_value'] = '';
- if ( $selected ) {
- $orderby = $selected;
- $lists['order_value'] = $selected;
- } else {
- $orderby = $params->get( 'orderby', 'rdate' );
- $selected = $orderby;
- }
- $params->set( 'type', 'category' );
- $params->def( 'description_cat', 1 );
- $params->def( 'description_cat_image', 1 );
- $params->def( 'page_title', 1 );
- $params->def( 'title', 1 );
- $params->def( 'hits', $mainframe->getCfg( 'hits' ) );
- $params->def( 'author', !$mainframe->getCfg( 'hideAuthor' ) );
- $params->def( 'date', !$mainframe->getCfg( 'hideCreateDate' ) );
- $params->def( 'date_format', _DATE_FORMAT_LC );
- $params->def( 'navigation', 2 );
- $params->def( 'display', 0 );
- $params->def( 'display_num', $mosConfig_list_limit );
- $params->def( 'other_cat', 0 );
- $params->def( 'empty_cat', 0 );
- $params->def( 'cat_items', 1 );
- $params->def( 'cat_description', 0 );
- $params->def( 'back_button', $mainframe->getCfg( 'back_button' ) );
- $params->def( 'pageclass_sfx', '' );
- $params->def( 'headings', 1 );
- $params->def( 'order_select', 0 );
- $params->def( 'filter', 0 );
- $params->def( 'filter_type', 'title' );
- // param controls whether unpublished items visible to publishers and above
- $params->def( 'unpublished', 1 );
- // Ordering control
- $orderby = _orderby_sec( $orderby );
- // Description & Description Image control
- $params->def( 'description', $params->get( 'description_cat' ) );
- $params->def( 'description_image', $params->get( 'description_cat_image' ) );
- if ( $sectionid == 0 ) {
- $sectionid = $category->section;
- }
- if ( $access->canEdit ) {
- $xwhere = '';
- if ( $params->get( 'unpublished' ) ) {
- // shows unpublished items for publishers and above
- $xwhere2 = "\n AND b.state >= 0";
- } else {
- // unpublished items NOT shown for publishers and above
- $xwhere2 = "\n AND b.state = 1";
- }
- } else {
- $xwhere = "\n AND c.published = 1";
- $xwhere2 = "\n AND b.state = 1"
- . "\n AND ( b.publish_up = " . $database->Quote( $nullDate ) . " OR b.publish_up <= " . $database->Quote( $now ) . " )"
- . "\n AND ( b.publish_down = " . $database->Quote( $nullDate ) . " OR b.publish_down >= " . $database->Quote( $now ) . " )"
- ;
- }
- $pagetitle = '';
- if ( $Itemid ) {
- $pagetitle = $menu->name;
- }
- // show/hide empty categories
- $empty = '';
- if ( !$params->get( 'empty_cat' ) )
- $empty = "\n HAVING COUNT( b.id ) > 0";
- // get the list of other categories
- $query = "SELECT c.*, COUNT( b.id ) AS numitems"
- . "\n FROM #__categories AS c"
- . "\n LEFT JOIN #__content AS b ON b.catid = c.id "
- . $xwhere2
- . ( $noauth ? "\n AND b.access <= " . (int) $gid : '' )
- . "\n WHERE c.section = '" . (int) $category->section . "'"
- . $xwhere
- . ( $noauth ? "\n AND c.access <= " . (int) $gid : '' )
- . "\n GROUP BY c.id"
- . $empty
- . "\n ORDER BY c.ordering"
- ;
- $database->setQuery( $query );
- $other_categories = $database->loadObjectList();
- // get the total number of published items in the category
- // filter functionality
- $and = null;
- if ( $params->get( 'filter' ) ) {
- if ( $filter ) {
- // clean filter variable
- $filter = strtolower( $filter );
- switch ( $params->get( 'filter_type' ) ) {
- case 'title':
- $and = "\n AND LOWER( a.title ) LIKE '%" . $database->getEscaped( $filter ) . "%'";
- break;
- case 'author':
- $and = "\n AND ( ( LOWER( u.name ) LIKE '%" . $database->getEscaped( $filter ) . "%' ) OR ( LOWER( a.created_by_alias ) LIKE '%" . $database->getEscaped( $filter ) . "%' ) )";
- break;
- case 'hits':
- $and = "\n AND a.hits LIKE '%" . $database->getEscaped( $filter ) . "%'";
- break;
- }
- }
- }
- if ( $access->canEdit ) {
- if ( $params->get( 'unpublished' ) ) {
- // shows unpublished items for publishers and above
- $xwhere = "\n AND a.state >= 0";
- } else {
- // unpublished items NOT shown for publishers and above
- $xwhere = "\n AND a.state = 1";
- }
- } else {
- $xwhere = "\n AND a.state = 1"
- . "\n AND ( publish_up = " . $database->Quote( $nullDate ) . " OR publish_up <= " . $database->Quote( $now ) . " )"
- . "\n AND ( publish_down = " . $database->Quote( $nullDate ) . " OR publish_down >= " . $database->Quote( $now ) . " )"
- ;
- }
- // query to determine total number of records
- $query = "SELECT COUNT(a.id) as numitems"
- . "\n FROM #__content AS a"
- . "\n LEFT JOIN #__users AS u ON u.id = a.created_by"
- . "\n LEFT JOIN #__groups AS g ON a.access = g.id"
- . "\n WHERE a.catid = " . (int) $category->id
- . $xwhere
- . ( $noauth ? "\n AND a.access <= " . (int) $gid : '' )
- . "\n AND " . (int) $category->access . " <= " . (int) $gid
- . $and
- . "\n ORDER BY $orderby"
- ;
- $database->setQuery( $query );
- $counter = $database->loadObjectList();
- $total = $counter[0]->numitems;
- $limit = $limit ? $limit : $params->get( 'display_num' ) ;
- if ( $total <= $limit ) {
- $limitstart = 0;
- }
- require_once( $GLOBALS['mosConfig_absolute_path'] . '/includes/pageNavigation.php' );
- $pageNav = new mosPageNav( $total, $limitstart, $limit );
- // get the list of items for this category
- $query = "SELECT a.id, a.title, a.hits, a.created_by, a.created_by_alias, a.images, a.created AS created, a.access, u.name AS author, a.state, g.name AS groups"
- . "\n FROM #__content AS a"
- . "\n LEFT JOIN #__users AS u ON u.id = a.created_by"
- . "\n LEFT JOIN #__groups AS g ON a.access = g.id"
- . "\n WHERE a.catid = " . (int) $category->id
- . $xwhere
- . ( $noauth ? "\n AND a.access <= " . (int) $gid : '' )
- . "\n AND " . (int) $category->access . " <= " . (int) $gid
- . $and
- . "\n ORDER BY $orderby"
- ;
- $database->setQuery( $query, $limitstart, $limit );
- $items = $database->loadObjectList();
- $check = 0;
- if ( $params->get( 'date' ) ) {
- $order[] = mosHTML::makeOption( 'date', _ORDER_DROPDOWN_DA );
- $order[] = mosHTML::makeOption( 'rdate', _ORDER_DROPDOWN_DD );
- $check .= 1;
- }
- if ( $params->get( 'title' ) ) {
- $order[] = mosHTML::makeOption( 'alpha', _ORDER_DROPDOWN_TA );
- $order[] = mosHTML::makeOption( 'ralpha', _ORDER_DROPDOWN_TD );
- $check .= 1;
- }
- if ( $params->get( 'hits' ) ) {
- $order[] = mosHTML::makeOption( 'hits', _ORDER_DROPDOWN_HA );
- $order[] = mosHTML::makeOption( 'rhits', _ORDER_DROPDOWN_HD );
- $check .= 1;
- }
- if ( $params->get( 'author' ) ) {
- $order[] = mosHTML::makeOption( 'author', _ORDER_DROPDOWN_AUA );
- $order[] = mosHTML::makeOption( 'rauthor', _ORDER_DROPDOWN_AUD );
- $check .= 1;
- }
- $order[] = mosHTML::makeOption( 'order', _ORDER_DROPDOWN_O );
- $lists['order'] = mosHTML::selectList( $order, 'order', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'value', 'text', $selected );
- if ( $check < 1 ) {
- $lists['order'] = '';
- $params->set( 'order_select', 0 );
- }
- $lists['task'] = 'category';
- $lists['filter'] = $filter;
- // remove slashes
- $category->name = stripslashes($category->name);
- // Dynamic Page Title
- $mainframe->SetPageTitle( ($category->name ? $category->name : $pagetitle) );
- HTML_content::showContentList( $category, $items, $access, $id, $sectionid, $gid, $params, $pageNav, $other_categories, $lists, $selected, true, $section );
- } // showCategory
- function showBlogSection( $id=0, $gid, &$access, $pop, $now=NULL, $limit, $limitstart ) {
- global $database, $mainframe, $Itemid, $mosConfig_blog_leading, $mosConfig_blog_intro, $mosConfig_blog_columns, $mosConfig_blog_links, $my;
- // needed for check whether section is published
- $check = ( $id ? $id : 0 );
- $now = _CURRENT_SERVER_TIME;
- $noauth = !$mainframe->getCfg( 'shownoauth' );
- // Parameters
- $params = new stdClass();
- if ( $Itemid ) {
- $menu = $mainframe->get( 'menu' );
- $params = new mosParameters( $menu->params );
- } else {
- $menu = '';
- $params = new mosParameters( '' );
- }
-
- // new blog multiple section handling
- if ( !$id ) {
- $id = $params->def( 'sectionid', 0 );
- }
- $where = _where( 1, $access, $noauth, $gid, $id, $now, NULL, NULL, $params );
- $where = ( count( $where ) ? "\n WHERE ". implode( "\n AND ", $where ) : '' );
- // Ordering control
- $orderby_sec = $params->def( 'orderby_sec', 'rdate' );
- $orderby_pri = $params->def( 'orderby_pri', '' );
- $order_sec = _orderby_sec( $orderby_sec );
- $order_pri = _orderby_pri( $orderby_pri );
- // voting control
- $voting = $params->def( 'rating', '' );
- $voting = votingQuery($voting);
- // Limit & limitstart
- $intro = $params->def( 'intro', $GLOBALS['mosConfig_blog_intro'] );
- $leading = $params->def( 'leading', $GLOBALS['mosConfig_blog_leading'] );
- $links = $params->def( 'link', $GLOBALS['mosConfig_blog_links'] );
- $limit = $limit ? $limit : ( $intro + $leading + $links );
- // query to determine total number of records
- $query = "SELECT COUNT(a.id)"
- . "\n FROM #__content AS a"
- . "\n INNER JOIN #__categories AS cc ON cc.id = a.catid"
- . "\n LEFT JOIN #__users AS u ON u.id = a.created_by"
- . "\n LEFT JOIN #__sections AS s ON a.sectionid = s.id"
- . "\n LEFT JOIN #__groups AS g ON a.access = g.id"
- . $where;
-
- $database->setQuery( $query );
- $total = $database->loadResult();
-
- if ( $total <= $limit ) {
- $limitstart = 0;
- }
-
- // Main data query
- $query = "SELECT a.id, a.title, a.title_alias, a.introtext, a.sectionid, a.state, a.catid, a.created, a.created_by, a.created_by_alias, a.modified, a.modified_by,"
- . "\n a.checked_out, a.checked_out_time, a.publish_up, a.publish_down, a.images, a.urls, a.ordering, a.metakey, a.metadesc, a.access,"
- . "\n CHAR_LENGTH( a.fulltext ) AS readmore, u.name AS author, u.usertype, s.name AS section, cc.name AS category, g.name AS groups"
- . $voting['select']
- . "\n FROM #__content AS a"
- . "\n INNER JOIN #__categories AS cc ON cc.id = a.catid"
- . "\n LEFT JOIN #__users AS u ON u.id = a.created_by"
- . "\n LEFT JOIN #__sections AS s ON a.sectionid = s.id"
- . "\n LEFT JOIN #__groups AS g ON a.access = g.id"
- . $voting['join']
- . $where
- . "\n ORDER BY $order_pri $order_sec"
- ;
- $database->setQuery( $query, $limitstart, $limit );
- $rows = $database->loadObjectList();
- // Dynamic Page Title & meta
- $section = new mosSection( $database );
- $section->load( (int)$check );
-
- if ($menu->name) {
- $mainframe->setPageTitle( $menu->name );
- }else{
- $mainframe->setPageTitle( $section->name );
- }
-
- if($check){
- $params_tmp = new mosParameters( $section->params );
- if($params_tmp->get('metadesc','')) $mainframe->addMetaTag( 'description', $params_tmp->get('metadesc','') );
- if($params_tmp->get('metakey','')) $mainframe->addMetaTag( 'keywords', $params_tmp->get('metakey','') );
- }
- // check whether section is published
- if (!count($rows) && $check) {
- $secCheck = new mosSection( $database );
- $secCheck->load( (int)$check );
- /*
- * check whether section is published
- */
- if (!$secCheck->published) {
- mosNotAuth();
- return;
- }
- /*
- * check whether section access level allows access
- */
- if ($secCheck->access > $gid) {
- mosNotAuth();
- return;
- }
- }
- BlogOutput( $rows, $params, $gid, $access, $pop, $menu, $limitstart, $limit, $total );
- }
- function showBlogCategory( $id=0, $gid, &$access, $pop, $now, $limit, $limitstart ) {
- global $database, $mainframe, $Itemid;
- $now = _CURRENT_SERVER_TIME;
- $noauth = !$mainframe->getCfg( 'shownoauth' );
- // needed for check whether section & category is published
- $check = ( $id ? $id : 0 );
- // Paramters
- $params = new stdClass();
- if ( $Itemid ) {
- $menu = $mainframe->get( 'menu' );
- $params = new mosParameters( $menu->params );
- } else {
- $menu = '';
- $params = new mosParameters( '' );
- }
- // ------------------------ A8E fixes start ------------------------
- // ADDED: menu-item is section, view is category
- // TODO: remove, as this is not an accessibility fix
- if ($menu->type == 'content_section' && $params->Get('category_as_blog', 0)) {
- $params = getCategorySettingsFromSection($params);
- }
- // ------------------------ A8E fixes end ------------------------
- // new blog multiple section handling
- if ( !$id ) {
- $id = $params->def( 'categoryid', 0 );
- }
- $where = _where( 2, $access, $noauth, $gid, $id, $now, NULL, NULL, $params );
- $where = ( count( $where ) ? "\n WHERE ". implode( "\n AND ", $where ) : '' );
- // Ordering control
- $orderby_sec = $params->def( 'orderby_sec', 'rdate' );
- $orderby_pri = $params->def( 'orderby_pri', '' );
- $order_sec = _orderby_sec( $orderby_sec );
- $order_pri = _orderby_pri( $orderby_pri );
- // voting control
- $voting = $params->def( 'rating', '' );
- $voting = votingQuery($voting);
- // Limit & limitstart
- $intro = $params->def( 'intro', $GLOBALS['mosConfig_blog_intro'] );
- $leading = $params->def( 'leading', $GLOBALS['mosConfig_blog_leading'] );
- $links = $params->def( 'link', $GLOBALS['mosConfig_blog_links'] );
- $limit = $limit ? $limit : ( $intro + $leading + $links );
- // query to determine total number of records
- $query = "SELECT COUNT(a.id)"
- . "\n FROM #__content AS a"
- . "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid"
- . "\n LEFT JOIN #__users AS u ON u.id = a.created_by"
- . "\n LEFT JOIN #__sections AS s ON a.sectionid = s.id"
- . "\n LEFT JOIN #__groups AS g ON a.access = g.id"
- . $where
- ;
- $database->setQuery( $query );
- $total = $database->loadResult();
- if ( $total <= $limit ) {
- $limitstart = 0;
- }
- // Main data query
- $query = "SELECT a.id, a.title, a.title_alias, a.introtext, a.sectionid, a.state, a.catid, a.created, a.created_by, a.created_by_alias, a.modified, a.modified_by,"
- . "\n a.checked_out, a.checked_out_time, a.publish_up, a.publish_down, a.images, a.urls, a.ordering, a.metakey, a.metadesc, a.access,"
- . "\n CHAR_LENGTH( a.fulltext ) AS readmore, s.published AS sec_pub, cc.published AS sec_pub, u.name AS author, u.usertype, s.name AS section, cc.name AS category, g.name AS groups"
- . $voting['select']
- . "\n FROM #__content AS a"
- . "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid"
- . "\n LEFT JOIN #__users AS u ON u.id = a.created_by"
- . "\n LEFT JOIN #__sections AS s ON a.sectionid = s.id"
- . "\n LEFT JOIN #__groups AS g ON a.access = g.id"
- . $voting['join']
- . $where
- . "\n ORDER BY $order_pri $order_sec"
- ;
- $database->setQuery( $query, $limitstart, $limit );
- $rows = $database->loadObjectList();
- // check whether section & category is published
- if (!count($rows) && $check) {
- $catCheck = new mosCategory( $database );
- $catCheck->load( (int)$check );
- /*
- * check whether category is published
- */
- if (!$catCheck->published) {
- mosNotAuth();
- return;
- }
- /*
- * check whether category access level allows access
- */
- if( $catCheck->access > $gid ) {
- mosNotAuth();
- return;
- }
- $secCheck = new mosSection( $database );
- $secCheck->load( $catCheck->section );
- /*
- * check whether section is published
- */
- if (!$secCheck->published) {
- mosNotAuth();
- return;
- }
- /*
- * check whether category access level allows access
- */
- if( $secCheck->access > $gid ) {
- mosNotAuth();
- return;
- }
- }
-
- // ------------------------ A8E fixes start ------------------------
- // load category
- // TODO: remove, as this is not an accessibility fix
- $currentCat = new mosCategory ($database);
- $currentCat->load ($id);
-
- //Add meta info
- if(!empty($description)){
- $params_tmp = new mosParameters( $currentCat->params );
- if($params_tmp->get('metadesc','')) $mainframe->addMetaTag( 'description', $params_tmp->get('metadesc','') );
- if($params_tmp->get('metakey','')) $mainframe->addMetaTag( 'keywords', $params_tmp->get('metakey','') );
- }
-
- // Dynamic Page Title
- if (count (explode (',', $id)) != 1) { //view on multiple categories -> must have menu-link -> menu-item title prevails
- $mainframe->SetPageTitle( $menu->name );
- } else if( $menu->name && $params->get('category_title',0)!=2 ) {
- $mainframe->SetPageTitle( $menu->name );
- }else { //view on single category -> category title prevails
- $mainframe->SetPageTitle( $currentCat->title );
- }
- // ------------------------ A8E fixes end ------------------------
- BlogOutput( $rows, $params, $gid, $access, $pop, $menu, $limitstart, $limit, $total );
- }
- function showArchiveSection( $id=NULL, $gid, &$access, $pop, $option, $year, $month, $limit, $limitstart ) {
- global $database, $mainframe;
- global $Itemid;
- $secID = ( $id ? $id : 0 );
- $noauth = !$mainframe->getCfg( 'shownoauth' );
- $params = new stdClass();
- if ( $Itemid ) {
- $menu = $mainframe->get( 'menu' );
- $params = new mosParameters( $menu->params );
- } else {
- $menu = "";
- $params = new mosParameters( '' );
- }
- $params->set( 'intro_only', 1 );
- $params->set( 'year', $year );
- $params->set( 'month', $month );
- // Ordering control
- $orderby_sec = $params->def( 'orderby_sec', 'rdate' );
- $orderby_pri = $params->def( 'orderby_pri', '' );
- $order_sec = _orderby_sec( $orderby_sec );
- $order_pri = _orderby_pri( $orderby_pri );
- // used in query
- $where = _where( -1, $access, $noauth, $gid, $id, NULL, $year, $month );
- $where = ( count( $where ) ? "\n WHERE ". implode( "\n AND ", $where ) : '' );
- // checks to see if 'All Sections' options used
- if ( $id == 0 ) {
- $check = '';
- } else {
- $check = "\n AND a.sectionid = " . (int) $id;
- }
- // query to determine if there are any archived entries for the section
- $query = "SELECT a.id"
- . "\n FROM #__content as a"
- . "\n WHERE a.state = -1"
- . $check
- ;
- $database->setQuery( $query );
- $items = $database->loadObjectList();
- $archives = count( $items );
- // voting control
- $voting = $params->def( 'rating', '' );
- $voting = votingQuery($voting);
- // Limit & limitstart
- $intro = $params->def( 'intro', $GLOBALS['mosConfig_blog_intro'] );
- $leading = $params->def( 'leading', $GLOBALS['mosConfig_blog_leading'] );
- $links = $params->def( 'link', $GLOBALS['mosConfig_blog_links'] );
- $limit = $limit ? $limit : ( $intro + $leading + $links );
- // query to determine total number of records
- $query = "SELECT COUNT(a.id)"
- . "\n FROM #__content AS a"
- . "\n INNER JOIN #__categories AS cc ON cc.id = a.catid"
- . "\n LEFT JOIN #__users AS u ON u.id = a.created_by"
- . "\n LEFT JOIN #__sections AS s ON a.sectionid = s.id"
- . "\n LEFT JOIN #__groups AS g ON a.access = g.id"
- . $where
- ;
- $database->setQuery( $query );
- $total = $database->loadResult();
- if ( $total <= $limit ) {
- $limitstart = 0;
- }
- // Main Query
- $query = "SELECT a.id, a.title, a.title_alias, a.introtext, a.sectionid, a.state, a.catid, a.created, a.created_by, a.created_by_alias, a.modified, a.modified_by,"
- . "\n a.checked_out, a.checked_out_time, a.publish_up, a.publish_down, a.images, a.urls, a.ordering, a.metakey, a.metadesc, a.access,"
- . "\n CHAR_LENGTH( a.fulltext ) AS readmore, u.name AS author, u.usertype, s.name AS section, cc.name AS category, g.name AS groups"
- . $voting['select']
- . "\n FROM #__content AS a"
- . "\n INNER JOIN #__categories AS cc ON cc.id = a.catid"
- . "\n LEFT JOIN #__users AS u ON u.id = a.created_by"
- . "\n LEFT JOIN #__sections AS s ON a.sectionid = s.id"
- . "\n LEFT JOIN #__groups AS g ON a.access = g.id"
- . $voting['join']
- . $where
- . "\n ORDER BY $order_pri $order_sec"
- ;
- $database->setQuery( $query, $limitstart, $limit );
- $rows = $database->loadObjectList();
- // check whether section is published
- if (!count($rows) && $secID != 0) {
- $secCheck = new mosSection( $database );
- $secCheck->load( (int)$secID );
- /*
- * check whether section is published
- */
- if (!$secCheck->published) {
- mosNotAuth();
- return;
- }
- /*
- * check whether section access level allows access
- */
- if ($secCheck->access > $gid) {
- mosNotAuth();
- return;
- }
- }
- // initiate form
- $link = 'index.php?option=com_content&task=archivesection&id='. $id .'&Itemid='. $Itemid;
- echo '<form action="'.sefRelToAbs( $link ).'" method="post">';
- // Dynamic Page Title
- $mainframe->SetPageTitle( $menu->name );
- if ( !$archives ) {
- // if no archives for category, hides search and outputs empty message
- echo '<br /><div align="center">'. _CATEGORY_ARCHIVE_EMPTY .'</div>';
- } else {
- BlogOutput( $rows, $params, $gid, $access, $pop, $menu, $limitstart, $limit, $total, 1, 1 );
- }
- echo '<input type="hidden" name="id" value="'. $id .'" />';
- echo '<input type="hidden" name="Itemid" value="'. $Itemid .'" />';
- echo '<input type="hidden" name="task" value="archivesection" />';
- echo '<input type="hidden" name="option" value="com_content" />';
- echo '</form>';
- }
- function showArchiveCategory( $id=0, $gid, &$access, $pop, $option, $year, $month, $module, $limit, $limitstart ) {
- global $database, $mainframe;
- global $Itemid;
- $now = _CURRENT_SERVER_TIME;
- $noauth = !$mainframe->getCfg( 'shownoauth' );
- // needed for check whether section & category is published
- $catID = ( $id ? $id : 0 );
- // used by archive module
- if ( $module ) {
- $check = '';
- } else {
- $check = "\n AND a.catid = " . (int) $id;
- }
- if ( $Itemid ) {
- $menu = $mainframe->get( 'menu' );
- $params = new mosParameters( $menu->params );
- } else {
- $menu = '';
- $params = new mosParameters( '' );
- }
- $params->set( 'year', $year );
- $params->set( 'month', $month );
- // Ordering control
- $orderby_sec = $params->def( 'orderby', 'rdate' );
- $order_sec = _orderby_sec( $orderby_sec );
- // used in query
- $where = _where( -2, $access, $noauth, $gid, $id, NULL, $year, $month );
- $where = ( count( $where ) ? "\n WHERE ". implode( "\n AND ", $where ) : '' );
- // query to determine if there are any archived entries for the category
- $query = "SELECT a.id"
- . "\n FROM #__content as a"
- . "\n WHERE a.state = -1"
- . $check
- ;
- $database->setQuery( $query );
- $items = $database->loadObjectList();
- $archives = count( $items );
- // voting control
- $voting = $params->def( 'rating', '' );
- $voting = votingQuery($voting);
- // Limit & limitstart
- $intro = $params->def( 'intro', $GLOBALS['mosConfig_blog_intro'] );
- $leading = $params->def( 'leading', $GLOBALS['mosConfig_blog_leading'] );
- $links = $params->def( 'link', $GLOBALS['mosConfig_blog_links'] );
- $limit = $limit ? $limit : ( $intro + $leading + $links );
- // query to determine total number of records
- $query = "SELECT COUNT(a.id)"
- . "\n FROM #__content AS a"
- . "\n INNER JOIN #__categories AS cc ON cc.id = a.catid"
- . "\n LEFT JOIN #__users AS u ON u.id = a.created_by"
- . "\n LEFT JOIN #__sections AS s ON a.sectionid = s.id"
- . "\n LEFT JOIN #__groups AS g ON a.access = g.id"
- . $where
- ;
- $database->setQuery( $query );
- $total = $database->loadResult();
- if ( $total <= $limit ) {
- $limitstart = 0;
- }
- // main query
- $query = "SELECT a.id, a.title, a.title_alias, a.introtext, a.sectionid, a.state, a.catid, a.created, a.created_by, a.created_by_alias, a.modified, a.modified_by,"
- . "\n a.checked_out, a.checked_out_time, a.publish_up, a.publish_down, a.images, a.urls, a.ordering, a.metakey, a.metadesc, a.access,"
- . "\n CHAR_LENGTH( a.fulltext ) AS readmore, u.name AS author, u.usertype, s.name AS section, cc.name AS category, g.name AS groups"
- . $voting['select']
- . "\n FROM #__content AS a"
- . "\n INNER JOIN #__categories AS cc ON cc.id = a.catid"
- . "\n LEFT JOIN #__users AS u ON u.id = a.created_by"
- . "\n LEFT JOIN #__sections AS s ON a.sectionid = s.id"
- . "\n LEFT JOIN #__groups AS g ON a.access = g.id"
- . $voting['join']
- . $where
- . "\n ORDER BY $order_sec"
- ;
- $database->setQuery( $query, $limitstart, $limit );
- $rows = $database->loadObjectList();
- // check whether section & category is published
- if (!count($rows) && $catID != 0) {
- $catCheck = new mosCategory( $database );
- $catCheck->load( (int)$catID );
- /*
- * check whether category is published
- */
- if (!$catCheck->published) {
- mosNotAuth();
- return;
- }
- /*
- * check whether category access level allows access
- */
- if( $catCheck->access > $gid ) {
- mosNotAuth();
- return;
- }
- $secCheck = new mosSection( $database );
- $secCheck->load( $catCheck->section );
- /*
- * check whether section is published
- */
- if (!$secCheck->published) {
- mosNotAuth();
- return;
- }
- /*
- * check whether category access level allows access
- */
- if( $secCheck->access > $gid ) {
- mosNotAuth();
- return;
- }
- }
- // initiate form
- // ------------------------ A8E fix ------------------------
- $link = ampReplace('index.php?option=com_content&task=archivecategory&id='. $id .'&Itemid='. $Itemid);
- echo '<form action="'.sefRelToAbs( $link ).'" method="post">';
- // Page Title
- $mainframe->SetPageTitle( $menu->name );
- if ( !$archives ) {
- // if no archives for category, hides search and outputs empty message
- echo '<br />';
- echo '<div align="center">'. _CATEGORY_ARCHIVE_EMPTY .'</div>';
- } else {
- // if coming from the Archive Module, the Archive Dropdown selector is not shown
- if ( $id ) {
- BlogOutput( $rows, $params, $gid, $access, $pop, $menu, $limitstart, $limit, $total, 1, 1 );
- } else {
- BlogOutput( $rows, $params, $gid, $access, $pop, $menu, $limitstart, $limit, $total, 0, 1 );
- }
- }
- echo '<input type="hidden" name="id" value="'. $id .'" />';
- echo '<input type="hidden" name="Itemid" value="'. $Itemid .'" />';
- echo '<input type="hidden" name="task" value="archivecategory" />';
- echo '<input type="hidden" name="option" value="com_content" />';
- echo '</form>';
- }
- function BlogOutput ( &$rows, &$params, $gid, &$access, $pop, &$menu, $limitstart, $limit, $total, $archive=NULL, $archive_page=NULL ) {
- global $mainframe, $Itemid, $task, $id, $option, $database, $mosConfig_live_site, $my;
-
- // ------------------------ A8E fixes start ------------------------
- // TODO: remove, as this is not an accessibility fix
- $category = null;
-
- //
- if (($menu->type == 'content_section' || $menu->type == 'content_blog_section') && $params->get('category_title',0)==2 && $task == 'blogcategory') {
- //category not in menu -> override menu item title
- $category = new mosCategory( $database );
- $category->load($id);
- $header = ampReplace($category->title);
- } else if ( $params->get( 'page_title', 1 ) && $menu && $params->get('category_title',0)!=1 ) {
- //parameters
- $header = ampReplace($params->def( 'header', $menu->name ));
- } else {
- $header = '';
- }
- // ------------------------ A8E fixes end ------------------------
-
- $columns = $params->def( 'columns', $GLOBALS['mosConfig_blog_columns'] );
-
- if ( $columns == 0 ) {
- $columns = 1;
- }
-
- $intro = $params->def( 'intro', $GLOBALS['mosConfig_blog_intro'] );
- $leading = $params->def( 'leading', $GLOBALS['mosConfig_blog_leading'] );
- $links = $params->def( 'link', $GLOBALS['mosConfig_blog_links'] );
- $pagination = $params->def( 'pagination', 2 );
- $pagination_results = $params->def( 'pagination_results', 1 );
- $pagination_results = $params->def( 'pagination_results', 1 );
- $descrip = $params->def( 'description', 1 );
- $descrip_image = $params->def( 'description_image', 1 );
-
- $params->def( 'back_button', $GLOBALS['mosConfig_back_button'] );
- $params->def( 'link_titles', $GLOBALS['mosConfig_link_titles']);
- $params->def( 'readmore', $GLOBALS['mosConfig_readmore'] );
- $params->def( 'author', 0 );
- $params->def( 'createdate', 0 );
- $params->def( 'modifydate', 0 );
- $params->def( 'pdf', 0 );
- $params->def( 'print', 0 );
- $params->def( 'email', 0 );
- $params->def( 'rating', 0 );
-
- // needed for back button for page
- $back = $params->get( 'back_button', $mainframe->getCfg( 'back_button' ) );
- // needed to disable back button for item
- $params->set( 'back_button', 0 );
- $params->def( 'pageclass_sfx', '' );
- $params->set( 'intro_only', 1 );
-
- $i = 0;
- // used to display section/catagory description text and images
- // currently not supported in Archives
- if ( $menu && $menu->componentid ) {
- switch ( $menu->type ) {
- case 'content_blog_section':
-
- if ($params->get('category_description',0)==2 && $task=='blogcategory') {
- $description = new mosCategory( $database );
- $description->load( (int)$id );
- } else {
- $description = new mosSection( $database );
- //$description->load( (int)$menu->componentid );
- $description->load( (int)$id );
- }
- break;
- case 'content_blog_category':
- $description = new mosCategory( $database );
- $description->load( (int)$menu->componentid );
- break;
- // ------------------------ A8E fixes start ------------------------
- // TODO: remove, as this is not an accessibility fix
- case 'content_section':
- //menu level stops at section, but displaying underlying category
- $description = $category;
- break;
- // ------------------------ A8E fixes end ------------------------
- default:
- $menu->componentid = 0;
- break;
- }
- }
- // Page Output
- // page header
- if ( $header ) {
- // ------------------------ A8E fix ------------------------
- echo '<h1 class="componentheading'.$params->get( 'pageclass_sfx' ) .'">'. $header .'</h1>';
- }
- if ( $archive ) {
- echo '<br />';
- echo mosHTML::monthSelectList( 'month', 'size="1" class="inputbox"', $params->get( 'month' ) );
- echo mosHTML::integerSelectList( 2000, 2010, 1, 'year', 'size="1" class="inputbox"', $params->get( 'year' ), "%04d" );
- echo '<input type="submit" class="button" value="'._SUBMIT_BUTTON.'" />';
- }
- // checks to see if there are there any items to display
- if ( $total ) {
- $col_with = 100 / $columns; // width of each column
- $width = intval( $col_with );
- if ( $archive ) {
- // Search Success message
- $msg = sprintf( _ARCHIVE_SEARCH_SUCCESS, $params->get( 'month' ), $params->get( 'year' ) );
- echo "<br /><br /><div align='center'>". $msg ."</div><br /><br />";
- }
- // ------------------------ A8E fixes start------------------------
- echo '<div class="blog' . $params->get( 'pageclass_sfx' ) . '">';
- // Secrion/Category Description & Image
- if ( $menu && $menu->componentid && $descrip && ( $description || $descrip_image ) ) {
- $link = $mosConfig_live_site .'/images/stories/'. $description->image;
- echo '<div class="blogdescription">';
- if ( $descrip_image && $description->image ) {
- echo '<div class="blogdescriptionimage"><img src="'. $link .'" style="float: '. $description->image_position .'; margin: 6px;" alt="" /></div>';
- }
- if ( $descrip && $description->description ) {
- echo '<div class="blogdescriptiontext">'.$description->description.'</div>';
- }
- echo '</div>';
- }
- // Leading story output
- if ( $leading ) {
- echo '<div class="blogleading">';
- for ( $z = 0; $z < $leading; $z++ ) {
- if ( $i >= ($total - $limitstart) ) {
- // stops loop if total number of items is less than the number set to display as leading
- break;
- }
- echo '<div class="itemblock item_'.$z.'">';
- show( $rows[$i], $params, $gid, $access, $pop );
- echo '</div>';
- $i++;
- }
- echo '</div>';
- }
- if ( $intro && ( $i < $total ) ) {
- echo '<div class="blogintro">';
-
- $colId = $i;
- $rowCount = ceil($intro / $columns);
- $introMax = $intro + $i;
- for($j = 1; $j <= $rowCount; $j++){
-
- //Break out if there are no more items
- if(!isset($rows[$i])) break;
-
- //Output row holder
- echo "<div class='blogrow row_$j' style='margin-bottom: 10px'>";
-
- $colCount = 1;
- //work out the maximum number of intro cells to output
- $max = ($columns + $i) > $introMax ? $introMax : ($columns + $i);
- $max = $max > $total ? $total : $max;
- for($i; $i < $max; $i++){
- //Calculate padding and width
- $colwidth = $colCount < $columns ? $width-1 : $width;
- $padding = $colCount < $columns ? 1 : 0;
-
- echo "<div class='blogcolumn column_$colCount' style='float: left; width: ".$colwidth."%; padding-right: ".$padding."%'>";
- echo '<div class="itemblock item_'.$z.'">';
- show( $rows[$i], $params, $gid, $access, $pop );
- echo '</div>';
- echo "</div>";
- //$i++;
- $colCount++;
-
- }
- //echo "<div style='clear: left'></div>";
- echo "</div>";
- }
- echo '</div>'; //closes <div class="blogintro">
- echo "<div style='clear: left'></div>";
- }
-
- // Links output
- if ( $links && ( $i < $total - $limitstart ) ) {
- $showmore = $leading + $intro;
- echo '<div class="blog_more'. $params->get( 'pageclass_sfx' ) .'" style="clear: left">';
- HTML_content::showLinks( $rows, $links, $total, $i, $showmore );
- echo '</div>';
- }
- // Pagination output
- if ( $pagination ) {
- if ( ( $pagination == 2 ) && ( $total <= $limit ) ) {
- // not visible when they is no 'other' pages to display
- } else {
- require_once( $GLOBALS['mosConfig_absolute_path'] . '/includes/pageNavigation.php' );
- // get the total number of records
- $limitstart = $limitstart ? $limitstart : 0;
- $pageNav = new mosPageNav( $total, $limitstart, $limit );
-
- if ( $Itemid && $Itemid != 99999999 ) {
- // where Itemid value is returned, do not add Itemid to url
- $Itemid_link = '&Itemid='. $Itemid;
- } else {
- // where Itemid value is NOT returned, do not add Itemid to url
- $Itemid_link = '';
- }
-
- if ( $option == 'com_frontpage' ) {
- $link = 'index.php?option=com_frontpage'. $Itemid_link;
- } else if ( $archive_page ) {
- $year = $params->get( 'year' );
- $month = $params->get( 'month' );
-
- if (!$archive) {
- // used when access via archive module
- $pid = '&id=0';
- $module = '&module=1';
- } else {
- // used when access via menu item
- $pid = '&id='. $id;
- $module = '';
- }
- $link = 'index.php?option=com_content&task='. $task . $pid . $Itemid_link .'&year='. $year .'&month='. $month . $module;
- } else {
- $link = 'index.php?option=com_content&task='. $task .'&id='. $id . $Itemid_link;
- }
-
- echo '<div class="blogpagination" style="text-align: center">';
- echo $pageNav->writePagesLinks( $link );
- echo '</div>';
-
- if ( $pagination_results ) {
- echo '<div class="blogpaginationcounter" style="text-align: center">';
- echo $pageNav->writePagesCounter();
- echo '</div>';
- }
- }
- }
- echo '</div>'; //closes <div class="blog">
- // ------------------------ A8E fixes end ------------------------
- } else if ( $archive && !$total ) {
- // Search Failure message for Archives
- $msg = sprintf( _ARCHIVE_SEARCH_FAILURE, $params->get( 'month' ), $params->get( 'year' ) );
- echo '<br /><br /><div align="center">'. $msg .'</div><br />';
- } else {
- // Generic blog empty display
- echo _EMPTY_BLOG;
- }
- // Back Button
- $params->set( 'back_button', $back );
- mosHTML::BackButton ( $params );
- }
- function showItem( $uid, $gid, &$access, $pop, $option='com_content', $now ) {
- global $database, $mainframe, $Itemid;
- global $mosConfig_MetaTitle, $mosConfig_MetaAuthor;
- $now = _CURRENT_SERVER_TIME;
- $nullDate = $database->getNullDate();
- if ( $access->canEdit ) {
- $xwhere = '';
- } else {
- $xwhere = " AND ( a.state = 1 OR a.state = -1 )"
- . "\n AND ( a.publish_up = " . $database->Quote( $nullDate ) . " OR a.publish_up <= " . $database->Quote( $now ) . " )"
- . "\n AND ( a.publish_down = " . $database->Quote( $nullDate ) . " OR a.publish_down >= " . $database->Quote( $now ) . " )"
- ;
- }
- // main query
- $query = "SELECT a.*, u.name AS author, u.usertype, cc.name AS category, s.name AS section, g.name AS groups,"
- . "\n s.published AS sec_pub, cc.published AS cat_pub, s.access AS sec_access, cc.access AS cat_access,"
- . "\n s.id AS sec_id, cc.id as cat_id"
- . "\n FROM #__content AS a"
- . "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid"
- . "\n LEFT JOIN #__sections AS s ON s.id = cc.section AND s.scope = 'content'"
- . "\n LEFT JOIN #__users AS u ON u.id = a.created_by"
- . "\n LEFT JOIN #__groups AS g ON a.access = g.id"
- . "\n WHERE a.id = " . (int) $uid
- . $xwhere
- . "\n AND a.access <= " . (int) $gid
- ;
- $database->setQuery( $query );
- $row = NULL;
- if ( $database->loadObject( $row ) ) {
- /*
- * check whether category is published
- */
- if ( !$row->cat_pub && $row->catid ) {
- mosNotAuth();
- return;
- }
- /*
- * check whether section is published
- */
- if ( !$row->sec_pub && $row->sectionid ) {
- mosNotAuth();
- return;
- }
- /*
- * check whether category access level allows access
- */
- if ( ($row->cat_access > $gid) && $row->catid ) {
- mosNotAuth();
- return;
- }
- /*
- * check whether section access level allows access
- */
- if ( ($row->sec_access > $gid) && $row->sectionid ) {
- mosNotAuth();
- return;
- }
- $params = new mosParameters( $row->attribs );
- $params->set( 'intro_only', 0 );
- $params->def( 'back_butto