Welcome to Geeklog, Anonymous Sunday, December 22 2024 @ 09:03 pm EST

Geeklog Forums

Comments Form on same page as story


Status: offline

Chase

Forum User
Regular Poster
Registered: 03/14/08
Posts: 110
Location:Karachi, Pakistan
Howto get comments on the same page as the story?

Is that possible? Many times people want to refer to original content when posting a comment to the story. At the moment GL takes you to a new page to post a comment which makes it difficult to look back at the original content.

pointers, ideas, hacks??


--
http://TazaKino.com - Pakistani News
Where YOU report the news
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
This was supposed to come as part of one of the Summer of Code projects, but didn't make it, from what I heard.

Has anyone tried "cheating" by using an iframe?

bye, Dirk
 Quote

Status: offline

::Ben

Forum User
Full Member
Registered: 01/14/05
Posts: 1569
Location:la rochelle, France
Story in an iframe

In your commentform.thtml or commentform_advanced.thtml add in the begining or after {start_block_postacomment}
Text Formatted Code
<iframe src="{site_url}/article2.php?story={sid}" width=100% height=200 frameborder="1">
</iframe>


Add this article2.php (site header and site footer are removed) in your public_html

Text Formatted Code
<?php

/* Reminder: always indent with 4 spaces (no tabs). */
// +---------------------------------------------------------------------------+
// | Geeklog 1.5                                                               |
// +---------------------------------------------------------------------------+
// | article2.php                                                               |
// |                                                                           |
// | Shows articles in various formats.                                        |
// +---------------------------------------------------------------------------+
// | Copyright (C) 2000-2008 by the following authors:                         |
// |                                                                           |
// | Authors: Tony Bibbs        - tony AT tonybibbs DOT com                    |
// |          Jason Whittenburg - jwhitten AT securitygeeks DOT com            |
// |          Dirk Haun         - dirk AT haun-online DOT de                   |
// |          Vincent Furia     - vinny01 AT users DOT sourceforge DOT net     |
// +---------------------------------------------------------------------------+
// |                                                                           |
// | This program is free software; you can redistribute it and/or             |
// | modify it under the terms of the GNU General Public License               |
// | as published by the Free Software Foundation; either version 2            |
// | of the License, or (at your option) any later version.                    |
// |                                                                           |
// | This program is distributed in the hope that it will be useful,           |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of            |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             |
// | GNU General Public License for more details.                              |
// |                                                                           |
// | You should have received a copy of the GNU General Public License         |
// | along with this program; if not, write to the Free Software Foundation,   |
// | Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.           |
// |                                                                           |
// +---------------------------------------------------------------------------+
//
// $Id: article.php,v 1.96 2008/05/18 19:29:30 dhaun Exp $

/**
* This page is responsible for showing a single article in different modes which
* may, or may not, include the comments attached
*
* @author   Jason Whittenburg
* @author   Tony Bibbbs <tony@tonybibbs.com>
* @author   Vincent Furia <vinny01 AT users DOT sourceforge DOT net>
*/

/**
* Geeklog common function library
*/
require_once 'lib-common.php';
require_once $_CONF['path_system'] . 'lib-story.php';
if ($_CONF['trackback_enabled']) {
    require_once $_CONF['path_system'] . 'lib-trackback.php';
}

// Uncomment the line below if you need to debug the HTTP variables being passed
// to the script.  This will sometimes cause errors but it will allow you to see
// the data being passed in a POST operation

// echo COM_debug($_POST);

// MAIN
$display = '';

$order = '';
$query = '';
$reply = '';
if (isset ($_POST['mode'])) {
    $sid = COM_applyFilter ($_POST['story']);
    $mode = COM_applyFilter ($_POST['mode']);
    if (isset ($_POST['order'])) {
        $order = COM_applyFilter ($_POST['order']);
    }
    if (isset ($_POST['query'])) {
        $query = COM_applyFilter ($_POST['query']);
    }
    if (isset ($_POST['reply'])) {
        $reply = COM_applyFilter ($_POST['reply']);
    }
} else {
    COM_setArgNames (array ('story', 'mode'));
    $sid = COM_applyFilter (COM_getArgument ('story'));
    $mode = COM_applyFilter (COM_getArgument ('mode'));
    if (isset ($_GET['order'])) {
        $order = COM_applyFilter ($_GET['order']);
    }
    if (isset ($_GET['query'])) {
        $query = COM_applyFilter ($_GET['query']);
    }
    if (isset ($_GET['reply'])) {
        $reply = COM_applyFilter ($_GET['reply']);
    }
}

if (empty ($sid)) {
    echo COM_refresh ($_CONF['site_url'] . '/index.php');
    exit();
}
if ((strcasecmp ($order, 'ASC') != 0) && (strcasecmp ($order, 'DESC') != 0)) {
    $order = '';
}

$result = DB_query("SELECT COUNT(*) AS count FROM {$_TABLES['stories']} WHERE sid = '$sid'" . COM_getPermSql ('AND'));
$A = DB_fetchArray($result);
if ($A['count'] > 0) {

    $story = new Story();

    $args = array (
                    'sid' => $sid,
                    'mode' => 'view'
                  );

    $output = STORY_LOADED_OK;
    $result = PLG_invokeService('story', 'get', $args, $output, $svc_msg);

    if($result == PLG_RET_OK) {
        /* loadFromArray cannot be used, since it overwrites the timestamp */
        reset($story->_dbFields);

        while (list($fieldname,$save) = each($story->_dbFields)) {
            $varname = '_' . $fieldname;

            if (array_key_exists($fieldname, $output)) {
                $story->{$varname} = $output[$fieldname];
            }
        }
    }

    /*$access = SEC_hasAccess ($A['owner_id'], $A['group_id'],
            $A['perm_owner'], $A['perm_group'], $A['perm_members'],
            $A['perm_anon']);
    if (($access == 0) OR !SEC_hasTopicAccess ($A['tid']) OR
        (($A['draft_flag'] == 1) AND !SEC_hasRights ('story.edit'))) {*/
    if ($output == STORY_PERMISSION_DENIED) {
        $display .= COM_siteHeader ('menu', $LANG_ACCESS['accessdenied'])
                 . COM_startBlock ($LANG_ACCESS['accessdenied'], '',
                           COM_getBlockTemplate ('_msg_block', 'header'))
                 . $LANG_ACCESS['storydenialmsg']
                 . COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'))
                 . COM_siteFooter ();
    } elseif ( $output == STORY_INVALID_SID ) {
        $display .= COM_refresh($_CONF['site_url'] . '/index.php');
    } elseif (($mode == 'print') && ($_CONF['hideprintericon'] == 0)) {
        $story_template = new Template ($_CONF['path_layout'] . 'article');
        $story_template->set_file ('article', 'printable.thtml');
        $story_template->set_var ('xhtml', XHTML);
        $story_template->set_var ('page_title',
                $_CONF['site_name'] . ': ' . $story->displayElements('title'));
        $story_template->set_var ( 'story_title', $story->DisplayElements( 'title' ) );
        header ('Content-Type: text/html; charset=' . COM_getCharset ());
        $story_template->set_var ('story_date', $story->displayElements('date'));

        if ($_CONF['contributedbyline'] == 1) {
            $story_template->set_var ('lang_contributedby', $LANG01[1]);
            $authorname = COM_getDisplayName ($story->displayElements('uid'));
            $story_template->set_var ('author', $authorname);
            $story_template->set_var ('story_author', $authorname);
            $story_template->set_var ('story_author_username', $story->DisplayElements('username'));
        }

        $story_template->set_var ('story_introtext',
                                    $story->DisplayElements('introtext'));
        $story_template->set_var ('story_bodytext',
                                    $story->DisplayElements('bodytext'));

        $story_template->set_var ('site_url', $_CONF['site_url']);
        $story_template->set_var ('layout_url', $_CONF['layout_url']);
        $story_template->set_var ('site_name', $_CONF['site_name']);
        $story_template->set_var ('site_slogan', $_CONF['site_slogan']);
        $story_template->set_var ('story_id', $story->getSid());
        $articleUrl = COM_buildUrl ($_CONF['site_url']
                                    . '/article.php?story=' . $story->getSid());
        if ($story->DisplayElements('commentcode') >= 0) {
            $commentsUrl = $articleUrl . '#comments';
            $comments = $story->DisplayElements('comments');
            $numComments = COM_numberFormat ($comments);
            $story_template->set_var ('story_comments', $numComments);
            $story_template->set_var ('comments_url', $commentsUrl);
            $story_template->set_var ('comments_text',
                    $numComments . ' ' . $LANG01[3]);
            $story_template->set_var ('comments_count', $numComments);
            $story_template->set_var ('lang_comments', $LANG01[3]);
            $comments_with_count = sprintf ($LANG01[121], $numComments);

            if ($comments > 0) {
                $comments_with_count = COM_createLink($comments_with_count, $commentsUrl);
            }
            $story_template->set_var ('comments_with_count', $comments_with_count);
        }
        $story_template->set_var ('lang_full_article', $LANG08[33]);
        $story_template->set_var ('article_url', $articleUrl);

        $langAttr = '';
        if( !empty( $_CONF['languages'] ) && !empty( $_CONF['language_files'] ))
        {
            $langId = COM_getLanguageId();
        }
        else
        {
            // try to derive the language id from the locale
            $l = explode( '.', $_CONF['locale'] );
            $langId = $l[0];
        }
        if( !empty( $langId ))
        {
            $l = explode( '-', str_replace( '_', '-', $langId ));
            if(( count( $l ) == 1 ) && ( strlen( $langId ) == 2 ))
            {
                $langAttr = 'lang="' . $langId . '"';
            }
            else if( count( $l ) == 2 )
            {
                if(( $l[0] == 'i' ) || ( $l[0] == 'x' ))
                {
                    $langId = implode( '-', $l );
                    $langAttr = 'lang="' . $langId . '"';
                }
                else if( strlen( $l[0] ) == 2 )
                {
                    $langId = implode( '-', $l );
                    $langAttr = 'lang="' . $langId . '"';
                }
                else
                {
                    $langId = $l[0];
                }
            }
        }
        $story_template->set_var( 'lang_id', $langId );
        $story_template->set_var( 'lang_attribute', $langAttr );

        $story_template->parse ('output', 'article');
        $display = $story_template->finish ($story_template->get_var('output'));
    } else {
        // Set page title
        $pagetitle = $story->DisplayElements('title');

        $rdf = '';
        if ($story->DisplayElements('trackbackcode') == 0) {
            if ($_CONF['trackback_enabled']) {
                $permalink = COM_buildUrl ($_CONF['site_url']
                                           . '/article.php?story=' . $story->getSid());
                $trackbackurl = TRB_makeTrackbackUrl ($story->getSid());
                $rdf = '<!--' . LB
                     . TRB_trackbackRdf ($permalink, $pagetitle, $trackbackurl)
                     . LB . '-->' . LB;
            }
            if ($_CONF['pingback_enabled']) {
                header ('X-Pingback: ' . $_CONF['site_url'] . '/pingback.php');
            }
        }


        if (isset ($_GET['msg'])) {
            $display .= COM_showMessage (COM_applyFilter ($_GET['msg'], true));
        }

        DB_query ("UPDATE {$_TABLES['stories']} SET hits = hits + 1 WHERE (sid = '".$story->getSid()."') AND (date <= NOW()) AND (draft_flag = 0)");

        // Display whats related

        $story_template = new Template($_CONF['path_layout'] . 'article');
        $story_template->set_file('article','article2.thtml');

        $story_template->set_var('xhtml', XHTML);
        $story_template->set_var('site_url', $_CONF['site_url']);
        $story_template->set_var('site_admin_url', $_CONF['site_admin_url']);
        $story_template->set_var('layout_url', $_CONF['layout_url']);
        $story_template->set_var('story_id', $story->getSid());
        $story_template->set_var('story_title', $pagetitle);
        $story_options = array ();
        if (($_CONF['hideemailicon'] == 0) && (!empty ($_USER['username']) ||
                (($_CONF['loginrequired'] == 0) &&
                 ($_CONF['emailstoryloginrequired'] == 0)))) {
            $emailUrl = $_CONF['site_url'] . '/profiles.php?sid=' . $story->getSid()
                      . '&amp;what=emailstory';
            $story_options[] = COM_createLink($LANG11[2], $emailUrl);
            $story_template->set_var ('email_story_url', $emailUrl);
            $story_template->set_var ('lang_email_story', $LANG11[2]);
            $story_template->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'] == 0) {
            $story_options[] = COM_createLink($LANG11[3], $printUrl, array('rel' => 'nofollow'));
            $story_template->set_var ('print_story_url', $printUrl);
            $story_template->set_var ('lang_print_story', $LANG11[3]);
            $story_template->set_var ('lang_print_story_alt', $LANG01[65]);
        }
        if ($_CONF['pdf_enabled'] == 1) {
            $pdfUrl = $_CONF['site_url']
                    . '/pdfgenerator.php?pageType=2&amp;pageData='
                    . urlencode ($printUrl);
            $story_options[] = COM_createLink($LANG11[5], $pdfUrl);
            $story_template->set_var ('pdf_story_url', $printUrl);
            $story_template->set_var ('lang_pdf_story', $LANG11[5]);
        }
        $related = STORY_whatsRelated ($story->displayElements('related'),
                        $story->displayElements('uid'), $story->displayElements('tid'));
        if (!empty ($related)) {
            $related = COM_startBlock ($LANG11[1], '',
                COM_getBlockTemplate ('whats_related_block', 'header'))
                . $related
                . COM_endBlock (COM_getBlockTemplate ('whats_related_block',
                    'footer'));
        }
        if (count ($story_options) > 0) {
            $optionsblock = COM_startBlock ($LANG11[4], '',
                    COM_getBlockTemplate ('story_options_block', 'header'))
                . COM_makeList ($story_options, 'list-story-options')
                . COM_endBlock (COM_getBlockTemplate ('story_options_block',
                    'footer'));
        } else {
            $optionsblock = '';
        }
        $story_template->set_var ('whats_related', $related);
        $story_template->set_var ('story_options', $optionsblock);
        $story_template->set_var ('whats_related_story_options',
                                  $related . $optionsblock);

        $story_template->set_var ('formatted_article',
                                  STORY_renderArticle ($story, 'n', '', $query));

        // display comments or not?
        if ( (is_numeric($mode)) and ($_CONF['allow_page_breaks'] == 1) )
        {
            $story_page = $mode;
            $mode = '';
            if( $story_page <= 0 ) {
                $story_page = 1;
            }
            $article_arr = explode( '[page_break]', $story->displayElements('bodytext'));
            $conf = $_CONF['page_break_comments'];
            if  (
                 ($conf == 'all') or
                 ( ($conf =='first') and ($story_page == 1) ) or
                 ( ($conf == 'last') and (count($article_arr) == ($story_page)) )
                ) {
                $show_comments = true;
            } else {
                $show_comments = false;
            }
        } else {
            $show_comments = true;
        }

        // Display the comments, if there are any ..
        if (($story->displayElements('commentcode') >= 0) and $show_comments) {
            $delete_option = (SEC_hasRights('story.edit') && ($story->getAccess() == 3)
                             ? true : false);
            require_once ( $_CONF['path_system'] . 'lib-comment.php' );
            $story_template->set_var ('commentbar',
                    CMT_userComments ($story->getSid(), $story->displayElements('title'), 'article',
                                      $order, $mode, 0, $page, false, $delete_option, $story->displayElements('commentcode')));
        }

        $display .= $story_template->finish ($story_template->parse ('output', 'article'));

    }
} else {
    $display .= COM_refresh($_CONF['site_url'] . '/index.php');
}

echo $display;

?>
 


It's working.

::Ben
I'm available to customise your themes or plugins for your Geeklog CMS
 Quote

Status: offline

::Ben

Forum User
Full Member
Registered: 01/14/05
Posts: 1569
Location:la rochelle, France
Can everybody go in our requests tracker to made some good comments or votes to this feature. We really need to show the story and the comments with the comment form in the next releases.

::Ben
I'm available to customise your themes or plugins for your Geeklog CMS
 Quote

Status: offline

::Ben

Forum User
Full Member
Registered: 01/14/05
Posts: 1569
Location:la rochelle, France
This feature (iframe) will be available in the next purepro theme. You can see a demo on geeklog.fr for any type of comment (story, filemgmt, mediagallery...).

If you try to reply to a comment, only old comments are display in the iframe

Any feedback is welcome.

Ben
I'm available to customise your themes or plugins for your Geeklog CMS
 Quote

Status: offline

::Ben

Forum User
Full Member
Registered: 01/14/05
Posts: 1569
Location:la rochelle, France
Since I'm testing this feature, I noticed more and more comments on some of my sites. I think we should implement this feature in the core Cool

Ben
I'm available to customise your themes or plugins for your Geeklog CMS
 Quote

Status: offline

kobab

Forum User
Regular Poster
Registered: 02/22/10
Posts: 73
I also really hope this would be implemented to future Geeklog.
 Quote

Status: offline

Laugh

Site Admin
Admin
Registered: 09/27/05
Posts: 1470
Location:Canada
The patch from the bug tracker uses an iframe right? Is this the way to do it?

Also I know some have requested the comment form added to the actual story, etc. instead of going to a new page. Is this the preferred way or would we rather have this patch applied?

I personally rather have it working as you suggest, going to a new form with the preview above of what you are replying to. I find the other way tends to get lost especially on a story that has a number of comments that span multiple pages.

Tom
One of the Geeklog Core Developers.
 Quote

Status: offline

::Ben

Forum User
Full Member
Registered: 01/14/05
Posts: 1569
Location:la rochelle, France
I think we could have the iframe feature on the comment.php page. Like this we can display story or comments we are replying to... But if we could have also a comment form on the story page it would a +, because with a lot of comments, users need to scroll up to find the link to post a comment. Maybe It would also improve usability, as many other cms display a form under the comments.

Ben
I'm available to customise your themes or plugins for your Geeklog CMS
 Quote

Status: offline

kobab

Forum User
Regular Poster
Registered: 02/22/10
Posts: 73
Dengen submitted his updated code HERE.
 Quote

Status: offline

kobab

Forum User
Regular Poster
Registered: 02/22/10
Posts: 73
Dengen set up demo site for his script HERE. Please give it a try.
 Quote

Status: offline

dengen

Site Admin
Admin
Registered: 05/03/07
Posts: 37
Location:Japan
I updated the demo site.

* Removed "Post a comment" button
* Changed Speed Limit message
* Fixed changing the comment title with previewing
* Fixed behavior about multiple pages

But I do not support displaying the comment list when a user replys to a comment on the comment.php page.
 Quote

Status: offline

::Ben

Forum User
Full Member
Registered: 01/14/05
Posts: 1569
Location:la rochelle, France
Nice job Smile

But I do not support displaying the comment list when a user replys to a comment on the comment.php page.


On purepro theme I implemented this feature like this :

In commentform.thtml and in commentform_advanced.thtml I added

Text Formatted Code
<iframe src="{layout_url}/display_comments.php?story={sid}&sid={sid}&pid={pid}&type={type}&title={title}" width=98% id="comments_frame" frameborder="0"  style="height:350px">


an this is the display_comments.php file

Text Formatted Code
<?php
 
/* Reminder: always indent with 4 spaces (no tabs). */
// +---------------------------------------------------------------------------+
// | Purepro 1.8.1.0                                                           |
// +---------------------------------------------------------------------------+
// | display_comments.php                                                      |
// +---------------------------------------------------------------------------+
// | Copyright (C) 2000-2011 by the following authors:                         |
// |                                                                           |
// | Authors: Tony Bibbs        - tony AT tonybibbs DOT com                    |
// |          Jason Whittenburg - jwhitten AT securitygeeks DOT com            |
// |          Dirk Haun         - dirk AT haun-online DOT de                   |
// |          Vincent Furia     - vinny01 AT users DOT sourceforge DOT net     |
// |          Ben               - ben AT geeklog DOT fr                        |
// +---------------------------------------------------------------------------+
// |                                                                           |
// | This program is free software; you can redistribute it and/or             |
// | modify it under the terms of the GNU General Public License               |
// | as published by the Free Software Foundation; either version 2            |
// | of the License, or (at your option) any later version.                    |
// |                                                                           |
// | This program is distributed in the hope that it will be useful,           |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of            |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             |
// | GNU General Public License for more details.                              |
// |                                                                           |
// | You should have received a copy of the GNU General Public License         |
// | along with this program; if not, write to the Free Software Foundation,   |
// | Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.           |
// |                                                                           |
// +---------------------------------------------------------------------------+
//

 
/**
* Geeklog common function library
*/
require_once '../../lib-common.php';
require_once $_CONF['path_system'] . 'lib-story.php';
if ($_CONF['trackback_enabled']) {
    require_once $_CONF['path_system'] . 'lib-trackback.php';
}
 
// Uncomment the line below if you need to debug the HTTP variables being passed
// to the script.  This will sometimes cause errors but it will allow you to see
// the data being passed in a POST operation
 
// echo COM_debug($_POST);

/**
* This function displays the comments in a high level format.
*
* Begins displaying user comments for an item
*
* @param    string      $sid       ID for item to show comments for
* @param    string      $title     Title of item
* @param    string      $type      Type of item (article, polls, etc.)
* @param    string      $order     How to order the comments 'ASC' or 'DESC'
* @param    string      $mode      comment mode (nested, flat, etc.)
* @param    int         $pid       id of parent comment
* @param    int         $page      page number of comments to display
* @param    boolean     $cid       true if $pid should be interpreted as a cid instead
* @param    boolean     $delete_option   if current user can delete comments
* @param    int         $ccode     Comment code: -1=no comments, 0=allowed, 1=closed
* @return   string  HTML Formated Comments
* @see CMT_commentBar
*
*/
function PP_displayUserComments( $sid, $title, $type='article', $order='', $mode='', $pid = 0, $page = 1, $cid = false, $delete_option = false, $ccode = 0 )
{
    global $_CONF, $_TABLES, $_USER, $LANG01;

    $retval = '';

    if (! COM_isAnonUser()) {
        $result = DB_query( "SELECT commentorder,commentmode,commentlimit FROM {$_TABLES['usercomment']} WHERE uid = '{$_USER['uid']}'" );
        $U = DB_fetchArray( $result );
        if( empty( $order ) ) {
            $order = $U['commentorder'];
        }
        if( empty( $mode ) ) {
            $mode = $U['commentmode'];
        }
        $limit = $U['commentlimit'];
    }

    if( $order != 'ASC' && $order != 'DESC' ) {
        $order = 'ASC';
    }

    if( empty( $mode )) {
        $mode = $_CONF['comment_mode'];
    }

    if( empty( $limit )) {
        $limit = $_CONF['comment_limit'];
    }

    if( !is_numeric($page) || $page < 1 ) {
        $page = 1;
    }

    $start = $limit * ( $page - 1 );

    $template = COM_newTemplate($_CONF['path_layout'] . 'comment');
    $template->set_file( array( 'commentarea' => 'startcomment_display.thtml' ));
    $template->set_var( 'commentbar', '');
    $template->set_var( 'sid', $sid );
    $template->set_var( 'comment_type', $type );

    if( $mode == 'nested' || $mode == 'threaded' || $mode == 'flat' ) {
        // build query
        switch( $mode ) {
            case 'flat':
                if( $cid ) {
                    $count = 1;

                    $q = "SELECT c.*, u.username, u.fullname, u.photo, u.email, "
                       . "UNIX_TIMESTAMP(c.date) AS nice_date "
                       . "FROM {$_TABLES['comments']} AS c, {$_TABLES['users']} AS u "
                       . "WHERE c.uid = u.uid AND c.cid = $pid AND type='{$type}'";
                } else {
                    $count = DB_count( $_TABLES['comments'],
                                array( 'sid', 'type' ), array( $sid, $type ));

                    $q = "SELECT c.*, u.username, u.fullname, u.photo, u.email, "
                       . "UNIX_TIMESTAMP(c.date) AS nice_date "
                       . "FROM {$_TABLES['comments']} AS c, {$_TABLES['users']} AS u "
                       . "WHERE c.uid = u.uid AND c.sid = '$sid' AND type='{$type}' "
                       . "ORDER BY date $order LIMIT $start, $limit";
                }
                break;

            case 'nested':
            case 'threaded':
            default:
                if( $order == 'DESC' ) {
                    $cOrder = 'c.rht DESC';
                } else {
                    $cOrder = 'c.lft ASC';
                }

                // We can simplify the query, and hence increase performance
                // when pid = 0 (when fetching all the comments for a given sid)
                if( $cid ) {  // pid refers to commentid rather than parentid
                    // count the total number of applicable comments
                    $q2 = "SELECT COUNT(*) "
                        . "FROM {$_TABLES['comments']} AS c, {$_TABLES['comments']} AS c2 "
                        . "WHERE c.sid = '$sid' AND (c.lft >= c2.lft AND c.lft <= c2.rht) "
                        . "AND c2.cid = $pid AND c.type='{$type}'";
                    $result = DB_query( $q2 );
                    list( $count ) = DB_fetchArray( $result );

                    $q = "SELECT c.*, u.username, u.fullname, u.photo, u.email, c2.indent AS pindent, "
                       . "UNIX_TIMESTAMP(c.date) AS nice_date "
                       . "FROM {$_TABLES['comments']} AS c, {$_TABLES['comments']} AS c2, "
                       . "{$_TABLES['users']} AS u "
                       . "WHERE c.sid = '$sid' AND (c.lft >= c2.lft AND c.lft <= c2.rht) "
                       . "AND c2.cid = $pid AND c.uid = u.uid AND c.type='{$type}' "
                       . "ORDER BY $cOrder LIMIT $start, $limit";
                } else {    // pid refers to parentid rather than commentid
                    if( $pid == 0 ) {  // the simple, fast case
                        // count the total number of applicable comments
                        $count = DB_count( $_TABLES['comments'],
                                array( 'sid', 'type' ), array( $sid, $type ));

                        $q = "SELECT c.*, u.username, u.fullname, u.photo, u.email, 0 AS pindent, "
                           . "UNIX_TIMESTAMP(c.date) AS nice_date "
                           . "FROM {$_TABLES['comments']} AS c, {$_TABLES['users']} AS u "
                           . "WHERE c.sid = '$sid' AND c.uid = u.uid  AND type='{$type}' "
                           . "ORDER BY $cOrder LIMIT $start, $limit";
                    } else {
                        // count the total number of applicable comments
                        $q2 = "SELECT COUNT(*) "
                            . "FROM {$_TABLES['comments']} AS c, {$_TABLES['comments']} AS c2 "
                            . "WHERE c.sid = '$sid' AND (c.lft > c2.lft AND c.lft < c2.rht) "
                            . "AND c2.cid = $pid AND c.type='{$type}'";
                        $result = DB_query($q2);
                        list($count) = DB_fetchArray($result);

                        $q = "SELECT c.*, u.username, u.fullname, u.photo, u.email, c2.indent + 1 AS pindent, "
                           . "UNIX_TIMESTAMP(c.date) AS nice_date "
                           . "FROM {$_TABLES['comments']} AS c, {$_TABLES['comments']} AS c2, "
                           . "{$_TABLES['users']} AS u "
                           . "WHERE c.sid = '$sid' AND (c.lft > c2.lft AND c.lft < c2.rht) "
                           . "AND c2.cid = $pid AND c.uid = u.uid AND c.type='{$type}' "
                           . "ORDER BY $cOrder LIMIT $start, $limit";
                    }
                }
                break;
        }

        $thecomments = '';
        $result = DB_query( $q );
        $thecomments .= PP_getComment( $result, $mode, $type, $order,
                                        $delete_option, false, $ccode );

        // Pagination
        $tot_pages =  ceil($count / $limit);
        if ($type == 'article') {
            $pLink = $_CONF['site_url'] . "/article.php?story=$sid";
        } else {
            list($plgurl, $plgid) = PLG_getCommentUrlId($type);
            $pLink = "$plgurl?$plgid=$sid";
        }
        $pLink .= "&amp;type=$type&amp;order=$order&amp;mode=$mode";
       
        $page_str = "cpage=";
        $template->set_var('pagenav',
                           COM_printPageNavigation($pLink, $page, $tot_pages, $page_str, false));

        $template->set_var('comments', $thecomments);
        $retval = $template->finish($template->parse('output', 'commentarea'));
    }

    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 PP_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 = COM_newTemplate($_CONF['path_layout'] . 'comment');
    $template->set_file( array( 'comment' => 'comment_display.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 ) {
        $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']);
            }
            $profile_link = $_CONF['site_url']
                          . '/users.php?mode=profile&amp;uid=' . $A['uid'];
            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, $profile_link));
            } else {
                $template->set_var('author_photo', '');
                $template->set_var('camera_icon', '');
            }

            $template->set_var('start_author_anchortag',
                               '<a href="' . $profile_link . '">' );
            $template->set_var('end_author_anchortag', '</a>');
            $template->set_var('author_link',
                               COM_createLink($fullname, $profile_link));

        } 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 (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', '' );
        }

        // 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&amp;sid='
                       . $A['sid'] . '&amp;title=' . urlencode( htmlspecialchars( $P['title'] ))
                       . '&amp;type=' . $type . '&amp;order=' . $order . '&amp;pid='
                       . $P['pid'] . '&amp;format=threaded';
            } else {
                $plink = $_CONF['site_url'] . '/comment.php?mode=view&amp;sid='
                       . $A['sid'] . '&amp;title=' . urlencode( htmlspecialchars( $P['title'] ))
                       . '&amp;type=' . $type . '&amp;order=' . $order . '&amp;cid='
                       . $A['pid'] . '&amp;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&amp;cid='
                . $A['cid'] . '&amp;sid=' . $A['sid'] . '&amp;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&amp;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&amp;cid='
                . $A['cid'] . '&amp;sid=' . $A['sid'] . '&amp;type=' . $type
                . '&amp;' . 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&amp;cid=' . $A['cid']
                    . '&amp;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'] = '<p>' . nl2br($A['comment']) . '</p>';
        }

        // highlight search terms if specified
        if( !empty( $_REQUEST['query'] )) {
            $A['comment'] = COM_highlightQuery( $A['comment'],
                                                $_REQUEST['query'] );
        }

        $A['comment'] = str_replace( '$', '&#36;',  $A['comment'] );
        $A['comment'] = str_replace( '{', '&#123;', $A['comment'] );
        $A['comment'] = str_replace( '}', '&#125;', $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']
                        . '&amp;pid=' . $A['cid'] . '&amp;title='
                        . urlencode($A['title']) . '&amp;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( '$', '&#36;', $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( !$preview && ($A = DB_fetchArray( $comments )));
   


    return $retval;
}
 
// MAIN
if (! in_array('purepro', $_PLUGINS) || DB_getItem($_TABLES['plugins'], 'pi_enabled', "pi_name = 'purepro'") == 0 || is_numeric(DB_getItem($_TABLES['pp_settings'], 'id', "bydefault = 1")) == false) {
        //Purepro theme
        if ( file_exists($_CONF['path_data'] . 'purepro/1/theme.php') ) {
                include $_CONF['path_data'] . 'purepro/1/theme.php';
                $id = 1;

                if(!defined("PUREPROID")) {
                        define("PUREPROID", $id);
                }
        } else {
                die("Oups... No template : Help! >> Please be sure your data/purepro/1/theme.php file exists.");
        }
} else {
        //Purepro online theme maker
        if ($_COOKIE['pureprotheme'] == '') {
                $_COOKIE['pureprotheme'] = 1;
        }
        if(!defined("PUREPROID")) {
                define("PUREPROID", $_COOKIE['pureprotheme']);
        }
}
$cssvers = getcsscounter(PUREPROID);
$css_url = $_CONF['layout_url'] . '/css.php?id='. PUREPROID . '&vers=' . $cssvers;
$display = '<link rel="stylesheet" type="text/css" href="' . $css_url . '"><body style="background:#BBB !important; margin:10px !important;">';
 
$order = '';
$query = '';
$reply = '';
if (isset ($_POST['mode'])) {
    $sid = COM_applyFilter ($_POST['story']);
    $mode = COM_applyFilter ($_POST['mode']);
    if (isset ($_POST['order'])) {
        $order = COM_applyFilter ($_POST['order']);
    }
    if (isset ($_POST['query'])) {
        $query = COM_applyFilter ($_POST['query']);
    }
    if (isset ($_POST['reply'])) {
        $reply = COM_applyFilter ($_POST['reply']);
    }
} else {
    COM_setArgNames (array ('story', 'mode'));
    $sid = COM_applyFilter (COM_getArgument ('story'));
    $mode = COM_applyFilter (COM_getArgument ('mode'));
    if (isset ($_GET['order'])) {
        $order = COM_applyFilter ($_GET['order']);
    }
    if (isset ($_GET['query'])) {
        $query = COM_applyFilter ($_GET['query']);
    }
    if (isset ($_GET['reply'])) {
        $reply = COM_applyFilter ($_GET['reply']);
    }
}
       
if ((strcasecmp ($order, 'ASC') != 0) && (strcasecmp ($order, 'DESC') != 0)) {
    $order = '';
}
 
$result = DB_query("SELECT COUNT(*) AS count FROM {$_TABLES['stories']} WHERE sid = '$sid'" . COM_getPermSql ('AND'));
$A = DB_fetchArray($result);
if ($A['count'] > 0 && ($_GET['pid'] == 0) ) {
 
    $story = new Story();
 
    $args = array (
                    'sid' => $sid,
                    'mode' => 'view'
                  );
 
    $output = STORY_LOADED_OK;
    $result = PLG_invokeService('story', 'get', $args, $output, $svc_msg);
 
    if($result == PLG_RET_OK) {
        /* loadFromArray cannot be used, since it overwrites the timestamp */
        reset($story->_dbFields);
 
        while (list($fieldname,$save) = each($story->_dbFields)) {
            $varname = '_' . $fieldname;
 
            if (array_key_exists($fieldname, $output)) {
                $story->{$varname} = $output[$fieldname];
            }
        }
    }
 
    /*$access = SEC_hasAccess ($A['owner_id'], $A['group_id'],
            $A['perm_owner'], $A['perm_group'], $A['perm_members'],
            $A['perm_anon']);
    if (($access == 0) OR !SEC_hasTopicAccess ($A['tid']) OR
        (($A['draft_flag'] == 1) AND !SEC_hasRights ('story.edit'))) {*/
    if ($output == STORY_PERMISSION_DENIED) {
        $display .= COM_siteHeader ('menu', $LANG_ACCESS['accessdenied'])
                 . COM_startBlock ($LANG_ACCESS['accessdenied'], '',
                           COM_getBlockTemplate ('_msg_block', 'header'))
                 . $LANG_ACCESS['storydenialmsg']
                 . COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'))
                 . COM_siteFooter ();
    } elseif ( $output == STORY_INVALID_SID ) {
        $display .= COM_refresh($_CONF['site_url'] . '/index.php');
    } elseif (($mode == 'print') && ($_CONF['hideprintericon'] == 0)) {
        $story_template = new Template ($_CONF['path_layout'] . 'article');
        $story_template->set_file ('article', 'printable.thtml');
        $story_template->set_var ('xhtml', XHTML);
        $story_template->set_var ('page_title',
                $_CONF['site_name'] . ': ' . $story->displayElements('title'));
        $story_template->set_var ( 'story_title', $story->DisplayElements( 'title' ) );
        header ('Content-Type: text/html; charset=' . COM_getCharset ());
        $story_template->set_var ('story_date', $story->displayElements('date'));
 
        if ($_CONF['contributedbyline'] == 1) {
            $story_template->set_var ('lang_contributedby', $LANG01[1]);
            $authorname = COM_getDisplayName ($story->displayElements('uid'));
            $story_template->set_var ('author', $authorname);
            $story_template->set_var ('story_author', $authorname);
            $story_template->set_var ('story_author_username', $story->DisplayElements('username'));
        }
 
        $story_template->set_var ('story_introtext',
                                    $story->DisplayElements('introtext'));
        $story_template->set_var ('story_bodytext',
                                    $story->DisplayElements('bodytext'));
 
        $story_template->set_var ('site_url', $_CONF['site_url']);
        $story_template->set_var ('layout_url', $_CONF['layout_url']);
        $story_template->set_var ('site_name', $_CONF['site_name']);
        $story_template->set_var ('site_slogan', $_CONF['site_slogan']);
        $story_template->set_var ('story_id', $story->getSid());
        $articleUrl = COM_buildUrl ($_CONF['site_url']
                                    . '/article.php?story=' . $story->getSid());
        if ($story->DisplayElements('commentcode') >= 0) {
            $commentsUrl = $articleUrl . '#comments';
            $comments = $story->DisplayElements('comments');
            $numComments = COM_numberFormat ($comments);
            $story_template->set_var ('story_comments', $numComments);
            $story_template->set_var ('comments_url', $commentsUrl);
            $story_template->set_var ('comments_text',
                    $numComments . ' ' . $LANG01[3]);
            $story_template->set_var ('comments_count', $numComments);
            $story_template->set_var ('lang_comments', $LANG01[3]);
            $comments_with_count = sprintf ($LANG01[121], $numComments);
 
            if ($comments > 0) {
                $comments_with_count = COM_createLink($comments_with_count, $commentsUrl);
            }
            $story_template->set_var ('comments_with_count', $comments_with_count);
        }
        $story_template->set_var ('lang_full_article', $LANG08[33]);
        $story_template->set_var ('article_url', $articleUrl);
 
        $langAttr = '';
        if( !empty( $_CONF['languages'] ) && !empty( $_CONF['language_files'] ))
        {
            $langId = COM_getLanguageId();
        }
        else
        {
            // try to derive the language id from the locale
            $l = explode( '.', $_CONF['locale'] );
            $langId = $l[0];
        }
        if( !empty( $langId ))
        {
            $l = explode( '-', str_replace( '_', '-', $langId ));
            if(( count( $l ) == 1 ) && ( strlen( $langId ) == 2 ))
            {
                $langAttr = 'lang="' . $langId . '"';
            }
            else if( count( $l ) == 2 )
            {
                if(( $l[0] == 'i' ) || ( $l[0] == 'x' ))
                {
                    $langId = implode( '-', $l );
                    $langAttr = 'lang="' . $langId . '"';
                }
                else if( strlen( $l[0] ) == 2 )
                {
                    $langId = implode( '-', $l );
                    $langAttr = 'lang="' . $langId . '"';
                }
                else
                {
                    $langId = $l[0];
                }
            }
        }
        $story_template->set_var( 'lang_id', $langId );
        $story_template->set_var( 'lang_attribute', $langAttr );
 
        $story_template->parse ('output', 'article');
        $display = $story_template->finish ($story_template->get_var('output'));
    } else {
        // Set page title
        $pagetitle = $story->DisplayElements('title');
 
        $rdf = '';
        if ($story->DisplayElements('trackbackcode') == 0) {
            if ($_CONF['trackback_enabled']) {
                $permalink = COM_buildUrl ($_CONF['site_url']
                                           . '/article.php?story=' . $story->getSid());
                $trackbackurl = TRB_makeTrackbackUrl ($story->getSid());
                $rdf = '<!--' . LB
                     . TRB_trackbackRdf ($permalink, $pagetitle, $trackbackurl)
                     . LB . '-->' . LB;
            }
            if ($_CONF['pingback_enabled']) {
                header ('X-Pingback: ' . $_CONF['site_url'] . '/pingback.php');
            }
        }
 
 
        if (isset ($_GET['msg'])) {
            $display .= COM_showMessage (COM_applyFilter ($_GET['msg'], true));
        }
 
        //DB_query ("UPDATE {$_TABLES['stories']} SET hits = hits + 1 WHERE (sid = '".$story->getSid()."') AND (date <= NOW()) AND (draft_flag = 0)");
 
        // Display whats related
 
        $story_template = new Template($_CONF['path_layout'] . 'article');
        $story_template->set_file('article','article_display.thtml');
 
        $story_template->set_var('xhtml', XHTML);
        $story_template->set_var('site_url', $_CONF['site_url']);
        $story_template->set_var('site_admin_url', $_CONF['site_admin_url']);
        $story_template->set_var('layout_url', $_CONF['layout_url']);
        $story_template->set_var('story_id', $story->getSid());
        $story_template->set_var('story_title', $pagetitle);
        $story_options = array ();
        if (($_CONF['hideemailicon'] == 0) && (!empty ($_USER['username']) ||
                (($_CONF['loginrequired'] == 0) &&
                 ($_CONF['emailstoryloginrequired'] == 0)))) {
            $emailUrl = $_CONF['site_url'] . '/profiles.php?sid=' . $story->getSid()
                      . '&amp;what=emailstory';
            $story_options[] = COM_createLink($LANG11[2], $emailUrl);
            $story_template->set_var ('email_story_url', $emailUrl);
            $story_template->set_var ('lang_email_story', $LANG11[2]);
            $story_template->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'] == 0) {
            $story_options[] = COM_createLink($LANG11[3], $printUrl, array('rel' => 'nofollow'));
            $story_template->set_var ('print_story_url', $printUrl);
            $story_template->set_var ('lang_print_story', $LANG11[3]);
            $story_template->set_var ('lang_print_story_alt', $LANG01[65]);
        }
        if ($_CONF['pdf_enabled'] == 1) {
            $pdfUrl = $_CONF['site_url']
                    . '/pdfgenerator.php?pageType=2&amp;pageData='
                    . urlencode ($printUrl);
            $story_options[] = COM_createLink($LANG11[5], $pdfUrl);
            $story_template->set_var ('pdf_story_url', $printUrl);
            $story_template->set_var ('lang_pdf_story', $LANG11[5]);
        }
        $related = STORY_whatsRelated ($story->displayElements('related'),
                        $story->displayElements('uid'), $story->displayElements('tid'));
        if (!empty ($related)) {
            $related = COM_startBlock ($LANG11[1], '',
                COM_getBlockTemplate ('whats_related_block', 'header'))
                . $related
                . COM_endBlock (COM_getBlockTemplate ('whats_related_block',
                    'footer'));
        }
        if (count ($story_options) > 0) {
            $optionsblock = COM_startBlock ($LANG11[4], '',
                    COM_getBlockTemplate ('story_options_block', 'header'))
                . COM_makeList ($story_options, 'list-story-options')
                . COM_endBlock (COM_getBlockTemplate ('story_options_block',
                    'footer'));
        } else {
            $optionsblock = '';
        }
        $story_template->set_var ('whats_related', '');
        $story_template->set_var ('story_options', '');
        $story_template->set_var ('whats_related_story_options',
                                  '');
 
        $story_template->set_var ('formatted_article',
                                  STORY_renderArticle ($story, 'n', '', $query));
 
        // display comments or not?
        if ( (is_numeric($mode)) and ($_CONF['allow_page_breaks'] == 1) )
        {
            $story_page = $mode;
            $mode = '';
            if( $story_page <= 0 ) {
                $story_page = 1;
            }
            $article_arr = explode( '[page_break]', $story->displayElements('bodytext'));
            $conf = $_CONF['page_break_comments'];
            if  (
                 ($conf == 'all') or
                 ( ($conf =='first') and ($story_page == 1) ) or
                 ( ($conf == 'last') and (count($article_arr) == ($story_page)) )
                ) {
                $show_comments = true;
            } else {
                $show_comments = false;
            }
        } else {
            $show_comments = true;
        }
 
        // Display the comments, if there are any ..
        if (($story->displayElements('commentcode') >= 0) and $show_comments) {
            $delete_option = (SEC_hasRights('story.edit') && ($story->getAccess() == 3)
                             ? true : false);
            require_once ( $_CONF['path_system'] . 'lib-comment.php' );
            $story_template->set_var ('commentbar',
                    '');
        }
 
        $display .= $story_template->finish ($story_template->parse ('output', 'article'));
 
    }
} else {
        if (isset ($_GET['sid'])) {
                $sid = COM_applyFilter ($_GET['sid']);
        }
        if (isset ($_GET['pid'])) {
                $pid = COM_applyFilter ($_GET['pid']);
        }
        if (isset ($_GET['type'])) {
                $type = COM_applyFilter ($_GET['type']);
        }
        if (isset ($_GET['title'])) {
                $title = COM_applyFilter ($_GET['title']);
        }

    $display .= PP_displayUserComments($sid, $title, $type);
}

COM_output($display);
 
?>

Maybe this can help.

Ben
I'm available to customise your themes or plugins for your Geeklog CMS
 Quote

Status: offline

dengen

Site Admin
Admin
Registered: 05/03/07
Posts: 37
Location:Japan
Thanks Ben.

I'll try your code.
 Quote

Status: offline

dengen

Site Admin
Admin
Registered: 05/03/07
Posts: 37
Location:Japan
I updated the demo site.
Now support displaying the comment list when a user replies to a comment on the comment.php page.
Check it out!

http://test.trybase.com/gldemo/
 Quote

All times are EST. The time is now 09:03 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content