Source for file newsfeed.php

Documentation is available at newsfeed.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  com_newsfeeds
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  8.  */
  9.  
  10. defined('_JEXEC'or die;
  11.  
  12. JLoader::register('NewsfeedsHelper'JPATH_ADMINISTRATOR '/components/com_newsfeeds/helpers/newsfeeds.php');
  13.  
  14. /**
  15.  * Utility class for creating HTML Grids
  16.  *
  17.  * @static
  18.  * @package     Joomla.Administrator
  19.  * @subpackage  com_newsfeeds
  20.  * @since       1.5
  21.  */
  22. {
  23.     /**
  24.      * Get the associated language flags
  25.      *
  26.      * @param   int  $newsfeedid  The item id to search associations
  27.      *
  28.      * @return  string  The language HTML
  29.      */
  30.     public static function association($newsfeedid)
  31.     {
  32.         // Defaults
  33.         $html '';
  34.  
  35.         // Get the associations
  36.         if ($associations JLanguageAssociations::getAssociations('com_newsfeeds''#__newsfeeds''com_newsfeeds.item'$newsfeedid))
  37.         {
  38.             foreach ($associations as $tag => $associated)
  39.             {
  40.                 $associations[$tag= (int) $associated->id;
  41.             }
  42.  
  43.             // Get the associated newsfeed items
  44.             $db JFactory::getDbo();
  45.             $query $db->getQuery(true)
  46.                 ->select('c.id, c.name as title')
  47.                 ->select('l.sef as lang_sef')
  48.                 ->from('#__newsfeeds as c')
  49.                 ->select('cat.title as category_title')
  50.                 ->join('LEFT''#__categories as cat ON cat.id=c.catid')
  51.                 ->where('c.id IN (' implode(','array_values($associations)) ')')
  52.                 ->join('LEFT''#__languages as l ON c.language=l.lang_code')
  53.                 ->select('l.image')
  54.                 ->select('l.title as language_title');
  55.             $db->setQuery($query);
  56.  
  57.             try
  58.             {
  59.                 $items $db->loadObjectList('id');
  60.             }
  61.             catch (RuntimeException $e)
  62.             {
  63.                 throw new Exception($e->getMessage()500);
  64.             }
  65.  
  66.             if ($items)
  67.             {
  68.                 foreach ($items as &$item)
  69.                 {
  70.                     $text strtoupper($item->lang_sef);
  71.                     $url JRoute::_('index.php?option=com_newsfeeds&task=newsfeed.edit&id=' . (int) $item->id);
  72.                     $tooltipParts array(
  73.                         JHtml::_('image''mod_languages/' $item->image '.gif',
  74.                             $item->language_title,
  75.                             array('title' => $item->language_title),
  76.                             true
  77.                         ),
  78.                         $item->title,
  79.                         '(' $item->category_title ')'
  80.                     );
  81.                     $item->link JHtml::_('tooltip'implode(' '$tooltipParts)nullnull$text$urlnull'hasTooltip label label-association label-' $item->lang_sef);
  82.                 }
  83.             }
  84.  
  85.             $html JLayoutHelper::render('joomla.content.associations'$items);
  86.         }
  87.  
  88.         return $html;
  89.     }
  90. }

Documentation generated on Tue, 19 Nov 2013 15:09:23 +0100 by phpDocumentor 1.4.3