PageRenderTime 871ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 1ms

/components/com_content/content.php

https://bitbucket.org/dgough/annamaria-daneswood-25102012
PHP | 1539 lines | 1071 code | 228 blank | 240 comment | 195 complexity | bfde6f6cb5eaa5d3e57176234e2dc28f MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. /**
  3. * @version $Id: content.php 6019 2006-12-18 19:50:34Z friesengeist $
  4. * @package Joomla
  5. * @subpackage Content
  6. * @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
  7. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
  8. * Joomla! is free software. This version may have been modified pursuant
  9. * to the GNU General Public License, and as distributed it includes or
  10. * is derivative of works licensed under the GNU General Public License or
  11. * other free or open source software licenses.
  12. * See COPYRIGHT.php for copyright notices and details.
  13. */
  14. // no direct access
  15. defined( '_VALID_MOS' ) or die( 'Restricted access' );
  16. require_once( $mainframe->getPath( 'front_html', 'com_content' ) );
  17. $id = intval( mosGetParam( $_REQUEST, 'id', 0 ) );
  18. $sectionid = intval( mosGetParam( $_REQUEST, 'sectionid', 0 ) );
  19. $pop = intval( mosGetParam( $_REQUEST, 'pop', 0 ) );
  20. $limit = intval( mosGetParam( $_REQUEST, 'limit', 0 ) );
  21. $limitstart = intval( mosGetParam( $_REQUEST, 'limitstart', 0 ) );
  22. $year = intval( mosGetParam( $_REQUEST, 'year', date( 'Y' ) ) );
  23. $month = intval( mosGetParam( $_REQUEST, 'month', date( 'm' ) ) );
  24. $module = intval( mosGetParam( $_REQUEST, 'module', 0 ) );
  25. // Editor usertype check
  26. $access = new stdClass();
  27. $access->canEdit = $acl->acl_check( 'action', 'edit', 'users', $my->usertype, 'content', 'all' );
  28. $access->canEditOwn = $acl->acl_check( 'action', 'edit', 'users', $my->usertype, 'content', 'own' );
  29. $access->canPublish = $acl->acl_check( 'action', 'publish', 'users', $my->usertype, 'content', 'all' );
  30. // cache activation
  31. $cache =& mosCache::getCache( 'com_content' );
  32. // loads function for frontpage component
  33. if ( $option == 'com_frontpage' ) {
  34. $cache->call( 'frontpage', $gid, $access, $pop, 0, $limit, $limitstart );
  35. return;
  36. }
  37. switch ( $task ) {
  38. case 'findkey':
  39. findKeyItem( $gid, $access, $pop, $option, 0 );
  40. break;
  41. case 'view':
  42. if ($mosConfig_enable_stats) {
  43. showItem( $id, $gid, $access, $pop, $option, 0 );
  44. } else {
  45. $cache->call( 'showItem', $id, $gid, $access, $pop, $option, 0, $limit, $limitstart );
  46. }
  47. break;
  48. case 'section':
  49. $cache->call( 'showSection', $id, $gid, $access, 0 );
  50. break;
  51. case 'category':
  52. $selected = strval( mosGetParam( $_REQUEST, 'order', '' ) );
  53. $filter = stripslashes( strval( mosGetParam( $_REQUEST, 'filter', '' ) ) );
  54. $cache->call( 'showCategory', $id, $gid, $access, $sectionid, $limit, NULL, $limitstart, 0, $selected, $filter );
  55. break;
  56. case 'blogsection':
  57. // Itemid is a dummy value to cater for caching
  58. $cache->call('showBlogSection', $id, $gid, $access, $pop, $Itemid, $limit, $limitstart );
  59. break;
  60. case 'blogcategorymulti':
  61. case 'blogcategory':
  62. // Itemid is a dummy value to cater for caching
  63. $cache->call( 'showBlogCategory', $id, $gid, $access, $pop, $Itemid, $limit, $limitstart );
  64. break;
  65. case 'archivesection':
  66. // Itemid is a dummy value to cater for caching
  67. $cache->call( 'showArchiveSection', $id, $gid, $access, $pop, $option, $year, $month, $limit, $limitstart, $Itemid );
  68. break;
  69. case 'archivecategory':
  70. // Itemid is a dummy value to cater for caching
  71. $cache->call( 'showArchiveCategory', $id, $gid, $access, $pop, $option, $year, $month, $module, $limit, $limitstart, $Itemid );
  72. break;
  73. case 'edit':
  74. editItem( $id, $gid, $access, 0, $task, $Itemid );
  75. break;
  76. case 'new':
  77. editItem( 0, $gid, $access, $sectionid, $task, $Itemid );
  78. break;
  79. case 'save':
  80. case 'apply':
  81. case 'apply_new':
  82. mosCache::cleanCache( 'com_content' );
  83. saveContent( $access, $task );
  84. break;
  85. case 'cancel':
  86. cancelContent( $access );
  87. break;
  88. case 'emailform':
  89. emailContentForm( $id, $gid );
  90. // ------------------------ A8E fix ------------------------
  91. if(basename($_SERVER['PHP_SELF']) == 'index.php') showItem( $id, $gid, $access, $pop, $option, $now );
  92. break;
  93. case 'emailsend':
  94. emailContentSend( $id, $gid );
  95. // ------------------------ A8E fix ------------------------
  96. if(basename($_SERVER['PHP_SELF']) == 'index.php') showItem( $id, $gid, $access, $pop, $option, $now );
  97. break;
  98. case 'vote':
  99. recordVote ();
  100. break;
  101. default:
  102. header("HTTP/1.0 404 Not Found");
  103. echo _NOT_EXIST;
  104. break;
  105. }
  106. /**
  107. * Searches for an item by a key parameter
  108. * @param int The user access level
  109. * @param object Actions this user can perform
  110. * @param int
  111. * @param string The url option
  112. * @param string A timestamp
  113. */
  114. function findKeyItem( $gid, $access, $pop, $option, $now ) {
  115. global $database;
  116. $keyref = stripslashes( strval( mosGetParam( $_REQUEST, 'keyref', '' ) ) );
  117. $query = "SELECT id"
  118. . "\n FROM #__content"
  119. . "\n WHERE attribs LIKE '%keyref=" . $database->getEscaped( $keyref ) . "%'"
  120. ;
  121. $database->setQuery( $query );
  122. $id = $database->loadResult();
  123. if ($id > 0) {
  124. showItem( $id, $gid, $access, $pop, $option, 0 );
  125. } else {
  126. echo _KEY_NOT_FOUND;
  127. }
  128. }
  129. function frontpage( $gid, &$access, $pop, $now, $limit, $limitstart ) {
  130. global $database, $mainframe;
  131. $now = _CURRENT_SERVER_TIME;
  132. $nullDate = $database->getNullDate();
  133. $noauth = !$mainframe->getCfg( 'shownoauth' );
  134. // Parameters
  135. $menu = $mainframe->get( 'menu' );
  136. $params = new mosParameters( $menu->params );
  137. // Ordering control
  138. $orderby_sec = $params->def( 'orderby_sec', '' );
  139. $orderby_pri = $params->def( 'orderby_pri', '' );
  140. $order_sec = _orderby_sec( $orderby_sec );
  141. $order_pri = _orderby_pri( $orderby_pri );
  142. // voting control
  143. $voting = $params->def( 'rating', '' );
  144. $voting = votingQuery($voting);
  145. $where = _where( 1, $access, $noauth, $gid, 0, $now, NULL, NULL, $params );
  146. //Cater for static content
  147. $static = array('a.sectionid = 0');
  148. foreach(_where( 1, $access, $noauth, $gid, 0, $now, NULL, NULL, $params ) as $x){
  149. $exclude = array("s.published = 1","cc.published = 1", "s.access <= " . (int) $gid, "cc.access <= " . (int) $gid);
  150. if(!in_array($x, $exclude)){
  151. $static[] = $x;
  152. }
  153. }
  154. $where = ( count( $where ) ? "\n WHERE (". implode( "\n AND ", $where ).') OR ('.implode("\n AND ", $static).') ' : '' );
  155. // Limit & limitstart
  156. $intro = $params->def( 'intro', $GLOBALS['mosConfig_blog_intro'] );
  157. $leading = $params->def( 'leading', $GLOBALS['mosConfig_blog_leading'] );
  158. $links = $params->def( 'link', $GLOBALS['mosConfig_blog_links'] );
  159. $limit = $intro + $leading + $links;
  160. // query to determine total number of records
  161. $query = "SELECT COUNT(a.id)"
  162. . "\n FROM #__content AS a"
  163. . "\n INNER JOIN #__content_frontpage AS f ON f.content_id = a.id"
  164. . "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid"
  165. . "\n LEFT JOIN #__sections AS s ON s.id = a.sectionid"
  166. . "\n LEFT JOIN #__users AS u ON u.id = a.created_by"
  167. . "\n LEFT JOIN #__groups AS g ON a.access = g.id"
  168. . $where
  169. ;
  170. $database->setQuery( $query );
  171. $total = $database->loadResult();
  172. if ( $total <= $limit ) {
  173. $limitstart = 0;
  174. }
  175. // query records
  176. $query = "SELECT a.id, a.title, a.title_alias, a.introtext, a.sectionid, a.state, a.catid, a.created, a.created_by, a.created_by_alias, a.modified, a.modified_by,"
  177. . "\n a.checked_out, a.checked_out_time, a.publish_up, a.publish_down, a.images, a.urls, a.ordering, a.metakey, a.metadesc, a.access, a.hits,"
  178. . "\n CHAR_LENGTH( a.fulltext ) AS readmore, u.name AS author, u.usertype, s.name AS section, cc.name AS category, g.name AS groups"
  179. . "\n, s.id AS sec_id, cc.id as cat_id"
  180. . $voting['select']
  181. . "\n FROM #__content AS a"
  182. . "\n INNER JOIN #__content_frontpage AS f ON f.content_id = a.id"
  183. . "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid"
  184. . "\n LEFT JOIN #__sections AS s ON s.id = a.sectionid"
  185. . "\n LEFT JOIN #__users AS u ON u.id = a.created_by"
  186. . "\n LEFT JOIN #__groups AS g ON a.access = g.id"
  187. . $voting['join']
  188. . $where
  189. . "\n ORDER BY $order_pri $order_sec"
  190. ;
  191. $database->setQuery( $query, $limitstart, $limit );
  192. $rows = $database->loadObjectList();
  193. // Dynamic Page Title
  194. $mainframe->SetPageTitle( $menu->name );
  195. $mainframe->addMetaTag( 'description', $params->get('metadesc','') );
  196. $mainframe->addMetaTag( 'keywords', $params->get('metakey','') );
  197. BlogOutput( $rows, $params, $gid, $access, $pop, $menu, $limitstart, $limit, $total );
  198. }
  199. function showSection( $id, $gid, &$access, $now ) {
  200. global $database, $mainframe, $Itemid;
  201. $section = new mosSection( $database );
  202. $section->load( (int)$id );
  203. /*
  204. Check if section is published
  205. */
  206. if(!$section->published) {
  207. mosNotAuth();
  208. return;
  209. }
  210. /*
  211. * check whether section access level allows access
  212. */
  213. if( $section->access > $gid ) {
  214. mosNotAuth();
  215. return;
  216. }
  217. $now = _CURRENT_SERVER_TIME;
  218. $nullDate = $database->getNullDate();
  219. $noauth = !$mainframe->getCfg( 'shownoauth' );
  220. // Paramters
  221. $params = new stdClass();
  222. if ( $Itemid ) {
  223. $menu = $mainframe->get( 'menu' );
  224. $params = new mosParameters( $menu->params );
  225. } else {
  226. $menu = '';
  227. $params = new mosEmpty();
  228. }
  229. $orderby = $params->get( 'orderby', '' );
  230. $params->set( 'type', 'section' );
  231. $params->def( 'page_title', 1 );
  232. $params->def( 'pageclass_sfx', '' );
  233. $params->def( 'description_sec', 1 );
  234. $params->def( 'description_sec_image', 1 );
  235. $params->def( 'other_cat_section', 1 );
  236. $params->def( 'empty_cat_section', 0 );
  237. $params->def( 'other_cat', 1 );
  238. $params->def( 'empty_cat', 0 );
  239. $params->def( 'cat_items', 1 );
  240. $params->def( 'cat_description', 1 );
  241. $params->def( 'back_button', $mainframe->getCfg( 'back_button' ) );
  242. $params->def( 'pageclass_sfx', '' );
  243. // param controls whether unpublished items visible to publishers and above
  244. $params->def( 'unpublished', 1 );
  245. // Ordering control
  246. $orderby = _orderby_sec( $orderby );
  247. // Description & Description Image control
  248. $params->def( 'description', $params->get( 'description_sec' ) );
  249. $params->def( 'description_image', $params->get( 'description_sec_image' ) );
  250. if ( $access->canEdit ) {
  251. $xwhere = '';
  252. if ( $params->get( 'unpublished' ) ) {
  253. // shows unpublished items for publishers and above
  254. $xwhere2 = "\n AND (b.state >= 0 or b.state is null)";
  255. } else {
  256. // unpublished items NOT shown for publishers and above
  257. $xwhere2 = "\n AND (b.state = 1 or b.state is null)";
  258. }
  259. } else {
  260. $xwhere = "\n AND a.published = 1";
  261. $xwhere2 = "\n AND b.state = 1"
  262. . "\n AND ( b.publish_up = " . $database->Quote( $nullDate ) . " OR b.publish_up <= " . $database->Quote( $now ) . " )"
  263. . "\n AND ( b.publish_down = " . $database->Quote( $nullDate ) . " OR b.publish_down >= " . $database->Quote( $now ) . " )"
  264. ;
  265. }
  266. $empty = '';
  267. $empty_sec = '';
  268. if ( $params->get( 'type' ) == 'category' ) {
  269. // show/hide empty categories
  270. if ( !$params->get( 'empty_cat' ) ) {
  271. $empty = "\n HAVING numitems > 0";
  272. }
  273. }
  274. if ( $params->get( 'type' ) == 'section' ) {
  275. // show/hide empty categories in section
  276. if ( !$params->get( 'empty_cat_section' ) ) {
  277. $empty_sec = "\n HAVING numitems > 0";
  278. }
  279. }
  280. $access_check = '';
  281. $access_check_content = '';
  282. if ($noauth) {
  283. $access_check = "\n AND a.access <= " . (int) $gid;
  284. $access_check_content = "\n AND b.access <= " . (int) $gid;
  285. }
  286. // Query of categories within section
  287. $query = "SELECT a.*, COUNT( b.id ) AS numitems"
  288. . "\n FROM #__categories AS a"
  289. . "\n LEFT JOIN #__content AS b ON b.catid = a.id"
  290. . $xwhere2
  291. . "\n WHERE a.section = '" . (int) $section->id . "'"
  292. . $xwhere
  293. . $access_check
  294. . $access_check_content
  295. . "\n GROUP BY a.id"
  296. . $empty
  297. . $empty_sec
  298. . "\n ORDER BY $orderby"
  299. ;
  300. $database->setQuery( $query );
  301. $categories = $database->loadObjectList();
  302. // If categories exist, the "new content" icon may be displayed
  303. $categories_exist = false;
  304. if ( $access->canEdit ) {
  305. $query = "SELECT count(*) as numCategories"
  306. . "\n FROM #__categories as a"
  307. . "\n WHERE a.section = '" . (int) $section->id . "'"
  308. . $access_check;
  309. $database->setQuery ( $query );
  310. $categories_exist = ($database->loadResult()) > 0;
  311. }
  312. // remove slashes
  313. $section->name = stripslashes($section->name);
  314. // Dynamic Page Title
  315. $mainframe->SetPageTitle( $menu->name );
  316. $null = null;
  317. HTML_content::showContentList( $section, $null, $access, $id, $null, $gid, $params, $null, $categories, $null, $null, $categories_exist );
  318. }
  319. /**
  320. * @param int The category id
  321. * @param int The group id of the user
  322. * @param int The access level of the user
  323. * @param int The section id
  324. * @param int The number of items to dislpay
  325. * @param int The offset for pagination
  326. */
  327. function showCategory( $id, $gid, &$access, $sectionid, $limit, $selected, $limitstart, $now, $selected, $filter ) {
  328. global $database, $mainframe, $Itemid, $mosConfig_list_limit;
  329. $category = new mosCategory( $database );
  330. $category->load( (int)$id );
  331. /*
  332. Check if category is published
  333. */
  334. if(!$category->published) {
  335. mosNotAuth();
  336. return;
  337. }
  338. /*
  339. * check whether category access level allows access
  340. */
  341. if( $category->access > $gid ) {
  342. mosNotAuth();
  343. return;
  344. }
  345. $section = new mosSection( $database );
  346. $section->load( $category->section );
  347. /*
  348. Check if category is published
  349. */
  350. if(!$section->published) {
  351. mosNotAuth();
  352. return;
  353. }
  354. /*
  355. * check whether section access level allows access
  356. */
  357. if( $section->access > $gid ) {
  358. mosNotAuth();
  359. return;
  360. }
  361. $now = _CURRENT_SERVER_TIME;
  362. $nullDate = $database->getNullDate();
  363. $noauth = !$mainframe->getCfg( 'shownoauth' );
  364. // Paramters
  365. $params = new stdClass();
  366. if ( $Itemid ) {
  367. $menu = $mainframe->get( 'menu' );
  368. $params = new mosParameters( $menu->params );
  369. } else {
  370. $menu = '';
  371. $params = new mosParameters( '' );
  372. }
  373. $lists['order_value'] = '';
  374. if ( $selected ) {
  375. $orderby = $selected;
  376. $lists['order_value'] = $selected;
  377. } else {
  378. $orderby = $params->get( 'orderby', 'rdate' );
  379. $selected = $orderby;
  380. }
  381. $params->set( 'type', 'category' );
  382. $params->def( 'description_cat', 1 );
  383. $params->def( 'description_cat_image', 1 );
  384. $params->def( 'page_title', 1 );
  385. $params->def( 'title', 1 );
  386. $params->def( 'hits', $mainframe->getCfg( 'hits' ) );
  387. $params->def( 'author', !$mainframe->getCfg( 'hideAuthor' ) );
  388. $params->def( 'date', !$mainframe->getCfg( 'hideCreateDate' ) );
  389. $params->def( 'date_format', _DATE_FORMAT_LC );
  390. $params->def( 'navigation', 2 );
  391. $params->def( 'display', 0 );
  392. $params->def( 'display_num', $mosConfig_list_limit );
  393. $params->def( 'other_cat', 0 );
  394. $params->def( 'empty_cat', 0 );
  395. $params->def( 'cat_items', 1 );
  396. $params->def( 'cat_description', 0 );
  397. $params->def( 'back_button', $mainframe->getCfg( 'back_button' ) );
  398. $params->def( 'pageclass_sfx', '' );
  399. $params->def( 'headings', 1 );
  400. $params->def( 'order_select', 0 );
  401. $params->def( 'filter', 0 );
  402. $params->def( 'filter_type', 'title' );
  403. // param controls whether unpublished items visible to publishers and above
  404. $params->def( 'unpublished', 1 );
  405. // Ordering control
  406. $orderby = _orderby_sec( $orderby );
  407. // Description & Description Image control
  408. $params->def( 'description', $params->get( 'description_cat' ) );
  409. $params->def( 'description_image', $params->get( 'description_cat_image' ) );
  410. if ( $sectionid == 0 ) {
  411. $sectionid = $category->section;
  412. }
  413. if ( $access->canEdit ) {
  414. $xwhere = '';
  415. if ( $params->get( 'unpublished' ) ) {
  416. // shows unpublished items for publishers and above
  417. $xwhere2 = "\n AND b.state >= 0";
  418. } else {
  419. // unpublished items NOT shown for publishers and above
  420. $xwhere2 = "\n AND b.state = 1";
  421. }
  422. } else {
  423. $xwhere = "\n AND c.published = 1";
  424. $xwhere2 = "\n AND b.state = 1"
  425. . "\n AND ( b.publish_up = " . $database->Quote( $nullDate ) . " OR b.publish_up <= " . $database->Quote( $now ) . " )"
  426. . "\n AND ( b.publish_down = " . $database->Quote( $nullDate ) . " OR b.publish_down >= " . $database->Quote( $now ) . " )"
  427. ;
  428. }
  429. $pagetitle = '';
  430. if ( $Itemid ) {
  431. $pagetitle = $menu->name;
  432. }
  433. // show/hide empty categories
  434. $empty = '';
  435. if ( !$params->get( 'empty_cat' ) )
  436. $empty = "\n HAVING COUNT( b.id ) > 0";
  437. // get the list of other categories
  438. $query = "SELECT c.*, COUNT( b.id ) AS numitems"
  439. . "\n FROM #__categories AS c"
  440. . "\n LEFT JOIN #__content AS b ON b.catid = c.id "
  441. . $xwhere2
  442. . ( $noauth ? "\n AND b.access <= " . (int) $gid : '' )
  443. . "\n WHERE c.section = '" . (int) $category->section . "'"
  444. . $xwhere
  445. . ( $noauth ? "\n AND c.access <= " . (int) $gid : '' )
  446. . "\n GROUP BY c.id"
  447. . $empty
  448. . "\n ORDER BY c.ordering"
  449. ;
  450. $database->setQuery( $query );
  451. $other_categories = $database->loadObjectList();
  452. // get the total number of published items in the category
  453. // filter functionality
  454. $and = null;
  455. if ( $params->get( 'filter' ) ) {
  456. if ( $filter ) {
  457. // clean filter variable
  458. $filter = strtolower( $filter );
  459. switch ( $params->get( 'filter_type' ) ) {
  460. case 'title':
  461. $and = "\n AND LOWER( a.title ) LIKE '%" . $database->getEscaped( $filter ) . "%'";
  462. break;
  463. case 'author':
  464. $and = "\n AND ( ( LOWER( u.name ) LIKE '%" . $database->getEscaped( $filter ) . "%' ) OR ( LOWER( a.created_by_alias ) LIKE '%" . $database->getEscaped( $filter ) . "%' ) )";
  465. break;
  466. case 'hits':
  467. $and = "\n AND a.hits LIKE '%" . $database->getEscaped( $filter ) . "%'";
  468. break;
  469. }
  470. }
  471. }
  472. if ( $access->canEdit ) {
  473. if ( $params->get( 'unpublished' ) ) {
  474. // shows unpublished items for publishers and above
  475. $xwhere = "\n AND a.state >= 0";
  476. } else {
  477. // unpublished items NOT shown for publishers and above
  478. $xwhere = "\n AND a.state = 1";
  479. }
  480. } else {
  481. $xwhere = "\n AND a.state = 1"
  482. . "\n AND ( publish_up = " . $database->Quote( $nullDate ) . " OR publish_up <= " . $database->Quote( $now ) . " )"
  483. . "\n AND ( publish_down = " . $database->Quote( $nullDate ) . " OR publish_down >= " . $database->Quote( $now ) . " )"
  484. ;
  485. }
  486. // query to determine total number of records
  487. $query = "SELECT COUNT(a.id) as numitems"
  488. . "\n FROM #__content AS a"
  489. . "\n LEFT JOIN #__users AS u ON u.id = a.created_by"
  490. . "\n LEFT JOIN #__groups AS g ON a.access = g.id"
  491. . "\n WHERE a.catid = " . (int) $category->id
  492. . $xwhere
  493. . ( $noauth ? "\n AND a.access <= " . (int) $gid : '' )
  494. . "\n AND " . (int) $category->access . " <= " . (int) $gid
  495. . $and
  496. . "\n ORDER BY $orderby"
  497. ;
  498. $database->setQuery( $query );
  499. $counter = $database->loadObjectList();
  500. $total = $counter[0]->numitems;
  501. $limit = $limit ? $limit : $params->get( 'display_num' ) ;
  502. if ( $total <= $limit ) {
  503. $limitstart = 0;
  504. }
  505. require_once( $GLOBALS['mosConfig_absolute_path'] . '/includes/pageNavigation.php' );
  506. $pageNav = new mosPageNav( $total, $limitstart, $limit );
  507. // get the list of items for this category
  508. $query = "SELECT a.id, a.title, a.hits, a.created_by, a.created_by_alias, a.images, a.created AS created, a.access, u.name AS author, a.state, g.name AS groups"
  509. . "\n FROM #__content AS a"
  510. . "\n LEFT JOIN #__users AS u ON u.id = a.created_by"
  511. . "\n LEFT JOIN #__groups AS g ON a.access = g.id"
  512. . "\n WHERE a.catid = " . (int) $category->id
  513. . $xwhere
  514. . ( $noauth ? "\n AND a.access <= " . (int) $gid : '' )
  515. . "\n AND " . (int) $category->access . " <= " . (int) $gid
  516. . $and
  517. . "\n ORDER BY $orderby"
  518. ;
  519. $database->setQuery( $query, $limitstart, $limit );
  520. $items = $database->loadObjectList();
  521. $check = 0;
  522. if ( $params->get( 'date' ) ) {
  523. $order[] = mosHTML::makeOption( 'date', _ORDER_DROPDOWN_DA );
  524. $order[] = mosHTML::makeOption( 'rdate', _ORDER_DROPDOWN_DD );
  525. $check .= 1;
  526. }
  527. if ( $params->get( 'title' ) ) {
  528. $order[] = mosHTML::makeOption( 'alpha', _ORDER_DROPDOWN_TA );
  529. $order[] = mosHTML::makeOption( 'ralpha', _ORDER_DROPDOWN_TD );
  530. $check .= 1;
  531. }
  532. if ( $params->get( 'hits' ) ) {
  533. $order[] = mosHTML::makeOption( 'hits', _ORDER_DROPDOWN_HA );
  534. $order[] = mosHTML::makeOption( 'rhits', _ORDER_DROPDOWN_HD );
  535. $check .= 1;
  536. }
  537. if ( $params->get( 'author' ) ) {
  538. $order[] = mosHTML::makeOption( 'author', _ORDER_DROPDOWN_AUA );
  539. $order[] = mosHTML::makeOption( 'rauthor', _ORDER_DROPDOWN_AUD );
  540. $check .= 1;
  541. }
  542. $order[] = mosHTML::makeOption( 'order', _ORDER_DROPDOWN_O );
  543. $lists['order'] = mosHTML::selectList( $order, 'order', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'value', 'text', $selected );
  544. if ( $check < 1 ) {
  545. $lists['order'] = '';
  546. $params->set( 'order_select', 0 );
  547. }
  548. $lists['task'] = 'category';
  549. $lists['filter'] = $filter;
  550. // remove slashes
  551. $category->name = stripslashes($category->name);
  552. // Dynamic Page Title
  553. $mainframe->SetPageTitle( ($category->name ? $category->name : $pagetitle) );
  554. HTML_content::showContentList( $category, $items, $access, $id, $sectionid, $gid, $params, $pageNav, $other_categories, $lists, $selected, true, $section );
  555. } // showCategory
  556. function showBlogSection( $id=0, $gid, &$access, $pop, $now=NULL, $limit, $limitstart ) {
  557. global $database, $mainframe, $Itemid, $mosConfig_blog_leading, $mosConfig_blog_intro, $mosConfig_blog_columns, $mosConfig_blog_links, $my;
  558. // needed for check whether section is published
  559. $check = ( $id ? $id : 0 );
  560. $now = _CURRENT_SERVER_TIME;
  561. $noauth = !$mainframe->getCfg( 'shownoauth' );
  562. // Parameters
  563. $params = new stdClass();
  564. if ( $Itemid ) {
  565. $menu = $mainframe->get( 'menu' );
  566. $params = new mosParameters( $menu->params );
  567. } else {
  568. $menu = '';
  569. $params = new mosParameters( '' );
  570. }
  571. // new blog multiple section handling
  572. if ( !$id ) {
  573. $id = $params->def( 'sectionid', 0 );
  574. }
  575. $where = _where( 1, $access, $noauth, $gid, $id, $now, NULL, NULL, $params );
  576. $where = ( count( $where ) ? "\n WHERE ". implode( "\n AND ", $where ) : '' );
  577. // Ordering control
  578. $orderby_sec = $params->def( 'orderby_sec', 'rdate' );
  579. $orderby_pri = $params->def( 'orderby_pri', '' );
  580. $order_sec = _orderby_sec( $orderby_sec );
  581. $order_pri = _orderby_pri( $orderby_pri );
  582. // voting control
  583. $voting = $params->def( 'rating', '' );
  584. $voting = votingQuery($voting);
  585. // Limit & limitstart
  586. $intro = $params->def( 'intro', $GLOBALS['mosConfig_blog_intro'] );
  587. $leading = $params->def( 'leading', $GLOBALS['mosConfig_blog_leading'] );
  588. $links = $params->def( 'link', $GLOBALS['mosConfig_blog_links'] );
  589. $limit = $limit ? $limit : ( $intro + $leading + $links );
  590. // query to determine total number of records
  591. $query = "SELECT COUNT(a.id)"
  592. . "\n FROM #__content AS a"
  593. . "\n INNER JOIN #__categories AS cc ON cc.id = a.catid"
  594. . "\n LEFT JOIN #__users AS u ON u.id = a.created_by"
  595. . "\n LEFT JOIN #__sections AS s ON a.sectionid = s.id"
  596. . "\n LEFT JOIN #__groups AS g ON a.access = g.id"
  597. . $where;
  598. $database->setQuery( $query );
  599. $total = $database->loadResult();
  600. if ( $total <= $limit ) {
  601. $limitstart = 0;
  602. }
  603. // Main data query
  604. $query = "SELECT a.id, a.title, a.title_alias, a.introtext, a.sectionid, a.state, a.catid, a.created, a.created_by, a.created_by_alias, a.modified, a.modified_by,"
  605. . "\n a.checked_out, a.checked_out_time, a.publish_up, a.publish_down, a.images, a.urls, a.ordering, a.metakey, a.metadesc, a.access,"
  606. . "\n CHAR_LENGTH( a.fulltext ) AS readmore, u.name AS author, u.usertype, s.name AS section, cc.name AS category, g.name AS groups"
  607. . $voting['select']
  608. . "\n FROM #__content AS a"
  609. . "\n INNER JOIN #__categories AS cc ON cc.id = a.catid"
  610. . "\n LEFT JOIN #__users AS u ON u.id = a.created_by"
  611. . "\n LEFT JOIN #__sections AS s ON a.sectionid = s.id"
  612. . "\n LEFT JOIN #__groups AS g ON a.access = g.id"
  613. . $voting['join']
  614. . $where
  615. . "\n ORDER BY $order_pri $order_sec"
  616. ;
  617. $database->setQuery( $query, $limitstart, $limit );
  618. $rows = $database->loadObjectList();
  619. // Dynamic Page Title & meta
  620. $section = new mosSection( $database );
  621. $section->load( (int)$check );
  622. if ($menu->name) {
  623. $mainframe->setPageTitle( $menu->name );
  624. }else{
  625. $mainframe->setPageTitle( $section->name );
  626. }
  627. if($check){
  628. $params_tmp = new mosParameters( $section->params );
  629. if($params_tmp->get('metadesc','')) $mainframe->addMetaTag( 'description', $params_tmp->get('metadesc','') );
  630. if($params_tmp->get('metakey','')) $mainframe->addMetaTag( 'keywords', $params_tmp->get('metakey','') );
  631. }
  632. // check whether section is published
  633. if (!count($rows) && $check) {
  634. $secCheck = new mosSection( $database );
  635. $secCheck->load( (int)$check );
  636. /*
  637. * check whether section is published
  638. */
  639. if (!$secCheck->published) {
  640. mosNotAuth();
  641. return;
  642. }
  643. /*
  644. * check whether section access level allows access
  645. */
  646. if ($secCheck->access > $gid) {
  647. mosNotAuth();
  648. return;
  649. }
  650. }
  651. BlogOutput( $rows, $params, $gid, $access, $pop, $menu, $limitstart, $limit, $total );
  652. }
  653. function showBlogCategory( $id=0, $gid, &$access, $pop, $now, $limit, $limitstart ) {
  654. global $database, $mainframe, $Itemid;
  655. $now = _CURRENT_SERVER_TIME;
  656. $noauth = !$mainframe->getCfg( 'shownoauth' );
  657. // needed for check whether section & category is published
  658. $check = ( $id ? $id : 0 );
  659. // Paramters
  660. $params = new stdClass();
  661. if ( $Itemid ) {
  662. $menu = $mainframe->get( 'menu' );
  663. $params = new mosParameters( $menu->params );
  664. } else {
  665. $menu = '';
  666. $params = new mosParameters( '' );
  667. }
  668. // ------------------------ A8E fixes start ------------------------
  669. // ADDED: menu-item is section, view is category
  670. // TODO: remove, as this is not an accessibility fix
  671. if ($menu->type == 'content_section' && $params->Get('category_as_blog', 0)) {
  672. $params = getCategorySettingsFromSection($params);
  673. }
  674. // ------------------------ A8E fixes end ------------------------
  675. // new blog multiple section handling
  676. if ( !$id ) {
  677. $id = $params->def( 'categoryid', 0 );
  678. }
  679. $where = _where( 2, $access, $noauth, $gid, $id, $now, NULL, NULL, $params );
  680. $where = ( count( $where ) ? "\n WHERE ". implode( "\n AND ", $where ) : '' );
  681. // Ordering control
  682. $orderby_sec = $params->def( 'orderby_sec', 'rdate' );
  683. $orderby_pri = $params->def( 'orderby_pri', '' );
  684. $order_sec = _orderby_sec( $orderby_sec );
  685. $order_pri = _orderby_pri( $orderby_pri );
  686. // voting control
  687. $voting = $params->def( 'rating', '' );
  688. $voting = votingQuery($voting);
  689. // Limit & limitstart
  690. $intro = $params->def( 'intro', $GLOBALS['mosConfig_blog_intro'] );
  691. $leading = $params->def( 'leading', $GLOBALS['mosConfig_blog_leading'] );
  692. $links = $params->def( 'link', $GLOBALS['mosConfig_blog_links'] );
  693. $limit = $limit ? $limit : ( $intro + $leading + $links );
  694. // query to determine total number of records
  695. $query = "SELECT COUNT(a.id)"
  696. . "\n FROM #__content AS a"
  697. . "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid"
  698. . "\n LEFT JOIN #__users AS u ON u.id = a.created_by"
  699. . "\n LEFT JOIN #__sections AS s ON a.sectionid = s.id"
  700. . "\n LEFT JOIN #__groups AS g ON a.access = g.id"
  701. . $where
  702. ;
  703. $database->setQuery( $query );
  704. $total = $database->loadResult();
  705. if ( $total <= $limit ) {
  706. $limitstart = 0;
  707. }
  708. // Main data query
  709. $query = "SELECT a.id, a.title, a.title_alias, a.introtext, a.sectionid, a.state, a.catid, a.created, a.created_by, a.created_by_alias, a.modified, a.modified_by,"
  710. . "\n a.checked_out, a.checked_out_time, a.publish_up, a.publish_down, a.images, a.urls, a.ordering, a.metakey, a.metadesc, a.access,"
  711. . "\n CHAR_LENGTH( a.fulltext ) AS readmore, s.published AS sec_pub, cc.published AS sec_pub, u.name AS author, u.usertype, s.name AS section, cc.name AS category, g.name AS groups"
  712. . $voting['select']
  713. . "\n FROM #__content AS a"
  714. . "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid"
  715. . "\n LEFT JOIN #__users AS u ON u.id = a.created_by"
  716. . "\n LEFT JOIN #__sections AS s ON a.sectionid = s.id"
  717. . "\n LEFT JOIN #__groups AS g ON a.access = g.id"
  718. . $voting['join']
  719. . $where
  720. . "\n ORDER BY $order_pri $order_sec"
  721. ;
  722. $database->setQuery( $query, $limitstart, $limit );
  723. $rows = $database->loadObjectList();
  724. // check whether section & category is published
  725. if (!count($rows) && $check) {
  726. $catCheck = new mosCategory( $database );
  727. $catCheck->load( (int)$check );
  728. /*
  729. * check whether category is published
  730. */
  731. if (!$catCheck->published) {
  732. mosNotAuth();
  733. return;
  734. }
  735. /*
  736. * check whether category access level allows access
  737. */
  738. if( $catCheck->access > $gid ) {
  739. mosNotAuth();
  740. return;
  741. }
  742. $secCheck = new mosSection( $database );
  743. $secCheck->load( $catCheck->section );
  744. /*
  745. * check whether section is published
  746. */
  747. if (!$secCheck->published) {
  748. mosNotAuth();
  749. return;
  750. }
  751. /*
  752. * check whether category access level allows access
  753. */
  754. if( $secCheck->access > $gid ) {
  755. mosNotAuth();
  756. return;
  757. }
  758. }
  759. // ------------------------ A8E fixes start ------------------------
  760. // load category
  761. // TODO: remove, as this is not an accessibility fix
  762. $currentCat = new mosCategory ($database);
  763. $currentCat->load ($id);
  764. //Add meta info
  765. if(!empty($description)){
  766. $params_tmp = new mosParameters( $currentCat->params );
  767. if($params_tmp->get('metadesc','')) $mainframe->addMetaTag( 'description', $params_tmp->get('metadesc','') );
  768. if($params_tmp->get('metakey','')) $mainframe->addMetaTag( 'keywords', $params_tmp->get('metakey','') );
  769. }
  770. // Dynamic Page Title
  771. if (count (explode (',', $id)) != 1) { //view on multiple categories -> must have menu-link -> menu-item title prevails
  772. $mainframe->SetPageTitle( $menu->name );
  773. } else if( $menu->name && $params->get('category_title',0)!=2 ) {
  774. $mainframe->SetPageTitle( $menu->name );
  775. }else { //view on single category -> category title prevails
  776. $mainframe->SetPageTitle( $currentCat->title );
  777. }
  778. // ------------------------ A8E fixes end ------------------------
  779. BlogOutput( $rows, $params, $gid, $access, $pop, $menu, $limitstart, $limit, $total );
  780. }
  781. function showArchiveSection( $id=NULL, $gid, &$access, $pop, $option, $year, $month, $limit, $limitstart ) {
  782. global $database, $mainframe;
  783. global $Itemid;
  784. $secID = ( $id ? $id : 0 );
  785. $noauth = !$mainframe->getCfg( 'shownoauth' );
  786. $params = new stdClass();
  787. if ( $Itemid ) {
  788. $menu = $mainframe->get( 'menu' );
  789. $params = new mosParameters( $menu->params );
  790. } else {
  791. $menu = "";
  792. $params = new mosParameters( '' );
  793. }
  794. $params->set( 'intro_only', 1 );
  795. $params->set( 'year', $year );
  796. $params->set( 'month', $month );
  797. // Ordering control
  798. $orderby_sec = $params->def( 'orderby_sec', 'rdate' );
  799. $orderby_pri = $params->def( 'orderby_pri', '' );
  800. $order_sec = _orderby_sec( $orderby_sec );
  801. $order_pri = _orderby_pri( $orderby_pri );
  802. // used in query
  803. $where = _where( -1, $access, $noauth, $gid, $id, NULL, $year, $month );
  804. $where = ( count( $where ) ? "\n WHERE ". implode( "\n AND ", $where ) : '' );
  805. // checks to see if 'All Sections' options used
  806. if ( $id == 0 ) {
  807. $check = '';
  808. } else {
  809. $check = "\n AND a.sectionid = " . (int) $id;
  810. }
  811. // query to determine if there are any archived entries for the section
  812. $query = "SELECT a.id"
  813. . "\n FROM #__content as a"
  814. . "\n WHERE a.state = -1"
  815. . $check
  816. ;
  817. $database->setQuery( $query );
  818. $items = $database->loadObjectList();
  819. $archives = count( $items );
  820. // voting control
  821. $voting = $params->def( 'rating', '' );
  822. $voting = votingQuery($voting);
  823. // Limit & limitstart
  824. $intro = $params->def( 'intro', $GLOBALS['mosConfig_blog_intro'] );
  825. $leading = $params->def( 'leading', $GLOBALS['mosConfig_blog_leading'] );
  826. $links = $params->def( 'link', $GLOBALS['mosConfig_blog_links'] );
  827. $limit = $limit ? $limit : ( $intro + $leading + $links );
  828. // query to determine total number of records
  829. $query = "SELECT COUNT(a.id)"
  830. . "\n FROM #__content AS a"
  831. . "\n INNER JOIN #__categories AS cc ON cc.id = a.catid"
  832. . "\n LEFT JOIN #__users AS u ON u.id = a.created_by"
  833. . "\n LEFT JOIN #__sections AS s ON a.sectionid = s.id"
  834. . "\n LEFT JOIN #__groups AS g ON a.access = g.id"
  835. . $where
  836. ;
  837. $database->setQuery( $query );
  838. $total = $database->loadResult();
  839. if ( $total <= $limit ) {
  840. $limitstart = 0;
  841. }
  842. // Main Query
  843. $query = "SELECT a.id, a.title, a.title_alias, a.introtext, a.sectionid, a.state, a.catid, a.created, a.created_by, a.created_by_alias, a.modified, a.modified_by,"
  844. . "\n a.checked_out, a.checked_out_time, a.publish_up, a.publish_down, a.images, a.urls, a.ordering, a.metakey, a.metadesc, a.access,"
  845. . "\n CHAR_LENGTH( a.fulltext ) AS readmore, u.name AS author, u.usertype, s.name AS section, cc.name AS category, g.name AS groups"
  846. . $voting['select']
  847. . "\n FROM #__content AS a"
  848. . "\n INNER JOIN #__categories AS cc ON cc.id = a.catid"
  849. . "\n LEFT JOIN #__users AS u ON u.id = a.created_by"
  850. . "\n LEFT JOIN #__sections AS s ON a.sectionid = s.id"
  851. . "\n LEFT JOIN #__groups AS g ON a.access = g.id"
  852. . $voting['join']
  853. . $where
  854. . "\n ORDER BY $order_pri $order_sec"
  855. ;
  856. $database->setQuery( $query, $limitstart, $limit );
  857. $rows = $database->loadObjectList();
  858. // check whether section is published
  859. if (!count($rows) && $secID != 0) {
  860. $secCheck = new mosSection( $database );
  861. $secCheck->load( (int)$secID );
  862. /*
  863. * check whether section is published
  864. */
  865. if (!$secCheck->published) {
  866. mosNotAuth();
  867. return;
  868. }
  869. /*
  870. * check whether section access level allows access
  871. */
  872. if ($secCheck->access > $gid) {
  873. mosNotAuth();
  874. return;
  875. }
  876. }
  877. // initiate form
  878. $link = 'index.php?option=com_content&task=archivesection&id='. $id .'&Itemid='. $Itemid;
  879. echo '<form action="'.sefRelToAbs( $link ).'" method="post">';
  880. // Dynamic Page Title
  881. $mainframe->SetPageTitle( $menu->name );
  882. if ( !$archives ) {
  883. // if no archives for category, hides search and outputs empty message
  884. echo '<br /><div align="center">'. _CATEGORY_ARCHIVE_EMPTY .'</div>';
  885. } else {
  886. BlogOutput( $rows, $params, $gid, $access, $pop, $menu, $limitstart, $limit, $total, 1, 1 );
  887. }
  888. echo '<input type="hidden" name="id" value="'. $id .'" />';
  889. echo '<input type="hidden" name="Itemid" value="'. $Itemid .'" />';
  890. echo '<input type="hidden" name="task" value="archivesection" />';
  891. echo '<input type="hidden" name="option" value="com_content" />';
  892. echo '</form>';
  893. }
  894. function showArchiveCategory( $id=0, $gid, &$access, $pop, $option, $year, $month, $module, $limit, $limitstart ) {
  895. global $database, $mainframe;
  896. global $Itemid;
  897. $now = _CURRENT_SERVER_TIME;
  898. $noauth = !$mainframe->getCfg( 'shownoauth' );
  899. // needed for check whether section & category is published
  900. $catID = ( $id ? $id : 0 );
  901. // used by archive module
  902. if ( $module ) {
  903. $check = '';
  904. } else {
  905. $check = "\n AND a.catid = " . (int) $id;
  906. }
  907. if ( $Itemid ) {
  908. $menu = $mainframe->get( 'menu' );
  909. $params = new mosParameters( $menu->params );
  910. } else {
  911. $menu = '';
  912. $params = new mosParameters( '' );
  913. }
  914. $params->set( 'year', $year );
  915. $params->set( 'month', $month );
  916. // Ordering control
  917. $orderby_sec = $params->def( 'orderby', 'rdate' );
  918. $order_sec = _orderby_sec( $orderby_sec );
  919. // used in query
  920. $where = _where( -2, $access, $noauth, $gid, $id, NULL, $year, $month );
  921. $where = ( count( $where ) ? "\n WHERE ". implode( "\n AND ", $where ) : '' );
  922. // query to determine if there are any archived entries for the category
  923. $query = "SELECT a.id"
  924. . "\n FROM #__content as a"
  925. . "\n WHERE a.state = -1"
  926. . $check
  927. ;
  928. $database->setQuery( $query );
  929. $items = $database->loadObjectList();
  930. $archives = count( $items );
  931. // voting control
  932. $voting = $params->def( 'rating', '' );
  933. $voting = votingQuery($voting);
  934. // Limit & limitstart
  935. $intro = $params->def( 'intro', $GLOBALS['mosConfig_blog_intro'] );
  936. $leading = $params->def( 'leading', $GLOBALS['mosConfig_blog_leading'] );
  937. $links = $params->def( 'link', $GLOBALS['mosConfig_blog_links'] );
  938. $limit = $limit ? $limit : ( $intro + $leading + $links );
  939. // query to determine total number of records
  940. $query = "SELECT COUNT(a.id)"
  941. . "\n FROM #__content AS a"
  942. . "\n INNER JOIN #__categories AS cc ON cc.id = a.catid"
  943. . "\n LEFT JOIN #__users AS u ON u.id = a.created_by"
  944. . "\n LEFT JOIN #__sections AS s ON a.sectionid = s.id"
  945. . "\n LEFT JOIN #__groups AS g ON a.access = g.id"
  946. . $where
  947. ;
  948. $database->setQuery( $query );
  949. $total = $database->loadResult();
  950. if ( $total <= $limit ) {
  951. $limitstart = 0;
  952. }
  953. // main query
  954. $query = "SELECT a.id, a.title, a.title_alias, a.introtext, a.sectionid, a.state, a.catid, a.created, a.created_by, a.created_by_alias, a.modified, a.modified_by,"
  955. . "\n a.checked_out, a.checked_out_time, a.publish_up, a.publish_down, a.images, a.urls, a.ordering, a.metakey, a.metadesc, a.access,"
  956. . "\n CHAR_LENGTH( a.fulltext ) AS readmore, u.name AS author, u.usertype, s.name AS section, cc.name AS category, g.name AS groups"
  957. . $voting['select']
  958. . "\n FROM #__content AS a"
  959. . "\n INNER JOIN #__categories AS cc ON cc.id = a.catid"
  960. . "\n LEFT JOIN #__users AS u ON u.id = a.created_by"
  961. . "\n LEFT JOIN #__sections AS s ON a.sectionid = s.id"
  962. . "\n LEFT JOIN #__groups AS g ON a.access = g.id"
  963. . $voting['join']
  964. . $where
  965. . "\n ORDER BY $order_sec"
  966. ;
  967. $database->setQuery( $query, $limitstart, $limit );
  968. $rows = $database->loadObjectList();
  969. // check whether section & category is published
  970. if (!count($rows) && $catID != 0) {
  971. $catCheck = new mosCategory( $database );
  972. $catCheck->load( (int)$catID );
  973. /*
  974. * check whether category is published
  975. */
  976. if (!$catCheck->published) {
  977. mosNotAuth();
  978. return;
  979. }
  980. /*
  981. * check whether category access level allows access
  982. */
  983. if( $catCheck->access > $gid ) {
  984. mosNotAuth();
  985. return;
  986. }
  987. $secCheck = new mosSection( $database );
  988. $secCheck->load( $catCheck->section );
  989. /*
  990. * check whether section is published
  991. */
  992. if (!$secCheck->published) {
  993. mosNotAuth();
  994. return;
  995. }
  996. /*
  997. * check whether category access level allows access
  998. */
  999. if( $secCheck->access > $gid ) {
  1000. mosNotAuth();
  1001. return;
  1002. }
  1003. }
  1004. // initiate form
  1005. // ------------------------ A8E fix ------------------------
  1006. $link = ampReplace('index.php?option=com_content&task=archivecategory&id='. $id .'&Itemid='. $Itemid);
  1007. echo '<form action="'.sefRelToAbs( $link ).'" method="post">';
  1008. // Page Title
  1009. $mainframe->SetPageTitle( $menu->name );
  1010. if ( !$archives ) {
  1011. // if no archives for category, hides search and outputs empty message
  1012. echo '<br />';
  1013. echo '<div align="center">'. _CATEGORY_ARCHIVE_EMPTY .'</div>';
  1014. } else {
  1015. // if coming from the Archive Module, the Archive Dropdown selector is not shown
  1016. if ( $id ) {
  1017. BlogOutput( $rows, $params, $gid, $access, $pop, $menu, $limitstart, $limit, $total, 1, 1 );
  1018. } else {
  1019. BlogOutput( $rows, $params, $gid, $access, $pop, $menu, $limitstart, $limit, $total, 0, 1 );
  1020. }
  1021. }
  1022. echo '<input type="hidden" name="id" value="'. $id .'" />';
  1023. echo '<input type="hidden" name="Itemid" value="'. $Itemid .'" />';
  1024. echo '<input type="hidden" name="task" value="archivecategory" />';
  1025. echo '<input type="hidden" name="option" value="com_content" />';
  1026. echo '</form>';
  1027. }
  1028. function BlogOutput ( &$rows, &$params, $gid, &$access, $pop, &$menu, $limitstart, $limit, $total, $archive=NULL, $archive_page=NULL ) {
  1029. global $mainframe, $Itemid, $task, $id, $option, $database, $mosConfig_live_site, $my;
  1030. // ------------------------ A8E fixes start ------------------------
  1031. // TODO: remove, as this is not an accessibility fix
  1032. $category = null;
  1033. //
  1034. if (($menu->type == 'content_section' || $menu->type == 'content_blog_section') && $params->get('category_title',0)==2 && $task == 'blogcategory') {
  1035. //category not in menu -> override menu item title
  1036. $category = new mosCategory( $database );
  1037. $category->load($id);
  1038. $header = ampReplace($category->title);
  1039. } else if ( $params->get( 'page_title', 1 ) && $menu && $params->get('category_title',0)!=1 ) {
  1040. //parameters
  1041. $header = ampReplace($params->def( 'header', $menu->name ));
  1042. } else {
  1043. $header = '';
  1044. }
  1045. // ------------------------ A8E fixes end ------------------------
  1046. $columns = $params->def( 'columns', $GLOBALS['mosConfig_blog_columns'] );
  1047. if ( $columns == 0 ) {
  1048. $columns = 1;
  1049. }
  1050. $intro = $params->def( 'intro', $GLOBALS['mosConfig_blog_intro'] );
  1051. $leading = $params->def( 'leading', $GLOBALS['mosConfig_blog_leading'] );
  1052. $links = $params->def( 'link', $GLOBALS['mosConfig_blog_links'] );
  1053. $pagination = $params->def( 'pagination', 2 );
  1054. $pagination_results = $params->def( 'pagination_results', 1 );
  1055. $pagination_results = $params->def( 'pagination_results', 1 );
  1056. $descrip = $params->def( 'description', 1 );
  1057. $descrip_image = $params->def( 'description_image', 1 );
  1058. $params->def( 'back_button', $GLOBALS['mosConfig_back_button'] );
  1059. $params->def( 'link_titles', $GLOBALS['mosConfig_link_titles']);
  1060. $params->def( 'readmore', $GLOBALS['mosConfig_readmore'] );
  1061. $params->def( 'author', 0 );
  1062. $params->def( 'createdate', 0 );
  1063. $params->def( 'modifydate', 0 );
  1064. $params->def( 'pdf', 0 );
  1065. $params->def( 'print', 0 );
  1066. $params->def( 'email', 0 );
  1067. $params->def( 'rating', 0 );
  1068. // needed for back button for page
  1069. $back = $params->get( 'back_button', $mainframe->getCfg( 'back_button' ) );
  1070. // needed to disable back button for item
  1071. $params->set( 'back_button', 0 );
  1072. $params->def( 'pageclass_sfx', '' );
  1073. $params->set( 'intro_only', 1 );
  1074. $i = 0;
  1075. // used to display section/catagory description text and images
  1076. // currently not supported in Archives
  1077. if ( $menu && $menu->componentid ) {
  1078. switch ( $menu->type ) {
  1079. case 'content_blog_section':
  1080. if ($params->get('category_description',0)==2 && $task=='blogcategory') {
  1081. $description = new mosCategory( $database );
  1082. $description->load( (int)$id );
  1083. } else {
  1084. $description = new mosSection( $database );
  1085. //$description->load( (int)$menu->componentid );
  1086. $description->load( (int)$id );
  1087. }
  1088. break;
  1089. case 'content_blog_category':
  1090. $description = new mosCategory( $database );
  1091. $description->load( (int)$menu->componentid );
  1092. break;
  1093. // ------------------------ A8E fixes start ------------------------
  1094. // TODO: remove, as this is not an accessibility fix
  1095. case 'content_section':
  1096. //menu level stops at section, but displaying underlying category
  1097. $description = $category;
  1098. break;
  1099. // ------------------------ A8E fixes end ------------------------
  1100. default:
  1101. $menu->componentid = 0;
  1102. break;
  1103. }
  1104. }
  1105. // Page Output
  1106. // page header
  1107. if ( $header ) {
  1108. // ------------------------ A8E fix ------------------------
  1109. echo '<h1 class="componentheading'.$params->get( 'pageclass_sfx' ) .'">'. $header .'</h1>';
  1110. }
  1111. if ( $archive ) {
  1112. echo '<br />';
  1113. echo mosHTML::monthSelectList( 'month', 'size="1" class="inputbox"', $params->get( 'month' ) );
  1114. echo mosHTML::integerSelectList( 2000, 2010, 1, 'year', 'size="1" class="inputbox"', $params->get( 'year' ), "%04d" );
  1115. echo '<input type="submit" class="button" value="'._SUBMIT_BUTTON.'" />';
  1116. }
  1117. // checks to see if there are there any items to display
  1118. if ( $total ) {
  1119. $col_with = 100 / $columns; // width of each column
  1120. $width = intval( $col_with );
  1121. if ( $archive ) {
  1122. // Search Success message
  1123. $msg = sprintf( _ARCHIVE_SEARCH_SUCCESS, $params->get( 'month' ), $params->get( 'year' ) );
  1124. echo "<br /><br /><div align='center'>". $msg ."</div><br /><br />";
  1125. }
  1126. // ------------------------ A8E fixes start------------------------
  1127. echo '<div class="blog' . $params->get( 'pageclass_sfx' ) . '">';
  1128. // Secrion/Category Description & Image
  1129. if ( $menu && $menu->componentid && $descrip && ( $description || $descrip_image ) ) {
  1130. $link = $mosConfig_live_site .'/images/stories/'. $description->image;
  1131. echo '<div class="blogdescription">';
  1132. if ( $descrip_image && $description->image ) {
  1133. echo '<div class="blogdescriptionimage"><img src="'. $link .'" style="float: '. $description->image_position .'; margin: 6px;" alt="" /></div>';
  1134. }
  1135. if ( $descrip && $description->description ) {
  1136. echo '<div class="blogdescriptiontext">'.$description->description.'</div>';
  1137. }
  1138. echo '</div>';
  1139. }
  1140. // Leading story output
  1141. if ( $leading ) {
  1142. echo '<div class="blogleading">';
  1143. for ( $z = 0; $z < $leading; $z++ ) {
  1144. if ( $i >= ($total - $limitstart) ) {
  1145. // stops loop if total number of items is less than the number set to display as leading
  1146. break;
  1147. }
  1148. echo '<div class="itemblock item_'.$z.'">';
  1149. show( $rows[$i], $params, $gid, $access, $pop );
  1150. echo '</div>';
  1151. $i++;
  1152. }
  1153. echo '</div>';
  1154. }
  1155. if ( $intro && ( $i < $total ) ) {
  1156. echo '<div class="blogintro">';
  1157. $colId = $i;
  1158. $rowCount = ceil($intro / $columns);
  1159. $introMax = $intro + $i;
  1160. for($j = 1; $j <= $rowCount; $j++){
  1161. //Break out if there are no more items
  1162. if(!isset($rows[$i])) break;
  1163. //Output row holder
  1164. echo "<div class='blogrow row_$j' style='margin-bottom: 10px'>";
  1165. $colCount = 1;
  1166. //work out the maximum number of intro cells to output
  1167. $max = ($columns + $i) > $introMax ? $introMax : ($columns + $i);
  1168. $max = $max > $total ? $total : $max;
  1169. for($i; $i < $max; $i++){
  1170. //Calculate padding and width
  1171. $colwidth = $colCount < $columns ? $width-1 : $width;
  1172. $padding = $colCount < $columns ? 1 : 0;
  1173. echo "<div class='blogcolumn column_$colCount' style='float: left; width: ".$colwidth."%; padding-right: ".$padding."%'>";
  1174. echo '<div class="itemblock item_'.$z.'">';
  1175. show( $rows[$i], $params, $gid, $access, $pop );
  1176. echo '</div>';
  1177. echo "</div>";
  1178. //$i++;
  1179. $colCount++;
  1180. }
  1181. //echo "<div style='clear: left'></div>";
  1182. echo "</div>";
  1183. }
  1184. echo '</div>'; //closes <div class="blogintro">
  1185. echo "<div style='clear: left'></div>";
  1186. }
  1187. // Links output
  1188. if ( $links && ( $i < $total - $limitstart ) ) {
  1189. $showmore = $leading + $intro;
  1190. echo '<div class="blog_more'. $params->get( 'pageclass_sfx' ) .'" style="clear: left">';
  1191. HTML_content::showLinks( $rows, $links, $total, $i, $showmore );
  1192. echo '</div>';
  1193. }
  1194. // Pagination output
  1195. if ( $pagination ) {
  1196. if ( ( $pagination == 2 ) && ( $total <= $limit ) ) {
  1197. // not visible when they is no 'other' pages to display
  1198. } else {
  1199. require_once( $GLOBALS['mosConfig_absolute_path'] . '/includes/pageNavigation.php' );
  1200. // get the total number of records
  1201. $limitstart = $limitstart ? $limitstart : 0;
  1202. $pageNav = new mosPageNav( $total, $limitstart, $limit );
  1203. if ( $Itemid && $Itemid != 99999999 ) {
  1204. // where Itemid value is returned, do not add Itemid to url
  1205. $Itemid_link = '&amp;Itemid='. $Itemid;
  1206. } else {
  1207. // where Itemid value is NOT returned, do not add Itemid to url
  1208. $Itemid_link = '';
  1209. }
  1210. if ( $option == 'com_frontpage' ) {
  1211. $link = 'index.php?option=com_frontpage'. $Itemid_link;
  1212. } else if ( $archive_page ) {
  1213. $year = $params->get( 'year' );
  1214. $month = $params->get( 'month' );
  1215. if (!$archive) {
  1216. // used when access via archive module
  1217. $pid = '&amp;id=0';
  1218. $module = '&amp;module=1';
  1219. } else {
  1220. // used when access via menu item
  1221. $pid = '&amp;id='. $id;
  1222. $module = '';
  1223. }
  1224. $link = 'index.php?option=com_content&amp;task='. $task . $pid . $Itemid_link .'&amp;year='. $year .'&amp;month='. $month . $module;
  1225. } else {
  1226. $link = 'index.php?option=com_content&amp;task='. $task .'&amp;id='. $id . $Itemid_link;
  1227. }
  1228. echo '<div class="blogpagination" style="text-align: center">';
  1229. echo $pageNav->writePagesLinks( $link );
  1230. echo '</div>';
  1231. if ( $pagination_results ) {
  1232. echo '<div class="blogpaginationcounter" style="text-align: center">';
  1233. echo $pageNav->writePagesCounter();
  1234. echo '</div>';
  1235. }
  1236. }
  1237. }
  1238. echo '</div>'; //closes <div class="blog">
  1239. // ------------------------ A8E fixes end ------------------------
  1240. } else if ( $archive && !$total ) {
  1241. // Search Failure message for Archives
  1242. $msg = sprintf( _ARCHIVE_SEARCH_FAILURE, $params->get( 'month' ), $params->get( 'year' ) );
  1243. echo '<br /><br /><div align="center">'. $msg .'</div><br />';
  1244. } else {
  1245. // Generic blog empty display
  1246. echo _EMPTY_BLOG;
  1247. }
  1248. // Back Button
  1249. $params->set( 'back_button', $back );
  1250. mosHTML::BackButton ( $params );
  1251. }
  1252. function showItem( $uid, $gid, &$access, $pop, $option='com_content', $now ) {
  1253. global $database, $mainframe, $Itemid;
  1254. global $mosConfig_MetaTitle, $mosConfig_MetaAuthor;
  1255. $now = _CURRENT_SERVER_TIME;
  1256. $nullDate = $database->getNullDate();
  1257. if ( $access->canEdit ) {
  1258. $xwhere = '';
  1259. } else {
  1260. $xwhere = " AND ( a.state = 1 OR a.state = -1 )"
  1261. . "\n AND ( a.publish_up = " . $database->Quote( $nullDate ) . " OR a.publish_up <= " . $database->Quote( $now ) . " )"
  1262. . "\n AND ( a.publish_down = " . $database->Quote( $nullDate ) . " OR a.publish_down >= " . $database->Quote( $now ) . " )"
  1263. ;
  1264. }
  1265. // main query
  1266. $query = "SELECT a.*, u.name AS author, u.usertype, cc.name AS category, s.name AS section, g.name AS groups,"
  1267. . "\n s.published AS sec_pub, cc.published AS cat_pub, s.access AS sec_access, cc.access AS cat_access,"
  1268. . "\n s.id AS sec_id, cc.id as cat_id"
  1269. . "\n FROM #__content AS a"
  1270. . "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid"
  1271. . "\n LEFT JOIN #__sections AS s ON s.id = cc.section AND s.scope = 'content'"
  1272. . "\n LEFT JOIN #__users AS u ON u.id = a.created_by"
  1273. . "\n LEFT JOIN #__groups AS g ON a.access = g.id"
  1274. . "\n WHERE a.id = " . (int) $uid
  1275. . $xwhere
  1276. . "\n AND a.access <= " . (int) $gid
  1277. ;
  1278. $database->setQuery( $query );
  1279. $row = NULL;
  1280. if ( $database->loadObject( $row ) ) {
  1281. /*
  1282. * check whether category is published
  1283. */
  1284. if ( !$row->cat_pub && $row->catid ) {
  1285. mosNotAuth();
  1286. return;
  1287. }
  1288. /*
  1289. * check whether section is published
  1290. */
  1291. if ( !$row->sec_pub && $row->sectionid ) {
  1292. mosNotAuth();
  1293. return;
  1294. }
  1295. /*
  1296. * check whether category access level allows access
  1297. */
  1298. if ( ($row->cat_access > $gid) && $row->catid ) {
  1299. mosNotAuth();
  1300. return;
  1301. }
  1302. /*
  1303. * check whether section access level allows access
  1304. */
  1305. if ( ($row->sec_access > $gid) && $row->sectionid ) {
  1306. mosNotAuth();
  1307. return;
  1308. }
  1309. $params = new mosParameters( $row->attribs );
  1310. $params->set( 'intro_only', 0 );
  1311. $params->def( 'back_butto