示例#1
0
 function parse($p1, $p2 = '', $fulltag)
 {
     global $_CONF, $_MG_CONF, $_TABLES, $_USER, $LANG_MG03, $_PLUGINS, $MG_albums, $_DB_dbms, $mg_installed_version;
     $retval = '';
     $skip = 0;
     $itemsToDisplay = 15;
     if (!in_array('mediagallery', $_PLUGINS)) {
         return $retval;
     }
     // defaults:
     $itemsToDisplay = $p1;
     $uniqueID = md5($p1);
     if ($mg_installed_version != $_MG_CONF['pi_version']) {
         return $retval;
     }
     $truncate = 1;
     $caption = 0;
     $px = explode(' ', trim($p2));
     if (is_array($px)) {
         foreach ($px as $part) {
             if (substr($part, 0, 9) == 'truncate:') {
                 $a = explode(':', $part);
                 $truncate = (int) $a[1];
                 $skip++;
             } elseif (substr($part, 0, 8) == 'caption:') {
                 $a = explode(':', $part);
                 $caption = (int) $a[1];
                 $skip++;
             } else {
                 break;
             }
         }
     }
     if ($truncate == 1) {
         $truncate_word = 'true';
     } else {
         $truncate_word = 'false';
     }
     $outputHandle = outputHandler::getInstance();
     $outputHandle->addLinkScript($_CONF['site_url'] . '/mediagallery/js/jquery.flex-images.js');
     $outputHandle->addLinkStyle($_CONF['site_url'] . '/mediagallery/js/jquery.flex-images.css');
     $hash = CACHE_security_hash();
     $instance_id = 'whatsnew_newimages_' . $uniqueID . '_' . $hash . '_' . $_USER['theme'];
     if (($cache = CACHE_check_instance($instance_id, 0)) !== FALSE) {
         return $cache;
     }
     $imageArray = array();
     require_once $_CONF['path'] . 'plugins/mediagallery/include/init.php';
     MG_initAlbums();
     $sql = "SELECT ma.album_id,m.media_user_id,m.media_id,m.media_filename,m.media_title,\n                u.fullname FROM {$_TABLES['mg_albums']} as a\n                LEFT JOIN {$_TABLES['mg_media_albums']} as ma\n                on a.album_id=ma.album_id LEFT JOIN {$_TABLES['mg_media']} as m\n                on ma.media_id=m.media_id\n                LEFT JOIN {$_TABLES['users']} as u ON m.media_user_id=u.uid\n                WHERE\n                m.media_type=0 AND a.enable_random=1 AND a.hidden=0 " . COM_getPermSQL('and') . " ORDER BY m.media_upload_time DESC LIMIT " . (int) $itemsToDisplay;
     $result = DB_query($sql, 1);
     $nRows = DB_numRows($result);
     for ($x = 0; $x < $nRows; $x++) {
         $row = DB_fetchArray($result);
         $url_media = $_MG_CONF['site_url'] . '/media.php?s=' . $row['media_id'];
         $url_album = $_MG_CONF['site_url'] . '/album.php?aid=' . $row['album_id'] . '&amp;s=' . $row['media_id'] . '#' . $row['media_id'];
         $msize = false;
         foreach ($_MG_CONF['validExtensions'] as $ext) {
             if (file_exists($_MG_CONF['path_mediaobjects'] . 'disp/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $ext)) {
                 $media_thumbnail = $_MG_CONF['mediaobjects_url'] . '/disp/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $ext;
                 $msize = @getimagesize($_MG_CONF['path_mediaobjects'] . 'disp/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $ext);
                 $media_url = $_MG_CONF['site_url'] . '/mediaobjects/' . 'disp/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $ext;
                 break;
             }
         }
         if ($msize == false) {
             continue;
         }
         $imageArray[] = array('url' => $media_url, 'height' => $msize[1], 'width' => $msize[0], 'link' => $url_media, 'caption' => $row['media_title']);
     }
     $retval .= '<div class="flex-images uk-panel uk-panel-box">';
     foreach ($imageArray as $image) {
         $retval .= '<div class="item" data-w="' . $image['width'] . '" data-h="' . $image['height'] . '">';
         if ($caption) {
             $retval .= '<div class="over uk-hidden-small">' . $image['caption'] . '</div>';
         }
         $retval .= '<a href="' . $image['url'] . '"  data-uk-lightbox>';
         $retval .= '<img class="uk-thumbnail" src="' . $image['url'] . '">';
         $retval .= '</a>';
         $retval .= '</div>';
     }
     $retval .= '</div>';
     $retval .= '<script>$(\'.flex-images\').flexImages({rowHeight: 200, truncate:' . $truncate_word . '});</script>';
     CACHE_create_instance($instance_id, $retval, 0);
     return $retval;
 }
示例#2
0
/**
 * 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&amp;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&amp;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() . '&amp;pid=0&amp;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() . '&amp;pid=0&amp;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&amp;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() . '&amp;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() . '&amp;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&amp;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'));
}
示例#3
0
/**
* This function is called when a user's information
* (profile or preferences) has changed.
*
* @param    int     $uid    user id
* @return   void
*
*/
function plugin_user_changed_topic($uid)
{
    global $_CONF;
    // Wipe out user's session variable for last_topic_update (if it exists) since their
    // security may have changed and the topic tree should be updated again
    $cacheInstance = 'topic_tree__' . CACHE_security_hash();
    CACHE_remove_instance($cacheInstance);
}
示例#4
0
 public function parse($p1, $p2 = '', $fulltag)
 {
     global $_CONF, $_TABLES, $_USER, $LANG01;
     USES_lib_comments();
     $retval = '';
     $skip = 0;
     $dt = new Date('now', $_USER['tzid']);
     // topic = specific topic or 'all'
     // display = how many stories to display, if 0, then all
     // meta = show meta data (i.e.; who when etc)
     // titleLink - make title a hot link
     // featured - 0 = show all, 1 = only featured, 2 = all except featured
     // frontpage - 1 = show only items marked for frontpage - 0 = show all
     // cols - number of columns to show
     // template - the template name
     $topic = $p1;
     if ($topic == 'all') {
         $topic = '';
     }
     $uniqueID = md5($p1 . $p2);
     $display = 10;
     // display 10 articles
     $meta = 0;
     // do not display meta data
     $titleLink = 0;
     // do not use links in title
     $featured = 0;
     // 0 = show all, 1 = only featured, 2 = all except featured
     $frontpage = 0;
     // only show items marked for frontpage
     $cols = 3;
     // number of columns
     $truncate = 0;
     // maximum number of characters to include in story text
     $template = 'headlines.thtml';
     $px = explode(' ', trim($p2));
     if (is_array($px)) {
         foreach ($px as $part) {
             if (substr($part, 0, 8) == 'display:') {
                 $a = explode(':', $part);
                 $display = $a[1];
                 $skip++;
             } elseif (substr($part, 0, 5) == 'meta:') {
                 $a = explode(':', $part);
                 $meta = $a[1];
                 $skip++;
             } elseif (substr($part, 0, 10) == 'titlelink:') {
                 $a = explode(':', $part);
                 $titleLink = $a[1];
                 $skip++;
             } elseif (substr($part, 0, 9) == 'featured:') {
                 $a = explode(':', $part);
                 $featured = $a[1];
                 $skip++;
             } elseif (substr($part, 0, 10) == 'frontpage:') {
                 $a = explode(':', $part);
                 $frontpage = (int) $a[1];
                 $skip++;
             } elseif (substr($part, 0, 5) == 'cols:') {
                 $a = explode(':', $part);
                 $cols = $a[1];
                 $skip++;
             } elseif (substr($part, 0, 9) == 'template:') {
                 $a = explode(':', $part);
                 $template = $a[1];
                 $skip++;
             } elseif (substr($part, 0, 9) == 'truncate:') {
                 $a = explode(':', $part);
                 $truncate = (int) $a[1];
                 $skip++;
             } else {
                 break;
             }
         }
         if ($skip != 0) {
             if (count($px) > $skip) {
                 for ($i = 0; $i < $skip; $i++) {
                     array_shift($px);
                 }
                 $caption = trim(implode(' ', $px));
             } else {
                 $caption = '';
             }
         }
     } else {
         $caption = trim($p2);
     }
     if ($display < 0) {
         $display = 3;
     }
     $hash = CACHE_security_hash();
     $instance_id = 'whatsnew_headlines_' . $uniqueID . '_' . $hash . '_' . $_USER['theme'];
     if (($cache = CACHE_check_instance($instance_id, 0)) !== FALSE) {
         return $cache;
     }
     $archivetid = DB_getItem($_TABLES['topics'], 'tid', "archive_flag=1");
     $sql = " (date <= NOW()) AND (draft_flag = 0)";
     if (empty($topic)) {
         $sql .= COM_getLangSQL('tid', 'AND', 's');
     }
     // if a topic was provided only select those stories.
     if (!empty($topic)) {
         $sql .= " AND s.tid = '" . DB_escapeString($topic) . "' ";
     }
     if ($featured == 1) {
         $sql .= " AND s.featured = 1 ";
     } else {
         if ($featured == 2) {
             $sql .= " AND s.featured = 0 ";
         }
     }
     if ($frontpage == 1) {
         $sql .= " AND frontpage = 1 ";
     }
     if ($topic != $archivetid) {
         $sql .= " AND s.tid != '{$archivetid}' ";
     }
     $sql .= COM_getPermSQL('AND', 0, 2, 's');
     $sql .= COM_getTopicSQL('AND', 0, 's') . ' ';
     $userfields = 'u.uid, u.username, u.fullname';
     if ($_CONF['allow_user_photo'] == 1) {
         $userfields .= ', u.photo';
         if ($_CONF['use_gravatar']) {
             $userfields .= ', u.email';
         }
     }
     $orderBy = ' date DESC ';
     $headlinesSQL = "SELECT STRAIGHT_JOIN s.*, UNIX_TIMESTAMP(s.date) AS unixdate, " . 'UNIX_TIMESTAMP(s.expire) as expireunix, ' . $userfields . ", t.topic, t.imageurl " . "FROM {$_TABLES['stories']} AS s, {$_TABLES['users']} AS u, " . "{$_TABLES['topics']} AS t WHERE (s.uid = u.uid) AND (s.tid = t.tid) AND" . $sql . "ORDER BY featured DESC," . $orderBy;
     if ($display > 0) {
         $headlinesSQL .= " LIMIT " . $display;
     }
     $result = DB_query($headlinesSQL);
     $numRows = DB_numRows($result);
     if ($numRows < $cols) {
         $cols = $numRows;
     }
     if ($cols > 6) {
         $cols = 6;
     }
     if ($numRows > 0) {
         $T = new Template($_CONF['path'] . 'system/autotags/');
         $T->set_file('page', $template);
         $T->set_var('columns', $cols);
         $T->set_block('page', 'headlines', 'hl');
         $newstories = array();
         while ($A = DB_fetchArray($result)) {
             $T->unset_var('readmore_url');
             $T->unset_var('lang_readmore');
             if ($A['attribution_author'] != '') {
                 $author = $A['attribution_author'];
             } else {
                 $author = $A['username'];
             }
             $title = COM_undoSpecialChars($A['title']);
             $title = str_replace('&nbsp;', ' ', $title);
             $subtitle = COM_undoSpecialChars($A['subtitle']);
             if ($A['story_image'] != '') {
                 $story_image = $_CONF['site_url'] . $A['story_image'];
             } else {
                 $story_image = '';
             }
             $A['introtext'] = STORY_renderImages($A['sid'], $A['introtext']);
             if (!empty($A['bodytext'])) {
                 $closingP = strrpos($A['introtext'], "</p>");
                 if ($closingP !== FALSE) {
                     $text = substr($A['introtext'], 0, $closingP);
                     $A['introtext'] = $text;
                 }
                 // adds the read more link
                 $T->set_var('readmore_url', COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $A['sid']));
                 $T->set_var('lang_readmore', $LANG01['continue_reading']);
             }
             if ($truncate > 0) {
                 $A['introtext'] = $this->truncateHTML($A['introtext'], $truncate, '...');
             }
             $topicurl = $_CONF['site_url'] . '/index.php?topic=' . $A['tid'];
             $dt->setTimestamp($A['unixdate']);
             if ($A['commentcode'] >= 0) {
                 $cmtLinkArray = CMT_getCommentLinkWithCount('article', $A['sid'], $_CONF['site_url'] . '/article.php?story=' . $A['sid'], $A['comments'], 1);
                 $T->set_var(array('lang_comments' => '', 'comments_count' => $cmtLinkArray['comment_count'], 'comments_url' => $cmtLinkArray['url'], 'comments_url_extra' => $cmtLinkArray['url_extra']));
             } else {
                 $T->unset_var('lang_comments');
                 $T->unset_var('comments_count');
                 $T->unset_var('comments_url');
                 $T->unset_var('comments_url_extra');
             }
             $T->set_var(array('titlelink' => $titleLink ? TRUE : '', 'meta' => $meta ? TRUE : '', 'lang_by' => $LANG01[95], 'lang_posted_in' => $LANG01['posted_in'], 'story_topic_url' => $topicurl, 'title' => $title, 'subtitle' => $subtitle, 'story_image' => $story_image, 'text' => PLG_replaceTags($A['introtext']), 'date' => $A['date'], 'time' => $dt->format('Y-m-d', true) . 'T' . $dt->format('H:i:s', true), 'topic' => $A['topic'], 'tid' => $A['tid'], 'author' => $author, 'author_id' => $A['uid'], 'sid' => $A['sid'], 'short_date' => $dt->format($_CONF['shortdate'], true), 'date_only' => $dt->format($_CONF['dateonly'], true), 'date' => $dt->format($dt->getUserFormat(), true), 'url' => COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $A['sid']), 'attribution_url' => $A['attribution_url'], 'attribution_name' => $A['attribution_name']));
             $T->parse('hl', 'headlines', true);
         }
         $retval = $T->finish($T->parse('output', 'page'));
         CACHE_create_instance($instance_id, $retval, 0);
     }
     return $retval;
 }
示例#5
0
/**
* Shows any new information in a block
*
* Return the HTML that shows any new stories, comments, etc
*
* @param    string  $help     Help file for block
* @param    string  $title    Title used in block header
* @param    string  $position Position in which block is being rendered 'left', 'right' or blank (for centre)
* @return   string  Return the HTML that shows any new stories, comments, etc
*
*/
function COM_whatsNewBlock($help = '', $title = '', $position = '')
{
    global $_CONF, $_TABLES, $LANG01, $LANG_WHATSNEW, $page, $_USER;
    if ($_CONF['whatsnew_cache_time'] > 0) {
        $cacheInstance = 'whatsnew__' . CACHE_security_hash() . '__' . $_CONF['theme'];
        $retval = CACHE_check_instance($cacheInstance);
        if ($retval) {
            $lu = CACHE_get_instance_update($cacheInstance);
            $now = time();
            if ($now - $lu < $_CONF['whatsnew_cache_time']) {
                return $retval;
            }
        }
    }
    $retval = COM_startBlock($title, $help, COM_getBlockTemplate('whats_new_block', 'header', $position));
    $topicsql = '';
    if ($_CONF['hidenewstories'] == 0 || $_CONF['hidenewcomments'] == 0 || $_CONF['trackback_enabled'] && $_CONF['hidenewtrackbacks'] == 0) {
        $topicsql = COM_getTopicSql('AND', 0, 'ta');
    }
    if ($_CONF['hidenewstories'] == 0) {
        $where_sql = " AND ta.type = 'article' AND ta.id = sid";
        $archsql = '';
        $archivetid = DB_getItem($_TABLES['topics'], 'tid', "archive_flag=1");
        if (!empty($archivetid)) {
            $where_sql .= " AND (ta.tid <> '{$archivetid}')";
        }
        // Find the newest stories
        $sql['mssql'] = "SELECT sid, title FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta\n            WHERE (date >= (date_sub(NOW(), INTERVAL {$_CONF['newstoriesinterval']} SECOND))) AND (date <= NOW()) AND (draft_flag = 0)" . $where_sql . COM_getPermSQL('AND') . $topicsql . COM_getLangSQL('sid', 'AND') . "\n            GROUP BY sid, title ORDER BY date DESC";
        $sql['mysql'] = "SELECT sid, title FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta\n            WHERE (date >= (date_sub(NOW(), INTERVAL {$_CONF['newstoriesinterval']} SECOND))) AND (date <= NOW()) AND (draft_flag = 0)" . $where_sql . COM_getPermSQL('AND') . $topicsql . COM_getLangSQL('sid', 'AND') . "\n            GROUP BY sid, title ORDER BY date DESC";
        $sql['pgsql'] = "SELECT sid, title FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta\n            WHERE (date >= (NOW() - INTERVAL '{$_CONF['newstoriesinterval']} SECOND')) AND (date <= NOW()) AND (draft_flag = 0)" . $where_sql . COM_getPermSQL('AND') . $topicsql . COM_getLangSQL('sid', 'AND') . "\n            GROUP BY sid, title ORDER BY date DESC";
        $result = DB_query($sql);
        $nrows = DB_numRows($result);
        if (empty($title)) {
            $title = DB_getItem($_TABLES['blocks'], 'title', "name='whats_new_block'");
        }
        // Any late breaking news stories?
        $retval .= '<h3>' . $LANG01[99] . ' <small>' . COM_formatTimeString($LANG_WHATSNEW['new_last'], $_CONF['newstoriesinterval']) . '</small></h3>';
        if ($nrows > 0) {
            $newarticles = array();
            for ($x = 0; $x < $nrows; $x++) {
                $A = DB_fetchArray($result);
                $url = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $A['sid']);
                $title = COM_undoSpecialChars(stripslashes($A['title']));
                $titletouse = COM_truncate($title, $_CONF['title_trim_length'], '...');
                if ($title != $titletouse) {
                    $attr = array('title' => htmlspecialchars($title));
                } else {
                    $attr = array();
                }
                $aarticle = str_replace('$', '&#36;', $titletouse);
                $aarticle = str_replace(' ', '&nbsp;', $aarticle);
                $newarticles[] = COM_createLink($aarticle, $url, $attr);
            }
            $retval .= COM_makeList($newarticles, 'list-new-plugins');
        } else {
            $retval .= $LANG01[100] . '<br' . XHTML . '>' . LB;
            // No new stories
        }
        if ($_CONF['hidenewcomments'] == 0 || $_CONF['hidenewplugins'] == 0 || $_CONF['trackback_enabled'] && $_CONF['hidenewtrackbacks'] == 0) {
            $retval .= '<div class="divider-whats-new"></div>';
        }
    }
    if ($_CONF['hidenewcomments'] == 0) {
        // Go get the newest comments
        $retval .= '<h3>' . $LANG01[83] . ' <small>' . COM_formatTimeString($LANG_WHATSNEW['new_last'], $_CONF['newcommentsinterval']) . '</small></h3>';
        $new_plugin_comments = array();
        $new_plugin_comments = PLG_getWhatsNewComment();
        if (!empty($new_plugin_comments)) {
            // Sort array by element lastdate newest to oldest
            foreach ($new_plugin_comments as $k => $v) {
                $b[$k] = strtolower($v['lastdate']);
            }
            arsort($b);
            foreach ($b as $key => $val) {
                $temp[] = $new_plugin_comments[$key];
            }
            $new_plugin_comments = $temp;
            $newcomments = array();
            $count = 0;
            foreach ($new_plugin_comments as $A) {
                $count .= +1;
                $url = '';
                $info = PLG_getItemInfo($A['type'], $A['sid'], 'url');
                if (!empty($info)) {
                    $url = $info . '#comments';
                }
                // Check to see if url (plugin may not support PLG_getItemInfo
                if (!empty($url)) {
                    $title = COM_undoSpecialChars(stripslashes($A['title']));
                    $titletouse = COM_truncate($title, $_CONF['title_trim_length'], '...');
                    if ($title != $titletouse) {
                        $attr = array('title' => htmlspecialchars($title));
                    } else {
                        $attr = array();
                    }
                    $acomment = str_replace('$', '&#36;', $titletouse);
                    $acomment = str_replace(' ', '&nbsp;', $acomment);
                    if ($A['dups'] > 1) {
                        $acomment .= ' [+' . $A['dups'] . ']';
                    }
                    $newcomments[] = COM_createLink($acomment, $url, $attr);
                    if ($count == 15) {
                        break;
                    }
                }
            }
            $retval .= COM_makeList($newcomments, 'list-new-comments');
        } else {
            $retval .= $LANG01[86] . '<br' . XHTML . '>' . LB;
        }
        if ($_CONF['hidenewplugins'] == 0 || $_CONF['trackback_enabled'] && $_CONF['hidenewtrackbacks'] == 0) {
            $retval .= '<div class="divider-whats-new"></div>';
        }
    }
    if ($_CONF['trackback_enabled'] && $_CONF['hidenewtrackbacks'] == 0) {
        $retval .= '<h3>' . $LANG01[114] . ' <small>' . COM_formatTimeString($LANG_WHATSNEW['new_last'], $_CONF['newtrackbackinterval']) . '</small></h3>';
        $sql['mysql'] = "SELECT DISTINCT COUNT(*) AS count,s.title,t.sid,max(t.date) AS lastdate\n            FROM {$_TABLES['trackback']} AS t, {$_TABLES['stories']} s, {$_TABLES['topic_assignments']} ta\n            WHERE ta.type = 'article' AND ta.id = s.sid AND (t.type = 'article') AND (t.sid = s.sid) AND (t.date >= (DATE_SUB(NOW(), INTERVAL {$_CONF['newtrackbackinterval']} SECOND)))" . COM_getPermSQL('AND', 0, 2, 's') . " AND (s.draft_flag = 0) AND (s.trackbackcode = 0)" . $topicsql . COM_getLangSQL('sid', 'AND', 's') . "\n            GROUP BY t.sid, s.title\n            ORDER BY lastdate DESC LIMIT 15";
        $sql['mssql'] = $sql['mysql'];
        $sql['pgsql'] = "SELECT DISTINCT COUNT(*) AS count,s.title,t.sid,max(t.date) AS lastdate\n            FROM {$_TABLES['trackback']} AS t, {$_TABLES['stories']} s, {$_TABLES['topic_assignments']} ta\n            WHERE ta.type = 'article' AND ta.id = s.sid AND (t.type = 'article') AND (t.sid = s.sid) AND (t.date >= (NOW()+ INTERVAL '{$_CONF['newtrackbackinterval']} SECOND'))" . COM_getPermSQL('AND', 0, 2, 's') . " AND (s.draft_flag = 0) AND (s.trackbackcode = 0)" . $topicsql . COM_getLangSQL('sid', 'AND', 's') . "\n            GROUP BY t.sid, s.title\n            ORDER BY lastdate DESC LIMIT 15";
        $result = DB_query($sql);
        $nrows = DB_numRows($result);
        if ($nrows > 0) {
            $newcomments = array();
            for ($i = 0; $i < $nrows; $i++) {
                $A = DB_fetchArray($result);
                $url = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $A['sid']) . '#trackback';
                $title = COM_undoSpecialChars(stripslashes($A['title']));
                $titletouse = COM_truncate($title, $_CONF['title_trim_length'], '...');
                if ($title != $titletouse) {
                    $attr = array('title' => htmlspecialchars($title));
                } else {
                    $attr = array();
                }
                $acomment = str_replace('$', '&#36;', $titletouse);
                $acomment = str_replace(' ', '&nbsp;', $acomment);
                if ($A['count'] > 1) {
                    $acomment .= ' [+' . $A['count'] . ']';
                }
                $newcomments[] = COM_createLink($acomment, $url, $attr);
            }
            $retval .= COM_makeList($newcomments, 'list-new-trackbacks');
        } else {
            $retval .= $LANG01[115] . '<br' . XHTML . '>' . LB;
        }
        if ($_CONF['hidenewplugins'] == 0) {
            $retval .= '<div class="divider-whats-new"></div>';
        }
    }
    if ($_CONF['hidenewplugins'] == 0) {
        list($headlines, $smallheadlines, $content) = PLG_getWhatsNew();
        $plugins = count($headlines);
        if ($plugins > 0) {
            for ($i = 0; $i < $plugins; $i++) {
                $retval .= '<h3>' . $headlines[$i] . ' <small>' . $smallheadlines[$i] . '</small></h3>';
                if (is_array($content[$i])) {
                    $retval .= COM_makeList($content[$i], 'list-new-plugins');
                } else {
                    $retval .= $content[$i];
                }
                if ($i + 1 < $plugins) {
                    $retval .= '<div class="divider-whats-new"></div>';
                }
            }
        }
    }
    $retval .= COM_endBlock(COM_getBlockTemplate('whats_new_block', 'footer', $position));
    if ($_CONF['whatsnew_cache_time'] > 0) {
        CACHE_create_instance($cacheInstance, $retval);
    }
    return $retval;
}
示例#6
0
function assembleMenu($name, $skipCache = false)
{
    $menuData = NULL;
    $lang = COM_getLanguageId();
    if (!empty($lang)) {
        $menuName = $name . '_' . $lang;
    } else {
        $menuName = $name;
    }
    $cacheInstance = 'menudata_' . $menuName . '_' . CACHE_security_hash() . '__data';
    if ($skipCache == false) {
        $cacheCheck = CACHE_check_instance($cacheInstance, 0);
        if ($cacheCheck) {
            $menuData = unserialize($cacheCheck);
            return $menuData;
        }
    }
    $menuObject = initMenu($menuName, $skipCache);
    if ($menuObject != NULL) {
        $menuData = $menuObject->_parseMenu();
        $menuData['type'] = $menuObject->type;
        $cacheMenu = serialize($menuData);
        CACHE_create_instance($cacheInstance, $cacheMenu, 0);
    }
    return $menuData;
}
示例#7
0
/**
* Shows any new information in a block
*
* Return the HTML that shows any new stories, comments, etc
*
* @param    string  $help     Help file for block
* @param    string  $title    Title used in block header
* @param    string  $position Position in which block is being rendered 'left', 'right' or blank (for centre)
* @return   string  Return the HTML that shows any new stories, comments, etc
*
*/
function COM_whatsNewBlock($help = '', $title = '', $position = '')
{
    global $_CONF, $_TABLES, $_USER, $_PLUGINS, $LANG01, $LANG_WHATSNEW, $page, $newstories;
    if (!isset($_CONF['whatsnew_cache_time'])) {
        $_CONF['whatsnew_cache_time'] = 3600;
    }
    $cacheInstance = 'whatsnew__' . CACHE_security_hash() . '__' . $_USER['theme'];
    $retval = CACHE_check_instance($cacheInstance, 0);
    if ($retval) {
        $lu = CACHE_get_instance_update($cacheInstance, 0);
        $now = time();
        if ($now - $lu < $_CONF['whatsnew_cache_time']) {
            return $retval;
        }
    }
    $T = new Template($_CONF['path_layout'] . 'blocks');
    $T->set_file('block', 'whatsnew.thtml');
    $items_found = 0;
    $header = COM_startBlock($title, $help, COM_getBlockTemplate('whats_new_block', 'header', $position), 'whats_new_block');
    $T->set_var('block_start', $header);
    $topicsql = '';
    if ($_CONF['hidenewstories'] == 0 || $_CONF['hidenewcomments'] == 0 || $_CONF['trackback_enabled'] && $_CONF['hidenewtrackbacks'] == 0) {
        $topicsql = COM_getTopicSql('AND', 0, $_TABLES['stories']);
    }
    if ($_CONF['hidenewstories'] == 0) {
        $archsql = '';
        $archivetid = DB_getItem($_TABLES['topics'], 'tid', "archive_flag=1");
        if (!empty($archivetid)) {
            $archsql = " AND (tid <> '" . DB_escapeString($archivetid) . "')";
        }
        // Find the newest stories
        $sql = "SELECT * FROM {$_TABLES['stories']} WHERE (date >= (date_sub(NOW(), INTERVAL {$_CONF['newstoriesinterval']} SECOND))) AND (date <= NOW()) AND (draft_flag = 0)" . $archsql . COM_getPermSQL('AND') . $topicsql . COM_getLangSQL('sid', 'AND') . ' ORDER BY date DESC';
        $result = DB_query($sql);
        $nrows = DB_numRows($result);
        if (empty($title)) {
            $title = DB_getItem($_TABLES['blocks'], 'title', "name='whats_new_block'");
        }
        $T->set_block('block', 'section', 'sectionblock');
        if ($nrows > 0) {
            // Any late breaking news stories?
            $T->set_var('section_title', $LANG01[99]);
            $T->set_var('interval', COM_formatTimeString($LANG_WHATSNEW['new_last'], $_CONF['newcommentsinterval']));
            $newstory = array();
            $T->set_block('block', 'datarow', 'datablock');
            while ($A = DB_fetchArray($result)) {
                $title = COM_undoSpecialChars($A['title']);
                $title = str_replace('&nbsp;', ' ', $title);
                $titletouse = COM_truncate($title, $_CONF['title_trim_length'], '...');
                $attr = array('title' => htmlspecialchars($title, ENT_COMPAT, COM_getEncodingt()));
                $url = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $A['sid']);
                $storyitem = COM_createLink($titletouse, $url, $attr);
                $newstory[] = $storyitem;
                $T->set_var('data_item', $storyitem);
                $T->parse('datablock', 'datarow', true);
                $items_found++;
            }
            $T->parse('sectionblock', 'section', true);
        }
    }
    $T->unset_var('datablock');
    if ($_CONF['hidenewcomments'] == 0) {
        // Go get the newest comments
        $commentHeader = 0;
        $newcomments = array();
        $commentrow = array();
        // get story whats new
        $stwhere = '';
        if (!COM_isAnonUser()) {
            $stwhere .= "({$_TABLES['stories']}.owner_id IS NOT NULL AND {$_TABLES['stories']}.perm_owner IS NOT NULL) OR ";
            $stwhere .= "({$_TABLES['stories']}.group_id IS NOT NULL AND {$_TABLES['stories']}.perm_group IS NOT NULL) OR ";
            $stwhere .= "({$_TABLES['stories']}.perm_members IS NOT NULL)";
        } else {
            $stwhere .= "({$_TABLES['stories']}.perm_anon IS NOT NULL)";
        }
        $sql = "SELECT DISTINCT COUNT(*) AS dups, type, {$_TABLES['stories']}.title, {$_TABLES['stories']}.sid, UNIX_TIMESTAMP(max({$_TABLES['comments']}.date)) AS lastdate FROM {$_TABLES['comments']} LEFT JOIN {$_TABLES['stories']} ON (({$_TABLES['stories']}.sid = {$_TABLES['comments']}.sid)" . COM_getPermSQL('AND', 0, 2, $_TABLES['stories']) . " AND ({$_TABLES['stories']}.draft_flag = 0) AND ({$_TABLES['stories']}.commentcode >= 0)" . $topicsql . COM_getLangSQL('sid', 'AND', $_TABLES['stories']) . ") WHERE ({$_TABLES['comments']}.date >= (DATE_SUB(NOW(), INTERVAL {$_CONF['newcommentsinterval']} SECOND))) AND ((({$stwhere}))) GROUP BY {$_TABLES['comments']}.sid,type, {$_TABLES['stories']}.title, {$_TABLES['stories']}.title, {$_TABLES['stories']}.sid ORDER BY 5 DESC LIMIT 15";
        $result = DB_query($sql);
        $nrows = DB_numRows($result);
        if ($nrows > 0) {
            $T->set_var('section_title', $LANG01[83]);
            $T->set_var('interval', COM_formatTimeString($LANG_WHATSNEW['new_last'], $_CONF['newcommentsinterval']));
            $commentHeader = 1;
            for ($x = 0; $x < $nrows; $x++) {
                $A = DB_fetchArray($result);
                $A['url'] = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $A['sid']) . '#comments';
                $commentrow[] = $A;
            }
        }
        $pluginComments = PLG_getWhatsNewComment();
        $commentrow = array_merge($pluginComments, $commentrow);
        usort($commentrow, '_commentsort');
        $nrows = count($commentrow);
        if ($nrows > 0) {
            if ($commentHeader == 0) {
                $commentHeader = 1;
                $T->set_var('section_title', $LANG01[83]);
                $T->set_var('interval', COM_formatTimeString($LANG_WHATSNEW['new_last'], $_CONF['newcommentsinterval']));
            }
            $newcomments = array();
            for ($x = 0; $x < $nrows; $x++) {
                $titletouse = '';
                $url = $commentrow[$x]['url'];
                $title = COM_undoSpecialChars($commentrow[$x]['title']);
                $title = str_replace('&nbsp;', ' ', $title);
                $titletouse = COM_truncate($title, $_CONF['title_trim_length'], '...');
                $attr = array('title' => htmlspecialchars($title, ENT_COMPAT, COM_getEncodingt()));
                if ($commentrow[$x]['dups'] > 1) {
                    $titletouse .= ' [+' . $commentrow[$x]['dups'] . ']';
                }
                $newcomments[] = COM_createLink($titletouse, $url, $attr);
            }
            $T->set_block('block', 'datarow', 'datablock');
            foreach ($newcomments as $comment) {
                $T->set_var('data_item', $comment);
                $T->parse('datablock', 'datarow', true);
                $items_found++;
            }
            $T->parse('sectionblock', 'section', true);
        }
    }
    $T->unset_var('datablock');
    if ($_CONF['trackback_enabled'] && $_CONF['hidenewtrackbacks'] == 0) {
        $sql = "SELECT DISTINCT COUNT(*) AS count,{$_TABLES['stories']}.title,t.sid,max(t.date) AS lastdate FROM {$_TABLES['trackback']} AS t,{$_TABLES['stories']} WHERE (t.type = 'article') AND (t.sid = {$_TABLES['stories']}.sid) AND (t.date >= (DATE_SUB(NOW(), INTERVAL {$_CONF['newtrackbackinterval']} SECOND)))" . COM_getPermSQL('AND', 0, 2, $_TABLES['stories']) . " AND ({$_TABLES['stories']}.draft_flag = 0) AND ({$_TABLES['stories']}.trackbackcode = 0)" . $topicsql . COM_getLangSQL('sid', 'AND', $_TABLES['stories']) . " GROUP BY t.sid, {$_TABLES['stories']}.title ORDER BY lastdate DESC LIMIT 15";
        $result = DB_query($sql);
        $nrows = DB_numRows($result);
        if ($nrows > 0) {
            $T->set_var('section_title', $LANG01[114]);
            $T->set_var('interval', COM_formatTimeString($LANG_WHATSNEW['new_last'], $_CONF['newtrackbackinterval']));
            $newcomments = array();
            $T->set_block('block', 'datarow', 'datablock');
            for ($i = 0; $i < $nrows; $i++) {
                $titletouse = '';
                $A = DB_fetchArray($result);
                $url = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $A['sid']) . '#trackback';
                $title = COM_undoSpecialChars($A['title']);
                $title = str_replace('&nbsp;', ' ', $title);
                $titletouse = COM_truncate($title, $_CONF['title_trim_length'], '...');
                $attr = array('title' => htmlspecialchars($title, ENT_COMPAT, COM_getEncodingt()));
                if ($A['count'] > 1) {
                    $titletouse .= ' [+' . $A['count'] . ']';
                }
                $trackback = COM_createLink($titletouse, $url, $attr);
                $newcomments[] = $trackback;
                $T->set_var('data_item', $trackback);
                $T->parse('datablock', 'datarow', true);
                $items_found++;
            }
            $T->parse('sectionblock', 'section', true);
        }
    }
    $T->unset_var('datablock');
    if ($_CONF['hidenewplugins'] == 0) {
        list($headlines, $smallheadlines, $content) = PLG_getWhatsNew();
        $plugins = count($headlines);
        if ($plugins > 0) {
            for ($i = 0; $i < $plugins; $i++) {
                $T->set_var('section_title', $headlines[$i]);
                $T->set_var('interval', $smallheadlines[$i]);
                $T->set_block('block', 'datarow', 'datablock');
                if (is_array($content[$i])) {
                    foreach ($content[$i] as $item) {
                        $T->set_var('data_item', $item);
                        $T->parse('datablock', 'datarow', true);
                        $items_found++;
                    }
                } else {
                    $T->set_var('data_item', $content[$i]);
                    $T->parse('datablock', 'datarow', true);
                    $items_found++;
                }
                $T->parse('sectionblock', 'section', true);
                $T->unset_var('datablock');
                $T->unset_var('interval');
                $T->unset_var('section_title');
            }
        }
    }
    if ($items_found == 0) {
        $T->set_var('no_items_found', $LANG01['no_new_items']);
    } else {
        $T->set_var('no_items_found', '');
    }
    $T->set_var('block_end', COM_endBlock(COM_getBlockTemplate('whats_new_block', 'footer', $position)));
    $T->parse('output', 'block');
    $final = $T->finish($T->get_var('output'));
    CACHE_create_instance($cacheInstance, $final, 0);
    return $final;
}
示例#8
0
/**
 * 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&amp;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&amp;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' . '&amp;pid=0&amp;type=article');
                }
                if ($story->DisplayElements('commentcode') == 0 && ($_CONF['commentsloginrequired'] == 0 || !COM_isAnonUser())) {
                    $postCommentUrl = $_CONF['site_url'] . '/comment.php?sid=' . $story->getSid() . '&amp;pid=0&amp;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&amp;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() . '&amp;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() . '&amp;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&amp;sid=' . $story->getSid()));
            $article->set_var('edit_url', $_CONF['site_admin_url'] . '/story.php?edit=x&amp;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&amp;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'));
}
示例#9
0
function SOC_getFollowMeIcons($uid = 0, $templateFile = 'follow_user.thtml')
{
    global $_CONF, $_TABLES, $_USER, $LANG_SOCIAL;
    $retval = '';
    if ($uid == 0) {
        if (COM_isAnonUser()) {
            return;
        }
        $uid = $_USER['uid'];
    }
    if ($uid == -1) {
        $hash = CACHE_security_hash() . md5($templateFile);
        $instance_id = 'social_site_' . $hash . '_' . $_USER['theme'];
        if (($cache = CACHE_check_instance($instance_id, 0)) !== FALSE) {
            return $cache;
        }
    }
    $T = new Template($_CONF['path_layout'] . 'social');
    $T->set_file('links', $templateFile);
    // build SQL to pull this user's active social integrations
    $sql = "SELECT * FROM {$_TABLES['social_follow_services']} as ss LEFT JOIN\n            {$_TABLES['social_follow_user']} AS su ON ss.ssid = su.ssid\n            WHERE su.uid = " . (int) $uid . " AND ss.enabled = 1 ORDER BY service_name";
    $result = DB_query($sql);
    $numRows = DB_numRows($result);
    if ($numRows > 0) {
        $T->set_block('links', 'social_buttons', 'sb');
        for ($x = 0; $x < $numRows; $x++) {
            $row = DB_fetchArray($result);
            $social_url = str_replace("%%u", $row['ss_username'], $row['url']);
            $T->set_var(array('service_icon' => $row['icon'], 'service_display_name' => $row['display_name'], 'social_url' => $social_url));
            $T->set_var('lang_follow_me', $LANG_SOCIAL['follow_me']);
            $T->set_var('lang_follow_us', $LANG_SOCIAL['follow_us']);
            $T->parse('sb', 'social_buttons', true);
        }
        $T->set_var('lang_share_it', $LANG_SOCIAL['share_it_label']);
        $T->set_var('lang_follow_us', $LANG_SOCIAL['follow_us']);
        if ($uid == -1) {
            $cfg =& config::get_instance();
            $_SOCIAL = $cfg->get_config('social_internal');
            if (isset($_SOCIAL['social_site_extra'])) {
                $T->set_var('extra', $_SOCIAL['social_site_extra']);
            }
        }
        $retval = $T->finish($T->parse('output', 'links'));
    }
    if ($uid == -1) {
        CACHE_create_instance($instance_id, $retval, 0);
    }
    return $retval;
}