Annotation of /mambo/branches/4.6/components/com_content/content.php
Parent Directory
|
Revision Log
Revision 1625 - (view) (download)
| 1 : | alwarren | 1561 | <?php |
| 2 : | /** | ||
| 3 : | * @package Mambo | ||
| 4 : | * @subpackage Content | ||
| 5 : | * @author Mambo Foundation Inc see README.php | ||
| 6 : | * @copyright Mambo Foundation Inc. | ||
| 7 : | * See COPYRIGHT.php for copyright notices and details. | ||
| 8 : | * @license GNU/GPL Version 2, see LICENSE.php | ||
| 9 : | * Mambo is free software; you can redistribute it and/or | ||
| 10 : | * modify it under the terms of the GNU General Public License | ||
| 11 : | * as published by the Free Software Foundation; version 2 of the License. | ||
| 12 : | */ | ||
| 13 : | |||
| 14 : | /** ensure this file is being included by a parent file */ | ||
| 15 : | defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); | ||
| 16 : | |||
| 17 : | require_once( $mainframe->getPath( 'front_html', 'com_content' ) ); | ||
| 18 : | require_once($mainframe->getPath('class')); | ||
| 19 : | |||
| 20 : | $id = intval( mosGetParam( $_REQUEST, 'id', 0 ) ); | ||
| 21 : | $sectionid = intval( mosGetParam( $_REQUEST, 'sectionid', 0 ) ); | ||
| 22 : | $pop = intval( mosGetParam( $_REQUEST, 'pop', 0 ) ); | ||
| 23 : | $task = trim( mosGetParam( $_REQUEST, 'task', '' ) ); | ||
| 24 : | $limit = intval( mosGetParam( $_REQUEST, 'limit', '' ) ); | ||
| 25 : | $limitstart = intval( mosGetParam( $_REQUEST, 'limitstart', 0 ) ); | ||
| 26 : | |||
| 27 : | $now = date( 'Y-m-d H:i:s', time() + $mosConfig_offset * 60 * 60 ); | ||
| 28 : | |||
| 29 : | // Editor usertype check | ||
| 30 : | $access = new stdClass(); | ||
| 31 : | $access->canEdit = $acl->acl_check( 'action', 'edit', 'users', $my->usertype, 'content', 'all' ); | ||
| 32 : | $access->canEditOwn = $acl->acl_check( 'action', 'edit', 'users', $my->usertype, 'content', 'own' ); | ||
| 33 : | $access->canPublish = $acl->acl_check( 'action', 'publish', 'users', $my->usertype, 'content', 'all' ); | ||
| 34 : | |||
| 35 : | // cache activation | ||
| 36 : | $cache =& mosCache::getCache( 'com_content' ); | ||
| 37 : | |||
| 38 : | // loads function for frontpage component | ||
| 39 : | if ( $option == 'com_frontpage' ) { | ||
| 40 : | //frontpage( $option, $gid, $pop, $now ); | ||
| 41 : | $cache->call( 'frontpage', $gid, $access, $pop); | ||
| 42 : | return; | ||
| 43 : | } | ||
| 44 : | |||
| 45 : | switch ( strtolower( $task ) ) { | ||
| 46 : | case 'findkey': | ||
| 47 : | findKeyItem( $gid, $access, $pop, $option, $now ); | ||
| 48 : | break; | ||
| 49 : | |||
| 50 : | case 'view': | ||
| 51 : | showItem( $id, $gid, $access, $pop, $option, $now ); | ||
| 52 : | break; | ||
| 53 : | |||
| 54 : | case 'section': | ||
| 55 : | $cache->call( 'showSection', $id, $gid, $access ); | ||
| 56 : | break; | ||
| 57 : | |||
| 58 : | case 'category': | ||
| 59 : | $cache->call( 'showCategory', $id, $gid, $access, $sectionid, $limit, $limitstart ); | ||
| 60 : | break; | ||
| 61 : | |||
| 62 : | case 'blogsection': | ||
| 63 : | $cache->call('showBlogSection', $id, $gid, $access, $pop); | ||
| 64 : | break; | ||
| 65 : | |||
| 66 : | case 'blogcategorymulti': | ||
| 67 : | case 'blogcategory': | ||
| 68 : | $cache->call( 'showBlogCategory', $id, $gid, $access, $pop ); | ||
| 69 : | break; | ||
| 70 : | |||
| 71 : | case 'archivesection': | ||
| 72 : | showArchiveSection( $id, $gid, $access, $pop, $option ); | ||
| 73 : | break; | ||
| 74 : | |||
| 75 : | case 'archivecategory': | ||
| 76 : | showArchiveCategory( $id, $gid, $access, $pop, $option, $now ); | ||
| 77 : | break; | ||
| 78 : | |||
| 79 : | case 'edit': | ||
| 80 : | editItem( $id, $gid, $access, 0, $task, $Itemid ); | ||
| 81 : | break; | ||
| 82 : | |||
| 83 : | case 'new': | ||
| 84 : | editItem( 0, $gid, $access, $sectionid, $task, $Itemid ); | ||
| 85 : | break; | ||
| 86 : | |||
| 87 : | case 'save': | ||
| 88 : | mosCache::cleanCache( 'com_content' ); | ||
| 89 : | saveContent( $access ); | ||
| 90 : | break; | ||
| 91 : | |||
| 92 : | case 'cancel': | ||
| 93 : | cancelContent( $access ); | ||
| 94 : | break; | ||
| 95 : | |||
| 96 : | case 'emailform': | ||
| 97 : | emailContentForm( $id ); | ||
| 98 : | break; | ||
| 99 : | |||
| 100 : | case 'emailsend': | ||
| 101 : | emailContentSend( $id ); | ||
| 102 : | break; | ||
| 103 : | |||
| 104 : | case 'vote': | ||
| 105 : | recordVote ( $user_rating , $cid , $database); | ||
| 106 : | break; | ||
| 107 : | |||
| 108 : | default: | ||
| 109 : | $cache->call('showBlogSection', 0, $gid, $access, $pop); | ||
| 110 : | break; | ||
| 111 : | } | ||
| 112 : | |||
| 113 : | /** | ||
| 114 : | * Searches for an item by a key parameter | ||
| 115 : | * @param int The user access level | ||
| 116 : | * @param object Actions this user can perform | ||
| 117 : | * @param int | ||
| 118 : | * @param string The url option | ||
| 119 : | * @param string A timestamp | ||
| 120 : | */ | ||
| 121 : | function findKeyItem( $gid, $access, $pop, $option, $now ) { | ||
| 122 : | global $database; | ||
| 123 : | $keyref = mosGetParam( $_REQUEST, 'keyref', '' ); | ||
| 124 : | $keyref = $database->getEscaped( $keyref ); | ||
| 125 : | |||
| 126 : | $query = 'SELECT id | ||
| 127 : | FROM #__content | ||
| 128 : | WHERE attribs LIKE \'%keyref=' . $keyref . '%\' | ||
| 129 : | '; | ||
| 130 : | $database->setQuery( $query ); | ||
| 131 : | $id = $database->loadResult(); | ||
| 132 : | if ($id > 0) { | ||
| 133 : | showItem( $id, $gid, $access, $pop, $option, $now ); | ||
| 134 : | } else { | ||
| 135 : | echo 'Key not found '. $keyref; | ||
| 136 : | } | ||
| 137 : | } | ||
| 138 : | |||
| 139 : | function frontpage( $gid, &$access, $pop) { | ||
| 140 : | global $database, $mainframe, $my, $Itemid; | ||
| 141 : | global $mosConfig_offset; | ||
| 142 : | |||
| 143 : | $noauth = !$mainframe->getCfg( 'shownoauth' ); | ||
| 144 : | |||
| 145 : | // Parameters | ||
| 146 : | $menu =& new mosMenu( $database ); | ||
| 147 : | $menu->load( $Itemid ); | ||
| 148 : | $params =& new mosParameters( $menu->params ); | ||
| 149 : | $orderby_sec = $params->def( 'orderby_sec', '' ); | ||
| 150 : | $orderby_pri = $params->def( 'orderby_pri', '' ); | ||
| 151 : | $header = $params->def( 'header', $menu->name ); | ||
| 152 : | $page_title = $params->def( 'page_title', 0 ); | ||
| 153 : | // Ordering control | ||
| 154 : | $order_sec = _orderby_sec( $orderby_sec ); | ||
| 155 : | $order_pri = _orderby_pri( $orderby_pri ); | ||
| 156 : | |||
| 157 : | $now = date( "Y-m-d H:i:s", time()+$mosConfig_offset*60*60 ); | ||
| 158 : | |||
| 159 : | global $acl; | ||
| 160 : | $viewAccess = ($gid >= $acl->get_group_id( 'Registered', 'ARO' ) ? 1 : 0) + ($gid >= $acl->get_group_id( 'Author', 'ARO' ) ? 1 : 0); | ||
| 161 : | // query records | ||
| 162 : | $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" | ||
| 163 : | . "\n FROM #__content AS a" | ||
| 164 : | . "\n INNER JOIN #__content_frontpage AS f ON f.content_id = a.id" | ||
| 165 : | . "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid" | ||
| 166 : | . "\n LEFT JOIN #__sections AS s ON s.id = a.sectionid" | ||
| 167 : | . "\n LEFT JOIN #__users AS u ON u.id = a.created_by" | ||
| 168 : | . "\n LEFT JOIN #__content_rating AS v ON a.id = v.content_id" | ||
| 169 : | . "\n LEFT JOIN #__groups AS g ON a.access = g.id" | ||
| 170 : | . "\n WHERE a.state = '1'" | ||
| 171 : | . ( $noauth ? "\n AND a.access <= '". $my->gid ."'" : '' ) | ||
| 172 : | . "\n AND ( publish_up = '0000-00-00 00:00:00' OR publish_up <= '$now' )" | ||
| 173 : | . "\n AND ( publish_down = '0000-00-00 00:00:00' OR publish_down >= '$now' )" | ||
| 174 : | . "\n AND a.access <= ". $viewAccess | ||
| 175 : | . "\n ORDER BY ". $order_pri . $order_sec | ||
| 176 : | ; | ||
| 177 : | $rows = $database->doSQLget($query, 'mosExtendedContent'); | ||
| 178 : | |||
| 179 : | // Dynamic Page Title | ||
| 180 : | $mainframe->SetPageTitle( $header ); | ||
| 181 : | |||
| 182 : | BlogOutput( $rows, $params, $gid, $access, $pop, $menu ); | ||
| 183 : | } | ||
| 184 : | |||
| 185 : | |||
| 186 : | function showSection( $id, $gid, &$access ) { | ||
| 187 : | global $database, $mainframe, $mosConfig_offset, $Itemid; | ||
| 188 : | |||
| 189 : | $noauth = !$mainframe->getCfg( 'shownoauth' ); | ||
| 190 : | $now = date( 'Y-m-d H:i:s', time() + $mosConfig_offset * 60 * 60 ); | ||
| 191 : | // Paramters | ||
| 192 : | $params = new stdClass(); | ||
| 193 : | if ( $Itemid ) { | ||
| 194 : | $menu = new mosMenu( $database ); | ||
| 195 : | $menu->load( $Itemid ); | ||
| 196 : | $params =& new mosParameters( $menu->params ); | ||
| 197 : | } else { | ||
| 198 : | $menu = ""; | ||
| 199 : | alwarren | 1622 | $params =& new mosParameters( $menu->params ); |
| 200 : | alwarren | 1561 | |
| 201 : | } | ||
| 202 : | $orderby = $params->get( 'orderby', '' ); | ||
| 203 : | |||
| 204 : | $params->set( 'type', 'section' ); | ||
| 205 : | |||
| 206 : | $params->def( 'page_title', 1 ); | ||
| 207 : | $params->def( 'pageclass_sfx', '' ); | ||
| 208 : | $params->def( 'other_cat_section', 1 ); | ||
| 209 : | $params->def( 'other_cat', 1 ); | ||
| 210 : | $params->def( 'empty_cat', 0 ); | ||
| 211 : | $params->def( 'cat_items', 1 ); | ||
| 212 : | $params->def( 'cat_description', 1 ); | ||
| 213 : | $params->def( 'description', 1 ); | ||
| 214 : | $params->def( 'description-image', 1 ); | ||
| 215 : | $params->def( 'back_button', $mainframe->getCfg( 'back_button' ) ); | ||
| 216 : | $params->def( 'pageclass_sfx', '' ); | ||
| 217 : | |||
| 218 : | // Ordering control | ||
| 219 : | $orderby = _orderby_sec( $orderby ); | ||
| 220 : | |||
| 221 : | $section = new mosSection( $database ); | ||
| 222 : | $section->load( $id ); | ||
| 223 : | |||
| 224 : | if ( $access->canEdit ) { | ||
| 225 : | $xwhere = ''; | ||
| 226 : | $xwhere2 = "\n AND b.state >= '0'"; | ||
| 227 : | } else { | ||
| 228 : | $xwhere = "\n AND a.published = '1'"; | ||
| 229 : | $xwhere2 = "\n AND b.state = '1'" | ||
| 230 : | . "\n AND ( publish_up = '0000-00-00 00:00:00' OR publish_up <= '". $now ."' )" | ||
| 231 : | . "\n AND ( publish_down = '0000-00-00 00:00:00' OR publish_down >= '". $now ."' )" | ||
| 232 : | ; | ||
| 233 : | } | ||
| 234 : | |||
| 235 : | // show/hide empty categories | ||
| 236 : | if ( $params->get( 'empty_cat' ) ) { | ||
| 237 : | $empty = ''; | ||
| 238 : | } else { | ||
| 239 : | $empty = "\n HAVING COUNT( b.id ) > 0"; | ||
| 240 : | } | ||
| 241 : | |||
| 242 : | // Main Query | ||
| 243 : | $query = ' | ||
| 244 : | SELECT a.*, COUNT( b.id ) AS numitems | ||
| 245 : | FROM #__categories AS a | ||
| 246 : | LEFT JOIN #__content AS b ON b.catid = a.id '. $xwhere2 .' | ||
| 247 : | WHERE a.section = \'' . $section->id .'\' '. $xwhere; | ||
| 248 : | if ($noauth) { | ||
| 249 : | $query .= ' | ||
| 250 : | AND a.access <= '. $gid; | ||
| 251 : | } | ||
| 252 : | $query .= ' | ||
| 253 : | GROUP BY a.id | ||
| 254 : | ' . $empty . ' | ||
| 255 : | ORDER BY ' . $orderby; | ||
| 256 : | |||
| 257 : | $database->setQuery( $query ); | ||
| 258 : | $other_categories = $database->loadObjectList(); | ||
| 259 : | |||
| 260 : | // Dynamic Page Title | ||
| 261 : | $mainframe->SetPageTitle( $menu->name ); | ||
| 262 : | |||
| 263 : | HTML_content::showContentList( $section, NULL, $access, $id, NULL, $gid, $params, NULL, $other_categories, NULL ); | ||
| 264 : | } | ||
| 265 : | |||
| 266 : | |||
| 267 : | /** | ||
| 268 : | * @param int The category id | ||
| 269 : | * @param int The group id of the user | ||
| 270 : | * @param int The access level of the user | ||
| 271 : | * @param int The section id | ||
| 272 : | * @param int The number of items to dislpay | ||
| 273 : | * @param int The offset for pagination | ||
| 274 : | */ | ||
| 275 : | function showCategory( $id, $gid, &$access, $sectionid, $limit, $limitstart ) { | ||
| 276 : | global $database, $mainframe, $Itemid, $mosConfig_offset, $mosConfig_list_limit; | ||
| 277 : | |||
| 278 : | $noauth = !$mainframe->getCfg( 'shownoauth' ); | ||
| 279 : | $selected = mosGetParam( $_POST, 'order', '' ); | ||
| 280 : | $now = date( 'Y-m-d H:i:s', time() + $mosConfig_offset * 60 * 60 ); | ||
| 281 : | // Paramters | ||
| 282 : | $params = new stdClass(); | ||
| 283 : | if ( $Itemid ) { | ||
| 284 : | $menu = new mosMenu( $database ); | ||
| 285 : | $menu->load( $Itemid ); | ||
| 286 : | $params =& new mosParameters( $menu->params ); | ||
| 287 : | } else { | ||
| 288 : | $menu = ""; | ||
| 289 : | $params =& new mosParameters( '' ); | ||
| 290 : | } | ||
| 291 : | |||
| 292 : | if ( $selected ) { | ||
| 293 : | $orderby = $selected; | ||
| 294 : | } else { | ||
| 295 : | $orderby = $params->get( 'orderby', 'rdate' ); | ||
| 296 : | $selected = $orderby; | ||
| 297 : | } | ||
| 298 : | |||
| 299 : | $params->set( 'type', 'category' ); | ||
| 300 : | |||
| 301 : | $params->def( 'page_title', 1 ); | ||
| 302 : | $params->def( 'title', 1 ); | ||
| 303 : | $params->def( 'hits', $mainframe->getCfg( 'hits' ) ); | ||
| 304 : | $params->def( 'author', !$mainframe->getCfg( 'hideAuthor' ) ); | ||
| 305 : | $params->def( 'date', !$mainframe->getCfg( 'hideCreateDate' ) ); | ||
| 306 : | $params->def( 'date_format', _DATE_FORMAT_LC ); | ||
| 307 : | $params->def( 'navigation', 2 ); | ||
| 308 : | $params->def( 'display', 1 ); | ||
| 309 : | $params->def( 'display_num', $mosConfig_list_limit ); | ||
| 310 : | $params->def( 'other_cat', 1 ); | ||
| 311 : | $params->def( 'empty_cat', 0 ); | ||
| 312 : | $params->def( 'cat_items', 1 ); | ||
| 313 : | $params->def( 'cat_description', 0 ); | ||
| 314 : | $params->def( 'description', 1 ); | ||
| 315 : | $params->def( 'description-image', 1 ); | ||
| 316 : | $params->def( 'back_button', $mainframe->getCfg( 'back_button' ) ); | ||
| 317 : | $params->def( 'pageclass_sfx', '' ); | ||
| 318 : | $params->def( 'headings', 1 ); | ||
| 319 : | $params->def( 'order_select', 1 ); | ||
| 320 : | $params->def( 'filter', 1 ); | ||
| 321 : | $params->def( 'filter_type', 'title' ); | ||
| 322 : | |||
| 323 : | // Ordering control | ||
| 324 : | $orderby = _orderby_sec( $orderby ); | ||
| 325 : | |||
| 326 : | $category = new mosCategory( $database ); | ||
| 327 : | $category->load( $id ); | ||
| 328 : | |||
| 329 : | if ( $sectionid == 0 ) { | ||
| 330 : | $sectionid = $category->section; | ||
| 331 : | } | ||
| 332 : | |||
| 333 : | $pathway =& mosPathway::getInstance(); | ||
| 334 : | $pathway->addItem($category->title, categoryURL($sectionid, $id)); | ||
| 335 : | |||
| 336 : | if ( $access->canEdit ) { | ||
| 337 : | $xwhere = ''; | ||
| 338 : | $xwhere2 = "\n AND b.state >= '0'"; | ||
| 339 : | } else { | ||
| 340 : | $xwhere = "\n AND c.published='1'"; | ||
| 341 : | $xwhere2 = "\n AND b.state='1'" | ||
| 342 : | . "\n AND ( publish_up = '0000-00-00 00:00:00' OR publish_up <= '". $now ."' )" | ||
| 343 : | . "\n AND ( publish_down = '0000-00-00 00:00:00' OR publish_down >= '". $now ."' )" | ||
| 344 : | ; | ||
| 345 : | } | ||
| 346 : | |||
| 347 : | $pagetitle = ''; | ||
| 348 : | if ( $Itemid ) { | ||
| 349 : | $menu = new mosMenu( $database ); | ||
| 350 : | $menu->load( $Itemid ); | ||
| 351 : | $pagetitle = $menu->name; | ||
| 352 : | } // if | ||
| 353 : | |||
| 354 : | // show/hide empty categories | ||
| 355 : | $empty = ''; | ||
| 356 : | if ( !$params->get( 'empty_cat' ) ) | ||
| 357 : | $empty = "\n HAVING COUNT( b.id ) > 0"; | ||
| 358 : | |||
| 359 : | // get the list of other categories | ||
| 360 : | $query = "SELECT c.*, COUNT( b.id ) AS numitems" | ||
| 361 : | . "\n FROM #__categories AS c" | ||
| 362 : | . "\n LEFT JOIN #__content AS b ON b.catid = c.id " | ||
| 363 : | . $xwhere2 | ||
| 364 : | . ( $noauth ? "\n AND b.access <= '". $gid ."'" : '' ) | ||
| 365 : | . "\n WHERE c.section = '". $category->section. "'" | ||
| 366 : | . $xwhere | ||
| 367 : | . ( $noauth ? "\n AND c.access <= '". $gid ."'" : '' ) | ||
| 368 : | . "\n GROUP BY c.id" | ||
| 369 : | . $empty | ||
| 370 : | . "\n ORDER BY c.ordering" | ||
| 371 : | ; | ||
| 372 : | $database->setQuery( $query ); | ||
| 373 : | $other_categories = $database->loadObjectList(); | ||
| 374 : | |||
| 375 : | // get the total number of published items in the category | ||
| 376 : | // filter functionality | ||
| 377 : | $_and = ''; | ||
| 378 : | if ($filter = mosGetParam($_POST, 'filter', '')) { | ||
| 379 : | $filter = strtolower( $filter ); | ||
| 380 : | $filter = $database->getEscaped($filter); | ||
| 381 : | if ( $params->get( 'filter' ) ) { | ||
| 382 : | switch ( $params->get( 'filter_type' ) ) { | ||
| 383 : | case 'title': | ||
| 384 : | $_and = "\n AND LOWER( a.title ) LIKE '%". $filter ."%'"; | ||
| 385 : | break; | ||
| 386 : | case 'author': | ||
| 387 : | $_and = "\n AND ( ( LOWER( u.name ) LIKE '%". $filter ."%' ) OR ( LOWER( a.created_by_alias ) LIKE '%". $filter ."%' ) )"; | ||
| 388 : | break; | ||
| 389 : | case 'hits': | ||
| 390 : | $_and = "\n AND a.hits LIKE '%". $filter ."%'"; | ||
| 391 : | break; | ||
| 392 : | } | ||
| 393 : | } | ||
| 394 : | |||
| 395 : | } | ||
| 396 : | |||
| 397 : | if ( $access->canEdit ) { | ||
| 398 : | $xwhere = "\n AND a.state >= '0'"; | ||
| 399 : | } else { | ||
| 400 : | $xwhere = "\n AND a.state='1'" | ||
| 401 : | . "\n AND ( publish_up = '0000-00-00 00:00:00' OR publish_up <= '$now' )" | ||
| 402 : | . "\n AND ( publish_down = '0000-00-00 00:00:00' OR publish_down >= '$now' )" | ||
| 403 : | ; | ||
| 404 : | } | ||
| 405 : | |||
| 406 : | $query = "SELECT COUNT(a.id) as numitems" | ||
| 407 : | . "\n FROM #__content AS a" | ||
| 408 : | . "\n LEFT JOIN #__users AS u ON u.id = a.created_by" | ||
| 409 : | . "\n LEFT JOIN #__groups AS g ON a.access = g.id" | ||
| 410 : | . "\n WHERE a.catid='". $category->id ."' ". $xwhere | ||
| 411 : | . ( $noauth ? "\n AND a.access<='". $gid ."'" : '' ) | ||
| 412 : | . "\n AND '". $category->access ."'<='". $gid ."'" | ||
| 413 : | . $_and | ||
| 414 : | . "\n ORDER BY ". $orderby ."" | ||
| 415 : | ; | ||
| 416 : | $database->setQuery( $query ); | ||
| 417 : | $counter = $database->loadObjectList(); | ||
| 418 : | $total = $counter[0]->numitems; | ||
| 419 : | $limit = $limit ? $limit : $params->get( 'display_num' ) ; | ||
| 420 : | if ( $total <= $limit ) $limitstart = 0; | ||
| 421 : | |||
| 422 : | require_once( $GLOBALS['mosConfig_absolute_path'] . '/includes/pageNavigation.php' ); | ||
| 423 : | $pageNav = new mosPageNav( $total, $limitstart, $limit ); | ||
| 424 : | |||
| 425 : | // get the list of items for this category | ||
| 426 : | $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" | ||
| 427 : | . "\n FROM #__content AS a" | ||
| 428 : | . "\n LEFT JOIN #__users AS u ON u.id = a.created_by" | ||
| 429 : | . "\n LEFT JOIN #__groups AS g ON a.access = g.id" | ||
| 430 : | . "\n WHERE a.catid='". $category->id ."' ". $xwhere | ||
| 431 : | . ( $noauth ? "\n AND a.access<='". $gid ."'" : '' ) | ||
| 432 : | . "\n AND '". $category->access ."'<='". $gid ."'" | ||
| 433 : | . $_and | ||
| 434 : | . "\n ORDER BY ". $orderby ."" | ||
| 435 : | . "\n LIMIT ". $limitstart .", ". $limit | ||
| 436 : | ; | ||
| 437 : | $database->setQuery( $query ); | ||
| 438 : | $items = $database->loadObjectList(); | ||
| 439 : | |||
| 440 : | $check = 0; | ||
| 441 : | if ( $params->get( 'date' ) ) { | ||
| 442 : | $order[] = mosHTML::makeOption( 'date', T_('Date Asc') ); | ||
| 443 : | $order[] = mosHTML::makeOption( 'rdate', T_('Date Desc')); | ||
| 444 : | $check .= 1; | ||
| 445 : | } | ||
| 446 : | if ( $params->get( 'title' ) ) { | ||
| 447 : | $order[] = mosHTML::makeOption( 'alpha', T_('Title Asc') ); | ||
| 448 : | $order[] = mosHTML::makeOption( 'ralpha', T_('Title Desc') ); | ||
| 449 : | $check .= 1; | ||
| 450 : | } | ||
| 451 : | if ( $params->get( 'hits' ) ) { | ||
| 452 : | $order[] = mosHTML::makeOption( 'hits', T_('Hits Asc') ); | ||
| 453 : | $order[] = mosHTML::makeOption( 'rhits', T_('Hits Desc') ); | ||
| 454 : | $check .= 1; | ||
| 455 : | } | ||
| 456 : | if ( $params->get( 'author' ) ) { | ||
| 457 : | $order[] = mosHTML::makeOption( 'author', T_('Author Asc') ); | ||
| 458 : | $order[] = mosHTML::makeOption( 'rauthor', T_('Author Desc') ); | ||
| 459 : | $check .= 1; | ||
| 460 : | } | ||
| 461 : | $order[] = mosHTML::makeOption( 'order', T_('Ordering') ); | ||
| 462 : | $lists['order'] = mosHTML::selectList( $order, 'order', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'value', 'text', $selected ); | ||
| 463 : | if ( $check < 1 ) { | ||
| 464 : | $lists['order'] = ''; | ||
| 465 : | $params->set( 'order_select', 0 ); | ||
| 466 : | } | ||
| 467 : | |||
| 468 : | $lists['task'] = 'category'; | ||
| 469 : | $lists['filter'] = $filter; | ||
| 470 : | |||
| 471 : | // Dynamic Page Title | ||
| 472 : | $mainframe->SetPageTitle( $pagetitle ); | ||
| 473 : | |||
| 474 : | HTML_content::showContentList( $category, $items, $access, $id, $sectionid, $gid, $params, $pageNav, $other_categories, $lists ); | ||
| 475 : | } // showCategory | ||
| 476 : | |||
| 477 : | |||
| 478 : | function showBlogSection( $id=0, $gid, &$access, $pop ) { | ||
| 479 : | global $database, $mainframe, $mosConfig_offset, $Itemid, $option, $task; | ||
| 480 : | |||
| 481 : | $noauth = !$mainframe->getCfg( 'shownoauth' ); | ||
| 482 : | $now = date( 'Y-m-d H:i:s', time() + $mosConfig_offset * 60 * 60 ); | ||
| 483 : | // Parameters | ||
| 484 : | alwarren | 1625 | $pageTitle = ''; |
| 485 : | alwarren | 1561 | if ( $Itemid ) { |
| 486 : | $menu = new mosMenu( $database ); | ||
| 487 : | $menu->load( $Itemid ); | ||
| 488 : | if ( strpos(strtolower($menu->link), 'blogsection') === false ) { | ||
| 489 : | $menu = ''; | ||
| 490 : | } else { | ||
| 491 : | // only load params and set title if the menu item loaded is a blog section | ||
| 492 : | $pageTitle = $menu->name; | ||
| 493 : | $params =& new mosParameters( $menu->params ); | ||
| 494 : | } | ||
| 495 : | } | ||
| 496 : | |||
| 497 : | // no Itemid OR menu item loaded is not a blog section | ||
| 498 : | // try to find a blog entry in the menu database | ||
| 499 : | if (!$menu) { | ||
| 500 : | $database->setQuery("SELECT * FROM #__menu WHERE link LIKE '%blogsection%'"); | ||
| 501 : | $rows = $database->loadObjectList(); | ||
| 502 : | if (count($rows)) { | ||
| 503 : | $params =& new mosParameters( $rows[0]->params ); | ||
| 504 : | } | ||
| 505 : | } | ||
| 506 : | |||
| 507 : | // no menu item found and no params loaded so create a default params object | ||
| 508 : | alwarren | 1622 | if (!$params) $params =& new mosParameters( $menu->params ); |
| 509 : | alwarren | 1561 | |
| 510 : | // new blog multiple section handling | ||
| 511 : | if ( !$id ) { | ||
| 512 : | $id = $params->def( 'sectionid', 0 ); | ||
| 513 : | } | ||
| 514 : | |||
| 515 : | $where = _where( 1, $access, $noauth, $gid, $id, $now ); | ||
| 516 : | |||
| 517 : | // Ordering control | ||
| 518 : | $orderby_sec = $params->def( 'orderby_sec', 'rdate' ); | ||
| 519 : | $orderby_pri = $params->def( 'orderby_pri', '' ); | ||
| 520 : | $order_sec = _orderby_sec( $orderby_sec ); | ||
| 521 : | $order_pri = _orderby_pri( $orderby_pri ); | ||
| 522 : | |||
| 523 : | // Main data query | ||
| 524 : | $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" | ||
| 525 : | . "\n FROM #__content AS a" | ||
| 526 : | . "\n INNER JOIN #__categories AS cc ON cc.id = a.catid" | ||
| 527 : | . "\n LEFT JOIN #__users AS u ON u.id = a.created_by" | ||
| 528 : | . "\n LEFT JOIN #__content_rating AS v ON a.id = v.content_id" | ||
| 529 : | . "\n LEFT JOIN #__sections AS s ON a.sectionid = s.id" | ||
| 530 : | . "\n LEFT JOIN #__groups AS g ON a.access = g.id" | ||
| 531 : | . ( count( $where ) ? "\n WHERE ".implode( "\n AND ", $where ) : '' ) | ||
| 532 : | . "\n AND s.access<=$gid" | ||
| 533 : | . "\n ORDER BY ". $order_pri . $order_sec | ||
| 534 : | ; | ||
| 535 : | // $database->setQuery( $query ); | ||
| 536 : | // $rows = $database->loadObjectList(); | ||
| 537 : | $rows = $database->doSQLget($query, 'mosExtendedContent'); | ||
| 538 : | |||
| 539 : | // Dynamic Page Title | ||
| 540 : | // do we have multiple sections? | ||
| 541 : | $multiple_sections = false; | ||
| 542 : | if (count($rows)) { | ||
| 543 : | $temp = array(); | ||
| 544 : | foreach($rows as $row) { | ||
| 545 : | $temp[$row->section] = ''; | ||
| 546 : | } | ||
| 547 : | if (count($temp) > 1) { | ||
| 548 : | $multiple_sections = true; | ||
| 549 : | } | ||
| 550 : | unset($temp); | ||
| 551 : | } | ||
| 552 : | if (!$pageTitle) { | ||
| 553 : | // set the page title | ||
| 554 : | if ($rows[0]->section && !$multiple_sections){ | ||
| 555 : | $pageTitle = $rows[0]->section; | ||
| 556 : | } else { | ||
| 557 : | $pageTitle = T_('Blog'); | ||
| 558 : | } | ||
| 559 : | // fudge the pathway | ||
| 560 : | $mainframe->appendPathway($pageTitle); | ||
| 561 : | } | ||
| 562 : | $mainframe->setPageTitle( $pageTitle ); | ||
| 563 : | |||
| 564 : | // restore borrowed $row->section to null - IMPORTANT | ||
| 565 : | if (count($rows)) { | ||
| 566 : | for($i=0; $i<count($rows); $i++) $rows[$i]->section = ''; | ||
| 567 : | } | ||
| 568 : | |||
| 569 : | BlogOutput( $rows, $params, $gid, $access, $pop, $menu ); | ||
| 570 : | } | ||
| 571 : | |||
| 572 : | function showBlogCategory( $id=0, $gid, &$access, $pop ) { | ||
| 573 : | global $database, $mainframe, $mosConfig_offset, $Itemid; | ||
| 574 : | |||
| 575 : | $noauth = !$mainframe->getCfg( 'shownoauth' ); | ||
| 576 : | $now = date( 'Y-m-d H:i:s', time() + $mosConfig_offset * 60 * 60 ); | ||
| 577 : | // Paramters | ||
| 578 : | $params = new stdClass(); | ||
| 579 : | if ( $Itemid ) { | ||
| 580 : | $menu = new mosMenu( $database ); | ||
| 581 : | $menu->load( $Itemid ); | ||
| 582 : | $params =& new mosParameters( $menu->params ); | ||
| 583 : | } else { | ||
| 584 : | $menu = ""; | ||
| 585 : | $params =& new mosParameters( '' ); | ||
| 586 : | } | ||
| 587 : | |||
| 588 : | // new blog multiple section handling | ||
| 589 : | if ( !$id ) { | ||
| 590 : | $id = $params->def( 'categoryid', 0 ); | ||
| 591 : | } | ||
| 592 : | |||
| 593 : | $where = _where( 2, $access, $noauth, $gid, $id, $now ); | ||
| 594 : | |||
| 595 : | // Ordering control | ||
| 596 : | $orderby_sec = $params->def( 'orderby_sec', 'rdate' ); | ||
| 597 : | $orderby_pri = $params->def( 'orderby_pri', '' ); | ||
| 598 : | $order_sec = _orderby_sec( $orderby_sec ); | ||
| 599 : | $order_pri = _orderby_pri( $orderby_pri ); | ||
| 600 : | |||
| 601 : | // Main data query | ||
| 602 : | $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" | ||
| 603 : | . "\n FROM #__content AS a" | ||
| 604 : | . "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid" | ||
| 605 : | . "\n LEFT JOIN #__users AS u ON u.id = a.created_by" | ||
| 606 : | . "\n LEFT JOIN #__content_rating AS v ON a.id = v.content_id" | ||
| 607 : | . "\n LEFT JOIN #__sections AS s ON a.sectionid = s.id" | ||
| 608 : | . "\n LEFT JOIN #__groups AS g ON a.access = g.id" | ||
| 609 : | . ( count( $where ) ? "\n WHERE ".implode( "\n AND ", $where ) : '' ) | ||
| 610 : | . "\n AND s.access <= ". $gid | ||
| 611 : | . "\n ORDER BY ". $order_pri . $order_sec; | ||
| 612 : | ; | ||
| 613 : | // $database->setQuery( $query ); | ||
| 614 : | // $rows = $database->loadObjectList(); | ||
| 615 : | $rows = $database->doSQLget($query, 'mosExtendedContent'); | ||
| 616 : | |||
| 617 : | // Dynamic Page Title | ||
| 618 : | $mainframe->SetPageTitle( $menu->name ); | ||
| 619 : | |||
| 620 : | BlogOutput( $rows, $params, $gid, $access, $pop, $menu ); | ||
| 621 : | } | ||
| 622 : | |||
| 623 : | function showArchiveSection( $id=NULL, $gid, &$access, $pop, $option ) { | ||
| 624 : | global $database, $mainframe, $mosConfig_offset; | ||
| 625 : | global $Itemid; | ||
| 626 : | |||
| 627 : | $noauth = !$mainframe->getCfg( 'shownoauth' ); | ||
| 628 : | |||
| 629 : | // Parameters | ||
| 630 : | $year = mosGetParam( $_REQUEST, 'year', date( 'Y' ) ); | ||
| 631 : | $month = mosGetParam( $_REQUEST, 'month', date( 'm' ) ); | ||
| 632 : | |||
| 633 : | $params = new stdClass(); | ||
| 634 : | if ( $Itemid ) { | ||
| 635 : | $menu = new mosMenu( $database ); | ||
| 636 : | $menu->load( $Itemid ); | ||
| 637 : | $params =& new mosParameters( $menu->params ); | ||
| 638 : | } else { | ||
| 639 : | $menu = ""; | ||
| 640 : | $params =& new mosParameters( '' ); | ||
| 641 : | } | ||
| 642 : | |||
| 643 : | $params->set( 'intro_only', 1 ); | ||
| 644 : | $params->set( 'year', $year ); | ||
| 645 : | $params->set( 'month', $month ); | ||
| 646 : | |||
| 647 : | // Ordering control | ||
| 648 : | $orderby_sec = $params->def( 'orderby_sec', 'rdate' ); | ||
| 649 : | $orderby_pri = $params->def( 'orderby_pri', '' ); | ||
| 650 : | $order_sec = _orderby_sec( $orderby_sec ); | ||
| 651 : | $order_pri = _orderby_pri( $orderby_pri ); | ||
| 652 : | |||
| 653 : | // used in query | ||
| 654 : | $where = _where( -1, $access, $noauth, $gid, $id, NULL, $year, $month ); | ||
| 655 : | |||
| 656 : | // checks to see if 'All Sections' options used | ||
| 657 : | if ( $id == 0 ) { | ||
| 658 : | $check = ''; | ||
| 659 : | } else { | ||
| 660 : | $check = 'AND a.sectionid = '. $id ; | ||
| 661 : | } | ||
| 662 : | // query to determine if there are any archived entries for the section | ||
| 663 : | $query = "SELECT a.id" | ||
| 664 : | . "\n FROM #__content as a" | ||
| 665 : | . "\n WHERE a.state = '-1'" | ||
| 666 : | . $check | ||
| 667 : | ; | ||
| 668 : | $database->setQuery( $query ); | ||
| 669 : | $items = $database->loadObjectList(); | ||
| 670 : | $archives = count( $items ); | ||
| 671 : | |||
| 672 : | // Main Query | ||
| 673 : | $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" | ||
| 674 : | . "\n FROM #__content AS a" | ||
| 675 : | . "\n INNER JOIN #__categories AS cc ON cc.id = a.catid" | ||
| 676 : | . "\n LEFT JOIN #__users AS u ON u.id = a.created_by" | ||
| 677 : | . "\n LEFT JOIN #__content_rating AS v ON a.id = v.content_id" | ||
| 678 : | . "\n LEFT JOIN #__sections AS s ON a.sectionid = s.id" | ||
| 679 : | . "\n LEFT JOIN #__groups AS g ON a.access = g.id" | ||
| 680 : | . ( count( $where ) ? "\n WHERE ". implode( "\n AND ", $where ) : '') | ||
| 681 : | . "\n AND s.access <= ". $gid | ||
| 682 : | . "\n ORDER BY ". $order_pri . $order_sec | ||
| 683 : | ; | ||
| 684 : | // $database->setQuery( $query ); | ||
| 685 : | // $rows = $database->loadObjectList(); | ||
| 686 : | $rows = $database->doSQLget($query, 'mosExtendedContent'); | ||
| 687 : | |||
| 688 : | // initiate form | ||
| 689 : | echo '<form action="'.sefRelToAbs( 'index.php').'" method="post">'; | ||
| 690 : | |||
| 691 : | // Dynamic Page Title | ||
| 692 : | $mainframe->SetPageTitle( $menu->name ); | ||
| 693 : | |||
| 694 : | if ( !$archives ) { | ||
| 695 : | // if no archives for category, hides search and outputs empty message | ||
| 696 : | echo '<br /><div align="center">'. T_('There are currently no Archived Entries for this Category') .'</div>'; | ||
| 697 : | } else { | ||
| 698 : | BlogOutput( $rows, $params, $gid, $access, $pop, $menu, 1 ); | ||
| 699 : | } | ||
| 700 : | |||
| 701 : | echo '<input type="hidden" name="id" value="'. $id .'" />'; | ||
| 702 : | echo '<input type="hidden" name="Itemid" value="'. $Itemid .'" />'; | ||
| 703 : | echo '<input type="hidden" name="task" value="archivesection" />'; | ||
| 704 : | echo '<input type="hidden" name="option" value="com_content" />'; | ||
| 705 : | echo '<input type="hidden" name="module" value="1" />'; | ||
| 706 : | echo '</form>'; | ||
| 707 : | } | ||
| 708 : | |||
| 709 : | |||
| 710 : | function showArchiveCategory( $id=0, $gid, &$access, $pop, $option, $now ) { | ||
| 711 : | global $database, $mainframe, $mosConfig_offset; | ||
| 712 : | global $Itemid; | ||
| 713 : | |||
| 714 : | // Parameters | ||
| 715 : | $noauth = !$mainframe->getCfg( 'shownoauth' ); | ||
| 716 : | $year = mosGetParam( $_REQUEST, 'year', date( 'Y' ) ); | ||
| 717 : | $month = mosGetParam( $_REQUEST, 'month', date( 'm' ) ); | ||
| 718 : | $module = trim( mosGetParam( $_REQUEST, 'module', '' ) ); | ||
| 719 : | |||
| 720 : | // used by archive module | ||
| 721 : | if ( $module ) { | ||
| 722 : | $check = ''; | ||
| 723 : | } else { | ||
| 724 : | $check = 'AND a.catid = '. $id; | ||
| 725 : | } | ||
| 726 : | |||
| 727 : | if ( $Itemid ) { | ||
| 728 : | $menu = new mosMenu( $database ); | ||
| 729 : | $menu->load( $Itemid ); | ||
| 730 : | $params =& new mosParameters( $menu->params ); | ||
| 731 : | } else { | ||
| 732 : | $menu = ""; | ||
| 733 : | $params =& new mosParameters( '' ); | ||
| 734 : | } | ||
| 735 : | |||
| 736 : | $params->set( 'year', $year ); | ||
| 737 : | $params->set( 'month', $month ); | ||
| 738 : | |||
| 739 : | // Ordering control | ||
| 740 : | $orderby_sec = $params->def( 'orderby', 'rdate' ); | ||
| 741 : | $order_sec = _orderby_sec( $orderby_sec ); | ||
| 742 : | |||
| 743 : | // used in query | ||
| 744 : | $where = _where( -2, $access, $noauth, $gid, $id, NULL, $year, $month ); | ||
| 745 : | |||
| 746 : | // query to determine if there are any archived entries for the category | ||
| 747 : | $query = "SELECT a.id" | ||
| 748 : | . "\n FROM #__content as a" | ||
| 749 : | . "\n WHERE a.state = '-1'" | ||
| 750 : | . "\n ". $check | ||
| 751 : | ; | ||
| 752 : | $database->setQuery( $query ); | ||
| 753 : | $items = $database->loadObjectList(); | ||
| 754 : | $archives = count( $items ); | ||
| 755 : | |||
| 756 : | $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" | ||
| 757 : | . "\n FROM #__content AS a" | ||
| 758 : | . "\n LEFT JOIN #__users AS u ON u.id = a.created_by" | ||
| 759 : | . "\n LEFT JOIN #__content_rating AS v ON a.id = v.content_id" | ||
| 760 : | . "\n LEFT JOIN #__sections AS s ON a.sectionid = s.id" | ||
| 761 : | . "\n LEFT JOIN #__groups AS g ON a.access = g.id" | ||
| 762 : | . ( count( $where ) ? "\n WHERE ". implode( "\n AND ", $where ) : '' ) | ||
| 763 : | . "\n AND s.access <= ". $gid | ||
| 764 : | . "\n ORDER BY ". $order_sec | ||
| 765 : | ; | ||
| 766 : | // $database->setQuery( $query ); | ||
| 767 : | // $rows = $database->loadObjectList(); | ||
| 768 : | $rows = $database->doSQLget($query, 'mosExtendedContent'); | ||
| 769 : | |||
| 770 : | // initiate form | ||
| 771 : | echo '<form action="'.sefRelToAbs( 'index.php').'" method="post">'; | ||
| 772 : | |||
| 773 : | // Page Title | ||
| 774 : | $mainframe->SetPageTitle( $menu->name ); | ||
| 775 : | |||
| 776 : | if ( !$archives ) { | ||
| 777 : | // if no archives for category, hides search and outputs empty message | ||
| 778 : | echo '<br /><div align="center">'. T_('There are currently no Archived Entries for this Category') .'</div>'; | ||
| 779 : | } else { | ||
| 780 : | BlogOutput( $rows, $params, $gid, $access, $pop, $menu, 1 ); | ||
| 781 : | } | ||
| 782 : | |||
| 783 : | echo '<input type="hidden" name="id" value="'. $id .'" />'; | ||
| 784 : | echo '<input type="hidden" name="Itemid" value="'. $Itemid .'" />'; | ||
| 785 : | echo '<input type="hidden" name="task" value="archivecategory" />'; | ||
| 786 : | echo '<input type="hidden" name="option" value="com_content" />'; | ||
| 787 : | echo '<input type="hidden" name="module" value="1" />'; | ||
| 788 : | echo '</form>'; | ||
| 789 : | } | ||
| 790 : | |||
| 791 : | |||
| 792 : | function BlogOutput ( &$rows, &$params, $gid, &$access, $pop, &$menu, $archive=NULL ) { | ||
| 793 : | global $mainframe, $Itemid, $task, $id, $option, $database, $mosConfig_live_site; | ||
| 794 : | |||
| 795 : | // parameters | ||
| 796 : | if ( $params->get( 'page_title', 1 ) && $menu) { | ||
| 797 : | $header = $params->def( 'header', $menu->name ); | ||
| 798 : | } else { | ||
| 799 : | $header = ''; | ||
| 800 : | } | ||
| 801 : | $columns = $params->def( 'columns', 2 ); | ||
| 802 : | if ( $columns == 0 ) { | ||
| 803 : | $columns = 1; | ||
| 804 : | } | ||
| 805 : | $intro = $params->def( 'intro', 4 ); | ||
| 806 : | $leading = $params->def( 'leading', 1 ); | ||
| 807 : | $links = $params->def( 'link', 4 ); | ||
| 808 : | $pagination = $params->def( 'pagination', 2 ); | ||
| 809 : | $pagination_results = $params->def( 'pagination_results', 1 ); | ||
| 810 : | $pagination_results = $params->def( 'pagination_results', 1 ); | ||
| 811 : | $descrip = $params->def( 'description', 1 ); | ||
| 812 : | $descrip_image = $params->def( 'description_image', 1 ); | ||
| 813 : | // needed for back button for page | ||
| 814 : | $back = $params->get( 'back_button', $mainframe->getCfg( 'back_button' ) ); | ||
| 815 : | // needed to disable back button for item | ||
| 816 : | $params->set( 'back_button', 0 ); | ||
| 817 : | $params->def( 'pageclass_sfx', '' ); | ||
| 818 : | $params->set( 'intro_only', 1 ); | ||
| 819 : | |||
| 820 : | $total = count( $rows ); | ||
| 821 : | |||
| 822 : | // pagination support | ||
| 823 : | $limitstart = intval( mosGetParam( $_REQUEST, 'limitstart', 0 ) ); | ||
| 824 : | $limit = $intro + $leading + $links; | ||
| 825 : | if ( $total <= $limit ) { | ||
| 826 : | $limitstart = 0; | ||
| 827 : | } | ||
| 828 : | $i = $limitstart; | ||
| 829 : | |||
| 830 : | // needed to reduce queries used by getItemid | ||
| 831 : | require_once(mamboCore::get('mosConfig_absolute_path').'/components/com_content/content.class.php'); | ||
| 832 : | $handler =& new contentHandler(); | ||
| 833 : | $ItemidCount['bs'] = $handler->getBlogSectionCount(); | ||
| 834 : | $ItemidCount['bc'] = $handler->getBlogCategoryCount(); | ||
| 835 : | $ItemidCount['gbs'] = $handler->getGlobalBlogSectionCount(); | ||
| 836 : | |||
| 837 : | // used to display section/catagory description text and images | ||
| 838 : | // currently not supported in Archives | ||
| 839 : | if ( $menu && $menu->componentid && ( $descrip || $descrip_image ) ) { | ||
| 840 : | switch ( $menu->type ) { | ||
| 841 : | case 'content_blog_section': | ||
| 842 : | $description = new mosSection( $database ); | ||
| 843 : | $description->load( $menu->componentid ); | ||
| 844 : | break; | ||
| 845 : | |||
| 846 : | case 'content_blog_category': | ||
| 847 : | $description = new mosCategory( $database ); | ||
| 848 : | $description->load( $menu->componentid ); | ||
| 849 : | break; | ||
| 850 : | |||
| 851 : | default: | ||
| 852 : | $menu->componentid = 0; | ||
| 853 : | break; | ||
| 854 : | } | ||
| 855 : | } | ||
| 856 : | |||
| 857 : | // Page Output | ||
| 858 : | // page header | ||
| 859 : | if ( $header ) { | ||
| 860 : | echo '<div class="componentheading'. $params->get( 'pageclass_sfx' ) .'">'. $header .'</div>'; | ||
| 861 : | } | ||
| 862 : | |||
| 863 : | if ( $archive ) { | ||
| 864 : | echo '<br />'; | ||
| 865 : | echo mosHTML::monthSelectList( 'month', 'size="1" class="inputbox"', $params->get( 'month' ) ); | ||
| 866 : | echo mosHTML::integerSelectList( 2000, 2010, 1, 'year', 'size="1" class="inputbox"', $params->get( 'year' ), "%04d" ); | ||
| 867 : | echo '<input type="submit" class="button" />'; | ||
| 868 : | } | ||
| 869 : | |||
| 870 : | // checks to see if there are there any items to display | ||
| 871 : | if ( $total ) { | ||
| 872 : | $col_with = 100 / $columns; // width of each column | ||
| 873 : | $width = 'width="'. $col_with .'%"'; | ||
| 874 : | |||
| 875 : | if ( $archive ) { | ||
| 876 : | // Search Success message | ||
| 877 : | $msg = sprintf( T_('Here are the Archived entries for %s %s'), $params->get( 'month' ), $params->get( 'year' ) ); | ||
| 878 : | echo "<br /><br /><div align='center'>". $msg ."</div><br /><br />"; | ||
| 879 : | } | ||
| 880 : | echo '<table class="blog' . $params->get( 'pageclass_sfx' ) . '" cellpadding="0" cellspacing="0">'; | ||
| 881 : | |||
| 882 : | // Secrion/Category Description & Image | ||
| 883 : | if ( $menu && $menu->componentid && ( $descrip || $descrip_image ) ) { | ||
| 884 : | $link = $mosConfig_live_site .'/images/stories/'. $description->image; | ||
| 885 : | echo '<tr>'; | ||
| 886 : | echo '<td valign="top">'; | ||
| 887 : | if ( $descrip_image && $description->image ) { | ||
| 888 : | echo '<img src="'. $link .'" align="'. $description->image_position .'" hspace="6" alt="" />'; | ||
| 889 : | } | ||
| 890 : | if ( $descrip && $description->description ) { | ||
| 891 : | echo $description->description; | ||
| 892 : | } | ||
| 893 : | echo '<br /><br />'; | ||
| 894 : | echo '</td>'; | ||
| 895 : | echo '</tr>'; | ||
| 896 : | } | ||
| 897 : | |||
| 898 : | // Leading story output | ||
| 899 : | if ( $leading ) { | ||
| 900 : | echo '<tr>'; | ||
| 901 : | echo '<td valign="top">'; | ||
| 902 : | for ( $z = 0; $z < $leading; $z++ ) { | ||
| 903 : | if ( $i >= $total ) { | ||
| 904 : | // stops loop if total number of items is less than the number set to display as leading | ||
| 905 : | break; | ||
| 906 : | } | ||
| 907 : | echo '<div>'; | ||
| 908 : | show( $rows[$i], $params, $gid, $access, $pop, $option, $ItemidCount ); | ||
| 909 : | echo '</div>'; | ||
| 910 : | $i++; | ||
| 911 : | } | ||
| 912 : | echo '</td>'; | ||
| 913 : | echo '</tr>'; | ||
| 914 : | } | ||
| 915 : | |||
| 916 : | if ( $intro && ( $i < $total ) ) { | ||
| 917 : | echo '<tr>'; | ||
| 918 : | echo '<td valign="top">'; | ||
| 919 : | echo '<table width="100%" cellpadding="0" cellspacing="0">'; | ||
| 920 : | // intro story output | ||
| 921 : | for ( $z = 0; $z < $intro; $z++ ) { | ||
| 922 : | if ( $i >= $total ) { | ||
| 923 : | // stops loop if total number of items is less than the number set to display as intro + leading | ||
| 924 : | break; | ||
| 925 : | } | ||
| 926 : | |||
| 927 : | if ( !( $z % $columns ) || $columns == 1 ) { | ||
| 928 : | echo '<tr>'; | ||
| 929 : | } | ||
| 930 : | |||
| 931 : | echo '<td valign="top" '. $width .'>'; | ||
| 932 : | |||
| 933 : | // outputs either intro or only a link | ||
| 934 : | if ( $z < $intro ) { | ||
| 935 : | show( $rows[$i], $params, $gid, $access, $pop, $option, $ItemidCount ); | ||
| 936 : | } else { | ||
| 937 : | echo '</td>'; | ||
| 938 : | echo '</tr>'; | ||
| 939 : | break; | ||
| 940 : | } | ||
| 941 : | |||
| 942 : | echo '</td>'; | ||
| 943 : | |||
| 944 : | if ( !( ( $z + 1 ) % $columns ) || $columns == 1 ) { | ||
| 945 : | echo '</tr>'; | ||
| 946 : | } | ||
| 947 : | |||
| 948 : | $i++; | ||
| 949 : | } | ||
| 950 : | |||
| 951 : | // this is required to output a final closing </tr> tag when the number of items does not fully | ||
| 952 : | // fill the last row of output - a blank column is left | ||
| 953 : | if ( $intro % $columns ) { | ||
| 954 : | echo '</tr>'; | ||
| 955 : | } | ||
| 956 : | |||
| 957 : | echo '</table>'; | ||
| 958 : | echo '</td>'; | ||
| 959 : | echo '</tr>'; | ||
| 960 : | } | ||
| 961 : | |||
| 962 : | // Links output | ||
| 963 : | if ( $links && ( $i < $total ) ) { | ||
| 964 : | echo '<tr>'; | ||
| 965 : | echo '<td valign="top">'; | ||
| 966 : | echo '<div class="blog_more'. $params->get( 'pageclass_sfx' ) .'">'; | ||
| 967 : | HTML_content::showLinks( $rows, $links, $total, $i, 1, $ItemidCount ); | ||
| 968 : | echo '</div>'; | ||
| 969 : | echo '</td>'; | ||
| 970 : | echo '</tr>'; | ||
| 971 : | } | ||
| 972 : | |||
| 973 : | // Pagination output | ||
| 974 : | if ( $pagination ) { | ||
| 975 : | if ( ( $pagination == 2 ) && ( $total <= $limit ) ) { | ||
| 976 : | // not visible when they is no 'other' pages to display | ||
| 977 : | } else { | ||
| 978 : | // get the total number of records | ||
| 979 : | $limitstart = $limitstart ? $limitstart : 0; | ||
| 980 : | require_once( $GLOBALS['mosConfig_absolute_path'] . '/includes/pageNavigation.php' ); | ||
| 981 : | $pageNav = new mosPageNav( $total, $limitstart, $limit ); | ||
| 982 : | if ( $option == 'com_frontpage' ) { | ||
| 983 : | $link = 'index.php?option=com_frontpage&Itemid='. $Itemid; | ||
| 984 : | } else if ( $archive ) { | ||
| 985 : | $year = $params->get( 'year' ); | ||
| 986 : | $month = $params->get( 'month' ); | ||
| 987 : | $link = 'index.php?option=com_content&task='. $task .'&id='. $id .'&Itemid='. $Itemid.'&year='. $year .'&month='. $month; | ||
| 988 : | } else { | ||
| 989 : | $link = 'index.php?option=com_content&task='. $task .'&id='. $id .'&Itemid='. $Itemid; | ||
| 990 : | } | ||
| 991 : | echo '<tr>'; | ||
| 992 : | echo '<td valign="top" align="center">'; | ||
| 993 : | echo $pageNav->writePagesLinks( $link ); | ||
| 994 : | echo '<br /><br />'; | ||
| 995 : | echo '</td>'; | ||
| 996 : | echo '</tr>'; | ||
| 997 : | if ( $pagination_results ) { | ||
| 998 : | echo '<tr>'; | ||
| 999 : | echo '<td valign="top" align="center">'; | ||
| 1000 : | echo $pageNav->writePagesCounter(); | ||
| 1001 : | echo '</td>'; | ||
| 1002 : | echo '</tr>'; | ||
| 1003 : | } | ||
| 1004 : | } | ||
| 1005 : | } | ||
| 1006 : | |||
| 1007 : | echo '</table>'; | ||
| 1008 : | |||
| 1009 : | } else if ( $archive && !$total ) { | ||
| 1010 : | // Search Failure message for Archives | ||
| 1011 : | $msg = sprintf( T_('There are no Archived entries for %s %s'), $params->get( 'month' ), $params->get( 'year' ) ); | ||
| 1012 : | echo '<br /><br /><div align="center">'. $msg .'</div><br />'; | ||
| 1013 : | } else { | ||
| 1014 : | // Generic blog empty display | ||
| 1015 : | echo T_('There are no items to display'); | ||
| 1016 : | } | ||
| 1017 : | |||
| 1018 : | // Back Button | ||
| 1019 : | $params->set( 'back_button', $back ); | ||
| 1020 : | mosHTML::BackButton ( $params ); | ||
| 1021 : | } | ||
| 1022 : | |||
| 1023 : | |||
| 1024 : | function showItem( $uid, $gid, &$access, $pop, $option, $now ) { | ||
| 1025 : | global $database, $mainframe; | ||
| 1026 : | global $mosConfig_offset, $mosConfig_live_site, $mosConfig_MetaTitle, $mosConfig_MetaAuthor; | ||
| 1027 : | |||
| 1028 : | if ( $access->canEdit ) { | ||
| 1029 : | $xwhere=''; | ||
| 1030 : | } else { | ||
| 1031 : | $xwhere = "AND (a.state = '1' OR a.state = '-1')" | ||
| 1032 : | . "\n AND (publish_up = '0000-00-00 00:00:00' OR publish_up <= '$now')" | ||
| 1033 : | . "\n AND (publish_down = '0000-00-00 00:00:00' OR publish_down >= '$now')" | ||
| 1034 : | ; | ||
| 1035 : | } | ||
| 1036 : | |||
| 1037 : | global $acl; | ||
| 1038 : | $viewAccess = ($gid >= $acl->get_group_id( 'Registered', 'ARO' ) ? 1 : 0) + ($gid >= $acl->get_group_id( 'Author', 'ARO' ) ? 1 : 0); | ||
| 1039 : | $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" | ||
| 1040 : | . "\n FROM #__content AS a" | ||
| 1041 : | . "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid" | ||
| 1042 : | . "\n LEFT JOIN #__sections AS s ON s.id = cc.section AND s.scope='content'" | ||
| 1043 : | . "\n LEFT JOIN #__users AS u ON u.id = a.created_by" | ||
| 1044 : | . "\n LEFT JOIN #__content_rating AS v ON a.id = v.content_id" | ||
| 1045 : | . "\n LEFT JOIN #__groups AS g ON a.access = g.id" | ||
| 1046 : | . "\n WHERE a.id='". $uid ."' ". $xwhere | ||
| 1047 : | . "\n AND a.access <= ". $viewAccess | ||
| 1048 : | ; | ||
| 1049 : | $database->setQuery( $query ); | ||
| 1050 : | $row = new mosExtendedContent(); | ||
| 1051 : | |||
| 1052 : | if ( $database->loadObject( $row ) ) { | ||
| 1053 : | $pathway =& mosPathway::getInstance(); | ||
| 1054 : | $pathway->addItem($row->category, categoryURL($row->sectionid, $row->catid)); | ||
| 1055 : | $pathway->addItem($row->title, ''); | ||
| 1056 : | $params =& new mosParameters( $row->attribs ); | ||
| 1057 : | $params->set( 'intro_only', 0 ); | ||
| 1058 : | $params->def( 'back_button', $mainframe->getCfg( 'back_button' ) ); | ||
| 1059 : | if ( $row->sectionid == 0) { | ||
| 1060 : | $params->set( 'item_navigation', 0 ); | ||
| 1061 : | } else { | ||
| 1062 : | $params->set( 'item_navigation', $mainframe->getCfg( 'item_navigation' ) ); | ||
| 1063 : | } | ||
| 1064 : | // loads the links for Next & Previous Button | ||
| 1065 : | if ( $params->get( 'item_navigation' ) ) { | ||
| 1066 : | $query = "SELECT a.id" | ||
| 1067 : | . "\n FROM #__content AS a" | ||
| 1068 : | . "\n WHERE a.catid = ". $row->catid."" | ||
| 1069 : | . "\n AND a.state = $row->state AND ordering < $row->ordering" | ||
| 1070 : | . ($access->canEdit ? "" : "\n AND a.access <= '". $gid ."'" ) | ||
| 1071 : | . "\n AND ( a.publish_up = '0000-00-00 00:00:00' OR a.publish_up <= '". $now ."' )" | ||
| 1072 : | . "\n AND ( a.publish_down = '0000-00-00 00:00:00' OR a.publish_down >= '". $now ."' )" | ||
| 1073 : | . "\n ORDER BY a.ordering DESC" | ||
| 1074 : | . "\n LIMIT 1" | ||
| 1075 : | ; | ||
| 1076 : | $database->setQuery( $query ); | ||
| 1077 : | $row->prev = $database->loadResult(); | ||
| 1078 : | |||
| 1079 : | $query = "SELECT a.id" | ||
| 1080 : | . "\n FROM #__content AS a" | ||
| 1081 : | . "\n WHERE a.catid = ". $row->catid."" | ||
| 1082 : | . "\n AND a.state = $row->state AND ordering > $row->ordering" | ||
| 1083 : | . ($access->canEdit ? "" : "\n AND a.access <= '". $gid ."'" ) | ||
| 1084 : | . "\n AND ( a.publish_up = '0000-00-00 00:00:00' OR a.publish_up <= '". $now ."' )" | ||
| 1085 : | . "\n AND ( a.publish_down = '0000-00-00 00:00:00' OR a.publish_down >= '". $now ."' )" | ||
| 1086 : | . "\n ORDER BY a.ordering" | ||
| 1087 : | . "\n LIMIT 1" | ||
| 1088 : | ; | ||
| 1089 : | $database->setQuery( $query ); | ||
| 1090 : | $row->next = $database->loadResult(); | ||
| 1091 : | } | ||
| 1092 : | // page title | ||
| 1093 : | $mainframe->setPageTitle( $row->title ); | ||
| 1094 : | if ($mosConfig_MetaTitle=='1') { | ||
| 1095 : | $mainframe->addMetaTag( 'title' , $row->title ); | ||
| 1096 : | } | ||
| 1097 : | if ($mosConfig_MetaAuthor=='1') { | ||
| 1098 : | $mainframe->addMetaTag( 'author' , $row->author ); | ||
| 1099 : | } | ||
| 1100 : | |||
| 1101 : | show( $row, $params, $gid, $access, $pop, $option ); | ||
| 1102 : | } else { | ||
| 1103 : | mosNotAuth(); | ||
| 1104 : | return; | ||
| 1105 : | } | ||
| 1106 : | } | ||
| 1107 : | |||
| 1108 : | |||
| 1109 : | function show( $row, $params, $gid, &$access, $pop, $option, $ItemidCount=NULL ) { | ||
| 1110 : | global $database, $mainframe, $Itemid; | ||
| 1111 : | global $mosConfig_live_site, $mosConfig_absolute_path; | ||
| 1112 : | global $options, $cache; | ||
| 1113 : | |||
| 1114 : | $noauth = !$mainframe->getCfg( 'shownoauth' ); | ||
| 1115 : | |||
| 1116 : | if ( $access->canEdit ) { | ||
| 1117 : | if ( $row->id === null || $row->access > $gid ) { | ||
| 1118 : | mosNotAuth(); | ||
| 1119 : | return; | ||
| 1120 : | } | ||
| 1121 : | } else { | ||
| 1122 : | if ( $row->id === null || $row->state == 0 ) { | ||
| 1123 : | mosNotAuth(); | ||
| 1124 : | return; | ||
| 1125 : | } | ||
| 1126 : | if ( $row->access > $gid ) { | ||
| 1127 : | if ( $noauth ) { | ||
| 1128 : | mosNotAuth(); | ||
| 1129 : | return; | ||
| 1130 : | } else { | ||
| 1131 : | if ( !( $params->get( 'intro_only' ) ) ) { | ||
| 1132 : | mosNotAuth(); | ||
| 1133 : | return; | ||
| 1134 : | } | ||
| 1135 : | } | ||
| 1136 : | } | ||
| 1137 : | } | ||
| 1138 : | |||
| 1139 : | // GC Parameters | ||
| 1140 : | $params->def( 'link_titles', $mainframe->getCfg( 'link_titles' ) ); | ||
| 1141 : | $params->def( 'author', !$mainframe->getCfg( 'hideAuthor' ) ); | ||
| 1142 : | $params->def( 'createdate', !$mainframe->getCfg( 'hideCreateDate' ) ); | ||
| 1143 : | $params->def( 'modifydate', !$mainframe->getCfg( 'hideModifyDate' ) ); | ||
| 1144 : | $params->def( 'print', !$mainframe->getCfg( 'hidePrint' ) ); | ||
| 1145 : | $params->def( 'pdf', !$mainframe->getCfg( 'hidePdf' ) ); | ||
| 1146 : | $params->def( 'email', !$mainframe->getCfg( 'hideEmail' ) ); | ||
| 1147 : | $params->def( 'rating', $mainframe->getCfg( 'vote' ) ); | ||
| 1148 : | $params->def( 'icons', $mainframe->getCfg( 'icons' ) ); | ||
| 1149 : | $params->def( 'readmore', $mainframe->getCfg( 'readmore' ) ); | ||
| 1150 : | // Other Params | ||
| 1151 : | $params->def( 'image', 1 ); | ||
| 1152 : | $params->def( 'section', 0 ); | ||
| 1153 : | $params->def( 'section_link', 0 ); | ||
| 1154 : | $params->def( 'category', 0 ); | ||
| 1155 : | $params->def( 'category_link', 0 ); | ||
| 1156 : | $params->def( 'introtext', 1 ); | ||
| 1157 : | $params->def( 'pageclass_sfx', '' ); | ||
| 1158 : | $params->def( 'item_title', 1 ); | ||
| 1159 : | $params->def( 'url', 1 ); | ||
| 1160 : | |||
| 1161 : | // loads the link for Section name | ||
| 1162 : | if ( $params->get( 'section_link' ) ) { | ||
| 1163 : | $query = "SELECT a.id" | ||
| 1164 : | . "\n FROM #__menu AS a" | ||
| 1165 : | . "\n WHERE a.componentid = '". $row->sectionid."'" | ||
| 1166 : | . "\n AND a.type = 'content_section'" | ||
| 1167 : | . "\n AND a.published = 1" | ||
| 1168 : | ; | ||
| 1169 : | $database->setQuery( $query ); | ||
| 1170 : | $_Itemid = $database->loadResult(); | ||
| 1171 : | if (!intval($_Itemid)) | ||
| 1172 : | $_Itemid = intval($Itemid) ? intval($Itemid) : 1; | ||
| 1173 : | $link = sefRelToAbs( 'index.php?option=com_content&task=section&id='. $row->sectionid .'&Itemid='.$_Itemid ); | ||
| 1174 : | $row->section = '<a href="'. $link .'">'. $row->section .'</a>'; | ||
| 1175 : | } | ||
| 1176 : | |||
| 1177 : | // loads the link for Category name | ||
| 1178 : | if ( $params->get( 'category_link' ) ) { | ||
| 1179 : | $query = "SELECT a.id" | ||
| 1180 : | . "\n FROM #__menu AS a" | ||
| 1181 : | . "\n WHERE a.componentid = ". $row->catid."" | ||
| 1182 : | . "\n AND a.type = 'content_category'" | ||
| 1183 : | . "\n AND a.published = 1" | ||
| 1184 : | ; | ||
| 1185 : | $database->setQuery( $query ); | ||
| 1186 : | $_Itemid = $database->loadResult(); | ||
| 1187 : | if (!intval($_Itemid)) | ||
| 1188 : | $_Itemid = intval($Itemid) ? intval($Itemid) : 1; | ||
| 1189 : | $link = sefRelToAbs( 'index.php?option=com_content&task=section&id='. $row->sectionid .'&Itemid='.$_Itemid ); | ||
| 1190 : | $link = sefRelToAbs( 'index.php?option=com_content&task=category&sectionid='. $row->sectionid .'&id='. $row->catid .'&Itemid='.$_Itemid ); | ||
| 1191 : | $row->category = '<a href="'. $link .'">'. $row->category .'</a>'; | ||
| 1192 : | } | ||
| 1193 : | |||
| 1194 : | // loads current template for the pop-up window | ||
| 1195 : | $template = ''; | ||
| 1196 : | if ( $pop ) { | ||
| 1197 : | $params->set( 'popup', 1 ); | ||
| 1198 : | $database->setQuery( "SELECT template FROM #__templates_menu WHERE client_id='0' AND menuid='0'" ); | ||
| 1199 : | $template = $database->loadResult(); | ||
| 1200 : | } | ||
| 1201 : | |||
| 1202 : | // show/hides the intro text | ||
| 1203 : | if ( $params->get( 'introtext' ) ) { | ||
| 1204 : | $row->text = $row->introtext. ( $params->get( 'intro_only' ) ? '' : chr(13) . chr(13) . $row->fulltext); | ||
| 1205 : | } else { | ||
| 1206 : | $row->text = $row->fulltext; | ||
| 1207 : | } | ||
| 1208 : | |||
| 1209 : | // deal with the {mospagebreak} mambots | ||
| 1210 : | // only permitted in the full text area | ||
| 1211 : | $page = intval( mosGetParam( $_REQUEST, 'limitstart', 0 ) ); | ||
| 1212 : | |||
| 1213 : | // record the hit | ||
| 1214 : | if ( !$params->get( 'intro_only' ) ) { | ||
| 1215 : | $obj = new mosContent( $database ); | ||
| 1216 : | $obj->hit( $row->id ); | ||
| 1217 : | } | ||
| 1218 : | |||
| 1219 : | $cache->call( 'HTML_content::show', $row, $params, $access, $page, $option, $ItemidCount ); | ||
| 1220 : | } | ||
| 1221 : | |||
| 1222 : | |||
| 1223 : | function editItem( $uid, $gid, &$access, $sectionid=0, $task, $Itemid ){ | ||
| 1224 : | global $database, $mainframe, $my; | ||
| 1225 : | global $mosConfig_absolute_path, $mosConfig_live_site; | ||
| 1226 : | |||
| 1227 : | $row = new mosContent( $database ); | ||
| 1228 : | // load the row from the db table | ||
| 1229 : | $row->load( $uid ); | ||
| 1230 : | |||
| 1231 : | // fail if checked out not by 'me' | ||
| 1232 : | if ( $row->checked_out && $row->checked_out <> $my->id ) { | ||
| 1233 : | echo"<script>alert('".sprintf(T_('The module [ %s ] is currently being edited by another person.'), $row->title)."'); window.history.go(-1); </script>"; | ||
| 1234 : | exit; | ||
| 1235 : | } | ||
| 1236 : | |||
| 1237 : | if ( $uid ) { | ||
| 1238 : | // existing record | ||
| 1239 : | if ( !( $access->canEdit || ( $access->canEditOwn && $row->created_by == $my->id ) ) ) { | ||
| 1240 : | mosNotAuth(); | ||
| 1241 : | return; | ||
| 1242 : | } | ||
| 1243 : | } else { | ||
| 1244 : | // new record | ||
| 1245 : | if (!($access->canEdit || $access->canEditOwn)) { | ||
| 1246 : | mosNotAuth(); | ||
| 1247 : | return; | ||
| 1248 : | } | ||
| 1249 : | } | ||
| 1250 : | |||
| 1251 : | if ( $uid ) { | ||
| 1252 : | $sectionid = $row->sectionid; | ||
| 1253 : | } | ||
| 1254 : | |||
| 1255 : | $lists = array(); | ||
| 1256 : | |||
| 1257 : | // get the type name - which is a special category | ||
| 1258 : | $query = "SELECT name FROM #__sections WHERE id='$sectionid'"; | ||
| 1259 : | $database->setQuery( $query ); | ||
| 1260 : | $section = $database->loadResult(); | ||
| 1261 : | |||
| 1262 : | if ( $uid == 0 ) { | ||
| 1263 : | $row->catid = 0; | ||
| 1264 : | } | ||
| 1265 : | |||
| 1266 : | if ( $uid ) { | ||
| 1267 : | $row->checkout( $my->id ); | ||
| 1268 : | if (trim( $row->publish_down ) == "0000-00-00 00:00:00") { | ||
| 1269 : | $row->publish_down = 'Never'; | ||
| 1270 : | } | ||
| 1271 : | if (trim( $row->images )) { | ||
| 1272 : | $row->images = explode( "\n", $row->images ); | ||
| 1273 : | } else { | ||
| 1274 : | $row->images = array(); | ||
| 1275 : | } | ||
| 1276 : | $query = "SELECT name from #__users" | ||
| 1277 : | . "\n WHERE id = ". $row->created_by | ||
| 1278 : | ; | ||
| 1279 : | $database->setQuery( $query ); | ||
| 1280 : | $row->creator = $database->loadResult(); | ||
| 1281 : | |||
| 1282 : | $query = "SELECT name from #__users" | ||
| 1283 : | . "\n WHERE id = ". $row->modified_by | ||
| 1284 : | ; | ||
| 1285 : | $database->setQuery( $query ); | ||
| 1286 : | $row->modifier = $database->loadResult(); | ||
| 1287 : | |||
| 1288 : | $query = "SELECT content_id from #__content_frontpage" | ||
| 1289 : | ."\n WHERE content_id = ". $row->id | ||
| 1290 : | ; | ||
| 1291 : | $database->setQuery( $query ); | ||
| 1292 : | $row->frontpage = $database->loadResult(); | ||
| 1293 : | } else { | ||
| 1294 : | $row->sectionid = $sectionid; | ||
| 1295 : | $row->version = 0; | ||
| 1296 : | $row->state = 0; | ||
| 1297 : | $row->ordering = 0; | ||
| 1298 : | $row->images = array(); | ||
| 1299 : | $row->publish_up = date( 'Y-m-d', time() ); | ||
| 1300 : | $row->publish_down = 'Never'; | ||
| 1301 : | $row->creator = 0; | ||
| 1302 : | $row->modifier = 0; | ||
| 1303 : | $row->frontpage = 0; | ||
| 1304 : | } | ||
| 1305 : | |||
| 1306 : | // calls function to read image from directory | ||
| 1307 : | $pathA = $mosConfig_absolute_path .'/images/stories'; | ||
| 1308 : | $pathL = $mosConfig_live_site .'/images/stories'; | ||
| 1309 : | $images = array(); | ||
| 1310 : | $folders = array(); | ||
| 1311 : | $folders[] = mosHTML::makeOption( '/' ); | ||
| 1312 : | require_once($mosConfig_absolute_path.'/administrator/includes/mosAdminMenus.php'); | ||
| 1313 : | mosAdminMenus::ReadImages( $pathA, '/', $folders, $images ); | ||
| 1314 : | // list of folders in images/stories/ | ||
| 1315 : | $lists['folders'] = mosAdminMenus::GetImageFolders( $folders, $pathL ); | ||
| 1316 : | // list of images in specfic folder in images/stories/ | ||
| 1317 : | $lists['imagefiles'] = mosAdminMenus::GetImages( $images, $pathL ); | ||
| 1318 : | // list of saved images | ||
| 1319 : | $lists['imagelist'] = mosAdminMenus::GetSavedImages( $row, $pathL ); | ||
| 1320 : | |||
| 1321 : | // make the select list for the states | ||
| 1322 : | $states[] = mosHTML::makeOption( 0, T_('Unpublished') ); | ||
| 1323 : | $states[] = mosHTML::makeOption( 1, T_('Published') ); | ||
| 1324 : | $lists['state'] = mosHTML::selectList( $states, 'state', 'class="inputbox" size="1"', 'value', 'text', intval( $row->state ) ); | ||
| 1325 : | |||
| 1326 : | // build the html select list for ordering | ||
| 1327 : | $query = "SELECT ordering AS value, title AS text" | ||
| 1328 : | . "\n FROM #__content" | ||
| 1329 : | . "\n WHERE catid = '$row->catid'" | ||
| 1330 : | . "\n ORDER BY ordering" | ||
| 1331 : | ; | ||
| 1332 : | $lists['ordering'] = mosAdminMenus::SpecificOrdering( $row, $uid, $query, 1 ); | ||
| 1333 : | // build list of categories | ||
| 1334 : | $lists['catid'] = mosAdminMenus::ComponentCategory( 'catid', $sectionid, intval( $row->catid ) ); | ||
| 1335 : | // build the select list for the image positions | ||
| 1336 : | $lists['_align'] = mosAdminMenus::Positions( '_align' ); | ||
| 1337 : | ocs_cms | 1553 | // build the select list for the image caption alignment |
| 1338 : | $lists['_caption_align'] = mosAdminMenus::Positions( '_caption_align' ); | ||
| 1339 : | // build the html select list for the group access | ||
| 1340 : | $lists['access'] = mosAdminMenus::Access( $row ); | ||
| 1341 : | |||
| 1342 : | // build the select list for the image caption position | ||
| 1343 : | $pos[] = mosHTML::makeOption( 'bottom', _CMN_BOTTOM ); | ||
| 1344 : | $pos[] = mosHTML::makeOption( 'top', _CMN_TOP ); | ||
| 1345 : | $lists['_caption_position'] = mosHTML::selectList( $pos, '_caption_position', 'class="inputbox" size="1"', 'value', 'text' ); | ||
| 1346 : | alwarren | 1561 | |
| 1347 : | HTML_content::editContent( $row, $section, $lists, $images, $access, $my->id, $sectionid, $task, $Itemid ); | ||
| 1348 : | } | ||
| 1349 : | |||
| 1350 : | |||
| 1351 : | /** | ||
| 1352 : | * Saves the content item an edit form submit | ||
| 1353 : | */ | ||
| 1354 : | function saveContent( &$access ) { | ||
| 1355 : | global $database, $mainframe, $my; | ||
| 1356 : | global $mosConfig_absolute_path; | ||
| 1357 : | |||
| 1358 : | $row = new mosContent( $database ); | ||
| 1359 : | if ( !$row->bind( $_POST ) ) { | ||
| 1360 : | echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n"; | ||
| 1361 : | exit(); | ||
| 1362 : | } | ||
| 1363 : | // sanitize | ||
| 1364 : | $row->id = intval($row->id); | ||
| 1365 : | $row->catid = intval($row->catid); | ||
| 1366 : | $row->sectionid = intval($row->sectionid); | ||
| 1367 : | $isNew = $row->id < 1; | ||
| 1368 : | if ( $isNew ) { | ||
| 1369 : | // new record | ||
| 1370 : | if ( !( $access->canEdit || $access->canEditOwn ) ) { | ||
| 1371 : | mosNotAuth(); | ||
| 1372 : | return; | ||
| 1373 : | } | ||
| 1374 : | $row->created = date( 'Y-m-d H:i:s' ); | ||
| 1375 : | $row->created_by = $my->id; | ||
| 1376 : | } else { | ||
| 1377 : | // existing record | ||
| 1378 : | if ( !( $access->canEdit || ( $access->canEditOwn && $row->created_by == $my->id ) ) ) { | ||
| 1379 : | mosNotAuth(); | ||
| 1380 : | return; | ||
| 1381 : | } | ||
| 1382 : | $row->modified = date( 'Y-m-d H:i:s' ); | ||
| 1383 : | $row->modified_by = $my->id; | ||
| 1384 : | } | ||
| 1385 : | if ( trim( $row->publish_down ) == 'Never' ) { | ||
| 1386 : | $row->publish_down = '0000-00-00 00:00:00'; | ||
| 1387 : | } | ||
| 1388 : | |||
| 1389 : | if (!$row->check()) { | ||
| 1390 : | echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n"; | ||
| 1391 : | exit(); | ||
| 1392 : | } | ||
| 1393 : | $row->version++; | ||
| 1394 : | if (!$row->store()) { | ||
| 1395 : | echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n"; | ||
| 1396 : | exit(); | ||
| 1397 : | } | ||
| 1398 : | |||
| 1399 : | // manage frontpage items | ||
| 1400 : | require_once( $mainframe->getPath( 'class', 'com_frontpage' ) ); | ||
| 1401 : | $fp = new mosFrontPage( $database ); | ||
| 1402 : | |||
| 1403 : | if ( mosGetParam( $_REQUEST, 'frontpage', 0 ) ) { | ||
| 1404 : | |||
| 1405 : | // toggles go to first place | ||
| 1406 : | if (!$fp->load( $row->id )) { | ||
| 1407 : | // new entry | ||
| 1408 : | $database->setQuery( "INSERT INTO #__content_frontpage VALUES ('$row->id','1')" ); | ||
| 1409 : | if (!$database->query()) { | ||
| 1410 : | echo "<script> alert('".$database->stderr()."');</script>\n"; | ||
| 1411 : | exit(); | ||
| 1412 : | } | ||
| 1413 : | $fp->ordering = 1; | ||
| 1414 : | } | ||
| 1415 : | } else { | ||
| 1416 : | // no frontpage mask | ||
| 1417 : | if ( !$fp->delete( $row->id ) ) { | ||
| 1418 : | $msg .= $fp->stderr(); | ||
| 1419 : | } | ||
| 1420 : | $fp->ordering = 0; | ||
| 1421 : | } | ||
| 1422 : | $fp->updateOrder(); | ||
| 1423 : | |||
| 1424 : | $row->checkin(); | ||
| 1425 : | $row->updateOrder( "catid='$row->catid'" ); | ||
| 1426 : | |||
| 1427 : | // gets section name of item | ||
| 1428 : | $database->setQuery( "SELECT s.title" | ||
| 1429 : | . "\n FROM #__sections AS s" | ||
| 1430 : | . "\n WHERE s.scope = 'content'" | ||
| 1431 : | . "\n AND s.id = '". $row->sectionid ."'" | ||
| 1432 : | ); | ||
| 1433 : | // gets category name of item | ||
| 1434 : | $section = $database->loadResult(); | ||
| 1435 : | $database->setQuery( "SELECT c.title" | ||
| 1436 : | . "\n FROM #__categories AS c" | ||
| 1437 : | . "\n WHERE c.id = '". $row->catid ."'" | ||
| 1438 : | ); | ||
| 1439 : | $category = $database->loadResult(); | ||
| 1440 : | |||
| 1441 : | if ( $isNew ) { | ||
| 1442 : | // messaging for new items | ||
| 1443 : | require_once( $mosConfig_absolute_path .'/components/com_messages/messages.class.php' ); | ||
| 1444 : | $database->setQuery( "SELECT id FROM #__users WHERE sendEmail = '1'" ); | ||
| 1445 : | $users = $database->loadResultArray(); | ||
| 1446 : | if ($users) { | ||
| 1447 : | foreach ($users as $user_id) { | ||
| 1448 : | $msg = new mosMessage( $database ); | ||
| 1449 : | $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 ) ); | ||
| 1450 : | } | ||
| 1451 : | } | ||
| 1452 : | } | ||
| 1453 : | $Itemid = mosGetParam( $_POST, 'Returnid', '0' ); | ||
| 1454 : | $msg = $isNew ? T_('Thanks for your submission; it will be reviewed before being posted to the site.') : T_('Item saved successfully.'); | ||
| 1455 : | mosRedirect( 'index.php', $msg ); | ||
| 1456 : | } | ||
| 1457 : | |||
| 1458 : | |||
| 1459 : | /** | ||
| 1460 : | * Cancels an edit operation | ||
| 1461 : | * @param database A database connector object | ||
| 1462 : | */ | ||
| 1463 : | function cancelContent( &$access ) { | ||
| 1464 : | global $database, $mainframe, $my; | ||
| 1465 : | |||
| 1466 : | $row = new mosContent( $database ); | ||
| 1467 : | $row->bind( $_POST ); | ||
| 1468 : | // sanitize | ||
| 1469 : | $row->id = intval($row->id); | ||
| 1470 : | |||
| 1471 : | if ( $access->canEdit || ( $access->canEditOwn && $row->created_by == $my->id ) ) { | ||
| 1472 : | $row->checkin(); | ||
| 1473 : | } | ||
| 1474 : | |||
| 1475 : | $Itemid = mosGetParam( $_POST, 'Returnid', '0' ); | ||
| 1476 : | |||
| 1477 : | mosRedirect( 'index.php' ); | ||
| 1478 : | } | ||
| 1479 : | |||
| 1480 : | /** | ||
| 1481 : | * Shows the email form for a given content item. | ||
| 1482 : | */ | ||
| 1483 : | function emailContentForm( $uid ) { | ||
| 1484 : | global $database, $mainframe, $my; | ||
| 1485 : | $row = new mosContent( $database ); | ||
| 1486 : | $row->load( $uid ); | ||
| 1487 : | |||
| 1488 : | if ( $row->id === null || $row->access > $my->gid ) { | ||
| 1489 : | mosNotAuth(); | ||
| 1490 : | return; | ||
| 1491 : | } else { | ||
| 1492 : | $template=''; | ||
| 1493 : | $database->setQuery( "SELECT template FROM #__templates_menu WHERE client_id = '0' AND menuid = '0'" ); | ||
| 1494 : | $template = $database->loadResult(); | ||
| 1495 : | HTML_content::emailForm( $row->id, $row->title, $template ); | ||
| 1496 : | } | ||
| 1497 : | |||
| 1498 : | } | ||
| 1499 : | |||
| 1500 : | |||
| 1501 : | /** | ||
| 1502 : | * Shows the email form for a given content item. | ||
| 1503 : | */ | ||
| 1504 : | function emailContentSend( $uid ) { | ||
| 1505 : | global $database, $mainframe; | ||
| 1506 : | global $mosConfig_live_site, $mosConfig_sitename; | ||
| 1507 : | global $mosConfig_mailfrom, $mosConfig_fromname; | ||
| 1508 : | |||
| 1509 : | $_Itemid = $mainframe->getItemid( $uid, 0, 0 ); | ||
| 1510 : | |||
| 1511 : | $email = trim( mosGetParam( $_POST, 'email', '' ) ); | ||
| 1512 : | $yourname = trim( mosGetParam( $_POST, 'yourname', '' ) ); | ||
| 1513 : | $youremail = trim( mosGetParam( $_POST, 'youremail', '' ) ); | ||
| 1514 : | $subject_default = sprintf(T_('Item sent by %s'), $yourname); | ||
| 1515 : | $subject = trim( mosGetParam( $_POST, 'subject', $subject_default ) ); | ||
| 1516 : | |||
| 1517 : | mos_session_start(); | ||
| 1518 : | $form_check = mosGetParam( $_POST, 'form_check', '' ); | ||
| 1519 : | if (empty($_SESSION['_form_check_']['com_content']) || $form_check != $_SESSION['_form_check_']['com_content']) { | ||
| 1520 : | // the form hasn't been generated by the server on this session | ||
| 1521 : | exit; | ||
| 1522 : | } | ||
| 1523 : | if ( !$email || !$youremail || ( is_email( $email ) == false ) || ( is_email( $youremail ) == false ) ) { | ||
| 1524 : | echo "<script>alert (\"".T_('You must enter valid e-mail addresses for both yourself and your recipient.')."\"); window.history.go(-1);</script>"; | ||
| 1525 : | exit(0); | ||
| 1526 : | } | ||
| 1527 : | |||
| 1528 : | $template=''; | ||
| 1529 : | $database->setQuery( "SELECT template FROM #__templates_menu WHERE client_id='0' AND menuid='0'" ); | ||
| 1530 : | $template = $database->loadResult(); | ||
| 1531 : | |||
| 1532 : | // link sent in email | ||
| 1533 : | $link = sefRelToAbs( $mosConfig_live_site .'/index.php?option=com_content&task=view&id='. $uid .'&Itemid='. $_Itemid ); | ||
| 1534 : | // message text | ||
| 1535 : | $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 ); | ||
| 1536 : | |||
| 1537 : | // mail function | ||
| 1538 : | mosMail( $mosConfig_mailfrom, $mosConfig_fromname, $email, $subject, $msg ); | ||
| 1539 : | |||
| 1540 : | HTML_content::emailSent( $email, $template ); | ||
| 1541 : | } | ||
| 1542 : | |||
| 1543 : | function is_email( $email ){ | ||
| 1544 : | $rBool = false; | ||
| 1545 : | |||
| 1546 : | if ( preg_match( "/[\w\.\-]+@\w+[\w\.\-]*?\.\w{1,4}/", $email ) ) { | ||
| 1547 : | $rBool = true; | ||
| 1548 : | } | ||
| 1549 : | return $rBool; | ||
| 1550 : | } | ||
| 1551 : | |||
| 1552 : | function recordVote() { | ||
| 1553 : | global $database, $mosConfig_live_site, $mosConfig_offset; | ||
| 1554 : | |||
| 1555 : | $user_rating = mosGetParam( $_REQUEST, 'user_rating', 0 ); | ||
| 1556 : | $cid = mosGetParam( $_REQUEST, 'cid', 0 ); | ||
| 1557 : | $cid = intval( $cid ); | ||
| 1558 : | $Itemid = mosGetParam( $_REQUEST, 'Itemid', 0 ); | ||
| 1559 : | $Itemid = intval( $Itemid ); | ||
| 1560 : | $user_rating = intval( $user_rating ); | ||
| 1561 : | $now = date( 'Y-m-d H:i:s', time() + $mosConfig_offset * 60 * 60 ); | ||
| 1562 : | |||
| 1563 : | $url = sefReltoAbs("index.php?option=com_content&task=view&id={$cid}&Itemid={$Itemid}"); | ||
| 1564 : | if ( ( $user_rating >= 1 ) and ( $user_rating <= 5 ) ) { | ||
| 1565 : | $currip = getenv( 'REMOTE_ADDR' ); | ||
| 1566 : | |||
| 1567 : | $query = "SELECT * FROM #__content as c WHERE id = $cid AND (c.state = '1' OR c.state = '-1')" | ||
| 1568 : | . "\n AND (c.publish_up = '0000-00-00 00:00:00' OR c.publish_up <= '$now')" | ||
| 1569 : | . "\n AND (c.publish_down = '0000-00-00 00:00:00' OR c.publish_down >= '$now')" | ||
| 1570 : | ; | ||
| 1571 : | $database->setQuery( $query ); | ||
| 1572 : | $database->loadObject( $row ); | ||
| 1573 : | if ( $row != NULL){ | ||
| 1574 : | $query = "SELECT * FROM #__content_rating WHERE content_id = $cid"; | ||
| 1575 : | $database->setQuery( $query ); | ||
| 1576 : | $votesdb = NULL; | ||
| 1577 : | if ( !( $database->loadObject( $votesdb ) ) ) { | ||
| 1578 : | $query = "INSERT INTO #__content_rating ( content_id, lastip, rating_sum, rating_count )" | ||
| 1579 : | . "\n VALUES ( '$cid', '$currip', '$user_rating', '1' )"; | ||
| 1580 : | $database->setQuery( $query ); | ||
| 1581 : | $database->query() or die( $database->stderr() );; | ||
| 1582 : | } else { | ||
| 1583 : | if ($currip <> ($votesdb->lastip)) { | ||
| 1584 : | $query = "UPDATE #__content_rating" | ||
| 1585 : | . "\n SET rating_count = rating_count + 1," | ||
| 1586 : | . "\n rating_sum = rating_sum + $user_rating," | ||
| 1587 : | . "\n lastip = '$currip'" | ||
| 1588 : | . "\n WHERE content_id = ". $cid | ||
| 1589 : | ; | ||
| 1590 : | $database->setQuery( $query ); | ||
| 1591 : | $database->query() or die( $database->stderr() ); | ||
| 1592 : | } else { | ||
| 1593 : | mosRedirect ( $url, T_('You already voted for this poll today!') ); | ||
| 1594 : | } | ||
| 1595 : | } | ||
| 1596 : | mosRedirect ( $url, T_('Thanks for your vote!') ); | ||
| 1597 : | } else { | ||
| 1598 : | mosRedirect ( $url, T_('The rating for this item is not allowed!') ); | ||
| 1599 : | } | ||
| 1600 : | } | ||
| 1601 : | } | ||
| 1602 : | |||
| 1603 : | |||
| 1604 : | function _orderby_pri( $orderby ) { | ||
| 1605 : | switch ( $orderby ) { | ||
| 1606 : | case 'alpha': | ||
| 1607 : | $orderby = 'cc.title, '; | ||
| 1608 : | break; | ||
| 1609 : | case 'ralpha': | ||
| 1610 : | $orderby = 'cc.title DESC, '; | ||
| 1611 : | break; | ||
| 1612 : | case 'order': | ||
| 1613 : | $orderby = 'cc.ordering, '; | ||
| 1614 : | break; | ||
| 1615 : | default: | ||
| 1616 : | $orderby = ''; | ||
| 1617 : | break; | ||
| 1618 : | } | ||
| 1619 : | |||
| 1620 : | return $orderby; | ||
| 1621 : | } | ||
| 1622 : | |||
| 1623 : | |||
| 1624 : | function _orderby_sec( $orderby ) { | ||
| 1625 : | switch ( $orderby ) { | ||
| 1626 : | case 'date': | ||
| 1627 : | $orderby = 'a.created'; | ||
| 1628 : | break; | ||
| 1629 : | case 'rdate': | ||
| 1630 : | $orderby = 'a.created DESC'; | ||
| 1631 : | break; | ||
| 1632 : | case 'alpha': | ||
| 1633 : | $orderby = 'a.title'; | ||
| 1634 : | break; | ||
| 1635 : | case 'ralpha': | ||
| 1636 : | $orderby = 'a.title DESC'; | ||
| 1637 : | break; | ||
| 1638 : | case 'hits': | ||
| 1639 : | $orderby = 'a.hits DESC'; | ||
| 1640 : | break; | ||
| 1641 : | case 'rhits': | ||
| 1642 : | $orderby = 'a.hits ASC'; | ||
| 1643 : | break; | ||
| 1644 : | case 'order': | ||
| 1645 : | $orderby = 'a.ordering'; | ||
| 1646 : | break; | ||
| 1647 : | case 'author': | ||
| 1648 : | $orderby = 'a.created_by, u.name'; | ||
| 1649 : | break; | ||
| 1650 : | case 'rauthor': | ||
| 1651 : | $orderby = 'a.created_by DESC, u.name DESC'; | ||
| 1652 : | break; | ||
| 1653 : | case 'front': | ||
| 1654 : | $orderby = 'f.ordering'; | ||
| 1655 : | break; | ||
| 1656 : | default: | ||
| 1657 : | $orderby = 'a.ordering'; | ||
| 1658 : | break; | ||
| 1659 : | } | ||
| 1660 : | |||
| 1661 : | return $orderby; | ||
| 1662 : | } | ||
| 1663 : | |||
| 1664 : | /* | ||
| 1665 : | * @param int 0 = Archives, 1 = Section, 2 = Category | ||
| 1666 : | */ | ||
| 1667 : | function _where( $type=1, &$access, &$noauth, $gid, $id, $now=NULL, $year=NULL, $month=NULL ) { | ||
| 1668 : | $where = array(); | ||
| 1669 : | |||
| 1670 : | // normal | ||
| 1671 : | if ( $type > 0) { | ||
| 1672 : | $where[] = "a.state = '1'"; | ||
| 1673 : | if ( !$access->canEdit ) { | ||
| 1674 : | $where[] = "( a.publish_up = '0000-00-00 00:00:00' OR a.publish_up <= '". $now ."' )"; | ||
| 1675 : | $where[] = "( a.publish_down = '0000-00-00 00:00:00' OR a.publish_down >= '". $now ."' )"; | ||
| 1676 : | } | ||
| 1677 : | if ( $noauth ) { | ||
| 1678 : | $where[] = "a.access <= '". $gid ."'"; | ||
| 1679 : | } | ||
| 1680 : | if ( $id > 0 ) { | ||
| 1681 : | if ( $type == 1 ) { | ||
| 1682 : | $where[] = "a.sectionid IN ( ". $id ." ) "; | ||
| 1683 : | } else if ( $type == 2 ) { | ||
| 1684 : | $where[] = "a.catid IN ( ". $id ." ) "; | ||
| 1685 : | } | ||
| 1686 : | } | ||
| 1687 : | } | ||
| 1688 : | |||
| 1689 : | // archive | ||
| 1690 : | if ( $type < 0 ) { | ||
| 1691 : | $where[] = "a.state='-1'"; | ||
| 1692 : | if ( $year ) { | ||
| 1693 : | $where[] = "YEAR( a.created ) = '". $year ."'"; | ||
| 1694 : | } | ||
| 1695 : | if ( $month ) { | ||
| 1696 : | $where[] = "MONTH( a.created ) = '". $month ."'"; | ||
| 1697 : | } | ||
| 1698 : | if ( $noauth ) { | ||
| 1699 : | $where[] = "a.access <= '". $gid ."'"; | ||
| 1700 : | } | ||
| 1701 : | if ( $id > 0 ) { | ||
| 1702 : | if ( $type == -1 ) { | ||
| 1703 : | $where[] = "a.sectionid = '". $id ."'"; | ||
| 1704 : | } else if ( $type == -2) { | ||
| 1705 : | $where[] = "a.catid = '". $id ."'"; | ||
| 1706 : | } | ||
| 1707 : | } | ||
| 1708 : | } | ||
| 1709 : | |||
| 1710 : | return $where; | ||
| 1711 : | } | ||
| 1712 : | |||
| 1713 : | function sectionURL ($sectionid) { | ||
| 1714 : | global $Itemid; | ||
| 1715 : | return "index.php?option=com_content&task=section&id=$sectionid&Itemid=$Itemid"; | ||
| 1716 : | } | ||
| 1717 : | |||
| 1718 : | function categoryURL ($sectionid, $catid) { | ||
| 1719 : | global $Itemid; | ||
| 1720 : | return "index.php?option=com_content&task=category§ionid=$sectionid&id=$catid&Itemid=$Itemid"; | ||
| 1721 : | } | ||
| 1722 : | |||
| 1723 : | ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

