[Customisation Database Commits] r881 - in /trunk/titania: includes/ includes/manage_tools/ language/en/manage_tools/ manage/ styles/default/template/manage/

Nathan Guse exreaction at phpbb.com
Thu Mar 25 20:24:57 GMT 2010


Author: exreaction
Date: Thu Mar 25 20:24:57 2010
New Revision: 881

Log:
Tool to add phpBB version support to certain revisions based on their existing phpBB version and/or what categories they are in.

(We use something like this for the ariel converter to make 2.0 avatars/smilies/ranks supported be listed as supported on 3.0)

Added:
    trunk/titania/includes/manage_tools/phpbb_version_add.php   (with props)
    trunk/titania/language/en/manage_tools/phpbb_version_add.php   (with props)
    trunk/titania/styles/default/template/manage/generate_category_select.html
Modified:
    trunk/titania/includes/functions_manage.php
    trunk/titania/includes/manage_tools/reindex.php
    trunk/titania/language/en/manage_tools/reindex.php
    trunk/titania/manage/administration.php
    trunk/titania/styles/default/template/manage/administration.html
    trunk/titania/styles/default/template/manage/tool_options.html

Modified: trunk/titania/includes/functions_manage.php
==============================================================================
*** trunk/titania/includes/functions_manage.php (original)
--- trunk/titania/includes/functions_manage.php Thu Mar 25 20:24:57 2010
***************
*** 126,132 ****
  			}
  			else if ($tpl_type[0] == 'select_multiple')
  			{
! 				$tpl['tpl'] = '<select id="' . $name . '" name="' . $name . '[]" multiple="multiple">' . $return . '</select>';
  			}
  			else
  			{
--- 126,132 ----
  			}
  			else if ($tpl_type[0] == 'select_multiple')
  			{
! 				$tpl['tpl'] = '<select id="' . $name . '" name="' . $name . '[]" multiple="multiple" size="7">' . $return . '</select>';
  			}
  			else
  			{

Added: trunk/titania/includes/manage_tools/phpbb_version_add.php
==============================================================================
*** trunk/titania/includes/manage_tools/phpbb_version_add.php (added)
--- trunk/titania/includes/manage_tools/phpbb_version_add.php Thu Mar 25 20:24:57 2010
***************
*** 0 ****
--- 1,161 ----
+ <?php
+ /**
+ *
+ * @package Titania
+ * @version $Id$
+ * @copyright (c) 2008 phpBB Customisation Database Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ *
+ */
+ 
+ if (!defined('IN_PHPBB'))
+ {
+ 	exit;
+ }
+ 
+ class phpbb_version_add
+ {
+ 	function display_options()
+ 	{
+ 		return array(
+ 			'title'	=> 'PHPBB_VERSION_ADD',
+ 			'vars'	=> array(
+ 				'new_phpbb_version'		=> array('lang' => 'NEW_PHPBB_VERSION', 'type' => 'text:40:255', 'explain' => true),
+ 				'limit_phpbb_version'	=> array('lang' => 'VERSION_RESTRICTION', 'type' => 'select_multiple', 'function' => 'pva_generate_phpbb_version_select', 'explain' => true, 'default' => ''),
+ 				'category'				=> array('lang' => 'CATEGORY', 'type' => 'select_multiple', 'function' => 'pva_generate_category_select', 'explain' => true),
+ 			)
+ 		);
+ 	}
+ 
+ 	function run_tool()
+ 	{
+ 		$new_phpbb_version = request_var('new_phpbb_version', '');
+ 		$limit_phpbb_versions = request_var('limit_phpbb_version', array(''));
+ 		$categories = request_var('category', array(0));
+ 
+ 		if (!$new_phpbb_version || strlen($new_phpbb_version) < 5 || $new_phpbb_version[1] != '.' || $new_phpbb_version[3] != '.')
+ 		{
+ 			trigger_back('NO_VERSION_SELECTED');
+ 		}
+ 
+ 		$phpbb_version_branch = (int) $new_phpbb_version[0] . (int) $new_phpbb_version[2];
+ 		$phpbb_version_revision = substr($new_phpbb_version, 4);
+ 
+ 		// Is it in our version cache?
+ 		$versions = titania::$cache->get_phpbb_versions();
+ 		if (!isset($versions[$phpbb_version_branch . $phpbb_version_revision]))
+ 		{
+ 			titania::$cache->destroy('_titania_phpbb_versions');
+ 		}
+ 
+ 		// Categories limiter
+ 		$contribs = $revisions = array();
+ 		if (sizeof($categories) > 1 || (sizeof($categories) && $categories[0] != 0))
+ 		{
+ 			$sql = 'SELECT contrib_id FROM ' . TITANIA_CONTRIB_IN_CATEGORIES_TABLE . '
+ 				WHERE ' . phpbb::$db->sql_in_set('category_id', array_map('intval', $categories));
+ 			$result = phpbb::$db->sql_query($sql);
+ 			while ($row = phpbb::$db->sql_fetchrow($result))
+ 			{
+ 				$contribs[] = $row['contrib_id'];
+ 			}
+ 			phpbb::$db->sql_freeresult($result);
+ 
+ 			if (!sizeof($contribs))
+ 			{
+ 				trigger_back('NO_REVISIONS_UPDATED');
+ 			}
+ 		}
+ 
+ 		if (sizeof($limit_phpbb_versions) > 1 || (sizeof($limit_phpbb_versions) && $limit_phpbb_versions[0] != 0))
+ 		{
+ 			// phpBB versions limiter
+ 			foreach ($limit_phpbb_versions as $limit_phpbb_version)
+ 			{
+ 				$sql = 'SELECT contrib_id, revision_id FROM ' . TITANIA_REVISIONS_PHPBB_TABLE . '
+ 					WHERE phpbb_version_branch = ' . (int) substr($limit_phpbb_version, 0, 2) . '
+ 						AND phpbb_version_revision = \'' . phpbb::$db->sql_escape(substr($limit_phpbb_version, 2)) . '\'' .
+ 						((sizeof($contribs)) ? ' AND ' . phpbb::$db->sql_in_set('contrib_id', array_map('intval', $contribs)) : '');
+ 				$result = phpbb::$db->sql_query($sql);
+ 				while ($row = phpbb::$db->sql_fetchrow($result))
+ 				{
+ 					$revisions[$row['revision_id']] = $row['contrib_id'];
+ 				}
+ 				phpbb::$db->sql_freeresult($result);
+ 			}
+ 		}
+ 		else if (sizeof($categories) > 1 || (sizeof($categories) && $categories[0] != 0))
+ 		{
+ 			// Only category limited
+ 			$sql = 'SELECT contrib_id, revision_id FROM ' . TITANIA_REVISIONS_TABLE . '
+ 				WHERE ' . phpbb::$db->sql_in_set('contrib_id', array_map('intval', $contribs));
+ 			$result = phpbb::$db->sql_query($sql);
+ 			while ($row = phpbb::$db->sql_fetchrow($result))
+ 			{
+ 				$revisions[$row['revision_id']] = $row['contrib_id'];
+ 			}
+ 			phpbb::$db->sql_freeresult($result);
+ 		}
+ 		else
+ 		{
+ 			// All
+ 			$sql = 'SELECT contrib_id, revision_id FROM ' . TITANIA_REVISIONS_TABLE;
+ 			$result = phpbb::$db->sql_query($sql);
+ 			while ($row = phpbb::$db->sql_fetchrow($result))
+ 			{
+ 				$revisions[$row['revision_id']] = $row['contrib_id'];
+ 			}
+ 			phpbb::$db->sql_freeresult($result);
+ 		}
+ 
+ 		if (!sizeof($revisions))
+ 		{
+ 			trigger_back('NO_REVISIONS_UPDATED');
+ 		}
+ 
+ 		$sql_ary = array();
+ 		foreach ($revisions as $revision_id => $contrib_id)
+ 		{
+ 			$sql_ary[] = array(
+ 				'contrib_id'				=> (int) $contrib_id,
+ 				'revision_id'				=> (int) $revision_id,
+ 				'phpbb_version_branch'		=> $phpbb_version_branch,
+ 				'phpbb_version_revision'	=> $phpbb_version_revision,
+ 			);
+ 		}
+ 
+ 		phpbb::$db->sql_multi_insert(TITANIA_REVISIONS_PHPBB_TABLE, $sql_ary);
+ 
+ 		trigger_back(sprintf(phpbb::$user->lang['REVISIONS_UPDATED'], sizeof($revisions)));
+ 	}
+ }
+ 
+ function pva_generate_phpbb_version_select()
+ {
+ 	$versions = titania::$cache->get_phpbb_versions();
+ 
+ 	$select = '<option value="0" selected="selected">-----</option>';
+ 
+ 	foreach ($versions as $version => $name)
+ 	{
+ 		$select .= '<option value="' . $version . '">' . $name . '</option>';
+ 	}
+ 
+ 	return $select;
+ }
+ 
+ function pva_generate_category_select()
+ {
+ 	titania::_include('functions_posting', 'generate_category_select');
+ 
+ 	phpbb::$template->destroy_block_vars('category_select');
+ 	generate_category_select();
+ 
+ 	phpbb::$template->set_filenames(array(
+ 		'generate_category_select'		=> 'manage/generate_category_select.html',
+ 	));
+ 
+ 	$select = phpbb::$template->assign_display('generate_category_select');
+ 
+ 	return $select;
+ }

Propchange: trunk/titania/includes/manage_tools/phpbb_version_add.php
------------------------------------------------------------------------------
    svn:keywords = Revision Author Date Id

Modified: trunk/titania/includes/manage_tools/reindex.php
==============================================================================
*** trunk/titania/includes/manage_tools/reindex.php (original)
--- trunk/titania/includes/manage_tools/reindex.php Thu Mar 25 20:24:57 2010
***************
*** 1,9 ****
  <?php
  /**
  *
! * @package Support Tool Kit - Organize Language Files
  * @version $Id$
! * @copyright (c) 2009 phpBB Group
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  *
  */
--- 1,9 ----
  <?php
  /**
  *
! * @package Titania
  * @version $Id$
! * @copyright (c) 2008 phpBB Customisation Database Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  *
  */

Added: trunk/titania/language/en/manage_tools/phpbb_version_add.php
==============================================================================
*** trunk/titania/language/en/manage_tools/phpbb_version_add.php (added)
--- trunk/titania/language/en/manage_tools/phpbb_version_add.php Thu Mar 25 20:24:57 2010
***************
*** 0 ****
--- 1,50 ----
+ <?php
+ /**
+ *
+ * @package Titania
+ * @version $Id$
+ * @copyright (c) 2008 phpBB Customisation Database Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ *
+ */
+ 
+ /**
+ * DO NOT CHANGE
+ */
+ if (!defined('IN_PHPBB'))
+ {
+ 	exit;
+ }
+ 
+ if (empty($lang) || !is_array($lang))
+ {
+ 	$lang = array();
+ }
+ 
+ // DEVELOPERS PLEASE NOTE
+ //
+ // All language files should use UTF-8 as their encoding and the files must not contain a BOM.
+ //
+ // Placeholders can now contain order information, e.g. instead of
+ // 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
+ // translators to re-order the output of data while ensuring it remains correct
+ //
+ // You do not need this where single placeholders are used, e.g. 'Message %d' is fine
+ // equally where a string contains only two placeholders which are used to wrap text
+ // in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
+ //
+ // Some characters you may want to copy&paste:
+ // ’ » “ ” …
+ //
+ 
+ $lang = array_merge($lang, array(
+ 	'PHPBB_VERSION_ADD'			=> 'Add phpBB Version support to revisions',
+ 	'VERSION_RESTRICTION' => 'Version Restriction',
+ 	'VERSION_RESTRICTION_EXPLAIN' => 'Limit the new version support to only the selected versions.',
+ 	'NEW_PHPBB_VERSION' => 'New phpBB Version',
+ 	'NEW_PHPBB_VERSION_EXPLAIN' => 'New phpBB version to list support on the revision for.',
+ 	'CATEGORY_EXPLAIN' => 'Limit the new version support to only the selected categories.',
+ 	'NO_VERSION_SELECTED' => 'You must give a proper phpBB version.  Ex: 3.0.7 or 3.0.7-pl1.',
+ 	'NO_REVISIONS_UPDATED' => 'No revisions were updated from the given limitations.',
+ 	'REVISIONS_UPDATED' => '%s revisions have been updated.',
+ ));

Propchange: trunk/titania/language/en/manage_tools/phpbb_version_add.php
------------------------------------------------------------------------------
    svn:keywords = Revision Author Date Id

Modified: trunk/titania/language/en/manage_tools/reindex.php
==============================================================================
*** trunk/titania/language/en/manage_tools/reindex.php (original)
--- trunk/titania/language/en/manage_tools/reindex.php Thu Mar 25 20:24:57 2010
***************
*** 1,9 ****
  <?php
  /**
  *
! * @package Support Tool Kit - Organize Language Files
  * @version $Id$
! * @copyright (c) 2009 phpBB Group
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  *
  */
--- 1,9 ----
  <?php
  /**
  *
! * @package Titania
  * @version $Id$
! * @copyright (c) 2008 phpBB Customisation Database Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  *
  */

Modified: trunk/titania/manage/administration.php
==============================================================================
*** trunk/titania/manage/administration.php (original)
--- trunk/titania/manage/administration.php Thu Mar 25 20:24:57 2010
***************
*** 74,80 ****
  
  		if (is_array($options) && isset($options['vars']))
  		{
! 			titania::page_header(phpbb::$user->lang[$options['title']]);
  
  			titania::_include('functions_manage', 'use_lang');
  
--- 74,80 ----
  
  		if (is_array($options) && isset($options['vars']))
  		{
! 			titania::page_header($options['title']);
  
  			titania::_include('functions_manage', 'use_lang');
  

Modified: trunk/titania/styles/default/template/manage/administration.html
==============================================================================
*** trunk/titania/styles/default/template/manage/administration.html (original)
--- trunk/titania/styles/default/template/manage/administration.html Thu Mar 25 20:24:57 2010
***************
*** 5,26 ****
  <div class="panel">
  	<div class="inner"><span class="corners-top"><span></span></span>
  
! 	<!-- IF .tools -->
! 	<fieldset>
! 		<!-- BEGIN tools -->
! 			<form action="{S_ACTION}" method="post">
! 			<dl>
! 				<dt><label for="action_{tools.TOOL}">{tools.L_TITLE}</label></dt>
! 				<dd><input type="hidden" name="t" value="{tools.TOOL}" /><input class="button2" type="submit" id="action_{tools.TOOL}" name="action_{tools.TOOL}" value="{L_RUN}" /></dd>
! 			</dl>
! 			</form>
! 			<!-- IF not tools.S_LAST_ROW --><hr /><!-- ENDIF -->
! 		<!-- END tools -->
! 	</fieldset>
! 	<!-- ENDIF -->
  
  	<span class="corners-bottom"><span></span></span></div>
  </div>
  
- 
  <!-- INCLUDE manage/manage_footer.html -->
\ No newline at end of file
--- 5,25 ----
  <div class="panel">
  	<div class="inner"><span class="corners-top"><span></span></span>
  
! 		<!-- IF .tools -->
! 		<fieldset>
! 			<!-- BEGIN tools -->
! 				<form action="{S_ACTION}" method="post">
! 				<dl>
! 					<dt><label for="action_{tools.TOOL}">{tools.L_TITLE}</label></dt>
! 					<dd><input type="hidden" name="t" value="{tools.TOOL}" /><input class="button2" type="submit" id="action_{tools.TOOL}" name="action_{tools.TOOL}" value="{L_RUN}" /></dd>
! 				</dl>
! 				</form>
! 				<!-- IF not tools.S_LAST_ROW --><hr /><!-- ENDIF -->
! 			<!-- END tools -->
! 		</fieldset>
! 		<!-- ENDIF -->
  
  	<span class="corners-bottom"><span></span></span></div>
  </div>
  
  <!-- INCLUDE manage/manage_footer.html -->
\ No newline at end of file

Added: trunk/titania/styles/default/template/manage/generate_category_select.html
==============================================================================
*** trunk/titania/styles/default/template/manage/generate_category_select.html (added)
--- trunk/titania/styles/default/template/manage/generate_category_select.html Thu Mar 25 20:24:57 2010
***************
*** 0 ****
--- 1,5 ----
+ <!-- BEGIN category_select -->
+ <option value="{category_select.VALUE}"<!-- IF category_select.S_SELECTED --> selected="selected"<!-- ENDIF --><!-- IF category_select.S_DISABLED --> disabled="disabled"<!-- ENDIF -->>
+ 	<!-- BEGIN level -->&nbsp; &nbsp;<!-- END level -->{category_select.NAME}
+ </option>
+ <!-- END category_select -->
\ No newline at end of file

Modified: trunk/titania/styles/default/template/manage/tool_options.html
==============================================================================
*** trunk/titania/styles/default/template/manage/tool_options.html (original)
--- trunk/titania/styles/default/template/manage/tool_options.html Thu Mar 25 20:24:57 2010
***************
*** 1,10 ****
  <!-- INCLUDE manage/manage_header.html -->
  
! <a name="maincontent"></a>
! 
! <h1>{L_TITLE}</h1>
! 
! <p>{L_TITLE_EXPLAIN}</p>
  
  <!-- IF S_ERROR -->
  	<div class="errorbox">
--- 1,6 ----
  <!-- INCLUDE manage/manage_header.html -->
  
! <h3 class="section-name">{PAGE_TITLE}</h3>
  
  <!-- IF S_ERROR -->
  	<div class="errorbox">
***************
*** 16,29 ****
  <form id="stk" method="post" action="{S_ACTION}" name="support_tool_kit" autocomplete="off">
  
  	<!-- BEGIN options -->
! 		<!-- IF options.S_LEGEND -->
  			<!-- IF not options.S_FIRST_ROW -->
  				</fieldset>
  			<!-- ENDIF -->
  			<fieldset>
  				<legend>{options.LEGEND}</legend>
  
! 		<!-- ELSE -->
  			<dl>
  				<dt><label for="{options.KEY}">{options.TITLE}:</label><!-- IF options.S_EXPLAIN --><br /><span>{options.TITLE_EXPLAIN}</span><!-- ENDIF --></dt>
  				<dd>{options.CONTENT}</dd>
--- 12,26 ----
  <form id="stk" method="post" action="{S_ACTION}" name="support_tool_kit" autocomplete="off">
  
  	<!-- BEGIN options -->
! 		<!-- IF options.S_LEGEND or options.S_FIRST_ROW -->
  			<!-- IF not options.S_FIRST_ROW -->
  				</fieldset>
  			<!-- ENDIF -->
  			<fieldset>
  				<legend>{options.LEGEND}</legend>
+ 		<!-- ENDIF -->
  
! 		<!-- IF not options.S_LEGEND-->
  			<dl>
  				<dt><label for="{options.KEY}">{options.TITLE}:</label><!-- IF options.S_EXPLAIN --><br /><span>{options.TITLE_EXPLAIN}</span><!-- ENDIF --></dt>
  				<dd>{options.CONTENT}</dd>




More information about the customisationdb-commits mailing list