コード例 #1
0
 protected function formatDetail($values, $info, Person $person)
 {
     if (isset($info['format'])) {
         $value = vsprintf($this->replaceFormat($info['format']), $values);
     } else {
         $value = implode(' ', $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'] = 'tel:' . strtr($value, '-', '');
             $detail['class'] = 'phone';
             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;
 }
コード例 #2
0
 protected function initializeForPage()
 {
     switch ($this->page) {
         case 'help':
             break;
         case 'pane':
             $start = new DateTime(date('Y-m-d H:i:s', time()), $this->timezone);
             $start->setTime(0, 0, 0);
             $end = clone $start;
             $end->setTime(23, 59, 59);
             $type = $this->getArg('type', 'static');
             $calendar = $this->getArg('calendar', $this->getDefaultFeed($type));
             $options = array('type' => $type, 'calendar' => $calendar, 'start' => $start, 'end' => $end);
             $iCalEvents = $this->searchItems('', null, $options);
             $options['noBreadcrumbs'] = true;
             $events = array();
             foreach ($iCalEvents as $iCalEvent) {
                 $events[] = $this->linkforItem($iCalEvent, $options, false);
             }
             $this->assign('events', $events);
             break;
         case 'resources':
             if ($resourceFeeds = $this->getFeeds('resource')) {
                 $resources = array();
                 foreach ($resourceFeeds as $calendar => $resource) {
                     $feed = $this->getFeed($calendar, 'resource');
                     $availability = $this->getLocalizedString('RESOURCE_AVAILABLE');
                     if ($event = $feed->getNextEvent()) {
                         $now = time();
                         if ($event->overlaps(new TimeRange($now, $now))) {
                             $availability = $this->getLocalizedString('RESOURCE_IN_USE');
                         } elseif ($event->overlaps(new TimeRange($now + 900, $now + 1800))) {
                             $availability = $this->getLocalizedString('RESOURCE_IN_USE_TIME', $this->timeText($event, true));
                         }
                     }
                     $resources[$calendar] = array('title' => $resource['TITLE'], 'subtitle' => $availability, 'url' => $this->buildBreadcrumbURL('day', array('type' => 'resource', 'calendar' => $calendar)));
                 }
                 $this->assign('resources', $resources);
             } else {
                 $this->redirectTo('index');
             }
             break;
         case 'user':
             if ($userFeeds = $this->getFeeds('user')) {
                 $userCalendars = array();
                 foreach ($userFeeds as $id => $calendar) {
                     $userCalendars[$id] = array('title' => $calendar['TITLE'], 'url' => $this->buildBreadcrumbURL('day', array('type' => 'user', 'calendar' => $id)));
                 }
                 $this->assign('userCalendars', $userCalendars);
             } else {
                 $this->redirectTo('index');
             }
             break;
         case 'index':
             if ($userCalendar = $this->getDefaultFeed('user')) {
                 $this->assign('selectedFeed', 'user|' . $userCalendar);
                 $feed = $this->getFeed($userCalendar, 'user');
                 $feeds = $this->getFeeds('user');
                 $upcomingEvents = array();
                 if ($event = $feed->getNextEvent(true)) {
                     $upcomingEvents[] = $this->linkForItem($event, array('type' => 'user', 'calendar' => $userCalendar));
                 } else {
                     $upcomingEvents[] = array('title' => $this->getLocalizedString('NO_EVENTS_REMAINING'));
                 }
                 $upcomingEvents[] = array('title' => $this->getLocalizedString('MY_CALENDAR'), 'url' => $this->dayURL(time(), 'user', $userCalendar));
                 if (count($feeds) > 1) {
                     $upcomingEvents[] = array('title' => $this->getLocalizedString('OTHER_CALENDARS'), 'url' => $this->buildBreadcrumbURL('user', array()));
                 }
                 $this->assign('upcomingEvents', $upcomingEvents);
             }
             if ($resourceFeeds = $this->getFeeds('resource')) {
                 $resources = array(array('title' => $this->getLocalizedString('RESOURCES'), 'url' => $this->buildBreadcrumbURL('resources', array())));
                 $this->assign('resources', $resources);
             }
             $this->loadPageConfigFile('index', 'calendarPages');
             $this->assign('today', mktime(0, 0, 0));
             $this->assign('dateFormat', $this->getLocalizedString("LONG_DATE_FORMAT"));
             $this->assign('placeholder', $this->getLocalizedString('SEARCH_TEXT'));
             $this->assign('searchOptions', $this->searchOptions());
             $this->assign('feeds', $this->getFeedsByType());
             break;
         case 'categories':
             $categories = array();
             $type = $this->getArg('type', 'static');
             $calendar = $this->getArg('calendar', $this->getDefaultFeed($type));
             $feed = $this->getFeed($calendar, $type);
             $categoryObjects = $feed->getEventCategories();
             foreach ($categoryObjects as $categoryObject) {
                 $categories[] = $this->linkForCategory($categoryObject);
             }
             $this->assign('categories', $categories);
             break;
         case 'category':
             $type = $this->getArg('type', 'static');
             $calendar = $this->getArg('calendar', $this->getDefaultFeed($type));
             $catid = $this->getArg('catid', '');
             $name = $this->getArg('name', '');
             $current = $this->getArg('time', time(), FILTER_VALIDATE_INT);
             $next = strtotime("+1 day", $current);
             $prev = strtotime("-1 day", $current);
             $this->setBreadcrumbTitle($name);
             $this->setBreadcrumbLongTitle($name);
             // wouldn't this already be formatted from the url building stage?
             $catname = $this->formatTitle($name);
             $this->assign('category', $catname);
             $this->setLogData($catid, $catname);
             $dayRange = new DayRange(time());
             $this->assign('current', $current);
             $this->assign('next', $next);
             $this->assign('prev', $prev);
             $this->assign('nextURL', $this->categoryDayURL($next, $catid, $name, false));
             $this->assign('prevURL', $this->categoryDayURL($prev, $catid, $name, false));
             $this->assign('titleDateFormat', $this->getLocalizedString('MEDIUM_DATE_FORMAT'));
             $this->assign('linkDateFormat', $this->getLocalizedString('SHORT_DATE_FORMAT'));
             $this->assign('isToday', $dayRange->contains(new TimeRange($current)));
             $events = array();
             if (strlen($catid) > 0) {
                 $feed = $this->getFeed($calendar, $type);
                 // this allows us to have multiple feeds in the future
                 $start = new DateTime(date('Y-m-d H:i:s', $current), $this->timezone);
                 $start->setTime(0, 0, 0);
                 $end = clone $start;
                 $end->setTime(23, 59, 59);
                 $feed->setStartDate($start);
                 $feed->setEndDate($end);
                 $feed->addFilter('category', $catid);
                 $iCalEvents = $feed->items();
                 foreach ($iCalEvents as $iCalEvent) {
                     $events[] = $this->linkForItem($iCalEvent, array('catid' => $catid, 'calendar' => $calendar, 'type' => $type));
                 }
             }
             $this->assign('events', $events);
             break;
         case 'list':
             $current = $this->getArg('time', time(), FILTER_VALIDATE_INT);
             $type = $this->getArg('type', 'static');
             $calendar = $this->getArg('calendar', $this->getDefaultFeed($type));
             $limit = $this->getArg('limit', 20);
             $feed = $this->getFeed($calendar, $type);
             $title = $this->getFeedTitle($calendar, $type);
             $this->setLogData($type . ':' . $calendar, $title);
             $this->setPageTitle($title);
             $this->setBreadcrumbTitle('List');
             $this->setBreadcrumbLongTitle($title);
             $start = new DateTime(date('Y-m-d H:i:s', $current), $this->timezone);
             $start->setTime(0, 0, 0);
             $feed->setStartDate($start);
             $iCalEvents = $feed->items(0, $limit);
             $events = array();
             foreach ($iCalEvents as $iCalEvent) {
                 $events[] = $this->linkForItem($iCalEvent, array('calendar' => $calendar, 'type' => $type));
             }
             $this->assign('feedTitle', $this->getFeedTitle($calendar, $type));
             $this->assign('calendar', $calendar);
             $this->assign('current', $current);
             $this->assign('events', $events);
             $this->assign('titleDateFormat', $this->getLocalizedString('MEDIUM_DATE_FORMAT'));
             $this->assign('linkDateFormat', $this->getLocalizedString('SHORT_DATE_FORMAT'));
             break;
         case 'day':
             $current = $this->getArg('time', time(), FILTER_VALIDATE_INT);
             $type = $this->getArg('type', 'static');
             $calendar = $this->getArg('calendar', $this->getDefaultFeed($type));
             $next = strtotime("+1 day", $current);
             $prev = strtotime("-1 day", $current);
             $feed = $this->getFeed($calendar, $type);
             $title = $this->getFeedTitle($calendar, $type);
             $this->setLogData($type . ':' . $calendar, $title);
             $start = new DateTime(date('Y-m-d H:i:s', $current), $this->timezone);
             $start->setTime(0, 0, 0);
             $end = clone $start;
             $end->setTime(23, 59, 59);
             $feed->setStartDate($start);
             $feed->setEndDate($end);
             $iCalEvents = $feed->items();
             $events = array();
             foreach ($iCalEvents as $iCalEvent) {
                 $events[] = $this->linkForItem($iCalEvent, array('calendar' => $calendar, 'type' => $type));
             }
             $dayRange = new DayRange(time());
             $this->assign('feedTitle', $title);
             $this->assign('type', $type);
             $this->assign('calendar', $calendar);
             $this->assign('current', $current);
             $this->assign('next', $next);
             $this->assign('prev', $prev);
             $this->assign('nextURL', $this->dayURL($next, $type, $calendar, false));
             $this->assign('prevURL', $this->dayURL($prev, $type, $calendar, false));
             $this->assign('titleDateFormat', $this->getLocalizedString('MEDIUM_DATE_FORMAT'));
             $this->assign('linkDateFormat', $this->getLocalizedString('SHORT_DATE_FORMAT'));
             $this->assign('isToday', $dayRange->contains(new TimeRange($current)));
             $this->assign('events', $events);
             break;
         case 'detail':
             $calendarFields = $this->getModuleSections('page-detail');
             $type = $this->getArg('type', 'static');
             $calendar = $this->getArg('calendar', $this->getDefaultFeed($type));
             $feed = $this->getFeed($calendar, $type);
             if ($filter = $this->getArg('filter')) {
                 $feed->addFilter('search', $filter);
             }
             if ($catid = $this->getArg('catid')) {
                 $feed->addFilter('category', $catid);
             }
             $time = $this->getArg('time', time(), FILTER_VALIDATE_INT);
             if ($event = $feed->getItem($this->getArg('id'), $time)) {
                 $this->assign('event', $event);
             } else {
                 throw new KurogoUserException($this->getLocalizedString('ERROR_NOT_FOUND'));
             }
             $this->setLogData($event->get_uid(), $event->get_summary());
             // build the list of attributes
             $allKeys = array_keys($calendarFields);
             $fields = array();
             foreach ($calendarFields as $key => $info) {
                 $field = array();
                 $value = $event->get_attribute($key);
                 if (empty($value)) {
                     continue;
                 }
                 if (isset($info['label'])) {
                     $field['label'] = $info['label'];
                 }
                 if (isset($info['class'])) {
                     $field['class'] = $info['class'];
                 }
                 if (is_array($value)) {
                     $fieldValues = array();
                     foreach ($value as $item) {
                         $fieldValue = '';
                         $fieldValueUrl = null;
                         if (isset($info['type'])) {
                             $fieldValue = $this->valueForType($info['type'], $item);
                             $fieldValueUrl = $this->urlForType($info['type'], $item);
                         } else {
                             $fieldValue = $item;
                         }
                         if (isset($fieldValueUrl)) {
                             $fieldValue = '<a href="' . $fieldValueUrl . '">' . $fieldValue . '</a>';
                         }
                         $fieldValues[] = $fieldValue;
                     }
                     $field['title'] = implode(', ', $fieldValues);
                 } else {
                     if (isset($info['type'])) {
                         $field['title'] = $this->valueForType($info['type'], $value);
                         $field['url'] = $this->urlForType($info['type'], $value);
                     } elseif (isset($info['module'])) {
                         $field = array_merge($field, Kurogo::moduleLinkForValue($info['module'], $value, $this, $event));
                     } else {
                         $field['title'] = nl2br($value);
                     }
                 }
                 if (isset($info['urlfunc'])) {
                     $urlFunction = create_function('$value,$event', $info['urlfunc']);
                     $field['url'] = $urlFunction($value, $event);
                 }
                 $fields[] = $field;
             }
             $this->assign('fields', $fields);
             //error_log(print_r($fields, true));
             break;
         case 'search':
             if ($filter = $this->getArg('filter')) {
                 $searchTerms = trim($filter);
                 $timeframe = $this->getArg('timeframe', 0);
                 $type = $this->getArg('type', 'static');
                 $searchCalendar = $this->getArg('calendar', $this->getDefaultFeed($type));
                 if (preg_match("/^(.*?)\\|(.*?)\$/", $searchCalendar, $bits)) {
                     $type = $bits[1];
                     $calendar = $bits[2];
                 } else {
                     $calendar = $searchCalendar;
                 }
                 $options = array('type' => $type, 'calendar' => $calendar, 'timeframe' => $timeframe);
                 $this->setLogData($searchTerms);
                 $iCalEvents = $this->searchItems($searchTerms, null, $options);
                 $events = array();
                 foreach ($iCalEvents as $iCalEvent) {
                     $events[] = $this->linkForItem($iCalEvent, array('filter' => $searchTerms, 'timeframe' => $timeframe, 'calendar' => $calendar, 'type' => $type));
                 }
                 $this->assign('events', $events);
                 $this->assign('searchTerms', $searchTerms);
                 $this->assign('selectedOption', $timeframe);
                 $this->assign('searchOptions', $this->searchOptions());
                 $this->assign('feeds', $this->getFeedsByType());
                 $this->assign('searchCalendar', $searchCalendar);
             } else {
                 $this->redirectTo('index');
             }
             break;
         case 'year':
             $type = $this->getArg('type', 'static');
             $calendar = $this->getArg('calendar', $this->getDefaultFeed($type));
             // Figure out when the calendar year starts; default to January 1
             // Allow setting either per-calendar with config or override with url parameter
             $defaultStartMonth = $this->getOptionalModuleVar(strtoupper($calendar) . '_CALENDAR_START_MONTH', 1);
             $defaultStartDay = $this->getOptionalModuleVar(strtoupper($calendar) . '_CALENDAR_START_DAY', 1);
             $month = intval($this->getArg('month', $defaultStartMonth));
             $day = intval($this->getArg('day', $defaultStartDay));
             // Figure out which year we are currently in based on year start month and day:
             $currentYear = intval(date('Y'));
             $yearStartForCurrentYear = new DateTime(sprintf("%d%02d%02d", $currentYear, $month, $day), $this->timezone);
             if (time() < intval($yearStartForCurrentYear->format('U'))) {
                 $currentYear--;
                 // today's date is before the start date for the current year
             }
             // Which year to view; default to current year based on year start month and day:
             $year = intval($this->getArg('year', $currentYear));
             $start = new DateTime(sprintf("%d%02d%02d", $year, $month, $day), $this->timezone);
             $end = new DateTime(sprintf("%d%02d%02d", $year + 1, $month, $day), $this->timezone);
             $feed = $this->getFeed($calendar, $type);
             $feed->setStartDate($start);
             $feed->setEndDate($end);
             $feed->addFilter('year', $year);
             $iCalEvents = $feed->items();
             $title = $this->getFeedTitle($calendar, $type);
             $this->setLogData($type . ':' . $calendar, $title);
             $events = array();
             foreach ($iCalEvents as $iCalEvent) {
                 $events[] = array('title' => $iCalEvent->get_summary(), 'subtitle' => date('l F j', $iCalEvent->get_start()));
             }
             $current = $year . '&nbsp;-&nbsp;' . ($year + 1);
             $next = $year + 1 . '&nbsp;-&nbsp;' . ($year + 2);
             $prev = $year - 1 . '&nbsp;-&nbsp;' . $year;
             // How many years into the future and past to page:
             $maxNextYears = $this->getOptionalModuleVar(strtoupper($calendar) . '_CALENDAR_MAX_NEXT_YEARS', 1);
             $maxPrevYears = $this->getOptionalModuleVar(strtoupper($calendar) . '_CALENDAR_MAX_PREV_YEARS', 1);
             if ($year < $currentYear + $maxNextYears) {
                 $this->assign('next', $next);
                 $this->assign('nextURL', $this->yearURL($year + 1, $month, $day, $type, $calendar, false));
             }
             if ($year > $currentYear - $maxPrevYears) {
                 $this->assign('prev', $prev);
                 $this->assign('prevURL', $this->yearURL($year - 1, $month, $day, $type, $calendar, false));
             }
             $this->assign('current', $current);
             $this->assign('events', $events);
             $this->assign('feedTitle', $title);
             break;
     }
 }
コード例 #3
0
 private function formatPersonByNative($person)
 {
     $result = array();
     $result['uid'] = $person->getId();
     foreach ($this->fieldConfig as $fieldID => $fieldOptions) {
         $attributes = array();
         for ($i = 0; $i < count($fieldOptions['attributes']); $i++) {
             if (isset($fieldOptions['labels'])) {
                 $label = $fieldOptions['labels'][$i];
             } else {
                 $label = $i;
             }
             $attribute = $fieldOptions['attributes'][$i];
             $values = $person->getField($attribute);
             if ($values) {
                 if (self::argVal($fieldOptions, 'type') == 'imgdata') {
                     $attributes[$label] = FULL_URL_PREFIX . $this->configModule . '/photo?' . http_build_query(array('uid' => $person->getID()));
                 } else {
                     if (is_array($values)) {
                         $delimiter = isset($fieldOptions['delimiter']) ? $fieldOptions['delimiter'] : ' ';
                         $attributes[$label] = implode($delimiter, $values);
                     } else {
                         $attributes[$label] = $values;
                     }
                 }
             } elseif (isset($fieldOptions['format'])) {
                 //always include attributes when using format
                 $attributes[$label] = null;
             }
         }
         // if we use format and there are no fields then skip
         if (isset($fieldOptions['format'])) {
             if (!array_filter($attributes)) {
                 $attributes = array();
             }
         }
         if ($attributes) {
             if (isset($fieldOptions['format'])) {
                 $value = vsprintf($fieldOptions['format'], $attributes);
             } elseif (isset($fieldOptions['parse'])) {
                 $formatFunction = create_function('$value', $fieldOptions['parse']);
                 $value = $formatFunction($attributes);
             } elseif (isset($fieldOptions['labels'])) {
                 $value = $attributes;
             } else {
                 $value = $attributes[0];
             }
             $url = NULL;
             if (self::argVal($fieldOptions, 'type') == 'map') {
                 $link = Kurogo::moduleLinkForValue('map', $value, $this, $person);
                 if (isset($link, $link['url'])) {
                     $url = $link['url'];
                 }
             }
             if (isset($fieldOptions['section'])) {
                 $section = $fieldOptions['section'];
                 if (!isset($result[$section])) {
                     $result[$section] = array();
                 }
                 $valueArray = array('title' => $fieldOptions['label'], 'type' => $fieldOptions['type'], 'value' => $value);
                 if (isset($url)) {
                     $valueArray['url'] = $url;
                 }
                 $result[$section][] = $valueArray;
             } else {
                 $result[$fieldOptions['label']] = $value;
             }
         }
     }
     return $result;
 }
コード例 #4
0
 protected function initializeSchedule()
 {
     $locationID = $this->getArg('section');
     $eventID = $this->getArg('id');
     $feedID = $this->getArg('groupID');
     $model = $this->loadFeed($feedID);
     $location = $model->getLocation($locationID);
     $locationEvents = $location->getAttribute('events');
     $time = $this->getArg('time', time(), FILTER_VALIDATE_INT);
     if ($event = $locationEvents->getItem($eventID, $time)) {
         $this->assign('event', $event);
     } else {
         throw new KurogoUserException($this->getLocalizedString('EVENT_NOT_FOUND'));
     }
     $eventFields = $this->getModuleSections('schedule-detail');
     $fields = array();
     foreach ($eventFields as $key => $info) {
         $field = array();
         $value = $event->get_attribute($key);
         if (empty($value)) {
             continue;
         }
         if (isset($info['label'])) {
             $field['label'] = $info['label'];
         }
         if (isset($info['class'])) {
             $field['class'] = $info['class'];
         }
         if (Kurogo::arrayVal($info, 'nl2br')) {
             $value = nl2br($value);
         }
         if (isset($info['type'])) {
             $field['title'] = $this->valueForType($info['type'], $value);
             $field['url'] = $this->urlForType($info['type'], $value);
         } elseif (isset($info['module'])) {
             $field = array_merge($field, Kurogo::moduleLinkForValue($info['module'], $value, $this, $event));
         } else {
             $field['title'] = $value;
         }
         $fields[] = $field;
     }
     $this->assign('fields', $fields);
 }
コード例 #5
0
 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('@', '@&shy;', $value);
             }
             $detail['url'] = "mailto:{$value}";
             $detail['class'] = trim(Kurogo::arrayVal($detail, 'class', '') . ' email');
             break;
         case 'phone':
             if (!isset($detail['title'])) {
                 $detail['title'] = str_replace('-', '-&shy;', $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;
 }
コード例 #6
0
ファイル: AthleticsWebModule.php プロジェクト: nncsang/Kurogo
 protected function formatScheduleDetail(AthleticEvent $event)
 {
     $allFieldsValue = $this->getFieldsForSechedule($event);
     $showFields = $this->getModuleSections('schedule-detail');
     $fields = array();
     foreach ($showFields as $key => $info) {
         $field = array();
         if (!isset($allFieldsValue[$key]) || !$allFieldsValue[$key]) {
             continue;
         }
         $value = $allFieldsValue[$key];
         if (isset($info['label'])) {
             $field['label'] = $info['label'];
         }
         if (isset($info['class'])) {
             $field['class'] = $info['class'];
         }
         if (isset($info['type'])) {
             $field['title'] = $this->valueForType($info['type'], $value, $event);
             $field['url'] = $this->urlForType($info['type'], $value);
         } elseif (isset($info['module'])) {
             $field = array_merge($field, Kurogo::moduleLinkForValue($info['module'], $value, $this, $event));
         } else {
             $field['title'] = nl2br($value);
         }
         $fields[] = $field;
     }
     return $fields;
 }