A dodanie np. czegoś do kodu PHP
Tak wyglada ten kod:
<?php
/**
*
* @package phpBB Sidebar
* @copyright (c) 2011
* @license <a href="http://opensource.org/licenses/gpl-license.php" target="_blank">http://opensource.org/licenses/gpl-license.php</a> GNU Public License
*/
/**
* @ignore
*/
{
}
/**
* @package phpBB Sidebar - newest topics
*/
class newest_topics
{
/*
* basic variables:
* $module_file - php file, language file and template file, php file must be in "includes/sidebar/", language file in "language/{$user->lang}/mods/sidebar/" and template file in "style/{$user->style}/templates/sidebar/"
* $module_name - language name, please choose a distinct name, i.e. 'SIDEBAR_...', always has to be in capital letters
* version - module version
*/
var $module_file = 'newest_topics';
var $module_name = 'SIDEBAR_NEWEST_TOPICS';
var $version = '1.0.0';
/**
* set this to false if you do not need any acp settings
*/
var $load_acp_settings = true;
/**
* module functions below
*/
function load_module()
{
global $auth, $user, $db, $phpbb_root_path, $phpEx, $template, $config, $sidebar_config;
$user->add_lang('mods/sidebar/newest_topics');
$sql_and = '';
{
$sql_and = ' AND ' . $db->sql_in_set('t.forum_id', $forum_array, true);
}
'SELECT' => 'u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height, t.topic_id, t.forum_id, t.topic_title, t.topic_poster, t.topic_time, t.topic_first_poster_name, t.topic_first_poster_colour',
'FROM' => array(TOPICS_TABLE
=> 't'), 'FROM' => array(USERS_TABLE
=> 'u'), 'ON' => 't.topic_poster = u.user_id',
),
),
'WHERE'=> 't.topic_approved = 1 AND t.topic_status <> ' . ITEM_MOVED . ' ' . $sql_and,
'ORDER_BY' => 't.topic_id DESC',
);
$result = $db->sql_query_limit($db->sql_build_query('SELECT', $sql_ary), $sidebar_config['nt_per_page']);
$is_row = false;
while( $row = $db->sql_fetchrow($result) )
{
$is_row = true;
$view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']);
$topic_title = censor_text($row['topic_title']);
$sidebar_avatar = $row['user_avatar'] ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], ($row['user_avatar_width'] > $row['user_avatar_height']) ? 35 : (35 / $row['user_avatar_height']) * $row['user_avatar_width'], ($row['user_avatar_height'] > $row['user_avatar_width']) ? 35 : (35 / $row['user_avatar_width']) * $row['user_avatar_height']) : '';
$template->assign_block_vars('newest_topics',array( 'U_TOPIC' => $view_topic_url,
'TOPIC_AUTHOR_FULL' => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
'SIDEBAR_AVATAR' => $sidebar_avatar,
'S_DISPLAY_AVATARS' => ($sidebar_config['nt_avatars'] && $user->optionget('viewavatars')) ? true : false,
'U_VIEWPROFILE' => ($row['topic_poster'] != ANONYMOUS) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $row['topic_poster']) : '',
'TOPIC_TIME' => $user->format_date($row['topic_time']),
'TOPIC_TITLE' => $topic_title
));
}
$db->sql_freeresult($result);
if (!$is_row)
{
$template->assign_block_vars('newest_topics', array( 'NO_TOPICS' => $user->lang['SIDEBAR_NO_TOPICS'],
));
}
}
/**
* acp frontend for the module
* put the function in a comment or delete it if you don't need an acp frontend
*/
function load_acp()
{
'title' => 'SIDEBAR_NEWEST_TOPICS',
'legend1' => 'SETTINGS',
'nt_avatars' => array('lang' => 'ACP_NEWEST_TOPICS_AVATAR' , 'validate' => 'bool' , 'type' => 'radio:yes_no' , 'explain' => true), 'nt_per_page' => array('lang' => 'ACP_NEWEST_TOPICS_PER_PAGE', 'validate' => 'int:1', 'type' => 'text:3:4', 'explain' => false), )
);
return $display_vars;
}
/**
* API functions
*/
function add_config()
{
set_sidebar_config('nt_avatars', 1);
set_sidebar_config('nt_per_page', 5);
}
}
?>
Chodzi oczywiście o topic_title