Merge branch '3.1.x' into ticket/15081

This commit is contained in:
javiexin 2017-03-05 15:07:26 +01:00 committed by GitHub
commit 376e85c1d6
19 changed files with 386 additions and 71 deletions

View file

@ -48,7 +48,7 @@
</tr> </tr>
<!-- BEGIN enabled --> <!-- BEGIN enabled -->
<tr class="ext_enabled row-highlight"> <tr class="ext_enabled row-highlight">
<td><strong title="{enabled.NAME}">{enabled.META_DISPLAY_NAME}</strong></td> <td><strong title="{enabled.NAME}">{enabled.META_DISPLAY_NAME}</strong><!-- EVENT acp_ext_list_enabled_name_after --></td>
<td style="text-align: center;"> <td style="text-align: center;">
<!-- IF enabled.S_VERSIONCHECK --> <!-- IF enabled.S_VERSIONCHECK -->
<strong <!-- IF enabled.S_UP_TO_DATE -->style="color: #228822;"<!-- ELSE -->style="color: #BC2A4D;"<!-- ENDIF -->>{enabled.META_VERSION}</strong> <strong <!-- IF enabled.S_UP_TO_DATE -->style="color: #228822;"<!-- ELSE -->style="color: #BC2A4D;"<!-- ENDIF -->>{enabled.META_VERSION}</strong>
@ -73,7 +73,7 @@
</tr> </tr>
<!-- BEGIN disabled --> <!-- BEGIN disabled -->
<tr class="ext_disabled row-highlight"> <tr class="ext_disabled row-highlight">
<td><strong title="{disabled.NAME}">{disabled.META_DISPLAY_NAME}</strong></td> <td><strong title="{disabled.NAME}">{disabled.META_DISPLAY_NAME}</strong><!-- EVENT acp_ext_list_disabled_name_after --></td>
<td style="text-align: center;"> <td style="text-align: center;">
<!-- IF disabled.S_VERSIONCHECK --> <!-- IF disabled.S_VERSIONCHECK -->
<strong <!-- IF disabled.S_UP_TO_DATE -->style="color: #228822;"<!-- ELSE -->style="color: #BC2A4D;"<!-- ENDIF -->>{disabled.META_VERSION}</strong> <strong <!-- IF disabled.S_UP_TO_DATE -->style="color: #228822;"<!-- ELSE -->style="color: #BC2A4D;"<!-- ENDIF -->>{disabled.META_VERSION}</strong>

View file

@ -70,12 +70,24 @@ acp_ext_details_notice
* Since: 3.1.11-RC1 * Since: 3.1.11-RC1
* Purpose: Add extension detail notices after version check information. * Purpose: Add extension detail notices after version check information.
acp_ext_list_disabled_name_after
===
* Location: adm/style/acp_ext_list.html
* Since: 3.1.11-RC1
* Purpose: Add content after the name of disabled extensions in the list
acp_ext_list_disabled_title_after acp_ext_list_disabled_title_after
=== ===
* Location: adm/style/acp_ext_list.html * Location: adm/style/acp_ext_list.html
* Since: 3.1.11-RC1 * Since: 3.1.11-RC1
* Purpose: Add text after disabled extensions section title. * Purpose: Add text after disabled extensions section title.
acp_ext_list_enabled_name_after
===
* Location: adm/style/acp_ext_list.html
* Since: 3.1.11-RC1
* Purpose: Add content after the name of enabled extensions in the list
acp_ext_list_enabled_title_after acp_ext_list_enabled_title_after
=== ===
* Location: adm/style/acp_ext_list.html * Location: adm/style/acp_ext_list.html

View file

@ -262,7 +262,7 @@ else
* @var string mode Download mode * @var string mode Download mode
* @var bool thumbnail Flag indicating if the file is a thumbnail * @var bool thumbnail Flag indicating if the file is a thumbnail
* @since 3.1.6-RC1 * @since 3.1.6-RC1
* @change 3.1.7-RC1 Fixing wrong name of a variable (replacing "extension" by "extensions") * @changed 3.1.7-RC1 Fixing wrong name of a variable (replacing "extension" by "extensions")
*/ */
$vars = array( $vars = array(
'attach_id', 'attach_id',

View file

@ -15,16 +15,31 @@ class acp_logs_info
{ {
function module() function module()
{ {
global $phpbb_dispatcher;
$modes = array(
'admin' => array('title' => 'ACP_ADMIN_LOGS', 'auth' => 'acl_a_viewlogs', 'cat' => array('ACP_FORUM_LOGS')),
'mod' => array('title' => 'ACP_MOD_LOGS', 'auth' => 'acl_a_viewlogs', 'cat' => array('ACP_FORUM_LOGS')),
'users' => array('title' => 'ACP_USERS_LOGS', 'auth' => 'acl_a_viewlogs', 'cat' => array('ACP_FORUM_LOGS')),
'critical' => array('title' => 'ACP_CRITICAL_LOGS', 'auth' => 'acl_a_viewlogs', 'cat' => array('ACP_FORUM_LOGS')),
);
/**
* Event to add or modify ACP log modulemodes
*
* @event core.acp_logs_info_modify_modes
* @var array modes Array with modes info
* @since 3.1.11-RC1
* @since 3.2.1-RC1
*/
$vars = array('modes');
extract($phpbb_dispatcher->trigger_event('core.acp_logs_info_modify_modes', compact($vars)));
return array( return array(
'filename' => 'acp_logs', 'filename' => 'acp_logs',
'title' => 'ACP_LOGGING', 'title' => 'ACP_LOGGING',
'version' => '1.0.0', 'version' => '1.0.0',
'modes' => array( 'modes' => $modes,
'admin' => array('title' => 'ACP_ADMIN_LOGS', 'auth' => 'acl_a_viewlogs', 'cat' => array('ACP_FORUM_LOGS')),
'mod' => array('title' => 'ACP_MOD_LOGS', 'auth' => 'acl_a_viewlogs', 'cat' => array('ACP_FORUM_LOGS')),
'users' => array('title' => 'ACP_USERS_LOGS', 'auth' => 'acl_a_viewlogs', 'cat' => array('ACP_FORUM_LOGS')),
'critical' => array('title' => 'ACP_CRITICAL_LOGS', 'auth' => 'acl_a_viewlogs', 'cat' => array('ACP_FORUM_LOGS')),
),
); );
} }

View file

@ -646,7 +646,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
* @var array row The data of the forum * @var array row The data of the forum
* @var array subforums_row Template data of subforums * @var array subforums_row Template data of subforums
* @since 3.1.0-a1 * @since 3.1.0-a1
* @change 3.1.0-b5 Added var subforums_row * @changed 3.1.0-b5 Added var subforums_row
*/ */
$vars = array('forum_row', 'row', 'subforums_row'); $vars = array('forum_row', 'row', 'subforums_row');
extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_template_vars', compact($vars))); extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_template_vars', compact($vars)));

View file

@ -2514,7 +2514,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
* @var string url The "Return to topic" URL * @var string url The "Return to topic" URL
* *
* @since 3.1.0-a3 * @since 3.1.0-a3
* @change 3.1.0-RC3 Added vars mode, subject, username, topic_type, * @changed 3.1.0-RC3 Added vars mode, subject, username, topic_type,
* poll, update_message, update_search_index * poll, update_message, update_search_index
*/ */
$vars = array( $vars = array(

View file

@ -272,13 +272,15 @@ function user_add($user_row, $cp_data = false, $notifications_data = null)
* Use this event to modify the values to be inserted when a user is added * Use this event to modify the values to be inserted when a user is added
* *
* @event core.user_add_modify_data * @event core.user_add_modify_data
* @var array user_row Array of user details submited to user_add * @var array user_row Array of user details submited to user_add
* @var array cp_data Array of Custom profile fields submited to user_add * @var array cp_data Array of Custom profile fields submited to user_add
* @var array sql_ary Array of data to be inserted when a user is added * @var array sql_ary Array of data to be inserted when a user is added
* @var array notifications_data Array of notification data to be inserted when a user is added
* @since 3.1.0-a1 * @since 3.1.0-a1
* @change 3.1.0-b5 * @changed 3.1.0-b5 Added user_row and cp_data
* @changed 3.1.11-RC1 Added notifications_data
*/ */
$vars = array('user_row', 'cp_data', 'sql_ary'); $vars = array('user_row', 'cp_data', 'sql_ary', 'notifications_data');
extract($phpbb_dispatcher->trigger_event('core.user_add_modify_data', compact($vars))); extract($phpbb_dispatcher->trigger_event('core.user_add_modify_data', compact($vars)));
$sql = 'INSERT INTO ' . USERS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); $sql = 'INSERT INTO ' . USERS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);

View file

@ -164,7 +164,7 @@ class mcp_main
* @var string action Topic quick moderation action name * @var string action Topic quick moderation action name
* @var bool quickmod Flag indicating whether MCP is in quick moderation mode * @var bool quickmod Flag indicating whether MCP is in quick moderation mode
* @since 3.1.0-a4 * @since 3.1.0-a4
* @change 3.1.0-RC4 Added variables: action, quickmod * @changed 3.1.0-RC4 Added variables: action, quickmod
*/ */
$vars = array('action', 'quickmod'); $vars = array('action', 'quickmod');
extract($phpbb_dispatcher->trigger_event('core.modify_quickmod_actions', compact($vars))); extract($phpbb_dispatcher->trigger_event('core.modify_quickmod_actions', compact($vars)));

View file

@ -1171,7 +1171,7 @@ class parse_message extends bbcode_firstpass
* @var bool return Do we return after the event is triggered if $warn_msg is not empty * @var bool return Do we return after the event is triggered if $warn_msg is not empty
* @var array warn_msg Array of the warning messages * @var array warn_msg Array of the warning messages
* @since 3.1.2-RC1 * @since 3.1.2-RC1
* @change 3.1.3-RC1 Added vars $bbcode_bitfield and $bbcode_uid * @changed 3.1.3-RC1 Added vars $bbcode_bitfield and $bbcode_uid
*/ */
$message = $this->message; $message = $this->message;
$warn_msg = $this->warn_msg; $warn_msg = $this->warn_msg;

View file

@ -510,7 +510,7 @@ class php_exporter
/** /**
* Find the "@changed" Information lines * Find the "@changed" Information lines
* *
* @param string $tag_name Should be 'changed' or 'change' * @param string $tag_name Should be 'change', not 'changed'
* @return array Absolute line numbers * @return array Absolute line numbers
* @throws \LogicException * @throws \LogicException
*/ */
@ -658,7 +658,7 @@ class php_exporter
{ {
$match = array(); $match = array();
$line = str_replace("\t", ' ', ltrim($line, "\t ")); $line = str_replace("\t", ' ', ltrim($line, "\t "));
preg_match('#^\* @change(d)? (\d+\.\d+\.\d+(?:-(?:a|b|RC|pl)\d+)?)( (?:.*))?$#', $line, $match); preg_match('#^\* @changed (\d+\.\d+\.\d+(?:-(?:a|b|RC|pl)\d+)?)( (?:.*))?$#', $line, $match);
if (!isset($match[2])) if (!isset($match[2]))
{ {
throw new \LogicException("Invalid '@changed' information for event " throw new \LogicException("Invalid '@changed' information for event "

View file

@ -132,6 +132,14 @@ abstract class base implements template
return $this->context->alter_block_array($blockname, $vararray, $key, $mode); return $this->context->alter_block_array($blockname, $vararray, $key, $mode);
} }
/**
* {@inheritdoc}
*/
public function find_key_index($blockname, $key)
{
return $this->context->find_key_index($blockname, $key);
}
/** /**
* Calls hook if any is defined. * Calls hook if any is defined.
* *

View file

@ -263,6 +263,89 @@ class context
return true; return true;
} }
/**
* Find the index for a specified key in the innermost specified block
*
* @param string $blockname the blockname, for example 'loop'
* @param mixed $key Key to search for
*
* array: KEY => VALUE [the key/value pair to search for within the loop to determine the correct position]
*
* int: Position [the position to search for]
*
* If key is false the position is set to 0
* If key is true the position is set to the last entry
*
* @return mixed false if not found, index position otherwise; be sure to test with ===
*/
public function find_key_index($blockname, $key)
{
// For nested block, $blockcount > 0, for top-level block, $blockcount == 0
$blocks = explode('.', $blockname);
$blockcount = sizeof($blocks) - 1;
$block = $this->tpldata;
for ($i = 0; $i < $blockcount; $i++)
{
if (($pos = strpos($blocks[$i], '[')) !== false)
{
$name = substr($blocks[$i], 0, $pos);
if (strpos($blocks[$i], '[]') === $pos)
{
$index = sizeof($block[$name]) - 1;
}
else
{
$index = min((int) substr($blocks[$i], $pos + 1, -1), sizeof($block[$name]) - 1);
}
}
else
{
$name = $blocks[$i];
$index = sizeof($block[$name]) - 1;
}
if (!isset($block[$name]))
{
return false;
}
$block = $block[$name];
if (!isset($block[$index]))
{
return false;
}
$block = $block[$index];
}
if (!isset($block[$blocks[$i]]))
{
return false;
}
$block = $block[$blocks[$i]]; // Traverse the last block
// Change key to zero (change first position) if false and to last position if true
if ($key === false || $key === true)
{
return ($key === false) ? 0 : sizeof($block) - 1;
}
// Get correct position if array given
if (is_array($key))
{
// Search array to get correct position
list($search_key, $search_value) = @each($key);
foreach ($block as $i => $val_ary)
{
if ($val_ary[$search_key] === $search_value)
{
return $i;
}
}
}
return (is_int($key) && ((0 <= $key) && ($key < sizeof($block)))) ? $key : false;
}
/** /**
* Change already assigned key variable pair (one-dimensional - single loop entry) * Change already assigned key variable pair (one-dimensional - single loop entry)
* *
@ -293,45 +376,49 @@ class context
public function alter_block_array($blockname, array $vararray, $key = false, $mode = 'insert') public function alter_block_array($blockname, array $vararray, $key = false, $mode = 'insert')
{ {
$this->num_rows_is_set = false; $this->num_rows_is_set = false;
if (strpos($blockname, '.') !== false)
// For nested block, $blockcount > 0, for top-level block, $blockcount == 0
$blocks = explode('.', $blockname);
$blockcount = sizeof($blocks) - 1;
$block = &$this->tpldata;
for ($i = 0; $i < $blockcount; $i++)
{ {
// Nested block. if (($pos = strpos($blocks[$i], '[')) !== false)
$blocks = explode('.', $blockname);
$blockcount = sizeof($blocks) - 1;
$block = &$this->tpldata;
for ($i = 0; $i < $blockcount; $i++)
{ {
if (($pos = strpos($blocks[$i], '[')) !== false) $name = substr($blocks[$i], 0, $pos);
{
$name = substr($blocks[$i], 0, $pos);
if (strpos($blocks[$i], '[]') === $pos) if (strpos($blocks[$i], '[]') === $pos)
{ {
$index = sizeof($block[$name]) - 1; $index = sizeof($block[$name]) - 1;
}
else
{
$index = min((int) substr($blocks[$i], $pos + 1, -1), sizeof($block[$name]) - 1);
}
} }
else else
{ {
$name = $blocks[$i]; $index = min((int) substr($blocks[$i], $pos + 1, -1), sizeof($block[$name]) - 1);
$index = sizeof($block[$name]) - 1;
} }
$block = &$block[$name];
$block = &$block[$index];
} }
else
{
$name = $blocks[$i];
$index = sizeof($block[$name]) - 1;
}
$block = &$block[$name];
$block = &$block[$index];
}
$name = $blocks[$i];
$block = &$block[$blocks[$i]]; // Traverse the last block // If last block does not exist and we are inserting, and not searching for key, we create it empty; otherwise, nothing to do
} if (!isset($block[$name]))
else
{ {
// Top-level block. if ($mode != 'insert' || is_array($key))
$block = &$this->tpldata[$blockname]; {
return false;
}
$block[$name] = array();
} }
$block = &$block[$name]; // Now we can traverse the last block
// Change key to zero (change first position) if false and to last position if true // Change key to zero (change first position) if false and to last position if true
if ($key === false || $key === true) if ($key === false || $key === true)
{ {
@ -371,14 +458,15 @@ class context
unset($block[($key - 1)]['S_LAST_ROW']); unset($block[($key - 1)]['S_LAST_ROW']);
$vararray['S_LAST_ROW'] = true; $vararray['S_LAST_ROW'] = true;
} }
else if ($key === 0) if ($key <= 0)
{ {
$key = 0;
unset($block[0]['S_FIRST_ROW']); unset($block[0]['S_FIRST_ROW']);
$vararray['S_FIRST_ROW'] = true; $vararray['S_FIRST_ROW'] = true;
} }
// Assign S_BLOCK_NAME // Assign S_BLOCK_NAME
$vararray['S_BLOCK_NAME'] = $blockname; $vararray['S_BLOCK_NAME'] = $name;
// Re-position template blocks // Re-position template blocks
for ($i = sizeof($block); $i > $key; $i--) for ($i = sizeof($block); $i > $key; $i--)
@ -398,6 +486,12 @@ class context
// Which block to change? // Which block to change?
if ($mode == 'change') if ($mode == 'change')
{ {
// If key is out of bounds, do not change anything
if ($key > sizeof($block) || $key < 0)
{
return false;
}
if ($key == sizeof($block)) if ($key == sizeof($block))
{ {
$key--; $key--;

View file

@ -172,6 +172,23 @@ interface template
*/ */
public function alter_block_array($blockname, array $vararray, $key = false, $mode = 'insert'); public function alter_block_array($blockname, array $vararray, $key = false, $mode = 'insert');
/**
* Find the index for a specified key in the innermost specified block
*
* @param string $blockname the blockname, for example 'loop'
* @param mixed $key Key to search for
*
* array: KEY => VALUE [the key/value pair to search for within the loop to determine the correct position]
*
* int: Position [the position to search for]
*
* If key is false the position is set to 0
* If key is true the position is set to the last entry
*
* @return mixed false if not found, index position otherwise; be sure to test with ===
*/
public function find_key_index($blockname, $key);
/** /**
* Get path to template for handle (required for BBCode parser) * Get path to template for handle (required for BBCode parser)
* *

View file

@ -84,7 +84,7 @@ $current_time = time();
* NOTE: Should be actual language strings, NOT * NOTE: Should be actual language strings, NOT
* language keys. * language keys.
* @since 3.1.0-a1 * @since 3.1.0-a1
* @change 3.1.2-RC1 Removed 'delete' var as it does not exist * @changed 3.1.2-RC1 Removed 'delete' var as it does not exist
*/ */
$vars = array( $vars = array(
'post_id', 'post_id',
@ -941,7 +941,9 @@ if ($submit || $preview || $refresh)
* is posting a new topic or editing a post) * is posting a new topic or editing a post)
* @var bool refresh Whether or not to retain previously submitted data * @var bool refresh Whether or not to retain previously submitted data
* @var object message_parser The message parser object * @var object message_parser The message parser object
* @var array error Array of errors
* @since 3.1.2-RC1 * @since 3.1.2-RC1
* @changed 3.1.11-RC1 Added error
*/ */
$vars = array( $vars = array(
'post_data', 'post_data',
@ -956,6 +958,7 @@ if ($submit || $preview || $refresh)
'cancel', 'cancel',
'refresh', 'refresh',
'message_parser', 'message_parser',
'error',
); );
extract($phpbb_dispatcher->trigger_event('core.posting_modify_message_text', compact($vars))); extract($phpbb_dispatcher->trigger_event('core.posting_modify_message_text', compact($vars)));
@ -1261,7 +1264,7 @@ if ($submit || $preview || $refresh)
* @var array error Any error strings; a non-empty array aborts form submission. * @var array error Any error strings; a non-empty array aborts form submission.
* NOTE: Should be actual language strings, NOT language keys. * NOTE: Should be actual language strings, NOT language keys.
* @since 3.1.0-RC5 * @since 3.1.0-RC5
* @change 3.1.5-RC1 Added poll array to the event * @changed 3.1.5-RC1 Added poll array to the event
*/ */
$vars = array( $vars = array(
'post_data', 'post_data',
@ -1869,13 +1872,13 @@ if (($mode == 'post' || ($mode == 'edit' && $post_id == $post_data['topic_first_
* posting page via $template->assign_vars() * posting page via $template->assign_vars()
* @var object message_parser The message parser object * @var object message_parser The message parser object
* @since 3.1.0-a1 * @since 3.1.0-a1
* @change 3.1.0-b3 Added vars post_data, moderators, mode, page_title, * @changed 3.1.0-b3 Added vars post_data, moderators, mode, page_title,
* s_topic_icons, form_enctype, s_action, s_hidden_fields, * s_topic_icons, form_enctype, s_action, s_hidden_fields,
* post_id, topic_id, forum_id, submit, preview, save, load, * post_id, topic_id, forum_id, submit, preview, save, load,
* delete, cancel, refresh, error, page_data, message_parser * delete, cancel, refresh, error, page_data, message_parser
* @change 3.1.2-RC1 Removed 'delete' var as it does not exist * @changed 3.1.2-RC1 Removed 'delete' var as it does not exist
* @change 3.1.5-RC1 Added poll variables to the page_data array * @changed 3.1.5-RC1 Added poll variables to the page_data array
* @change 3.1.6-RC1 Added 'draft_id' var * @changed 3.1.6-RC1 Added 'draft_id' var
*/ */
$vars = array( $vars = array(
'post_data', 'post_data',

View file

@ -431,9 +431,9 @@ $sql_array = array(
* Author, Post time, Replies, Subject, Views * Author, Post time, Replies, Subject, Views
* @var string sort_dir Either "a" for ascending or "d" for descending * @var string sort_dir Either "a" for ascending or "d" for descending
* @since 3.1.0-a1 * @since 3.1.0-a1
* @change 3.1.0-RC4 Added forum_data var * @changed 3.1.0-RC4 Added forum_data var
* @change 3.1.4-RC1 Added forum_id, topics_count, sort_days, sort_key and sort_dir vars * @changed 3.1.4-RC1 Added forum_id, topics_count, sort_days, sort_key and sort_dir vars
* @change 3.1.9-RC1 Fix types of properties * @changed 3.1.9-RC1 Fix types of properties
*/ */
$vars = array( $vars = array(
'forum_data', 'forum_data',

View file

@ -168,7 +168,7 @@ $sql_ary = array(
* @var int guest_counter Number of guests displayed * @var int guest_counter Number of guests displayed
* @var array forum_data Array with forum data * @var array forum_data Array with forum data
* @since 3.1.0-a1 * @since 3.1.0-a1
* @change 3.1.0-a2 Added vars guest_counter and forum_data * @changed 3.1.0-a2 Added vars guest_counter and forum_data
*/ */
$vars = array('sql_ary', 'show_guests', 'guest_counter', 'forum_data'); $vars = array('sql_ary', 'show_guests', 'guest_counter', 'forum_data');
extract($phpbb_dispatcher->trigger_event('core.viewonline_modify_sql', compact($vars))); extract($phpbb_dispatcher->trigger_event('core.viewonline_modify_sql', compact($vars)));
@ -385,7 +385,7 @@ while ($row = $db->sql_fetchrow($result))
* @var string location_url Page url to displayed in the list * @var string location_url Page url to displayed in the list
* @var array forum_data Array with forum data * @var array forum_data Array with forum data
* @since 3.1.0-a1 * @since 3.1.0-a1
* @change 3.1.0-a2 Added var forum_data * @changed 3.1.0-a2 Added var forum_data
*/ */
$vars = array('on_page', 'row', 'location', 'location_url', 'forum_data'); $vars = array('on_page', 'row', 'location', 'location_url', 'forum_data');
extract($phpbb_dispatcher->trigger_event('core.viewonline_overwrite_location', compact($vars))); extract($phpbb_dispatcher->trigger_event('core.viewonline_overwrite_location', compact($vars)));

View file

@ -700,7 +700,7 @@ $base_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=
* @var int total_posts Topic total posts count * @var int total_posts Topic total posts count
* @var string viewtopic_url URL to the topic page * @var string viewtopic_url URL to the topic page
* @since 3.1.0-RC4 * @since 3.1.0-RC4
* @change 3.1.2-RC1 Added viewtopic_url * @changed 3.1.2-RC1 Added viewtopic_url
*/ */
$vars = array( $vars = array(
'base_url', 'base_url',
@ -1200,7 +1200,7 @@ $sql_ary = array(
* @var int start Pagination information * @var int start Pagination information
* @var array sql_ary The SQL array to get the data of posts and posters * @var array sql_ary The SQL array to get the data of posts and posters
* @since 3.1.0-a1 * @since 3.1.0-a1
* @change 3.1.0-a2 Added vars forum_id, topic_id, topic_data, post_list, sort_days, sort_key, sort_dir, start * @changed 3.1.0-a2 Added vars forum_id, topic_id, topic_data, post_list, sort_days, sort_key, sort_dir, start
*/ */
$vars = array( $vars = array(
'forum_id', 'forum_id',
@ -2007,9 +2007,9 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
* @var array post_row Template block array of the post * @var array post_row Template block array of the post
* @var array topic_data Array with topic data * @var array topic_data Array with topic data
* @since 3.1.0-a1 * @since 3.1.0-a1
* @change 3.1.0-a3 Added vars start, current_row_number, end, attachments * @changed 3.1.0-a3 Added vars start, current_row_number, end, attachments
* @change 3.1.0-b3 Added topic_data array, total_posts * @changed 3.1.0-b3 Added topic_data array, total_posts
* @change 3.1.0-RC3 Added poster_id * @changed 3.1.0-RC3 Added poster_id
*/ */
$vars = array( $vars = array(
'start', 'start',
@ -2107,7 +2107,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
* @var array post_row Template block array of the post * @var array post_row Template block array of the post
* @var array topic_data Array with topic data * @var array topic_data Array with topic data
* @since 3.1.0-a3 * @since 3.1.0-a3
* @change 3.1.0-b3 Added topic_data array, total_posts * @changed 3.1.0-b3 Added topic_data array, total_posts
*/ */
$vars = array( $vars = array(
'start', 'start',
@ -2270,7 +2270,7 @@ $page_title = $topic_data['topic_title'] . ($start ? ' - ' . sprintf($user->lang
* @var int start Start offset used to calculate the page * @var int start Start offset used to calculate the page
* @var array post_list Array with post_ids we are going to display * @var array post_list Array with post_ids we are going to display
* @since 3.1.0-a1 * @since 3.1.0-a1
* @change 3.1.0-RC4 Added post_list var * @changed 3.1.0-RC4 Added post_list var
*/ */
$vars = array('page_title', 'topic_data', 'forum_id', 'start', 'post_list'); $vars = array('page_title', 'topic_data', 'forum_id', 'start', 'post_list');
extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_page_title', compact($vars))); extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_page_title', compact($vars)));

View file

@ -34,7 +34,7 @@
* posting page via $template->assign_vars() * posting page via $template->assign_vars()
* @var object message_parser The message parser object * @var object message_parser The message parser object
* @since 3.1.0-a1 * @since 3.1.0-a1
* @change 3.1.0-b3 Added vars post_data, moderators, mode, page_title, * @changed 3.1.0-b3 Added vars post_data, moderators, mode, page_title,
* s_topic_icons, form_enctype, s_action, s_hidden_fields, * s_topic_icons, form_enctype, s_action, s_hidden_fields,
* post_id, topic_id, forum_id, submit, preview, save, load, * post_id, topic_id, forum_id, submit, preview, save, load,
* delete, cancel, refresh, error, page_data, message_parser * delete, cancel, refresh, error, page_data, message_parser

View file

@ -528,11 +528,11 @@ EOT
), ),
array( array(
'outer', 'outer',
array('VARIABLE' => 'pos #1'), array('VARIABLE' => 'changed'),
0, 0,
'change', 'change',
<<<EOT <<<EOT
outer - 0 - pos #1 outer - 0 - changed
middle - 0 middle - 0
middle - 1 middle - 1
outer - 1 outer - 1
@ -543,7 +543,124 @@ middle - 0
middle - 1 middle - 1
EOT EOT
, ,
'Test inserting at 1 on top level block', 'Test changing at 0 on top level block',
),
array(
'outer',
array('VARIABLE' => 'changed'),
array('S_ROW_NUM' => 2),
'change',
<<<EOT
outer - 0
middle - 0
middle - 1
outer - 1
middle - 0
middle - 1
outer - 2 - changed
middle - 0
middle - 1
EOT
,
'Test changing at KEY on top level block',
),
array(
'outer.middle',
array('VARIABLE' => 'before'),
false,
'insert',
<<<EOT
outer - 0
middle - 0
middle - 1
outer - 1
middle - 0
middle - 1
outer - 2
middle - 0 - before
middle - 1
middle - 2
EOT
,
'Test inserting before on middle level block',
),
array(
'outer.middle',
array('VARIABLE' => 'after'),
true,
'insert',
<<<EOT
outer - 0
middle - 0
middle - 1
outer - 1
middle - 0
middle - 1
outer - 2
middle - 0
middle - 1
middle - 2 - after
EOT
,
'Test inserting after on middle level block',
),
array(
'outer[1].middle',
array('VARIABLE' => 'pos #1'),
1,
'insert',
<<<EOT
outer - 0
middle - 0
middle - 1
outer - 1
middle - 0
middle - 1 - pos #1
middle - 2
outer - 2
middle - 0
middle - 1
EOT
,
'Test inserting at 1 on middle level block',
),
array(
'outer[].middle',
array('VARIABLE' => 'changed'),
0,
'change',
<<<EOT
outer - 0
middle - 0
middle - 1
outer - 1
middle - 0
middle - 1
outer - 2
middle - 0 - changed
middle - 1
EOT
,
'Test changing at beginning of last top level block',
),
array(
'outer.middle',
array('VARIABLE' => 'changed'),
array('S_ROW_NUM' => 1),
'change',
<<<EOT
outer - 0
middle - 0
middle - 1
outer - 1
middle - 0
middle - 1
outer - 2
middle - 0
middle - 1 - changed
EOT
,
'Test changing at beginning of last top level block',
), ),
); );
} }
@ -601,8 +718,55 @@ EOT
$expect = 'outer - 0[outer|4]outer - 1[outer|4]middle - 0[middle|1]outer - 2 - test[outer|4]middle - 0[middle|2]middle - 1[middle|2]outer - 3[outer|4]middle - 0[middle|3]middle - 1[middle|3]middle - 2[middle|3]'; $expect = 'outer - 0[outer|4]outer - 1[outer|4]middle - 0[middle|1]outer - 2 - test[outer|4]middle - 0[middle|2]middle - 1[middle|2]outer - 3[outer|4]middle - 0[middle|3]middle - 1[middle|3]middle - 2[middle|3]';
$this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring S_NUM_ROWS is correct after modification'); $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring S_NUM_ROWS is correct after modification');
$this->template->alter_block_array('outer.middle', array());
$expect = 'outer - 0[outer|4]outer - 1[outer|4]middle - 0[middle|1]outer - 2 - test[outer|4]middle - 0[middle|2]middle - 1[middle|2]outer - 3[outer|4]middle - 0[middle|4]middle - 1[middle|4]middle - 2[middle|4]middle - 3[middle|4]';
$this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring S_NUM_ROWS is correct after insertion at middle level');
$this->template->alter_block_array('outer.middle', array('VARIABLE' => 'test'), 2, 'change');
$expect = 'outer - 0[outer|4]outer - 1[outer|4]middle - 0[middle|1]outer - 2 - test[outer|4]middle - 0[middle|2]middle - 1[middle|2]outer - 3[outer|4]middle - 0[middle|4]middle - 1[middle|4]middle - 2 - test[middle|4]middle - 3[middle|4]';
$this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring S_NUM_ROWS is correct after modification at middle level');
} }
public function test_find_key_index()
{
$this->template->set_filenames(array('test' => 'loop_nested.html'));
$this->template->assign_var('TEST_MORE', true);
// @todo Change this
$this->template->assign_block_vars('outer', array('VARIABLE' => 'zero'));
$this->template->assign_block_vars('outer', array('VARIABLE' => 'one'));
$this->template->assign_block_vars('outer.middle', array('VARIABLE' => '1A'));
$this->template->assign_block_vars('outer', array('VARIABLE' => 'two'));
$this->template->assign_block_vars('outer.middle', array('VARIABLE' => '2A'));
$this->template->assign_block_vars('outer.middle', array('VARIABLE' => '2B'));
$this->template->assign_block_vars('outer', array('VARIABLE' => 'three'));
$this->template->assign_block_vars('outer.middle', array('VARIABLE' => '3A'));
$this->template->assign_block_vars('outer.middle', array('VARIABLE' => '3B'));
$this->template->assign_block_vars('outer.middle', array('VARIABLE' => '3C'));
$expect = 'outer - 0 - zero[outer|4]outer - 1 - one[outer|4]middle - 0 - 1A[middle|1]outer - 2 - two[outer|4]middle - 0 - 2A[middle|2]middle - 1 - 2B[middle|2]outer - 3 - three[outer|4]middle - 0 - 3A[middle|3]middle - 1 - 3B[middle|3]middle - 2 - 3C[middle|3]';
$this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring template is built correctly before modification');
$this->template->find_key_index('outer', false);
$this->assertEquals(0, $this->template->find_key_index('outer', false), 'Find index at the beginning of outer loop');
$this->assertEquals(1, $this->template->find_key_index('outer', 1), 'Find index by index in outer loop');
$this->assertEquals(2, $this->template->find_key_index('outer', array('VARIABLE' => 'two')), 'Find index by key in outer loop');
$this->assertEquals(3, $this->template->find_key_index('outer', true), 'Find index at the end of outer loop');
$this->assertEquals(false, $this->template->find_key_index('outer', 7), 'Find index out of bounds of outer loop');
$this->assertEquals(false, $this->template->find_key_index('outer[0].middle', false), 'Find index at the beginning of middle loop, no middle block');
$this->assertEquals(false, $this->template->find_key_index('outer[1].middle', 1), 'Find index by index in inner loop, out of bounds');
$this->assertEquals(1, $this->template->find_key_index('outer[2].middle', array('VARIABLE' => '2B')), 'Find index by key in middle loop');
$this->assertEquals(2, $this->template->find_key_index('outer.middle', true), 'Find index at the end of middle loop');
$this->assertEquals(false, $this->template->find_key_index('outer.wrong', true), 'Wrong middle block name');
$this->assertEquals(false, $this->template->find_key_index('wrong.middle', false), 'Wrong outer block name');
}
public function assign_block_vars_array_data() public function assign_block_vars_array_data()
{ {
return array( return array(