示例#1
1
	function onBeforeDisplayContent( &$article, &$params, $limitstart ){
		//this may fire fron a component other than com_content
		
		if(!file_exists(JPATH_SITE.DS.'plugins'.DS.'system'.DS.'myApiConnectFacebook.php') || ( !array_key_exists('category',$article) && !array_key_exists('showK2Plugins',$params)  )){ return; }
		
		if((@$article->id != '') && (@$_POST['fb_sig_api_key'] == '') && class_exists('plgSystemmyApiOpenGraph')){
			$row = & JTable::getInstance('content');
			$row->load($article->id);
			$attribs = new JParameter($row->attribs);
			if($attribs->get('ogimage','') == ''){
				$attribs->set('ogimage',plgContentmyApiOpenGraphContent::getContentImage($article->text));
				$row->attribs = $attribs->toString();
				$row->bind($row);
				$row->store();
			}
			//Set open graph tags
			if(JRequest::getVar('view','','get') == 'article' || (JRequest::getVar('option','','get') == 'com_k2' && JRequest::getVar('view','','get') == 'item')){
				if(isset($article->slug)){
					require_once(JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php');
					$link = ContentHelperRoute::getArticleRoute($article->slug, $article->catslug, $article->sectionid);
				}elseif(method_exists('K2HelperRoute','getItemRoute')){
					$link = K2HelperRoute::getItemRoute($article->id.':'.urlencode($article->alias),$article->catid.':'.urlencode($article->category->alias));
				}else{
					error_log('myApi unable to calculate link for the article id '.$article->id);
					return;
				}
				$u =& JURI::getInstance( JURI::base().$link );
				$port 	= ($u->getPort() == '') ? '' : ":".$u->getPort();
				$articleURL = 'http://'.$u->getHost().$port.$u->getPath().'?'.$u->getQuery();
				$rawText = strip_tags($article->introtext);
				$newTags = array();
				$newTags['og:title'] 		= $article->title;
				$newTags['og:description'] 	= (strlen($rawText) > 247) ? substr($rawText,0,247).'...' : $rawText;
				$newTags['og:type']	= 'article';
				$newTags['og:author']	= (is_object($article->author)) ? $article->author->name : $article->author;
				$newTags['og:url'] 	= $articleURL;
				if($attribs->get('ogimage','0') != '0') $newTags['og:image'] = $attribs->get('ogimage');
				
				plgSystemmyApiOpenGraph::setTags($newTags);
			}
		}
	}
示例#2
0
 public static function getAssociations($id = 0, $view = null)
 {
     jimport('helper.route', JPATH_COMPONENT_SITE);
     $application = JFactory::getApplication();
     $view = is_null($view) ? $application->input->get('view') : $view;
     $task = $application->input->get('task');
     $id = empty($id) ? $application->input->getInt('id') : $id;
     if ($view == 'item') {
         if ($id) {
             $associations = self::getItemAssociations($id);
             $return = array();
             foreach ($associations as $tag => $item) {
                 $return[$tag] = K2HelperRoute::getItemRoute($item->id, $item->catid, $item->language);
             }
             return $return;
         }
     } else {
         if ($view == 'itemlist' && $task == 'category') {
             if ($id) {
                 $associations = self::getCategoryAssociations($id);
                 $return = array();
                 foreach ($associations as $tag => $category) {
                     $return[$tag] = K2HelperRoute::getCategoryRoute($category->id, $category->language);
                 }
                 return $return;
             }
         }
     }
     return array();
 }
示例#3
0
 /** I HAVE NOT MODIFIED BELOW THIS LINE **/
 function getItems($args)
 {
     global $mainframe;
     $advlink =& AdvLink::getInstance();
     require_once JPATH_SITE . DS . 'components' . DS . 'com_k2' . DS . 'helpers' . DS . 'route.php';
     $items = array();
     $view = isset($args->view) ? $args->view : '';
     switch ($view) {
         default:
             $categories = AdvlinkK2::_getK2Categories();
             foreach ($categories as $category) {
                 $items[] = array('id' => K2HelperRoute::getCategoryRoute($category->id), 'name' => $category->name, 'class' => 'folder content');
             }
             break;
         case 'itemlist':
             $categories = AdvlinkK2::_getK2Categories($args->id);
             $itemlist = AdvlinkK2::_getK2Items($args->id);
             foreach ($categories as $category) {
                 $items[] = array('id' => K2HelperRoute::getCategoryRoute($category->id), 'name' => $category->name, 'class' => 'folder content');
             }
             foreach ($itemlist as $item) {
                 $items[] = array('id' => K2HelperRoute::getItemRoute($item->id, $args->id), 'name' => $item->title, 'class' => 'file');
             }
             break;
         case 'item':
             break;
     }
     return $items;
 }
示例#4
0
 /**
  * Prepare item properties
  */
 protected function _prepareItem($item)
 {
     $item->link = JRoute::_(K2HelperRoute::getItemRoute($item->id, $item->catid));
     $item->introtext = JHtml::_('string.truncate', $item->introtext, $this->_params->get('intro_length', 200));
     $item->cat_link = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($item->catid . ':' . urlencode($item->catslug))));
     return $item;
 }
示例#5
0
 private static function _getCurrentItemURL($article)
 {
     require_once JPATH_SITE . '/components/com_k2/helpers/route.php';
     $url = K2HelperRoute::getItemRoute($article->id . ":" . urlencode($article->alias), $article->catid);
     $url = SCArticleContent::_getCompleteURL($url);
     return $url;
 }
示例#6
0
 function getAuthors(&$params)
 {
     $componentParams =& JComponentHelper::getParams('com_k2');
     $where = '';
     $cid = $params->get('authors_module_category');
     if ($cid > 0) {
         $categories = modK2ToolsHelper::getCategoryChildren($cid);
         $categories[] = $cid;
         JArrayHelper::toInteger($categories);
         $where = " catid IN(" . implode(',', $categories) . ") AND ";
     }
     $user =& JFactory::getUser();
     $aid = (int) $user->get('aid');
     $db =& JFactory::getDBO();
     $jnow =& JFactory::getDate();
     $now = $jnow->toMySQL();
     $nullDate = $db->getNullDate();
     $query = "SELECT DISTINCT created_by FROM #__k2_items  WHERE {$where} published=1 AND ( publish_up = " . $db->Quote($nullDate) . " OR publish_up <= " . $db->Quote($now) . " ) AND ( publish_down = " . $db->Quote($nullDate) . " OR publish_down >= " . $db->Quote($now) . " ) AND trash=0 AND access<={$aid} AND created_by_alias='' AND EXISTS (SELECT * FROM #__k2_categories WHERE id= #__k2_items.catid AND published=1 AND trash=0 AND access<={$aid} )";
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     $authors = array();
     if (count($rows)) {
         foreach ($rows as $row) {
             $author = JFactory::getUser($row->created_by);
             $author->link = JRoute::_(K2HelperRoute::getUserRoute($author->id));
             $query = "SELECT id, gender, description, image, url, `group`, plugins FROM #__k2_users WHERE userID=" . (int) $author->id;
             $db->setQuery($query);
             $author->profile = $db->loadObject();
             if ($params->get('authorAvatar')) {
                 $author->avatar = K2HelperUtilities::getAvatar($author->id, $author->email, $componentParams->get('userImageWidth'));
             }
             $query = "SELECT i.*, c.alias as categoryalias FROM #__k2_items as i\n        LEFT JOIN #__k2_categories c ON c.id = i.catid\n        WHERE i.created_by = " . (int) $author->id . "\n        AND i.published = 1\n        AND i.access <= {$aid}\n        AND ( i.publish_up = " . $db->Quote($nullDate) . " OR i.publish_up <= " . $db->Quote($now) . " )\n        AND ( i.publish_down = " . $db->Quote($nullDate) . " OR i.publish_down >= " . $db->Quote($now) . " )\n        AND i.trash = 0 AND created_by_alias='' AND c.published = 1 AND c.access <= {$aid} AND c.trash = 0 ORDER BY created DESC";
             $db->setQuery($query, 0, 1);
             $author->latest = $db->loadObject();
             $author->latest->id = (int) $author->latest->id;
             $author->latest->link = urldecode(JRoute::_(K2HelperRoute::getItemRoute($author->latest->id . ':' . urlencode($author->latest->alias), $author->latest->catid . ':' . urlencode($author->latest->categoryalias))));
             $query = "SELECT COUNT(*) FROM #__k2_comments WHERE published=1 AND itemID={$author->latest->id}";
             $db->setQuery($query);
             $author->latest->numOfComments = $db->loadResult();
             if ($params->get('authorItemsCounter')) {
                 $query = "SELECT COUNT(*) FROM #__k2_items  WHERE {$where} published=1 AND ( publish_up = " . $db->Quote($nullDate) . " OR publish_up <= " . $db->Quote($now) . " ) AND ( publish_down = " . $db->Quote($nullDate) . " OR publish_down >= " . $db->Quote($now) . " ) AND trash=0 AND access<={$aid} AND created_by_alias='' AND created_by={$row->created_by} AND EXISTS (SELECT * FROM #__k2_categories WHERE id= #__k2_items.catid AND published=1 AND trash=0 AND access<={$aid} )";
                 $db->setQuery($query);
                 $numofitems = $db->loadResult();
                 $author->items = $numofitems;
             }
             $authors[] = $author;
         }
     }
     return $authors;
 }
示例#7
0
 function get_link($num)
 {
     if ($this->mode == 'com_content') {
         return $this->parent->content[$num]['id'] != 0 ? JRoute::_(ContentHelperRoute::getArticleRoute($this->parent->content[$num]['id'], $this->parent->content[$num]['cid'])) : JRoute::_('index.php?option=com_users&view=login');
     } else {
         if ($this->mode == 'com_k2') {
             //
             require_once JPATH_SITE . DS . 'components' . DS . 'com_k2' . DS . 'helpers' . DS . 'route.php';
             //
             return urldecode(JRoute::_(K2HelperRoute::getItemRoute($this->parent->content[$num]['id'] . ':' . urlencode($this->parent->content[$num]['alias']), $this->parent->content[$num]['cid'] . ':' . urlencode($this->parent->content[$num]['cat_alias']))));
         } else {
             return false;
         }
     }
 }
示例#8
0
 public function getArticleUrl()
 {
     if (isset($this->article->url)) {
         return $this->article->url;
     }
     if (!isset($this->article->id)) {
         return false;
     }
     if (!isset($this->article->category)) {
         JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_k2/tables');
         $category = JTable::getInstance('K2Category', 'Table');
         $category->load($this->article->catid);
         $this->article->category = $category;
     }
     require_once JPATH_SITE . '/components/com_k2/helpers/route.php';
     $this->article->url = K2HelperRoute::getItemRoute($this->article->id . ':' . $this->article->alias, $this->article->catid . ':' . $this->article->category->alias);
     return $this->article->url;
 }
示例#9
0
文件: ping.php 项目: Rikisha/proj
function com_k2_get_url(&$article, $isNew)
{
    $url = null;
    $helperPath = dirname(__FILE__) . "/../../../../../components/com_k2/helpers/route.php";
    if (is_file($helperPath)) {
        require_once $helperPath;
        $helper = new K2HelperRoute();
        $url = $helper->getItemRoute($article->id, $article->catid);
        $app = JApplication::getInstance('site');
        $router =& $app->getRouter();
        $uri = $router->build($url);
        $url = $uri->toString();
        if (strpos($url, "/administrator") === 0) {
            $url = substr($url, strlen("/administrator"));
        }
    }
    return $url;
}
示例#10
0
 function getObjectInfo($id, $language = null)
 {
     $info = new JCommentsObjectInfo();
     $routerHelper = JPATH_SITE . '/components/com_k2/helpers/route.php';
     if (is_file($routerHelper)) {
         require_once $routerHelper;
         $db = JFactory::getDBO();
         $query = "SELECT i.id, i.title, i.catid, i.alias, i.access, i.created_by, c.alias as catalias" . " FROM #__k2_items as i" . " LEFT JOIN #__k2_categories as c ON c.id=i.catid" . " WHERE i.id = " . $id;
         $db->setQuery($query);
         $row = $db->loadObject();
         if (!empty($row)) {
             $info->title = $row->title;
             $info->access = $row->access;
             $info->userid = $row->created_by;
             $info->link = JRoute::_(K2HelperRoute::getItemRoute($row->id . ':' . urlencode($row->alias), $row->catid . ':' . urlencode($row->catalias)));
         }
     }
     return $info;
 }
示例#11
0
 function get_link($num)
 {
     if ($this->mode == 'com_content') {
         return $this->parent->content[$num]['id'] != 0 ? JRoute::_(ContentHelperRoute::getArticleRoute($this->parent->content[$num]['id'], $this->parent->content[$num]['cid'])) : JRoute::_('index.php?option=com_users&view=login');
     } else {
         if ($this->mode == 'com_k2') {
             //
             require_once JPATH_SITE . DS . 'components' . DS . 'com_k2' . DS . 'helpers' . DS . 'route.php';
             //
             return urldecode(JRoute::_(K2HelperRoute::getItemRoute($this->parent->content[$num]['id'] . ':' . urlencode($this->parent->content[$num]['alias']), $this->parent->content[$num]['cid'] . ':' . urlencode($this->parent->content[$num]['cat_alias']))));
         } else {
             if ($this->mode == 'com_virtuemart') {
                 $itemid = $this->parent->config['vm_itemid'];
                 $link = 'index.php?option=com_virtuemart&amp;view=productdetails&amp;virtuemart_product_id=' . $this->parent->content[$num]['id'] . '&amp;virtuemart_category_id=' . $this->parent->content[$num]['cid'] . '&amp;Itemid=' . $itemid;
                 //
                 return $link;
             } else {
                 return false;
             }
         }
     }
 }
示例#12
0
 public function go($allGet)
 {
     $uri = JUri::getInstance();
     $currentLink = $uri->toString(array('path', 'query'));
     $start = JFactory::getApplication()->input->getInt('start', 0);
     JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_k2/tables');
     $limitstring = '';
     if ($start > 0) {
         $limits = $this->params->get('limits', 5);
         if ($start % $limits != 0) {
             $start = intval($start / $limits) * $limits;
         }
         $limitstring .= "?start=" . $start;
     }
     if ($allGet['view'] == 'item' && $allGet['task'] == '') {
         $item = JTable::getInstance('K2Item', 'Table');
         $item->load($allGet['id']);
         $category = JTable::getInstance('K2Category', 'Table');
         $category->load($item->catid);
         $original_link = JRoute::_(K2HelperRoute::getItemRoute($item->id . ':' . urlencode($item->alias), $item->catid . ':' . urlencode($category->alias)), false);
     } else {
         if ($allGet['view'] == 'itemlist' && $allGet['task'] == 'category') {
             $category = JTable::getInstance('K2Category', 'Table');
             $category->load((int) $allGet['id']);
             $original_link = JRoute::_(K2HelperRoute::getCategoryRoute((int) $allGet['id'] . ':' . urlencode($category->alias)), false) . $limitstring;
         } else {
             if ($allGet['view'] == 'itemlist' && $allGet['task'] == 'user') {
                 $original_link = JRoute::_(K2HelperRoute::getUserRoute((int) $allGet['id']), false) . $limitstring;
             } else {
                 return false;
             }
         }
     }
     if ($original_link && $original_link != $currentLink) {
         $this->shRedirect($original_link);
     }
     return true;
 }
示例#13
0
 private function format(&$items, $params)
 {
     if (!$items) {
         return;
     }
     // Add K2's table path
     JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_k2/tables');
     foreach ($items as $item) {
         $category = JTable::getInstance('K2Category', 'Table');
         $category->load($item->catid);
         $item->category = $category;
         $item->permalink = K2HelperRoute::getItemRoute($item->id . ':' . $item->alias, $item->catid);
         $item->category->permalink = K2HelperRoute::getCategoryRoute($category->id . ':' . $category->alias);
         $item->content = empty($item->introtext) ? $item->fulltext : $item->introtext;
         $titleLength = $params->get('title_length');
         $contentLength = $params->get('content_length');
         if ($titleLength) {
             $item->title = JString::substr($item->title, 0, $titleLength);
         }
         if ($contentLength) {
             $item->content = JString::substr(strip_tags($item->content), 0, $contentLength);
         }
     }
 }
示例#14
0
 /**
  * get the list of k2 items
  * 
  * @param JParameter $params;
  * @return Array
  */
 public function __getList($params)
 {
     global $mainframe;
     $maxTitle = $params->get('max_title', '100');
     $maxDesciption = $params->get('max_description', 100);
     $openTarget = $params->get('open_target', 'parent');
     $formatter = $params->get('style_displaying', 'title');
     $titleMaxChars = $params->get('title_max_chars', '100');
     $descriptionMaxChars = $params->get('description_max_chars', 100);
     $condition = $this->buildConditionQuery($params);
     $ordering = $params->get('k2_ordering', 'created_asc');
     $limit = $params->get('limit_items', 5);
     $ordering = str_replace('_', '  ', $ordering);
     $my =& JFactory::getUser();
     $aid = $my->get('aid', 0);
     $limitDescriptionBy = $params->get('limit_description_by', 'char');
     $thumbWidth = (int) $params->get('thumbnail_width', 35);
     $thumbHeight = (int) $params->get('thumbnail_height', 60);
     $imageHeight = (int) $params->get('main_height', 300);
     $imageWidth = (int) $params->get('main_width', 660);
     $isThumb = $params->get('auto_renderthumb', 1);
     $isStripedTags = $params->get('auto_strip_tags', 1);
     $extraURL = $params->get('open_target') != 'modalbox' ? '' : '&tmpl=component';
     $db =& JFactory::getDBO();
     $date =& JFactory::getDate();
     $now = $date->toMySQL();
     require_once JPath::clean(JPATH_SITE . '/components/com_k2/helpers/route.php');
     $query = "SELECT a.*, cr.rating_sum/cr.rating_count as rating, c.name as category_title,\n\t\t\t\t\t\t\tc.id as categoryid, c.alias as categoryalias, c.params as categoryparams, cc.commentcount as commentcount" . " FROM #__k2_items as a" . " LEFT JOIN #__k2_categories c ON c.id = a.catid" . " LEFT JOIN #__k2_rating as cr ON a.id = cr.itemid" . " LEFT JOIN (select cm.itemid  as id, count(cm.id) as commentcount from #__k2_comments as cm\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhere cm.published=1 group by cm.itemid) as cc on a.id = cc.id";
     $query .= " WHERE a.published = 1" . " AND a.access IN (" . implode(',', $my->authorisedLevels()) . ")" . " AND a.trash = 0";
     if ($params->get('featured_items_show', '0') == 0) {
         $query .= " AND a.featured != 1";
     } elseif ($params->get('featured_items_show', '0') == 2) {
         $query .= " AND a.featured = 1";
     }
     $query .= $condition . ' ORDER BY ' . $ordering;
     $query .= $limit ? ' LIMIT ' . $limit : '';
     $db->setQuery($query);
     $data = $db->loadObjectlist();
     if (empty($data)) {
         return array();
     }
     foreach ($data as $key => &$item) {
         $item->link = JRoute::_(K2HelperRoute::getItemRoute($item->id . ':' . $item->alias, $item->catid . ':' . $item->categoryalias) . $extraURL);
         $item->date = JHtml::_('date', $item->created, JText::_('DATE_FORMAT_LC2'));
         $item->subtitle = $this->substring($item->title, $titleMaxChars);
         if ($limitDescriptionBy == 'word') {
             $string = preg_replace("/\\s+/", " ", strip_tags($item->introtext));
             $tmp = explode(" ", $string);
             $item->description = $descriptionMaxChars > count($tmp) ? $string : implode(" ", array_slice($tmp, 0, $descriptionMaxChars));
         } else {
             $item->description = self::substring($item->introtext, $descriptionMaxChars, '', $isStripedTags);
         }
         $item->rating = is_numeric($item->rating) ? floatval($item->rating / 5 * 100) : null;
         $item->author = $item->created_by;
         $item = $this->generateImages($item, $isThumb);
         $item->categoryLink = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($item->catid . ':' . urlencode($item->categoryalias))));
         if ($params->get('itemAuthor')) {
             if (!empty($item->created_by_alias)) {
                 $item->author = $item->created_by_alias;
                 $item->authorGender = NULL;
             } else {
                 $author =& JFactory::getUser($item->created_by);
                 $item->author = $author->name;
                 $query = "SELECT `gender` FROM #__k2_users WHERE userID=" . (int) $author->id;
                 $db->setQuery($query, 0, 1);
                 $item->authorGender = $db->loadResult();
                 //Author Link
                 $item->authorLink = JRoute::_(K2HelperRoute::getUserRoute($item->created_by));
             }
         }
     }
     return $data;
 }
示例#15
0
	/**
	 * @param  int|TableInterface  $row
	 * @param  bool                $htmlspecialchars
	 * @param  string              $type
	 * @return string
	 */
	static public function getUrl( $row, $htmlspecialchars = true, $type = 'article' )
	{
		global $_CB_framework;

		$plugin				=	cbconsultationsClass::getPlugin();

		if ( is_integer( $row ) ) {
			$row			=	new cbconsultationsconsultationTable();

			$row->load( (int) $row );
		}

		$category			=	$row->getCategory();

		/** @noinspection PhpIncludeInspection */
		require_once ( $_CB_framework->getCfg( 'absolute_path' ) . '/components/com_k2/helpers/route.php' );

		$categorySlug		=	$row->get( 'catid' ) . ( $category->get( 'alias' ) ? ':' . $category->get( 'alias' ) : null );
		$articleSlug		=	$row->get( 'id' ) . ( $row->get( 'alias' ) ? ':' . $row->get( 'alias' ) : null );

		switch ( $type ) {
			case 'section':
				/** @noinspection PhpUndefinedClassInspection */
				$url		=	K2HelperRoute::getCategoryRoute( $plugin->params->get( 'consultation_section', null ) );
				break;
			case 'category':
				/** @noinspection PhpUndefinedClassInspection */
				$url		=	K2HelperRoute::getCategoryRoute( $categorySlug );
				break;
			case 'article':
			default:
			/** @noinspection PhpUndefinedClassInspection */
				$url		=	K2HelperRoute::getItemRoute( $articleSlug, $categorySlug );
				break;
		}

		if ( ! stristr( $url, 'Itemid' ) ) {
			$url			=	$_CB_framework->getCfg( 'live_site' ) . '/' . $url;
		} else {
			$url			=	JRoute::_( $url, false );
		}

		if ( $url ) {
			if ( $htmlspecialchars ) {
				$url		=	htmlspecialchars( $url );
			}
		}

		return $url;
	}
示例#16
0
	function onBeforeDisplayContent( &$article, &$params, $limitstart ){
		if(!file_exists(JPATH_SITE.DS.'plugins'.DS.'system'.DS.'myApiConnectFacebook.php') || (!array_key_exists('category',$article) && !isset($params->showK2Plugins)  )){ return; }
		
		//this may fire fron a component other than com_content
		if((@$article->id != '') && (@$_POST['fb_sig_api_key'] == '')){
			$doc = & JFactory::getDocument();
			
			$plugin = & JPluginHelper::getPlugin('content', 'myApiSend');

			// Load plugin params info
			$myapiparama = new JParameter($plugin->params);
			
			$send_sections 		= $myapiparama->get('send_sections');
			$send_categories 	= $myapiparama->get('send_categories');
			$send_show_on 		= $myapiparama->get('send_show_on');
			$layout_style 		= $myapiparama->get('layout_style');
			$show_faces 		= $myapiparama->get('show_faces');
			$color_scheme 		= $myapiparama->get('color_scheme');
			$verb 				= $myapiparama->get('verb');
			$width 				= $myapiparama->get('width');
			$send_style 		= $myapiparama->get('send_style');
			$font 				= $myapiparama->get('send_font');
			$ref 				= $myapiparama->get('send_ref');
			$show_send 			= $myapiparama->get('send_send');
			$position			= $myapiparama->get('position','myApiShareTop');
			$send_show 			= false;
		
			$facebook = plgSystemmyApiConnect::getFacebook();
			
			if(isset($article->sectionid)){
				if( is_array($send_sections) ){	
					foreach($send_sections as $id){ if($id == $article->sectionid) $send_show = true;  }
				}
				elseif($send_sections == $article->sectionid) $send_show = true;
			}
			
			if(isset($article->category)){
				if( is_array($send_categories) ){	
					foreach($send_categories as $id){ if($id == $article->category) $send_show = true; }
				}
				elseif($send_categories == $article->category) $send_show = true;
			}
			
			if(($send_show) || ($send_show_on == 'all')){
				require_once(JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php');
				
				if(isset($article->slug)){
					require_once(JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php');
					$link = ContentHelperRoute::getArticleRoute($article->slug, $article->catslug, $article->sectionid);
				}elseif(method_exists('K2HelperRoute','getItemRoute')){
					$link = K2HelperRoute::getItemRoute($article->id.':'.urlencode($article->alias),$article->catid.':'.urlencode($article->category->alias));
				}else{
					error_log('myApi unable to calculate link for the article id '.$article->id);
					return;
				}
				$u =& JURI::getInstance( JURI::base().$link );
				$port 	= ($u->getPort() == '') ? '' : ":".$u->getPort();
				$link = 'http://'.$u->getHost().$port.$u->getPath().'?'.$u->getQuery();
				$button	= '<fb:send href="'.$link.'" colorscheme="'.$color_scheme.'" font="'.$font.'" ref="'.$ref.'"></fb:send>';
		
				require_once(JPATH_SITE.DS.'plugins'.DS.'system'.DS.'myApiDom.php');
				$article->text = myApiButtons::addToTable($article->text,$position,$button);
			}
		}
	}
示例#17
0
    function display($tpl = null)
    {
        $mainframe =& JFactory::getApplication();
        $user =& JFactory::getUser();
        $document =& JFactory::getDocument();
        $params =& JComponentHelper::getParams('com_k2');
        $limitstart = JRequest::getInt('limitstart', 0);
        $view = JRequest::getWord('view');
        $task = JRequest::getWord('task');
        $db =& JFactory::getDBO();
        $jnow =& JFactory::getDate();
        $now = $jnow->toMySQL();
        $nullDate = $db->getNullDate();
        $this->setLayout('item');
        //Add link
        if (K2HelperPermissions::canAddItem()) {
            $addLink = JRoute::_('index.php?option=com_k2&view=item&task=add&tmpl=component');
        }
        $this->assignRef('addLink', $addLink);
        //Get item
        $model =& $this->getModel();
        $item = $model->getData();
        //Prepare item
        if ($user->guest) {
            $cache =& JFactory::getCache('com_k2_extended');
            $hits = $item->hits;
            $item->hits = 0;
            $item = $cache->call(array('K2ModelItem', 'prepareItem'), $item, $view, $task);
            $item->hits = $hits;
        } else {
            $item = $model->prepareItem($item, $view, $task);
        }
        //Plugins
        $item = $model->execPlugins($item, $view, $task);
        //Access check
        if ($this->getLayout() == 'form') {
            JError::raiseError(403, JText::_("ALERTNOTAUTH"));
        }
        if ($item->access > $user->get('aid', 0) || $item->category->access > $user->get('aid', 0)) {
            JError::raiseError(403, JText::_("ALERTNOTAUTH"));
        }
        //Published check
        if (!$item->published || $item->trash) {
            JError::raiseError(404, JText::_("Item not found"));
        }
        if ($item->publish_up != $nullDate && $item->publish_up > $now) {
            JError::raiseError(404, JText::_("Item not found"));
        }
        if ($item->publish_down != $nullDate && $item->publish_down < $now) {
            JError::raiseError(404, JText::_("Item not found"));
        }
        if (!$item->category->published || $item->category->trash) {
            JError::raiseError(404, JText::_("Item not found"));
        }
        //Increase hits counter
        $model->hit($item->id);
        //Set default image
        K2HelperUtilities::setDefaultImage($item, $view);
        //Comments
        $item->event->K2CommentsCounter = '';
        $item->event->K2CommentsBlock = '';
        if ($item->params->get('itemComments')) {
            //Trigger comments events
            $dispatcher =& JDispatcher::getInstance();
            JPluginHelper::importPlugin('k2');
            $results = $dispatcher->trigger('onK2CommentsCounter', array(&$item, &$params, $limitstart));
            $item->event->K2CommentsCounter = trim(implode("\n", $results));
            $results = $dispatcher->trigger('onK2CommentsBlock', array(&$item, &$params, $limitstart));
            $item->event->K2CommentsBlock = trim(implode("\n", $results));
            //Load K2 native comments system only if there are no plugins overriding it
            if (empty($item->event->K2CommentsCounter) && empty($item->event->K2CommentsBlock)) {
                //Load reCAPTCHA script
                if (!JRequest::getInt('print') && ($item->params->get('comments') == '1' || $item->params->get('comments') == '2' && K2HelperPermissions::canAddComment($item->catid))) {
                    if ($item->params->get('recaptcha') && $user->guest) {
                        $document->addScript('http://api.recaptcha.net/js/recaptcha_ajax.js');
                        $js = 'function showRecaptcha(){
								    Recaptcha.create("' . $item->params->get('recaptcha_public_key') . '", "recaptcha", {
								        theme: "' . $item->params->get('recaptcha_theme', 'clean') . '"
								    });
								}
								window.addEvent(\'load\', function(){
									showRecaptcha();
								})';
                        $document->addScriptDeclaration($js);
                    }
                    //Auto complete some fields for registered users
                    if (!$user->guest) {
                        $js = "window.addEvent('domready', function(){\n\t\t\t\t\t\t\t\t\t\$('userName').setProperty('value','" . $user->name . "');\n\t\t\t\t\t\t\t\t\t\$('userName').setProperty('disabled','disabled');\n\t\t\t\t\t\t\t\t\t\$('commentEmail').setProperty('value','" . $user->email . "');\n\t\t\t\t\t\t\t\t\t\$('commentEmail').setProperty('disabled','disabled');\n\n\t\t\t\t\t\t\t\t})";
                        $document->addScriptDeclaration($js);
                    }
                }
                $limit = $params->get('commentsLimit');
                $comments = $model->getItemComments($item->id, $limitstart, $limit);
                $pattern = "@\\b(https?://)?(([0-9a-zA-Z_!~*'().&=+\$%-]+:)?[0-9a-zA-Z_!~*'().&=+\$%-]+\\@)?(([0-9]{1,3}\\.){3}[0-9]{1,3}|([0-9a-zA-Z_!~*'()-]+\\.)*([0-9a-zA-Z][0-9a-zA-Z-]{0,61})?[0-9a-zA-Z]\\.[a-zA-Z]{2,6})(:[0-9]{1,4})?((/[0-9a-zA-Z_!~*'().;?:\\@&=+\$,%#-]+)*/?)@";
                for ($i = 0; $i < sizeof($comments); $i++) {
                    $comments[$i]->commentText = nl2br($comments[$i]->commentText);
                    $comments[$i]->commentText = preg_replace($pattern, '<a target="_blank" rel="nofollow" href="\\0">\\0</a>', $comments[$i]->commentText);
                    $comments[$i]->userImage = K2HelperUtilities::getAvatar($comments[$i]->userID, $comments[$i]->commentEmail, $params->get('commenterImgWidth'));
                    if ($comments[$i]->userID > 0) {
                        $comments[$i]->userLink = K2HelperRoute::getUserRoute($comments[$i]->userID);
                    } else {
                        $comments[$i]->userLink = $comments[$i]->commentURL;
                    }
                }
                $item->comments = $comments;
                jimport('joomla.html.pagination');
                $total = $item->numOfComments;
                $pagination = new JPagination($total, $limitstart, $limit);
            }
        }
        //Author's latest items
        if ($params->get('itemAuthorLatest') && $item->created_by_alias == '') {
            $model =& $this->getModel('itemlist');
            $authorLatestItems = $model->getAuthorLatest($item->id, $params->get('itemAuthorLatestLimit'), $item->created_by);
            if (count($authorLatestItems)) {
                for ($i = 0; $i < sizeof($authorLatestItems); $i++) {
                    $authorLatestItems[$i]->link = urldecode(JRoute::_(K2HelperRoute::getItemRoute($authorLatestItems[$i]->id . ':' . urlencode($authorLatestItems[$i]->alias), $authorLatestItems[$i]->catid . ':' . urlencode($authorLatestItems[$i]->categoryalias))));
                }
                $this->assignRef('authorLatestItems', $authorLatestItems);
            }
        }
        //Related items
        if ($params->get('itemRelated') && isset($item->tags) && count($item->tags)) {
            $model =& $this->getModel('itemlist');
            $relatedItems = $model->getRelatedItems($item->id, $item->tags, $params->get('itemRelatedLimit'));
            if (count($relatedItems)) {
                for ($i = 0; $i < sizeof($relatedItems); $i++) {
                    $relatedItems[$i]->link = urldecode(JRoute::_(K2HelperRoute::getItemRoute($relatedItems[$i]->id . ':' . urlencode($relatedItems[$i]->alias), $relatedItems[$i]->catid . ':' . urlencode($relatedItems[$i]->categoryalias))));
                }
                $this->assignRef('relatedItems', $relatedItems);
            }
        }
        //Navigation (previous and next item)
        if ($params->get('itemNavigation')) {
            $model =& $this->getModel('item');
            $nextItem = $model->getNextItem($item->id, $item->catid, $item->ordering);
            if (!is_null($nextItem)) {
                $item->nextLink = urldecode(JRoute::_(K2HelperRoute::getItemRoute($nextItem->id . ':' . urlencode($nextItem->alias), $nextItem->catid . ':' . urlencode($item->category->alias))));
                $item->nextTitle = $nextItem->title;
            }
            $previousItem = $model->getPreviousItem($item->id, $item->catid, $item->ordering);
            if (!is_null($previousItem)) {
                $item->previousLink = urldecode(JRoute::_(K2HelperRoute::getItemRoute($previousItem->id . ':' . urlencode($previousItem->alias), $previousItem->catid . ':' . urlencode($item->category->alias))));
                $item->previousTitle = $previousItem->title;
            }
        }
        // Absolute URL
        $uri =& JURI::getInstance();
        $item->absoluteURL = $uri->_uri;
        //Email link
        $item->emailLink = JRoute::_('index.php?option=com_mailto&tmpl=component&link=' . base64_encode($item->absoluteURL));
        //Twitter link
        if ($params->get('itemTwitterLink') && $params->get('twitterUsername')) {
            $itemURLForTwitter = $params->get('tinyURL') ? @file_get_contents('http://tinyurl.com/api-create.php?url=' . $item->absoluteURL) : $item->absoluteURL;
            $item->twitterURL = 'http://twitter.com/home/?status=' . urlencode('Reading @' . $params->get('twitterUsername') . ' ' . $item->title . ' ' . $itemURLForTwitter);
        }
        //Social link
        $item->socialLink = urlencode($item->absoluteURL);
        //Look for template files in component folders
        $this->_addPath('template', JPATH_COMPONENT . DS . 'templates');
        $this->_addPath('template', JPATH_COMPONENT . DS . 'templates' . DS . 'default');
        //Look for overrides in template folder (K2 template structure)
        $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'templates');
        $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'templates' . DS . 'default');
        //Look for overrides in template folder (Joomla! template structure)
        $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'default');
        $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2');
        //Look for specific K2 theme files
        if ($item->params->get('theme')) {
            $this->_addPath('template', JPATH_COMPONENT . DS . 'templates' . DS . $item->params->get('theme'));
            $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'templates' . DS . $item->params->get('theme'));
            $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . $item->params->get('theme'));
        }
        //Assign data
        $this->assignRef('item', $item);
        $this->assignRef('user', $user);
        $this->assignRef('params', $item->params);
        $this->assignRef('pagination', $pagination);
        parent::display($tpl);
    }
示例#18
0
<?php
示例#19
0
 function getTopCommenters(&$params)
 {
     JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_k2' . DS . 'tables');
     $limit = $params->get('commenters_limit', '5');
     $user =& JFactory::getUser();
     $aid = $user->get('aid');
     $db =& JFactory::getDBO();
     $query = "SELECT COUNT(id) as counter, userName, userID, commentEmail FROM #__k2_comments WHERE userID > 0 AND published = 1 GROUP BY userID ORDER BY counter DESC";
     $db->setQuery($query, 0, $limit);
     $rows = $db->loadObjectList();
     $pattern = "@\\b(https?://)?(([0-9a-zA-Z_!~*'().&=+\$%-]+:)?[0-9a-zA-Z_!~*'().&=+\$%-]+\\@)?(([0-9]{1,3}\\.){3}[0-9]{1,3}|([0-9a-zA-Z_!~*'()-]+\\.)*([0-9a-zA-Z][0-9a-zA-Z-]{0,61})?[0-9a-zA-Z]\\.[a-zA-Z]{2,6})(:[0-9]{1,4})?((/[0-9a-zA-Z_!~*'().;?:\\@&=+\$,%#-]+)*/?)@";
     require_once JPATH_SITE . DS . 'components' . DS . 'com_k2' . DS . 'models' . DS . 'item.php';
     $model = new K2ModelItem();
     $componentParams =& JComponentHelper::getParams('com_k2');
     if (count($rows)) {
         foreach ($rows as $row) {
             if ($row->counter > 0) {
                 $row->link = JRoute::_(K2HelperRoute::getUserRoute($row->userID));
                 if ($params->get('commentAvatar')) {
                     $row->userImage = K2HelperUtilities::getAvatar($row->userID, $row->commentEmail, $componentParams->get('commenterImgWidth'));
                 }
                 if ($params->get('commenterLatestComment')) {
                     $query = "SELECT * FROM #__k2_comments WHERE userID = " . (int) $row->userID . " AND published = 1 ORDER BY commentDate DESC";
                     $db->setQuery($query, 0, 1);
                     $comment = $db->loadObject();
                     $item =& JTable::getInstance('K2Item', 'Table');
                     $item->load($comment->itemID);
                     $category =& JTable::getInstance('K2Category', 'Table');
                     $category->load($item->catid);
                     $row->latestCommentText = $comment->commentText;
                     $row->latestCommentText = preg_replace($pattern, '<a target="_blank" rel="nofollow" href="\\0">\\0</a>', $row->latestCommentText);
                     $row->latestCommentLink = urldecode(JRoute::_(K2HelperRoute::getItemRoute($item->id . ':' . urlencode($item->alias), $item->catid . ':' . urlencode($category->alias)))) . "#comment{$comment->id}";
                     $row->latestCommentDate = $comment->commentDate;
                 }
                 $commenters[] = $row;
             }
         }
         if (isset($commenters)) {
             return $commenters;
         }
     }
 }
示例#20
0
 /**
  * get list k2 items follow setting configuration.
  *
  * @param JParameter $param
  * @return array
  */
 public function getListK2($params)
 {
     global $mainframe;
     if (!file_exists(JPATH_SITE . DS . 'components' . DS . 'com_k2' . DS . 'k2.php')) {
         return;
     }
     $catsid = $params->get('k2catsid');
     $catids = array();
     if (!is_array($catsid)) {
         $catids[] = $catsid;
     } else {
         $catids = $catsid;
     }
     JArrayHelper::toInteger($catids);
     if ($catids) {
         if ($catids && count($catids) > 0) {
             foreach ($catids as $k => $catid) {
                 if (!$catid) {
                     unset($catids[$k]);
                 }
             }
         }
     }
     jimport('joomla.filesystem.file');
     $user = JFactory::getUser();
     $aid = $user->get('aid') ? $user->get('aid') : 1;
     $db = JFactory::getDBO();
     $jnow = JFactory::getDate();
     if (version_compare(JVERSION, '3.0', 'ge')) {
         $now = $jnow->toSql();
     } else {
         if (version_compare(JVERSION, '2.5', 'ge')) {
             $now = $jnow->toMySQL();
         } else {
             $now = $jnow->toMySQL();
         }
     }
     $nullDate = $db->getNullDate();
     $query = "SELECT i.*, c.name AS categoryname,c.id AS categoryid, c.alias AS categoryalias, c.name as cattitle, c.params AS categoryparams";
     $query .= "\n FROM #__k2_items as i LEFT JOIN #__k2_categories c ON c.id = i.catid";
     $query .= "\n WHERE i.published = 1 AND i.access <= {$aid} AND i.trash = 0 AND c.published = 1 AND c.access <= {$aid} AND c.trash = 0";
     $query .= "\n AND ( i.publish_up = " . $db->Quote($nullDate) . " OR i.publish_up <= " . $db->Quote($now) . " )";
     $query .= "\n AND ( i.publish_down = " . $db->Quote($nullDate) . " OR i.publish_down >= " . $db->Quote($now) . " )";
     if ($catids) {
         $catids_new = $catids;
         foreach ($catids as $k => $catid) {
             $subcatids = modJABulletin::getK2CategoryChildren($catid, true);
             if ($subcatids) {
                 $catids_new = array_merge($catids_new, array_diff($subcatids, $catids_new));
             }
         }
         $catids = implode(',', $catids_new);
         $query .= "\n AND i.catid IN ({$catids})";
     }
     $featured = $params->get('show_featured', 1);
     switch ($featured) {
         case 0:
             $query .= " AND i.featured = 0 ";
             break;
         case 2:
             $query .= " AND i.featured = 1 ";
             break;
     }
     // Set ordering
     $ordering = $params->get('type', 'latest');
     if ($ordering == 'latest') {
         // Set ordering
         $order_map = array('m_dsc' => 'i.modified DESC, i.created', 'mc_dsc' => 'CASE WHEN (a.modified = ' . $db->quote($db->getNullDate()) . ') THEN i.created ELSE i.modified END', 'c_dsc' => 'i.created', 'p_dsc' => 'i.publish_up');
         $ordering = JArrayHelper::getValue($order_map, $params->get('ordering', 'm_dsc'), 'i.publish_up');
     } else {
         $ordering = 'i.hits';
     }
     if ($ordering == "i.hits" && $params->get('timerange')) {
         $datenow = JFactory::getDate();
         if (version_compare(JVERSION, '3.0', 'ge')) {
             $date = $datenow->toSql();
         } else {
             if (version_compare(JVERSION, '2.5', 'ge')) {
                 $date = $datenow->toMySQL();
             } else {
                 $date = $datenow->toMySQL();
             }
         }
         $query .= " AND i.created > DATE_SUB('{$date}',INTERVAL " . $params->get('timerange') . " DAY) ";
     }
     $query .= ' ORDER BY ' . $ordering . ' DESC ';
     if ((int) trim($params->get('count', 5)) == 0) {
         $query = str_replace("i.published = 1 AND", "i.published = 10 AND", $query);
     }
     $db->setQuery($query, 0, (int) trim($params->get('count', 5)));
     $items = $db->loadObjectList();
     if ($items) {
         $i = 0;
         $showHits = $params->get('show_hits', 0);
         $showHits = $showHits == "1" ? true : false;
         $showimg = $params->get('show_image', 1);
         $w = (int) $params->get('width', 80);
         $h = (int) $params->get('height', 96);
         $showdate = $params->get('show_date', 1);
         $thumbnailMode = $params->get('thumbnail_mode', 'crop');
         $aspect = $params->get('use_ratio', '1');
         $crop = $thumbnailMode == 'crop' ? true : false;
         $lists = array();
         $jaimage = JAImage::getInstance();
         foreach ($items as &$item) {
             $item->link = urldecode(JRoute::_(K2HelperRoute::getItemRoute($item->id . ':' . urlencode($item->alias), $item->catid . ':' . urlencode($item->categoryalias))));
             $item->text = htmlspecialchars($item->title);
             if ($showdate) {
                 $item->date = $item->modified == null || $item->modified == "" || $item->modified == "0000-00-00 00:00:00" ? $item->created : $item->modified;
             }
             $item->image = '';
             if ($showimg) {
                 $imageSource = $this->parseImages($item, $params, 'k2');
                 if ($imageSource) {
                     if ($thumbnailMode != 'none') {
                         $imageURL = $jaimage->resize($imageSource, $w, $h, $crop, $aspect);
                         if ($imageURL) {
                             if ($imageURL == $imageSource) {
                                 $width = $w ? "width=\"{$w}\"" : "";
                                 $height = $h ? "height=\"{$h}\"" : "";
                                 $item->image = "<img src=\"{$imageURL}\" alt=\"{$item->text}\" title=\"{$item->text}\" {$width} {$height} />";
                             } else {
                                 $item->image = "<img src=\"{$imageURL}\" alt=\"{$item->text}\" title=\"{$item->text}\" />";
                             }
                         } else {
                             $item->image = '';
                         }
                     } else {
                         $width = $w ? "width=\"{$w}\"" : "";
                         $height = $h ? "height=\"{$h}\"" : "";
                         $item->image = "<img src=\"{$imageSource}\" alt=\"{$item->text}\" title=\"{$item->text}\" {$width} {$height} />";
                     }
                 }
             }
             //Author
             $author = JFactory::getUser($item->created_by);
             $item->creater = $author->name;
             if ($showHits) {
                 $item->hits = isset($item->hits) ? $item->hits : 0;
             } else {
                 $item->hits = null;
             }
         }
     }
     return $items;
 }
示例#21
0
 protected function index(FinderIndexerResult $item, $format = 'html')
 {
     // Check if the extension is enabled
     if (JComponentHelper::isEnabled($this->extension) == false) {
         return;
     }
     // Initialize the item parameters.
     $registry = new JRegistry();
     $registry->loadString($item->params);
     $item->params = JComponentHelper::getParams('com_k2', true);
     $item->params->merge($registry);
     $registry = new JRegistry();
     $registry->loadString($item->metadata);
     $item->metadata = $registry;
     // Trigger the onContentPrepare event.
     $item->summary = FinderIndexerHelper::prepareContent($item->summary, $item->params);
     $item->body = FinderIndexerHelper::prepareContent($item->body, $item->params);
     // Build the necessary route and path information.
     $item->url = $this->getURL($item->id, $this->extension, $this->layout);
     $item->route = K2HelperRoute::getItemRoute($item->slug, $item->catslug);
     $item->path = FinderIndexerHelper::getContentPath($item->route);
     // Get the menu title if it exists.
     $title = $this->getItemMenuTitle($item->url);
     // Adjust the title if necessary.
     if (!empty($title) && $this->params->get('use_menu_title', true)) {
         $item->title = $title;
     }
     // Add the meta-author.
     $item->metaauthor = $item->metadata->get('author');
     // Add the meta-data processing instructions.
     $item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey');
     $item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc');
     $item->addInstruction(FinderIndexer::META_CONTEXT, 'metaauthor');
     $item->addInstruction(FinderIndexer::META_CONTEXT, 'author');
     $item->addInstruction(FinderIndexer::META_CONTEXT, 'created_by_alias');
     // Translate the state. Articles should only be published if the category is published.
     $item->state = $this->translateState($item->state, $item->cat_state);
     // Translate the trash state. Articles should only be accesible if the category is accessible.
     if ($item->trash || $item->cat_trash) {
         $item->state = 0;
     }
     // Add the type taxonomy data.
     $item->addTaxonomy('Type', 'K2 Item');
     // Add the author taxonomy data.
     if (!empty($item->author) || !empty($item->created_by_alias)) {
         $item->addTaxonomy('Author', !empty($item->created_by_alias) ? $item->created_by_alias : $item->author);
     }
     // Add the category taxonomy data.
     $item->addTaxonomy('K2 Category', $item->category, $item->cat_state, $item->cat_access);
     // Add the language taxonomy data.
     $item->addTaxonomy('Language', $item->language);
     // Get content extras.
     FinderIndexerHelper::getContentExtras($item);
     // Index the item.
     FinderIndexer::index($item);
 }
示例#22
0
 /**
  *
  * Get Articles of K2
  * @param array $catids categories of K2
  * @param object $helper
  * @param object $params
  * @return object
  */
 function getArticles($catids, &$helper, $params)
 {
     jimport('joomla.filesystem.file');
     $limit = (int) $params->get('introitems', $helper->get('introitems')) + (int) $params->get('linkitems', $helper->get('linkitems'));
     if (!$limit) {
         $limit = 4;
     }
     $ordering = $helper->get('ordering', '');
     //get params of K2 component
     $componentParams = JComponentHelper::getParams('com_k2');
     $limitstart = 0;
     $user = JFactory::getUser();
     $aid = $user->get('aid') ? $user->get('aid') : 1;
     $db = JFactory::getDBO();
     $jnow = JFactory::getDate();
     //$now 				= $jnow->toMySQL();
     if (version_compare(JVERSION, '3.0', 'ge')) {
         $now = $jnow->toSql();
     } else {
         if (version_compare(JVERSION, '2.5', 'ge')) {
             $now = $jnow->toMySQL();
         } else {
             $now = $jnow->toMySQL();
         }
     }
     $nullDate = $db->getNullDate();
     $query = "SELECT i.*, c.name AS categoryname,c.id AS categoryid, c.alias AS categoryalias, c.name as cattitle, c.params AS categoryparams";
     $query .= "\n FROM #__k2_items as i LEFT JOIN #__k2_categories c ON c.id = i.catid";
     $query .= "\n WHERE i.published = 1 AND i.access <= {$aid} AND i.trash = 0 AND c.published = 1 AND c.access <= {$aid} AND c.trash = 0";
     $query .= "\n AND i.catid IN ({$catids})";
     $query .= "\n AND ( i.publish_up = " . $db->Quote($nullDate) . " OR i.publish_up <= " . $db->Quote($now) . " )";
     $query .= "\n AND ( i.publish_down = " . $db->Quote($nullDate) . " OR i.publish_down >= " . $db->Quote($now) . " )";
     if ($helper->get('featured') == 'hide') {
         $query .= "\n AND i.featured = 0";
     }
     if ($helper->get('featured') == 'only') {
         $query .= "\n AND i.featured = 1";
     }
     if ($helper->get('timerange') > 0) {
         $datenow = JFactory::getDate();
         //$date 		= $datenow->toMySQL();
         if (version_compare(JVERSION, '3.0', 'ge')) {
             $date = $datenow->toSql();
         } else {
             if (version_compare(JVERSION, '2.5', 'ge')) {
                 $date = $datenow->toMySQL();
             } else {
                 $date = $datenow->toMySQL();
             }
         }
         $query .= " AND i.created > DATE_SUB('{$date}',INTERVAL " . $helper->get('timerange') . " DAY) ";
     }
     $sort_order = $helper->get('sort_order', 'DESC');
     switch ($ordering) {
         case 'ordering':
             $ordering = 'ordering ' . $sort_order;
             break;
         case 'rand':
             $ordering = 'RAND()';
             break;
         case 'hits':
             $ordering = 'hits ' . $sort_order;
             break;
         case 'created':
             $ordering = 'created ' . $sort_order;
             break;
         case 'modified':
             $ordering = 'modified ' . $sort_order;
             break;
         case 'title':
             $ordering = 'title ' . $sort_order;
             break;
     }
     if ($ordering == 'RAND()') {
         $query .= "\n ORDER BY " . $ordering;
     } else {
         $query .= "\n ORDER BY i." . $ordering;
     }
     $db->setQuery($query, 0, $limit);
     $rows = $db->loadObjectList();
     $autoresize = intval(trim($helper->get('autoresize', 0)));
     $width_img = (int) $helper->get('width', 100) < 0 ? 100 : $helper->get('width', 100);
     $height_img = (int) $helper->get('height', 100) < 0 ? 100 : $helper->get('height', 100);
     $img_w = intval(trim($width_img));
     $img_h = intval(trim($height_img));
     //$img_w 				= intval(trim($helper->get('width', 100)));
     //$img_h 				= intval(trim($helper->get('height', 100)));
     $img_align = $helper->get('align', 'left');
     $showimage = $params->get('showimage', $helper->get('showimage', 0));
     $maxchars = intval(trim($helper->get('maxchars', 200)));
     $hiddenClasses = trim($helper->get('hiddenClasses', ''));
     $showdate = $helper->get('showdate', 0);
     $enabletimestamp = $helper->get('timestamp', 0);
     if (count($rows)) {
         foreach ($rows as $j => $row) {
             $row->introtext1 = "";
             $row->cat_link = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($row->categoryid . ':' . urlencode($row->categoryalias))));
             //Clean title
             $row->title = JFilterOutput::ampReplace($row->title);
             //Images
             $image = '';
             if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $row->id) . '_XL.jpg')) {
                 $image = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $row->id) . '_XL.jpg';
             } elseif (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $row->id) . '_XS.jpg')) {
                 $image = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $row->id) . '_XS.jpg';
             } elseif (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $row->id) . '_L.jpg')) {
                 $image = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $row->id) . '_L.jpg';
             } elseif (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $row->id) . '_S.jpg')) {
                 $image = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $row->id) . '_S.jpg';
             } elseif (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $row->id) . '_M.jpg')) {
                 $image = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $row->id) . '_M.jpg';
             } elseif (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $row->id) . '_Generic.jpg')) {
                 $image = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $row->id) . '_Generic.jpg';
             }
             if ($image != '') {
                 $thumbnailMode = $helper->get('thumbnail_mode', 'crop');
                 $aspect = $helper->get('use_ratio', '1');
                 $crop = $thumbnailMode == 'crop' ? true : false;
                 $align = $img_align ? "align=\"{$img_align}\"" : "";
                 $jaimage = JAImage::getInstance();
                 if ($thumbnailMode != 'none' && $jaimage->sourceExited($image)) {
                     $imageURL = $jaimage->resize($image, $img_w, $img_h, $crop, $aspect);
                     $imageURL = str_replace(JURI::base(), '', $imageURL);
                     $imageURL = JURI::base() . $imageURL;
                     $row->image = $imageURL ? "<img class=\"{$img_align}\" src=\"" . $imageURL . "\" alt=\"{$row->title}\" {$align} />" : "";
                 } else {
                     $width = $img_w ? "width=\"{$img_w}\"" : "";
                     $height = $img_h ? "height=\"{$img_h}\"" : "";
                     $imageURL = str_replace(JURI::base(), '', $imageURL);
                     $imageURL = JURI::base() . $imageURL;
                     $row->image = "<img class=\"{$img_align}\" src=\"" . $image . "\" alt=\"{$row->title}\" {$img_w} {$img_h} {$align} />";
                 }
                 if ($maxchars && strlen($row->introtext) > $maxchars) {
                     $doc = JDocument::getInstance();
                     if (function_exists('mb_substr')) {
                         $row->introtext1 = SmartTrim::mb_trim($row->introtext, 0, $maxchars, $doc->_charset);
                     } else {
                         $row->introtext1 = SmartTrim::trim($row->introtext, 0, $maxchars);
                     }
                 } elseif ($maxchars == 0) {
                     $row->introtext1 = '';
                 }
                 $helper->replaceImage($row, $img_align, $autoresize, $maxchars, $showimage, $img_w, $img_h, $hiddenClasses);
             } else {
                 $row->image = $helper->replaceImage($row, $img_align, $autoresize, $maxchars, $showimage, $img_w, $img_h, $hiddenClasses);
                 if ($maxchars == 0) {
                     $row->introtext1 = '';
                 }
             }
             // Introtext
             $row->text = $row->introtext;
             //Read more link
             $row->link = urldecode(JRoute::_(K2HelperRoute::getItemRoute($row->id . ':' . urlencode($row->alias), $row->catid . ':' . urlencode($row->categoryalias))));
             $helper->_params->set('parsedInModule', 1);
             $dispatcher = JDispatcher::getInstance();
             if ($helper->get('JPlugins', 1)) {
                 //Plugins
                 $results = $dispatcher->trigger('onBeforeDisplay', array(&$row, &$helper->_params, $limitstart));
                 $row->event->BeforeDisplay = trim(implode("\n", $results));
                 $results = $dispatcher->trigger('onAfterDisplay', array(&$row, &$helper->_params, $limitstart));
                 $row->event->AfterDisplay = trim(implode("\n", $results));
                 $results = $dispatcher->trigger('onAfterDisplayTitle', array(&$row, &$helper->_params, $limitstart));
                 $row->event->AfterDisplayTitle = trim(implode("\n", $results));
                 $results = $dispatcher->trigger('onBeforeDisplayContent', array(&$row, &$helper->_params, $limitstart));
                 $row->event->BeforeDisplayContent = trim(implode("\n", $results));
                 $results = $dispatcher->trigger('onAfterDisplayContent', array(&$row, &$helper->_params, $limitstart));
                 $row->event->AfterDisplayContent = trim(implode("\n", $results));
                 $dispatcher->trigger('onPrepareContent', array(&$row, &$helper->_params, $limitstart));
                 $row->introtext = $row->text;
             }
             //Init K2 plugin events
             $row->event->K2BeforeDisplay = '';
             $row->event->K2AfterDisplay = '';
             $row->event->K2AfterDisplayTitle = '';
             $row->event->K2BeforeDisplayContent = '';
             $row->event->K2AfterDisplayContent = '';
             $row->event->K2CommentsCounter = '';
             //K2 plugins
             if ($helper->get('K2Plugins', 1)) {
                 JPluginHelper::importPlugin('k2');
                 $results = $dispatcher->trigger('onK2BeforeDisplay', array(&$row, &$helper->_params, $limitstart));
                 $row->event->K2BeforeDisplay = trim(implode("\n", $results));
                 $results = $dispatcher->trigger('onK2AfterDisplay', array(&$row, &$helper->_params, $limitstart));
                 $row->event->K2AfterDisplay = trim(implode("\n", $results));
                 $results = $dispatcher->trigger('onK2AfterDisplayTitle', array(&$row, &$helper->_params, $limitstart));
                 $row->event->K2AfterDisplayTitle = trim(implode("\n", $results));
                 $results = $dispatcher->trigger('onK2BeforeDisplayContent', array(&$row, &$helper->_params, $limitstart));
                 $row->event->K2BeforeDisplayContent = trim(implode("\n", $results));
                 $results = $dispatcher->trigger('onK2AfterDisplayContent', array(&$row, &$helper->_params, $limitstart));
                 $row->event->K2AfterDisplayContent = trim(implode("\n", $results));
                 $dispatcher->trigger('onK2PrepareContent', array(&$row, &$helper->_params, $limitstart));
                 $row->introtext = $row->text;
             }
             //Clean the plugin tags
             $row->introtext = preg_replace("#{(.*?)}(.*?){/(.*?)}#s", '', $row->introtext);
             $row->introtext = '<p>' . $row->introtext . '</p>';
             //Author
             if ($helper->get('showcreator')) {
                 if (!empty($row->created_by_alias)) {
                     $row->author = $row->created_by_alias;
                     $row->authorGender = NULL;
                 } else {
                     $author = JFactory::getUser($row->created_by);
                     $row->author = $author->name;
                     $query = "SELECT `gender` FROM #__k2_users WHERE userID=" . (int) $author->id;
                     $db->setQuery($query, 0, 1);
                     $row->authorGender = $db->loadResult();
                     //Author Link
                     $row->authorLink = JRoute::_(K2HelperRoute::getUserRoute($row->created_by));
                 }
             }
             $row->created = $row->modified != '' && $row->modified != '0000-00-00 00:00:00' ? $row->modified : $row->created;
             if ($enabletimestamp) {
                 $row->created = $helper->generatTimeStamp($row->created);
             } else {
                 $row->created = JHTML::_('date', $row->created);
             }
             $rows[$j] = $row;
         }
     }
     return $rows;
 }
示例#23
0
 public static function getList($params)
 {
     $app = JFactory::getApplication();
     $lang = JFactory::getLanguage();
     $user = JFactory::getUser();
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     // Source
     $source = $params->get('source', 'categories');
     $exclude = $params->get('exclude', array());
     $articles_k2 = $params->get('articles_k2', array());
     $categories_k2 = $params->get('categories_k2', array());
     // General
     $readmore = $params->get('readmore', '');
     $ordering = $params->get('ordering', 'random');
     $item_counts = $params->get('item_counts', 5);
     $skip_counts = $params->get('skip_counts', 0);
     $limit_intro = $params->get('limit_intro', 200);
     // Display
     $show_date = $params->get('show_date', 1);
     $show_hits = $params->get('show_hits', 1);
     $show_tags = $params->get('show_tags', 1);
     $show_image = $params->get('show_image', 1);
     $show_intro = $params->get('show_intro', 1);
     $show_title = $params->get('show_title', 1);
     $show_author = $params->get('show_author', 1);
     $show_avatar = $params->get('show_avatar', 1);
     $show_rating = $params->get('show_rating', 1);
     $show_profile = $params->get('show_profile', 1);
     $show_category = $params->get('show_category', 1);
     $show_comments = $params->get('show_comments', 1);
     // Date
     $date_type = $params->get('date_type', 'created');
     $date_format = $params->get('date_format', 'd F Y');
     // Image
     $image_width = $params->get('image_width', 200);
     $image_height = $params->get('image_height', 100);
     $image_quality = $params->get('image_quality', 100);
     $image_link = $params->get('image_link', 'none');
     $image_title = $params->get('image_title', 1);
     $image_resize = $params->get('image_resize', 1);
     $image_source = $params->get('image_source', 'auto');
     // 3rd-party
     $avatar_width = $params->get('avatar_width', 60);
     $avatar_height = $params->get('avatar_height', 60);
     $avatar_system = $params->get('avatar_system', 'kunena');
     $profile_system = $params->get('profile_system', 'kunena');
     $comments_system = $params->get('comments_system', 'komento');
     // User access
     $authorised = implode(',', $user->getAuthorisedViewLevels());
     // Clean HTML tags
     $clean_intro = $params->get('clean_intro', 1);
     $allowed_tags = str_replace(' ', '', $params->get('allowed_tags'));
     $allowed_tags = "<" . str_replace(',', '><', $allowed_tags) . ">";
     // Content filtering
     $tags_k2 = $params->get('tags_k2', array());
     $author = $params->get('author', array());
     $featured = $params->get('featured', 0);
     // Featured label/ribbon
     $featured_label = $params->get('featured_label', 0);
     $featured_label_text = $params->get('featured_label_text', 'Featured');
     $featured_label_color = $params->get('featured_label_color', '#e52626');
     // Link
     $title_link = $params->get('title_link', 1);
     $category_link = $params->get('category_link', 1);
     if (JFile::exists(JPATH_SITE . '/components/com_k2/k2.php')) {
         if ($source == 'categories' && $categories_k2) {
             if ($categories_k2[0] != '') {
                 $categories_k2 = count($categories_k2) == 1 ? ' = ' . $categories_k2[0] . '' : 'IN (' . implode(',', $categories_k2) . ')';
                 $query->where('a.catid ' . $categories_k2);
             }
             $exclude ? $query->where('a.id NOT IN (' . $exclude . ')') : '';
         } else {
             if ($source == 'articles' && $articles_k2) {
                 $query->where('a.id IN (' . implode(',', $articles_k2) . ')');
             } else {
                 echo JText::_('MOD_GIANTCONTENT_ERROR_SOURCE');
                 return;
             }
         }
     } else {
         echo JText::_('MOD_GIANTCONTENT_ERROR_TYPE_K2');
         return;
     }
     // Ordering
     switch ($ordering) {
         case 'random':
             $orderBy = 'RAND()';
             break;
         case 'id_asc':
             $orderBy = 'a.id ASC';
             break;
         case 'id_desc':
             $orderBy = 'a.id DESC';
             break;
         case 'title_asc':
             $orderBy = 'a.title ASC';
             break;
         case 'title_desc':
             $orderBy = 'a.title DESC';
             break;
         case 'popular_last':
             $orderBy = 'a.hits ASC';
             break;
         case 'popular_first':
             $orderBy = 'a.hits DESC';
             break;
         case 'created_oldest':
             $orderBy = 'date ASC';
             break;
         case 'created_newest':
             $orderBy = 'date DESC';
             break;
         case 'most_rated':
             $orderBy = 'rating_total DESC, r.rating_count DESC';
             break;
         case 'least_rated':
             $orderBy = 'rating_total ASC, r.rating_count ASC';
             break;
         case 'most_commented':
             $orderBy = 'comments_count DESC, comments_date DESC';
             break;
         case 'latest_commented':
             $orderBy = 'comments_date DESC, date DESC';
             break;
     }
     // Content
     $query->select('a.id, a.title, a.alias, a.introtext, a.fulltext, a.hits');
     $query->from('#__k2_items AS a');
     // Category
     $query->select('a.catid AS category_id, c.name AS category_name, c.alias AS category_alias');
     $query->join('LEFT', '#__k2_categories AS c ON c.id = a.catid');
     // Join user
     $query->select('u.id AS user_id, u.email AS user_email, u.name AS user_name, a.created_by_alias AS user_alias');
     $query->join('LEFT', '#__users AS u ON u.id = a.created_by');
     // Join rating
     $query->select('ROUND(AVG(r.rating_sum / r.rating_count), 2) AS rating_average, r.rating_count');
     $query->join('LEFT', '#__k2_rating AS r ON r.itemID = a.id');
     // Select date
     if ($date_type !== 'created') {
         $query->select('CASE WHEN a.' . $date_type . ' = "0000-00-00 00:00:00" THEN a.created ELSE a.' . $date_type . ' END AS date');
     } else {
         $query->select('a.created AS date');
     }
     // Join avatar for author
     if ($show_avatar) {
         switch ($avatar_system) {
             // K2 avatar integration - http://getk2.org
             case 'k2':
                 if (JFile::exists(JPATH_SITE . '/components/com_k2/k2.php')) {
                     $query->select('ua.image AS avatar_user');
                     $query->join('LEFT', '#__k2_users AS ua ON ua.userID = u.id');
                     $avatar_path = 'media/k2/users/';
                 } else {
                     echo JText::_('MOD_GIANTCONTENT_ERROR_AVATAR_SYSTEM_K2');
                     return;
                 }
                 break;
                 // Kunena avatar integration - http://kunena.org
             // Kunena avatar integration - http://kunena.org
             case 'kunena':
                 if (JFile::exists(JPATH_SITE . '/components/com_kunena/kunena.php')) {
                     $query->select('ua.avatar AS avatar_user');
                     $query->join('LEFT', '#__kunena_users AS ua ON ua.userid = u.id');
                     $avatar_path = 'media/kunena/avatars/';
                 } else {
                     echo JText::_('MOD_GIANTCONTENT_ERROR_AVATAR_SYSTEM_KUNENA');
                     return;
                 }
                 break;
                 // JomSocial avatar integration - http://jomsocial.com
             // JomSocial avatar integration - http://jomsocial.com
             case 'jomsocial':
                 if (JFile::exists(JPATH_SITE . '/components/com_community/community.php')) {
                     $query->select("ua.avatar AS avatar_user");
                     $query->join('LEFT', '#__community_users AS ua ON ua.userid = u.id');
                     $avatar_path = '';
                 } else {
                     echo JText::_('MOD_GIANTCONTENT_ERROR_AVATAR_SYSTEM_JOMSOCIAL');
                     return;
                 }
                 break;
                 // Comprofiler avatar integration - http://joomlapolis.com
             // Comprofiler avatar integration - http://joomlapolis.com
             case 'comprofiler':
                 if (JFile::exists(JPATH_SITE . '/components/com_comprofiler/comprofiler.php')) {
                     $query->select('ua.avatar AS avatar_user');
                     $query->join('LEFT', '#__comprofiler AS ua ON ua.user_id = u.id');
                     $avatar_path = 'images/comprofiler/';
                 } else {
                     echo JText::_('MOD_GIANTCONTENT_ERROR_AVATAR_SYSTEM_COMPROFILER');
                     return;
                 }
                 break;
                 // EasyBlog avatar integration - http://stackideas.com
             // EasyBlog avatar integration - http://stackideas.com
             case 'easyblog':
                 if (JFile::exists(JPATH_SITE . '/components/com_easyblog/easyblog.php')) {
                     $query->select("ua.avatar AS avatar_user");
                     $query->join('LEFT', '#__easyblog_users AS ua ON ua.id = u.id');
                     $avatar_path = 'images/easyblog_avatar/';
                 } else {
                     echo JText::_('MOD_GIANTCONTENT_ERROR_AVATAR_SYSTEM_EASYBLOG');
                     return;
                 }
                 break;
                 // EasySocial avatar integration - http://stackideas.com
             // EasySocial avatar integration - http://stackideas.com
             case 'easysocial':
                 if (JFile::exists(JPATH_SITE . '/components/com_easysocial/easysocial.php')) {
                     $query->select("ua.large AS avatar_user");
                     $query->join('LEFT', '#__social_avatars AS ua ON ua.uid = u.id');
                     $avatar_path = 'media/com_easysocial/avatars/users/';
                 } else {
                     echo JText::_('MOD_GIANTCONTENT_ERROR_AVATAR_SYSTEM_EASYSOCIAL');
                     return;
                 }
                 break;
                 // EasyDiscuss avatar integration - http://stackideas.com
             // EasyDiscuss avatar integration - http://stackideas.com
             case 'easydiscuss':
                 if (JFile::exists(JPATH_SITE . '/components/com_easydiscuss/easydiscuss.php')) {
                     $query->select("ua.avatar AS avatar_user");
                     $query->join('LEFT', '#__discuss_users AS ua ON ua.id = u.id');
                     $avatar_path = 'images/discuss_avatar/';
                 } else {
                     echo JText::_('MOD_GIANTCONTENT_ERROR_AVATAR_SYSTEM_EASYDISCUSS');
                     return;
                 }
                 break;
         }
     }
     // Join comments for content
     if ($show_comments || $ordering == 'most_commented' || $ordering == 'latest_commented') {
         switch ($comments_system) {
             // Default comment system
             case 'default':
                 $query->select('COUNT(cm.id) AS comments_count, MAX(cm.commentDate) AS comments_date');
                 $query->join('LEFT', '#__k2_comments AS cm ON cm.itemID = a.id AND cm.published = 1');
                 $comments_link = '#itemCommentsAnchor';
                 break;
                 // Komento comment integration - http://stackideas.com
             // Komento comment integration - http://stackideas.com
             case 'komento':
                 if (JFile::exists(JPATH_SITE . '/components/com_komento/komento.php')) {
                     $query->select('COUNT(cm.id) AS comments_count, MAX(cm.created) AS comments_date');
                     $query->join('LEFT', '#__komento_comments AS cm ON cm.cid = a.id AND cm.component = "com_k2" AND cm.published = 1');
                     $comments_link = '#section-kmt';
                 } else {
                     echo JText::_('MOD_GIANTCONTENT_ERROR_COMMENTS_SYSTEM_KOMENTO');
                     return;
                 }
                 break;
                 // CComment comment integration - http://compojoom.com
             // CComment comment integration - http://compojoom.com
             case 'ccomment':
                 if (JFile::exists(JPATH_SITE . '/components/com_comment/comment.php')) {
                     $query->select('COUNT(cm.id) AS comments_count, MAX(cm.date) AS comments_date');
                     $query->join('LEFT', '#__comment AS cm ON cm.contentid = a.id AND cm.component = "com_k2" AND cm.published = 1');
                     $comments_link = '#!/ccomment';
                 } else {
                     echo JText::_('MOD_GIANTCONTENT_ERROR_COMMENTS_SYSTEM_CCOMMENT');
                     return;
                 }
                 break;
                 // JComments comment integration - http://joomlatune.com
             // JComments comment integration - http://joomlatune.com
             case 'jcomments':
                 if (JFile::exists(JPATH_SITE . '/components/com_jcomments/jcomments.php')) {
                     $query->select('COUNT(cm.id) AS comments_count, MAX(cm.date) AS comments_date');
                     $query->join('LEFT', '#__jcomments AS cm ON cm.object_id = a.id AND cm.object_group = "com_k2" AND cm.published = 1');
                     $comments_link = '#comments';
                 } else {
                     echo JText::_('MOD_GIANTCONTENT_ERROR_COMMENTS_SYSTEM_JCOMMENTS');
                     return;
                 }
                 break;
                 // JA Comment comment integration - http://joomlart.com
             // JA Comment comment integration - http://joomlart.com
             case 'jacomment':
                 if (JFile::exists(JPATH_SITE . '/components/com_jacomment/jacomment.php')) {
                     $query->select('COUNT(cm.id) AS comments_count, MAX(cm.date) AS comments_date');
                     $query->join('LEFT', '#__jacomment_items AS cm ON cm.contentid = a.id AND cm.option = "com_k2" AND cm.published = 1');
                     $comments_link = '#jac-wrapper';
                 } else {
                     echo JText::_('MOD_GIANTCONTENT_ERROR_COMMENTS_SYSTEM_JACOMMENT');
                     return;
                 }
                 break;
         }
     }
     // Filter tags
     if ($tags_k2) {
         $query->join('INNER', '#__k2_tags_xref AS t ON t.itemID = a.id');
         $query->where('t.tagID IN (' . implode(',', $tags_k2) . ')');
     }
     // Filter author
     if ($author) {
         $query->where('a.created_by IN (' . implode(',', $author) . ')');
     }
     // Filter featured
     if ($featured) {
         $query->where('a.featured = 1');
     }
     // Access or published
     $query->where('a.trash = 0 AND c.trash = 0 AND a.published = 1 AND c.published = 1 AND a.access IN (' . $authorised . ') AND c.access IN (' . $authorised . ') AND a.publish_up <= "' . JFactory::getDate() . '"');
     $query->group('a.id');
     $query->order($orderBy);
     $db->setQuery($query, $skip_counts, $item_counts);
     $items = $db->loadObjectList();
     $lists = array();
     foreach ($items as $i => &$item) {
         $lists[$i] = new stdClass();
         $lists[$i]->id = $item->id;
         $lists[$i]->date = '';
         $lists[$i]->hits = '';
         $lists[$i]->link = '';
         $lists[$i]->tags = '';
         $lists[$i]->intro = '';
         $lists[$i]->image = '';
         $lists[$i]->title = '';
         $lists[$i]->author = '';
         $lists[$i]->avatar = '';
         $lists[$i]->rating = '';
         $lists[$i]->featured = '';
         $lists[$i]->category = '';
         $lists[$i]->comments = '';
         $lists[$i]->readmore = '';
         $lists[$i]->fulltext = $item->fulltext;
         $lists[$i]->introtext = $item->introtext;
         $lists[$i]->category_id = $item->category_id;
         $lists[$i]->category_alias = $item->category_alias;
         // Content link
         $lists[$i]->link = JRoute::_(K2HelperRoute::getItemRoute($item->id . ':' . $item->alias, $item->category_id));
         // Readmore link
         $lists[$i]->readmore = $readmore ? '<a href="' . $lists[$i]->link . '"><span>' . $readmore . '</span></a>' : '';
         // Show content date
         $lists[$i]->date = $show_date ? JHtml::_('date', $item->date, $date_format) : '';
         // Show content hits
         $lists[$i]->hits = $show_hits ? '<span>' . $item->hits . '</span>' : '';
         // Show content image
         if ($show_image) {
             $img = array();
             $image = md5("Image" . $item->id);
             if (JFile::exists(JPATH_SITE . '/media/k2/items/src/' . $image . '.jpg')) {
                 $image = 'media/k2/items/src/' . $image . '.jpg';
             } else {
                 $image = '';
             }
             if ($image_source == 'auto') {
                 if (@$image) {
                     $img_source = 'media';
                 } else {
                     $img_source = 'content';
                 }
             } else {
                 $img_source = $image_source;
             }
             if ($img_source == 'media') {
                 if (@$image) {
                     $img['src'] = $image;
                     $img['alt'] = $item->title;
                     $img['ttl'] = $item->title;
                 }
             } else {
                 $pattern = '/<img[^>]+>/i';
                 preg_match($pattern, $item->introtext, $img_tag);
                 if (!count($img_tag)) {
                     preg_match($pattern, $item->fulltext, $img_tag);
                 }
                 if (count($img_tag)) {
                     preg_match_all('/(src|alt|title)\\s*=\\s*(["\'])(.*?)\\2/i', $img_tag[0], $img_elem);
                     $img_elem = array_combine($img_elem[1], $img_elem[3]);
                     if (@$img_elem['src']) {
                         $img['src'] = trim(@$img_elem['src']);
                         $img['alt'] = trim(@$img_elem['alt']);
                         $img['ttl'] = trim(@$img_elem['title']);
                         $item->introtext = preg_replace($pattern, '', $item->introtext, 1);
                     }
                 }
             }
             if (!@$img['src']) {
                 // Default image
                 $img['src'] = 'modules/mod_giantcontent/assets/images/default.png';
                 $img['alt'] = $item->title;
             }
             if ($img['src']) {
                 $img_src = $img_attr = $img_title = '';
                 // Use timthumb to resize image
                 if ($image_resize) {
                     $img_src = JURI::base(true) . '/modules/mod_giantcontent/assets/libraries/includes/timthumb.php?src=';
                     $img_attr = '&amp;w=' . $image_width . '&amp;h=' . $image_height . '&amp;q=' . $image_quality;
                 }
                 $img_src = $img_src && strncasecmp($img['src'], "http", 4) !== 0 ? $img_src . JURI::base(true) . '/' : $img_src;
                 $img['ttl'] = $image_title ? $item->title : @$img['ttl'];
                 $img_title = $img['ttl'] ? 'title="' . $img['ttl'] . '"' : '';
                 $lists[$i]->image = '<img src="' . @$img_src . @$img['src'] . @$img_attr . '" alt="' . @$img['alt'] . '" ' . @$img_title . ' />';
                 switch ($image_link) {
                     case 'none':
                         $lists[$i]->image = $lists[$i]->image;
                         break;
                     case 'content':
                         $lists[$i]->image = '<a href="' . $lists[$i]->link . '">' . $lists[$i]->image . '</a>';
                         break;
                     case 'shadowbox':
                         $lists[$i]->image = '<a href="' . @$img['src'] . '" rel="shadowbox" ' . @$img_title . '>' . $lists[$i]->image . '</a>';
                         break;
                 }
                 $lists[$i]->image_src = @$img['src'];
                 $lists[$i]->image_alt = @$img['alt'];
                 $lists[$i]->image_title = @$img['ttl'];
             }
         }
         // Show author profile
         if ($show_profile) {
             switch ($profile_system) {
                 // K2 profile integration - http://getk2.org
                 case 'k2':
                     if (JFile::exists(JPATH_SITE . '/components/com_k2/k2.php')) {
                         require_once JPATH_SITE . '/components/com_k2/helpers/route.php';
                         $profile_link = JRoute::_(K2HelperRoute::getUserRoute($item->user_id));
                     } else {
                         echo JText::_('MOD_GIANTCONTENT_ERROR_PROFILE_SYSTEM_K2');
                         return;
                     }
                     break;
                     // Kunena profile integration - http://kunena.org
                 // Kunena profile integration - http://kunena.org
                 case 'kunena':
                     if (JFile::exists(JPATH_SITE . '/components/com_kunena/kunena.php')) {
                         $profile_link = KunenaRoute::_('index.php?option=com_kunena&view=profile&userid=' . $item->user_id);
                     } else {
                         echo JText::_('MOD_GIANTCONTENT_ERROR_PROFILE_SYSTEM_KUNENA');
                         return;
                     }
                     break;
                     // JomSocial profile integration - http://jomsocial.com
                 // JomSocial profile integration - http://jomsocial.com
                 case 'jomsocial':
                     if (JFile::exists(JPATH_SITE . '/components/com_community/community.php')) {
                         require_once JPATH_SITE . '/components/com_community/libraries/core.php';
                         $profile_link = CRoute::_('index.php?option=com_community&view=profile&userid=' . $item->user_id);
                     } else {
                         echo JText::_('MOD_GIANTCONTENT_ERROR_PROFILE_SYSTEM_JOMSOCIAL');
                         return;
                     }
                     break;
                     // Comprofiler profile integration - http://joomlapolis.com
                 // Comprofiler profile integration - http://joomlapolis.com
                 case 'comprofiler':
                     if (JFile::exists(JPATH_SITE . '/components/com_comprofiler/comprofiler.php')) {
                         $profile_link = JRoute::_('index.php?option=com_comprofiler&task=userProfile&user='******'MOD_GIANTCONTENT_ERROR_PROFILE_SYSTEM_COMPROFILER');
                         return;
                     }
                     break;
                     // EasyBlog profile integration - http://stackideas.com
                 // EasyBlog profile integration - http://stackideas.com
                 case 'easyblog':
                     if (JFile::exists(JPATH_SITE . '/components/com_easyblog/easyblog.php')) {
                         require_once JPATH_SITE . '/components/com_easyblog/helpers/router.php';
                         $profile_link = EasyBlogRouter::_('index.php?option=com_easyblog&view=blogger&layout=listings&id=' . $item->user_id);
                     } else {
                         echo JText::_('MOD_GIANTCONTENT_ERROR_PROFILE_SYSTEM_EASYBLOG');
                         return;
                     }
                     break;
                     // EasySocial profile integration - http://stackideas.com
                 // EasySocial profile integration - http://stackideas.com
                 case 'easysocial':
                     if (JFile::exists(JPATH_SITE . '/components/com_easysocial/easysocial.php')) {
                         $profile_link = Foundry::user($item->user_id)->getPermalink();
                     } else {
                         echo JText::_('MOD_GIANTCONTENT_ERROR_PROFILE_SYSTEM_EASYSOCIAL');
                         return;
                     }
                     break;
                     // EasyDiscuss profile integration - http://stackideas.com
                 // EasyDiscuss profile integration - http://stackideas.com
                 case 'easydiscuss':
                     if (JFile::exists(JPATH_SITE . '/components/com_easydiscuss/easydiscuss.php')) {
                         require_once JPATH_SITE . '/components/com_easydiscuss/helpers/router.php';
                         $profile_link = DiscussHelper::getTable('Profile')->load($item->user_id)->getLink();
                     } else {
                         echo JText::_('MOD_GIANTCONTENT_ERROR_PROFILE_SYSTEM_EASYDISCUSS');
                         return;
                     }
                     break;
             }
         }
         // Show content intro
         if ($show_intro) {
             // Clean HTML tags
             if ($clean_intro) {
                 $item->introtext = strip_tags($item->introtext, $allowed_tags);
                 $item->introtext = str_replace('&nbsp;', ' ', $item->introtext);
                 $item->introtext = preg_replace('/\\s{2,}/u', ' ', trim($item->introtext));
             }
             $lists[$i]->intro = $limit_intro ? self::truncateText($item->introtext, $limit_intro) : $item->introtext;
         }
         // Show content title
         if ($show_title) {
             $lists[$i]->title_name = $item->title;
             $lists[$i]->title = $title_link ? '<a href="' . $lists[$i]->link . '">' . $lists[$i]->title_name . '</a>' : $lists[$i]->title_name;
         }
         // Show content category
         if ($show_category) {
             $lists[$i]->category_name = $item->category_name;
             $lists[$i]->category_link = JRoute::_(K2HelperRoute::getCategoryRoute($item->category_id . ':' . $item->category_alias));
             $lists[$i]->category = $category_link ? '<a href="' . $lists[$i]->category_link . '">' . $lists[$i]->category_name . '</a>' : $lists[$i]->category_name;
         }
         // Show content comments
         if ($show_comments) {
             $lists[$i]->comments_count = $item->comments_count;
             $lists[$i]->comments_link = $lists[$i]->link . $comments_link;
             $lists[$i]->comments = '<a href="' . $lists[$i]->comments_link . '">' . $item->comments_count . '</a>';
         }
         // Show content author
         if ($show_author) {
             $lists[$i]->author_name = $item->user_alias ? $item->user_alias : $item->user_name;
             $lists[$i]->author = $show_profile ? '<a href="' . $profile_link . '">' . $lists[$i]->author_name . '</a>' : $lists[$i]->author_name;
         }
         // Show profile avatar
         if ($show_avatar) {
             $avatar_src = 'modules/mod_giantcontent/assets/libraries/includes/timthumb.php?src=' . JURI::base(true) . '/';
             $avatar_attr = '&amp;w=' . $avatar_width . '&amp;h=' . $avatar_height;
             $avatar_default = '<img src="' . $avatar_src . '/modules/mod_giantcontent/assets/images/avatar.png' . $avatar_attr . '"  alt="' . $item->user_name . '" />';
             $lists[$i]->avatar_user = $item->avatar_user;
             if ($avatar_system == 'easysocial') {
                 $avatar_img = $avatar_path . $item->user_id . '/' . $item->avatar_user;
             } else {
                 $avatar_img = $avatar_path . $item->avatar_user;
             }
             if (JFile::exists($avatar_img)) {
                 $lists[$i]->avatar = '<img src="' . $avatar_src . $avatar_img . $avatar_attr . '" alt="' . $item->user_name . '" />';
                 $lists[$i]->avatar = $show_profile ? '<a href="' . $profile_link . '">' . $lists[$i]->avatar . '</a>' : $lists[$i]->avatar;
             } else {
                 $lists[$i]->avatar = $show_profile ? '<a href="' . $profile_link . '">' . $avatar_default . '</a>' : $avatar_default;
             }
         }
         // Show content rating
         if ($show_rating) {
             if ($item->rating_count > 0) {
                 $lists[$i]->rating_count = $item->rating_count;
                 $lists[$i]->rating_average = $item->rating_average;
             } else {
                 $lists[$i]->rating_count = 0;
                 $lists[$i]->rating_average = 0.0;
             }
             $rating_current = $item->rating_average * 20;
             $lists[$i]->rating = '<span class="gc-rating-list"><span style="width:' . $rating_current . '%;" class="gc-rating-current"></span></span>';
         }
         // Show content tags
         if ($show_tags) {
             $db = JFactory::getDbo();
             $query = $db->getQuery(true);
             $query->select('t.id, t.name AS title');
             $query->from('#__k2_tags AS t');
             $query->join('LEFT', '#__k2_tags_xref AS tm ON tm.tagID = t.id');
             $query->where('t.published = 1 AND tm.itemID = ' . $item->id);
             $db->setQuery($query);
             $tags = $db->loadObjectList();
             $list_tags = '';
             if ($tags) {
                 foreach ($tags as $tag) {
                     $link_tags = JRoute::_(K2HelperRoute::getTagRoute($tag->title));
                     $list_tags .= '<a class="gc-tag" href="' . $link_tags . '">' . $tag->title . '</a>';
                 }
             }
             $lists[$i]->tags = $list_tags;
         }
         // Show featured label
         if ($featured_label) {
             $db = JFactory::getDbo();
             $db->setQuery('SELECT * FROM #__k2_items WHERE id = ' . $item->id . ' AND featured = 1');
             $featured = $db->loadResult();
             if ($featured) {
                 $lists[$i]->featured = '<span class="gc-featured" style="background: ' . $featured_label_color . '">' . $featured_label_text . '</span>';
             }
         }
     }
     return $lists;
 }
示例#24
0
							<?php 
    echo $row->commentEmail;
    ?>
						</td>
						<td>
							<a target="_blank" href="<?php 
    echo JFilterOutput::cleanText($row->commentURL);
    ?>
"><?php 
    echo $row->commentURL;
    ?>
</a>
						</td>
						<td>
							<a class="modal" rel="{handler: 'iframe', size: {x: 1000, y: 600}}"	href="<?php 
    echo JURI::root() . K2HelperRoute::getItemRoute($row->itemID . ':' . urlencode($row->itemAlias), $row->catid . ':' . urlencode($row->catAlias));
    ?>
"><?php 
    echo $row->title;
    ?>
</a>
						</td>
						<td>
							<?php 
    echo $row->catName;
    ?>
						</td>
						<td>
							<?php 
    $user =& JFactory::getUser($row->created_by);
    echo $user->name;
示例#25
0
文件: item.php 项目: jhener79/vlakc
    function getDataK2($id)
    {
        //
        jimport('joomla.filesystem.file');
        require_once JPATH_SITE . DS . 'components' . DS . 'com_k2' . DS . 'helpers' . DS . 'route.php';
        // prepare an array
        $results = array();
        // generate the query
        $database = JFactory::getDBO();
        // SQL query for slides
        $query = '
		SELECT 
			`c`.`id` AS `id`,
			`c`.`catid` AS `cid`,
			`c`.`created_by` AS `created_by`,
			`c`.`title` AS `title`,
			`c`.`hits` AS `hits`,
			`c`.`published` AS `published`,
			`c`.`created` AS `created`,
			`c`.`introtext` AS `introtext`,
			`c`.`fulltext` AS `fulltext`,
			`c`.alias AS `alias`,
			`cats`.alias AS `cat_alias`
		FROM 
			#__k2_items AS `c` 
			LEFT JOIN 
					#__k2_categories AS `cats`
					ON cats.id = `c`.`id` 
		WHERE 
			`c`.`id` IN (' . $id . ')
		;';
        // running query
        $database->setQuery($query);
        // if results exists
        if ($datas = $database->loadObjectList()) {
            // parsing data
            foreach ($datas as $item) {
                if (JFile::exists(JPATH_SITE . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'k2' . DIRECTORY_SEPARATOR . 'items' . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . md5("Image" . $item->id) . '_XL.jpg')) {
                    $item->image_large = JURI::base() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_XL.jpg';
                } else {
                    $item->image_large = '';
                }
                // array with prepared image
                if ($item->published == 1) {
                    $cat1 = bdthemes_shortcodesHelperItem::getk2CatTitle($item->cid);
                    $cat = $cat1[$item->cid]['title'];
                    $results[$item->id] = array('id' => $item->id, 'cid' => $item->cid, 'created_by' => $item->created_by, 'category' => $cat, 'hits' => $item->hits, 'image' => $item->image_large, 'title' => $item->title, 'introtext' => $item->introtext, 'fulltext' => $item->fulltext, 'created' => $item->created, 'link' => JRoute::_(K2HelperRoute::getItemRoute($item->id . ':' . urlencode($item->alias), $item->cid . ':' . urlencode($item->cat_alias))));
                } else {
                    return false;
                }
            }
        }
        // return the results
        return $results;
    }
示例#26
0
 public function getContentPermalink()
 {
     $link = '';
     if (JFactory::getApplication()->isSite()) {
         $link = K2HelperRoute::getItemRoute($this->_item->id . ':' . urlencode($this->_item->alias), $this->_item->catid . ':' . urlencode($this->_item->category_alias));
         $link = urldecode(JRoute::_($link));
     } else {
         $link = 'index.php?option=com_k2&view=item&id=' . $this->_item->id . $this->_getItemId();
     }
     $link = $this->prepareLink($link);
     return $link;
 }
示例#27
0
 public static function getList(&$params)
 {
     jimport('joomla.filesystem.file');
     $mainframe = JFactory::getApplication();
     $limit = $params->get('itemCount', 5);
     $cid = $params->get('category_id', NULL);
     $ordering = $params->get('itemsOrdering', '');
     $componentParams = JComponentHelper::getParams('com_k2');
     $limitstart = JRequest::getInt('limitstart');
     $user = JFactory::getUser();
     $aid = $user->get('aid');
     $db = JFactory::getDBO();
     $jnow = JFactory::getDate();
     $now = K2_JVERSION == '15' ? $jnow->toMySQL() : $jnow->toSql();
     $nullDate = $db->getNullDate();
     if ($params->get('source') == 'specific') {
         $value = $params->get('items');
         $current = array();
         if (is_string($value) && !empty($value)) {
             $current[] = $value;
         }
         if (is_array($value)) {
             $current = $value;
         }
         $items = array();
         foreach ($current as $id) {
             $query = "SELECT i.*, c.name AS categoryname,c.id AS categoryid, c.alias AS categoryalias, c.params AS categoryparams \n\t\t\t\tFROM #__k2_items as i \n\t\t\t\tLEFT JOIN #__k2_categories c ON c.id = i.catid \n\t\t\t\tWHERE i.published = 1 ";
             if (K2_JVERSION != '15') {
                 $query .= " AND i.access IN(" . implode(',', $user->getAuthorisedViewLevels()) . ") ";
             } else {
                 $query .= " AND i.access<={$aid} ";
             }
             $query .= " AND i.trash = 0 AND c.published = 1 ";
             if (K2_JVERSION != '15') {
                 $query .= " AND c.access IN(" . implode(',', $user->getAuthorisedViewLevels()) . ") ";
             } else {
                 $query .= " AND c.access<={$aid} ";
             }
             $query .= " AND c.trash = 0 \n\t\t\t\tAND ( i.publish_up = " . $db->Quote($nullDate) . " OR i.publish_up <= " . $db->Quote($now) . " ) \n\t\t\t\tAND ( i.publish_down = " . $db->Quote($nullDate) . " OR i.publish_down >= " . $db->Quote($now) . " ) \n\t\t\t\tAND i.id={$id}";
             if (K2_JVERSION != '15') {
                 if ($mainframe->getLanguageFilter()) {
                     $languageTag = JFactory::getLanguage()->getTag();
                     $query .= " AND c.language IN (" . $db->Quote($languageTag) . ", " . $db->Quote('*') . ") AND i.language IN (" . $db->Quote($languageTag) . ", " . $db->Quote('*') . ")";
                 }
             }
             $db->setQuery($query);
             $item = $db->loadObject();
             if ($item) {
                 $items[] = $item;
             }
         }
     } else {
         $query = "SELECT i.*, CASE WHEN i.modified = 0 THEN i.created ELSE i.modified END as lastChanged, c.name AS categoryname,c.id AS categoryid, c.alias AS categoryalias, c.params AS categoryparams";
         if ($ordering == 'best') {
             $query .= ", (r.rating_sum/r.rating_count) AS rating";
         }
         if ($ordering == 'comments') {
             $query .= ", COUNT(comments.id) AS numOfComments";
         }
         $query .= " FROM #__k2_items as i RIGHT JOIN #__k2_categories c ON c.id = i.catid";
         if ($ordering == 'best') {
             $query .= " LEFT JOIN #__k2_rating r ON r.itemID = i.id";
         }
         if ($ordering == 'comments') {
             $query .= " LEFT JOIN #__k2_comments comments ON comments.itemID = i.id";
         }
         if (K2_JVERSION != '15') {
             $query .= " WHERE i.published = 1 AND i.access IN(" . implode(',', $user->getAuthorisedViewLevels()) . ") AND i.trash = 0 AND c.published = 1 AND c.access IN(" . implode(',', $user->getAuthorisedViewLevels()) . ")  AND c.trash = 0";
         } else {
             $query .= " WHERE i.published = 1 AND i.access <= {$aid} AND i.trash = 0 AND c.published = 1 AND c.access <= {$aid} AND c.trash = 0";
         }
         $query .= " AND ( i.publish_up = " . $db->Quote($nullDate) . " OR i.publish_up <= " . $db->Quote($now) . " )";
         $query .= " AND ( i.publish_down = " . $db->Quote($nullDate) . " OR i.publish_down >= " . $db->Quote($now) . " )";
         if ($params->get('catfilter')) {
             if (!is_null($cid)) {
                 if (is_array($cid)) {
                     if ($params->get('getChildren')) {
                         $itemListModel = K2Model::getInstance('Itemlist', 'K2Model');
                         $categories = $itemListModel->getCategoryTree($cid);
                         $sql = @implode(',', $categories);
                         $query .= " AND i.catid IN ({$sql})";
                     } else {
                         JArrayHelper::toInteger($cid);
                         $query .= " AND i.catid IN(" . implode(',', $cid) . ")";
                     }
                 } else {
                     if ($params->get('getChildren')) {
                         $itemListModel = K2Model::getInstance('Itemlist', 'K2Model');
                         $categories = $itemListModel->getCategoryTree($cid);
                         $sql = @implode(',', $categories);
                         $query .= " AND i.catid IN ({$sql})";
                     } else {
                         $query .= " AND i.catid=" . (int) $cid;
                     }
                 }
             }
         }
         if ($params->get('FeaturedItems') == '0') {
             $query .= " AND i.featured != 1";
         }
         if ($params->get('FeaturedItems') == '2') {
             $query .= " AND i.featured = 1";
         }
         if ($params->get('videosOnly')) {
             $query .= " AND (i.video IS NOT NULL AND i.video!='')";
         }
         if ($ordering == 'comments') {
             $query .= " AND comments.published = 1";
         }
         if (K2_JVERSION != '15') {
             if ($mainframe->getLanguageFilter()) {
                 $languageTag = JFactory::getLanguage()->getTag();
                 $query .= " AND c.language IN (" . $db->Quote($languageTag) . ", " . $db->Quote('*') . ") AND i.language IN (" . $db->Quote($languageTag) . ", " . $db->Quote('*') . ")";
             }
         }
         switch ($ordering) {
             case 'date':
                 $orderby = 'i.created ASC';
                 break;
             case 'rdate':
                 $orderby = 'i.created DESC';
                 break;
             case 'alpha':
                 $orderby = 'i.title';
                 break;
             case 'ralpha':
                 $orderby = 'i.title DESC';
                 break;
             case 'order':
                 if ($params->get('FeaturedItems') == '2') {
                     $orderby = 'i.featured_ordering';
                 } else {
                     $orderby = 'i.ordering';
                 }
                 break;
             case 'rorder':
                 if ($params->get('FeaturedItems') == '2') {
                     $orderby = 'i.featured_ordering DESC';
                 } else {
                     $orderby = 'i.ordering DESC';
                 }
                 break;
             case 'hits':
                 if ($params->get('popularityRange')) {
                     $datenow = JFactory::getDate();
                     $date = K2_JVERSION == '15' ? $datenow->toMySQL() : $datenow->toSql();
                     $query .= " AND i.created > DATE_SUB('{$date}',INTERVAL " . $params->get('popularityRange') . " DAY) ";
                 }
                 $orderby = 'i.hits DESC';
                 break;
             case 'rand':
                 $orderby = 'RAND()';
                 break;
             case 'best':
                 $orderby = 'rating DESC';
                 break;
             case 'comments':
                 if ($params->get('popularityRange')) {
                     $datenow = JFactory::getDate();
                     $date = K2_JVERSION == '15' ? $datenow->toMySQL() : $datenow->toSql();
                     $query .= " AND i.created > DATE_SUB('{$date}',INTERVAL " . $params->get('popularityRange') . " DAY) ";
                 }
                 $query .= " GROUP BY i.id ";
                 $orderby = 'numOfComments DESC';
                 break;
             case 'modified':
                 $orderby = 'lastChanged DESC';
                 break;
             case 'publishUp':
                 $orderby = 'i.publish_up DESC';
                 break;
             default:
                 $orderby = 'i.id DESC';
                 break;
         }
         $query .= " ORDER BY " . $orderby;
         // $sql = str_replace('#__','jos_',$query);
         // echo $sql;die;
         //var_dump($limit);
         $db->setQuery($query, 0, $limit);
         $items = $db->loadObjectList();
     }
     $model = K2Model::getInstance('Item', 'K2Model');
     $show_introtext = $params->get('item_desc_display', 0);
     $introtext_limit = $params->get('item_desc_max_characs', 100);
     $show_title = $params->get('item_title_display', 1);
     $title_limit = $params->get('item_title_max_characs', 20);
     $item_title_ending_char = $params->get('item_title_ending_char', '');
     $item_desc_ending_char = $params->get('item_desc_ending_char', '');
     if (count($items)) {
         foreach ($items as $item) {
             //Clean title
             $item->title = JFilterOutput::ampReplace($item->title);
             $item->displaytitle = $show_title ? self::truncate($item->title, $title_limit, $item_title_ending_char) : '';
             //Read more link
             $item->link = urldecode(JRoute::_(K2HelperRoute::getItemRoute($item->id . ':' . urlencode($item->alias), $item->catid . ':' . urlencode($item->categoryalias))));
             //Tags
             $item->tags = '';
             if ($params->get('item_tags_display')) {
                 $tags = $model->getItemTags($item->id);
                 for ($i = 0; $i < sizeof($tags); $i++) {
                     $tags[$i]->link = JRoute::_(K2HelperRoute::getTagRoute($tags[$i]->name));
                 }
                 $item->tags = $tags;
             } else {
                 $item->tags = '';
             }
             // Restore the intotext variable after plugins execution
             self::getK2Images($item, $params);
             //Clean the plugin tags
             $item->introtext = preg_replace("#{(.*?)}(.*?){/(.*?)}#s", '', $item->introtext);
             if ($item->fulltext != '') {
                 $item->fulltext = preg_replace("#{(.*?)}(.*?){/(.*?)}#s", '', $item->fulltext);
                 $item->introtext = self::_cleanText($item->introtext . $item->fulltext);
             } else {
                 $item->introtext = self::_cleanText($item->introtext);
             }
             $item->displayIntrotext = $show_introtext ? self::truncate($item->introtext, $introtext_limit, $item_desc_ending_char) : '';
             $rows[] = $item;
         }
         return $rows;
     }
 }
示例#28
0
文件: k2.php 项目: Tommar/vino
 /**
  * get the list of k2 items
  *
  * @param JParameter $params;
  * @return Array
  */
 public function getList()
 {
     // check k2 existing
     if (!is_file(JPATH_SITE . "/components/com_k2/k2.php")) {
         return array();
     }
     $params =& $this->_params;
     // Init vars
     $show_title = $params->get('show_title', 1);
     $titleMaxChars = $params->get('title_max_chars', '100');
     $limit_title_by = $params->get('limit_title_by', 'char');
     $replacer = $params->get('replacer', '...');
     $isStrips = $params->get("auto_strip_tags", 1);
     $stringtags = '';
     if ($isStrips) {
         $allow_tags = $params->get("allow_tags", '');
         $stringtags = '';
         if (!is_array($allow_tags)) {
             $allow_tags = explode(',', $allow_tags);
         }
         foreach ($allow_tags as $tag) {
             $stringtags .= '<' . $tag . '>';
         }
     }
     if (!$params->get('default_thumb', 1)) {
         $this->_defaultThumb = '';
     }
     /* intro */
     $show_intro = $params->get('show_intro', 1);
     $maxDesciption = $params->get('description_max_chars', 100);
     $limitDescriptionBy = $params->get('limit_description_by', 'char');
     $ordering = $params->get('ordering', 'created-desc');
     $limit = $params->get('limit_items', 12);
     // Set ordering
     $ordering = explode('-', $ordering);
     if (trim($ordering[0]) == 'rand') {
         $ordering = ' RAND() ';
     } else {
         $ordering = $ordering[0] . ' ' . $ordering[1];
     }
     $user = JFactory::getUser();
     $isThumb = $params->get('image_thumb', 1);
     $thumbWidth = (int) $params->get('thumbnail_width', 280);
     $thumbHeight = (int) $params->get('thumbnail_height', 150);
     $quality = (int) $params->get('image_quality', 80);
     $db = JFactory::getDBO();
     $date = JFactory::getDate();
     $now = $date->toSQL();
     $dateFormat = $params->get('date_format', 'DATE_FORMAT_LC3');
     $show_author = $params->get('show_author', 0);
     // main query
     $query = "SELECT  a.*, c.name as category_title,\n\t\t\t\t\t\tc.id as categoryid, c.alias as categoryalias, c.params as categoryparams, c.image as category_image" . " FROM #__k2_items as a" . " LEFT JOIN #__k2_categories c ON c.id = a.catid";
     $query .= " WHERE a.published = 1" . " AND a.access IN(" . implode(',', $user->getAuthorisedViewLevels()) . ")" . " AND a.trash = 0" . " AND c.published = 1" . " AND c.access IN(" . implode(',', $user->getAuthorisedViewLevels()) . ")" . " AND c.trash = 0 ";
     // filter by user
     $userId = $user->get('id');
     switch ($params->get('user_id')) {
         case 'by_me':
             $query .= 'AND a.created_by = ' . $userId;
             break;
         case 'not_me':
             $query .= 'AND a.created_by != ' . $userId;
             break;
         case 0:
             break;
         default:
             $query .= 'AND a.created_by = ' . $userId;
             break;
     }
     // filter by featured params
     if ($params->get('show_featured', '1') == 2) {
         $query .= " AND a.featured != 1";
     } elseif ($params->get('show_featured', '1') == 3) {
         $query .= " AND a.featured = 1";
     }
     // valid publish date
     $jnow = JFactory::getDate();
     $now = $jnow->toSql();
     $nullDate = $db->getNullDate();
     $query .= " AND ( a.publish_up = " . $db->Quote($nullDate) . " OR a.publish_up <= " . $db->Quote($now) . " )";
     $query .= " AND ( a.publish_down = " . $db->Quote($nullDate) . " OR a.publish_down >= " . $db->Quote($now) . " )";
     //filter by language
     $languageTag = JFactory::getLanguage()->getTag();
     $query .= " AND a.language IN (" . $db->quote($languageTag) . "," . $db->quote('*') . ") AND c.language IN (" . $db->quote($languageTag) . "," . $db->quote('*') . ")";
     //Get data
     $data = array();
     $source = trim($this->_params->get('source', 'k2_category'));
     $catids = self::getCategoryIds();
     if ($source == 'k2_category' && !empty($catids) && $this->_params->get('limit_items_for_each')) {
         $db->setQuery('SELECT id from #__k2_categories where id in (' . implode($catids, ',') . ') order by ordering');
         $catids = $db->loadColumn();
         foreach ($catids as $catid) {
             $condition = ' AND  a.catid = ' . $catid . ' ';
             $db->setQuery($query . $condition . ' ORDER BY ' . $ordering . ($limit ? ' LIMIT ' . $limit : ''));
             $data = array_merge($data, $db->loadObjectlist());
         }
     } else {
         $condition = $this->buildConditionQuery($source, $catids);
         $db->setQuery($query . $condition . ' ORDER BY ' . $ordering . ($limit ? ' LIMIT ' . $limit : ''));
         $data = array_merge($data, $db->loadObjectlist());
     }
     // Rebuild data
     foreach ($data as $key => &$item) {
         // authorise
         if (in_array($item->access, $user->getAuthorisedViewLevels())) {
             $item->link = JRoute::_(K2HelperRoute::getItemRoute($item->id . ':' . $item->alias, $item->catid . ':' . $item->categoryalias));
         } else {
             $item->link = JRoute::_('index.php?option=com_users&view=login');
         }
         // format date
         $item->date = JHtml::_('date', $item->created, JText::_($dateFormat));
         //cut title
         if ($limit_title_by == 'word' && $titleMaxChars > 0) {
             $item->title_cut = self::substrword($item->title, $titleMaxChars, $replacer, $isStrips);
         } elseif ($limit_title_by == 'char' && $titleMaxChars > 0) {
             $item->title_cut = self::substring($item->title, $titleMaxChars, $replacer, $isStrips);
         }
         // escape html characters
         $item->title = htmlspecialchars($item->title);
         // import joomla content prepare plugin
         if ($params->get('content_plugin')) {
             $item->introtext = JHtml::_('content.prepare', $item->introtext);
         }
         // cut introtext
         if ($limitDescriptionBy == 'word') {
             $item->description = self::substrword($item->introtext, $maxDesciption, $replacer, $isStrips, $stringtags);
         } else {
             $item->description = self::substring($item->introtext, $maxDesciption, $replacer, $isStrips, $stringtags);
         }
         $item->categoryLink = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($item->catid . ':' . urlencode($item->categoryalias))));
         // get author name & link
         if ($show_author) {
             if (!empty($item->created_by_alias)) {
                 $item->author = $item->created_by_alias;
             } else {
                 $author = JFactory::getUser($item->created_by);
                 $item->author = $author->name;
             }
             $item->authorLink = JRoute::_(K2HelperRoute::getUserRoute($item->created_by));
         }
         // make thumbnail
         $item->thumbnail = '';
         $item->mainImage = '';
         if ($params->get('show_image')) {
             $item = $this->generateImages($item, $isThumb, $quality);
         }
         //get extrafields
         $showExtrafields = $params->get('show_extrafields', array());
         if (count($showExtrafields) && $item->extra_fields) {
             $item->extra_fields = json_decode($item->extra_fields);
             if (count($item->extra_fields)) {
                 $exIds = array();
                 foreach ($item->extra_fields as $ex) {
                     $exIds[] = $ex->id;
                 }
                 $exIds = implode(',', $exIds);
                 $query = 'SELECT name FROM #__k2_extra_fields WHERE id IN (' . $exIds . ') ORDER BY ordering';
                 $db->setQuery($query);
                 $rs = $db->loadObjectlist();
                 foreach ($item->extra_fields as $key => &$ex) {
                     $ex->name = $rs[$key]->name;
                 }
             }
         }
     }
     return $data;
 }
示例#29
0
文件: view.raw.php 项目: emavro/k2
 function display($tpl = null)
 {
     $mainframe = JFactory::getApplication();
     $user = JFactory::getUser();
     $document = JFactory::getDocument();
     $params = K2HelperUtilities::getParams('com_k2');
     $limitstart = JRequest::getInt('limitstart', 0);
     $view = JRequest::getWord('view');
     $task = JRequest::getWord('task');
     $db = JFactory::getDBO();
     $jnow = JFactory::getDate();
     $now = K2_JVERSION == '15' ? $jnow->toMySQL() : $jnow->toSql();
     $nullDate = $db->getNullDate();
     $this->setLayout('item');
     // Add link
     if (K2HelperPermissions::canAddItem()) {
         $addLink = JRoute::_('index.php?option=com_k2&view=item&task=add&tmpl=component');
     }
     $this->assignRef('addLink', $addLink);
     // Get item
     $model = $this->getModel();
     $item = $model->getData();
     $item->event = new stdClass();
     // Does the item exists?
     if (!is_object($item) || !$item->id) {
         JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
     }
     // Prepare item
     $item = $model->prepareItem($item, $view, $task);
     // Plugins
     $item = $model->execPlugins($item, $view, $task);
     // User K2 plugins
     $item->event->K2UserDisplay = '';
     if (isset($item->author) && is_object($item->author->profile) && isset($item->author->profile->id)) {
         $dispatcher = JDispatcher::getInstance();
         JPluginHelper::importPlugin('k2');
         $results = $dispatcher->trigger('onK2UserDisplay', array(&$item->author->profile, &$params, $limitstart));
         $item->event->K2UserDisplay = trim(implode("\n", $results));
         $item->author->profile->url = htmlspecialchars($item->author->profile->url, ENT_QUOTES, 'UTF-8');
     }
     // Access check
     if ($this->getLayout() == 'form') {
         JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
     }
     if (K2_JVERSION != '15') {
         if (!in_array($item->access, $user->getAuthorisedViewLevels()) || !in_array($item->category->access, $user->getAuthorisedViewLevels())) {
             if ($user->guest) {
                 $uri = JFactory::getURI();
                 $url = 'index.php?option=com_users&view=login&return=' . base64_encode($uri->toString());
                 $mainframe->enqueueMessage(JText::_('K2_YOU_NEED_TO_LOGIN_FIRST'), 'notice');
                 $mainframe->redirect(JRoute::_($url, false));
             } else {
                 JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
                 return;
             }
         }
     } else {
         if ($item->access > $user->get('aid', 0) || $item->category->access > $user->get('aid', 0)) {
             if ($user->guest) {
                 $uri = JFactory::getURI();
                 $url = 'index.php?option=com_user&view=login&return=' . base64_encode($uri->toString());
                 $mainframe->enqueueMessage(JText::_('K2_YOU_NEED_TO_LOGIN_FIRST'), 'notice');
                 $mainframe->redirect(JRoute::_($url, false));
             } else {
                 JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
                 return;
             }
         }
     }
     // Published check
     if (!$item->published || $item->trash) {
         JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
     }
     if ($item->publish_up != $nullDate && $item->publish_up > $now) {
         JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
     }
     if ($item->publish_down != $nullDate && $item->publish_down < $now) {
         JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
     }
     if (!$item->category->published || $item->category->trash) {
         JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
     }
     // Increase hits counter
     $model->hit($item->id);
     // Set default image
     K2HelperUtilities::setDefaultImage($item, $view);
     // Comments
     $item->event->K2CommentsCounter = '';
     $item->event->K2CommentsBlock = '';
     if ($item->params->get('itemComments')) {
         // Trigger comments events
         $dispatcher = JDispatcher::getInstance();
         JPluginHelper::importPlugin('k2');
         $results = $dispatcher->trigger('onK2CommentsCounter', array(&$item, &$params, $limitstart));
         $item->event->K2CommentsCounter = trim(implode("\n", $results));
         $results = $dispatcher->trigger('onK2CommentsBlock', array(&$item, &$params, $limitstart));
         $item->event->K2CommentsBlock = trim(implode("\n", $results));
         // Load K2 native comments system only if there are no plugins overriding it
         if (empty($item->event->K2CommentsCounter) && empty($item->event->K2CommentsBlock)) {
             $limit = $params->get('commentsLimit');
             $comments = $model->getItemComments($item->id, $limitstart, $limit);
             $pattern = "@\\b(https?://)?(([0-9a-zA-Z_!~*'().&=+\$%-]+:)?[0-9a-zA-Z_!~*'().&=+\$%-]+\\@)?(([0-9]{1,3}\\.){3}[0-9]{1,3}|([0-9a-zA-Z_!~*'()-]+\\.)*([0-9a-zA-Z][0-9a-zA-Z-]{0,61})?[0-9a-zA-Z]\\.[a-zA-Z]{2,6})(:[0-9]{1,4})?((/[0-9a-zA-Z_!~*'().;?:\\@&=+\$,%#-]+)*/?)@";
             for ($i = 0; $i < sizeof($comments); $i++) {
                 $comments[$i]->commentText = nl2br($comments[$i]->commentText);
                 $comments[$i]->commentText = preg_replace($pattern, '<a target="_blank" rel="nofollow" href="\\0">\\0</a>', $comments[$i]->commentText);
                 $comments[$i]->userImage = K2HelperUtilities::getAvatar($comments[$i]->userID, $comments[$i]->commentEmail, $params->get('commenterImgWidth'));
                 if ($comments[$i]->userID > 0) {
                     $comments[$i]->userLink = K2HelperRoute::getUserRoute($comments[$i]->userID);
                 } else {
                     $comments[$i]->userLink = $comments[$i]->commentURL;
                 }
             }
             $item->comments = $comments;
             jimport('joomla.html.pagination');
             $total = $item->numOfComments;
             $pagination = new JPagination($total, $limitstart, $limit);
         }
     }
     // Author's latest items
     if ($item->params->get('itemAuthorLatest') && $item->created_by_alias == '') {
         $model = $this->getModel('itemlist');
         $authorLatestItems = $model->getAuthorLatest($item->id, $item->params->get('itemAuthorLatestLimit'), $item->created_by);
         if (count($authorLatestItems)) {
             for ($i = 0; $i < sizeof($authorLatestItems); $i++) {
                 $authorLatestItems[$i]->link = urldecode(JRoute::_(K2HelperRoute::getItemRoute($authorLatestItems[$i]->id . ':' . urlencode($authorLatestItems[$i]->alias), $authorLatestItems[$i]->catid . ':' . urlencode($authorLatestItems[$i]->categoryalias))));
             }
             $this->assignRef('authorLatestItems', $authorLatestItems);
         }
     }
     // Related items
     if ($item->params->get('itemRelated') && isset($item->tags) && count($item->tags)) {
         $model = $this->getModel('itemlist');
         $relatedItems = $model->getRelatedItems($item->id, $item->tags, $item->params);
         if (count($relatedItems)) {
             for ($i = 0; $i < sizeof($relatedItems); $i++) {
                 $relatedItems[$i]->link = urldecode(JRoute::_(K2HelperRoute::getItemRoute($relatedItems[$i]->id . ':' . urlencode($relatedItems[$i]->alias), $relatedItems[$i]->catid . ':' . urlencode($relatedItems[$i]->categoryalias))));
             }
             $this->assignRef('relatedItems', $relatedItems);
         }
     }
     // Navigation (previous and next item)
     if ($item->params->get('itemNavigation')) {
         $model = $this->getModel('item');
         $nextItem = $model->getNextItem($item->id, $item->catid, $item->ordering);
         if (!is_null($nextItem)) {
             $item->nextLink = urldecode(JRoute::_(K2HelperRoute::getItemRoute($nextItem->id . ':' . urlencode($nextItem->alias), $nextItem->catid . ':' . urlencode($item->category->alias))));
             $item->nextTitle = $nextItem->title;
         }
         $previousItem = $model->getPreviousItem($item->id, $item->catid, $item->ordering);
         if (!is_null($previousItem)) {
             $item->previousLink = urldecode(JRoute::_(K2HelperRoute::getItemRoute($previousItem->id . ':' . urlencode($previousItem->alias), $previousItem->catid . ':' . urlencode($item->category->alias))));
             $item->previousTitle = $previousItem->title;
         }
     }
     // Absolute URL
     $uri = JURI::getInstance();
     $item->absoluteURL = $uri->toString();
     // Email link
     if (K2_JVERSION != '15') {
         require_once JPATH_SITE . '/components/com_mailto/helpers/mailto.php';
         $template = $mainframe->getTemplate();
         $item->emailLink = JRoute::_('index.php?option=com_mailto&tmpl=component&template=' . $template . '&link=' . MailToHelper::addLink($item->absoluteURL));
     } else {
         require_once JPATH_SITE . DS . 'components' . DS . 'com_mailto' . DS . 'helpers' . DS . 'mailto.php';
         $item->emailLink = JRoute::_('index.php?option=com_mailto&tmpl=component&link=' . MailToHelper::addLink($item->absoluteURL));
     }
     // Twitter link (legacy code)
     if ($params->get('twitterUsername')) {
         $item->twitterURL = 'http://twitter.com/intent/tweet?text=' . urlencode($item->title) . '&amp;url=' . urlencode($item->absoluteURL) . '&amp;via=' . $params->get('twitterUsername');
     } else {
         $item->twitterURL = 'http://twitter.com/intent/tweet?text=' . urlencode($item->title) . '&amp;url=' . urlencode($item->absoluteURL);
     }
     // Social link
     $item->socialLink = urlencode($item->absoluteURL);
     // Look for template files in component folders
     $this->_addPath('template', JPATH_COMPONENT . DS . 'templates');
     $this->_addPath('template', JPATH_COMPONENT . DS . 'templates' . DS . 'default');
     // Look for overrides in template folder (K2 template structure)
     $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'templates');
     $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'templates' . DS . 'default');
     // Look for overrides in template folder (Joomla! template structure)
     $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'default');
     $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2');
     // Look for specific K2 theme files
     if ($item->params->get('theme')) {
         $this->_addPath('template', JPATH_COMPONENT . DS . 'templates' . DS . $item->params->get('theme'));
         $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'templates' . DS . $item->params->get('theme'));
         $this->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . $item->params->get('theme'));
     }
     // Assign data
     $this->assignRef('item', $item);
     $this->assignRef('user', $user);
     $this->assignRef('params', $item->params);
     $this->assignRef('pagination', $pagination);
     parent::display($tpl);
 }
示例#30
0
文件: model.php 项目: paisit/pyzid
    function getDataK2($ids)
    {
        //
        require_once JPATH_SITE . DS . 'components' . DS . 'com_k2' . DS . 'helpers' . DS . 'route.php';
        // prepare an array
        $results = array();
        // prepare an query part
        $query_ids = implode(',', $ids);
        // generate the query
        $database = JFactory::getDBO();
        // SQL query for slides
        $query = '
		SELECT 
			`c`.`id` AS `id`,
			`c`.`catid` AS `cid`,
			`c`.`title` AS `title`,
			`c`.`introtext` AS `introtext`,
			`c`.alias AS `alias`,
			`cats`.alias AS `cat_alias`
		FROM 
			#__k2_items AS `c` 
			LEFT JOIN 
					#__k2_categories AS `cats`
					ON cats.id = `c`.`id` 
		WHERE 
			`c`.`id` IN (' . $query_ids . ')
		;';
        // running query
        $database->setQuery($query);
        // if results exists
        if ($datas = $database->loadObjectList()) {
            // parsing data
            foreach ($datas as $item) {
                // array with prepared image
                $results[$item->id] = array('id' => $item->id, 'cid' => $item->cid, 'title' => stripslashes($item->title), 'link' => urldecode(JRoute::_(K2HelperRoute::getItemRoute($item->id . ':' . urlencode($item->alias), $item->cid . ':' . urlencode($item->cat_alias)))));
            }
        }
        // return the results
        return $results;
    }