Revision 827
Added by doc over 16 years ago
trunk/CHANGELOG | ||
---|---|---|
12 | 12 |
|
13 | 13 |
------------------------------------- 2.7.0 ------------------------------------- |
14 | 14 |
14-Apr-2008 Christian Sommer |
15 |
+ added show_menu2() to pre-installed WB modules (many thanks to Brodie Thiesfield for this great menu function replacment) |
|
15 | 16 |
! allowed tags for multi-lingual module descriptions |
16 | 17 |
14-Apr-2008 Thomas Hornik |
17 | 18 |
# fixed issue with multigroups (level 0 page-creation) |
trunk/wb/modules/show_menu2/info.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
// $Id$ |
|
4 |
|
|
5 |
/* |
|
6 |
show_menu2: show_menu replacement for Website Baker |
|
7 |
Copyright (C) 2006-2008, Brodie Thiesfield |
|
8 |
|
|
9 |
This program is free software; you can redistribute it and/or |
|
10 |
modify it under the terms of the GNU General Public License |
|
11 |
as published by the Free Software Foundation; either version 2 |
|
12 |
of the License, or (at your option) any later version. |
|
13 |
|
|
14 |
This program is distributed in the hope that it will be useful, |
|
15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17 |
GNU General Public License for more details. |
|
18 |
|
|
19 |
You should have received a copy of the GNU General Public License |
|
20 |
along with this program; if not, write to the Free Software |
|
21 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
22 |
02110-1301, USA. |
|
23 |
|
|
24 |
THANKS |
|
25 |
====== |
|
26 |
Thanks to the following people: |
|
27 |
|
|
28 |
Stuart Fraser |
|
29 |
* Original request for a better menu system |
|
30 |
|
|
31 |
Ezra Peisach |
|
32 |
* Bug fixes |
|
33 |
|
|
34 |
Thorn |
|
35 |
* Added support for WB 2.7 multiple groups and publish by date |
|
36 |
|
|
37 |
*/ |
|
38 |
|
|
39 |
$module_directory = 'show_menu2'; |
|
40 |
$module_name = 'show_menu2'; |
|
41 |
$module_function = 'snippet'; |
|
42 |
$module_version = '4.5'; |
|
43 |
$module_platform = '2.6.x | 2.7.x'; |
|
44 |
$module_author = 'Brodie Thiesfield'; |
|
45 |
$module_license = 'GNU General Public License'; |
|
46 |
$module_description = 'A code snippet for the Website Baker CMS providing a complete replacement for the builtin menu functions. See <a href="http://code.jellycan.com/show_menu2/" target="_blank">http://code.jellycan.com/show_menu2/</a> for details or view the <a href="' .WB_URL .'/modules/show_menu2/README" target="_blank">README</a> file.'; |
|
47 |
?> |
|
0 | 48 |
trunk/wb/modules/show_menu2/LICENCE | ||
---|---|---|
1 |
GNU GENERAL PUBLIC LICENSE |
|
2 |
Version 2, June 1991 |
|
3 |
|
|
4 |
Copyright (C) 1989, 1991 Free Software Foundation, Inc. |
|
5 |
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|
6 |
Everyone is permitted to copy and distribute verbatim copies |
|
7 |
of this license document, but changing it is not allowed. |
|
8 |
|
|
9 |
Preamble |
|
10 |
|
|
11 |
The licenses for most software are designed to take away your |
|
12 |
freedom to share and change it. By contrast, the GNU General Public |
|
13 |
License is intended to guarantee your freedom to share and change free |
|
14 |
software--to make sure the software is free for all its users. This |
|
15 |
General Public License applies to most of the Free Software |
|
16 |
Foundation's software and to any other program whose authors commit to |
|
17 |
using it. (Some other Free Software Foundation software is covered by |
|
18 |
the GNU Library General Public License instead.) You can apply it to |
|
19 |
your programs, too. |
|
20 |
|
|
21 |
When we speak of free software, we are referring to freedom, not |
|
22 |
price. Our General Public Licenses are designed to make sure that you |
|
23 |
have the freedom to distribute copies of free software (and charge for |
|
24 |
this service if you wish), that you receive source code or can get it |
|
25 |
if you want it, that you can change the software or use pieces of it |
|
26 |
in new free programs; and that you know you can do these things. |
|
27 |
|
|
28 |
To protect your rights, we need to make restrictions that forbid |
|
29 |
anyone to deny you these rights or to ask you to surrender the rights. |
|
30 |
These restrictions translate to certain responsibilities for you if you |
|
31 |
distribute copies of the software, or if you modify it. |
|
32 |
|
|
33 |
For example, if you distribute copies of such a program, whether |
|
34 |
gratis or for a fee, you must give the recipients all the rights that |
|
35 |
you have. You must make sure that they, too, receive or can get the |
|
36 |
source code. And you must show them these terms so they know their |
|
37 |
rights. |
|
38 |
|
|
39 |
We protect your rights with two steps: (1) copyright the software, and |
|
40 |
(2) offer you this license which gives you legal permission to copy, |
|
41 |
distribute and/or modify the software. |
|
42 |
|
|
43 |
Also, for each author's protection and ours, we want to make certain |
|
44 |
that everyone understands that there is no warranty for this free |
|
45 |
software. If the software is modified by someone else and passed on, we |
|
46 |
want its recipients to know that what they have is not the original, so |
|
47 |
that any problems introduced by others will not reflect on the original |
|
48 |
authors' reputations. |
|
49 |
|
|
50 |
Finally, any free program is threatened constantly by software |
|
51 |
patents. We wish to avoid the danger that redistributors of a free |
|
52 |
program will individually obtain patent licenses, in effect making the |
|
53 |
program proprietary. To prevent this, we have made it clear that any |
|
54 |
patent must be licensed for everyone's free use or not licensed at all. |
|
55 |
|
|
56 |
The precise terms and conditions for copying, distribution and |
|
57 |
modification follow. |
|
58 |
|
|
59 |
GNU GENERAL PUBLIC LICENSE |
|
60 |
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION |
|
61 |
|
|
62 |
0. This License applies to any program or other work which contains |
|
63 |
a notice placed by the copyright holder saying it may be distributed |
|
64 |
under the terms of this General Public License. The "Program", below, |
|
65 |
refers to any such program or work, and a "work based on the Program" |
|
66 |
means either the Program or any derivative work under copyright law: |
|
67 |
that is to say, a work containing the Program or a portion of it, |
|
68 |
either verbatim or with modifications and/or translated into another |
|
69 |
language. (Hereinafter, translation is included without limitation in |
|
70 |
the term "modification".) Each licensee is addressed as "you". |
|
71 |
|
|
72 |
Activities other than copying, distribution and modification are not |
|
73 |
covered by this License; they are outside its scope. The act of |
|
74 |
running the Program is not restricted, and the output from the Program |
|
75 |
is covered only if its contents constitute a work based on the |
|
76 |
Program (independent of having been made by running the Program). |
|
77 |
Whether that is true depends on what the Program does. |
|
78 |
|
|
79 |
1. You may copy and distribute verbatim copies of the Program's |
|
80 |
source code as you receive it, in any medium, provided that you |
|
81 |
conspicuously and appropriately publish on each copy an appropriate |
|
82 |
copyright notice and disclaimer of warranty; keep intact all the |
|
83 |
notices that refer to this License and to the absence of any warranty; |
|
84 |
and give any other recipients of the Program a copy of this License |
|
85 |
along with the Program. |
|
86 |
|
|
87 |
You may charge a fee for the physical act of transferring a copy, and |
|
88 |
you may at your option offer warranty protection in exchange for a fee. |
|
89 |
|
|
90 |
2. You may modify your copy or copies of the Program or any portion |
|
91 |
of it, thus forming a work based on the Program, and copy and |
|
92 |
distribute such modifications or work under the terms of Section 1 |
|
93 |
above, provided that you also meet all of these conditions: |
|
94 |
|
|
95 |
a) You must cause the modified files to carry prominent notices |
|
96 |
stating that you changed the files and the date of any change. |
|
97 |
|
|
98 |
b) You must cause any work that you distribute or publish, that in |
|
99 |
whole or in part contains or is derived from the Program or any |
|
100 |
part thereof, to be licensed as a whole at no charge to all third |
|
101 |
parties under the terms of this License. |
|
102 |
|
|
103 |
c) If the modified program normally reads commands interactively |
|
104 |
when run, you must cause it, when started running for such |
|
105 |
interactive use in the most ordinary way, to print or display an |
|
106 |
announcement including an appropriate copyright notice and a |
|
107 |
notice that there is no warranty (or else, saying that you provide |
|
108 |
a warranty) and that users may redistribute the program under |
|
109 |
these conditions, and telling the user how to view a copy of this |
|
110 |
License. (Exception: if the Program itself is interactive but |
|
111 |
does not normally print such an announcement, your work based on |
|
112 |
the Program is not required to print an announcement.) |
|
113 |
|
|
114 |
These requirements apply to the modified work as a whole. If |
|
115 |
identifiable sections of that work are not derived from the Program, |
|
116 |
and can be reasonably considered independent and separate works in |
|
117 |
themselves, then this License, and its terms, do not apply to those |
|
118 |
sections when you distribute them as separate works. But when you |
|
119 |
distribute the same sections as part of a whole which is a work based |
|
120 |
on the Program, the distribution of the whole must be on the terms of |
|
121 |
this License, whose permissions for other licensees extend to the |
|
122 |
entire whole, and thus to each and every part regardless of who wrote it. |
|
123 |
|
|
124 |
Thus, it is not the intent of this section to claim rights or contest |
|
125 |
your rights to work written entirely by you; rather, the intent is to |
|
126 |
exercise the right to control the distribution of derivative or |
|
127 |
collective works based on the Program. |
|
128 |
|
|
129 |
In addition, mere aggregation of another work not based on the Program |
|
130 |
with the Program (or with a work based on the Program) on a volume of |
|
131 |
a storage or distribution medium does not bring the other work under |
|
132 |
the scope of this License. |
|
133 |
|
|
134 |
3. You may copy and distribute the Program (or a work based on it, |
|
135 |
under Section 2) in object code or executable form under the terms of |
|
136 |
Sections 1 and 2 above provided that you also do one of the following: |
|
137 |
|
|
138 |
a) Accompany it with the complete corresponding machine-readable |
|
139 |
source code, which must be distributed under the terms of Sections |
|
140 |
1 and 2 above on a medium customarily used for software interchange; or, |
|
141 |
|
|
142 |
b) Accompany it with a written offer, valid for at least three |
|
143 |
years, to give any third party, for a charge no more than your |
|
144 |
cost of physically performing source distribution, a complete |
|
145 |
machine-readable copy of the corresponding source code, to be |
|
146 |
distributed under the terms of Sections 1 and 2 above on a medium |
|
147 |
customarily used for software interchange; or, |
|
148 |
|
|
149 |
c) Accompany it with the information you received as to the offer |
|
150 |
to distribute corresponding source code. (This alternative is |
|
151 |
allowed only for noncommercial distribution and only if you |
|
152 |
received the program in object code or executable form with such |
|
153 |
an offer, in accord with Subsection b above.) |
|
154 |
|
|
155 |
The source code for a work means the preferred form of the work for |
|
156 |
making modifications to it. For an executable work, complete source |
|
157 |
code means all the source code for all modules it contains, plus any |
|
158 |
associated interface definition files, plus the scripts used to |
|
159 |
control compilation and installation of the executable. However, as a |
|
160 |
special exception, the source code distributed need not include |
|
161 |
anything that is normally distributed (in either source or binary |
|
162 |
form) with the major components (compiler, kernel, and so on) of the |
|
163 |
operating system on which the executable runs, unless that component |
|
164 |
itself accompanies the executable. |
|
165 |
|
|
166 |
If distribution of executable or object code is made by offering |
|
167 |
access to copy from a designated place, then offering equivalent |
|
168 |
access to copy the source code from the same place counts as |
|
169 |
distribution of the source code, even though third parties are not |
|
170 |
compelled to copy the source along with the object code. |
|
171 |
|
|
172 |
4. You may not copy, modify, sublicense, or distribute the Program |
|
173 |
except as expressly provided under this License. Any attempt |
|
174 |
otherwise to copy, modify, sublicense or distribute the Program is |
|
175 |
void, and will automatically terminate your rights under this License. |
|
176 |
However, parties who have received copies, or rights, from you under |
|
177 |
this License will not have their licenses terminated so long as such |
|
178 |
parties remain in full compliance. |
|
179 |
|
|
180 |
5. You are not required to accept this License, since you have not |
|
181 |
signed it. However, nothing else grants you permission to modify or |
|
182 |
distribute the Program or its derivative works. These actions are |
|
183 |
prohibited by law if you do not accept this License. Therefore, by |
|
184 |
modifying or distributing the Program (or any work based on the |
|
185 |
Program), you indicate your acceptance of this License to do so, and |
|
186 |
all its terms and conditions for copying, distributing or modifying |
|
187 |
the Program or works based on it. |
|
188 |
|
|
189 |
6. Each time you redistribute the Program (or any work based on the |
|
190 |
Program), the recipient automatically receives a license from the |
|
191 |
original licensor to copy, distribute or modify the Program subject to |
|
192 |
these terms and conditions. You may not impose any further |
|
193 |
restrictions on the recipients' exercise of the rights granted herein. |
|
194 |
You are not responsible for enforcing compliance by third parties to |
|
195 |
this License. |
|
196 |
|
|
197 |
7. If, as a consequence of a court judgment or allegation of patent |
|
198 |
infringement or for any other reason (not limited to patent issues), |
|
199 |
conditions are imposed on you (whether by court order, agreement or |
|
200 |
otherwise) that contradict the conditions of this License, they do not |
|
201 |
excuse you from the conditions of this License. If you cannot |
|
202 |
distribute so as to satisfy simultaneously your obligations under this |
|
203 |
License and any other pertinent obligations, then as a consequence you |
|
204 |
may not distribute the Program at all. For example, if a patent |
|
205 |
license would not permit royalty-free redistribution of the Program by |
|
206 |
all those who receive copies directly or indirectly through you, then |
|
207 |
the only way you could satisfy both it and this License would be to |
|
208 |
refrain entirely from distribution of the Program. |
|
209 |
|
|
210 |
If any portion of this section is held invalid or unenforceable under |
|
211 |
any particular circumstance, the balance of the section is intended to |
|
212 |
apply and the section as a whole is intended to apply in other |
|
213 |
circumstances. |
|
214 |
|
|
215 |
It is not the purpose of this section to induce you to infringe any |
|
216 |
patents or other property right claims or to contest validity of any |
|
217 |
such claims; this section has the sole purpose of protecting the |
|
218 |
integrity of the free software distribution system, which is |
|
219 |
implemented by public license practices. Many people have made |
|
220 |
generous contributions to the wide range of software distributed |
|
221 |
through that system in reliance on consistent application of that |
|
222 |
system; it is up to the author/donor to decide if he or she is willing |
|
223 |
to distribute software through any other system and a licensee cannot |
|
224 |
impose that choice. |
|
225 |
|
|
226 |
This section is intended to make thoroughly clear what is believed to |
|
227 |
be a consequence of the rest of this License. |
|
228 |
|
|
229 |
8. If the distribution and/or use of the Program is restricted in |
|
230 |
certain countries either by patents or by copyrighted interfaces, the |
|
231 |
original copyright holder who places the Program under this License |
|
232 |
may add an explicit geographical distribution limitation excluding |
|
233 |
those countries, so that distribution is permitted only in or among |
|
234 |
countries not thus excluded. In such case, this License incorporates |
|
235 |
the limitation as if written in the body of this License. |
|
236 |
|
|
237 |
9. The Free Software Foundation may publish revised and/or new versions |
|
238 |
of the General Public License from time to time. Such new versions will |
|
239 |
be similar in spirit to the present version, but may differ in detail to |
|
240 |
address new problems or concerns. |
|
241 |
|
|
242 |
Each version is given a distinguishing version number. If the Program |
|
243 |
specifies a version number of this License which applies to it and "any |
|
244 |
later version", you have the option of following the terms and conditions |
|
245 |
either of that version or of any later version published by the Free |
|
246 |
Software Foundation. If the Program does not specify a version number of |
|
247 |
this License, you may choose any version ever published by the Free Software |
|
248 |
Foundation. |
|
249 |
|
|
250 |
10. If you wish to incorporate parts of the Program into other free |
|
251 |
programs whose distribution conditions are different, write to the author |
|
252 |
to ask for permission. For software which is copyrighted by the Free |
|
253 |
Software Foundation, write to the Free Software Foundation; we sometimes |
|
254 |
make exceptions for this. Our decision will be guided by the two goals |
|
255 |
of preserving the free status of all derivatives of our free software and |
|
256 |
of promoting the sharing and reuse of software generally. |
|
257 |
|
|
258 |
NO WARRANTY |
|
259 |
|
|
260 |
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY |
|
261 |
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN |
|
262 |
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES |
|
263 |
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED |
|
264 |
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
|
265 |
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS |
|
266 |
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE |
|
267 |
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, |
|
268 |
REPAIR OR CORRECTION. |
|
269 |
|
|
270 |
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
|
271 |
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR |
|
272 |
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, |
|
273 |
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING |
|
274 |
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED |
|
275 |
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY |
|
276 |
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER |
|
277 |
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE |
|
278 |
POSSIBILITY OF SUCH DAMAGES. |
trunk/wb/modules/show_menu2/README_DE | ||
---|---|---|
1 |
// $Id$ |
|
2 |
|
|
3 |
show_menu2, version 4.5 |
|
4 |
======================= |
|
5 |
Ist ein Code-Snippet f?r das CMS Website Baker. Es stellt einen kompletten Ersatz f?r die eingebaute Men?funtionalit?t zur Verf?gung. Alle f?r die Erzeugung des Men?s erforderlichen Daten werden durch eine einzige Datenbankabfrage erzeugt. Durch umfangreiche Anpassungsm?glichkeiten des erzeugten HTML-Code k?nnen alle m?glichen Men?arten (Listen, Breadcrumbs, Sitemaps, usw.) erzeugt werden. |
|
6 |
|
|
7 |
--- |
|
8 |
Deutsche ?bersetzung von BerndJM. Dies ist eine weitgehend direkte ?bersetzung des englischen Originals. Bei ?bersetzungs- oder Interpretationsfehlern, bitte eine Email an bjm@wwnw.de. |
|
9 |
--- |
|
10 |
|
|
11 |
INSTALLATION |
|
12 |
============ |
|
13 |
1. Die aktuelle Version von http://code.jellycan.com/show_menu2/ herunterladen. |
|
14 |
2. In das Admin-Backend der Website Baker Installation einlogen. |
|
15 |
3. Erweiterungen -> Module aufrufen. |
|
16 |
4. Wenn bereits eine fr?here Version von show_menu2 installiert ist, diese ?ber "Modul deinstallieren" ausw?hlen und deinstallieren. |
|
17 |
5. Im Abschnitt "Modul installieren" das im Schritt 1 heruntergeladene zip-File ausw?hlen und installieren. |
|
18 |
|
|
19 |
|
|
20 |
BENUTZUNG VON SHOW_MENU2 |
|
21 |
======================== |
|
22 |
Um show_menu2 zu benutzen muss das verwendete Template an den Stellen modifiziert werden, an denen das Men? erscheinen soll. Bitte beachten: Wenn alte Men?aufrufe ersetzt werden, m?ssen unbedingt auch die entsprechenden neuen Parameter verwendet werden die show_menu2 ben?tigt. |
|
23 |
|
|
24 |
In den meisten F?llen gen?gt bereits der Standardaufruf ohne weitere Parameter von show_menu2. In diesem Fall werden die Vorgabewerte verwendet, dies erzeugt ein Men? das die aktuelle Seite und die Unterseiten der aktuellen Seite anzeigt: |
|
25 |
|
|
26 |
show_menu2(); |
|
27 |
|
|
28 |
Bitte beachten: der Aufruf von show_menu2 ist PHP und muss normalerweise in PHP-Codezeichen eingeschlossen werden (ausser der Aufruf erfolgt bereits innerhalb von PHP Code): |
|
29 |
|
|
30 |
<?php show_menu2(); ?> |
|
31 |
|
|
32 |
Dieses Vorgabe Men? erzeugt bereits ein komplettes Men? auf Listenbasis mit etlichen Klassen, die eine leichte Formatierung mittels CSS erm?glichen. Es wird z.B. die Klasse "menu-current" zu dem <li> Tag des aktuellen Men?punktes hinzugef?gt, zus?tzlich erh?lt jeder Men?punkt der Unterpunkte enth?lt die Klasse "menu-expand". Dies erlaubt es sehr differenzierte CSS Regeln f?r die einzelnen Men?punkte aufzustellen. |
|
33 |
Zum Beispiel: |
|
34 |
|
|
35 |
li.menu-expand { font-weight: bold; } |
|
36 |
li.menu-current { background: red; } |
|
37 |
|
|
38 |
Im Abschnitt "HTML-Ausgabe" findet sich eine detaillierte Beschreibung welche Klassen welchem Element zugeordnet werden. Durch die Verwendung von verschiedenen Parametern bei dem show_menu2 Funktionsaufruf lassen sich auch recht umfangreiche und unterschiedliche Men?strukturen erzeugen. Um beispielsweise nur Men?punkte aus der obersten Ebene der Men?struktur darzustellen, k?nnte man folgenden Aufruf verwenden: |
|
39 |
|
|
40 |
show_menu2(0, SM2_ROOT, SM2_START); |
|
41 |
|
|
42 |
Oder um beispielsweise bis zu zwei Unterebenen der aktuellen Seite anzuzeigen: |
|
43 |
|
|
44 |
show_menu2(0, SM2_CURR+1, SM2_CURR+2); |
|
45 |
|
|
46 |
Es gibt jede Menge M?glichkeiten, um die unterschiedlichten Men?strukturen zu erzeugen, zahlreiche Beispiele dazu findet man auf der Demo-Website: http://code.jellycan.com/sm2test/ |
|
47 |
|
|
48 |
|
|
49 |
FUNKTION |
|
50 |
======== |
|
51 |
Der komplette Aufruf und die Vorgabe Parameterwerte f?r show_menu2 sind wie folgt: |
|
52 |
|
|
53 |
show_menu2( |
|
54 |
$aMenu = 0, |
|
55 |
$aStart = SM2_ROOT, |
|
56 |
$aMaxLevel = SM2_CURR+1, |
|
57 |
$aFlags = SM2_TRIM, |
|
58 |
$aItemOpen = '[li][a][menu_title]</a>', |
|
59 |
$aItemClose = '</li>', |
|
60 |
$aMenuOpen = '[ul]', |
|
61 |
$aMenuClose = '</ul>', |
|
62 |
$aTopItemOpen = false, |
|
63 |
$aTopMenuOpen = false |
|
64 |
) |
|
65 |
|
|
66 |
Im Abschnitt "Parameter" findet sich eine detaillierte Beschreibung jedes einzelnen Parameters. |
|
67 |
Ab $aItemOpen kann jedem Parameter der Wert false ?bergeben werden um den jeweiligen Vorgabewert zu erhalten. |
|
68 |
Dies kann beispielsweise verwendet werden um eine nummerierte Liste zu erzeugen, w?hrend f?r die einzelnen Men?punkte trotzdem die Vorgabewerte Verwendung finden: |
|
69 |
|
|
70 |
show_menu2(0, SM2_ROOT, SM2_ALL, SM2_ALL, false, false, '<ol>', '</ol>'); |
|
71 |
|
|
72 |
Bitte beachten: bis einschliessich $aFlags m?ssen alle Parameter explizit ?bergeben werden! |
|
73 |
|
|
74 |
|
|
75 |
HTML-AUSGABE |
|
76 |
============ |
|
77 |
Die HTML-Ausgabe h?ngt wesentlich davon ab, welche Parameter an die Funktion ?bergeben werden. Unabh?ngig davon werden nachfolgende Klassen grunds?tzlich f?r jedes Men? verwendet, wobei einzelne Men?punkte, wenn erforderlich, auch mehrere Klassen erhalten k?nnen. |
|
78 |
|
|
79 |
KLAssE ZUORDNUNG |
|
80 |
------------ ------------------------------------------------------- |
|
81 |
menu-top Nur der erste Men?punkt |
|
82 |
menu-parent Jeder Hauptmen?punkt. |
|
83 |
menu-current Nur der Men?punkt der aktuellen Seite. |
|
84 |
menu-sibling Alle "Geschwister" der aktuellen Seite. |
|
85 |
menu-child Jedes Untermen? der aktuellen Seite. |
|
86 |
menu-expand Jedes Men? das Untermen?s hat. |
|
87 |
menu-first Der erste Punkt eines jeden Men?s oder Untermen?s. |
|
88 |
menu-last Der letzte Punkt eines jeden Men?s oder Untermen?s. |
|
89 |
|
|
90 |
Folgende Klassen werden nur hinzugef?gt, wenn das SM2_NUMCLAss flag gesetzt ist: |
|
91 |
|
|
92 |
menu-N Jeder Men?punkt, wobei das N f?r die ABSOLUTE Men?tiefe, |
|
93 |
beginnend bei 0, des jeweiligen Men?punktes steht. |
|
94 |
Die oberste Ebene ist also immer menu-0, die n?chste |
|
95 |
Ebene menu-1 usw. |
|
96 |
menu-child-N Jedes Untermen? der aktuellen Seiten, wobei das N f?r die |
|
97 |
RELATIVE Tiefe des Untermen?s, beginnend bei 0, steht. |
|
98 |
|
|
99 |
Beispiel einer HTML-Ausgabe: |
|
100 |
|
|
101 |
<ul class="menu-top menu-0"> |
|
102 |
<li class="menu-0 menu-first"> ... </li> |
|
103 |
<li class="menu-0 menu-expand menu-parent"> ... |
|
104 |
<ul class="menu-1"> |
|
105 |
<li class="menu-1 menu-expand menu-first"> ... |
|
106 |
<ul class="menu-2"> |
|
107 |
<li class="menu-2 menu-first"> ... |
|
108 |
<li class="menu-2 menu-last"> ... |
|
109 |
</ul> |
|
110 |
</li> |
|
111 |
<li class="menu-1 menu-expand menu-parent"> ... |
|
112 |
<ul class="menu-2"> |
|
113 |
<li class="menu-2 menu-expand menu-current menu-first"> ... ** CURRENT PAGE ** |
|
114 |
<ul class="menu-3"> |
|
115 |
<li class="menu-3 menu-child menu-child-0 menu-first"> ... |
|
116 |
<ul class="menu-4"> |
|
117 |
<li class="menu-4 menu-child menu-child-1 menu-first"> ... </li> |
|
118 |
<li class="menu-4 menu-child menu-child-1 menu-last"> ... </li> |
|
119 |
</ul> |
|
120 |
</li> |
|
121 |
<li class="menu-3 menu-child menu-child-0 menu-last"> ... </li> |
|
122 |
</ul> |
|
123 |
</li> |
|
124 |
<li class="menu-2 menu-sibling menu-last"> ... </li> |
|
125 |
</ul> |
|
126 |
</li> |
|
127 |
<li class="menu-1"> ... </li> |
|
128 |
<li class="menu-1 menu-expand menu-last"> ... |
|
129 |
<ul class="menu-2"> |
|
130 |
<li class="menu-2 menu-first menu-last"> ... </li> |
|
131 |
</ul> |
|
132 |
</li> |
|
133 |
</ul> |
|
134 |
</li> |
|
135 |
<li class="menu-0 menu-last"> ... </li> |
|
136 |
</ul> |
|
137 |
|
|
138 |
|
|
139 |
PARAMETER |
|
140 |
========= |
|
141 |
$aMenu |
|
142 |
Nummer des Men?s. Dies ist n?tzlich um mehrere Men?s auf einer Seite zu verwenden. |
|
143 |
Men? Nummer 0 ist das Vorgabemen? der aktuellen Seite, SM2_ALLMENU gibt alle |
|
144 |
im System verwendeten Men?s zur?ck. |
|
145 |
|
|
146 |
$aStart |
|
147 |
Gibt an, ab welcher Ebene die Erzeugung des Men?s beginnen soll. In den meisten |
|
148 |
F?llen wird dies die oberste Ebene des anzuzeigenden Men?s sein. Es kann einer |
|
149 |
der folgenden Werte verwendet werden: |
|
150 |
|
|
151 |
SM2_ROOT+N Beginnt N Ebenen unterhalb der obersten Ebene, z.B.: |
|
152 |
SM2_ROOT Beginnt auf der obersten Ebene |
|
153 |
SM2_ROOT+1 Beginnt eine Ebene unterhalbe der obersten Ebene |
|
154 |
SM2_ROOT+2 Beginnt zwei Ebenen unterhalbe der obersten Ebene |
|
155 |
|
|
156 |
SM2_CURR+N Beginnt N Ebenen unterhalb der aktuellen Ebene, z.B.: |
|
157 |
SM2_CURR Beginnt auf der aktuellen Ebene. Alle Geschwister |
|
158 |
der aktuellen Ebene |
|
159 |
SM2_CURR+1 Beginnt eine Ebene unterhalb der aktuellen Ebene |
|
160 |
mit allen Unterebenen |
|
161 |
|
|
162 |
page_id Verwendet die Seite mit der angegebenen page id als Elternelement. |
|
163 |
Alle Untermen?s dieser Seite werden angezeigt. (Die page id kann |
|
164 |
ermittelt werden, wenn man die Seite im Admin-Backend editiert, |
|
165 |
sie steht dann in der Adresszeile des Browsers: |
|
166 |
http://SITE/admin/pages/modify.php?page_id=35 |
|
167 |
|
|
168 |
$aMaxLevel |
|
169 |
Die maximale Anzahl der Ebenen die angezeigt werden, die Anzeige |
|
170 |
beginnt ab der in $aStart festgelegten Ebene bis hin zu der hier |
|
171 |
festgelegten Ebene. |
|
172 |
|
|
173 |
SM2_ALL Keine Beschr?nkung, alle Ebenen werden angezeigt |
|
174 |
|
|
175 |
SM2_CURR+N Zeigt immer die aktuelle Seite + N Ebenen. |
|
176 |
SM2_CURR Aktuelle Ebene (keine Unterebene) |
|
177 |
SM2_CURR+3 Alle ?bergeordneten + aktuelle + 3 Unterebenen |
|
178 |
|
|
179 |
SM2_START+N Beginnt immer auf der Startebene + N Ebenen. |
|
180 |
Die Ebenen werden unabh?ngig davon angezeigt |
|
181 |
auf welcher Ebene sich die aktuelle Seite befindet. |
|
182 |
SM2_START Eine einzelne Ebene ab der Startebene |
|
183 |
SM2_START+1 Startebene + eine Ebene darunter |
|
184 |
|
|
185 |
SM2_MAX+N Zeigt h?chstens N Ebenen ab der Startebene. |
|
186 |
Ebenen unterhalb der aktuellen Ebene werden nicht angezeigt. |
|
187 |
SM2_MAX Starting level only (same as SM2_START) |
|
188 |
SM2_MAX+1 Maximum of starting level and 1 level. |
|
189 |
|
|
190 |
$aFlags |
|
191 |
Spezielle Flags f?r verschiedene Men?generierungs Optionen. Sie k?nnen mittels |
|
192 |
einer ODER Verkn?pfung (|) miteinander kombiniert werden. Um beispielsweise |
|
193 |
sowohl TRIM als auch PRETTY zu definieren, verwendet man: SM2_TRIM|SM2_PRETTY. |
|
194 |
|
|
195 |
GROUP 1 |
|
196 |
------- |
|
197 |
Aus dieser Gruppe muss stets genau ein Flag angegeben werden. Diese Flags |
|
198 |
bestimmen auf welche Weise die Geschwisterelemente im Men?baum in der |
|
199 |
Ausgabe unterdr?ckt werden. |
|
200 |
|
|
201 |
SM2_ALL Zeigt alle Zweige des Men?baums |
|
202 |
A-1 -> B-1 |
|
203 |
-> B-2 -> C-1 |
|
204 |
-> C-2 (CURRENT) |
|
205 |
-> D-1 |
|
206 |
-> D-2 |
|
207 |
-> C-3 |
|
208 |
A-2 -> B-3 |
|
209 |
-> B-4 |
|
210 |
|
|
211 |
SM2_TRIM Zeigt alle Geschwistermen?s der Seite im aktuellen Pfad. |
|
212 |
Alle Untermen?s von Elemnten die sich nicht im Pfad befinden |
|
213 |
werden entfernt. |
|
214 |
A-1 -> B-1 |
|
215 |
-> B-2 -> C-1 |
|
216 |
-> C-2 (CURRENT) |
|
217 |
-> D-1 |
|
218 |
-> D-2 |
|
219 |
-> C-3 |
|
220 |
A-2 |
|
221 |
|
|
222 |
SM2_CRUMB Zeigt den Breadcrumb Pfad des Men?s an, also den aktuellen |
|
223 |
Men?punkt sowie alle Men?punkte die dorthin f?hren. |
|
224 |
A-1 -> B-2 -> C-2 (CURRENT) |
|
225 |
|
|
226 |
SM2_SIBLING Wie SM2_TRIM, es werden aber nur Geschwistermen?s der aktuellen |
|
227 |
Seite angezeigt. Alle anderen Punkte werden unterdr?ckt. |
|
228 |
A-1 -> B-2 -> C-1 |
|
229 |
-> C-2 (CURRENT) |
|
230 |
-> D-1 |
|
231 |
-> D-2 |
|
232 |
-> C-3 |
|
233 |
|
|
234 |
GROUP 2 |
|
235 |
------- |
|
236 |
Diese Flags sind optional, sie k?nnen in beliebiger Anzahl kombiniert werden. |
|
237 |
|
|
238 |
SM2_NUMCLAss F?gt die nummerierten Men?klassen "menu-N" und |
|
239 |
"menu-child-N hinzu. |
|
240 |
|
|
241 |
SM2_ALLINFO L?dt alle Felder aus der Seitentabelle der Datenbank. |
|
242 |
Dies verursacht einen ziemlich hohen Speicherverbauch und sollte |
|
243 |
deshalb nur mit Bedacht verwendet werden. |
|
244 |
Dadurch werden z.B. die Keywords, die Seitenbeschreibung sowie |
|
245 |
all die anderen Informationen verf?gbar, die normalerweise nicht |
|
246 |
geladen werden. |
|
247 |
Bitte beachten: dieses Flag muss beim ERSTEN Aufruf von schow_menu2 |
|
248 |
f?r die jeweilige Men? ID verwendet werden, oder in Verbindung |
|
249 |
mit SM2_NOCACHE, sonst zeigt es keine Wirkung. |
|
250 |
|
|
251 |
SM2_NOCACHE Die aus der Datenbank gelesenen Daten werden bei erneutem Aufruf von |
|
252 |
show_menu2 nicht wiederverwendet sondern erneut aus der Datenbank gelesen. |
|
253 |
|
|
254 |
SM2_PRETTY Bringt die HTML-Ausgabe des Men?s mittels Leerzeichen und |
|
255 |
Zeilenumbr?chen in eine gut lesbare Form. Dies ist besonders n?tzlich |
|
256 |
beim Debuggen der Men?ausgabe. |
|
257 |
|
|
258 |
SM2_BUFFER Gibt den HTML-Code nicht direkt aus, sondern speichert ihn intern |
|
259 |
zwischen und gibt ihn al kompletten String aus. |
|
260 |
|
|
261 |
SM2_CURRTREE Schliesst alle anderen Toplevelmen?s von der Betrachtung aus. |
|
262 |
Es werden nur Men?punkte des aktuellen Men?zweiges dargestellt. |
|
263 |
Dieses Flag kann bei Bedarf mit jedem flag aus der Gruppe 1 |
|
264 |
kombiniert werden. |
|
265 |
|
|
266 |
SM2_ESCAPE Wendet htmlspecialchars auf den Men?string an. |
|
267 |
Dies kann bei ?lteren Websitebaker Installationen erforderlich |
|
268 |
sein um eine valide HTML Ausgabe zu erzeugen. |
|
269 |
|
|
270 |
SM2_NOESCAPE Dies ist das Standarverhalten und existiert nur aus Gr?nden der |
|
271 |
Abw?rtskompatibilt?t. |
|
272 |
|
|
273 |
$aItemOpen |
|
274 |
Dies legt den Formatstring fest, mit dem jeder einzelne Men?eintrag begonnen |
|
275 |
wird. F?r den allerersten Men?eintrag kann mittels $aTopItemOpen ein anderer |
|
276 |
Formatstring definiert werden. |
|
277 |
Wenn dieser Parameter auf false gesetzt wird, wird der Vorgabe Formatstring |
|
278 |
'[li][a][menu_title]</a>' verwendet um die Kompatibilt?t zur Website Baker |
|
279 |
Standardfunktion show_menu() zu gew?hrleiten. |
|
280 |
Da die Formatierung mittels CSS-Klassen oftmals einfacher ist, wenn sie auf den |
|
281 |
<a> Tag angewendet werden, empfiehlt es sich hier folgenden Formatstring zu |
|
282 |
verwenden: '<li>[ac][menu_title]</a>'. |
|
283 |
|
|
284 |
Dieser Parameter kann auch als Instanz eine Formatierungklasse f?r das Men? |
|
285 |
verwendet werden. Im Abschnitt "Formatter" findet sich dazu eine detailierte |
|
286 |
Beschreibung. Wenn hier ein Formatter angegeben wird, werden alle Argumente |
|
287 |
nach $aItenOpen ignoriert. |
|
288 |
|
|
289 |
$aItemClose |
|
290 |
Dieser String schliesst jeden Men?punkt ab. |
|
291 |
Bitte beachten: dies ist kein Formatstring und es werden keine Schl?sselworte |
|
292 |
ersetzt! |
|
293 |
Wenn dieser Parameter auf false gesetzt ist, wird die Vorgabe '</li>' verwendet. |
|
294 |
|
|
295 |
$aMenuOpen |
|
296 |
Mit diesem Formatstring wird eine Liste von Men?eintr?gen ge?ffnet. F?r das erste |
|
297 |
Men? kann mittels $aTopMenuOpen ein davon abweichender Formatstring definiert |
|
298 |
werden. |
|
299 |
Wenn dieser Parameter auf false gesetzt ist wird der Vorgabewert '[ul]' |
|
300 |
verwendet. |
|
301 |
|
|
302 |
$aMenuClose |
|
303 |
Dieser String schliesst jedes Men? ab. |
|
304 |
Bitte beachten: dies ist kein Formatstring und es werden keine Schl?sselworte |
|
305 |
ersetzt! |
|
306 |
Wenn dieser Parameter auf false gesetzt ist, wird die Vorgabe '</ul>' verwendet. |
|
307 |
|
|
308 |
$aTopItemOpen |
|
309 |
Der Formatstring f?r den allerersten Men?punkt. Wenn dieser Parameter auf false |
|
310 |
gesetzt wird, wird der selbe Formatstring wie bei $aItemOpen verwendet. |
|
311 |
|
|
312 |
$aTopMenuOpen |
|
313 |
Der Formatstring f?r das erste Men?. Wenn dieser Parameter auf false |
|
314 |
gesetzt wird, wird der selbe Formatstring wie bei $aMenuOpen verwendet. |
|
315 |
|
|
316 |
|
|
317 |
FORMAT STRINGS |
|
318 |
============== |
|
319 |
Die folgenden Tags k?nnen in den Formatstrings f?r $aItemOpen und $aMenuOpen |
|
320 |
verwendet werden und werden durch den entsprechenden Text ersetzt. |
|
321 |
|
|
322 |
[a] <a> tag ohne Klasse: '<a href="[url]" target="[target]">' |
|
323 |
[ac] <a> tag mit Klasse: '<a href="[url]" target="[target]" class="[class]">' |
|
324 |
[li] <li> tag mit Klasse: '<li class="[class]">' |
|
325 |
[ul] <ul> tag mit Klasse: '<ul class="[class]">' |
|
326 |
[class] Liste der Klassen f?r diese Seite |
|
327 |
[menu_title] Text des Men?titel (HTML entity escaped ausser das SM2_NOESCAPE Flag ist gesetzt) |
|
328 |
[page_title] text des Seitentitel (HTML entity escaped ausser das SM2_NOESCAPE Flag ist gesetzt) |
|
329 |
[url] die URL der Seiten f?r den <a> tag |
|
330 |
[target] das Seitenziel f?r den <a> tag |
|
331 |
[page_id] die Page ID des aktuellen Men?punktes |
|
332 |
[parent] die Page ID des ?bergeorneten Men?punktes |
|
333 |
[level] die Seitenebene, dies ist die gleiche Zahl die im "menu-N" CSS tag verwendet wird. |
|
334 |
[sib] Anzahl der Geschwister des aktuellen Men?punktes |
|
335 |
[sibCount] Anzahl aller Geschwister in diesem Men? |
|
336 |
[if] Bedingung (Details hierzu im Abschnitt "Bedingte Formatierung') |
|
337 |
|
|
338 |
Folgende tags sind nur verf?gbar, wenn das SM2_ALLINFO flag gesetzt ist. |
|
339 |
|
|
340 |
[description] Seitenbeschreibung |
|
341 |
[keywords] Schl?sselworte der Seite |
|
342 |
|
|
343 |
|
|
344 |
BEDINGTE FORMATIERUNG |
|
345 |
===================== |
|
346 |
Die Anweisung f?r eine bedingte Formatierung kann eine der folgenden Formen haben: |
|
347 |
|
|
348 |
[if(A){B}] |
|
349 |
[if(A){B}else{C}] |
|
350 |
|
|
351 |
A Die Bedingung. Details dazu, siehe unten. |
|
352 |
|
|
353 |
B Der Ausdruck der verwendet wird, wenn die Bedingung erf?llt ist. |
|
354 |
Dies kann ein beliebiger String sein, der jedoch nicht das Zeichen '}' |
|
355 |
enthalten darf. Er kann jeden beliebigen Formatstring aus dem Abschnitt |
|
356 |
'Format Strings' enthalten, jedoch keinen weiteren Bedingungstest (da das |
|
357 |
Zeichen '}' nicht erlaubt ist). |
|
358 |
|
|
359 |
C Der Ausdruck der verwendet wird, wenn die Bedingung nicht erf?llt ist. |
|
360 |
Dies kann ein beliebiger String sein, der jedoch nicht das zeichen '}' |
|
361 |
enthalten darf. Er kann jeden beliebigen Formatstring aus dem Abschnitt |
|
362 |
'Format Strings' enthalten, jedoch keinen weiteren Bedingungstest (da das |
|
363 |
Zeichen '}' nicht erlaubt ist). |
|
364 |
|
|
365 |
Die Bedingung ist eine Kombination von einem oder mehreren boolschen Vergleichen. |
|
366 |
Wenn mehr als ein Vergleich erforderlich ist, so muss dieser mit den anderen Vergleichen |
|
367 |
mittels || (boolsches oder - OR) oder && (boolsches und - AND) vern?pft werden. |
|
368 |
|
|
369 |
Ein einzelner Vergleich besteht aus dem linken Operanden, dem Operator und dem rechten Operanden. |
|
370 |
z.B. X == Y - hierbei ist X der linke Operand, == der Operator und Y der rechte Operand. |
|
371 |
|
|
372 |
Linker Operand. Muss eines der folgende Schl?sselworte sein: |
|
373 |
class ?berpr?fung ob diese Klasse existiert. Es sind nur die |
|
374 |
"==" and "!=" Operatoren erlaubt. In diesem Fall haben die Operatoren |
|
375 |
die Bedeutung von "enth?lt" bzw. "enth?lt nicht" an Stelle von |
|
376 |
"ist gleich" bzw. "ist nicht gleich" |
|
377 |
level ?berpr?fung der Seitenebene. |
|
378 |
sib ?berpr?fung der Geschwisteranzahl der aktuellen Seite. |
|
379 |
sibCount ?berpr?fung der Geamtanzahl der Geschwister im aktuellen Men?. |
|
380 |
id ?berpr?fung der page id. |
|
381 |
|
|
382 |
Operator. Muss einer der folgenden sein: |
|
383 |
< Kleiner als |
|
384 |
<= Kleiner oder gleich als |
|
385 |
== Gleich |
|
386 |
!= Nicht gleich |
|
387 |
>= Gr?ssr oder gleich als |
|
388 |
> gr?sser als |
|
389 |
|
|
390 |
Rechter Operand. Die Art dieses Operanden h?ngt von dem, f?r den linken Operanden |
|
391 |
verwendeten Schl?sselwort ab. |
|
392 |
class einer der "menu-*" Klassennamen wie sie im Abschnitt "Ausgabe" |
|
393 |
spezifiziert sind. |
|
394 |
level ?berpr?fung der Seitenebene gegen folgende Werte: |
|
395 |
<number> die absolute Seitenebene |
|
396 |
root die oberste Seitenebene |
|
397 |
granny die Seitenebene ?ber der ?bergeordneten Seitenebene |
|
398 |
parent die ?bergeordnete Seitenebene |
|
399 |
current die aktuelle Seitenebene |
|
400 |
child die untergeornete Seitenebene |
|
401 |
id ?berpr?fung der page id gegen folgende Werte: |
|
402 |
<number> die absolute page id |
|
403 |
parent die ?bergeordnete page id |
|
404 |
current die aktuelle page id |
|
405 |
sib Eine positive Integerzahl, oder "sibCount" um die Anzahl der |
|
406 |
Geschwister in diesem Men? zu ?berpr?fen |
|
407 |
sibCount Eine positive Integerzahl |
|
408 |
|
|
409 |
Folgende Beispiele ergeben "wahr" und der Ausdruck {exp} wird ausgef?hrt, wenn zutrifft: |
|
410 |
|
|
411 |
[if(class==menu-expand){exp}] hat ein Untermen? |
|
412 |
[if(class==menu-first){exp}] ist der erste Eintrag in einem Men? |
|
413 |
[if(class!=menu-first){exp}] ist NICHT der erste Eintrag in einem Men? |
|
414 |
[if(class==menu-last){exp}] ist der letzte Eintrag in einem Men? |
|
415 |
[if(level==0){exp}] befindet sich auf der obersten Ebene |
|
416 |
[if(level>0){exp}] befindet sich NICHT auf der obersten Ebene |
|
417 |
[if(sib==2){exp}] ist der zweite Eintrag in einem Men? |
|
418 |
[if(sibCount>1){exp}] ist in einem Men? mit mehr als einem Eintrag |
|
419 |
[if(sibCount!=2){exp}] ist in einem Men?, das nicht genau 2 Eintr?ge hat |
|
420 |
[if(level>parent){exp}] ist ine eine Geschwistermen? oder dem Untermen? eines Geschwistermen?s |
|
421 |
[if(id==parent){exp}] ist der ?bergeordnete Punkt der aktuellen id |
|
422 |
|
|
423 |
Wenn eine sonst-Klausel (else) hinzugef?gt wird, so wird diese in allen anderen F?llen ausgef?hrt. |
|
424 |
Zum Beispiel wird "foo" immer dann ausgef?hrt, wenn die if ?berpr?fung falsch ergibt, also: |
|
425 |
|
|
426 |
[if(sib==2){exp}else{foo}] ist NICHT der zweite Eintrag im Men? |
|
427 |
[if(sibCount>2){exp}else{foo}] ist NICHT in einem Men? mit mehr als zwei Eintr?gen |
|
428 |
|
|
429 |
Bei mehrfach Vergleichen wird der Ausdruck "exp" nur ausgef?hrt, wenn: |
|
430 |
|
|
431 |
[if(sib == 1 || sib > 3){exp}] ist der erste Eintrag ODER ist der vierte oder h?here Eintrag im Men? |
|
432 |
|
|
433 |
[if(id == current && class == menu-expand){exp} ist der aktuelle Eintrag UND hat Untermen?s |
|
434 |
|
|
435 |
Bitte beachten: |
|
436 |
Alle ?berpr?fungen werden in der Reihenfolge ausgef?hrt, in der sie notiert sind, denn: |
|
437 |
* es findet keine ?berpr?fung auf evtl. Schleifen statt (alle ?berpr?fungen werden immer ausgef?hrt) |
|
438 |
* ?berpr?fungen werden nicht gruppiert (eine Klammerung von ?berpr?fungen wird nicht unterst?tzt) |
|
439 |
* sowohl || als auch && haben die gleiche Wertigkeit |
|
440 |
|
|
441 |
FORMATTER |
|
442 |
========= |
|
443 |
Achtung: dies ist ein fortgeschrittenes und ?usserst selten ben?tigtes Feature! |
|
444 |
|
|
445 |
Mit umfangreichen Kenntnissen in der PHP Programmierung ist es m?glich den vordefinierten |
|
446 |
Formatierer von show_menu2 mit einem eigenen zu ersetzen. |
|
447 |
In der include.php von show_menu2 sieht man wie der Formatierer geschreiben werden muss. |
|
448 |
Die API die verwendet werden muss sieht wie folgt aus: |
|
449 |
|
|
450 |
(Anmerkung des ?bersetzers: Kommentare nicht ?bersetzt, wer sich so weit vorwagt, sollte |
|
451 |
damit keine Probleme haben ;-) |
|
452 |
|
|
453 |
class SM2_Formatter |
|
454 |
{ |
|
455 |
// called once before any menu is processed to allow object initialization |
|
456 |
function initialize() { } |
|
457 |
|
|
458 |
// called to open the menu list |
|
459 |
function startList($aPage, $aUrl) { } |
|
460 |
|
|
461 |
// called to open the menu item |
|
462 |
function startItem($aPage, $aUrl, $aCurrSib, $aSibCount) { } |
|
463 |
|
|
464 |
// called to close the menu item |
|
465 |
function finishItem() { } |
|
466 |
|
|
467 |
// called to close the menu list |
|
468 |
function finishList() { } |
|
469 |
|
|
470 |
// called once after all menu has been processed to allow object finalization |
|
471 |
function finalize() { } |
|
472 |
|
|
473 |
// called once after finalize() if the SM2_NOOUTPUT flag is used |
|
474 |
function getOutput() { } |
|
475 |
}; |
|
476 |
|
|
477 |
|
|
478 |
|
|
0 | 479 |
trunk/wb/modules/show_menu2/languages/index.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
// $Id$ |
|
4 |
|
|
5 |
/* |
|
6 |
show_menu2: show_menu replacement for Website Baker |
|
7 |
Copyright (C) 2006-2008, Brodie Thiesfield |
|
8 |
|
|
9 |
This program is free software; you can redistribute it and/or |
|
10 |
modify it under the terms of the GNU General Public License |
|
11 |
as published by the Free Software Foundation; either version 2 |
|
12 |
of the License, or (at your option) any later version. |
|
13 |
|
|
14 |
This program is distributed in the hope that it will be useful, |
|
15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17 |
GNU General Public License for more details. |
|
18 |
|
|
19 |
You should have received a copy of the GNU General Public License |
|
20 |
along with this program; if not, write to the Free Software |
|
21 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
22 |
02110-1301, USA. |
|
23 |
*/ |
|
24 |
|
|
25 |
header('Location: ../index.php'); |
|
26 |
|
|
27 |
?> |
|
0 | 28 |
trunk/wb/modules/show_menu2/languages/DE.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
// $Id$ |
|
4 |
|
|
5 |
/* |
|
6 |
show_menu2: show_menu replacement for Website Baker |
|
7 |
Copyright (C) 2006-2008, Brodie Thiesfield |
|
8 |
|
|
9 |
This program is free software; you can redistribute it and/or |
|
10 |
modify it under the terms of the GNU General Public License |
|
11 |
as published by the Free Software Foundation; either version 2 |
|
12 |
of the License, or (at your option) any later version. |
|
13 |
|
|
14 |
This program is distributed in the hope that it will be useful, |
|
15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17 |
GNU General Public License for more details. |
|
18 |
|
|
19 |
You should have received a copy of the GNU General Public License |
|
20 |
along with this program; if not, write to the Free Software |
|
21 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
22 |
02110-1301, USA. |
|
23 |
*/ |
|
24 |
|
|
25 |
// Deutsche Modulbeschreibung |
|
26 |
$module_description = 'Dieses Modul integriert die erweiterte Menüfunktion <code>show_menu2()</code> in Website Baker. Detailierte Informationen gibt es auf <a href="http://code.jellycan.com/show_menu2/" target="_blank">http://code.jellycan.com/show_menu2/</a> oder in der <a href="{WB_URL}/modules/show_menu2/README_DE" target="_blank">README</a> Datei.'; |
|
27 |
|
|
28 |
?> |
|
0 | 29 |
trunk/wb/modules/show_menu2/include.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
// $Id$ |
|
4 |
|
|
5 |
/* |
|
6 |
show_menu2: show_menu replacement for Website Baker |
|
7 |
Copyright (C) 2006-2008, Brodie Thiesfield |
|
8 |
|
|
9 |
This program is free software; you can redistribute it and/or |
|
10 |
modify it under the terms of the GNU General Public License |
|
11 |
as published by the Free Software Foundation; either version 2 |
|
12 |
of the License, or (at your option) any later version. |
|
13 |
|
|
14 |
This program is distributed in the hope that it will be useful, |
|
15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17 |
GNU General Public License for more details. |
|
18 |
|
|
19 |
You should have received a copy of the GNU General Public License |
|
20 |
along with this program; if not, write to the Free Software |
|
21 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
22 |
02110-1301, USA. |
|
23 |
|
|
24 |
*********************************************** |
|
25 |
** Version 4.5: see README for documentation ** |
|
26 |
*********************************************** |
|
27 |
*/ |
|
28 |
|
|
29 |
define('SM2_ROOT', -1000); |
|
30 |
define('SM2_CURR', -2000); |
|
31 |
define('SM2_ALLMENU', -1); |
|
32 |
define('SM2_START', 1000); |
|
33 |
define('SM2_MAX', 2000); |
|
34 |
define('SM2_ALL', 0x0001); // bit 0 (group 1) (Note: also used for max level!) |
|
35 |
define('SM2_TRIM', 0x0002); // bit 1 (group 1) |
|
36 |
define('SM2_CRUMB', 0x0004); // bit 2 (group 1) |
|
37 |
define('SM2_SIBLING', 0x0008); // bit 3 (group 1) |
|
38 |
define('SM2_NUMCLASS', 0x0010); // bit 4 |
|
39 |
define('SM2_ALLINFO', 0x0020); // bit 5 |
|
40 |
define('SM2_NOCACHE', 0x0040); // bit 6 |
|
41 |
define('SM2_PRETTY', 0x0080); // bit 7 |
|
42 |
define('SM2_ESCAPE', 0x0100); // bit 8 |
|
43 |
define('SM2_NOESCAPE', 0); // NOOP, unnecessary with WB 2.6.7+ |
|
44 |
define('SM2_BUFFER', 0x0200); // bit 9 |
|
45 |
define('SM2_CURRTREE', 0x0400); // bit 10 |
|
46 |
|
|
47 |
define('_SM2_GROUP_1', 0x000F); // exactly one flag from group 1 is required |
|
48 |
|
|
49 |
|
|
50 |
// Implement support for page_menu and show_menu using show_menu2. If you remove |
|
51 |
// the comments characters from the beginning of the following include, all menu |
|
52 |
// functions in Website Baker will be implemented using show_menu2. While it is |
|
53 |
// commented out, the original WB functions will be used. |
|
54 |
//include('legacy.php'); |
|
55 |
|
|
56 |
// This class is the default menu formatter for sm2. If desired, you can |
|
57 |
// create your own formatter class and pass the object into show_menu2 |
|
58 |
// as $aItemFormat. |
|
59 |
define('SM2_CONDITIONAL','if\s*\(([^\)]+)\)\s*{([^}]*)}\s*(?:else\s*{([^}]*)}\s*)?'); |
|
60 |
define('SM2_COND_TERM','\s*(\w+)\s*(<|<=|==|=|=>|>|!=)\s*([\w\-]+)\s*'); |
|
61 |
class SM2_Formatter |
|
62 |
{ |
|
63 |
var $output; |
|
64 |
var $flags; |
|
65 |
var $itemOpen; |
|
66 |
var $itemClose; |
|
67 |
var $menuOpen; |
|
68 |
var $menuClose; |
|
69 |
var $topItemOpen; |
|
70 |
var $topMenuOpen; |
|
71 |
|
|
72 |
var $isFirst; |
|
73 |
var $page; |
|
74 |
var $url; |
|
75 |
var $currSib; |
|
76 |
var $sibCount; |
|
77 |
var $currClass; |
|
78 |
var $prettyLevel; |
|
79 |
|
|
80 |
// output the data |
|
81 |
function output($aString) { |
|
82 |
if ($this->flags & SM2_BUFFER) { |
|
83 |
$this->output .= $aString; |
|
84 |
} |
|
85 |
else { |
|
86 |
echo $aString; |
|
87 |
} |
|
88 |
} |
|
89 |
|
|
90 |
// set the default values for all of our formatting items |
|
91 |
function set($aFlags, $aItemOpen, $aItemClose, $aMenuOpen, $aMenuClose, $aTopItemOpen, $aTopMenuOpen) { |
|
92 |
$this->flags = $aFlags; |
|
93 |
$this->itemOpen = is_string($aItemOpen) ? $aItemOpen : '[li][a][menu_title]</a>'; |
|
94 |
$this->itemClose = is_string($aItemClose) ? $aItemClose : '</li>'; |
|
95 |
$this->menuOpen = is_string($aMenuOpen) ? $aMenuOpen : '[ul]'; |
|
96 |
$this->menuClose = is_string($aMenuClose) ? $aMenuClose : '</ul>'; |
|
97 |
$this->topItemOpen = is_string($aTopItemOpen) ? $aTopItemOpen : $this->itemOpen; |
|
98 |
$this->topMenuOpen = is_string($aTopMenuOpen) ? $aTopMenuOpen : $this->menuOpen; |
|
99 |
} |
|
100 |
|
|
101 |
// initialize the state of the formatter before anything is output |
|
102 |
function initialize() { |
|
103 |
$this->output = ''; |
|
104 |
$this->prettyLevel = 0; |
|
105 |
if ($this->flags & SM2_PRETTY) { |
|
106 |
$this->output("\n<!-- show_menu2 -->"); |
|
107 |
} |
|
108 |
} |
|
109 |
|
|
110 |
// start a menu |
|
111 |
function startList(&$aPage, &$aUrl) { |
|
112 |
$currClass = ''; |
|
113 |
$currItem = $this->menuOpen; |
|
114 |
|
|
115 |
// use the top level menu open if this is the first menu |
|
116 |
if ($this->topMenuOpen) { |
|
117 |
$currItem = $this->topMenuOpen; |
|
118 |
$currClass .= ' menu-top'; |
|
119 |
$this->topMenuOpen = false; |
|
120 |
} |
|
121 |
|
|
122 |
// add the numbered menu class only if requested |
|
123 |
if (($this->flags & SM2_NUMCLASS) == SM2_NUMCLASS) { |
|
124 |
$currClass .= ' menu-'.$aPage['level']; |
|
125 |
} |
|
126 |
|
|
127 |
$this->prettyLevel += 1; |
|
128 |
|
|
129 |
// replace all keywords in the output |
|
130 |
if ($this->flags & SM2_PRETTY) { |
|
131 |
$this->output("\n".str_repeat(' ',$this->prettyLevel). |
|
132 |
$this->format($aPage, $aUrl, $currItem, $currClass)); |
|
133 |
} |
|
134 |
else { |
|
135 |
$this->output($this->format($aPage, $aUrl, $currItem, $currClass)); |
|
136 |
} |
|
137 |
|
|
138 |
$this->prettyLevel += 3; |
|
139 |
} |
|
140 |
|
|
141 |
// start an item within the menu |
|
142 |
function startItem(&$aPage, &$aUrl, $aCurrSib, $aSibCount) { |
|
143 |
// generate our class list |
|
144 |
$currClass = ''; |
|
145 |
if (($this->flags & SM2_NUMCLASS) == SM2_NUMCLASS) { |
|
146 |
$currClass .= ' menu-'.$aPage['level']; |
|
147 |
} |
|
148 |
if (array_key_exists('sm2_has_child', $aPage)) { |
|
149 |
// not set if false, so existence = true |
|
150 |
$currClass .= ' menu-expand'; |
|
151 |
} |
|
152 |
if ($aPage['page_id'] == PAGE_ID) { |
|
153 |
$currClass .= ' menu-current'; |
|
154 |
} |
|
155 |
elseif (array_key_exists('sm2_is_parent', $aPage)) { |
|
156 |
// not set if false, so existence = true |
|
157 |
$currClass .= ' menu-parent'; |
|
158 |
} |
|
159 |
elseif (array_key_exists('sm2_is_sibling', $aPage)) { |
|
160 |
// not set if false, so existence = true |
|
161 |
$currClass .= ' menu-sibling'; |
|
162 |
} |
|
163 |
elseif (array_key_exists('sm2_child_level',$aPage)) { |
|
164 |
// not set if not a child |
|
165 |
$currClass .= ' menu-child'; |
|
166 |
if (($this->flags & SM2_NUMCLASS) == SM2_NUMCLASS) { |
|
167 |
$currClass .= ' menu-child-'.($aPage['sm2_child_level']-1); |
|
168 |
} |
|
169 |
} |
|
170 |
if ($aCurrSib == 1) { |
|
171 |
$currClass .= ' menu-first'; |
|
172 |
} |
|
173 |
if ($aCurrSib == $aSibCount) { |
|
174 |
$currClass .= ' menu-last'; |
|
175 |
} |
|
176 |
|
|
177 |
// use the top level item if this is the first item |
|
178 |
$currItem = $this->itemOpen; |
|
179 |
if ($this->topItemOpen) { |
|
180 |
$currItem = $this->topItemOpen; |
|
181 |
$this->topItemOpen = false; |
|
182 |
} |
|
183 |
|
|
184 |
// replace all keywords in the output |
|
185 |
if ($this->flags & SM2_PRETTY) { |
|
186 |
$this->output("\n".str_repeat(' ',$this->prettyLevel)); |
|
187 |
} |
|
188 |
$this->output($this->format($aPage, $aUrl, $currItem, $currClass, $aCurrSib, $aSibCount)); |
|
189 |
} |
|
190 |
|
|
191 |
// find and replace all keywords, setting the state variables first |
|
192 |
function format(&$aPage, &$aUrl, &$aCurrItem, &$aCurrClass, |
|
193 |
$aCurrSib = 0, $aSibCount = 0) |
|
194 |
{ |
|
195 |
$this->page = &$aPage; |
|
196 |
$this->url = &$aUrl; |
|
197 |
$this->currClass = trim($aCurrClass); |
|
198 |
$this->currSib = $aCurrSib; |
|
199 |
$this->sibCount = $aSibCount; |
|
200 |
|
|
201 |
$item = $this->format2($aCurrItem); |
|
202 |
|
|
203 |
unset($this->page); |
|
204 |
unset($this->url); |
|
205 |
unset($this->currClass); |
|
206 |
|
|
207 |
return $item; |
|
208 |
} |
|
209 |
|
|
210 |
// find and replace all keywords |
|
211 |
function format2(&$aCurrItem) { |
|
212 |
if (!is_string($aCurrItem)) return ''; |
|
213 |
return preg_replace( |
|
214 |
'@\[('. |
|
215 |
'a|ac|/a|li|/li|ul|/ul|menu_title|page_title|url|target|page_id|'. |
|
216 |
'parent|level|sib|sibCount|class|description|keywords|'. |
|
217 |
SM2_CONDITIONAL. |
|
218 |
')\]@e', |
|
219 |
'$this->replace("\1")', $aCurrItem); |
|
220 |
} |
|
221 |
|
|
222 |
// replace the keywords |
|
223 |
function replace($aMatch) { |
|
224 |
switch ($aMatch) { |
|
225 |
case 'a': |
|
226 |
return '<a href="'.$this->url.'" target="'.$this->page['target'].'">'; |
|
227 |
case 'ac': |
|
228 |
return '<a href="'.$this->url.'" target="'.$this->page['target'].'" class="'.$this->currClass.'">'; |
|
229 |
case '/a': |
|
230 |
return '</a>'; |
|
231 |
case 'li': |
|
232 |
return '<li class="'.$this->currClass.'">'; |
|
233 |
case '/li': |
|
234 |
return '</li>'; |
|
235 |
case 'ul': |
|
236 |
return '<ul class="'.$this->currClass.'">'; |
|
237 |
case '/ul': |
|
238 |
return '</ul>'; |
|
239 |
case 'url': |
|
240 |
return $this->url; |
|
241 |
case 'sib': |
|
242 |
return $this->currSib; |
|
243 |
case 'sibCount': |
|
244 |
return $this->sibCount; |
|
245 |
case 'class': |
|
246 |
return $this->currClass; |
|
247 |
default: |
|
248 |
if (array_key_exists($aMatch, $this->page)) { |
|
249 |
if ($this->flags & SM2_ESCAPE) { |
|
250 |
return htmlspecialchars($this->page[$aMatch], ENT_QUOTES); |
|
251 |
} |
|
252 |
else { |
|
253 |
return $this->page[$aMatch]; |
|
254 |
} |
|
255 |
} |
|
256 |
if (preg_match('/'.SM2_CONDITIONAL.'/', $aMatch, $rgMatches)) { |
|
257 |
return $this->replaceIf($rgMatches[1], $rgMatches[2], $rgMatches[3]); |
|
258 |
} |
|
259 |
} |
|
260 |
return "[$aMatch=UNKNOWN]"; |
|
261 |
} |
|
262 |
|
|
263 |
// conditional replacement |
|
264 |
function replaceIf(&$aExpression, &$aIfValue, &$aElseValue) { |
|
265 |
// evaluate all of the tests in the conditional (we don't do short-circuit |
|
266 |
// evaluation) and replace the string test with the boolean result |
|
267 |
$rgTests = preg_split('/(\|\||\&\&)/', $aExpression, -1, PREG_SPLIT_DELIM_CAPTURE); |
|
268 |
for ($n = 0; $n < count($rgTests); $n += 2) { |
|
269 |
if (preg_match('/'.SM2_COND_TERM.'/', $rgTests[$n], $rgMatches)) { |
|
270 |
$rgTests[$n] = $this->ifTest($rgMatches[1], $rgMatches[2], $rgMatches[3]); |
|
271 |
} |
|
272 |
else { |
|
273 |
error_log("show_menu2 error: conditional expression is invalid!"); |
|
274 |
$rgTests[$n] = false; |
|
275 |
} |
|
276 |
} |
|
277 |
|
|
278 |
// combine all test results for a final result |
|
279 |
$ok = $rgTests[0]; |
|
280 |
for ($n = 1; $n+1 < count($rgTests); $n += 2) { |
|
281 |
if ($rgTests[$n] == '||') { |
|
282 |
$ok = $ok || $rgTests[$n+1]; |
|
283 |
} |
|
284 |
else { |
|
285 |
$ok = $ok && $rgTests[$n+1]; |
|
286 |
} |
|
287 |
} |
|
288 |
|
|
289 |
// return the formatted expression if the test succeeded |
|
290 |
return $ok ? $this->format2($aIfValue) : $this->format2($aElseValue); |
|
291 |
} |
|
292 |
|
|
293 |
// conditional test |
|
294 |
function ifTest(&$aKey, &$aOperator, &$aValue) { |
|
295 |
global $wb; |
|
296 |
|
|
297 |
// find the correct operand |
|
298 |
$operand = false; |
|
299 |
switch($aKey) { |
|
300 |
case 'class': |
|
301 |
// we need to wrap the class names in spaces so we can test for a unique |
|
302 |
// class name that will not match prefixes or suffixes. Same must be done |
|
303 |
// for the value we are testing. |
|
304 |
$operand = " $this->currClass "; |
|
305 |
break; |
|
306 |
case 'sib': |
|
307 |
$operand = $this->currSib; |
|
308 |
if ($aValue == 'sibCount') { |
|
309 |
$aValue = $this->sibCount; |
|
310 |
} |
|
311 |
break; |
|
312 |
case 'sibCount': |
|
313 |
$operand = $this->sibCount; |
|
314 |
break; |
|
315 |
case 'level': |
|
316 |
$operand = $this->page['level']; |
|
317 |
switch ($aValue) { |
|
318 |
case 'root': $aValue = 0; break; |
|
319 |
case 'granny': $aValue = $wb->page['level']-2; break; |
|
320 |
case 'parent': $aValue = $wb->page['level']-1; break; |
|
321 |
case 'current': $aValue = $wb->page['level']; break; |
|
322 |
case 'child': $aValue = $wb->page['level']+1; break; |
|
323 |
} |
|
324 |
if ($aValue < 0) $aValue = 0; |
|
325 |
break; |
|
326 |
case 'id': |
|
327 |
$operand = $this->page['page_id']; |
|
328 |
switch ($aValue) { |
|
329 |
case 'parent': $aValue = $wb->page['parent']; break; |
|
330 |
case 'current': $aValue = $wb->page['page_id']; break; |
|
331 |
} |
|
332 |
break; |
|
333 |
default: |
|
334 |
return ''; |
|
335 |
} |
|
336 |
|
|
337 |
// do the test |
|
338 |
$ok = false; |
|
339 |
switch ($aOperator) { |
|
340 |
case '<': |
|
341 |
$ok = ($operand < $aValue); |
|
342 |
break; |
|
343 |
case '<=': |
|
344 |
$ok = ($operand <= $aValue); |
|
345 |
break; |
|
346 |
case '=': |
|
347 |
case '==': |
|
348 |
case '!=': |
|
349 |
if ($aKey == 'class') { |
|
350 |
$ok = strstr($operand, " $aValue ") !== FALSE; |
|
351 |
} |
|
352 |
else { |
|
353 |
$ok = ($operand == $aValue); |
|
354 |
} |
|
355 |
if ($aOperator == '!=') { |
|
356 |
$ok = !$ok; |
|
357 |
} |
|
358 |
break; |
|
359 |
case '>=': |
|
360 |
$ok = ($operand >= $aValue); |
|
361 |
case '>': |
|
362 |
$ok = ($operand > $aValue); |
|
363 |
} |
|
364 |
|
|
365 |
return $ok; |
|
366 |
} |
|
367 |
|
|
368 |
// finish the current menu item |
|
369 |
function finishItem() { |
|
370 |
if ($this->flags & SM2_PRETTY) { |
|
371 |
$this->output(str_repeat(' ',$this->prettyLevel).$this->itemClose); |
|
372 |
} |
|
373 |
else { |
|
374 |
$this->output($this->itemClose); |
|
375 |
} |
|
376 |
} |
|
377 |
|
|
378 |
// finish the current menu |
|
379 |
function finishList() { |
|
380 |
$this->prettyLevel -= 3; |
|
381 |
|
|
382 |
if ($this->flags & SM2_PRETTY) { |
|
383 |
$this->output("\n".str_repeat(' ',$this->prettyLevel).$this->menuClose."\n"); |
|
384 |
} |
|
385 |
else { |
|
386 |
$this->output($this->menuClose); |
|
387 |
} |
|
388 |
|
|
389 |
$this->prettyLevel -= 1; |
|
390 |
} |
|
391 |
|
|
392 |
// cleanup the state of the formatter after everything has been output |
|
393 |
function finalize() { |
|
394 |
if ($this->flags & SM2_PRETTY) { |
|
395 |
$this->output("\n"); |
|
396 |
} |
|
397 |
} |
|
398 |
|
|
399 |
// return the output |
|
400 |
function getOutput() { |
|
401 |
return $this->output; |
|
402 |
} |
|
403 |
}; |
|
404 |
|
|
405 |
function show_menu2( |
|
406 |
$aMenu = 0, |
|
407 |
$aStart = SM2_ROOT, |
|
408 |
$aMaxLevel = -1999, // SM2_CURR+1 |
|
409 |
$aFlags = SM2_TRIM, |
|
410 |
$aItemOpen = false, |
|
411 |
$aItemClose = false, |
|
412 |
$aMenuOpen = false, |
|
413 |
$aMenuClose = false, |
|
414 |
$aTopItemOpen = false, |
|
415 |
$aTopMenuOpen = false |
|
416 |
) |
|
417 |
{ |
|
418 |
global $wb; |
|
419 |
|
|
420 |
// ensure we have our group 1 flag, we don't check for the "exactly 1" part, but |
|
421 |
// we do ensure that they provide at least one. |
|
422 |
if (0 == ($aFlags & _SM2_GROUP_1)) { |
|
423 |
error_log("show_menu2 error: no flags from group 1 supplied! Exactly one flag is required!"); |
|
424 |
$aFlags |= SM2_TRIM; // default to TRIM |
|
425 |
} |
|
426 |
|
|
427 |
// fix up the menu number to default to the menu number |
|
428 |
// of the current page if no menu has been supplied |
|
429 |
if ($aMenu == 0) { |
|
430 |
$aMenu = $wb->page['menu'] == '' ? 1 : $wb->page['menu']; |
|
431 |
} |
|
432 |
|
|
433 |
// Set some of the $wb->page[] settings to defaults if not set |
|
434 |
$pageLevel = $wb->page['level'] == '' ? 0 : $wb->page['level']; |
|
435 |
$pageParent = $wb->page['parent'] == '' ? 0 : $wb->page['parent']; |
|
436 |
|
|
437 |
// adjust the start level and start page ID as necessary to |
|
438 |
// handle the special values that can be passed in as $aStart |
|
439 |
$aStartLevel = 0; |
|
440 |
if ($aStart < SM2_ROOT) { // SM2_CURR+N |
|
441 |
if ($aStart == SM2_CURR) { |
|
442 |
$aStartLevel = $pageLevel; |
|
443 |
$aStart = $pageParent; |
|
444 |
} |
|
445 |
else { |
|
446 |
$aStartLevel = $pageLevel + $aStart - SM2_CURR; |
|
447 |
$aStart = PAGE_ID; |
|
448 |
} |
|
449 |
} |
|
450 |
elseif ($aStart < 0) { // SM2_ROOT+N |
|
451 |
$aStartLevel = $aStart - SM2_ROOT; |
|
452 |
$aStart = 0; |
|
453 |
} |
|
454 |
|
|
455 |
// we get the menu data once and store it in a global variable. This allows |
|
456 |
// multiple calls to show_menu2 in a single page with only a single call to |
|
457 |
// the database. If this variable exists, then we have already retrieved all |
|
458 |
// of the information and processed it, so we don't need to do it again. |
|
459 |
if (($aFlags & SM2_NOCACHE) != 0 |
|
460 |
|| !array_key_exists('show_menu2_data', $GLOBALS) |
|
461 |
|| !array_key_exists($aMenu, $GLOBALS['show_menu2_data'])) |
|
462 |
{ |
|
463 |
global $database; |
|
464 |
|
|
465 |
// create an array of all parents of the current page. As the page_trail |
|
466 |
// doesn't include the theoretical root element 0, we add it ourselves. |
|
467 |
$rgCurrParents = split(',', '0,'.$wb->page['page_trail']); |
|
468 |
array_pop($rgCurrParents); // remove the current page |
|
469 |
$rgParent = array(); |
|
470 |
|
|
471 |
// if the caller wants all menus gathered together (e.g. for a sitemap) |
|
472 |
// then we don't limit our SQL query |
|
473 |
$menuLimitSql = ' AND menu = ' .$aMenu; |
|
474 |
if ($aMenu == SM2_ALLMENU) { |
|
475 |
$menuLimitSql = ''; |
|
476 |
} |
|
477 |
|
|
478 |
// we only load the description and keywords if we have been told to, |
|
479 |
// this cuts the memory load for pages that don't use them. Note that if |
|
480 |
// we haven't been told to load these fields the *FIRST TIME* show_menu2 |
|
481 |
// is called (i.e. where the database is loaded) then the info won't |
|
482 |
// exist anyhow. |
|
483 |
$fields = 'parent,page_id,menu_title,page_title,link,target,level,visibility,viewing_groups'; |
|
484 |
if(version_compare(WB_VERSION, '2.7', '>=')) { // WB 2.7+ |
|
485 |
$fields .= ',viewing_users'; |
|
486 |
} |
|
487 |
if ($aFlags & SM2_ALLINFO) { |
|
488 |
$fields = '*'; |
|
489 |
} |
|
490 |
|
|
491 |
// get this once for performance. We really should be calling only need to |
|
492 |
// call $wb->get_group_id() but that outputs a warning notice if the |
|
493 |
// groupid isn't set in the session, so we check it first here. |
|
494 |
$currGroup = array_key_exists('GROUP_ID', $_SESSION) ? |
|
495 |
','.$wb->get_group_id().',' : 'NOGROUP'; |
|
496 |
|
|
497 |
// we request all matching rows from the database for the menu that we |
|
498 |
// are about to create it is cheaper for us to get everything we need |
|
499 |
// from the database once and create the menu from memory then make |
|
500 |
// multiple calls to the database. |
|
501 |
$sql = "SELECT $fields FROM ".TABLE_PREFIX. |
|
502 |
"pages WHERE $wb->extra_where_sql $menuLimitSql ". |
|
503 |
'ORDER BY level ASC, position ASC'; |
|
504 |
$oRowset = $database->query($sql); |
|
505 |
if (is_object($oRowset) && $oRowset->numRows() > 0) { |
|
506 |
// create an in memory array of the database data based on the item's parent. |
|
507 |
// The array stores all elements in the correct display order. |
|
508 |
while ($page = $oRowset->fetchRow()) { |
|
509 |
// ignore all pages that the current user is not permitted to view |
|
510 |
if(version_compare(WB_VERSION, '2.7', '>=')) { // WB >= 2.7 |
|
511 |
// 1. all pages with no active sections (unless it is the top page) are ignored |
|
512 |
if(!$wb->page_is_active($page) && $page['link'] != $wb->default_link && !INTRO_PAGE) { |
|
513 |
continue; |
|
514 |
} |
|
515 |
// 2. all pages not visible to this user (unless always visible to registered users) are ignored |
|
516 |
if(!$wb->page_is_visible($page) && $page['visibility'] != 'registered') { |
|
517 |
continue; |
|
518 |
} |
|
519 |
|
|
520 |
} |
|
521 |
else { // WB < 2.7 |
|
522 |
// We can't do this in SQL as the viewing_groups column contains multiple |
|
523 |
// values which are hard to process correctly in SQL. Essentially we add the |
|
524 |
// following limit to the SQL query above: |
|
525 |
// (visibility <> "private" OR $wb->get_group_id() IN viewing_groups) |
|
526 |
if ($page['visibility'] == 'private' |
|
527 |
&& false === strstr(",{$page['viewing_groups']},", $currGroup)) |
|
528 |
{ |
|
529 |
continue; |
|
530 |
} |
|
531 |
} |
|
532 |
|
|
533 |
// ensure that we have an array entry in the table to add this to |
|
534 |
$idx = $page['parent']; |
|
535 |
if (!array_key_exists($idx, $rgParent)) { |
|
536 |
$rgParent[$idx] = array(); |
|
537 |
} |
|
538 |
|
|
539 |
// mark our current page as being on the current path |
|
540 |
if ($page['page_id'] == PAGE_ID) { |
|
541 |
$page['sm2_on_curr_path'] = true; |
|
542 |
} |
|
543 |
|
|
544 |
// mark parents of the current page as such |
|
545 |
if (in_array($page['page_id'], $rgCurrParents)) { |
|
546 |
$page['sm2_is_parent'] = true; |
|
547 |
$page['sm2_on_curr_path'] = true; |
|
548 |
} |
|
549 |
|
|
550 |
// add the entry to the array |
|
551 |
$rgParent[$idx][] = $page; |
|
552 |
} |
|
553 |
} |
|
554 |
unset($oRowset); |
Also available in: Unified diff
Added show_menu2() to pre-installed WB modules (many thanks to Brodie Thiesfield for this great menu function replacment)