[ Index ]

PHP Cross Reference of Joomla 2.5.4 DE

title

Body

[close]

/administrator/components/com_content/models/fields/modal/ -> article.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 article picker.
  11   *
  12   * @package        Joomla.Administrator
  13   * @subpackage    com_content
  14   * @since        1.6
  15   */
  16  class JFormFieldModal_Article extends JFormField
  17  {
  18      /**
  19       * The form field type.
  20       *
  21       * @var        string
  22       * @since    1.6
  23       */
  24      protected $type = 'Modal_Article';
  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 modal behavior script.
  35          JHtml::_('behavior.modal', 'a.modal');
  36  
  37          // Build the script.
  38          $script = array();
  39          $script[] = '    function jSelectArticle_'.$this->id.'(id, title, catid, object) {';
  40          $script[] = '        document.id("'.$this->id.'_id").value = id;';
  41          $script[] = '        document.id("'.$this->id.'_name").value = title;';
  42          $script[] = '        SqueezeBox.close();';
  43          $script[] = '    }';
  44  
  45          // Add the script to the document head.
  46          JFactory::getDocument()->addScriptDeclaration(implode("\n", $script));
  47  
  48  
  49          // Setup variables for display.
  50          $html    = array();
  51          $link    = 'index.php?option=com_content&amp;view=articles&amp;layout=modal&amp;tmpl=component&amp;function=jSelectArticle_'.$this->id;
  52  
  53          $db    = JFactory::getDBO();
  54          $db->setQuery(
  55              'SELECT title' .
  56              ' FROM #__content' .
  57              ' WHERE id = '.(int) $this->value
  58          );
  59          $title = $db->loadResult();
  60  
  61          if ($error = $db->getErrorMsg()) {
  62              JError::raiseWarning(500, $error);
  63          }
  64  
  65          if (empty($title)) {
  66              $title = JText::_('COM_CONTENT_SELECT_AN_ARTICLE');
  67          }
  68          $title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
  69  
  70          // The current user display field.
  71          $html[] = '<div class="fltlft">';
  72          $html[] = '  <input type="text" id="'.$this->id.'_name" value="'.$title.'" disabled="disabled" size="35" />';
  73          $html[] = '</div>';
  74  
  75          // The user select button.
  76          $html[] = '<div class="button2-left">';
  77          $html[] = '  <div class="blank">';
  78          $html[] = '    <a class="modal" title="'.JText::_('COM_CONTENT_CHANGE_ARTICLE').'"  href="'.$link.'&amp;'.JSession::getFormToken().'=1" rel="{handler: \'iframe\', size: {x: 800, y: 450}}">'.JText::_('COM_CONTENT_CHANGE_ARTICLE_BUTTON').'</a>';
  79          $html[] = '  </div>';
  80          $html[] = '</div>';
  81  
  82          // The active article 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 implode("\n", $html);
  98      }
  99  }


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