/** * Shortens a long text string to only a few words * * Returns a shorter version of the in putted text centred * around the keyword. The keyword is highlighted in bold. * Adds '...' to the beginning or the end of the shortened * version depending where the text was cut. Works on a * word basis, so long words wont get cut. * * @param string $keyword The word to centre around * @param string $text The complete text string * @param int $num_words The number of words to display, best to use an odd number * @return string A short version of the text * */ private function _shortenText($keyword, $text, $num_words = 7) { $text = COM_getTextContent($text); $words = explode(' ', $text); $word_count = count($words); if ($word_count <= $num_words) { return COM_highlightQuery($text, $keyword, 'b'); } $rt = ''; $pos = stripos($text, $keyword); if ($pos !== false) { $pos_space = strpos($text, ' ', $pos); if (empty($pos_space)) { // Keyword at the end of text $key = $word_count - 1; $start = 0 - $num_words; $end = 0; $rt = '<b>...</b> '; } else { $str = substr($text, $pos, $pos_space - $pos); $m = (int) (($num_words - 1) / 2); $key = $this->_arraySearch($keyword, $words); if ($key === false) { // Keyword(s) not found - show start of text $key = 0; $start = 0; $end = $num_words - 1; } elseif ($key <= $m) { // Keyword at the start of text $start = 0 - $key; $end = $num_words - 1; $end = $key + $m <= $word_count - 1 ? $key : $word_count - $m - 1; $abs_length = abs($start) + abs($end) + 1; if ($abs_length < $num_words) { $end += $num_words - $abs_length; } } else { // Keyword in the middle of text $start = 0 - $m; $end = $key + $m <= $word_count - 1 ? $m : $word_count - $key - 1; $abs_length = abs($start) + abs($end) + 1; if ($abs_length < $num_words) { $start -= $num_words - $abs_length; } $rt = '<b>...</b> '; } } } else { $key = 0; $start = 0; $end = $num_words - 1; } for ($i = $start; $i <= $end; $i++) { $rt .= $words[$key + $i] . ' '; } if ($key + $i != $word_count) { $rt .= ' <b>...</b>'; } return COM_highlightQuery($rt, $keyword, 'b'); }
/** * Shortens a long text string to only a few words * * Returns a shorter version of the in putted text centred * around the keyword. The keyword is highlighted in bold. * Adds '...' to the beginning or the end of the shortened * version depending where the text was cut. Works on a * word basis, so long words wont get cut. * * @author Sami Barakat <s.m.barakat AT gmail DOT com> * @access private * @param string $keyword The word to centre around * @param string $text The complete text string * @param integer $num_words The number of words to display, best to use an odd number * @return string A short version of the text * */ function _shortenText($keyword, $text, $num_words = 7) { $text = COM_getTextContent($text); // parse some general bbcode / auto tags $bbcode = array("/\\[b\\](.*?)\\[\\/b\\]/is" => "\$1", "/\\[u\\](.*?)\\[\\/u\\]/is" => "\$1", "/\\[i\\](.*?)\\[\\/i\\]/is" => "\$1", "/\\[quote\\](.*?)\\[\\/quote\\]/is" => "\$1", "/\\[code\\](.*?)\\[\\/code\\]/is" => " \$1 ", "/\\[p\\](.*?)\\[\\/p\\]/is" => " \$1 ", "/\\[url\\=(.*?)\\](.*?)\\[\\/url\\]/is" => "\$2", "/\\[wiki:(.*?) (.*?)[\\]]/is" => "\$2"); $text = @preg_replace(array_keys($bbcode), array_values($bbcode), $text); $words = explode(' ', $text); $word_count = count($words); if ($word_count <= $num_words) { return COM_highlightQuery($text, $keyword, 'b'); } $rt = ''; $pos = $this->_stripos($text, $keyword); if ($pos !== false) { $pos_space = strpos($text, ' ', $pos); if (empty($pos_space)) { // Keyword at the end of text $key = $word_count - 1; $start = 0 - $num_words; $end = 0; $rt = '<b>...</b> '; } else { $str = substr($text, $pos, $pos_space - $pos); $m = (int) (($num_words - 1) / 2); $key = $this->_arraySearch($keyword, $words); if ($key === false) { // Keyword(s) not found - show start of text $key = 0; $start = 0; $end = $num_words - 1; } elseif ($key <= $m) { // Keyword at the start of text $start = 0 - $key; $end = $num_words - 1; $end = $key + $m <= $word_count - 1 ? $key : $word_count - $m - 1; $abs_length = abs($start) + abs($end) + 1; if ($abs_length < $num_words) { $end += $num_words - $abs_length; } } else { // Keyword in the middle of text $start = 0 - $m; $end = $key + $m <= $word_count - 1 ? $m : $word_count - $key - 1; $abs_length = abs($start) + abs($end) + 1; if ($abs_length < $num_words) { $start -= $num_words - $abs_length; } $rt = '<b>...</b> '; } } } else { $key = 0; $start = 0; $end = $num_words - 1; } for ($i = $start; $i <= $end; $i++) { $rt .= $words[$key + $i] . ' '; } if ($key + $i != $word_count) { $rt .= ' <b>...</b>'; } return COM_highlightQuery($rt, $keyword, 'b'); }
/** * Takes an article class and renders HTML in the specified template and style. * Formats the given article into HTML. Called by index.php, article.php, * submit.php and admin/story.php (Preview mode for the last two). * * @param Story $story The story to display, an instance of the Story class. * @param string $index n = Full display of article. p = 'Preview' mode. Else introtext only. * @param string $storyTpl The template to use to render the story. * @param string $query A search query, if one was specified. * @return string Article as formatted HTML. * Note: Formerly named COM_Article, and re-written totally since then. */ function STORY_renderArticle($story, $index = '', $storyTpl = 'storytext.thtml', $query = '') { global $_CONF, $_TABLES, $_USER, $LANG01, $LANG05, $LANG11, $LANG_TRB, $_IMAGE_TYPE, $mode; static $storyCounter = 0; if ($story->DisplayElements('featured') == 1) { $article_filevar = 'featuredarticle'; } elseif ($story->DisplayElements('statuscode') == STORY_ARCHIVE_ON_EXPIRE && $story->DisplayElements('expire') <= time()) { $article_filevar = 'archivearticle'; } else { $article_filevar = 'article'; } if (empty($storyTpl)) { $storyTpl = 'storytext.thtml'; } // Change article template file with the topic (feature request #275) $templateDir = $_CONF['path_layout']; $topicDir = $templateDir . 'topics/' . $story->DisplayElements('tid') . '/'; if (is_dir($topicDir) && file_exists($topicDir . $storyTpl)) { $templateDir = $topicDir; } $article = COM_newTemplate($templateDir); $article->set_file(array('article' => $storyTpl, 'bodytext' => 'storybodytext.thtml', 'featuredarticle' => 'featuredstorytext.thtml', 'featuredbodytext' => 'featuredstorybodytext.thtml', 'archivearticle' => 'archivestorytext.thtml', 'archivebodytext' => 'archivestorybodytext.thtml')); // begin instance caching... $cache_time = $story->DisplayElements('cache_time'); $current_article_tid = $story->DisplayElements('tid'); $retval = false; // If stays false will rebuild article and not used cache (checks done below) if ($cache_time > 0 || $cache_time == -1) { $hash = CACHE_security_hash(); $cacheInstance = 'article__' . $story->getSid() . '_' . $index . $mode . '_' . $article_filevar . '_' . $current_article_tid . '_' . $hash . '_' . $_USER['theme']; if ($_CONF['cache_templates']) { $retval = $article->check_instance($cacheInstance, $article_filevar); } else { $retval = CACHE_check_instance($cacheInstance); } if ($retval && $cache_time == -1) { // Cache file found so use it since no time limit set to recreate } elseif ($retval && $cache_time > 0) { $lu = CACHE_get_instance_update($cacheInstance); $now = time(); if ($now - $lu < $cache_time) { // Cache file found so use it since under time limit set to recreate } else { // generate article and create cache file // Cache time is not built into template caching so need to delete it manually and reset $retval if ($_CONF['cache_templates']) { // Need to close and recreate template class since issues arise when theme templates are cached unset($article); // Close template class CACHE_remove_instance($cacheInstance); $article = COM_newTemplate($_CONF['path_layout']); $article->set_file(array('article' => $storyTpl, 'bodytext' => 'storybodytext.thtml', 'featuredarticle' => 'featuredstorytext.thtml', 'featuredbodytext' => 'featuredstorybodytext.thtml', 'archivearticle' => 'archivestorytext.thtml', 'archivebodytext' => 'archivestorybodytext.thtml')); } else { // theme templates are not cache so can go ahead and delete story cache CACHE_remove_instance($cacheInstance); } $retval = false; } } else { // Need to reset especially if caching is disabled for a certain story but template caching has been enabled for the theme $retval = false; } } $articleUrl = COM_buildURL($_CONF['site_url'] . '/article.php?story=' . $story->getSid()); $article->set_var('article_url', $articleUrl); $article->set_var('story_title', $story->DisplayElements('title')); // Date formatting set by user therefore cannot be cached $article->set_var('story_date', $story->DisplayElements('date'), false, true); $article->set_var('story_datetime', $story->DisplayElements('datetime'), false, true); // Story views increase with every visit so cannot be cached if ($_CONF['hideviewscount'] != 1) { $article->set_var('lang_views', $LANG01[106], false, true); $article->set_var('story_hits', $story->DisplayElements('hits'), false, true); } // Topic Icon is user configurable so do not cache $topicname = $story->DisplayElements('topic'); $topicurl = COM_buildURL($_CONF['site_url'] . '/index.php?topic=' . $story->DisplayElements('tid')); if ((!isset($_USER['noicons']) || $_USER['noicons'] != 1) && $story->DisplayElements('show_topic_icon') == 1) { $imageurl = $story->DisplayElements('imageurl'); if (!empty($imageurl)) { $imageurl = COM_getTopicImageUrl($imageurl); $article->set_var('story_topic_image_url', $imageurl, false, true); $topicimage = '<img src="' . $imageurl . '" class="float' . $_CONF['article_image_align'] . '" alt="' . $topicname . '" title="' . $topicname . '"' . XHTML . '>'; $article->set_var('story_anchortag_and_image', COM_createLink($topicimage, $topicurl, array()), false, true); $article->set_var('story_topic_image', $topicimage, false, true); $topicimage_noalign = '<img src="' . $imageurl . '" alt="' . $topicname . '" title="' . $topicname . '"' . XHTML . '>'; $article->set_var('story_anchortag_and_image_no_align', COM_createLink($topicimage_noalign, $topicurl, array()), false, true); $article->set_var('story_topic_image_no_align', $topicimage_noalign, false, true); } } // Main article content if ($index == 'p') { $introtext = $story->getPreviewText('introtext'); $bodytext = $story->getPreviewText('bodytext'); } else { $introtext = $story->displayElements('introtext'); $bodytext = $story->displayElements('bodytext'); } $readmore = empty($bodytext) ? 0 : 1; $numwords = COM_numberFormat(count(explode(' ', COM_getTextContent($bodytext)))); if (COM_onFrontpage()) { $bodytext = ''; } if (!empty($query)) { $introtext = COM_highlightQuery($introtext, $query); $bodytext = COM_highlightQuery($bodytext, $query); } // Create article only if preview, or query not empty, or if no cache version or cache version is not required if ($index == 'p' || !empty($query) || !$retval) { $article->set_var('article_filevar', ''); $article->set_var('site_name', $_CONF['site_name']); //$article->set_var( 'story_date', $story->DisplayElements('date') ); $article->set_var('story_date_short', $story->DisplayElements('shortdate')); $article->set_var('story_date_only', $story->DisplayElements('dateonly')); $article->set_var('story_id', $story->getSid()); if ($_CONF['contributedbyline'] == 1) { $article->set_var('lang_contributed_by', $LANG01[1]); $article->set_var('contributedby_uid', $story->DisplayElements('uid')); $fullname = $story->DisplayElements('fullname'); $username = $story->DisplayElements('username'); $article->set_var('contributedby_user', $username); if (empty($fullname)) { $article->set_var('contributedby_fullname', $username); } else { $article->set_var('contributedby_fullname', $fullname); } $authorname = COM_getDisplayName($story->DisplayElements('uid'), $username, $fullname); $article->set_var('contributedby_author', $authorname); $article->set_var('author', $authorname); $profileUrl = ''; if ($story->DisplayElements('uid') > 1) { $profileUrl = $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $story->DisplayElements('uid'); $article->set_var('start_contributedby_anchortag', '<a class="storybyline" href="' . $profileUrl . '" rel="author">'); $article->set_var('end_contributedby_anchortag', '</a>'); $article->set_var('contributedby_url', $profileUrl); } $photo = ''; if ($_CONF['allow_user_photo'] == 1) { $authphoto = $story->DisplayElements('photo'); if (empty($authphoto)) { $authphoto = '(none)'; // user does not have a photo } $photo = USER_getPhoto($story->DisplayElements('uid'), $authphoto, $story->DisplayElements('email')); } if (!empty($photo)) { $article->set_var('contributedby_photo', $photo); $article->set_var('author_photo', $photo); $camera_icon = '<img src="' . $_CONF['layout_url'] . '/images/smallcamera.' . $_IMAGE_TYPE . '" alt=""' . XHTML . '>'; $article->set_var('camera_icon', COM_createLink($camera_icon, $profileUrl)); } else { $article->set_var('contributedby_photo', ''); $article->set_var('author_photo', ''); $article->set_var('camera_icon', ''); } } $article->set_var('story_topic_id', $story->DisplayElements('tid')); $article->set_var('story_topic_name', $topicname); $article->set_var('story_topic_url', $topicurl); $recent_post_anchortag = ''; $article->set_var('lang_permalink', $LANG01[127]); $show_comments = true; // n = Full display of article. p = 'Preview' mode. if ($index != 'n' && $index != 'p' || !empty($query)) { $attributes = ' class="non-ul"'; $attr_array = array('class' => 'non-ul'); if (!empty($query)) { $attributes .= ' rel="bookmark"'; $attr_array['rel'] = 'bookmark'; } $article->set_var('start_storylink_anchortag', '<a href="' . $articleUrl . '"' . $attributes . '>'); $article->set_var('end_storylink_anchortag', '</a>'); $article->set_var('story_title_link', COM_createLink($story->DisplayElements('title'), $articleUrl, $attr_array)); } else { $article->set_var('story_title_link', $story->DisplayElements('title')); } $related_topics = ''; if ($index == 'n') { if ($_CONF['supported_version_theme'] == '1.8.1') { $article->set_var('breadcrumb_trail', TOPIC_breadcrumbs('article', $story->getSid())); } if ($_CONF['related_topics'] > 0) { $related_topics = TOPIC_relatedTopics('article', $story->getSid(), $_CONF['related_topics_max']); $article->set_var('related_topics', $related_topics); } } elseif ($index != 'p') { if ($_CONF['related_topics'] > 1) { $related_topics = TOPIC_relatedTopics('article', $story->getSid(), $_CONF['related_topics_max']); $article->set_var('related_topics', $related_topics); } } $page_selector = ''; $readmore_link = ''; $post_comment_link = ''; $plugin_itemdisplay = ''; $comments_with_count = ''; $trackbacks_with_count = ''; if ($index == 'n' || $index == 'p') { if (empty($bodytext)) { $article->set_var('story_introtext', $introtext); $article->set_var('story_text_no_br', $introtext); } else { if ($_CONF['allow_page_breaks'] == 1 && $index == 'n') { $story_page = 1; // page selector if (is_numeric($mode)) { $story_page = $mode; if ($story_page <= 0) { $story_page = 1; $mode = 0; } elseif ($story_page > 1) { $introtext = ''; } } $article_array = explode('[page_break]', $bodytext); $page_break_count = count($article_array); if ($story_page > $page_break_count) { // Can't have page count greater than actual number of pages $story_page = $page_break_count; } $page_selector = COM_printPageNavigation($articleUrl, $story_page, $page_break_count, 'mode=', $_CONF['url_rewrite'], $LANG01[118]); if (count($article_array) > 1) { $bodytext = $article_array[$story_page - 1]; } $article->set_var('page_selector', $page_selector); if ($_CONF['page_break_comments'] == 'last' && $story_page < count($article_array) || $_CONF['page_break_comments'] == 'first' && $story_page != 1) { $show_comments = false; } $article->set_var('story_page', $story_page); } $article->set_var('story_introtext', $introtext . '<br' . XHTML . '><br' . XHTML . '>' . $bodytext); $article->set_var('story_text_no_br', $introtext . ' ' . $bodytext); } $article->set_var('story_introtext_only', $introtext); $article->set_var('story_bodytext_only', $bodytext); if (($_CONF['trackback_enabled'] || $_CONF['pingback_enabled']) && SEC_hasRights('story.ping')) { $url = $_CONF['site_admin_url'] . '/trackback.php?mode=sendall&id=' . $story->getSid(); $article->set_var('send_trackback_link', COM_createLink($LANG_TRB['send_trackback'], $url)); $pingico = '<img src="' . $_CONF['layout_url'] . '/images/sendping.' . $_IMAGE_TYPE . '" alt="' . $LANG_TRB['send_trackback'] . '" title="' . $LANG_TRB['send_trackback'] . '"' . XHTML . '>'; $article->set_var('send_trackback_icon', COM_createLink($pingico, $url)); $article->set_var('send_trackback_url', $url); $article->set_var('lang_send_trackback_text', $LANG_TRB['send_trackback']); } $article->set_var('story_display', $index == 'p' ? 'preview' : 'article'); $article->set_var('story_counter', 0); } else { $article->set_var('story_introtext', $introtext); $article->set_var('story_text_no_br', $introtext); $article->set_var('story_introtext_only', $introtext); if ($readmore) { $article->set_var('lang_readmore', $LANG01[2]); $article->set_var('lang_readmore_words', $LANG01[62]); $article->set_var('readmore_words', $numwords); $readmore_link = COM_createLink($LANG01[2], $articleUrl, array('class' => 'story-read-more-link')) . ' (' . $numwords . ' ' . $LANG01[62] . ') '; $article->set_var('readmore_link', $readmore_link); $article->set_var('start_readmore_anchortag', '<a href="' . $articleUrl . '" class="story-read-more-link">'); $article->set_var('end_readmore_anchortag', '</a>'); $article->set_var('read_more_class', 'class="story-read-more-link"'); } if ($story->DisplayElements('commentcode') >= 0 && $show_comments) { $commentsUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid()) . '#comments'; $article->set_var('comments_url', $commentsUrl); $article->set_var('comments_text', COM_numberFormat($story->DisplayElements('comments')) . ' ' . $LANG01[3]); $article->set_var('comments_count', COM_numberFormat($story->DisplayElements('comments'))); $article->set_var('lang_comments', $LANG01[3]); $comments_with_count = sprintf($LANG01[121], COM_numberFormat($story->DisplayElements('comments'))); if ($story->DisplayElements('comments') > 0) { $result = DB_query("SELECT UNIX_TIMESTAMP(date) AS day,username,fullname,{$_TABLES['comments']}.uid as cuid FROM {$_TABLES['comments']},{$_TABLES['users']} WHERE {$_TABLES['users']}.uid = {$_TABLES['comments']}.uid AND sid = '" . $story->getSid() . "' ORDER BY date DESC LIMIT 1"); $C = DB_fetchArray($result); $recent_post_anchortag = '<span class="storybyline">' . $LANG01[27] . ': ' . strftime($_CONF['daytime'], $C['day']) . ' ' . $LANG01[104] . ' ' . COM_getDisplayName($C['cuid'], $C['username'], $C['fullname']) . '</span>'; $comments_with_count = COM_createLink($comments_with_count, $commentsUrl); $article->set_var('comments_with_count', $comments_with_count); $article->set_var('start_comments_anchortag', '<a href="' . $commentsUrl . '">'); $article->set_var('end_comments_anchortag', '</a>'); } else { $article->set_var('comments_with_count', $comments_with_count); if ($_CONF['comment_on_same_page'] == true) { $recent_post_anchortag = COM_createLink($LANG01[60], $_CONF['site_url'] . '/article.php?story=' . $story->getSid() . '#commenteditform'); } else { $recent_post_anchortag = COM_createLink($LANG01[60], $_CONF['site_url'] . '/comment.php?sid=' . $story->getSid() . '&pid=0&type=article'); if ($_CONF['show_comments_at_replying'] == true) { $recent_post_anchortag .= '#commenteditform'; } } } if ($story->DisplayElements('commentcode') == 0) { if ($_CONF['comment_on_same_page'] == true) { $postCommentUrl = $_CONF['site_url'] . '/article.php?story=' . $story->getSid() . '#commenteditform'; } else { $postCommentUrl = $_CONF['site_url'] . '/comment.php?sid=' . $story->getSid() . '&pid=0&type=article'; if ($_CONF['show_comments_at_replying'] == true) { $postCommentUrl .= '#commenteditform'; } } $post_comment_link = COM_createLink($LANG01[60], $postCommentUrl, array('rel' => 'nofollow')); $article->set_var('post_comment_link', $post_comment_link); /* $article->set_var( 'subscribe_link', COM_createLink('Nubbies', '', array('rel' => 'nofollow')) ); */ $article->set_var('lang_post_comment', $LANG01[60]); $article->set_var('start_post_comment_anchortag', '<a href="' . $postCommentUrl . '" rel="nofollow">'); $article->set_var('end_post_comment_anchortag', '</a>'); } } if (($_CONF['trackback_enabled'] || $_CONF['pingback_enabled']) && $story->DisplayElements('trackbackcode') >= 0 && $show_comments) { $num_trackbacks = COM_numberFormat($story->DisplayElements('trackbacks')); $trackbacksUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid()) . '#trackback'; $article->set_var('trackbacks_url', $trackbacksUrl); $article->set_var('trackbacks_text', $num_trackbacks . ' ' . $LANG_TRB['trackbacks']); $article->set_var('trackbacks_count', $num_trackbacks); $article->set_var('lang_trackbacks', $LANG_TRB['trackbacks']); if (SEC_hasRights('story.ping')) { $pingurl = $_CONF['site_admin_url'] . '/trackback.php?mode=sendall&id=' . $story->getSid(); $pingico = '<img src="' . $_CONF['layout_url'] . '/images/sendping.' . $_IMAGE_TYPE . '" alt="' . $LANG_TRB['send_trackback'] . '" title="' . $LANG_TRB['send_trackback'] . '"' . XHTML . '>'; $article->set_var('send_trackback_icon', COM_createLink($pingico, $pingurl)); } $trackbacks_with_count = sprintf($LANG01[122], $num_trackbacks); if ($story->DisplayElements('trackbacks') > 0) { $trackbacks_with_count = COM_createLink($trackbacks_with_count, $trackbacksUrl); } $article->set_var('trackbacks_with_count', $trackbacks_with_count); } if ($_CONF['hideemailicon'] == 1 || COM_isAnonUser() && ($_CONF['loginrequired'] == 1 || $_CONF['emailstoryloginrequired'] == 1)) { $article->set_var('email_icon', ''); } else { $emailUrl = $_CONF['site_url'] . '/profiles.php?sid=' . $story->getSid() . '&what=emailstory'; $emailicon = '<img src="' . $_CONF['layout_url'] . '/images/mail.' . $_IMAGE_TYPE . '" alt="' . $LANG01[64] . '" title="' . $LANG11[2] . '"' . XHTML . '>'; $article->set_var('email_icon', COM_createLink($emailicon, $emailUrl)); $article->set_var('email_story_url', $emailUrl); $article->set_var('lang_email_story', $LANG11[2]); $article->set_var('lang_email_story_alt', $LANG01[64]); } $printUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid() . '&mode=print'); if ($_CONF['hideprintericon'] == 1) { $article->set_var('print_icon', ''); } else { $printicon = '<img src="' . $_CONF['layout_url'] . '/images/print.' . $_IMAGE_TYPE . '" alt="' . $LANG01[65] . '" title="' . $LANG11[3] . '"' . XHTML . '>'; $article->set_var('print_icon', COM_createLink($printicon, $printUrl, array('rel' => 'nofollow'))); $article->set_var('print_story_url', $printUrl); $article->set_var('lang_print_story', $LANG11[3]); $article->set_var('lang_print_story_alt', $LANG01[65]); } $article->set_var('story_display', 'index'); $storyCounter++; $article->set_var('story_counter', $storyCounter); } $article->set_var('recent_post_anchortag', $recent_post_anchortag); if ($index != 'p' && SEC_hasRights('story.edit') && $story->checkAccess() == 3 && TOPIC_hasMultiTopicAccess('article', $story->DisplayElements('sid')) == 3) { $editUrl = $_CONF['site_admin_url'] . '/story.php?mode=edit&sid=' . $story->getSid(); $editiconhtml = '<img src="' . $_CONF['layout_url'] . '/images/edit.' . $_IMAGE_TYPE . '" alt="' . $LANG01[4] . '" title="' . $LANG01[4] . '"' . XHTML . '>'; $article->set_var('edit_link', COM_createLink($LANG01[4], $editUrl)); $article->set_var('edit_url', $editUrl); $article->set_var('lang_edit_text', $LANG01[4]); $article->set_var('edit_icon', COM_createLink($editiconhtml, $editUrl, array('class' => 'editlink'))); $article->set_var('edit_image', $editiconhtml); } $navi_list = true; $feedback_list = true; if ($index == 'p') { $navi_list = false; $feedback_list = false; } else { $navi_list = $page_selector !== '' || $readmore_link !== '' || $post_comment_link !== ''; $feedback_list = $plugin_itemdisplay !== '' || $comments_with_count !== '' || $trackbacks_with_count !== ''; } $story_footer = $navi_list || $feedback_list || $related_topics !== ''; $article->set_var('navi_list', $navi_list); $article->set_var('feedback_list', $feedback_list); $article->set_var('story_footer', $story_footer); if ($story->DisplayElements('featured') == 1) { $article->set_var('lang_todays_featured_article', $LANG05[4]); $article->parse('story_bodyhtml', 'featuredbodytext', true); PLG_templateSetVars('featuredstorytext', $article); } elseif ($story->DisplayElements('statuscode') == STORY_ARCHIVE_ON_EXPIRE && $story->DisplayElements('expire') <= time()) { $article->parse('story_bodyhtml', 'archivestorybodytext', true); PLG_templateSetVars('archivestorytext', $article); } else { $article->parse('story_bodyhtml', 'bodytext', true); PLG_templateSetVars('storytext', $article); } // Add related articles if ($index === 'n') { $article->set_var('related_articles_by_keyword', Story::getRelatedArticlesByKeywords($story->getSid(), $story->DisplayElements('meta_keywords'))); } PLG_templateSetVars($article_filevar, $article); if ($index != 'p' && ($cache_time > 0 || $cache_time == -1)) { $article->create_instance($cacheInstance, $article_filevar); // CACHE_create_instance($cacheInstance, $article); } } else { PLG_templateSetVars($article_filevar, $article); if (!$_CONF['cache_templates']) { // Hack (see Geeklog Bug Tracker issue #0001817): Cannot set the template variable directly with set_var since // this template variable was set with set_file which uses the templatecode array (set_var uses varvals array) // so have to update the templatecode array directly. This array really shouldn't be accessed this way // and this hack should be changed in the future: either set_var or set_file functions need to allow update of the file template variable found in templatecode // $article->set_var($article_filevar, $retval); $article->templateCode[$article_filevar] = $retval; } } $article->parse('finalstory', $article_filevar); return $article->finish($article->get_var('finalstory')); }
} if (empty($A['address1']) || empty($A['address2']) && !$hasCityEtc) { $cal_templates->set_var('br1', ''); } else { $cal_templates->set_var('br1', '<br' . XHTML . '>'); } if (empty($A['address2']) || !$hasCityEtc) { $cal_templates->set_var('br2', ''); } else { $cal_templates->set_var('br2', '<br' . XHTML . '>'); } } $cal_templates->set_var('lang_description', $LANG_CALJP_1[5]); $description = $gltext->getDisplayText($A['description'], $A['postmode']); if (!empty($query)) { $description = COM_highlightQuery($description, $query); } $cal_templates->set_var('event_description', $description); $cal_templates->set_var('lang_event_type', $LANG_CALJP_1[37]); $cal_templates->set_var('event_type', $A['event_type']); $cal_templates->set_var('event_id', $A['eid']); if ($mode == 'personal') { $editurl = $_CONF['site_url'] . '/calendarjp/event.php?action=edit' . '&eid=' . $A['eid']; $cal_templates->set_var('event_edit', COM_createLink($LANG01[4], $editurl)); $img = '<img src="' . $_CONF['layout_url'] . '/images/edit.' . $_IMAGE_TYPE . '" alt="' . $LANG01[4] . '" title="' . $LANG01[4] . '"' . XHTML . '>'; $cal_templates->set_var('edit_icon', COM_createLink($img, $editurl)); } else { if (SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']) == 3 && SEC_hasRights('calendarjp.edit')) { $editurl = $_CONF['site_admin_url'] . '/plugins/calendarjp/index.php?mode=edit&eid=' . $A['eid']; $cal_templates->set_var('event_edit', COM_createLink($LANG01[4], $editurl)); $img = '<img src="' . $_CONF['layout_url'] . '/images/edit.' . $_IMAGE_TYPE . '" alt="' . $LANG01[4] . '" title="' . $LANG01[4] . '"' . XHTML . '>';
/** * Display an ad's detail * @param string $ad_id ID of ad to display */ function adDetail($ad_id = '') { global $_USER, $_TABLES, $_CONF, $LANG_ADVT, $_CONF_ADVT; USES_lib_comments(); // Determind if this is an administrator $admin = SEC_hasRights($_CONF_ADVT['pi_name'] . '.admin'); $ad_id = COM_sanitizeID($ad_id); if ($ad_id == '') { // An ad id is required for this function return CLASSIFIEDS_errorMsg($LANG_ADVT['missing_id'], 'alert'); } $srchval = isset($_GET['query']) ? trim($_GET['query']) : ''; // We use this in a few places here, so might as well just // figure it out once and save it. $perm_sql = COM_getPermSQL('AND', 0, 2, 'ad') . ' ' . COM_getPermSQL('AND', 0, 2, 'cat'); // get the ad information. $sql = "SELECT ad.*\n FROM {$_TABLES['ad_ads']} ad\n LEFT JOIN {$_TABLES['ad_category']} cat\n ON ad.cat_id = cat.cat_id\n WHERE ad_id='{$ad_id}'"; if (!$admin) { $sql .= $perm_sql; } $result = DB_query($sql); if (!$result || DB_numRows($result) < 1) { return CLASSIFIEDS_errorMsg($LANG_ADVT['no_ad_found'], 'note', 'Oops...'); } $ad = DB_fetchArray($result, false); // Check access to the ad. If granted, check that access isn't // blocked by any category. $my_access = CLASSIFIEDS_checkAccess($ad['ad_id'], $ad); if ($my_access >= 2) { $my_cat_access = CLASSIFIEDS_checkCatAccess($ad['cat_id'], false); if ($my_cat_access < $my_access) { $my_access = $my_cat_access; } } if ($my_access < 2) { return CLASSIFIEDS_errorMsg($LANG_ADVT['no_permission'], 'alert', $LANG_ADVT['access_denied']); } $cat = (int) $ad['cat_id']; // Increment the views counter $sql = "UPDATE {$_TABLES['ad_ads']} \n SET views = views + 1 \n WHERE ad_id='{$ad_id}'"; DB_query($sql); // Get the previous and next ads $condition = " AND ad.cat_id={$cat}"; if (!$admin) { $condition .= $perm_sql; } $sql = "SELECT ad_id\n FROM {$_TABLES['ad_ads']} ad\n LEFT JOIN {$_TABLES['ad_category']} cat\n ON ad.cat_id = cat.cat_id\n WHERE ad_id < '{$ad_id}' \n {$condition}\n ORDER BY ad_id DESC\n LIMIT 1"; $r = DB_query($sql); list($preAd_id) = DB_fetchArray($r, false); $sql = "SELECT ad_id\n FROM {$_TABLES['ad_ads']} ad\n LEFT JOIN {$_TABLES['ad_category']} cat\n ON ad.cat_id = cat.cat_id\n WHERE ad_id > '{$ad_id}' \n {$condition}\n ORDER BY ad_id ASC\n LIMIT 1"; $r = DB_query($sql); list($nextAd_id) = DB_fetchArray($r, false); // Get the user contact info. If none, just show the email link $sql = "SELECT * \n FROM {$_TABLES['ad_uinfo']} \n WHERE uid='{$ad['uid']}'"; //echo $sql; $result = DB_query($sql); $uinfo = array(); if ($result && DB_numRows($result) > 0) { $uinfo = DB_fetchArray($result); } else { $uinfo['uid'] = ''; $uinfo['address'] = ''; $uinfo['city'] = ''; $uinfo['state'] = ''; $uinfo['postal'] = ''; $uinfo['tel'] = ''; $uinfo['fax'] = ''; } // Get the hot results (most viewed ads) $time = time(); $sql = "SELECT ad.ad_id, ad.cat_id, ad.subject,\n cat.cat_id, cat.fgcolor, cat.bgcolor\n FROM {$_TABLES['ad_ads']} ad\n LEFT JOIN {$_TABLES['ad_category']} cat\n ON ad.cat_id = cat.cat_id\n WHERE ad.exp_date > {$time} \n {$perm_sql}\n ORDER BY views DESC \n LIMIT 4"; //echo $sql;die; $hotresult = DB_query($sql); // convert line breaks & others to html $patterns = array('/\\n/'); $replacements = array('<br />'); $ad['descript'] = PLG_replaceTags(COM_checkHTML($ad['descript'])); $ad['descript'] = preg_replace($patterns, $replacements, $ad['descript']); $ad['subject'] = strip_tags($ad['subject']); $ad['price'] = strip_tags($ad['price']); $ad['url'] = COM_sanitizeUrl($ad['url']); $ad['keywords'] = strip_tags($ad['keywords']); // Highlight search terms, if any if ($srchval != '') { $ad['subject'] = COM_highlightQuery($ad['subject'], $srchval); $ad['descript'] = COM_highlightQuery($ad['descript'], $srchval); } $detail = new Template(CLASSIFIEDS_PI_PATH . '/templates'); $detail->set_file('detail', 'detail.thtml'); if ($admin) { $base_url = CLASSIFIEDS_ADMIN_URL . '/index.php'; $del_link = $base_url . '?delete=ad&ad_id=' . $ad_id; $edit_link = $base_url . '?edit=ad&ad_id=' . $ad_id; } else { $base_url = CLASSIFIEDS_URL . '/index.php'; $del_link = $base_url . '?mode=Delete&id=' . $ad_id; $edit_link = $base_url . '?mode=editad&id=' . $ad_id; } // Set up the "add days" form if this user is the owner // or an admin if ($my_access == 3) { // How many days has the ad run? $max_add_days = CLASSIFIEDS_calcMaxAddDays(($ad['exp_date'] - $ad['add_date']) / 86400); if ($max_add_days > 0) { $detail->set_var('max_add_days', $max_add_days); } } if ($ad['exp_date'] < $time) { $detail->set_var('is_expired', 'true'); } USES_classifieds_class_category(); $detail->set_var(array('base_url' => $base_url, 'edit_link' => $edit_link, 'del_link' => $del_link, 'curr_loc' => adCategory::BreadCrumbs($cat, true), 'subject' => $ad['subject'], 'add_date' => date($_CONF['shortdate'], $ad['add_date']), 'exp_date' => date($_CONF['shortdate'], $ad['exp_date']), 'views_no' => $ad['views'], 'descript' => $ad['descript'], 'ad_type' => CLASSIFIEDS_getAdTypeString($ad['ad_type']), 'uinfo_address' => $uinfo['address'], 'uinfo_city' => $uinfo['city'], 'uinfo_state' => $uinfo['state'], 'uinfo_postcode' => $uinfo['postcode'], 'uinfo_tel' => $uinfo['tel'], 'uinfo_fax' => $uinfo['fax'], 'price' => $ad['price'], 'ad_id' => $ad_id, 'ad_url' => $ad['url'], 'username' => $_CONF_ADVT['disp_fullname'] == 1 ? COM_getDisplayName($ad['uid']) : DB_getItem($_TABLES['users'], 'username', "uid={$ad['uid']}"), 'fgcolor' => $ad['fgcolor'], 'bgcolor' => $ad['bgcolor'], 'cat_id' => $ad['cat_id'])); // Display a link to email the poster, or other message as needed $emailfromuser = DB_getItem($_TABLES['userprefs'], 'emailfromuser', "uid={$ad['uid']}"); if ($_CONF['emailuserloginrequired'] == 1 && COM_isAnonUser() || $emailfromuser < 1) { $detail->set_var('ad_uid', ''); } else { $detail->set_var('ad_uid', $ad['uid']); } if ($my_access == 3) { $detail->set_var('have_userlinks', 'true'); if ($admin || $_CONF_ADVT['usercanedit'] == 1) { $detail->set_var('have_editlink', 'true'); } else { $detail->set_var('have_editlink', ''); } } else { $detail->set_var('have_userlinks', ''); } // Retrieve the photos and put into the template $sql = "SELECT photo_id, filename\n FROM {$_TABLES['ad_photo']} \n WHERE ad_id='{$ad_id}'"; $photo = DB_query($sql); $photo_detail = ''; $detail->set_var('have_photo', ''); // assume no photo available if ($photo && DB_numRows($photo) >= 1) { while ($prow = DB_fetchArray($photo)) { $img_small = LGLIB_ImageUrl(CLASSIFIEDS_IMGPATH . '/' . $prow['filename'], $_CONF_ADVT['detail_img_width']); $img_disp = CLASSIFIEDS_dispUrl($prow['filename']); if (!empty($img_small)) { $detail->set_block('detail', 'PhotoBlock', 'PBlock'); $detail->set_var(array('tn_width' => $_CONF_ADVT['detail_img_width'], 'small_url' => $img_small, 'disp_url' => $img_disp)); $detail->parse('PBlock', 'PhotoBlock', true); $detail->set_var('have_photo', 'true'); } } } if (DB_count($_TABLES['ad_ads'], 'owner_id', (int) $ad['owner_id']) > 1) { $detail->set_var('byposter_url', CLASSIFIEDS_URL . '/index.php?' . "page=byposter&uid={$ad['owner_id']}"); } // Show previous and next ads if ($preAd_id != '') { $detail->set_var('previous', '<a href="' . CLASSIFIEDS_makeURL('detail', $preAd_id) . "\"><<</a>"); } if ($nextAd_id != '') { $detail->set_var('next', '<a href="' . CLASSIFIEDS_makeURL('detail', $nextAd_id) . "\"> >></a>"); } // Show the "hot results" $hot_data = ''; if ($hotresult) { $detail->set_block('detail', 'HotBlock', 'HBlock'); while ($hotrow = DB_fetchArray($hotresult)) { $detail->set_var(array('hot_title' => $hotrow['subject'], 'hot_url' => CLASSIFIEDS_makeURL('detail', $hotrow['ad_id']), 'hot_cat' => displayCat($hotrow['cat_id']))); /*$hot_data .= "<tr><td class=\"hottitle\"><a href=\"" . CLASSIFIEDS_makeURL('detail', $hotrow['ad_id']) . "\">{$hotrow['subject']}</a></small></td>\n"; $hot_data .= "<td class=\"hotcat\">( " . displayCat($hotrow['cat_id']) . " )</td></tr>\n";*/ } $detail->parse('HBlock', 'HotBlock', true); } $detail->set_var('whats_hot_row', $hot_data); // Show the user comments if (plugin_commentsupport_classifieds() && $ad['comments_enabled'] < 2) { $detail->set_var('usercomments', CMT_userComments($ad_id, $ad['subject'], 'classifieds', '', '', 0, 1, false, false, $ad['comments_enabled'])); //$detail->set_var('usercomments', CMT_userComments($ad_id, $subject, // 'classifieds')); } $detail->parse('output', 'detail'); $display = $detail->finish($detail->get_var('output')); return $display; }
/** * Display the detail page for the event occurrence. * * @param integer $rp_id ID of the repeat to display * @param string $query Optional query string, for highlighting * @param string $tpl Optional template filename, e.g. 'event_print' * @return string HTML for the page. */ public function Render($rp_id = 0, $query = '', $tpl = '') { global $_CONF, $_USER, $_EV_CONF, $_TABLES, $LANG_EVLIST, $LANG_WEEK, $_SYSTEM; $retval = ''; $url = ''; $location = ''; $street = ''; $city = ''; $province = ''; $country = ''; $postal = ''; $name = ''; $email = ''; $phone = ''; if ($rp_id != 0) { $this->Read($rp_id); } if ($this->rp_id == 0) { return EVLIST_alertMessage($LANG_EVLIST['access_denied']); } //update hit count evlist_hit($this->ev_id); $template = 'event'; if (!empty($tpl)) { $template .= '_' . $tpl; } else { $template .= $_SYSTEM['framework'] == 'uikit' ? '.uikit' : ''; } $T = new Template(EVLIST_PI_PATH . '/templates/'); $T->set_file(array('event' => $template . '.thtml', 'datetime' => 'date_time.thtml', 'address' => 'address.thtml', 'contact' => 'contact.thtml')); // If plain text then replace newlines with <br> tags if ($this->Event->postmode == '1') { //plaintext $this->Event->Detail->summary = nl2br($this->Event->Detail->summary); $this->Event->Detail->full_description = nl2br($this->Event->Detail->full_description); $this->Event->Detail->location = nl2br($this->Event->Detail->location); } $title = $this->Event->Detail->title; if ($this->postmode != 'plaintext') { $summary = PLG_replaceTags($this->Event->Detail->summary); $fulldescription = PLG_replaceTags($this->Event->Detail->full_description); $location = $this->Event->Detail->location != '' ? PLG_replaceTags($this->Event->Detail->location) : ''; } else { $summary = $this->Event->Detail->summary; $fulldescription = $this->Event->Detail->full_description; $location = $this->Event->Detail->location; } if ($query != '') { $title = COM_highlightQuery($title, $query); if (!empty($summary)) { $summary = COM_highlightQuery($summary, $query); } if (!empty($fulldescription)) { $fulldescription = COM_highlightQuery($fulldescription, $query); } if (!empty($location)) { $location = COM_highlightQuery($location, $query); } } $date_start = EVLIST_formattedDate($this->date_start); if ($this->date_start != $this->date_end) { $date_end = EVLIST_formattedDate($this->date_end); } else { $date_end = ''; } if ($this->Event->allday == '1') { $allday = '<br />' . $LANG_EVLIST['all_day_event']; } else { $allday = ''; if ($this->time_start1 != '') { $time_start1 = EVLIST_formattedTime($this->time_start1); $time_end1 = EVLIST_formattedTime($this->time_end1); } else { $time_start1 = ''; $time_end1 = ''; } //$time_period = $time_start . $time_end; if ($this->Event->split == '1') { $time_start2 = EVLIST_formattedTime($this->time_start2); $time_end2 = EVLIST_formattedTime($this->time_end2); } } $url = $this->Event->Detail->url; $street = $this->Event->Detail->street; $city = $this->Event->Detail->city; $province = $this->Event->Detail->province; $postal = $this->Event->Detail->postal; $country = $this->Event->Detail->country; // Now get the text description of the recurring interval, if any if ($this->Event->recurring && $this->Event->rec_data['type'] < EV_RECUR_DATES) { $rec_data = $this->Event->rec_data; $rec_string = $LANG_EVLIST['recur_freq_txt'] . ' ' . $this->Event->RecurDescrip(); switch ($rec_data['type']) { case EV_RECUR_WEEKLY: // sequential days $weekdays = array(); if (is_array($rec_data['listdays'])) { foreach ($rec_data['listdays'] as $daynum) { $weekdays[] = $LANG_WEEK[$daynum]; } $days_text = implode(', ', $weekdays); } else { $days_text = ''; } $rec_string .= ' ' . sprintf($LANG_EVLIST['on_days'], $days_text); break; case EV_RECUR_DOM: $days = array(); foreach ($rec_data['interval'] as $key => $day) { $days[] = $LANG_EVLIST['rec_intervals'][$day]; } $days_text = implode(', ', $days) . ' ' . $LANG_WEEK[$rec_data['weekday']]; $rec_string .= ' ' . sprintf($LANG_EVLIST['on_the_days'], $days_text); break; } if ($this->Event->rec_data['stop'] != '' && $this->Event->rec_data['stop'] < EV_MAX_DATE) { $rec_string .= ' ' . sprintf($LANG_EVLIST['recur_stop_desc'], EVLIST_formattedDate($this->Event->rec_data['stop'])); } } else { $rec_string = ''; } $T->set_var(array('pi_url' => EVLIST_URL, 'webcal_url' => preg_replace('/^https?/', 'webcal', EVLIST_URL), 'rp_id' => $this->rp_id, 'ev_id' => $this->ev_id, 'title' => $title, 'summary' => $summary, 'full_description' => $fulldescription, 'can_edit' => $this->isAdmin ? 'true' : '', 'start_time1' => $time_start1, 'end_time1' => $time_end1, 'start_time2' => $time_start2, 'end_time2' => $time_end2, 'start_date' => $date_start, 'end_date' => $date_end, 'start_datetime1' => $date_start . $time_start, 'end_datetime1' => $date_end . $time_end, 'allday_event' => $this->Event->allday == 1 ? 'true' : '', 'is_recurring' => $this->Event->recurring, 'can_subscribe' => $this->Event->Calendar->cal_ena_ical, 'recurring_event' => $rec_string, 'owner_id' => $this->Event->owner_id, 'cal_name' => $this->Event->Calendar->cal_name, 'cal_id' => $this->Event->cal_id, 'site_name' => $_CONF['site_name'], 'site_slogan' => $_CONF['site_slogan'], 'more_info_link' => sprintf($LANG_EVLIST['click_here'], $url))); if ($_EV_CONF['enable_rsvp'] == 1 && $this->Event->options['use_rsvp'] > 0) { if ($this->Event->options['rsvp_cutoff'] > 0) { $dt = new Date($this->event->date_start1 . ' ' . $this->Event->time_start1, $_CONF['timezone']); if (time() > $dt->toUnix() - $this->Event->options['rsvp_cutoff'] * 86400) { $past_cutoff = false; } else { $past_cutoff = true; } } if (COM_isAnonUser()) { // Just show a must-log-in message $T->set_var('login_to_register', 'true'); } elseif (!$past_cutoff) { $num_free_tickets = $this->isRegistered(0, true); $total_tickets = $this->isRegistered(0, false); if ($num_free_tickets > 0) { // If the user is already registered for any free tickets, // show the cancel link $T->set_var(array('unregister_link' => 'true', 'num_free_reg' => $num_free_tickets)); } // Show the registration link if (($this->Event->options['max_rsvp'] == 0 || $this->Event->options['rsvp_waitlist'] == 1 || $this->Event->options['max_rsvp'] > $this->TotalRegistrations()) && ($this->Event->options['max_user_rsvp'] == 0 || $total_tickets < $this->Event->options['max_user_rsvp'])) { USES_evlist_class_tickettype(); $Ticks = evTicketType::GetTicketTypes(); if ($this->Event->options['max_user_rsvp'] > 0) { $T->set_block('event', 'tickCntBlk', 'tcBlk'); $T->set_var('register_multi', true); //$rsvp_user_count = ''; $avail_tickets = $this->Event->options['max_user_rsvp'] - $total_tickets; for ($i = 1; $i <= $avail_tickets; $i++) { $T->set_var('tick_cnt', $i); $T->parse('tcBlk', 'tickCntBlk', true); //$rsvp_user_count .= '<option value="'.$i.'">'.$i. // '</option>'.LB; } //$T->set_var('register_multi', $rsvp_user_count); } else { // max_rsvp == 0 indicates openended registration $T->set_var('register_unltd', 'true'); } $T->set_block('event', 'tickTypeBlk', 'tBlk'); foreach ($this->Event->options['tickets'] as $tick_id => $data) { /*$options .= '<option value="' . $tick_id . '">' . $Ticks[$tick_id]->description; if ($data['fee'] > 0) { $options .= ' - ' . COM_numberFormat($data['fee'], 2); } $options .= '</option>' . LB;*/ $status = LGLIB_invokeService('paypal', 'formatAmount', array('amount' => $data['fee']), $pp_fmt_amt, $svc_msg); $fmt_amt = $status == PLG_RET_OK ? $pp_fmt_amt : COM_numberFormat($data['fee'], 2); $T->set_var(array('tick_type' => $tick_id, 'tick_descr' => $Ticks[$tick_id]->description, 'tick_fee' => $data['fee'] > 0 ? $fmt_amt : 'FREE')); $T->parse('tBlk', 'tickTypeBlk', true); } $T->set_var(array('register_link' => 'true', 'ticket_options' => $options, 'ticket_types_multi' => count($this->Event->options['tickets']) > 1 ? 'true' : '')); } } // If ticket printing is enabled for this event, see if the // current user has any tickets to print. if ($this->Event->options['rsvp_print'] > 0) { $paid = $this->Event->options['rsvp_print'] == 1 ? 'paid' : ''; USES_evlist_class_ticket(); $tickets = evTicket::GetTickets($this->ev_id, '', $this->uid, $paid); if (count($tickets) > 0) { $T->set_var('have_tickets', 'true'); } } } // if enable_rsvp if (!empty($date_start) || !empty($date_end)) { $T->parse('datetime_info', 'datetime'); } // Only process the location block if at least one element exists. // Don't want an empty block showing. if (!empty($location) || !empty($street) || !empty($city) || !empty($province) || !empty($postal)) { $T->set_var(array('location' => $location, 'street' => $street, 'city' => $city, 'province' => $province, 'country' => $country, 'postal' => $postal)); $T->parse('address_info', 'address'); // Get info from the Weather plugin, if configured and available // There has to be at least some location data for this to work. if ($_EV_CONF['use_weather']) { // The postal code works best, but not internationally. // Try the regular address first. $loc = ''; if (!empty($city) && !empty($province)) { $loc = $city . ', ' . $province . ' ' . $country; } if (!empty($postal)) { $loc .= ' ' . $postal; } if (!empty($loc)) { // Location info was found, get the weather LGLIB_invokeService('weather', 'embed', array('loc' => $loc), $weather, $svc_msg); if (!empty($weather)) { // Weather info was found $T->set_var('weather', $weather); } } } } // Get a map from the Locator plugin, if configured and available if ($_EV_CONF['use_locator'] == 1 && $this->Event->Detail->lat != 0 && $this->Event->Detail->lng != 0) { $status = LGLIB_invokeService('locator', 'getMap', array('lat' => $this->Event->Detail->lat, 'lng' => $this->Event->Detail->lng), $map, $svc_msg); if ($status == PLG_RET_OK) { $T->set_var(array('map' => $map, 'lat' => number_format($this->Event->Detail->lat, 8, '.', ''), 'lng' => number_format($this->Event->Detail->lng, 8, '.', ''))); } } //put contact info here: contact, email, phone# $name = $this->Event->Detail->contact != '' ? COM_applyFilter($this->Event->Detail->contact) : ''; if ($this->Event->Detail->email != '') { $email = COM_applyFilter($this->Event->Detail->email); $email = EVLIST_obfuscate($email); } else { $email = ''; } $phone = $this->Event->Detail->phone != '' ? COM_applyFilter($this->Event->Detail->phone) : ''; if (!empty($name) || !empty($email) || !empty($phone)) { $T->set_var(array('name' => $name, 'email' => $email, 'phone' => $phone)); $T->parse('contact_info', 'contact'); } // TODO: Is the range needed? if (!empty($range)) { $andrange = '&range=' . $range; } else { $andrange = '&range=2'; } if (!empty($cat)) { $andcat = '&cat=' . $cat; } else { $andcat = ''; } $cats = $this->Event->GetCategories(); $catcount = count($cats); if ($catcount > 0) { $catlinks = array(); for ($i = 0; $i < $catcount; $i++) { $catlinks[] = '<a href="' . COM_buildURL(EVLIST_URL . '/index.php?op=list' . $andrange . '&cat=' . $cats[$i]['id']) . '">' . $cats[$i]['name'] . '</a> '; } $catlink = join('| ', $catlinks); $T->set_var('category_link', $catlink, true); } // reminders must be enabled globally first and then per event in // order to be active if (!isset($_EV_CONF['reminder_days'])) { $_EV_CONF['reminder_days'] = 1; } $hasReminder = 0; if ($_EV_CONF['enable_reminders'] == '1' && $this->Event->enable_reminders == '1' && time() < strtotime("-" . $_EV_CONF['reminder_days'] . " days", strtotime($this->date_start))) { //form will not appear within XX days of scheduled event. $show_reminders = true; // Let's see if we have already asked for a reminder... if ($_USER['uid'] > 1) { $hasReminder = DB_count($_TABLES['evlist_remlookup'], array('eid', 'uid', 'rp_id'), array($this->ev_id, $_USER['uid'], $this->rp_id)); } } else { $show_reminders = false; } if ($this->Event->options['contactlink'] == 1) { $ownerlink = $_CONF['site_url'] . '/profiles.php?uid=' . $this->Event->owner_id; $ownerlink = sprintf($LANG_EVLIST['contact_us'], $ownerlink); } else { $ownerlink = ''; } $T->set_var(array('owner_link' => $ownerlink, 'reminder_set' => $hasReminder ? 'true' : 'false', 'reminder_email' => isset($_USER['email']) ? $_USER['email'] : '', 'notice' => 1, 'rp_id' => $this->rp_id, 'eid' => $this->ev_id, 'show_reminderform' => $show_reminders ? 'true' : '')); USES_evlist_class_tickettype(); $tick_types = evTicketType::GetTicketTypes(); $T->set_block('event', 'registerBlock', 'rBlock'); if (is_array($this->Event->options['tickets'])) { foreach ($this->Event->options['tickets'] as $tic_type => $info) { $T->set_var(array('tic_description' => $tick_types[$tic_type]->description, 'tic_fee' => COM_numberFormat($info['fee'], 2))); $T->parse('rBlock', 'registerBlock', true); } } // Show the "manage reservations" link to the event owner if ($_EV_CONF['enable_rsvp'] == 1 && $this->Event->options['use_rsvp'] > 0) { if ($this->isAdmin) { $T->set_var('admin_rsvp', EVLIST_adminRSVP($this->rp_id)); } } $T->parse('output', 'event'); $retval .= $T->finish($T->get_var('output')); return $retval; }
/** * This function prints &$comments (db results set of comments) in comment format * -For previews, &$comments is assumed to be an associative array containing * data for a single comment. * * @param array &$comments Database result set of comments to be printed * @param string $mode 'flat', 'threaded', etc * @param string $type Type of item (article, poll, etc.) * @param string $order How to order the comments 'ASC' or 'DESC' * @param boolean $delete_option if current user can delete comments * @param boolean $preview Preview display (for edit) or not * @param int $ccode Comment code: -1=no comments, 0=allowed, 1=closed * @return string HTML Formated Comment * */ function CMT_getComment(&$comments, $mode, $type, $order, $delete_option = false, $preview = false, $ccode = 0) { global $_CONF, $_TABLES, $_USER, $LANG01, $LANG03, $MESSAGE, $_IMAGE_TYPE; $indent = 0; // begin with 0 indent $retval = ''; // initialize return value $template = new Template($_CONF['path_layout'] . 'comment'); $template->set_file(array('comment' => 'comment.thtml', 'thread' => 'thread.thtml')); // generic template variables $template->set_var('xhtml', XHTML); $template->set_var('site_url', $_CONF['site_url']); $template->set_var('site_admin_url', $_CONF['site_admin_url']); $template->set_var('layout_url', $_CONF['layout_url']); $template->set_var('lang_authoredby', $LANG01[42]); $template->set_var('lang_on', $LANG01[36]); $template->set_var('lang_permlink', $LANG01[120]); $template->set_var('order', $order); if ($ccode == 0) { $template->set_var('lang_replytothis', $LANG01[43]); $template->set_var('lang_reply', $LANG01[25]); } else { $template->set_var('lang_replytothis', ''); $template->set_var('lang_reply', ''); } // Make sure we have a default value for comment indentation if (!isset($_CONF['comment_indent'])) { $_CONF['comment_indent'] = 25; } if ($preview) { $A = $comments; if (empty($A['nice_date'])) { $A['nice_date'] = time(); } if (!isset($A['cid'])) { $A['cid'] = 0; } if (!isset($A['photo'])) { if (isset($_USER['photo'])) { $A['photo'] = $_USER['photo']; } else { $A['photo'] = ''; } } if (!isset($A['email'])) { if (isset($_USER['email'])) { $A['email'] = $_USER['email']; } else { $A['email'] = ''; } } $mode = 'flat'; } else { $A = DB_fetchArray($comments); } if (empty($A)) { return ''; } $token = ''; if ($delete_option && !$preview) { $token = SEC_createToken(); } // check for comment edit $row = 1; do { // check for comment edit $commentedit = DB_query("SELECT cid,uid,UNIX_TIMESTAMP(time) AS time FROM {$_TABLES['commentedits']} WHERE cid = {$A['cid']}"); $B = DB_fetchArray($commentedit); if ($B) { //comment edit present // get correct editor name if ($A['uid'] == $B['uid']) { $editname = $A['username']; } else { $editname = DB_getItem($_TABLES['users'], 'username', "uid={$B['uid']}"); } // add edit info to text $A['comment'] .= '<div class="comment-edit">' . $LANG03[30] . ' ' . strftime($_CONF['date'], $B['time']) . ' ' . $LANG03[31] . ' ' . $editname . '</div><!-- /COMMENTEDIT -->'; } // determines indentation for current comment if ($mode == 'threaded' || $mode == 'nested') { $indent = ($A['indent'] - $A['pindent']) * $_CONF['comment_indent']; } // comment variables $template->set_var('indent', $indent); $template->set_var('author_name', strip_tags($A['username'])); $template->set_var('author_id', $A['uid']); $template->set_var('cid', $A['cid']); $template->set_var('cssid', $row % 2); if ($A['uid'] > 1) { $fullname = ''; if (!empty($A['fullname'])) { $fullname = $A['fullname']; } $fullname = COM_getDisplayName($A['uid'], $A['username'], $fullname); $template->set_var('author_fullname', $fullname); $template->set_var('author', $fullname); $alttext = $fullname; $photo = ''; if ($_CONF['allow_user_photo']) { if (isset($A['photo']) && empty($A['photo'])) { $A['photo'] = '(none)'; } $photo = USER_getPhoto($A['uid'], $A['photo'], $A['email']); } if (!empty($photo)) { $template->set_var('author_photo', $photo); $camera_icon = '<img src="' . $_CONF['layout_url'] . '/images/smallcamera.' . $_IMAGE_TYPE . '" alt=""' . XHTML . '>'; $template->set_var('camera_icon', COM_createLink($camera_icon, $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $A['uid'])); } else { $template->set_var('author_photo', ''); $template->set_var('camera_icon', ''); } $template->set_var('start_author_anchortag', '<a href="' . $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $A['uid'] . '">'); $template->set_var('end_author_anchortag', '</a>'); $template->set_var('author_link', COM_createLink($fullname, $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $A['uid'])); } else { //comment is from anonymous user if (isset($A['name'])) { $A['username'] = strip_tags($A['name']); } $template->set_var('author', $A['username']); $template->set_var('author_fullname', $A['username']); $template->set_var('author_link', $A['username']); $template->set_var('author_photo', ''); $template->set_var('camera_icon', ''); $template->set_var('start_author_anchortag', ''); $template->set_var('end_author_anchortag', ''); } // hide reply link from anonymous users if they can't post replies $hidefromanon = false; if (empty($_USER['username']) && ($_CONF['loginrequired'] == 1 || $_CONF['commentsloginrequired'] == 1)) { $hidefromanon = true; } // this will hide HTML that should not be viewed in preview mode if ($preview || $hidefromanon) { $template->set_var('hide_if_preview', 'style="display:none"'); } else { $template->set_var('hide_if_preview', ''); } // for threaded mode, add a link to comment parent if ($mode == 'threaded' && $A['pid'] != 0 && $indent == 0) { $result = DB_query("SELECT title,pid FROM {$_TABLES['comments']} WHERE cid = '{$A['pid']}'"); $P = DB_fetchArray($result); if ($P['pid'] != 0) { $plink = $_CONF['site_url'] . '/comment.php?mode=display&sid=' . $A['sid'] . '&title=' . urlencode(htmlspecialchars($P['title'])) . '&type=' . $type . '&order=' . $order . '&pid=' . $P['pid'] . '&format=threaded'; } else { $plink = $_CONF['site_url'] . '/comment.php?mode=view&sid=' . $A['sid'] . '&title=' . urlencode(htmlspecialchars($P['title'])) . '&type=' . $type . '&order=' . $order . '&cid=' . $A['pid'] . '&format=threaded'; } $parent_link = COM_createLink($LANG01[44], $plink) . ' | '; $template->set_var('parent_link', $parent_link); } else { $template->set_var('parent_link', ''); } $template->set_var('date', strftime($_CONF['date'], $A['nice_date'])); $template->set_var('sid', $A['sid']); $template->set_var('type', $A['type']); // COMMENT edit rights $edit_option = false; if (isset($A['uid']) && isset($_USER['uid']) && $_USER['uid'] == $A['uid'] && $_CONF['comment_edit'] == 1 && time() - $A['nice_date'] < $_CONF['comment_edittime'] && DB_getItem($_TABLES['comments'], 'COUNT(*)', "pid = {$A['cid']}") == 0) { $edit_option = true; if (empty($token)) { $token = SEC_createToken(); } } elseif (SEC_hasRights('comment.moderate')) { $edit_option = true; } // edit link $edit = ''; if ($edit_option) { $editlink = $_CONF['site_url'] . '/comment.php?mode=edit&cid=' . $A['cid'] . '&sid=' . $A['sid'] . '&type=' . $type; $edit = COM_createLink($LANG01[4], $editlink) . ' | '; } // unsubscribe link $unsubscribe = ''; if ($_CONF['allow_reply_notifications'] == 1 && !COM_isAnonUser() && isset($A['uid']) && isset($_USER['uid']) && $_USER['uid'] == $A['uid']) { $hash = DB_getItem($_TABLES['commentnotifications'], 'deletehash', "cid = {$A['cid']} AND uid = {$_USER['uid']}"); if (!empty($hash)) { $unsublink = $_CONF['site_url'] . '/comment.php?mode=unsubscribe&key=' . $hash; $unsubattr = array('title' => $LANG03[43]); $unsubscribe = COM_createLink($LANG03[42], $unsublink, $unsubattr) . ' | '; } } // if deletion is allowed, displays delete link if ($delete_option) { $deloption = ''; // always place edit option first, if available if (!empty($edit)) { $deloption .= $edit; } // actual delete option $dellink = $_CONF['site_url'] . '/comment.php?mode=delete&cid=' . $A['cid'] . '&sid=' . $A['sid'] . '&type=' . $type . '&' . CSRF_TOKEN . '=' . $token; $delattr = array('onclick' => "return confirm('{$MESSAGE[76]}');"); $deloption .= COM_createLink($LANG01[28], $dellink, $delattr) . ' | '; if (!empty($A['ipaddress'])) { if (empty($_CONF['ip_lookup'])) { $deloption .= $A['ipaddress'] . ' | '; } else { $iplookup = str_replace('*', $A['ipaddress'], $_CONF['ip_lookup']); $deloption .= COM_createLink($A['ipaddress'], $iplookup) . ' | '; } } if (!empty($unsubscribe)) { $deloption .= $unsubscribe; } $template->set_var('delete_option', $deloption); } elseif ($edit_option) { $template->set_var('delete_option', $edit . $unsubscribe); } elseif (!COM_isAnonUser()) { $reportthis = ''; if ($A['uid'] != $_USER['uid']) { $reportthis_link = $_CONF['site_url'] . '/comment.php?mode=report&cid=' . $A['cid'] . '&type=' . $type; $report_attr = array('title' => $LANG01[110]); $reportthis = COM_createLink($LANG01[109], $reportthis_link, $report_attr) . ' | '; } $template->set_var('delete_option', $reportthis . $unsubscribe); } else { $template->set_var('delete_option', ''); } //and finally: format the actual text of the comment, but check only the text, not sig or edit $text = str_replace('<!-- COMMENTSIG --><div class="comment-sig">', '', $A['comment']); $text = str_replace('</div><!-- /COMMENTSIG -->', '', $text); $text = str_replace('<div class="comment-edit">', '', $text); $text = str_replace('</div><!-- /COMMENTEDIT -->', '', $text); if (preg_match('/<.*>/', $text) == 0) { $A['comment'] = nl2br($A['comment']); } // highlight search terms if specified if (!empty($_REQUEST['query'])) { $A['comment'] = COM_highlightQuery($A['comment'], $_REQUEST['query']); } $A['comment'] = str_replace('$', '$', $A['comment']); $A['comment'] = str_replace('{', '{', $A['comment']); $A['comment'] = str_replace('}', '}', $A['comment']); // Replace any plugin autolink tags $A['comment'] = PLG_replaceTags($A['comment']); // create a reply to link $reply_link = ''; if ($ccode == 0) { $reply_link = $_CONF['site_url'] . '/comment.php?sid=' . $A['sid'] . '&pid=' . $A['cid'] . '&title=' . urlencode($A['title']) . '&type=' . $A['type']; $reply_option = COM_createLink($LANG01[43], $reply_link, array('rel' => 'nofollow')) . ' | '; $template->set_var('reply_option', $reply_option); } else { $template->set_var('reply_option', ''); } $template->set_var('reply_link', $reply_link); // format title for display, must happen after reply_link is created $A['title'] = htmlspecialchars($A['title']); $A['title'] = str_replace('$', '$', $A['title']); $template->set_var('title', $A['title']); $template->set_var('comments', $A['comment']); // parse the templates if ($mode == 'threaded' && $indent > 0) { $template->set_var('pid', $A['pid']); $retval .= $template->parse('output', 'thread'); } else { $template->set_var('pid', $A['cid']); $retval .= $template->parse('output', 'comment'); } $row++; } while ($A = DB_fetchArray($comments)); return $retval; }
/** * Takes an article class and renders HTML in the specified template and style. * * Formats the given article into HTML. Called by index.php, article.php, * submit.php and admin/story.php (Preview mode for the last two). * * @param object $story The story to display, an instance of the Story class. * @param string $index n = 'Compact display' for list of stories. p = 'Preview' mode. Else full display of article. * @param string $storytpl The template to use to render the story. * @param string $query A search query, if one was specified. * * @return string Article as formated HTML. * * Note: Formerly named COM_Article, and re-written totally since then. */ function STORY_renderArticle(&$story, $index = '', $storytpl = 'storytext.thtml', $query = '') { global $_CONF, $_TABLES, $_USER, $LANG01, $LANG05, $LANG11, $LANG_TRB, $_IMAGE_TYPE, $mode; static $storycounter = 0; if (empty($storytpl)) { $storytpl = 'storytext.thtml'; } $introtext = $story->displayElements('introtext'); $bodytext = $story->displayElements('bodytext'); if (!empty($query)) { $introtext = COM_highlightQuery($introtext, $query); $bodytext = COM_highlightQuery($bodytext, $query); } $article = new Template($_CONF['path_layout']); $article->set_file(array('article' => $storytpl, 'bodytext' => 'storybodytext.thtml', 'featuredarticle' => 'featuredstorytext.thtml', 'featuredbodytext' => 'featuredstorybodytext.thtml', 'archivearticle' => 'archivestorytext.thtml', 'archivebodytext' => 'archivestorybodytext.thtml')); $article->set_var('xhtml', XHTML); $article->set_var('layout_url', $_CONF['layout_url']); $article->set_var('site_url', $_CONF['site_url']); $article->set_var('site_admin_url', $_CONF['site_admin_url']); $article->set_var('site_name', $_CONF['site_name']); $article->set_var('story_date', $story->DisplayElements('date')); $article->set_var('story_date_short', $story->DisplayElements('shortdate')); $article->set_var('story_date_only', $story->DisplayElements('dateonly')); if ($_CONF['hideviewscount'] != 1) { $article->set_var('lang_views', $LANG01[106]); $article->set_var('story_hits', $story->DisplayElements('hits')); } $article->set_var('story_id', $story->getSid()); if ($_CONF['contributedbyline'] == 1) { $article->set_var('lang_contributed_by', $LANG01[1]); $article->set_var('contributedby_uid', $story->DisplayElements('uid')); $fullname = $story->DisplayElements('fullname'); $username = $story->DisplayElements('username'); $article->set_var('contributedby_user', $username); if (empty($fullname)) { $article->set_var('contributedby_fullname', $username); } else { $article->set_var('contributedby_fullname', $fullname); } $authorname = COM_getDisplayName($story->DisplayElements('uid'), $username, $fullname); $article->set_var('contributedby_author', $authorname); $article->set_var('author', $authorname); if ($story->DisplayElements('uid') > 1) { $profileUrl = $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $story->DisplayElements('uid'); $article->set_var('start_contributedby_anchortag', '<a class="storybyline" href="' . $profileUrl . '">'); $article->set_var('end_contributedby_anchortag', '</a>'); $article->set_var('contributedby_url', $profileUrl); } $photo = ''; if ($_CONF['allow_user_photo'] == 1) { $authphoto = $story->DisplayElements('photo'); if (empty($authphoto)) { $authphoto = '(none)'; // user does not have a photo } $photo = USER_getPhoto($story->DisplayElements('uid'), $authphoto, $story->DisplayElements('email')); } if (!empty($photo)) { $article->set_var('contributedby_photo', $photo); $article->set_var('author_photo', $photo); $camera_icon = '<img src="' . $_CONF['layout_url'] . '/images/smallcamera.' . $_IMAGE_TYPE . '" alt=""' . XHTML . '>'; $article->set_var('camera_icon', COM_createLink($camera_icon, $profileUrl)); } else { $article->set_var('contributedby_photo', ''); $article->set_var('author_photo', ''); $article->set_var('camera_icon', ''); } } $topicname = $story->DisplayElements('topic'); $article->set_var('story_topic_id', $story->DisplayElements('tid')); $article->set_var('story_topic_name', $topicname); $topicurl = $_CONF['site_url'] . '/index.php?topic=' . $story->DisplayElements('tid'); if ((!isset($_USER['noicons']) or $_USER['noicons'] != 1) and $story->DisplayElements('show_topic_icon') == 1) { $imageurl = $story->DisplayElements('imageurl'); if (!empty($imageurl)) { $imageurl = COM_getTopicImageUrl($imageurl); $article->set_var('story_topic_image_url', $imageurl); $topicimage = '<img src="' . $imageurl . '" class="float' . $_CONF['article_image_align'] . '" alt="' . $topicname . '" title="' . $topicname . '"' . XHTML . '>'; $article->set_var('story_anchortag_and_image', COM_createLink($topicimage, $topicurl, array('rel' => "category"))); $article->set_var('story_topic_image', $topicimage); $topicimage_noalign = '<img src="' . $imageurl . '" alt="' . $topicname . '" title="' . $topicname . '"' . XHTML . '>'; $article->set_var('story_anchortag_and_image_no_align', COM_createLink($topicimage_noalign, $topicurl, array('rel' => "category"))); $article->set_var('story_topic_image_no_align', $topicimage_noalign); } } $article->set_var('story_topic_url', $topicurl); $recent_post_anchortag = ''; $articleUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid()); $article->set_var('story_title', $story->DisplayElements('title')); $article->set_var('lang_permalink', $LANG01[127]); $show_comments = true; // n = 'Compact display' for list of stories. p = 'Preview' mode. if ($index != 'n' && $index != 'p' || !empty($query)) { $attributes = ' class="non-ul"'; $attr_array = array('class' => 'non-ul'); if (!empty($query)) { $attributes .= ' rel="bookmark"'; $attr_array['rel'] = 'bookmark'; } $article->set_var('start_storylink_anchortag', '<a href="' . $articleUrl . '"' . $attributes . '>'); $article->set_var('end_storylink_anchortag', '</a>'); $article->set_var('story_title_link', COM_createLink($story->DisplayElements('title'), $articleUrl, $attr_array)); } else { $article->set_var('story_title_link', $story->DisplayElements('title')); } if ($index == 'n' || $index == 'p') { if (empty($bodytext)) { $article->set_var('story_introtext', $introtext); $article->set_var('story_text_no_br', $introtext); } else { if ($_CONF['allow_page_breaks'] == 1 and $index == 'n') { $story_page = 1; // page selector if (is_numeric($mode)) { $story_page = $mode; if ($story_page <= 0) { $story_page = 1; $mode = 0; } elseif ($story_page > 1) { $introtext = ''; } } $article_array = explode('[page_break]', $bodytext); $pagelinks = COM_printPageNavigation($articleUrl, $story_page, count($article_array), 'mode=', $_CONF['url_rewrite'], $LANG01[118]); if (count($article_array) > 1) { $bodytext = $article_array[$story_page - 1]; } $article->set_var('page_selector', $pagelinks); if ($_CONF['page_break_comments'] == 'last' and $story_page < count($article_array) or $_CONF['page_break_comments'] == 'first' and $story_page != 1) { $show_comments = false; } $article->set_var('story_page', $story_page); } $article->set_var('story_introtext', $introtext . '<br' . XHTML . '><br' . XHTML . '>' . $bodytext); $article->set_var('story_text_no_br', $introtext . ' ' . $bodytext); } $article->set_var('story_introtext_only', $introtext); $article->set_var('story_bodytext_only', $bodytext); if (($_CONF['trackback_enabled'] || $_CONF['pingback_enabled']) && SEC_hasRights('story.ping')) { $url = $_CONF['site_admin_url'] . '/trackback.php?mode=sendall&id=' . $story->getSid(); $article->set_var('send_trackback_link', COM_createLink($LANG_TRB['send_trackback'], $url)); $pingico = '<img src="' . $_CONF['layout_url'] . '/images/sendping.' . $_IMAGE_TYPE . '" alt="' . $LANG_TRB['send_trackback'] . '" title="' . $LANG_TRB['send_trackback'] . '"' . XHTML . '>'; $article->set_var('send_trackback_icon', COM_createLink($pingico, $url)); $article->set_var('send_trackback_url', $url); $article->set_var('lang_send_trackback_text', $LANG_TRB['send_trackback']); } $article->set_var('story_display', $index == 'p' ? 'preview' : 'article'); $article->set_var('story_counter', 0); } else { $article->set_var('story_introtext', $introtext); $article->set_var('story_text_no_br', $introtext); $article->set_var('story_introtext_only', $introtext); if (!empty($bodytext)) { $article->set_var('lang_readmore', $LANG01[2]); $article->set_var('lang_readmore_words', $LANG01[62]); $numwords = COM_numberFormat(count(explode(' ', COM_getTextContent($bodytext)))); $article->set_var('readmore_words', $numwords); $article->set_var('readmore_link', COM_createLink($LANG01[2], $articleUrl, array('class' => 'story-read-more-link')) . ' (' . $numwords . ' ' . $LANG01[62] . ') '); $article->set_var('start_readmore_anchortag', '<a href="' . $articleUrl . '" class="story-read-more-link">'); $article->set_var('end_readmore_anchortag', '</a>'); $article->set_var('read_more_class', 'class="story-read-more-link"'); } if ($story->DisplayElements('commentcode') >= 0 and $show_comments) { $commentsUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid()) . '#comments'; $article->set_var('comments_url', $commentsUrl); $article->set_var('comments_text', COM_numberFormat($story->DisplayElements('comments')) . ' ' . $LANG01[3]); $article->set_var('comments_count', COM_numberFormat($story->DisplayElements('comments'))); $article->set_var('lang_comments', $LANG01[3]); $comments_with_count = sprintf($LANG01[121], COM_numberFormat($story->DisplayElements('comments'))); if ($story->DisplayElements('comments') > 0) { $result = DB_query("SELECT UNIX_TIMESTAMP(date) AS day,username,fullname,{$_TABLES['comments']}.uid as cuid FROM {$_TABLES['comments']},{$_TABLES['users']} WHERE {$_TABLES['users']}.uid = {$_TABLES['comments']}.uid AND sid = '" . $story->getsid() . "' ORDER BY date desc LIMIT 1"); $C = DB_fetchArray($result); $recent_post_anchortag = '<span class="storybyline">' . $LANG01[27] . ': ' . strftime($_CONF['daytime'], $C['day']) . ' ' . $LANG01[104] . ' ' . COM_getDisplayName($C['cuid'], $C['username'], $C['fullname']) . '</span>'; $article->set_var('comments_with_count', COM_createLink($comments_with_count, $commentsUrl)); $article->set_var('start_comments_anchortag', '<a href="' . $commentsUrl . '">'); $article->set_var('end_comments_anchortag', '</a>'); } else { $article->set_var('comments_with_count', $comments_with_count); $recent_post_anchortag = COM_createLink($LANG01[60], $_CONF['site_url'] . '/comment.php?sid=' . $story->getsid() . '&pid=0&type=article'); } if ($story->DisplayElements('commentcode') == 0) { $postCommentUrl = $_CONF['site_url'] . '/comment.php?sid=' . $story->getSid() . '&pid=0&type=article'; $article->set_var('post_comment_link', COM_createLink($LANG01[60], $postCommentUrl, array('rel' => 'nofollow'))); /* $article->set_var( 'subscribe_link', COM_createLink('Nubbies', '', array('rel' => 'nofollow')) ); */ $article->set_var('lang_post_comment', $LANG01[60]); $article->set_var('start_post_comment_anchortag', '<a href="' . $postCommentUrl . '" rel="nofollow">'); $article->set_var('end_post_comment_anchortag', '</a>'); } } if (($_CONF['trackback_enabled'] || $_CONF['pingback_enabled']) && $story->DisplayElements('trackbackcode') >= 0 && $show_comments) { $num_trackbacks = COM_numberFormat($story->DisplayElements('trackbacks')); $trackbacksUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid()) . '#trackback'; $article->set_var('trackbacks_url', $trackbacksUrl); $article->set_var('trackbacks_text', $num_trackbacks . ' ' . $LANG_TRB['trackbacks']); $article->set_var('trackbacks_count', $num_trackbacks); $article->set_var('lang_trackbacks', $LANG_TRB['trackbacks']); $article->set_var('trackbacks_with_count', COM_createLink(sprintf($LANG01[122], $num_trackbacks), $trackbacksUrl)); if (SEC_hasRights('story.ping')) { $pingurl = $_CONF['site_admin_url'] . '/trackback.php?mode=sendall&id=' . $story->getSid(); $pingico = '<img src="' . $_CONF['layout_url'] . '/images/sendping.' . $_IMAGE_TYPE . '" alt="' . $LANG_TRB['send_trackback'] . '" title="' . $LANG_TRB['send_trackback'] . '"' . XHTML . '>'; $article->set_var('send_trackback_icon', COM_createLink($pingico, $pingurl)); } if ($story->DisplayElements('trackbacks') > 0) { $article->set_var('trackbacks_with_count', COM_createLink(sprintf($LANG01[122], $num_trackbacks), $trackbacksUrl)); } else { $article->set_var('trackbacks_with_count', sprintf($LANG01[122], $num_trackbacks)); } } if ($_CONF['hideemailicon'] == 1 || empty($_USER['username']) && ($_CONF['loginrequired'] == 1 || $_CONF['emailstoryloginrequired'] == 1)) { $article->set_var('email_icon', ''); } else { $emailUrl = $_CONF['site_url'] . '/profiles.php?sid=' . $story->getSid() . '&what=emailstory'; $emailicon = '<img src="' . $_CONF['layout_url'] . '/images/mail.' . $_IMAGE_TYPE . '" alt="' . $LANG01[64] . '" title="' . $LANG11[2] . '"' . XHTML . '>'; $article->set_var('email_icon', COM_createLink($emailicon, $emailUrl)); $article->set_var('email_story_url', $emailUrl); $article->set_var('lang_email_story', $LANG11[2]); $article->set_var('lang_email_story_alt', $LANG01[64]); } $printUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid() . '&mode=print'); if ($_CONF['hideprintericon'] == 1) { $article->set_var('print_icon', ''); } else { $printicon = '<img src="' . $_CONF['layout_url'] . '/images/print.' . $_IMAGE_TYPE . '" alt="' . $LANG01[65] . '" title="' . $LANG11[3] . '"' . XHTML . '>'; $article->set_var('print_icon', COM_createLink($printicon, $printUrl, array('rel' => 'nofollow'))); $article->set_var('print_story_url', $printUrl); $article->set_var('lang_print_story', $LANG11[3]); $article->set_var('lang_print_story_alt', $LANG01[65]); } $article->set_var('story_display', 'index'); $storycounter++; $article->set_var('story_counter', $storycounter); } $article->set_var('article_url', $articleUrl); $article->set_var('recent_post_anchortag', $recent_post_anchortag); if ($story->checkAccess() == 3 and SEC_hasrights('story.edit') and $index != 'p') { $article->set_var('edit_link', COM_createLink($LANG01[4], $_CONF['site_admin_url'] . '/story.php?mode=edit&sid=' . $story->getSid())); $article->set_var('edit_url', $_CONF['site_admin_url'] . '/story.php?mode=edit&sid=' . $story->getSid()); $article->set_var('lang_edit_text', $LANG01[4]); $editicon = $_CONF['layout_url'] . '/images/edit.' . $_IMAGE_TYPE; $editiconhtml = '<img src="' . $editicon . '" alt="' . $LANG01[4] . '" title="' . $LANG01[4] . '"' . XHTML . '>'; $article->set_var('edit_icon', COM_createLink($editiconhtml, $_CONF['site_admin_url'] . '/story.php?mode=edit&sid=' . $story->getSid())); $article->set_var('edit_image', $editiconhtml); } if ($story->DisplayElements('featured') == 1) { $article->set_var('lang_todays_featured_article', $LANG05[4]); $article->parse('story_bodyhtml', 'featuredbodytext', true); PLG_templateSetVars('featuredstorytext', $article); $article->parse('finalstory', 'featuredarticle'); } elseif ($story->DisplayElements('statuscode') == STORY_ARCHIVE_ON_EXPIRE and $story->DisplayElements('expire') <= time()) { $article->parse('story_bodyhtml', 'archivestorybodytext', true); PLG_templateSetVars('archivestorytext', $article); $article->parse('finalstory', 'archivearticle'); } else { $article->parse('story_bodyhtml', 'bodytext', true); PLG_templateSetVars('storytext', $article); $article->parse('finalstory', 'article'); } return $article->finish($article->get_var('finalstory')); }
/** * Display the detail page for the product. * * @return string HTML for the product page. */ public function Detail() { global $_CONF, $_PP_CONF, $_TABLES, $LANG_PP, $_USER, $_SYSTEM; USES_lib_comments(); $prod_id = $this->id; if ($prod_id < 1 || !$this->enabled || !$this->isAvailable()) { return PAYPAL_errorMessage($LANG_PP['invalid_product_id'], 'info'); } $retval = COM_startBlock(); // Set the template dir based on the configured template version $tpl_dir = PAYPAL_PI_PATH . '/templates/detail/' . $_PP_CONF['product_tpl_ver']; $T = new Template($tpl_dir); $T->set_file('product', 'product_detail_attrib.thtml'); $name = $this->name; $l_desc = PLG_replaceTags($this->description); $s_desc = PLG_replaceTags($this->short_description); // Highlight the query terms if coming from a search if (isset($_REQUEST['query']) && !empty($_REQUEST['query'])) { $name = COM_highlightQuery($name, $_REQUEST['query']); $l_desc = COM_highlightQuery($l_desc, $_REQUEST['query']); $s_desc = COM_highlightQuery($s_desc, $_REQUEST['query']); } $onsale = $this->isOnSale(); $act_price = $onsale ? $this->sale_price : $this->price; $qty_disc_txt = ''; foreach ($this->qty_discounts as $qty => $pct) { $qty_disc_txt .= sprintf('Buy %d, save %.02f%%<br />', $qty, $pct); } // Get custom text input fields if ('' != $this->custom) { $T->set_block('product', 'CustAttrib', 'cAttr'); $text_field_names = explode('|', $this->custom); foreach ($text_field_names as $id => $text_field_name) { $T->set_var(array('fld_id' => "cust_text_fld_{$id}", 'fld_name' => htmlspecialchars($text_field_name))); $T->parse('cAttr', 'CustAttrib', true); } } $T->set_var(array('is_uikit' => $_SYSTEM['framework'] == 'uikit' ? 'true' : '', 'have_attributes' => $this->hasAttributes(), 'id' => $prod_id, 'name' => $name, 'short_description' => $s_desc, 'description' => $l_desc, 'cur_decimals' => $this->currency->Decimals(), 'price' => $this->currency->FormatValue($act_price), 'orig_price' => $this->currency->Format($this->price), 'on_sale' => $onsale ? 'true' : '', 'img_cell_width' => $_PP_CONF['max_thumb_size'] + 20, 'price_prefix' => $this->currency->Pre(), 'price_postfix' => $this->currency->Post(), 'onhand' => $this->track_onhand ? $this->onhand : '', 'qty_disc' => $qty_disc_txt)); // Retrieve the photos and put into the template $sql = "SELECT img_id, filename\n FROM {$_TABLES['paypal.images']} \n WHERE product_id='{$prod_id}'"; //echo $sql;die; $img_res = DB_query($sql); $photo_detail = ''; $T->set_var('have_photo', ''); // assume no photo available if ($img_res && DB_numRows($img_res) > 0) { for ($i = 0; $prow = DB_fetchArray($img_res, false); $i++) { if ($prow['filename'] != '' && file_exists("{$_PP_CONF['image_dir']}/{$prow['filename']}")) { if ($i == 0) { $T->set_var('main_img', PAYPAL_ImageUrl($prow['filename'], $tpl_config['lg_img_width'] - 20, $tpl_config['lg_img_height'] - 20)); } $T->set_block('product', 'Thumbnail', 'PBlock'); $T->set_var(array('img_file' => $prow['filename'], 'disp_img' => PAYPAL_ImageUrl($prow['filename'], $tpl_config['lg_img_width'] - 20, $tpl_config['lg_img_height'] - 20), 'lg_img' => PAYPAL_URL . '/images/products/' . $prow['filename'], 'img_url' => PAYPAL_URL . '/images/products', 'thumb_url' => PAYPAL_ImageUrl($prow['filename']), 'tn_width' => $_PP_CONF['max_thumb_size'], 'tn_height' => $_PP_CONF['max_thumb_size'])); $T->parse('PBlock', 'Thumbnail', true); } } } // Get the product options, if any, and set them into the form $cbrk = ''; $T->set_block('product', 'AttrSelect', 'attrSel'); foreach ($this->options as $id => $Attr) { /*if ($Attr['attr_value'] === '') { $type = 'text'; } else { $type = 'select'; }*/ $type = 'select'; if ($Attr['attr_name'] != $cbrk) { if ($cbrk != '') { // end block if not the first element $T->set_var(array('attr_name' => $cbrk, 'attr_options' => $attributes, 'opt_id' => $id)); $T->parse('attrSel', 'AttrSelect', true); } $cbrk = $Attr['attr_name']; $attributes = ''; } if ($type == 'select') { if ($Attr['attr_price'] != 0) { $attr_str = sprintf(" ( %+.2f )", $Attr['attr_price']); } else { $attr_str = ''; } $attributes .= '<option value="' . $id . '|' . $Attr['attr_value'] . '|' . $Attr['attr_price'] . '">' . $Attr['attr_value'] . $attr_str . '</option>' . LB; /*} else { $attributes .= "<input type=\"hidden\" name=\"on{$i}\" value=\"{$Attr['attr_name']}\">\n"; $attributes .= $Attr['attr_name'] . ':</td> <td><input class="uk-contrast uk-form" type"text" name="os' . $i. '" value="" size="32" /></td></tr>'; */ } } if ($cbrk != '') { // finish off the last selection $T->set_var(array('attr_name' => $cbrk, 'attr_options' => $attributes, 'opt_id' => $id)); $T->parse('attrSel', 'AttrSelect', true); } $buttons = $this->PurchaseLinks(); $T->set_block('product', 'BtnBlock', 'Btn'); foreach ($buttons as $name => $html) { if ($name == 'add_cart') { // Set the add to cart button in the main form $T->set_var('add_cart_button', $html); } else { $T->set_var('buy_now_button', $html); $T->parse('Btn', 'BtnBlock', true); } } // Show the user comments if enabled globally and for this product if (plugin_commentsupport_paypal() && $this->comments_enabled != PP_COMMENTS_DISABLED) { // if enabled or closed if ($_CONF['commentsloginrequired'] == 1 && COM_isAnonUser()) { // Set mode to "disabled" $mode = -1; } else { $mode = $this->comments_enabled; } $T->set_var('usercomments', CMT_userComments($prod_id, $this->short_description, 'paypal', '', '', 0, 1, false, false, $mode)); } if ($this->rating_enabled == 1) { $PP_ratedIds = RATING_getRatedIds('paypal'); if (in_array($prod_id, $PP_ratedIds)) { $static = true; $voted = 1; } elseif (plugin_canuserrate_paypal($A['id'], $_USER['uid'])) { $static = 0; $voted = 0; } else { $static = 1; $voted = 0; } $rating_box = RATING_ratingBar('paypal', $prod_id, $this->votes, $this->rating, $voted, 5, $static, 'sm'); $T->set_var('rating_bar', $rating_box); } else { $T->set_var('ratign_bar', ''); } if ($this->isAdmin) { // Add the quick-edit link for administrators $T->set_var(array('pi_admin_url' => PAYPAL_ADMIN_URL, 'can_edit' => 'true')); } $retval .= $T->parse('output', 'product'); // Update the hit counter DB_query("UPDATE {$_TABLES['paypal.products']}\n SET views = views + 1\n WHERE id = '{$prod_id}'"); $retval .= COM_endBlock(); return $retval; }
/** * Display the detail page for the product. * * @return string HTML for the product page. */ public function Detail() { global $_CONF, $_PP_CONF, $_TABLES, $LANG_PP, $_USER; USES_lib_comments(); $prod_id = $this->id; if ($prod_id < 1 || !$this->enabled) { return PAYPAL_errorMessage($LANG_PP['invalid_product_id'], 'info'); } $retval = COM_startBlock(); // Set the template dir based on the configured template version $T = new Template(PAYPAL_PI_PATH . '/templates/detail' . $_PP_CONF['tpl_ver_detail']); if ($this->hasAttributes()) { $detail_template = 'product_detail_attrib.thtml'; } else { $detail_template = 'product_detail.thtml'; } $T->set_file('product', $detail_template); $name = $this->name; $l_desc = PLG_replaceTags($this->description); $s_desc = PLG_replaceTags($this->short_description); // Highlight the query terms if coming from a search if (isset($_REQUEST['query']) && !empty($_REQUEST['query'])) { $name = COM_highlightQuery($name, $_REQUEST['query']); $l_desc = COM_highlightQuery($l_desc, $_REQUEST['query']); $s_desc = COM_highlightQuery($s_desc, $_REQUEST['query']); } $act_price = $this->sale_price == $this->price ? $this->price : $this->sale_price; $T->set_var(array('id' => $prod_id, 'name' => $name, 'short_description' => $s_desc, 'description' => $l_desc, 'cur_decimals' => $this->currency->Decimals(), 'price' => $this->currency->FormatValue($act_price), 'orig_price' => $this->currency->Format($this->price), 'on_sale' => $act_price == $this->price ? '' : 'true', 'img_cell_width' => $_PP_CONF['max_thumb_size'] + 20, 'price_prefix' => $this->currency->Pre(), 'price_postfix' => $this->currency->Post(), 'onhand' => $this->track_onhand ? $this->onhand : '')); // Retrieve the photos and put into the template $sql = "SELECT img_id, filename\n FROM {$_TABLES['paypal.images']} \n WHERE product_id='{$prod_id}'"; //echo $sql;die; $img_res = DB_query($sql); $photo_detail = ''; $T->set_var('have_photo', ''); // assume no photo available if ($img_res && DB_numRows($img_res) > 0) { for ($i = 0; $prow = DB_fetchArray($img_res, false); $i++) { if ($prow['filename'] != '' && file_exists("{$_PP_CONF['image_dir']}/{$prow['filename']}")) { if ($i == 0) { $T->set_var('main_img', $prow['filename']); } $T->set_block('product', 'Thumbnail', 'PBlock'); $T->set_var('img_file', $prow['filename']); $T->set_var('img_url', PAYPAL_URL . '/images/products'); $T->set_var('thumb_url', PAYPAL_ImageUrl($prow['filename'])); $T->parse('PBlock', 'Thumbnail', true); $T->set_var('have_photo', 'true'); } } } // Get the product options, if any, and set them into the form $i = 0; $cbrk = ''; $attributes = ''; foreach ($this->options as $id => $Attr) { if ($Attr['attr_name'] != $cbrk) { if ($i > 0) { $attributes .= "</select></td></tr>\n"; } else { $attributes = '<table border="0">' . "\n"; } $cbrk = $Attr['attr_name']; $attributes .= "<tr><td>\n <input type=\"hidden\" name=\"on{$i}\" \n value=\"{$Attr['attr_name']}\">\n\n <input type=\"hidden\" name=\"os{$i}\" \n value=\"\">\n\n {$Attr['attr_name']}:</td>\n <td align=\"left\">\n <select name=\"options[]\"\n onchange=\"ProcessForm(this.form);\">\n"; /*<td align=\"left\"><select name=\"pp_os{$i}\"*/ $i++; } if ($Attr['attr_price'] != 0) { $attr_str = sprintf(" ( %+.2f )", $Attr['attr_price']); } else { $attr_str = ''; } $attributes .= '<option value="' . $id . '|' . $Attr['attr_value'] . '|' . $Attr['attr_price'] . '">' . $Attr['attr_value'] . $attr_str . '</option>' . LB; } if ($attributes != '') { $attributes .= "</select></td></tr></table>\n"; $T->set_var('attributes', $attributes); } $buttons = $this->PurchaseLinks(); $T->set_block('product', 'BtnBlock', 'Btn'); foreach ($buttons as $name => $html) { $T->set_var('button', $html); $T->parse('Btn', 'BtnBlock', true); } // Show the user comments if enabled globally and for this product if (plugin_commentsupport_paypal() && $this->comments_enabled != PP_COMMENTS_DISABLED) { // if enabled or closed if ($_CONF['commentsloginrequired'] == 1 && COM_isAnonUser()) { // Set mode to "disabled" $mode = -1; } else { $mode = $this->comments_enabled; } $T->set_var('usercomments', CMT_userComments($prod_id, $this->short_description, 'paypal', '', '', 0, 1, false, false, $mode)); } if ($this->rating_enabled == 1) { $PP_ratedIds = RATING_getRatedIds('paypal'); if (in_array($prod_id, $PP_ratedIds)) { $static = true; $voted = 1; } elseif (plugin_canuserrate_paypal($A['id'], $_USER['uid'])) { $static = 0; $voted = 0; } else { $static = 1; $voted = 0; } $rating_box = RATING_ratingBar('paypal', $prod_id, $this->votes, $this->rating, $voted, 5, $static, 'sm'); $T->set_var('rating_bar', $rating_box); } else { $T->set_var('ratign_bar', ''); } if ($this->isAdmin) { // Add the quick-edit link for administrators $T->set_var(array('pi_admin_url' => PAYPAL_ADMIN_URL, 'can_edit' => 'true')); } $retval .= $T->parse('output', 'product'); // Update the hit counter DB_query("UPDATE {$_TABLES['paypal.products']}\n SET views = views + 1\n WHERE id = '{$prod_id}'"); $retval .= COM_endBlock(); return $retval; }
/** * This function prints &$comments (db results set of comments) in comment format * -For previews, &$comments is assumed to be an associative array containing * data for a single comment. * * @param array &$comments Database result set of comments to be printed * @param string $mode 'flat', 'threaded', etc * @param string $type Type of item (article, polls, etc.) * @param string $order How to order the comments 'ASC' or 'DESC' * @param boolean $delete_option if current user can delete comments * @param boolean $preview Preview display (for edit) or not * @param int $ccode Comment code: -1=no comments, 0=allowed, 1=closed * @return string HTML Formated Comment * */ function CMT_getComment(&$comments, $mode, $type, $order, $delete_option = false, $preview = false, $ccode = 0, $sid_author_id = '') { global $_CONF, $_TABLES, $_USER, $LANG01, $LANG03, $MESSAGE, $_IMAGE_TYPE; $indent = 0; // begin with 0 indent $retval = ''; // initialize return value $filter = sanitizer::getInstance(); $AllowedElements = $filter->makeAllowedElements($_CONF['htmlfilter_comment']); $filter->setAllowedelements($AllowedElements); $filter->setNamespace('glfusion', 'comment'); if ($mode == 'threaded') { $mode = 'nested'; } $template = new Template($_CONF['path_layout'] . 'comment'); $template->set_file(array('comment' => 'comment.thtml', 'thread' => 'thread.thtml')); // generic template variables $template->set_var('lang_authoredby', $LANG01[42]); $template->set_var('lang_on', $LANG01[36]); $template->set_var('lang_permlink', $LANG01[120]); $template->set_var('order', $order); if ($ccode == 0 && ($_CONF['commentsloginrequired'] == 0 || !COM_isAnonUser())) { $template->set_var('lang_replytothis', $LANG01[43]); $template->set_var('lang_reply', $LANG01[25]); } else { $template->set_var('lang_replytothis', ''); $template->set_var('lang_reply', ''); } // Make sure we have a default value for comment indentation if (!isset($_CONF['comment_indent'])) { $_CONF['comment_indent'] = 25; } if ($preview) { $A = $comments; if (empty($A['nice_date'])) { $A['nice_date'] = time(); } if (!isset($A['cid'])) { $A['cid'] = 0; } if (!isset($A['photo'])) { if (isset($_USER['photo'])) { $A['photo'] = $_USER['photo']; } else { $A['photo'] = ''; } } if (!isset($A['email'])) { if (isset($_USER['email'])) { $A['email'] = $_USER['email']; } else { $A['email'] = ''; } } $A['name'] = $A['username']; $mode = 'flat'; $template->set_var('preview_mode', true); } else { $A = DB_fetchArray($comments); $template->unset_var('preview_mode'); } if (empty($A)) { return ''; } $token = ''; if ($delete_option && !$preview) { $token = SEC_createToken(); } $row = 1; do { $template->unset_var('delete_link'); $template->unset_var('ipaddress'); $template->unset_var('reply_link'); $template->unset_var('edit_link'); //check for comment edit $commentedit = DB_query("SELECT cid,uid,UNIX_TIMESTAMP(time) as time FROM {$_TABLES['commentedits']} WHERE cid = " . (int) $A['cid']); $B = DB_fetchArray($commentedit); if ($B) { //comment edit present //get correct editor name if ($A['uid'] == $B['uid']) { $editname = $A['username']; } else { $editname = DB_getItem($_TABLES['users'], 'username', "uid=" . (int) $B['uid']); } //add edit info to text $dtObject = new Date($B['time'], $_USER['tzid']); $A['comment'] .= LB . '<div class="comment-edit">' . $LANG03[30] . ' ' . $dtObject->format($_CONF['date'], true) . ' ' . $LANG03[31] . ' ' . $editname . '</div><!-- /COMMENTEDIT -->'; } // determines indentation for current comment if ($mode == 'threaded' || $mode == 'nested') { $indent = ($A['indent'] - $A['pindent']) * $_CONF['comment_indent']; } // comment variables if (!isset($A['uid']) || $A['uid'] == '') { $A['uid'] = 1; } $template->set_var('indent', $indent); $template->set_var('author_name', $filter->sanitizeUsername($A['username'])); $template->set_var('author_id', $A['uid']); $template->set_var('cid', $A['cid']); $template->set_var('cssid', $row % 2); if ($sid_author_id != '' && $sid_author_id != 1 && $sid_author_id == $A['uid']) { $template->set_var('author_match', '1'); } else { $template->set_var('author_match', ''); } if ($A['uid'] > 1) { $fullname = COM_getDisplayName($A['uid'], $A['username'], isset($A['fullname']) ? $A['fullname'] : ''); $template->set_var('author_fullname', $fullname); $template->set_var('author', $fullname); $alttext = $fullname; $photo = ''; if ($_CONF['allow_user_photo']) { if (isset($A['photo']) && empty($A['photo'])) { $A['photo'] = ''; } $photo = USER_getPhoto($A['uid'], $A['photo'], $A['email']); $photo_raw = USER_getPhoto($A['uid'], $A['photo'], $A['email'], 64, 0); if (!empty($photo)) { $template->set_var('author_photo', $photo); $template->set_var('author_photo_raw', $photo_raw); $camera_icon = '<img src="' . $_CONF['layout_url'] . '/images/smallcamera.' . $_IMAGE_TYPE . '" alt=""/>'; $template->set_var('camera_icon', COM_createLink($camera_icon, $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $A['uid'])); } else { $template->set_var('author_photo', '<img src="' . $_CONF['default_photo'] . '" alt="" class="userphoto"/>'); $template->set_var('author_photo_raw', $_CONF['default_photo']); $template->set_var('camera_icon', ''); } } else { $template->set_var('author_photo_raw', ''); $template->set_var('author_photo', ''); $template->set_var('camera_icon', ''); } $template->set_var('start_author_anchortag', '<a href="' . $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $A['uid'] . '">'); $template->set_var('end_author_anchortag', '</a>'); $template->set_var('author_link', COM_createLink($fullname, $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $A['uid'])); } else { $username = $filter->sanitizeUsername($A['name']); if ($username == '') { $username = $LANG01[24]; } $template->set_var('author', $username); $template->set_var('author_fullname', $username); $template->set_var('author_link', @htmlspecialchars($username, ENT_COMPAT, COM_getEncodingt())); if ($_CONF['allow_user_photo']) { $template->set_var('author_photo_raw', $_CONF['default_photo']); $template->set_var('author_photo', '<img src="' . $_CONF['default_photo'] . '" alt="" class="userphoto"/>'); $template->set_var('camera_icon', ''); } else { $template->set_var('author_photo_raw', ''); $template->set_var('author_photo', ''); $template->set_var('camera_icon', ''); } $template->set_var('start_author_anchortag', ''); $template->set_var('end_author_anchortag', ''); } // hide reply link from anonymous users if they can't post replies $hidefromanon = false; if (COM_isAnonUser() && ($_CONF['loginrequired'] == 1 || $_CONF['commentsloginrequired'] == 1)) { $hidefromanon = true; } // this will hide HTML that should not be viewed in preview mode if ($preview || $hidefromanon) { $template->set_var('hide_if_preview', 'style="display:none"'); } else { $template->set_var('hide_if_preview', ''); } $dtObject = new Date($A['nice_date'], $_USER['tzid']); $template->set_var('date', $dtObject->format($_CONF['date'], true)); $template->set_var('sid', $A['sid']); $template->set_var('type', $A['type']); //COMMENT edit rights if (!COM_isAnonUser()) { if ($_USER['uid'] == $A['uid'] && $_CONF['comment_edit'] == 1 && ($_CONF['comment_edittime'] == 0 || time() - $A['nice_date'] < $_CONF['comment_edittime']) && $ccode == 0 && DB_getItem($_TABLES['comments'], 'COUNT(*)', "pid = " . (int) $A['cid']) == 0) { $edit_option = true; } else { if (SEC_inGroup('Root')) { $edit_option = true; } else { $edit_option = false; } } } else { $edit_option = false; } //edit link if ($edit_option) { if (empty($token)) { $token = SEC_createToken(); } $editlink = $_CONF['site_url'] . '/comment.php?mode=edit&cid=' . $A['cid'] . '&sid=' . $A['sid'] . '&type=' . $type . '&' . CSRF_TOKEN . '=' . $token . '#comment_entry'; $template->set_var('edit_link', $editlink); $template->set_var('lang_edit', $LANG01[4]); $edit = COM_createLink($LANG01[4], $editlink) . ' | '; } else { $editlink = ''; $edit = ''; } // If deletion is allowed, displays delete link if ($delete_option) { $deloption = ''; if (SEC_inGroup('Root')) { if (!empty($A['ipaddress'])) { if (empty($_CONF['ip_lookup'])) { $deloption = $A['ipaddress'] . ' | '; $template->set_var('ipaddress', $A['ipaddress']); } else { $iplookup = str_replace('*', $A['ipaddress'], $_CONF['ip_lookup']); $template->set_var('iplookup_link', $iplookup); $template->set_var('ipaddress', $A['ipaddress']); $deloption = COM_createLink($A['ipaddress'], $iplookup) . ' | '; } //insert re-que link here } } $dellink = $_CONF['site_url'] . '/comment.php?mode=delete&cid=' . $A['cid'] . '&sid=' . $A['sid'] . '&type=' . $type . '&' . CSRF_TOKEN . '=' . $token; $delattr = array('onclick' => "return confirm('{$MESSAGE[76]}');"); $delete_link = $dellink; $template->set_var('delete_link', $delete_link); $template->set_var('lang_delete_link_confirm', $MESSAGE[76]); $template->set_var('lang_delete', $LANG01[28]); $deloption .= COM_createLink($LANG01[28], $dellink, $delattr) . ' | '; $template->set_var('delete_option', $deloption . $edit); } else { if ($edit_option) { $template->set_var('delete_option', $edit); } elseif (!COM_isAnonUser()) { $reportthis = ''; if ($A['uid'] != $_USER['uid']) { $reportthis_link = $_CONF['site_url'] . '/comment.php?mode=report&cid=' . $A['cid'] . '&type=' . $type; $report_attr = array('title' => $LANG01[110]); $template->set_var('report_link', $reportthis_link); $template->set_var('lang_report', $LANG01[109]); $reportthis = COM_createLink($LANG01[109], $reportthis_link, $report_attr) . ' | '; } $template->set_var('delete_option', $reportthis); } else { $template->set_var('delete_option', ''); } } //and finally: format the actual text of the comment, but check only the text, not sig or edit $text = str_replace('<!-- COMMENTSIG --><div class="comment-sig">', '', $A['comment']); $text = str_replace('</div><!-- /COMMENTSIG -->', '', $text); $text = str_replace('<div class="comment-edit">', '', $text); $text = str_replace('</div><!-- /COMMENTEDIT -->', '', $text); $filter->setReplaceTags(true); $filter->setCensorData(true); if (preg_match('/<.*>/', $text) == 0) { $A['comment'] = nl2br($A['comment']); } $filter->setPostmode('html'); $A['comment'] = $filter->displayText($A['comment']); // highlight search terms if specified if (!empty($_REQUEST['query'])) { $A['comment'] = COM_highlightQuery($A['comment'], strip_tags($_REQUEST['query'])); } if (function_exists('msg_replaceEmoticons')) { $A['comment'] = msg_replaceEmoticons($A['comment']); } // create a reply to link $reply_link = ''; if ($ccode == 0 && ($_CONF['commentsloginrequired'] == 0 || !COM_isAnonUser())) { $reply_link = $_CONF['site_url'] . '/comment.php?sid=' . $A['sid'] . '&pid=' . $A['cid'] . '&title=' . urlencode($A['title']) . '&type=' . $A['type'] . '#comment_entry'; $template->set_var('reply_link', $reply_link); $template->set_var('lang_reply', $LANG01[43]); $reply_option = COM_createLink($LANG01[43], $reply_link, array('rel' => 'nofollow')) . ' | '; $template->set_var('reply_option', $reply_option); } else { $template->set_var('reply_option', ''); } $template->set_var('reply_link', $reply_link); // format title for display, must happen after reply_link is created $A['title'] = @htmlspecialchars($A['title'], ENT_COMPAT, COM_getEncodingt()); $template->set_var('title', $A['title']); $template->set_var('comments', $A['comment']); // parse the templates if ($mode == 'threaded' && $indent > 0) { $template->set_var('pid', $A['pid']); $retval .= $template->parse('output', 'thread'); } else { $template->set_var('pid', $A['cid']); $retval .= $template->parse('output', 'comment'); } if ($preview) { return $retval; } $row++; } while ($A = DB_fetchArray($comments)); return $retval; }
/** * Takes an article class and renders HTML in the specified template and style. * * Formats the given article into HTML. Called by index.php, article.php, * submit.php and admin/story.php (Preview mode for the last two). * * @param object $story The story to display, an instance of the Story class. * @param string $index n = 'Compact display' for list of stories. p = 'Preview' mode. Else full display of article. * @param string $storytpl The template to use to render the story. * @param string $query A search query, if one was specified. * * @return string Article as formated HTML. * * Note: Formerly named COM_Article, and re-written totally since then. */ function STORY_renderArticle(&$story, $index = '', $storytpl = 'storytext.thtml', $query = '') { global $_CONF, $_TABLES, $_USER, $LANG01, $LANG05, $LANG11, $LANG_TRB, $_IMAGE_TYPE, $mode, $_GROUPS, $ratedIds; static $storycounter = 0; if (empty($storytpl)) { $storytpl = 'storytext.thtml'; } $introtext = $story->displayElements('introtext'); $bodytext = $story->displayElements('bodytext'); if (!empty($query)) { $introtext = COM_highlightQuery($introtext, $query); $bodytext = COM_highlightQuery($bodytext, $query); } $article = new Template($_CONF['path_layout']); $article->set_file(array('article' => $storytpl, 'featuredarticle' => 'featuredstorytext.thtml', 'archivearticle' => 'archivestorytext.thtml')); if ($_CONF['hideviewscount'] != 1) { $article->set_var('lang_views', $LANG01[106]); $article->set_var('story_hits', $story->DisplayElements('hits'), false, true); } if ($_CONF['hidestorydate'] != 1) { $article->set_var('story_date', $story->DisplayElements('date'), false, true); // make sure date format is in user's preferred format } $articleUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid()); $article->set_var('article_url', $articleUrl); $article->set_var('story_title', $story->DisplayElements('title')); // begin instance caching... if ($story->DisplayElements('featured') == 1) { $article_filevar = 'featuredarticle'; } elseif ($story->DisplayElements('statuscode') == STORY_ARCHIVE_ON_EXPIRE and $story->DisplayElements('expire') <= time()) { $article_filevar = 'archivearticle'; } else { $article_filevar = 'article'; } $hash = CACHE_security_hash(); $instance_id = 'story_' . $story->getSid() . '_' . $index . '_' . $article_filevar . '_' . $hash . '_' . $_USER['theme']; if ($index == 'p' || !empty($query) || !$article->check_instance($instance_id, $article_filevar)) { // end of instance cache $article->set_var('article_filevar', ''); $article->set_var('site_name', $_CONF['site_name']); if ($_CONF['hidestorydate'] != 1) { $article->set_var('story_date_short', $story->DisplayElements('shortdate')); $article->set_var('story_date_only', $story->DisplayElements('dateonly')); } $article->set_var('story_id', $story->getSid()); $article->set_var('lang_posted_in', $LANG01['posted_in']); if ($_CONF['contributedbyline'] == 1) { $article->set_var('lang_contributed_by', $LANG01[1]); $article->set_var('lang_by', $LANG01[95]); $article->set_var('contributedby_uid', $story->DisplayElements('uid')); $fullname = $story->DisplayElements('fullname'); $username = $story->DisplayElements('username'); $article->set_var('contributedby_user', $username); if (empty($fullname)) { $article->set_var('contributedby_fullname', $username); } else { $article->set_var('contributedby_fullname', $fullname); } $authorname = COM_getDisplayName($story->DisplayElements('uid'), $username, $fullname); $article->set_var('author', $authorname); $profileUrl = $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $story->DisplayElements('uid'); if ($story->DisplayElements('uid') > 1) { $article->set_var('contributedby_url', $profileUrl); $authorname = COM_createLink($authorname, $profileUrl, array('class' => 'storybyline')); } $article->set_var('contributedby_author', $authorname); $photo = ''; if ($_CONF['allow_user_photo'] == 1) { $authphoto = $story->DisplayElements('photo'); if (empty($authphoto)) { $authphoto = '(none)'; // user does not have a photo } $photo = USER_getPhoto($story->DisplayElements('uid'), $authphoto, $story->DisplayElements('email')); } if (!empty($photo)) { $article->set_var('contributedby_photo', $photo); $article->set_var('author_photo', $photo); $camera_icon = '<img src="' . $_CONF['layout_url'] . '/images/smallcamera.' . $_IMAGE_TYPE . '" alt=""' . '/>'; $article->set_var('camera_icon', COM_createLink($camera_icon, $profileUrl)); } else { $article->set_var('contributedby_photo', ''); $article->set_var('author_photo', ''); $article->set_var('camera_icon', ''); } } $topicname = $story->DisplayElements('topic'); if ($story->DisplayElements('alternate_tid') != NULL) { $alttopic = DB_getItem($_TABLES['topics'], 'topic', "tid = '" . DB_escapeString($story->DisplayElements('alternate_tid')) . "'"); } else { $alttopic = ''; } $article->set_var('story_topic_id', $story->DisplayElements('tid')); $article->set_var('alt_story_topic_id', $story->DisplayElements('alternate_tid')); $article->set_var('story_topic_name', $topicname); $article->set_var('story_alternate_topic_name', $alttopic); $topicurl = $_CONF['site_url'] . '/index.php?topic=' . $story->DisplayElements('tid'); $alttopicurl = $_CONF['site_url'] . '/index.php?topic=' . $story->DisplayElements('alternate_tid'); if ((!isset($_USER['noicons']) or $_USER['noicons'] != 1) and $story->DisplayElements('show_topic_icon') == 1) { $imageurl = $story->DisplayElements('imageurl'); if (!empty($imageurl)) { $imageurl = COM_getTopicImageUrl($imageurl); $article->set_var('story_topic_image_url', $imageurl); $topicimage = '<img src="' . $imageurl . '" class="float' . $_CONF['article_image_align'] . '" alt="' . $topicname . '" title="' . $topicname . '" />'; $article->set_var('story_anchortag_and_image', COM_createLink($topicimage, $topicurl, array('rel' => "category tag"))); $article->set_var('story_topic_image', $topicimage); $topicimage_noalign = '<img src="' . $imageurl . '" alt="' . $topicname . '" title="' . $topicname . '" />'; $article->set_var('story_anchortag_and_image_no_align', COM_createLink($topicimage_noalign, $topicurl, array('rel' => "category tag"))); $article->set_var('story_topic_image_no_align', $topicimage_noalign); } } $article->set_var('story_topic_url', $topicurl); $article->set_var('alt_story_topic_url', $alttopicurl); $recent_post_anchortag = ''; $articleUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid()); $article->set_var('story_title', $story->DisplayElements('title')); $article->set_var('lang_permalink', $LANG01[127]); $show_comments = true; // n = 'Compact display' for list of stories. p = 'Preview' mode. if ($index != 'n' && $index != 'p' || !empty($query)) { $attributes = ' class="non-ul"'; $attr_array = array('class' => 'non-ul'); if (!empty($query)) { $attributes .= ' rel="bookmark"'; $attr_array['rel'] = 'bookmark'; } $article->set_var('start_storylink_anchortag', '<a href="' . $articleUrl . '"' . $attributes . '>'); $article->set_var('end_storylink_anchortag', '</a>'); $article->set_var('story_title_link', COM_createLink($story->DisplayElements('title'), $articleUrl, $attr_array)); } else { $article->set_var('story_title_link', $story->DisplayElements('title')); } if ($index == 'n' || $index == 'p') { if (empty($bodytext)) { $article->set_var('story_introtext', $introtext); $article->set_var('story_text_no_br', $introtext); } else { if ($_CONF['allow_page_breaks'] == 1 and $index == 'n') { $story_page = 1; // page selector if (is_numeric($mode)) { $story_page = $mode; if ($story_page <= 0) { $story_page = 1; $mode = 0; } elseif ($story_page > 1) { $introtext = ''; } } $article_array = explode('[page_break]', $bodytext); $pagelinks = COM_printPageNavigation($articleUrl, $story_page, count($article_array), 'mode=', $_CONF['url_rewrite'], $LANG01[118]); if (count($article_array) > 1) { $bodytext = $article_array[$story_page - 1]; } $article->set_var('page_selector', $pagelinks); if ($_CONF['page_break_comments'] == 'last' and $story_page < count($article_array) or $_CONF['page_break_comments'] == 'first' and $story_page != 1) { $show_comments = false; } $article->set_var('story_page', $story_page); } $article->set_var('story_introtext', $introtext . '<br />' . $bodytext); $article->set_var('story_text_no_br', $introtext . $bodytext); } $article->set_var('story_introtext_only', $introtext); $article->set_var('story_bodytext_only', $bodytext); if (($_CONF['trackback_enabled'] || $_CONF['pingback_enabled']) && SEC_hasRights('story.ping')) { $url = $_CONF['site_admin_url'] . '/trackback.php?mode=sendall&id=' . $story->getSid(); $article->set_var('send_trackback_link', COM_createLink($LANG_TRB['send_trackback'], $url)); $pingico = '<img src="' . $_CONF['layout_url'] . '/images/sendping.' . $_IMAGE_TYPE . '" alt="' . $LANG_TRB['send_trackback'] . '" title="' . $LANG_TRB['send_trackback'] . '" />'; $article->set_var('send_trackback_icon', COM_createLink($pingico, $url)); $article->set_var('send_trackback_url', $url); $article->set_var('lang_send_trackback_text', $LANG_TRB['send_trackback']); } $article->set_var('story_display', $index == 'p' ? 'preview' : 'article'); $article->set_var('story_counter', 0); } else { $article->set_var('story_introtext', $introtext); $article->set_var('story_text_no_br', $introtext); $article->set_var('story_introtext_only', $introtext); if (!empty($bodytext)) { $article->set_var('lang_readmore', $LANG01[2]); $article->set_var('lang_readmore_words', $LANG01[62]); $numwords = COM_numberFormat(sizeof(explode(' ', strip_tags($bodytext)))); $article->set_var('readmore_words', $numwords); $article->set_var('readmore_link', COM_createLink($LANG01[2], $articleUrl, array('class' => 'story-read-more-link')) . ' (' . $numwords . ' ' . $LANG01[62] . ') '); $article->set_var('start_readmore_anchortag', '<a href="' . $articleUrl . '" class="story-read-more-link">'); $article->set_var('end_readmore_anchortag', '</a>'); $article->set_var('read_more_class', 'class="story-read-more-link"'); $article->set_var('readmore_url', $articleUrl); } if ($story->DisplayElements('commentcode') >= 0 and $show_comments) { $commentsUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid()) . '#comments'; $article->set_var('comments_url', $commentsUrl); $article->set_var('comments_text', COM_numberFormat($story->DisplayElements('comments')) . ' ' . $LANG01[3]); $article->set_var('comments_count', COM_numberFormat($story->DisplayElements('comments'))); $article->set_var('lang_comments', $LANG01[3]); $comments_with_count = sprintf($LANG01[121], COM_numberFormat($story->DisplayElements('comments'))); if ($story->DisplayElements('comments') > 0) { $result = DB_query("SELECT UNIX_TIMESTAMP(date) AS day,username,fullname,{$_TABLES['comments']}.uid as cuid FROM {$_TABLES['comments']},{$_TABLES['users']} WHERE {$_TABLES['users']}.uid = {$_TABLES['comments']}.uid AND sid = '" . DB_escapeString($story->getsid()) . "' ORDER BY date desc LIMIT 1"); $C = DB_fetchArray($result); $recent_post_anchortag = '<span class="storybyline">' . $LANG01[27] . ': ' . strftime($_CONF['daytime'], $C['day']) . ' ' . $LANG01[104] . ' ' . COM_getDisplayName($C['cuid'], $C['username'], $C['fullname']) . '</span>'; $article->set_var('comments_with_count', COM_createLink($comments_with_count, $commentsUrl)); $article->set_var('start_comments_anchortag', '<a href="' . $commentsUrl . '">'); $article->set_var('end_comments_anchortag', '</a>'); } else { $article->set_var('comments_with_count', $comments_with_count); $recent_post_anchortag = COM_createLink($LANG01[60], $_CONF['site_url'] . '/comment.php?sid=' . $story->getsid() . '#comment_entry' . '&pid=0&type=article'); } if ($story->DisplayElements('commentcode') == 0 && ($_CONF['commentsloginrequired'] == 0 || !COM_isAnonUser())) { $postCommentUrl = $_CONF['site_url'] . '/comment.php?sid=' . $story->getSid() . '&pid=0&type=article#comment_entry'; $article->set_var('post_comment_link', COM_createLink($LANG01[60], $postCommentUrl, array('rel' => 'nofollow'))); $article->set_var('lang_post_comment', $LANG01[60]); $article->set_var('start_post_comment_anchortag', '<a href="' . $postCommentUrl . '" rel="nofollow">'); $article->set_var('end_post_comment_anchortag', '</a>'); $article->set_var('post_comment_url', $postCommentUrl); } } if (($_CONF['trackback_enabled'] || $_CONF['pingback_enabled']) && $story->DisplayElements('trackbackcode') >= 0 && $show_comments) { $num_trackbacks = COM_numberFormat($story->DisplayElements('trackbacks')); $trackbacksUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid()) . '#trackback'; $article->set_var('trackbacks_url', $trackbacksUrl); $article->set_var('trackbacks_text', $num_trackbacks . ' ' . $LANG_TRB['trackbacks']); $article->set_var('trackbacks_count', $num_trackbacks); $article->set_var('lang_trackbacks', $LANG_TRB['trackbacks']); $article->set_var('trackbacks_with_count', COM_createLink(sprintf($LANG01[122], $num_trackbacks), $trackbacksUrl)); if (SEC_hasRights('story.ping')) { $pingurl = $_CONF['site_admin_url'] . '/trackback.php?mode=sendall&id=' . $story->getSid(); $pingico = '<img src="' . $_CONF['layout_url'] . '/images/sendping.' . $_IMAGE_TYPE . '" alt="' . $LANG_TRB['send_trackback'] . '" title="' . $LANG_TRB['send_trackback'] . '" />'; $article->set_var('send_trackback_icon', COM_createLink($pingico, $pingurl)); } if ($story->DisplayElements('trackbacks') > 0) { $article->set_var('trackbacks_with_count', COM_createLink(sprintf($LANG01[122], $num_trackbacks), $trackbacksUrl)); } else { $article->set_var('trackbacks_with_count', sprintf($LANG01[122], $num_trackbacks)); } } if ($_CONF['hideemailicon'] == 1 || COM_isAnonUser() && ($_CONF['loginrequired'] == 1 || $_CONF['emailstoryloginrequired'] == 1)) { $article->set_var('email_icon', ''); } else { $emailUrl = $_CONF['site_url'] . '/profiles.php?sid=' . $story->getSid() . '&what=emailstory'; $emailicon = '<img src="' . $_CONF['layout_url'] . '/images/mail.' . $_IMAGE_TYPE . '" alt="' . $LANG01[64] . '" title="' . $LANG11[2] . '" />'; $article->set_var('email_icon', COM_createLink($emailicon, $emailUrl)); $article->set_var('email_story_url', $emailUrl); $article->set_var('lang_email_story', $LANG11[2]); $article->set_var('lang_email_story_alt', $LANG01[64]); } $printUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid() . '&mode=print'); if ($_CONF['hideprintericon'] == 1) { $article->set_var('print_icon', ''); } else { $printicon = '<img src="' . $_CONF['layout_url'] . '/images/print.' . $_IMAGE_TYPE . '" alt="' . $LANG01[65] . '" title="' . $LANG11[3] . '" />'; $article->set_var('print_icon', COM_createLink($printicon, $printUrl, array('rel' => 'nofollow'))); $article->set_var('print_story_url', $printUrl); $article->set_var('lang_print_story', $LANG11[3]); $article->set_var('lang_print_story_alt', $LANG01[65]); } $article->set_var('pdf_icon', ''); if ($_CONF['backend'] == 1) { $tid = $story->displayElements('tid'); $alt_tid = $story->displayElements('alternate_tid'); $result = DB_query("SELECT filename, title FROM {$_TABLES['syndication']} WHERE type = 'article' AND topic = '" . DB_escapeString($tid) . "' AND is_enabled = 1"); $feeds = DB_numRows($result); for ($i = 0; $i < $feeds; $i++) { list($filename, $title) = DB_fetchArray($result); $feedUrl = SYND_getFeedUrl($filename); $feedTitle = sprintf($LANG11[6], $title); } if ($feeds > 0) { $feedicon = '<img src="' . $_CONF['layout_url'] . '/images/rss_small.' . $_IMAGE_TYPE . '" alt="' . $feedTitle . '" title="' . $feedTitle . '" />'; $article->set_var('feed_icon', COM_createLink($feedicon, $feedUrl, array("type" => "application/rss+xml"))); $article->set_var('feed_url', $feedUrl); } else { $article->set_var('feed_icon', ''); } } else { $article->set_var('feed_icon', ''); } $article->set_var('story_display', 'index'); $storycounter++; $article->set_var('story_counter', $storycounter); } $article->set_var('article_url', $articleUrl); $article->set_var('recent_post_anchortag', $recent_post_anchortag); $access = $story->checkAccess(); $storyAccess = min($access, SEC_hasTopicAccess($story->DisplayElements('tid'))); if ($index != 'p' and SEC_hasRights('story.edit') and $story->checkAccess() == 3 and SEC_hasTopicAccess($story->DisplayElements('tid')) == 3) { $article->set_var('edit_link', COM_createLink($LANG01[4], $_CONF['site_admin_url'] . '/story.php?edit=x&sid=' . $story->getSid())); $article->set_var('edit_url', $_CONF['site_admin_url'] . '/story.php?edit=x&sid=' . $story->getSid()); $article->set_var('lang_edit_text', $LANG01[4]); $editicon = $_CONF['layout_url'] . '/images/edit.' . $_IMAGE_TYPE; $editiconhtml = '<img src="' . $editicon . '" alt="' . $LANG01[4] . '" title="' . $LANG01[4] . '" />'; $article->set_var('edit_icon', COM_createLink($editiconhtml, $_CONF['site_admin_url'] . '/story.php?edit=x&sid=' . $story->getSid())); $article->set_var('edit_image', $editiconhtml); } $article->set_var('lang_continue_reading', $LANG01['continue_reading']); PLG_templateSetVars($article_filevar, $article); if ($_CONF['rating_enabled'] != 0 && $index != 'p') { if (@in_array($story->getSid(), $ratedIds)) { $static = true; $voted = 1; } else { $static = 0; $voted = 0; } $uid = isset($_USER['uid']) ? $_USER['uid'] : 1; if ($_CONF['rating_enabled'] == 2 && $uid != $story->DisplayElements('owner_id')) { $article->set_var('rating_bar', RATING_ratingBar('article', $story->getSid(), $story->DisplayElements('votes'), $story->DisplayElements('rating'), $voted, 5, $static, 'sm'), false, true); } else { if (!COM_isAnonUser() && $uid != $story->DisplayElements('owner_id')) { $article->set_var('rating_bar', RATING_ratingBar('article', $story->getSid(), $story->DisplayElements('votes'), $story->DisplayElements('rating'), $voted, 5, $static, 'sm'), false, true); } else { $article->set_var('rating_bar', RATING_ratingBar('article', $story->getSid(), $story->DisplayElements('votes'), $story->DisplayElements('rating'), 1, 5, TRUE, 'sm'), false, true); } } } else { $article->set_var('rating_bar', '', false, true); } if ($index != 'p') { $article->create_instance($instance_id, $article_filevar); } } else { PLG_templateSetVars($article_filevar, $article); if ($_CONF['rating_enabled'] != 0) { if (@in_array($story->getSid(), $ratedIds)) { $static = true; $voted = 1; } else { $static = 0; $voted = 0; } $uid = isset($_USER['uid']) ? $_USER['uid'] : 1; if ($_CONF['rating_enabled'] == 2 && $uid != $story->DisplayElements('owner_id')) { $article->set_var('rating_bar', RATING_ratingBar('article', $story->getSid(), $story->DisplayElements('votes'), $story->DisplayElements('rating'), $voted, 5, $static, 'sm'), false, true); } else { if (!COM_isAnonUser() && $uid != $story->DisplayElements('owner_id')) { $article->set_var('rating_bar', RATING_ratingBar('article', $story->getSid(), $story->DisplayElements('votes'), $story->DisplayElements('rating'), $voted, 5, $static, 'sm'), false, true); } else { $article->set_var('rating_bar', RATING_ratingBar('article', $story->getSid(), $story->DisplayElements('votes'), $story->DisplayElements('rating'), $voted, 5, TRUE, 'sm'), false, true); } } } else { $article->set_var('rating_bar', '', false, true); } } $article->parse('finalstory', $article_filevar); return $article->finish($article->get_var('finalstory')); }
/** * This function prints &$comments (db results set of comments) in comment format * -For previews, &$comments is assumed to be an associative array containing * data for a single comment. * * @param array &$comments Database result set of comments to be printed * @param string $order How to order the comments 'ASC' or 'DESC' * @param boolean $delete_option if current user can delete comments * @param boolean $preview Preview display (for edit) or not * @return string HTML Formated Comment * */ function PAYPAL_get_review(&$comments, $order, $url, $delete_option = false, $preview = false) { global $_CONF, $_TABLES, $_USER, $LANG01, $_IMAGE_TYPE, $LANG_RATING, $_RATING_CONF; $indent = 0; // begin with 0 indent $retval = ''; // initialize return value //$template = COM_newTemplate( $_CONF['path_layout'] . 'comment' ); $template = COM_newTemplate($_CONF['path'] . 'plugins/rating/templates'); $template->set_file(array('comment' => 'review.thtml')); // generic template variables $template->set_var('site_url', $_CONF['site_url']); $template->set_var('layout_url', $_CONF['layout_url']); $template->set_var('lang_replytothis', $LANG01[43]); $template->set_var('lang_reply', $LANG01[25]); $template->set_var('lang_authoredby', $LANG01[42]); $template->set_var('lang_on', $LANG01[36]); $template->set_var('order', $order); // Make sure we have a default value for comment indentation if (!isset($_CONF['comment_indent'])) { $_CONF['comment_indent'] = 25; } if ($preview) { $A = $comments; if (empty($A['nice_date'])) { $A['nice_date'] = time(); } //$mode = 'flat'; } else { $A = DB_fetchArray($comments); } if (empty($A['comment'])) { $NotReview = true; } else { $NotReview = false; } if (empty($A)) { return ''; } if (rating_rt_is_digg($A['rt_id'])) { $is_digg = true; } $row = 1; do { // comment variables $template->set_var('indent', $indent); $template->set_var('author', $A['username']); $template->set_var('author_id', $A['owner_id']); $template->set_var('rt_id', $A['rt_id']); $template->set_var('cssid', $row % 2); if ($A['owner_id'] > 1) { if (empty($A['fullname'])) { $template->set_var('author_fullname', $A['username']); $alttext = $A['username']; } else { $template->set_var('author_fullname', $A['fullname']); $alttext = $A['fullname']; } $photo = ''; if ($_CONF['allow_user_photo']) { // $photo = USER_getPhoto( $A['owner_id'], $A['photo'] ); } if (!empty($photo)) { $template->set_var('author_photo', $photo); $template->set_var('camera_icon', '<a href="' . $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $A['owner_id'] . '"><img src="' . $_CONF['layout_url'] . '/images/smallcamera.' . $_IMAGE_TYPE . '" border="0" alt=""></a>'); } else { $template->set_var('author_photo', ''); $template->set_var('camera_icon', ''); } $template->set_var('start_author_anchortag', '<a href="' . $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $A['owner_id'] . '">'); $template->set_var('end_author_anchortag', '</a>'); } else { $template->set_var('author_fullname', $A['username']); $template->set_var('author_photo', ''); $template->set_var('camera_icon', ''); $template->set_var('start_author_anchortag', ''); $template->set_var('end_author_anchortag', ''); } // this will hide HTML that should not be viewed in preview mode if ($preview || $hidefromanon) { $template->set_var('hide_if_preview', 'style="display:none"'); } else { $template->set_var('hide_if_preview', ''); } $template->set_var('date', strftime($_CONF['date'], $A['nice_date'])); // If deletion is allowed, displays delete link (this varible is for the owner of the rating) // Now check if you show individual rating or review // never trust $uid ... if (empty($_USER['uid'])) { $uid = 1; } else { $uid = $_USER['uid']; } // this will hide HTML that should not be viewed when user logged in if ($uid > 1) { $template->set_var('hide_if_user', 'style="display:none"'); } else { $template->set_var('hide_if_user', ''); } // ***************************************************** // Edit & delete links $UserFlag = false; if ($uid > 1) { $sql = 'SELECT COUNT(*) AS count, owner_id, group_id, perm_owner, perm_group, ' . "perm_members, perm_anon FROM {$_TABLES['rating']} WHERE (rid = '" . $A['rid'] . "') " . 'AND (created <= NOW())' . COM_getPermSQL('AND') . 'GROUP BY rid'; $result = DB_query($sql); $B = DB_fetchArray($result); $allowed = $B['count']; if ($allowed >= 1) { $access = SEC_hasAccess($B['owner_id'], $B['group_id'], $B['perm_owner'], $B['perm_group'], $B['perm_members'], $B['perm_anon']); if ($access == 3) { $UserFlag = true; } } } if ($delete_option || $UserFlag) { $deloption = '[ '; if ($delete_option) { $onclick = 'onclick="return confirm(' . "'" . $LANG_RATING['delete_confirm'] . "'" . ');"'; // Delete Confirm $deloption .= '<a href="' . $_CONF['site_admin_url'] . '/plugins/rating/index.php?mode=edit&rid=' . $A['rid'] . '&rt_id=' . $A['rt_id'] . '">' . $LANG01[04] . '</a>' . ' | <a href="' . $_CONF['site_url'] . '/rating/review.php?mode=delete&rid=' . $A['rid'] . '&rt_id=' . $A['rt_id'] . '" ' . $onclick . '>' . $LANG01[28] . '</a> '; if (!empty($A['ipaddress'])) { if (empty($_CONF['ip_lookup'])) { $deloption .= '| ' . $A['ipaddress'] . ' '; } else { $iplookup = str_replace('*', $A['ipaddress'], $_CONF['ip_lookup']); $deloption .= '| <a href="' . $iplookup . '">' . $A['ipaddress'] . '</a> '; } } } elseif (!$delete_option && $UserFlag) { $deloption .= '<a href="' . $_CONF['site_url'] . '/rating/review.php?mode=edit&rid=' . $A['rid'] . '&rt_id=' . $A['rt_id'] . '">' . $LANG01[04] . '</a>'; } // ***************************************************** $deloption .= ' ]'; $template->set_var('delete_option', $deloption); } else { $template->set_var('delete_option', ''); } // and finally: format the actual text of the comment if (preg_match('/<.*>/', $A['comment']) == 0) { $A['comment'] = nl2br($A['comment']); } // highlight search terms if specified if (!empty($_REQUEST['query'])) { $A['comment'] = COM_highlightQuery($A['comment'], $_REQUEST['query']); } $review_for = DB_getItem($_TABLES['rating_totals'], 'title_link', "rt_id='" . $A['rt_id'] . "'"); if ($review_for == '') { $review_for = DB_getItem($_TABLES['rating_totals'], 'title', "rt_id='" . $A['rt_id'] . "'"); } if ($review_for == '') { $template->set_var('hide_no_review_for', 'style="display:none"'); $template->set_var('lang_review_for', ''); $template->set_var('review_for', ''); } else { $template->set_var('lang_review_for', $LANG_RATING[340]); $template->set_var('review_for', $review_for); } $template->set_var('lang_location', $LANG_RATING[339]); if ($A['location'] == '') { $template->set_var('hide_no_location', 'style="display:none"'); $template->set_var('location', ''); } else { $template->set_var('hide_no_location', ''); $template->set_var('location', $A['location']); } if ($A['nickname'] == '') { $template->set_var('nickname', ''); } else { $template->set_var('nickname', '(' . $A['nickname'] . ')'); } $A['comment'] = str_replace('$', '$', $A['comment']); $A['comment'] = str_replace('{', '{', $A['comment']); $A['comment'] = str_replace('}', '}', $A['comment']); // Replace any plugin autolink tags $A['comment'] = PLG_replaceTags($A['comment']); // format title for display, must happen after reply_link is created $A['title'] = htmlspecialchars($A['title']); $A['title'] = str_replace('$', '$', $A['title']); $A['title'] = COM_stripslashes($A['title']); $A['pros'] = htmlspecialchars($A['pros']); $A['pros'] = str_replace('$', '$', $A['pros']); $A['pros'] = COM_stripslashes($A['pros']); $A['cons'] = htmlspecialchars($A['cons']); $A['cons'] = str_replace('$', '$', $A['cons']); $A['cons'] = COM_stripslashes($A['cons']); $A['bottomline'] = htmlspecialchars($A['bottomline']); $A['bottomline'] = str_replace('$', '$', $A['bottomline']); $A['bottomline'] = COM_stripslashes($A['bottomline']); $template->set_var('title', $A['title']); if ($A['pros'] == '') { $template->set_var('hide_no_pros', 'style="display:none"'); $template->set_var('pros', ''); } else { $template->set_var('hide_no_pros', ''); $template->set_var('pros', $A['pros']); } if ($A['cons'] == '') { $template->set_var('hide_no_cons', 'style="display:none"'); $template->set_var('cons', ''); } else { $template->set_var('hide_no_cons', ''); $template->set_var('cons', $A['cons']); } if ($A['bottomline'] == '') { $template->set_var('hide_no_bottomline', 'style="display:none"'); $template->set_var('bottomline', ''); } else { $template->set_var('hide_no_bottomline', ''); $template->set_var('bottomline', $A['bottomline']); } $template->set_var('lang_pros', $LANG_RATING[335]); $template->set_var('lang_cons', $LANG_RATING[336]); $template->set_var('lang_bottomline', $LANG_RATING[337]); $template->set_var('comments', $A['comment']); $template->set_var('lang_rating', $LANG_RATING[111]); if ($is_digg) { $template->set_var('lang_rating', $LANG_RATING[119]); $template->set_var('rating', ''); $template->set_var('hide_question', 'style="display:none"'); $template->set_var('review_question', ''); $template->set_var('buttons_yes_no', ''); } else { $template->set_var('lang_rating', $LANG_RATING[111]); $template->set_var('rating', RATING_rating_as_html($A['score'], DB_getItem($_TABLES['rating_totals'], 'score_max', "rt_id='" . $A['rt_id'] . "'"), $_RATING_CONF['user_review_default_display'])); // Helpful Question if ($preview || $NotReview) { $template->set_var('hide_question', 'style="display:none"'); $template->set_var('review_question', ''); $template->set_var('buttons_yes_no', ''); } else { $template->set_var('hide_question', ''); $review_question = $A['helpful_yes'] . $LANG_RATING[345] . ($A['helpful_yes'] + $A['helpful_no']) . $LANG_RATING[346]; $template->set_var('review_question', $review_question); $template->set_var('rid', $A['rid']); $template->set_var('rt_id', $A['rt_id']); $template->set_var('url', $url); if ($_RATING_CONF['use_image_buttons'] == 1) { $button_info = ' <input type="image" value="' . $LANG_RATING[347] . '" name="mode" border="0" src="' . $_CONF["site_url"] . '/rating/images/yesbutton.gif">'; $button_info .= ' <input type="image" value="' . $LANG_RATING[348] . '" name="mode" border="0" src="' . $_CONF["site_url"] . '/rating/images/nobutton.gif">'; } else { $button_info = ' <input type="submit" value="' . $LANG_RATING[347] . '" name="mode">'; $button_info .= ' <input type="submit" value="' . $LANG_RATING[348] . '" name="mode">'; } $template->set_var('buttons_yes_no', $button_info); } } // parse the templates //$template->set_var( 'pid', $A['cid'] ); $retval .= $template->parse('output', 'comment'); $row++; } while ($A = DB_fetchArray($comments)); return $retval; }