[ Index ]

PHP Cross Reference of Joomla 2.5.4 DE

title

Body

[close]

/administrator/components/com_contact/models/fields/modal/ -> contacts.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 contact picker.
  11   *
  12   * @package        Joomla.Administrator
  13   * @subpackage    com_contact
  14   * @since        1.6
  15   */
  16  class JFormFieldModal_Contacts extends JFormField
  17  {
  18      /**
  19       * The form field type.
  20       *
  21       * @var        string
  22       * @since    1.6
  23       */
  24      protected $type = 'Modal_Contacts';
  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', 'a.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          // Get the title of the linked chart
  50          $db = JFactory::getDBO();
  51          $db->setQuery(
  52              'SELECT name' .
  53              ' FROM #__contact_details' .
  54              ' WHERE id = '.(int) $this->value
  55          );
  56          $title = $db->loadResult();
  57  
  58          if ($error = $db->getErrorMsg()) {
  59              JError::raiseWarning(500, $error);
  60          }
  61  
  62          if (empty($title)) {
  63              $title = JText::_('COM_CONTACT_SELECT_A_CONTACT');
  64          }
  65  
  66          $link = 'index.php?option=com_contact&amp;view=contacts&amp;layout=modal&amp;tmpl=component&amp;function=jSelectChart_'.$this->id;
  67  
  68          $html = "\n".'<div class="fltlft"><input type="text" id="'.$this->id.'_name" value="'.htmlspecialchars($title, ENT_QUOTES, 'UTF-8').'" disabled="disabled" /></div>';
  69          $html .= '<div class="button2-left"><div class="blank"><a class="modal" title="'.JText::_('COM_CONTACT_CHANGE_CONTACT_BUTTON').'"  href="'.$link.'" rel="{handler: \'iframe\', size: {x: 800, y: 450}}">'.JText::_('COM_CONTACT_CHANGE_CONTACT_BUTTON').'</a></div></div>'."\n";
  70          // The active contact id field.
  71          if (0 == (int)$this->value) {
  72              $value = '';
  73          } else {
  74              $value = (int)$this->value;
  75          }
  76  
  77          // class='required' for client side validation
  78          $class = '';
  79          if ($this->required) {
  80              $class = ' class="required modal-value"';
  81          }
  82  
  83          $html .= '<input type="hidden" id="'.$this->id.'_id"'.$class.' name="'.$this->name.'" value="'.$value.'" />';
  84  
  85          return $html;
  86      }
  87  }


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