<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[PunBB Forums - What are "hooks"?]]></title>
		<link>http://punbb.informer.com/forums/topic/20205/what-are-hooks/</link>
		<description><![CDATA[The most recent posts in What are "hooks"?.]]></description>
		<lastBuildDate>Mon, 10 Aug 2009 07:54:20 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: What are "hooks"?]]></title>
			<link>http://punbb.informer.com/forums/post/129533/#p129533</link>
			<description><![CDATA[<p>Hooking covers a range of techniques used to alter or augment the behavior of an operating system, of applications, or of other software components by intercepting function calls or messages or events passed between software components.</p>]]></description>
			<author><![CDATA[dummy@example.com (bryansmith)]]></author>
			<pubDate>Mon, 10 Aug 2009 07:54:20 +0000</pubDate>
			<guid>http://punbb.informer.com/forums/post/129533/#p129533</guid>
		</item>
		<item>
			<title><![CDATA[Re: What are "hooks"?]]></title>
			<link>http://punbb.informer.com/forums/post/121295/#p121295</link>
			<description><![CDATA[<div class="quotebox"><cite>Garciat wrote:</cite><blockquote><p>There really is no point in having a hooks list when you don&#039;t know where they are (line-wise).</p></blockquote></div><p>Lol, actually I meant a list of hooks telling me where they are. Thought it was obvious <img src="http://punbb.informer.com/forums/img/smilies/wink.png" width="15" height="15" alt="wink" /></p><div class="quotebox"><cite>hcgtv wrote:</cite><blockquote><p>I haven&#039;t created a Xref for PunBB 1.3, but here is one from the FluxBB 1.3 svn:<br /><a href="http://phpxref.com/xref/fluxbb/_functions/get_hook.html">http://phpxref.com/xref/fluxbb/_functions/get_hook.html</a></p></blockquote></div><p>Thanks... but I think I&#039;ll stick with Google for the moment.</p>]]></description>
			<author><![CDATA[dummy@example.com (patheticcockroach)]]></author>
			<pubDate>Thu, 18 Dec 2008 17:29:52 +0000</pubDate>
			<guid>http://punbb.informer.com/forums/post/121295/#p121295</guid>
		</item>
		<item>
			<title><![CDATA[Re: What are "hooks"?]]></title>
			<link>http://punbb.informer.com/forums/post/121293/#p121293</link>
			<description><![CDATA[<div class="quotebox"><cite>Garciat wrote:</cite><blockquote><p>There really is no point in having a hooks list when you don&#039;t know where they are (line-wise).</p></blockquote></div><p>I haven&#039;t created a Xref for PunBB 1.3, but here is one from the FluxBB 1.3 svn:<br /><a href="http://phpxref.com/xref/fluxbb/_functions/get_hook.html">http://phpxref.com/xref/fluxbb/_functions/get_hook.html</a></p><p>I do have a PunBB Xref: <a href="http://phpxref.com/xref/punbb/">http://phpxref.com/xref/punbb/</a> - but it&#039;s based off of the 1.2 line.</p>]]></description>
			<author><![CDATA[dummy@example.com (hcgtv)]]></author>
			<pubDate>Thu, 18 Dec 2008 16:57:24 +0000</pubDate>
			<guid>http://punbb.informer.com/forums/post/121293/#p121293</guid>
		</item>
		<item>
			<title><![CDATA[Re: What are "hooks"?]]></title>
			<link>http://punbb.informer.com/forums/post/121292/#p121292</link>
			<description><![CDATA[<p>There really is no point in having a hooks list when you don&#039;t know where they are (line-wise).</p>]]></description>
			<author><![CDATA[dummy@example.com (Garciat)]]></author>
			<pubDate>Thu, 18 Dec 2008 16:32:01 +0000</pubDate>
			<guid>http://punbb.informer.com/forums/post/121292/#p121292</guid>
		</item>
		<item>
			<title><![CDATA[Re: What are "hooks"?]]></title>
			<link>http://punbb.informer.com/forums/post/121291/#p121291</link>
			<description><![CDATA[<div class="quotebox"><cite>patheticcockroach wrote:</cite><blockquote><p>Is there a list of hooks somewhere?</p></blockquote></div><p>You can create your own: <a href="http://fluxbb.org/forums/post/18531/#p18531">http://fluxbb.org/forums/post/18531/#p18531</a></p>]]></description>
			<author><![CDATA[dummy@example.com (hcgtv)]]></author>
			<pubDate>Thu, 18 Dec 2008 16:27:32 +0000</pubDate>
			<guid>http://punbb.informer.com/forums/post/121291/#p121291</guid>
		</item>
		<item>
			<title><![CDATA[Re: What are "hooks"?]]></title>
			<link>http://punbb.informer.com/forums/post/121275/#p121275</link>
			<description><![CDATA[<p>You&#039;re supposed to look for them on the PunBB files.</p>]]></description>
			<author><![CDATA[dummy@example.com (Garciat)]]></author>
			<pubDate>Thu, 18 Dec 2008 12:27:26 +0000</pubDate>
			<guid>http://punbb.informer.com/forums/post/121275/#p121275</guid>
		</item>
		<item>
			<title><![CDATA[Re: What are "hooks"?]]></title>
			<link>http://punbb.informer.com/forums/post/121270/#p121270</link>
			<description><![CDATA[<p>Is there a list of hooks somewhere? For the moment, I search for them using Google &quot;PunBB [hookname]&quot;, which gives decent results but I suppose there is maybe a more efficient way to find them <img src="http://punbb.informer.com/forums/img/smilies/big_smile.png" width="15" height="15" alt="big_smile" /></p>]]></description>
			<author><![CDATA[dummy@example.com (patheticcockroach)]]></author>
			<pubDate>Thu, 18 Dec 2008 09:53:29 +0000</pubDate>
			<guid>http://punbb.informer.com/forums/post/121270/#p121270</guid>
		</item>
		<item>
			<title><![CDATA[Re: What are "hooks"?]]></title>
			<link>http://punbb.informer.com/forums/post/119011/#p119011</link>
			<description><![CDATA[<div class="quotebox"><cite>lie2815 wrote:</cite><blockquote><p>Hint: Nice tutorial, but it&#039;s not manifex.xml neither manifest.php, but manifest.xml</p></blockquote></div><p>Fixed. Thanks.<br />(it was late evening after long working day... ))</p>]]></description>
			<author><![CDATA[dummy@example.com (Anatoly)]]></author>
			<pubDate>Sun, 09 Nov 2008 09:19:56 +0000</pubDate>
			<guid>http://punbb.informer.com/forums/post/119011/#p119011</guid>
		</item>
		<item>
			<title><![CDATA[Re: What are "hooks"?]]></title>
			<link>http://punbb.informer.com/forums/post/118994/#p118994</link>
			<description><![CDATA[<p>@anatoly:</p><p>Hint: Nice tutorial, but it&#039;s not manifex.xml neither manifest.php, but manifest.xml</p><p>You should edit it.</p>]]></description>
			<author><![CDATA[dummy@example.com (lie2815)]]></author>
			<pubDate>Sat, 08 Nov 2008 14:48:53 +0000</pubDate>
			<guid>http://punbb.informer.com/forums/post/118994/#p118994</guid>
		</item>
		<item>
			<title><![CDATA[Re: What are "hooks"?]]></title>
			<link>http://punbb.informer.com/forums/post/118982/#p118982</link>
			<description><![CDATA[<p>Oh, I get it now <img src="http://punbb.informer.com/forums/img/smilies/smile.png" width="15" height="15" alt="smile" /> Thanks!</p>]]></description>
			<author><![CDATA[dummy@example.com (Garciat)]]></author>
			<pubDate>Fri, 07 Nov 2008 23:03:59 +0000</pubDate>
			<guid>http://punbb.informer.com/forums/post/118982/#p118982</guid>
		</item>
		<item>
			<title><![CDATA[Re: What are "hooks"?]]></title>
			<link>http://punbb.informer.com/forums/post/118980/#p118980</link>
			<description><![CDATA[<p>1. Extension developer puts his PHP code into manifest.xml file.<br />He specifies the name of the hook, where he wants his code to be executed.<br />E.g. I want to print out the list of extensions installed in <strong>ft_about_end</strong> hook:<br /></p><div class="codebox"><pre><code>        &lt;hook id=&quot;ft_about_end&quot; priority=&quot;10&quot;&gt;&lt;![CDATA[
if (!defined(&#039;PUN_EXTENSIONS_USED&#039;) &amp;&amp; !empty($pun_extensions_used))
{
    define(&#039;PUN_EXTENSIONS_USED&#039;, 1);
    echo &#039;&lt;p id=&quot;extensions-used&quot;&gt;Currently used extensions: &#039;.implode(&#039;, &#039;, $pun_extensions_used).&#039;. Copyright &amp;copy; 2008 &lt;a href=&quot;http://punbb.informer.com/&quot;&gt;PunBB&lt;/a&gt;&lt;/p&gt;&#039;;
}
        ]]&gt;&lt;/hook&gt;</code></pre></div><p>(<a href="http://punbb.informer.com/trac/browser/extensions/trunk/pun_bbcode/manifest.xml#L110">pun_bbcode/manifest.xml</a>)<br />You may find this hook in <a href="http://punbb.informer.com/trac/browser/punbb/branches/punbb-1.3-dev/footer.php#L48">footer.php</a>.</p><p>2. When you install the extension, PunBB <a href="http://punbb.informer.com/trac/browser/punbb/branches/punbb-1.3-dev/admin/extensions.php#L48">parses its&#039; manifest.xml</a> and <a href="http://punbb.informer.com/trac/browser/punbb/branches/punbb-1.3-dev/admin/extensions.php#L189">places the code for each hook into database</a>. After extension installation, you have pairs (hook_id, code) in DB.</p><p>3. Before PunBB generates the page, it <a href="http://punbb.informer.com/trac/browser/punbb/branches/punbb-1.3-dev/include/cache.php#L269">caches the code for each hook</a>. It iterates through the pairs (hook_id, code) and creates the PHP array containing all the codes for every hook used by all the extensions enabled. This array is being included on every page hit. You may find the cache file in <em>/cache/cache_hooks.php</em>. Different extensions may use the same hook. Their codes are joined in the cache then (ordered by priority, if given in manifest.xml).</p><p>4. PunBB developers has placed hook calls in the code like this:<br /></p><div class="codebox"><pre><code>($hook = get_hook(&#039;ft_about_end&#039;)) ? eval($hook) : null;</code></pre></div><p>When PHP finds this line, it <a href="http://punbb.informer.com/trac/browser/punbb/branches/punbb-1.3-dev/include/functions.php#L681">looks through the cache</a> for the code for the hook name given. E.g. <em>$forum_hooks[&#039;ft_about_end&#039;]</em>.</p><p>5. If the code for the hook is present. It is being evaluated in <em>eval($hook)</em>. This means that the code is virtually inserted just in the place of hook. The code has the same variable scope as the hook: you may use all the variables around, create new ones and s.o. (This differs from function call.)</p><p>That&#039;s it.<br />Ooh...</p><p><span style="color: #c99">UPDATE: Fixed mistakes noted by lie2815 :-)</span></p>]]></description>
			<author><![CDATA[dummy@example.com (Anatoly)]]></author>
			<pubDate>Fri, 07 Nov 2008 16:27:29 +0000</pubDate>
			<guid>http://punbb.informer.com/forums/post/118980/#p118980</guid>
		</item>
		<item>
			<title><![CDATA[Re: What are "hooks"?]]></title>
			<link>http://punbb.informer.com/forums/post/118976/#p118976</link>
			<description><![CDATA[<p>Yes, please <img src="http://punbb.informer.com/forums/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[dummy@example.com (Garciat)]]></author>
			<pubDate>Fri, 07 Nov 2008 12:13:46 +0000</pubDate>
			<guid>http://punbb.informer.com/forums/post/118976/#p118976</guid>
		</item>
		<item>
			<title><![CDATA[Re: What are "hooks"?]]></title>
			<link>http://punbb.informer.com/forums/post/118975/#p118975</link>
			<description><![CDATA[<p>You mean the hook from <a href="http://en.wikipedia.org/wiki/Hooking">hooking</a> as it is used in PunBB 1.3 extension system or the word <a href="http://en.wikipedia.org/wiki/Hook">hook</a> itself?<br />Should I explain PunBB hooks in details?</p>]]></description>
			<author><![CDATA[dummy@example.com (Anatoly)]]></author>
			<pubDate>Fri, 07 Nov 2008 12:12:03 +0000</pubDate>
			<guid>http://punbb.informer.com/forums/post/118975/#p118975</guid>
		</item>
		<item>
			<title><![CDATA[What are "hooks"?]]></title>
			<link>http://punbb.informer.com/forums/post/118974/#p118974</link>
			<description><![CDATA[<p>What the title says <img src="http://punbb.informer.com/forums/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[dummy@example.com (Garciat)]]></author>
			<pubDate>Fri, 07 Nov 2008 11:52:05 +0000</pubDate>
			<guid>http://punbb.informer.com/forums/post/118974/#p118974</guid>
		</item>
	</channel>
</rss>
