[ Index ]

PHP Cross Reference of Mambo 4.6.5

[ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/components/com_newsfeeds/ -> newsfeeds.php (source)

   1  <?php
   2  /**
   3  * @package Mambo
   4  * @subpackage Newsfeeds
   5  * @author Mambo Foundation Inc see README.php
   6  * @copyright (C) 2000 - 2009 Mambo Foundation Inc.
   7  * See COPYRIGHT.php for copyright notices and details.
   8  * @license GNU/GPL Version 2, see LICENSE.php
   9  *
  10  * Redistributions of files must retain the above copyright notice.
  11  *
  12  * Mambo is free software; you can redistribute it and/or
  13  * modify it under the terms of the GNU General Public License
  14  * as published by the Free Software Foundation; version 2 of the License.
  15  */
  16  
  17  /** ensure this file is being included by a parent file */
  18  defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
  19  
  20  // load the html drawing class
  21  require_once( $mainframe->getPath( 'front_html' ) );
  22  
  23  $feedid = intval( mosGetParam( $_REQUEST ,'feedid', 0 ) );
  24  $catid = intval( mosGetParam( $_REQUEST ,'catid', 0 ) );
  25  
  26  switch( $task ) {
  27      case 'view':
  28          showFeed( $option, $feedid );
  29          break;
  30      default:
  31          listFeeds( $option, $catid );
  32          break;
  33  }
  34  
  35  
  36  function listFeeds( $option, $catid ) {
  37      global $mainframe, $database, $my;
  38      global $mosConfig_shownoauth, $mosConfig_live_site, $mosConfig_absolute_path;
  39      global $cur_template, $Itemid;
  40  
  41      /* Query to retrieve all categories that belong under the contacts section and that are published. */
  42      $query = "SELECT cc.*, a.catid, COUNT(a.id) AS numlinks"
  43      . "\n FROM #__categories AS cc"
  44      . "\n LEFT JOIN #__newsfeeds AS a ON a.catid = cc.id"
  45      . "\n WHERE a.published='1'"
  46      . "\n AND cc.section='com_newsfeeds'"
  47      . "\n AND cc.published='1'"
  48      . "\n AND cc.access <= '". $my->gid ."'"
  49      . "\n GROUP BY cc.id"
  50      . "\n ORDER BY cc.ordering"
  51      ;
  52      $database->setQuery( $query );
  53      $categories = $database->loadObjectList();
  54  
  55      $rows = array();
  56      $currentcat = NULL;
  57      if ( $catid ) {
  58          // url links info for category
  59          $query = "SELECT *"
  60          . "\n FROM #__newsfeeds"
  61          . "\n WHERE catid = '". $catid."'"
  62           . "\n AND published='1'"
  63          . "\n ORDER BY ordering"
  64          ;
  65          $database->setQuery( $query );
  66          $rows = $database->loadObjectList();
  67  
  68          // current category info
  69          $query = "SELECT name, description, image, image_position"
  70          . "\n FROM #__categories"
  71          . "\n WHERE id = '". $catid ."'"
  72          . "\n AND published = '1'"
  73          . "\n AND access <= '". $my->gid ."'"
  74          ;
  75          $database->setQuery( $query );
  76          $database->loadObject( $currentcat );
  77      }
  78  
  79      // Parameters
  80      $menu =& new mosMenu( $database );
  81      $menu->load( $Itemid );
  82      $params =& new mosParameters( $menu->params );
  83  
  84      $params->def( 'page_title', 1 );
  85      $params->def( 'header', $menu->name );
  86      $params->def( 'pageclass_sfx', '' );
  87      $params->def( 'headings', 1 );
  88      $params->def( 'back_button', $mainframe->getCfg( 'back_button' ) );
  89      $params->def( 'description_text', '' );
  90      $params->def( 'image', -1 );
  91      $params->def( 'image_align', 'right' );
  92      $params->def( 'other_cat_section', 1 );
  93      // Category List Display control
  94      $params->def( 'other_cat', 1 );
  95      $params->def( 'cat_description', 1 );
  96      $params->def( 'cat_items', 1 );
  97      // Table Display control
  98      $params->def( 'headings', 1 );
  99      $params->def( 'name', 1 );
 100      $params->def( 'articles', '1' );
 101      $params->def( 'link', '1' );
 102  
 103      if ( $catid ) {
 104          $params->set( 'type', 'category' );
 105      } else {
 106          $params->set( 'type', 'section' );
 107      }
 108      
 109      // page description
 110      $currentcat->descrip = '';
 111      if( ( @$currentcat->description ) <> '' ) {
 112          $currentcat->descrip = $currentcat->description;
 113      } else if ( !$catid ) {
 114          // show description
 115          if ( $params->get( 'description' ) ) {
 116              $currentcat->descrip = $params->get( 'description_text' );
 117          }
 118      }
 119  
 120      // page image
 121      $currentcat->img = '';
 122      $path = $mosConfig_live_site .'/images/stories/';
 123      if ( ( @$currentcat->image ) <> '' ) {
 124          $currentcat->img = $path . $currentcat->image;
 125          $currentcat->align = $currentcat->image_position;
 126      } else if ( !$catid ) {
 127          if ( $params->get( 'image' ) <> -1 ) {
 128              $currentcat->img = $path . $params->get( 'image' );
 129              $currentcat->align = $params->get( 'image_align' );
 130          }
 131      }
 132  
 133      // page header
 134      $currentcat->header = '';
 135      if ( @$currentcat->name <> '' ) {
 136          $currentcat->header = $currentcat->name;
 137          $pathway =& mosPathway::getInstance();
 138          $pathway->addItem($currentcat->header, '');
 139      } else {
 140          $currentcat->header = $params->get( 'header' );
 141      }
 142      // used to show table rows in alternating colours
 143      $tabclass = array( 'sectiontableentry1', 'sectiontableentry2' );
 144  
 145      $mainframe->SetPageTitle($menu->name);
 146  
 147      HTML_newsfeed::displaylist( $categories, $rows, $catid, $currentcat, $params, $tabclass );
 148  }
 149  
 150  
 151  function showFeed( $option, $feedid ) {
 152      global $database, $mainframe, $mosConfig_absolute_path, $Itemid;
 153  
 154      // Adds parameter handling
 155      $menu =& new mosMenu( $database );
 156      $menu->load( $Itemid );
 157      $params =& new mosParameters( $menu->params );
 158      $params->def( 'page_title', 1 );
 159      $params->def( 'header', $menu->name );
 160      $params->def( 'pageclass_sfx', '' );
 161      $params->def( 'back_button', $mainframe->getCfg( 'back_button' ) );
 162      // Feed Display control
 163      $params->def( 'feed_image', 1 );
 164      $params->def( 'feed_descr', 1 );
 165      $params->def( 'item_descr', 1 );
 166      $params->def( 'word_count', 0 );    
 167      
 168      if ( !$params->get( 'page_title' ) ) {
 169          $params->set( 'header', '' );
 170      }
 171  
 172      $_and = '';
 173      if ( $feedid ) {
 174          $_and = "\n AND id='". $feedid ."'";
 175      }
 176  
 177      $query = "SELECT name, link, numarticles, cache_time"
 178      . "\n FROM #__newsfeeds"
 179      . "\n WHERE published='1'"
 180      . "\n AND checked_out='0'"
 181      . $_and
 182      . "\n ORDER BY ordering"
 183      ;
 184      $database->setQuery( $query );
 185      $newsfeeds = $database->loadObjectList();
 186  
 187      $mainframe->SetPageTitle($menu->name);
 188  
 189      HTML_newsfeed::showNewsfeeds( $newsfeeds, $params );
 190  }
 191  
 192  ?>