[ Index ]

PHP Cross Reference of Joomla 2.5.4 DE

title

Body

[close]

/administrator/components/com_newsfeeds/models/fields/modal/ -> newsfeeds.php (source)

   1  <?php
   2  /**
   3   * @copyright    Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
   4   * @license        GNU General Public License version 2 or later; see LICENSE.txt
   5   */
   6  
   7  defined('JPATH_BASE') or die;
   8  
   9  /**
  10   * Supports a modal newsfeeds picker.
  11   *
  12   * @package        Joomla.Administrator
  13   * @subpackage    com_newsfeeds
  14   * @since        1.6
  15   */
  16  class JFormFieldModal_Newsfeeds extends JFormField
  17  {
  18      /**
  19       * The form field type.
  20       *
  21       * @var        string
  22       * @since    1.6
  23       */
  24      protected $type = 'Modal_Newsfeeds';
  25  
  26      /**
  27       * Method to get the field input markup.
  28       *
  29       * @return    string    The field input markup.
  30       * @since    1.6
  31       */
  32  	protected function getInput()
  33      {
  34          // Load the javascript
  35          JHtml::_('behavior.framework');
  36          JHtml::_('behavior.modal', 'input.modal');
  37  
  38          // Build the script.
  39          $script = array();
  40          $script[] = '    function jSelectChart_'.$this->id.'(id, name, object) {';
  41          $script[] = '        document.id("'.$this->id.'_id").value = id;';
  42          $script[] = '        document.id("'.$this->id.'_name").value = name;';
  43          $script[] = '        SqueezeBox.close();';
  44          $script[] = '    }';
  45  
  46          // Add the script to the document head.
  47          JFactory::getDocument()->addScriptDeclaration(implode("\n", $script));
  48  
  49          // Build the script.
  50          $script = array();
  51          $script[] = '    window.addEvent("domready", function() {';
  52          $script[] = '        var div = new Element("div").setStyle("display", "none").inject(document.id("menu-types"), "before");';
  53          $script[] = '        document.id("menu-types").inject(div, "bottom");';
  54          $script[] = '    });';
  55  
  56          // Add the script to the document head.
  57          JFactory::getDocument()->addScriptDeclaration(implode("\n", $script));
  58  
  59  
  60          // Get the title of the linked chart
  61          $db = JFactory::getDBO();
  62          $db->setQuery(
  63              'SELECT name' .
  64              ' FROM #__newsfeeds' .
  65              ' WHERE id = '.(int) $this->value
  66          );
  67          $title = $db->loadResult();
  68  
  69          if ($error = $db->getErrorMsg()) {
  70              JError::raiseWarning(500, $error);
  71          }
  72  
  73          if (empty($title)) {
  74              $title = JText::_('COM_NEWSFEEDS_SELECT_A_FEED');
  75          }
  76  
  77          $link = 'index.php?option=com_newsfeeds&amp;view=newsfeeds&amp;layout=modal&amp;tmpl=component&amp;function=jSelectChart_'.$this->id;
  78  
  79          JHtml::_('behavior.modal', 'a.modal');
  80          $html = "\n".'<div class="fltlft"><input type="text" id="'.$this->id.'_name" value="'.htmlspecialchars($title, ENT_QUOTES, 'UTF-8').'" disabled="disabled" /></div>';
  81          $html .= '<div class="button2-left"><div class="blank"><a class="modal" title="'.JText::_('COM_NEWSFEEDS_CHANGE_FEED_BUTTON').'"  href="'.$link.'" rel="{handler: \'iframe\', size: {x: 800, y: 450}}">'.JText::_('COM_NEWSFEEDS_CHANGE_FEED_BUTTON').'</a></div></div>'."\n";
  82          // The active newsfeed id field.
  83          if (0 == (int)$this->value) {
  84              $value = '';
  85          } else {
  86              $value = (int)$this->value;
  87          }
  88  
  89          // class='required' for client side validation
  90          $class = '';
  91          if ($this->required) {
  92              $class = ' class="required modal-value"';
  93          }
  94  
  95          $html .= '<input type="hidden" id="'.$this->id.'_id"'.$class.' name="'.$this->name.'" value="'.$value.'" />';
  96  
  97          return $html;
  98      }
  99  }


Generated: Tue Apr 3 11:40:28 2012 Cross-referenced by PHPXref 0.7.1