applying printer friendly mod to easyCMS

This forum is now closed as part of retiring phpBB2
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

This forum is now closed due to phpBB2.0 being retired.
Post Reply
krisbfunk
Registered User
Posts: 150
Joined: Mon Jul 10, 2006 1:47 am

applying printer friendly mod to easyCMS

Post by krisbfunk »

Having a little trouble making the printer friendly mod work for easyCMS, especially around the pagenation and 'FORUM_ID' => $forum_id, part. The tpl file modifications aren't a problem, just the php file.

Could someone please post a revision for this for easyCMS?

printer friendly mod found here:
http://www.phpbb.com/phpBB/viewtopic.ph ... 858#799858

Here is the install.mod for the 'printer friendly topic view' mod that needs editing to convert for easyCMS

Code: Select all

##############################################################
## MOD Title: printer-friendly topic view option mod
## MOD Author: Svyatozar < svyatozar@pochtamt.ru > (N/A) N/A
## MOD Description: This mode will add a button with a printer in topic view
## MOD Version: 1.0.8
##
## Installation Level: Intermediate
## Installation Time: 10 minutes.
## Files To Edit: templates/subSilver/subSilver.cfg
##              viewtopic.php
##              templates/subSilver/viewtopic_body.tpl
##              language/lang_english/lang_faq.php
## Included Files: templates/subSilver/images/printer.gif
##              templates/subSilver/printer_header.tpl
##              templates/subSilver/printertopic_body.tpl
##              include/page_header_printer.php
##              language/lang_english/lang_printertopic.php
## Generator: MOD Studio.net [Beta 3c 1.2.1306.29431]
##############################################################
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the 
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code 
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered 
## in our MOD-Database, located at: http://www.phpbb.com/mods/ 
##############################################################
## Author Notes:
## NOTE: this version 1.0.8 is the same as version 1.0.8test, so do not run this file if you have 1.0.8test installed!
## After installing the mod, you may want to install additional language support by running corresponding .mod files.
## Printer-friendly Topic Mod's home page with demo forum:
## http://wiking.sourceforge.net/phpBB2/wakka.php?wakka=PrinterFriendlyTopicView
##############################################################
## MOD History:
##
##   2004-03-24 - Version 1.0.8
##      - important: this release works with phpBB version 2.0.7!
##      - no more symbols: all the buttons are now named properly
##      - introduced language files for English, Russian, Russian_tu, Romanian, Spanish
##        thanks to Vegara < Vegara [ad hoc] tomatoma [dot] ws > for Spanish translation
##        and to bog_tom (Bogdan) < bog_tom@yahoo.com > for Romanian translation
##        please send your translation(s) to http://wiking.sourceforge.net/phpBB2/viewtopic.php?t=3
##      - improved user interface, more intuitive look and feel, javascript "Print" button to start printing
##        thanks to wirewolf (http://shipmodeling.info) for his ideas on how to improve the look of this mod
##      - version 1.0.8 has been tested for almost 3 months so far and is being released without major changes
##
##   2003-11-16 - Version 1.0.7
##      - bugfix release: now fonts in the printer-friendly view are totally template-independent  
##      - added some {} inside if clauses, to conform with the phpbb coding standart
##      - added a faq section to the forum
##
##   2003-10-05 - Version 1.0.6
##      - now finish_rel when negative enables old msgcount's functionality
##      - changed everything that goes with the additional use of finish_rel
##      - major improvement in the clarity of the code, hoping to officially release it soon
##
##   2003-10-05 - Version 1.0.5
##      - this mod is now 100% easymod compatible, thanks to POilf for the example code
##      - alternate text for "printer-friendly" button is now: |##| -> |=|
##
##   2003-09-21 - Version 1.0.4
##      - replaced msgcount with finish_rel get variable to improve on user interface
##      - added start_rel get variable to improve on user interface
##      - added possibility for reader to set a range of messages to print
##      - each message in a topic now has a number shown in the beginning in the printer view
##
##   2003-09-14 - Version 1.0.3
##      - fixed an inconsistent bug of missing timezone in the printer-friendly view
##      - general clean up to prepare for release
##      - passed local test of compatibility with phpBB 2.0.6
##      - passed test to comply with phpBB2 MOD validator tool
##
##   2003-07-18 - Version 1.0.2
##      - added an option for the user to remove pagination
##      - GET variable msgcount is introduced to allow change pagination in the printable view
##      - the printer button is now language independed, making the mod totally language independed
##      - you can now flip pages of a topic within the printable view mode
##      - changed separator between author and the message to make it more readable
##
##   2003-02-03 - Version 1.0.1
##      - pages beyond 1 can now be printed as well
##      - removed signatures from the printer output
##      - poll results are now always in the printer output
##
##   2003-01-21 - Version 1.0.0
##      - this mod was created from scratch when I found out that Print Engine mod (Printable Topics v2)
## apparently discontinued http://phpbb.com/phpBB/viewtopic.php?t=66347
##
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
##############################################################

#
#-----[ COPY ]------------------------------------------
#
copy printer.gif to templates/subSilver/images/printer.gif
copy printer_header.tpl to templates/subSilver/printer_header.tpl
copy printertopic_body.tpl to templates/subSilver/printertopic_body.tpl
copy page_header_printer.php to includes/page_header_printer.php
copy lang_printertopic.php to language/lang_english/lang_printertopic.php
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/subSilver.cfg
#
#-----[ FIND ]------------------------------------------
#
$images['reply_locked'] = "$current_template_images/{LANG}/reply-locked.gif";
#
#-----[ AFTER, ADD ]------------------------------------------
#
$images['printer'] = "$current_template_images/printer.gif";
#
#-----[ OPEN ]------------------------------------------
#
viewtopic.php
#
#-----[ FIND ]------------------------------------------
#
$start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;
#
#-----[ AFTER, ADD ]------------------------------------------
#
if(isset($HTTP_GET_VARS['printertopic']))
{
	$start = ( isset($HTTP_GET_VARS['start_rel']) ) && ( isset($HTTP_GET_VARS['printertopic']) ) ? intval($HTTP_GET_VARS['start_rel']) - 1 : $start;
	// $finish when positive indicates last message; when negative it indicates range; can't be 0
	if(isset($HTTP_GET_VARS['finish_rel']))
	{
		$finish = intval($HTTP_GET_VARS['finish_rel']);
	}
	if(($finish >= 0) && (($finish - $start) <=0))
	{
	unset($finish);
	}
}
#
#-----[ FIND ]------------------------------------------
#
//
// End session management
//
#
#-----[ AFTER, ADD ]------------------------------------------
#
if(!file_exists(@phpbb_realpath($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_printertopic.'.$phpEx)))
{
	include($phpbb_root_path . 'language/lang_english/lang_printertopic.' . $phpEx);
} else
{
	include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_printertopic.' . $phpEx);
}
#
#-----[ FIND ]------------------------------------------
#
	LIMIT $start, ".$board_config['posts_per_page'];
#
#-----[ REPLACE WITH ]------------------------------------------
#
	LIMIT $start, ".(isset($finish)? ((($finish - $start) > 0)? ($finish - $start): -$finish): $board_config['posts_per_page']);
#
#-----[ FIND ]------------------------------------------
#
// Post, reply and other URL generation for
// templating vars
#
#-----[ AFTER, ADD ]------------------------------------------
#
$printer_topic_url = append_sid("viewtopic.$phpEx?printertopic=1&" . POST_TOPIC_URL . "=$topic_id&start=$start&postdays=$post_days&postorder=$post_order&vote=viewresult");
#
#-----[ FIND ]------------------------------------------
#
$post_alt = ( $forum_topic_data['forum_status'] == FORUM_LOCKED ) ? $lang['Forum_locked'] : $lang['Post_new_topic'];
#
#-----[ AFTER, ADD ]------------------------------------------
#
$printer_img = $images['printer'];
$printer_alt = $lang['printertopic_button'];
#
#-----[ FIND ]------------------------------------------
#
//
// Load templates
//
$template->set_filenames(array(
	'body' => 'viewtopic_body.tpl')
);
make_jumpbox('viewforum.'.$phpEx, $forum_id);
#
#-----[ REPLACE WITH ]------------------------------------------
#
//
// Load templates
//
if(isset($HTTP_GET_VARS['printertopic']))
{
	$template->set_filenames(array(
		'body' => 'printertopic_body.tpl')
	);
} else
{
	$template->set_filenames(array(
		'body' => 'viewtopic_body.tpl')
	);
}
make_jumpbox('viewforum.'.$phpEx, $forum_id);
#
#-----[ FIND ]------------------------------------------
#
//
// Output page header
// 
$page_title = $lang['View_topic'] .' - ' . $topic_title;
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
#
#-----[ REPLACE WITH ]------------------------------------------
#
//
// Output page header
//
$page_title = $lang['View_topic'] .' - ' . $topic_title;
if(isset($HTTP_GET_VARS['printertopic']))
{
	include($phpbb_root_path . 'includes/page_header_printer.'.$phpEx);
} else
{
	include($phpbb_root_path . 'includes/page_header.'.$phpEx);
}
#
#-----[ FIND ]------------------------------------------
#
$pagination = ( $highlight != '' ) ? generate_pagination("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&postdays=$post_days&postorder=$post_order&highlight=$highlight", $total_replies, $board_config['posts_per_page'], $start) : generate_pagination("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&postdays=$post_days&postorder=$post_order", $total_replies, $board_config['posts_per_page'], $start);
#
#-----[ REPLACE WITH ]------------------------------------------
#
if(isset($HTTP_GET_VARS['printertopic']))
{
$pagination_printertopic = "printertopic=1&";
}
if($highlight != '')
{
$pagination_highlight = "highlight=$highlight&";
}
$pagination_ppp = $board_config['posts_per_page'];
if(isset($finish))
{
	$pagination_ppp = ($finish < 0)? -$finish: ($finish - $start);
	$pagination_finish_rel = "finish_rel=". -$pagination_ppp. "&amp";
}

$pagination = generate_pagination("viewtopic.$phpEx?". $pagination_printertopic . POST_TOPIC_URL . "=$topic_id&postdays=$post_days&postorder=$post_order&". $pagination_highlight . $pagination_finish_rel, $total_replies, $pagination_ppp, $start);
if($pagination != '' && isset($pagination_printertopic))
{
$pagination .= " &nbsp;<a href=\"viewtopic.$phpEx?". $pagination_printertopic. POST_TOPIC_URL . "=$topic_id&postdays=$post_days&postorder=$post_order&". $pagination_highlight. "start=0&finish_rel=-10000\" title=\"" . $lang['printertopic_cancel_pagination_desc'] . "\">:|&nbsp;|:</a>";
}
#
#-----[ FIND ]------------------------------------------
#
	'FORUM_ID' => $forum_id,
#
#-----[ BEFORE, ADD ]------------------------------------------
#
	'START_REL' => ($start + 1),
	'FINISH_REL' => (isset($HTTP_GET_VARS['finish_rel'])? intval($HTTP_GET_VARS['finish_rel']) : ($board_config['posts_per_page'] - $start)),
#
#-----[ FIND ]------------------------------------------
#
	'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / intval($board_config['posts_per_page']) ) + 1 ), ceil( $total_replies / intval($board_config['posts_per_page']) )),

#
#-----[ REPLACE WITH ]------------------------------------------
#
	'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $pagination_ppp ) + 1 ), ceil( $total_replies / $pagination_ppp )),
#
#-----[ FIND ]------------------------------------------
#
	'REPLY_IMG' => $reply_img,
#
#-----[ AFTER, ADD ]------------------------------------------
#
	'PRINTER_IMG' => $printer_img,
#
#-----[ FIND ]------------------------------------------
#
	'L_POST_REPLY_TOPIC' => $reply_alt,
#
#-----[ AFTER, ADD ]------------------------------------------
#
	'L_PRINTER_TOPIC' => $printer_alt,
#
#-----[ FIND ]------------------------------------------
#
	'U_POST_NEW_TOPIC' => $new_topic_url,
#
#-----[ AFTER, ADD ]------------------------------------------
#
	'U_PRINTER_TOPIC' => $printer_topic_url,
#
#-----[ FIND ]------------------------------------------
#
		'POST_DATE' => $post_date,
#
#-----[ BEFORE, ADD ]------------------------------------------
#
		'POST_NUMBER' => ($i + $start + 1),
#
#-----[ FIND ]------------------------------------------
#
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
#
#-----[ BEFORE, ADD ]------------------------------------------
#
if(isset($HTTP_GET_VARS['printertopic']))
{
	$gen_simple_header = 1;
}
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/viewtopic_body.tpl
#
#-----[ FIND ]------------------------------------------
#
	<td align="left" valign="bottom" nowrap="nowrap"><span class="nav"><a href="{U_POST_NEW_TOPIC}"><img src="{POST_IMG}" border="0" alt="{L_POST_NEW_TOPIC}" align="middle" /></a>&nbsp;&nbsp;&nbsp;<a href="{U_POST_REPLY_TOPIC}"><img src="{REPLY_IMG}" border="0" alt="{L_POST_REPLY_TOPIC}" align="middle" /></a></span></td>
#
#-----[ IN-LINE FIND ]------------------------------------------
#
{L_POST_REPLY_TOPIC}" align="middle" /></a>
#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
&nbsp;&nbsp;&nbsp;<a target="_blank" href="{U_PRINTER_TOPIC}"><img src="{PRINTER_IMG}" border="0" alt="{L_PRINTER_TOPIC}" align="middle" /></a>
#
#-----[ FIND ]------------------------------------------
#
	<td align="left" valign="middle" nowrap="nowrap"><span class="nav"><a href="{U_POST_NEW_TOPIC}"><img src="{POST_IMG}" border="0" alt="{L_POST_NEW_TOPIC}" align="middle" /></a>&nbsp;&nbsp;&nbsp;<a href="{U_POST_REPLY_TOPIC}"><img src="{REPLY_IMG}" border="0" alt="{L_POST_REPLY_TOPIC}" align="middle" /></a></span></td>
#
#-----[ IN-LINE FIND ]------------------------------------------
#
{L_POST_REPLY_TOPIC}" align="middle" /></a>
#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
&nbsp;&nbsp;&nbsp;<a target="_blank" href="{U_PRINTER_TOPIC}"><img src="{PRINTER_IMG}" border="0" alt="{L_PRINTER_TOPIC}" align="middle" /></a>
#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_faq.php
#
#-----[ FIND ]------------------------------------------
#
$faq[] = array("--","Private Messaging");
#
#-----[ BEFORE, ADD ]------------------------------------------
#
$faq[] = array("--","Printer-Friendly Topic View");
$faq[] = array("What is the :| |: button for? - Cancelling the board's pagination", "By clicking on this button you can locally remove the board's fixed pagination for the current topic to help your web browser do the proper pagination for printing based on actual line spacing, rather than the forum-wide limit for number of messages per page.");
$faq[] = array("What are the boxes on top of the printable output? - Range selection", "There are two boxes on top of the page and a tape-recorder-like button Show. They allow to select a range of messages. Note that every message in the printable view has a number. Use those numbers to fill out the boxes on top to set up the first and the last message you want to be printed, and press the Show button to rearrange the messages. Another way to set a range is to put a negative number in the second box, which will mean that you want -n of messages to be printed. For example, 4 7 will output messages 4, 5, 6, 7. However if you enter values 4 -7 in first and second box respectively, messages 4, 5, 6, 7, 8, 9, 10 will be shown after you press the rewind button.");
$faq[] = array("How to print only one message? - Advanced range selection", "First, go to the printable view of the topic by pressing the Printer button in the topic view. Find your message and note the number in the left of it. Type that number into the first box in the top left of the printable view. In the second box put value -1 and press the Show button. This will tell the database to output only one message starting from the given one. Another way of getting this result is by putting the same number in both boxes. Let's say you want to print only the message number 16. Fill out the boxes in the top as such: 16 -1 and press the go button Show. Instead of 16 and -1 you could as well enter 16 and 16. The result will be the same. This example will work only if there are at least sixteen messages in the current topic, of course.");
$faq[] = array("More questions?", "Detailed documentation and support forums are <a href=\"http://wiking.sourceforge.net/phpBB2/wakka.php?wakka=PrinterFriendlyTopicView\">here</a>");
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
and here is the equivalent file in easyCMS for viewtopic.php

cms_view_article.php

Code: Select all

<?php
//-- mod : easy CMS attachments v.1.0.1a ---------------------------------------

// This file modified for Template Dependant Article Icons for easyCMS


define('IN_PHPBB', true);
$phpbb_root_path = './';

include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
include($phpbb_root_path . 'includes/cms_auth.'.$phpEx);
include($phpbb_root_path . 'includes/cms_functions.'.$phpEx);
//-- add mod : easy CMS attachments v.1.0.1a -----------------------------------
include($phpbb_root_path . 'attach_mod/cms_displaying.'.$phpEx);
//-- end mod : easy CMS attachments v.1.0.1a -----------------------------------

include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_cms.'.$phpEx);

get_cms_config();


//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_CMS_VIEW_ARTICLE);
init_userprefs($userdata);
//
// End session management
//

//----------------------------------------------------------------------
// Template Dependant Article Icons for easyCMS - Begin Code Alteration
//
update_icon_config();
//
// Template Dependant Article Icons for easyCMS - End Code Alteration
//----------------------------------------------------------------------




//
// Parameters
//
if( isset($HTTP_GET_VARS['aid']) )
{
	$article_id = intval($HTTP_GET_VARS['aid']);
}

if( isset($HTTP_GET_VARS['cmid']))
{
	$comment_id = intval($HTTP_GET_VARS['cmid']);
}

if( !isset($article_id) && !isset($comment_id) )
{
	message_die(GENERAL_MESSAGE, 'Article_comment_not_exist');
}

$start = ( isset($HTTP_POST_VARS['start']) ) ? intval($HTTP_POST_VARS['start']) : ( ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0 );
$mode = ( isset($HTTP_POST_VARS['mode']) ) ? htmlspecialchars($HTTP_POST_VARS['mode']) : ( ( isset($HTTP_GET_VARS['mode']) ) ? htmlspecialchars($HTTP_GET_VARS['mode']) : '' );


//
// Define censored word matches
//
$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);


//
// Ranks
//
$sql = "SELECT *
		FROM " . RANKS_TABLE . "
		ORDER BY rank_special, rank_min";
if( !$result = $db->sql_query($sql) )
{
	message_die(GENERAL_ERROR, 'Could not obtain ranks information', '', __LINE__, __FILE__, $sql);
}

$ranksrow = array();
while ( $row = $db->sql_fetchrow($result) )
{
	$ranksrow[] = $row;
}
$db->sql_freeresult($result);


if( $comment_id )
{
	$sql = "SELECT article_id FROM " . CMS_COMMENTS_TABLE . " WHERE comment_id = $comment_id";
	if( !$result = $db->sql_query($sql) )
	{
		message_die(GENERAL_ERROR, 'Could not query article id', '', __LINE__, __FILE__, $sql);
	}

	$row = $db->sql_fetchrow($result);
	$article_id = $row['article_id'];
}


//
// Fetch the article information
//
$pending_sql = ( $userdata['user_level'] == ADMIN ) ? '' : 'AND a.article_pending = 0';
$join_sql_table = ( !isset($comment_id) ) ? '' : ", " . CMS_COMMENTS_TABLE . " cm, " . CMS_COMMENTS_TABLE . " cm2 ";
$join_sql = ( !isset($comment_id) ) ? "a.article_id = $article_id" : "cm.comment_id = $comment_id AND a.article_id = cm.article_id AND cm2.article_id = cm.article_id AND cm2.comment_id <= $comment_id";
$count_sql = ( !isset($comment_id) ) ? '' : ", COUNT(cm2.comment_id) AS prev_comments";

$order_sql = ( !isset($comment_id) ) ? '' : "GROUP BY cm.comment_id, a.article_id ORDER BY cm.comment_id ASC";
$sql = "SELECT c.*, a.*, at.*, u.*" . $count_sql . "
		FROM " . CMS_CHAPTERS_TABLE . " c, " . CMS_ARTICLES_TABLE . " a, " . CMS_ARTICLES_TEXT_TABLE . " at, " . USERS_TABLE . " u" . $join_sql_table . "
		WHERE $join_sql
			AND at.article_id = a.article_id
			AND c.chapter_id = a.chapter_id
			AND u.user_id = a.user_id
			$pending_sql
			$order_sql";
if( !$result = $db->sql_query($sql) )
{
	message_die(GENERAL_ERROR, 'Could not retrieve most recent articles information', '', __LINE__, __FILE__, $sql);
}

if( !$article_info = $db->sql_fetchrow($result) )
{
	message_die(GENERAL_MESSAGE, 'No_such_article_id');
}
$db->sql_freeresult($result);

$chapter_id = intval($article_info['chapter_id']);
$article_id = intval($article_info['article_id']);
$poster_id = intval($article_info['user_id']);


//
// Start auth check
//
$is_auth = array();
$is_auth = cms_auth($chapter_id, $userdata, $article_info);
//
// End auth check
//


if( !empty($comment_id) )
{
	$start = floor(($article_info['prev_comments'] - 1) / intval($cms_config['comments_per_page'])) * intval($cms_config['comments_per_page']);
}


//
// Update view count for this article
//
$sql = "UPDATE " . CMS_ARTICLES_TABLE . " SET article_views = article_views + 1 WHERE article_id = $article_id";
if( !$db->sql_query($sql) )
{
	message_die(GENERAL_ERROR, 'Could not update article view stats', '', __LINE__, __FILE__, $sql);
}


//
// Get comments count
//
if( $is_auth['c_view'] && $article_info['enable_comments'] )
{
	$pending_sql = ( $userdata['user_level'] == ADMIN ) ? '' : 'AND comment_pending = 0';
	$sql = "SELECT COUNT(*) AS total
			FROM " . CMS_COMMENTS_TABLE . "
			WHERE article_id = $article_id
				$pending_sql";
	if( !$result = $db->sql_query($sql) )
	{
		message_die(GENERAL_ERROR, 'Could not retrieve comments total', '', __LINE__, __FILE__, $sql);
	}

	$row = $db->sql_fetchrow($result);
	$db->sql_freeresult($result);

	$total_comments = $row['total'];


	//
	// Pagination
	//
	$pagination = '';
	if( $total_comments > 0 )
	{
		$template->assign_vars(array(
			'PAGINATION' => generate_pagination("cms_view_article.$phpEx?aid=$article_id", $total_comments, $cms_config['comments_per_page'], $start),
			'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / intval($cms_config['comments_per_page']) ) + 1 ), ceil( $total_comments / intval($cms_config['comments_per_page']) ))
			)
		);
	}


	//
	// Fetch the comments
	//
	$pending_sql = ( $userdata['user_level'] == ADMIN ) ? '' : 'AND cm.comment_pending = 0';
	$sql = "SELECT cm.*, cmt.*, u.*
			FROM " . CMS_COMMENTS_TABLE . " cm, " . CMS_COMMENTS_TEXT_TABLE . " cmt, " . USERS_TABLE . " u
			WHERE cm.article_id = $article_id
				AND cmt.comment_id = cm.comment_id
				AND u.user_id = cm.user_id
				$pending_sql
			ORDER BY cm.time ASC
			LIMIT $start, " . $cms_config['comments_per_page'];
	if( !$result = $db->sql_query($sql) )
	{
		message_die(GENERAL_ERROR, 'Could not retrieve article comments', '', __LINE__, __FILE__, $sql);
	}

	$comments_row = array();
	while( $row = $db->sql_fetchrow($result) )
	{
		$comments_row[] = $row;
	}

	$db->sql_freeresult($result);
}


$s_post_comment = '';
if( $is_auth['c_new'] && $article_info['enable_comments'] )
{
	$temp_url = append_sid("cms_post_comment.$phpEx?mode=new&aid=$article_id");
	$s_post_comment = '<a href="' . $temp_url . '">' . $lang['Post_comment'] . '</a>';
}


//
// Article icons
//
$sql = "SELECT * FROM " . CMS_ICONS_TABLE . " ORDER BY icon_id ASC";
if( !$result = $db->sql_query($sql) )
{
	message_die(GENERAL_ERROR, 'Could not retrieve icons information', '', __LINE__, __FILE__, $sql);
}

$icon_row = array();
while( $row = $db->sql_fetchrow($result) )
{
	$icon_row[] = $row;
}

$db->sql_freeresult($result);


//
// Output page to template
//
$page_title = $lang['View_article'] . ' - ' . $article_info['article_title'];
include($phpbb_root_path . 'includes/page_header.'.$phpEx);

$template->set_filenames(array(
	'body' => 'cms_articles_view.tpl'
	)
);

$template->assign_vars(array(
	'L_ARTICLE' => $lang['Article'],
	'L_AUTHOR' => $lang['Author'],
	'L_COMMENTS' => $lang['Comments'],
	'L_NO_COMMENTS' => $lang['No_comments'],
	'L_POSTED' => $lang['Posted'],
	'L_POST_SUBJECT' => $lang['Post_subject'],
	'L_RATING' => $lang['Rating'],

	'S_POST_COMMENT' => $s_post_comment,
	'S_RATING_STATS' => calc_rating('article', $article_id)
	)
);

make_chapterbox("cms_articles.$phpEx");
make_cms_navlinks($chapter_id);

if( $is_auth['a_rate'] )
{
	make_ratingbox('article', 'rating', "cms_post_article.$phpEx", $article_id, $poster_id);
}


//
// Article
//
$article_title = $article_info['article_title'];
$article_text = $article_info['article_text'];
$bbcode_uid = $article_info['bbcode_uid'];

//
// HTML, BBcode and Smilies
//
if( !$cms_config['allow_html'] && $article_info['user_level'] != ADMIN )
{
	if( $article_info['enable_html'] )
	{
		$article_text = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $article_text);
	}
}

if( $cms_config['allow_bbcode'] )
{
	if( $bbcode_uid != '' )
	{
		$article_text = ( $cms_config['allow_bbcode'] ) ? bbencode_second_pass($article_text, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $article_text);
	}
}

$article_text = make_clickable($article_text);

if( $cms_config['allow_smilies'] )
{
	if( $article_info['enable_smilies'] )
	{
		$article_text = smilies_pass($article_text);
	}
}

$article_text = str_replace("\n", "\n<br />\n", $article_text);


if( count($orig_word) )
{
	$article_title = preg_replace($orig_word, $replacement_word, $article_title);
	$article_text = str_replace('\"', '"', substr(@preg_replace('#(\>(((\?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $article_text . '<'), 1, -1));
}


$article_icon = '';
for( $i = 0; $i < count($icon_row); $i++ )
{
	if( $icon_row[$i]['icon_id'] == $article_info['article_icon'] )
	{
		$article_icon = '<img src="' . $cms_config['icons_path'] . '/' . $icon_row[$i]['icon_href'] . '" width="19" height="19" alt="" border="0" hspace="0" />';
	}
}


//
// Approve, edit and delete images
//
$approve_img = '';
$approve = '';
if( $is_auth['a_approve'] && $article_info['article_pending'] )
{
	$temp_url = append_sid("cms_post_article.$phpEx?mode=approve&aid=$article_id");
	$approve_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_approve'] . '" alt="' . $lang['Approve_article'] . '" title="' . $lang['Approve_article'] . '" border="0" /></a>';
	$approve = '<a href="' . $temp_url . '">' . $lang['Approve_article'] . '</a>';
}

$edit_img = '';
$edit = '';
if( ($is_auth['a_edit'] && $poster_id == $userdata['user_id']) || $userdata['user_level'] == ADMIN )
{
	$temp_url = append_sid("cms_post_article.$phpEx?mode=editarticle&aid=$article_id");
	$edit_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_edit'] . '" alt="' . $lang['Edit_article'] . '" title="' . $lang['Edit_article'] . '" border="0" /></a>';
	$edit = '<a href="' . $temp_url . '">' . $lang['Edit_article'] . '</a>';
}

$delete_img = '';
$delete = '';
if( ($is_auth['a_delete'] && $poster_id == $userdata['user_id']) || $userdata['user_level'] == ADMIN )
{
	$temp_url = append_sid("cms_post_article.$phpEx?mode=delete&aid=$article_id");
	$delete_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_delpost'] . '" alt="' . $lang['Delete_article'] . '" title="' . $lang['Delete_article'] . '" border="0" /></a>';
	$delete = '<a href="' . $temp_url . '">' . $lang['Delete_article'] . '</a>';
}


//
// Show descriptive text of permissions
//
$s_auth_can = '';
$s_auth_can .= ( $is_auth['a_new'] ) ? $lang['Can_post_articles'] : $lang['Cannot_post_articles'];
$s_auth_can .= ( $is_auth['a_edit'] ) ? $lang['Can_edit_articles'] : $lang['Cannot_edit_articles'];
$s_auth_can .= ( $is_auth['a_delete'] ) ? $lang['Can_delete_articles'] : $lang['Cannot_delete_articles'];
$s_auth_can .= ( $is_auth['a_rate'] ) ? $lang['Can_rate_articles'] : $lang['Cannot_rate_articles'];
$s_auth_can .= ( $article_info['pending_article'] ) ? ( ( $is_auth['a_approve'] ) ? $lang['Can_approve_articles'] : $lang['Cannot_approve_articles'] ) : '';
if( $article_info['enable_comments'] )
{
	$s_auth_can .= '<br />';
	$s_auth_can .= ( $is_auth['c_new'] ) ? $lang['Can_post_comments'] : $lang['Cannot_post_comments'];
	$s_auth_can .= ( $is_auth['c_edit'] ) ? $lang['Can_edit_comments'] : $lang['Cannot_edit_comments'];
	$s_auth_can .= ( $is_auth['c_delete'] ) ? $lang['Can_delete_comments'] : $lang['Cannot_delete_comments'];
	$s_auth_can .= ( $is_auth['c_rate'] ) ? $lang['Can_rate_comments'] : $lang['Cannot_rate_comments'];
	$s_auth_can .= ( $article_info['pending_comments'] ) ? ( ( $is_auth['c_approve'] ) ? $lang['Can_approve_comments'] : $lang['Cannot_approve_comments'] ) : '';
}
//-- add mod : easy CMS attachments v.1.0.1a -----------------------------------
if( !$attach_config['disable_mod'] )
{
	$s_auth_can .= '<br />';
	$s_auth_can .= ($is_auth['a_attach'] && ($is_auth['a_new'] || $is_auth['c_new'])) ? $lang['Can_attach_files'] : $lang['Cannot_attach_files'];
	$s_auth_can .= ($is_auth['a_download']) ? $lang['Can_download_files'] : $lang['Cannot_download_files'];
}
//-- end mod : easy CMS attachments v.1.0.1a -----------------------------------



//
// Set the post details
//
$poster = ( $poster_id == ANONYMOUS ) ? $lang['Guest'] : $article_info['username'];
$poster_articles = ( $poster_id != ANONYMOUS ) ? $lang['Articles'] . ': ' . $article_info['user_articles'] : '';
$poster_comments = ( $poster_id != ANONYMOUS ) ? $lang['Comments'] . ': ' . $article_info['user_comments'] : '';
$poster_from = ( $article_info['user_from'] && $poster_id != ANONYMOUS ) ? $lang['Location'] . ': ' . $article_info['user_from'] : '';
$poster_joined = ( $poster_id != ANONYMOUS ) ? $lang['Joined'] . ': ' . create_date($lang['DATE_FORMAT'], $article_info['user_regdate'], $board_config['board_timezone']) : '';

$poster_avatar = '';
if ( $article_info['user_avatar_type'] && $poster_id != ANONYMOUS && $article_info['user_allowavatar'] && $cms_config['allow_avatar'] )
{
	switch( $article_info['user_avatar_type'] )
	{
		case USER_AVATAR_UPLOAD:
			$poster_avatar = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $article_info['user_avatar'] . '" alt="" border="0" />' : '';
			break;
		case USER_AVATAR_REMOTE:
			$poster_avatar = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $article_info['user_avatar'] . '" alt="" border="0" />' : '';
			break;
		case USER_AVATAR_GALLERY:
			$poster_avatar = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $article_info['user_avatar'] . '" alt="" border="0" />' : '';
			break;
	}
}


//
// User is anonymous and has a username
//
if( $poster_id == ANONYMOUS )
{
	if( $article_info['article_username'] != '' )
	{
		$poster = ( count($orig_word) ) ? preg_replace($orig_word, $replacement_word, $article_info['article_username']) : $article_info['article_username'];
	}
}


//
// Generate ranks, set them to empty string initially.
//
$poster_rank = '';
$rank_image = '';
if( $poster_id == ANONYMOUS )
{
}
else if ( $article_info['user_rank'] )
{
	for($j = 0; $j < count($ranksrow); $j++)
	{
		if ( $article_info['user_rank'] == $ranksrow[$j]['rank_id'] && $ranksrow[$j]['rank_special'] )
		{
			$poster_rank = $ranksrow[$j]['rank_title'];
			$rank_image = ( $ranksrow[$j]['rank_image'] ) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : '';
		}
	}
}
else
{
	for($j = 0; $j < count($ranksrow); $j++)
	{
		if ( $article_info['user_posts'] >= $ranksrow[$j]['rank_min'] && !$ranksrow[$j]['rank_special'] )
		{
			$poster_rank = $ranksrow[$j]['rank_title'];
			$rank_image = ( $ranksrow[$j]['rank_image'] ) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : '';
		}
	}
}


$template->assign_vars(array(
	'ARTICLE_TITLE' => $article_title,
	'ARTICLE_TEXT' => $article_text,
	'AUTHOR' => $poster,
	'ARTICLE_ICON' => $article_icon,
	'POST_TIME' => create_date($board_config['default_dateformat'], $article_info['time'], $board_config['board_timezone']),
	'POSTER_RANK' => $poster_rank,
	'RANK_IMAGE' => $rank_image,
	'POSTER_JOINED' => $poster_joined,
	'POSTER_ARTICLES' => $poster_articles,
	'POSTER_COMMENTS' => $poster_comments,
	'POSTER_FROM' => $poster_from,
	'POSTER_AVATAR' => $poster_avatar,

	'APPROVE_IMG' => $approve_img,
	'APPROVE' => $approve,
	'EDIT_IMG' => $edit_img,
	'EDIT' => $edit,
	'DELETE_IMG' => $delete_img,
	'DELETE' => $delete,

	'U_VIEW_ARTICLE' => append_sid("cms_view_article.$phpEx?aid=$article_id&start=$start"),

	'S_AUTH_CAN' => $s_auth_can
	)
);
//-- add mod : easy CMS attachments v.1.0.1a -----------------------------------
init_display_article_attachments($article_info['article_attachment']);
display_article_attachments($article_id, $article_info['article_attachment']);
//-- end mod : easy CMS attachments v.1.0.1a -----------------------------------



//
// Comments
//
if( $is_auth['c_view'] && $article_info['enable_comments'] )
{
	$template->set_filenames(array(
		'commentsbox' => 'cms_comments_body.tpl'
		)
	);
//-- add mod : easy CMS attachments v.1.0.1a -----------------------------------
	$allowed_extensions = array();
	$display_categories = array();
	$download_modes = array();
	$upload_icons = array();
	$attachments = array();
	init_display_comment_attachments($article_info['article_attachment']);
//-- end mod : easy CMS attachments v.1.0.1a -----------------------------------


	if( $total_comments == 0 )
	{
		$template->assign_block_vars('switch_no_comments', array());
	}

	for( $i = 0; $i < count($comments_row); $i++ )
	{
		$poster_id = $comments_row[$i]['user_id'];
		$comment_id = $comments_row[$i]['comment_id'];
		$subject = $comments_row[$i]['subject'];
		$comments = $comments_row[$i]['comments'];
		$bbcode_uid = $comments_row[$i]['bbcode_uid'];


		//
		// HTML, BBcode and Smilies
		//
		if( !$cms_config['allow_html'] )
		{
			if( $comments_row[$i]['enable_html'] )
			{
				$comments = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $comments);
			}
		}

		if( $cms_config['allow_bbcode'] )
		{
			if( $bbcode_uid != '' )
			{
				$comments = ( $cms_config['allow_bbcode'] ) ? bbencode_second_pass($comments, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $comments);
			}
		}

		$comments = make_clickable($comments);

		if( $cms_config['allow_smilies'] )
		{
			if( $comments_row[$i]['enable_smilies'] )
			{
				$comments = smilies_pass($comments);
			}
		}

		$comments = str_replace("\n", "\n<br />\n", $comments);


		if( count($orig_word) )
		{
			$subject = preg_replace($orig_word, $replacement_word, $subject);
			$comments = str_replace('\"', '"', substr(@preg_replace('#(\>(((\?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $comments . '<'), 1, -1));
		}


		//
		// Comment icon
		//
		$comment_icon = '';
		for( $j = 0; $j < count($icon_row); $j++ )
		{
			if( $icon_row[$j]['icon_id'] == $comments_row[$i]['comment_icon'] )
			{
				$comment_icon = '<img src="' . $cms_config['icons_path'] . '/' . $icon_row[$j]['icon_href'] . '" width="19" height="19" alt="" border="0" hspace="0" />';
			}
		}


		//
		// Approve, edit and delete images
		//
		$approve_img = '';
		$approve = '';
		if( $is_auth['c_approve'] && $comments_row[$i]['comment_pending'] )
		{
			$temp_url = append_sid("cms_post_comment.$phpEx?mode=approve&cmid=$comment_id");
			$approve_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_approve'] . '" alt="' . $lang['Approve_comment'] . '" title="' . $lang['Approve_comment'] . '" border="0" /></a>';
			$approve = '<a href="' . $temp_url . '">' . $lang['Approve_comment'] . '</a>';
		}

		$edit_img = '';
		$edit = '';
		if( ($is_auth['c_edit'] && $poster_id == $userdata['user_id']) || $userdata['user_level'] == ADMIN )
		{
			$temp_url = append_sid("cms_post_comment.$phpEx?mode=editcomment&cmid=$comment_id");
			$edit_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_edit'] . '" alt="' . $lang['Edit_comment'] . '" title="' . $lang['Edit_comment'] . '" border="0" /></a>';
			$edit = '<a href="' . $temp_url . '">' . $lang['Edit_comment'] . '</a>';
		}

		$delete_img = '';
		$delete = '';
		if( ($is_auth['c_delete'] && $poster_id == $userdata['user_id']) || $userdata['user_level'] == ADMIN )
		{
			$temp_url = append_sid("cms_post_comment.$phpEx?mode=delete&cmid=$comment_id");
			$delete_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_delpost'] . '" alt="' . $lang['Delete_comment'] . '" title="' . $lang['Delete_comment'] . '" border="0" /></a>';
			$delete = '<a href="' . $temp_url . '">' . $lang['Delete_comment'] . '</a>';
		}


		//
		// Set the post details
		//
		$poster = ( $poster_id == ANONYMOUS ) ? $lang['Guest'] : $comments_row[$i]['username'];
		$poster_articles = ( $poster_id != ANONYMOUS ) ? $lang['Articles'] . ': ' . $comments_row[$i]['user_articles'] : '';
		$poster_comments = ( $poster_id != ANONYMOUS ) ? $lang['Comments'] . ': ' . $comments_row[$i]['user_comments'] : '';
		$poster_from = ( $comments_row[$i]['user_from'] && $poster_id != ANONYMOUS ) ? $lang['Location'] . ': ' . $comments_row[$i]['user_from'] : '';
		$poster_joined = ( $poster_id != ANONYMOUS ) ? $lang['Joined'] . ': ' . create_date($lang['DATE_FORMAT'], $comments_row[$i]['user_regdate'], $board_config['board_timezone']) : '';

		$poster_avatar = '';
		if ( $comments_row[$i]['user_avatar_type'] && $poster_id != ANONYMOUS && $comments_row[$i]['user_allowavatar'] && $cms_config['allow_avatar'] )
		{
			switch( $comments_row[$i]['user_avatar_type'] )
			{
				case USER_AVATAR_UPLOAD:
					$poster_avatar = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $comments_row[$i]['user_avatar'] . '" alt="" border="0" />' : '';
					break;
				case USER_AVATAR_REMOTE:
					$poster_avatar = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $comments_row[$i]['user_avatar'] . '" alt="" border="0" />' : '';
					break;
				case USER_AVATAR_GALLERY:
					$poster_avatar = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $comments_row[$i]['user_avatar'] . '" alt="" border="0" />' : '';
					break;
			}
		}


		//
		// User is anonymous and has a username
		//
		if( $poster_id == ANONYMOUS )
		{
			if( $comments_row[$i]['comment_username'] != '' )
			{
				$poster = ( count($orig_word) ) ? preg_replace($orig_word, $replacement_word, $comments_row[$i]['comment_username']) : $comments_row[$i]['comment_username'];
			}
		}


		//
		// Generate ranks, set them to empty string initially.
		//
		$poster_rank = '';
		$rank_image = '';
		if( $poster_id == ANONYMOUS )
		{
		}
		else if( $comments_row[$i]['user_rank'] )
		{
			for($j = 0; $j < count($ranksrow); $j++)
			{
				if( $comments_row[$i]['user_rank'] == $ranksrow[$j]['rank_id'] && $ranksrow[$j]['rank_special'] )
				{
					$poster_rank = $ranksrow[$j]['rank_title'];
					$rank_image = ( $ranksrow[$j]['rank_image'] ) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : '';
				}
			}
		}
		else
		{
			for($j = 0; $j < count($ranksrow); $j++)
			{
				if( $comments_row[$i]['user_posts'] >= $ranksrow[$j]['rank_min'] && !$ranksrow[$j]['rank_special'] )
				{
					$poster_rank = $ranksrow[$j]['rank_title'];
					$rank_image = ( $ranksrow[$j]['rank_image'] ) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : '';
				}
			}
		}


		$row_class = ( $i % 2 ) ? $theme['td_class1'] : $theme['td_class2'];
		$row_color = ( $i % 2 ) ? $theme['td_color1'] : $theme['td_color2'];

		$template->assign_block_vars('commentsrow', array(
			'ROW_CLASS' => $row_class,
			'ROW_COLOR' => '#' . $row_color,

			'SUBJECT' => $subject,
			'COMMENTS' => $comments,
			'POSTER_NAME' => $poster,
			'COMMENT_ICON' => $comment_icon,
			'POST_TIME' => create_date($board_config['default_dateformat'], $comments_row[$i]['time'], $board_config['board_timezone']),
			'POSTER_RANK' => $poster_rank,
			'RANK_IMAGE' => $rank_image,
			'POSTER_JOINED' => $poster_joined,
			'POSTER_ARTICLES' => $poster_articles,
			'POSTER_COMMENTS' => $poster_comments,
			'POSTER_FROM' => $poster_from,
			'POSTER_AVATAR' => $poster_avatar,

			'APPROVE_IMG' => $approve_img,
			'APPROVE' => $approve,
			'EDIT_IMG' => $edit_img,
			'EDIT' => $edit,
			'DELETE_IMG' => $delete_img,
			'DELETE' => $delete,

			'S_RATING_STATS' => calc_rating('comment', $comment_id),
			'S_COMMENT_ID' => $comment_id
			)
		);

		if( $is_auth['c_rate'] )
		{
			make_ratingbox('comment', 'rating', "cms_post_comment.$phpEx", $comment_id, $poster_id);
		}
//-- add mod : easy CMS attachments v.1.0.1a -----------------------------------
		display_comment_attachments($comment_id, $comments_row[$i]['comment_attachment']);
//-- end mod : easy CMS attachments v.1.0.1a -----------------------------------
	}

	$template->assign_var_from_handle('COMMENTSBOX', 'commentsbox');
}


include($phpbb_root_path . 'includes/cms_articles_navigate.'.$phpEx);
$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);

?>
Post Reply

Return to “[2.0.x] MOD Requests”