document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. <?php
  2.  
  3. defined (\'_JEXEC\') or die(\'resticted aceess\');
  4.  
  5. JLoader::register(\'JHtmlString\', JPATH_LIBRARIES.\'/joomla/html/html/string.php\');
  6.  
  7. AddonParser::addAddon(\'sp_latest_post\',\'sp_latest_posts_addon\');
  8.  
  9. function get_categories($parent=1) {
  10.     $db = JFactory::getDbo();
  11.     $query = $db->getQuery(true);
  12.  
  13.     $query
  14.     ->select(\'*\')
  15.     ->from($db->quoteName(\'#__categories\'))
  16.     ->where($db->quoteName(\'extension\') . \' = \' . $db->quote(\'com_content\'))
  17.     ->where($db->quoteName(\'published\') . \' = \' . $db->quote(1))
  18.     ->where($db->quoteName(\'parent_id\') . \' = \' . $db->quote($parent))
  19.     ->order($db->quoteName(\'created_time\') . \' DESC\');
  20.  
  21.     $db->setQuery($query);
  22.  
  23.     $cats = $db->loadObjectList();
  24.  
  25.     $categories = array($parent);
  26.  
  27.     foreach ($cats as $key => $cat) {
  28.         $categories[] = $cat->id;
  29.     }
  30.  
  31.     return $categories;
  32. }
  33.  
  34. function sp_latest_posts_addon($atts){
  35.  
  36.     extract(spAddonAtts(array(
  37.         "title"                 => \'\',
  38.         "heading_selector"      => \'h3\',
  39.         "title_fontsize"        => \'\',
  40.         "title_text_color"      => \'\',
  41.         "title_margin_top"      => \'\',
  42.         "title_margin_bottom"   => \'\',
  43.         "item_limit"            => \'\',
  44.         "intro_text_limit"      => \'100\',
  45.         "column_no"             => \'3\',
  46.         "category"              => \'\',
  47.         "class"                 => \'\',
  48.         ), $atts));
  49.  
  50.     //Add js
  51.     $app = JFactory::getApplication();
  52.     $doc = JFactory::getDocument();
  53.     $doc->addScript( JURI::base() . \'/templates/\' . $app->getTemplate() . \'/js/matchheight.js\' );
  54.  
  55.     // Database Query
  56.     require_once JPATH_SITE . \'/components/com_content/helpers/route.php\';
  57.  
  58.     // Access filter
  59.     $access     = !JComponentHelper::getParams(\'com_content\')->get(\'show_noauth\');
  60.     $authorised = JAccess::getAuthorisedViewLevels(JFactory::getUser()->get(\'id\'));
  61.  
  62.    
  63.     $db = JFactory::getDbo();
  64.     $query = $db->getQuery(true);
  65.  
  66.     $query
  67.      ->select(\'a.*\')
  68.      ->from($db->quoteName(\'#__content\', \'a\'))
  69.      ->select($db->quoteName(\'b.alias\', \'category_alias\'))
  70.      ->select($db->quoteName(\'b.title\', \'category\'))
  71.      ->join(\'LEFT\', $db->quoteName(\'#__categories\', \'b\') . \' ON (\' . $db->quoteName(\'a.catid\') . \' = \' . $db->quoteName(\'b.id\') . \')\')
  72.      ->where($db->quoteName(\'b.extension\') . \' = \' . $db->quote(\'com_content\'))
  73.      ->where($db->quoteName(\'a.state\') . \' = \' . $db->quote(1));
  74.      // has category
  75.      if (!empty($category)) {
  76.       $query->where($db->quoteName(\'a.catid\')." IN (" . implode( \',\', get_categories($category) ) . ")");
  77.      }
  78.     $query->where($db->quoteName(\'a.access\')." IN (" . implode( \',\', $authorised ) . ")")
  79.     ->order($db->quoteName(\'a.created\') . \' DESC\')
  80.     ->setLimit($item_limit);
  81.  
  82.  
  83.     $db->setQuery($query);
  84.  
  85.     $items = $db->loadObjectList();
  86.  
  87.     // End Database Query
  88.  
  89.     $output  = \'<div class="sppb-addon sppb-addon-latest-posts \' . $class . \'">\';
  90.  
  91.     if ($title) {
  92.         $output .= \'<div class="sppb-section-title sppb-text-center">\';
  93.             $output .= \'<\' . $heading_selector . \' class="sppb-title-heading" style="font-size:35px;line-height: 35px;font-weight:700;color:#000000;"> \' . $title . \'</\' . $heading_selector . \'>\';
  94.         $output .= \'</div>\'; // END :: title
  95.     }
  96.  
  97.     $output .= \'<div class="sppb-addon-content">\';
  98.     $output .= \'<div class="latest-posts clearfix">\';
  99.  
  100.     foreach(array_chunk($items, $column_no) as $items) {
  101.         $output .= \'<div class="sppb-row">\';
  102.         foreach ($items as $item) {
  103.  
  104.             $item->slug    = $item->id . \':\' . $item->alias;
  105.             $item->catslug = $item->catid . \':\' . $item->category_alias;
  106.             $item->user    = JFactory::getUser($item->created_by)->name;
  107.  
  108.             if ($access || in_array($item->access, $authorised))
  109.             {
  110.                 // We know that user has the privilege to view the article
  111.                 $item->link = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catid, $item->language));
  112.             }
  113.             else
  114.             {
  115.                 $item->link = JRoute::_(\'index.php?option=com_users&view=login\');
  116.             }
  117.  
  118.             $images = json_decode($item->images);
  119.  
  120.             $image = \'\';
  121.  
  122.             if (isset($images->image_intro) && !empty($images->image_intro)) {
  123.                 $image = $images->image_intro;
  124.             } elseif (isset($images->image_fulltext) && !empty($images->image_fulltext)) {
  125.                 $image = $images->image_fulltext;
  126.             }
  127.  
  128.             $output .= \'<div class="latest-post sppb-col-sm-\' . round(12/$column_no) . \'">\';
  129.  
  130.  
  131.                 $output .= \'<div class="latest-post-inner match-height">\';
  132.                 $output .= \'<div class="entry-meta"><span class="entry-date"> \' . JHtml::_(\'date\', $item->created, \'DATE_FORMAT_LC1\') . \'</span></div>\';
  133.                 $output .= \'<h2 class="entry-title"><a href="\' . $item->link . \'">\' . $item->title . \'</a></h2>\';
  134.                 //$output .= \'<p class="intro-text" >\' . truncate($item->introtext, $length=100) . \'</p>\';
  135.                 //$output .= \'<p class="intro-text" >\' . JHtml::_(\'string.truncate\', strip_tags($item->introtext), $intro_text_limit) . \'</p>\';
  136.                    
  137.                 $output .= \'<div class="post-author"> <span class="entry-author"> \' . JText::_(\'COM_SPPAGEBUILDER_ADDON_SF_POSTED_BY\'). \' \' . $item->user . \'</span> </div>\';
  138.                
  139.                 $output .= \'</div>\';
  140.            
  141.             $output .= \'</div>\';
  142.         }
  143.         $output .= \'</div>\';
  144.     }
  145.  
  146.     $output .= \'</div>\';
  147.     $output .= \'</div>\';
  148.     $output .= \'</div>\';
  149.  
  150.     return $output;
  151.  
  152. }
');