<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[PunBB Forums - What are "hooks"?]]></title>
	<link rel="self" href="http://punbb.informer.com/forums/feed/atom/topic/20205/"/>
	<updated>2009-08-10T07:54:20Z</updated>
	<generator>PunBB</generator>
	<id>http://punbb.informer.com/forums/topic/20205/what-are-hooks/</id>
		<entry>
			<title type="html"><![CDATA[Re: What are "hooks"?]]></title>
			<link rel="alternate" href="http://punbb.informer.com/forums/post/129533/#p129533"/>
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[bryansmith]]></name>
				<uri>http://punbb.informer.com/forums/user/16063/</uri>
			</author>
			<updated>2009-08-10T07:54:20Z</updated>
			<id>http://punbb.informer.com/forums/post/129533/#p129533</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: What are "hooks"?]]></title>
			<link rel="alternate" href="http://punbb.informer.com/forums/post/121295/#p121295"/>
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[patheticcockroach]]></name>
				<uri>http://punbb.informer.com/forums/user/14469/</uri>
			</author>
			<updated>2008-12-18T17:29:52Z</updated>
			<id>http://punbb.informer.com/forums/post/121295/#p121295</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: What are "hooks"?]]></title>
			<link rel="alternate" href="http://punbb.informer.com/forums/post/121293/#p121293"/>
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[hcgtv]]></name>
				<uri>http://punbb.informer.com/forums/user/1461/</uri>
			</author>
			<updated>2008-12-18T16:57:24Z</updated>
			<id>http://punbb.informer.com/forums/post/121293/#p121293</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: What are "hooks"?]]></title>
			<link rel="alternate" href="http://punbb.informer.com/forums/post/121292/#p121292"/>
			<content type="html"><![CDATA[<p>There really is no point in having a hooks list when you don&#039;t know where they are (line-wise).</p>]]></content>
			<author>
				<name><![CDATA[Garciat]]></name>
				<uri>http://punbb.informer.com/forums/user/12481/</uri>
			</author>
			<updated>2008-12-18T16:32:01Z</updated>
			<id>http://punbb.informer.com/forums/post/121292/#p121292</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: What are "hooks"?]]></title>
			<link rel="alternate" href="http://punbb.informer.com/forums/post/121291/#p121291"/>
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[hcgtv]]></name>
				<uri>http://punbb.informer.com/forums/user/1461/</uri>
			</author>
			<updated>2008-12-18T16:27:32Z</updated>
			<id>http://punbb.informer.com/forums/post/121291/#p121291</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: What are "hooks"?]]></title>
			<link rel="alternate" href="http://punbb.informer.com/forums/post/121275/#p121275"/>
			<content type="html"><![CDATA[<p>You&#039;re supposed to look for them on the PunBB files.</p>]]></content>
			<author>
				<name><![CDATA[Garciat]]></name>
				<uri>http://punbb.informer.com/forums/user/12481/</uri>
			</author>
			<updated>2008-12-18T12:27:26Z</updated>
			<id>http://punbb.informer.com/forums/post/121275/#p121275</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: What are "hooks"?]]></title>
			<link rel="alternate" href="http://punbb.informer.com/forums/post/121270/#p121270"/>
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[patheticcockroach]]></name>
				<uri>http://punbb.informer.com/forums/user/14469/</uri>
			</author>
			<updated>2008-12-18T09:53:29Z</updated>
			<id>http://punbb.informer.com/forums/post/121270/#p121270</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: What are "hooks"?]]></title>
			<link rel="alternate" href="http://punbb.informer.com/forums/post/119011/#p119011"/>
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Anatoly]]></name>
				<uri>http://punbb.informer.com/forums/user/12152/</uri>
			</author>
			<updated>2008-11-09T09:19:56Z</updated>
			<id>http://punbb.informer.com/forums/post/119011/#p119011</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: What are "hooks"?]]></title>
			<link rel="alternate" href="http://punbb.informer.com/forums/post/118994/#p118994"/>
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[lie2815]]></name>
				<uri>http://punbb.informer.com/forums/user/9678/</uri>
			</author>
			<updated>2008-11-08T14:48:53Z</updated>
			<id>http://punbb.informer.com/forums/post/118994/#p118994</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: What are "hooks"?]]></title>
			<link rel="alternate" href="http://punbb.informer.com/forums/post/118982/#p118982"/>
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Garciat]]></name>
				<uri>http://punbb.informer.com/forums/user/12481/</uri>
			</author>
			<updated>2008-11-07T23:03:59Z</updated>
			<id>http://punbb.informer.com/forums/post/118982/#p118982</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: What are "hooks"?]]></title>
			<link rel="alternate" href="http://punbb.informer.com/forums/post/118980/#p118980"/>
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Anatoly]]></name>
				<uri>http://punbb.informer.com/forums/user/12152/</uri>
			</author>
			<updated>2008-11-07T16:27:29Z</updated>
			<id>http://punbb.informer.com/forums/post/118980/#p118980</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: What are "hooks"?]]></title>
			<link rel="alternate" href="http://punbb.informer.com/forums/post/118976/#p118976"/>
			<content type="html"><![CDATA[<p>Yes, please <img src="http://punbb.informer.com/forums/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></content>
			<author>
				<name><![CDATA[Garciat]]></name>
				<uri>http://punbb.informer.com/forums/user/12481/</uri>
			</author>
			<updated>2008-11-07T12:13:46Z</updated>
			<id>http://punbb.informer.com/forums/post/118976/#p118976</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: What are "hooks"?]]></title>
			<link rel="alternate" href="http://punbb.informer.com/forums/post/118975/#p118975"/>
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Anatoly]]></name>
				<uri>http://punbb.informer.com/forums/user/12152/</uri>
			</author>
			<updated>2008-11-07T12:12:03Z</updated>
			<id>http://punbb.informer.com/forums/post/118975/#p118975</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[What are "hooks"?]]></title>
			<link rel="alternate" href="http://punbb.informer.com/forums/post/118974/#p118974"/>
			<content type="html"><![CDATA[<p>What the title says <img src="http://punbb.informer.com/forums/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></content>
			<author>
				<name><![CDATA[Garciat]]></name>
				<uri>http://punbb.informer.com/forums/user/12481/</uri>
			</author>
			<updated>2008-11-07T11:52:05Z</updated>
			<id>http://punbb.informer.com/forums/post/118974/#p118974</id>
		</entry>
</feed>
