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('_JEXEC'or die;
  11.  
  12. JLoader::register('ContactHelper'JPATH_ADMINISTRATOR '/components/com_contact/helpers/contact.php');
  13.  
  14. /**
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_contact
  17.  */
  18. abstract class JHtmlContact
  19. {
  20.     /**
  21.      * Get the associated language flags
  22.      *
  23.      * @param   int  $contactid  The item id to search associations
  24.      *
  25.      * @return  string  The language HTML
  26.      */
  27.     public static function association($contactid)
  28.     {
  29.         // Defaults
  30.         $html '';
  31.  
  32.         // Get the associations
  33.         if ($associations JLanguageAssociations::getAssociations('com_contact''#__contact_details''com_contact.item'$contactid))
  34.         {
  35.             foreach ($associations as $tag => $associated)
  36.             {
  37.                 $associations[$tag= (int) $associated->id;
  38.             }
  39.  
  40.             // Get the associated contact items
  41.             $db JFactory::getDbo();
  42.             $query $db->getQuery(true)
  43.                 ->select('c.id, c.name as title')
  44.                 ->select('l.sef as lang_sef')
  45.                 ->from('#__contact_details as c')
  46.                 ->select('cat.title as category_title')
  47.                 ->join('LEFT''#__categories as cat ON cat.id=c.catid')
  48.                 ->where('c.id IN (' implode(','array_values($associations)) ')')
  49.                 ->join('LEFT''#__languages as l ON c.language=l.lang_code')
  50.                 ->select('l.image')
  51.                 ->select('l.title as language_title');
  52.             $db->setQuery($query);
  53.  
  54.             try
  55.             {
  56.                 $items $db->loadObjectList('id');
  57.             }
  58.             catch (runtimeException $e)
  59.             {
  60.                 throw new Exception($e->getMessage()500);
  61.  
  62.                 return false;
  63.             }
  64.  
  65.             if ($items)
  66.             {
  67.                 foreach ($items as &$item)
  68.                 {
  69.                     $text strtoupper($item->lang_sef);
  70.                     $url JRoute::_('index.php?option=com_contact&task=contact.edit&id=' . (int) $item->id);
  71.                     $tooltipParts array(
  72.                         JHtml::_('image''mod_languages/' $item->image '.gif',
  73.                                 $item->language_title,
  74.                                 array('title' => $item->language_title),
  75.                                 true
  76.                         ),
  77.                         $item->title,
  78.                         '(' $item->category_title ')'
  79.                     );
  80.  
  81.                     $item->link JHtml::_('tooltip'implode(' '$tooltipParts)nullnull$text$urlnull'hasTooltip label label-association label-' $item->lang_sef);
  82.                 }
  83.             }
  84.  
  85.             $html JLayoutHelper::render('joomla.content.associations'$items);
  86.         }
  87.  
  88.         return $html;
  89.     }
  90.  
  91.     /**
  92.      * @param   int $value    The featured value
  93.      * @param   int $i 
  94.      * @param   bool $canChange Whether the value can be changed or not
  95.      *
  96.      * @return  string    The anchor tag to toggle featured/unfeatured contacts.
  97.      * @since   1.6
  98.      */
  99.     public static function featured($value 0$i$canChange true)
  100.     {
  101.         // Array of image, task, title, action
  102.         $states    array(
  103.             0    => array('disabled.png''contacts.featured''COM_CONTACT_UNFEATURED''COM_CONTACT_TOGGLE_TO_FEATURE'),
  104.             1    => array('featured.png''contacts.unfeatured''JFEATURED''COM_CONTACT_TOGGLE_TO_UNFEATURE'),
  105.         );
  106.         $state    JArrayHelper::getValue($states(int) $value$states[1]);
  107.         $html    JHtml::_('image''admin/'.$state[0]JText::_($state[2])nulltrue);
  108.         if ($canChange)
  109.         {
  110.             $html    '<a href="#" onclick="return listItemTask(\'cb'.$i.'\',\''.$state[1].'\')" title="'.JText::_($state[3]).'">'
  111.                     . $html .'</a>';
  112.         }
  113.  
  114.         return $html;
  115.     }
  116. }

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