|
|
@@ -0,0 +1,116 @@
|
|
|
+<?xml version="1.0" encoding="UTF-8"?>
|
|
|
+<!-- Reviewed: no -->
|
|
|
+<!-- EN-Revision: 17175 -->
|
|
|
+<sect2 id="zend.navigation.pages.factory">
|
|
|
+ <title>ページ・ファクトリを使ってページを作成</title>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ すべてのページ(また、カスタマイズしたクラス)を、
|
|
|
+ ページ・ファクトリ <methodname>Zend_Navigation_Page::factory()</methodname> を用いて
|
|
|
+ 作成できます。
|
|
|
+ ファクトリは任意の配列、
|
|
|
+ または<classname>Zend_Config</classname>オブジェクトをとることができます。
|
|
|
+ <link linkend="zend.navigation.pages">ページ</link>の節でご覧いただけるように、
|
|
|
+ 配列または構成の各々のキーはページ・オプションと一致します。
|
|
|
+ <code>uri</code>が与えられ、<acronym>MVC</acronym>オプション
|
|
|
+ (<code>action, controller, module, route</code>)
|
|
|
+ が与えられないなら、
|
|
|
+ <acronym>URI</acronym>ページが作成されます。
|
|
|
+ <acronym>MVC</acronym>オプションのいずれかが与えられると、
|
|
|
+ <acronym>MVC</acronym>ページが作成されます。
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ <code>type</code>が与えられると、
|
|
|
+ ファクトリは、その値が作成されるべきであるクラスの名前であると仮定します。
|
|
|
+ <!-- TODO -->
|
|
|
+ If the value is
|
|
|
+ <code>mvc</code> or <code>uri</code> and <acronym>MVC</acronym>/URI page will be created.
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <example id="zend.navigation.pages.factory.example.mvc">
|
|
|
+ <title>ページ・ファクトリを使ってMVCページを作成</title>
|
|
|
+
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
+$page = Zend_Navigation_Page::factory(array(
|
|
|
+ 'label' => 'My MVC page',
|
|
|
+ 'action' => 'index'
|
|
|
+));
|
|
|
+
|
|
|
+$page = Zend_Navigation_Page::factory(array(
|
|
|
+ 'label' => 'Search blog',
|
|
|
+ 'action' => 'index',
|
|
|
+ 'controller' => 'search',
|
|
|
+ 'module' => 'blog'
|
|
|
+));
|
|
|
+
|
|
|
+$page = Zend_Navigation_Page::factory(array(
|
|
|
+ 'label' => 'Home',
|
|
|
+ 'action' => 'index',
|
|
|
+ 'controller' => 'index',
|
|
|
+ 'module' => 'index',
|
|
|
+ 'route' => 'home'
|
|
|
+));
|
|
|
+
|
|
|
+$page = Zend_Navigation_Page::factory(array(
|
|
|
+ 'type' => 'mvc',
|
|
|
+ 'label' => 'My MVC page'
|
|
|
+));
|
|
|
+]]></programlisting>
|
|
|
+ </example>
|
|
|
+
|
|
|
+ <example id="zend.navigation.pages.factory.example.uri">
|
|
|
+ <title>ページ・ファクトリを使ってURIページを作成</title>
|
|
|
+
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
+$page = Zend_Navigation_Page::factory(array(
|
|
|
+ 'label' => 'My URI page',
|
|
|
+ 'uri' => 'http://www.example.com/'
|
|
|
+));
|
|
|
+
|
|
|
+$page = Zend_Navigation_Page::factory(array(
|
|
|
+ 'label' => 'Search',
|
|
|
+ 'uri' => 'http://www.example.com/search',
|
|
|
+ 'active' => true
|
|
|
+));
|
|
|
+
|
|
|
+$page = Zend_Navigation_Page::factory(array(
|
|
|
+ 'label' => 'My URI page',
|
|
|
+ 'uri' => '#'
|
|
|
+));
|
|
|
+
|
|
|
+$page = Zend_Navigation_Page::factory(array(
|
|
|
+ 'type' => 'uri',
|
|
|
+ 'label' => 'My URI page'
|
|
|
+));
|
|
|
+]]></programlisting>
|
|
|
+ </example>
|
|
|
+
|
|
|
+ <example id="zend.navigation.pages.factory.example.custom">
|
|
|
+ <title>ページ・ファクトリを使ってカスタムページ型を作成</title>
|
|
|
+
|
|
|
+ <para>
|
|
|
+ ページ・ファクトリを使ってカスタムページ型を作成するには、
|
|
|
+ インスタンス化するクラス名を指定するために、
|
|
|
+ <code>type</code>オプションを使ってください。
|
|
|
+ </para>
|
|
|
+
|
|
|
+ <programlisting language="php"><![CDATA[
|
|
|
+class My_Navigation_Page extends Zend_Navigation_Page
|
|
|
+{
|
|
|
+ protected $_fooBar = 'ok';
|
|
|
+
|
|
|
+ public function setFooBar($fooBar)
|
|
|
+ {
|
|
|
+ $this->_fooBar = $fooBar;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+$page = Zend_Navigation_Page::factory(array(
|
|
|
+ 'type' => 'My_Navigation_Page',
|
|
|
+ 'label' => 'My custom page',
|
|
|
+ 'foo_bar' => 'foo bar'
|
|
|
+));
|
|
|
+]]></programlisting>
|
|
|
+ </example>
|
|
|
+</sect2>
|