Ejemplo n.º 1
0
 /**
  * ReadMore Link
  * @param object $article
  * @return string 
  */
 function readmoreLink(&$article)
 {
     // Получить слитые параметры
     jimport('joomla.html.parameter');
     $params = new JParameter($article->attribs, JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_content' . DS . 'models' . DS . 'article.xml');
     $menuitemid = JRequest::getInt('Itemid');
     if ($menuitemid) {
         $menu = JSite::getMenu();
         $menuparams = $menu->getParams($menuitemid);
         $params->merge($menuparams);
     }
     $params->merge($article->params);
     // Если для статьи есть уже ссылка, сделать ссылкой и изобржение
     if (@$article->readmore || $params->get('link_titles')) {
         if ($this->plugin->jVersion == '1.5') {
             $readmore = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catslug, $article->sectionid));
         } else {
             $readmore = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catid));
         }
     } else {
         $readmore = '';
     }
     return $readmore;
 }
Ejemplo n.º 2
0
 function prepareItem($item, $view, $task)
 {
     jimport('joomla.filesystem.file');
     JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'tables');
     $limitstart = JRequest::getInt('limitstart');
     //Initialize params
     if ($view != 'item') {
         $component = JComponentHelper::getComponent('com_k2');
         $params = new JParameter($component->params);
         $itemid = JRequest::getInt('Itemid');
         if ($itemid) {
             $menu = JSite::getMenu();
             $menuparams = $menu->getParams($itemid);
             $params->merge($menuparams);
         }
     } else {
         $params =& JComponentHelper::getParams('com_k2');
     }
     //Category
     $db =& JFactory::getDBO();
     $query = "SELECT * FROM #__k2_categories WHERE id={$item->catid}";
     $db->setQuery($query, 0, 1);
     $category = $db->loadObject();
     $item->category = $category;
     $item->category->link = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($category->id . ':' . urlencode($category->alias))));
     //Read more link
     $link = K2HelperRoute::getItemRoute($item->id . ':' . urlencode($item->alias), $item->catid . ':' . urlencode($item->category->alias));
     $item->link = urldecode(JRoute::_($link));
     //Print link
     $item->printLink = urldecode(JRoute::_($link . '&tmpl=component&print=1'));
     //Params
     $cparams = new JParameter($category->params);
     $iparams = new JParameter($item->params);
     $item->params = $params;
     if ($cparams->get('inheritFrom')) {
         $masterCategoryID = $cparams->get('inheritFrom');
         $query = "SELECT * FROM #__k2_categories WHERE id={$masterCategoryID}";
         $db->setQuery($query, 0, 1);
         $masterCategory = $db->loadObject();
         $cparams = new JParameter($masterCategory->params);
     }
     $item->params->merge($cparams);
     $item->params->merge($iparams);
     //Edit link
     if (K2HelperPermissions::canEditItem($item->created_by, $item->catid)) {
         $item->editLink = JRoute::_('index.php?option=com_k2&view=item&task=edit&cid=' . $item->id . '&tmpl=component');
     }
     //Tags
     if ($view == 'item' && ($item->params->get('itemTags') || $item->params->get('itemRelated')) || $view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemTags') || $view == 'itemlist' && $task == 'user' && $item->params->get('userItemTags') || $view == 'latest' && $params->get('latestItemTags')) {
         $tags = K2ModelItem::getItemTags($item->id);
         for ($i = 0; $i < sizeof($tags); $i++) {
             $tags[$i]->link = urldecode(JRoute::_(K2HelperRoute::getTagRoute($tags[$i]->name)));
         }
         $item->tags = $tags;
     }
     //Image
     $item->imageXSmall = '';
     $item->imageSmall = '';
     $item->imageMedium = '';
     $item->imageLarge = '';
     $item->imageXLarge = '';
     if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_XS.jpg')) {
         $item->imageXSmall = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_XS.jpg';
     }
     if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_S.jpg')) {
         $item->imageSmall = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_S.jpg';
     }
     if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_M.jpg')) {
         $item->imageMedium = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_M.jpg';
     }
     if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_L.jpg')) {
         $item->imageLarge = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_L.jpg';
     }
     if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_XL.jpg')) {
         $item->imageXLarge = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_XL.jpg';
     }
     if (JFile::exists(JPATH_SITE . DS . 'media' . DS . 'k2' . DS . 'items' . DS . 'cache' . DS . md5("Image" . $item->id) . '_Generic.jpg')) {
         $item->imageGeneric = JURI::root() . 'media/k2/items/cache/' . md5("Image" . $item->id) . '_Generic.jpg';
     }
     //Extra fields
     if ($view == 'item' && $item->params->get('itemExtraFields') || $view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemExtraFields') || $view == 'itemlist' && ($task == 'search' || $task == 'tag' || $task == 'date') && $item->params->get('genericItemExtraFields')) {
         $item->extra_fields = K2ModelItem::getItemExtraFields($item->extra_fields);
     }
     //Attachments
     if ($view == 'item' && $item->params->get('itemAttachments') || $view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemAttachments')) {
         $item->attachments = K2ModelItem::getItemAttachments($item->id);
     }
     //Import plugins
     $dispatcher =& JDispatcher::getInstance();
     JPluginHelper::importPlugin('content');
     //Gallery
     if ($view == 'item' && $item->params->get('itemImageGallery') || $view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemImageGallery')) {
         $params->set('galleries_rootfolder', 'media/k2/galleries');
         $params->set('popup_engine', 'mootools_slimbox');
         $params->set('enabledownload', '0');
         $item->text = $item->gallery;
         $dispatcher->trigger('onPrepareContent', array(&$item, &$params, $limitstart));
         $item->gallery = $item->text;
     }
     //Video
     if ($view == 'item' && $item->params->get('itemVideo') || $view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemVideo') || $view == 'latest' && $item->params->get('latestItemVideo')) {
         if (!empty($item->video) && JString::substr($item->video, 0, 1) !== '{') {
             $item->video = $item->video;
             $item->videoType = 'embedded';
         } else {
             $item->videoType = 'allvideos';
             $params->set('vfolder', 'media/k2/videos');
             if ($view == 'item') {
                 $params->set('vwidth', $item->params->get('itemVideoWidth'));
                 $params->set('vheight', $item->params->get('itemVideoHeight'));
                 $params->set('autoplay', $item->params->get('itemVideoAutoPlay'));
             } else {
                 if ($view == 'latest') {
                     $params->set('vwidth', $item->params->get('latestItemVideoWidth'));
                     $params->set('vheight', $item->params->get('latestItemVideoHeight'));
                     $params->set('autoplay', $item->params->get('latestItemVideoAutoPlay'));
                 } else {
                     $params->set('vwidth', $item->params->get('catItemVideoWidth'));
                     $params->set('vheight', $item->params->get('catItemVideoHeight'));
                     $params->set('autoplay', $item->params->get('catItemVideoAutoPlay'));
                 }
             }
             $item->text = $item->video;
             $dispatcher->trigger('onPrepareContent', array(&$item, &$params, $limitstart));
             $item->video = $item->text;
         }
     }
     //Rating
     if ($view == 'item' && $item->params->get('itemRating') || $view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemRating')) {
         $item->votingPercentage = K2ModelItem::getVotesPercentage($item->id);
         $item->numOfvotes = K2ModelItem::getVotesNum($item->id);
     }
     //Filtering
     if ($params->get('introTextCleanup')) {
         $filterTags = preg_split('#[,\\s]+#', trim($params->get('introTextCleanupExcludeTags')));
         $filterAttrs = preg_split('#[,\\s]+#', trim($params->get('introTextCleanupTagAttr')));
         $filter = new JFilterInput($filterTags, $filterAttrs, 0, 1);
         $item->introtext = $filter->clean($item->introtext);
     }
     if ($params->get('fullTextCleanup')) {
         $filterTags = preg_split('#[,\\s]+#', trim($params->get('fullTextCleanupExcludeTags')));
         $filterAttrs = preg_split('#[,\\s]+#', trim($params->get('fullTextCleanupTagAttr')));
         $filter = new JFilterInput($filterTags, $filterAttrs, 0, 1);
         $item->fulltext = $filter->clean($item->fulltext);
     }
     if ($item->params->get('catItemIntroTextWordLimit') && $task == 'category') {
         $item->introtext = K2HelperUtilities::wordLimit($item->introtext, $item->params->get('catItemIntroTextWordLimit'));
     }
     //Plugins
     $item->text = '';
     $params->set('vfolder', NULL);
     $params->set('vwidth', NULL);
     $params->set('vheight', NULL);
     $params->set('autoplay', NULL);
     $params->set('galleries_rootfolder', NULL);
     $params->set('popup_engine', NULL);
     $params->set('enabledownload', NULL);
     if ($view == 'item') {
         if ($item->params->get('itemIntroText')) {
             $item->text .= $item->introtext;
         }
         if ($item->params->get('itemFullText')) {
             $item->text .= '{K2Splitter}' . $item->fulltext;
         }
     } else {
         switch ($task) {
             case '':
             case 'category':
                 if ($item->params->get('catItemIntroText')) {
                     $item->text .= $item->introtext;
                 }
                 break;
             case 'user':
                 if ($item->params->get('userItemIntroText')) {
                     $item->text .= $item->introtext;
                 }
                 break;
             default:
                 if ($item->params->get('genericItemIntroText')) {
                     $item->text .= $item->introtext;
                 }
                 break;
         }
     }
     $results = $dispatcher->trigger('onBeforeDisplay', array(&$item, &$params, $limitstart));
     $item->event->BeforeDisplay = trim(implode("\n", $results));
     $results = $dispatcher->trigger('onAfterDisplay', array(&$item, &$params, $limitstart));
     $item->event->AfterDisplay = trim(implode("\n", $results));
     $results = $dispatcher->trigger('onAfterDisplayTitle', array(&$item, &$params, $limitstart));
     $item->event->AfterDisplayTitle = trim(implode("\n", $results));
     $results = $dispatcher->trigger('onBeforeDisplayContent', array(&$item, &$params, $limitstart));
     $item->event->BeforeDisplayContent = trim(implode("\n", $results));
     $results = $dispatcher->trigger('onAfterDisplayContent', array(&$item, &$params, $limitstart));
     $item->event->AfterDisplayContent = trim(implode("\n", $results));
     $dispatcher->trigger('onPrepareContent', array(&$item, &$params, $limitstart));
     //Author
     if ($view == 'item' && ($item->params->get('itemAuthorBlock') || $item->params->get('itemAuthor')) || $view == 'itemlist' && ($task == '' || $task == 'category') && ($item->params->get('catItemAuthorBlock') || $item->params->get('catItemAuthor')) || $view == 'itemlist' && $task == 'user') {
         if (!empty($item->created_by_alias)) {
             $item->author->name = $item->created_by_alias;
             $item->author->avatar = K2HelperUtilities::getAvatar('alias');
         } else {
             $author =& JFactory::getUser($item->created_by);
             $item->author = $author;
             $item->author->link = JRoute::_(K2HelperRoute::getUserRoute($item->created_by));
             $item->author->profile = K2ModelItem::getUserProfile($item->created_by);
             $item->author->avatar = K2HelperUtilities::getAvatar($author->id, $author->email, $params->get('userImageWidth'));
         }
         if (!is_object($item->author->profile)) {
             $item->author->profile = new JObject();
             $item->author->profile->gender = NULL;
         }
     }
     //Num of comments
     $item->numOfComments = K2ModelItem::countItemComments($item->id);
     //K2 plugins
     $item->event->K2BeforeDisplay = '';
     $item->event->K2AfterDisplay = '';
     $item->event->K2AfterDisplayTitle = '';
     $item->event->K2BeforeDisplayContent = '';
     $item->event->K2AfterDisplayContent = '';
     if ($view == 'item' && $item->params->get('itemK2Plugins') || $view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemK2Plugins') || $view == 'itemlist' && $task == 'user' && $item->params->get('userItemK2Plugins')) {
         JPluginHelper::importPlugin('k2');
         $results = $dispatcher->trigger('onK2BeforeDisplay', array(&$item, &$params, $limitstart));
         $item->event->K2BeforeDisplay = trim(implode("\n", $results));
         $results = $dispatcher->trigger('onK2AfterDisplay', array(&$item, &$params, $limitstart));
         $item->event->K2AfterDisplay = trim(implode("\n", $results));
         $results = $dispatcher->trigger('onK2AfterDisplayTitle', array(&$item, &$params, $limitstart));
         $item->event->K2AfterDisplayTitle = trim(implode("\n", $results));
         $results = $dispatcher->trigger('onK2BeforeDisplayContent', array(&$item, &$params, $limitstart));
         $item->event->K2BeforeDisplayContent = trim(implode("\n", $results));
         $results = $dispatcher->trigger('onK2AfterDisplayContent', array(&$item, &$params, $limitstart));
         $item->event->K2AfterDisplayContent = trim(implode("\n", $results));
         $dispatcher->trigger('onK2PrepareContent', array(&$item, &$params, $limitstart));
     }
     if ($view == 'item') {
         @(list($item->introtext, $item->fulltext) = explode('{K2Splitter}', $item->text));
     } else {
         $item->introtext = $item->text;
     }
     return $item;
 }
Ejemplo n.º 3
0
	function prepareItem($item, $view, $task){

		jimport('joomla.filesystem.file');
		JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
		$limitstart=JRequest::getInt('limitstart');

		//Initialize params
		if ($view!='item'){

			$component = JComponentHelper::getComponent( 'com_k2' );
			$params = new JParameter( $component->params );
			$itemid = JRequest::getInt( 'Itemid' );
			if ($itemid) {
				$menu = JSite::getMenu();
				$menuparams = $menu->getParams( $itemid );
				$params->merge( $menuparams );
			}

		}
		else {
			$params = & JComponentHelper::getParams('com_k2');
		}

		//Category
		$db = & JFactory::getDBO();
		$query = "SELECT * FROM #__k2_categories WHERE id=".(int)$item->catid;
		$db->setQuery($query, 0, 1);
		$category = $db->loadObject();

		$item->category=$category;
		$item->category->link=urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($category->id.':'.urlencode($category->alias))));

		//Read more link
		$link = K2HelperRoute::getItemRoute($item->id.':'.urlencode($item->alias),$item->catid.':'.urlencode($item->category->alias));
		$item->link=urldecode(JRoute::_($link));

		//Print link
		$item->printLink = urldecode(JRoute::_($link.'&tmpl=component&print=1'));

		//Params
		$cparams = new JParameter( $category->params );
		$iparams = new JParameter( $item->params );
		$item->params= $params;
		if ($cparams->get('inheritFrom')){
			$masterCategoryID = $cparams->get('inheritFrom');
			$query = "SELECT * FROM #__k2_categories WHERE id=".(int)$masterCategoryID;
			$db->setQuery($query, 0, 1);
			$masterCategory = $db->loadObject();
			$cparams = new JParameter( $masterCategory->params );
		}
		$item->params->merge($cparams);
		$item->params->merge($iparams);

		//Edit link
		if (K2HelperPermissions::canEditItem($item->created_by,$item->catid))
		$item->editLink = JRoute::_('index.php?option=com_k2&view=item&task=edit&cid='.$item->id.'&tmpl=component');

		//Tags
		if(
		($view=='item' && ($item->params->get('itemTags') || $item->params->get('itemRelated'))) ||
		($view=='itemlist' && ($task=='' || $task=='category') && $item->params->get('catItemTags')) ||
		($view=='itemlist' && $task=='user' && $item->params->get('userItemTags')) ||
		($view=='latest' && $params->get('latestItemTags'))
		)
		{
			$tags = K2ModelItem::getItemTags($item->id);
			for ($i=0; $i<sizeof($tags); $i++) {
				$tags[$i]->link = JRoute::_(K2HelperRoute::getTagRoute($tags[$i]->name));
			}
			$item->tags=$tags;
		}


		//Image
		$item->imageXSmall='';
		$item->imageSmall='';
		$item->imageMedium='';
		$item->imageLarge='';
		$item->imageXLarge='';

		if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XS.jpg'))
		$item->imageXSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XS.jpg';

		if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_S.jpg'))
		$item->imageSmall = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_S.jpg';

		if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_M.jpg'))
		$item->imageMedium = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_M.jpg';

		if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_L.jpg'))
		$item->imageLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_L.jpg';

		if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XL.jpg'))
		$item->imageXLarge = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_XL.jpg';

		if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_Generic.jpg'))
		$item->imageGeneric = JURI::root().'media/k2/items/cache/'.md5("Image".$item->id).'_Generic.jpg';


		//Extra fields
		if(
		($view=='item' && $item->params->get('itemExtraFields')) ||
		($view=='itemlist' && ($task=='' || $task=='category') && $item->params->get('catItemExtraFields')) ||
		($view=='itemlist' && ($task=='search' || $task=='tag' || $task=='date') && $item->params->get('genericItemExtraFields'))
		)
		{
			$item->extra_fields=K2ModelItem::getItemExtraFields($item->extra_fields);
		}

		//Attachments
		if(
		($view=='item' && $item->params->get('itemAttachments')) ||
		($view=='itemlist' && ($task=='' || $task=='category') && $item->params->get('catItemAttachments'))
		)
		{
			$item->attachments=K2ModelItem::getItemAttachments($item->id);
		}


		//Rating
		if(
		($view=='item' && $item->params->get('itemRating')) ||
		($view=='itemlist' && ($task=='' || $task=='category') && $item->params->get('catItemRating'))
		)
		{
			$item->votingPercentage = K2ModelItem::getVotesPercentage($item->id);
			$item->numOfvotes = K2ModelItem::getVotesNum($item->id);

		}

		//Filtering
		if ($params->get('introTextCleanup')){
			$filterTags	= preg_split( '#[,\s]+#', trim( $params->get( 'introTextCleanupExcludeTags' ) ) );
			$filterAttrs = preg_split( '#[,\s]+#', trim( $params->get( 'introTextCleanupTagAttr' ) ) );
			$filter	= new JFilterInput( $filterTags, $filterAttrs, 0, 1 );
			$item->introtext= $filter->clean( $item->introtext );
		}

		if ($params->get('fullTextCleanup')){
			$filterTags	= preg_split( '#[,\s]+#', trim( $params->get( 'fullTextCleanupExcludeTags' ) ) );
			$filterAttrs = preg_split( '#[,\s]+#', trim( $params->get( 'fullTextCleanupTagAttr' ) ) );
			$filter	= new JFilterInput( $filterTags, $filterAttrs, 0, 1 );
			$item->fulltext= $filter->clean( $item->fulltext );
		}

		if ($item->params->get('catItemIntroTextWordLimit') && $task=='category'){
			$item->introtext = K2HelperUtilities::wordLimit($item->introtext, $item->params->get('catItemIntroTextWordLimit'));
		}

		$item->cleanTitle = $item->title;
		$item->title = htmlspecialchars($item->title, ENT_QUOTES);
		$item->image_caption = htmlspecialchars($item->image_caption, ENT_QUOTES);

		//Author
		if(
		($view=='item' && ($item->params->get('itemAuthorBlock') || $item->params->get('itemAuthor'))) ||
		($view=='itemlist' && ($task=='' || $task=='category') && ($item->params->get('catItemAuthorBlock') || $item->params->get('catItemAuthor')) ) ||
		($view=='itemlist' && $task=='user')
		)
		{
			if (!empty($item->created_by_alias)){
				$item->author->name = $item->created_by_alias;
				$item->author->avatar = K2HelperUtilities::getAvatar('alias');
				$item->author->link = JURI::root();
			}
			else {
				$author=&JFactory::getUser($item->created_by);
				$item->author = $author;
				$item->author->link = JRoute::_(K2HelperRoute::getUserRoute($item->created_by));
				$item->author->profile = K2ModelItem::getUserProfile($item->created_by);
				$item->author->avatar = K2HelperUtilities::getAvatar($author->id, $author->email, $params->get('userImageWidth'));
			}

			if (!isset($item->author->profile) || is_null($item->author->profile)){

				$item->author->profile = new JObject;
				$item->author->profile->gender = NULL;

			}


		}

		//Num of comments
		$item->numOfComments = K2ModelItem::countItemComments($item->id);

		return $item;
	}
function shGetDefaultDisplayNum($menuItemid, $url, $fromSession = false, $includeBlogLinks = false) {

  $app = JFactory::getApplication();

  // default value is general configuration list length param
  $ret = $app->getCfg( 'list_limit', 10 );

  // get elements of the url
  $option = shGetURLVar($url, 'option');
  $layout = shGetURLVar( $url, 'layout');
  if (empty( $layout)) {
    $layout = 'default';
  }
  $view = shGetURLVar( $url, 'view');

  // is this a sobi2 url ? we must read config from database
  if ($option == 'com_sobi2') {
    $itemsPerLine = (int) shGetSobi2Config( 'itemsInLine', 'frontpage');
    $linesPerPage = (int) shGetSobi2Config( 'lineOnSite', 'frontpage');
    return $itemsPerLine * $linesPerPage;
  }

  // if there is a menu item, we can try read more params
  if (!empty($menuItemid)) {

    // itemid, try read params from the menu item
    $menu = & JFactory::getApplication()->getMenu();
    $menuItem = $menu->getItem($menuItemid);  // load menu item from DB
    if (empty($menuItem)) return $ret;  // if none, default
    jimport( 'joomla.html.parameter');

    // Load the parameters. Merge Global and Menu Item params into new object
    $currentOption = JRequest::getCmd('option');
    $params = new JParameter( $menuItem->params );  // get params from menu item
    if(!empty($currentOption)) {
      $params->merge($app->getParams());
    }

    // layout = blog and frontpage
    if ( ($option =='com_content' && $layout == 'blog')
    || ($option == 'com_content' && $view == 'frontpage')) {
      $num_leading_articles = $params->get('num_leading_articles');
      $num_intro_articles = $params->get('num_intro_articles');
      //adjust limit and listLimit for page calculation as blog views include
      //# of links in the limit value, while it should not be included for
      // page number calculation
      $num_links = $includeBlogLinks ? $params->get('num_links') : 0;

      $ret = $num_leading_articles + $num_intro_articles + $num_links;  // calculate how many items on a page
      return $ret;
    }

    // elements with a display_num parameter
    $displayNum = intval($params->get('display_num'));
    $ret = !empty( $displayNum) ? $displayNum : $ret;
  }

  if ($fromSession) {
    // now handle special cases
    if ( $option =='com_content' && $layout != 'blog' && ($view == 'category' || $view == 'section')) {
      $limit = $app->getUserStateFromRequest( 'com_content.sh.' . $view . '.' . $layout . '.limit', 'limit', null);
      if (!is_null($limit)) {
        return $limit;
      }
    }

    if ($option == 'com_contact') {
      $limit = $app->getUserState( $option . '.' . $view. '.limit');
      if (!is_null($limit)) {
        return $limit;
      }
    }

    if ($option == 'com_weblinks') {
      $limit = $app->getUserState( $option . '.limit');
      if (!is_null($limit)) {
        return $limit;
      }
    }
  }

  // return calculated value
  return $ret;
}
<?php

defined('_JEXEC') or die('Restricted access');
$oldsectionid = -1;
$oldcatid = -1;
$contentarray = array();
foreach ($list as $article) {
    $component = JComponentHelper::getComponent('com_content');
    $cparams = new JParameter($component->params);
    $aparams = $article->parameters;
    $cparams->merge($aparams);
    ob_start();
    if ($article->catid == $oldcatid && $article->sectionid == $oldsectionid) {
        $article->catid = 0;
        $article->sectionid = 0;
    } else {
        $oldcatid = $article->catid;
        $oldsectionid = $article->sectionid;
    }
    // DO NOT EDIT BEFORE THIS
    ?>

<?php 
    if ($cparams->get('show_title')) {
        ?>

<h2 class="contentheading<?php 
        echo $params->get('pageclass_sfx');
        ?>
">
    <?php 
Ejemplo n.º 6
0
 function autoResizerProcess(&$article)
 {
     $app = JFactory::getApplication();
     if (get_class($app) === "JAdministrator") {
         return true;
     }
     // get image information of article
     $image_infos = json_decode($article->images, true);
     if (empty($image_infos['image_intro']) && empty($image_infos['image_fulltext'])) {
         return true;
     }
     // get plugin parameter
     $plugin = JPluginHelper::getPlugin('content', 'autoresizer');
     if (version_compare(JVERSION, '1.6.0', '<')) {
         $pluginParams = new JParameter($plugin->params);
         $option = JRequest::getVar('option', '');
         if ($option) {
             $mergeparams = $app->getParams($option);
         }
         if (isset($mergeparams)) {
             $pluginParams->merge($mergeparams);
         }
     } else {
         $version = new JVersion();
         $pluginParams = new JRegistry();
         if (version_compare($version->getShortVersion(), '3.0.0', '>=')) {
             $pluginParams->loadString($plugin->params);
         } else {
             $pluginParams->loadJSON($plugin->params);
         }
     }
     $resize_image_intro = $pluginParams->def('resize_image_intro', '0');
     $resize_image_article = $pluginParams->def('resize_image_article', '0');
     if (!$resize_image_intro && !$resize_image_article) {
         return true;
     }
     // resize image intro
     if ($resize_image_intro && !$resize_image_article) {
         if (empty($image_infos['image_intro'])) {
             return true;
         }
     }
     // resize image fulltext
     if (!$resize_image_intro && $resize_image_article) {
         if (empty($image_infos['image_fulltext'])) {
             return true;
         }
     }
     // process convert image
     if ($resize_image_intro) {
         // Get parameter for image intro
         $scale_img_intro_width = $pluginParams->def('scale_img_intro_width', 160);
         $scale_img_intro_height = $pluginParams->def('scale_img_intro_height', 120);
         // check path file and get information of image
         $path = JPATH_ROOT . "/";
         $original_img_file = $path . $image_infos['image_intro'];
         if (file_exists($original_img_file) && is_file($original_img_file)) {
             $original_img_file_info = pathinfo($original_img_file);
             // check extension support
             $is_img = $original_img_file_info['extension'] == 'jpg' || $original_img_file_info['extension'] == 'jpeg' || $original_img_file_info['extension'] == 'png' || $original_img_file_info['extension'] == 'gif' || $original_img_file_info['extension'] == 'JPG' || $original_img_file_info['extension'] == 'JPEG' || $original_img_file_info['extension'] == 'PNG' || $original_img_file_info['extension'] == 'GIF';
             if ($is_img) {
                 // create new file
                 $file_name = md5($original_img_file_info['filename'] . $scale_img_intro_width . $scale_img_intro_height) . "." . $original_img_file_info['extension'];
                 // check exist resized image
                 $resize_image_store_dir = $pluginParams->def('resize_image_store_dir', 1);
                 if ($resize_image_store_dir == 0) {
                 } else {
                     if ($resize_image_store_dir == 1) {
                         if (!file_exists(JPATH_ROOT . "/cache/" . $file_name) || !is_file(JPATH_ROOT . "/cache/" . $file_name)) {
                             // process resize image
                             list($original_width, $original_height) = getimagesize($original_img_file);
                             if ($scale_img_intro_width != $original_width || $scale_img_intro_height != $original_height) {
                                 $image = new Image($original_img_file);
                                 $image->resize($scale_img_intro_width, $scale_img_intro_height, $original_img_file_info['extension']);
                                 $image->save(JPATH_ROOT . "/cache/" . $file_name);
                             }
                         }
                         $image_infos['image_intro'] = "cache/" . $file_name;
                     } else {
                     }
                 }
             }
         }
         /*
         $old_image = $file_name;
         $new_image = 'cache/' . utf8_substr($file_name, 0, utf8_strrpos($file_name, '.')) . '-' . $scale_img_intro_width . 'x' . $scale_img_intro_height . $type .'.' . $extension;
         
         if (!file_exists(DIR_IMAGE . $new_image) || (filemtime(DIR_IMAGE . $old_image) > filemtime(DIR_IMAGE . $new_image))) {
         	$path = '';
         
         	$directories = explode('/', dirname(str_replace('../', '', $new_image)));
         
         	foreach ($directories as $directory) {
         		$path = $path . '/' . $directory;
         
         		if (!file_exists(DIR_IMAGE . $path)) {
         			@mkdir(DIR_IMAGE . $path, 0777);
         		}
         	}
         
         	list($width_orig, $height_orig) = getimagesize(DIR_IMAGE . $old_image);
         
         	if ($width_orig != $width || $height_orig != $height) {
         		$image = new Image(DIR_IMAGE . $old_image);
         		$image->resize($width, $height, $type);
         		$image->save(DIR_IMAGE . $new_image);
         	} else {
         		copy(DIR_IMAGE . $old_image, DIR_IMAGE . $new_image);
         	}
         }
         */
     }
     if ($resize_image_article) {
     }
     // update image information of article
     $article->images = json_encode($image_infos);
 }
Ejemplo n.º 7
0
 function onPrepareContent(&$article, &$params, $limitstart = 0)
 {
     $mainframe =& JFactory::getApplication();
     if (get_class($mainframe) === "JAdministrator") {
         return true;
     }
     $plugin =& JPluginHelper::getPlugin('content', 'smartresizer');
     $option = JRequest::getVar('option', '');
     if (version_compare(JVERSION, '1.6.0', '<')) {
         $pluginParams = new JParameter($plugin->params);
         if ($option) {
             $mergeparams =& $mainframe->getParams($option);
         }
         if (isset($mergeparams)) {
             $pluginParams->merge($mergeparams);
         }
     } else {
         $version = new JVersion();
         $pluginParams = new JRegistry();
         if (version_compare($version->getShortVersion(), '3.0.0', '>=')) {
             $pluginParams->loadString($plugin->params);
         } else {
             $pluginParams->loadJSON($plugin->params);
         }
     }
     $processall = (int) $pluginParams->def('processall', '0');
     //for J1.7
     $isblogintro = 0;
     if (!version_compare(JVERSION, '1.6.0', '<')) {
         $view = JRequest::getCmd('view');
         if ($option == 'com_content') {
             if ($view == 'article') {
                 if (empty($article->text)) {
                     $article->text = $article->introtext . $article->fulltext;
                 }
             } else {
                 if ($article->introtext) {
                     $isblogintro = 1;
                 }
                 if (empty($article->text)) {
                     $article->text = $article->introtext;
                 }
             }
         }
     }
     if (strpos($article->text, 'smartresize') === false && !$processall) {
         return true;
     }
     if ($processall && strpos($article->text, 'img') === false && strpos($article->text, 'IMG') === false) {
         return true;
     }
     if ($processall) {
         $runword = "";
     } else {
         $runword = "smartresize";
     }
     $regex_img = "|<[\\s\v]*img[\\s\v]([^>]*" . $runword . "[^>]*)>|Ui";
     preg_match_all($regex_img, $article->text, $matches_img);
     $count_img = count($matches_img[0]);
     // plugin only processes if there are any instances of the plugin in the text
     if ($count_img) {
         $this->plgContentProcessSmartResizeImages($article, $pluginParams, $matches_img, $count_img);
         if ($isblogintro) {
             $article->introtext = $article->text;
         }
     }
 }