Source for file contact.php

Documentation is available at contact.php

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

Documentation generated on Tue, 19 Nov 2013 14:56:35 +0100 by phpDocumentor 1.4.3