static function info($config, $item, $num = 1) { // %AUTHOR %DATE %HITS %CATEGORY $news_info = ''; // if ($num == 1) { if ($config['news_content_info_pos'] != 'disabled') { $class = 'nspInfo1 t' . $config['news_content_info_pos'] . ' f' . $config['news_content_info_float']; } } else { if ($config['news_content_info2_pos'] != 'disabled') { $class = 'nspInfo2 t' . $config['news_content_info2_pos'] . ' f' . $config['news_content_info2_float']; } } // if ($config['news_content_info_pos'] != 'disabled' && $num == 1 || $config['news_content_info2_pos'] != 'disabled' && $num == 2) { $news_info = '<p class="nspInfo ' . $class . '">' . $config['info' . ($num == 2 ? '2' : '') . '_format'] . '</p>'; // $author = trim(htmlspecialchars($item['author_alias'])) != '' ? htmlspecialchars($item['author_alias']) : htmlspecialchars($item['author_username']); $info_author = $config['user_avatar'] == 1 ? '<span><img src="' . K2HelperUtilities::getAvatar($item['author_id'], $item['author_email'], $config['avatar_size']) . '" alt="' . $author . ' - avatar" class="nspAvatar" width="' . $config['avatar_size'] . '" height="' . $config['avatar_size'] . '" /> ' . $author . '</span>' : $author; // $info_date = JHTML::_('date', $item['date'], $config['date_format']); // $info_hits = JText::_('MOD_NEWS_PRO_GK5_NHITS') . $item['hits']; $info_rate = $item['rating_count'] > 0 ? '<span class="nspRate">' . JText::_('MOD_NEWS_PRO_GK5_NSP_RATE') . ' ' . number_format($item['rating_sum'] / $item['rating_count'], 2) . '</span>' : ''; $info_category = $config['category_link'] == 1 ? '<a href="' . NSP_GK5_com_k2_View::categoryLink($item) . '" >' . $item['catname'] . '</a>' : $item['catname']; $info_comments = JText::_('MOD_NEWS_PRO_GK5_NO_COMMENTS'); // if (isset($item['comments'])) { if ($item['comments'] == 1) { $info_comments = JText::_('MOD_NEWS_PRO_GK5_1COMMENT'); } else { if ($item['comments'] > 1 && $item['comments'] < 5) { $info_comments = $item['comments'] . ' ' . JText::_('MOD_NEWS_PRO_GK5_MORECOMMENTS'); } else { if ($item['comments'] >= 5) { $info_comments = $item['comments'] . ' ' . JText::_('MOD_NEWS_PRO_GK5_MUCHMORECOMMENTS'); } } } } // $info_tags = ''; if (isset($item['tags']) && count($item['tags']) > 0) { $i = 0; foreach ($item['tags'] as $tag) { $link = urldecode(JRoute::_(K2HelperRoute::getTagRoute($tag))); if ($i == 0) { $info_tags .= '<a href="' . $link . '">' . $tag . '</a>'; } else { $info_tags .= ', <a href="' . $link . '">' . $tag . '</a>'; } // $i++; } } // $news_info = str_replace('%AUTHOR', $info_author, $news_info); $news_info = str_replace('%DATE', $info_date, $news_info); $news_info = str_replace('%HITS', $info_hits, $news_info); $news_info = str_replace('%CATEGORY', $info_category, $news_info); $news_info = str_replace('%RATE', $info_rate, $news_info); $news_info = str_replace('%COMMENTS', $info_comments, $news_info); $news_info = str_replace('%TAGS', $info_tags, $news_info); } else { return ''; } // return $news_info; }
static function info($config, $item, $num = 1) { // %AUTHOR %DATE %HITS %CATEGORY $news_info = ''; // if ($num == 1) { if ($config['news_content_info_pos'] != 'disabled') { $class = 'nspInfo1 t' . $config['news_content_info_pos'] . ' f' . $config['news_content_info_float']; } } else { if ($config['news_content_info2_pos'] != 'disabled') { $class = 'nspInfo2 t' . $config['news_content_info2_pos'] . ' f' . $config['news_content_info2_float']; } } // if ($config['news_content_info_pos'] != 'disabled' && $num == 1 || $config['news_content_info2_pos'] != 'disabled' && $num == 2) { $news_info_tag = stripos($config['info' . ($num == 2 ? '2' : '') . '_format'], '%CART') !== FALSE ? 'div' : 'p'; $news_info = '<' . $news_info_tag . ' class="nspInfo ' . $class . '">' . $config['info' . ($num == 2 ? '2' : '') . '_format'] . '</' . $news_info_tag . '>'; // $author = trim(htmlspecialchars($item['author_alias'])) != '' ? htmlspecialchars($item['author_alias']) : htmlspecialchars($item['author_username']); $info_author = $config['user_avatar'] == 1 ? '<span><img src="' . K2HelperUtilities::getAvatar($item['author_id'], $item['author_email'], $config['avatar_size']) . '" alt="' . $author . ' - avatar" class="nspAvatar" width="' . $config['avatar_size'] . '" height="' . $config['avatar_size'] . '" /> ' . $author . '</span>' : $author; // $info_date = JHTML::_('date', $item['date'], $config['date_format']); // $info_hits = JText::_('MOD_NEWS_PRO_GK5_NHITS') . $item['hits']; // case when there is no rates if ($item['rating_count'] == 0) { $item['rating_count'] = 1; } $info_rate = $item['rating_count'] > 0 ? '<span class="nspRate">' . JText::_('MOD_NEWS_PRO_GK5_NSP_RATE') . ' ' . number_format($item['rating_sum'] / $item['rating_count'], 2) . '</span>' : ''; $info_stars = '<span class="nsp-stars">'; $stars_count = floor($item['rating_sum'] / $item['rating_count']); for ($i = 0; $i < 5; $i++) { $info_stars .= $i < $stars_count ? '<span class="nsp-star-1"></span>' : '<span class="nsp-star-0"></span>'; } $info_stars .= '</span>'; $info_category = $config['category_link'] == 1 ? '<a href="' . NSP_GK5_com_k2_View::categoryLink($item) . '" >' . $item['catname'] . '</a>' : $item['catname']; $info_comments = JText::_('MOD_NEWS_PRO_GK5_NO_COMMENTS'); // if (isset($item['comments'])) { if ($item['comments'] == 1) { $info_comments = JText::_('MOD_NEWS_PRO_GK5_1COMMENT'); } else { if ($item['comments'] > 1 && $item['comments'] < 5) { $info_comments = $item['comments'] . ' ' . JText::_('MOD_NEWS_PRO_GK5_MORECOMMENTS'); } else { if ($item['comments'] >= 5) { $info_comments = $item['comments'] . ' ' . JText::_('MOD_NEWS_PRO_GK5_MUCHMORECOMMENTS'); } } } } // $info_comments_short = '0'; $link = NSP_GK5_com_k2_View::itemLink($item); // if (isset($item['comments'])) { $info_comments_short = $item['comments']; } $info_comments_short = '<a href="' . $link . '">' . $info_comments_short . '</a>'; // $info_tags = ''; if (isset($item['tags']) && count($item['tags']) > 0) { $i = 0; foreach ($item['tags'] as $tag) { $link = urldecode(JRoute::_(K2HelperRoute::getTagRoute($tag))); if ($i == 0) { $info_tags .= '<a href="' . $link . '">' . $tag . '</a>'; } else { $info_tags .= ', <a href="' . $link . '">' . $tag . '</a>'; } // $i++; } } // get k2 store data $k2store_data = array('cart' => '', 'price' => ''); // get K2Store data if necessary if (stripos($news_info, '%CART') !== FALSE || stripos($news_info, '%PRICE') !== FALSE) { $k2store_data = NSP_GK5_com_k2_View::k2Store($item); if (stripos($news_info, '%CART') !== FALSE) { // load K2Store scripts $uri = JURI::getInstance(); $document = JFactory::getDocument(); $headData = $document->getHeadData(); // generate keys of script section $headData_keys = array_keys($headData["scripts"]); // set variable for false $engine_founded = false; // searching phrase mootools in scripts paths if (array_search($uri->root() . 'media/k2store/js/k2store.js', $headData_keys) > 0) { $engine_founded = true; } // if engine doesn't exists in the head section if (!$engine_founded) { // add new script tag connected with mootools from module $document->addScript($uri->root() . 'media/k2store/js/k2store.noconflict.js'); $document->addScript($uri->root() . 'media/k2store/js/k2store.js'); } } } // $news_info = str_replace('%AUTHOR', $info_author, $news_info); $news_info = str_replace('%DATE', $info_date, $news_info); $news_info = str_replace('%HITS', $info_hits, $news_info); $news_info = str_replace('%CATEGORY', $info_category, $news_info); $news_info = str_replace('%STARS', $info_stars, $news_info); $news_info = str_replace('%RATE', $info_rate, $news_info); $news_info = str_replace('%COMMENTS_SHORT', $info_comments_short, $news_info); $news_info = str_replace('%COMMENTS', $info_comments, $news_info); $news_info = str_replace('%TAGS', $info_tags, $news_info); $news_info = str_replace('%CART', $k2store_data['cart'], $news_info); $news_info = str_replace('%PRICE', $k2store_data['price'], $news_info); } else { return ''; } // return $news_info; }