<?php ################################################################################################### # Display News 1.6.03 - July -2009 by bkomraz1@gmail.com # http://joomlacode.org/gf/project/display_news/ # Based on Display News - Latest 1-3 [07 June 2004] by Rey Gigataras [stingrey] www.stingrey.biz mambo@stingrey.biz # @ Released under GNU/GPL License : http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL ################################################################################################### defined('_JEXEC') or die('Direct Access to this location is not allowed.'); require_once dirname(__FILE__) . '/helper.php'; global $modDisplayNewsHelperRuns; if (!$modDisplayNewsHelperRuns) { $modDisplayNewsHelperRuns++; $dn = new modDisplayNewsHelper(); $dn->main($params, $module->id); $modDisplayNewsHelperRuns--; }
function main(&$params, $module_id) { if ($this->init_params($params, $module_id) === false) { return; } $app = JFactory::getApplication(); if ($app->input->get('option') === 'com_content' and $app->input->get('view') === 'article' and $this->params->get('show_on_article_page', 1) == 0) { return; } static $id = 0; $this->id = $id; $config = JFactory::getConfig(); if (version_compare($this->getShortVersion(), '3.0.0', '>=')) { $jtzoffset = $config->get('config.offset'); } else { $jtzoffset = $config->getValue('config.offset'); } $datenow = new JDate('now', $jtzoffset); if (version_compare($this->getShortVersion(), '3.0.0', '>=')) { $dbdatenow = new JDate($datenow->toSql(), $jtzoffset); } else { $dbdatenow = new JDate($datenow->toMySQL(), $jtzoffset); } $this->tzoffset = ($datenow->toUnix() - $dbdatenow->toUnix()) / 3600; if ($this->params->get('avoid_shown') == 3) { modDisplayNewsHelper::$shown_list = array(); } if ($this->params->get('video') != "") { require_once dirname(__FILE__) . '/../../plugins/content/jw_allvideos/jw_allvideos/includes/helper.php'; require dirname(__FILE__) . '/../../plugins/content/jw_allvideos/jw_allvideos/includes/sources.php'; $this->grabTags = str_replace("(", "", str_replace(")", "", implode(array_keys($tagReplace), "|"))); if ($this->params->get('video')) { jimport('joomla.html.parameter'); $jw_allvideos_plugin = JPluginHelper::getPlugin('content', "jw_allvideos"); $this->jw_allvideos_params = new JParameter($jw_allvideos_plugin->params); if ($this->params->get('vwidth')) { $this->jw_allvideos_params->set('vwidth', $this->params->get('vwidth')); } if ($this->params->get('vheight')) { $this->jw_allvideos_params->set('vheight', $this->params->get('vheight')); } if ($this->params->get('awidth')) { $this->jw_allvideos_params->set('awidth', $this->params->get('awidth')); } if ($this->params->get('aheight')) { $this->jw_allvideos_params->set('aheight', $this->params->get('aheight')); } if ($this->params->get('autoplay') != "") { $this->jw_allvideos_params->set('autoplay', $this->params->get('autoplay')); } $dispatcher = JDispatcher::getInstance(); $this->plgAllvideos = new plgContentJw_allvideos($dispatcher, $jw_allvideos_plugin->params); } } $query = $this->query(); $db = JFactory::getDBO(); $db->setQuery($query); $rows = $db->loadObjectList(); if (is_null($rows) && $this->params->get('debug')) { $jAp = JFactory::getApplication(); $jAp->enqueueMessage(nl2br($db->getErrorMsg()), 'error'); return; } ###################################################################################################################################### $rows_out = ""; $use_table = false; $mod_automore_out = ''; // Error checker, that tests whether any data has resulted from the query // If not an Error message is displayed $mod_cat_out = ""; $mod_start_out = $mod_end_out = $mod_title_out = ""; if ($rows != NULL) { // Code for displaying of individual items Section $this->import_content_plugins(); // $mod_automore_out = $this->mod_automore_out($rows[0]); $mod_title_out = $this->mod_title_out($rows[0]); $mod_cat_out = $this->params->get('show_category') == 2 ? $this->cat_out($rows[0], "") . $this->cat_desc_out($rows[0]) : ""; $mod_start_out = $this->mod_start_out(); $mod_end_out = $this->mod_end_out(); } // $mod_end_out .= "\n<!-- END '".$this->version."' -->\n"; $rows_count = count($rows); $vr = (int) (($rows_count + $this->params->get('set_column') - 1) / $this->params->get('set_column')); // Start of Loop // $k = 0; $r = 0; $c = 0; $v = 0; $sc = $this->params->get('set_column', 1); if ($this->params->get('mod_dn_style') == 'latestnews' or $this->params->get('mod_dn_style') == 'vert' or $this->params->get('mod_dn_style') == 'flat' or $this->params->get('mod_dn_style') == 'flatlist') { $sc = ceil(count($rows) / $sc); } if ($rows_count != 0) { foreach ($rows as $row) { if ($this->params->get('avoid_shown')) { modDisplayNewsHelper::$shown_list[] = $row->id; } $r++; $last = count($rows) == $r; $fc = $fr = $lc = $lr = $vc = 0; switch ($this->params->get('mod_dn_style')) { case 'tabs': case 'collapse': case 'carousel': $fc = (int) ($r == 1); break; case 'horiz': case 'blog': case 'featured': $vr = ceil($r / $sc) - 1; $vc = $r - $vr * $sc; $fc = (int) ($vc == 1); $lc = (int) ($vc == $sc or $last); break; case 'vert': case 'flat': case 'latestnews': case 'flatlist': $vc = ceil($r / $sc) - 1; $vr = $r - $vc * $sc; $fr = (int) ($vr == 1); $lr = (int) ($vr == $sc or $last); if ($lr) { $sc = ceil((count($rows) - $r + 1) / $this->params->get('set_column', 1)); } break; } $v++; $row_out = ""; $aparams = new JRegistry(); if (version_compare($this->getShortVersion(), '3.0.0', '>=')) { $aparams->loadString($row->attribs); } else { $aparams->loadJSON($row->attribs); } $croute = modDisplayNewsHelper::fixItemId(ContentHelperRoute::getCategoryRoute($row->catid), $this->params->get('item_id_cat_type'), $this->params->get('item_id_cat')); if ($this->params->get('article_link')) { $aroute = $croute; } else { $aroute = modDisplayNewsHelper::fixItemId(ContentHelperRoute::getArticleRoute($row->slug, $row->catid), $this->params->get('item_id_type'), $this->params->get('item_id')); } $row_start_out = $this->row_start_out($row, $fc, $fr, $sc, $vc, $vr); $row_end_out = $this->row_end_out($lc, $lr); // Start of Module Display for each News Item if ($this->params->get('css_type') == "table") { $k = 1 - $k; } // Code for displaying of individual items Intro Text switch ($this->params->get('show_text')) { case 0: $row->text = ""; break; case 1: $row->text = $row->introtext; break; case 2: if ($aparams->get('show_intro', $this->globalConfig->get('show_intro'))) { $row->text = $row->introtext . ' ' . $row->fulltext; } else { $row->text = $row->fulltext; } break; } if ($this->params->get('raw_data_change') != "") { eval($this->params->get('raw_data_change') . ";"); } $before_out = $this->before_out($row, $aparams); if ($this->params->get('on_prepare_content_plugins') == 1) { $this->onPrepareContent($row, $aparams); } $cat_out = $this->params->get('show_category') == 1 ? $this->cat_out($row, $croute) : ""; $cat_desc_out = $this->params->get('show_category') == 1 ? $this->cat_desc_out($row) : ""; $date_out = $this->date_out($row, $aparams); $author_out = $this->author_out($row, $aparams); if ($this->params->get('mod_dn_style') == 'collapse' or $this->params->get('mod_dn_style') == 'tabs') { $title_out = ""; } else { $title_out = $this->title_out($row, $aroute); } $hits_out = $this->hits_out($row); $rate_out = $this->rate_out($row); list($text_out, $img_out, $video_out) = $this->text_out($row, $aparams, $aroute); if ($this->params->get('on_prepare_content_plugins') == 2) { $this->onPrepareContent($row, $aparams); } $readmore_out = $this->readmore_out($row, $aroute, $aparams); $jcomments_out = $this->jcomments_out($row); $tags_out = $this->tags_out($row); if ($this->params->get('use_rows_template') == 0) { $format = $this->params->get('format', "%t<br>%s - %c<br>%d - %a<br>%b<br>%p%v%i<br>%m<div class=\"item-separator\"> </div>"); $row_out = str_replace(array("%c", "%S", "%d", "%t", "%h", "%a", "%p", "%v", "%b", "%i", "%r", "%m", "%C", "%T"), array($cat_out, $cat_desc_out, $date_out, $title_out, $hits_out, $author_out, $img_out, $video_out, $before_out, $text_out, $rate_out, $readmore_out, $jcomments_out, $tags_out), $format); } else { $style = $this->params->get('mod_dn_style'); eval("\$row_out = " . str_replace('"', '"', $this->params->get('row_template')) . ";"); } if ($this->params->get('scroll_direction') == "paging") { $row_start_out = '<script type="text/javascript">pausecontent' . $this->id . '[' . ($r - 1) . ']=\'' . str_replace(array("'", "\n", "\r"), array("\\'", "", ""), $row_start_out); $row_out = str_replace(array("'", "\n", "\r"), array("\\'", "", ""), $row_out); $row_end_out = str_replace(array("'", "\n", "\r"), array("\\'", "", ""), $row_end_out) . '\'</script> '; } $rows_out .= $row_start_out . $row_out . $row_end_out; } // foreach } else { if ($this->params->get('if_no_articles') == 0) { return; } // End of Loop // if ($this->params->get('if_no_articles') == 2) { $rows_out = $this->params->get('no_articles_message', "No articles are found!"); } } $rows_out = $mod_start_out . $rows_out . $mod_end_out; $scroll_start = $this->scroll_start(); $scroll_finish = $this->scroll_finish(); if ($this->params->get('use_module_template')) { $format = $this->params->get('module_format', "%t %c %s %r %f %m"); $out = str_replace(array("%t", "%r", "%s", "%f", "%m", "%c"), array($mod_title_out, $rows_out, $scroll_start, $scroll_finish, $mod_automore_out, $mod_cat_out), $format); } else { eval("\$out = " . str_replace('"', '"', $this->params->get('module_template')) . ";"); } echo "<!-- BEGIN '" . $this->version . "' -->" . $out . "<!-- END '" . $this->version . "' -->\n"; }