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('JPATH_BASE'or die;
  11.  
  12. /**
  13.  * Supports a modal newsfeeds picker.
  14.  *
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_newsfeeds
  17.  * @since       1.6
  18.  */
  19. {
  20.     /**
  21.      * The form field type.
  22.      *
  23.      * @var        string 
  24.      * @since   1.6
  25.      */
  26.     protected $type = 'Modal_Newsfeed';
  27.  
  28.     /**
  29.      * Method to get the field input markup.
  30.      *
  31.      * @return  string    The field input markup.
  32.      * @since   1.6
  33.      */
  34.     protected function getInput()
  35.     {
  36.         $allowEdit        ((string) $this->element['edit'== 'true'true false;
  37.         $allowClear        ((string) $this->element['clear'!= 'false'true false;
  38.  
  39.         // Load language
  40.         JFactory::getLanguage()->load('com_newsfeeds'JPATH_ADMINISTRATOR);
  41.  
  42.         // Load the javascript
  43.         JHtml::_('behavior.framework');
  44.         JHtml::_('behavior.modal''a.modal');
  45.         JHtml::_('bootstrap.tooltip');
  46.  
  47.         // Build the script.
  48.         $script array();
  49.  
  50.         // Select button script
  51.         $script['    function jSelectNewsfeed_'.$this->id.'(id, name, object) {';
  52.         $script['        document.id("'.$this->id.'_id").value = id;';
  53.         $script['        document.id("'.$this->id.'_name").value = name;';
  54.  
  55.         if ($allowEdit)
  56.         {
  57.             $script['        jQuery("#'.$this->id.'_edit").removeClass("hidden");';
  58.         }
  59.  
  60.         if ($allowClear)
  61.         {
  62.             $script['        jQuery("#'.$this->id.'_clear").removeClass("hidden");';
  63.         }
  64.  
  65.         $script['        SqueezeBox.close();';
  66.         $script['    }';
  67.  
  68.         // Clear button script
  69.         static $scriptClear;
  70.  
  71.         if ($allowClear && !$scriptClear)
  72.         {
  73.             $scriptClear true;
  74.  
  75.             $script['    function jClearNewsfeed(id) {';
  76.             $script['        document.getElementById(id + "_id").value = "";';
  77.             $script['        document.getElementById(id + "_name").value = "'.htmlspecialchars(JText::_('COM_NEWSFEEDS_SELECT_A_FEED'true)ENT_COMPAT'UTF-8').'";';
  78.             $script['        jQuery("#"+id + "_clear").addClass("hidden");';
  79.             $script['        if (document.getElementById(id + "_edit")) {';
  80.             $script['            jQuery("#"+id + "_edit").addClass("hidden");';
  81.             $script['        }';
  82.             $script['        return false;';
  83.             $script['    }';
  84.         }
  85.  
  86.         // Add the script to the document head.
  87.         JFactory::getDocument()->addScriptDeclaration(implode("\n"$script));
  88.  
  89.         // Setup variables for display.
  90.         $html    array();
  91.         $link    'index.php?option=com_newsfeeds&amp;view=newsfeeds&amp;layout=modal&amp;tmpl=component&amp;function=jSelectNewsfeed_'.$this->id;
  92.  
  93.         if (isset($this->element['language']))
  94.         {
  95.             $link .= '&amp;forcedLanguage='.$this->element['language'];
  96.         }
  97.  
  98.         // Get the title of the linked chart
  99.         $db JFactory::getDbo();
  100.         $db->setQuery(
  101.             'SELECT name' .
  102.             ' FROM #__newsfeeds' .
  103.             ' WHERE id = '.(int) $this->value
  104.         );
  105.  
  106.         try
  107.         {
  108.             $title $db->loadResult();
  109.         }
  110.         catch (RuntimeException $e)
  111.         {
  112.             JError::raiseWarning(500$e->getMessage);
  113.         }
  114.  
  115.         if (empty($title))
  116.         {
  117.             $title JText::_('COM_NEWSFEEDS_SELECT_A_FEED');
  118.         }
  119.         $title htmlspecialchars($titleENT_QUOTES'UTF-8');
  120.  
  121.         // The active newsfeed id field.
  122.         if (== (int) $this->value)
  123.         {
  124.             $value '';
  125.         }
  126.         else
  127.         {
  128.             $value = (int) $this->value;
  129.         }
  130.  
  131.         // The current newsfeed display field.
  132.         $html['<span class="input-append">';
  133.         $html['<input type="text" class="input-medium" id="'.$this->id.'_name" value="'.$title.'" disabled="disabled" size="35" />';
  134.         $html['<a class="modal btn hasTooltip" title="'.JHtml::tooltipText('COM_NEWSFEEDS_CHANGE_FEED_BUTTON').'"  href="'.$link.'&amp;'.JSession::getFormToken().'=1" rel="{handler: \'iframe\', size: {x: 800, y: 450}}"><i class="icon-file"></i> '.JText::_('JSELECT').'</a>';
  135.  
  136.         // Edit newsfeed button
  137.         if ($allowEdit)
  138.         {
  139.             $html['<a class="btn hasTooltip'.($value '' ' hidden').'" href="index.php?option=com_newsfeeds&layout=modal&tmpl=component&task=newsfeed.edit&id=' $value'" target="_blank" title="'.JHtml::tooltipText('COM_NEWSFEEDS_EDIT_NEWSFEED').'" ><span class="icon-edit"></span> ' JText::_('JACTION_EDIT''</a>';
  140.         }
  141.  
  142.         // Clear newsfeed button
  143.         if ($allowClear)
  144.         {
  145.             $html['<button id="'.$this->id.'_clear" class="btn'.($value '' ' hidden').'" onclick="return jClearNewsfeed(\''.$this->id.'\')"><span class="icon-remove"></span> ' JText::_('JCLEAR''</button>';
  146.         }
  147.  
  148.         $html['</span>';
  149.  
  150.         // class='required' for client side validation
  151.         $class '';
  152.  
  153.         if ($this->required)
  154.         {
  155.             $class ' class="required modal-value"';
  156.         }
  157.  
  158.         $html['<input type="hidden" id="'.$this->id.'_id"'.$class.' name="'.$this->name.'" value="'.$value.'" />';
  159.  
  160.         return implode("\n"$html);
  161.     }
  162. }

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