示例#1
0
 public function render($params = array())
 {
     if (!empty($this->_item)) {
         if ($this->_item->getState()) {
             $url = RouteHelper::getItemRoute($this->_item);
             return '<a href="' . JRoute::_($url) . '">' . JText::_('READ_MORE') . '</a>';
         } else {
             return JText::_('READ_MORE');
         }
     }
 }
示例#2
0
 public function render($params = array())
 {
     if (!empty($this->_item)) {
         $params = new YArray($params);
         if ($params->get('link_to_item', false) && $this->_item->getState()) {
             $url = RouteHelper::getItemRoute($this->_item);
             return '<a title="' . $this->_item->name . '" href="' . JRoute::_($url) . '">' . $this->_item->name . '</a>';
         } else {
             return $this->_item->name;
         }
     }
 }
示例#3
0
 public function render($params = array())
 {
     $params = new YArray($params);
     // include assets css
     JHTML::stylesheet('itemprint.css', 'administrator/components/com_zoo/elements/itemprint/assets/css/');
     if (YRequest::getBool('print', 0)) {
         return '<a class="element-print-button" onclick="window.print();return false;" href="#"></a>';
     } else {
         JHTML::_('behavior.modal', 'a.modal');
         $text = $params->get('showicon') ? '' : JText::_('Print');
         $class = $params->get('showicon') ? 'modal element-print-button' : 'modal';
         return '<a href="' . JRoute::_(RouteHelper::getItemRoute($this->_item) . '&amp;tmpl=component&amp;print=1') . '" title="' . JText::_('Print') . '" rel="{handler: \'iframe\', size: {x: 850, y: 500}}" class="' . $class . '">' . $text . '</a>';
     }
 }
示例#4
0
 public function render($params)
 {
     // init vars
     $params = new YArray($params);
     $height = $params->get('height');
     $width = $params->get('width');
     $enabled = $this->_data->get('value');
     // render html
     if ($width && $height && $enabled) {
         $permalink = urlencode(JRoute::_(RouteHelper::getItemRoute($this->_item), true, -1));
         $href = 'http://www.facebook.com/plugins/like.php?href=' . $permalink . '&amp;layout=standard&amp;show_faces=false&amp;width=300&amp;action=like&amp;colorscheme=light&amp;height=' . $height;
         $html = '<iframe src="' . $href . '" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width: ' . $width . 'px; height: ' . $height . 'px;" ></iframe>';
         return $html;
     }
     return null;
 }
示例#5
0
 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);
 }
示例#6
0
文件: image.php 项目: bizanto/Hooked
 public function render($params = array())
 {
     // init vars
     $title = $this->_data->get('title');
     $params = new YArray($params);
     $file = ZooHelper::resizeImage(JPATH_ROOT . DS . $this->_data->get('file'), $params->get('width', 0), $params->get('height', 0));
     $link = JURI::root() . trim(str_replace('\\', '/', preg_replace('/^' . preg_quote(JPATH_ROOT, '/') . '/i', '', $file)), '/');
     if ($params->get('link_to_item', false)) {
         if ($this->getItem()->getState()) {
             $url = RouteHelper::getItemRoute($this->_item);
             $target = false;
             $rel = '';
             $title = empty($title) ? $this->_item->name : $title;
         } else {
             $url = $target = $rel = '';
         }
     } else {
         if ($this->_data->get('link')) {
             $url = $this->_data->get('link');
             $target = $this->_data->get('target');
             $rel = $this->_data->get('rel');
         } else {
             if ($this->_data->get('lightbox_image')) {
                 // load lightbox
                 if ($this->_config->get('load_lightbox', 0)) {
                     JHTML::script('slimbox_packed.js', 'administrator/components/com_zoo/elements/gallery/assets/lightbox/');
                     JHTML::stylesheet('slimbox.css', 'administrator/components/com_zoo/elements/gallery/assets/lightbox/css/');
                 }
                 $lightbox_image = ZooHelper::resizeImage(JPATH_ROOT . DS . $this->_data->get('lightbox_image', ''), 0, 0);
                 $url = JURI::root() . trim(str_replace('\\', '/', preg_replace('/^' . preg_quote(JPATH_ROOT, '/') . '/i', '', $lightbox_image)), '/');
                 $target = '';
                 $rel = 'lightbox[' . $title . ']';
             } else {
                 $url = $target = $rel = '';
             }
         }
     }
     // get alt
     $alt = empty($title) ? $this->_item->name : $title;
     // render layout
     if ($layout = $this->getLayout()) {
         return self::renderLayout($layout, array('file' => $file, 'title' => $title, 'alt' => $alt, 'link' => $link, 'link_enabled' => !empty($url), 'url' => $url, 'target' => $target, 'rel' => $rel));
     }
     return null;
 }
示例#7
0
 public function render($params = array())
 {
     if (!empty($this->_item)) {
         $comment_count = $this->_item->getCommentsCount(1);
         if ($comment_count == 0) {
             $text = isset($params['no_comments_text']) ? $params['no_comments_text'] : JText::_('No comments');
         } else {
             if ($comment_count == 1) {
                 $text = sprintf(isset($params['single_comment_text']) ? $params['single_comment_text'] : JText::_('%s comment'), 1);
             } else {
                 $text = sprintf(isset($params['multiple_comments_text']) ? $params['multiple_comments_text'] : JText::_('%s comments'), $comment_count);
             }
         }
         if ($this->_item->getState()) {
             $url = RouteHelper::getItemRoute($this->_item) . '#comments';
             return '<a href="' . JRoute::_($url) . '">' . $text . '</a>';
         } else {
             return $text;
         }
     }
 }
示例#8
0
文件: list-v.php 项目: bizanto/Hooked
            }
            ?>
					</h3>
					<?php 
        }
        ?>
				
					<?php 
        if ($params->get('show_meta', 1)) {
            ?>
					<p class="meta">
						<?php 
            echo JHTML::_('date', $comment->created, JText::_('ZOO_COMMENT_MODULE_DATE_FORMAT'));
            ?>
						| <a class="permalink" href="<?php 
            echo JRoute::_(RouteHelper::getItemRoute($item) . '#comment-' . $comment->id);
            ?>
">#</a>
					</p>
					<?php 
        }
        ?>
				
					<p class="content">
						<?php 
        echo CommentHelper::filterContentOutput(YString::truncate($comment->content, modZooCommentHelper::MAX_CHARACTERS));
        ?>
					</p>
	
				</li>
			
示例#9
0
 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);
     }
 }
示例#10
0
 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;
 }
示例#11
0
 public function facebookAuthenticate()
 {
     // init vars
     $item_id = YRequest::getInt('item_id', 0);
     $item = YTable::getInstance('item')->get($item_id);
     // get facebook client
     $connection = CommentHelper::getFacebookClient();
     if ($connection) {
         $code = YRequest::getString('code', '');
         $uri = new JURI();
         $redirect = $uri->root() . $this->link_base . '&controller=comment&task=facebookauthenticate&item_id=' . $item_id;
         $url = $connection->getAccessTokenURL($code, $redirect);
         $http = new HttpHelper();
         $result = $http->get($url, array('ssl_verifypeer' => false));
         $token = str_replace('access_token=', '', $result['body']);
         $_SESSION['facebook_access_token'] = $token;
     }
     $redirect = JRoute::_(RouteHelper::getItemRoute($item));
     $this->setRedirect($redirect);
 }