|
@@ -794,33 +794,45 @@ $container = new Zend_Navigation();
|
|
|
|
|
|
|
|
// add page by giving a page instance
|
|
// add page by giving a page instance
|
|
|
$container->addPage(Zend_Navigation_Page::factory(array(
|
|
$container->addPage(Zend_Navigation_Page::factory(array(
|
|
|
- 'uri' => 'http://www.example.com/'
|
|
|
|
|
-)))
|
|
|
|
|
|
|
+ 'uri' => 'http://www.example.com/',
|
|
|
|
|
+)));
|
|
|
|
|
|
|
|
// add page by giving an array
|
|
// add page by giving an array
|
|
|
$container->addPage(array(
|
|
$container->addPage(array(
|
|
|
- 'uri' => 'http://www.example.com/'
|
|
|
|
|
-)))
|
|
|
|
|
|
|
+ 'uri' => 'http://www.example.com/',
|
|
|
|
|
+));
|
|
|
|
|
|
|
|
// add page by giving a config object
|
|
// add page by giving a config object
|
|
|
$container->addPage(new Zend_Config(array(
|
|
$container->addPage(new Zend_Config(array(
|
|
|
- 'uri' => 'http://www.example.com/'
|
|
|
|
|
-)))
|
|
|
|
|
|
|
+ 'uri' => 'http://www.example.com/',
|
|
|
|
|
+)));
|
|
|
|
|
|
|
|
$pages = array(
|
|
$pages = array(
|
|
|
array(
|
|
array(
|
|
|
- 'label' => 'Save'
|
|
|
|
|
|
|
+ 'label' => 'Save',
|
|
|
'action' => 'save',
|
|
'action' => 'save',
|
|
|
),
|
|
),
|
|
|
array(
|
|
array(
|
|
|
- 'label' => 'Delete',
|
|
|
|
|
- 'action' => 'delete'
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ 'label' => 'Delete',
|
|
|
|
|
+ 'action' => 'delete',
|
|
|
|
|
+ ),
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
// add two pages
|
|
// add two pages
|
|
|
$container->addPages($pages);
|
|
$container->addPages($pages);
|
|
|
|
|
|
|
|
|
|
+// add container
|
|
|
|
|
+$container->addPages(new Zend_Navigation(array(
|
|
|
|
|
+ array(
|
|
|
|
|
+ 'label' => 'Move up',
|
|
|
|
|
+ 'action' => 'up',
|
|
|
|
|
+ ),
|
|
|
|
|
+ array(
|
|
|
|
|
+ 'label' => 'Move down',
|
|
|
|
|
+ 'action' => 'down',
|
|
|
|
|
+ ),
|
|
|
|
|
+)));
|
|
|
|
|
+
|
|
|
// remove existing pages and add the given pages
|
|
// remove existing pages and add the given pages
|
|
|
$container->setPages($pages);
|
|
$container->setPages($pages);
|
|
|
]]></programlisting>
|
|
]]></programlisting>
|
|
@@ -879,11 +891,13 @@ $container->removePages(); // removes all pages
|
|
|
|
|
|
|
|
<para>
|
|
<para>
|
|
|
Containers have finder methods for retrieving pages.
|
|
Containers have finder methods for retrieving pages.
|
|
|
- They are <methodname>findOneBy($property, $value)</methodname>,
|
|
|
|
|
- <methodname>findAllBy($property, $value)</methodname>, and
|
|
|
|
|
- <methodname>findBy($property, $value, $all = false)</methodname>.
|
|
|
|
|
|
|
+ They are <methodname>findOneBy($property, $value, $useRegex = false)</methodname>,
|
|
|
|
|
+ <methodname>findAllBy($property, $value, $useRegex = false)</methodname>, and
|
|
|
|
|
+ <methodname>findBy($property, $value, $all = false, $useRegex = false)</methodname>.
|
|
|
Those methods will recursively search the container for
|
|
Those methods will recursively search the container for
|
|
|
- pages matching the given <command>$page->$property == $value</command>.
|
|
|
|
|
|
|
+ pages matching the given <command>$page->$property == $value</command>
|
|
|
|
|
+ or when regular expressions are used:
|
|
|
|
|
+ <command>preg_match($value, $page->$property)</command>.
|
|
|
The first method, <methodname>findOneBy()</methodname>, will return a
|
|
The first method, <methodname>findOneBy()</methodname>, will return a
|
|
|
single page matching the property with the given value, or
|
|
single page matching the property with the given value, or
|
|
|
<constant>NULL</constant> if it cannot be found. The second method will return
|
|
<constant>NULL</constant> if it cannot be found. The second method will return
|
|
@@ -951,24 +965,19 @@ $container = new Zend_Navigation(array(
|
|
|
// The 'id' is not required to be unique, but be aware that
|
|
// The 'id' is not required to be unique, but be aware that
|
|
|
// having two pages with the same id will render the same id attribute
|
|
// having two pages with the same id will render the same id attribute
|
|
|
// in menus and breadcrumbs.
|
|
// in menus and breadcrumbs.
|
|
|
-$found = $container->findBy('id',
|
|
|
|
|
- 'page_2_and_3'); // returns Page 2
|
|
|
|
|
-$found = $container->findOneBy('id',
|
|
|
|
|
- 'page_2_and_3'); // returns Page 2
|
|
|
|
|
-$found = $container->findBy('id',
|
|
|
|
|
- 'page_2_and_3',
|
|
|
|
|
- true); // returns Page 2 and Page 3
|
|
|
|
|
-$found = $container->findById('page_2_and_3'); // returns Page 2
|
|
|
|
|
|
|
+$found = $container->findBy('id', 'page_2_and_3'); // returns Page 2
|
|
|
|
|
+$found = $container->findOneBy('id', 'page_2_and_3'); // returns Page 2
|
|
|
|
|
+$found = $container->findBy('id', 'page_2_and_3', true); // returns Page 2 and Page 3
|
|
|
|
|
+$found = $container->findById('page_2_and_3'); // returns Page 2
|
|
|
$found = $container->findOneById('page_2_and_3'); // returns Page 2
|
|
$found = $container->findOneById('page_2_and_3'); // returns Page 2
|
|
|
$found = $container->findAllById('page_2_and_3'); // returns Page 2 and Page 3
|
|
$found = $container->findAllById('page_2_and_3'); // returns Page 2 and Page 3
|
|
|
|
|
|
|
|
// Find all matching CSS class my-class
|
|
// Find all matching CSS class my-class
|
|
|
-$found = $container->findAllBy('class',
|
|
|
|
|
- 'my-class'); // returns Page 1.2 and Page 2
|
|
|
|
|
|
|
+$found = $container->findAllBy('class', 'my-class'); // returns Page 1.2 and Page 2
|
|
|
$found = $container->findAllByClass('my-class'); // returns Page 1.2 and Page 2
|
|
$found = $container->findAllByClass('my-class'); // returns Page 1.2 and Page 2
|
|
|
|
|
|
|
|
// Find first matching CSS class my-class
|
|
// Find first matching CSS class my-class
|
|
|
-$found = $container->findOneByClass('my-class'); // returns Page 1.2
|
|
|
|
|
|
|
+$found = $container->findOneByClass('my-class'); // returns Page 1.2
|
|
|
|
|
|
|
|
// Find all matching CSS class non-existant
|
|
// Find all matching CSS class non-existant
|
|
|
$found = $container->findAllByClass('non-existant'); // returns array()
|
|
$found = $container->findAllByClass('non-existant'); // returns array()
|
|
@@ -987,6 +996,19 @@ $found = $container->findAllByfoo('bar');
|
|
|
// Find all with controller = 'index'
|
|
// Find all with controller = 'index'
|
|
|
$found = $container->findAllByController('index'); // returns Page 2 and Page 3
|
|
$found = $container->findAllByController('index'); // returns Page 2 and Page 3
|
|
|
]]></programlisting>
|
|
]]></programlisting>
|
|
|
|
|
+
|
|
|
|
|
+ <para>
|
|
|
|
|
+ Use regular expressions to find pages:
|
|
|
|
|
+ </para>
|
|
|
|
|
+
|
|
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
|
|
+$found = $container->findBy('class','/my/', false, true); // returns Page 1.2
|
|
|
|
|
+$found = $container->findOneBy('class', '/my/', true); // returns Page 1.2
|
|
|
|
|
+$found = $container->findBy('class', '/my/', true, true); // returns Page 1.2 and Page 2
|
|
|
|
|
+$found = $container->findAllBy('class', '/my/', true); // returns Page 1.2 and Page 2
|
|
|
|
|
+$found = $container->findOneByClass('/my/', true); // returns Page 1.2
|
|
|
|
|
+$found = $container->findAllByClass('/my/', true); // returns Page 1.2 and Page 2
|
|
|
|
|
+]]></programlisting>
|
|
|
</example>
|
|
</example>
|
|
|
</sect2>
|
|
</sect2>
|
|
|
|
|
|