aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/docs/hook_system.html
blob: fbc8baaf758826f8cf3893f7c393cb47a42becec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
Diffstat (limited to 'po')
-rw-r--r--po/ca.po64
1 files changed, 31 insertions, 33 deletions
diff --git a/po/ca.po b/po/ca.po
index c61093cd..e8d5080e 100644
--- a/po/ca.po
+++ b/po/ca.po
@@ -10,7 +10,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Mageia\n"
"POT-Creation-Date: 2017-03-13 19:04+0100\n"
-"PO-Revision-Date: 2017-11-25 11:36+0000\n"
+"PO-Revision-Date: 2017-11-25 22:38+0000\n"
"Last-Translator: Robert Antoni Buj Gelonch <rbuj@fedoraproject.org>\n"
"Language-Team: Catalan (http://www.transifex.com/MageiaLinux/mageia/language/"
"ca/)\n"
@@ -66,7 +66,7 @@ msgstr "Configura FTP"
#: ../control-center:199
#, c-format
msgid "Set up an FTP server"
-msgstr "Configura un servidor FTP"
+msgstr "Prepara un servidor FTP"
#: ../control-center:201
#, c-format
@@ -79,7 +79,7 @@ msgid ""
"Set up a file and print server for workstations running Linux and non-Linux "
"systems"
msgstr ""
-"Configura un servidor de fitxers i d'impressió per a estacions de treball "
+"Prepara un servidor de fitxers i d'impressió per a estacions de treball "
"Linux i no Linux"
#: ../control-center:204
@@ -100,7 +100,7 @@ msgstr "Configura el servidor web"
#: ../control-center:208
#, c-format
msgid "Set up a web server"
-msgstr "Configura un servidor web"
+msgstr "Prepara un servidor web"
#: ../control-center:210
#, c-format
@@ -110,7 +110,7 @@ msgstr "Configura el servidor d'instal·lació"
#: ../control-center:211
#, c-format
msgid "Set up server for network installations of %s"
-msgstr "Configura un servidor per a instal·lacions per xarxa de %s"
+msgstr "Prepara un servidor per a les instal·lacions per xarxa de %s"
#. -PO: please keep the following message very short: it must fit in the left list of MCC!!!
#: ../control-center:221 ../control-center:224
@@ -126,7 +126,7 @@ msgstr "Configura DHCP"
#: ../control-center:228
#, c-format
msgid "Set up a DHCP server"
-msgstr "Configura un servidor DHCP"
+msgstr "Prepara un servidor DHCP"
#: ../control-center:230
#, c-format
@@ -136,7 +136,7 @@ msgstr "Configura DNS"
#: ../control-center:231
#, c-format
msgid "Set up a DNS server (network name resolution)"
-msgstr "Configura un servidor DNS (resolució de noms de xarxa)"
+msgstr "Prepara un servidor DNS (resolució de noms de xarxa)"
#: ../control-center:233
#, c-format
@@ -361,7 +361,7 @@ msgstr "CD-ROM (%s)"
#: ../control-center:503
#, c-format
msgid "Set where your \"%s\" CD-ROM drive is mounted"
-msgstr "Defineix on es muntarà la unitat CD-ROM «%s»"
+msgstr "Estableix on es muntarà la vostra unitat CD-ROM «%s»"
#: ../control-center:505
#, c-format
@@ -371,7 +371,7 @@ msgstr "DVD-ROM (%s)"
#: ../control-center:506
#, c-format
msgid "Set where your \"%s\" DVD-ROM drive is mounted"
-msgstr "Defineix on es muntarà la unitat «%s» DVD-ROM"
+msgstr "Estableix on es muntarà la vostra unitat «%s» DVD-ROM"
#: ../control-center:508
#, c-format
@@ -381,7 +381,7 @@ msgstr "Enregistrador de CD/DVD (%s)"
#: ../control-center:509
#, c-format
msgid "Set where your \"%s\" CD/DVD burner is mounted"
-msgstr "Defineix on es muntarà l'enregistrador de CD/DVD %s"
+msgstr "Estableix on es muntarà la vostra gravadora de CD/DVD %s"
#: ../control-center:511
#, c-format
@@ -391,7 +391,7 @@ msgstr "Unitat ZIP"
#: ../control-center:512
#, c-format
msgid "Set where your ZIP drive is mounted"
-msgstr "Defineix on es muntarà la unitat ZIP"
+msgstr "Estableix on es muntarà la vostra unitat ZIP"
#. -PO: please keep the following message very short: it must fit in the left list of MCC!!!
#: ../control-center:524 ../control-center:527
@@ -672,7 +672,7 @@ msgstr "Seleccioneu l'eina que voleu utilitzar"
#: ../lib/MDV/Control_Center.pm:53 ../lib/MDV/Control_Center.pm:54
#, c-format
msgid "Configure 3D Desktop effects"
-msgstr "Configura els efectes de l'escriptori 3D"
+msgstr "Configura els efectes 3D de l'escriptori"
#: ../lib/MDV/Control_Center.pm:66
#, c-format
@@ -684,7 +684,7 @@ msgstr ""
#: ../lib/MDV/Control_Center.pm:75
#, c-format
msgid "Set up autologin to automatically log in"
-msgstr "Activa l'entrada automàtica per entrar automàticament"
+msgstr "Prepara l'entrada automàtica per entrar automàticament"
#: ../lib/MDV/Control_Center.pm:76
#, c-format
@@ -701,12 +701,12 @@ msgstr "Instantànies "
#: ../lib/MDV/Control_Center.pm:95
#, c-format
msgid "Set up boot system"
-msgstr "Configura el sistema d'arrencada"
+msgstr "Prepara el sistema d'arrencada"
#: ../lib/MDV/Control_Center.pm:96
#, c-format
msgid "Set up how the system boots"
-msgstr "Configura com arrenca el sistema"
+msgstr "Prepara com arrenca el sistema"
#: ../lib/MDV/Control_Center.pm:105 ../lib/MDV/Control_Center.pm:106
#, c-format
@@ -716,7 +716,7 @@ msgstr "Comparteix la connexió a Internet amb altres màquines locals"
#: ../lib/MDV/Control_Center.pm:115 ../lib/MDV/Control_Center.pm:116
#, c-format
msgid "Set up a new network interface (LAN, ISDN, ADSL, ...)"
-msgstr "Configura una nova interfície de xarxa (LAN, XDSI, ADSL...)"
+msgstr "Prepara una interfície de xarxa nova (LAN, XDSI, ADSL, etc.)"
#: ../lib/MDV/Control_Center.pm:125
#, c-format
@@ -741,7 +741,7 @@ msgstr "Gestiona la data i l'hora"
#: ../lib/MDV/Control_Center.pm:156
#, c-format
msgid "Set up display manager"
-msgstr "Configura el gestor de pantalla"
+msgstr "Prepara el gestor de pantalla"
#: ../lib/MDV/Control_Center.pm:157
#, c-format
@@ -757,24 +757,23 @@ msgstr "Configura un servidor de fax"
#: ../lib/MDV/Control_Center.pm:176
#, c-format
msgid "Set up your personal firewall"
-msgstr "Configura un tallafoc personal"
+msgstr "Prepara el vostre tallafoc personal"
#: ../lib/MDV/Control_Center.pm:177
#, c-format
msgid ""
"Set up a personal firewall in order to protect the computer and the network"
-msgstr ""
-"Configura un tallafoc personal per tal de protegir l'ordinador i la xarxa"
+msgstr "Prepara un tallafoc personal per protegir l'ordinador i la xarxa"
#: ../lib/MDV/Control_Center.pm:186 ../lib/MDV/Control_Center.pm:187
#, c-format
msgid "Manage, add and remove fonts. Import Windows(TM) fonts"
-msgstr "Gestiona, afegeix i elimina lletres Importa lletres de Windows (TM)"
+msgstr "Gestiona, afegeix i elimina lletres. Importa lletres de Windows (TM)"
#: ../lib/MDV/Control_Center.pm:196 ../lib/MDV/Control_Center.pm:197
#, c-format
msgid "Set up the graphical server"
-msgstr "Configura el servidor gràfic"
+msgstr "Prepara el servidor gràfic"
#: ../lib/MDV/Control_Center.pm:206
#, c-format
@@ -824,13 +823,12 @@ msgstr "Configuració avançada per a les interfícies de xarxa i del tallafoc"
#: ../lib/MDV/Control_Center.pm:259
#, c-format
msgid "Set up network interfaces failover and firewall replication"
-msgstr ""
-"Configura les interfícies de xarxa failover i la replicació del tallafoc"
+msgstr "Prepara les interfícies de xarxa failover i la replicació del tallafoc"
#: ../lib/MDV/Control_Center.pm:268 ../lib/MDV/Control_Center.pm:269
#, c-format
msgid "Set up the keyboard layout"
-msgstr "Configura la disposició del teclat"
+msgstr "Prepara la disposició del teclat"
#: ../lib/MDV/Control_Center.pm:278
#, c-format
@@ -840,7 +838,7 @@ msgstr "Kolab"
#: ../lib/MDV/Control_Center.pm:279
#, c-format
msgid "Set up a groupware server"
-msgstr "Configura un servidor de programari de grup"
+msgstr "Prepara un servidor de programari de grup"
#: ../lib/MDV/Control_Center.pm:288
#, c-format
@@ -908,7 +906,7 @@ msgstr ""
#: ../lib/MDV/Control_Center.pm:346 ../lib/MDV/Control_Center.pm:347
#, c-format
msgid "Import Windows(TM) documents and settings"
-msgstr "Importa documents i configuracions de Windows(TM)"
+msgstr "Importa documents i paràmetres de Windows(TM)"
#: ../lib/MDV/Control_Center.pm:356
#, c-format
@@ -923,7 +921,7 @@ msgstr "Monitora les connexions de xarxa"
#: ../lib/MDV/Control_Center.pm:366 ../lib/MDV/Control_Center.pm:367
#, c-format
msgid "Set up the pointer device (mouse, touchpad)"
-msgstr "Configura el dispositiu de punter (ratolí, ratolí tàctil)"
+msgstr "Prepara el dispositiu de punter (ratolí, ratolí tàctil)"
#: ../lib/MDV/Control_Center.pm:375 ../lib/MDV/Control_Center.pm:376
#, c-format
@@ -983,12 +981,12 @@ msgstr "Comparteix les particions del disc dur"
#: ../lib/MDV/Control_Center.pm:437
#, c-format
msgid "Set up sharing of your hard disk partitions"
-msgstr "Configura la compartició de les particions del disc dur"
+msgstr "Prepara la compartició de les particions del vostre disc dur"
#: ../lib/MDV/Control_Center.pm:446 ../lib/MDV/Control_Center.pm:448
#, c-format
msgid "Set up the printer(s), the print job queues, ..."
-msgstr "Configura les impressores, les cues d'impressió..."
+msgstr "Prepara les impressores, les cues d'impressió, etc."
#: ../lib/MDV/Control_Center.pm:458
#, c-format
@@ -1008,7 +1006,7 @@ msgstr "Servidor intermediari"
#: ../lib/MDV/Control_Center.pm:469
#, c-format
msgid "Set up a proxy server for files and web browsing"
-msgstr "Configura un servidor intermediari per a fitxers i navegació web"
+msgstr "Prepara un servidor intermediari per als fitxers i navegació web"
#: ../lib/MDV/Control_Center.pm:477
#, c-format
@@ -1058,7 +1056,7 @@ msgstr "Gestiona la configuració de Samba"
#: ../lib/MDV/Control_Center.pm:528 ../lib/MDV/Control_Center.pm:529
#, c-format
msgid "Set up scanner"
-msgstr "Configura un escàner"
+msgstr "Prepara un escàner"
#: ../lib/MDV/Control_Center.pm:538
#, c-format
@@ -1097,7 +1095,7 @@ msgstr "Configura la freqüència de les actualitzacions"
#: ../lib/MDV/Control_Center.pm:581 ../lib/MDV/Control_Center.pm:584
#, c-format
msgid "Set up a UPS for power monitoring"
-msgstr "Configura un SAI per monitorar el corrent"
+msgstr "Prepara un SAI per monitorar el corrent"
#: ../lib/MDV/Control_Center.pm:594
#, c-format
8 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en" xml:lang="en">
<head>

<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="content-style-type" content="text/css" />
<meta http-equiv="content-language" content="en" />
<meta http-equiv="imagetoolbar" content="no" />
<meta name="resource-type" content="document" />
<meta name="distribution" content="global" />
<meta name="copyright" content="phpBB Group" />
<meta name="keywords" content="" />
<meta name="description" content="Hook System explanation" />
<title>phpBB3 &bull; Hook System</title>

<style type="text/css">
/* <![CDATA[ */

/*
	The original "prosilver" theme for phpBB3
	Created by subBlue design :: http://www.subBlue.com
*/

* { margin: 0; padding: 0; }

html { font-size: 100%; height: 100%; margin-bottom: 1px; }

body {
	font-family: Verdana, Helvetica, Arial, sans-serif;
	color: #828282;
	background-color: #FFFFFF;
	font-size: 12px;
	margin: 0;
	padding: 12px 0;
}

img { border-width: 0; }

p {
	line-height: 1.3em;
	font-size: 1.1em;
	margin-bottom: 1.5em;
}

hr {
	border: 0 none #FFFFFF;
	border-top: 1px solid #CCCCCC;
	height: 1px;
	margin: 5px 0;
	display: block;
	clear: both;
}

html, body {
	color: #536482;
	background-color: #FFFFFF;
}

#doc-description h1 {
	font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
	margin-right: 200px;
	color: #FFFFFF;
	margin-top: 15px;
	font-weight: bold;
	font-size: 2em;
	color: #fff;
}

h1 {
	font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
	font-weight: normal;
	color: #000;
	font-size: 2em;
	margin: 0.8em 0 0.2em 0;
}

h2 {
	font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
	font-weight: normal;
	color: #28313F;
	font-size: 1.5em;
	margin: 0.8em 0 0.2em 0;
}

h3 {
	font-family: Arial, Helvetica, sans-serif;
	font-weight: bold;
	border-bottom: 1px solid #CCCCCC;
	margin-bottom: 3px;
	padding-bottom: 2px;
	font-size: 1.05em;
	color: #115098;
	margin-top: 20px;
}

.good { color: green; }
.bad { color: red; }

.version {
	margin-top: 20px;
	text-align: left;
	font-size: 70%;
	color: #006600;
	border-top: 1px solid #ccc;
}

code {
	color: #006600;
	font-weight: normal;
	font-family: 'Courier New', monospace;
	border-color: #D1D7DC;
	border-width: 1px;
	border-style: solid;
	background-color: #FAFAFA;
}

#wrap {
	padding: 0 20px;
	min-width: 650px;
}

#simple-wrap {
	padding: 6px 10px;
}

#page-body {
	margin: 4px 0;
	clear: both;
}

#page-footer {
	clear: both;
}

#logo {
	float: left;
	width: auto;
	padding: 10px 13px 0 10px;
}

a#logo:hover {
	text-decoration: none;
}

#doc-description {
	float: left;
	width: 70%;
}

#doc-description h1 {
	margin-right: 0;
}

.headerbar {
	background: #ebebeb none repeat-x 0 0;
	color: #FFFFFF;
	margin-bottom: 4px;
	padding: 0 5px;
}

span.corners-top, span.corners-bottom, span.corners-top span, span.corners-bottom span {
	font-size: 1px;
	line-height: 1px;
	display: block;
	height: 5px;
	background-repeat: no-repeat;
}

span.corners-top {
	background-image: none;
	background-position: 0 0;
	margin: 0 -5px;
}

span.corners-top span {
	background-image: none;
	background-position: 100% 0;
}

span.corners-bottom {
	background-image: none;
	background-position: 0 100%;
	margin: 0 -5px;
	clear: both;
}

span.corners-bottom span {
	background-image: none;
	background-position: 100% 100%;
}

.paragraph {
	padding: 0 10px;
	margin-bottom: 4px;
	background-repeat: no-repeat;
	background-position: 100% 0;
	background-color: #ECF3F7;
}

.paragraph:target .content {
	color: #000000;
}

.paragraph:target h3 a {
	color: #000000;
}

.content {
	color: #333333;
}

.content h2, .panel h2 {
	color: #115098;
	border-bottom-color:  #CCCCCC;
}

a:link	{ color: #898989; text-decoration: none; }
a:visited	{ color: #898989; text-decoration: none; }
a:hover	{ color: #d3d3d3; text-decoration: underline; }
a:active	{ color: #d2d2d2; text-decoration: none; }

hr {
	border-color: #FFFFFF;
	border-top-color: #CCCCCC;
}

.menu {
	background-color: #cadceb;
}

.headerbar {
	background-color: #12A3EB;
	background-image: url("bg_header.gif");
	color: #FFFFFF;
}

.panel {
	background-color: #ECF1F3;
	color: #28313F;
}


span.corners-top {
	background-image: url("corners_left.png");
}

span.corners-top span {
	background-image: url("corners_right.png");
}

span.corners-bottom {
	background-image: url("corners_left.png");
}

span.corners-bottom span {
	background-image: url("corners_right.png");
}

.error {
	color: #BC2A4D;
}

a:link	{ color: #105289; }
a:visited	{ color: #105289; }
a:hover	{ color: #D31141; }
a:active	{ color: #368AD2; }

.paragraph span.corners-top, .paragraph span.corners-bottom {
	margin: 0 -10px;
}

.content {
	padding: 0;
	line-height: 1.48em;
	color: #333333;
}

.content h2, .panel h2 {
	color: #115098;
	border-bottom-color:  #CCCCCC;
}

.notice {
	border-top-color:  #CCCCCC;
}

.codebox {
	padding: 3px;
	background-color: #FFFFFF;
	border: 1px solid #C9D2D8;
	font-size: 1em;
	margin-bottom: 10px;
	display: block;
	font: 0.9em Monaco, "Andale Mono","Courier New", Courier, mono;
	line-height: 1.3em;
}

* html hr { margin: 0; }
* html span.corners-top, * html span.corners-bottom { background-image: url("corners_left.gif"); }
* html span.corners-top span, * html span.corners-bottom span { background-image: url("corners_right.gif"); }

.back2top {
	clear: both;
	height: 11px;
	text-align: right;
}

.content ol {
	margin-left: 25px;
}

/* ]]> */
</style>

</head>

<body id="phpbb" class="section-docs">

<div id="wrap">
	<a id="top" name="top" accesskey="t"></a>
	<div id="page-header">
		<div class="headerbar">
			<div class="inner"><span class="corners-top"><span></span></span>

			<div id="doc-description">
				<a href="../index.php" id="logo"><img src="site_logo.gif" alt="" /></a>
				<h1>Hook System</h1>
				<p>This is an explanation of how to use the phpBB3 hook system.</p>
				<p style="display: none;"><a href="#start_here">Skip</a></p>
			</div>

			<span class="corners-bottom"><span></span></span></div>
		</div>
	</div>

	<a name="start_here"></a>

	<div id="page-body">

	<h1>Hook System</h1>

	<div class="paragraph menu">
		<div class="inner"><span class="corners-top"><span></span></span>

		<div class="content">

			<ol>
				<li><a href="#intro">Introduction</a></li>
				<li><a href="#use">Allow hooks in functions/methods</a></li>
				<li><a href="#register">Registering hooks</a></li>
				<li><a href="#return">Result returning</a></li>
				<li><a href="#embed">Embedding your hook files/classes/methods</a></li>
				<li><a href="#disclaimer">Copyright and disclaimer</a></li>
			</ol>

		</div>

		<span class="corners-bottom"><span></span></span></div>
	</div>

	<hr />

	<a name="intro"></a><h2>1. Introduction</h2>

	<div class="paragraph">
		<div class="inner"><span class="corners-top"><span></span></span>

		<div class="content">

<h3>What is it?</h3>

<p>The hook system allows applicaton and mod developers to hook into phpBB's or their own functions.</p>

<h3>Pre-defined hookable phpBB3 functions</h3>

<p>In phpBB3 there are four functions you are able to hook into with your custom functions:</p>

<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>$template-&gt;display($handle, $include_once = true);</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>

<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>There are also valid external constants you may want to use if you embed phpBB3 into your application:</p>

<div class="codebox"><pre>
PHPBB_MSG_HANDLER (overwrite message handler)
PHPBB_DB_NEW_LINK (overwrite new_link parameter for sql_connect)
PHPBB_ROOT_PATH   (overwrite $phpbb_root_path)
PHPBB_ADMIN_PATH  (overwrite $phpbb_admin_path)
PHPBB_USE_BOARD_URL_PATH (use generate_board_url() for image paths instead of $phpbb_root_path)
</pre></div>

<p>If the <code>PHPBB_USE_BOARD_URL_PATH</code> constant is set to true, phpBB uses generate_board_url() (this will return the boards url with the script path included) on all instances where web-accessible images are loaded. The exact locations are:</p>

<ul>
	<li>/includes/session.php - user::img()</li>
	<li>/includes/functions_content.php - smiley_text()</li>
</ul>

<p>Path locations for the following template variables are affected by this too:</p>

<ul>
	<li>{T_THEME_PATH} - styles/xxx/theme</li>
	<li>{T_TEMPLATE_PATH} - styles/xxx/template</li>
	<li>{T_SUPER_TEMPLATE_PATH} - styles/xxx/template</li>
	<li>{T_IMAGESET_PATH} - styles/xxx/imageset</li>
	<li>{T_IMAGESET_LANG_PATH} - styles/xxx/imageset/yy</li>
	<li>{T_IMAGES_PATH} - images/</li>
	<li>{T_SMILIES_PATH} - $config['smilies_path']/</li>
	<li>{T_AVATAR_PATH} - $config['avatar_path']/</li>
	<li>{T_AVATAR_GALLERY_PATH} - $config['avatar_gallery_path']/</li>
	<li>{T_ICONS_PATH} - $config['icons_path']/</li>
	<li>{T_RANKS_PATH} - $config['ranks_path']/</li>
	<li>{T_UPLOAD_PATH} - $config['upload_path']/</li>
	<li>{T_STYLESHEET_LINK} - styles/xxx/theme/stylesheet.css (or link to style.php if css is parsed dynamically)</li>
	<li>New template variable {BOARD_URL} for the board url + script path.</li>
</ul>


		</div>

		<div class="back2top"><a href="#wrap" class="top">Back to Top</a></div>

		<span class="corners-bottom"><span></span></span></div>
	</div>

	<a name="use"></a><h2>2. Allow hooks in functions/methods</h2>

	<div class="paragraph">
		<div class="inner"><span class="corners-top"><span></span></span>

		<div class="content">

<p>The following examples explain how phpBB3 utilize the in-build hook system. You will be more interested in registering your hooks, but showing you this may help you understand the system better along the way.</p>

<p>First of all, this is how a function need to be layed out if you want to allow it to be hookable...</p>

<div class="codebox"><pre>
function my_own_function($my_first_parameter, $my_second_parameter)
{
	global $phpbb_hook;

	if ($phpbb_hook-&gt;call_hook(__FUNCTION__, $my_first_parameter, $my_second_parameter))
	{
		if ($phpbb_hook-&gt;hook_return(__FUNCTION__))
		{
			return $phpbb_hook-&gt;hook_return_result(__FUNCTION__);
		}
	}

	[YOUR CODE HERE]
}
</pre></div>

<p>Above, the call_hook function should always be mapping your function call... in regard to the number of parameters passed.</p>

<p>This is how you could make a method being hookable...</p>

<div class="codebox"><pre>
class my_hookable_object
{
	function hook_me($my_first_parameter, $my_second_parameter)
	{
		global $phpbb_hook;

		if ($phpbb_hook-&gt;call_hook(array(__CLASS__, __FUNCTION__), $my_first_parameter, $my_second_parameter))
		{
			if ($phpbb_hook-&gt;hook_return(array(__CLASS__, __FUNCTION__)))
			{
				return $phpbb_hook-&gt;hook_return_result(array(__CLASS__, __FUNCTION__));
			}
		}

		[YOUR CODE HERE]
	}
}
</pre></div>

<p>The only difference about calling it is the way you define the first parameter. For a function it is only <code>__FUNCTION__</code>, for a method it is <code>array(__CLASS__, __FUNCTION__)</code>. In PHP4 __CLASS__ is always returning the class in lowercase.</p>

<p>Now, in phpBB there are some pre-defined hooks available, but how do you make your own hookable function available (and therefore allowing others to hook into it)? For this, there is the add_hook() method:</p>

<div class="codebox"><pre>
// Adding your own hookable function:
$phpbb_hook-&gt;add_hook('my_own_function');

// Adding your own hookable method:
$phpbb_hook-&gt;add_hook(array('my_hookable_object', 'hook_me'));
</pre></div>

<p>You are also able to remove the possibility of hooking a function/method by calling <code>$phpbb_hook-&gt;remove_hook()</code> with the same parameters as add_hook().<br />
This comes in handy if you want to force some hooks not to be called - at all.</p>

		</div>

		<div class="back2top"><a href="#wrap" class="top">Back to Top</a></div>

		<span class="corners-bottom"><span></span></span></div>
	</div>

	<a name="register"></a><h2>3. Registering hooks</h2>

	<div class="paragraph">
		<div class="inner"><span class="corners-top"><span></span></span>

		<div class="content">

		<h3>Registering hooks</h3>

<p>Now to actually defining your functions which should be called. For this we take the append_sid() function as an example (this function is able to be hooked by default). We create two classes, one being static and a function:</p>

<div class="codebox"><pre>
class my_append_sid_class
{
	// Our functions
	function my_append_sid(&amp;$hook, $url, $params = false, $is_amp = true, $session_id = false)
	{
		// Get possible previous results
		$result = $hook-&gt;previous_hook_result('append_sid');

		return $result['result'] . '&lt;br /&gt;And i was the second one.';
	}
}

// Yet another class :o
class my_second_append_sid_class
{
	function my_append_sid(&amp;$hook, $url, $params = false, $is_amp = true, $session_id = false)
	{
		// Get possible previous results
		$result = $hook-&gt;previous_hook_result('append_sid');

		echo $result['result'] . '&lt;br /&gt;I was called as the third one.';
	}
}

// And a normal function
function my_append_sid(&amp;$hook, $url, $params = false, $is_amp = true, $session_id = false)
{
	// Get possible previous results
	$result = $hook-&gt;previous_hook_result('append_sid');

	return 'I was called as the first one';
}

// Initializing the second class
$my_second_append_sid_class = new my_second_append_sid_class();
</pre></div>

<p>Make sure you add the same parameters to your function as is defined for the hookable function with one exception: The first variable is always <code>&amp;$hook</code>... this is the hook object itself you are able to operate on.</p>

<p>Now we register the hooks one by one with the <code>$phpbb_hook-&gt;register()</code> method:</p>

<div class="codebox"><pre>
// Now, we register our append_sid &quot;replacements&quot; in a stacked way...
// Registering the function (this is called first)
$phpbb_hook-&gt;register('append_sid', 'my_append_sid');

// Registering the first class
$phpbb_hook-&gt;register('append_sid', array('my_append_sid_class', 'my_append_sid'));
$phpbb_hook-&gt;register('append_sid', array(&amp;$my_second_append_sid_class, 'my_append_sid'));
</pre></div>

<p>With this you are even able to make your own functions that are already hooked itself being hooked again...</p>

<div class="codebox"><pre>
// Registering hook, which will be called
$phpbb_hook-&gt;register('append_sid', 'my_own_append_sid');

// Add hook to our called hook function
$phpbb_hook-&gt;add_hook('my_own_append_sid');

// Register added hook
$phpbb_hook-&gt;register('my_own_append_sid', 'also_my_own_append_sid');
</pre></div>

		<h3>Special treatment/chains</h3>

		<p>The <code>register</code> method is able to take a third argument to specify a special 'chain' mode. The valid modes are <code>first</code>, <code>last</code> and <code>standalone</code></p>

		<p><code>$phpbb_hook-&gt;register('append_sid', 'my_own_append_sid', 'first')</code> would make sure that the function is called in the beginning of the chain. It is possible that more than one function is called within the first block - here the FIFO principle is used.</p>

		<p><code>$phpbb_hook-&gt;register('append_sid', 'my_own_append_sid', 'last')</code> would make sure that the function is called at the very end of the chain. It is possible that more than one function is called within the last block - here the FIFO principle is used.</p>

		<p><code>$phpbb_hook-&gt;register('append_sid', 'my_own_append_sid', 'standalone')</code> makes sure only the defined function is called. All other functions are removed from the chain and no other functions are added to it later on. If two applications try to trigger the standalone mode a PHP notice will be printed and the second function being discarded.</p>

		<h3>Only allowing hooks for some objects</h3>

		<p>Because the hook system is not able to differate between initialized objects and only operate on the class, you need to solve this on the code level.</p>

		<p>One possibility would be to use a property:</p>

		<div class="codebox"><pre>
class my_hookable_object
{
	function blabla()
	{
	}
}

class my_hookable_object2 extends my_hookable_object
{
	var $call_hook = true;

	function hook_me($my_first_parameter, $my_second_parameter)
	{
		if ($this-&gt;call_hook)
		{
			global $phpbb_hook;

			if ($phpbb_hook-&gt;call_hook(array(__CLASS__, __FUNCTION__), $my_first_parameter, $my_second_parameter))
			{
				if ($phpbb_hook-&gt;hook_return(array(__CLASS__, __FUNCTION__)))
				{
					return $phpbb_hook-&gt;hook_return_result(array(__CLASS__, __FUNCTION__));
				}
			}
		}

		return 'not hooked';
	}
}

function hooking(&amp;$hook, $first, $second)
{
	return 'hooked';
}

$first_object = new my_hookable_object2();
$second_object = new my_hookable_object2();

$phpbb_hook-&gt;add_hook(array('my_hookable_object2', 'hook_me'));

$phpbb_hook-&gt;register(array('my_hookable_object2', 'hook_me'), 'hooking');

// Do not call the hook for $first_object
$first_object-&gt;call_hook = false;

echo $first_object-&gt;hook_me('first', 'second') . '&lt;br /&gt;';
echo $second_object-&gt;hook_me('first', 'second') . '&lt;br /&gt;';
</pre></div>

<p>OUTPUT:</p>

<div class="codebox"><pre>
not hooked
hooked
</pre></div>

		<p>A different possibility would be using a function variable (which could be left out on passing the function variables to the hook):</p>

		<div class="codebox"><pre>
class my_hookable_object
{
	function blabla()
	{
	}
}

class my_hookable_object2 extends my_hookable_object
{
	function hook_me($my_first_parameter, $my_second_parameter, $hook_me = true)
	{
		if ($hook_me)
		{
			global $phpbb_hook;

			if ($phpbb_hook-&gt;call_hook(array(__CLASS__, __FUNCTION__), $my_first_parameter, $my_second_parameter))
			{
				if ($phpbb_hook-&gt;hook_return(array(__CLASS__, __FUNCTION__)))
				{
					return $phpbb_hook-&gt;hook_return_result(array(__CLASS__, __FUNCTION__));
				}
			}
		}

		return 'not hooked';
	}
}

function hooking(&amp;$hook, $first, $second)
{
	return 'hooked';
}

$first_object = new my_hookable_object2();
$second_object = new my_hookable_object2();

$phpbb_hook-&gt;add_hook(array('my_hookable_object2', 'hook_me'));

$phpbb_hook-&gt;register(array('my_hookable_object2', 'hook_me'), 'hooking');

echo $first_object-&gt;hook_me('first', 'second', false) . '&lt;br /&gt;';
echo $second_object-&gt;hook_me('first', 'second') . '&lt;br /&gt;';
		</pre></div>

		<p>OUTPUT:</p>

		<div class="codebox"><pre>
not hooked
hooked
		</pre></div>

		</div>

		<div class="back2top"><a href="#wrap" class="top">Back to Top</a></div>

		<span class="corners-bottom"><span></span></span></div>
	</div>

	<a name="return"></a><h2>4. Result returning</h2>

	<div class="paragraph">
		<div class="inner"><span class="corners-top"><span></span></span>

		<div class="content">

<p>Generally, the distinction has to be made if a function returns the result obtained from the called function or continue the execution. Based on the needs of the application this may differ. Therefore, the function returns the results only if the called hook function is returning a result.</p>

<h3>Case 1 - Returning the result</h3>

<p>Imagine the following function supporting hooks:</p>

<div class="codebox"><pre>
function append_sid($url, $params = false, $is_amp = true, $session_id = false)
{
	global $_SID, $_EXTRA_URL, $phpbb_hook;

	// Developers using the hook function need to globalise the $_SID and $_EXTRA_URL on their own and also handle it appropiatly.
	// They could mimick most of what is within this function
	if ($phpbb_hook-&gt;call_hook(__FUNCTION__, $url, $params, $is_amp, $session_id))
	{
		if ($phpbb_hook-&gt;hook_return(__FUNCTION__))
		{
			return $phpbb_hook-&gt;hook_return_result(__FUNCTION__);
		}
	}

	[...]
}
</pre></div>

<p>Now, the following function is yours. Since you return a value, the append_sid() function itself is returning it as is:</p>

<div class="codebox"><pre>
// The function called
function my_append_sid(&amp;$hook, $url, $params = false, $is_amp = true, $session_id = false)
{
	// Get possible previous results
	$result = $hook-&gt;previous_hook_result('append_sid');

	return 'Since i return something the append_sid() function will return my result.';
}
</pre></div>

<p>To be able to get the results returned from functions higher in the change the <code>previous_hook_result()</code> method should always be used, it returns an <code>array('result' => [your result])</code> construct.</p>

<h3>Case 2 - Not Returning any result</h3>

<p>Sometimes applications want to return nothing and therefore force the underlying function to continue it's execution:</p>

<div class="codebox"><pre>
function append_sid($url, $params = false, $is_amp = true, $session_id = false)
{
	global $_SID, $_EXTRA_URL, $phpbb_hook;

	// Developers using the hook function need to globalise the $_SID and $_EXTRA_URL on their own and also handle it appropiatly.
	// They could mimick most of what is within this function
	if ($phpbb_hook-&gt;call_hook(__FUNCTION__, $url, $params, $is_amp, $session_id))
	{
		if ($phpbb_hook-&gt;hook_return(__FUNCTION__))
		{
			return $phpbb_hook-&gt;hook_return_result(__FUNCTION__);
		}
	}

	[...]
}

// The function called
function my_append_sid(&amp;$hook, $url, $params = false, $is_amp = true, $session_id = false)
{
	// Get possible previous results
	$result = $hook-&gt;previous_hook_result('append_sid');

	[...]

	// I only rewrite some variables, but return nothing. Therefore, the append_sid() function will not return my (non)result.
}
</pre></div>

<p>Please Note: The decision to return or not return is solely made of the very last function call within the hook chain. An example:</p>

<div class="codebox"><pre>
// The function called
function my_append_sid(&amp;$hook, $url, $params = false, $is_amp = true, $session_id = false)
{
	// Get possible previous results
	$result = $hook-&gt;previous_hook_result('append_sid');

	// $result is not filled

	return 'FILLED';
}

// This function is registered too and gets executed after my_append_sid()
function my_own_append_sid(&amp;$hook, $url, $params = false, $is_amp = true, $session_id = false)
{
	$result = $hook->previous_hook_result('append_sid');

	// $result is actually filled with $result['result'] = 'FILLED'
	// But i return nothing, therefore append_sid() continues it's execution.
}

// The way both functions are registered.
$phpbb_hook->register('append_sid', 'my_append_sid');
$phpbb_hook->register('append_sid', 'my_own_append_sid');
</pre></div>

		</div>

		<div class="back2top"><a href="#wrap" class="top">Back to Top</a></div>

		<span class="corners-bottom"><span></span></span></div>
	</div>

	<a name="embed"></a><h2>5. Embedding your hook files/classes/methods</h2>

	<div class="paragraph">
		<div class="inner"><span class="corners-top"><span></span></span>

		<div class="content">

<p>There are basically two methods you are able to choose from:</p>

<p>1) Add a file to includes/hooks/. The file need to be prefixed by <code>hook_</code>. This file is included within common.php, you are able to register your hooks, include other files or functions, etc. It is advised to only include other files if needed (within a function call for example).</p>

<p>Please be aware that you need to purge your cache within the ACP to make your newly placed file available to phpBB3.</p>

<p>2) The second method is meant for those wanting to wrap phpBB3 without placing a custom file to the hooks directory. This is mostly done by including phpBB's files within the application file. To be able to register your hooks you need to create a function within your application:</p>

<div class="codebox"><pre>
// My function which gets executed within the hooks constuctor
function phpbb_hook_register(&amp;$hook)
{
	$hook-&gt;register('append_sid', 'my_append_sid');
}

[...]
</pre></div>

<p>You should get the idea. ;)</p>

		</div>

		<div class="back2top"><a href="#wrap" class="top">Back to Top</a></div>

		<span class="corners-bottom"><span></span></span></div>
	</div>

	<a name="disclaimer"></a><h2>6. Copyright and disclaimer</h2>

	<div class="paragraph">
		<div class="inner"><span class="corners-top"><span></span></span>

		<div class="content">

	<p>This application is opensource software released under the <a href="http://opensource.org/licenses/gpl-2.0.php">GNU General Public License v2</a>. Please see source code and the docs directory for more details. This package and its contents are Copyright (c) <a href="https://www.phpbb.com/">phpBB Group</a>, All Rights Reserved.</p>

		</div>

		<div class="back2top"><a href="#wrap" class="top">Back to Top</a></div>

		<span class="corners-bottom"><span></span></span></div>
	</div>

	<div id="page-footer">
		<div class="version">&nbsp;</div>
	</div>
</div></div>

<div>
	<a id="bottom" name="bottom" accesskey="z"></a>
</div>

</body>
</html>