Zend_Dojo-View-Helpers.xml 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect2 id="zend.dojo.view.dijit">
  4. <title>Dijit-Specific View Helpers</title>
  5. <para>
  6. From the Dojo manual: "Dijit is a widget system layered on top of
  7. dojo." Dijit includes a variety of layout and form widgets designed to
  8. provide accessibility features, localization, and standardized (and
  9. themeable) look-and-feel.
  10. </para>
  11. <para>
  12. Zend Framework ships a variety of view helpers that allow you to render
  13. and utilize dijits within your view scripts. There are three basic
  14. types:
  15. </para>
  16. <itemizedlist>
  17. <listitem>
  18. <para>
  19. <emphasis>Layout Containers</emphasis>: these are designed to be
  20. used within your view scripts or consumed by form decorators
  21. for forms, sub forms, and display groups. They wrap the various
  22. classes offerred in <command>dijit.layout</command>. Each dijit layout view helper
  23. expects the following arguments:
  24. </para>
  25. <itemizedlist>
  26. <listitem>
  27. <para>
  28. <varname>$id</varname>: the container name or <acronym>DOM</acronym> ID.
  29. </para>
  30. </listitem>
  31. <listitem>
  32. <para>
  33. <varname>$content</varname>: the content to wrap in the
  34. layout container.
  35. </para>
  36. </listitem>
  37. <listitem>
  38. <para>
  39. <varname>$params</varname> (optional): dijit-specific
  40. parameters. Basically, any non-HTML attribute that can
  41. be used to configure the dijit layout container.
  42. </para>
  43. </listitem>
  44. <listitem>
  45. <para>
  46. <varname>$attribs</varname> (optional): any additional
  47. <acronym>HTML</acronym> attributes that should be used to render the
  48. container div. If the key 'id' is passed in this array, it will
  49. be used for the form element <acronym>DOM</acronym> id, and
  50. <varname>$id</varname> will be used for its name.
  51. </para>
  52. </listitem>
  53. </itemizedlist>
  54. <para>
  55. If you pass no arguments to a dijit layout view helper, the
  56. helper itself will be returned. This allows you to capture
  57. content, which is often an easier way to pass content to the
  58. layout container. Examples of this functionality will be shown
  59. later in this section.
  60. </para>
  61. </listitem>
  62. <listitem>
  63. <para>
  64. <emphasis>Form Dijit</emphasis>: the <command>dijit.form.Form</command> dijit, while
  65. not completely necessary for use with dijit form elements, will
  66. ensure that if an attempt is made to submit a form that does
  67. not validate against client-side validations, submission will
  68. be halted and validation error messages raised. The form dijit
  69. view helper expects the following arguments:
  70. </para>
  71. <itemizedlist>
  72. <listitem>
  73. <para>
  74. <varname>$id</varname>: the container name or <acronym>DOM</acronym> ID.
  75. </para>
  76. </listitem>
  77. <listitem>
  78. <para>
  79. <varname>$attribs</varname> (optional): any additional
  80. <acronym>HTML</acronym> attributes that should be used to render the
  81. container div.
  82. </para>
  83. </listitem>
  84. <listitem>
  85. <para>
  86. <varname>$content</varname> (optional): the content to wrap
  87. in the form. If none is passed, an empty string will be
  88. used.
  89. </para>
  90. </listitem>
  91. </itemizedlist>
  92. <para>
  93. The argument order varies from the other dijits in order to
  94. keep compatibility with the standard <methodname>form()</methodname> view
  95. helper.
  96. </para>
  97. </listitem>
  98. <listitem>
  99. <para>
  100. <emphasis>Form Elements</emphasis>: these are designed to be
  101. consumed with <classname>Zend_Form</classname>, but can be used
  102. standalone within view scripts as well. Each dijit element view
  103. helper expects the following arguments:
  104. </para>
  105. <itemizedlist>
  106. <listitem>
  107. <para>
  108. <varname>$id</varname>: the element name or <acronym>DOM</acronym> ID.
  109. </para>
  110. </listitem>
  111. <listitem>
  112. <para>
  113. <varname>$value</varname> (optional): the current value of the element.
  114. </para>
  115. </listitem>
  116. <listitem>
  117. <para>
  118. <varname>$params</varname> (optional): dijit-specific
  119. parameters. Basically, any non-HTML attribute that can
  120. be used to configure a dijit.
  121. </para>
  122. </listitem>
  123. <listitem>
  124. <para>
  125. <varname>$attribs</varname> (optional): any additional
  126. <acronym>HTML</acronym> attributes that should be used to render the dijit.
  127. If the key 'id' is passed in this array, it will be used
  128. for the form element <acronym>DOM</acronym> id, and <varname>$id</varname>
  129. will be used for its name.
  130. </para>
  131. </listitem>
  132. </itemizedlist>
  133. <para>
  134. Some elements require more arguments; these will be noted with
  135. the individual element helper descriptions.
  136. </para>
  137. </listitem>
  138. </itemizedlist>
  139. <para>
  140. In order to utilize these view helpers, you need to register the path
  141. to the dojo view helpers with your view object.
  142. </para>
  143. <example id="zend.dojo.view.dijit.prefixpath">
  144. <title>Registering the Dojo View Helper Prefix Path</title>
  145. <programlisting language="php"><![CDATA[
  146. $view->addHelperPath('Zend/Dojo/View/Helper', 'Zend_Dojo_View_Helper');
  147. ]]></programlisting>
  148. </example>
  149. <sect3 id="zend.dojo.view.dijit.layout">
  150. <title>Dijit Layout Elements</title>
  151. <para>
  152. The <command>dijit.layout</command> family of elements are for creating custom,
  153. predictable layouts for your site. For any questions on general
  154. usage, <ulink
  155. url="http://dojotoolkit.org/reference-guide/dijit/layout.html">read
  156. more about them in the Dojo manual</ulink>.
  157. </para>
  158. <para>
  159. All dijit layout elements have the signature <command>string ($id = null, $content = '',
  160. array $params = array(), array $attribs = array())</command>.
  161. In all caess, if you pass no arguments, the helper object itself will be returned. This
  162. gives you access to the <methodname>captureStart()</methodname> and
  163. <methodname>captureEnd()</methodname> methods, which allow you to capture
  164. content instead of passing it to the layout container.
  165. </para>
  166. <itemizedlist>
  167. <listitem>
  168. <para>
  169. <emphasis>AccordionContainer</emphasis>:
  170. <command>dijit.layout.AccordionContainer</command>. Stack all panes together
  171. vertically; clicking on a pane titlebar will expand and
  172. display that particular pane.
  173. </para>
  174. <programlisting language="php"><![CDATA[
  175. <?php echo $view->accordionContainer(
  176. 'foo',
  177. $content,
  178. array(
  179. 'duration' => 200,
  180. ),
  181. array(
  182. 'style' => 'width: 200px; height: 300px;',
  183. ),
  184. ); ?>
  185. ]]></programlisting>
  186. </listitem>
  187. <listitem>
  188. <para>
  189. <emphasis>AccordionPane</emphasis>:
  190. <command>dijit.layout.AccordionPane</command>. For use within
  191. AccordionContainer.
  192. </para>
  193. <programlisting language="php"><![CDATA[
  194. <?php echo $view->accordionPane(
  195. 'foo',
  196. $content,
  197. array(
  198. 'title' => 'Pane Title',
  199. ),
  200. array(
  201. 'style' => 'background-color: lightgray;',
  202. ),
  203. ); ?>
  204. ]]></programlisting>
  205. </listitem>
  206. <listitem>
  207. <para>
  208. <emphasis>BorderContainer</emphasis>:
  209. <command>dijit.layout.BorderContainer</command>. Achieve layouts with
  210. optionally resizable panes such as you might see in a
  211. traditional application.
  212. </para>
  213. <programlisting language="php"><![CDATA[
  214. <?php echo $view->borderContainer(
  215. 'foo',
  216. $content,
  217. array(
  218. 'design' => 'headline',
  219. ),
  220. array(
  221. 'style' => 'width: 100%; height: 100%',
  222. ),
  223. ); ?>
  224. ]]></programlisting>
  225. </listitem>
  226. <listitem>
  227. <para>
  228. <emphasis>ContentPane</emphasis>: <command>dijit.layout.ContentPane</command>.
  229. Use inside any container except AccordionContainer.
  230. </para>
  231. <programlisting language="php"><![CDATA[
  232. <?php echo $view->contentPane(
  233. 'foo',
  234. $content,
  235. array(
  236. 'title' => 'Pane Title',
  237. 'region' => 'left',
  238. ),
  239. array(
  240. 'style' => 'width: 120px; background-color: lightgray;',
  241. ),
  242. ); ?>
  243. ]]></programlisting>
  244. </listitem>
  245. <listitem>
  246. <para>
  247. <emphasis>SplitContainer</emphasis>:
  248. <command>dijit.layout.SplitContainer</command>. Allows resizable content
  249. panes; deprecated in Dojo in favor of BorderContainer.
  250. </para>
  251. <programlisting language="php"><![CDATA[
  252. <?php echo $view->splitContainer(
  253. 'foo',
  254. $content,
  255. array(
  256. 'orientation' => 'horizontal',
  257. 'sizerWidth' => 7,
  258. 'activeSizing' => true,
  259. ),
  260. array(
  261. 'style' => 'width: 400px; height: 500px;',
  262. ),
  263. ); ?>
  264. ]]></programlisting>
  265. </listitem>
  266. <listitem>
  267. <para>
  268. <emphasis>StackContainer</emphasis>:
  269. <command>dijit.layout.StackContainer</command>. All panes within a
  270. StackContainer are placed in a stack; build buttons or
  271. functionality to reveal one at a time.
  272. </para>
  273. <programlisting language="php"><![CDATA[
  274. <?php echo $view->stackContainer(
  275. 'foo',
  276. $content,
  277. array(),
  278. array(
  279. 'style' => 'width: 400px; height: 500px; border: 1px;',
  280. ),
  281. ); ?>
  282. ]]></programlisting>
  283. </listitem>
  284. <listitem>
  285. <para>
  286. <emphasis>TabContainer</emphasis>:
  287. <command>dijit.layout.TabContainer</command>. All panes within a
  288. TabContainer are placed in a stack, with tabs positioned on
  289. one side for switching between them.
  290. </para>
  291. <programlisting language="php"><![CDATA[
  292. <?php echo $view->tabContainer(
  293. 'foo',
  294. $content,
  295. array(),
  296. array(
  297. 'style' => 'width: 400px; height: 500px; border: 1px;',
  298. ),
  299. ); ?>
  300. ]]></programlisting>
  301. </listitem>
  302. </itemizedlist>
  303. <para>
  304. The following capture methods are available for all layout
  305. containers:
  306. </para>
  307. <itemizedlist>
  308. <listitem>
  309. <para>
  310. <command>captureStart($id, array $params = array(), array $attribs =
  311. array());</command>: begin capturing content to include in a container.
  312. <varname>$params</varname> refers to the dijit params to use with
  313. the container, while <varname>$attribs</varname> refer to any
  314. general <acronym>HTML</acronym> attributes to use.
  315. </para>
  316. <para>
  317. Containers may be nested when capturing, <emphasis>so long
  318. as no ids are duplicated</emphasis>.
  319. </para>
  320. </listitem>
  321. <listitem>
  322. <para>
  323. <methodname>captureEnd($id)</methodname>:
  324. finish capturing content to include in a container.
  325. <varname>$id</varname> should refer to an id previously used with
  326. a <methodname>captureStart()</methodname> call. Returns a string
  327. representing the container and its contents, just as if
  328. you'd simply passed content to the helper itself.
  329. </para>
  330. </listitem>
  331. </itemizedlist>
  332. <example id="zend.dojo.view.dijit.layout.borderexample">
  333. <title>BorderContainer layout dijit example</title>
  334. <para>
  335. BorderContainers, particularly when coupled with the ability to
  336. capture content, are especially useful for achieving complex
  337. layout effects.
  338. </para>
  339. <programlisting language="php"><![CDATA[
  340. $view->borderContainer()->captureStart('masterLayout',
  341. array('design' => 'headline'));
  342. echo $view->contentPane(
  343. 'menuPane',
  344. 'This is the menu pane',
  345. array('region' => 'top'),
  346. array('style' => 'background-color: darkblue;')
  347. );
  348. echo $view->contentPane(
  349. 'navPane',
  350. 'This is the navigation pane',
  351. array('region' => 'left'),
  352. array('style' => 'width: 200px; background-color: lightblue;')
  353. );
  354. echo $view->contentPane(
  355. 'mainPane',
  356. 'This is the main content pane area',
  357. array('region' => 'center'),
  358. array('style' => 'background-color: white;')
  359. );
  360. echo $view->contentPane(
  361. 'statusPane',
  362. 'Status area',
  363. array('region' => 'bottom'),
  364. array('style' => 'background-color: lightgray;')
  365. );
  366. echo $view->borderContainer()->captureEnd('masterLayout');
  367. ]]></programlisting>
  368. </example>
  369. </sect3>
  370. <sect3 id="zend.dojo.view.dijit.form">
  371. <title>Dijit Form Elements</title>
  372. <para>
  373. Dojo's form validation and input dijits are in the <command>dijit.form</command> tree.
  374. For more information on general usage of these elements, as well as
  375. accepted parameters, please <ulink
  376. url="http://dojotoolkit.org/reference-guide/dijit/form.html">visit
  377. the dijit.form documentation</ulink>.
  378. </para>
  379. <para>
  380. The following dijit form elements are available in Zend Framework.
  381. Except where noted, all have the signature <command>string ($id,
  382. $value = '', array $params = array(), array $attribs =
  383. array())</command>.
  384. </para>
  385. <itemizedlist>
  386. <listitem>
  387. <para>
  388. <emphasis>Button</emphasis>: <command>dijit.form.Button</command>. Display a
  389. form button.
  390. </para>
  391. <programlisting language="php"><![CDATA[
  392. <?php echo $view->button(
  393. 'foo',
  394. 'Show Me!',
  395. array('iconClass' => 'myButtons'),
  396. ); ?>
  397. ]]></programlisting>
  398. </listitem>
  399. <listitem>
  400. <para>
  401. <emphasis>CheckBox</emphasis>:
  402. <command>dijit.form.CheckBox</command>. Display a checkbox. Accepts an
  403. optional fifth argument, the array
  404. <varname>$checkedOptions</varname>, which may contain either:
  405. </para>
  406. <itemizedlist>
  407. <listitem>
  408. <para>
  409. an indexed array with two values, a checked value
  410. and unchecked value, in that order; or
  411. </para>
  412. </listitem>
  413. <listitem>
  414. <para>
  415. an associative array with the keys 'checkedValue'
  416. and 'unCheckedValue'.
  417. </para>
  418. </listitem>
  419. </itemizedlist>
  420. <para>
  421. If <varname>$checkedOptions</varname> is not provided, 1 and 0
  422. are assumed.
  423. </para>
  424. <programlisting language="php"><![CDATA[
  425. <?php echo $view->checkBox(
  426. 'foo',
  427. 'bar',
  428. array(),
  429. array(),
  430. array('checkedValue' => 'foo', 'unCheckedValue' => 'bar')
  431. ); ?>
  432. ]]></programlisting>
  433. </listitem>
  434. <listitem>
  435. <para>
  436. <emphasis>ComboBox</emphasis>:
  437. <command>dijit.layout.ComboBox</command>. ComboBoxes are a hybrid between a
  438. select and a text box with autocompletion. The key
  439. difference is that you may type an option that is not in
  440. the list of available options, and it will still consider
  441. it valid input. It accepts an optional fifth argument, an
  442. associative array <varname>$options</varname>; if provided,
  443. ComboBox will be rendered as a <emphasis>select</emphasis>. Note
  444. also that the <emphasis>label values</emphasis> of the
  445. <varname>$options</varname> array will be returned in the form --
  446. not the values themselves.
  447. </para>
  448. <para>
  449. Alternately, you may pass information regarding a <command>dojo.data</command>
  450. datastore to use with the element. If provided, the
  451. ComboBox will be rendered as a text <emphasis>input</emphasis>, and
  452. will pull its options via that datastore.
  453. </para>
  454. <para>
  455. To specify a datastore, provide one of the following
  456. <varname>$params</varname> key combinations:
  457. </para>
  458. <itemizedlist>
  459. <listitem>
  460. <para>
  461. The key 'store', with an array value; the array
  462. should contain the keys:
  463. </para>
  464. <itemizedlist>
  465. <listitem>
  466. <para>
  467. <emphasis>store</emphasis>: the name of the
  468. javascript variable representing the datastore
  469. (this could be the name you would like for it
  470. to use).
  471. </para>
  472. </listitem>
  473. <listitem>
  474. <para>
  475. <emphasis>type</emphasis>: the datastore type
  476. to use; e.g., '<command>dojo.data.ItemFileReadStore</command>'.
  477. </para>
  478. </listitem>
  479. <listitem>
  480. <para>
  481. <emphasis>params</emphasis> (optional): an
  482. associative array of key and value pairs to use to
  483. configure the datastore. The 'url' param is a
  484. typical example.
  485. </para>
  486. </listitem>
  487. </itemizedlist>
  488. </listitem>
  489. <listitem>
  490. <para>
  491. The keys:
  492. </para>
  493. <itemizedlist>
  494. <listitem>
  495. <para>
  496. <emphasis>store</emphasis>: a string indicating
  497. the datastore name to use.
  498. </para>
  499. </listitem>
  500. <listitem>
  501. <para>
  502. <emphasis>storeType</emphasis>: a string indicating
  503. the datastore <command>dojo.data</command> type to use (e.g.,
  504. '<command>dojo.data.ItemFileReadStore</command>').
  505. </para>
  506. </listitem>
  507. <listitem>
  508. <para>
  509. <emphasis>storeParams</emphasis>: an
  510. associative array of key and value pairs with which
  511. to configure the datastore.
  512. </para>
  513. </listitem>
  514. </itemizedlist>
  515. </listitem>
  516. </itemizedlist>
  517. <programlisting language="php"><![CDATA[
  518. // As a select element:
  519. echo $view->comboBox(
  520. 'foo',
  521. 'bar',
  522. array(
  523. 'autocomplete' => false,
  524. ),
  525. array(),
  526. array(
  527. 'foo' => 'Foo',
  528. 'bar' => 'Bar',
  529. 'baz' => 'Baz',
  530. )
  531. );
  532. // As a dojo.data-enabled element:
  533. echo $view->comboBox(
  534. 'foo',
  535. 'bar',
  536. array(
  537. 'autocomplete' => false,
  538. 'store' => 'stateStore',
  539. 'storeType' => 'dojo.data.ItemFileReadStore',
  540. 'storeParams' => array('url' => '/js/states.json'),
  541. ),
  542. );
  543. ]]></programlisting>
  544. </listitem>
  545. <listitem>
  546. <para>
  547. <emphasis>CurrencyTextBox</emphasis>:
  548. <command>dijit.form.CurrencyTextBox</command>. Inherits from
  549. ValidationTextBox, and provides client-side validation of
  550. currency. It expects that the dijit parameter 'currency'
  551. will be provided with an appropriate 3-character currency
  552. code. You may also specify any dijit parameters valid for
  553. ValidationTextBox and TextBox.
  554. </para>
  555. <programlisting language="php"><![CDATA[
  556. echo $view->currencyTextBox(
  557. 'foo',
  558. '$25.00',
  559. array('currency' => 'USD'),
  560. array('maxlength' => 20)
  561. );
  562. ]]></programlisting>
  563. <note>
  564. <title>Issues with Builds</title>
  565. <para>
  566. There are currently <ulink
  567. url="http://trac.dojotoolkit.org/ticket/7183">known
  568. issues with using CurrencyTextBox with build
  569. layers</ulink>. A known work-around is to ensure that
  570. your document's Content-Type http-equiv meta tag sets the
  571. character set to utf-8, which you can do by calling:
  572. </para>
  573. <programlisting language="php"><![CDATA[
  574. $view->headMeta()->appendHttpEquiv('Content-Type',
  575. 'text/html; charset=utf-8');
  576. ]]></programlisting>
  577. <para>
  578. This will mean, of course, that you will need to ensure
  579. that the <methodname>headMeta()</methodname> placeholder is echoed
  580. in your layout script.
  581. </para>
  582. </note>
  583. </listitem>
  584. <listitem>
  585. <para>
  586. <emphasis>DateTextBox</emphasis>:
  587. <command>dijit.form.DateTextBox</command>. Inherits from
  588. ValidationTextBox, and provides both client-side validation of
  589. dates, as well as a dropdown calendar from which to select a date.
  590. You may specify any dijit parameters available to
  591. ValidationTextBox or TextBox.
  592. </para>
  593. <programlisting language="php"><![CDATA[
  594. echo $view->dateTextBox(
  595. 'foo',
  596. '2008-07-11',
  597. array('required' => true)
  598. );
  599. ]]></programlisting>
  600. </listitem>
  601. <listitem>
  602. <para>
  603. <emphasis>Editor</emphasis>: <command>dijit.Editor</command>. Provides a
  604. <acronym>WYSIWYG</acronym> editor via which users may create or edit content.
  605. <command>dijit.Editor</command> is a pluggable, extensible editor
  606. with a variety of parameters you can utilize for customization; see <ulink
  607. url="http://dojotoolkit.org/reference-guide/dijit/Editor.html">the
  608. dijit.Editor documentation</ulink> for more details.
  609. </para>
  610. <programlisting language="php"><![CDATA[
  611. echo $view->editor('foo');
  612. ]]></programlisting>
  613. <note>
  614. <title>Editor Dijit uses div by default</title>
  615. <para>
  616. The Editor dijit uses an <acronym>HTML</acronym> <acronym>DIV</acronym> by
  617. default. The <command>dijit._editor.RichText</command> <ulink
  618. url="http://api.dojotoolkit.org/jsdoc/HEAD/dijit._editor.RichText">documentation</ulink>
  619. indicates that having it built on an <acronym>HTML</acronym>
  620. <acronym>TEXTAREA</acronym> can potentially have security implications.
  621. </para>
  622. <para>
  623. In order to allow graceful degradation in environments where Javascript is
  624. unavailable, <classname>Zend_Dojo_View_Helper_Editor</classname> also wraps
  625. a <acronym>TEXTAREA</acronym> within a <acronym>NOSCRIPT</acronym> tag;
  626. the content of this <acronym>TEXTAREA</acronym> will be properly escaped to
  627. avoid security vulnerability vectors.
  628. </para>
  629. </note>
  630. </listitem>
  631. <listitem>
  632. <para>
  633. <emphasis>FilteringSelect</emphasis>:
  634. <command>dijit.form.FilteringSelect</command>. Similar to ComboBox, this is a
  635. select and text hybrid that can either render a provided list
  636. of options or those fetched via a <command>dojo.data</command> datastore.
  637. Unlike ComboBox, however, FilteringSelect does not allow
  638. typing in an option not in its list. Additionally, it
  639. operates like a standard select in that the option values,
  640. not the labels, are returned when the form is submitted.
  641. </para>
  642. <para>
  643. Please see the information above on ComboBox for examples
  644. and available options for defining datastores.
  645. </para>
  646. </listitem>
  647. <listitem>
  648. <para>
  649. <emphasis>HorizontalSlider</emphasis> and
  650. <emphasis>VerticalSlider</emphasis>:
  651. <command>dijit.form.HorizontalSlider</command> and
  652. <command>dijit.form.VerticalSlider</command>. Sliders allow are UI widgets for
  653. selecting numbers in a given range; these are horizontal and vertical variants.
  654. </para>
  655. <para>
  656. At their most basic, they require the dijit parameters
  657. 'minimum', 'maximum', and 'discreteValues'. These define
  658. the range of values. Other common options are:
  659. </para>
  660. <itemizedlist>
  661. <listitem>
  662. <para>
  663. 'intermediateChanges' can be set to indicate whether or not
  664. to fire onChange events while the handle is being dragged.
  665. </para>
  666. </listitem>
  667. <listitem>
  668. <para>
  669. 'clickSelect' can be set to allow clicking a location
  670. on the slider to set the value.
  671. </para>
  672. </listitem>
  673. <listitem>
  674. <para>
  675. 'pageIncrement' can specify the value by which to
  676. increase or decrease when pageUp and pageDown are used.
  677. </para>
  678. </listitem>
  679. <listitem>
  680. <para>
  681. 'showButtons' can be set to allow displaying buttons on
  682. either end of the slider for manipulating the value.
  683. </para>
  684. </listitem>
  685. </itemizedlist>
  686. <para>
  687. The implication from Zend Framework creates a hidden element
  688. to store the value of the slider.
  689. </para>
  690. <para>
  691. You may optionally desire to show a rule or labels for the
  692. slider. To do so, you will assign one or more of the dijit
  693. params 'topDecoration' and/or 'bottomDecoration'
  694. (HorizontalSlider) or 'leftDecoration' and/or
  695. 'rightDecoration' (VerticalSlider). Each of these expects
  696. the following options:
  697. </para>
  698. <itemizedlist>
  699. <listitem>
  700. <para>
  701. <emphasis>container</emphasis>: name of the container.
  702. </para>
  703. </listitem>
  704. <listitem>
  705. <para>
  706. <emphasis>labels</emphasis> (optional): an array of
  707. labels to utilize. Use empty strings on either end to
  708. provide labels for inner values only. Required when
  709. specifying one of the 'Labels' dijit variants.
  710. </para>
  711. </listitem>
  712. <listitem>
  713. <para>
  714. <emphasis>dijit</emphasis> (optional): one of
  715. HorizontalRule, HorizontalRuleLabels, VerticalRule, or
  716. VerticalRuleLabels, Defaults to one of the Rule dijits.
  717. </para>
  718. </listitem>
  719. <listitem>
  720. <para>
  721. <emphasis>params</emphasis> (optional): dijit params
  722. for configuring the Rule dijit in use. Parameters
  723. specific to these dijits include:
  724. </para>
  725. <itemizedlist>
  726. <listitem>
  727. <para>
  728. <emphasis>container</emphasis> (optional):
  729. array of parameters and attributes for the rule
  730. container.
  731. </para>
  732. </listitem>
  733. <listitem>
  734. <para>
  735. <emphasis>labels</emphasis> (optional):
  736. array of parameters and attributes for the
  737. labels list container.
  738. </para>
  739. </listitem>
  740. </itemizedlist>
  741. </listitem>
  742. <listitem>
  743. <para>
  744. <emphasis>attribs</emphasis> (optional): <acronym>HTML</acronym>
  745. attributes to use with the rules and labels. This should
  746. follow the <property>params</property> option format and be an
  747. associative array with the keys 'container' and
  748. 'labels'.
  749. </para>
  750. </listitem>
  751. </itemizedlist>
  752. <programlisting language="php"><![CDATA[
  753. echo $view->horizontalSlider(
  754. 'foo',
  755. 1,
  756. array(
  757. 'minimum' => -10,
  758. 'maximum' => 10,
  759. 'discreteValues' => 11,
  760. 'intermediateChanges' => true,
  761. 'showButtons' => true,
  762. 'topDecoration' => array(
  763. 'container' => 'topContainer'
  764. 'dijit' => 'HorizontalRuleLabels',
  765. 'labels' => array(
  766. ' ',
  767. '20%',
  768. '40%',
  769. '60%',
  770. '80%',
  771. ' ',
  772. ),
  773. 'params' => array(
  774. 'container' => array(
  775. 'style' => 'height:1.2em; font-size=75%;color:gray;',
  776. ),
  777. 'labels' => array(
  778. 'style' => 'height:1em; font-size=75%;color:gray;',
  779. ),
  780. ),
  781. ),
  782. 'bottomDecoration' => array(
  783. 'container' => 'bottomContainer'
  784. 'labels' => array(
  785. '0%',
  786. '50%',
  787. '100%',
  788. ),
  789. 'params' => array(
  790. 'container' => array(
  791. 'style' => 'height:1.2em; font-size=75%;color:gray;',
  792. ),
  793. 'labels' => array(
  794. 'style' => 'height:1em; font-size=75%;color:gray;',
  795. ),
  796. ),
  797. ),
  798. )
  799. );
  800. ]]></programlisting>
  801. </listitem>
  802. <listitem>
  803. <para>
  804. <emphasis>NumberSpinner</emphasis>:
  805. <command>dijit.form.NumberSpinner</command>. Text box for numeric entry, with
  806. buttons for incrementing and decrementing.
  807. </para>
  808. <para>
  809. Expects either an associative array for the dijit parameter
  810. 'constraints', or simply the keys 'min', 'max', and
  811. 'places' (these would be the expected entries of the
  812. constraints parameter as well). 'places' can be used to
  813. indicate how much the number spinner will increment and
  814. decrement.
  815. </para>
  816. <programlisting language="php"><![CDATA[
  817. echo $view->numberSpinner(
  818. 'foo',
  819. 5,
  820. array(
  821. 'min' => -10,
  822. 'max' => 10,
  823. 'places' => 2,
  824. ),
  825. array(
  826. 'maxlenth' => 3,
  827. )
  828. );
  829. ]]></programlisting>
  830. </listitem>
  831. <listitem>
  832. <para>
  833. <emphasis>NumberTextBox</emphasis>:
  834. <command>dijit.form.NumberTextBox</command>. NumberTextBox provides the
  835. ability to format and display number entries in a localized
  836. fashion, as well as validate numerical entries, optionally
  837. against given constraints.
  838. </para>
  839. <programlisting language="php"><![CDATA[
  840. echo $view->numberTextBox(
  841. 'foo',
  842. 5,
  843. array(
  844. 'places' => 4,
  845. 'type' => 'percent',
  846. ),
  847. array(
  848. 'maxlength' => 20,
  849. )
  850. );
  851. ]]></programlisting>
  852. </listitem>
  853. <listitem>
  854. <para>
  855. <emphasis>PasswordTextBox</emphasis>:
  856. <command>dijit.form.ValidationTextBox</command> tied to a password input.
  857. PasswordTextBox provides the
  858. ability to create password input that adheres to the current
  859. dijit theme, as well as allow for client-side validation.
  860. </para>
  861. <programlisting language="php"><![CDATA[
  862. echo $view->passwordTextBox(
  863. 'foo',
  864. '',
  865. array(
  866. 'required' => true,
  867. ),
  868. array(
  869. 'maxlength' => 20,
  870. )
  871. );
  872. ]]></programlisting>
  873. </listitem>
  874. <listitem>
  875. <para>
  876. <emphasis>RadioButton</emphasis>: <command>dijit.form.RadioButton</command>. A
  877. set of options from which only one may be selected. This
  878. behaves in every way like a regular radio, but has a
  879. look-and-feel consistent with other dijits.
  880. </para>
  881. <para>
  882. RadioButton accepts an optional fifth argument,
  883. <varname>$options</varname>, an associative array of value and label
  884. pairs used as the radio options. You may also pass these as
  885. the <varname>$attribs</varname> key <property>options</property>.
  886. </para>
  887. <programlisting language="php"><![CDATA[
  888. echo $view->radioButton(
  889. 'foo',
  890. 'bar',
  891. array(),
  892. array(),
  893. array(
  894. 'foo' => 'Foo',
  895. 'bar' => 'Bar',
  896. 'baz' => 'Baz',
  897. )
  898. );
  899. ]]></programlisting>
  900. </listitem>
  901. <listitem>
  902. <para>
  903. <emphasis>SimpleTextarea</emphasis>:
  904. <command>dijit.form.SimpleTextarea</command>. These act like normal textareas,
  905. but are styled using the current dijit theme. You do not need to specify either
  906. the rows or columns attributes; use <property>ems</property> or
  907. percentages for the width and height, instead.
  908. </para>
  909. <programlisting language="php"><![CDATA[
  910. echo $view->simpleTextarea(
  911. 'foo',
  912. 'Start writing here...',
  913. array(),
  914. array('style' => 'width: 90%; height: 5ems;')
  915. );
  916. ]]></programlisting>
  917. </listitem>
  918. <listitem>
  919. <para>
  920. <emphasis>SubmitButton</emphasis>: a <command>dijit.form.Button</command> tied
  921. to a submit input element. See the Button view helper for
  922. more details; the key difference is that this button can
  923. submit a form.
  924. </para>
  925. </listitem>
  926. <listitem>
  927. <para>
  928. <emphasis>Textarea</emphasis>: <command>dijit.form.Textarea</command>. These
  929. act like normal textareas, except that instead of having a
  930. set number of rows, they expand as the user types. The
  931. width should be specified via a style setting.
  932. </para>
  933. <programlisting language="php"><![CDATA[
  934. echo $view->textarea(
  935. 'foo',
  936. 'Start writing here...',
  937. array(),
  938. array('style' => 'width: 300px;')
  939. );
  940. ]]></programlisting>
  941. </listitem>
  942. <listitem>
  943. <para>
  944. <emphasis>TextBox</emphasis>: <command>dijit.form.TextBox</command>. This
  945. element is primarily present to provide a common
  946. look-and-feel between various dijit elements, and to
  947. provide base functionality for the other TextBox-derived
  948. classes (ValidationTextBox, NumberTextBox, CurrencyTextBox,
  949. DateTextBox, and TimeTextBox).
  950. </para>
  951. <para>
  952. Common dijit parameter flags include 'lowercase' (cast to
  953. lowercase), 'uppercase' (cast to <acronym>UPPERCASE</acronym>), 'propercase'
  954. (cast to Proper Case), and trim (trim leading and trailing
  955. whitespace); all accept boolean values. Additionally, you
  956. may specifiy the parameters 'size' and 'maxLength'.
  957. </para>
  958. <programlisting language="php"><![CDATA[
  959. echo $view->textBox(
  960. 'foo',
  961. 'some text',
  962. array(
  963. 'trim' => true,
  964. 'propercase' => true,
  965. 'maxLength' => 20,
  966. ),
  967. array(
  968. 'size' => 20,
  969. )
  970. );
  971. ]]></programlisting>
  972. </listitem>
  973. <listitem>
  974. <para>
  975. <emphasis>TimeTextBox</emphasis>: <command>dijit.form.TimeTextBox</command>.
  976. Also in the TextBox family, TimeTextBox provides a
  977. scrollable drop down selection of times from which a user
  978. may select. Dijit parameters allow you to specify the time
  979. increments available in the select as well as the visible
  980. range of times available.
  981. </para>
  982. <programlisting language="php"><![CDATA[
  983. echo $view->timeTextBox(
  984. 'foo',
  985. '',
  986. array(
  987. 'am.pm' => true,
  988. 'visibleIncrement' => 'T00:05:00', // 5-minute increments
  989. 'visibleRange' => 'T02:00:00', // show 2 hours of increments
  990. ),
  991. array(
  992. 'size' => 20,
  993. )
  994. );
  995. ]]></programlisting>
  996. </listitem>
  997. <listitem>
  998. <para>
  999. <emphasis>ValidationTextBox</emphasis>:
  1000. <command>dijit.form.ValidateTextBox</command>. Provide client-side validations
  1001. for a text element. Inherits from TextBox.
  1002. </para>
  1003. <para>
  1004. Common dijit parameters include:
  1005. </para>
  1006. <itemizedlist>
  1007. <listitem>
  1008. <para>
  1009. <emphasis>invalidMessage</emphasis>: a message to
  1010. display when an invalid entry is detected.
  1011. </para>
  1012. </listitem>
  1013. <listitem>
  1014. <para>
  1015. <emphasis>promptMessage</emphasis>: a tooltip help
  1016. message to use.
  1017. </para>
  1018. </listitem>
  1019. <listitem>
  1020. <para>
  1021. <emphasis>regExp</emphasis>: a regular expression to
  1022. use to validate the text. Regular expression does not
  1023. require boundary markers.
  1024. </para>
  1025. </listitem>
  1026. <listitem>
  1027. <para>
  1028. <emphasis>required</emphasis>: whether or not the
  1029. element is required. If so, and the element is embedded
  1030. in a <command>dijit.form.Form</command>, it will be flagged as invalid
  1031. and prevent submission.
  1032. </para>
  1033. </listitem>
  1034. </itemizedlist>
  1035. <programlisting language="php"><![CDATA[
  1036. echo $view->validationTextBox(
  1037. 'foo',
  1038. '',
  1039. array(
  1040. 'required' => true,
  1041. 'regExp' => '[\w]+',
  1042. 'invalidMessage' => 'No spaces or non-word characters allowed',
  1043. 'promptMessage' => 'Single word consisting of alphanumeric ' .
  1044. 'characters and underscores only',
  1045. ),
  1046. array(
  1047. 'maxlength' => 20,
  1048. )
  1049. );
  1050. ]]></programlisting>
  1051. </listitem>
  1052. </itemizedlist>
  1053. </sect3>
  1054. <sect3 id="zend.dojo.view.dijit.custom">
  1055. <title>Custom Dijits</title>
  1056. <para>
  1057. If you delve into Dojo much at all, you'll find yourself writing
  1058. custom dijits, or using experimental dijits from Dojox. While Zend
  1059. Framework cannot support every dijit directly, it does provide some
  1060. rudimentary support for arbitrary dijit types via the
  1061. <classname>CustomDijit</classname> view helper.
  1062. </para>
  1063. <para>
  1064. The <classname>CustomDijit</classname> view helper's <acronym>API</acronym> is exactly
  1065. that of any other dijit, with one major difference: the third "params"
  1066. argument <emphasis>must</emphasis> contain the attribute "dojotype".
  1067. The value of this attribute should be the Dijit class you plan to
  1068. use.
  1069. </para>
  1070. <para>
  1071. <classname>CustomDijit</classname> extends the base
  1072. <classname>DijitContainer</classname> view helper, which also allows it to
  1073. capture content (using the
  1074. <methodname>captureStart()</methodname>/<methodname>captureEnd()</methodname> pair of
  1075. methods). <methodname>captureStart()</methodname> also expects that you pass the
  1076. "dojoType" attribute to its "params" argument.
  1077. </para>
  1078. <example id="zend.dojo.view.dijit.custom.example">
  1079. <title>Using CustomDijit to render a dojox.layout.ContentPane</title>
  1080. <para>
  1081. <command>dojox.layout.ContentPane</command> is a next-generation
  1082. iteration of <command>dijit.layout.ContentPane</command>, and provides
  1083. a superset of that class's capabilities. Until it's
  1084. functionality stabilizes, it will continue to live in Dojox.
  1085. However, if you want to use it in Zend Framework today, you can,
  1086. using the <classname>CustomDijit</classname> view helper.
  1087. </para>
  1088. <para>
  1089. At its most basic, you can do the following:
  1090. </para>
  1091. <programlisting language="php"><![CDATA[
  1092. <?php echo $this->customDijit(
  1093. 'foo',
  1094. $content,
  1095. array(
  1096. 'dojoType' => 'dojox.layout.ContentPane',
  1097. 'title' => 'Custom pane',
  1098. 'region' => 'center'
  1099. )
  1100. ); ?>
  1101. ]]></programlisting>
  1102. <para>
  1103. If you wanted to capture content instead, simply use the
  1104. <methodname>captureStart()</methodname> method, and pass the "dojoType" to
  1105. the "params" argument:
  1106. </para>
  1107. <programlisting language="php"><![CDATA[
  1108. <?php $this->customDijit()->captureStart(
  1109. 'foo',
  1110. array(
  1111. 'dojoType' => 'dojox.layout.ContentPane',
  1112. 'title' => 'Custom pane',
  1113. 'region' => 'center'
  1114. )
  1115. ); ?>
  1116. This is the content of the pane
  1117. <?php echo $this->customDijit()->captureEnd('foo'); ?>
  1118. ]]></programlisting>
  1119. <para>
  1120. You can also extend <classname>CustomDijit</classname> easily to create
  1121. support for your own custom dijits. As an example, if you
  1122. extended <command>dijit.layout.ContentPane</command> to create your
  1123. own <command>foo.ContentPane</command> class, you could create the
  1124. following helper to support it:
  1125. </para>
  1126. <programlisting language="php"><![CDATA[
  1127. class My_View_Helper_FooContentPane
  1128. extends Zend_Dojo_View_Helper_CustomDijit
  1129. {
  1130. protected $_defaultDojoType = 'foo.ContentPane';
  1131. public function fooContentPane(
  1132. $id = null, $value = null,
  1133. array $params = array(), array $attribs = array()
  1134. ) {
  1135. return $this->customDijit($id, $value, $params, $attribs);
  1136. }
  1137. }
  1138. ]]></programlisting>
  1139. <para>
  1140. As long as your custom dijit follows the same basic <acronym>API</acronym> as
  1141. official dijits, using or extending <classname>CustomDijit</classname>
  1142. should work correctly.
  1143. </para>
  1144. </example>
  1145. </sect3>
  1146. </sect2>
  1147. <!--
  1148. vim:se ts=4 sw=4 et:
  1149. -->