Project

General

Profile

« Previous | Next » 

Revision 845

Added by doc almost 16 years ago

Updated show_menu2 to version 4.60 (to avoid disappearing menus)

View differences:

trunk/CHANGELOG
10 10
# = Bugfix
11 11
! = Update/Change
12 12

  
13
------------------------------------- 2.7.1 -------------------------------------
14
08-Jun-2008 Thomas Hornik
15
# hebrew-table in charsets-table.php was faultily imported - fixed. Thanks to forum-member iti.
13
------------------------------------- 2.7.1 -------------------------------------
14
21-June-2008 Christian Sommer
15
#	updated show_menu2 to version 4.60 (to avoid disappearing menus)
16
08-Jun-2008 Thomas Hornik
17
#	hebrew-table in charsets-table.php was faultily imported - fixed. Thanks to forum-member iti.
16 18
24-May-2008 Christian Sommer
17
! modified output filter routine to prevent errors if database entries do not exist
19
!	modified output filter routine to prevent errors if database entries do not exist
18 20
04-May-2008 Thomas Hornik
19
! changed register_backend_modfile() to work with wysiwyg-module, too
21
!	changed register_backend_modfile() to work with wysiwyg-module, too
20 22
01-May-2008 Thomas Hornik
21 23
#	fixed file-naming issue when old page-names (from before 2.7) contains "&"
22 24
26-Apr-2008 Thomas Hornik
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

  
479 0

  
trunk/wb/modules/show_menu2/README
1
// $Id$
2

  
3
show_menu2, version 4.5
4
=======================
5
A code snippet for the Website Baker CMS software. It provides a complete 
6
replacement for the builtin menu functions. All menu data is retrieved using 
7
a single database query, all types of menu styles (lists, breadcrums, sitemaps) 
8
can be generated with extensive customisation of the resulting HTML.
9

  
10

  
11
INSTALLATION
12
============
13
1. Download the latest version from http://code.jellycan.com/show_menu2/
14
2. Log into your WebsiteBaker installation
15
3. Go to Addons -> Modules
16
4. If a previous version of show_menu2 is already installed, select it from
17
   the "Uninstall Module" list and choose the "Uninstall" button.
18
5. In the "Install Module" section, enter the path to the show_menu2 zip file
19
   that you downloaded in step 1, and choose the "Install" button.
20
   
21
   
22
USING SHOW_MENU2
23
================
24
You need to modify the PHP files of your template to call show_menu2 where you 
25
wish to have the menu displayed. Remember when you replace calls to the old
26
menu functions to use the new parameters that show_menu2 requires. 
27

  
28
Often times the default menu generated by show_menu2 is all that you need.
29
This menu shows the current page and children of the current page. It is
30
generated by just calling show_menu2 with no parameters. For example:
31

  
32
    show_menu2();
33
    
34
Note that the call to show_menu2 is PHP, so you usually need to wrap it in the
35
PHP code brackets so that it will execute. Like this:
36

  
37
    <?php show_menu2(); ?>
38

  
39
This default menu generates a complete list based menu with many classes that
40
allow easy CSS styling. For example, the current menu item will have the
41
"menu-current" class added to the <li> tag. Additionally, every menu item with
42
a sub-menu will have the "menu-expand" class added to the <li> tag. This allows 
43
you to create CSS rules to style those menu items differently. For example:
44

  
45
    li.menu-expand  { font-weight: bold; }
46
    li.menu-current { background: red; }
47

  
48
See the "Output" section for details of exactly what classes are added to each 
49
element. More elaborate and different menu structures are able to be created by 
50
supplying parameters to the show_menu2 function call. For example, to show only 
51
menu items from the top level of the menu you use:
52

  
53
    show_menu2(0, SM2_ROOT, SM2_START);
54
    
55
Alternatively, to show up to two levels of the child menus of the current page:
56

  
57
    show_menu2(0, SM2_CURR+1, SM2_CURR+2);
58

  
59
There are many more possible menus that can be generated by show_menu2. See the
60
demonstration website at http://code.jellycan.com/sm2test/ for more examples. 
61

  
62

  
63
FUNCTION
64
========
65

  
66
The complete call signature and default parameter value for show_menu2 is:
67

  
68
    show_menu2(
69
        $aMenu          = 0,
70
        $aStart         = SM2_ROOT,
71
        $aMaxLevel      = SM2_CURR+1,
72
        $aFlags         = SM2_TRIM,
73
        $aItemOpen      = '[li][a][menu_title]</a>',
74
        $aItemClose     = '</li>',
75
        $aMenuOpen      = '[ul]',
76
        $aMenuClose     = '</ul>',
77
        $aTopItemOpen   = false,
78
        $aTopMenuOpen   = false
79
        )
80

  
81
See the "Parameters" section for detailed descriptions of each parameter.
82
Note that every parameter from $aItemOpen onwards can be supplied as false
83
in order to get the default value, this allows (for example) a numbered list
84
to be used while still using the the default menu parameters for the items.
85
Note that all parameters up to $aFlags need to be explicitly supplied.
86
For example:
87

  
88
show_menu2(0, SM2_ROOT, SM2_ALL, SM2_ALL, false, false, '<ol>', '</ol>');
89

  
90

  
91
OUTPUT
92
======
93
The menu is output differently depending on what parameters have been 
94
supplied to the function, however in general the following classes are used 
95
for each menu. Note that items will have multiple classes when relevant.
96

  
97
    CLASS           ATTACHED TO
98
    ------------    -------------------------------------------------------
99
    menu-top        First menu tag only
100
    menu-parent     Every parent menu item of the current page.
101
    menu-current    Only the menu item for the current page.
102
    menu-sibling    Every sibling of the current page.
103
    menu-child      Every sub-menu of the current page.
104
    menu-expand     Every menu item with children.
105
    menu-first      First item in any menu or sub-menu.
106
    menu-last       Last item in any menu or sub-menu.
107

  
108
    The following classes are added only if SM2_NUMCLASS flag has been used.
109

  
110
    menu-N          Every menu item. The N is replaced with the ABSOLUTE 
111
                    menu depth of the item starting with 0. The root level 
112
                    menu is always menu-0, the next level is menu-1, etc.
113
    menu-child-N    Every sub-menu of the current page, the N is replaced 
114
                    with the relative depth of the submenu starting at 0.
115

  
116

  
117
<ul class="menu-top menu-0">
118
  <li class="menu-0 menu-first">  ... </li>
119
  <li class="menu-0 menu-expand menu-parent">  ...
120
  <ul class="menu-1">
121
    <li class="menu-1 menu-expand menu-first">  ...
122
    <ul class="menu-2">
123
      <li class="menu-2 menu-first">  ...
124
      <li class="menu-2 menu-last">  ...
125
    </ul>
126
    </li>
127
    <li class="menu-1 menu-expand menu-parent">  ...
128
    <ul class="menu-2">
129
      <li class="menu-2 menu-expand menu-current menu-first">  ...      ** CURRENT PAGE **
130
      <ul class="menu-3">
131
        <li class="menu-3 menu-child menu-child-0 menu-first">  ...
132
        <ul class="menu-4">
133
          <li class="menu-4 menu-child menu-child-1 menu-first">  ... </li>
134
          <li class="menu-4 menu-child menu-child-1 menu-last">  ... </li>
135
        </ul>
136
        </li>
137
        <li class="menu-3 menu-child menu-child-0 menu-last">  ... </li>
138
      </ul>
139
      </li>
140
      <li class="menu-2 menu-sibling menu-last">  ... </li>
141
    </ul>
142
    </li>
143
    <li class="menu-1">  ... </li>
144
    <li class="menu-1 menu-expand menu-last">  ...
145
    <ul class="menu-2">
146
      <li class="menu-2 menu-first menu-last">  ... </li>
147
    </ul>
148
    </li>
149
  </ul>
150
  </li>
151
  <li class="menu-0 menu-last">  ... </li>
152
</ul>
153

  
154

  
155

  
156
PARAMETERS
157
==========
158
$aMenu      
159
    Menu number to use. This is useful when you are using multiple menus. 
160
    Supplying a menu number of 0 will use the default menu for the current 
161
    page. Supplying SM2_ALLMENU will return all menus in the system.
162

  
163
$aStart  
164
    Specify where the menu generation should start from. This is most
165
    times the parent item of the menu to display. It must be one of the 
166
    following values:
167
        SM2_ROOT+N  Start N levels down from the root. e.g.
168
                      SM2_ROOT      Starting at the root menu 
169
                      SM2_ROOT+1    Start 1 level below the root
170
                      SM2_ROOT+2    Start 2 levels below the root
171
        SM2_CURR+N  Start N levels down from the current page level. e.g.
172
                      SM2_CURR      Starts at the current page level. All
173
                                    sibling menus to the current page.
174
                      SM2_CURR+1    Starts 1 level down from the current
175
                                    page with the children menus.
176
        page_id     Display using the specific page as the parent. All
177
                    child menus of that page will be displayed. The 
178
                    page_id can be found by editing the page in WB admin 
179
                    interface. The page_id is included in the URL like: 
180
                        http://SITE/admin/pages/modify.php?page_id=35
181

  
182
$aMaxLevel   
183
    Maximum menu level to display. Menus are displayed from the start
184
    level down to this level.
185
        SM2_ALL     No limit, all levels are displayed
186
        SM2_CURR+N  Always show to the current page + N levels. 
187
                      SM2_CURR      Current (no children)
188
                      SM2_CURR+3    All parents + current + 3 children
189
        SM2_START+N Always show from the starting level + N levels. The
190
                    levels of menu will always be displayed regardless of
191
                    what level the current page is.
192
                      SM2_START     Single level of menus from starting level
193
                      SM2_START+1   Starting level and 1 level down
194
        SM2_MAX+N   Show at most N levels from the starting level. Levels 
195
                    won't be shown if they are below the current level.
196
                      SM2_MAX       Starting level only (same as SM2_START)
197
                      SM2_MAX+1     Maximum of starting level and 1 level.
198

  
199
$aFlags   
200
    Specify flags for different generation options for the menu. The flags
201
    may be combined together using bitwise OR (|). For example, to specify
202
    both TRIM and PRETTY you should use, SM2_TRIM|SM2_PRETTY.
203

  
204
    GROUP 1
205
    -------
206
    Exactly one flag from this group must always be supplied. These flags 
207
    affect how the siblings in the tree are removed from the output. 
208

  
209
    SM2_ALL         Show all branches of the menu tree
210
                        A-1 -> B-1 
211
                            -> B-2 -> C-1
212
                                   -> C-2 (CURRENT)
213
                                          -> D-1
214
                                          -> D-2
215
                                   -> C-3
216
                        A-2 -> B-3
217
                            -> B-4
218
    SM2_TRIM        Show all sibling menus of pages on the current path. 
219
                    All sub-menus of elements that are not on the path 
220
                    are removed.
221
                        A-1 -> B-1 
222
                            -> B-2 -> C-1
223
                                   -> C-2 (CURRENT)
224
                                          -> D-1
225
                                          -> D-2
226
                                   -> C-3
227
                        A-2 
228
    SM2_CRUMB       Show only the breadcrumb trail, i.e. the current
229
                    menu and all of it's ancestor menus.
230
                        A-1 -> B-2 -> C-2 (CURRENT)
231
    SM2_SIBLING     The same as SM2_TRIM however only sibling menus of 
232
                    the current page are displayed. All other menus are 
233
                    trimmed to show only the path.
234
                        A-1 -> B-2 -> C-1
235
                                   -> C-2 (CURRENT)
236
                                          -> D-1
237
                                          -> D-2
238
                                   -> C-3
239

  
240
    GROUP 2
241
    -------
242
    All of these flags are optional. Any number of them may be combined.
243

  
244
    SM2_NUMCLASS    Add the numbered menu classes to the menu. If this 
245
                    flag is supplied, the "menu-N" and "menu-child-N" 
246
                    classes will be added.
247
    SM2_ALLINFO     Load all fields from the page table of the database.
248
                    This will result in quite a lot of memory being used
249
                    and is not recommended, however it will make keywords,
250
                    descriptions, and other fields available. This data
251
                    is not loaded by default.
252
                    NOTE: This flag must be used on the *FIRST* call to
253
                    show_menu2 *for this menu ID*, or in combination with
254
                    SM2_NOCACHE otherwise it will have no effect.
255
    SM2_NOCACHE     Do not reuse or store the data read from the database
256
                    between calls to show_menu2. 
257
    SM2_PRETTY      Pretty print the menu HTML with spacing and newlines
258
                    for debugging purposes.
259
    SM2_BUFFER      Do not output the menu HTML but instead buffer it 
260
                    internally and return it as a string from show_menu2.
261
    SM2_CURRTREE    Exclude all other top level menus from being considered. 
262
                    Only items in the current menu tree will be output.
263
                    This can be combined with any of the Group 1 flags as
264
                    necessary.
265
    SM2_ESCAPE      Call htmlspecialchars on the menu strings. This may be
266
                    required with older installations of WB. By escaping the
267
                    raw database strings, it permits menus to have HTML 
268
                    formatting in them that would cause otherwise cause
269
                    pages to fail validation. 
270
    SM2_NOESCAPE    Default behaviour. Exists only for backwards compatibility.                    
271

  
272

  
273
$aItemOpen
274
    Format string to use for creating each individual menu item entry.
275
    A different format string may be used for the very first entry by 
276
    supplying a different format string for $aTopItemOpen. When set to 
277
    false, it uses the default of '[li][a][menu_title]</a>' to maintain
278
    compatibility with show_menu(). Note however that CSS formatting is
279
    often easier if the classes are added to the <a> tag. Use the format
280
    string of '<li>[ac][menu_title]</a>' for this style of tag.
281

  
282
    This parameter may also be specified as an instance of a formatting 
283
    class for the menu. See the section "Formatter" below for details of
284
    the API this class must expose. When a formatter is supplied, all 
285
    arguments after $aItemOpen are ignored.
286

  
287
$aItemClose
288
    String used to close each item. Note that this is not a format
289
    string and no keywords will be replaced. When set to false, it uses 
290
    the default of '</li>'.
291

  
292
$aMenuOpen
293
    Format string to use for opening a list of menu item entries. A 
294
    different format string may be used for the very first menu by 
295
    supplying a different format string for $aTopMenuOpen. When set to 
296
    false, it uses the default of '[ul]'.
297

  
298
$aMenuClose
299
    String used to close each menu. Note that this is not a format
300
    string and no keywords will be replaced. When set to false, it uses 
301
    the default of '</ul>'.
302

  
303
$aTopItemOpen
304
    Format string for the first item. When set to false, it uses the same 
305
    format as $aItemOpen.
306

  
307
$aTopMenuOpen 
308
    Format string for the first menu. When set to false, it uses the same 
309
    format as $aMenuOpen.
310
        
311

  
312

  
313
FORMAT STRINGS
314
==============
315
The following tags may be included in the format strings for $aItemOpen and 
316
$aMenuOpen and will be replaced with the appropriate text.
317

  
318
[a]             <a> tag (no class):         '<a href="[url]" target="[target]">'
319
[ac]            <a> tag including class:    '<a href="[url]" target="[target]" class="[class]">'
320
[li]            <li> tag including class:   '<li class="[class]">'
321
[ul]            <ul> tag including class:   '<ul class="[class]">'
322
[class]         List of classes for that page
323
[menu_title]    Menu title text (HTML entity escaped unless SM2_NOESCAPE flag is used)
324
[page_title]    Page title text (HTML entity escaped unless SM2_NOESCAPE flag is used)
325
[url]           Page URL for the <a> tag
326
[target]        Page target for the <a> tag
327
[page_id]       Page ID of the current menu item
328
[parent]        Page ID of the parent menu item
329
[level]         Page level, the same number as is used for the "menu-N" CSS tag.
330
[sib]           Current menu sibling number
331
[sibCount]      Total number of siblings in this menu
332
[if]            Conditional test (see section CONDITIONAL FORMATTING)
333

  
334
The following tags are only available when the SM2_ALLINFO flag is used.
335

  
336
[description]   Page description
337
[keywords]      Page keywords
338

  
339

  
340
CONDITIONAL FORMATTING
341
======================
342
The conditional formatting directive takes one of the following forms:
343

  
344
    [if(A){B}]
345
    [if(A){B}else{C}]
346
    
347
    A   Conditional test. See below for more details.
348
    
349
    B   Expression emitted when the if-test is true. This may be any string 
350
        that does NOT include the '}' character. It may include any of the 
351
        format strings described in the section FORMAT STRINGS with the 
352
        exception of the conditional test (because '}' is not permitted).
353
        
354
    C   Expression emitted when the if-test is false. This may be any string 
355
        that does NOT include the '}' character. It may include any of the 
356
        format strings described in the section FORMAT STRINGS with the 
357
        exception of the conditional test (because '}' is not permitted).
358
    
359
The conditional test is a combination of one or more boolean tests.
360
If more than one test is supplied, it must be combined with other tests
361
using either || (boolean OR) or && (boolean AND). 
362

  
363
A single test is made up of the left operand, operator and right operand.
364
e.g. X == Y where X is the left operand, == is the operator and Y is the
365
right operand.
366
    
367
    Left operand. It must be one of the following keywords:
368
        class       Test for existence of one of the classes. Only the
369
                    "==" and "!=" operators are permitted. In this case
370
                    these operators have the meaning of "includes" 
371
                    instead of "equals".
372
        level       Test against the page level.
373
        sib         Test against the current page sibling number.
374
        sibCount    Test against the number of siblings in the menu.
375
        id          Test against the page id.
376
    
377
    Operator. It must be one of the following:
378
        <           Less Than
379
        <=          Less Than Equals
380
        ==          Equals
381
        !=          Not Equal
382
        >=          Greater Than Equals
383
        >           Greater Than
384
    
385
    Right operand. The type of this operand depends on the keyword used
386
    for the left operand:
387
        class       One of the "menu-*" class names as listed in the 
388
                    section "OUTPUT".
389
        level       Test the page level against the following values:
390
                      <number>  absolute page level
391
                      root      the root page level
392
                      granny    the grand-parent page level
393
                      parent    the parent page level
394
                      current   the current page level
395
                      child     the child page level
396
        id          Test the page id against the following values:
397
                      <number>  absolute page id
398
                      parent    the parent page id
399
                      current   the current page id
400
        sib         A positive integer, or "sibCount" to test against
401
                    the count of siblings in this menu.
402
        sibCount    A positive integer.
403
        
404
For example, valid tests are expression "exp" is emitted only when the menu item:
405
    
406
    [if(class==menu-expand){exp}]   has a sub-menu
407
    [if(class==menu-first){exp}]    is first item in a menu
408
    [if(class!=menu-first){exp}]    is NOT first item in a menu
409
    [if(class==menu-last){exp}]     is last item in a menu
410
    [if(level==0){exp}]             is at the root
411
    [if(level>0){exp}]              is not at the root
412
    [if(sib==2){exp}]               is the second item in a menu
413
    [if(sibCount>1){exp}]           is in a menu with more than 1 entry
414
    [if(sibCount!=2){exp}]          is in a menu which doesn't have exactly
415
    [if(level>parent){exp}]         is in a sibling menu or child of a sibling
416
    [if(id==parent){exp}]           is the parent of the current page
417

  
418
If an else-clause was added, then the expression for the else would be 
419
emitted in all other cases. For example the expression "foo" is emitted
420
whenever the if-test is false, so therefore:
421

  
422
    [if(sib==2){exp}else{foo}]          is NOT the second item in a menu
423
    [if(sibCount>2){exp}else{foo}]      is NOT in a menu with more than 2 entries
424

  
425
For multiple tests, the expression "exp" is emitted only when the menu item:
426

  
427
    [if(sib == 1 || sib > 3){exp}]      
428
        [is the first item] OR [is the 4th or larger item] in the menu
429
        
430
    [if(id == current && class == menu-expand){exp}
431
        [is the current item] AND [it has children]
432

  
433
Note that all tests are evaluated in the order listed because:
434
 * there is no short-circuit evaluation (all individual tests are always evaluated)
435
 * there is no grouping of tests (i.e. no support for parenthesis)
436
 * both || and && are considered the same level 
437

  
438

  
439

  
440
FORMATTER
441
=========
442
Note: This is an advanced and rarely needed feature!
443

  
444
If you are capable of extensive PHP programming, it is possible to replace the 
445
predefined menu formatter that show_menu2 is uses with a custom module. See the
446
include.php file of show_menu2 for an example of how the menu formatter must be 
447
written. The API it must use is:
448

  
449
class SM2_Formatter
450
{
451
    // called once before any menu is processed to allow object initialization
452
    function initialize() { }
453
    
454
    // called to open the menu list
455
    function startList($aPage, $aUrl) { }
456
    
457
    // called to open the menu item
458
    function startItem($aPage, $aUrl, $aCurrSib, $aSibCount) { }
459
    
460
    // called to close the menu item
461
    function finishItem() { }
462
    
463
    // called to close the menu list
464
    function finishList() { }
465
    
466
    // called once after all menu has been processed to allow object finalization
467
    function finalize() { }
468
    
469
    // called once after finalize() if the SM2_NOOUTPUT flag is used
470
    function getOutput() { }
471
};
472

  
473

  
474

  
475 0

  
trunk/wb/modules/show_menu2/LICENCE.txt
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
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff