Source for file mod_latestnews.php

Documentation is available at mod_latestnews.php

  1. <?php
  2. /**
  3. @package Mambo
  4. @author Mambo Foundation Inc see README.php
  5. @copyright Mambo Foundation Inc.
  6. *  See COPYRIGHT.php for copyright notices and details.
  7. @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see
  8. *  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
  12. *  License.
  13. */ 
  14.  
  15. /** ensure this file is being included by a parent file */
  16. defined'_VALID_MOS' or die'Direct Access to this location is not allowed.' );
  17.  
  18. global $mosConfig_offset$mosConfig_live_site$mainframe$acl$my;
  19.  
  20. $type         intval$params->get'type') );
  21. $count         intval$params->get'count') );
  22. $count         intval$params->get'count') );
  23. $catid         trim$params->get'catid' ) );
  24. $secid         trim$params->get'secid' ) );
  25. $show_front    $params->get'show_front');
  26. $class_sfx    $params->get'moduleclass_sfx' );
  27.  
  28. $now         date'Y-m-d H:i:s'time($mosConfig_offset 60 60 );
  29.  
  30. $access !$mainframe->getCfg'shownoauth' );
  31. $viewAccess ($my->gid >= $acl->get_group_id'Registered''ARO' 0($my->gid >= $acl->get_group_id'Author''ARO' 0);
  32.  
  33. // select between Content Items, Static Content or both
  34. switch $type {
  35.     case 2//Static Content only
  36.         $query "SELECT a.id, a.title"
  37.         . "\n FROM #__content AS a"
  38.         . "\n WHERE ( a.state = '1' AND a.checked_out = '0' AND a.sectionid = '0' )"
  39.         . "\n AND ( a.publish_up = '0000-00-00 00:00:00' OR a.publish_up <= '"$now ."' )"
  40.         . "\n AND ( a.publish_down = '0000-00-00 00:00:00' OR a.publish_down >= '"$now ."' )"
  41.         . $access "\n AND a.access <= '"$viewAccess ."'" '' )
  42.         . "\n ORDER BY a.created DESC LIMIT $count"
  43.         ;
  44.         $database->setQuery$query );
  45.         $rows $database->loadObjectList();    
  46.         break;
  47.  
  48.     case 3//Both
  49.         $query "SELECT a.id, a.title, a.sectionid"
  50.         . "\n FROM #__content AS a"
  51.         . "\n WHERE ( a.state = '1' AND a.checked_out = '0' )"
  52.         . "\n AND ( a.publish_up = '0000-00-00 00:00:00' OR a.publish_up <= '"$now ."' )"
  53.         . "\n AND ( a.publish_down = '0000-00-00 00:00:00' OR a.publish_down >= '"$now ."' )"
  54.         . $access "\n AND a.access <= '"$viewAccess ."'" '' )
  55.         . "\n ORDER BY a.created DESC LIMIT $count"
  56.         ;
  57.         $database->setQuery$query );
  58.         $rows $database->loadObjectList();    
  59.         break;
  60.         
  61.     case 1:  //Content Items only
  62.     default:
  63.         $query "SELECT a.id, a.title, a.sectionid, a.catid"
  64.         . "\n FROM #__content AS a"
  65.         . "\n LEFT JOIN #__content_frontpage AS f ON f.content_id = a.id"
  66.         . "\n WHERE ( a.state = '1' AND a.checked_out = '0' AND a.sectionid > '0' )"
  67.         . "\n AND ( a.publish_up = '0000-00-00 00:00:00' OR a.publish_up <= '"$now ."' )"
  68.         . "\n AND ( a.publish_down = '0000-00-00 00:00:00' OR a.publish_down >= '"$now ."' )"
  69.         . $access "\n AND a.access <= '"$viewAccess ."'" '' )
  70.         . $catid "\n AND ( a.catid IN ("$catid .") )" '' )
  71.         . $secid "\n AND ( a.sectionid IN ("$secid .") )" '' )
  72.         . $show_front == "0" "\n AND f.content_id IS NULL" '' )
  73.         . "\n ORDER BY a.created DESC LIMIT $count"
  74.         ;
  75.         $database->setQuery$query );
  76.         $rows $database->loadObjectList();
  77.         break;        
  78. }
  79.  
  80. // Output
  81. ?>
  82.  
  83. <?php
  84. if (is_array($rows)) {
  85.     // needed to reduce queries used by getItemid for Content Items
  86.     if ( ( $type == || $type == ) ) {
  87.         require_once(mamboCore::get('mosConfig_absolute_path').'/components/com_content/content.class.php');
  88.         $handler =new contentHandler();
  89.         $bs     $handler->getBlogSectionCount();
  90.         $bc     $handler->getBlogCategoryCount();
  91.         $gbs     $handler->getGlobalBlogSectionCount();
  92.     }
  93.     
  94.     $menuhandler =mosMenuHandler::getInstance();
  95.     
  96.     echo '<ul class="latestnews'.$class_sfx.'">';
  97.     
  98.     foreach $rows as $row {
  99.         // get Itemid
  100.         switch $type {
  101.             case 2:
  102.                 $Itemid $menuhandler->getIDByTypeCid ('content_typed'$row->id);
  103.                 break;
  104.                 
  105.             case 3:
  106.                 if $row->sectionid {
  107.                     $Itemid $mainframe->getItemid$row->id00$bs$bc$gbs );
  108.                 }
  109.                 else $Itemid $menuhandler->getIDByTypeCid ('content_typed'$row->id);
  110.                 break;
  111.  
  112.             case 1:
  113.             default:
  114.                 $Itemid $mainframe->getItemid$row->id00$bs$bc$gbs );
  115.                 break;
  116.         }
  117.         
  118.         // Blank itemid checker for SEF
  119.         if ($Itemid == NULL{
  120.             $Itemid '';
  121.         else {
  122.             $Itemid '&amp;Itemid='$Itemid;
  123.         }
  124.         
  125.         $link sefRelToAbs'index.php?option=com_content&amp;task=view&amp;id='$row->id $Itemid );
  126.         ?>
  127.         <li class="latestnews<?php echo $class_sfx?>">
  128.         <a href="<?php echo $link?>" class="latestnews<?php echo $class_sfx?>">
  129.         <?php echo $row->title?>
  130.         </a>
  131.         </li>
  132.         <?php
  133.     }
  134.     
  135.     echo '</ul>';
  136. }
  137. ?>

Documentation generated on Mon, 05 May 2008 16:21:17 +0400 by phpDocumentor 1.4.0