2
0

Zend_Navigation-Pages-Common.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect2 id="zend.navigation.pages.common">
  4. <title>Common page features</title>
  5. <para>
  6. All page classes must extend <classname>Zend_Navigation_Page</classname>,
  7. and will thus share a common set of features and properties. Most notably
  8. they share the options in the table below and the same initialization
  9. process.
  10. </para>
  11. <para>
  12. Option keys are mapped to <code>set</code> methods. This means that
  13. the option <code>order</code> maps to the method <methodname>setOrder()</methodname>,
  14. and <code>reset_params</code> maps to the method
  15. <methodname>setResetParams()</methodname>. If there is no setter method for
  16. the option, it will be set as a custom property of the page.
  17. </para>
  18. <para>
  19. Read more on extending <classname>Zend_Navigation_Page</classname> in
  20. <link linkend="zend.navigation.pages.custom">Creating custom page types</link>.
  21. </para>
  22. <table id="zend.navigation.pages.common.options">
  23. <title>Common page options</title>
  24. <tgroup cols="4">
  25. <thead>
  26. <row>
  27. <entry>Key</entry>
  28. <entry>Type</entry>
  29. <entry>Default</entry>
  30. <entry>Description</entry>
  31. </row>
  32. </thead>
  33. <tbody>
  34. <row>
  35. <entry><code>label</code></entry>
  36. <entry><type>String</type></entry>
  37. <entry><constant>NULL</constant></entry>
  38. <entry>A page label, such as 'Home' or 'Blog'.</entry>
  39. </row>
  40. <row>
  41. <entry><code>id</code></entry>
  42. <entry><type>String</type> | <code>int</code></entry>
  43. <entry><constant>NULL</constant></entry>
  44. <entry>
  45. An id tag/attribute that may be used when rendering
  46. the page, typically in an anchor element.
  47. </entry>
  48. </row>
  49. <row>
  50. <entry><code>class</code></entry>
  51. <entry><type>String</type></entry>
  52. <entry><constant>NULL</constant></entry>
  53. <entry>
  54. A <acronym>CSS</acronym> class that may be used when rendering the page,
  55. typically in an anchor element.
  56. </entry>
  57. </row>
  58. <row>
  59. <entry><code>title</code></entry>
  60. <entry><type>String</type></entry>
  61. <entry><constant>NULL</constant></entry>
  62. <entry>
  63. A short page description, typically for using
  64. as the <code>title</code> attribute in an anchor.
  65. </entry>
  66. </row>
  67. <row>
  68. <entry><code>target</code></entry>
  69. <entry><type>String</type></entry>
  70. <entry><constant>NULL</constant></entry>
  71. <entry>
  72. Specifies a target that may be used for the page,
  73. typically in an anchor element.
  74. </entry>
  75. </row>
  76. <row>
  77. <entry><code>accesskey</code></entry>
  78. <entry><type>String</type></entry>
  79. <entry><constant>NULL</constant></entry>
  80. <entry>
  81. This attribute assigns an access key to an <code>A</code> element.
  82. An access key is a single character from the document character set.
  83. </entry>
  84. </row>
  85. <row>
  86. <entry><code>fragment</code></entry>
  87. <entry><type>String</type></entry>
  88. <entry><constant>NULL</constant></entry>
  89. <entry>
  90. The fragment identifier (anchor identifier) pointing to
  91. an anchor within a resource that is subordinate to another,
  92. primary resource. The fragment identifier introduced by
  93. a hash mark '#'.
  94. Example: http://www.example.org/foo.html#bar
  95. ('bar' is the fragment identifier)
  96. </entry>
  97. </row>
  98. <row>
  99. <entry><code>rel</code></entry>
  100. <entry><type>Array</type></entry>
  101. <entry><methodname>array()</methodname></entry>
  102. <entry>
  103. Specifies forward relations for the page.
  104. Each element in the array is a key-value pair, where the
  105. key designates the relation/link type, and the value is
  106. a pointer to the linked page. An example of a key-value
  107. pair is <code>'alternate' => 'format/plain.html'</code>.
  108. To allow full flexbility, there are no restrictions on
  109. relation values. The value does not have to be a string.
  110. Read more about <code>rel</code> and <code>rev</code> in
  111. <link linkend="zend.view.helpers.initial.navigation.links">the
  112. section on the Links helper.</link>.
  113. </entry>
  114. </row>
  115. <row>
  116. <entry><code>rev</code></entry>
  117. <entry><type>Array</type></entry>
  118. <entry><methodname>array()</methodname></entry>
  119. <entry>
  120. Specifies reverse relations for the page. Works exactly
  121. like <code>rel</code>.
  122. </entry>
  123. </row>
  124. <row>
  125. <entry><code>order</code></entry>
  126. <entry>
  127. <type>String</type> | <code>int</code> | <constant>NULL</constant>
  128. </entry>
  129. <entry><constant>NULL</constant></entry>
  130. <entry>
  131. Works like order for elements in
  132. <link linkend="zend.form.quickstart.render">
  133. <classname>Zend_Form</classname></link>. If specified,
  134. the page will be iterated in a specific order, meaning
  135. you can force a page to be iterated before others by
  136. setting the <code>order</code> attribute to a low number,
  137. e.g. -100. If a <type>String</type> is given, it must
  138. parse to a valid <code>int</code>. If <constant>NULL</constant>
  139. is given, it will be reset, meaning the order in which
  140. the page was added to the container will be used.
  141. </entry>
  142. </row>
  143. <row>
  144. <entry><code>resource</code></entry>
  145. <entry>
  146. <type>String</type> | <classname>Zend_Acl_Resource_Interface</classname>
  147. | <constant>NULL</constant>
  148. </entry>
  149. <entry><constant>NULL</constant></entry>
  150. <entry>
  151. <acronym>ACL</acronym> resource to associate with the page. Read more in
  152. <link linkend="zend.view.helpers.initial.navigation.acl">the
  153. section on <acronym>ACL</acronym> integration in view helpers.</link>.
  154. </entry>
  155. </row>
  156. <row>
  157. <entry><code>privilege</code></entry>
  158. <entry><type>String</type> | <constant>NULL</constant></entry>
  159. <entry><constant>NULL</constant></entry>
  160. <entry>
  161. <acronym>ACL</acronym> privilege to associate with the page. Read more in
  162. <link linkend="zend.view.helpers.initial.navigation.acl">the
  163. section on <acronym>ACL</acronym> integration in view helpers.</link>.
  164. </entry>
  165. </row>
  166. <row>
  167. <entry><code>active</code></entry>
  168. <entry><code>bool</code></entry>
  169. <entry><constant>FALSE</constant></entry>
  170. <entry>
  171. Whether the page should be considered active for the
  172. current request. If active is <constant>FALSE</constant> or not
  173. given, <acronym>MVC</acronym> pages will check its properties against the
  174. request object upon calling <code>$page->isActive()</code>.
  175. </entry>
  176. </row>
  177. <row>
  178. <entry><code>visible</code></entry>
  179. <entry><code>bool</code></entry>
  180. <entry><constant>TRUE</constant></entry>
  181. <entry>
  182. Whether page should be visible for the user, or just
  183. be a part of the structure. Invisible pages are skipped
  184. by view helpers.
  185. </entry>
  186. </row>
  187. <row>
  188. <entry><code>pages</code></entry>
  189. <entry>
  190. <type>Array</type> | <classname>Zend_Config</classname> |
  191. <constant>NULL</constant>
  192. </entry>
  193. <entry><constant>NULL</constant></entry>
  194. <entry>
  195. Child pages of the page. This could be an <type>Array</type>
  196. or <classname>Zend_Config</classname> object containing either page
  197. options that can be passed to the <methodname>factory()</methodname>
  198. method, or actual <classname>Zend_Navigation_Page</classname>
  199. instances, or a mixture of both.
  200. </entry>
  201. </row>
  202. </tbody>
  203. </tgroup>
  204. </table>
  205. <note>
  206. <title>Custom properties</title>
  207. <para>
  208. All pages support setting and getting of custom properties by
  209. use of the magic methods <methodname>__set($name, $value)</methodname>,
  210. <methodname>__get($name)</methodname>, <methodname>__isset($name)</methodname> and
  211. <methodname>__unset($name)</methodname>. Custom properties may have any value,
  212. and will be included in the array that is returned from
  213. <code>$page->toArray()</code>, which means that pages
  214. can be serialized/deserialized successfully even if the pages
  215. contains properties that are not native in the page class.
  216. </para>
  217. <para>
  218. Both native and custom properties can be set using
  219. <code>$page->set($name, $value)</code> and retrieved using
  220. <code>$page->get($name)</code>, or by using magic methods.
  221. </para>
  222. </note>
  223. <example id="zend.navigation.pages.common.example.customprops">
  224. <title>Custom page properties</title>
  225. <para>
  226. This example shows how custom properties can be used.
  227. </para>
  228. <programlisting language="php"><![CDATA[
  229. $page = new Zend_Navigation_Page_Mvc();
  230. $page->foo = 'bar';
  231. $page->meaning = 42;
  232. echo $page->foo;
  233. if ($page->meaning != 42) {
  234. // action should be taken
  235. }
  236. ]]></programlisting>
  237. </example>
  238. </sect2>