Exemplo n.º 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;
 }
Exemplo n.º 2
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();
     $max = $params->get('max_images');
     $catid = (int) $params->get('plg_content_id', 0);
     $default_image = $params->get('plg_content_image');
     require_once JPATH_BASE . '/components/com_content/helpers/route.php';
     JModelLegacy::addIncludePath(JPATH_BASE . '/components/com_content/models', 'ContentModel');
     $model = JModelLegacy::getInstance('Articles', 'ContentModel', array('ignore_request' => true));
     $model->setState('params', $app->getParams('com_content'));
     $model->setState('list.select', 'a.id, a.title, a.alias, a.introtext, a.fulltext, ' . 'a.checked_out, a.checked_out_time, ' . 'a.catid, a.created, a.created_by, a.created_by_alias, ' . 'CASE WHEN a.modified = 0 THEN a.created ELSE a.modified END as modified, ' . 'a.modified_by, uam.name as modified_by_name,' . 'CASE WHEN a.publish_up = 0 THEN a.created ELSE a.publish_up END as publish_up,' . 'a.publish_down, a.images, a.urls, a.attribs, a.metadata, a.metakey, a.metadesc, a.access, ' . 'a.hits, a.xreference, a.featured');
     $model->setState('list.start', 0);
     $model->setState('list.limit', $max);
     if ($params->get('sort_by')) {
         $model->setState('list.ordering', $params->get('plg_content_order', 'a.ordering'));
         $model->setState('list.direction', $params->get('plg_content_order_dir', 'ASC'));
     } else {
         $model->setState('list.ordering', 'RAND()');
     }
     $user = JFactory::getUser();
     if (!$user->authorise('core.edit.state', 'com_content') && !$user->authorise('core.edit', 'com_content')) {
         // filter on published for those who do not have edit or edit.state rights.
         $model->setState('filter.published', 1);
     }
     $model->setState('filter.language', $app->getLanguageFilter());
     // check for category selection
     if ($catid) {
         $model->setState('filter.category_id', $catid);
     }
     if ($params->get('plg_content_type') == 'featured') {
         $model->setState('filter.featured', 'only');
     }
     $showSubcategories = $params->get('plg_content_maxlevel', '0');
     if ($showSubcategories) {
         $model->setState('filter.subcategories', true);
         $model->setState('filter.max_category_levels', $params->get('plg_content_maxlevel', '1'));
     }
     $items = $model->getItems();
     $slides = array();
     foreach ($items as $item) {
         $slide = (object) array();
         $images = new JRegistry($item->images);
         if ($images->get('image_intro')) {
             $slide->image = $images->get('image_intro');
         } else {
             if ($images->get('image_fulltext')) {
                 $slide->image = $images->get('image_fulltext');
             } else {
                 $slide->image = DJMediatoolsLayoutHelper::getImageFromText($item->introtext);
             }
         }
         //djdebug($item->fulltext);
         // 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->id = $item->alias ? $item->id . ':' . $item->alias : $item->id;
         $slide->canonical = $slide->link = JRoute::_(ContentHelperRoute::getArticleRoute($slide->id, $item->catid));
         if ($comments = $params->get('commnets', 0)) {
             $host = str_replace(JURI::root(true), '', JURI::root());
             $host = preg_replace('/\\/$/', '', $host);
             switch ($comments) {
                 case 1:
                     // jcomments
                     $slide->comments = array('id' => $item->id, 'group' => 'com_content');
                     break;
                 case 2:
                     // disqus
                     $disqus_shortname = $params->get('disqus_shortname', '');
                     if (!empty($disqus_shortname)) {
                         $slide->comments = array();
                         $slide->comments['url'] = $host . $slide->link;
                         $slide->comments['identifier'] = substr(md5($disqus_shortname), 0, 10) . "_id" . $item->id;
                     }
                     break;
                 case 3:
                     // facebook
                     $slide->comments = $host . $slide->link;
                     break;
                 case 4:
                     //komento
                     // not implemented
                     break;
             }
         }
         $slides[] = $slide;
     }
     return $slides;
 }
Exemplo n.º 3
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_easyblog_image');
     $path = JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_easyblog' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'helper.php';
     if (!JFile::exists($path)) {
         return null;
     }
     require_once $path;
     require_once EBLOG_HELPERS . DIRECTORY_SEPARATOR . 'router.php';
     JFactory::getLanguage()->load('com_easyblog', JPATH_ROOT);
     $mparams = new JRegistry();
     $count = $params->get('max_images');
     $sort = array();
     $sort[0] = $params->get('plg_easyblog_order');
     $sort[1] = $params->get('plg_easyblog_order_dir');
     $featured = $params->get('plg_easyblog_usefeatured');
     $type = 'latest';
     $model = EasyBlogHelper::getModel('Blog');
     $categories = EasyBlogHelper::getCategoryInclusion($params->get('plg_easyblog_catid'));
     $catIds = array();
     if (!empty($categories)) {
         if (!is_array($categories)) {
             $categories = array($categories);
         }
         foreach ($categories as $item) {
             $category = new stdClass();
             $category->id = trim($item);
             $catIds[] = $category->id;
             if ($params->get('plg_easyblog_includesubcategory', 0)) {
                 $category->childs = null;
                 EasyBlogHelper::buildNestedCategories($category->id, $category, false, true);
                 EasyBlogHelper::accessNestedCategoriesId($category, $catIds);
             }
         }
         $catIds = array_unique($catIds);
     }
     $cid = $catIds;
     if (!empty($cid)) {
         $type = 'category';
     }
     $posts = $model->getBlogsBy($type, $cid, $sort, $count, EBLOG_FILTER_PUBLISHED, null, $featured, array(), false, false, true, array(), $cid);
     $slides = array();
     foreach ($posts as $item) {
         $slide = (object) array();
         $row = EasyBlogHelper::getTable('Blog', 'Table');
         $row->bind($item);
         $image = $row->getImage();
         if (!empty($image)) {
             $slide->image = str_replace(JURI::base(), '', $image->getSource('original'));
         } else {
             $slide->image = DJMediatoolsLayoutHelper::getImageFromText($item->intro);
         }
         // if no image found in images and introtext then try fulltext
         if (empty($slide->image)) {
             $slide->image = DJMediatoolsLayoutHelper::getImageFromText($item->content);
         }
         // if no image found in fulltext then take default image
         if (empty($slide->image)) {
             $slide->image = $default_image;
         }
         // if no default image set then don't display this article
         if (empty($slide->image)) {
             continue;
         }
         $slide->title = $item->title;
         $slide->description = $item->intro;
         if (empty($slide->description)) {
             $slide->description = $item->content;
         }
         $slide->canonical = $slide->link = EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $item->id);
         //.'&Itemid='. EasyBlogRouter::getItemIdByCategories( $item->category_id ) );
         $slide->id = $item->id . ':' . $item->permalink;
         //$this->dd($item);
         if ($comments = $params->get('commnets', 0)) {
             $host = str_replace(JURI::root(true), '', JURI::root());
             $host = preg_replace('/\\/$/', '', $host);
             switch ($comments) {
                 case 1:
                     // jcomments
                     $slide->comments = array('id' => $item->id, 'group' => 'com_easyblog');
                     break;
                 case 2:
                     // disqus
                     $disqus_shortname = $params->get('disqus_shortname', '');
                     if (!empty($disqus_shortname)) {
                         $slide->comments = array();
                         $slide->comments['url'] = $host . $slide->link;
                         $slide->comments['identifier'] = $disqus_shortname . '-easyblog-' . $item->id;
                         // ??
                     }
                     break;
                 case 3:
                     // facebook
                     $slide->comments = $host . $slide->link;
                     break;
                 case 4:
                     //komento
                     // not implemented
                     break;
             }
         }
         $slides[] = $slide;
     }
     return $slides;
 }
Exemplo n.º 4
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();
     require_once JPATH_ADMINISTRATOR . '/components/com_hikashop/helpers/helper.php';
     require_once JPATH_BASE . '/components/com_hikashop/views/product/view.html.php';
     $view = new ProductViewProduct(array('base_path' => HIKASHOP_FRONT));
     $view->setLayout('listing');
     // create params for hikashop view
     $mparams = new JRegistry();
     $mparams->set('show_limit', 0);
     $mparams->set('from_module', 'djmediatools');
     $mparams->set('content_type', 'product');
     $mparams->set('add_to_wishlist', 0);
     $mparams->set('link_to_product_page', 0);
     $mparams->set('show_vote_product', 0);
     $mparams->set('display_custom_item_fields', 0);
     $mparams->set('display_filters', 0);
     $mparams->set('display_badges', 0);
     // get options from album
     $mparams->def('limit', $params->get('max_images'));
     $mparams->def('content_synchronize', (int) $params->get('plg_hikashop_content_synchronize'));
     $mparams->def('product_synchronize', $params->get('plg_hikashop_product_synchronize'));
     $mparams->def('recently_viewed', (int) $params->get('plg_hikashop_recently_viewed'));
     $mparams->def('selectparentlisting', $params->get('plg_hikashop_selectparentlisting'));
     $mparams->def('filter_type', $params->get('plg_hikashop_filter_type'));
     $mparams->def('product_order', $params->get('plg_hikashop_product_order'));
     $mparams->def('order_dir', $params->get('plg_hikashop_order_dir'));
     $mparams->def('itemid', $params->get('plg_hikashop_itemid'));
     $mparams->def('add_to_cart', $params->get('plg_hikashop_add_to_cart'));
     $mparams->def('show_quantity_field', $params->get('plg_hikashop_show_quantity_field'));
     $mparams->def('show_out_of_stock', $params->get('plg_hikashop_show_out_of_stock'));
     $mparams->def('show_price', $params->get('plg_hikashop_show_price'));
     $mparams->def('random', $mparams->get('product_order') == 'random' ? 1 : 0);
     $show_price = (bool) $mparams->get('show_price');
     $show_addtocart = (bool) $mparams->get('add_to_cart');
     $default_image = $params->get('plg_hikashop_image');
     /* hikashop authors force me to do it, because their component is not object oriented and there is no other way
      * to get listing of the products unless we will rewrite the whole component logic, what is nonsens :)
      */
     ob_start();
     $view->display(null, $mparams);
     $js = @$view->js;
     ob_get_clean();
     // we don't need this, just $view object after view rendering
     //$this->debug($view->row);
     $slides = array();
     foreach ($view->rows as $item) {
         $slide = (object) array();
         $slide->image = $item->file_path;
         $slide->alt = $item->file_name;
         if (empty($slide->image)) {
             $slide->image = DJMediatoolsLayoutHelper::getImageFromText($item->product_description);
         }
         // if no image found in product description then take default image
         if (empty($slide->image)) {
             $slide->image = $default_image;
         } else {
             $slide->image = str_replace(JURI::root(true), '', $view->image->uploadFolder_url) . $slide->image;
         }
         // if no default image set then don't display this product
         if (empty($slide->image)) {
             continue;
         }
         $slide->title = $item->product_name;
         $slide->description = $item->product_description;
         $slide->canonical = $slide->link = hikashop_contentLink('product&task=show&cid=' . $item->product_id . '&name=' . $item->alias . $view->itemid . $view->category_pathway, $item);
         $slide->id = $item->product_id . ':' . $item->alias;
         if ($comments = $params->get('commnets', 0)) {
             $host = str_replace(JURI::root(true), '', JURI::root());
             $host = preg_replace('/\\/$/', '', $host);
             switch ($comments) {
                 case 1:
                     // jcomments
                     $slide->comments = array('id' => $item->product_id, 'group' => 'com_hikashop');
                     break;
                 case 2:
                     // disqus
                     $disqus_shortname = $params->get('disqus_shortname', '');
                     if (!empty($disqus_shortname)) {
                         $slide->comments = array();
                         $slide->comments['url'] = $host . $slide->link;
                         $slide->comments['identifier'] = $disqus_shortname . '-hikashop-' . $item->product_id;
                         // ??
                     }
                     break;
                 case 3:
                     // facebook
                     $slide->comments = $host . $slide->link;
                     break;
                 case 4:
                     //komento
                     // not implemented
                     break;
             }
         }
         $view->row =& $item;
         if ($show_price) {
             $view->setLayout('listing_price');
             $slide->extra = $view->loadTemplate();
         }
         if ($show_addtocart) {
             if (!isset($slide->extra)) {
                 $slide->extra = '';
             }
             $view->setLayout('add_to_cart_listing');
             $slide->extra .= $view->loadTemplate();
         }
         $slides[] = $slide;
     }
     return $slides;
 }
Exemplo n.º 5
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();
     require_once JPATH_ROOT . '/components/com_sobipro/lib/sobi.php';
     Sobi::Initialise($params->get('section'));
     require_once dirname(__FILE__) . '/lib/emod.php';
     $emod = new SPEntriesDJMTCtrl();
     $default_image = $params->get('plg_sobipro_image');
     // create parameters for K2 content module helper
     $mparams = new JRegistry();
     $mparams->def('entriesLimit', $params->get('max_images'));
     $mparams->def('section', $params->get('section'));
     $mparams->def('cid', $params->get('cid'));
     $mparams->def('sid', $params->get('sid'));
     $mparams->def('autoListing', $params->get('plg_sobipro_autoListing'));
     $mparams->def('spOrder', $params->get('spOrder'));
     $mparams->def('spOrderDir', $params->get('spOrderDir'));
     $mparams->def('spLimit', $params->get('spLimit'));
     $mparams->def('engine', 'static');
     $items = $emod->getSourceEntries($mparams);
     $slides = array();
     //$this->debug($items);
     foreach ($items as $item) {
         $slide = (object) array();
         $slide->title = $item['name']['_data'];
         $slide->description = $item['fields']['field_short_description']['_data']['data']['_data'];
         $slide->image = $item['fields']['field_company_logo']['_data']['data']['_attributes']['image'];
         if (!$slide->image) {
             $slide->image = DJMediatoolsLayoutHelper::getImageFromText($slide->description);
         }
         if (!$slide->image) {
             $slide->image = $default_image;
         }
         // if no default image set then don't display this entry
         if (!$slide->image) {
             continue;
         }
         $slide->id = $item->id;
         $slide->canonical = $slide->link = $item['url'];
         if ($comments = $params->get('commnets', 0)) {
             $host = str_replace(JURI::root(true), '', JURI::root());
             $host = preg_replace('/\\/$/', '', $host);
             switch ($comments) {
                 case 1:
                     // jcomments
                     $slide->comments = array('id' => $item->id, 'group' => 'com_sobipro');
                     break;
                 case 2:
                     // disqus
                     $disqus_shortname = $params->get('disqus_shortname', '');
                     if (!empty($disqus_shortname)) {
                         $slide->comments = array();
                         $slide->comments['url'] = $host . $slide->link;
                         $slide->comments['identifier'] = substr(md5($disqus_shortname), 0, 10) . "_id" . $item->id;
                     }
                     break;
                 case 3:
                     // facebook
                     $slide->comments = $host . $slide->link;
                     break;
                 case 4:
                     //komento
                     // not implemented
                     break;
             }
         }
         $slides[] = $slide;
     }
     return $slides;
 }