Current Path :
/
home
/
develito
/
public_html
/
modules
/
mod_jptabs
/
Or
Select Your Path :
Upload File :
New :
File
Dir
/home/develito/public_html/modules/mod_jptabs/helper.php
<?php /** * @package JP Extensions * @subpackage mod_jptabs * * @copyright Copyright (C) 2005 - 2015 JoomPortal.Com. All rights reserved. * @license GNU General Public License version 2 or later. */ // no direct access defined('_JEXEC') or die ('Restricted access'); require_once JPATH_SITE.'/components/com_content/helpers/route.php'; jimport('joomla.application.component.model'); JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_content/models', 'ContentModel'); jimport('joomla.utilities.string'); jimport( 'joomla.application.module.helper' ); abstract class modJpTabsHelper { /** * @return array of tab element(modules, cates) which prepared for rendering * @called by root */ public static function getTabsSelection($params) { if (trim($params->get('tabs')) == '') return false; return json_decode($params->get('tabs'), true); } /** * @return array of modules * @called by template */ public static function getModule($modId) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('*'); $query->from('#__modules'); $query->where('id='.$modId); $db->setQuery($query); if (!($module = $db->loadObject())) { JError::raiseWarning(500, JText::sprintf('JLIB_APPLICATION_ERROR_MODULE_LOAD', $db->getErrorMsg())); return false; } $module->user = substr($module->module, 0, 4) == 'mod_' ? 0 : 1; return $module; } /** * @return an article * @called by template */ public static function getArticle($id) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $db->setQuery( 'SELECT `id`, `catid`, `title`, `alias` FROM #__content WHERE `id` = '.(int)$id.';' ); try { $article = $db->loadObject(); } catch (RuntimeException $e) { JError::raiseWarning(500, $e->getMessage()); } if (!$article->id) return ''; return '<iframe class="contentpanel" src="'.JRoute::_(ContentHelperRoute::getArticleRoute($article->id.':'.$article->alias, $article->catid) . '&tmpl=component').'" frameborder="0" width="100%" height="100%" >'.JText::_('COM_WRAPPER_NO_IFRAMES').'</iframe>'; } /** * @return array of articles specified by category ID * @called by template */ public static function getArticleList($catId, $params) { $number_of_article = $params->get('number_of_article', 4); $number_of_character = $params->get('number_of_character', 100); $show_link = $params->get('show_link', 1); $show_readmore = $params->get('show_readmore', 1); $show_date = $params->get('show_date', 0); $date_format = $params->get('date_format', 'd.m.Y'); $show_thumbnail = $params->get('show_thumbnail', 1); //$default_image = $params->get('default_image', 'modules/mod_jptabs/images/sampledefault.jpg'); $thumb_width = $params->get('thumb_width', 70); $thumb_height = $params->get('thumb_height', 50); $show_view_all = $params->get('show_view_all', 1); // Get the dbo $db = JFactory::getDbo(); // Get an instance of the generic articles model $model = JModelLegacy::getInstance('Articles', 'ContentModel', array('ignore_request' => true)); // Set application parameters in model $app = JFactory::getApplication(); $appParams = $app->getParams(); $model->setState('params', $appParams); // Set the filters based on the module params $model->setState('list.start', 0); $model->setState('list.limit', (int) $number_of_article); $model->setState('filter.published', 1); // Access filter $access = !JComponentHelper::getParams('com_content')->get('show_noauth'); $authorised = JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id')); $model->setState('filter.access', $access); // Category filter $model->setState('filter.category_id', $catId); // User filter $userId = JFactory::getUser()->get('id'); switch ($params->get('user_id')) { case 'by_me': $model->setState('filter.author_id', (int) $userId); break; case 'not_me': $model->setState('filter.author_id', $userId); $model->setState('filter.author_id.include', false); break; case '0': break; default: $model->setState('filter.author_id', (int) $params->get('user_id')); break; } // Filter by language $model->setState('filter.language',$app->getLanguageFilter()); // Featured switch switch ($params->get('show_featured')) { case '1': $model->setState('filter.featured', 'only'); break; case '0': $model->setState('filter.featured', 'hide'); break; default: $model->setState('filter.featured', 'show'); break; } // Set ordering $order_map = array( 'm_dsc' => 'a.modified DESC, a.created', 'mc_dsc' => 'CASE WHEN (a.modified = '.$db->quote($db->getNullDate()).') THEN a.created ELSE a.modified END', 'c_dsc' => 'a.created', 'p_dsc' => 'a.publish_up', 'h_dsc' => 'a.hits' ); $ordering = JArrayHelper::getValue($order_map, $params->get('ordering'), 'a.publish_up'); $dir = 'DESC'; $model->setState('list.ordering', $ordering); $model->setState('list.direction', $dir); $items = $model->getItems(); if (!is_array($items) || empty($items)) return JText::_('No articles'); $cateHtml = array(); $itemsHtml = '<div class="jp-items-wrapper">'; foreach ($items as &$item) { $item->slug = $item->id.':'.$item->alias; $item->catslug = $item->catid ? $item->catid .':'.$item->category_alias : $item->catid; if ($access || in_array($item->access, $authorised)) { $item->link = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug)); } else { $item->link = JRoute::_('index.php?option=com_user&view=login'); } $itemsHtml .= '<div class="jp-item-wrapper">'; if ($show_thumbnail == 1) { //Get images $images = ""; if (isset($item->images)) $images = json_decode($item->images); $imgexists = (isset($images->image_intro) and !empty($images->image_intro)) || (isset($images->image_fulltext) and !empty($images->image_fulltext)); $itemsHtml .= '<div class="jp-thumb-wrapper">'; if ($imgexists) { $images->image_intro = $images->image_intro?$images->image_intro:$images->image_fulltext; $itemsHtml .= '<img src="'.htmlspecialchars($images->image_intro).'" alt="'.htmlspecialchars($images->image_intro_alt).'"/>'; } else { $itemsHtml .='<img src="http://placehold.it/1280x800" alt="Default Image"/>'; } $itemsHtml .='</div>'; } if($show_link == 1) { $itemsHtml .= '<h4 class="jp-title">'. '<a href="'.$item->link.'" class="jp-title-link">'.$item->title.'</a>'. '</h4>'; } else { $itemsHtml .= '<h4 class="jp-title">'. $item->title. '</h4>'; } if($show_date == 1) { $itemsHtml .= '<span class="created_date">'. JHTML::_('date', $item->created, $params->get( 'date_format' )). '</span>'; } $itemsHtml .= '<div class="jp-article-introtext">'. JString::substr(strip_tags(preg_replace('/<img([^>]+)>/i',"",JHtml::_('content.prepare', $item->introtext ))), 0, $number_of_character).'...'. '</div>'; if($show_readmore == 1) { $itemsHtml .= '<a href="'.$item->link.'" class="btn-readmore">'.JText::_('READMORE').'</a>'; } $itemsHtml .= '</div>'; $cate_title = $item->category_title; } if($show_view_all == 1) { $itemsHtml .= '<a class="view-all btn btn-default" href="'.JRoute::_(ContentHelperRoute::getCategoryRoute($catId)).'" title="view all">'.JText::_('VIEW_ALL').'</a>'; } $itemsHtml .= '</div>'; return $itemsHtml; } }