protected function formatDetail($values, $info, Person $person)
 {
     if (isset($info['format'])) {
         $value = vsprintf($this->replaceFormat($info['format']), $values);
     } else {
         $delimiter = isset($info['delimiter']) ? $info['delimiter'] : ' ';
         $value = implode($delimiter, $values);
     }
     $detail = array('label' => isset($info['label']) ? $info['label'] : '', 'title' => $value);
     switch (isset($info['type']) ? $info['type'] : 'text') {
         case 'email':
             $detail['title'] = str_replace('@', '@­', $detail['title']);
             $detail['url'] = "mailto:{$value}";
             $detail['class'] = 'email';
             break;
         case 'phone':
             $detail['title'] = str_replace('-', '-­', $detail['title']);
             if (strpos($value, '+1') !== 0) {
                 $value = "+1{$value}";
             }
             $detail['url'] = PhoneFormatter::getPhoneURL($value);
             $detail['class'] = 'phone';
             break;
         case 'imgdata':
             $detail['title'] = "";
             $detail['class'] = 'img';
             $detail['img'] = $this->buildURL('photo', array('id' => $person->getID()));
             break;
         case 'imgurl':
             $detail['title'] = "";
             $detail['class'] = 'img';
             $detail['img'] = $value;
             break;
             // compatibility
         // compatibility
         case 'map':
             $info['module'] = 'map';
             break;
     }
     if (isset($info['module'])) {
         $detail = array_merge($detail, Kurogo::moduleLinkForValue($info['module'], $value, $this, $person));
     }
     if (isset($info['urlfunc'])) {
         $urlFunction = create_function('$value,$person', $info['urlfunc']);
         $detail['url'] = $urlFunction($value, $person);
     }
     $detail['title'] = nl2br($detail['title']);
     return $detail;
 }
 protected function urlForType($type, $value)
 {
     $urlForType = null;
     switch ($type) {
         case 'url':
             $urlForType = str_replace("http://http://", "http://", $value);
             if (strlen($urlForType) && !preg_match('/^http\\:\\/\\//', $urlForType)) {
                 $urlForType = 'http://' . $urlForType;
             }
             break;
         case 'phone':
             $urlForType = PhoneFormatter::getPhoneURL($value);
             break;
         case 'email':
             $urlForType = "mailto:{$value}";
             break;
         case 'category':
             $urlForType = $this->categoryURL($value, false);
             break;
     }
     return $urlForType;
 }
 protected function formatDetailFieldInfo($value, $info, KurogoDataObject $object)
 {
     // if the value is empty then see if there is a ifBlankfield
     if (is_null($value) || is_string($value) && strlen($value) == 0) {
         if (isset($info['ifBlank'])) {
             $info['title'] = $info['ifBlank'];
             $info['titlefield'] = null;
         } else {
             return null;
         }
     }
     $type = Kurogo::arrayVal($info, 'type', 'text');
     if (is_array($value)) {
         if (isset($info['format'])) {
             $value = vsprintf($this->replaceFormat($info['format']), $value);
         } else {
             $delimiter = isset($info['delimiter']) ? $info['delimiter'] : ' ';
             $value = implode($delimiter, $value);
         }
     } elseif (is_object($value)) {
         if ($type == 'date') {
             if (!$value instanceof DateTime) {
                 throw new KurogoDataException("Date type must be an instance of DateTime");
             }
             $value = $value->format('U');
         } else {
             throw new KurogoDataException("Value is an object. This needs to be traced");
         }
     }
     $detail = $info;
     foreach (array('title', 'subtitle', 'label', 'url', 'class', 'img', 'listclass', 'imagealt', 'imageheight', 'imagewidth') as $attrib) {
         if (isset($info[$attrib . 'field'])) {
             $detail[$attrib] = $this->getObjectField($object, $info[$attrib . 'field']);
         }
     }
     if (!isset($detail['class'])) {
         $detail['class'] = '';
     }
     switch ($type) {
         case 'email':
             if (!isset($detail['title'])) {
                 $detail['title'] = str_replace('@', '@­', $value);
             }
             $detail['url'] = "mailto:{$value}";
             $detail['class'] = trim(Kurogo::arrayVal($detail, 'class', '') . ' email');
             break;
         case 'phone':
             if (!isset($detail['title'])) {
                 $detail['title'] = str_replace('-', '-­', $value);
             }
             if (strpos($value, '+1') !== 0) {
                 $value = "+1{$value}";
             }
             $detail['url'] = PhoneFormatter::getPhoneURL($value);
             $detail['class'] = trim(Kurogo::arrayVal($detail, 'class', '') . ' phone');
             break;
         case 'currency':
             if (!isset($detail['title'])) {
                 $detail['title'] = sprintf("\$%s", number_format($value, 2));
             }
             break;
         case 'date':
             if (!isset($detail['title'])) {
                 $format = Kurogo::arrayVal($detail, 'format', '%m/%d/%Y');
                 $detail['title'] = strftime($format, $value);
             }
             break;
         case 'text':
             if (!isset($detail['title'])) {
                 $detail['title'] = nl2br(trim($value));
             }
             break;
         case 'image':
             $url = $value;
             $alt = Kurogo::arrayVal($detail, 'imagealt');
             if ($height = Kurogo::arrayVal($detail, 'imageheight')) {
                 $height = sprintf('height="%d"', $height);
             }
             if ($width = Kurogo::arrayVal($detail, 'imagewidth')) {
                 $width = sprintf('width="%d"', $width);
             }
             if (!isset($detail['title'])) {
                 $detail['title'] = sprintf('<img src="%s" alt="%s" %s %s class="detailimage" />', $value, htmlentities($alt), $height, $width);
             }
             break;
         default:
             throw new KurogoConfigurationException("Unhandled type {$type}");
             break;
     }
     if (isset($info['module'])) {
         $modValue = $value;
         if (isset($info['value'])) {
             $modValue = $this->getObjectField($object, $info['value']);
         }
         $moduleLink = Kurogo::moduleLinkForValue($info['module'], $modValue, $this->module, $object);
         $detail = array_merge($moduleLink, $detail);
         $detail['class'] .= " " . Kurogo::arrayVal($moduleLink, 'class');
     } elseif (isset($info['page'])) {
         $pageValue = $value;
         if (isset($info['value'])) {
             $pageValue = $this->getObjectField($object, $info['value']);
         }
         $pageLink = $this->module->pageLinkForValue($info['page'], $pageValue, $object);
         $detail = array_merge($pageLink, $detail);
         $detail['class'] .= " " . Kurogo::arrayVal($pageLink, 'class');
     }
     return $detail;
 }
 public function getPhoneDialable()
 {
     return PhoneFormatter::getPhoneURL($this->phone);
 }