Exemple #1
0
 /**
  * Plugin that returns the object list for DJ-Mediatools album
  * 
  * Each object must contain following properties (mandatory): title, description, image
  * Optional properties: link, target (_blank or _self), alt (alt attribute for image)
  * 
  * @param	object	The album params
  */
 public function onAlbumPrepare(&$source, &$params)
 {
     // Lets check the requirements
     $check = $this->onCheckRequirements($source);
     if (is_null($check) || is_string($check)) {
         return null;
     }
     $app = JFactory::getApplication();
     $default_image = $params->get('plg_k2_image');
     require_once JPATH_BASE . '/modules/mod_k2_content/helper.php';
     // fix K2 models path inclusion, we need to add path with prefix to avoid conflicts with other extensions
     JModelLegacy::addIncludePath(JPATH_BASE . '/components/com_k2/models', 'K2Model');
     // create parameters for K2 content module helper
     $mparams = new JRegistry();
     $mparams->def('itemCount', $params->get('max_images'));
     $mparams->def('source', $params->get('plg_k2_source'));
     $mparams->def('catfilter', $params->get('plg_k2_catfilter'));
     $mparams->set('category_id', $params->get('plg_k2_category_id', array()));
     $mparams->def('getChildren', $params->get('plg_k2_getChildren'));
     $mparams->def('itemsOrdering', $params->get('plg_k2_itemsOrdering'));
     $mparams->def('FeaturedItems', $params->get('plg_k2_FeaturedItems'));
     $mparams->def('popularityRange', $params->get('plg_k2_popularityRange'));
     $mparams->def('videosOnly', $params->get('plg_k2_videosOnly'));
     $mparams->def('item', $params->get('plg_k2_item'));
     $mparams->set('items', $params->get('plg_k2_items', array()));
     $mparams->def('itemImage', 1);
     $mparams->def('itemIntroText', 1);
     //JFactory::getApplication()->enqueueMessage("<pre>".print_r($mparams, true)."</pre>");
     //$mparams->def('extra_fields', 1);
     $items = modK2ContentHelper::getItems($mparams);
     $slides = array();
     foreach ($items as $item) {
         $slide = (object) array();
         if (isset($item->imageXLarge)) {
             $slide->image = str_replace(JURI::base(true), '', $item->imageXLarge);
         } else {
             $slide->image = DJMediatoolsLayoutHelper::getImageFromText($item->introtext);
         }
         // if no image found in article images and introtext then try fulltext
         if (!$slide->image) {
             $slide->image = DJMediatoolsLayoutHelper::getImageFromText($item->fulltext);
         }
         // if no image found in fulltext then take default image
         if (!$slide->image) {
             $slide->image = $default_image;
         }
         // if no default image set then don't display this article
         if (!$slide->image) {
             continue;
         }
         $slide->title = $item->title;
         $slide->description = $item->introtext;
         if (empty($slide->description)) {
             $slide->description = $item->fulltext;
         }
         $slide->link = $item->link;
         $slides[] = $slide;
     }
     return $slides;
 }
Exemple #2
0
 public function getItems(array $params)
 {
     require_once JPATH_ROOT . '/modules/mod_k2_content/helper.php';
     if (K2_JVERSION != '15') {
         $language = JFactory::getLanguage();
         $language->load('mod_k2.j16', JPATH_ADMINISTRATOR, null, true);
     }
     return modK2ContentHelper::getItems(new JRegistry($params)) ?: array();
 }
Exemple #3
0
 function getModuleItems($moduleID)
 {
     $db =& JFactory::getDBO();
     $query = "SELECT * FROM #__modules WHERE id={$moduleID} AND published=1 AND client_id=0";
     $db->setQuery($query, 0, 1);
     $module = $db->loadObject();
     $format = JRequest::getWord('format');
     if (is_null($module)) {
         JError::raiseError(404, JText::_('K2_NOT_FOUND'));
     } else {
         $params = new JParameter($module->params);
         switch ($module->module) {
             case 'mod_k2_content':
                 require_once JPATH_SITE . DS . 'modules' . DS . 'mod_k2_content' . DS . 'helper.php';
                 $helper = new modK2ContentHelper();
                 $items = $helper->getItems($params, $format);
                 break;
             case 'mod_k2_comments':
                 if ($params->get('module_usage') == 1) {
                     JError::raiseError(404, JText::_('K2_NOT_FOUND'));
                 }
                 require_once JPATH_SITE . DS . 'modules' . DS . 'mod_k2_comments' . DS . 'helper.php';
                 $helper = new modK2CommentsHelper();
                 $items = $helper->getLatestComments($params);
                 foreach ($items as $item) {
                     $item->title = $item->userName . ' ' . JText::_('K2_COMMENTED_ON') . ' ' . $item->title;
                     $item->introtext = $item->commentText;
                     $item->created = $item->commentDate;
                     $item->id = $item->itemID;
                 }
                 break;
             default:
                 JError::raiseError(404, JText::_('K2_NOT_FOUND'));
         }
         $result = new JObject();
         $result->items = $items;
         $result->title = $module->title;
         $result->module = $module->module;
         $result->params = $module->params;
         return $result;
     }
 }
<?php

/**
 * @version		$Id: mod_k2_content.php 303 2010-01-07 02:56:33Z joomlaworks $
 * @package		K2
 * @author    JoomlaWorks http://www.joomlaworks.gr
 * @copyright	Copyright (c) 2006 - 2010 JoomlaWorks Ltd. All rights reserved.
 * @license		GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
 */
// no direct access
defined('_JEXEC') or die('Restricted access');
require_once dirname(__FILE__) . DS . 'helper.php';
$moduleclass_sfx = $params->get('moduleclass_sfx', '');
$getTemplate = $params->get('getTemplate', '');
$componentParams =& JComponentHelper::getParams('com_k2');
$items = modK2ContentHelper::getItems($params);
if (count($items)) {
    require JModuleHelper::getLayoutPath('mod_k2_content', $getTemplate . DS . 'default');
}