XoopsModules25x /
news
| 1 | <?php |
||
| 2 | /* |
||
| 3 | * You may not change or alter any portion of this comment or credits |
||
| 4 | * of supporting developers from this source code or any supporting source code |
||
| 5 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 6 | * |
||
| 7 | * This program is distributed in the hope that it will be useful, |
||
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 10 | */ |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||
| 14 | * @license {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
||
| 15 | * @package |
||
| 16 | * @since |
||
| 17 | * @author XOOPS Development Team |
||
| 18 | */ |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Article's page |
||
| 22 | * |
||
| 23 | * This page is used to see an article (or story) and is mainly called from |
||
| 24 | * the module's index page. |
||
| 25 | * |
||
| 26 | * If no story Id has been placed on the URL or if the story is not yet published |
||
| 27 | * then the page will redirect user to the module's index. |
||
| 28 | * If the user does not have the permissions to see the article, he is also redirected |
||
| 29 | * to the module's index page but with a error message saying : |
||
| 30 | * "Sorry, you don't have the permission to access this area" |
||
| 31 | * |
||
| 32 | * Each time a page is seen, and only if we are on the first page, its counter of hits is |
||
| 33 | * updated |
||
| 34 | * |
||
| 35 | * Each file(s) attached to the article is visible at the bottom of the article and can |
||
| 36 | * be downloaded |
||
| 37 | * |
||
| 38 | * Notes : |
||
| 39 | * - To create more than one page in your story, use the tag [pagebreak] |
||
| 40 | * - If you are a module's admin, you have the possibility to see two links at the bottom |
||
| 41 | * of the article, "Edit & Delete" |
||
| 42 | * |
||
| 43 | * @param int storyid Id of the story we want to see |
||
| 44 | * @param int page page's number (in the case where there are more than one page) |
||
| 45 | * |
||
| 46 | * @page_title Article's title - Topic's title - Module's name |
||
| 47 | * |
||
| 48 | * @template_name news_article.html wich will call news_item.html |
||
| 49 | * |
||
| 50 | * Template's variables : |
||
| 51 | * @template_var string pagenav some links to navigate thru pages |
||
| 52 | * @template_var array story Contains all the information about the story |
||
| 53 | * Structure : |
||
| 54 | * @template_var int id Story's ID |
||
| 55 | * @template_var string posttime Story's date of publication |
||
| 56 | * @template_var string title A link to go and see all the articles in the same topic and the story's title |
||
| 57 | * @template_var string news_title Just the news title |
||
| 58 | * @template_var string topic_title Just the topic's title |
||
| 59 | * @template_var string text Defined as "The scoop" |
||
| 60 | * @template_var string poster A link to see the author's profil and his name or "Anonymous" |
||
| 61 | * @template_var int posterid Author's uid (or 0 if it's an anonymous or a user wich does not exist any more) |
||
| 62 | * @template_var string morelink Never used ???? May be it could be deleted |
||
| 63 | * @template_var string adminlink A link to Edit or Delete the story or a blank string if you are not the module's admin |
||
| 64 | * @template_var string topicid News topic's Id |
||
| 65 | * @template_var string topic_color Topic's color |
||
| 66 | * @template_var string imglink A link to go and see the topic of the story with the topic's picture (if it exists) |
||
| 67 | * @template_var string align Topic's image alignement |
||
| 68 | * @template_var int hits Story's counter of visits |
||
| 69 | * @template_var string mail_link A link (with a mailto) to email the story's URL to someone |
||
| 70 | * @template_var string lang_printerpage Used in the link and picture to have a "printable version" (fixed text) |
||
| 71 | * @template_var string lang_on Fixed text "On" ("published on") |
||
| 72 | * @template_var string lang_postedby Fixed text "Posted by" |
||
| 73 | * @template_var string lang_reads Fixed text "Reads" |
||
| 74 | * @template_var string news_by_the_same_author_link According the the module's option named "newsbythisauthor", it contains a link to see all the article's stories |
||
| 75 | * @template_var int summary_count Number of stories really visibles in the summary table |
||
| 76 | * @template_var boolean showsummary According to the module's option named "showsummarytable", this contains "True" of "False" |
||
| 77 | * @template_var array summary Contains the required information to create a summary table at the bottom of the article. Note, we use the module's option "storyhome" to determine the maximum number of stories visibles in this summary table |
||
| 78 | * Structure : |
||
| 79 | * @template_var int story_id Story's ID |
||
| 80 | * @template_var string story_title Story's title |
||
| 81 | * @template_var int story_hits Counter of hits |
||
| 82 | * @template_var string story_published Story's date of creation |
||
| 83 | * @template_var string lang_attached_files Fixed text "Attached Files:" |
||
| 84 | * @template_var int attached_files_count Number of files attached to the story |
||
| 85 | * @template_var array attached_files Contains the list of all the files attached to the story |
||
| 86 | * Structure : |
||
| 87 | * @template_var int file_id File's ID |
||
| 88 | * @template_var string visitlink Link to download the file |
||
| 89 | * @template_var string file_realname Original filename (not the real one use to store the file but the one it have when it was on the user hard disk) |
||
| 90 | * @template_var string file_attacheddate Date to wich the file was attached to the story (in general that's equal to the article's creation date) |
||
| 91 | * @template_var string file_mimetype File's mime type |
||
| 92 | * @template_var string file_downloadname Real name of the file on the webserver's disk (changed by the module) |
||
| 93 | * @template_var boolean nav_links According to the module's option named "showprevnextlink" it contains "True" or "False" to know if we have to show two links to go to the previous and next article |
||
| 94 | * @template_var int previous_story_id Id of the previous story (according to the published date and to the perms) |
||
| 95 | * @template_var int next_story_id Id of the next story (according to the published date and to the perms) |
||
| 96 | * @template_var string previous_story_title Title of the previous story |
||
| 97 | * @template_var string next_story_title Title of the next story |
||
| 98 | * @template_var string lang_previous_story Fixed text "Previous article" |
||
| 99 | * @template_var string lang_next_story Fixed text "Next article" |
||
| 100 | * @template_var string lang_other_story Fixed text "Other articles" |
||
| 101 | * @template_var boolean rates To know if rating is enable or not |
||
| 102 | * @template_var string lang_ratingc Fixed text "Rating: " |
||
| 103 | * @template_var string lang_ratethisnews Fixed text "Rate this News" |
||
| 104 | * @template_var float rating Article's rating |
||
| 105 | * @template_var string votes "1 vote" or "X votes" |
||
| 106 | * @template_var string topic_path A path from the root to the current topic (of the current news) |
||
| 107 | * @copyright (c) XOOPS Project (https://xoops.org) |
||
| 108 | * |
||
| 109 | * Parameters received by this page : |
||
| 110 | * |
||
| 111 | * @package News |
||
| 112 | * @author Xoops Modules Dev Team |
||
| 113 | */ |
||
| 114 | |||
| 115 | use Xmf\Request; |
||
| 116 | use XoopsModules\News; |
||
| 117 | use XoopsModules\News\Files; |
||
| 118 | use XoopsModules\News\Keyhighlighter; |
||
| 119 | use XoopsModules\News\NewsStory; |
||
| 120 | |||
| 121 | require_once dirname(__DIR__, 2) . '/mainfile.php'; |
||
| 122 | //require_once XOOPS_ROOT_PATH . '/modules/news/class/class.newsstory.php'; |
||
| 123 | //require_once XOOPS_ROOT_PATH . '/modules/news/class/class.sfiles.php'; |
||
| 124 | //require_once XOOPS_ROOT_PATH . '/modules/news/class/tree.php'; |
||
| 125 | //; |
||
| 126 | //require_once XOOPS_ROOT_PATH . '/modules/news/class/class.newstopic.php'; |
||
| 127 | //require_once XOOPS_ROOT_PATH . '/modules/news/class/Keyhighlighter.php'; |
||
| 128 | require_once XOOPS_ROOT_PATH . '/modules/news/config.php'; |
||
| 129 | |||
| 130 | /** @var News\Helper $helper */ |
||
| 131 | $helper = News\Helper::getInstance(); |
||
| 132 | |||
| 133 | $storyid = Request::getInt('storyid', 0, 'GET'); |
||
| 134 | |||
| 135 | if (empty($storyid)) { |
||
| 136 | redirect_header(XOOPS_URL . '/modules/news/index.php', 2, _NW_NOSTORY); |
||
| 137 | } |
||
| 138 | |||
| 139 | $myts = \MyTextSanitizer::getInstance(); |
||
| 140 | |||
| 141 | // Not yet published |
||
| 142 | $article = new NewsStory($storyid); |
||
| 143 | if (0 == $article->published() || $article->published() > time()) { |
||
| 144 | redirect_header(XOOPS_URL . '/modules/news/index.php', 2, _NW_NOTYETSTORY); |
||
| 145 | } |
||
| 146 | // Expired |
||
| 147 | if (0 != $article->expired() && $article->expired() < time()) { |
||
| 148 | redirect_header(XOOPS_URL . '/modules/news/index.php', 2, _NW_NOSTORY); |
||
| 149 | } |
||
| 150 | |||
| 151 | /** @var \XoopsGroupPermHandler $grouppermHandler */ |
||
| 152 | $grouppermHandler = xoops_getHandler('groupperm'); |
||
| 153 | if (is_object($xoopsUser)) { |
||
| 154 | $groups = $xoopsUser->getGroups(); |
||
| 155 | } else { |
||
| 156 | $groups = XOOPS_GROUP_ANONYMOUS; |
||
| 157 | } |
||
| 158 | if (!$grouppermHandler->checkRight('news_view', $article->topicid(), $groups, $xoopsModule->getVar('mid'))) { |
||
| 159 | redirect_header(XOOPS_URL . '/modules/news/index.php', 3, _NOPERM); |
||
| 160 | } |
||
| 161 | |||
| 162 | $storypage = Request::getInt('page', 0, 'GET'); |
||
| 163 | $dateformat = News\Utility::getModuleOption('dateformat'); |
||
| 164 | $hcontent = ''; |
||
| 165 | |||
| 166 | /** |
||
| 167 | * update counter only when viewing top page and when you are not the author or an admin |
||
| 168 | */ |
||
| 169 | if (empty($_GET['com_id']) && 0 == $storypage) { |
||
| 170 | if (is_object($xoopsUser)) { |
||
| 171 | if (($xoopsUser->getVar('uid') == $article->uid()) || News\Utility::isAdminGroup()) { |
||
| 172 | // nothing ! ;-) |
||
| 173 | } else { |
||
| 174 | $article->updateCounter(); |
||
| 175 | } |
||
| 176 | } else { |
||
| 177 | $article->updateCounter(); |
||
| 178 | } |
||
| 179 | } |
||
| 180 | $GLOBALS['xoopsOption']['template_main'] = 'news_article.tpl'; |
||
| 181 | require_once XOOPS_ROOT_PATH . '/header.php'; |
||
| 182 | |||
| 183 | $story['id'] = $storyid; |
||
| 184 | $story['posttime'] = formatTimestamp($article->published(), $dateformat); |
||
| 185 | $story['news_title'] = $article->title(); |
||
| 186 | $story['title'] = $article->textlink() . ' : ' . $article->title(); |
||
| 187 | $story['subtitle'] = $article->subtitle(); |
||
| 188 | $story['topic_title'] = $article->textlink(); |
||
| 189 | |||
| 190 | $story['text'] = $article->hometext(); |
||
| 191 | $bodytext = $article->bodytext(); |
||
| 192 | |||
| 193 | if ('' !== xoops_trim($bodytext)) { |
||
| 194 | $articletext = []; |
||
| 195 | if (News\Utility::getModuleOption('enhanced_pagenav')) { |
||
| 196 | $articletext = preg_split('/(\[pagebreak:|\[pagebreak)(.*)(\])/iU', $bodytext); |
||
| 197 | $arr_titles = []; |
||
| 198 | $auto_summary = $article->auto_summary($bodytext, $arr_titles); |
||
| 199 | $bodytext = str_replace('[summary]', $auto_summary, $bodytext); |
||
| 200 | $articletext[$storypage] = str_replace('[summary]', $auto_summary, $articletext[$storypage]); |
||
| 201 | $story['text'] = str_replace('[summary]', $auto_summary, $story['text']); |
||
| 202 | } else { |
||
| 203 | $articletext = explode('[pagebreak]', $bodytext); |
||
| 204 | } |
||
| 205 | |||
| 206 | $story_pages = count($articletext); |
||
| 207 | |||
| 208 | if ($story_pages > 1) { |
||
| 209 | require_once XOOPS_ROOT_PATH . '/modules/news/include/pagenav.php'; |
||
| 210 | $pagenav = new \XoopsPageNav($story_pages, 1, $storypage, 'page', 'storyid=' . $storyid); |
||
| 211 | if (News\Utility::isBot()) { // A bot is reading the articles, we are going to show him all the links to the pages |
||
| 212 | $xoopsTpl->assign('pagenav', $pagenav->renderNav($story_pages)); |
||
| 213 | } elseif (News\Utility::getModuleOption('enhanced_pagenav')) { |
||
| 214 | $xoopsTpl->assign('pagenav', $pagenav->renderEnhancedSelect(true, $arr_titles)); |
||
| 215 | } else { |
||
| 216 | $xoopsTpl->assign('pagenav', $pagenav->renderNav()); |
||
| 217 | } |
||
| 218 | |||
| 219 | if (0 == $storypage) { |
||
| 220 | $story['text'] = $story['text'] . '<br>' . News\Utility::getModuleOption('advertisement') . '<br>' . $articletext[$storypage]; |
||
| 221 | } else { |
||
| 222 | $story['text'] = $articletext[$storypage]; |
||
| 223 | } |
||
| 224 | } else { |
||
| 225 | $story['text'] = $story['text'] . '<br>' . News\Utility::getModuleOption('advertisement') . '<br>' . $bodytext; |
||
| 226 | } |
||
| 227 | } |
||
| 228 | // Publicit� |
||
| 229 | $xoopsTpl->assign('advertisement', News\Utility::getModuleOption('advertisement')); |
||
| 230 | |||
| 231 | // **************************************************************************************************************** |
||
| 232 | /** |
||
| 233 | * @param $matches |
||
| 234 | * |
||
| 235 | * @return string |
||
| 236 | */ |
||
| 237 | function my_highlighter($matches) |
||
| 238 | { |
||
| 239 | $color = News\Utility::getModuleOption('highlightcolor'); |
||
| 240 | if (0 !== mb_strpos($color, '#')) { |
||
| 241 | $color = '#' . $color; |
||
| 242 | } |
||
| 243 | |||
| 244 | return '<span style="font-weight: bolder; background-color: ' . $color . ';">' . $matches[0] . '</span>'; |
||
| 245 | } |
||
| 246 | |||
| 247 | $highlight = false; |
||
| 248 | $highlight = News\Utility::getModuleOption('keywordshighlight'); |
||
| 249 | |||
| 250 | if ($highlight && isset($_GET['keywords'])) { |
||
| 251 | $keywords = htmlspecialchars(trim(urldecode($_GET['keywords'])), ENT_QUOTES | ENT_HTML5); |
||
| 252 | $h = new Keyhighlighter($keywords, true, 'my_highlighter'); |
||
| 253 | $story['text'] = $h->highlight($story['text']); |
||
| 254 | } |
||
| 255 | // **************************************************************************************************************** |
||
| 256 | |||
| 257 | $story['poster'] = $article->uname(); |
||
| 258 | if ($story['poster']) { |
||
| 259 | $story['posterid'] = $article->uid(); |
||
| 260 | $story['poster'] = '<a href="' . XOOPS_URL . '/userinfo.php?uid=' . $story['posterid'] . '">' . $story['poster'] . '</a>'; |
||
| 261 | $tmp_user = new \XoopsUser($article->uid()); |
||
| 262 | $story['poster_avatar'] = XOOPS_UPLOAD_URL . '/' . $tmp_user->getVar('user_avatar'); |
||
| 263 | $story['poster_signature'] = $tmp_user->getVar('user_sig'); |
||
| 264 | $story['poster_email'] = $tmp_user->getVar('email'); |
||
| 265 | $story['poster_url'] = $tmp_user->getVar('url'); |
||
| 266 | $story['poster_from'] = $tmp_user->getVar('user_from'); |
||
| 267 | unset($tmp_user); |
||
| 268 | } else { |
||
| 269 | $story['poster'] = ''; |
||
| 270 | $story['posterid'] = 0; |
||
| 271 | $story['poster_avatar'] = ''; |
||
| 272 | $story['poster_signature'] = ''; |
||
| 273 | $story['poster_email'] = ''; |
||
| 274 | $story['poster_url'] = ''; |
||
| 275 | $story['poster_from'] = ''; |
||
| 276 | if (3 != News\Utility::getModuleOption('displayname')) { |
||
| 277 | $story['poster'] = $xoopsConfig['anonymous']; |
||
| 278 | } |
||
| 279 | } |
||
| 280 | $story['morelink'] = ''; |
||
| 281 | $story['adminlink'] = ''; |
||
| 282 | unset($isadmin); |
||
| 283 | |||
| 284 | if (is_object($xoopsUser)) { |
||
| 285 | if ($xoopsUser->isAdmin($xoopsModule->getVar('mid')) |
||
| 286 | || (News\Utility::getModuleOption('authoredit') |
||
| 287 | && $article->uid() == $xoopsUser->getVar('uid'))) { |
||
| 288 | $isadmin = true; |
||
| 289 | // $story['adminlink'] = $article->adminlink(); |
||
| 290 | } |
||
| 291 | } |
||
| 292 | $story['topicid'] = $article->topicid(); |
||
| 293 | $story['topic_color'] = '#' . $myts->displayTarea($article->topic_color); |
||
| 294 | |||
| 295 | $story['imglink'] = ''; |
||
| 296 | $story['align'] = ''; |
||
| 297 | if ($article->topicdisplay()) { |
||
| 298 | $story['imglink'] = $article->imglink(); |
||
| 299 | $story['align'] = $article->topicalign(); |
||
| 300 | } |
||
| 301 | $story['hits'] = $article->counter(); |
||
| 302 | $story['mail_link'] = 'mailto:?subject=' . sprintf(_NW_INTARTICLE, $xoopsConfig['sitename']) . '&body=' . sprintf(_NW_INTARTFOUND, $xoopsConfig['sitename']) . ': ' . XOOPS_URL . '/modules/news/article.php?storyid=' . $article->storyid(); |
||
| 303 | $xoopsTpl->assign('lang_printerpage', _NW_PRINTERFRIENDLY); |
||
| 304 | $xoopsTpl->assign('lang_sendstory', _NW_SENDSTORY); |
||
| 305 | $xoopsTpl->assign('lang_pdfstory', _NW_MAKEPDF); |
||
| 306 | $xoopsTpl->assign('lang_on', _ON); |
||
| 307 | $xoopsTpl->assign('lang_postedby', _POSTEDBY); |
||
| 308 | $xoopsTpl->assign('lang_reads', _READS); |
||
| 309 | $xoopsTpl->assign('mail_link', 'mailto:?subject=' . sprintf(_NW_INTARTICLE, $xoopsConfig['sitename']) . '&body=' . sprintf(_NW_INTARTFOUND, $xoopsConfig['sitename']) . ': ' . XOOPS_URL . '/modules/news/article.php?storyid=' . $article->storyid()); |
||
| 310 | |||
| 311 | if ('' !== xoops_trim($article->picture())) { |
||
| 312 | $story['picture'] = XOOPS_URL . '/uploads/news/image/' . $article->picture(); |
||
| 313 | $story['pictureinfo'] = $article->pictureinfo(); |
||
| 314 | } else { |
||
| 315 | $story['picture'] = ''; |
||
| 316 | $story['pictureinfo'] = ''; |
||
| 317 | } |
||
| 318 | |||
| 319 | $xoopsTpl->assign('lang_attached_files', _NW_ATTACHEDFILES); |
||
| 320 | $sfiles = new Files(); |
||
| 321 | $filesarr = $newsfiles = []; |
||
| 322 | $filesarr = $sfiles->getAllbyStory($storyid); |
||
| 323 | $filescount = count($filesarr); |
||
| 324 | $xoopsTpl->assign('attached_files_count', $filescount); |
||
| 325 | if ($filescount > 0) { |
||
| 326 | foreach ($filesarr as $onefile) { |
||
| 327 | $newsfiles[] = [ |
||
| 328 | 'file_id' => $onefile->getFileid(), |
||
| 329 | 'visitlink' => XOOPS_URL . '/modules/news/visit.php?fileid=' . $onefile->getFileid(), |
||
| 330 | 'file_realname' => $onefile->getFileRealName(), |
||
| 331 | 'file_attacheddate' => formatTimestamp($onefile->getDate(), $dateformat), |
||
| 332 | 'file_mimetype' => $onefile->getMimetype(), |
||
| 333 | 'file_downloadname' => XOOPS_UPLOAD_URL . '/' . $onefile->getDownloadname(), |
||
| 334 | ]; |
||
| 335 | } |
||
| 336 | $xoopsTpl->assign('attached_files', $newsfiles); |
||
| 337 | } |
||
| 338 | |||
| 339 | /** |
||
| 340 | * Create page's title |
||
| 341 | */ |
||
| 342 | $complement = ''; |
||
| 343 | if (News\Utility::getModuleOption('enhanced_pagenav') |
||
| 344 | && (isset($arr_titles) && is_array($arr_titles) |
||
| 345 | && isset($arr_titles, $storypage) |
||
| 346 | && $storypage > 0)) { |
||
| 347 | $complement = ' - ' . $arr_titles[$storypage]; |
||
| 348 | } |
||
| 349 | $xoopsTpl->assign('xoops_pagetitle', $article->title() . $complement . ' - ' . $article->topic_title() . ' - ' . $xoopsModule->name('s')); |
||
| 350 | |||
| 351 | if (News\Utility::getModuleOption('newsbythisauthor')) { |
||
| 352 | $xoopsTpl->assign('news_by_the_same_author_link', sprintf("<a href='%s?uid=%d'>%s</a>", XOOPS_URL . '/modules/news/newsbythisauthor.php', $article->uid(), _NW_NEWSSAMEAUTHORLINK)); |
||
| 353 | } |
||
| 354 | |||
| 355 | /** |
||
| 356 | * Create a clickable path from the root to the current topic (if we are viewing a topic) |
||
| 357 | * Actually this is not used in the default's templates but you can use it as you want |
||
| 358 | * Uncomment the code to be able to use it |
||
| 359 | */ |
||
| 360 | if ($cfg['create_clickable_path']) { |
||
| 361 | $mytree = new \XoopsModules\News\ObjectTree($xoopsDB->prefix('news_topics'), 'topic_id', 'topic_pid'); |
||
| 362 | $topicpath = $mytree->getNicePathFromId($article->topicid(), 'topic_title', 'index.php?op=1'); |
||
| 363 | $xoopsTpl->assign('topic_path', $topicpath); |
||
| 364 | unset($mytree); |
||
| 365 | } |
||
| 366 | |||
| 367 | /** |
||
| 368 | * Summary table |
||
| 369 | * |
||
| 370 | * When you are viewing an article, you can see a summary table containing |
||
| 371 | * the first n links to the last published news. |
||
| 372 | * This summary table is visible according to a module's option (showsummarytable) |
||
| 373 | * The number of items is equal to the module's option "storyhome" ("Select the number |
||
| 374 | * of news items to display on top page") |
||
| 375 | * We also use the module's option "restrictindex" ("Restrict Topics on Index Page"), like |
||
| 376 | * this you (the webmaster) select if users can see restricted stories or not. |
||
| 377 | */ |
||
| 378 | if (News\Utility::getModuleOption('showsummarytable')) { |
||
| 379 | $xoopsTpl->assign('showsummary', true); |
||
| 380 | $xoopsTpl->assign('lang_other_story', _NW_OTHER_ARTICLES); |
||
| 381 | $count = 0; |
||
| 382 | $tmparticle = new NewsStory(); |
||
| 383 | $infotips = News\Utility::getModuleOption('infotips'); |
||
| 384 | $sarray = NewsStory::getAllPublished($cfg['article_summary_items_count'], 0, $helper->getConfig('restrictindex')); |
||
| 385 | if (count($sarray) > 0) { |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 386 | foreach ($sarray as $onearticle) { |
||
| 387 | ++$count; |
||
| 388 | $htmltitle = ''; |
||
| 389 | $tooltips = ''; |
||
| 390 | $htmltitle = ''; |
||
| 391 | if ($infotips > 0) { |
||
| 392 | $tooltips = News\Utility::makeInfotips($onearticle->hometext()); |
||
| 393 | $htmltitle = ' title="' . $tooltips . '"'; |
||
| 394 | } |
||
| 395 | $xoopsTpl->append( |
||
| 396 | 'summary', |
||
| 397 | [ |
||
| 398 | 'story_id' => $onearticle->storyid(), |
||
| 399 | 'htmltitle' => $htmltitle, |
||
| 400 | 'infotips' => $tooltips, |
||
| 401 | 'story_title' => $onearticle->title(), |
||
| 402 | 'story_hits' => $onearticle->counter(), |
||
| 403 | 'story_published' => formatTimestamp($onearticle->published, $dateformat), |
||
| 404 | ] |
||
| 405 | ); |
||
| 406 | } |
||
| 407 | } |
||
| 408 | $xoopsTpl->assign('summary_count', $count); |
||
| 409 | unset($tmparticle); |
||
| 410 | } else { |
||
| 411 | $xoopsTpl->assign('showsummary', false); |
||
| 412 | } |
||
| 413 | |||
| 414 | /** |
||
| 415 | * Show a link to go to the previous article and to the next article |
||
| 416 | * |
||
| 417 | * According to a module's option "showprevnextlink" ("Show Previous and Next link?") |
||
| 418 | * you can display, at the bottom of each article, two links used to navigate thru stories. |
||
| 419 | * This feature uses the module's option "restrictindex" so that we can, or can't see |
||
| 420 | * restricted stories |
||
| 421 | */ |
||
| 422 | if (News\Utility::getModuleOption('showprevnextlink')) { |
||
| 423 | $xoopsTpl->assign('nav_links', true); |
||
| 424 | $tmparticle = new NewsStory(); |
||
| 425 | $nextId = $previousId = -1; |
||
| 426 | $next = $previous = []; |
||
| 427 | $previousTitle = $nextTitle = ''; |
||
| 428 | |||
| 429 | $next = $tmparticle->getNextArticle($storyid, $helper->getConfig('restrictindex')); |
||
| 430 | if (count($next) > 0) { |
||
| 431 | $nextId = $next['storyid']; |
||
| 432 | $nextTitle = $next['title']; |
||
| 433 | } |
||
| 434 | |||
| 435 | $previous = $tmparticle->getPreviousArticle($storyid, $helper->getConfig('restrictindex')); |
||
| 436 | if (count($previous) > 0) { |
||
| 437 | $previousId = $previous['storyid']; |
||
| 438 | $previousTitle = $previous['title']; |
||
| 439 | } |
||
| 440 | |||
| 441 | $xoopsTpl->assign('previous_story_id', $previousId); |
||
| 442 | $xoopsTpl->assign('next_story_id', $nextId); |
||
| 443 | if ($previousId > 0) { |
||
| 444 | $xoopsTpl->assign('previous_story_title', $previousTitle); |
||
| 445 | $hcontent .= sprintf("<link rel=\"Prev\" title=\"%s\" href=\"%s/\">\n", $previousTitle, XOOPS_URL . '/modules/news/article.php?storyid=' . $previousId); |
||
| 446 | } |
||
| 447 | |||
| 448 | if ($nextId > 0) { |
||
| 449 | $xoopsTpl->assign('next_story_title', $nextTitle); |
||
| 450 | $hcontent .= sprintf("<link rel=\"Next\" title=\"%s\" href=\"%s/\">\n", $nextTitle, XOOPS_URL . '/modules/news/article.php?storyid=' . $nextId); |
||
| 451 | } |
||
| 452 | $xoopsTpl->assign('lang_previous_story', _NW_PREVIOUS_ARTICLE); |
||
| 453 | $xoopsTpl->assign('lang_next_story', _NW_NEXT_ARTICLE); |
||
| 454 | unset($tmparticle); |
||
| 455 | } else { |
||
| 456 | $xoopsTpl->assign('nav_links', false); |
||
| 457 | } |
||
| 458 | |||
| 459 | /** |
||
| 460 | * Manage all the meta datas |
||
| 461 | */ |
||
| 462 | News\Utility::createMetaDatas($article); |
||
| 463 | |||
| 464 | /** |
||
| 465 | * Show a "Bookmark this article at these sites" block ? |
||
| 466 | */ |
||
| 467 | if (News\Utility::getModuleOption('bookmarkme')) { |
||
| 468 | $xoopsTpl->assign('bookmarkme', true); |
||
| 469 | $xoopsTpl->assign('encoded_title', rawurlencode($article->title())); |
||
| 470 | } else { |
||
| 471 | $xoopsTpl->assign('bookmarkme', false); |
||
| 472 | } |
||
| 473 | |||
| 474 | /** |
||
| 475 | * Use Facebook Comments Box? |
||
| 476 | */ |
||
| 477 | if (News\Utility::getModuleOption('fbcomments')) { |
||
| 478 | $xoopsTpl->assign('fbcomments', true); |
||
| 479 | } else { |
||
| 480 | $xoopsTpl->assign('fbcomments', false); |
||
| 481 | } |
||
| 482 | |||
| 483 | /** |
||
| 484 | * Enable users to vote |
||
| 485 | * |
||
| 486 | * According to a module's option, "ratenews", you can display a link to rate the current news |
||
| 487 | * The actual rate in showed (and the number of votes) |
||
| 488 | * Possible modification, restrict votes to registred users |
||
| 489 | */ |
||
| 490 | $other_test = true; |
||
| 491 | if ($cfg['config_rating_registred_only']) { |
||
| 492 | if (isset($xoopsUser) && is_object($xoopsUser)) { |
||
| 493 | $other_test = true; |
||
| 494 | } else { |
||
| 495 | $other_test = false; |
||
| 496 | } |
||
| 497 | } |
||
| 498 | |||
| 499 | if (News\Utility::getModuleOption('ratenews') && $other_test) { |
||
| 500 | $xoopsTpl->assign('rates', true); |
||
| 501 | $xoopsTpl->assign('lang_ratingc', _NW_RATINGC); |
||
| 502 | $xoopsTpl->assign('lang_ratethisnews', _NW_RATETHISNEWS); |
||
| 503 | $story['rating'] = number_format($article->rating(), 2); |
||
| 504 | if (1 == $article->votes) { |
||
| 505 | $story['votes'] = _NW_ONEVOTE; |
||
| 506 | } else { |
||
| 507 | $story['votes'] = sprintf(_NW_NUMVOTES, $article->votes); |
||
| 508 | } |
||
| 509 | } else { |
||
| 510 | $xoopsTpl->assign('rates', false); |
||
| 511 | } |
||
| 512 | |||
| 513 | $xoopsTpl->assign('story', $story); |
||
| 514 | |||
| 515 | // Added in version 1.63, TAGS |
||
| 516 | if (xoops_isActiveModule('tag') && News\Utility::getModuleOption('tags')) { |
||
| 517 | require_once XOOPS_ROOT_PATH . '/modules/tag/include/tagbar.php'; |
||
| 518 | $xoopsTpl->assign('tags', true); |
||
| 519 | $xoopsTpl->assign('tagbar', tagBar($storyid, 0)); |
||
| 520 | } else { |
||
| 521 | $xoopsTpl->assign('tags', false); |
||
| 522 | } |
||
| 523 | |||
| 524 | $xoopsTpl->assign('share', $helper->getConfig('share')); |
||
| 525 | $xoopsTpl->assign('showicons', $helper->getConfig('showicons')); |
||
| 526 | |||
| 527 | $canPdf = 1; |
||
| 528 | if (!is_object($GLOBALS['xoopsUser']) && 0 == $helper->getConfig('show_pdficon')) { |
||
| 529 | $canPdf = 0; |
||
| 530 | } |
||
| 531 | $xoopsTpl->assign('showPdfIcon', $canPdf); |
||
| 532 | |||
| 533 | if (1 == News\Utility::getModuleOption('displaytopictitle')) { |
||
| 534 | $xoopsTpl->assign('displaytopictitle', true); |
||
| 535 | } else { |
||
| 536 | $xoopsTpl->assign('displaytopictitle', false); |
||
| 537 | } |
||
| 538 | |||
| 539 | //Add style css |
||
| 540 | $xoTheme->addStylesheet('modules/news/assets/css/style.css'); |
||
| 541 | |||
| 542 | require_once XOOPS_ROOT_PATH . '/include/comment_view.php'; |
||
| 543 | require_once XOOPS_ROOT_PATH . '/footer.php'; |
||
| 544 |