diff options
| author | Nathan Guse <nathaniel.guse@gmail.com> | 2013-07-29 07:18:41 -0700 | 
|---|---|---|
| committer | Nathan Guse <nathaniel.guse@gmail.com> | 2013-07-29 07:18:41 -0700 | 
| commit | 6cbe887ea0be71c4796b91b63af07b0a645c105b (patch) | |
| tree | 34e8e4a12b6a7c0a97753d5bbc82142869e4934e | |
| parent | 26dac64d45944dce14b33a9c82e531f01f9a623f (diff) | |
| parent | 9902f1c75178aa72d3b89f51033fcda552141b40 (diff) | |
| download | forums-6cbe887ea0be71c4796b91b63af07b0a645c105b.tar forums-6cbe887ea0be71c4796b91b63af07b0a645c105b.tar.gz forums-6cbe887ea0be71c4796b91b63af07b0a645c105b.tar.bz2 forums-6cbe887ea0be71c4796b91b63af07b0a645c105b.tar.xz forums-6cbe887ea0be71c4796b91b63af07b0a645c105b.zip | |
Merge pull request #1619 from VSEphpbb/ticket/11749
[ticket/11749] PHP and Template Events for Topic Preview Extension
| -rw-r--r-- | phpBB/docs/events.md | 18 | ||||
| -rw-r--r-- | phpBB/search.php | 29 | ||||
| -rw-r--r-- | phpBB/styles/prosilver/template/search_results.html | 2 | ||||
| -rw-r--r-- | phpBB/styles/prosilver/template/viewforum_body.html | 2 | ||||
| -rw-r--r-- | phpBB/styles/subsilver2/template/search_results.html | 2 | ||||
| -rw-r--r-- | phpBB/styles/subsilver2/template/viewforum_body.html | 4 | ||||
| -rw-r--r-- | phpBB/viewforum.php | 21 | 
7 files changed, 76 insertions, 2 deletions
| diff --git a/phpBB/docs/events.md b/phpBB/docs/events.md index 3723bf7b3f..855f238653 100644 --- a/phpBB/docs/events.md +++ b/phpBB/docs/events.md @@ -114,6 +114,24 @@ simple_footer_after  * Location: styles/prosilver/template/simple_footer.html  * Purpose: Add content directly prior to the `</body>` tag of the simple footer +topiclist_row_prepend +=== +* Locations: +    + styles/prosilver/template/search_results.html +    + styles/prosilver/template/viewforum_body.html +    + styles/subsilver2/template/search_results.html +    + styles/subsilver2/template/viewforum_body.html +* Purpose: Add content into topic rows (inside the elements containing topic titles) + +topiclist_row_append +=== +* Locations: +    + styles/prosilver/template/search_results.html +    + styles/prosilver/template/viewforum_body.html +    + styles/subsilver2/template/search_results.html +    + styles/subsilver2/template/viewforum_body.html +* Purpose: Add content into topic rows (inside the elements containing topic titles) +  ucp_pm_viewmessage_print_head_append  ===  * Location: styles/prosilver/template/ucp_pm_viewmessage_print.html diff --git a/phpBB/search.php b/phpBB/search.php index 8bcbfc498b..40c0b9a8ce 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -687,6 +687,18 @@ if ($keywords || $author || $author_id || $search_id || $submit)  				$tracking_topics = ($tracking_topics) ? tracking_unserialize($tracking_topics) : array();  			} +			/** +			* Event to modify the SQL query before the topic data is retrieved +			* +			* @event core.search_get_topic_data +			* @var	string	sql_select		The SQL SELECT string used by search to get topic data +			* @var	string	sql_from		The SQL FROM string used by search to get topic data +			* @var	string	sql_where		The SQL WHERE string used by search to get topic data +			* @since 3.1-A1 +			*/ +			$vars = array('sql_select', 'sql_from', 'sql_where'); +			extract($phpbb_dispatcher->trigger_event('core.search_get_topic_data', compact($vars))); +  			$sql = "SELECT $sql_select  				FROM $sql_from  				WHERE $sql_where"; @@ -989,7 +1001,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)  				);  			} -			$template->assign_block_vars('searchresults', array_merge($tpl_ary, array( +			$tpl_ary = array_merge($tpl_ary, array(  				'FORUM_ID'			=> $forum_id,  				'TOPIC_ID'			=> $result_topic_id,  				'POST_ID'			=> ($show_results == 'posts') ? $row['post_id'] : false, @@ -1001,9 +1013,22 @@ if ($keywords || $author || $author_id || $search_id || $submit)  				'U_VIEW_TOPIC'		=> $view_topic_url,  				'U_VIEW_FORUM'		=> append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id), -				'U_VIEW_POST'		=> (!empty($row['post_id'])) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=" . $row['topic_id'] . '&p=' . $row['post_id'] . (($u_hilit) ? '&hilit=' . $u_hilit : '')) . '#p' . $row['post_id'] : '') +				'U_VIEW_POST'		=> (!empty($row['post_id'])) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=" . $row['topic_id'] . '&p=' . $row['post_id'] . (($u_hilit) ? '&hilit=' . $u_hilit : '')) . '#p' . $row['post_id'] : '',  			)); +			/** +			* Modify the topic data before it is assigned to the template +			* +			* @event core.search_modify_tpl_ary +			* @var	array	row			Array with topic data +			* @var	array	tpl_ary		Template block array with topic data +			* @since 3.1-A1 +			*/ +			$vars = array('row', 'tpl_ary'); +			extract($phpbb_dispatcher->trigger_event('core.search_modify_tpl_ary', compact($vars))); + +			$template->assign_block_vars('searchresults', $tpl_ary); +  			if ($show_results == 'topics')  			{  				phpbb_generate_template_pagination($template, $view_topic_url, 'searchresults.pagination', 'start', $replies + 1, $config['posts_per_page'], 1, true, true); diff --git a/phpBB/styles/prosilver/template/search_results.html b/phpBB/styles/prosilver/template/search_results.html index f0424c45db..54e8867526 100644 --- a/phpBB/styles/prosilver/template/search_results.html +++ b/phpBB/styles/prosilver/template/search_results.html @@ -63,6 +63,7 @@  					<dt <!-- IF searchresults.TOPIC_ICON_IMG -->style="background-image: url({T_ICONS_PATH}{searchresults.TOPIC_ICON_IMG}); background-repeat: no-repeat;"<!-- ENDIF --> title="{searchresults.TOPIC_FOLDER_IMG_ALT}">  						<div class="list-inner"> +							<!-- EVENT topiclist_row_prepend -->  							<!-- IF searchresults.S_UNREAD_TOPIC --><a href="{searchresults.U_NEWEST_POST}">{NEWEST_POST_IMG}</a> <!-- ENDIF -->  							<a href="{searchresults.U_VIEW_TOPIC}" class="topictitle">{searchresults.TOPIC_TITLE}</a> {searchresults.ATTACH_ICON_IMG}  							<!-- IF searchresults.S_TOPIC_UNAPPROVED or searchresults.S_POSTS_UNAPPROVED --><a href="{searchresults.U_MCP_QUEUE}">{searchresults.UNAPPROVED_IMG}</a> <!-- ENDIF --> @@ -83,6 +84,7 @@  							</div>  							<!-- ENDIF -->  							{L_POST_BY_AUTHOR} {searchresults.TOPIC_AUTHOR_FULL} » {searchresults.FIRST_POST_TIME} » {L_IN} <a href="{searchresults.U_VIEW_FORUM}">{searchresults.FORUM_TITLE}</a> +							<!-- EVENT topiclist_row_append -->  						</div>  					</dt> diff --git a/phpBB/styles/prosilver/template/viewforum_body.html b/phpBB/styles/prosilver/template/viewforum_body.html index 69b0608a64..ecd993d7fb 100644 --- a/phpBB/styles/prosilver/template/viewforum_body.html +++ b/phpBB/styles/prosilver/template/viewforum_body.html @@ -144,6 +144,7 @@  			<dl class="icon {topicrow.TOPIC_IMG_STYLE}">  				<dt<!-- IF topicrow.TOPIC_ICON_IMG and S_TOPIC_ICONS --> style="background-image: url({T_ICONS_PATH}{topicrow.TOPIC_ICON_IMG}); background-repeat: no-repeat;"<!-- ENDIF --> title="{topicrow.TOPIC_FOLDER_IMG_ALT}">  					<div class="list-inner"> +						<!-- EVENT topiclist_row_prepend -->  						<!-- IF topicrow.S_UNREAD_TOPIC --><a href="{topicrow.U_NEWEST_POST}">{NEWEST_POST_IMG}</a> <!-- ENDIF --><a href="{topicrow.U_VIEW_TOPIC}" class="topictitle">{topicrow.TOPIC_TITLE}</a>  						<!-- IF topicrow.S_TOPIC_UNAPPROVED or topicrow.S_POSTS_UNAPPROVED --><a href="{topicrow.U_MCP_QUEUE}">{topicrow.UNAPPROVED_IMG}</a> <!-- ENDIF -->  						<!-- IF topicrow.S_TOPIC_DELETED --><a href="{topicrow.U_MCP_QUEUE}">{DELETED_IMG}</a> <!-- ENDIF --> @@ -164,6 +165,7 @@  						<!-- ENDIF -->  						<!-- IF topicrow.ATTACH_ICON_IMG -->{topicrow.ATTACH_ICON_IMG} <!-- ENDIF -->{L_POST_BY_AUTHOR} {topicrow.TOPIC_AUTHOR_FULL} » {topicrow.FIRST_POST_TIME}  						<!-- IF topicrow.S_POST_GLOBAL and FORUM_ID != topicrow.FORUM_ID --> » {L_IN} <a href="{topicrow.U_VIEW_FORUM}">{topicrow.FORUM_NAME}</a><!-- ENDIF --> +						<!-- EVENT topiclist_row_append -->  					</div>  				</dt>  				<dd class="posts">{topicrow.REPLIES} <dfn>{L_REPLIES}</dfn></dd> diff --git a/phpBB/styles/subsilver2/template/search_results.html b/phpBB/styles/subsilver2/template/search_results.html index d98079de20..19ba0b196a 100644 --- a/phpBB/styles/subsilver2/template/search_results.html +++ b/phpBB/styles/subsilver2/template/search_results.html @@ -34,6 +34,7 @@  			<!-- ENDIF -->  			</td>  			<td class="row1"> +				<!-- EVENT topiclist_row_prepend -->  				<!-- IF searchresults.S_UNREAD_TOPIC --><a href="{searchresults.U_NEWEST_POST}" class="imageset">{NEWEST_POST_IMG}</a><!-- ENDIF -->  				{searchresults.ATTACH_ICON_IMG} <a href="{searchresults.U_VIEW_TOPIC}" class="topictitle">{searchresults.TOPIC_TITLE}</a>  				<!-- IF searchresults.S_TOPIC_UNAPPROVED or searchresults.S_POSTS_UNAPPROVED --> @@ -58,6 +59,7 @@  					] </p>  				<!-- ENDIF -->  				<p class="gensmall">{L_IN} <a href="{searchresults.U_VIEW_FORUM}">{searchresults.FORUM_TITLE}</a></p> +				<!-- EVENT topiclist_row_append -->  			</td>  			<td class="row2" width="100" align="center"><p class="topicauthor">{searchresults.TOPIC_AUTHOR_FULL}</p></td>  			<td class="row1" width="50" align="center"><p class="topicdetails">{searchresults.TOPIC_REPLIES}</p></td> diff --git a/phpBB/styles/subsilver2/template/viewforum_body.html b/phpBB/styles/subsilver2/template/viewforum_body.html index d07e9a1372..dfbe0a605b 100644 --- a/phpBB/styles/subsilver2/template/viewforum_body.html +++ b/phpBB/styles/subsilver2/template/viewforum_body.html @@ -40,6 +40,7 @@  				<td class="row1" width="25" align="center"><!-- IF topicrow.TOPIC_ICON_IMG --><img src="{T_ICONS_PATH}{topicrow.TOPIC_ICON_IMG}" width="{topicrow.TOPIC_ICON_IMG_WIDTH}" height="{topicrow.TOPIC_ICON_IMG_HEIGHT}" alt="" title="" /><!-- ENDIF --></td>  			<!-- ENDIF -->  			<td class="row1"> +				<!-- EVENT topiclist_row_prepend -->  				<!-- IF topicrow.S_UNREAD_TOPIC --><a href="{topicrow.U_NEWEST_POST}" class="imageset">{NEWEST_POST_IMG}</a><!-- ENDIF -->  				{topicrow.ATTACH_ICON_IMG} <!-- IF topicrow.S_HAS_POLL or topicrow.S_TOPIC_MOVED --><b>{topicrow.TOPIC_TYPE}</b> <!-- ENDIF --><a title="{L_POSTED}{L_COLON} {topicrow.FIRST_POST_TIME}" href="{topicrow.U_VIEW_TOPIC}"class="topictitle">{topicrow.TOPIC_TITLE}</a>  				<!-- IF topicrow.S_TOPIC_UNAPPROVED or topicrow.S_POSTS_UNAPPROVED --> @@ -63,6 +64,7 @@  					<!-- END pagination -->  					] </p>  				<!-- ENDIF --> +				<!-- EVENT topiclist_row_append -->  			</td>  			<td class="row2" width="130" align="center"><p class="topicauthor">{topicrow.TOPIC_AUTHOR_FULL}</p></td>  			<td class="row1" width="50" align="center"><p class="topicdetails">{topicrow.REPLIES}</p></td> @@ -203,6 +205,7 @@  					<td class="row1" width="25" align="center"><!-- IF topicrow.TOPIC_ICON_IMG --><img src="{T_ICONS_PATH}{topicrow.TOPIC_ICON_IMG}" width="{topicrow.TOPIC_ICON_IMG_WIDTH}" height="{topicrow.TOPIC_ICON_IMG_HEIGHT}" alt="" title="" /><!-- ENDIF --></td>  				<!-- ENDIF -->  				<td class="row1"> +					<!-- EVENT topiclist_row_prepend -->  					<!-- IF topicrow.S_UNREAD_TOPIC --><a href="{topicrow.U_NEWEST_POST}" class="imageset">{NEWEST_POST_IMG}</a><!-- ENDIF -->  					{topicrow.ATTACH_ICON_IMG} <!-- IF topicrow.S_HAS_POLL or topicrow.S_TOPIC_MOVED --><b>{topicrow.TOPIC_TYPE}</b> <!-- ENDIF --><a title="{L_POSTED}{L_COLON} {topicrow.FIRST_POST_TIME}" href="{topicrow.U_VIEW_TOPIC}" class="topictitle">{topicrow.TOPIC_TITLE}</a>  					<!-- IF topicrow.S_TOPIC_UNAPPROVED or topicrow.S_POSTS_UNAPPROVED --> @@ -227,6 +230,7 @@  						] </p>  					<!-- ENDIF -->  					<!-- IF topicrow.S_POST_GLOBAL and FORUM_ID != topicrow.FORUM_ID --><p class="gensmall">{L_IN} <a href="{topicrow.U_VIEW_FORUM}">{topicrow.FORUM_NAME}</a></p><!-- ENDIF --> +					<!-- EVENT topiclist_row_append -->  				</td>  				<td class="row2" width="130" align="center"><p class="topicauthor">{topicrow.TOPIC_AUTHOR_FULL}</p></td>  				<td class="row1" width="50" align="center"><p class="topicdetails">{topicrow.REPLIES}</p></td> diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 5a59e021b3..1fa2030671 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -372,6 +372,16 @@ $sql_array = array(  	'LEFT_JOIN'	=> array(),  ); +/** +* Event to modify the SQL query before the topic data is retrieved +* +* @event core.viewforum_get_topic_data +* @var	array	sql_array		The SQL array to get the data of all topics +* @since 3.1-A1 +*/ +$vars = array('sql_array'); +extract($phpbb_dispatcher->trigger_event('core.viewforum_get_topic_data', compact($vars))); +  $sql_approved = ' AND ' . $phpbb_content_visibility->get_visibility_sql('topic', $forum_id, 't.');  if ($user->data['is_registered']) @@ -554,6 +564,17 @@ if (sizeof($shadow_topic_list))  	$sql = 'SELECT *  		FROM ' . TOPICS_TABLE . '  		WHERE ' . $db->sql_in_set('topic_id', array_keys($shadow_topic_list)); + +	/** +	* Event to modify the SQL query before the shadowtopic data is retrieved +	* +	* @event core.viewforum_get_shadowtopic_data +	* @var	string	sql		The SQL string to get the data of any shadowtopics +	* @since 3.1-A1 +	*/ +	$vars = array('sql'); +	extract($phpbb_dispatcher->trigger_event('core.viewforum_get_shadowtopic_data', compact($vars))); +  	$result = $db->sql_query($sql);  	while ($row = $db->sql_fetchrow($result)) | 
