public function render($params = array()) { // init vars $params = new YArray($params); $items = array(); $output = array(); $layout_path = $params->get('layout_path'); $renderer = new ItemRenderer(); $renderer->addPath($layout_path); $layout = $params->get('layout'); $items = $this->_getRelatedItems(); // sort items $order = $params->get('order'); if (in_array($order, array('alpha', 'ralpha'))) { usort($items, create_function('$a,$b', 'return strcmp($a->name, $b->name);')); } elseif (in_array($order, array('date', 'rdate'))) { usort($items, create_function('$a,$b', 'return (strtotime($a->created) == strtotime($b->created)) ? 0 : (strtotime($a->created) < strtotime($b->created)) ? -1 : 1;')); } elseif (in_array($order, array('hits', 'rhits'))) { usort($items, create_function('$a,$b', 'return ($a->hits == $b->hits) ? 0 : ($a->hits < $b->hits) ? -1 : 1;')); } elseif ($order == 'random') { shuffle($items); } else { } if (in_array($order, array('ralpha', 'rdate', 'rhits'))) { $items = array_reverse($items); } // create output foreach ($items as $item) { $path = 'item'; $prefix = 'item.'; $type = $item->getType()->id; if ($renderer->pathExists($path . DIRECTORY_SEPARATOR . $type)) { $path .= DIRECTORY_SEPARATOR . $type; $prefix .= $type . '.'; } if (in_array($layout, $renderer->getLayouts($path))) { $output[] = $renderer->render($prefix . $layout, array('item' => $item)); } elseif ($params->get('link_to_item', false) && $item->getState()) { $url = RouteHelper::getItemRoute($item); $output[] = '<a href="' . JRoute::_($url) . '" title="' . $item->name . '">' . $item->name . '</a>'; } else { $output[] = $item->name; } } return ElementHelper::applySeparators($params->get('separated_by'), $output); }
public function render($params = array()) { // init vars $location = $this->_data->get('location'); $locale = $this->_config->get('locale'); // init display params $params = new YArray($params); $layout_path = $params->get('layout_path'); $layout = $params->get('layout'); $width = $params->get('width'); $width_unit = $params->get('width_unit'); $height = $params->get('height'); $marker_popup = $params->get('marker_popup'); $zoom_level = $params->get('zoom_level'); $map_controls = $params->get('map_controls'); $scroll_wheel_zoom = $params->get('scroll_wheel_zoom'); $map_type = $params->get('map_type'); $map_controls = $params->get('map_controls'); $type_controls = $params->get('type_controls'); $directions = $params->get('directions'); $main_icon = $params->get('main_icon'); $information = $params->get('information'); // determine locale if (empty($locale) || $locale == 'auto') { $locale = UserHelper::getBrowserDefaultLanguage(); } // get marker text $marker_text = ''; $renderer = new ItemRenderer(); $renderer->addPath($layout_path); if ($item = $this->getItem()) { $path = 'item'; $prefix = 'item.'; $type = $item->getType()->id; if ($renderer->pathExists($path . DIRECTORY_SEPARATOR . $type)) { $path .= DIRECTORY_SEPARATOR . $type; $prefix .= $type . '.'; } if (in_array($layout, $renderer->getLayouts($path))) { $marker_text = $renderer->render($prefix . $layout, array('item' => $item)); } else { $marker_text = $item->name; } } // get geocode cache $cache = new YCache(ZOO_CACHE_PATH . DS . 'geocode_cache.txt'); if (!$cache->check()) { return "<div class=\"alert\"><strong>Cache not writeable please update the file permissions! (geocode_cache.txt)</strong></div>\n"; } // get map center coordinates $center = GooglemapsHelper::locate($location, $cache); if (!$center) { return "<div class=\"alert\"><strong>Unable to get map center coordinates, please verify your location! (" . $location . ")</strong></div>\n"; } // save location to geocode cache if ($cache) { $cache->save(); } // css parameters $maps_id = 'googlemaps-' . $this->_item->id; $css_module_width = 'width: ' . $width . $width_unit . ';'; $css_module_height = 'height: ' . $height . 'px;'; $from_address = JText::_('From address:'); $get_directions = JText::_('Get directions'); $empty = JText::_('Please fill in your address.'); $not_found = JText::_('Sorry, address not found!'); $address_not_found = ', ' . JText::_('not found!'); // js parameters $javascript = "\$('#{$maps_id}').Googlemaps({ lat:" . $center['lat'] . ", lng:" . $center['lng'] . ", popup: " . $marker_popup . ", text: '" . GooglemapsHelper::stripText($marker_text) . "', zoom: " . $zoom_level . ", mapCtrl: " . $map_controls . ", zoomWhl: " . $scroll_wheel_zoom . ", mapType: " . $map_type . ", typeCtrl: " . $type_controls . ", directions: " . $directions . ", locale: '" . $locale . "', mainIcon:'" . $main_icon . "', msgFromAddress: '" . $from_address . "', msgGetDirections: '" . $get_directions . "', msgEmpty: '" . $empty . "', msgNotFound: '" . $not_found . "', msgAddressNotFound: '" . $address_not_found . "' });"; $javascript = "jQuery(function(\$) { {$javascript} });"; // render layout if ($layout = $this->getLayout()) { return self::renderLayout($layout, array('maps_id' => $maps_id, 'javascript' => $javascript, 'css_module_width' => $css_module_width, 'css_module_height' => $css_module_height, 'information' => $information, 'locale' => $locale)); } return null; }
</td> <td class="submission"> <?php foreach ($this->templates as $template) { $metadata = $template->getMetadata(); echo '<div>' . $metadata['name'] . ': '; $renderer = new ItemRenderer(); $renderer->addPath($template->getPath()); $path = 'item'; $prefix = 'item.'; if ($renderer->pathExists($path . DIRECTORY_SEPARATOR . $type->id)) { $path .= DIRECTORY_SEPARATOR . $type->id; $prefix .= $type->id . '.'; } $links = array(); foreach ($renderer->getLayouts($path) as $layout) { // get layout metadata $metadata = $renderer->getLayoutMetaData($prefix . $layout); if ($metadata->get('type') == 'submission') { // create link $link = '<a href="' . JRoute::_($this->baseurl . '&task=assignsubmission&type=' . $type->id . '&template=' . $template->name . '&layout=' . $layout) . '">' . $metadata->get('name', $layout) . '</a>'; // create tooltip if ($description = $metadata->get('description')) { $link = '<span class="editlinktip hasTip" title="' . $metadata->get('name', $layout) . '::' . $description . '">' . $link . '</span>'; } $links[] = $link; } } echo implode(' | ', $links); echo '</div>'; }
public static function getLayouts($application, $type_id, $layout_type = '') { $result = array(); // get template if ($template = $application->getTemplate()) { // get renderer $renderer = new ItemRenderer(); $renderer->addPath($template->getPath()); $path = 'item'; $prefix = 'item.'; if ($renderer->pathExists($path . DIRECTORY_SEPARATOR . $type_id)) { $path .= DIRECTORY_SEPARATOR . $type_id; $prefix .= $type_id . '.'; } foreach ($renderer->getLayouts($path) as $layout) { $metadata = $renderer->getLayoutMetaData($prefix . $layout); if (empty($layout_type) || $metadata->get('type') == $layout_type) { $result[$layout] = $metadata; } } } return $result; }