Zend_View-Helpers-UserAgent.xml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect3 id="zend.view.helpers.initial.user-agent">
  4. <title>UserAgent View Helper</title>
  5. <sect4 id="zend.view.helpers.initial.user-agent.intro">
  6. <title>Overview</title>
  7. <para>
  8. This view helper provides the ability to inject and later retrieve a
  9. <classname>Zend_Http_UserAgent</classname> instance for use in branching display logic
  10. based on device capabilities.
  11. </para>
  12. </sect4>
  13. <sect4 id="zend.view.helpers.initial.user-agent.quick-start">
  14. <title>Quick Start</title>
  15. <para>
  16. In most cases, you can simply retrieve the User-Agent and related device by calling the
  17. helper. If the <classname>UserAgent</classname> was configured in the <link
  18. linkend="zend.application.application.available-resources.useragent">
  19. bootstrap</link>, that instance will be injected already in the helper; otherwise, it
  20. will instantiate one for you.
  21. </para>
  22. <programlisting language="php"><![CDATA[
  23. <?php if ($this->userAgent()->getDevice()->hasFlash()): ?>
  24. <object ...></object>
  25. <?php endif ?>
  26. ]]></programlisting>
  27. <para>
  28. If you initialize the <classname>UserAgent</classname> object manually, you can still
  29. inject it into the helper, in one of two ways.
  30. </para>
  31. <programlisting language="php"><![CDATA[
  32. // Pull the helper from the view, and inject:
  33. $helper = $view->getHelper('userAgent');
  34. $helper->setUserAgent($userAgent);
  35. // Pass the UserAgent to the helper:
  36. $view->userAgent($userAgent);
  37. ]]></programlisting>
  38. </sect4>
  39. <sect4 id="zend.view.helpers.initial.user-agent.methods">
  40. <title>Available Methods</title>
  41. <refentry id="zend.view.helpers.initial.user-agent.methods.user-agent">
  42. <refnamediv>
  43. <refname>userAgent</refname>
  44. <refpurpose>Set and/or retrieve the UserAgent instance</refpurpose>
  45. </refnamediv>
  46. <refsynopsisdiv>
  47. <methodsynopsis>
  48. <methodname>userAgent</methodname>
  49. <methodparam>
  50. <funcparams>Zend_Http_UserAgent $userAgent = null</funcparams>
  51. </methodparam>
  52. </methodsynopsis>
  53. </refsynopsisdiv>
  54. <refsect1>
  55. <title>userAgent()</title>
  56. <para>
  57. Use this method to set or retrieve the <classname>UserAgent</classname>
  58. instance. Passing an instance will set it; passing no arguments will retrieve
  59. it. If no previous instance has been registered, one will be lazy-loaded using
  60. defaults.
  61. </para>
  62. </refsect1>
  63. </refentry>
  64. <refentry id="zend.view.helpers.initial.user-agent.methods.set-user-agent">
  65. <refnamediv>
  66. <refname>setUserAgent</refname>
  67. <refpurpose>Set the UserAgent instance</refpurpose>
  68. </refnamediv>
  69. <refsynopsisdiv>
  70. <methodsynopsis>
  71. <methodname>setUserAgent</methodname>
  72. <methodparam>
  73. <funcparams>Zend_Http_UserAgent $userAgent</funcparams>
  74. </methodparam>
  75. </methodsynopsis>
  76. </refsynopsisdiv>
  77. <refsect1>
  78. <title>setUserAgent()</title>
  79. <para>
  80. If you have an instance of the helper -- for instance, by calling the view
  81. object's <methodname>getHelper()</methodname> method -- you may use this method
  82. to set the <classname>UserAgent</classname> instance.
  83. </para>
  84. </refsect1>
  85. </refentry>
  86. <refentry id="zend.view.helpers.initial.user-agent.methods.get-user-agent">
  87. <refnamediv>
  88. <refname>getUserAgent</refname>
  89. <refpurpose>Retrieve the UserAgent instance</refpurpose>
  90. </refnamediv>
  91. <refsynopsisdiv>
  92. <methodsynopsis>
  93. <methodname>getUserAgent</methodname>
  94. </methodsynopsis>
  95. </refsynopsisdiv>
  96. <refsect1>
  97. <title>getUserAgent()</title>
  98. <para>
  99. Retrieves the <classname>UserAgent</classname> instance; if none is registered,
  100. it will lazy-load one using default values.
  101. </para>
  102. </refsect1>
  103. </refentry>
  104. </sect4>
  105. </sect3>