Source for file content.php
Documentation is available at content.php
* @copyright Refer to copyright.php
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* @author Mambo Foundation Inc see README.php
/** ensure this file is being included by a parent file */
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
require_once( $mainframe->getPath( 'front_html', 'com_content' ) );
require_once($mainframe->getPath('class'));
$now =
date( 'Y-m-d H:i:s', time() +
$mosConfig_offset *
60 *
60 );
$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' );
// loads function for frontpage component
if ( $option ==
'com_frontpage' ) {
//frontpage( $option, $gid, $pop, $now );
$cache->call( 'frontpage', $gid, $access, $pop, $now );
showItem( $id, $gid, $access, $pop, $option, $now );
$cache->call( 'showSection', $id, $gid, $access, $now );
$cache->call( 'showCategory', $id, $gid, $access, $sectionid, $limit, $limitstart, $now );
$cache->call('showBlogSection', $id, $gid, $access, $pop, $now );
case 'blogcategorymulti':
$cache->call( 'showBlogCategory', $id, $gid, $access, $pop, $now );
editItem( $id, $gid, $access, 0, $task, $Itemid );
editItem( 0, $gid, $access, $sectionid, $task, $Itemid );
recordVote ( $url , $user_rating , $cid , $database);
$cache->call('showBlogSection', 0, $gid, $access, $pop, $now );
* Searches for an item by a key parameter
* @param int The user access level
* @param object Actions this user can perform
* @param string The url option
* @param string A timestamp
function findKeyItem( $gid, $access, $pop, $option, $now ) {
$keyref =
$database->getEscaped( $keyref );
WHERE attribs LIKE \'%keyref=' .
$keyref .
'%\'
$database->setQuery( $query );
$id =
$database->loadResult();
showItem( $id, $gid, $access, $pop, $option, $now );
echo
'Key not found '.
$keyref;
function frontpage( $gid, &$access, $pop, $now ) {
global $database, $mainframe, $my, $Itemid;
global $mosConfig_offset;
$noauth =
!$mainframe->getCfg( 'shownoauth' );
$orderby_sec =
$params->def( 'orderby_sec', '' );
$orderby_pri =
$params->def( 'orderby_pri', '' );
$header =
$params->def( 'header', $menu->name );
$page_title =
$params->def( 'page_title', 0 );
$now =
date( "Y-m-d H:i:s", time()+
$mosConfig_offset*
60*
60 );
$viewAccess =
($gid >=
$acl->get_group_id( 'Registered', 'ARO' ) ?
1 :
0) +
($gid >=
$acl->get_group_id( 'Author', 'ARO' ) ?
1 :
0);
$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"
.
"\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 #__content_rating AS v ON a.id = v.content_id"
.
"\n LEFT JOIN #__groups AS g ON a.access = g.id"
.
"\n WHERE a.state = '1'"
.
( $noauth ?
"\n AND a.access <= '".
$my->gid .
"'" :
'' )
.
"\n AND ( publish_up = '0000-00-00 00:00:00' OR publish_up <= '$now' )"
.
"\n AND ( publish_down = '0000-00-00 00:00:00' OR publish_down >= '$now' )"
.
"\n AND a.access <= ".
$viewAccess
.
"\n ORDER BY ".
$order_pri .
$order_sec
$rows =
$database->doSQLget($query, 'mosExtendedContent');
$mainframe->SetPageTitle( $header );
BlogOutput( $rows, $params, $gid, $access, $pop, $menu );
global $database, $mainframe, $mosConfig_offset, $Itemid;
$noauth =
!$mainframe->getCfg( 'shownoauth' );
$params =
new stdClass();
$orderby =
$params->get( 'orderby', '' );
$params->set( 'type', 'section' );
$params->def( 'page_title', 1 );
$params->def( 'pageclass_sfx', '' );
$params->def( 'other_cat_section', 1 );
$params->def( 'other_cat', 1 );
$params->def( 'empty_cat', 0 );
$params->def( 'cat_items', 1 );
$params->def( 'cat_description', 1 );
$params->def( 'description', 1 );
$params->def( 'description-image', 1 );
$params->def( 'back_button', $mainframe->getCfg( 'back_button' ) );
$params->def( 'pageclass_sfx', '' );
if ( $access->canEdit ) {
$xwhere2 =
"\n AND b.state >= '0'";
$xwhere =
"\n AND a.published = '1'";
$xwhere2 =
"\n AND b.state = '1'"
.
"\n AND ( publish_up = '0000-00-00 00:00:00' OR publish_up <= '".
$now .
"' )"
.
"\n AND ( publish_down = '0000-00-00 00:00:00' OR publish_down >= '".
$now .
"' )"
// show/hide empty categories
if ( $params->get( 'empty_cat' ) ) {
$empty =
"\n HAVING COUNT( b.id ) > 0";
SELECT a.*, COUNT( b.id ) AS numitems
LEFT JOIN #__content AS b ON b.catid = a.id '.
$xwhere2 .
'
WHERE a.section = \'' .
$section->id .
'\' '.
$xwhere;
$database->setQuery( $query );
$other_categories =
$database->loadObjectList();
$mainframe->SetPageTitle( $menu->name );
HTML_content::showContentList( $section, NULL, $access, $id, NULL, $gid, $params, NULL, $other_categories, NULL );
* @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, $limitstart, $now ) {
global $database, $mainframe, $Itemid, $mosConfig_offset, $mosConfig_list_limit;
$noauth =
!$mainframe->getCfg( 'shownoauth' );
$params =
new stdClass();
$orderby =
$params->get( 'orderby', 'rdate' );
$params->set( 'type', 'category' );
$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( 'navigation', 2 );
$params->def( 'display', 1 );
$params->def( 'display_num', $mosConfig_list_limit );
$params->def( 'other_cat', 1 );
$params->def( 'empty_cat', 0 );
$params->def( 'cat_items', 1 );
$params->def( 'cat_description', 0 );
$params->def( 'description', 1 );
$params->def( 'description-image', 1 );
$params->def( 'back_button', $mainframe->getCfg( 'back_button' ) );
$params->def( 'pageclass_sfx', '' );
$params->def( 'headings', 1 );
$params->def( 'order_select', 1 );
$params->def( 'filter', 1 );
$params->def( 'filter_type', 'title' );
$sectionid =
$category->section;
$pathway->addItem($category->title, categoryURL($sectionid, $id));
if ( $access->canEdit ) {
$xwhere2 =
"\n AND b.state >= '0'";
$xwhere =
"\n AND c.published='1'";
$xwhere2 =
"\n AND b.state='1'"
.
"\n AND ( publish_up = '0000-00-00 00:00:00' OR publish_up <= '".
$now .
"' )"
.
"\n AND ( publish_down = '0000-00-00 00:00:00' OR publish_down >= '".
$now .
"' )"
$pagetitle =
$menu->name;
// show/hide empty categories
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 "
.
( $noauth ?
"\n AND b.access <= '".
$gid .
"'" :
'' )
.
"\n WHERE c.section = '".
$category->section.
"'"
.
( $noauth ?
"\n AND c.access <= '".
$gid .
"'" :
'' )
.
"\n ORDER BY c.ordering"
$database->setQuery( $query );
$other_categories =
$database->loadObjectList();
// get the total number of published items in the category
$filter =
$database->getEscaped($filter);
if ( $params->get( 'filter' ) ) {
switch ( $params->get( 'filter_type' ) ) {
$_and =
"\n AND LOWER( a.title ) LIKE '%".
$filter .
"%'";
$_and =
"\n AND ( ( LOWER( u.name ) LIKE '%".
$filter .
"%' ) OR ( LOWER( a.created_by_alias ) LIKE '%".
$filter .
"%' ) )";
$_and =
"\n AND a.hits LIKE '%".
$filter .
"%'";
if ( $access->canEdit ) {
$xwhere =
"\n AND a.state >= '0'";
$xwhere =
"\n AND a.state='1'"
.
"\n AND ( publish_up = '0000-00-00 00:00:00' OR publish_up <= '$now' )"
.
"\n AND ( publish_down = '0000-00-00 00:00:00' OR publish_down >= '$now' )"
$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='".
$category->id .
"' ".
$xwhere
.
( $noauth ?
"\n AND a.access<='".
$gid .
"'" :
'' )
.
"\n AND '".
$category->access .
"'<='".
$gid .
"'"
.
"\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.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='".
$category->id .
"' ".
$xwhere
.
( $noauth ?
"\n AND a.access<='".
$gid .
"'" :
'' )
.
"\n AND '".
$category->access .
"'<='".
$gid .
"'"
.
"\n ORDER BY ".
$orderby .
""
.
"\n LIMIT ".
$limitstart .
", ".
$limit
$database->setQuery( $query );
$items =
$database->loadObjectList();
if ( $params->get( 'date' ) ) {
if ( $params->get( 'title' ) ) {
if ( $params->get( 'hits' ) ) {
if ( $params->get( 'author' ) ) {
$lists['order'] =
mosHTML::selectList( $order, 'order', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'value', 'text', $selected );
$params->set( 'order_select', 0 );
$lists['task'] =
'category';
$lists['filter'] =
$filter;
$mainframe->SetPageTitle( $pagetitle );
HTML_content::showContentList( $category, $items, $access, $id, $sectionid, $gid, $params, $pageNav, $other_categories, $lists );
global $database, $mainframe, $mosConfig_offset, $Itemid;
$noauth =
!$mainframe->getCfg( 'shownoauth' );
$params =
new stdClass();
// new blog multiple section handling
$id =
$params->def( 'sectionid', 0 );
$where =
_where( 1, $access, $noauth, $gid, $id, $now );
$orderby_sec =
$params->def( 'orderby_sec', 'rdate' );
$orderby_pri =
$params->def( 'orderby_pri', '' );
$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"
.
"\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 #__content_rating AS v ON a.id = v.content_id"
.
"\n LEFT JOIN #__sections AS s ON a.sectionid = s.id"
.
"\n LEFT JOIN #__groups AS g ON a.access = g.id"
.
( count( $where ) ?
"\n WHERE ".
implode( "\n AND ", $where ) :
'' )
.
"\n AND s.access<=$gid"
.
"\n ORDER BY ".
$order_pri .
$order_sec
// $database->setQuery( $query );
// $rows = $database->loadObjectList();
$rows =
$database->doSQLget($query, 'mosExtendedContent');
$mainframe->setPageTitle( $menu->name );
BlogOutput( $rows, $params, $gid, $access, $pop, $menu );
global $database, $mainframe, $mosConfig_offset, $Itemid;
$noauth =
!$mainframe->getCfg( 'shownoauth' );
$params =
new stdClass();
// new blog multiple section handling
$id =
$params->def( 'categoryid', 0 );
$where =
_where( 2, $access, $noauth, $gid, $id, $now );
$orderby_sec =
$params->def( 'orderby_sec', 'rdate' );
$orderby_pri =
$params->def( 'orderby_pri', '' );
$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, g.name AS groups, cc.name AS category"
.
"\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 #__content_rating AS v ON a.id = v.content_id"
.
"\n LEFT JOIN #__sections AS s ON a.sectionid = s.id"
.
"\n LEFT JOIN #__groups AS g ON a.access = g.id"
.
( count( $where ) ?
"\n WHERE ".
implode( "\n AND ", $where ) :
'' )
.
"\n AND s.access <= ".
$gid
.
"\n ORDER BY ".
$order_pri .
$order_sec;
// $database->setQuery( $query );
// $rows = $database->loadObjectList();
$rows =
$database->doSQLget($query, 'mosExtendedContent');
$mainframe->SetPageTitle( $menu->name );
BlogOutput( $rows, $params, $gid, $access, $pop, $menu );
global $database, $mainframe, $mosConfig_offset;
$noauth =
!$mainframe->getCfg( 'shownoauth' );
$year =
mosGetParam( $_REQUEST, 'year', MosFormatDate( date("Y-m-d H:i:s"), 'QY' ) );
$month =
mosGetParam( $_REQUEST, 'month', MosFormatDate( date("Y-m-d H:i:s"), 'Qm' ) );
$params =
new stdClass();
$params->set( 'intro_only', 1 );
$params->set( 'year', $year );
$params->set( 'month', $month );
$orderby_sec =
$params->def( 'orderby_sec', 'rdate' );
$orderby_pri =
$params->def( 'orderby_pri', '' );
$where =
_where( -
1, $access, $noauth, $gid, $id, NULL, $year, $month );
// checks to see if 'All Sections' options used
$check =
'AND a.sectionid = '.
$id ;
// query to determine if there are any archived entries for the section
.
"\n FROM #__content as a"
.
"\n WHERE a.state = '-1'"
$database->setQuery( $query );
$items =
$database->loadObjectList();
$archives =
count( $items );
$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"
.
"\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 #__content_rating AS v ON a.id = v.content_id"
.
"\n LEFT JOIN #__sections AS s ON a.sectionid = s.id"
.
"\n LEFT JOIN #__groups AS g ON a.access = g.id"
.
( count( $where ) ?
"\n WHERE ".
implode( "\n AND ", $where ) :
'')
.
"\n AND s.access <= ".
$gid
.
"\n ORDER BY ".
$order_pri .
$order_sec
// $database->setQuery( $query );
// $rows = $database->loadObjectList();
$rows =
$database->doSQLget($query, 'mosExtendedContent');
echo
'<form action="'.
sefRelToAbs( 'index.php').
'" method="post">';
$mainframe->SetPageTitle( $menu->name );
// if no archives for category, hides search and outputs empty message
echo
'<br /><div align="center">'.
T_('There are currently no Archived Entries for this Category') .
'</div>';
BlogOutput( $rows, $params, $gid, $access, $pop, $menu, 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
'<input type="hidden" name="module" value="1" />';
global $database, $mainframe, $mosConfig_offset;
$noauth =
!$mainframe->getCfg( 'shownoauth' );
$year =
mosGetParam( $_REQUEST, 'year', MosFormatDate( date("Y-m-d H:i:s"), 'QY' ) );
$month =
mosGetParam( $_REQUEST, 'month', MosFormatDate( date("Y-m-d H:i:s"), 'Qm' ) );
// used by archive module
$check =
'AND a.catid = '.
$id;
$params->set( 'year', $year );
$params->set( 'month', $month );
$orderby_sec =
$params->def( 'orderby', 'rdate' );
$where =
_where( -
2, $access, $noauth, $gid, $id, NULL, $year, $month );
// query to determine if there are any archived entries for the category
.
"\n FROM #__content as a"
.
"\n WHERE a.state = '-1'"
$database->setQuery( $query );
$items =
$database->loadObjectList();
$archives =
count( $items );
$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, g.name AS groups"
.
"\n FROM #__content AS a"
.
"\n LEFT JOIN #__users AS u ON u.id = a.created_by"
.
"\n LEFT JOIN #__content_rating AS v ON a.id = v.content_id"
.
"\n LEFT JOIN #__sections AS s ON a.sectionid = s.id"
.
"\n LEFT JOIN #__groups AS g ON a.access = g.id"
.
( count( $where ) ?
"\n WHERE ".
implode( "\n AND ", $where ) :
'' )
.
"\n AND s.access <= ".
$gid
.
"\n ORDER BY ".
$order_sec
// $database->setQuery( $query );
// $rows = $database->loadObjectList();
$rows =
$database->doSQLget($query, 'mosExtendedContent');
echo
'<form action="'.
sefRelToAbs( 'index.php').
'" method="post">';
$mainframe->SetPageTitle( $menu->name );
// if no archives for category, hides search and outputs empty message
echo
'<br /><div align="center">'.
T_('There are currently no Archived Entries for this Category') .
'</div>';
BlogOutput( $rows, $params, $gid, $access, $pop, $menu, 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
'<input type="hidden" name="module" value="1" />';
function BlogOutput ( &$rows, &$params, $gid, &$access, $pop, &$menu, $archive=
NULL ) {
global $mainframe, $Itemid, $task, $id, $option, $database, $mosConfig_live_site;
if ( $params->get( 'page_title', 1 ) &&
$menu) {
$header =
$params->def( 'header', $menu->name );
$columns =
$params->def( 'columns', 2 );
$intro =
$params->def( 'intro', 4 );
$leading =
$params->def( 'leading', 1 );
$links =
$params->def( 'link', 4 );
$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 );
// 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 );
$limit =
$intro +
$leading +
$links;
if ( $total <=
$limit ) {
// needed to reduce queries used by getItemid
require_once(mamboCore::get('mosConfig_absolute_path').
'/components/com_content/content.class.php');
$ItemidCount['bs'] =
$handler->getBlogSectionCount();
$ItemidCount['bc'] =
$handler->getBlogCategoryCount();
$ItemidCount['gbs'] =
$handler->getGlobalBlogSectionCount();
// used to display section/catagory description text and images
// currently not supported in Archives
if ( $menu &&
$menu->componentid &&
( $descrip ||
$descrip_image ) ) {
case 'content_blog_section':
$description->load( $menu->componentid );
case 'content_blog_category':
$description->load( $menu->componentid );
echo
'<div class="componentheading'.
$params->get( 'pageclass_sfx' ) .
'">'.
$header .
'</div>';
echo
'<input type="submit" class="button" value="دریافت نتیجه"/>';
// checks to see if there are there any items to display
$col_with =
100 /
$columns; // width of each column
$width =
'width="'.
$col_with .
'%"';
// Search Success message
echo
"<br /><br /><div align='center'>".
$msg .
"</div><br /><br />";
echo
'<table class="blog' .
$params->get( 'pageclass_sfx' ) .
'" cellpadding="0" cellspacing="0">';
// Secrion/Category Description & Image
if ( $menu &&
$menu->componentid &&
( $descrip ||
$descrip_image ) ) {
$link =
$mosConfig_live_site .
'/images/stories/'.
$description->image;
echo
'<td valign="top">';
if ( $descrip_image &&
$description->image ) {
echo
'<img src="'.
$link .
'" align="'.
$description->image_position .
'" hspace="6" alt="" />';
if ( $descrip &&
$description->description ) {
echo
$description->description;
echo
'<td valign="top">';
for ( $z =
0; $z <
$leading; $z++
) {
// stops loop if total number of items is less than the number set to display as leading
show( $rows[$i], $params, $gid, $access, $pop, $option, $ItemidCount );
if ( $intro &&
( $i <
$total ) ) {
echo
'<td valign="top">';
echo
'<table width="100%" cellpadding="0" cellspacing="0">';
for ( $z =
0; $z <
$intro; $z++
) {
// stops loop if total number of items is less than the number set to display as intro + leading
if ( !( $z %
$columns ) ||
$columns ==
1 ) {
echo
'<td valign="top" '.
$width .
'>';
// outputs either intro or only a link
show( $rows[$i], $params, $gid, $access, $pop, $option, $ItemidCount );
if ( !( ( $z +
1 ) %
$columns ) ||
$columns ==
1 ) {
// this is required to output a final closing </tr> tag when the number of items does not fully
// fill the last row of output - a blank column is left
if ( $intro %
$columns ) {
if ( $links &&
( $i <
$total ) ) {
echo
'<td valign="top">';
echo
'<div class="blog_more'.
$params->get( 'pageclass_sfx' ) .
'">';
HTML_content::showLinks( $rows, $links, $total, $i, 1, $ItemidCount );
if ( ( $pagination ==
2 ) &&
( $total <=
$limit ) ) {
// not visible when they is no 'other' pages to display
// get the total number of records
$limitstart =
$limitstart ?
$limitstart :
0;
require_once( $GLOBALS['mosConfig_absolute_path'] .
'/includes/pageNavigation.php' );
$pageNav =
new mosPageNav( $total, $limitstart, $limit );
if ( $option ==
'com_frontpage' ) {
$link =
'index.php?option=com_frontpage&Itemid='.
$Itemid;
$year =
$params->get( 'year' );
$month =
$params->get( 'month' );
$link =
'index.php?option=com_content&task='.
$task .
'&id='.
$id .
'&Itemid='.
$Itemid.
'&year='.
$year .
'&month='.
$month;
$link =
'index.php?option=com_content&task='.
$task .
'&id='.
$id .
'&Itemid='.
$Itemid;
echo
'<td valign="top" align="center">';
echo
$pageNav->writePagesLinks( $link );
if ( $pagination_results ) {
echo
'<td valign="top" align="center">';
echo
$pageNav->writePagesCounter();
} else if ( $archive &&
!$total ) {
// Search Failure message for Archives
echo
'<br /><br /><div align="center">'.
$msg .
'</div><br />';
// Generic blog empty display
echo
T_('There are no items to display');
$params->set( 'back_button', $back );
function showItem( $uid, $gid, &$access, $pop, $option, $now ) {
global $database, $mainframe;
global $mosConfig_offset, $mosConfig_live_site, $mosConfig_MetaTitle, $mosConfig_MetaAuthor;
if ( $access->canEdit ) {
$xwhere =
"AND (a.state = '1' OR a.state = '-1')"
.
"\n AND (publish_up = '0000-00-00 00:00:00' OR publish_up <= '$now')"
.
"\n AND (publish_down = '0000-00-00 00:00:00' OR publish_down >= '$now')"
$viewAccess =
($gid >=
$acl->get_group_id( 'Registered', 'ARO' ) ?
1 :
0) +
($gid >=
$acl->get_group_id( 'Author', 'ARO' ) ?
1 :
0);
$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"
.
"\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 #__content_rating AS v ON a.id = v.content_id"
.
"\n LEFT JOIN #__groups AS g ON a.access = g.id"
.
"\n WHERE a.id='".
$uid .
"' ".
$xwhere
.
"\n AND a.access <= ".
$viewAccess
$database->setQuery( $query );
if ( $database->loadObject( $row ) ) {
$pathway->addItem($row->category, categoryURL($row->sectionid, $row->catid));
$pathway->addItem($row->title, '');
$params->set( 'intro_only', 0 );
$params->def( 'back_button', $mainframe->getCfg( 'back_button' ) );
if ( $row->sectionid ==
0) {
$params->set( 'item_navigation', 0 );
$params->set( 'item_navigation', $mainframe->getCfg( 'item_navigation' ) );
// loads the links for Next & Previous Button
if ( $params->get( 'item_navigation' ) ) {
.
"\n FROM #__content AS a"
.
"\n WHERE a.catid = ".
$row->catid.
""
.
"\n AND a.state = $row->state AND ordering < $row->ordering"
.
($access->canEdit ?
"" :
"\n AND a.access <= '".
$gid .
"'" )
.
"\n AND ( a.publish_up = '0000-00-00 00:00:00' OR a.publish_up <= '".
$now .
"' )"
.
"\n AND ( a.publish_down = '0000-00-00 00:00:00' OR a.publish_down >= '".
$now .
"' )"
.
"\n ORDER BY a.ordering DESC"
$database->setQuery( $query );
$row->prev =
$database->loadResult();
.
"\n FROM #__content AS a"
.
"\n WHERE a.catid = ".
$row->catid.
""
.
"\n AND a.state = $row->state AND ordering > $row->ordering"
.
($access->canEdit ?
"" :
"\n AND a.access <= '".
$gid .
"'" )
.
"\n AND ( a.publish_up = '0000-00-00 00:00:00' OR a.publish_up <= '".
$now .
"' )"
.
"\n AND ( a.publish_down = '0000-00-00 00:00:00' OR a.publish_down >= '".
$now .
"' )"
.
"\n ORDER BY a.ordering"
$database->setQuery( $query );
$row->next =
$database->loadResult();
$mainframe->setPageTitle( $row->title );
if ($mosConfig_MetaTitle==
'1') {
$mainframe->addMetaTag( 'title' , $row->title );
if ($mosConfig_MetaAuthor==
'1') {
$mainframe->addMetaTag( 'author' , $row->author );
show( $row, $params, $gid, $access, $pop, $option );
function show( $row, $params, $gid, &$access, $pop, $option, $ItemidCount=
NULL ) {
global $database, $mainframe, $Itemid;
global $mosConfig_live_site, $mosConfig_absolute_path;
$noauth =
!$mainframe->getCfg( 'shownoauth' );
if ( $access->canEdit ) {
if ( $row->id ===
null ||
$row->access >
$gid ) {
if ( $row->id ===
null ||
$row->state ==
0 ) {
if ( $row->access >
$gid ) {
if ( !( $params->get( 'intro_only' ) ) ) {
$params->def( 'link_titles', $mainframe->getCfg( 'link_titles' ) );
$params->def( 'author', !$mainframe->getCfg( 'hideAuthor' ) );
$params->def( 'createdate', !$mainframe->getCfg( 'hideCreateDate' ) );
$params->def( 'modifydate', !$mainframe->getCfg( 'hideModifyDate' ) );
$params->def( 'print', !$mainframe->getCfg( 'hidePrint' ) );
$params->def( 'pdf', !$mainframe->getCfg( 'hidePdf' ) );
$params->def( 'email', !$mainframe->getCfg( 'hideEmail' ) );
$params->def( 'rating', $mainframe->getCfg( 'vote' ) );
$params->def( 'icons', $mainframe->getCfg( 'icons' ) );
$params->def( 'readmore', $mainframe->getCfg( 'readmore' ) );
$params->def( 'image', 1 );
$params->def( 'section', 0 );
$params->def( 'section_link', 0 );
$params->def( 'category', 0 );
$params->def( 'category_link', 0 );
$params->def( 'introtext', 1 );
$params->def( 'pageclass_sfx', '' );
$params->def( 'item_title', 1 );
$params->def( 'url', 1 );
// loads the link for Section name
if ( $params->get( 'section_link' ) ) {
.
"\n WHERE a.componentid = '".
$row->sectionid.
"'"
.
"\n AND a.type = 'content_section'"
.
"\n AND a.published = 1"
$database->setQuery( $query );
$_Itemid =
$database->loadResult();
$link =
sefRelToAbs( 'index.php?option=com_content&task=section&id='.
$row->sectionid .
'&Itemid='.
$_Itemid );
$row->section =
'<a href="'.
$link .
'">'.
$row->section .
'</a>';
// loads the link for Category name
if ( $params->get( 'category_link' ) ) {
.
"\n WHERE a.componentid = ".
$row->catid.
""
.
"\n AND a.type = 'content_category'"
.
"\n AND a.published = 1"
$database->setQuery( $query );
$_Itemid =
$database->loadResult();
$link =
sefRelToAbs( 'index.php?option=com_content&task=section&id='.
$row->sectionid .
'&Itemid='.
$_Itemid );
$link =
sefRelToAbs( 'index.php?option=com_content&task=category&sectionid='.
$row->sectionid .
'&id='.
$row->catid .
'&Itemid='.
$_Itemid );
$row->category =
'<a href="'.
$link .
'">'.
$row->category .
'</a>';
// loads current template for the pop-up window
$params->set( 'popup', 1 );
$database->setQuery( "SELECT template FROM #__templates_menu WHERE client_id='0' AND menuid='0'" );
$template =
$database->loadResult();
// show/hides the intro text
if ( $params->get( 'introtext' ) ) {
$row->text =
$row->introtext.
( $params->get( 'intro_only' ) ?
'' :
chr(13) .
chr(13) .
$row->fulltext);
$row->text =
$row->fulltext;
// deal with the {mospagebreak} mambots
// only permitted in the full text area
if ( !$params->get( 'intro_only' ) ) {
$cache->call( 'HTML_content::show', $row, $params, $access, $page, $option, $ItemidCount );
function editItem( $uid, $gid, &$access, $sectionid=
0, $task, $Itemid ){
global $database, $mainframe, $my;
global $mosConfig_absolute_path, $mosConfig_live_site, $mosConfig_offset;
// load the row from the db table
// fail if checked out not by 'me'
if ( $row->checked_out &&
$row->checked_out <>
$my->id ) {
echo
"<script>alert('".
sprintf(T_('The module [ %s ] is currently being edited by another person.'), $row->title).
"'); window.history.go(-1); </script>";
if ( !( $access->canEdit ||
( $access->canEditOwn &&
$row->created_by ==
$my->id ) ) ) {
if (!($access->canEdit ||
$access->canEditOwn)) {
$sectionid =
$row->sectionid;
// get the type name - which is a special category
$query =
"SELECT name FROM #__sections WHERE id='$sectionid'";
$database->setQuery( $query );
$section =
$database->loadResult();
$row->checkout( $my->id );
if (trim( $row->publish_down ) ==
"0000-00-00 00:00:00") {
//$row->publish_down = 'Never';
$row->publish_down =
T_('Never');
$row->publish_down =
mosFormatDate( $row->publish_up, 'QY-m-d H:i:s' );
$row->modified =
mosFormatDate( $row->modified, 'QY-m-d H:i:s' );
$row->publish_up =
mosFormatDate( $row->publish_up, 'QY-m-d H:i:s' );
if (trim( $row->images )) {
$row->images =
explode( "\n", $row->images );
$query =
"SELECT name from #__users"
.
"\n WHERE id = ".
$row->created_by
$database->setQuery( $query );
$row->creator =
$database->loadResult();
$query =
"SELECT name from #__users"
.
"\n WHERE id = ".
$row->modified_by
$database->setQuery( $query );
$row->modifier =
$database->loadResult();
$query =
"SELECT content_id from #__content_frontpage"
.
"\n WHERE content_id = ".
$row->id
$database->setQuery( $query );
$row->sectionid =
$sectionid;
//$row->publish_up = mosFormatDate( time(), 'Y-m-d' );
$row->publish_up =
jdate( "d-m-Y", time() +
$mosConfig_offset *
60 *
60 );
//$row->publish_down = 'Never';
$row->publish_down =
T_('Never');
// calls function to read image from directory
$pathA =
$mosConfig_absolute_path .
'/images/stories';
$pathL =
$mosConfig_live_site .
'/images/stories';
require_once($mosConfig_absolute_path.
'/administrator/includes/mosAdminMenus.php');
// list of folders in images/stories/
// list of images in specfic folder in images/stories/
// make the select list for the states
$lists['state'] =
mosHTML::selectList( $states, 'state', 'class="inputbox" size="1"', 'value', 'text', intval( $row->state ) );
// build the html select list for ordering
$query =
"SELECT ordering AS value, title AS text"
.
"\n WHERE catid = '$row->catid'"
// build list of categories
// build the select list for the image positions
// build the html select list for the group access
* Saves the content item an edit form submit
global $database, $mainframe, $my;
global $mosConfig_absolute_path;
if ( !$row->bind( $_POST ) ) {
echo
"<script> alert('".
$row->getError().
"'); window.history.go(-1); </script>\n";
$row->catid =
intval($row->catid);
$row->sectionid =
intval($row->sectionid);
if ( !( $access->canEdit ||
$access->canEditOwn ) ) {
$row->created =
date( 'Y-m-d H:i:s' );
$row->created_by =
$my->id;
if ( !( $access->canEdit ||
( $access->canEditOwn &&
$row->created_by ==
$my->id ) ) ) {
$row->modified =
date( 'Y-m-d H:i:s' );
$row->modified_by =
$my->id;
//if ( trim( $row->publish_down ) == 'Never' ) {
if ( trim( $row->publish_down ) ==
T_('Never') ) {
$row->publish_down =
'0000-00-00 00:00:00';
$row->publish_down =
date('Y-m-d H:i:s', mlj($row->publish_down) );
$row->publish_up =
date('Y-m-d H:i:s', mlj($row->publish_up) );
echo
"<script> alert('".
$row->getError().
"'); window.history.go(-1); </script>\n";
echo
"<script> alert('".
$row->getError().
"'); window.history.go(-1); </script>\n";
// manage frontpage items
require_once( $mainframe->getPath( 'class', 'com_frontpage' ) );
// toggles go to first place
if (!$fp->load( $row->id )) {
$database->setQuery( "INSERT INTO #__content_frontpage VALUES ('$row->id','1')" );
if (!$database->query()) {
echo
"<script> alert('".
$database->stderr().
"');</script>\n";
if ( !$fp->delete( $row->id ) ) {
$row->updateOrder( "catid='$row->catid'" );
// gets section name of item
$database->setQuery( "SELECT s.title"
.
"\n FROM #__sections AS s"
.
"\n WHERE s.scope = 'content'"
.
"\n AND s.id = '".
$row->sectionid .
"'"
// gets category name of item
$section =
$database->loadResult();
$database->setQuery( "SELECT c.title"
.
"\n FROM #__categories AS c"
.
"\n WHERE c.id = '".
$row->catid .
"'"
$category =
$database->loadResult();
// messaging for new items
require_once( $mosConfig_absolute_path .
'/components/com_messages/messages.class.php' );
$database->setQuery( "SELECT id FROM #__users WHERE sendEmail = '1'" );
$users =
$database->loadResultArray();
foreach ($users as $user_id) {
$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 =
$isNew ?
T_('Thanks for your submission; it will be reviewed before being posted to the site.') :
T_('Item saved successfully.');
* Cancels an edit operation
* @param database A database connector object
global $database, $mainframe, $my;
if ( $access->canEdit ||
( $access->canEditOwn &&
$row->created_by ==
$my->id ) ) {
* Shows the email form for a given content item.
global $database, $mainframe, $my;
if ( $row->id ===
null ||
$row->access >
$my->gid ) {
$database->setQuery( "SELECT template FROM #__templates_menu WHERE client_id = '0' AND menuid = '0'" );
$template =
$database->loadResult();
HTML_content::emailForm( $row->id, $row->title, $template );
* Shows the email form for a given content item.
global $database, $mainframe;
global $mosConfig_live_site, $mosConfig_sitename;
global $mosConfig_mailfrom, $mosConfig_fromname;
$_Itemid =
$mainframe->getItemid( $uid, 0, 0 );
$subject_default =
sprintf(T_('Item sent by %s'), $yourname);
if (empty($_SESSION['_form_check_']['com_content']) ||
$form_check !=
$_SESSION['_form_check_']['com_content']) {
// the form hasn't been generated by the server on this session
if ( !$email ||
!$youremail ||
( is_email( $email ) ==
false ) ||
( is_email( $youremail ) ==
false ) ) {
echo
"<script>alert (\"".
T_('You must enter valid e-mail addresses for both yourself and your recipient.').
"\"); window.history.go(-1);</script>";
$database->setQuery( "SELECT template FROM #__templates_menu WHERE client_id='0' AND menuid='0'" );
$template =
$database->loadResult();
$link =
sefRelToAbs( $mosConfig_live_site .
'/index.php?option=com_content&task=view&id='.
$uid .
'&Itemid='.
$_Itemid );
$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 );
mosMail( $mosConfig_mailfrom, $mosConfig_fromname, $email, $subject, $msg );
if ( preg_match( "/[\w\.\-]+@\w+[\w\.\-]*?\.\w{1,4}/", $email ) ) {
$user_rating =
mosGetParam( $_REQUEST, 'user_rating', 0 );
$user_rating =
intval( $user_rating );
if ( ( $user_rating >=
1 ) and ( $user_rating <=
5 ) ) {
$currip =
getenv( 'REMOTE_ADDR' );
$query =
"SELECT * FROM #__content_rating WHERE content_id = $cid";
$database->setQuery( $query );
if ( !( $database->loadObject( $votesdb ) ) ) {
$query =
"INSERT INTO #__content_rating ( content_id, lastip, rating_sum, rating_count )"
.
"\n VALUES ( '$cid', '$currip', '$user_rating', '1' )";
$database->setQuery( $query );
$database->query() or die( $database->stderr() );;
if ($currip <>
($votesdb->lastip)) {
$query =
"UPDATE #__content_rating"
.
"\n SET rating_count = rating_count + 1,"
.
"\n rating_sum = rating_sum + $user_rating,"
.
"\n lastip = '$currip'"
.
"\n WHERE content_id = ".
$cid
$database->setQuery( $query );
$database->query() or die( $database->stderr() );
mosRedirect ( $url, T_('You already voted for this poll today!') );
$orderby =
'cc.title DESC, ';
$orderby =
'cc.ordering, ';
$orderby =
'a.created DESC';
$orderby =
'a.title DESC';
$orderby =
'a.hits DESC';
$orderby =
'a.created_by, u.name';
$orderby =
'a.created_by DESC, u.name DESC';
* @param int 0 = Archives, 1 = Section, 2 = Category
function _where( $type=
1, &$access, &$noauth, $gid, $id, $now=
NULL, $year=
NULL, $month=
NULL ) {
$where[] =
"a.state = '1'";
if ( !$access->canEdit ) {
$where[] =
"( a.publish_up = '0000-00-00 00:00:00' OR a.publish_up <= '".
$now .
"' )";
$where[] =
"( a.publish_down = '0000-00-00 00:00:00' OR a.publish_down >= '".
$now .
"' )";
$where[] =
"a.access <= '".
$gid .
"'";
$where[] =
"a.sectionid IN ( ".
$id .
" ) ";
} else if ( $type ==
2 ) {
$where[] =
"a.catid IN ( ".
$id .
" ) ";
// Jalali date to gregorian time
$start_time =
mlj($year.
'-'.
$month.
'-01');
// Get start date for Query
$start_date =
date("Y-m-d",$start_time);
$total_day =
jdate("t",$start_time);
$end_time =
mlj($year.
'-'.
$month.
'-'.
$total_day);
// Get end date for query
$end_date =
date("Y-m-d",$end_time);
$where[] =
"a.state='-1'";
$where[] =
"a.`created` >= '$start_date' AND a.`created` <= '$end_date'";
$where[] =
"a.access <= '".
$gid .
"'";
$where[] =
"a.sectionid = '".
$id .
"'";
} else if ( $type == -
2) {
$where[] =
"a.catid = '".
$id .
"'";
return "index.php?option=com_content&task=section&id=$sectionid&Itemid=$Itemid";
return "index.php?option=com_content&task=category§ionid=$sectionid&id=$catid&Itemid=$Itemid";
Documentation generated on Mon, 05 May 2008 16:18:34 +0400 by phpDocumentor 1.4.0