[feature/template-engine] Remove $include_once argument of display()

PHPBB3-9726
This commit is contained in:
Igor Wiedler 2011-07-10 01:05:54 +02:00
parent ae53623230
commit c58b09e65d
3 changed files with 9 additions and 12 deletions

View file

@ -377,10 +377,10 @@ a:active { color: #368AD2; }
<p><code>phpbb_user_session_handler();</code> which is called within user::setup after the session and the user object is correctly initialized.<br /> <p><code>phpbb_user_session_handler();</code> which is called within user::setup after the session and the user object is correctly initialized.<br />
<code>append_sid($url, $params = false, $is_amp = true, $session_id = false);</code> which is called for building urls (appending the session id)<br /> <code>append_sid($url, $params = false, $is_amp = true, $session_id = false);</code> which is called for building urls (appending the session id)<br />
<code>$template-&gt;display($handle, $include_once = true);</code> which is called directly before outputting the (not-yet-compiled) template.<br /> <code>$template-&gt;display($handle, $template);</code> which is called directly before outputting the (not-yet-compiled) template.<br />
<code>exit_handler();</code> which is called at the very end of phpBB3's execution.</p> <code>exit_handler();</code> which is called at the very end of phpBB3's execution.</p>
<p>Please note: The <code>$template-&gt;display</code> hook takes a third <code>$template</code> argument, which is the template instance being used, which should be used instead of the global.</p> <p>Please note: The <code>$template-&gt;display</code> hook takes a <code>$template</code> argument, which is the template instance being used, which should be used instead of the global.</p>
<p>There are also valid external constants you may want to use if you embed phpBB3 into your application:</p> <p>There are also valid external constants you may want to use if you embed phpBB3 into your application:</p>

View file

@ -216,12 +216,11 @@ class phpbb_template
/** /**
* Display handle * Display handle
* @param string $handle Handle to display * @param string $handle Handle to display
* @param bool $include_once Allow multiple inclusions
* @return bool True on success, false on failure * @return bool True on success, false on failure
*/ */
public function display($handle, $include_once = true) public function display($handle)
{ {
$result = $this->call_hook($handle, $include_once); $result = $this->call_hook($handle);
if ($result !== false) if ($result !== false)
{ {
return $result[0]; return $result[0];
@ -243,13 +242,12 @@ class phpbb_template
/** /**
* Calls hook if any is defined. * Calls hook if any is defined.
* @param string $handle Template handle being displayed. * @param string $handle Template handle being displayed.
* @param bool $include_once Allow multiple inclusions
*/ */
private function call_hook($handle, $include_once) private function call_hook($handle)
{ {
global $phpbb_hook; global $phpbb_hook;
if (!empty($phpbb_hook) && $phpbb_hook->call_hook(array(__CLASS__, __FUNCTION__), $handle, $include_once, $this)) if (!empty($phpbb_hook) && $phpbb_hook->call_hook(array(__CLASS__, __FUNCTION__), $handle, $this))
{ {
if ($phpbb_hook->hook_return(array(__CLASS__, __FUNCTION__))) if ($phpbb_hook->hook_return(array(__CLASS__, __FUNCTION__)))
{ {
@ -285,13 +283,12 @@ class phpbb_template
* @param string $handle Handle to operate on * @param string $handle Handle to operate on
* @param string $template_var Template variable to assign compiled handle to * @param string $template_var Template variable to assign compiled handle to
* @param bool $return_content If true return compiled handle, otherwise assign to $template_var * @param bool $return_content If true return compiled handle, otherwise assign to $template_var
* @param bool $include_once Allow multiple inclusions of the file
* @return bool|string false on failure, otherwise if $return_content is true return string of the compiled handle, otherwise return true * @return bool|string false on failure, otherwise if $return_content is true return string of the compiled handle, otherwise return true
*/ */
public function assign_display($handle, $template_var = '', $return_content = true, $include_once = false) public function assign_display($handle, $template_var = '', $return_content = true)
{ {
ob_start(); ob_start();
$result = $this->display($handle, $include_once); $result = $this->display($handle);
$contents = ob_get_clean(); $contents = ob_get_clean();
if ($result === false) if ($result === false)
{ {

View file

@ -20,7 +20,7 @@ class phpbb_template_template_test_case extends phpbb_test_case
protected function display($handle) protected function display($handle)
{ {
ob_start(); ob_start();
$this->assertTrue($this->template->display($handle, false)); $this->assertTrue($this->template->display($handle));
return self::trim_template_result(ob_get_clean()); return self::trim_template_result(ob_get_clean());
} }