本文整理汇总了PHP中Kurogo::moduleLinkForValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Kurogo::moduleLinkForValue方法的具体用法?PHP Kurogo::moduleLinkForValue怎么用?PHP Kurogo::moduleLinkForValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kurogo
的用法示例。
在下文中一共展示了Kurogo::moduleLinkForValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: formatDetail
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: initializeForPage
//.........这里部分代码省略.........
$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));
}
示例3: formatPersonByNative
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: initializeSchedule
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: formatDetailFieldInfo
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'])) {
//.........这里部分代码省略.........
示例6: formatScheduleDetail
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;
}