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 saveSubmission() { // check for request forgeries YRequest::checkToken() or jexit('Invalid Token'); // init vars $type = YRequest::getString('type'); $template = YRequest::getString('template'); $layout = YRequest::getString('layout'); $positions = YRequest::getVar('positions', array(), 'post', 'array'); unset($positions['unassigned']); // for template, module if ($template) { $path = $this->application->getPath() . '/templates/' . $template; } // get renderer $renderer = new ItemRenderer(); $renderer->addPath($path); // clean config $config = $renderer->getConfig('item'); foreach ($config->toArray() as $key => $value) { $parts = explode('.', $key); if ($parts[0] == $this->group && !$this->application->getType($parts[1])) { $config->remove($key); } } // save config $config->set($this->group . '.' . $type . '.' . $layout, $positions); $renderer->saveConfig($config, $path . '/renderer/item/positions.config'); switch ($this->getTask()) { case 'applysubmission': $link = $this->baseurl . '&task=assignsubmission&type=' . $type . '&layout=' . $layout; $link .= $template ? '&template=' . $template : null; break; default: $link = $this->baseurl . '&task=types'; break; } $this->setRedirect($link, JText::_('Submitable Elements Assigned')); }
public function feed() { // get request vars $category_id = (int) YRequest::getInt('category_id', $this->params->get('category')); // get params $all_categories = $this->application->getCategoryTree(true); // raise warning when category can not be accessed if (!isset($all_categories[$category_id])) { JError::raiseWarning(500, JText::_('Unable to access category')); return; } $category = $all_categories[$category_id]; $params = $category ? $category->getParams('site') : $this->application->getParams('frontpage'); $show_feed_link = $params->get('config.show_feed_link', 0); $feed_title = $params->get('config.feed_title', ''); // init vars $document = JFactory::getDocument(); // raise error when feed is link is disabled if (empty($show_feed_link)) { JError::raiseError(500, JText::_('Unable to access feed')); return; } // get feed items from category $categories = $category->getChildren(true); $categories[$category->id] = $category; $feed_limit = $this->joomla->getCfg('feed_limit'); $feed_items = YTable::getInstance('item')->getFromCategory($this->application->id, array_keys($categories), true, null, 'created DESC', 0, $feed_limit); // set title if ($feed_title) { $document->setTitle(html_entity_decode($this->getView()->escape($feed_title))); } // set feed link $document->link = JRoute::_($this->link_base . '&task=category'); // set renderer $renderer = new ItemRenderer(); $renderer->addPath(array($this->application->getTemplate()->getPath(), ZOO_SITE_PATH)); foreach ($feed_items as $feed_item) { // create feed item $item = new JFeedItem(); $item->title = html_entity_decode($this->getView()->escape($feed_item->name)); $item->link = JRoute::_(RouteHelper::getItemRoute($feed_item)); $item->date = $feed_item->created; $item->author = $feed_item->getAuthor(); $item->description = $this->_relToAbs($renderer->render('item.feed', array('item' => $feed_item))); // add to feed document $document->addItem($item); } }
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; }
} $links[] = $link; } } echo implode(' | ', $links); echo '</div>'; } ?> </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')) {
function onSearch($text, $phrase = '', $ordering = '', $areas = null) { // load config require_once JPATH_ADMINISTRATOR . '/components/com_zoo/config.php'; $db = JFactory::getDBO(); $user = JFactory::getUser(); $date = JFactory::getDate(); // init vars $now = $db->Quote($date->toMySQL()); $null = $db->Quote($db->getNullDate()); $text = trim($text); // return empty array, if no search text provided if (empty($text)) { return array(); } // get plugin info $plugin = JPluginHelper::getPlugin('search', 'zoosearch'); $params = new JParameter($plugin->params); $fulltext = $params->get('search_fulltext', 1) && strlen($text) > 3 && intval($db->getVersion()) >= 4; $limit = $params->get('search_limit', 50); // prepare search query switch ($phrase) { case 'exact': if ($fulltext) { $text = $db->getEscaped($text); $where[] = "MATCH(a.name) AGAINST ('{$text}' IN BOOLEAN MODE)"; $where[] = "MATCH(b.value) AGAINST ('{$text}' IN BOOLEAN MODE)"; $where[] = "MATCH(c.name) AGAINST ('{$text}' IN BOOLEAN MODE)"; $where = implode(" OR ", $where); } else { $text = $db->Quote('%' . $db->getEscaped($text, true) . '%', false); $like = array(); $like[] = 'a.name LIKE ' . $text; $like[] = 'b.value LIKE ' . $text; $like[] = 'c.name LIKE ' . $text; $where = '(' . implode(') OR (', $like) . ')'; } break; case 'all': case 'any': default: if ($fulltext) { $text = $db->getEscaped($text); $where[] = "MATCH(a.name) AGAINST ('{$text}' IN BOOLEAN MODE)"; $where[] = "MATCH(b.value) AGAINST ('{$text}' IN BOOLEAN MODE)"; $where[] = "MATCH(c.name) AGAINST ('{$text}' IN BOOLEAN MODE)"; $where = implode(" OR ", $where); } else { $words = explode(' ', $text); $wheres = array(); foreach ($words as $word) { $word = $db->Quote('%' . $db->getEscaped($word, true) . '%', false); $like = array(); $like[] = 'a.name LIKE ' . $word; $like[] = 'EXISTS (SELECT value FROM ' . ZOO_TABLE_SEARCH . ' WHERE a.id = item_id AND value LIKE ' . $word . ')'; $like[] = 'EXISTS (SELECT name FROM ' . ZOO_TABLE_TAG . ' WHERE a.id = item_id AND name LIKE ' . $word . ')'; $wheres[] = implode(' OR ', $like); } $where = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')'; } } // set search ordering switch ($ordering) { case 'newest': $order = 'a.created DESC'; break; case 'oldest': $order = 'a.created ASC'; break; case 'popular': $order = 'a.hits DESC'; break; case 'alpha': case 'category': default: $order = 'a.name ASC'; } // set query options $select = "DISTINCT a.*"; $from = ZOO_TABLE_ITEM . " AS a" . " LEFT JOIN " . ZOO_TABLE_SEARCH . " AS b ON a.id = b.item_id" . " LEFT JOIN " . ZOO_TABLE_TAG . " AS c ON a.id = c.item_id"; $conditions = array("(" . $where . ")" . " AND a.searchable = 1" . " AND a.access <= " . (int) $user->get('aid', 0) . " AND (a.state = 1" . " AND (a.publish_up = " . $null . " OR a.publish_up <= " . $now . ")" . " AND (a.publish_down = " . $null . " OR a.publish_down >= " . $now . "))"); // execute query $items = YTable::getInstance('item')->all(compact('select', 'from', 'conditions', 'order', 'limit')); // create search result rows $rows = array(); if (!empty($items)) { // set renderer $renderer = new ItemRenderer(); $renderer->addPath(array(dirname(__FILE__) . DS . basename(__FILE__, '.php'), ZOO_SITE_PATH)); foreach ($items as $item) { $row = new stdClass(); $row->title = $item->name; $row->text = $renderer->render('item.default', array('item' => $item)); $row->href = RouteHelper::getItemRoute($item); $row->created = $item->created; $row->section = ''; $row->browsernav = 2; $rows[] = $row; } } return $rows; }
$panel_height = $theme == "basic" ? $panel_height - 2 : $panel_height; /* only for basic styling */ $panel_height = $theme == "button" ? $panel_height - 7 : $panel_height; /* only for button styling */ $panel_width = $theme == "button" ? $panel_width - 10 : $panel_width; /* only for button styling */ $css_module_width = 'width: ' . $module_width . 'px;'; $css_module_height = 'height: ' . $module_height . 'px;'; $css_total_module_width = 'width: ' . ($module_width * $item_count + 3) . 'px;'; $css_panel_width = 'width: ' . $panel_width . 'px;'; $css_panel_height = 'height: ' . $panel_height . 'px;'; $css_total_panel_width = 'width: ' . ($panel_width * $item_count + 3) . 'px;'; } if ($transition_effect == 'crossfade' || $rotate_effect == 'crossfade') { $css_slide_position = ' position: absolute;'; $css_total_panel_width = $css_panel_width; } else { $css_slide_position = ''; } // set renderer $renderer = new ItemRenderer(); $renderer->addPath(array(dirname(__FILE__), ZOO_SITE_PATH)); include JModuleHelper::getLayoutPath('mod_zoocarousel', $theme); // js parameters $javascript = "new YOOcarousel('" . $carousel_id . "', { transitionEffect: '" . $transition_effect . "', transitionDuration: " . $transition_duration . ", rotateAction: '" . $rotate_action . "', rotateActionDuration: " . $rotate_duration . ", rotateActionEffect: '" . $rotate_effect . "', slideInterval: " . $slide_interval . ", autoplay: '" . $autoplay . "' });"; $javascript = "window.addEvent('domready', function(){ {$javascript} });"; $document = JFactory::getDocument(); $document->addStyleSheet($module_base . 'mod_zoocarousel.css.php'); $document->addScript($module_base . 'mod_zoocarousel.js'); $document->addScriptDeclaration($javascript); }
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; }