| 1 |
<?php |
<?php |
| 2 |
/** |
/** |
|
* @version $Id: content.php,v 1.7 2005/11/24 04:28:51 csouza Exp $ |
|
| 3 |
* @package Mambo |
* @package Mambo |
| 4 |
* @subpackage Content |
* @subpackage Content |
| 5 |
* @copyright (C) 2000 - 2005 Miro International Pty Ltd |
* @author Mambo Foundation Inc see README.php |
| 6 |
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL |
* @copyright (C) 2000 - 2009 Mambo Foundation Inc. |
| 7 |
* Mambo is Free Software |
* See COPYRIGHT.php for copyright notices and details. |
| 8 |
|
* @license GNU/GPL Version 2, see LICENSE.php |
| 9 |
|
* |
| 10 |
|
* Redistributions of files must retain the above copyright notice. |
| 11 |
|
* |
| 12 |
|
* Mambo is free software; you can redistribute it and/or |
| 13 |
|
* modify it under the terms of the GNU General Public License |
| 14 |
|
* as published by the Free Software Foundation; version 2 of the License. |
| 15 |
*/ |
*/ |
| 16 |
|
|
| 17 |
/** ensure this file is being included by a parent file */ |
/** ensure this file is being included by a parent file */ |
| 41 |
// loads function for frontpage component |
// loads function for frontpage component |
| 42 |
if ( $option == 'com_frontpage' ) { |
if ( $option == 'com_frontpage' ) { |
| 43 |
//frontpage( $option, $gid, $pop, $now ); |
//frontpage( $option, $gid, $pop, $now ); |
| 44 |
$cache->call( 'frontpage', $gid, $access, $pop, $now ); |
$cache->call( 'frontpage', $gid, $access, $pop, $limit, $limitstart); |
| 45 |
return; |
return; |
| 46 |
} |
} |
| 47 |
|
|
| 55 |
break; |
break; |
| 56 |
|
|
| 57 |
case 'section': |
case 'section': |
| 58 |
$cache->call( 'showSection', $id, $gid, $access, $now ); |
$cache->call( 'showSection', $id, $gid, $access ); |
| 59 |
break; |
break; |
| 60 |
|
|
| 61 |
case 'category': |
case 'category': |
| 62 |
$cache->call( 'showCategory', $id, $gid, $access, $sectionid, $limit, $limitstart, $now ); |
$cache->call( 'showCategory', $id, $gid, $access, $sectionid, $limit, $limitstart ); |
| 63 |
break; |
break; |
| 64 |
|
|
| 65 |
case 'blogsection': |
case 'blogsection': |
| 66 |
$cache->call('showBlogSection', $id, $gid, $access, $pop, $now ); |
$cache->call('showBlogSection', $id, $gid, $access, $pop, $limit, $limitstart ); |
| 67 |
break; |
break; |
| 68 |
|
|
| 69 |
case 'blogcategorymulti': |
case 'blogcategorymulti': |
| 70 |
case 'blogcategory': |
case 'blogcategory': |
| 71 |
$cache->call( 'showBlogCategory', $id, $gid, $access, $pop, $now ); |
$cache->call( 'showBlogCategory', $id, $gid, $access, $pop, $limit, $limitstart ); |
| 72 |
break; |
break; |
| 73 |
|
|
| 74 |
case 'archivesection': |
case 'archivesection': |
| 105 |
break; |
break; |
| 106 |
|
|
| 107 |
case 'vote': |
case 'vote': |
| 108 |
recordVote ( $url , $user_rating , $cid , $database); |
recordVote ( $user_rating , $cid , $database); |
| 109 |
break; |
break; |
| 110 |
|
|
| 111 |
default: |
default: |
| 112 |
$cache->call('showBlogSection', 0, $gid, $access, $pop, $now ); |
$cache->call('showBlogSection', 0, $gid, $access, $pop, $limit, $limitstart ); |
| 113 |
break; |
break; |
| 114 |
} |
} |
| 115 |
|
|
| 139 |
} |
} |
| 140 |
} |
} |
| 141 |
|
|
| 142 |
function frontpage( $gid, &$access, $pop, $now ) { |
function frontpage( $gid, &$access, $pop, $limit, $limitstart) { |
| 143 |
global $database, $mainframe, $my, $Itemid; |
global $database, $mainframe, $my, $Itemid; |
| 144 |
global $mosConfig_offset; |
global $mosConfig_offset; |
| 145 |
|
|
| 151 |
$params =& new mosParameters( $menu->params ); |
$params =& new mosParameters( $menu->params ); |
| 152 |
$orderby_sec = $params->def( 'orderby_sec', '' ); |
$orderby_sec = $params->def( 'orderby_sec', '' ); |
| 153 |
$orderby_pri = $params->def( 'orderby_pri', '' ); |
$orderby_pri = $params->def( 'orderby_pri', '' ); |
| 154 |
|
$header = $params->def( 'header', $menu->name ); |
| 155 |
|
$page_title = $params->def( 'page_title', 0 ); |
| 156 |
// Ordering control |
// Ordering control |
| 157 |
$order_sec = _orderby_sec( $orderby_sec ); |
$order_sec = _orderby_sec( $orderby_sec ); |
| 158 |
$order_pri = _orderby_pri( $orderby_pri ); |
$order_pri = _orderby_pri( $orderby_pri ); |
| 159 |
|
|
| 160 |
$now = date( "Y-m-d H:i:s", time()+$mosConfig_offset*60*60 ); |
$now = date( "Y-m-d H:i:s", time()+$mosConfig_offset*60*60 ); |
| 161 |
|
|
| 162 |
|
global $acl; |
| 163 |
|
$viewAccess = ($gid >= $acl->get_group_id( 'Registered', 'ARO' ) ? 1 : 0) + ($gid >= $acl->get_group_id( 'Author', 'ARO' ) ? 1 : 0); |
| 164 |
// query records |
// query records |
| 165 |
$query = "SELECT a.*, ROUND( v.rating_sum / v.rating_count ) AS rating, v.rating_count, u.name AS author, u.usertype, s.name AS section, cc.name AS category, g.name AS groups" |
$query = "SELECT a.*, ROUND( v.rating_sum / v.rating_count ) AS rating, v.rating_count, u.name AS author, u.usertype, s.name AS section, cc.name AS category, g.name AS groups" |
| 166 |
. "\n FROM #__content AS a" |
. "\n FROM #__content AS a" |
| 167 |
. "\n INNER JOIN #__content_frontpage AS f ON f.content_id = a.id" |
. "\n INNER JOIN #__content_frontpage AS f ON f.content_id = a.id" |
| 168 |
. "\n INNER JOIN #__categories AS cc ON cc.id = a.catid" |
. "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid" |
| 169 |
. "\n INNER JOIN #__sections AS s ON s.id = a.sectionid" |
. "\n LEFT JOIN #__sections AS s ON s.id = a.sectionid" |
| 170 |
. "\n LEFT JOIN #__users AS u ON u.id = a.created_by" |
. "\n LEFT JOIN #__users AS u ON u.id = a.created_by" |
| 171 |
. "\n LEFT JOIN #__content_rating AS v ON a.id = v.content_id" |
. "\n LEFT JOIN #__content_rating AS v ON a.id = v.content_id" |
| 172 |
. "\n LEFT JOIN #__groups AS g ON a.access = g.id" |
. "\n LEFT JOIN #__groups AS g ON a.access = g.id" |
| 174 |
. ( $noauth ? "\n AND a.access <= '". $my->gid ."'" : '' ) |
. ( $noauth ? "\n AND a.access <= '". $my->gid ."'" : '' ) |
| 175 |
. "\n AND ( publish_up = '0000-00-00 00:00:00' OR publish_up <= '$now' )" |
. "\n AND ( publish_up = '0000-00-00 00:00:00' OR publish_up <= '$now' )" |
| 176 |
. "\n AND ( publish_down = '0000-00-00 00:00:00' OR publish_down >= '$now' )" |
. "\n AND ( publish_down = '0000-00-00 00:00:00' OR publish_down >= '$now' )" |
| 177 |
|
. "\n AND a.access <= ". $viewAccess |
| 178 |
. "\n ORDER BY ". $order_pri . $order_sec |
. "\n ORDER BY ". $order_pri . $order_sec |
| 179 |
; |
; |
|
// $database->setQuery( $query ); |
|
|
// $rows = $database->loadObjectList(); |
|
| 180 |
$rows = $database->doSQLget($query, 'mosExtendedContent'); |
$rows = $database->doSQLget($query, 'mosExtendedContent'); |
| 181 |
|
|
| 182 |
// Dynamic Page Title |
// Dynamic Page Title |
| 183 |
$mainframe->SetPageTitle( $menu->name ); |
$mainframe->SetPageTitle( $header ); |
| 184 |
|
|
| 185 |
BlogOutput( $rows, $params, $gid, $access, $pop, $menu ); |
BlogOutput( $rows, $params, $gid, $access, $pop, $menu, null, $limit, $limitstart ); |
| 186 |
} |
} |
| 187 |
|
|
| 188 |
|
|
| 189 |
function showSection( $id, $gid, &$access, $now ) { |
function showSection( $id, $gid, &$access ) { |
| 190 |
global $database, $mainframe, $mosConfig_offset, $Itemid; |
global $database, $mainframe, $mosConfig_offset, $Itemid; |
| 191 |
|
|
| 192 |
$noauth = !$mainframe->getCfg( 'shownoauth' ); |
$noauth = !$mainframe->getCfg( 'shownoauth' ); |
| 193 |
|
$now = date( 'Y-m-d H:i:s', time() + $mosConfig_offset * 60 * 60 ); |
| 194 |
// Paramters |
// Paramters |
| 195 |
$params = new stdClass(); |
$params = new stdClass(); |
| 196 |
if ( $Itemid ) { |
if ( $Itemid ) { |
| 199 |
$params =& new mosParameters( $menu->params ); |
$params =& new mosParameters( $menu->params ); |
| 200 |
} else { |
} else { |
| 201 |
$menu = ""; |
$menu = ""; |
| 202 |
$params =& new mosEmpty(); |
$params =& new mosParameters( $menu->params ); |
| 203 |
|
|
| 204 |
} |
} |
| 205 |
$orderby = $params->get( 'orderby', '' ); |
$orderby = $params->get( 'orderby', '' ); |
| 213 |
$params->def( 'empty_cat', 0 ); |
$params->def( 'empty_cat', 0 ); |
| 214 |
$params->def( 'cat_items', 1 ); |
$params->def( 'cat_items', 1 ); |
| 215 |
$params->def( 'cat_description', 1 ); |
$params->def( 'cat_description', 1 ); |
| 216 |
|
$params->def( 'description', 1 ); |
| 217 |
|
$params->def( 'description-image', 1 ); |
| 218 |
$params->def( 'back_button', $mainframe->getCfg( 'back_button' ) ); |
$params->def( 'back_button', $mainframe->getCfg( 'back_button' ) ); |
| 219 |
$params->def( 'pageclass_sfx', '' ); |
$params->def( 'pageclass_sfx', '' ); |
| 220 |
|
|
| 275 |
* @param int The number of items to dislpay |
* @param int The number of items to dislpay |
| 276 |
* @param int The offset for pagination |
* @param int The offset for pagination |
| 277 |
*/ |
*/ |
| 278 |
function showCategory( $id, $gid, &$access, $sectionid, $limit, $limitstart, $now ) { |
function showCategory( $id, $gid, &$access, $sectionid, $limit, $limitstart ) { |
| 279 |
global $database, $mainframe, $Itemid, $mosConfig_offset, $mosConfig_list_limit; |
global $database, $mainframe, $Itemid, $mosConfig_offset, $mosConfig_list_limit; |
| 280 |
|
|
| 281 |
$noauth = !$mainframe->getCfg( 'shownoauth' ); |
$noauth = !$mainframe->getCfg( 'shownoauth' ); |
| 282 |
$selected = mosGetParam( $_POST, 'order', '' ); |
$selected = mosGetParam( $_POST, 'order', '' ); |
| 283 |
|
$now = date( 'Y-m-d H:i:s', time() + $mosConfig_offset * 60 * 60 ); |
| 284 |
// Paramters |
// Paramters |
| 285 |
$params = new stdClass(); |
$params = new stdClass(); |
| 286 |
if ( $Itemid ) { |
if ( $Itemid ) { |
| 314 |
$params->def( 'empty_cat', 0 ); |
$params->def( 'empty_cat', 0 ); |
| 315 |
$params->def( 'cat_items', 1 ); |
$params->def( 'cat_items', 1 ); |
| 316 |
$params->def( 'cat_description', 0 ); |
$params->def( 'cat_description', 0 ); |
| 317 |
|
$params->def( 'description', 1 ); |
| 318 |
|
$params->def( 'description-image', 1 ); |
| 319 |
$params->def( 'back_button', $mainframe->getCfg( 'back_button' ) ); |
$params->def( 'back_button', $mainframe->getCfg( 'back_button' ) ); |
| 320 |
$params->def( 'pageclass_sfx', '' ); |
$params->def( 'pageclass_sfx', '' ); |
| 321 |
$params->def( 'headings', 1 ); |
$params->def( 'headings', 1 ); |
| 377 |
|
|
| 378 |
// get the total number of published items in the category |
// get the total number of published items in the category |
| 379 |
// filter functionality |
// filter functionality |
| 380 |
$and = ''; |
$_and = ''; |
| 381 |
if ($filter = mosGetParam($_POST, 'filter', '')) { |
if ($filter = mosGetParam($_POST, 'filter', '')) { |
| 382 |
$filter = strtolower( $filter ); |
$filter = strtolower( $filter ); |
| 383 |
$filter = $database->getEscaped($filter); |
$filter = $database->getEscaped($filter); |
| 384 |
if ( $params->get( 'filter' ) ) { |
if ( $params->get( 'filter' ) ) { |
| 385 |
switch ( $params->get( 'filter_type' ) ) { |
switch ( $params->get( 'filter_type' ) ) { |
| 386 |
case 'title': |
case 'title': |
| 387 |
$and = "\n AND LOWER( a.title ) LIKE '%". $filter ."%'"; |
$_and = "\n AND LOWER( a.title ) LIKE '%". $filter ."%'"; |
| 388 |
break; |
break; |
| 389 |
case 'author': |
case 'author': |
| 390 |
$and = "\n AND ( ( LOWER( u.name ) LIKE '%". $filter ."%' ) OR ( LOWER( a.created_by_alias ) LIKE '%". $filter ."%' ) )"; |
$_and = "\n AND ( ( LOWER( u.name ) LIKE '%". $filter ."%' ) OR ( LOWER( a.created_by_alias ) LIKE '%". $filter ."%' ) )"; |
| 391 |
break; |
break; |
| 392 |
case 'hits': |
case 'hits': |
| 393 |
$and = "\n AND a.hits LIKE '%". $filter ."%'"; |
$_and = "\n AND a.hits LIKE '%". $filter ."%'"; |
| 394 |
break; |
break; |
| 395 |
} |
} |
| 396 |
} |
} |
| 413 |
. "\n WHERE a.catid='". $category->id ."' ". $xwhere |
. "\n WHERE a.catid='". $category->id ."' ". $xwhere |
| 414 |
. ( $noauth ? "\n AND a.access<='". $gid ."'" : '' ) |
. ( $noauth ? "\n AND a.access<='". $gid ."'" : '' ) |
| 415 |
. "\n AND '". $category->access ."'<='". $gid ."'" |
. "\n AND '". $category->access ."'<='". $gid ."'" |
| 416 |
. $and |
. $_and |
| 417 |
. "\n ORDER BY ". $orderby ."" |
. "\n ORDER BY ". $orderby ."" |
| 418 |
; |
; |
| 419 |
$database->setQuery( $query ); |
$database->setQuery( $query ); |
| 433 |
. "\n WHERE a.catid='". $category->id ."' ". $xwhere |
. "\n WHERE a.catid='". $category->id ."' ". $xwhere |
| 434 |
. ( $noauth ? "\n AND a.access<='". $gid ."'" : '' ) |
. ( $noauth ? "\n AND a.access<='". $gid ."'" : '' ) |
| 435 |
. "\n AND '". $category->access ."'<='". $gid ."'" |
. "\n AND '". $category->access ."'<='". $gid ."'" |
| 436 |
. $and |
. $_and |
| 437 |
. "\n ORDER BY ". $orderby ."" |
. "\n ORDER BY ". $orderby ."" |
| 438 |
. "\n LIMIT ". $limitstart .", ". $limit |
. "\n LIMIT ". $limitstart .", ". $limit |
| 439 |
; |
; |
| 478 |
} // showCategory |
} // showCategory |
| 479 |
|
|
| 480 |
|
|
| 481 |
function showBlogSection( $id=0, $gid, &$access, $pop, $now=NULL ) { |
function showBlogSection( $id=0, $gid, &$access, $pop, $limit, $limitstart ) { |
| 482 |
global $database, $mainframe, $mosConfig_offset, $Itemid; |
global $database, $mainframe, $mosConfig_offset, $Itemid, $option, $task; |
| 483 |
|
|
| 484 |
$noauth = !$mainframe->getCfg( 'shownoauth' ); |
$noauth = !$mainframe->getCfg( 'shownoauth' ); |
| 485 |
|
$now = date( 'Y-m-d H:i:s', time() + $mosConfig_offset * 60 * 60 ); |
| 486 |
// Parameters |
// Parameters |
| 487 |
$params = new stdClass(); |
$pageTitle = ''; |
| 488 |
if ( $Itemid ) { |
if ( $Itemid ) { |
| 489 |
$menu = new mosMenu( $database ); |
$menu = new mosMenu( $database ); |
| 490 |
$menu->load( $Itemid ); |
$menu->load( $Itemid ); |
| 491 |
$params =& new mosParameters( $menu->params ); |
if ( strpos(strtolower($menu->link), 'blogsection') === false ) { |
| 492 |
|
$menu = ''; |
| 493 |
} else { |
} else { |
| 494 |
$menu = ""; |
// only load params and set title if the menu item loaded is a blog section |
| 495 |
$params =& new mosParameters( '' ); |
$pageTitle = $menu->name; |
| 496 |
|
$params =& new mosParameters( $menu->params ); |
| 497 |
|
} |
| 498 |
} |
} |
| 499 |
|
|
| 500 |
|
// no Itemid OR menu item loaded is not a blog section |
| 501 |
|
// try to find a blog entry in the menu database |
| 502 |
|
if (!$menu) { |
| 503 |
|
$database->setQuery("SELECT * FROM #__menu WHERE link LIKE '%blogsection%'"); |
| 504 |
|
$rows = $database->loadObjectList(); |
| 505 |
|
if (count($rows)) { |
| 506 |
|
$params =& new mosParameters( $rows[0]->params ); |
| 507 |
|
} |
| 508 |
|
} |
| 509 |
|
|
| 510 |
|
// no menu item found and no params loaded so create a default params object |
| 511 |
|
if (!$params) $params =& new mosParameters( $menu->params ); |
| 512 |
|
|
| 513 |
// new blog multiple section handling |
// new blog multiple section handling |
| 514 |
if ( !$id ) { |
if ( !$id ) { |
| 515 |
$id = $params->def( 'sectionid', 0 ); |
$id = $params->def( 'sectionid', 0 ); |
| 524 |
$order_pri = _orderby_pri( $orderby_pri ); |
$order_pri = _orderby_pri( $orderby_pri ); |
| 525 |
|
|
| 526 |
// Main data query |
// Main data query |
| 527 |
$query = "SELECT a.*, ROUND( v.rating_sum / v.rating_count ) AS rating, v.rating_count, u.name AS author, u.usertype, cc.name AS category, g.name AS groups" |
$query = "SELECT a.*, ROUND( v.rating_sum / v.rating_count ) AS rating, v.rating_count, u.name AS author, u.usertype, cc.name AS category, g.name AS groups, s.title AS section" |
| 528 |
. "\n FROM #__content AS a" |
. "\n FROM #__content AS a" |
| 529 |
. "\n INNER JOIN #__categories AS cc ON cc.id = a.catid" |
. "\n INNER JOIN #__categories AS cc ON cc.id = a.catid" |
| 530 |
. "\n LEFT JOIN #__users AS u ON u.id = a.created_by" |
. "\n LEFT JOIN #__users AS u ON u.id = a.created_by" |
| 540 |
$rows = $database->doSQLget($query, 'mosExtendedContent'); |
$rows = $database->doSQLget($query, 'mosExtendedContent'); |
| 541 |
|
|
| 542 |
// Dynamic Page Title |
// Dynamic Page Title |
| 543 |
if ($menu) { |
// do we have multiple sections? |
| 544 |
$mainframe->setPageTitle( $menu->name ); |
$multiple_sections = false; |
| 545 |
|
if (count($rows)) { |
| 546 |
|
$temp = array(); |
| 547 |
|
foreach($rows as $row) { |
| 548 |
|
$temp[$row->section] = ''; |
| 549 |
|
} |
| 550 |
|
if (count($temp) > 1) { |
| 551 |
|
$multiple_sections = true; |
| 552 |
|
} |
| 553 |
|
unset($temp); |
| 554 |
} |
} |
| 555 |
|
if (!$pageTitle) { |
| 556 |
|
// set the page title |
| 557 |
|
if ($rows[0]->section && !$multiple_sections){ |
| 558 |
|
$pageTitle = $rows[0]->section; |
| 559 |
|
} else { |
| 560 |
|
$pageTitle = T_('Blog'); |
| 561 |
|
} |
| 562 |
|
// fudge the pathway |
| 563 |
|
$mainframe->appendPathway($pageTitle); |
| 564 |
|
} |
| 565 |
|
$mainframe->setPageTitle( $pageTitle ); |
| 566 |
|
|
| 567 |
BlogOutput( $rows, $params, $gid, $access, $pop, $menu ); |
// restore borrowed $row->section to null - IMPORTANT |
| 568 |
|
if (count($rows)) { |
| 569 |
|
for($i=0; $i<count($rows); $i++) $rows[$i]->section = ''; |
| 570 |
} |
} |
| 571 |
|
|
| 572 |
function showBlogCategory( $id=0, $gid, &$access, $pop, $now ) { |
BlogOutput( $rows, $params, $gid, $access, $pop, $menu, null, $limit, $limitstart ); |
| 573 |
|
} |
| 574 |
|
|
| 575 |
|
function showBlogCategory( $id=0, $gid, &$access, $pop, $limit, $limitstart ) { |
| 576 |
global $database, $mainframe, $mosConfig_offset, $Itemid; |
global $database, $mainframe, $mosConfig_offset, $Itemid; |
| 577 |
|
|
| 578 |
$noauth = !$mainframe->getCfg( 'shownoauth' ); |
$noauth = !$mainframe->getCfg( 'shownoauth' ); |
| 579 |
|
$now = date( 'Y-m-d H:i:s', time() + $mosConfig_offset * 60 * 60 ); |
| 580 |
// Paramters |
// Paramters |
| 581 |
$params = new stdClass(); |
$params = new stdClass(); |
| 582 |
if ( $Itemid ) { |
if ( $Itemid ) { |
| 620 |
// Dynamic Page Title |
// Dynamic Page Title |
| 621 |
$mainframe->SetPageTitle( $menu->name ); |
$mainframe->SetPageTitle( $menu->name ); |
| 622 |
|
|
| 623 |
BlogOutput( $rows, $params, $gid, $access, $pop, $menu ); |
BlogOutput( $rows, $params, $gid, $access, $pop, $menu, null, $limit, $limitstart ); |
| 624 |
} |
} |
| 625 |
|
|
| 626 |
function showArchiveSection( $id=NULL, $gid, &$access, $pop, $option ) { |
function showArchiveSection( $id=NULL, $gid, &$access, $pop, $option ) { |
| 629 |
|
|
| 630 |
$noauth = !$mainframe->getCfg( 'shownoauth' ); |
$noauth = !$mainframe->getCfg( 'shownoauth' ); |
| 631 |
|
|
| 632 |
// Paramters |
// Parameters |
| 633 |
$year = mosGetParam( $_REQUEST, 'year', date( 'Y' ) ); |
$year = mosGetParam( $_REQUEST, 'year', date( 'Y' ) ); |
| 634 |
$month = mosGetParam( $_REQUEST, 'month', date( 'm' ) ); |
$month = mosGetParam( $_REQUEST, 'month', date( 'm' ) ); |
| 635 |
|
|
| 705 |
echo '<input type="hidden" name="Itemid" value="'. $Itemid .'" />'; |
echo '<input type="hidden" name="Itemid" value="'. $Itemid .'" />'; |
| 706 |
echo '<input type="hidden" name="task" value="archivesection" />'; |
echo '<input type="hidden" name="task" value="archivesection" />'; |
| 707 |
echo '<input type="hidden" name="option" value="com_content" />'; |
echo '<input type="hidden" name="option" value="com_content" />'; |
| 708 |
|
echo '<input type="hidden" name="module" value="1" />'; |
| 709 |
echo '</form>'; |
echo '</form>'; |
| 710 |
} |
} |
| 711 |
|
|
| 787 |
echo '<input type="hidden" name="Itemid" value="'. $Itemid .'" />'; |
echo '<input type="hidden" name="Itemid" value="'. $Itemid .'" />'; |
| 788 |
echo '<input type="hidden" name="task" value="archivecategory" />'; |
echo '<input type="hidden" name="task" value="archivecategory" />'; |
| 789 |
echo '<input type="hidden" name="option" value="com_content" />'; |
echo '<input type="hidden" name="option" value="com_content" />'; |
| 790 |
|
echo '<input type="hidden" name="module" value="1" />'; |
| 791 |
echo '</form>'; |
echo '</form>'; |
| 792 |
} |
} |
| 793 |
|
|
| 794 |
|
|
| 795 |
function BlogOutput ( &$rows, &$params, $gid, &$access, $pop, &$menu, $archive=NULL ) { |
function BlogOutput ( &$rows, &$params, $gid, &$access, $pop, &$menu, $archive=NULL, $limit = 0, $limitstart = 0 ) { |
| 796 |
global $mainframe, $Itemid, $task, $id, $option, $database, $mosConfig_live_site; |
global $mainframe, $Itemid, $task, $id, $option, $database, $mosConfig_live_site; |
| 797 |
|
|
| 798 |
// parameters |
// parameters |
| 823 |
$total = count( $rows ); |
$total = count( $rows ); |
| 824 |
|
|
| 825 |
// pagination support |
// pagination support |
| 826 |
|
if (!$limitstart){ |
| 827 |
$limitstart = intval( mosGetParam( $_REQUEST, 'limitstart', 0 ) ); |
$limitstart = intval( mosGetParam( $_REQUEST, 'limitstart', 0 ) ); |
| 828 |
|
} |
| 829 |
$limit = $intro + $leading + $links; |
$limit = $intro + $leading + $links; |
| 830 |
if ( $total <= $limit ) { |
if ( $total <= $limit ) { |
| 831 |
$limitstart = 0; |
$limitstart = 0; |
| 969 |
echo '<tr>'; |
echo '<tr>'; |
| 970 |
echo '<td valign="top">'; |
echo '<td valign="top">'; |
| 971 |
echo '<div class="blog_more'. $params->get( 'pageclass_sfx' ) .'">'; |
echo '<div class="blog_more'. $params->get( 'pageclass_sfx' ) .'">'; |
| 972 |
HTML_content::showLinks( $rows, $links, $total, $i, 1, $ItemidCount ); |
HTML_content::showLinks( $rows, $links, $total, $i, 1 ); |
| 973 |
echo '</div>'; |
echo '</div>'; |
| 974 |
echo '</td>'; |
echo '</td>'; |
| 975 |
echo '</tr>'; |
echo '</tr>'; |
| 1039 |
; |
; |
| 1040 |
} |
} |
| 1041 |
|
|
| 1042 |
|
global $acl; |
| 1043 |
|
$viewAccess = ($gid >= $acl->get_group_id( 'Registered', 'ARO' ) ? 1 : 0) + ($gid >= $acl->get_group_id( 'Author', 'ARO' ) ? 1 : 0); |
| 1044 |
$query = "SELECT a.*, ROUND(v.rating_sum/v.rating_count) AS rating, v.rating_count, u.name AS author, u.usertype, cc.name AS category, s.name AS section, g.name AS groups" |
$query = "SELECT a.*, ROUND(v.rating_sum/v.rating_count) AS rating, v.rating_count, u.name AS author, u.usertype, cc.name AS category, s.name AS section, g.name AS groups" |
| 1045 |
. "\n FROM #__content AS a" |
. "\n FROM #__content AS a" |
| 1046 |
. "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid" |
. "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid" |
| 1049 |
. "\n LEFT JOIN #__content_rating AS v ON a.id = v.content_id" |
. "\n LEFT JOIN #__content_rating AS v ON a.id = v.content_id" |
| 1050 |
. "\n LEFT JOIN #__groups AS g ON a.access = g.id" |
. "\n LEFT JOIN #__groups AS g ON a.access = g.id" |
| 1051 |
. "\n WHERE a.id='". $uid ."' ". $xwhere |
. "\n WHERE a.id='". $uid ."' ". $xwhere |
| 1052 |
. "\n AND a.access <= ". $gid |
. "\n AND a.access <= ". $viewAccess |
| 1053 |
; |
; |
| 1054 |
$database->setQuery( $query ); |
$database->setQuery( $query ); |
|
// $row = NULL; |
|
| 1055 |
$row = new mosExtendedContent(); |
$row = new mosExtendedContent(); |
| 1056 |
|
|
| 1057 |
if ( $database->loadObject( $row ) ) { |
if ( $database->loadObject( $row ) ) { |
| 1073 |
. "\n WHERE a.catid = ". $row->catid."" |
. "\n WHERE a.catid = ". $row->catid."" |
| 1074 |
. "\n AND a.state = $row->state AND ordering < $row->ordering" |
. "\n AND a.state = $row->state AND ordering < $row->ordering" |
| 1075 |
. ($access->canEdit ? "" : "\n AND a.access <= '". $gid ."'" ) |
. ($access->canEdit ? "" : "\n AND a.access <= '". $gid ."'" ) |
| 1076 |
|
. "\n AND ( a.publish_up = '0000-00-00 00:00:00' OR a.publish_up <= '". $now ."' )" |
| 1077 |
|
. "\n AND ( a.publish_down = '0000-00-00 00:00:00' OR a.publish_down >= '". $now ."' )" |
| 1078 |
. "\n ORDER BY a.ordering DESC" |
. "\n ORDER BY a.ordering DESC" |
| 1079 |
. "\n LIMIT 1" |
. "\n LIMIT 1" |
| 1080 |
; |
; |
| 1086 |
. "\n WHERE a.catid = ". $row->catid."" |
. "\n WHERE a.catid = ". $row->catid."" |
| 1087 |
. "\n AND a.state = $row->state AND ordering > $row->ordering" |
. "\n AND a.state = $row->state AND ordering > $row->ordering" |
| 1088 |
. ($access->canEdit ? "" : "\n AND a.access <= '". $gid ."'" ) |
. ($access->canEdit ? "" : "\n AND a.access <= '". $gid ."'" ) |
| 1089 |
|
. "\n AND ( a.publish_up = '0000-00-00 00:00:00' OR a.publish_up <= '". $now ."' )" |
| 1090 |
|
. "\n AND ( a.publish_down = '0000-00-00 00:00:00' OR a.publish_down >= '". $now ."' )" |
| 1091 |
. "\n ORDER BY a.ordering" |
. "\n ORDER BY a.ordering" |
| 1092 |
. "\n LIMIT 1" |
. "\n LIMIT 1" |
| 1093 |
; |
; |
| 1114 |
function show( $row, $params, $gid, &$access, $pop, $option, $ItemidCount=NULL ) { |
function show( $row, $params, $gid, &$access, $pop, $option, $ItemidCount=NULL ) { |
| 1115 |
global $database, $mainframe, $Itemid; |
global $database, $mainframe, $Itemid; |
| 1116 |
global $mosConfig_live_site, $mosConfig_absolute_path; |
global $mosConfig_live_site, $mosConfig_absolute_path; |
| 1117 |
global $options, $cache; |
global $options, $task; |
| 1118 |
|
|
| 1119 |
|
//$cache = mosCache::getCache('com_content','Output'); |
| 1120 |
|
|
| 1121 |
$noauth = !$mainframe->getCfg( 'shownoauth' ); |
$noauth = !$mainframe->getCfg( 'shownoauth' ); |
| 1122 |
|
|
| 1169 |
if ( $params->get( 'section_link' ) ) { |
if ( $params->get( 'section_link' ) ) { |
| 1170 |
$query = "SELECT a.id" |
$query = "SELECT a.id" |
| 1171 |
. "\n FROM #__menu AS a" |
. "\n FROM #__menu AS a" |
| 1172 |
. "\n WHERE a.componentid = ". $row->sectionid."" |
. "\n WHERE a.componentid = '". $row->sectionid."'" |
| 1173 |
|
. "\n AND a.type = 'content_section'" |
| 1174 |
|
. "\n AND a.published = 1" |
| 1175 |
; |
; |
| 1176 |
$database->setQuery( $query ); |
$database->setQuery( $query ); |
| 1177 |
$_Itemid = $database->loadResult(); |
$_Itemid = $database->loadResult(); |
| 1178 |
|
if (!intval($_Itemid)) |
| 1179 |
|
$_Itemid = intval($Itemid) ? intval($Itemid) : 1; |
| 1180 |
$link = sefRelToAbs( 'index.php?option=com_content&task=section&id='. $row->sectionid .'&Itemid='.$_Itemid ); |
$link = sefRelToAbs( 'index.php?option=com_content&task=section&id='. $row->sectionid .'&Itemid='.$_Itemid ); |
| 1181 |
$row->section = '<a href="'. $link .'">'. $row->section .'</a>'; |
$row->section = '<a href="'. $link .'">'. $row->section .'</a>'; |
| 1182 |
} |
} |
| 1186 |
$query = "SELECT a.id" |
$query = "SELECT a.id" |
| 1187 |
. "\n FROM #__menu AS a" |
. "\n FROM #__menu AS a" |
| 1188 |
. "\n WHERE a.componentid = ". $row->catid."" |
. "\n WHERE a.componentid = ". $row->catid."" |
| 1189 |
|
. "\n AND a.type = 'content_category'" |
| 1190 |
|
. "\n AND a.published = 1" |
| 1191 |
; |
; |
| 1192 |
$database->setQuery( $query ); |
$database->setQuery( $query ); |
| 1193 |
$_Itemid = $database->loadResult(); |
$_Itemid = $database->loadResult(); |
| 1194 |
|
if (!intval($_Itemid)) |
| 1195 |
|
$_Itemid = intval($Itemid) ? intval($Itemid) : 1; |
| 1196 |
|
$link = sefRelToAbs( 'index.php?option=com_content&task=section&id='. $row->sectionid .'&Itemid='.$_Itemid ); |
| 1197 |
$link = sefRelToAbs( 'index.php?option=com_content&task=category&sectionid='. $row->sectionid .'&id='. $row->catid .'&Itemid='.$_Itemid ); |
$link = sefRelToAbs( 'index.php?option=com_content&task=category&sectionid='. $row->sectionid .'&id='. $row->catid .'&Itemid='.$_Itemid ); |
| 1198 |
$row->category = '<a href="'. $link .'">'. $row->category .'</a>'; |
$row->category = '<a href="'. $link .'">'. $row->category .'</a>'; |
| 1199 |
} |
} |
| 1222 |
$obj = new mosContent( $database ); |
$obj = new mosContent( $database ); |
| 1223 |
$obj->hit( $row->id ); |
$obj->hit( $row->id ); |
| 1224 |
} |
} |
| 1225 |
|
//if(!($cache->start($task.$row->id.$page,'com_content'))){ |
| 1226 |
$cache->call( 'HTML_content::show', $row, $params, $access, $page, $option, $ItemidCount ); |
HTML_content::show( $row, $params, $access, $page, $option, $ItemidCount ); |
| 1227 |
|
// $cache->end(); |
| 1228 |
|
//} |
| 1229 |
} |
} |
| 1230 |
|
|
| 1231 |
|
|
| 1343 |
$lists['catid'] = mosAdminMenus::ComponentCategory( 'catid', $sectionid, intval( $row->catid ) ); |
$lists['catid'] = mosAdminMenus::ComponentCategory( 'catid', $sectionid, intval( $row->catid ) ); |
| 1344 |
// build the select list for the image positions |
// build the select list for the image positions |
| 1345 |
$lists['_align'] = mosAdminMenus::Positions( '_align' ); |
$lists['_align'] = mosAdminMenus::Positions( '_align' ); |
| 1346 |
|
// build the select list for the image caption alignment |
| 1347 |
|
$lists['_caption_align'] = mosAdminMenus::Positions( '_caption_align' ); |
| 1348 |
// build the html select list for the group access |
// build the html select list for the group access |
| 1349 |
$lists['access'] = mosAdminMenus::Access( $row ); |
$lists['access'] = mosAdminMenus::Access( $row ); |
| 1350 |
|
|
| 1351 |
|
// build the select list for the image caption position |
| 1352 |
|
$pos[] = mosHTML::makeOption( 'bottom', _CMN_BOTTOM ); |
| 1353 |
|
$pos[] = mosHTML::makeOption( 'top', _CMN_TOP ); |
| 1354 |
|
$lists['_caption_position'] = mosHTML::selectList( $pos, '_caption_position', 'class="inputbox" size="1"', 'value', 'text' ); |
| 1355 |
|
|
| 1356 |
HTML_content::editContent( $row, $section, $lists, $images, $access, $my->id, $sectionid, $task, $Itemid ); |
HTML_content::editContent( $row, $section, $lists, $images, $access, $my->id, $sectionid, $task, $Itemid ); |
| 1357 |
} |
} |
| 1358 |
|
|
| 1369 |
echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n"; |
echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n"; |
| 1370 |
exit(); |
exit(); |
| 1371 |
} |
} |
| 1372 |
|
// sanitize |
| 1373 |
|
$row->id = intval($row->id); |
| 1374 |
|
$row->catid = intval($row->catid); |
| 1375 |
|
$row->sectionid = intval($row->sectionid); |
| 1376 |
$isNew = $row->id < 1; |
$isNew = $row->id < 1; |
| 1377 |
if ( $isNew ) { |
if ( $isNew ) { |
| 1378 |
// new record |
// new record |
| 1450 |
if ( $isNew ) { |
if ( $isNew ) { |
| 1451 |
// messaging for new items |
// messaging for new items |
| 1452 |
require_once( $mosConfig_absolute_path .'/components/com_messages/messages.class.php' ); |
require_once( $mosConfig_absolute_path .'/components/com_messages/messages.class.php' ); |
|
|
|
| 1453 |
$database->setQuery( "SELECT id FROM #__users WHERE sendEmail = '1'" ); |
$database->setQuery( "SELECT id FROM #__users WHERE sendEmail = '1'" ); |
| 1454 |
$users = $database->loadResultArray(); |
$users = $database->loadResultArray(); |
| 1455 |
|
if ($users) { |
| 1456 |
foreach ($users as $user_id) { |
foreach ($users as $user_id) { |
| 1457 |
$msg = new mosMessage( $database ); |
$msg = new mosMessage( $database ); |
| 1458 |
$msg->send( $my->id, $user_id, T_("New Item"), sprintf( T_('A new content item has been submitted by [ %s ] titled [ %s ] from section [ %s ] and category [ %s ]'), $my->username, $row->title, $section, $category ) ); |
$msg->send( $my->id, $user_id, T_("New Item"), sprintf( T_('A new content item has been submitted by [ %s ] titled [ %s ] from section [ %s ] and category [ %s ]'), $my->username, $row->title, $section, $category ) ); |
| 1459 |
} |
} |
| 1460 |
} |
} |
| 1461 |
|
} |
| 1462 |
$Itemid = mosGetParam( $_POST, 'Returnid', '0' ); |
$Itemid = mosGetParam( $_POST, 'Returnid', '0' ); |
| 1463 |
$msg = $isNew ? T_('Thanks for your submission; it will be reviewed before being posted to the site.') : T_('Item saved successfully.'); |
$msg = $isNew ? T_('Thanks for your submission; it will be reviewed before being posted to the site.') : T_('Item saved successfully.'); |
| 1464 |
mosRedirect( 'index.php', $msg ); |
|
| 1465 |
|
$link = $isNew ? 'index.php' : sefRelToAbs( 'index.php?option=com_content&task=view&id='.$row->id.'&Itemid='.$Itemid ); |
| 1466 |
|
mosRedirect( $link, $msg); |
| 1467 |
} |
} |
| 1468 |
|
|
| 1469 |
|
|
| 1476 |
|
|
| 1477 |
$row = new mosContent( $database ); |
$row = new mosContent( $database ); |
| 1478 |
$row->bind( $_POST ); |
$row->bind( $_POST ); |
| 1479 |
|
// sanitize |
| 1480 |
|
$row->id = intval($row->id); |
| 1481 |
|
|
| 1482 |
if ( $access->canEdit || ( $access->canEditOwn && $row->created_by == $my->id ) ) { |
if ( $access->canEdit || ( $access->canEditOwn && $row->created_by == $my->id ) ) { |
| 1483 |
$row->checkin(); |
$row->checkin(); |
| 1485 |
|
|
| 1486 |
$Itemid = mosGetParam( $_POST, 'Returnid', '0' ); |
$Itemid = mosGetParam( $_POST, 'Returnid', '0' ); |
| 1487 |
|
|
| 1488 |
mosRedirect( 'index.php' ); |
$link = sefRelToAbs( 'index.php?option=com_content&task=view&id='.$row->id.'&Itemid='.$Itemid ); |
| 1489 |
|
mosRedirect( $link ); |
| 1490 |
} |
} |
| 1491 |
|
|
| 1492 |
/** |
/** |
| 1526 |
$subject_default = sprintf(T_('Item sent by %s'), $yourname); |
$subject_default = sprintf(T_('Item sent by %s'), $yourname); |
| 1527 |
$subject = trim( mosGetParam( $_POST, 'subject', $subject_default ) ); |
$subject = trim( mosGetParam( $_POST, 'subject', $subject_default ) ); |
| 1528 |
|
|
| 1529 |
|
mos_session_start(); |
| 1530 |
$form_check = mosGetParam( $_POST, 'form_check', '' ); |
$form_check = mosGetParam( $_POST, 'form_check', '' ); |
| 1531 |
if (empty($_SESSION['_form_check_']['com_content']) || $form_check != $_SESSION['_form_check_']['com_content']) { |
if (empty($_SESSION['_form_check_']['com_content']) || $form_check != $_SESSION['_form_check_']['com_content']) { |
| 1532 |
// the form hasn't been generated by the server on this session |
// the form hasn't been generated by the server on this session |
| 1544 |
// link sent in email |
// link sent in email |
| 1545 |
$link = sefRelToAbs( $mosConfig_live_site .'/index.php?option=com_content&task=view&id='. $uid .'&Itemid='. $_Itemid ); |
$link = sefRelToAbs( $mosConfig_live_site .'/index.php?option=com_content&task=view&id='. $uid .'&Itemid='. $_Itemid ); |
| 1546 |
// message text |
// message text |
| 1547 |
$msg = sprintf( T_(' The following page from the "%s" website has been sent to you by %s ( %s ). |
$msg = sprintf( T_(' The following page from the \"%s\" website has been sent to you by %s ( %s ).\n\nYou can access it at the following url:\n%s'), $mosConfig_sitename, $yourname, $youremail, $link ); |
|
|
|
|
You can access it at the following url: |
|
|
%s'), $mosConfig_sitename, $yourname, $youremail, $link ); |
|
| 1548 |
|
|
| 1549 |
// mail function |
// mail function |
| 1550 |
mosMail( $mosConfig_mailfrom, $mosConfig_fromname, $email, $subject, $msg ); |
mosMail( $mosConfig_mailfrom, $mosConfig_fromname, $email, $subject, $msg ); |
| 1562 |
} |
} |
| 1563 |
|
|
| 1564 |
function recordVote() { |
function recordVote() { |
| 1565 |
global $database; |
global $database, $mosConfig_live_site, $mosConfig_offset, $acl, $gid; |
| 1566 |
|
|
| 1567 |
$user_rating = mosGetParam( $_REQUEST, 'user_rating', 0 ); |
$user_rating = mosGetParam( $_REQUEST, 'user_rating', 0 ); |
|
$url = mosGetParam( $_REQUEST, 'url', '' ); |
|
| 1568 |
$cid = mosGetParam( $_REQUEST, 'cid', 0 ); |
$cid = mosGetParam( $_REQUEST, 'cid', 0 ); |
| 1569 |
$cid = intval( $cid ); |
$cid = intval( $cid ); |
| 1570 |
|
$Itemid = mosGetParam( $_REQUEST, 'Itemid', 0 ); |
| 1571 |
|
$Itemid = intval( $Itemid ); |
| 1572 |
$user_rating = intval( $user_rating ); |
$user_rating = intval( $user_rating ); |
| 1573 |
|
$now = date( 'Y-m-d H:i:s', time() + $mosConfig_offset * 60 * 60 ); |
| 1574 |
|
$viewAccess = ($gid >= $acl->get_group_id( 'Registered', 'ARO' ) ? 1 : 0) + ($gid >= $acl->get_group_id( 'Author', 'ARO' ) ? 1 : 0); |
| 1575 |
|
|
| 1576 |
|
$url = sefReltoAbs("index.php?option=com_content&task=view&id={$cid}&Itemid={$Itemid}"); |
| 1577 |
if ( ( $user_rating >= 1 ) and ( $user_rating <= 5 ) ) { |
if ( ( $user_rating >= 1 ) and ( $user_rating <= 5 ) ) { |
| 1578 |
$currip = getenv( 'REMOTE_ADDR' ); |
$currip = getenv( 'REMOTE_ADDR' ); |
| 1579 |
|
|
| 1580 |
|
$query = "SELECT * FROM #__content as c WHERE id = $cid AND (c.state = '1' OR c.state = '-1')" |
| 1581 |
|
. "\n AND (c.publish_up = '0000-00-00 00:00:00' OR c.publish_up <= '$now')" |
| 1582 |
|
. "\n AND (c.publish_down = '0000-00-00 00:00:00' OR c.publish_down >= '$now')" |
| 1583 |
|
. "\n AND access <= ". $viewAccess; |
| 1584 |
|
; |
| 1585 |
|
$database->setQuery( $query ); |
| 1586 |
|
$database->loadObject( $row ); |
| 1587 |
|
if ( $row != NULL){ |
| 1588 |
$query = "SELECT * FROM #__content_rating WHERE content_id = $cid"; |
$query = "SELECT * FROM #__content_rating WHERE content_id = $cid"; |
| 1589 |
$database->setQuery( $query ); |
$database->setQuery( $query ); |
| 1590 |
$votesdb = NULL; |
$votesdb = NULL; |
| 1608 |
} |
} |
| 1609 |
} |
} |
| 1610 |
mosRedirect ( $url, T_('Thanks for your vote!') ); |
mosRedirect ( $url, T_('Thanks for your vote!') ); |
| 1611 |
|
} else { |
| 1612 |
|
mosRedirect ( $url, T_('The rating for this item is not allowed!') ); |
| 1613 |
|
} |
| 1614 |
} |
} |
| 1615 |
} |
} |
| 1616 |
|
|
| 1725 |
} |
} |
| 1726 |
|
|
| 1727 |
function sectionURL ($sectionid) { |
function sectionURL ($sectionid) { |
| 1728 |
global $Itemid; |
$menuHandler = mosMenuHandler::getInstance(); |
| 1729 |
|
$Itemid = $menuHandler->getSectionItemId($sectionid); |
| 1730 |
return "index.php?option=com_content&task=section&id=$sectionid&Itemid=$Itemid"; |
return "index.php?option=com_content&task=section&id=$sectionid&Itemid=$Itemid"; |
| 1731 |
} |
} |
| 1732 |
|
|
| 1733 |
function categoryURL ($sectionid, $catid) { |
function categoryURL ($sectionid, $catid) { |
| 1734 |
global $Itemid; |
$menuHandler = mosMenuHandler::getInstance(); |
| 1735 |
|
$Itemid = $menuHandler->getCategoryItemId($catid); |
| 1736 |
return "index.php?option=com_content&task=category§ionid=$sectionid&id=$catid&Itemid=$Itemid"; |
return "index.php?option=com_content&task=category§ionid=$sectionid&id=$catid&Itemid=$Itemid"; |
| 1737 |
} |
} |
| 1738 |
|
|