diff options
125 files changed, 1598 insertions, 815 deletions
diff --git a/.travis.yml b/.travis.yml index bbca989254..bfe58bee7d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ php:    - 5.3    - 5.4    - 5.5 +  - hhvm  env:    - DB=mariadb @@ -38,3 +39,7 @@ notifications:        - dev-team@phpbb.com      on_success: change      on_failure: change + +matrix: +  allow_failures: +    - php: hhvm diff --git a/phpBB/adm/style/acp_attachments.html b/phpBB/adm/style/acp_attachments.html index 9ce9fb5f13..9db0fc6521 100644 --- a/phpBB/adm/style/acp_attachments.html +++ b/phpBB/adm/style/acp_attachments.html @@ -331,7 +331,7 @@  	<fieldset class="tabulated">  	<legend>{L_TITLE}</legend> -	<table class="table1"> +	<table class="table1 zebra-table">  	<thead>  	<tr>  		<th>{L_FILENAME}</th> @@ -344,7 +344,7 @@  	</thead>  	<tbody>  	<!-- BEGIN orphan --> -		<!-- IF orphan.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF --> +		<tr>  			<td><a href="{orphan.U_FILE}">{orphan.REAL_FILENAME}</a></td>  			<td>{orphan.FILETIME}</td>  			<td>{orphan.FILESIZE}</td> @@ -389,7 +389,7 @@  	<!-- ENDIF -->  	</div> -	<table class="table1"> +	<table class="table1 zebra-table">  	<thead>  	<tr>  		<th>{L_FILENAME}</th> @@ -400,7 +400,7 @@  	</thead>  	<tbody>  	<!-- BEGIN attachments --> -		<!-- IF attachments.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF --> +		<tr>  			<td>  				<!-- IF attachments.S_IN_MESSAGE -->{L_EXTENSION_GROUP}{L_COLON} <strong><!-- IF attachments.EXT_GROUP_NAME -->{attachments.EXT_GROUP_NAME}<!-- ELSE -->{L_NO_EXT_GROUP}<!-- ENDIF --></strong><br />{attachments.L_DOWNLOAD_COUNT}<br />{L_IN} {L_PRIVATE_MESSAGE}  				<!-- ELSE --><a href="{attachments.U_FILE}" style="font-weight: bold;">{attachments.REAL_FILENAME}</a><br /><!-- IF attachments.COMMENT -->{attachments.COMMENT}<br /><!-- ENDIF -->{attachments.L_DOWNLOAD_COUNT}<br />{L_TOPIC}{L_COLON} <a href="{attachments.U_VIEW_TOPIC}">{attachments.TOPIC_TITLE}</a><!-- ENDIF --> diff --git a/phpBB/adm/style/acp_bbcodes.html b/phpBB/adm/style/acp_bbcodes.html index c22ed395e7..8c8b805975 100644 --- a/phpBB/adm/style/acp_bbcodes.html +++ b/phpBB/adm/style/acp_bbcodes.html @@ -47,6 +47,8 @@  	</dl>  	</fieldset> +	<!-- EVENT acp_bbcodes_edit_fieldsets_after --> +  	<fieldset class="submit-buttons">  		<legend>{L_SUBMIT}</legend>  		<input class="button1" type="submit" id="submit" name="submit" value="{L_SUBMIT}" />  @@ -71,7 +73,7 @@  	</thead>  	<tbody>  	<!-- BEGIN token --> -		<tr valign="top"> +		<tr style="vertical-align: top;">  			<td class="row1">{token.TOKEN}</td>  			<td class="row2">{token.EXPLAIN}</td>  		</tr> @@ -90,7 +92,7 @@  	<fieldset class="tabulated">  	<legend>{L_ACP_BBCODES}</legend> -	<table class="table1" id="down"> +	<table class="table1 zebra-table" id="down">  	<thead>  	<tr>  		<th>{L_BBCODE_TAG}</th> @@ -99,9 +101,9 @@  	</thead>  	<tbody>  	<!-- BEGIN bbcodes --> -		<!-- IF bbcodes.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF --> +		<tr>  			<td style="text-align: center;">{bbcodes.BBCODE_TAG}</td> -			<td style="text-align: right; width: 40px;"><a href="{bbcodes.U_EDIT}">{ICON_EDIT}</a> <a href="{bbcodes.U_DELETE}" data-ajax="row_delete">{ICON_DELETE}</a></td> +			<td class="actions"><!-- EVENT acp_bbcodes_actions_prepend --> <a href="{bbcodes.U_EDIT}">{ICON_EDIT}</a> <a href="{bbcodes.U_DELETE}" data-ajax="row_delete">{ICON_DELETE}</a> <!-- EVENT acp_bbcodes_actions_append --></td>  		</tr>  	<!-- BEGINELSE -->  		<tr class="row3"> diff --git a/phpBB/adm/style/acp_bots.html b/phpBB/adm/style/acp_bots.html index eeda13303d..b0e61015b6 100644 --- a/phpBB/adm/style/acp_bots.html +++ b/phpBB/adm/style/acp_bots.html @@ -62,7 +62,7 @@  	<form id="acp_bots" method="post" action="{U_ACTION}"> -	<table class="table1"> +	<table class="table1 zebra-table">  	<thead>  	<tr>  		<th>{L_BOT_NAME}</th> @@ -73,7 +73,7 @@  	</thead>  	<tbody>  	<!-- BEGIN bots --> -		<!-- IF bots.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF --> +		<tr>  			<td style="width: 50%;">{bots.BOT_NAME}</td>  			<td style="width: 15%; white-space: nowrap;" align="center"> {bots.LAST_VISIT} </td>  			<td style="text-align: center;"> <a href="{bots.U_ACTIVATE_DEACTIVATE}" data-ajax="activate_deactivate">{bots.L_ACTIVATE_DEACTIVATE}</a> </td> diff --git a/phpBB/adm/style/acp_groups.html b/phpBB/adm/style/acp_groups.html index 925d24f3a3..72f4f2b239 100644 --- a/phpBB/adm/style/acp_groups.html +++ b/phpBB/adm/style/acp_groups.html @@ -155,7 +155,7 @@  		<a href="{U_DEFAULT_ALL}">» {L_MAKE_DEFAULT_FOR_ALL}</a>  	</fieldset> -	<table class="table1"> +	<table class="table1 zebra-table">  	<thead>  	<tr>  		<th>{L_USERNAME}</th> @@ -170,7 +170,7 @@  		<td class="row3" colspan="5"><strong>{L_GROUP_LEAD}</strong></td>  	</tr>  	<!-- BEGIN leader --> -		<!-- IF leader.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF --> +		<tr>  			<td><!-- IF leader.USERNAME_COLOUR --><a href="{leader.U_USER_EDIT}" style="color: #{leader.USERNAME_COLOUR};" class="username-coloured">{leader.USERNAME}</a><!-- ELSE --><a href="{leader.U_USER_EDIT}">{leader.USERNAME}</a><!-- ENDIF --></td>  			<td style="text-align: center;"><!-- IF leader.S_GROUP_DEFAULT -->{L_YES}<!-- ELSE -->{L_NO}<!-- ENDIF --></td>  			<td style="text-align: center;">{leader.JOINED}</td> @@ -179,7 +179,7 @@  		</tr>  	<!-- BEGINELSE -->  		<tr> -			<td class="row1" colspan="5" style="text-align: center;">{L_GROUPS_NO_MODS}</td> +			<td colspan="5" style="text-align: center;">{L_GROUPS_NO_MODS}</td>  		</tr>  	<!-- END leader -->  	<tr> @@ -191,7 +191,7 @@  			<td class="row3" colspan="5"><strong>{L_GROUP_PENDING}</strong></td>  		</tr>  		<!-- ELSE --> -			<!-- IF member.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF --> +		<tr>  			<td><!-- IF member.USERNAME_COLOUR --><a href="{member.U_USER_EDIT}" style="color: #{member.USERNAME_COLOUR};" class="username-coloured">{member.USERNAME}</a><!-- ELSE --><a href="{member.U_USER_EDIT}">{member.USERNAME}</a><!-- ENDIF --></td>  			<td style="text-align: center;"><!-- IF member.S_GROUP_DEFAULT -->{L_YES}<!-- ELSE -->{L_NO}<!-- ENDIF --></td>  			<td style="text-align: center;">{member.JOINED}</td> @@ -201,7 +201,7 @@  		<!-- ENDIF -->  	<!-- BEGINELSE -->  		<tr> -			<td class="row1" colspan="5" style="text-align: center;">{L_GROUPS_NO_MEMBERS}</td> +			<td colspan="5" style="text-align: center;">{L_GROUPS_NO_MEMBERS}</td>  		</tr>  	<!-- END member -->  	</tbody> diff --git a/phpBB/adm/style/acp_icons.html b/phpBB/adm/style/acp_icons.html index bfe4878ba5..9117052d87 100644 --- a/phpBB/adm/style/acp_icons.html +++ b/phpBB/adm/style/acp_icons.html @@ -74,7 +74,7 @@  	<fieldset class="tabulated">  	<legend>{L_TITLE}</legend> -	<table class="table1" id="smilies"> +	<table class="table1 zebra-table" id="smilies">  	<thead>  	<tr>  		<th colspan="{COLSPAN}">{L_CONFIG}</th> @@ -100,7 +100,7 @@  	</thead>  	<tbody>  	<!-- BEGIN items --> -		<!-- IF items.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF --> +		<tr>  		<td style="text-align: center;"><img src="{items.IMG_SRC}" alt="" title="" /><input type="hidden" name="image[{items.IMG}]" value="1" /></td>  		<td style="vertical-align: top;">[{items.IMG}]</td> @@ -218,7 +218,7 @@  	<legend>{L_TITLE}</legend> -	<table class="table1"> +	<table class="table1 zebra-table">  	<thead>  	<tr>  		<th>{L_TITLE}</th> @@ -236,16 +236,18 @@  				<td class="row3" colspan="{COLSPAN}" style="text-align: center;">{L_NOT_DISPLAYED}</td>  			</tr>  		<!-- ENDIF --> -		<!-- IF items.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF --> +		<tr>  			<td style="width: 85%; text-align: center;"><img src="{items.IMG_SRC}" width="{items.WIDTH}" height="{items.HEIGHT}" alt="{items.ALT_TEXT}" title="{items.ALT_TEXT}" /></td>  			<!-- IF S_SMILIES -->  				<td style="text-align: center;">{items.CODE}</td>  				<td style="text-align: center;">{items.EMOTION}</td>  			<!-- ENDIF --> -			<td style="text-align: right; white-space: nowrap;"> -				<!-- IF items.S_FIRST_ROW and not U_PREVIOUS_PAGE -->{ICON_MOVE_UP_DISABLED}<!-- ELSE --><a href="{items.U_MOVE_UP}">{ICON_MOVE_UP}</a><!-- ENDIF -->  -				<!-- IF items.S_LAST_ROW and not U_NEXT_PAGE -->{ICON_MOVE_DOWN_DISABLED}<!-- ELSE --><a href="{items.U_MOVE_DOWN}">{ICON_MOVE_DOWN}</a><!-- ENDIF --> -				 <a href="{items.U_EDIT}">{ICON_EDIT}</a> <a href="{items.U_DELETE}" data-ajax="row_delete">{ICON_DELETE}</a> +			<td class="actions" style="text-align: right;"> +				<span class="up-disabled" style="display:none;">{ICON_MOVE_UP_DISABLED}</span> +				<span class="up"><a href="{items.U_MOVE_UP}" data-ajax="row_up">{ICON_MOVE_UP}</a></span> +				<span class="down-disabled" style="display:none;">{ICON_MOVE_DOWN_DISABLED}</span> +				<span class="down"><a href="{items.U_MOVE_DOWN}" data-ajax="row_down">{ICON_MOVE_DOWN}</a></span> +				<a href="{items.U_EDIT}">{ICON_EDIT}</a> <a href="{items.U_DELETE}" data-ajax="row_delete">{ICON_DELETE}</a>  			</td>  		</tr>  	<!-- BEGINELSE --> diff --git a/phpBB/adm/style/acp_inactive.html b/phpBB/adm/style/acp_inactive.html index 1c42c93f76..1cdc1abe6b 100644 --- a/phpBB/adm/style/acp_inactive.html +++ b/phpBB/adm/style/acp_inactive.html @@ -16,7 +16,7 @@  </div>  <!-- ENDIF --> -<table class="table1"> +<table class="table1 zebra-table">  <thead>  <tr>  	<th>{L_USERNAME}</th> @@ -29,8 +29,7 @@  </thead>  <tbody>  <!-- BEGIN inactive --> -	<!-- IF inactive.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF --> - +	<tr>  		<td style="vertical-align: top;">  			{inactive.USERNAME_FULL}  			<!-- IF inactive.POSTS --><br />{L_POSTS}{L_COLON} <strong>{inactive.POSTS}</strong> [<a href="{inactive.U_SEARCH_USER}">{L_SEARCH_USER_POSTS}</a>]<!-- ENDIF --> diff --git a/phpBB/adm/style/acp_language.html b/phpBB/adm/style/acp_language.html index d4fd572376..f5267e8f7f 100644 --- a/phpBB/adm/style/acp_language.html +++ b/phpBB/adm/style/acp_language.html @@ -211,7 +211,7 @@  	<p>{L_ACP_LANGUAGE_PACKS_EXPLAIN}</p> -	<table class="table1"> +	<table class="table1 zebra-table">  	<thead>  	<tr>  		<th>{L_LANGUAGE_PACK_NAME}</th> @@ -226,7 +226,7 @@  		<td class="row3" colspan="5"><strong>{L_INSTALLED_LANGUAGE_PACKS}</strong></td>  	</tr>  	<!-- BEGIN lang --> -		<!-- IF lang.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF --> +	<tr>  		<td><a href="{lang.U_DETAILS}">{lang.ENGLISH_NAME}</a> {lang.TAG}</td>  		<td>{lang.LOCAL_NAME}</td>  		<td style="text-align: center;"><strong>{lang.ISO}</strong></td> @@ -240,7 +240,7 @@  	</tr>  	<!-- ENDIF -->  	<!-- BEGIN notinst --> -		<!-- IF notinst.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF --> +	<tr>  		<td>{notinst.NAME}</td>  		<td>{notinst.LOCAL_NAME}</td>  		<td style="text-align: center;"><strong>{notinst.ISO}</strong></td> diff --git a/phpBB/adm/style/acp_logs.html b/phpBB/adm/style/acp_logs.html index f22eb67a72..592b5bbc16 100644 --- a/phpBB/adm/style/acp_logs.html +++ b/phpBB/adm/style/acp_logs.html @@ -22,7 +22,7 @@  <div><br style="clear: both;" /></div>  <!-- IF .log --> -	<table class="table1"> +	<table class="table1 zebra-table">  	<thead>  	<tr>  		<th>{L_USERNAME}</th> @@ -36,7 +36,7 @@  	</thead>  	<tbody>  	<!-- BEGIN log --> -		<!-- IF log.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF --> +		<tr>  			<td>  				{log.USERNAME}  				<!-- IF log.REPORTEE_USERNAME --> diff --git a/phpBB/adm/style/acp_main.html b/phpBB/adm/style/acp_main.html index bb39ffe050..6e28c7a0cc 100644 --- a/phpBB/adm/style/acp_main.html +++ b/phpBB/adm/style/acp_main.html @@ -26,6 +26,12 @@  		</div>  	<!-- ENDIF --> +	<!-- IF S_SEARCH_INDEX_MISSING --> +		<div class="errorbox"> +			<h3>{L_WARNING}</h3> +			<p>{L_NO_SEARCH_INDEX}</p> +		</div> +	<!-- ENDIF -->  	<!-- IF S_REMOVE_INSTALL -->  		<div class="errorbox"> @@ -216,7 +222,7 @@  		<div style="text-align: right;"><a href="{U_ADMIN_LOG}">» {L_VIEW_ADMIN_LOG}</a></div> -		<table class="table1"> +		<table class="table1 zebra-table">  		<thead>  		<tr>  			<th>{L_USERNAME}</th> @@ -227,8 +233,7 @@  		</thead>  		<tbody>  		<!-- BEGIN log --> -			<!-- IF log.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF --> - +			<tr>  				<td>{log.USERNAME}</td>  				<td style="text-align: center;">{log.IP}</td>  				<td style="text-align: center;">{log.DATE}</td> @@ -249,7 +254,7 @@  		<div style="text-align: right;"><a href="{U_INACTIVE_USERS}">» {L_VIEW_INACTIVE_USERS}</a></div> -		<table class="table1"> +		<table class="table1 zebra-table">  		<thead>  		<tr>  			<th>{L_USERNAME}</th> @@ -261,8 +266,7 @@  		</thead>  		<tbody>  		<!-- BEGIN inactive --> -			<!-- IF inactive.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF --> - +			<tr>  				<td style="vertical-align: top;">  					{inactive.USERNAME_FULL}  					<!-- IF inactive.POSTS --><br />{L_POSTS}{L_COLON} <strong>{inactive.POSTS}</strong> [<a href="{inactive.U_SEARCH_USER}">{L_SEARCH_USER_POSTS}</a>]<!-- ENDIF --> diff --git a/phpBB/adm/style/acp_modules.html b/phpBB/adm/style/acp_modules.html index 5024a950b9..c7688a610c 100644 --- a/phpBB/adm/style/acp_modules.html +++ b/phpBB/adm/style/acp_modules.html @@ -151,9 +151,9 @@  				<td style="width: 15%; white-space: nowrap; text-align: center; vertical-align: middle;"> <!-- IF modules.MODULE_ENABLED --><a href="{modules.U_DISABLE}">{L_DISABLE}</a><!-- ELSE --><a href="{modules.U_ENABLE}">{L_ENABLE}</a><!-- ENDIF --> </td>  				<td class="actions">  					<span class="up-disabled" style="display:none;">{ICON_MOVE_UP_DISABLED}</span> -					<span class="up"><a href="{modules.U_MOVE_UP}">{ICON_MOVE_UP}</a></span> +					<span class="up"><a href="{modules.U_MOVE_UP}" data-ajax="row_up">{ICON_MOVE_UP}</a></span>  					<span class="down-disabled" style="display:none;">{ICON_MOVE_DOWN_DISABLED}</span> -					<span class="down"><a href="{modules.U_MOVE_DOWN}">{ICON_MOVE_DOWN}</a></span> +					<span class="down"><a href="{modules.U_MOVE_DOWN}" data-ajax="row_down">{ICON_MOVE_DOWN}</a></span>  					<a href="{modules.U_EDIT}">{ICON_EDIT}</a>   					<a href="{modules.U_DELETE}" data-ajax="row_delete">{ICON_DELETE}</a>  				</td> diff --git a/phpBB/adm/style/acp_permission_roles.html b/phpBB/adm/style/acp_permission_roles.html index b8fdaeb837..b3137f134c 100644 --- a/phpBB/adm/style/acp_permission_roles.html +++ b/phpBB/adm/style/acp_permission_roles.html @@ -157,20 +157,11 @@  			<!-- IF roles.ROLE_DESCRIPTION --><br /><span>{roles.ROLE_DESCRIPTION}</span><!-- ENDIF -->  		</td>  		<td style="width: 30%; text-align: center; vertical-align: top; white-space: nowrap;"><!-- IF roles.U_DISPLAY_ITEMS --><a href="{roles.U_DISPLAY_ITEMS}">{L_VIEW_ASSIGNED_ITEMS}</a><!-- ELSE -->{L_VIEW_ASSIGNED_ITEMS}<!-- ENDIF --></td> -		<td style="width: 80px; text-align: right; vertical-align: top; white-space: nowrap;"> -			<!-- IF roles.S_FIRST_ROW && not roles.S_LAST_ROW --> -				{ICON_MOVE_UP_DISABLED} -				<a href="{roles.U_MOVE_DOWN}">{ICON_MOVE_DOWN}</a> -			<!-- ELSEIF not roles.S_FIRST_ROW && not roles.S_LAST_ROW--> -				<a href="{roles.U_MOVE_UP}">{ICON_MOVE_UP}</a>  -				<a href="{roles.U_MOVE_DOWN}">{ICON_MOVE_DOWN}</a>  -			<!-- ELSEIF roles.S_LAST_ROW && not roles.S_FIRST_ROW --> -				<a href="{roles.U_MOVE_UP}">{ICON_MOVE_UP}</a>	 -				{ICON_MOVE_DOWN_DISABLED} -			<!-- ELSE --> -				{ICON_MOVE_UP_DISABLED} -				{ICON_MOVE_DOWN_DISABLED} -			<!-- ENDIF -->	 +		<td class="actions"> +			<span class="up-disabled" style="display:none;">{ICON_MOVE_UP_DISABLED}</span> +			<span class="up"><a href="{roles.U_MOVE_UP}" data-ajax="row_up">{ICON_MOVE_UP}</a></span> +			<span class="down-disabled" style="display:none;">{ICON_MOVE_DOWN_DISABLED}</span> +			<span class="down"><a href="{roles.U_MOVE_DOWN}" data-ajax="row_down">{ICON_MOVE_DOWN}</a></span>  			<a href="{roles.U_EDIT}" title="{L_EDIT_ROLE}">{ICON_EDIT}</a>   			<a href="{roles.U_REMOVE}" title="{L_REMOVE_ROLE}" data-ajax="row_delete">{ICON_DELETE}</a>  		</td> diff --git a/phpBB/adm/style/acp_profile.html b/phpBB/adm/style/acp_profile.html index 3546873f6c..44c9cb6d49 100644 --- a/phpBB/adm/style/acp_profile.html +++ b/phpBB/adm/style/acp_profile.html @@ -185,7 +185,7 @@  		</div>  	<!-- ENDIF --> -	<table class="table1"> +	<table class="table1 zebra-table">  	<thead>  	<tr>  		<th>{L_FIELD_IDENT}</th> @@ -195,23 +195,16 @@  	</thead>  	<tbody>  	<!-- BEGIN fields --> -		<!-- IF fields.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF --> - +	<tr>  		<td>{fields.FIELD_IDENT}</td>  		<td>{fields.FIELD_TYPE}</td>  		<td style="text-align: center;"><a href="{fields.U_ACTIVATE_DEACTIVATE}" data-ajax="activate_deactivate">{fields.L_ACTIVATE_DEACTIVATE}</a><!-- IF fields.S_NEED_EDIT --> | <a href="{fields.U_TRANSLATE}" style="color: red;">{L_TRANSLATE}</a><!-- ENDIF --></td> -		<td style="width: 80px; text-align: right; white-space: nowrap;"> -			<!-- IF fields.S_FIRST_ROW && not fields.S_LAST_ROW --> -				{ICON_MOVE_UP_DISABLED} -				<a href="{fields.U_MOVE_DOWN}">{ICON_MOVE_DOWN}</a> -			<!-- ELSEIF not fields.S_FIRST_ROW && not fields.S_LAST_ROW--> -				<a href="{fields.U_MOVE_UP}">{ICON_MOVE_UP}</a> -				<a href="{fields.U_MOVE_DOWN}">{ICON_MOVE_DOWN}</a> -			<!-- ELSEIF fields.S_LAST_ROW && not fields.S_FIRST_ROW --> -				<a href="{fields.U_MOVE_UP}">{ICON_MOVE_UP}</a> -				{ICON_MOVE_DOWN_DISABLED} -			<!-- ENDIF --> +		<td class="actions" style="width: 80px;"> +			<span class="up-disabled" style="display:none;">{ICON_MOVE_UP_DISABLED}</span> +			<span class="up"><a href="{fields.U_MOVE_UP}" data-ajax="row_up">{ICON_MOVE_UP}</a></span> +			<span class="down-disabled" style="display:none;">{ICON_MOVE_DOWN_DISABLED}</span> +			<span class="down"><a href="{fields.U_MOVE_DOWN}" data-ajax="row_down">{ICON_MOVE_DOWN}</a></span>  			<!-- IF not fields.S_NEED_EDIT -->  				<a href="{fields.U_EDIT}">{ICON_EDIT}</a>  			<!-- ELSE --> diff --git a/phpBB/adm/style/acp_prune_forums.html b/phpBB/adm/style/acp_prune_forums.html index 1be9689cc7..4d748f1cce 100644 --- a/phpBB/adm/style/acp_prune_forums.html +++ b/phpBB/adm/style/acp_prune_forums.html @@ -8,7 +8,7 @@  	<p>{L_PRUNE_SUCCESS}</p> -	<table class="table1"> +	<table class="table1 zebra-table">  	<thead>  	<tr>  		<th>{L_FORUM}</th> @@ -18,7 +18,7 @@  	</thead>  	<tbody>  	<!-- BEGIN pruned --> -		<!-- IF pruned.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF --> +	<tr>  		<td style="text-align: center;">{pruned.FORUM_NAME}</td>  		<td style="text-align: center;">{pruned.NUM_TOPICS}</td>  		<td style="text-align: center;">{pruned.NUM_POSTS}</td> diff --git a/phpBB/adm/style/acp_ranks.html b/phpBB/adm/style/acp_ranks.html index a1409b15ef..be68dda695 100644 --- a/phpBB/adm/style/acp_ranks.html +++ b/phpBB/adm/style/acp_ranks.html @@ -65,7 +65,7 @@  	<fieldset class="tabulated">  	<legend>{L_ACP_MANAGE_RANKS}</legend> -	<table class="table1"> +	<table class="table1 zebra-table">  	<thead>  	<tr>  		<th>{L_RANK_IMAGE}</th> @@ -76,7 +76,7 @@  	</thead>  	<tbody>  	<!-- BEGIN ranks --> -		<!-- IF ranks.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF --> +	<tr>  		<td style="text-align: center;"><!-- IF ranks.S_RANK_IMAGE --><img src="{ranks.RANK_IMAGE}" alt="{ranks.RANK_TITLE}" title="{ranks.RANK_TITLE}" /><!-- ELSE -->  -  <!-- ENDIF --></td>  		<td style="text-align: center;">{ranks.RANK_TITLE}</td>  		<td style="text-align: center;"><!-- IF ranks.S_SPECIAL_RANK -->  -  <!-- ELSE -->{ranks.MIN_POSTS}<!-- ENDIF --></td> diff --git a/phpBB/adm/style/acp_reasons.html b/phpBB/adm/style/acp_reasons.html index ca3aebb338..d629a9553f 100644 --- a/phpBB/adm/style/acp_reasons.html +++ b/phpBB/adm/style/acp_reasons.html @@ -86,17 +86,11 @@  					<br /><span>{reasons.REASON_DESCRIPTION}</span>  				</td>  				<td style="width: 100px;">{reasons.REASON_COUNT}</td> -				<td style="width: 80px; text-align: right; white-space: nowrap;"> -					<!-- IF reasons.S_FIRST_ROW && not reasons.S_LAST_ROW --> -						{ICON_MOVE_UP_DISABLED} -						<a href="{reasons.U_MOVE_DOWN}">{ICON_MOVE_DOWN}</a> -					<!-- ELSEIF not reasons.S_FIRST_ROW && not reasons.S_LAST_ROW--> -						<a href="{reasons.U_MOVE_UP}">{ICON_MOVE_UP}</a>  -						<a href="{reasons.U_MOVE_DOWN}">{ICON_MOVE_DOWN}</a>  -					<!-- ELSEIF reasons.S_LAST_ROW && not reasons.S_FIRST_ROW --> -						<a href="{reasons.U_MOVE_UP}">{ICON_MOVE_UP}</a>	 -						{ICON_MOVE_DOWN_DISABLED} -					<!-- ENDIF --> +				<td class="actions" style="width: 80px;"> +					<span class="up-disabled" style="display:none;">{ICON_MOVE_UP_DISABLED}</span> +					<span class="up"><a href="{reasons.U_MOVE_UP}" data-ajax="row_up">{ICON_MOVE_UP}</a></span> +					<span class="down-disabled" style="display:none;">{ICON_MOVE_DOWN_DISABLED}</span> +					<span class="down"><a href="{reasons.U_MOVE_DOWN}" data-ajax="row_down">{ICON_MOVE_DOWN}</a></span>  					<a href="{reasons.U_EDIT}">{ICON_EDIT}</a>   					<!-- IF reasons.U_DELETE -->  						<a href="{reasons.U_DELETE}" data-ajax="row_delete">{ICON_DELETE}</a> diff --git a/phpBB/adm/style/acp_users.html b/phpBB/adm/style/acp_users.html index b213587def..b84e32013f 100644 --- a/phpBB/adm/style/acp_users.html +++ b/phpBB/adm/style/acp_users.html @@ -125,7 +125,7 @@  	<form id="user_groups" method="post" action="{U_ACTION}"> -	<table class="table1"> +	<table class="table1 zebra-table">  	<tbody>  	<!-- BEGIN group -->  		<!-- IF group.S_NEW_GROUP_TYPE --> @@ -133,7 +133,7 @@  			<td class="row3" colspan="4"><strong>{group.GROUP_TYPE}</strong></td>  		</tr>  		<!-- ELSE --> -			<!-- IF group.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF --> +			<tr>  				<td><a href="{group.U_EDIT_GROUP}">{group.GROUP_NAME}</a></td>  				<td><!-- IF group.S_IS_MEMBER --><!-- IF group.S_NO_DEFAULT --><a href="{group.U_DEFAULT}">{L_GROUP_DEFAULT}</a><!-- ELSE --><strong>{L_GROUP_DEFAULT}</strong><!-- ENDIF --><!-- ELSEIF not group.S_IS_MEMBER and group.U_APPROVE --><a href="{group.U_APPROVE}">{L_GROUP_APPROVE}</a><!-- ELSE --> <!-- ENDIF --></td>  				<td><!-- IF group.S_IS_MEMBER and not group.S_SPECIAL_GROUP --><a href="{group.U_DEMOTE_PROMOTE}">{group.L_DEMOTE_PROMOTE}</a><!-- ELSE --> <!-- ENDIF --></td> @@ -164,7 +164,7 @@  	</div>  	<!-- IF .attach --> -	<table class="table1"> +	<table class="table1 zebra-table">  	<thead>  	<tr>  		<th>{L_FILENAME}</th> @@ -176,7 +176,7 @@  	</thead>  	<tbody>  	<!-- BEGIN attach --> -		<!-- IF attach.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF --> +	<tr>  		<td><a href="{attach.U_DOWNLOAD}">{attach.REAL_FILENAME}</a><br /><span class="small"><!-- IF attach.S_IN_MESSAGE --><strong>{L_PM}{L_COLON} </strong><!-- ELSE --><strong>{L_POST}{L_COLON} </strong><!-- ENDIF --><a href="{attach.U_VIEW_TOPIC}">{attach.TOPIC_TITLE}</a></span></td>  		<td style="text-align: center">{attach.POST_TIME}</td>  		<td style="text-align: center">{attach.SIZE}</td> diff --git a/phpBB/adm/style/acp_users_feedback.html b/phpBB/adm/style/acp_users_feedback.html index 95892f2822..f251724cd2 100644 --- a/phpBB/adm/style/acp_users_feedback.html +++ b/phpBB/adm/style/acp_users_feedback.html @@ -7,7 +7,7 @@  	</div>  	<!-- IF .log --> -	<table class="table1"> +	<table class="table1 zebra-table">  	<thead>  	<tr>  		<th>{L_REPORT_BY}</th> @@ -19,8 +19,7 @@  	</thead>  	<tbody>  	<!-- BEGIN log --> -		<!-- IF log.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF --> - +		<tr>  			<td>{log.USERNAME}</td>  			<td style="text-align: center;">{log.IP}</td>  			<td style="text-align: center;">{log.DATE}</td> diff --git a/phpBB/adm/style/acp_users_signature.html b/phpBB/adm/style/acp_users_signature.html index 0a04c411d2..fff75c993d 100644 --- a/phpBB/adm/style/acp_users_signature.html +++ b/phpBB/adm/style/acp_users_signature.html @@ -49,6 +49,7 @@  		<legend>{L_SIGNATURE}</legend>  		<p>{L_SIGNATURE_EXPLAIN}</p> +		<!-- EVENT acp_users_signature_editor_buttons_before -->  		<div id="format-buttons">  			<input type="button" class="button2" accesskey="b" name="addbbcode0" value=" B " style="font-weight:bold; width: 30px" onclick="bbstyle(0)" title="{L_BBCODE_B_HELP}" />  			<input type="button" class="button2" accesskey="i" name="addbbcode2" value=" i " style="font-style:italic; width: 30px" onclick="bbstyle(2)" title="{L_BBCODE_I_HELP}" /> @@ -84,6 +85,7 @@  				<input type="button" class="button2" name="addbbcode{custom_tags.BBCODE_ID}" value="{custom_tags.BBCODE_TAG}" onclick="bbstyle({custom_tags.BBCODE_ID})" title="{custom_tags.BBCODE_HELPLINE}" />  			<!-- END custom_tags -->  		</div> +		<!-- EVENT acp_users_signature_editor_buttons_after -->  		<dl>  			<dt style="width: 90px;" id="color_palette_placeholder" data-orientation="v" data-height="12" data-width="15" data-bbcode="true"> diff --git a/phpBB/adm/style/acp_users_warnings.html b/phpBB/adm/style/acp_users_warnings.html index 9d082eda6d..6e7f521415 100644 --- a/phpBB/adm/style/acp_users_warnings.html +++ b/phpBB/adm/style/acp_users_warnings.html @@ -1,7 +1,7 @@  	<form id="list" method="post" action="{U_ACTION}">  	<!-- IF .warn --> -	<table class="table1"> +	<table class="table1 zebra-table">  	<thead>  	<tr>  		<th>{L_REPORT_BY}</th> @@ -12,7 +12,7 @@  	</thead>  	<tbody>  	<!-- BEGIN warn --> -		<!-- IF warn.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF --> +		<tr>  			<td>{warn.USERNAME}</td>  			<td style="text-align: center; nowrap: nowrap;">{warn.DATE}</td>  			<td>{warn.ACTION}</td> diff --git a/phpBB/adm/style/acp_words.html b/phpBB/adm/style/acp_words.html index 7e91bc4367..6038fc6161 100644 --- a/phpBB/adm/style/acp_words.html +++ b/phpBB/adm/style/acp_words.html @@ -47,7 +47,7 @@  		<input class="button2" name="add" type="submit" value="{L_ADD_WORD}" />  	</p> -	<table class="table1"> +	<table class="table1 zebra-table">  	<thead>  	<tr>  		<th>{L_WORD}</th> @@ -57,7 +57,7 @@  	</thead>  	<tbody>  	<!-- BEGIN words --> -		<!-- IF words.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF --> +	<tr>  		<td style="text-align: center;">{words.WORD}</td>  		<td style="text-align: center;">{words.REPLACEMENT}</td>  		<td> <a href="{words.U_EDIT}">{ICON_EDIT}</a>  <a href="{words.U_DELETE}" data-ajax="row_delete">{ICON_DELETE}</a> </td> diff --git a/phpBB/adm/style/admin.css b/phpBB/adm/style/admin.css index c4f1caf722..928479a31b 100644 --- a/phpBB/adm/style/admin.css +++ b/phpBB/adm/style/admin.css @@ -840,8 +840,14 @@ td.name {  	text-align: right;  } -.row1 { background-color: #F9F9F9; } -.row2 { background-color: #DCEBFE; } +.row1, table.zebra-table tbody tr:nth-child(odd) { +	background-color: #F9F9F9; +} + +.row2, table.zebra-table tbody tr:nth-child(even) { +	background-color: #DCEBFE; +} +  .row3 { background-color: #DBDFE2; }  .row4 { background-color: #E4E8EB; }  .col1 { background-color: #DCEBFE; } diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index 78fcbd88fd..959580d6c2 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -8,7 +8,11 @@   * an item is moved up. It moves the row up or down, and deactivates /   * activates any up / down icons that require it (the ones at the top or bottom).   */ -phpbb.addAjaxCallback('row_down', function() { +phpbb.addAjaxCallback('row_down', function(res) { +	if (typeof res.success === 'undefined' || !res.success) { +		return; +	} +  	var el = $(this),  		tr = el.parents('tr'),  		trSwap = tr.next(); @@ -16,7 +20,11 @@ phpbb.addAjaxCallback('row_down', function() {  	tr.insertAfter(trSwap);  }); -phpbb.addAjaxCallback('row_up', function() { +phpbb.addAjaxCallback('row_up', function(res) { +	if (typeof res.success === 'undefined' || !res.success) { +		return; +	} +  	var el = $(this),  		tr = el.parents('tr'),  		trSwap = tr.prev(); diff --git a/phpBB/adm/style/captcha_qa_acp.html b/phpBB/adm/style/captcha_qa_acp.html index 4ff7c328fc..6235f9a104 100644 --- a/phpBB/adm/style/captcha_qa_acp.html +++ b/phpBB/adm/style/captcha_qa_acp.html @@ -14,7 +14,7 @@  	<fieldset class="tabulated">  	<legend>{L_QUESTIONS}</legend> -	<table class="table1"> +	<table class="table1 zebra-table">  	<thead>  	<tr>  		<th colspan="3">{L_QUESTIONS}</th> @@ -27,14 +27,12 @@  	</thead>  	<tbody>  	<!-- BEGIN questions --> - -		<!-- IF questions.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF --> - +	<tr>  		<td style="text-align: left;">{questions.QUESTION_TEXT}</td>  		<td style="text-align: center;">{questions.QUESTION_LANG}</td>  		<td style="text-align: center;"><a href="{questions.U_EDIT}">{ICON_EDIT}</a> <a href="{questions.U_DELETE}">{ICON_DELETE}</a></td> -		</tr> -		<!-- END questions --> +	</tr> +	<!-- END questions -->  	</tbody>  	</table>  	<fieldset class="quick"> diff --git a/phpBB/adm/style/viewsource.html b/phpBB/adm/style/viewsource.html deleted file mode 100644 index 03e9ff50e5..0000000000 --- a/phpBB/adm/style/viewsource.html +++ /dev/null @@ -1,21 +0,0 @@ -<!-- INCLUDE simple_header.html --> -<div id="acp" style="padding: 0;"> -<div class="panel" style="padding: 10px;"> -<div style="overflow: auto;"> -	<h1>{FILENAME}</h1> - -	<table class="type2"> -	<tbody> -	<!-- BEGIN source --> -		<tr valign="top"> -			<td class="sourcenum">{source.LINENUM}  </td> -			<td class="source">{source.LINE}</td> -		</tr> -	<!-- END source --> -	</tbody> -	</table> - -</div> -</div> -</div> -<!-- INCLUDE simple_footer.html --> diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 2ad0586961..c11184d6b6 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -255,6 +255,12 @@ services:              - %tables.notifications%              - %tables.user_notifications% +    pagination: +        class: phpbb\pagination +        arguments: +            - @template +            - @user +      path_helper:          class: phpbb\path_helper          arguments: diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index 0130362131..f1df662f76 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -1,3 +1,21 @@ +acp_bbcodes_actions_append +=== +* Location: adm/style/acp_bbcodes.html +* Since: 3.1.0-a3 +* Purpose: Add actions to the BBCodes page, after edit/delete buttons + +acp_bbcodes_actions_prepend +=== +* Location: adm/style/acp_bbcodes.html +* Since: 3.1.0-a3 +* Purpose: Add actions to the BBCodes page, before edit/delete buttons + +acp_bbcodes_edit_fieldsets_after +=== +* Location: adm/style/acp_bbcodes.html +* Since: 3.1.0-a3 +* Purpose: Add settings to BBCode add/edit form +  acp_forums_normal_settings_append  ===  * Location: adm/style/acp_forums.html @@ -46,6 +64,20 @@ acp_users_overview_options_append  * Since: 3.1.0-a1  * Purpose: Add options and settings on user overview page +acp_users_signature_editor_buttons_after +=== +* Locations: +    + adm/style/acp_users_signature.html +* Since: 3.1.0-a3 +* Purpose: Add content after BBCode posting buttons in the ACP user signature + +acp_users_signature_editor_buttons_before +=== +* Locations: +    + adm/style/acp_users_signature.html +* Since: 3.1.0-a3 +* Purpose: Add content before BBCode posting buttons in the ACP user signature +  forumlist_body_last_post_title_prepend  ====  * Locations: @@ -54,13 +86,21 @@ forumlist_body_last_post_title_prepend  * Since: 3.1.0-a1  * Purpose: Add content before the post title of the latest post in a forum on the forum list. -index_body_forumlist_before +index_body_linklist_after +=== +* Locations: +    + styles/prosilver/template/index_body.html +    + styles/subsilver2/template/index_body.html +* Since: 3.1.0-a3 +* Purpose: Add content after the linklist above the forum list on Board index + +index_body_linklist_before  ===  * Locations:      + styles/prosilver/template/index_body.html      + styles/subsilver2/template/index_body.html  * Since: 3.1.0-a3 -* Purpose: Add content above the forums list (on forum index only) +* Purpose: Add content before the linklist above the forum list on Board index  index_body_stat_blocks_before  === @@ -181,6 +221,22 @@ overall_header_navigation_prepend  * Since: 3.1.0-a1  * Purpose: Add links before the navigation links in the header +posting_editor_buttons_after +=== +* Locations: +    + styles/prosilver/template/posting_buttons.html +    + styles/subsilver2/template/posting_buttons.html +* Since: 3.1.0-a3 +* Purpose: Add content after the BBCode posting buttons + +posting_editor_buttons_before +=== +* Locations: +    + styles/prosilver/template/posting_buttons.html +    + styles/subsilver2/template/posting_buttons.html +* Since: 3.1.0-a3 +* Purpose: Add content before the BBCode posting buttons +  posting_editor_message_after  ===  * Locations: diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php index 2282863746..e710260b35 100644 --- a/phpBB/includes/acp/acp_attachments.php +++ b/phpBB/includes/acp/acp_attachments.php @@ -25,7 +25,7 @@ class acp_attachments  	function main($id, $mode)  	{ -		global $db, $user, $auth, $template, $cache; +		global $db, $user, $auth, $template, $cache, $phpbb_container;  		global $config, $phpbb_admin_path, $phpbb_root_path, $phpEx;  		$user->add_lang(array('posting', 'viewtopic', 'acp/attachments')); @@ -1166,10 +1166,9 @@ class acp_attachments  				}  				// Make sure $start is set to the last page if it exceeds the amount -				if ($start < 0 || $start > $num_files) -				{ -					$start = ($start < 0) ? 0 : floor(($num_files - 1) / $attachments_per_page) * $attachments_per_page; -				} + +				$pagination = $phpbb_container->get('pagination'); +				$start = $pagination->validate_start($start, $attachments_per_page, $num_files);  				// If the user is trying to reach the second half of the attachments list, fetch it starting from the end  				$store_reverse = false; @@ -1179,15 +1178,11 @@ class acp_attachments  				{  					$store_reverse = true; -					if ($start + $attachments_per_page > $num_files) -					{ -						$sql_limit = min($attachments_per_page, max(1, $num_files - $start)); -					} -  					// Select the sort order. Add time sort anchor for non-time sorting cases  					$sql_sort_anchor = ($sort_key != 't') ? ', a.filetime ' . (($sort_dir == 'd') ? 'ASC' : 'DESC') : '';  					$sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'ASC' : 'DESC') . $sql_sort_anchor; -					$sql_start = max(0, $num_files - $sql_limit - $start); +					$sql_limit = $pagination->reverse_limit($start, $sql_limit, $num_files); +					$sql_start = $pagination->reverse_start($start, $sql_limit, $num_files);  				}  				else  				{ @@ -1195,7 +1190,6 @@ class acp_attachments  					$sql_sort_anchor = ($sort_key != 't') ? ', a.filetime ' . (($sort_dir == 'd') ? 'DESC' : 'ASC') : '';  					$sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC') . $sql_sort_anchor;  					$sql_start = $start; -  				}  				$attachments_list = array(); @@ -1222,13 +1216,13 @@ class acp_attachments  				$db->sql_freeresult($result);  				$base_url = $this->u_action . "&$u_sort_param"; -				phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $num_files, $attachments_per_page, $start); +				$pagination->generate_template_pagination($base_url, 'pagination', 'start', $num_files, $attachments_per_page, $start);  				$template->assign_vars(array(  					'TOTAL_FILES'		=> $num_files,  					'TOTAL_SIZE'		=> get_formatted_filesize($total_size), -					'S_ON_PAGE'			=> phpbb_on_page($template, $user, $base_url, $num_files, $attachments_per_page, $start), +					'S_ON_PAGE'			=> $pagination->on_page($base_url, $num_files, $attachments_per_page, $start),  					'S_LIMIT_DAYS'		=> $s_limit_days,  					'S_SORT_KEY'		=> $s_sort_key,  					'S_SORT_DIR'		=> $s_sort_dir) diff --git a/phpBB/includes/acp/acp_bbcodes.php b/phpBB/includes/acp/acp_bbcodes.php index 575ac84012..84382b6276 100644 --- a/phpBB/includes/acp/acp_bbcodes.php +++ b/phpBB/includes/acp/acp_bbcodes.php @@ -24,7 +24,7 @@ class acp_bbcodes  	function main($id, $mode)  	{ -		global $db, $user, $auth, $template, $cache, $request; +		global $db, $user, $auth, $template, $cache, $request, $phpbb_dispatcher;  		global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;  		$user->add_lang('acp/posting'); @@ -96,7 +96,7 @@ class acp_bbcodes  			case 'edit':  			case 'add': -				$template->assign_vars(array( +				$tpl_ary = array(  					'S_EDIT_BBCODE'		=> true,  					'U_BACK'			=> $this->u_action,  					'U_ACTION'			=> $this->u_action . '&action=' . (($action == 'add') ? 'create' : 'modify') . (($bbcode_id) ? "&bbcode=$bbcode_id" : ''), @@ -105,10 +105,27 @@ class acp_bbcodes  					'BBCODE_MATCH'			=> $bbcode_match,  					'BBCODE_TPL'			=> $bbcode_tpl,  					'BBCODE_HELPLINE'		=> $bbcode_helpline, -					'DISPLAY_ON_POSTING'	=> $display_on_posting) +					'DISPLAY_ON_POSTING'	=> $display_on_posting,  				);  				$bbcode_tokens = array('TEXT', 'SIMPLETEXT', 'INTTEXT', 'IDENTIFIER', 'NUMBER', 'EMAIL', 'URL', 'LOCAL_URL', 'RELATIVE_URL', 'COLOR'); + +				/** +				* Modify custom bbcode template data before we display the add/edit form +				* +				* @event core.acp_bbcodes_edit_add +				* @var	string	action			Type of the action: add|edit +				* @var	array	tpl_ary			Array with custom bbcode add/edit data +				* @var	int		bbcode_id		When editing: the bbcode id, +				*								when creating: 0 +				* @var	array	bbcode_tokens	Array of bbcode tokens +				* @since 3.1.0-a3 +				*/ +				$vars = array('action', 'tpl_ary', 'bbcode_id', 'bbcode_tokens'); +				extract($phpbb_dispatcher->trigger_event('core.acp_bbcodes_edit_add', compact($vars))); + +				$template->assign_vars($tpl_ary); +  				foreach ($bbcode_tokens as $token)  				{  					$template->assign_block_vars('token', array( @@ -124,6 +141,27 @@ class acp_bbcodes  			case 'modify':  			case 'create': +				$sql_ary = $hidden_fields = array(); +				 +				/** +				* Modify custom bbcode data before the modify/create action +				* +				* @event core.acp_bbcodes_modify_create +				* @var	string	action				Type of the action: modify|create +				* @var	array	sql_ary				Array with new bbcode data +				* @var	int		bbcode_id			When editing: the bbcode id, +				*									when creating: 0 +				* @var	bool	display_on_posting	Display bbcode on posting form +				* @var	string	bbcode_match		The bbcode usage string to match +				* @var	string	bbcode_tpl			The bbcode HTML replacement string +				* @var	string	bbcode_helpline		The bbcode help line string +				* @var	array	hidden_fields		Array of hidden fields for use when +				*									submitting form when $warn_text is true +				* @since 3.1.0-a3 +				*/ +				$vars = array('action', 'sql_ary', 'bbcode_id', 'display_on_posting', 'bbcode_match', 'bbcode_tpl', 'bbcode_helpline', 'hidden_fields'); +				extract($phpbb_dispatcher->trigger_event('core.acp_bbcodes_modify_create', compact($vars))); +  				$warn_text = preg_match('%<[^>]*\{text[\d]*\}[^>]*>%i', $bbcode_tpl);  				if (!$warn_text || confirm_box(true))  				{ @@ -178,7 +216,7 @@ class acp_bbcodes  						trigger_error($user->lang['BBCODE_HELPLINE_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING);  					} -					$sql_ary = array( +					$sql_ary = array_merge($sql_ary, array(  						'bbcode_tag'				=> $data['bbcode_tag'],  						'bbcode_match'				=> $bbcode_match,  						'bbcode_tpl'				=> $bbcode_tpl, @@ -188,7 +226,7 @@ class acp_bbcodes  						'first_pass_replace'		=> $data['first_pass_replace'],  						'second_pass_match'			=> $data['second_pass_match'],  						'second_pass_replace'		=> $data['second_pass_replace'] -					); +					));  					if ($action == 'create')  					{ @@ -244,14 +282,14 @@ class acp_bbcodes  				}  				else  				{ -					confirm_box(false, $user->lang['BBCODE_DANGER'], build_hidden_fields(array( +					confirm_box(false, $user->lang['BBCODE_DANGER'], build_hidden_fields(array_merge($hidden_fields, array(  						'action'				=> $action,  						'bbcode'				=> $bbcode_id,  						'bbcode_match'			=> $bbcode_match,  						'bbcode_tpl'			=> htmlspecialchars($bbcode_tpl),  						'bbcode_helpline'		=> $bbcode_helpline,  						'display_on_posting'	=> $display_on_posting, -						)) +						)))  					, 'confirm_bbcode.html');  				} @@ -300,22 +338,57 @@ class acp_bbcodes  			break;  		} -		$template->assign_vars(array( -			'U_ACTION'		=> $this->u_action . '&action=add') +		$u_action = $this->u_action; + +		$template_data = array( +			'U_ACTION'		=> $this->u_action . '&action=add', +		); + +		$sql_ary = array( +			'SELECT'	=> 'b.*', +			'FROM'		=> array(BBCODES_TABLE => 'b'), +			'ORDER_BY'	=> 'b.bbcode_tag',  		); -		$sql = 'SELECT * -			FROM ' . BBCODES_TABLE . ' -			ORDER BY bbcode_tag'; -		$result = $db->sql_query($sql); +		/** +		*  Modify custom bbcode template data before we display the form +		* +		* @event core.acp_bbcodes_display_form +		* @var	string	action			Type of the action: modify|create +		* @var	string	sql_ary			The SQL array to get custom bbcode data +		* @var	array	template_data	Array with form template data +		* @var	string	u_action		The u_action link +		* @since 3.1.0-a3 +		*/ +		$vars = array('action', 'sql_ary', 'template_data', 'u_action'); +		extract($phpbb_dispatcher->trigger_event('core.acp_bbcodes_display_form', compact($vars))); + +		$result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary)); + +		$template->assign_vars($template_data);  		while ($row = $db->sql_fetchrow($result))  		{ -			$template->assign_block_vars('bbcodes', array( +			$bbcodes_array = array(  				'BBCODE_TAG'		=> $row['bbcode_tag'], -				'U_EDIT'			=> $this->u_action . '&action=edit&bbcode=' . $row['bbcode_id'], -				'U_DELETE'			=> $this->u_action . '&action=delete&bbcode=' . $row['bbcode_id']) +				'U_EDIT'			=> $u_action . '&action=edit&bbcode=' . $row['bbcode_id'], +				'U_DELETE'			=> $u_action . '&action=delete&bbcode=' . $row['bbcode_id'],  			); + +			/** +			*  Modify display of custom bbcodes in the form +			* +			* @event core.acp_bbcodes_display_bbcodes +			* @var	array	row				Array with current bbcode data +			* @var	array	bbcodes_array	Array of bbcodes template data +			* @var	string	u_action		The u_action link +			* @since 3.1.0-a3 +			*/ +			$vars = array('bbcodes_array', 'row', 'u_action'); +			extract($phpbb_dispatcher->trigger_event('core.acp_bbcodes_display_bbcodes', compact($vars))); + +			$template->assign_block_vars('bbcodes', $bbcodes_array); +  		}  		$db->sql_freeresult($result);  	} diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php index c21c9f4e9d..2ff479d824 100644 --- a/phpBB/includes/acp/acp_extensions.php +++ b/phpBB/includes/acp/acp_extensions.php @@ -88,6 +88,11 @@ class acp_extensions  			break;  			case 'enable_pre': +				if (!$md_manager->validate_dir()) +				{ +					trigger_error($user->lang['EXTENSION_DIR_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); +				} +  				if (!$md_manager->validate_enable())  				{  					trigger_error($user->lang['EXTENSION_NOT_AVAILABLE'] . adm_back_link($this->u_action), E_USER_WARNING); @@ -108,6 +113,11 @@ class acp_extensions  			break;  			case 'enable': +				if (!$md_manager->validate_dir()) +				{ +					trigger_error($user->lang['EXTENSION_DIR_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); +				} +  				if (!$md_manager->validate_enable())  				{  					trigger_error($user->lang['EXTENSION_NOT_AVAILABLE'] . adm_back_link($this->u_action), E_USER_WARNING); diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index b36ea1a8d8..ec78e0b32b 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -676,6 +676,7 @@ class acp_groups  				}  				$this->page_title = 'GROUP_MEMBERS'; +				$pagination = $phpbb_container->get('pagination');  				// Grab the leaders - always, on every page...  				$sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_regdate, u.user_colour, u.user_posts, u.group_id, ug.group_leader, ug.user_pending @@ -719,14 +720,14 @@ class acp_groups  				}  				$base_url = $this->u_action . "&action=$action&g=$group_id"; -				phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $total_members, $config['topics_per_page'], $start); +				$pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_members, $config['topics_per_page'], $start);  				$template->assign_vars(array(  					'S_LIST'			=> true,  					'S_GROUP_SPECIAL'	=> ($group_row['group_type'] == GROUP_SPECIAL) ? true : false,  					'S_ACTION_OPTIONS'	=> $s_action_options, -					'S_ON_PAGE'		=> phpbb_on_page($template, $user, $base_url, $total_members, $config['topics_per_page'], $start), +					'S_ON_PAGE'		=> $pagination->on_page($base_url, $total_members, $config['topics_per_page'], $start),  					'GROUP_NAME'	=> ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'],  					'U_ACTION'			=> $this->u_action . "&g=$group_id", diff --git a/phpBB/includes/acp/acp_icons.php b/phpBB/includes/acp/acp_icons.php index 658be4cc6b..20b1f56182 100644 --- a/phpBB/includes/acp/acp_icons.php +++ b/phpBB/includes/acp/acp_icons.php @@ -27,7 +27,7 @@ class acp_icons  	{  		global $db, $user, $auth, $template, $cache;  		global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; -		global $request; +		global $request, $phpbb_container;  		$user->add_lang('acp/posting'); @@ -832,9 +832,10 @@ class acp_icons  					WHERE {$fields}_order = $switch_order_id  						AND {$fields}_id <> $icon_id";  				$db->sql_query($sql); +				$move_executed = (bool) $db->sql_affectedrows();  				// Only update the other entry too if the previous entry got updated -				if ($db->sql_affectedrows()) +				if ($move_executed)  				{  					$sql = "UPDATE $table  						SET {$fields}_order = $switch_order_id @@ -846,6 +847,14 @@ class acp_icons  				$cache->destroy('_icons');  				$cache->destroy('sql', $table); +				if ($request->is_ajax()) +				{ +					$json_response = new \phpbb\json_response; +					$json_response->send(array( +						'success'	=> $move_executed, +					)); +				} +  			break;  		} @@ -893,6 +902,7 @@ class acp_icons  		);  		$spacer = false; +		$pagination = $phpbb_container->get('pagination');  		$pagination_start = request_var('start', 0);  		$item_count = $this->item_count($table); @@ -927,7 +937,7 @@ class acp_icons  		}  		$db->sql_freeresult($result); -		phpbb_generate_template_pagination($template, $this->u_action, 'pagination', 'start', $item_count, $config['smilies_per_page'], $pagination_start); +		$pagination->generate_template_pagination($this->u_action, 'pagination', 'start', $item_count, $config['smilies_per_page'], $pagination_start);  	}  	/** diff --git a/phpBB/includes/acp/acp_inactive.php b/phpBB/includes/acp/acp_inactive.php index de4679b58d..305ba9ac69 100644 --- a/phpBB/includes/acp/acp_inactive.php +++ b/phpBB/includes/acp/acp_inactive.php @@ -30,7 +30,7 @@ class acp_inactive  	function main($id, $mode)  	{ -		global $config, $db, $user, $auth, $template; +		global $config, $db, $user, $auth, $template, $phpbb_container;  		global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix;  		include($phpbb_root_path . 'includes/functions_user.' . $phpEx); @@ -49,6 +49,7 @@ class acp_inactive  		$form_key = 'acp_inactive';  		add_form_key($form_key); +		$pagination = $phpbb_container->get('pagination');  		// We build the sort key and per page settings here, because they may be needed later @@ -285,7 +286,7 @@ class acp_inactive  		}  		$base_url = $this->u_action . "&$u_sort_param&users_per_page=$per_page"; -		phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $inactive_count, $per_page, $start); +		$pagination->generate_template_pagination($base_url, 'pagination', 'start', $inactive_count, $per_page, $start);  		$template->assign_vars(array(  			'S_INACTIVE_USERS'		=> true, @@ -294,7 +295,7 @@ class acp_inactive  			'S_LIMIT_DAYS'	=> $s_limit_days,  			'S_SORT_KEY'	=> $s_sort_key,  			'S_SORT_DIR'	=> $s_sort_dir, -			'S_ON_PAGE'		=> phpbb_on_page($template, $user, $base_url, $inactive_count, $per_page, $start), +			'S_ON_PAGE'		=> $pagination->on_page($base_url, $inactive_count, $per_page, $start),  			'USERS_PER_PAGE'	=> $per_page,  			'U_ACTION'		=> $this->u_action . "&$u_sort_param&users_per_page=$per_page&start=$start", diff --git a/phpBB/includes/acp/acp_logs.php b/phpBB/includes/acp/acp_logs.php index 229bf135ff..0ffea2737b 100644 --- a/phpBB/includes/acp/acp_logs.php +++ b/phpBB/includes/acp/acp_logs.php @@ -24,7 +24,7 @@ class acp_logs  	function main($id, $mode)  	{ -		global $db, $user, $auth, $template, $cache; +		global $db, $user, $auth, $template, $cache, $phpbb_container;  		global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;  		global $request; @@ -46,6 +46,7 @@ class acp_logs  		$this->tpl_name = 'acp_logs';  		$this->log_type = constant('LOG_' . strtoupper($mode)); +		$pagination = $phpbb_container->get('pagination');  		// Delete entries if requested and able  		if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs')) @@ -130,14 +131,14 @@ class acp_logs  		$start = view_log($mode, $log_data, $log_count, $config['topics_per_page'], $start, $forum_id, 0, 0, $sql_where, $sql_sort, $keywords);  		$base_url = $this->u_action . "&$u_sort_param$keywords_param"; -		phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start); +		$pagination->generate_template_pagination($base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start);  		$template->assign_vars(array(  			'L_TITLE'		=> $l_title,  			'L_EXPLAIN'		=> $l_title_explain,  			'U_ACTION'		=> $this->u_action . "&$u_sort_param$keywords_param&start=$start", -			'S_ON_PAGE'		=> phpbb_on_page($template, $user, $base_url, $log_count, $config['topics_per_page'], $start), +			'S_ON_PAGE'		=> $pagination->on_page($base_url, $log_count, $config['topics_per_page'], $start),  			'S_LIMIT_DAYS'	=> $s_limit_days,  			'S_SORT_KEY'	=> $s_sort_key, diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index eecd8c72dc..f01cba0bcc 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -620,6 +620,22 @@ class acp_main  			$template->assign_var('S_REMOVE_INSTALL', true);  		} +		// Warn if no search index is created +		if ($config['num_posts'] && class_exists($config['search_type'])) +		{ +			$error = false; +			$search_type = $config['search_type']; +			$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user); + +			if (!$search->index_created()) +			{ +				$template->assign_vars(array( +					'S_SEARCH_INDEX_MISSING'	=> true, +					'L_NO_SEARCH_INDEX'			=> $user->lang('NO_SEARCH_INDEX', $search->get_name(), '<a href="' . append_sid("{$phpbb_admin_path}index.$phpEx", 'i=acp_search&mode=index') . '">', '</a>'), +				)); +			} +		} +  		if (!defined('PHPBB_DISABLE_CONFIG_CHECK') && file_exists($phpbb_root_path . 'config.' . $phpEx) && phpbb_is_writable($phpbb_root_path . 'config.' . $phpEx))  		{  			// World-Writable? (000x) diff --git a/phpBB/includes/acp/acp_modules.php b/phpBB/includes/acp/acp_modules.php index 100e33044b..c124377ba9 100644 --- a/phpBB/includes/acp/acp_modules.php +++ b/phpBB/includes/acp/acp_modules.php @@ -170,6 +170,14 @@ class acp_modules  					$this->remove_cache_file();  				} +				if ($request->is_ajax()) +				{ +					$json_response = new \phpbb\json_response; +					$json_response->send(array( +						'success'	=> ($move_module_name !== false), +					)); +				} +  			break;  			case 'quickadd': diff --git a/phpBB/includes/acp/acp_permission_roles.php b/phpBB/includes/acp/acp_permission_roles.php index 17e48d6576..aca45575d3 100644 --- a/phpBB/includes/acp/acp_permission_roles.php +++ b/phpBB/includes/acp/acp_permission_roles.php @@ -27,6 +27,7 @@ class acp_permission_roles  	{  		global $db, $user, $auth, $template, $cache, $phpbb_container;  		global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; +		global $request;  		include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx);  		include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx); @@ -46,6 +47,11 @@ class acp_permission_roles  		$form_name = 'acp_permissions';  		add_form_key($form_name); +		if (!$role_id && in_array($action, array('remove', 'edit', 'move_up', 'move_down'))) +		{ +			trigger_error($user->lang['NO_ROLE_SELECTED'] . adm_back_link($this->u_action), E_USER_WARNING); +		} +  		switch ($mode)  		{  			case 'admin_roles': @@ -85,11 +91,6 @@ class acp_permission_roles  			{  				case 'remove': -					if (!$role_id) -					{ -						trigger_error($user->lang['NO_ROLE_SELECTED'] . adm_back_link($this->u_action), E_USER_WARNING); -					} -  					$sql = 'SELECT *  						FROM ' . ACL_ROLES_TABLE . '  						WHERE role_id = ' . $role_id; @@ -123,10 +124,6 @@ class acp_permission_roles  				break;  				case 'edit': -					if (!$role_id) -					{ -						trigger_error($user->lang['NO_ROLE_SELECTED'] . adm_back_link($this->u_action), E_USER_WARNING); -					}  					// Get role we edit  					$sql = 'SELECT * @@ -273,12 +270,7 @@ class acp_permission_roles  			case 'edit':  				if ($action == 'edit') -				{ -					if (!$role_id) -					{ -						trigger_error($user->lang['NO_ROLE_SELECTED'] . adm_back_link($this->u_action), E_USER_WARNING); -					} -					 +				{					  					$sql = 'SELECT *  						FROM ' . ACL_ROLES_TABLE . '  						WHERE role_id = ' . $role_id; @@ -366,7 +358,18 @@ class acp_permission_roles  			case 'move_up':  			case 'move_down': -				$order = request_var('order', 0); +				$sql = 'SELECT role_order +					FROM ' . ACL_ROLES_TABLE . " +					WHERE role_id = $role_id"; +				$result = $db->sql_query($sql); +				$order = $db->sql_fetchfield('role_order'); +				$db->sql_freeresult($result); + +				if ($order === false || ($order == 0 && $action == 'move_up')) +				{ +					break; +				} +				$order = (int) $order;  				$order_total = $order * 2 + (($action == 'move_up') ? -1 : 1);  				$sql = 'UPDATE ' . ACL_ROLES_TABLE . ' @@ -375,6 +378,14 @@ class acp_permission_roles  						AND role_order IN ($order, " . (($action == 'move_up') ? $order - 1 : $order + 1) . ')';  				$db->sql_query($sql); +				if ($request->is_ajax()) +				{ +					$json_response = new \phpbb\json_response; +					$json_response->send(array( +						'success'	=> (bool) $db->sql_affectedrows(), +					)); +				} +  			break;  		} @@ -421,8 +432,8 @@ class acp_permission_roles  				'U_EDIT'			=> $this->u_action . '&action=edit&role_id=' . $row['role_id'],  				'U_REMOVE'			=> $this->u_action . '&action=remove&role_id=' . $row['role_id'], -				'U_MOVE_UP'			=> $this->u_action . '&action=move_up&order=' . $row['role_order'], -				'U_MOVE_DOWN'		=> $this->u_action . '&action=move_down&order=' . $row['role_order'], +				'U_MOVE_UP'			=> $this->u_action . '&action=move_up&role_id=' . $row['role_id'], +				'U_MOVE_DOWN'		=> $this->u_action . '&action=move_down&role_id=' . $row['role_id'],  				'U_DISPLAY_ITEMS'	=> ($row['role_id'] == $display_item) ? '' : $this->u_action . '&display_item=' . $row['role_id'] . '#assigned_to')  			); diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php index 4e8145009f..6efd778b12 100644 --- a/phpBB/includes/acp/acp_profile.php +++ b/phpBB/includes/acp/acp_profile.php @@ -39,11 +39,17 @@ class acp_profile  		$this->tpl_name = 'acp_profile';  		$this->page_title = 'ACP_CUSTOM_PROFILE_FIELDS'; +		$field_id = $request->variable('field_id', 0);  		$action = (isset($_POST['create'])) ? 'create' : request_var('action', '');  		$error = array();  		$s_hidden_fields = ''; +		if (!$field_id && in_array($action, array('delete','activate', 'deactivate', 'move_up', 'move_down', 'edit'))) +		{ +			trigger_error($user->lang['NO_FIELD_ID'] . adm_back_link($this->u_action), E_USER_WARNING); +		} +  		// Define some default values for each field type  		$default_values = array(  			FIELD_STRING	=> array('field_length' => 10, 'field_minlen' => 0, 'field_maxlen' => 20, 'field_validation' => '.*', 'field_novalue' => '', 'field_default_value' => ''), @@ -98,12 +104,6 @@ class acp_profile  		switch ($action)  		{  			case 'delete': -				$field_id = request_var('field_id', 0); - -				if (!$field_id) -				{ -					trigger_error($user->lang['NO_FIELD_ID'] . adm_back_link($this->u_action), E_USER_WARNING); -				}  				if (confirm_box(true))  				{ @@ -210,12 +210,6 @@ class acp_profile  			break;  			case 'activate': -				$field_id = request_var('field_id', 0); - -				if (!$field_id) -				{ -					trigger_error($user->lang['NO_FIELD_ID'] . adm_back_link($this->u_action), E_USER_WARNING); -				}  				$sql = 'SELECT lang_id  					FROM ' . LANG_TABLE . " @@ -256,12 +250,6 @@ class acp_profile  			break;  			case 'deactivate': -				$field_id = request_var('field_id', 0); - -				if (!$field_id) -				{ -					trigger_error($user->lang['NO_FIELD_ID'] . adm_back_link($this->u_action), E_USER_WARNING); -				}  				$sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . "  					SET field_active = 0 @@ -291,7 +279,19 @@ class acp_profile  			case 'move_up':  			case 'move_down': -				$field_order = request_var('order', 0); + +				$sql = 'SELECT field_order +					FROM ' . PROFILE_FIELDS_TABLE . " +					WHERE field_id = $field_id"; +				$result = $db->sql_query($sql); +				$field_order = $db->sql_fetchfield('field_order'); +				$db->sql_freeresult($result); + +				if ($field_order === false || ($field_order == 0 && $action == 'move_up')) +				{ +					break; +				} +				$field_order = (int) $field_order;  				$order_total = $field_order * 2 + (($action == 'move_up') ? -1 : 1);  				$sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . " @@ -299,12 +299,19 @@ class acp_profile  					WHERE field_order IN ($field_order, " . (($action == 'move_up') ? $field_order - 1 : $field_order + 1) . ')';  				$db->sql_query($sql); +				if ($request->is_ajax()) +				{ +					$json_response = new \phpbb\json_response; +					$json_response->send(array( +						'success'	=> (bool) $db->sql_affectedrows(), +					)); +				} +  			break;  			case 'create':  			case 'edit': -				$field_id = request_var('field_id', 0);  				$step = request_var('step', 1);  				$submit = (isset($_REQUEST['next']) || isset($_REQUEST['prev'])) ? true : false; @@ -316,11 +323,6 @@ class acp_profile  				// We are editing... we need to grab basic things  				if ($action == 'edit')  				{ -					if (!$field_id) -					{ -						trigger_error($user->lang['NO_FIELD_ID'] . adm_back_link($this->u_action), E_USER_WARNING); -					} -  					$sql = 'SELECT l.*, f.*  						FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . ' f  						WHERE l.lang_id = ' . $this->edit_lang_id . " @@ -919,8 +921,8 @@ class acp_profile  				'U_EDIT'					=> $this->u_action . "&action=edit&field_id=$id",  				'U_TRANSLATE'				=> $this->u_action . "&action=edit&field_id=$id&step=3",  				'U_DELETE'					=> $this->u_action . "&action=delete&field_id=$id", -				'U_MOVE_UP'					=> $this->u_action . "&action=move_up&order={$row['field_order']}", -				'U_MOVE_DOWN'				=> $this->u_action . "&action=move_down&order={$row['field_order']}", +				'U_MOVE_UP'					=> $this->u_action . "&action=move_up&field_id=$id", +				'U_MOVE_DOWN'				=> $this->u_action . "&action=move_down&field_id=$id",  				'S_NEED_EDIT'				=> $s_need_edit)  			); diff --git a/phpBB/includes/acp/acp_reasons.php b/phpBB/includes/acp/acp_reasons.php index 71e9108c2c..569bb73ab0 100644 --- a/phpBB/includes/acp/acp_reasons.php +++ b/phpBB/includes/acp/acp_reasons.php @@ -26,6 +26,7 @@ class acp_reasons  	{  		global $db, $user, $auth, $template, $cache;  		global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; +		global $request;  		$user->add_lang(array('mcp', 'acp/posting')); @@ -280,7 +281,18 @@ class acp_reasons  			case 'move_up':  			case 'move_down': -				$order = request_var('order', 0); +				$sql = 'SELECT reason_order +					FROM ' . REPORTS_REASONS_TABLE . " +					WHERE reason_id = $reason_id"; +				$result = $db->sql_query($sql); +				$order = $db->sql_fetchfield('reason_order'); +				$db->sql_freeresult($result); + +				if ($order === false || ($order == 0 && $action == 'move_up')) +				{ +					break; +				} +				$order = (int) $order;  				$order_total = $order * 2 + (($action == 'move_up') ? -1 : 1);  				$sql = 'UPDATE ' . REPORTS_REASONS_TABLE . ' @@ -288,6 +300,13 @@ class acp_reasons  					WHERE reason_order IN (' . $order . ', ' . (($action == 'move_up') ? $order - 1 : $order + 1) . ')';  				$db->sql_query($sql); +				if ($request->is_ajax()) +				{ +					$json_response = new \phpbb\json_response; +					$json_response->send(array( +						'success'	=> (bool) $db->sql_affectedrows(), +					)); +				}  			break;  		} @@ -363,8 +382,8 @@ class acp_reasons  				'U_EDIT'		=> $this->u_action . '&action=edit&id=' . $row['reason_id'],  				'U_DELETE'		=> (!$other_reason) ? $this->u_action . '&action=delete&id=' . $row['reason_id'] : '', -				'U_MOVE_UP'		=> $this->u_action . '&action=move_up&order=' . $row['reason_order'], -				'U_MOVE_DOWN'	=> $this->u_action . '&action=move_down&order=' . $row['reason_order']) +				'U_MOVE_UP'		=> $this->u_action . '&action=move_up&id=' . $row['reason_id'], +				'U_MOVE_DOWN'	=> $this->u_action . '&action=move_down&id=' . $row['reason_id'])  			);  		}  		$db->sql_freeresult($result); diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 1a7bc2d186..b24adfc586 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1096,6 +1096,7 @@ class acp_users  				$deleteall	= (isset($_POST['delall'])) ? true : false;  				$marked		= request_var('mark', array(0));  				$message	= utf8_normalize_nfc(request_var('message', '', true)); +				$pagination = $phpbb_container->get('pagination');  				// Sort keys  				$sort_days	= request_var('st', 0); @@ -1166,11 +1167,11 @@ class acp_users  				$start = view_log('user', $log_data, $log_count, $config['topics_per_page'], $start, 0, 0, $user_id, $sql_where, $sql_sort);  				$base_url = $this->u_action . "&u=$user_id&$u_sort_param"; -				phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start); +				$pagination->generate_template_pagination($base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start);  				$template->assign_vars(array(  					'S_FEEDBACK'	=> true, -					'S_ON_PAGE'		=> phpbb_on_page($template, $user, $base_url, $log_count, $config['topics_per_page'], $start), +					'S_ON_PAGE'		=> $pagination->on_page($base_url, $log_count, $config['topics_per_page'], $start),  					'S_LIMIT_DAYS'	=> $s_limit_days,  					'S_SORT_KEY'	=> $s_sort_key, @@ -1998,6 +1999,7 @@ class acp_users  				$start		= request_var('start', 0);  				$deletemark = (isset($_POST['delmarked'])) ? true : false;  				$marked		= request_var('mark', array(0)); +				$pagination = $phpbb_container->get('pagination');  				// Sort keys  				$sort_key	= request_var('sk', 'a'); @@ -2134,11 +2136,11 @@ class acp_users  				$db->sql_freeresult($result);  				$base_url = $this->u_action . "&u=$user_id&sk=$sort_key&sd=$sort_dir"; -				phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $num_attachments, $config['topics_per_page'], $start); +				$pagination->generate_template_pagination($base_url, 'pagination', 'start', $num_attachments, $config['topics_per_page'], $start);  				$template->assign_vars(array(  					'S_ATTACHMENTS'		=> true, -					'S_ON_PAGE'			=> phpbb_on_page($template, $user, $base_url, $num_attachments, $config['topics_per_page'], $start), +					'S_ON_PAGE'			=> $pagination->on_page($base_url, $num_attachments, $config['topics_per_page'], $start),  					'S_SORT_KEY'		=> $s_sort_key,  					'S_SORT_DIR'		=> $s_sort_dir,  				)); diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index cc8478ace1..916c3799c2 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2205,225 +2205,6 @@ function tracking_unserialize($string, $max_depth = 3)  	return $level;  } -// Pagination functions -/** -* Generate a pagination link based on the url and the page information -* -* @param string $base_url is url prepended to all links generated within the function -*							If you use page numbers inside your controller route, base_url should contains a placeholder (%d) -*							for the page. Also be sure to specify the pagination path information into the start_name argument -* @param string $on_page is the page for which we want to generate the link -* @param string $start_name is the name of the parameter containing the first item of the given page (example: start=20) -*							If you use page numbers inside your controller route, start name should be the string -*							that should be removed for the first page (example: /page/%d) -* @param int $per_page the number of items, posts, etc. to display per page, used to determine the number of pages to produce -* @return URL for the requested page -*/ -function phpbb_generate_page_link($base_url, $on_page, $start_name, $per_page) -{ - -	if (strpos($start_name, '%d') !== false) -	{ -		return ($on_page > 1) ? sprintf($base_url, (int) $on_page) : str_replace($start_name, '', $base_url); -	} -	else -	{ -		$url_delim = (strpos($base_url, '?') === false) ? '?' : ((strpos($base_url, '?') === strlen($base_url) - 1) ? '' : '&'); -		return ($on_page > 1) ? $base_url . $url_delim . $start_name . '=' . (($on_page - 1) * $per_page) : $base_url; -	} -} - -/** -* Generate template rendered pagination -* Allows full control of rendering of pagination with the template -* -* @param object $template the template object -* @param string $base_url is url prepended to all links generated within the function -*							If you use page numbers inside your controller route, base_url should contains a placeholder (%d) -*							for the page. Also be sure to specify the pagination path information into the start_name argument -* @param string $block_var_name is the name assigned to the pagination data block within the template (example: <!-- BEGIN pagination -->) -* @param string $start_name is the name of the parameter containing the first item of the given page (example: start=20) -*							If you use page numbers inside your controller route, start name should be the string -*							that should be removed for the first page (example: /page/%d) -* @param int $num_items the total number of items, posts, etc., used to determine the number of pages to produce -* @param int $per_page the number of items, posts, etc. to display per page, used to determine the number of pages to produce -* @param int $start_item the item which should be considered currently active, used to determine the page we're on -* @param bool $reverse_count determines whether we weight display of the list towards the start (false) or end (true) of the list -* @param bool $ignore_on_page decides whether we enable an active (unlinked) item, used primarily for embedded lists -* @return null -*/ -function phpbb_generate_template_pagination($template, $base_url, $block_var_name, $start_name, $num_items, $per_page, $start_item = 1, $reverse_count = false, $ignore_on_page = false) -{ -	// Make sure $per_page is a valid value -	$per_page = ($per_page <= 0) ? 1 : $per_page; -	$total_pages = ceil($num_items / $per_page); - -	if ($total_pages == 1 || !$num_items) -	{ -		return; -	} - -	$on_page = floor($start_item / $per_page) + 1; - -	if ($reverse_count) -	{ -		$start_page = ($total_pages > 5) ? $total_pages - 4 : 1; -		$end_page = $total_pages; -	} -	else -	{ -		// What we're doing here is calculating what the "start" and "end" pages should be. We -		// do this by assuming pagination is "centered" around the currently active page with -		// the three previous and three next page links displayed. Anything more than that and -		// we display the ellipsis, likewise anything less. -		// -		// $start_page is the page at which we start creating the list. When we have five or less -		// pages we start at page 1 since there will be no ellipsis displayed. Anymore than that -		// and we calculate the start based on the active page. This is the min/max calculation. -		// First (max) would we end up starting on a page less than 1? Next (min) would we end -		// up starting so close to the end that we'd not display our minimum number of pages. -		// -		// $end_page is the last page in the list to display. Like $start_page we use a min/max to -		// determine this number. Again at most five pages? Then just display them all. More than -		// five and we first (min) determine whether we'd end up listing more pages than exist. -		// We then (max) ensure we're displaying the minimum number of pages. -		$start_page = ($total_pages > 5) ? min(max(1, $on_page - 3), $total_pages - 4) : 1; -		$end_page = ($total_pages > 5) ? max(min($total_pages, $on_page + 3), 5) : $total_pages; -	} - -	$u_previous_page = $u_next_page = ''; -	if ($on_page != 1) -	{ -		$u_previous_page = phpbb_generate_page_link($base_url, $on_page - 1, $start_name, $per_page); - -		$template->assign_block_vars($block_var_name, array( -			'PAGE_NUMBER'	=> '', -			'PAGE_URL'		=> $u_previous_page, -			'S_IS_CURRENT'	=> false, -			'S_IS_PREV'		=> true, -			'S_IS_NEXT'		=> false, -			'S_IS_ELLIPSIS'	=> false, -		)); -	} - -	// This do...while exists purely to negate the need for start and end assign_block_vars, i.e. -	// to display the first and last page in the list plus any ellipsis. We use this loop to jump -	// around a little within the list depending on where we're starting (and ending). -	$at_page = 1; -	do -	{ -		// We decide whether to display the ellipsis during the loop. The ellipsis is always -		// displayed as either the second or penultimate item in the list. So are we at either -		// of those points and of course do we even need to display it, i.e. is the list starting -		// on at least page 3 and ending three pages before the final item. -		$template->assign_block_vars($block_var_name, array( -			'PAGE_NUMBER'	=> $at_page, -			'PAGE_URL'		=> phpbb_generate_page_link($base_url, $at_page, $start_name, $per_page), -			'S_IS_CURRENT'	=> (!$ignore_on_page && $at_page == $on_page), -			'S_IS_NEXT'		=> false, -			'S_IS_PREV'		=> false, -			'S_IS_ELLIPSIS'	=> ($at_page == 2 && $start_page > 2) || ($at_page == $total_pages - 1 && $end_page < $total_pages - 1), -		)); - -		// We may need to jump around in the list depending on whether we have or need to display -		// the ellipsis. Are we on page 2 and are we more than one page away from the start -		// of the list? Yes? Then we jump to the start of the list. Likewise are we at the end of -		// the list and are there more than two pages left in total? Yes? Then jump to the penultimate -		// page (so we can display the ellipsis next pass). Else, increment the counter and keep -		// going -		if ($at_page == 2 && $at_page < $start_page - 1) -		{ -			$at_page = $start_page; -		} -		else if ($at_page == $end_page && $end_page < $total_pages - 1) -		{ -			$at_page = $total_pages - 1; -		} -		else -		{ -			$at_page++; -		} -	} -	while ($at_page <= $total_pages); - -	if ($on_page != $total_pages) -	{ -		$u_next_page = phpbb_generate_page_link($base_url, $on_page + 1, $start_name, $per_page); - -		$template->assign_block_vars($block_var_name, array( -			'PAGE_NUMBER'	=> '', -			'PAGE_URL'		=> $u_next_page, -			'S_IS_CURRENT'	=> false, -			'S_IS_PREV'		=> false, -			'S_IS_NEXT'		=> true, -			'S_IS_ELLIPSIS'	=> false, -		)); -	} - -	// If the block_var_name is a nested block, we will use the last (most -	// inner) block as a prefix for the template variables. If the last block -	// name is pagination, the prefix is empty. If the rest of the -	// block_var_name is not empty, we will modify the last row of that block -	// and add our pagination items. -	$tpl_block_name = $tpl_prefix = ''; -	if (strrpos($block_var_name, '.') !== false) -	{ -		$tpl_block_name = substr($block_var_name, 0, strrpos($block_var_name, '.')); -		$tpl_prefix = strtoupper(substr($block_var_name, strrpos($block_var_name, '.') + 1)); -	} -	else -	{ -		$tpl_prefix = strtoupper($block_var_name); -	} -	$tpl_prefix = ($tpl_prefix == 'PAGINATION') ? '' : $tpl_prefix . '_'; - -	$template_array = array( -		$tpl_prefix . 'BASE_URL'		=> $base_url, -		$tpl_prefix . 'PER_PAGE'		=> $per_page, -		'U_' . $tpl_prefix . 'PREVIOUS_PAGE'	=> ($on_page != 1) ? $u_previous_page : '', -		'U_' . $tpl_prefix . 'NEXT_PAGE'		=> ($on_page != $total_pages) ? $u_next_page : '', -		$tpl_prefix . 'TOTAL_PAGES'		=> $total_pages, -		$tpl_prefix . 'CURRENT_PAGE'	=> $on_page, -	); - -	if ($tpl_block_name) -	{ -		$template->alter_block_array($tpl_block_name, $template_array, true, 'change'); -	} -	else -	{ -		$template->assign_vars($template_array); -	} -} - -/** -* Return current page -* This function also sets certain specific template variables -* -* @param object $template the template object -* @param object $user the user object -* @param string $base_url the base url used to call this page, used by Javascript for popup jump to page -* @param int $num_items the total number of items, posts, topics, etc. -* @param int $per_page the number of items, posts, etc. per page -* @param int $start the item which should be considered currently active, used to determine the page we're on -* @return null -*/ -function phpbb_on_page($template, $user, $base_url, $num_items, $per_page, $start) -{ -	// Make sure $per_page is a valid value -	$per_page = ($per_page <= 0) ? 1 : $per_page; - -	$on_page = floor($start / $per_page) + 1; - -	$template->assign_vars(array( -		'PER_PAGE'		=> $per_page, -		'ON_PAGE'		=> $on_page, -		'BASE_URL'		=> $base_url, -	)); - -	return sprintf($user->lang['PAGE_OF'], $on_page, max(ceil($num_items / $per_page), 1)); -} -  // Server functions (building urls, redirecting...)  /** @@ -5274,7 +5055,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0  	}  	$hidden_fields_for_jumpbox = phpbb_build_hidden_fields_for_query_params($request, array('f')); - +	$notification_mark_hash = generate_link_hash('mark_all_notifications_read');  	// The following assigns all _common_ variables that may be used at any point in a template.  	$template->assign_vars(array( @@ -5294,6 +5075,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0  		'UNREAD_NOTIFICATIONS_COUNT'	=> ($notifications !== false) ? $notifications['unread_count'] : '',  		'NOTIFICATIONS_COUNT'			=> ($notifications !== false) ? $notifications['unread_count'] : '',  		'U_VIEW_ALL_NOTIFICATIONS'		=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=ucp_notifications'), +		'U_MARK_ALL_NOTIFICATIONS'		=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=ucp_notifications&mode=notification_list&mark=all&token=' . $notification_mark_hash),  		'U_NOTIFICATION_SETTINGS'		=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=ucp_notifications&mode=notification_options'),  		'S_NOTIFICATIONS_DISPLAY'		=> $config['load_notifications'], diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 0ff842ea6a..e663ac90c5 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -919,7 +919,7 @@ function topic_status(&$topic_row, $replies, $unread_topic, &$folder_img, &$fold  /**  * Assign/Build custom bbcodes for display in screens supporting using of bbcodes -* The custom bbcodes buttons will be placed within the template block 'custom_codes' +* The custom bbcodes buttons will be placed within the template block 'custom_tags'  */  function display_custom_bbcodes()  { @@ -928,11 +928,26 @@ function display_custom_bbcodes()  	// Start counting from 22 for the bbcode ids (every bbcode takes two ids - opening/closing)  	$num_predefined_bbcodes = 22; -	$sql = 'SELECT bbcode_id, bbcode_tag, bbcode_helpline -		FROM ' . BBCODES_TABLE . ' -		WHERE display_on_posting = 1 -		ORDER BY bbcode_tag'; -	$result = $db->sql_query($sql); +	$sql_ary = array( +		'SELECT'	=> 'b.bbcode_id, b.bbcode_tag, b.bbcode_helpline', +		'FROM'		=> array(BBCODES_TABLE => 'b'), +		'WHERE'		=> 'b.display_on_posting = 1', +		'ORDER_BY'	=> 'b.bbcode_tag', +	); + +	/** +	* Event to modify the SQL query before custom bbcode data is queried +	* +	* @event core.display_custom_bbcodes_modify_sql +	* @var	array	sql_ary					The SQL array to get the bbcode data +	* @var	int		num_predefined_bbcodes	The number of predefined core bbcodes +	*										(multiplied by factor of 2) +	* @since 3.1.0-a3 +	*/ +	$vars = array('sql_ary', 'num_predefined_bbcodes'); +	extract($phpbb_dispatcher->trigger_event('core.display_custom_bbcodes_modify_sql', compact($vars))); + +	$result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary));  	$i = 0;  	while ($row = $db->sql_fetchrow($result)) @@ -952,7 +967,7 @@ function display_custom_bbcodes()  		);  		/** -		* Modify the template data block of a bbcode +		* Event to modify the template data block of a custom bbcode  		*  		* This event is triggered once per bbcode  		* diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 1bcef7f1f2..172f4403ac 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1473,7 +1473,7 @@ function delete_post($forum_id, $topic_id, $post_id, &$data, $is_soft = false, $  */  function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $update_message = true, $update_search_index = true)  { -	global $db, $auth, $user, $config, $phpEx, $template, $phpbb_root_path, $phpbb_container; +	global $db, $auth, $user, $config, $phpEx, $template, $phpbb_root_path, $phpbb_container, $phpbb_dispatcher;  	// We do not handle erasing posts here  	if ($mode == 'delete') @@ -2305,6 +2305,23 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u  	$url = (!$params) ? "{$phpbb_root_path}viewforum.$phpEx" : "{$phpbb_root_path}viewtopic.$phpEx";  	$url = append_sid($url, 'f=' . $data['forum_id'] . $params) . $add_anchor; +	/** +	* This event is used for performing actions directly after a post or topic +	* has been submitted. When a new topic is posted, the topic ID is +	* available in the $data array. +	* +	* The only action that can be done by altering data made available to this +	* event is to modify the return URL ($url). +	* +	* @event core.submit_post_end +	* @var	string		url						The "Return to topic" URL +	* @var	array		data					Array of post data about the +	*											submitted post +	* @since 3.1-A3 +	*/ +	$vars = array('url', 'data'); +	extract($phpbb_dispatcher->trigger_event('core.submit_post_end', compact($vars))); +  	return $url;  } diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index d0d13aaf13..a3b2184d48 100644 --- a/phpBB/includes/mcp/mcp_forum.php +++ b/phpBB/includes/mcp/mcp_forum.php @@ -73,6 +73,8 @@ function mcp_forum_view($id, $mode, $action, $forum_info)  		break;  	} +	$pagination = $phpbb_container->get('pagination'); +  	$selected_ids = '';  	if (sizeof($post_id_list) && $action != 'merge_topics')  	{ @@ -102,7 +104,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info)  	$limit_time_sql = ($sort_days) ? 'AND t.topic_last_post_time >= ' . (time() - ($sort_days * 86400)) : '';  	$base_url = $url . "&i=$id&action=$action&mode=$mode&sd=$sort_dir&sk=$sort_key&st=$sort_days" . (($merge_select) ? $selected_ids : ''); -	phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $forum_topics, $topics_per_page, $start); +	$pagination->generate_template_pagination($base_url, 'pagination', 'start', $forum_topics, $topics_per_page, $start);  	$template->assign_vars(array(  		'ACTION'				=> $action, @@ -133,7 +135,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info)  		'S_MCP_ACTION'			=> $url . "&i=$id&forum_action=$action&mode=$mode&start=$start" . (($merge_select) ? $selected_ids : ''), -		'PAGE_NUMBER'			=> phpbb_on_page($template, $user, $base_url, $forum_topics, $topics_per_page, $start), +		'PAGE_NUMBER'			=> $pagination->on_page($base_url, $forum_topics, $topics_per_page, $start),  		'TOTAL_TOPICS'			=> $user->lang('VIEW_FORUM_TOPICS', (int) $forum_topics),  	)); diff --git a/phpBB/includes/mcp/mcp_logs.php b/phpBB/includes/mcp/mcp_logs.php index f706840492..ac7896606a 100644 --- a/phpBB/includes/mcp/mcp_logs.php +++ b/phpBB/includes/mcp/mcp_logs.php @@ -33,7 +33,7 @@ class mcp_logs  	function main($id, $mode)  	{  		global $auth, $db, $user, $template; -		global $config, $phpbb_root_path, $phpEx; +		global $config, $phpbb_root_path, $phpEx, $phpbb_container;  		$user->add_lang('acp/common'); @@ -62,6 +62,8 @@ class mcp_logs  		$this->tpl_name = 'mcp_logs';  		$this->page_title = 'MCP_LOGS'; +		$pagination = $phpbb_container->get('pagination'); +  		$forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_')));  		$forum_list[] = 0; @@ -172,10 +174,10 @@ class mcp_logs  		$start = view_log('mod', $log_data, $log_count, $config['topics_per_page'], $start, $forum_list, $topic_id, 0, $sql_where, $sql_sort, $keywords);  		$base_url = $this->u_action . "&$u_sort_param$keywords_param"; -		phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start); +		$pagination->generate_template_pagination($base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start);  		$template->assign_vars(array( -			'PAGE_NUMBER'		=> phpbb_on_page($template, $user, $base_url, $log_count, $config['topics_per_page'], $start), +			'PAGE_NUMBER'		=> $pagination->on_page($base_url, $log_count, $config['topics_per_page'], $start),  			'TOTAL'				=> $user->lang('TOTAL_LOGS', (int) $log_count),  			'L_TITLE'			=> $user->lang['MCP_LOGS'], diff --git a/phpBB/includes/mcp/mcp_notes.php b/phpBB/includes/mcp/mcp_notes.php index 12fcbfe91e..055ca0e882 100644 --- a/phpBB/includes/mcp/mcp_notes.php +++ b/phpBB/includes/mcp/mcp_notes.php @@ -72,7 +72,7 @@ class mcp_notes  	function mcp_notes_user_view($action)  	{  		global $phpEx, $phpbb_root_path, $config; -		global $template, $db, $user, $auth; +		global $template, $db, $user, $auth, $phpbb_container;  		$user_id = request_var('u', 0);  		$username = request_var('username', '', true); @@ -80,6 +80,7 @@ class mcp_notes  		$st	= request_var('st', 0);  		$sk	= request_var('sk', 'b');  		$sd	= request_var('sd', 'd'); +		$pagination = $phpbb_container->get('pagination');  		add_form_key('mcp_notes'); @@ -216,7 +217,7 @@ class mcp_notes  		}  		$base_url = $this->u_action . "&$u_sort_param$keywords_param"; -		phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start); +		$pagination->generate_template_pagination($base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start);  		$template->assign_vars(array(  			'U_POST_ACTION'			=> $this->u_action, @@ -228,7 +229,7 @@ class mcp_notes  			'L_TITLE'			=> $user->lang['MCP_NOTES_USER'], -			'PAGE_NUMBER'		=> phpbb_on_page($template, $user, $base_url, $log_count, $config['topics_per_page'], $start), +			'PAGE_NUMBER'		=> $pagination->on_page($base_url, $log_count, $config['topics_per_page'], $start),  			'TOTAL_REPORTS'		=> $user->lang('LIST_REPORTS', (int) $log_count),  			'RANK_TITLE'		=> $rank_title, diff --git a/phpBB/includes/mcp/mcp_pm_reports.php b/phpBB/includes/mcp/mcp_pm_reports.php index f0452b37a5..d0801a2b47 100644 --- a/phpBB/includes/mcp/mcp_pm_reports.php +++ b/phpBB/includes/mcp/mcp_pm_reports.php @@ -39,6 +39,7 @@ class mcp_pm_reports  		include_once($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx);  		$start = request_var('start', 0); +		$pagination = $phpbb_container->get('pagination');  		$this->page_title = 'MCP_PM_REPORTS'; @@ -297,7 +298,7 @@ class mcp_pm_reports  				}  				$base_url = $this->u_action . "&st=$sort_days&sk=$sort_key&sd=$sort_dir"; -				phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $total, $config['topics_per_page'], $start); +				$pagination->generate_template_pagination($base_url, 'pagination', 'start', $total, $config['topics_per_page'], $start);  				// Now display the page  				$template->assign_vars(array( @@ -308,7 +309,7 @@ class mcp_pm_reports  					'S_MCP_ACTION'			=> $this->u_action,  					'S_CLOSED'				=> ($mode == 'pm_reports_closed') ? true : false, -					'PAGE_NUMBER'			=> phpbb_on_page($template, $user, $base_url, $total, $config['topics_per_page'], $start), +					'PAGE_NUMBER'			=> $pagination->on_page($base_url, $total, $config['topics_per_page'], $start),  					'TOTAL'					=> $total,  					'TOTAL_REPORTS'			=> $user->lang('LIST_REPORTS', (int) $total),  					) diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 0318bc5e15..9f9c22a5c5 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -337,6 +337,7 @@ class mcp_queue  				$topic_id = $request->variable('t', 0);  				$forum_info = array(); +				$pagination = $phpbb_container->get('pagination');  				if ($topic_id)  				{ @@ -532,7 +533,7 @@ class mcp_queue  				unset($rowset, $forum_names);  				$base_url = $this->u_action . "&f=$forum_id&st=$sort_days&sk=$sort_key&sd=$sort_dir"; -				phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $total, $config['topics_per_page'], $start); +				$pagination->generate_template_pagination($base_url, 'pagination', 'start', $total, $config['topics_per_page'], $start);  				// Now display the page  				$template->assign_vars(array( @@ -546,7 +547,7 @@ class mcp_queue  					'S_TOPICS'				=> $is_topics,  					'S_RESTORE'				=> $is_restore, -					'PAGE_NUMBER'			=> phpbb_on_page($template, $user, $base_url, $total, $config['topics_per_page'], $start), +					'PAGE_NUMBER'			=> $pagination->on_page($base_url, $total, $config['topics_per_page'], $start),  					'TOPIC_ID'				=> $topic_id,  					'TOTAL'					=> $user->lang(((!$is_topics) ? 'VIEW_TOPIC_POSTS' : 'VIEW_FORUM_TOPICS'), (int) $total),  				)); @@ -653,6 +654,11 @@ class mcp_queue  				// Handle notifications  				foreach ($post_info as $post_id => $post_data)  				{ +					// A single topic approval may also happen here, so handle deleting the respective notification. +					if (!$post_data['topic_posts_approved']) +					{ +						$phpbb_notifications->delete_notifications('topic_in_queue', $post_data['topic_id']); +					}  					$phpbb_notifications->delete_notifications('post_in_queue', $post_id);  					$phpbb_notifications->add_notifications(array( @@ -772,9 +778,12 @@ class mcp_queue  			$notify_poster = ($action == 'approve' && isset($_REQUEST['notify_poster'])) ? true : false;  			$phpbb_content_visibility = $phpbb_container->get('content.visibility'); +			$first_post_ids = array(); +  			foreach ($topic_info as $topic_id => $topic_data)  			{  				$phpbb_content_visibility->set_topic_visibility(ITEM_APPROVED, $topic_id, $topic_data['forum_id'], $user->data['user_id'], time(), ''); +				$first_post_ids[$topic_id] = (int) $topic_data['topic_first_post_id'];  				$topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f={$topic_data['forum_id']}&t={$topic_id}"); @@ -798,23 +807,43 @@ class mcp_queue  			// Only send out the mails, when the posts are being approved  			if ($action == 'approve')  			{ +				// Grab the first post text as it's needed for the quote notification. +				$sql = 'SELECT topic_id, post_text +					FROM ' . POSTS_TABLE . ' +					WHERE ' . $db->sql_in_set('post_id', $first_post_ids); +				$result = $db->sql_query($sql); + +				while ($row = $db->sql_fetchrow($result)) +				{ +					$topic_info[$row['topic_id']]['post_text'] = $row['post_text']; +				} +				$db->sql_freeresult($result); +  				// Handle notifications  				$phpbb_notifications = $phpbb_container->get('notification_manager');  				foreach ($topic_info as $topic_id => $topic_data)  				{ -					$phpbb_notifications->delete_notifications('topic_in_queue', $post_data['topic_id']); +					$topic_data = array_merge($topic_data, array( +						'post_id'		=> $topic_data['topic_first_post_id'], +						'post_subject'	=> $topic_data['topic_title'], +						'post_time'		=> $topic_data['topic_time'], +						'poster_id'		=> $topic_data['topic_poster'], +						'username'		=> $topic_data['topic_first_poster_name'], +					)); + +					$phpbb_notifications->delete_notifications('topic_in_queue', $topic_id);  					$phpbb_notifications->add_notifications(array(  						'quote',  						'topic', -					), $post_data); +					), $topic_data); -					$phpbb_notifications->mark_notifications_read('quote', $post_data['post_id'], $user->data['user_id']); -					$phpbb_notifications->mark_notifications_read('topic', $post_data['topic_id'], $user->data['user_id']); +					$phpbb_notifications->mark_notifications_read('quote', $topic_data['post_id'], $user->data['user_id']); +					$phpbb_notifications->mark_notifications_read('topic', $topic_id, $user->data['user_id']);  					if ($notify_poster)  					{ -						$phpbb_notifications->add_notifications('approve_topic', $post_data); +						$phpbb_notifications->add_notifications('approve_topic', $topic_data);  					}  				}  			} diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index 8db5bb9727..954f8a8349 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -315,6 +315,7 @@ class mcp_reports  				$forum_list[] = 0;  				$forum_data = array(); +				$pagination = $phpbb_container->get('pagination');  				$forum_options = '<option value="0"' . (($forum_id == 0) ? ' selected="selected"' : '') . '>' . $user->lang['ALL_FORUMS'] . '</option>';  				foreach ($forum_list_reports as $row) @@ -410,7 +411,7 @@ class mcp_reports  				}  				$base_url = $this->u_action . "&f=$forum_id&t=$topic_id&st=$sort_days&sk=$sort_key&sd=$sort_dir"; -				phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $total, $config['topics_per_page'], $start); +				$pagination->generate_template_pagination($base_url, 'pagination', 'start', $total, $config['topics_per_page'], $start);  				// Now display the page  				$template->assign_vars(array( @@ -422,7 +423,7 @@ class mcp_reports  					'S_FORUM_OPTIONS'		=> $forum_options,  					'S_CLOSED'				=> ($mode == 'reports_closed') ? true : false, -					'PAGE_NUMBER'			=> phpbb_on_page($template, $user, $base_url, $total, $config['topics_per_page'], $start), +					'PAGE_NUMBER'			=> $pagination->on_page($base_url, $total, $config['topics_per_page'], $start),  					'TOPIC_ID'				=> $topic_id,  					'TOTAL'					=> $total,  					'TOTAL_REPORTS'			=> $user->lang('LIST_REPORTS', (int) $total), @@ -615,23 +616,25 @@ function close_report($report_id_list, $mode, $action, $pm = false)  		}  		unset($close_report_posts, $close_report_topics); +		$phpbb_notifications = $phpbb_container->get('notification_manager'); +  		foreach ($reports as $report)  		{  			if ($pm)  			{  				add_log('mod', 0, 0, 'LOG_PM_REPORT_' .  strtoupper($action) . 'D', $post_info[$report['pm_id']]['message_subject']); +				$phpbb_notifications->delete_notifications('report_pm', $report['pm_id']);  			}  			else  			{  				add_log('mod', $post_info[$report['post_id']]['forum_id'], $post_info[$report['post_id']]['topic_id'], 'LOG_REPORT_' .  strtoupper($action) . 'D', $post_info[$report['post_id']]['post_subject']); +				$phpbb_notifications->delete_notifications('report_post', $report['post_id']);  			}  		}  		// Notify reporters  		if (sizeof($notify_reporters))  		{ -			$phpbb_notifications = $phpbb_container->get('notification_manager'); -  			foreach ($notify_reporters as $report_id => $reporter)  			{  				if ($reporter['user_id'] == ANONYMOUS) @@ -648,8 +651,6 @@ function close_report($report_id_list, $mode, $action, $pm = false)  						'closer_id'			=> $user->data['user_id'],  						'from_user_id'		=> $post_info[$post_id]['author_id'],  					))); - -					$phpbb_notifications->delete_notifications('report_pm', $post_id);  				}  				else  				{ @@ -657,8 +658,6 @@ function close_report($report_id_list, $mode, $action, $pm = false)  						'reporter'			=> $reporter['user_id'],  						'closer_id'			=> $user->data['user_id'],  					))); - -					$phpbb_notifications->delete_notifications('report_post', $post_id);  				}  			}  		} diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php index a2aa03c583..a4c561a3bf 100644 --- a/phpBB/includes/mcp/mcp_topic.php +++ b/phpBB/includes/mcp/mcp_topic.php @@ -26,6 +26,7 @@ function mcp_topic_view($id, $mode, $action)  	$url = append_sid("{$phpbb_root_path}mcp.$phpEx?" . extra_url());  	$user->add_lang('viewtopic'); +	$pagination = $phpbb_container->get('pagination');  	$topic_id = request_var('t', 0);  	$topic_info = get_topic_data(array($topic_id), false, true); @@ -129,12 +130,7 @@ function mcp_topic_view($id, $mode, $action)  	{  		$start = 0;  	} - -	// Make sure $start is set to the last page if it exceeds the amount -	if ($start < 0 || $start >= $total) -	{ -		$start = ($start < 0) ? 0 : floor(($total - 1) / $posts_per_page) * $posts_per_page; -	} +	$start = $pagination->validate_start($start, $posts_per_page, $total);  	$sql = 'SELECT u.username, u.username_clean, u.user_colour, p.*  		FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u @@ -304,7 +300,7 @@ function mcp_topic_view($id, $mode, $action)  	$base_url = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&t={$topic_info['topic_id']}&mode=$mode&action=$action&to_topic_id=$to_topic_id&posts_per_page=$posts_per_page&st=$sort_days&sk=$sort_key&sd=$sort_dir");  	if ($posts_per_page)  	{ -		phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $total, $posts_per_page, $start); +		$pagination->generate_template_pagination($base_url, 'pagination', 'start', $total, $posts_per_page, $start);  	}  	$template->assign_vars(array( @@ -347,7 +343,7 @@ function mcp_topic_view($id, $mode, $action)  		'RETURN_TOPIC'		=> sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f={$topic_info['forum_id']}&t={$topic_info['topic_id']}&start=$start") . '">', '</a>'),  		'RETURN_FORUM'		=> sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", "f={$topic_info['forum_id']}&start=$start") . '">', '</a>'), -		'PAGE_NUMBER'		=> phpbb_on_page($template, $user, $base_url, $total, $posts_per_page, $start), +		'PAGE_NUMBER'		=> $pagination->on_page($base_url, $total, $posts_per_page, $start),  		'TOTAL_POSTS'		=> $user->lang('VIEW_TOPIC_POSTS', (int) $total),  	));  } diff --git a/phpBB/includes/mcp/mcp_warn.php b/phpBB/includes/mcp/mcp_warn.php index 3ffd75ac78..e39bddec5b 100644 --- a/phpBB/includes/mcp/mcp_warn.php +++ b/phpBB/includes/mcp/mcp_warn.php @@ -134,10 +134,11 @@ class mcp_warn  	*/  	function mcp_warn_list_view($action)  	{ -		global $phpEx, $phpbb_root_path, $config; +		global $phpEx, $phpbb_root_path, $config, $phpbb_container;  		global $template, $db, $user, $auth;  		$user->add_lang('memberlist'); +		$pagination = $phpbb_container->get('pagination');  		$start	= request_var('start', 0);  		$st		= request_var('st', 0); @@ -176,7 +177,7 @@ class mcp_warn  		}  		$base_url = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=warn&mode=list&st=$st&sk=$sk&sd=$sd"); -		phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $user_count, $config['topics_per_page'], $start); +		$pagination->generate_template_pagination($base_url, 'pagination', 'start', $user_count, $config['topics_per_page'], $start);  		$template->assign_vars(array(  			'U_POST_ACTION'			=> $this->u_action, @@ -185,7 +186,7 @@ class mcp_warn  			'S_SELECT_SORT_KEY'		=> $s_sort_key,  			'S_SELECT_SORT_DAYS'	=> $s_limit_days, -			'PAGE_NUMBER'		=> phpbb_on_page($template, $user, $base_url, $user_count, $config['topics_per_page'], $start), +			'PAGE_NUMBER'		=> $pagination->on_page($base_url, $user_count, $config['topics_per_page'], $start),  			'TOTAL_USERS'		=> $user->lang('LIST_USERS', (int) $user_count),  		));  	} diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index acd31fd519..b29f587385 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -103,6 +103,8 @@ class bbcode_firstpass extends bbcode  	*/  	function bbcode_init($allow_custom_bbcode = true)  	{ +		global $phpbb_dispatcher; +		  		static $rowset;  		// This array holds all bbcode data. BBCodes will be processed in this @@ -162,6 +164,21 @@ class bbcode_firstpass extends bbcode  				'regexp'	=> array($row['first_pass_match'] => str_replace('$uid', $this->bbcode_uid, $row['first_pass_replace']))  			);  		} + +		$bbcodes = $this->bbcodes; + +		/** +		* Event to modify the bbcode data for later parsing +		* +		* @event core.modify_bbcode_init +		* @var array	bbcodes		Array of bbcode data for use in parsing +		* @var array	rowset		Array of bbcode data from the database +		* @since 3.1.0-a3 +		*/ +		$vars = array('bbcodes', 'rowset'); +		extract($phpbb_dispatcher->trigger_event('core.modify_bbcode_init', compact($vars))); + +		$this->bbcodes = $bbcodes;  	}  	/** @@ -1198,6 +1215,8 @@ class parse_message extends bbcode_firstpass  	*/  	function format_display($allow_bbcode, $allow_magic_url, $allow_smilies, $update_this_message = true)  	{ +		global $phpbb_dispatcher; +  		// If false, then the parsed message get returned but internal message not processed.  		if (!$update_this_message)  		{ @@ -1226,6 +1245,28 @@ class parse_message extends bbcode_firstpass  		$this->message = bbcode_nl2br($this->message);  		$this->message = smiley_text($this->message, !$allow_smilies); +		$text = $this->message; +		$uid = $this->bbcode_uid; + +		/** +		* Event to modify the text after it is parsed +		* +		* @event core.modify_format_display_text_after +		* @var string	text				The message text to parse +		* @var string	uid					The bbcode uid +		* @var bool		allow_bbcode		Do we allow bbcodes +		* @var bool		allow_magic_url		Do we allow magic urls +		* @var bool		allow_smilies		Do we allow smilies +		* @var bool		update_this_message	Do we update the internal message +		*									with the parsed result +		* @since 3.1.0-a3 +		*/ +		$vars = array('text', 'uid', 'allow_bbcode', 'allow_magic_url', 'allow_smilies', 'update_this_message'); +		extract($phpbb_dispatcher->trigger_event('core.modify_format_display_text_after', compact($vars))); + +		$this->message = $text; +		$this->bbcode_uid = $uid; +  		if (!$update_this_message)  		{  			unset($this->message); diff --git a/phpBB/includes/ucp/ucp_attachments.php b/phpBB/includes/ucp/ucp_attachments.php index dc095e7b73..e687ee9cdc 100644 --- a/phpBB/includes/ucp/ucp_attachments.php +++ b/phpBB/includes/ucp/ucp_attachments.php @@ -26,7 +26,7 @@ class ucp_attachments  	function main($id, $mode)  	{ -		global $template, $user, $db, $config, $phpEx, $phpbb_root_path; +		global $template, $user, $db, $config, $phpEx, $phpbb_root_path, $phpbb_container;  		$start		= request_var('start', 0);  		$sort_key	= request_var('sk', 'a'); @@ -119,6 +119,10 @@ class ucp_attachments  		$num_attachments = $db->sql_fetchfield('num_attachments');  		$db->sql_freeresult($result); +		// Ensure start is a valid value +		$pagination = $phpbb_container->get('pagination'); +		$start = $pagination->validate_start($start, $config['topics_per_page'], $num_attachments); +  		$sql = 'SELECT a.*, t.topic_title, p.message_subject as message_title  			FROM ' . ATTACHMENTS_TABLE . ' a  				LEFT JOIN ' . TOPICS_TABLE . ' t ON (a.topic_id = t.topic_id AND a.in_message = 0) @@ -171,10 +175,10 @@ class ucp_attachments  		$db->sql_freeresult($result);  		$base_url = $this->u_action . "&sk=$sort_key&sd=$sort_dir"; -		phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $num_attachments, $config['topics_per_page'], $start); +		$pagination->generate_template_pagination($base_url, 'pagination', 'start', $num_attachments, $config['topics_per_page'], $start);  		$template->assign_vars(array( -			'PAGE_NUMBER'			=> phpbb_on_page($template, $user, $base_url, $num_attachments, $config['topics_per_page'], $start), +			'PAGE_NUMBER'			=> $pagination->on_page($base_url, $num_attachments, $config['topics_per_page'], $start),  			'TOTAL_ATTACHMENTS'		=> $num_attachments,  			'L_TITLE'				=> $user->lang['UCP_ATTACHMENTS'], diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php index 7c4bc8f617..a17c87e5a1 100644 --- a/phpBB/includes/ucp/ucp_groups.php +++ b/phpBB/includes/ucp/ucp_groups.php @@ -813,13 +813,15 @@ class ucp_groups  							$s_action_options .= '<option value="' . $option . '">' . $user->lang['GROUP_' . $lang] . '</option>';  						} +						$pagination = $phpbb_container->get('pagination');  						$base_url = $this->u_action . "&action=$action&g=$group_id"; -						phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $total_members, $config['topics_per_page'], $start); +						$start = $pagination->validate_start($start, $config['topics_per_page'], $total_members); +						$pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_members, $config['topics_per_page'], $start);  						$template->assign_vars(array(  							'S_LIST'			=> true,  							'S_ACTION_OPTIONS'	=> $s_action_options, -							'S_ON_PAGE'			=> phpbb_on_page($template, $user, $base_url, $total_members, $config['topics_per_page'], $start), +							'S_ON_PAGE'			=> $pagination->on_page($template, $user, $base_url, $total_members, $config['topics_per_page'], $start),  							'U_ACTION'			=> $this->u_action . "&g=$group_id",  							'S_UCP_ACTION'		=> $this->u_action . "&g=$group_id", diff --git a/phpBB/includes/ucp/ucp_main.php b/phpBB/includes/ucp/ucp_main.php index b859413d92..b9f951ace6 100644 --- a/phpBB/includes/ucp/ucp_main.php +++ b/phpBB/includes/ucp/ucp_main.php @@ -646,6 +646,7 @@ class ucp_main  		$table = ($mode == 'subscribed') ? TOPICS_WATCH_TABLE : BOOKMARKS_TABLE;  		$start = request_var('start', 0); +		$pagination = $phpbb_container->get('pagination');  		// Grab icons  		$icons = $cache->obtain_icons(); @@ -669,10 +670,11 @@ class ucp_main  		if ($topics_count)  		{ -			phpbb_generate_template_pagination($template, $this->u_action, 'pagination', 'start', $topics_count, $config['topics_per_page'], $start); +			$start = $pagination->validate_start($start, $config['topics_per_page'], $topics_count); +			$pagination->generate_template_pagination($this->u_action, 'pagination', 'start', $topics_count, $config['topics_per_page'], $start);  			$template->assign_vars(array( -				'PAGE_NUMBER'	=> phpbb_on_page($template, $user, $this->u_action, $topics_count, $config['topics_per_page'], $start), +				'PAGE_NUMBER'	=> $pagination->on_page($this->u_action, $topics_count, $config['topics_per_page'], $start),  				'TOTAL_TOPICS'	=> $user->lang('VIEW_FORUM_TOPICS', (int) $topics_count),  			));  		} @@ -839,7 +841,7 @@ class ucp_main  				'U_VIEW_FORUM'			=> append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id),  			)); -			phpbb_generate_template_pagination($template, append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . "&t=$topic_id"), 'topicrow.pagination', 'start', $replies + 1, $config['posts_per_page'], 1, true, true); +			$pagination->generate_template_pagination(append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . "&t=$topic_id"), 'topicrow.pagination', 'start', $replies + 1, $config['posts_per_page'], 1, true, true);  		}  	}  } diff --git a/phpBB/includes/ucp/ucp_notifications.php b/phpBB/includes/ucp/ucp_notifications.php index 63dbe79666..c5963a1ebc 100644 --- a/phpBB/includes/ucp/ucp_notifications.php +++ b/phpBB/includes/ucp/ucp_notifications.php @@ -31,6 +31,7 @@ class ucp_notifications  		$form_time = ($form_time <= 0 || $form_time > time()) ? time() : $form_time;  		$phpbb_notifications = $phpbb_container->get('notification_manager'); +		$pagination = $phpbb_container->get('pagination');  		switch ($mode)  		{ @@ -97,7 +98,19 @@ class ucp_notifications  						$phpbb_notifications->mark_notifications_read(false, false, $user->data['user_id'], $form_time);  						meta_refresh(3, $this->u_action); -						$message = $user->lang['NOTIFICATIONS_MARK_ALL_READ_SUCCESS'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); +						$message = $user->lang['NOTIFICATIONS_MARK_ALL_READ_SUCCESS']; +						 +						if ($request->is_ajax()) +						{ +							$json_response = new \phpbb\json_response(); +							$json_response->send(array( +								'MESSAGE_TITLE'	=> $user->lang['INFORMATION'], +								'MESSAGE_TEXT'	=> $message, +								'success'		=> true, +							)); +						} +						$message .= '<br /><br />' . $user->lang('RETURN_UCP', '<a href="' . $this->u_action . '">', '</a>'); +  						trigger_error($message);  					}  					else @@ -137,10 +150,11 @@ class ucp_notifications  				}  				$base_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=ucp_notifications&mode=notification_list"); -				phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $notifications['total_count'], $config['topics_per_page'], $start); +				$start = $pagination->validate_start($start, $config['topics_per_page'], $notifications['total_count']); +				$pagination->generate_template_pagination($base_url, 'pagination', 'start', $notifications['total_count'], $config['topics_per_page'], $start);  				$template->assign_vars(array( -					'PAGE_NUMBER'	=> phpbb_on_page($template, $user, $base_url, $notifications['total_count'], $config['topics_per_page'], $start), +					'PAGE_NUMBER'	=> $pagination->on_page($base_url, $notifications['total_count'], $config['topics_per_page'], $start),  					'TOTAL_COUNT'	=> $notifications['total_count'],  					'U_MARK_ALL'	=> $base_url . '&mark=all&token=' . generate_link_hash('mark_all_notifications_read'),  				)); diff --git a/phpBB/includes/ucp/ucp_pm_viewfolder.php b/phpBB/includes/ucp/ucp_pm_viewfolder.php index 9393e65f3c..0ea94835f2 100644 --- a/phpBB/includes/ucp/ucp_pm_viewfolder.php +++ b/phpBB/includes/ucp/ucp_pm_viewfolder.php @@ -393,7 +393,7 @@ function view_folder($id, $mode, $folder_id, $folder)  */  function get_pm_from($folder_id, $folder, $user_id)  { -	global $user, $db, $template, $config, $auth, $phpbb_root_path, $phpEx; +	global $user, $db, $template, $config, $auth, $phpbb_container, $phpbb_root_path, $phpEx;  	$start = request_var('start', 0); @@ -402,6 +402,8 @@ function get_pm_from($folder_id, $folder, $user_id)  	$sort_key	= request_var('sk', 't');  	$sort_dir	= request_var('sd', 'd'); +	$pagination = $phpbb_container->get('pagination'); +  	// PM ordering options  	$limit_days = array(0 => $user->lang['ALL_MESSAGES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']); @@ -452,10 +454,11 @@ function get_pm_from($folder_id, $folder, $user_id)  	}  	$base_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&mode=view&action=view_folder&f=$folder_id&$u_sort_param"); -	phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $pm_count, $config['topics_per_page'], $start); +	$start = $pagination->validate_start($start, $config['topics_per_page'], $pm_count); +	$pagination->generate_template_pagination($base_url, 'pagination', 'start', $pm_count, $config['topics_per_page'], $start);  	$template->assign_vars(array( -		'PAGE_NUMBER'		=> phpbb_on_page($template, $user, $base_url, $pm_count, $config['topics_per_page'], $start), +		'PAGE_NUMBER'		=> $pagination->on_page($base_url, $pm_count, $config['topics_per_page'], $start),  		'TOTAL_MESSAGES'	=> $user->lang('VIEW_PM_MESSAGES', (int) $pm_count),  		'POST_IMG'		=> (!$auth->acl_get('u_sendpm')) ? $user->img('button_topic_locked', 'POST_PM_LOCKED') : $user->img('button_pm_new', 'POST_NEW_PM'), @@ -481,14 +484,10 @@ function get_pm_from($folder_id, $folder, $user_id)  	{  		$store_reverse = true; -		if ($start + $config['topics_per_page'] > $pm_count) -		{ -			$sql_limit = min($config['topics_per_page'], max(1, $pm_count - $start)); -		} -  		// Select the sort order  		$direction = ($sort_dir == 'd') ? 'ASC' : 'DESC'; -		$sql_start = max(0, $pm_count - $sql_limit - $start); +		$sql_limit = $pagination->reverse_limit($start, $sql_limit, $pm_count); +		$sql_start = $pagination->reverse_start($start, $sql_limit, $pm_count);  	}  	else  	{ diff --git a/phpBB/index.php b/phpBB/index.php index 74fc1b9bda..e3cae26779 100644 --- a/phpBB/index.php +++ b/phpBB/index.php @@ -27,24 +27,44 @@ $user->setup('viewforum');  // Mark notifications read  if (($mark_notification = $request->variable('mark_notification', 0)))  { -	$phpbb_notifications = $phpbb_container->get('notification_manager'); - -	$notification = $phpbb_notifications->load_notifications(array( -		'notification_id'	=> $mark_notification -	)); +	if ($user->data['user_id'] == ANONYMOUS) +	{ +		if ($request->is_ajax()) +		{ +			trigger_error('LOGIN_REQUIRED'); +		} +		login_box('', $user->lang['LOGIN_REQUIRED']); +	} -	if (isset($notification['notifications'][$mark_notification])) +	if (check_link_hash($request->variable('hash', ''), 'mark_notification_read'))  	{ -		$notification = $notification['notifications'][$mark_notification]; +		$phpbb_notifications = $phpbb_container->get('notification_manager'); -		$notification->mark_read(); +		$notification = $phpbb_notifications->load_notifications(array( +			'notification_id'	=> $mark_notification, +		)); -		if (($redirect = $request->variable('redirect', ''))) +		if (isset($notification['notifications'][$mark_notification]))  		{ -			redirect(append_sid($phpbb_root_path . $redirect)); -		} +			$notification = $notification['notifications'][$mark_notification]; + +			$notification->mark_read(); + +			if ($request->is_ajax()) +			{ +				$json_response = new \phpbb\json_response(); +				$json_response->send(array( +					'success'	=> true, +				)); +			} -		redirect($notification->get_url()); +			if (($redirect = $request->variable('redirect', ''))) +			{ +				redirect(append_sid($phpbb_root_path . $redirect)); +			} + +			redirect($notification->get_url()); +		}  	}  } diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index 77a7618ce0..0117d85433 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -361,6 +361,7 @@ $lang = array_merge($lang, array(  	'GZIP_COMPRESSION'	=> 'GZip compression', +	'NO_SEARCH_INDEX'	=> 'The selected search backend does not have a search index.<br >Please create the index for “%1$s” in the %2$ssearch index%3$s section.',  	'NOT_AVAILABLE'		=> 'Not available',  	'NUMBER_FILES'		=> 'Number of attachments',  	'NUMBER_POSTS'		=> 'Number of posts', diff --git a/phpBB/language/en/acp/extensions.php b/phpBB/language/en/acp/extensions.php index 8279a68022..67b34ff0c7 100644 --- a/phpBB/language/en/acp/extensions.php +++ b/phpBB/language/en/acp/extensions.php @@ -41,6 +41,7 @@ $lang = array_merge($lang, array(  	'EXTENSIONS_EXPLAIN'		=> 'The Extensions Manager is a tool in your phpBB Board which allows you to manage all of your extensions statuses and view information about them.',  	'EXTENSION_INVALID_LIST'	=> 'The “%s” extension is not valid.<br />%s<br /><br />',  	'EXTENSION_NOT_AVAILABLE'	=> 'The selected extension is not available for this board, please verify your phpBB and PHP versions are allowed (see the details page).', +	'EXTENSION_DIR_INVALID'		=> 'The selected extension has an invalid directory structure and cannot be enabled.',  	'DETAILS'				=> 'Details', diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 851ffe8ec4..abe930c387 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -371,6 +371,7 @@ $lang = array_merge($lang, array(  	'LOGIN_VIEWFORUM'					=> 'The board requires you to be registered and logged in to view this forum.',  	'LOGIN_EXPLAIN_EDIT'				=> 'In order to edit posts in this forum you have to be registered and logged in.',  	'LOGIN_EXPLAIN_VIEWONLINE'			=> 'In order to view the online list you have to be registered and logged in.', +	'LOGIN_REQUIRED'					=> 'You need to login to perform this action.',  	'LOGOUT'							=> 'Logout',  	'LOGOUT_USER'						=> 'Logout [ %s ]',  	'LOG_ME_IN'							=> 'Remember me', @@ -378,6 +379,7 @@ $lang = array_merge($lang, array(  	'MAIN'					=> 'Main',  	'MARK'					=> 'Mark',  	'MARK_ALL'				=> 'Mark all', +	'MARK_ALL_READ'			=> 'Mark all read',  	'MARK_FORUMS_READ'		=> 'Mark forums read',  	'MARK_READ'				=> 'Mark read',  	'MARK_SUBFORUMS_READ'	=> 'Mark subforums read', diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index 941d0ca713..14425ca6e4 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -998,6 +998,7 @@ switch ($mode)  		// The basic memberlist  		$page_title = $user->lang['MEMBERLIST'];  		$template_html = 'memberlist_body.html'; +		$pagination = $phpbb_container->get('pagination');  		// Sorting  		$sort_key_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_LOCATION'], 'c' => $user->lang['SORT_JOINED'], 'd' => $user->lang['SORT_POST_COUNT'], 'f' => $user->lang['WEBSITE'], 'g' => $user->lang['ICQ'], 'h' => $user->lang['AIM'], 'i' => $user->lang['MSNM'], 'j' => $user->lang['YIM'], 'k' => $user->lang['JABBER']); @@ -1487,6 +1488,8 @@ switch ($mode)  			);  		} +		$start = $pagination->validate_start($start, $config['topics_per_page'], $config['num_users']); +  		// Get us some users :D  		$sql = "SELECT u.user_id  			FROM " . USERS_TABLE . " u @@ -1607,11 +1610,11 @@ switch ($mode)  			}  		} -		phpbb_generate_template_pagination($template, $pagination_url, 'pagination', 'start', $total_users, $config['topics_per_page'], $start); +		$pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $total_users, $config['topics_per_page'], $start);  		// Generate page  		$template->assign_vars(array( -			'PAGE_NUMBER'	=> phpbb_on_page($template, $user, $pagination_url, $total_users, $config['topics_per_page'], $start), +			'PAGE_NUMBER'	=> $pagination->on_page($pagination_url, $total_users, $config['topics_per_page'], $start),  			'TOTAL_USERS'	=> $user->lang('LIST_USERS', (int) $total_users),  			'PROFILE_IMG'	=> $user->img('icon_user_profile', $user->lang['PROFILE']), diff --git a/phpBB/phpbb/avatar/driver/driver.php b/phpBB/phpbb/avatar/driver/driver.php index d360614122..dd55f09119 100644 --- a/phpBB/phpbb/avatar/driver/driver.php +++ b/phpBB/phpbb/avatar/driver/driver.php @@ -112,17 +112,6 @@ abstract class driver implements \phpbb\avatar\driver\driver_interface  	/**  	* @inheritdoc  	*/ -	public function get_template_name() -	{ -		$driver = preg_replace('#^phpbb\\\\avatar\\\\driver\\\\#', '', get_class($this)); -		$template = "ucp_avatar_options_$driver.html"; - -		return $template; -	} - -	/** -	* @inheritdoc -	*/  	public function get_name()  	{  		return $this->name; diff --git a/phpBB/phpbb/avatar/driver/gravatar.php b/phpBB/phpbb/avatar/driver/gravatar.php index d64f4da734..9f14b7f468 100644 --- a/phpBB/phpbb/avatar/driver/gravatar.php +++ b/phpBB/phpbb/avatar/driver/gravatar.php @@ -147,6 +147,14 @@ class gravatar extends \phpbb\avatar\driver\driver  	}  	/** +	* @inheritdoc +	*/ +	public function get_template_name() +	{ +		return 'ucp_avatar_options_gravatar.html'; +	} + +	/**  	* Build gravatar URL for output on page  	*  	* @return string Gravatar URL diff --git a/phpBB/phpbb/avatar/driver/local.php b/phpBB/phpbb/avatar/driver/local.php index f6acc6e636..611a44cb3d 100644 --- a/phpBB/phpbb/avatar/driver/local.php +++ b/phpBB/phpbb/avatar/driver/local.php @@ -135,6 +135,14 @@ class local extends \phpbb\avatar\driver\driver  	}  	/** +	* @inheritdoc +	*/ +	public function get_template_name() +	{ +		return 'ucp_avatar_options_local.html'; +	} + +	/**  	* Get a list of avatars that are locally available  	* Results get cached for 24 hours (86400 seconds)  	* diff --git a/phpBB/phpbb/avatar/driver/remote.php b/phpBB/phpbb/avatar/driver/remote.php index 22d50c703e..36623942df 100644 --- a/phpBB/phpbb/avatar/driver/remote.php +++ b/phpBB/phpbb/avatar/driver/remote.php @@ -186,4 +186,12 @@ class remote extends \phpbb\avatar\driver\driver  			'avatar_height' => $height,  		);  	} + +	/** +	* @inheritdoc +	*/ +	public function get_template_name() +	{ +		return 'ucp_avatar_options_remote.html'; +	}  } diff --git a/phpBB/phpbb/avatar/driver/upload.php b/phpBB/phpbb/avatar/driver/upload.php index 822c40af98..1e50e135e4 100644 --- a/phpBB/phpbb/avatar/driver/upload.php +++ b/phpBB/phpbb/avatar/driver/upload.php @@ -168,6 +168,14 @@ class upload extends \phpbb\avatar\driver\driver  	}  	/** +	* @inheritdoc +	*/ +	public function get_template_name() +	{ +		return 'ucp_avatar_options_upload.html'; +	} + +	/**  	* Check if user is able to upload an avatar  	*  	* @return bool True if user can upload, false if not diff --git a/phpBB/phpbb/extension/manager.php b/phpBB/phpbb/extension/manager.php index 7f009867c9..23b281deaa 100644 --- a/phpBB/phpbb/extension/manager.php +++ b/phpBB/phpbb/extension/manager.php @@ -411,9 +411,24 @@ class manager  			if ($file_info->isFile() && $file_info->getFilename() == 'ext.' . $this->php_ext)  			{  				$ext_name = $iterator->getInnerIterator()->getSubPath(); +				$composer_file = $iterator->getPath() . '/composer.json'; +				// Ignore the extension if there is no composer.json. +				if (!is_readable($composer_file) || !($ext_info = file_get_contents($composer_file))) +				{ +					continue; +				} + +				$ext_info = json_decode($ext_info, true);  				$ext_name = str_replace(DIRECTORY_SEPARATOR, '/', $ext_name); +				// Ignore the extension if directory depth is not correct or if the directory structure +				// does not match the name value specified in composer.json. +				if (substr_count($ext_name, '/') !== 1 || !isset($ext_info['name']) || $ext_name != $ext_info['name']) +				{ +					continue; +				} +  				$available[$ext_name] = $this->phpbb_root_path . 'ext/' . $ext_name . '/';  			}  		} diff --git a/phpBB/phpbb/extension/metadata_manager.php b/phpBB/phpbb/extension/metadata_manager.php index d0323120d8..66cdb86513 100644 --- a/phpBB/phpbb/extension/metadata_manager.php +++ b/phpBB/phpbb/extension/metadata_manager.php @@ -266,8 +266,8 @@ class metadata_manager  	 */  	public function validate_enable()  	{ -		// Check for phpBB, PHP versions -		if (!$this->validate_require_phpbb() || !$this->validate_require_php()) +		// Check for valid directory & phpBB, PHP versions +		if (!$this->validate_dir() || !$this->validate_require_phpbb() || !$this->validate_require_php())  		{  			return false;  		} @@ -275,6 +275,16 @@ class metadata_manager  		return true;  	} +	/** +	 * Validates the most basic directory structure to ensure it follows <vendor>/<ext> convention. +	 * +	 * @return boolean True when passes validation +	 */ +	public function validate_dir() +	{ +		return (substr_count($this->ext_name, '/') === 1 && $this->ext_name == $this->get_metadata('name')); +	} +  	/**  	 * Validates the contents of the phpbb requirement field diff --git a/phpBB/phpbb/notification/type/base.php b/phpBB/phpbb/notification/type/base.php index 951585853f..10c876b286 100644 --- a/phpBB/phpbb/notification/type/base.php +++ b/phpBB/phpbb/notification/type/base.php @@ -282,15 +282,17 @@ abstract class base implements \phpbb\notification\type\type_interface  	*/  	public function prepare_for_display()  	{ +		$mark_hash = generate_link_hash('mark_notification_read'); +  		if ($this->get_url())  		{ -			$u_mark_read = append_sid($this->phpbb_root_path . 'index.' . $this->php_ext, 'mark_notification=' . $this->notification_id); +			$u_mark_read = append_sid($this->phpbb_root_path . 'index.' . $this->php_ext, 'mark_notification=' . $this->notification_id . '&hash=' . $mark_hash);  		}  		else  		{  			$redirect = (($this->user->page['page_dir']) ? $this->user->page['page_dir'] . '/' : '') . $this->user->page['page_name'] . (($this->user->page['query_string']) ? '?' . $this->user->page['query_string'] : ''); -			$u_mark_read = append_sid($this->phpbb_root_path . 'index.' . $this->php_ext, 'mark_notification=' . $this->notification_id . '&redirect=' . urlencode($redirect)); +			$u_mark_read = append_sid($this->phpbb_root_path . 'index.' . $this->php_ext, 'mark_notification=' . $this->notification_id . '&hash=' . $mark_hash . '&redirect=' . urlencode($redirect));  		}  		return array( diff --git a/phpBB/phpbb/pagination.php b/phpBB/phpbb/pagination.php new file mode 100644 index 0000000000..467dc2157f --- /dev/null +++ b/phpBB/phpbb/pagination.php @@ -0,0 +1,306 @@ +<?php +/** +* +* @package phpbb +* @copyright (c) 2013 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +namespace phpbb; + +class pagination +{ +	/** @var \phpbb\template\template */ +	protected $template; + +	/** @var \phpbb\user */ +	protected $user; + +	/** +	* Constructor +	* +	* @param	\phpbb\template\template	$template +	* @param	\phpbb\user					$user +	*/ +	public function __construct(\phpbb\template\template $template, \phpbb\user $user) +	{ +		$this->template = $template; +		$this->user = $user; +	} + +	/** +	* Generate a pagination link based on the url and the page information +	* +	* @param string $base_url is url prepended to all links generated within the function +	*							If you use page numbers inside your controller route, base_url should contains a placeholder (%d) +	*							for the page. Also be sure to specify the pagination path information into the start_name argument +	* @param string $on_page is the page for which we want to generate the link +	* @param string $start_name is the name of the parameter containing the first item of the given page (example: start=20) +	*							If you use page numbers inside your controller route, start name should be the string +	*							that should be removed for the first page (example: /page/%d) +	* @param int $per_page the number of items, posts, etc. to display per page, used to determine the number of pages to produce +	* @return URL for the requested page +	*/ +	protected function generate_page_link($base_url, $on_page, $start_name, $per_page) +	{ +		if (strpos($start_name, '%d') !== false) +		{ +			return ($on_page > 1) ? sprintf($base_url, (int) $on_page) : str_replace($start_name, '', $base_url); +		} +		else +		{ +			$url_delim = (strpos($base_url, '?') === false) ? '?' : ((strpos($base_url, '?') === strlen($base_url) - 1) ? '' : '&'); +			return ($on_page > 1) ? $base_url . $url_delim . $start_name . '=' . (($on_page - 1) * $per_page) : $base_url; +		} +	} + +	/** +	* Generate template rendered pagination +	* Allows full control of rendering of pagination with the template +	* +	* @param string $base_url is url prepended to all links generated within the function +	*							If you use page numbers inside your controller route, base_url should contains a placeholder (%d) +	*							for the page. Also be sure to specify the pagination path information into the start_name argument +	* @param string $block_var_name is the name assigned to the pagination data block within the template (example: <!-- BEGIN pagination -->) +	* @param string $start_name is the name of the parameter containing the first item of the given page (example: start=20) +	*							If you use page numbers inside your controller route, start name should be the string +	*							that should be removed for the first page (example: /page/%d) +	* @param int $num_items the total number of items, posts, etc., used to determine the number of pages to produce +	* @param int $per_page the number of items, posts, etc. to display per page, used to determine the number of pages to produce +	* @param int $start the item which should be considered currently active, used to determine the page we're on +	* @param bool $reverse_count determines whether we weight display of the list towards the start (false) or end (true) of the list +	* @param bool $ignore_on_page decides whether we enable an active (unlinked) item, used primarily for embedded lists +	* @return null +	*/ +	public function generate_template_pagination($base_url, $block_var_name, $start_name, $num_items, $per_page, $start = 1, $reverse_count = false, $ignore_on_page = false) +	{ +		$total_pages = ceil($num_items / $per_page); + +		if ($total_pages == 1 || !$num_items) +		{ +			return; +		} + +		$on_page = $this->get_on_page($per_page, $start); + +		if ($reverse_count) +		{ +			$start_page = ($total_pages > 5) ? $total_pages - 4 : 1; +			$end_page = $total_pages; +		} +		else +		{ +			// What we're doing here is calculating what the "start" and "end" pages should be. We +			// do this by assuming pagination is "centered" around the currently active page with +			// the three previous and three next page links displayed. Anything more than that and +			// we display the ellipsis, likewise anything less. +			// +			// $start_page is the page at which we start creating the list. When we have five or less +			// pages we start at page 1 since there will be no ellipsis displayed. Anymore than that +			// and we calculate the start based on the active page. This is the min/max calculation. +			// First (max) would we end up starting on a page less than 1? Next (min) would we end +			// up starting so close to the end that we'd not display our minimum number of pages. +			// +			// $end_page is the last page in the list to display. Like $start_page we use a min/max to +			// determine this number. Again at most five pages? Then just display them all. More than +			// five and we first (min) determine whether we'd end up listing more pages than exist. +			// We then (max) ensure we're displaying the minimum number of pages. +			$start_page = ($total_pages > 5) ? min(max(1, $on_page - 3), $total_pages - 4) : 1; +			$end_page = ($total_pages > 5) ? max(min($total_pages, $on_page + 3), 5) : $total_pages; +		} + +		$u_previous_page = $u_next_page = ''; +		if ($on_page != 1) +		{ +			$u_previous_page = $this->generate_page_link($base_url, $on_page - 1, $start_name, $per_page); + +			$this->template->assign_block_vars($block_var_name, array( +				'PAGE_NUMBER'	=> '', +				'PAGE_URL'		=> $u_previous_page, +				'S_IS_CURRENT'	=> false, +				'S_IS_PREV'		=> true, +				'S_IS_NEXT'		=> false, +				'S_IS_ELLIPSIS'	=> false, +			)); +		} + +		// This do...while exists purely to negate the need for start and end assign_block_vars, i.e. +		// to display the first and last page in the list plus any ellipsis. We use this loop to jump +		// around a little within the list depending on where we're starting (and ending). +		$at_page = 1; +		do +		{ +			// We decide whether to display the ellipsis during the loop. The ellipsis is always +			// displayed as either the second or penultimate item in the list. So are we at either +			// of those points and of course do we even need to display it, i.e. is the list starting +			// on at least page 3 and ending three pages before the final item. +			$this->template->assign_block_vars($block_var_name, array( +				'PAGE_NUMBER'	=> $at_page, +				'PAGE_URL'		=> $this->generate_page_link($base_url, $at_page, $start_name, $per_page), +				'S_IS_CURRENT'	=> (!$ignore_on_page && $at_page == $on_page), +				'S_IS_NEXT'		=> false, +				'S_IS_PREV'		=> false, +				'S_IS_ELLIPSIS'	=> ($at_page == 2 && $start_page > 2) || ($at_page == $total_pages - 1 && $end_page < $total_pages - 1), +			)); + +			// We may need to jump around in the list depending on whether we have or need to display +			// the ellipsis. Are we on page 2 and are we more than one page away from the start +			// of the list? Yes? Then we jump to the start of the list. Likewise are we at the end of +			// the list and are there more than two pages left in total? Yes? Then jump to the penultimate +			// page (so we can display the ellipsis next pass). Else, increment the counter and keep +			// going +			if ($at_page == 2 && $at_page < $start_page - 1) +			{ +				$at_page = $start_page; +			} +			else if ($at_page == $end_page && $end_page < $total_pages - 1) +			{ +				$at_page = $total_pages - 1; +			} +			else +			{ +				$at_page++; +			} +		} +		while ($at_page <= $total_pages); + +		if ($on_page != $total_pages) +		{ +			$u_next_page = $this->generate_page_link($base_url, $on_page + 1, $start_name, $per_page); + +			$this->template->assign_block_vars($block_var_name, array( +				'PAGE_NUMBER'	=> '', +				'PAGE_URL'		=> $u_next_page, +				'S_IS_CURRENT'	=> false, +				'S_IS_PREV'		=> false, +				'S_IS_NEXT'		=> true, +				'S_IS_ELLIPSIS'	=> false, +			)); +		} + +		// If the block_var_name is a nested block, we will use the last (most +		// inner) block as a prefix for the template variables. If the last block +		// name is pagination, the prefix is empty. If the rest of the +		// block_var_name is not empty, we will modify the last row of that block +		// and add our pagination items. +		$tpl_block_name = $tpl_prefix = ''; +		if (strrpos($block_var_name, '.') !== false) +		{ +			$tpl_block_name = substr($block_var_name, 0, strrpos($block_var_name, '.')); +			$tpl_prefix = strtoupper(substr($block_var_name, strrpos($block_var_name, '.') + 1)); +		} +		else +		{ +			$tpl_prefix = strtoupper($block_var_name); +		} +		$tpl_prefix = ($tpl_prefix == 'PAGINATION') ? '' : $tpl_prefix . '_'; + +		$template_array = array( +			$tpl_prefix . 'BASE_URL'		=> $base_url, +			$tpl_prefix . 'PER_PAGE'		=> $per_page, +			'U_' . $tpl_prefix . 'PREVIOUS_PAGE'	=> ($on_page != 1) ? $u_previous_page : '', +			'U_' . $tpl_prefix . 'NEXT_PAGE'		=> ($on_page != $total_pages) ? $u_next_page : '', +			$tpl_prefix . 'TOTAL_PAGES'		=> $total_pages, +			$tpl_prefix . 'CURRENT_PAGE'	=> $on_page, +		); + +		if ($tpl_block_name) +		{ +			$this->template->alter_block_array($tpl_block_name, $template_array, true, 'change'); +		} +		else +		{ +			$this->template->assign_vars($template_array); +		} +	} + +	/** +	* Get current page number +	* +	* @param int $per_page the number of items, posts, etc. per page +	* @param int $start the item which should be considered currently active, used to determine the page we're on +	* @return int	Current page number +	*/ +	public function get_on_page($per_page, $start) +	{ +		return floor($start / $per_page) + 1; +	} + +	/** +	* Return current page +	* This function also sets certain specific template variables +	* +	* @param string $base_url the base url used to call this page, used by Javascript for popup jump to page +	* @param int $num_items the total number of items, posts, topics, etc. +	* @param int $per_page the number of items, posts, etc. per page +	* @param int $start the item which should be considered currently active, used to determine the page we're on +	* @return string Descriptive pagination string (e.g. "page 1 of 10") +	*/ +	public function on_page($base_url, $num_items, $per_page, $start) +	{ +		$on_page = $this->get_on_page($per_page, $start); + +		$this->template->assign_vars(array( +			'PER_PAGE'		=> $per_page, +			'ON_PAGE'		=> $on_page, +			'BASE_URL'		=> $base_url, +		)); + +		return $this->user->lang('PAGE_OF', $on_page, max(ceil($num_items / $per_page), 1)); +	} + +	/** +	* Get current page number +	* +	* @param int $start the item which should be considered currently active, used to determine the page we're on +	* @param int $per_page the number of items, posts, etc. per page +	* @param int $num_items the total number of items, posts, topics, etc. +	* @return int	Current page number +	*/ +	public function validate_start($start, $per_page, $num_items) +	{ +		if ($start < 0 || $start >= $num_items) +		{ +			return ($start < 0) ? 0 : floor(($num_items - 1) / $per_page) * $per_page; +		} + +		return $start; +	} + +	/** +	* Get new start when searching from the end +	* +	* If the user is trying to reach late pages, start searching from the end. +	* +	* @param int $start the item which should be considered currently active, used to determine the page we're on +	* @param int $limit the number of items, posts, etc. to display +	* @param int $num_items the total number of items, posts, topics, etc. +	* @return int	Current page number +	*/ +	public function reverse_start($start, $limit, $num_items) +	{ +		return max(0, $num_items - $limit - $start); +	} + +	/** +	* Get new item limit when searching from the end +	* +	* If the user is trying to reach late pages, start searching from the end. +	* In this case the items to display might be lower then the actual per_page setting. +	* +	* @param int $start the item which should be considered currently active, used to determine the page we're on +	* @param int $per_page the number of items, posts, etc. per page +	* @param int $num_items the total number of items, posts, topics, etc. +	* @return int	Current page number +	*/ +	public function reverse_limit($start, $per_page, $num_items) +	{ +		if ($start + $per_page > $num_items) +		{ +			return min($per_page, max(1, $num_items - $start)); +		} + +		return $per_page; +	} +} diff --git a/phpBB/phpbb/request/request.php b/phpBB/phpbb/request/request.php index e158d33c01..3171a6edb7 100644 --- a/phpBB/phpbb/request/request.php +++ b/phpBB/phpbb/request/request.php @@ -217,7 +217,7 @@ class request implements \phpbb\request\request_interface  	* @return	mixed	The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the  	*					the same as that of $default. If the variable is not set $default is returned.  	*/ -	public function untrimmed_variable($var_name, $default, $multibyte, $super_global = \phpbb\request\request_interface::REQUEST) +	public function untrimmed_variable($var_name, $default, $multibyte = false, $super_global = \phpbb\request\request_interface::REQUEST)  	{  		return $this->_variable($var_name, $default, $multibyte, $super_global, false);  	} diff --git a/phpBB/search.php b/phpBB/search.php index ae573b18e8..4ddade90f5 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -120,6 +120,7 @@ $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';  gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);  $phpbb_content_visibility = $phpbb_container->get('content.visibility'); +$pagination = $phpbb_container->get('pagination');  if ($keywords || $author || $author_id || $search_id || $submit)  { @@ -501,14 +502,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)  			}  			// Make sure $start is set to the last page if it exceeds the amount -			if ($start < 0) -			{ -				$start = 0; -			} -			else if ($start >= $total_match_count) -			{ -				$start = floor(($total_match_count - 1) / $per_page) * $per_page; -			} +			$start = $pagination->validate_start($start, $per_page, $total_match_count);  			$id_ary = array_slice($id_ary, $start, $per_page);  		} @@ -600,7 +594,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)  		$phrase_search_disabled = $search->supports_phrase_search() ? false : true;  	} -	phpbb_generate_template_pagination($template, $u_search, 'pagination', 'start', $total_match_count, $per_page, $start); +	$pagination->generate_template_pagination($u_search, 'pagination', 'start', $total_match_count, $per_page, $start);  	$template->assign_vars(array(  		'SEARCH_TITLE'		=> $l_search_title, @@ -608,7 +602,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)  		'SEARCH_WORDS'		=> $keywords,  		'SEARCHED_QUERY'	=> $search->get_search_query(),  		'IGNORED_WORDS'		=> (sizeof($common_words)) ? implode(' ', $common_words) : '', -		'PAGE_NUMBER'		=> phpbb_on_page($template, $user, $u_search, $total_match_count, $per_page, $start), +		'PAGE_NUMBER'		=> $pagination->on_page($u_search, $total_match_count, $per_page, $start),  		'PHRASE_SEARCH_DISABLED'		=> $phrase_search_disabled, @@ -1025,7 +1019,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)  			if ($show_results == 'topics')  			{ -				phpbb_generate_template_pagination($template, $view_topic_url, 'searchresults.pagination', 'start', $replies + 1, $config['posts_per_page'], 1, true, true); +				$pagination->generate_template_pagination($view_topic_url, 'searchresults.pagination', 'start', $replies + 1, $config['posts_per_page'], 1, true, true);  			}  		} diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index 28656d47d3..1d70adc48d 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -106,6 +106,47 @@ phpbb.addAjaxCallback('mark_topics_read', function(res, update_topic_links) {  	phpbb.closeDarkenWrapper(3000);  }); +// This callback will mark all notifications read +phpbb.addAjaxCallback('notification.mark_all_read', function(res) { +	if (typeof res.success !== 'undefined') { +		phpbb.markNotifications($('#notification_list li.bg2'), 0); +		phpbb.closeDarkenWrapper(3000); +	} +}); + +// This callback will mark a notification read +phpbb.addAjaxCallback('notification.mark_read', function(res) { +	if (typeof res.success !== 'undefined') { +		var unreadCount = Number($('#notification_list_button strong').html()) - 1; +		phpbb.markNotifications($(this).parent('li.bg2'), unreadCount); +	} +}); + +/** + * Mark notification popup rows as read. + * + * @param {jQuery} el jQuery object(s) to mark read. + * @param {int} unreadCount The new unread notifications count. + */ +phpbb.markNotifications = function(el, unreadCount) { +	// Remove the unread status. +	el.removeClass('bg2'); +	el.find('a.mark_read').remove(); + +	// Update the notification link to the real URL. +	el.each(function() { +		var link = $(this).find('a'); +		link.attr('href', link.attr('data-real-url')); +	}); + +	// Update the unread count. +	$('#notification_list_button strong').html(unreadCount); +	// Remove the Mark all read link if there are no unread notifications. +	if (!unreadCount) { +		$('#mark_all_notifications').remove(); +	} +}; +  // This callback finds the post from the delete link, and removes it.  phpbb.addAjaxCallback('post_delete', function() {  	var el = $(this), diff --git a/phpBB/styles/prosilver/template/index_body.html b/phpBB/styles/prosilver/template/index_body.html index bd640fd63f..58a5420db3 100644 --- a/phpBB/styles/prosilver/template/index_body.html +++ b/phpBB/styles/prosilver/template/index_body.html @@ -3,6 +3,8 @@  <p class="{S_CONTENT_FLOW_END} responsive-center<!-- IF S_USER_LOGGED_IN --> rightside<!-- ENDIF -->"><!-- IF S_USER_LOGGED_IN -->{LAST_VISIT_DATE}<!-- ELSE -->{CURRENT_TIME}<!-- ENDIF --></p>  <!-- IF S_USER_LOGGED_IN --><p class="responsive-center">{CURRENT_TIME}<!-- IF U_MCP or U_ACP --> <br />[ <!-- IF U_ACP --><a href="{U_ACP}" title="{L_ACP}" data-responsive-text="{L_ACP_SHORT}">{L_ACP}</a><!-- IF U_MCP --> | <!-- ENDIF --><!-- ENDIF --><!-- IF U_MCP --><a href="{U_MCP}" title="{L_MCP}" data-responsive-text="{L_MCP_SHORT}">{L_MCP}</a><!-- ENDIF --> ]<!-- ENDIF --></p><!-- ENDIF --> +<!-- EVENT index_body_linklist_before --> +  <!-- IF S_DISPLAY_SEARCH or (S_USER_LOGGED_IN and not S_IS_BOT) -->  <ul class="linklist bulletin">  	<!-- IF S_DISPLAY_SEARCH --> @@ -19,7 +21,7 @@  </ul>  <!-- ENDIF --> -<!-- EVENT index_body_forumlist_before --> +<!-- EVENT index_body_linklist_after -->  <!-- INCLUDE forumlist_body.html --> diff --git a/phpBB/styles/prosilver/template/overall_footer.html b/phpBB/styles/prosilver/template/overall_footer.html index bbffe8dc3d..f7d0269edb 100644 --- a/phpBB/styles/prosilver/template/overall_footer.html +++ b/phpBB/styles/prosilver/template/overall_footer.html @@ -7,7 +7,7 @@  		<div class="inner">  		<ul class="linklist bulletin"> -			<li class="small-icon icon-home breadcrumbs"><!-- IF U_SITE_HOME --><span class="crumb"><a href="{U_SITE_HOME}">{L_SITE_HOME}</a> <strong>‹</strong></span> <!-- ENDIF --><span class="crumb"><a href="{U_INDEX}" accesskey="h">{L_INDEX}</a></span> +			<li class="small-icon icon-home breadcrumbs"><!-- IF U_SITE_HOME --><span class="crumb"><a href="{U_SITE_HOME}">{L_SITE_HOME}</a> <strong>‹</strong></span> <!-- ENDIF --><span class="crumb"><a href="{U_INDEX}">{L_INDEX}</a></span>  				<!-- EVENT overall_footer_breadcrumb_append -->  			</li>  			<!-- IF not S_IS_BOT --> diff --git a/phpBB/styles/prosilver/template/overall_header.html b/phpBB/styles/prosilver/template/overall_header.html index e4e1b3443b..529e6625fe 100644 --- a/phpBB/styles/prosilver/template/overall_header.html +++ b/phpBB/styles/prosilver/template/overall_header.html @@ -107,7 +107,12 @@  						<div class="dropdown-contents">  							<div class="header">  								{L_NOTIFICATIONS} -								<span class="header_settings"><a href="{U_NOTIFICATION_SETTINGS}">{L_SETTINGS}</a></span> +								<span class="header_settings"> +									<a href="{U_NOTIFICATION_SETTINGS}">{L_SETTINGS}</a> +									<!-- IF NOTIFICATIONS_COUNT --> +										<span id="mark_all_notifications"> • <a href="{U_MARK_ALL_NOTIFICATIONS}" data-ajax="notification.mark_all_read">{L_MARK_ALL_READ}</a></span> +									<!-- ENDIF --> +								</span>  							</div>  							<ul> @@ -118,17 +123,18 @@  								<!-- ENDIF -->  								<!-- BEGIN notifications -->  									<li class="<!-- IF notifications.UNREAD --> bg2<!-- ENDIF -->"> -										<!-- IF notifications.URL --><a href="<!-- IF notifications.UNREAD -->{notifications.U_MARK_READ}<!-- ELSE -->{notifications.URL}<!-- ENDIF -->"><!-- ENDIF --> +										<!-- IF notifications.URL --> +											<a href="<!-- IF notifications.UNREAD -->{notifications.U_MARK_READ}" data-real-url="{notifications.URL}<!-- ELSE -->{notifications.URL}<!-- ENDIF -->"> +										<!-- ENDIF -->  											<!-- IF notifications.AVATAR -->{notifications.AVATAR}<!-- ELSE --><img src="{T_THEME_PATH}/images/no_avatar.gif" alt="" /><!-- ENDIF -->  											<div class="notification_text">  												<p>{notifications.FORMATTED_TITLE}</p>  												<p>» {notifications.TIME}</p> - -												<!-- IF not notifications.URL and notifications.U_MARK_READ --> -													<p><a href="{notifications.U_MARK_READ}">{L_MARK_READ}</a></p> -												<!-- ENDIF -->  											</div>  										<!-- IF notifications.URL --></a><!-- ENDIF --> +										<!-- IF notifications.UNREAD --> +											<a href="{notifications.U_MARK_READ}" class="mark_read icon-mark" data-ajax="notification.mark_read" title="{L_MARK_READ}"></a> +										<!-- ENDIF -->  									</li>  					   			<!-- END notifications -->  							</ul> diff --git a/phpBB/styles/prosilver/template/posting_buttons.html b/phpBB/styles/prosilver/template/posting_buttons.html index e8338c6c86..137970bbdf 100644 --- a/phpBB/styles/prosilver/template/posting_buttons.html +++ b/phpBB/styles/prosilver/template/posting_buttons.html @@ -59,6 +59,7 @@  	</dl>  </div> +<!-- EVENT posting_editor_buttons_before -->  <div id="format-buttons">  	<input type="button" class="button2" accesskey="b" name="addbbcode0" value=" B " style="font-weight:bold; width: 30px" onclick="bbstyle(0)" title="{L_BBCODE_B_HELP}" />  	<input type="button" class="button2" accesskey="i" name="addbbcode2" value=" i " style="font-style:italic; width: 30px" onclick="bbstyle(2)" title="{L_BBCODE_I_HELP}" /> @@ -95,4 +96,5 @@  		<input type="button" class="button2" name="addbbcode{custom_tags.BBCODE_ID}" value="{custom_tags.BBCODE_TAG}" onclick="bbstyle({custom_tags.BBCODE_ID})" title="{custom_tags.BBCODE_HELPLINE}" />  	<!-- END custom_tags -->  </div> +<!-- EVENT posting_editor_buttons_after -->  <!-- ENDIF --> diff --git a/phpBB/styles/prosilver/template/ucp_profile_reg_details.html b/phpBB/styles/prosilver/template/ucp_profile_reg_details.html index 699be4a27e..4b26bc2e99 100644 --- a/phpBB/styles/prosilver/template/ucp_profile_reg_details.html +++ b/phpBB/styles/prosilver/template/ucp_profile_reg_details.html @@ -7,7 +7,7 @@  	<div class="inner">  	<!-- IF S_FORCE_PASSWORD --> -		<p>{L_FORCE_PASSWORD_EXPLAIN}</p> +		<p class="error">{L_FORCE_PASSWORD_EXPLAIN}</p>  	<!-- ENDIF -->  	<fieldset> diff --git a/phpBB/styles/prosilver/theme/colours.css b/phpBB/styles/prosilver/theme/colours.css index 68fbcde4f9..cad740200d 100644 --- a/phpBB/styles/prosilver/theme/colours.css +++ b/phpBB/styles/prosilver/theme/colours.css @@ -258,6 +258,11 @@ a:active	{ color: #368AD2; }  	color: #C8E6FF;  } +/* Notification mark read link */ +#notification_list a.mark_read { +	background-color: #FFFFFF; +} +  /* Links for forum/topic lists */  a.forumtitle {  	color: #105289; @@ -716,6 +721,7 @@ a.sendemail {  .icon-notification				{ background-image: url("./images/icon_notification.gif"); }  .icon-pm						{ background-image: url("./images/icon_pm.gif"); }  .icon-download					{ background-image: url("./images/icon_download.gif"); } +.icon-mark						{ background-image: url("./images/icon_mark.gif"); }  /* Profile & navigation icons */  .email-icon, .email-icon a		{ background-image: url("./images/icon_contact_email.gif"); } diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index cacae74649..288477f52a 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -1015,6 +1015,7 @@ form > p.post-notice strong {  	list-style-type: none;  	font-size: 0.95em;  	clear: both; +	position: relative;  }  #notification_list ul li:before, #notification_list ul li:after { @@ -1022,6 +1023,7 @@ form > p.post-notice strong {  }  #notification_list .dropdown-contents { +	max-height: none;  	padding: 0;  } diff --git a/phpBB/styles/prosilver/theme/images/icon_mark.gif b/phpBB/styles/prosilver/theme/images/icon_mark.gif Binary files differnew file mode 100644 index 0000000000..1a33fc3264 --- /dev/null +++ b/phpBB/styles/prosilver/theme/images/icon_mark.gif diff --git a/phpBB/styles/prosilver/theme/links.css b/phpBB/styles/prosilver/theme/links.css index 7e3dc094f0..d43886256d 100644 --- a/phpBB/styles/prosilver/theme/links.css +++ b/phpBB/styles/prosilver/theme/links.css @@ -49,6 +49,29 @@ ul.linklist li.small-icon > a, ul.linklist li.breadcrumbs span:first-child > a {  	padding-left: 17px;  } +/* Notification mark read link */ +#notification_list a.mark_read { +	background-position: center center; +	background-repeat: no-repeat; +	border-radius: 3px 0 0 3px; +	display: none; +	margin-top: -20px; +	position: absolute; +	z-index: 2; +	right: 0; +	top: 50%; +	width: 30px; +	height: 40px; +} + +#notification_list li:hover a.mark_read { +	display: block; +} + +#notification_list a.mark_read:hover { +	width: 40px; +} +  /* Links for forum/topic lists */  a.forumtitle {  	font-family: "Trebuchet MS", Helvetica, Arial, Sans-serif; diff --git a/phpBB/styles/subsilver2/template/index_body.html b/phpBB/styles/subsilver2/template/index_body.html index 00c328e994..763028966f 100644 --- a/phpBB/styles/subsilver2/template/index_body.html +++ b/phpBB/styles/subsilver2/template/index_body.html @@ -1,5 +1,7 @@  <!-- INCLUDE overall_header.html --> +<!-- EVENT index_body_linklist_before --> +  <!-- IF U_MCP or U_ACP -->  	<div id="pageheader">  		<p class="linkmcp">[ <!-- IF U_ACP --><a href="{U_ACP}">{L_ACP}</a><!-- IF U_MCP --> | <!-- ENDIF --><!-- ENDIF --><!-- IF U_MCP --><a href="{U_MCP}">{L_MCP}</a><!-- ENDIF --> ]</p> @@ -8,7 +10,7 @@  	<br clear="all" /><br />  <!-- ENDIF --> -<!-- EVENT index_body_forumlist_before --> +<!-- EVENT index_body_linklist_after -->  <!-- INCLUDE forumlist_body.html --> diff --git a/phpBB/styles/subsilver2/template/mcp_topic.html b/phpBB/styles/subsilver2/template/mcp_topic.html index d3b4408243..5bd762ec0b 100644 --- a/phpBB/styles/subsilver2/template/mcp_topic.html +++ b/phpBB/styles/subsilver2/template/mcp_topic.html @@ -73,7 +73,7 @@  		<td align="center"><b class="postauthor">{postrow.POST_AUTHOR_FULL}</b></td>  		<td width="100%">  			<table width="100%" cellspacing="0" cellpadding="0" border="0"> -			<tr valign="top"> +			<tr style="vertical-align: top;">  				<td class="gensmall" nowrap="nowrap"> <b>{L_POST_SUBJECT}{L_COLON}</b> </td>  				<td class="gensmall" width="100%">{postrow.POST_SUBJECT}</td>  			</tr> diff --git a/phpBB/styles/subsilver2/template/posting_buttons.html b/phpBB/styles/subsilver2/template/posting_buttons.html index 06de2c3169..2c60913fc0 100644 --- a/phpBB/styles/subsilver2/template/posting_buttons.html +++ b/phpBB/styles/subsilver2/template/posting_buttons.html @@ -36,6 +36,8 @@  		<!-- INCLUDEJS {T_ASSETS_PATH}/javascript/editor.js -->  <!-- IF S_BBCODE_ALLOWED --> +	<!-- EVENT posting_editor_buttons_before --> +	<div id="core-bbcode-buttons">  		<input type="button" class="btnbbcode" accesskey="b" name="addbbcode0" value=" B " style="font-weight:bold; width: 30px;" onclick="bbstyle(0)" onmouseover="helpline('b')" onmouseout="helpline('tip')" />  		<input type="button" class="btnbbcode" accesskey="i" name="addbbcode2" value=" i " style="font-style:italic; width: 30px;" onclick="bbstyle(2)" onmouseover="helpline('i')" onmouseout="helpline('tip')" />  		<input type="button" class="btnbbcode" accesskey="u" name="addbbcode4" value=" u " style="text-decoration: underline; width: 30px;" onclick="bbstyle(4)" onmouseover="helpline('u')" onmouseout="helpline('tip')" /> @@ -66,15 +68,19 @@  				<!-- ENDIF -->  			<!-- ENDIF -->  		</select></span> +	</div> +	<!-- EVENT posting_editor_buttons_after -->  <!-- ENDIF -->  	</td>  </tr>  <!-- IF S_BBCODE_ALLOWED and .custom_tags -->  	<tr valign="middle" align="{S_CONTENT_FLOW_BEGIN}">  		<td colspan="2"> +		<div id="custom-bbcode-buttons">  		<!-- BEGIN custom_tags -->  			<input type="button" class="btnbbcode" name="addbbcode{custom_tags.BBCODE_ID}" value="{custom_tags.BBCODE_TAG}" onclick="bbstyle({custom_tags.BBCODE_ID})"<!-- IF custom_tags.BBCODE_HELPLINE !== '' --> onmouseover="helpline('cb_{custom_tags.BBCODE_ID}')" onmouseout="helpline('tip')"<!-- ENDIF --> />  		<!-- END custom_tags --> +		</div>  		</td>  	</tr>  <!-- ENDIF --> diff --git a/phpBB/styles/subsilver2/template/ucp_profile_reg_details.html b/phpBB/styles/subsilver2/template/ucp_profile_reg_details.html index 6944a62764..d8fe84bf79 100644 --- a/phpBB/styles/subsilver2/template/ucp_profile_reg_details.html +++ b/phpBB/styles/subsilver2/template/ucp_profile_reg_details.html @@ -6,7 +6,7 @@  </tr>  <!-- IF S_FORCE_PASSWORD -->  	<tr> -		<td class="row3" colspan="2" align="center"><span class="gensmall">{L_FORCE_PASSWORD_EXPLAIN}</span></td> +		<td class="row3" colspan="2" align="center"><span class="gensmall error">{L_FORCE_PASSWORD_EXPLAIN}</span></td>  	</tr>  <!-- ENDIF -->  <!-- IF ERROR --> diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index c6712db46c..2c7a0a4829 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -33,6 +33,8 @@ $sort_days	= request_var('st', $default_sort_days);  $sort_key	= request_var('sk', $default_sort_key);  $sort_dir	= request_var('sd', $default_sort_dir); +$pagination = $phpbb_container->get('pagination'); +  // Check if the user has actually sent a forum ID with his/her request  // If not give them a nice error page.  if (!$forum_id) @@ -140,8 +142,13 @@ else  	}  } +$phpbb_content_visibility = $phpbb_container->get('content.visibility'); +  // Dump out the page header and load viewforum template -page_header($forum_data['forum_name'] . ($start ? ' - ' . sprintf($user->lang['PAGE_TITLE_NUMBER'], floor($start / $config['topics_per_page']) + 1) : ''), true, $forum_id); +$topics_count = $phpbb_content_visibility->get_count('forum_topics', $forum_data, $forum_id); +$start = $pagination->validate_start($start, $config['topics_per_page'], $topics_count); + +page_header($forum_data['forum_name'] . ($start ? ' - ' . $user->lang('PAGE_TITLE_NUMBER', $pagination->get_on_page($config['topics_per_page'], $start)) : ''), true, $forum_id);  $template->set_filenames(array(  	'body' => 'viewforum_body.html') @@ -246,8 +253,6 @@ $sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => 't.topic_last_po  $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';  gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param, $default_sort_days, $default_sort_key, $default_sort_dir); -$phpbb_content_visibility = $phpbb_container->get('content.visibility'); -  // Limit topics to certain time frame, obtain correct topic count  if ($sort_days)  { @@ -275,16 +280,9 @@ if ($sort_days)  }  else  { -	$topics_count = $phpbb_content_visibility->get_count('forum_topics', $forum_data, $forum_id);  	$sql_limit_time = '';  } -// Make sure $start is set to the last page if it exceeds the amount -if ($start < 0 || $start > $topics_count) -{ -	$start = ($start < 0) ? 0 : floor(($topics_count - 1) / $config['topics_per_page']) * $config['topics_per_page']; -} -  // Basic pagewide vars  $post_alt = ($forum_data['forum_status'] == ITEM_LOCKED) ? $user->lang['FORUM_LOCKED'] : $user->lang['POST_NEW_TOPIC']; @@ -480,14 +478,11 @@ if ($start > $topics_count / 2)  {  	$store_reverse = true; -	if ($start + $config['topics_per_page'] > $topics_count) -	{ -		$sql_limit = min($config['topics_per_page'], max(1, $topics_count - $start)); -	} -  	// Select the sort order  	$sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'ASC' : 'DESC'); -	$sql_start = max(0, $topics_count - $sql_limit - $start); + +	$sql_limit = $pagination->reverse_limit($start, $sql_limit, $topics_count); +	$sql_start = $pagination->reverse_start($start, $sql_limit, $topics_count);  }  else  { @@ -631,10 +626,10 @@ if ($s_display_active)  $total_topic_count = $topics_count - sizeof($global_announce_forums);  $base_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . ((strlen($u_sort_param)) ? "&$u_sort_param" : '')); -phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $topics_count, $config['topics_per_page'], $start); +$pagination->generate_template_pagination($base_url, 'pagination', 'start', $topics_count, $config['topics_per_page'], $start);  $template->assign_vars(array( -	'PAGE_NUMBER'	=> phpbb_on_page($template, $user, $base_url, $topics_count, $config['topics_per_page'], $start), +	'PAGE_NUMBER'	=> $pagination->on_page($base_url, $topics_count, $config['topics_per_page'], $start),  	'TOTAL_TOPICS'	=> ($s_display_active) ? false : $user->lang('VIEW_FORUM_TOPICS', (int) $total_topic_count),  )); @@ -802,7 +797,7 @@ if (sizeof($topic_list))  		$template->assign_block_vars('topicrow', $topic_row); -		phpbb_generate_template_pagination($template, $view_topic_url, 'topicrow.pagination', 'start', $replies + 1, $config['posts_per_page'], 1, true, true); +		$pagination->generate_template_pagination($view_topic_url, 'topicrow.pagination', 'start', $replies + 1, $config['posts_per_page'], 1, true, true);  		$s_type_switch = ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL) ? 1 : 0; diff --git a/phpBB/viewonline.php b/phpBB/viewonline.php index d6a6a79342..ef8bfb888b 100644 --- a/phpBB/viewonline.php +++ b/phpBB/viewonline.php @@ -39,6 +39,8 @@ if (!$auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel'))  	login_box('', $user->lang['LOGIN_EXPLAIN_VIEWONLINE']);  } +$pagination = $phpbb_container->get('pagination'); +  $sort_key_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_JOINED'], 'c' => $user->lang['SORT_LOCATION']);  $sort_key_sql = array('a' => 'u.username_clean', 'b' => 's.session_time', 'c' => 's.session_page'); @@ -419,15 +421,16 @@ $db->sql_freeresult($result);  // Refreshing the page every 60 seconds...  meta_refresh(60, append_sid("{$phpbb_root_path}viewonline.$phpEx", "sg=$show_guests&sk=$sort_key&sd=$sort_dir&start=$start")); +$start = $pagination->validate_start($start, $config['topics_per_page'], $counter);  $base_url = append_sid("{$phpbb_root_path}viewonline.$phpEx", "sg=$show_guests&sk=$sort_key&sd=$sort_dir"); -phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $counter, $config['topics_per_page'], $start); +$pagination->generate_template_pagination($base_url, 'pagination', 'start', $counter, $config['topics_per_page'], $start);  // Send data to template  $template->assign_vars(array(  	'TOTAL_REGISTERED_USERS_ONLINE'	=> $user->lang('REG_USERS_ONLINE', (int) $logged_visible_online, $user->lang('HIDDEN_USERS_ONLINE', (int) $logged_hidden_online)),  	'TOTAL_GUEST_USERS_ONLINE'		=> $user->lang('GUEST_USERS_ONLINE', (int) $guest_counter),  	'LEGEND'						=> $legend, -	'PAGE_NUMBER'					=> phpbb_on_page($template, $user, $base_url, $counter, $config['topics_per_page'], $start), +	'PAGE_NUMBER'					=> $pagination->on_page($base_url, $counter, $config['topics_per_page'], $start),  	'U_SORT_USERNAME'		=> append_sid("{$phpbb_root_path}viewonline.$phpEx", 'sk=a&sd=' . (($sort_key == 'a' && $sort_dir == 'a') ? 'd' : 'a') . '&sg=' . ((int) $show_guests)),  	'U_SORT_UPDATED'		=> append_sid("{$phpbb_root_path}viewonline.$phpEx", 'sk=b&sd=' . (($sort_key == 'b' && $sort_dir == 'a') ? 'd' : 'a') . '&sg=' . ((int) $show_guests)), diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index dd4f7e1b19..14040176cb 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -43,6 +43,8 @@ $sort_dir	= request_var('sd', $default_sort_dir);  $update		= request_var('update', false); +$pagination = $phpbb_container->get('pagination'); +  $s_can_vote = false;  /**  * @todo normalize? @@ -434,10 +436,7 @@ if ($hilit_words)  }  // Make sure $start is set to the last page if it exceeds the amount -if ($start < 0 || $start >= $total_posts) -{ -	$start = ($start < 0) ? 0 : floor(($total_posts - 1) / $config['posts_per_page']) * $config['posts_per_page']; -} +$start = $pagination->validate_start($start, $config['posts_per_page'], $total_posts);  // General Viewtopic URL for return links  $viewtopic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start") . ((strlen($u_sort_param)) ? "&$u_sort_param" : '') . (($highlight_match) ? "&hilit=$highlight" : '')); @@ -591,7 +590,7 @@ if (!empty($_EXTRA_URL))  // If we've got a hightlight set pass it on to pagination.  $base_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . ((strlen($u_sort_param)) ? "&$u_sort_param" : '') . (($highlight_match) ? "&hilit=$highlight" : '')); -phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $total_posts, $config['posts_per_page'], $start); +$pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_posts, $config['posts_per_page'], $start);  // Send vars to template  $template->assign_vars(array( @@ -606,7 +605,7 @@ $template->assign_vars(array(  	'TOPIC_AUTHOR_COLOUR'	=> get_username_string('colour', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']),  	'TOPIC_AUTHOR'			=> get_username_string('username', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']), -	'PAGE_NUMBER' 	=> phpbb_on_page($template, $user, $base_url, $total_posts, $config['posts_per_page'], $start), +	'PAGE_NUMBER' 	=> $pagination->on_page($base_url, $total_posts, $config['posts_per_page'], $start),  	'TOTAL_POSTS'	=> $user->lang('VIEW_TOPIC_POSTS', (int) $total_posts),  	'U_MCP' 		=> ($auth->acl_get('m_', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&mode=topic_view&f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start") . ((strlen($u_sort_param)) ? "&$u_sort_param" : ''), true, $user->session_id) : '',  	'MODERATORS'	=> (isset($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id])) ? implode($user->lang['COMMA_SEPARATOR'], $forum_moderators[$forum_id]) : '', @@ -910,14 +909,11 @@ if ($start > $total_posts / 2)  {  	$store_reverse = true; -	if ($start + $config['posts_per_page'] > $total_posts) -	{ -		$sql_limit = min($config['posts_per_page'], max(1, $total_posts - $start)); -	} -  	// Select the sort order  	$direction = (($sort_dir == 'd') ? 'ASC' : 'DESC'); -	$sql_start = max(0, $total_posts - $sql_limit - $start); + +	$sql_limit = $pagination->reverse_limit($start, $sql_limit, $total_posts); +	$sql_start = $pagination->reverse_start($start, $sql_limit, $total_posts);  }  else  { @@ -1909,7 +1905,7 @@ if (!request_var('t', 0) && !empty($topic_id))  	$request->overwrite('t', $topic_id);  } -$page_title = $topic_data['topic_title'] . ($start ? ' - ' . sprintf($user->lang['PAGE_TITLE_NUMBER'], floor($start / $config['posts_per_page']) + 1) : ''); +$page_title = $topic_data['topic_title'] . ($start ? ' - ' . sprintf($user->lang['PAGE_TITLE_NUMBER'], $pagination->get_on_page($config['topics_per_page'], $start)) : '');  /**  * You can use this event to modify the page title of the viewtopic page diff --git a/tests/avatar/driver/barfoo.php b/tests/avatar/driver/barfoo.php index 11c100db36..0bf30b8a91 100644 --- a/tests/avatar/driver/barfoo.php +++ b/tests/avatar/driver/barfoo.php @@ -18,4 +18,9 @@ class barfoo extends \phpbb\avatar\driver\driver  	{
  		return false;
  	}
 +
 +	public function get_template_name()
 +	{
 +		return 'barfoo.html';
 +	}
  }
 diff --git a/tests/avatar/driver/foobar.php b/tests/avatar/driver/foobar.php index a1e7bdf7cc..aabdaf5ac4 100644 --- a/tests/avatar/driver/foobar.php +++ b/tests/avatar/driver/foobar.php @@ -18,4 +18,9 @@ class foobar extends \phpbb\avatar\driver\driver  	{
  		return false;
  	}
 +
 +	public function get_template_name()
 +	{
 +		return 'foobar.html';
 +	}
  }
 diff --git a/tests/extension/ext/barfoo/composer.json b/tests/extension/ext/barfoo/composer.json new file mode 100644 index 0000000000..35d5d2a956 --- /dev/null +++ b/tests/extension/ext/barfoo/composer.json @@ -0,0 +1,22 @@ +{ +	"name": "vendor/barfoo", +	"type": "phpbb-extension", +	"description": "An example/sample extension to be used for testing purposes in phpBB Development.", +	"version": "1.0.0", +	"time": "2012-02-15 01:01:01", +	"licence": "GNU GPL v2", +	"authors": [{ +			"name": "John Smith", +			"username": "JohnSmith27", +			"email": "email@phpbb.com", +			"homepage": "http://phpbb.com", +			"role": "N/A" +		}], +	"require": { +		"php": ">=5.3", +		"phpbb/phpbb": "3.1.*@dev" +	}, +	"extra": { +		"display-name": "phpBB BarFoo Extension" +	} +} diff --git a/tests/extension/ext/barfoo/ext.php b/tests/extension/ext/barfoo/ext.php index 1b7bb7ca5e..0de403424c 100644 --- a/tests/extension/ext/barfoo/ext.php +++ b/tests/extension/ext/barfoo/ext.php @@ -1,6 +1,6 @@  <?php -namespace barfoo; +namespace vendor\barfoo;  class ext extends \phpbb\extension\base  { diff --git a/tests/extension/ext/vendor/moo/composer.json b/tests/extension/ext/vendor/moo/composer.json index 4dc36963b3..901cb7f17a 100644 --- a/tests/extension/ext/vendor/moo/composer.json +++ b/tests/extension/ext/vendor/moo/composer.json @@ -1,5 +1,5 @@  { -	"name": "moo/example", +	"name": "vendor/moo",  	"type": "phpbb-extension",  	"description": "An example/sample extension to be used for testing purposes in phpBB Development.",  	"version": "1.0.0", diff --git a/tests/extension/ext/barfoo/acp/a_info.php b/tests/extension/ext/vendor2/bar/acp/a_info.php index ea07189f7a..8132df587f 100644 --- a/tests/extension/ext/barfoo/acp/a_info.php +++ b/tests/extension/ext/vendor2/bar/acp/a_info.php @@ -1,14 +1,14 @@  <?php -namespace barfoo\acp; +namespace vendor2\bar\acp;  class a_info  {  	public function module()  	{  		return array( -			'filename'	=> 'barfoo\\acp\\a_module', -			'title'		=> 'Barfoo', +			'filename'	=> 'vendor2\\bar\\acp\\a_module', +			'title'		=> 'Bar',  			'version'	=> '3.1.0-dev',  			'modes'		=> array(  				'config'		=> array('title' => 'Config',	'auth' => '', 'cat' => array('ACP_MODS')), diff --git a/tests/extension/ext/barfoo/acp/a_module.php b/tests/extension/ext/vendor2/bar/acp/a_module.php index 0ae8775013..3a3d105790 100644 --- a/tests/extension/ext/barfoo/acp/a_module.php +++ b/tests/extension/ext/vendor2/bar/acp/a_module.php @@ -1,6 +1,6 @@  <?php -namespace barfoo\acp; +namespace vendor2\bar\acp;  class a_module  { diff --git a/tests/extension/ext/vendor2/bar/composer.json b/tests/extension/ext/vendor2/bar/composer.json new file mode 100644 index 0000000000..5d60ec031e --- /dev/null +++ b/tests/extension/ext/vendor2/bar/composer.json @@ -0,0 +1,21 @@ +{ +	"name": "vendor2/bar", +	"type": "phpbb-extension", +	"description": "An example/sample extension to be used for testing purposes in phpBB Development.", +	"version": "1.0.0", +	"time": "2012-02-15 01:01:01", +	"licence": "GPL-2.0", +	"authors": [{ +			"name": "John Smith", +			"email": "email@phpbb.com", +			"homepage": "http://phpbb.com", +			"role": "N/A" +		}], +	"require": { +		"php": ">=5.3", +		"phpbb/phpbb": "3.1.*@dev" +	}, +	"extra": { +		"display-name": "phpBB Bar Extension" +	} +} diff --git a/tests/extension/ext/bar/ext.php b/tests/extension/ext/vendor2/bar/ext.php index 22ff5e8077..f94ab9ad81 100644 --- a/tests/extension/ext/bar/ext.php +++ b/tests/extension/ext/vendor2/bar/ext.php @@ -1,6 +1,6 @@  <?php -namespace bar; +namespace vendor2\bar;  class ext extends \phpbb\extension\base  { diff --git a/tests/extension/ext/foo/a_class.php b/tests/extension/ext/vendor2/foo/a_class.php index 9db45a697f..06278c0e0c 100644 --- a/tests/extension/ext/foo/a_class.php +++ b/tests/extension/ext/vendor2/foo/a_class.php @@ -1,6 +1,6 @@  <?php -namespace foo; +namespace vendor2\foo;  class a_class  { diff --git a/tests/extension/ext/foo/acp/a_info.php b/tests/extension/ext/vendor2/foo/acp/a_info.php index 3b7d8cdd42..27e67c1556 100644 --- a/tests/extension/ext/foo/acp/a_info.php +++ b/tests/extension/ext/vendor2/foo/acp/a_info.php @@ -1,13 +1,13 @@  <?php -namespace foo\acp; +namespace vendor2\foo\acp;  class a_info  {  	public function module()  	{  		return array( -			'filename'	=> 'foo\\acp\\a_module', +			'filename'	=> 'vendor2\\foo\\acp\\a_module',  			'title'		=> 'Foobar',  			'version'	=> '3.1.0-dev',  			'modes'		=> array( diff --git a/tests/extension/ext/foo/mcp/a_module.php b/tests/extension/ext/vendor2/foo/acp/a_module.php index ca397e7004..78d91af2fe 100644 --- a/tests/extension/ext/foo/mcp/a_module.php +++ b/tests/extension/ext/vendor2/foo/acp/a_module.php @@ -1,6 +1,6 @@  <?php -namespace foo\mcp; +namespace vendor2\foo\acp;  class a_module  { diff --git a/tests/extension/ext/foo/acp/fail_info.php b/tests/extension/ext/vendor2/foo/acp/fail_info.php index 01d29fc5eb..d9b4353957 100644 --- a/tests/extension/ext/foo/acp/fail_info.php +++ b/tests/extension/ext/vendor2/foo/acp/fail_info.php @@ -1,6 +1,6 @@  <?php -namespace foo\acp; +namespace vendor2\foo\acp;  /*  * Due to the mismatch between the class name and the file name, this module @@ -11,7 +11,7 @@ class foo_info  	public function module()  	{  		return array( -			'filename'	=> 'foo\acp\fail_module', +			'filename'	=> 'vendor2\foo\acp\fail_module',  			'title'		=> 'Foobar',  			'version'	=> '3.1.0-dev',  			'modes'		=> array( diff --git a/tests/extension/ext/foo/acp/fail_module.php b/tests/extension/ext/vendor2/foo/acp/fail_module.php index 8070929d3c..c8a5eae745 100644 --- a/tests/extension/ext/foo/acp/fail_module.php +++ b/tests/extension/ext/vendor2/foo/acp/fail_module.php @@ -1,6 +1,6 @@  <?php -namespace foo\acp; +namespace vendor2\foo\acp;  /*  * Due to the mismatch between the class name and the file name of the module diff --git a/tests/extension/ext/foo/b_class.php b/tests/extension/ext/vendor2/foo/b_class.php index bb2a77c05e..3d0f193908 100644 --- a/tests/extension/ext/foo/b_class.php +++ b/tests/extension/ext/vendor2/foo/b_class.php @@ -1,6 +1,6 @@  <?php -namespace foo; +namespace vendor2\foo;  class b_class  { diff --git a/tests/extension/ext/foo/composer.json b/tests/extension/ext/vendor2/foo/composer.json index 5367eaf593..8821d9d50e 100644 --- a/tests/extension/ext/foo/composer.json +++ b/tests/extension/ext/vendor2/foo/composer.json @@ -1,5 +1,5 @@  { -	"name": "foo/example", +	"name": "vendor2/foo",  	"type": "phpbb-extension",  	"description": "An example/sample extension to be used for testing purposes in phpBB Development.",  	"version": "1.0.0", diff --git a/tests/extension/ext/foo/ext.php b/tests/extension/ext/vendor2/foo/ext.php index ac6098f2f1..15480fe92a 100644 --- a/tests/extension/ext/foo/ext.php +++ b/tests/extension/ext/vendor2/foo/ext.php @@ -1,6 +1,6 @@  <?php -namespace foo; +namespace vendor2\foo;  class ext extends \phpbb\extension\base  { diff --git a/tests/extension/ext/foo/mcp/a_info.php b/tests/extension/ext/vendor2/foo/mcp/a_info.php index 9a896ce808..b5599fde65 100644 --- a/tests/extension/ext/foo/mcp/a_info.php +++ b/tests/extension/ext/vendor2/foo/mcp/a_info.php @@ -1,13 +1,13 @@  <?php -namespace foo\mcp; +namespace vendor2\foo\mcp;  class a_info  {  	public function module()  	{  		return array( -			'filename'	=> 'foo\\mcp\\a_module', +			'filename'	=> 'vendor2\\foo\\mcp\\a_module',  			'title'		=> 'Foobar',  			'version'	=> '3.1.0-dev',  			'modes'		=> array( diff --git a/tests/extension/ext/foo/acp/a_module.php b/tests/extension/ext/vendor2/foo/mcp/a_module.php index 7aa2351ab3..fe29783827 100644 --- a/tests/extension/ext/foo/acp/a_module.php +++ b/tests/extension/ext/vendor2/foo/mcp/a_module.php @@ -1,6 +1,6 @@  <?php -namespace foo\acp; +namespace vendor2\foo\mcp;  class a_module  { diff --git a/tests/extension/ext/foo/sub/type/alternative.php b/tests/extension/ext/vendor2/foo/sub/type/alternative.php index 1eaf794609..1eaf794609 100644 --- a/tests/extension/ext/foo/sub/type/alternative.php +++ b/tests/extension/ext/vendor2/foo/sub/type/alternative.php diff --git a/tests/extension/ext/foo/type/alternative.php b/tests/extension/ext/vendor2/foo/type/alternative.php index 8f753491ef..8f753491ef 100644 --- a/tests/extension/ext/foo/type/alternative.php +++ b/tests/extension/ext/vendor2/foo/type/alternative.php diff --git a/tests/extension/ext/foo/type/dummy/empty.txt b/tests/extension/ext/vendor2/foo/type/dummy/empty.txt index e69de29bb2..e69de29bb2 100644 --- a/tests/extension/ext/foo/type/dummy/empty.txt +++ b/tests/extension/ext/vendor2/foo/type/dummy/empty.txt diff --git a/tests/extension/ext/foo/typewrong/error.php b/tests/extension/ext/vendor2/foo/typewrong/error.php index 5020926043..5020926043 100644 --- a/tests/extension/ext/foo/typewrong/error.php +++ b/tests/extension/ext/vendor2/foo/typewrong/error.php diff --git a/tests/extension/ext/vendor3/bar/ext.php b/tests/extension/ext/vendor3/bar/ext.php new file mode 100644 index 0000000000..37a5e92059 --- /dev/null +++ b/tests/extension/ext/vendor3/bar/ext.php @@ -0,0 +1,26 @@ +<?php + +namespace vendor3\bar; + +class ext extends \phpbb\extension\base +{ +	static public $state; + +	public function enable_step($old_state) +	{ +		// run 4 steps, then quit +		if ($old_state === 4) +		{ +			return false; +		} + +		if ($old_state === false) +		{ +			$old_state = 0; +		} + +		self::$state = ++$old_state; + +		return self::$state; +	} +} diff --git a/tests/extension/ext/bar/my/hidden_class.php b/tests/extension/ext/vendor3/bar/my/hidden_class.php index 504c1873dc..38eb59aadf 100644 --- a/tests/extension/ext/bar/my/hidden_class.php +++ b/tests/extension/ext/vendor3/bar/my/hidden_class.php @@ -1,6 +1,6 @@  <?php -namespace bar\my; +namespace vendor3\bar\my;  class hidden_class  { diff --git a/tests/extension/ext/bar/styles/prosilver/template/foobar_body.html b/tests/extension/ext/vendor3/bar/styles/prosilver/template/foobar_body.html index 00c2a84a18..00c2a84a18 100644 --- a/tests/extension/ext/bar/styles/prosilver/template/foobar_body.html +++ b/tests/extension/ext/vendor3/bar/styles/prosilver/template/foobar_body.html diff --git a/tests/extension/finder_test.php b/tests/extension/finder_test.php index 8e6e71aaf8..d0ca5956b4 100644 --- a/tests/extension/finder_test.php +++ b/tests/extension/finder_test.php @@ -18,15 +18,15 @@ class phpbb_extension_finder_test extends phpbb_test_case  		$this->extension_manager = new phpbb_mock_extension_manager(  			dirname(__FILE__) . '/',  			array( -				'foo' => array( -					'ext_name' => 'foo', +				'vendor2/foo' => array( +					'ext_name' => 'vendor2/foo',  					'ext_active' => '1', -					'ext_path' => 'ext/foo/', +					'ext_path' => 'ext/vendor2/foo/',  				), -				'bar' => array( -					'ext_name' => 'bar', +				'vendor3/bar' => array( +					'ext_name' => 'vendor3/bar',  					'ext_active' => '1', -					'ext_path' => 'ext/bar/', +					'ext_path' => 'ext/vendor3/bar/',  				),  			)); @@ -43,10 +43,10 @@ class phpbb_extension_finder_test extends phpbb_test_case  		sort($classes);  		$this->assertEquals(  			array( -				'\bar\my\hidden_class', -				'\foo\a_class', -				'\foo\b_class',  				'\phpbb\default\implementation', +				'\vendor2\foo\a_class', +				'\vendor2\foo\b_class', +				'\vendor3\bar\my\hidden_class',  			),  			$classes  		); @@ -60,7 +60,7 @@ class phpbb_extension_finder_test extends phpbb_test_case  		sort($dirs);  		$this->assertEquals(array( -			dirname(__FILE__) . '/ext/foo/type/', +			dirname(__FILE__) . '/ext/vendor2/foo/type/',  		), $dirs);  	} @@ -72,9 +72,9 @@ class phpbb_extension_finder_test extends phpbb_test_case  		sort($dirs);  		$this->assertEquals(array( -			dirname(__FILE__) . '/ext/foo/sub/type/', -			dirname(__FILE__) . '/ext/foo/type/', -			dirname(__FILE__) . '/ext/foo/typewrong/', +			dirname(__FILE__) . '/ext/vendor2/foo/sub/type/', +			dirname(__FILE__) . '/ext/vendor2/foo/type/', +			dirname(__FILE__) . '/ext/vendor2/foo/typewrong/',  		), $dirs);  	} @@ -88,8 +88,8 @@ class phpbb_extension_finder_test extends phpbb_test_case  		sort($classes);  		$this->assertEquals(  			array( -				'\bar\my\hidden_class',  				'\phpbb\default\implementation', +				'\vendor3\bar\my\hidden_class',  			),  			$classes  		); @@ -105,9 +105,9 @@ class phpbb_extension_finder_test extends phpbb_test_case  		sort($classes);  		$this->assertEquals(  			array( -				'\foo\sub\type\alternative', -				'\foo\type\alternative',  				'\phpbb\default\implementation', +				'\vendor2\foo\sub\type\alternative', +				'\vendor2\foo\type\alternative',  			),  			$classes  		); @@ -122,7 +122,7 @@ class phpbb_extension_finder_test extends phpbb_test_case  		sort($classes);  		$this->assertEquals(  			array( -				'\foo\type\alternative', +				'\vendor2\foo\type\alternative',  			),  			$classes  		); @@ -137,7 +137,7 @@ class phpbb_extension_finder_test extends phpbb_test_case  		sort($classes);  		$this->assertEquals(  			array( -				'\foo\sub\type\alternative', +				'\vendor2\foo\sub\type\alternative',  			),  			$classes  		); @@ -152,7 +152,7 @@ class phpbb_extension_finder_test extends phpbb_test_case  		sort($classes);  		$this->assertEquals(  			array( -				'\foo\sub\type\alternative', +				'\vendor2\foo\sub\type\alternative',  			),  			$classes  		); @@ -162,14 +162,14 @@ class phpbb_extension_finder_test extends phpbb_test_case  	{  		$files = $this->finder  			->extension_directory('/type') -			->find_from_extension('foo', dirname(__FILE__) . '/ext/foo/'); +			->find_from_extension('vendor2/foo', dirname(__FILE__) . '/ext/vendor2/foo/');  		$classes = $this->finder->get_classes_from_files($files);  		sort($classes);  		$this->assertEquals(  			array( -				'\foo\type\alternative', -				'\foo\type\dummy\empty', +				'\vendor2\foo\type\alternative', +				'\vendor2\foo\type\dummy\empty',  			),  			$classes  		); diff --git a/tests/extension/fixtures/extensions.xml b/tests/extension/fixtures/extensions.xml index 6eb6fd11a5..6846162f0f 100644 --- a/tests/extension/fixtures/extensions.xml +++ b/tests/extension/fixtures/extensions.xml @@ -5,7 +5,7 @@  		<column>ext_active</column>  		<column>ext_state</column>  		<row> -			<value>foo</value> +			<value>vendor2/foo</value>  			<value>1</value>  			<value></value>  		</row> diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php index b127daf2ed..cc32a6af4e 100644 --- a/tests/extension/manager_test.php +++ b/tests/extension/manager_test.php @@ -7,8 +7,8 @@  *  */ -require_once dirname(__FILE__) . '/ext/bar/ext.php'; -require_once dirname(__FILE__) . '/ext/foo/ext.php'; +require_once dirname(__FILE__) . '/ext/vendor2/bar/ext.php'; +require_once dirname(__FILE__) . '/ext/vendor2/foo/ext.php';  require_once dirname(__FILE__) . '/ext/vendor/moo/ext.php';  class phpbb_extension_manager_test extends phpbb_database_test_case @@ -30,52 +30,53 @@ class phpbb_extension_manager_test extends phpbb_database_test_case  	public function test_available()  	{ -		$this->assertEquals(array('bar', 'barfoo', 'foo', 'vendor/moo'), array_keys($this->extension_manager->all_available())); +		// barfoo and vendor3/bar should not listed due to missing composer.json. barfoo also has incorrect dir structure. +		$this->assertEquals(array('vendor/moo', 'vendor2/bar', 'vendor2/foo'), array_keys($this->extension_manager->all_available()));  	}  	public function test_enabled()  	{ -		$this->assertEquals(array('foo'), array_keys($this->extension_manager->all_enabled())); +		$this->assertEquals(array('vendor2/foo'), array_keys($this->extension_manager->all_enabled()));  	}  	public function test_configured()  	{ -		$this->assertEquals(array('foo', 'vendor/moo'), array_keys($this->extension_manager->all_configured())); +		$this->assertEquals(array('vendor/moo', 'vendor2/foo'), array_keys($this->extension_manager->all_configured()));  	}  	public function test_enable()  	{ -		bar\ext::$state = 0; +		vendor2\bar\ext::$state = 0; -		$this->assertEquals(array('foo'), array_keys($this->extension_manager->all_enabled())); -		$this->extension_manager->enable('bar'); -		$this->assertEquals(array('bar', 'foo'), array_keys($this->extension_manager->all_enabled())); -		$this->assertEquals(array('bar', 'foo', 'vendor/moo'), array_keys($this->extension_manager->all_configured())); +		$this->assertEquals(array('vendor2/foo'), array_keys($this->extension_manager->all_enabled())); +		$this->extension_manager->enable('vendor2/bar'); +		$this->assertEquals(array('vendor2/bar', 'vendor2/foo'), array_keys($this->extension_manager->all_enabled())); +		$this->assertEquals(array('vendor/moo', 'vendor2/bar', 'vendor2/foo'), array_keys($this->extension_manager->all_configured())); -		$this->assertEquals(4, bar\ext::$state); +		$this->assertEquals(4, vendor2\bar\ext::$state);  	}  	public function test_disable()  	{ -		foo\ext::$disabled = false; +		vendor2\foo\ext::$disabled = false; -		$this->assertEquals(array('foo'), array_keys($this->extension_manager->all_enabled())); -		$this->extension_manager->disable('foo'); +		$this->assertEquals(array('vendor2/foo'), array_keys($this->extension_manager->all_enabled())); +		$this->extension_manager->disable('vendor2/foo');  		$this->assertEquals(array(), array_keys($this->extension_manager->all_enabled())); -		$this->assertEquals(array('foo', 'vendor/moo'), array_keys($this->extension_manager->all_configured())); +		$this->assertEquals(array('vendor/moo', 'vendor2/foo'), array_keys($this->extension_manager->all_configured())); -		$this->assertTrue(foo\ext::$disabled); +		$this->assertTrue(vendor2\foo\ext::$disabled);  	}  	public function test_purge()  	{  		vendor\moo\ext::$purged = false; -		$this->assertEquals(array('foo'), array_keys($this->extension_manager->all_enabled())); -		$this->assertEquals(array('foo', 'vendor/moo'), array_keys($this->extension_manager->all_configured())); +		$this->assertEquals(array('vendor2/foo'), array_keys($this->extension_manager->all_enabled())); +		$this->assertEquals(array('vendor/moo', 'vendor2/foo'), array_keys($this->extension_manager->all_configured()));  		$this->extension_manager->purge('vendor/moo'); -		$this->assertEquals(array('foo'), array_keys($this->extension_manager->all_enabled())); -		$this->assertEquals(array('foo'), array_keys($this->extension_manager->all_configured())); +		$this->assertEquals(array('vendor2/foo'), array_keys($this->extension_manager->all_enabled())); +		$this->assertEquals(array('vendor2/foo'), array_keys($this->extension_manager->all_configured()));  		$this->assertTrue(vendor\moo\ext::$purged);  	} @@ -84,7 +85,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case  	{  		$extension_manager = $this->create_extension_manager(false); -		$this->assertEquals(array('foo'), array_keys($extension_manager->all_enabled())); +		$this->assertEquals(array('vendor2/foo'), array_keys($extension_manager->all_enabled()));  	}  	protected function create_extension_manager($with_cache = true) diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php index 09eb83cd86..592421f9e7 100644 --- a/tests/extension/metadata_manager_test.php +++ b/tests/extension/metadata_manager_test.php @@ -82,7 +82,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case  	// Should fail from missing composer.json  	public function test_bar()  	{ -		$ext_name = 'bar'; +		$ext_name = 'vendor3/bar';  		$manager = $this->get_metadata_manager($ext_name); @@ -98,7 +98,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case  	// Should be the same as a direct json_decode of the composer.json file  	public function test_foo()  	{ -		$ext_name = 'foo'; +		$ext_name = 'vendor2/foo';  		$manager = $this->get_metadata_manager($ext_name); @@ -111,7 +111,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case  			$this->fail($e);  		} -		$json = json_decode(file_get_contents($this->phpbb_root_path . 'ext/foo/composer.json'), true); +		$json = json_decode(file_get_contents($this->phpbb_root_path . 'ext/vendor2/foo/composer.json'), true);  		$this->assertEquals($metadata, $json);  	} diff --git a/tests/extension/modules_test.php b/tests/extension/modules_test.php index ef21c943c2..5dcb24c691 100644 --- a/tests/extension/modules_test.php +++ b/tests/extension/modules_test.php @@ -7,10 +7,10 @@  *  */ -require_once dirname(__FILE__) . '/ext/foo/acp/a_info.php'; -require_once dirname(__FILE__) . '/ext/foo/mcp/a_info.php'; -require_once dirname(__FILE__) . '/ext/foo/acp/fail_info.php'; -require_once dirname(__FILE__) . '/ext/barfoo/acp/a_info.php'; +require_once dirname(__FILE__) . '/ext/vendor2/foo/acp/a_info.php'; +require_once dirname(__FILE__) . '/ext/vendor2/foo/mcp/a_info.php'; +require_once dirname(__FILE__) . '/ext/vendor2/foo/acp/fail_info.php'; +require_once dirname(__FILE__) . '/ext/vendor2/bar/acp/a_info.php';  require_once dirname(__FILE__) . '/../../phpBB/includes/acp/acp_modules.php';  class phpbb_extension_modules_test extends phpbb_test_case @@ -25,15 +25,15 @@ class phpbb_extension_modules_test extends phpbb_test_case  		$this->extension_manager = new phpbb_mock_extension_manager(  			dirname(__FILE__) . '/',  			array( -				'foo' => array( -					'ext_name' => 'foo', +				'vendor2/foo' => array( +					'ext_name' => 'vendor2/foo',  					'ext_active' => '1', -					'ext_path' => 'ext/foo/', +					'ext_path' => 'ext/vendor2/foo/',  				), -				'bar' => array( -					'ext_name' => 'bar', +				'vendor3/bar' => array( +					'ext_name' => 'vendor3/bar',  					'ext_active' => '1', -					'ext_path' => 'ext/bar/', +					'ext_path' => 'ext/vendor3/bar/',  				),  			));  		$phpbb_extension_manager = $this->extension_manager; @@ -54,8 +54,8 @@ class phpbb_extension_modules_test extends phpbb_test_case  		$this->acp_modules->module_class = 'acp';  		$acp_modules = $this->acp_modules->get_module_infos();  		$this->assertEquals(array( -				'foo\\acp\\a_module' => array( -					'filename'	=> 'foo\\acp\\a_module', +				'vendor2\\foo\\acp\\a_module' => array( +					'filename'	=> 'vendor2\\foo\\acp\\a_module',  					'title'		=> 'Foobar',  					'version'	=> '3.1.0-dev',  					'modes'		=> array( @@ -76,8 +76,8 @@ class phpbb_extension_modules_test extends phpbb_test_case  		$this->acp_modules->module_class = 'mcp';  		$acp_modules = $this->acp_modules->get_module_infos();  		$this->assertEquals(array( -				'foo\\mcp\\a_module' => array( -					'filename'	=> 'foo\\mcp\\a_module', +				'vendor2\\foo\\mcp\\a_module' => array( +					'filename'	=> 'vendor2\\foo\\mcp\\a_module',  					'title'		=> 'Foobar',  					'version'	=> '3.1.0-dev',  					'modes'		=> array( @@ -90,8 +90,8 @@ class phpbb_extension_modules_test extends phpbb_test_case  		$this->acp_modules->module_class = 'mcp';  		$acp_modules = $this->acp_modules->get_module_infos('mcp_a_module');  		$this->assertEquals(array( -				'foo\\mcp\\a_module' => array( -					'filename'	=> 'foo\\mcp\\a_module', +				'vendor2\\foo\\mcp\\a_module' => array( +					'filename'	=> 'vendor2\\foo\\mcp\\a_module',  					'title'		=> 'Foobar',  					'version'	=> '3.1.0-dev',  					'modes'		=> array( @@ -104,8 +104,8 @@ class phpbb_extension_modules_test extends phpbb_test_case  		$this->acp_modules->module_class = '';  		$acp_modules = $this->acp_modules->get_module_infos('mcp_a_module', 'mcp');  		$this->assertEquals(array( -				'foo\\mcp\\a_module' => array( -					'filename'	=> 'foo\\mcp\\a_module', +				'vendor2\\foo\\mcp\\a_module' => array( +					'filename'	=> 'vendor2\\foo\\mcp\\a_module',  					'title'		=> 'Foobar',  					'version'	=> '3.1.0-dev',  					'modes'		=> array( @@ -128,8 +128,8 @@ class phpbb_extension_modules_test extends phpbb_test_case  		$this->acp_modules->module_class = 'acp';  		$acp_modules = $this->acp_modules->get_module_infos('foo_acp_a_module');  		$this->assertEquals(array( -				'foo\\acp\\a_module' => array ( -					'filename' => 'foo\\acp\\a_module', +				'vendor2\\foo\\acp\\a_module' => array ( +					'filename' => 'vendor2\\foo\\acp\\a_module',  					'title' => 'Foobar',  					'version' => '3.1.0-dev',  					'modes' => array ( @@ -148,12 +148,12 @@ class phpbb_extension_modules_test extends phpbb_test_case  		$this->assertEquals(array(), $acp_modules);  		// No specific module, module class set to false (will default to the above acp) -		// Setting $use_all_available will cause get_module_infos() to also load not enabled extensions (barfoo) +		// Setting $use_all_available will cause get_module_infos() to also load not enabled extensions (vendor2/bar)  		$this->acp_modules->module_class = 'acp';  		$acp_modules = $this->acp_modules->get_module_infos('', false, true);  		$this->assertEquals(array( -				'foo\\acp\\a_module' => array( -					'filename'	=> 'foo\\acp\\a_module', +				'vendor2\\foo\\acp\\a_module' => array( +					'filename'	=> 'vendor2\\foo\\acp\\a_module',  					'title'		=> 'Foobar',  					'version'	=> '3.1.0-dev',  					'modes'		=> array( @@ -168,9 +168,9 @@ class phpbb_extension_modules_test extends phpbb_test_case  						'test'		=> array('title' => 'Test', 'auth' => '', 'cat' => array('ACP_GENERAL')),  					),  				), -				'barfoo\\acp\\a_module' => array( -					'filename'	=> 'barfoo\\acp\\a_module', -					'title'		=> 'Barfoo', +				'vendor2\\bar\\acp\\a_module' => array( +					'filename'	=> 'vendor2\\bar\\acp\\a_module', +					'title'		=> 'Bar',  					'version'	=> '3.1.0-dev',  					'modes'		=> array(  						'config'		=> array('title' => 'Config',	'auth' => '', 'cat' => array('ACP_MODS')), @@ -179,11 +179,11 @@ class phpbb_extension_modules_test extends phpbb_test_case  			), $acp_modules);  		// Specific module set to disabled extension -		$acp_modules = $this->acp_modules->get_module_infos('barfoo_acp_a_module', 'acp', true); +		$acp_modules = $this->acp_modules->get_module_infos('vendor2_bar_acp_a_module', 'acp', true);  		$this->assertEquals(array( -				'barfoo\\acp\\a_module' => array( -					'filename'	=> 'barfoo\\acp\\a_module', -					'title'		=> 'Barfoo', +				'vendor2\\bar\\acp\\a_module' => array( +					'filename'	=> 'vendor2\\bar\\acp\\a_module', +					'title'		=> 'Bar',  					'version'	=> '3.1.0-dev',  					'modes'		=> array(  						'config'		=> array('title' => 'Config',	'auth' => '', 'cat' => array('ACP_MODS')), diff --git a/tests/functional/extension_acp_test.php b/tests/functional/extension_acp_test.php index 5d391e42f7..53f62c4f19 100644 --- a/tests/functional/extension_acp_test.php +++ b/tests/functional/extension_acp_test.php @@ -45,7 +45,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case  		// Insert our base data  		$insert_rows = array(  			array( -				'ext_name'		=> 'foo', +				'ext_name'		=> 'vendor2/foo',  				'ext_active'	=> true,  				'ext_state'		=> 'b:0;',  			), @@ -57,12 +57,12 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case  			// do not exist  			array( -				'ext_name'		=> 'test2', +				'ext_name'		=> 'vendor/test2',  				'ext_active'	=> true,  				'ext_state'		=> 'b:0;',  			),  			array( -				'ext_name'		=> 'test3', +				'ext_name'		=> 'vendor/test3',  				'ext_active'	=> false,  				'ext_state'		=> 'b:0;',  			), @@ -80,30 +80,38 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case  		$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid);  		$this->assertCount(1, $crawler->filter('.ext_enabled')); -		$this->assertCount(5, $crawler->filter('.ext_disabled')); +		$this->assertCount(4, $crawler->filter('.ext_disabled'));  		$this->assertContains('phpBB Foo Extension', $crawler->filter('.ext_enabled')->eq(0)->text());  		$this->assertContainsLang('EXTENSION_DISABLE', $crawler->filter('.ext_enabled')->eq(0)->text()); -		$this->assertContains('The “test2” extension is not valid.', $crawler->filter('.ext_disabled')->eq(0)->text()); +		$this->assertContains('phpBB Moo Extension', $crawler->filter('.ext_disabled')->eq(1)->text()); +		$this->assertContainsLang('DETAILS', $crawler->filter('.ext_disabled')->eq(1)->text()); +		$this->assertContainsLang('EXTENSION_ENABLE', $crawler->filter('.ext_disabled')->eq(1)->text()); +		$this->assertContainsLang('EXTENSION_DELETE_DATA', $crawler->filter('.ext_disabled')->eq(1)->text()); -		$this->assertContains('The “test3” extension is not valid.', $crawler->filter('.ext_disabled')->eq(1)->text()); +		$this->assertContains('The “vendor/test2” extension is not valid.', $crawler->filter('.ext_disabled')->eq(0)->text()); -		$this->assertContains('phpBB Moo Extension', $crawler->filter('.ext_disabled')->eq(2)->text()); -		$this->assertContainsLang('DETAILS', $crawler->filter('.ext_disabled')->eq(2)->text()); -		$this->assertContainsLang('EXTENSION_ENABLE', $crawler->filter('.ext_disabled')->eq(2)->text()); -		$this->assertContainsLang('EXTENSION_DELETE_DATA', $crawler->filter('.ext_disabled')->eq(2)->text()); +		$this->assertContains('The “vendor/test3” extension is not valid.', $crawler->filter('.ext_disabled')->eq(2)->text()); -		$this->assertContains('The “bar” extension is not valid.', $crawler->filter('.ext_disabled')->eq(3)->text()); +		$this->assertContains('phpBB Bar Extension', $crawler->filter('.ext_disabled')->eq(3)->text()); +		$this->assertContainsLang('DETAILS', $crawler->filter('.ext_disabled')->eq(3)->text()); +		$this->assertContainsLang('EXTENSION_ENABLE', $crawler->filter('.ext_disabled')->eq(3)->text()); + +		// Check that invalid extensions are not listed. +		$this->assertNotContains('phpBB BarFoo Extension', $crawler->filter('.table1')->text()); +		$this->assertNotContains('barfoo', $crawler->filter('.table1')->text()); + +		$this->assertNotContains('vendor3/bar', $crawler->filter('.table1')->text());  	}  	public function test_details()  	{ -		$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=details&ext_name=foo&sid=' . $this->sid); +		$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=details&ext_name=vendor2%2Ffoo&sid=' . $this->sid);  		$validation = array(  			'DISPLAY_NAME'		=> 'phpBB Foo Extension', -			'CLEAN_NAME'		=> 'foo/example', +			'CLEAN_NAME'		=> 'vendor2/foo',  			'TYPE'				=> 'phpbb-extension',  			'DESCRIPTION'		=> 'An example/sample extension to be used for testing purposes in phpBB Development.',  			'VERSION'	  		=> '1.0.0', @@ -143,7 +151,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case  	public function test_enable_pre()  	{  		// Foo is already enabled (redirect to list) -		$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=foo&sid=' . $this->sid); +		$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=vendor2%2Ffoo&sid=' . $this->sid);  		$this->assertContainsLang('EXTENSION_NAME', $crawler->filter('div.main thead')->text());  		$this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('div.main thead')->text());  		$this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('div.main thead')->text()); @@ -160,7 +168,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case  		$this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('div.main thead')->text());  		$this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('div.main thead')->text()); -		$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=foo&sid=' . $this->sid); +		$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=vendor2%2Ffoo&sid=' . $this->sid);  		$this->assertContains($this->lang('EXTENSION_DISABLE_CONFIRM', 'phpBB Foo Extension'), $crawler->filter('.errorbox')->text());  	} @@ -171,7 +179,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case  		$this->assertContains('The required file does not exist', $crawler->filter('.errorbox')->text());  		// foo is not disabled (redirect to list) -		$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=foo&sid=' . $this->sid); +		$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=vendor2%2Ffoo&sid=' . $this->sid);  		$this->assertContainsLang('EXTENSION_NAME', $crawler->filter('div.main thead')->text());  		$this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('div.main thead')->text());  		$this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('div.main thead')->text()); @@ -211,5 +219,9 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case  		$form = $crawler->selectButton('delete_data')->form();  		$crawler = self::submit($form);  		$this->assertContainsLang('EXTENSION_DELETE_DATA_SUCCESS', $crawler->filter('.successbox')->text()); + +		// Attempt to enable invalid extension +		$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=barfoo&sid=' . $this->sid); +		$this->assertContainsLang('EXTENSION_DIR_INVALID', $crawler->filter('.errorbox')->text());  	}  } diff --git a/tests/pagination/generate_template_test.php b/tests/pagination/generate_template_test.php deleted file mode 100644 index 587a948583..0000000000 --- a/tests/pagination/generate_template_test.php +++ /dev/null @@ -1,111 +0,0 @@ -<?php -/** -* -* @package testing -* @copyright (c) 2013 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 -* -*/ - -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../template/template_test_case.php'; - -class phpbb_pagination_generate_template_test extends phpbb_template_template_test_case -{ -	protected $test_path = 'tests/pagination'; - -	public function phpbb_generate_template_pagination_data() -	{ -		return array( -			array( -				'page.php', -				'start', -				95, -				10, -				10, -				'pagination -				:previous::page.php -				:else:1:page.php -				:current:2:page.php?start=10 -				:else:3:page.php?start=20 -				:else:4:page.php?start=30 -				:else:5:page.php?start=40 -				:ellipsis:9:page.php?start=80 -				:else:10:page.php?start=90 -				:next::page.php?start=20 -				:u_prev:page.php -				:u_next:page.php?start=20', -			), -			array( -				'page.php', -				'start', -				95, -				10, -				20, -				'pagination -				:previous::page.php?start=10 -				:else:1:page.php -				:else:2:page.php?start=10 -				:current:3:page.php?start=20 -				:else:4:page.php?start=30 -				:else:5:page.php?start=40 -				:else:6:page.php?start=50 -				:ellipsis:9:page.php?start=80 -				:else:10:page.php?start=90 -				:next::page.php?start=30 -				:u_prev:page.php?start=10 -				:u_next:page.php?start=30', -			), -			array( -				'test/page/%d', -				'/page/%d', -				95, -				10, -				10, -				'pagination -				:previous::test -				:else:1:test -				:current:2:test/page/2 -				:else:3:test/page/3 -				:else:4:test/page/4 -				:else:5:test/page/5 -				:ellipsis:9:test/page/9 -				:else:10:test/page/10 -				:next::test/page/3 -				:u_prev:test -				:u_next:test/page/3', -			), -			array( -				'test/page/%d', -				'/page/%d', -				95, -				10, -				20, -				'pagination -				:previous::test/page/2 -				:else:1:test -				:else:2:test/page/2 -				:current:3:test/page/3 -				:else:4:test/page/4 -				:else:5:test/page/5 -				:else:6:test/page/6 -				:ellipsis:9:test/page/9 -				:else:10:test/page/10 -				:next::test/page/4 -				:u_prev:test/page/2 -				:u_next:test/page/4', -			), -		); -	} - -	/** -	* @dataProvider phpbb_generate_template_pagination_data -	*/ -	public function test_phpbb_generate_template_pagination($base_url, $start_name, $num_items, $per_page, $start_item, $expect) -	{ -		phpbb_generate_template_pagination($this->template, $base_url, 'pagination', $start_name, $num_items, $per_page, $start_item); -		$this->template->set_filenames(array('test' => 'pagination.html')); - -		$this->assertEquals(str_replace("\t", '', $expect), $this->display('test')); -	} -} diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php new file mode 100644 index 0000000000..4e8083b47f --- /dev/null +++ b/tests/pagination/pagination_test.php @@ -0,0 +1,240 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2013 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +require_once dirname(__FILE__) . '/../template/template_test_case.php'; + +class phpbb_pagination_pagination_test extends phpbb_template_template_test_case +{ +	protected $test_path = 'tests/pagination'; + +	public function return_callback_implode() +	{ +		return implode('-', func_get_args()); +	} + +	public function setUp() +	{ +		parent::setUp(); +		$user = $this->getMock('\phpbb\user'); +		$user->expects($this->any()) +			->method('lang') +			->will($this->returnCallback(array($this, 'return_callback_implode'))); +		$this->pagination = new \phpbb\pagination($this->template, $user); +	} + +	public function generate_template_pagination_data() +	{ +		return array( +			array( +				'page.php', +				'start', +				95, +				10, +				10, +				'pagination +				:previous::page.php +				:else:1:page.php +				:current:2:page.php?start=10 +				:else:3:page.php?start=20 +				:else:4:page.php?start=30 +				:else:5:page.php?start=40 +				:ellipsis:9:page.php?start=80 +				:else:10:page.php?start=90 +				:next::page.php?start=20 +				:u_prev:page.php +				:u_next:page.php?start=20', +			), +			array( +				'page.php', +				'start', +				95, +				10, +				20, +				'pagination +				:previous::page.php?start=10 +				:else:1:page.php +				:else:2:page.php?start=10 +				:current:3:page.php?start=20 +				:else:4:page.php?start=30 +				:else:5:page.php?start=40 +				:else:6:page.php?start=50 +				:ellipsis:9:page.php?start=80 +				:else:10:page.php?start=90 +				:next::page.php?start=30 +				:u_prev:page.php?start=10 +				:u_next:page.php?start=30', +			), +			array( +				'test/page/%d', +				'/page/%d', +				95, +				10, +				10, +				'pagination +				:previous::test +				:else:1:test +				:current:2:test/page/2 +				:else:3:test/page/3 +				:else:4:test/page/4 +				:else:5:test/page/5 +				:ellipsis:9:test/page/9 +				:else:10:test/page/10 +				:next::test/page/3 +				:u_prev:test +				:u_next:test/page/3', +			), +			array( +				'test/page/%d', +				'/page/%d', +				95, +				10, +				20, +				'pagination +				:previous::test/page/2 +				:else:1:test +				:else:2:test/page/2 +				:current:3:test/page/3 +				:else:4:test/page/4 +				:else:5:test/page/5 +				:else:6:test/page/6 +				:ellipsis:9:test/page/9 +				:else:10:test/page/10 +				:next::test/page/4 +				:u_prev:test/page/2 +				:u_next:test/page/4', +			), +		); +	} + +	/** +	* @dataProvider generate_template_pagination_data +	*/ +	public function test_generate_template_pagination($base_url, $start_name, $num_items, $per_page, $start_item, $expect) +	{ +		$this->pagination->generate_template_pagination($base_url, 'pagination', $start_name, $num_items, $per_page, $start_item); +		$this->template->set_filenames(array('test' => 'pagination.html')); + +		$this->assertEquals(str_replace("\t", '', $expect), $this->display('test')); +	} + +	public function on_page_data() +	{ +		return array( +			array( +				'page.php', +				10, +				10, +				0, +				'PAGE_OF-1-1', +				'on_page +				per_page:10 +				on_page:1 +				base_url:page.php', +			), +		); +	} + +	/** +	* @dataProvider on_page_data +	*/ +	public function test_on_page($base_url, $num_items, $per_page, $start_item, $expect_return, $expect) +	{ +		$this->assertEquals($expect_return, $this->pagination->on_page($base_url, $num_items, $per_page, $start_item)); + +		$this->template->set_filenames(array('test' => 'on_page.html')); + +		$this->assertEquals(str_replace("\t", '', $expect), $this->display('test')); +	} + +	public function validate_start_data() +	{ +		return array( +			array( +				-1, +				0, +			), +			array( +				0, +				0, +			), +			array( +				10, +				10, +			), +			array( +				20, +				10, +			), +			array( +				30, +				10, +			), +		); +	} + +	/** +	* @dataProvider validate_start_data +	*/ +	public function test_validate_start($start, $expect) +	{ +		$this->assertEquals($expect, $this->pagination->validate_start($start, 10, 20)); +	} + +	public function reverse_start_data() +	{ +		return array( +			array( +				10, +				5, +				15, +				0, +			), +			array( +				10, +				10, +				25, +				5, +			), +		); +	} + +	/** +	* @dataProvider reverse_start_data +	*/ +	public function test_reverse_start($start, $limit, $num_items, $expect) +	{ +		$this->assertEquals($expect, $this->pagination->reverse_start($start, $limit, $num_items)); +	} + +	public function reverse_limit_data() +	{ +		return array( +			array( +				10, +				10, +				15, +				5, +			), +			array( +				20, +				10, +				15, +				1, +			), +		); +	} + +	/** +	* @dataProvider reverse_limit_data +	*/ +	public function test_reverse_limit($start, $per_page, $num_items, $expect) +	{ +		$this->assertEquals($expect, $this->pagination->reverse_limit($start, $per_page, $num_items)); +	} +} diff --git a/tests/pagination/templates/on_page.html b/tests/pagination/templates/on_page.html new file mode 100644 index 0000000000..364bcf9f5e --- /dev/null +++ b/tests/pagination/templates/on_page.html @@ -0,0 +1,4 @@ +on_page +per_page:{PER_PAGE} +on_page:{ON_PAGE} +base_url:{BASE_URL}  | 
