예제 #1
0
 /**
  * given a contact type, get the contact image
  *
  * @param string $contact_type
  *
  * @return string
  * @access public
  * @static
  */
 static function getImage($contactType, $urlOnly = false, $contactId = null)
 {
     static $imageInfo = array();
     if (!array_key_exists($contactType, $imageInfo)) {
         $imageInfo[$contactType] = array();
         $typeInfo = array();
         $params = array('name' => $contactType);
         require_once 'CRM/Contact/BAO/ContactType.php';
         CRM_Contact_BAO_ContactType::retrieve($params, $typeInfo);
         if (CRM_Utils_Array::value('image_URL', $typeInfo)) {
             $imageUrl = $typeInfo['image_URL'];
             $config = CRM_Core_Config::singleton();
             if (!preg_match("/^(\\/|(http(s)?:)).+\$/i", $imageUrl)) {
                 $imageUrl = $config->resourceBase . $imageUrl;
             }
             $imageInfo[$contactType]['image'] = "<div class=\"icon crm-icon {$typeInfo['name']}-icon\" style=\"background: url('{$imageUrl}')\" title=\"{$contactType}\"></div>";
             $imageInfo[$contactType]['url'] = $imageUrl;
         } else {
             $isSubtype = array_key_exists('parent_id', $typeInfo) && $typeInfo['parent_id'] ? true : false;
             if ($isSubtype) {
                 $type = CRM_Contact_BAO_ContactType::getBasicType($typeInfo['name']) . "-subtype";
             } else {
                 $type = $typeInfo['name'];
             }
             $imageInfo[$contactType]['image'] = "<div class=\"icon crm-icon {$type}-icon\" title=\"{$contactType}\"></div>";
             $imageInfo[$contactType]['url'] = null;
         }
     }
     $summaryOvelayProfileId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', 'summary_overlay', 'id', 'name');
     $profileURL = CRM_Utils_System::url('civicrm/profile/view', "reset=1&gid={$summaryOvelayProfileId}&id={$contactId}&snippet=4");
     $imageInfo[$contactType]['summary-link'] = '<a href="' . $profileURL . '" class="crm-summary-link">' . $imageInfo[$contactType]["image"] . '</a>';
     return $urlOnly ? $imageInfo[$contactType]['url'] : $imageInfo[$contactType]['summary-link'];
 }
예제 #2
0
파일: Utils.php 프로젝트: ksecor/civicrm
 /**
  * given a contact type, get the contact image
  *
  * @param string $contact_type
  *
  * @return string
  * @access public
  * @static
  */
 static function getImage($contactType, $urlOnly = false)
 {
     static $imageInfo = array();
     if (!array_key_exists($contactType, $imageInfo)) {
         $imageInfo[$contactType] = array();
         $params = array('name' => $contactType);
         CRM_Contact_BAO_ContactType::retrieve($params, $typeInfo);
         if ($typeInfo['image_URL']) {
             $imageUrl = $typeInfo['image_URL'];
             $config =& CRM_Core_Config::singleton();
             if (!preg_match("/^(\\/|(http(s)?:)).+\$/i", $imageUrl)) {
                 $imageUrl = $config->resourceBase . $imageUrl;
             }
             $imageInfo[$contactType]['image'] = "<div class=\"icon crm-icon {$typeInfo['name']}-icon\" style=\"background: url('{$imageUrl}')\"></div>";
             $imageInfo[$contactType]['url'] = $imageUrl;
         } else {
             $isSubtype = array_key_exists('parent_id', $typeInfo) && $typeInfo['parent_id'] ? true : false;
             if ($isSubtype) {
                 $type = CRM_Contact_BAO_ContactType::getBasicType($typeInfo['name']) . "-subtype";
             } else {
                 $type = $typeInfo['name'];
             }
             $imageInfo[$contactType]['image'] = "<div class=\"icon crm-icon {$type}-icon\"></div>";
             $imageInfo[$contactType]['url'] = null;
         }
     }
     return $urlOnly ? $imageInfo[$contactType]['url'] : $imageInfo[$contactType]['image'];
 }
예제 #3
0
 /**
  * Given a contact type, get the contact image.
  *
  * @param string $contactType
  *   Contact type.
  * @param bool $urlOnly
  *   If we need to return only image url.
  * @param int $contactId
  *   Contact id.
  * @param bool $addProfileOverlay
  *   If profile overlay class should be added.
  *
  * @return string
  */
 public static function getImage($contactType, $urlOnly = FALSE, $contactId = NULL, $addProfileOverlay = TRUE)
 {
     static $imageInfo = array();
     $contactType = explode(CRM_Core_DAO::VALUE_SEPARATOR, trim($contactType, CRM_Core_DAO::VALUE_SEPARATOR));
     $contactType = $contactType[0];
     if (!array_key_exists($contactType, $imageInfo)) {
         $imageInfo[$contactType] = array();
         $typeInfo = array();
         $params = array('name' => $contactType);
         CRM_Contact_BAO_ContactType::retrieve($params, $typeInfo);
         if (!empty($typeInfo['image_URL'])) {
             $imageUrl = $typeInfo['image_URL'];
             $config = CRM_Core_Config::singleton();
             if (!preg_match("/^(\\/|(http(s)?:)).+\$/i", $imageUrl)) {
                 $imageUrl = $config->resourceBase . $imageUrl;
             }
             $imageInfo[$contactType]['image'] = "<div class=\"icon crm-icon {$typeInfo['name']}-icon\" style=\"background: url('{$imageUrl}')\" title=\"{$contactType}\"></div>";
             $imageInfo[$contactType]['url'] = $imageUrl;
         } else {
             $isSubtype = array_key_exists('parent_id', $typeInfo) && $typeInfo['parent_id'] ? TRUE : FALSE;
             if ($isSubtype) {
                 $type = CRM_Contact_BAO_ContactType::getBasicType($typeInfo['name']) . '-subtype';
             } else {
                 $type = CRM_Utils_Array::value('name', $typeInfo);
             }
             // do not add title since it hides contact name
             if ($addProfileOverlay) {
                 $imageInfo[$contactType]['image'] = "<div class=\"icon crm-icon {$type}-icon\"></div>";
             } else {
                 $imageInfo[$contactType]['image'] = "<div class=\"icon crm-icon {$type}-icon\" title=\"{$contactType}\"></div>";
             }
             $imageInfo[$contactType]['url'] = NULL;
         }
     }
     if ($addProfileOverlay) {
         static $summaryOverlayProfileId = NULL;
         if (!$summaryOverlayProfileId) {
             $summaryOverlayProfileId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', 'summary_overlay', 'id', 'name');
         }
         $profileURL = CRM_Utils_System::url('civicrm/profile/view', "reset=1&gid={$summaryOverlayProfileId}&id={$contactId}&snippet=4");
         $imageInfo[$contactType]['summary-link'] = '<a href="' . $profileURL . '" class="crm-summary-link">' . $imageInfo[$contactType]['image'] . '</a>';
     } else {
         $imageInfo[$contactType]['summary-link'] = $imageInfo[$contactType]['image'];
     }
     return $urlOnly ? $imageInfo[$contactType]['url'] : $imageInfo[$contactType]['summary-link'];
 }