<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="modx.prosilver.zh_cmn_hant.xsl"?>
<!--For security purposes, please check: http://www.phpbb.com/mods/ for the latest version of this MOD. Although MODs are checked before being allowed in the MODs Database there is no guarantee that there are no security problems within the MOD. No support will be given for MODs not found within the MODs Database which can be found at http://www.phpbb.com/mods/-->
<mod xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.phpbb.com/mods/xml/modx-1.2.2.xsd">
	<header>
		<license>http://opensource.org/licenses/gpl-license.php GNU General Public License v2</license>
		<title lang="zh_cmn_hant">MOD Topic Colour</title>
		<description lang="zh_cmn_hant">此模組允許擁有權限的會員自定主題顯示在版面上的顏色。</description>
		<author-group>
			<author>
				<realname>wasabi</realname>
				<email>wasabi@wasabistudio.ca</email>
				<username>wasabi</username>
				<homepage>http://demo.sabi.tw</homepage>
			</author>
		</author-group>
		<mod-version>1.0.1</mod-version>
		<installation>
			<level>easy</level>
			<time>1200</time>
			<target-version>3.0.x</target-version>
		</installation>
		<history>
			<entry>
				<date>2009-03-03</date>
				<rev-version>1.0.1</rev-version>
				<changelog lang="zh_cmn_hant">
					<change>允許使用HTML顏色名稱來取代16進位顏色碼</change>
					<change>在搜尋結果頁面顯示主題上色</change>
					<change>在版主控制台的版面概觀頁面顯示主題上色</change>
				</changelog>
			</entry>
			<entry>
				<date>2008-04-11</date>
				<rev-version>1.0.0</rev-version>
				<changelog lang="zh_cmn_hant">
					<change>最初版。</change>
				</changelog>
			</entry>
		</history>
	</header>
	<action-group>
		<sql><![CDATA[ALTER TABLE `phpbb_topics` ADD `topic_colour` VARCHAR( 30 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' AFTER `topic_status`;]]></sql>
		<sql><![CDATA[INSERT INTO `phpbb_config` (
`config_name` ,
`config_value` ,
`is_dynamic`
)
VALUES (
'topic_colours', '紅色:red,綠色:green,藍色:blue,橘色:orange,紫色:fuchsia,灰色:dimgray', '0'
);]]></sql>
		<sql><![CDATA[INSERT INTO `phpbb_acl_options` (
`auth_option`,
`is_global`,
`is_local`
)
VALUES (
'f_topic_colour', '0', '1'
)]]></sql>
		<open src="posting.php">
			<edit>
				<find>$post_data['topic_time_limit']	= request_var('topic_time_limit', (($mode != 'post') ? (int) $post_data['topic_time_limit'] : 0));</find>
				<action type="after-add"><![CDATA[	// mod: Topic Colour ----------------------------------
	// by: wasabi
	$post_data['topic_colour']		= ($auth->acl_get('f_topic_colour', $forum_id) && ($mode == 'post' || ($mode == 'edit' && $post_data['post_id'] == $post_data['topic_first_post_id']))) ? request_var('topic_colour', 0) : ((isset($post_data['topic_colour'])) ? $post_data['topic_colour'] : '');
	// fin mod : Topic Colour -----------------------------]]></action>
			</edit>
			<edit>
				<find>// DNSBL check</find>
				<action type="before-add"><![CDATA[	// mod: Topic Colour ----------------------------------
	// by: wasabi
	if (isset($_POST['topic_colour']) && $auth->acl_get('f_topic_colour', $forum_id))
	{
		$topic_colours = explode(",", $config['topic_colours']);

		if ($post_data['topic_colour'] > 0 && $post_data['topic_colour'] <= count($topic_colours))
		{
			list(, $post_data['topic_colour']) = explode(':', $topic_colours[$post_data['topic_colour'] - 1]);
		}
		else
		{
			$post_data['topic_colour'] = '';
		}

		unset($topic_colours);
	}
	// fin mod : Topic Colour -----------------------------]]></action>
			</edit>
			<edit>
				<find>'topic_attachment'		=> (isset($post_data['topic_attachment'])) ? (int) $post_data['topic_attachment'] : 0,</find>
				<action type="after-add"><![CDATA[				// mod: Topic Colour ----------------------------------
				// by: wasabi
				'topic_colour'			=> (string) $post_data['topic_colour'],
				// fin mod : Topic Colour -----------------------------]]></action>
			</edit>
			<edit>
				<find>// Start assigning vars for main posting page ...</find>
				<action type="before-add"><![CDATA[// mod: Topic Colour ----------------------------------
// by: wasabi
$topic_colour_toggle = false;
if ($auth->acl_get('f_topic_colour', $forum_id) && ($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_post_id'])) && !empty($config['topic_colours']))
{
	$topic_colour_toggle = true;

	// deal with new topic/post
	if (!isset($post_data['topic_colour']))
	{
		$post_data['topic_colour'] = '';
	}

	// now show the options
	$topic_colours		= explode(',', $config['topic_colours']);
	$topic_colour_array	= array();

	// default
	$checked = '';
	$topic_colour_array[] = array(
		'VALUE'				=> 0,
		'COLOUR_CODE'		=> '',
		'S_CHECKED'			=> (empty($post_data['topic_colour'])) ? ' checked="checked"' : '',
		'L_TOPIC_COLOUR'	=> $user->lang['DEFAULT_TOPIC_COLOUR']);

	// loop through each colour
	$index = 1;
	foreach ($topic_colours as $colour)
	{
		list($colour_name, $colour_code) = explode(':', $colour);
		$topic_colour_array[] = array(
			'VALUE'				=> $index,
			'COLOUR_CODE'		=> $colour_code,
			'S_CHECKED'			=> ($colour_code == $post_data['topic_colour']) ? ' checked="checked"' : '',
			'L_TOPIC_COLOUR'	=> $colour_name);
		$index++;
	}

	foreach ($topic_colour_array as $array)
	{
		$template->assign_block_vars('topic_colour', $array);
	}

	unset($topic_colours);
}
// fin mod : Topic Colour -----------------------------]]></action>
			</edit>
			<edit>
				<find>'S_TYPE_TOGGLE'				=> $topic_type_toggle,</find>
				<action type="after-add"><![CDATA[	// mod: Topic Colour ----------------------------------
	// by: wasabi
	'S_COLOUR_TOGGLE'			=> $topic_colour_toggle,
	// fin mod : Topic Colour -----------------------------]]></action>
			</edit>
		</open>
		<open src="viewforum.php">
			<edit>
				<find>'TOPIC_TITLE'		=> censor_text($row['topic_title']),</find>
				<action type="before-add"><![CDATA[			// mod: Topic Colour ----------------------------------
			// by: wasabi
			'TOPIC_COLOUR'		=> $row['topic_colour'],
			// fin mod : Topic Colour -----------------------------]]></action>
			</edit>
		</open>
		<open src="search.php">
			<edit>
				<find>'FORUM_TITLE'		=> $row['forum_name'],</find>
				<action type="after-add"><![CDATA[				// mod: Topic Colour ----------------------------------
				// by: wasabi
				'TOPIC_COLOUR'		=> $row['topic_colour'],
				// fin mod : Topic Colour -----------------------------]]></action>
			</edit>
		</open>
		<open src="includes/functions_posting.php">
			<edit>
				<find>'topic_first_poster_colour'	=> $user->data['user_colour'],</find>
				<action type="after-add"><![CDATA[				// mod: Topic Colour ----------------------------------
				// by: wasabi
				'topic_colour'				=> $data['topic_colour'],
				// fin mod : Topic Colour -----------------------------]]></action>
			</edit>
			<edit>
				<find>'topic_first_poster_name'	=> $username,</find>
				<action type="after-add"><![CDATA[				// mod: Topic Colour ----------------------------------
				// by: wasabi
				'topic_colour'				=> $data['topic_colour'],
				// fin mod : Topic Colour -----------------------------]]></action>
			</edit>
		</open>
		<open src="includes/acp/acp_board.php">
			<edit>
				<find>'enable_post_confirm'	=> array('lang' => 'VISUAL_CONFIRM_POST',	'validate' => 'bool',	'type' => 'radio:yes_no', 'explain' => true),</find>
				<action type="after-add"><![CDATA[						// mod: Topic Colour ----------------------------------
						// by: wasabi
						'topic_colours'			=> array('lang' => 'TOPIC_COLOURS',			'validate' => 'string',	'type' => 'text:30:255', 'explain' => true),
						// fin mod : Topic Colour -----------------------------]]></action>
			</edit>
		</open>
		<open src="includes/mcp/mcp_forum.php">
			<edit>
				<find>'TOPIC_TYPE'		=> $topic_type,</find>
				<action type="after-add"><![CDATA[			// mod: Topic Colour ----------------------------------
			// by: wasabi
			'TOPIC_COLOUR'		=> $row['topic_colour'],
			// fin mod : Topic Colour -----------------------------]]></action>
			</edit>
		</open>
		<open src="language/zh_cmn_hant/acp/permissions_phpbb.php">
			<edit>
				<find>'acl_f_smilies'		=> array('lang' => '可以在文章中使用表情符號', 'cat' => 'content'),</find>
				<action type="after-add"><![CDATA[	// mod: Topic Colour ----------------------------------
	// by: wasabi
	'acl_f_topic_colour'	=> array('lang' => '可以改變主題顏色', 'cat' => 'content'),
	// fin mod : Topic Colour -----------------------------]]></action>
			</edit>
		</open>
		<open src="language/zh_cmn_hant/acp/board.php">
			<edit>
				<find>'ALLOW_BOOKMARKS_EXPLAIN'	=> '會員能夠貯藏其個人最愛的主題.',</find>
				<action type="after-add"><![CDATA[	// mod: Topic Colour ----------------------------------
	// by: wasabi
	'TOPIC_COLOURS'				=> '可用的主題顏色',
	'TOPIC_COLOURS_EXPLAIN'		=> '顯示於文章列表中的主題顏色選項, 用逗號(,)隔開各個顏色, 用冒號(:)隔開顏色名稱和16進位顏色碼.',
	// fin mod : Topic Colour -----------------------------]]></action>
			</edit>
		</open>
		<open src="language/zh_cmn_hant/posting.php">
			<edit>
				<find>));</find>
				<action type="before-add"><![CDATA[	// mod: Topic Colour ----------------------------------
	// by: wasabi
	'CHANGE_COLOUR_TO'		=> '將主題顏色轉換成',
	'POST_TOPIC_COLOUR_AS'	=> '設定主題顏色為',
	'DEFAULT_TOPIC_COLOUR'	=> '預設顏色',
	// fin mod : Topic Colour -----------------------------]]></action>
			</edit>
		</open>
		<open src="styles/prosilver/template/posting_editor.html">
			<edit>
				<find><![CDATA[<!-- IF S_TYPE_TOGGLE -->]]></find>
				<action type="before-add"><![CDATA[			<!-- mod : TOPIC COLOUR -->
			<!-- by : wasabi -->
			<!-- IF S_COLOUR_TOGGLE -->
			<dl>
				<dt><label for="topic_colour-0"><!-- IF S_EDIT_POST -->{L_CHANGE_COLOUR_TO}<!-- ELSE -->{L_POST_TOPIC_COLOUR_AS}<!-- ENDIF -->:</label></dt>
				<dd><!-- BEGIN topic_colour --><label for="topic_colour-{topic_colour.VALUE}"><input type="radio" name="topic_colour" id="topic_colour-{topic_colour.VALUE}" value="{topic_colour.VALUE}"{topic_colour.S_CHECKED} /><!-- IF topic_colour.COLOUR_CODE --><span style="color: {topic_colour.COLOUR_CODE}"><!-- ENDIF -->{topic_colour.L_TOPIC_COLOUR}</span><!-- IF topic_colour.COLOUR_CODE --></span><!-- ENDIF --></label> <!-- END topic_colour --></dd>
			</dl>
			<!-- ENDIF -->
			<!-- fin mod: TOPIC_COLOUR -->]]></action>
			</edit>
		</open>
		<open src="styles/prosilver/template/mcp_forum.html">
			<edit>
				<find><![CDATA[<a href="{topicrow.U_VIEW_TOPIC}" class="topictitle">{topicrow.TOPIC_TITLE}</a>]]></find>
				<inline-edit>
					<inline-find>{topicrow.TOPIC_TITLE}</inline-find>
					<inline-action type="replace-with"><![CDATA[<!-- IF topicrow.TOPIC_COLOUR --><span style="color: {topicrow.TOPIC_COLOUR}">{topicrow.TOPIC_TITLE}</span><!-- ELSE -->{topicrow.TOPIC_TITLE}<!-- ENDIF -->]]></inline-action>
				</inline-edit>
			</edit>
		</open>
		<open src="styles/prosilver/template/viewforum_body.html">
			<edit>
				<find><![CDATA[<dt<!-- IF topicrow.TOPIC_ICON_IMG and S_TOPIC_ICONS --> style="background-image: url({T_ICONS_PATH}{topicrow.TOPIC_ICON_IMG}); background-repeat: no-repeat;"<!-- ENDIF --> title="{topicrow.TOPIC_FOLDER_IMG_ALT}"><!-- IF topicrow.S_UNREAD_TOPIC --><a href="{topicrow.U_NEWEST_POST}">{NEWEST_POST_IMG}</a> <!-- ENDIF --><a href="{topicrow.U_VIEW_TOPIC}" class="topictitle">{topicrow.TOPIC_TITLE}</a>]]></find>
				<inline-edit>
					<inline-find>{topicrow.TOPIC_TITLE}</inline-find>
					<inline-action type="replace-with"><![CDATA[<!-- IF topicrow.TOPIC_COLOUR --><span style="color: {topicrow.TOPIC_COLOUR}">{topicrow.TOPIC_TITLE}</span><!-- ELSE -->{topicrow.TOPIC_TITLE}<!-- ENDIF -->]]></inline-action>
				</inline-edit>
			</edit>
		</open>
		<open src="styles/prosilver/template/search_results.html">
			<edit>
				<find><![CDATA[<a href="{searchresults.U_VIEW_TOPIC}" class="topictitle">{searchresults.TOPIC_TITLE}</a> {searchresults.ATTACH_ICON_IMG}]]></find>
				<inline-edit>
					<inline-find>{searchresults.TOPIC_TITLE}</inline-find>
					<inline-action type="replace-with"><![CDATA[<!-- IF searchresults.TOPIC_COLOUR --><span style="color: {searchresults.TOPIC_COLOUR}">{searchresults.TOPIC_TITLE}</span><!-- ELSE -->{searchresults.TOPIC_TITLE}<!-- ENDIF -->]]></inline-action>
				</inline-edit>
			</edit>
			<edit>
				<find><![CDATA[<dd>{L_TOPIC}: <a href="{searchresults.U_VIEW_TOPIC}">{searchresults.TOPIC_TITLE}</a></dd>]]></find>
				<inline-edit>
					<inline-find>{searchresults.TOPIC_TITLE}</inline-find>
					<inline-action type="replace-with"><![CDATA[<!-- IF searchresults.TOPIC_COLOUR --><span style="color: {searchresults.TOPIC_COLOUR}">{searchresults.TOPIC_TITLE}</span><!-- ELSE -->{searchresults.TOPIC_TITLE}<!-- ENDIF -->]]></inline-action>
				</inline-edit>
			</edit>
			<edit>
				<find><![CDATA[<dd>{L_GLOBAL}: <a href="{searchresults.U_VIEW_TOPIC}">{searchresults.TOPIC_TITLE}</a></dd>]]></find>
				<inline-edit>
					<inline-find>{searchresults.TOPIC_TITLE}</inline-find>
					<inline-action type="replace-with"><![CDATA[<!-- IF searchresults.TOPIC_COLOUR --><span style="color: {searchresults.TOPIC_COLOUR}">{searchresults.TOPIC_TITLE}</span><!-- ELSE -->{searchresults.TOPIC_TITLE}<!-- ENDIF -->]]></inline-action>
				</inline-edit>
			</edit>
		</open>
	</action-group>
</mod>
