Zend_Http_UserAgent.xml 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.http.user-agent">
  4. <title>Zend_Http_UserAgent</title>
  5. <sect2 id="zend.http.user-agent.intro">
  6. <title>Overview</title>
  7. <para>
  8. With the plethora of mobile devices available on the market, it's increasingly important
  9. to be able to identify the capabilities of those devices in order to present content in
  10. a an appropriate way. For instance, if the device is not capable of displaying images,
  11. you might want to omit them from the markup; alternately, if a device is capable of
  12. Flash, you may want to provide a Flash-based user interface.
  13. </para>
  14. <para>
  15. The process of identifying a device's capabilities typically first requires knowing the
  16. HTTP User Agent, and then comparing that user agent against a database of user agent
  17. capabilities. <classname>Zend_Http_UserAgent</classname> was created to provide these
  18. capabilities for your applications. It consists of several major features:
  19. </para>
  20. <itemizedlist>
  21. <listitem>
  22. <para>
  23. The primary <classname>Zend_Http_UserAgent</classname> class, which detects the
  24. User Agent, and gives you a device object, as well as persists the device object
  25. for later retrieval.
  26. </para>
  27. </listitem>
  28. <listitem>
  29. <para>
  30. A <link linkend="zend.http.user-agent-device">Zend_Http_UserAgent_Device</link>
  31. interface, and a number of implementations that implement it. These objects
  32. utilize a features adatper to discover device capabilities, and then allow you
  33. to introspect those capabilities.
  34. </para>
  35. </listitem>
  36. <listitem>
  37. <para>
  38. A <link linkend="zend.http.user-agent-features">Zend_Http_UserAgent_Features_Adapter</link>
  39. interface; concrete implementations provide the ability to discover device
  40. capabilities, or features.
  41. </para>
  42. </listitem>
  43. <listitem>
  44. <para>
  45. A <link linkend="zend.http.user-agent-storage">Zend_Http_UserAgent_Storage</link>
  46. interface, which is used to persist discovered devices for given users, allowing
  47. for faster device capability discovery on subsequent page visits.
  48. </para>
  49. </listitem>
  50. <listitem>
  51. <para>
  52. A <link linkend="zend.view.helpers.initial.user-agent">view helper</link> that
  53. can be used within your view scripts and layouts to branch display logic based
  54. on device capabilities.
  55. </para>
  56. </listitem>
  57. <listitem>
  58. <para>
  59. A <classname>Zend_Application</classname> <link
  60. linkend="zend.application.available-resources.useragent">resource</link> for
  61. configuring and instantiating the user agent object, as well as seeding the view
  62. helper with the user agent object instance.
  63. </para>
  64. </listitem>
  65. </itemizedlist>
  66. <para>
  67. At the time of this writing, The <classname>UserAgent</classname> component provides
  68. three adapters:
  69. </para>
  70. <itemizedlist>
  71. <listitem>
  72. <para>
  73. <link
  74. linkend="zend.http.user-agent-features-wurfl">Zend_Http_UserAgent_Features_Adapter_Wurfl</link>
  75. consumes the <ulink url="http://wurfl.sourceforge.net/">WURFL</ulink> (Wireless
  76. Universal Resource File) PHP API. This database is considered one of the most
  77. comprehensive mobile device capabilities databases available.
  78. </para>
  79. </listitem>
  80. <listitem>
  81. <para>
  82. <link
  83. linkend="zend.http.user-agent-features-tera-wurfl">Zend_Http_UserAgent_Features_Adapter_TeraWurfl</link>
  84. consumes the TeraWurfl API, which is built on top of <acronym>WURFL</acronym>,
  85. and aimed at providing a highly available, highly performant lookup mechanism.
  86. </para>
  87. </listitem>
  88. <listitem>
  89. <para>
  90. <link
  91. linkend="zend.http.user-agent-features-device-atlas">Zend_Http_UserAgent_Features_Adapter_DeviceAtlas</link>
  92. consumes the DeviceAtlas API, which is a paid, Enterprise-grade mobile device
  93. capabilities database.
  94. </para>
  95. </listitem>
  96. </itemizedlist>
  97. </sect2>
  98. <sect2 id="zend.http.user-agent.quick-start">
  99. <title>Quick Start</title>
  100. <para>
  101. First, you will need to download the following:
  102. </para>
  103. <itemizedlist>
  104. <listitem>
  105. <para>
  106. The <acronym>WURFL</acronym> <ulink
  107. url="http://sourceforge.net/projects/wurfl/files/WURFL%20PHP/1.1/wurfl-php-1.1.tar.gz/download">PHP
  108. API</ulink>. This includes the <filename>wurfl.xml</filename> file, which is
  109. the actual <acronym>WURFL</acronym> database.
  110. </para>
  111. </listitem>
  112. </itemizedlist>
  113. <para>
  114. We suggest that you place this library in your "library" directory. Inflating the
  115. archive will create a <filename>Wurfl/1.1/</filename> directory.
  116. </para>
  117. <programlisting language="text">
  118. project
  119. |-- application
  120. |-- data
  121. |-- library
  122. | |-- Wurfl
  123. | | |-- 1.1
  124. | | | |-- resources
  125. | | | |-- wurfl.xml
  126. | | | `-- wurfl-config.php
  127. </programlisting>
  128. <para>
  129. Next, find the file <filename>resources/wurfl-config.php</filename> in your
  130. <acronym>WURFL</acronym> library. The <acronym>WURFL</acronym> PHP API is designed to
  131. cache data. As such, you will want to set the <varname>['persistence']['dir']</varname>
  132. key. We recommend having these point to <filename>APPLICATION_PATH .
  133. "/../data/wurfl/</filename>; you will need to create this directory if it does not
  134. yet.
  135. </para>
  136. <programlisting language="php"><![CDATA[
  137. $configuration['persistence']['dir'] = APPLICATION_PATH . '/../data/wurfl';
  138. ]]></programlisting>
  139. <para>
  140. Now, in your <filename>application.ini</filename>, add the following entries:
  141. </para>
  142. <programlisting language="ini">
  143. resources.useragent.wurflapi.wurfl_api_version = "1.1"
  144. resources.useragent.wurflapi.wurfl_lib_dir = APPLICATION_PATH "/../library/Wurfl/1.1"
  145. resources.useragent.wurflapi.wurfl_config_file = APPLICATION_PATH "/../library/Wurfl/1.1/resources/wurfl-config.php"
  146. </programlisting>
  147. <para>
  148. At this point, everything is setup. The first request will populate the
  149. <acronym>WURFL</acronym> cache by parsing the <filename>resources/wurfl.xml</filename>
  150. file, and as such may take up to a minute. After that, lookups will be quite fast, and
  151. each request will contain detailed information on the user agent.
  152. </para>
  153. <para>
  154. You can access this information in a variety of ways. From within the MVC portion of
  155. your application, you can access it via the bootstrap. Within plugins, this is done by
  156. grabbing the bootstrap from the front controller.
  157. </para>
  158. <programlisting language="php"><![CDATA[
  159. $bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap');
  160. $userAgent = $bootstrap->getResource('useragent');
  161. ]]></programlisting>
  162. <para>
  163. From your action controller, use <methodname>getInvokeArg()</methodname> to grab the
  164. bootstrap, and from there, the user agent object.
  165. </para>
  166. <programlisting language="php"><![CDATA[
  167. $bootstrap = $this->getInvokeArg('bootstrap');
  168. $userAgent = $bootstrap->getResource('useragent');
  169. ]]></programlisting>
  170. <para>
  171. Within your view, you can grab it using the <classname>UserAgent</classname> view
  172. helper.
  173. </para>
  174. <programlisting language="php"><![CDATA[
  175. $userAgent = $this->userAgent();
  176. ]]></programlisting>
  177. <para>
  178. Once you have the user agent object, you can query it for different capabilities. As one
  179. example, you may want to use an alternate layout script based on the user agent
  180. capabilities.
  181. </para>
  182. <programlisting language="php"><![CDATA[
  183. $width = $userAgent->getDevice()->getPhysicalScreenWidth();
  184. switch (true) {
  185. case ($width <= 128):
  186. $layout->setLayout('layout-poor');
  187. break;
  188. case ($width <= 176):
  189. $layout->setLayout('layout-medium');
  190. break;
  191. case ($width <= 240):
  192. $layout->setLayout('layout-high');
  193. break;
  194. case ($width <= 320):
  195. $layout->setLayout('layout-ultra');
  196. break;
  197. default:
  198. // use default
  199. break;
  200. }
  201. ]]></programlisting>
  202. </sect2>
  203. <sect2 id="zend.http.user-agent.options">
  204. <title>Configuration Options</title>
  205. <variablelist>
  206. <title>UserAgent Options</title>
  207. <para>
  208. The following options may be passed to the constructor or within your application
  209. configuration. A "." indicates another layer of depth in the configuration array; as
  210. an example, assigning "wurflapi.wurfl_config_array.wurfl.main-file" as part of a PHP
  211. configuration would require the following definition:
  212. </para>
  213. <programlisting language="php"><![CDATA[
  214. $config = array(
  215. 'wurflapi' => array(
  216. 'wurfl_config_array' => array(
  217. 'wurfl' => array(
  218. 'main-file' => 'path/to/some/file',
  219. ),
  220. ),
  221. ),
  222. );
  223. ]]></programlisting>
  224. <para>
  225. Each features adapter has its own options available as well, which may be mixed in
  226. with the general UserAgent options.
  227. </para>
  228. <varlistentry>
  229. <term>browser_type</term>
  230. <listitem>
  231. <para>
  232. Used to seed the list of devices the component will search. See also
  233. <varname>identification_sequence</varname>; this value will be prepended to
  234. that list during user agent device discovery.
  235. </para>
  236. </listitem>
  237. </varlistentry>
  238. <varlistentry>
  239. <term>http_accept</term>
  240. <listitem>
  241. <para>
  242. The value of the <varname>Accept</varname> <acronym>HTTP</acronym> header;
  243. used by some user agents to determine capabilities. Set this to seed the
  244. value explicitly.
  245. </para>
  246. </listitem>
  247. </varlistentry>
  248. <varlistentry>
  249. <term>identification_sequence</term>
  250. <listitem>
  251. <para>
  252. A comma-separated list of device types to scan for matches; defaults to
  253. "mobile,desktop".
  254. </para>
  255. </listitem>
  256. </varlistentry>
  257. <varlistentry>
  258. <term>storage.adapter</term>
  259. <listitem>
  260. <para>
  261. The name of a storage adapter used to persist the device capabilities,
  262. typically within a given user session. The value may either be a fully
  263. qualified class name, or a short name to resolve by the plugin loader for
  264. storage classes. By default, uses "Session" as the value, resolving to
  265. <classname>Zend_Http_UserAgent_Storage_Session</classname>.
  266. </para>
  267. </listitem>
  268. </varlistentry>
  269. <varlistentry>
  270. <term>storage.options[]</term>
  271. <listitem>
  272. <para>
  273. An array of options to pass to the constructor of a storage adapter. By
  274. default, the option <varname>browser_type</varname> will be present.
  275. </para>
  276. </listitem>
  277. </varlistentry>
  278. <varlistentry>
  279. <term>plugin_loader.[type] = [class]</term>
  280. <listitem>
  281. <para>
  282. Plugin loader configuration; allows you to specify a pre-configured
  283. <classname>Zend_Loader_PluginLoader</classname> extension class to use for
  284. one of the plugin loader types managed by <classname>UserAgent</classname>
  285. (currently "storage" and "device".
  286. </para>
  287. </listitem>
  288. </varlistentry>
  289. <varlistentry>
  290. <term>server[]</term>
  291. <listitem>
  292. <para>
  293. Typically, you will not set this; this simply allows injection of the
  294. <varname>$_SERVER</varname> superglobal (or a filtered version of it). The
  295. value should be an associative array.
  296. </para>
  297. </listitem>
  298. </varlistentry>
  299. <varlistentry>
  300. <term>user_agent</term>
  301. <listitem>
  302. <para>
  303. The actual <acronym>HTTP</acronym> User-Agent string you wish to try and
  304. match. Typically, this will be auto-discovered from the
  305. <varname>server</varname> array.
  306. </para>
  307. </listitem>
  308. </varlistentry>
  309. <varlistentry>
  310. <term>[browser_type].device.classname</term>
  311. <listitem>
  312. <para>
  313. The device class to use for a given browser type; typically,
  314. <varname>browser_type</varname> will be one of the supported browser
  315. devices, including:
  316. </para>
  317. <itemizedlist>
  318. <listitem><para>Bot</para></listitem>
  319. <listitem><para>Checker</para></listitem>
  320. <listitem><para>Console</para></listitem>
  321. <listitem><para>Desktop</para></listitem>
  322. <listitem><para>Email</para></listitem>
  323. <listitem><para>Feed</para></listitem>
  324. <listitem><para>Mobile</para></listitem>
  325. <listitem><para>Offline</para></listitem>
  326. <listitem><para>Probe</para></listitem>
  327. <listitem><para>Spam</para></listitem>
  328. <listitem><para>Text</para></listitem>
  329. <listitem><para>Validator</para></listitem>
  330. </itemizedlist>
  331. <para>
  332. The <varname>browser_type</varname> should be normalized to lowercase for
  333. configuration purposes.
  334. </para>
  335. </listitem>
  336. </varlistentry>
  337. <varlistentry>
  338. <term>[browser_type].device.path and [browser_type].device.prefix</term>
  339. <listitem>
  340. <para>
  341. An alternate way to specify the device class for a given browser type is to
  342. assume it is named after the device, and that all device classes are in the
  343. same path sharing the same prefix. Configure the prefix and path using these
  344. keys.
  345. </para>
  346. <para>
  347. As an example, the following would look for a class named
  348. "Mobile_Device_Bot" on the path "Mobile/Device/" under the application
  349. library.
  350. </para>
  351. <programlisting language="ini">
  352. resources.useragent.bot.device.path = APPLICATION_PATH '/../library/Mobile/Device"
  353. resources.useragent.bot.device.prefix = "Mobile_Device"
  354. </programlisting>
  355. </listitem>
  356. </varlistentry>
  357. <varlistentry>
  358. <term>[browser_type].features.path and [browser_type].features.classname</term>
  359. <listitem>
  360. <para>
  361. These settings are used to load the features capabilities detection class
  362. for a given browser type. The class will be named using the
  363. <varname>classname</varname> key, and is expected to exist in the file
  364. denoted by the <varname>path</varname> key. The class should implement
  365. <classname>Zend_Http_UserAgent_Features_Adapter</classname>.
  366. </para>
  367. </listitem>
  368. </varlistentry>
  369. <varlistentry>
  370. <term>wurflapi.wurfl_api_version</term>
  371. <listitem>
  372. <para>
  373. If using the <acronym>WURFL</acronym> API, use this key to specify which
  374. version you are using; typically, this will be either "1.0" or "1.1".
  375. </para>
  376. </listitem>
  377. </varlistentry>
  378. <varlistentry>
  379. <term>wurflapi.wurfl_lib_dir</term>
  380. <listitem>
  381. <para>
  382. If using the <acronym>WURFL</acronym> API, use this key to specify in which
  383. directory the library exists.
  384. </para>
  385. </listitem>
  386. </varlistentry>
  387. <varlistentry>
  388. <term>wurflapi.wurfl_config_file</term>
  389. <listitem>
  390. <para>
  391. If using the <acronym>WURFL</acronym> API, use this key to specify the
  392. location of the configuration file you will use; typically, this will be
  393. <filename>resources/wurfl-config.php</filename> within the
  394. <varname>wurfl_lib_dir</varname>.
  395. </para>
  396. </listitem>
  397. </varlistentry>
  398. <varlistentry>
  399. <term>wurflapi.wurfl_config_array.wurfl.main-file</term>
  400. <listitem>
  401. <para>
  402. If using version 1.1 of the <acronym>WURFL</acronym> API, you can omit using
  403. a <varname>wurfl_config_file</varname>, and instead provide an associative
  404. array of configuration values. This particular value indicates the location
  405. of the <filename>wurfl.xml</filename> file containing the actual
  406. <acronym>WURFL</acronym> database.
  407. </para>
  408. </listitem>
  409. </varlistentry>
  410. <varlistentry>
  411. <term>wurflapi.wurfl_config_array.wurfl.patches[]</term>
  412. <listitem>
  413. <para>
  414. If using version 1.1 of the <acronym>WURFL</acronym> API, you can omit using
  415. a <varname>wurfl_config_file</varname>, and instead provide an associative
  416. array of configuration values. This particular value is an array of file
  417. locations containing patchfiles for the <varname>wurfl.main-file</varname>
  418. (which are used to ammend and extend the primary database file).
  419. </para>
  420. </listitem>
  421. </varlistentry>
  422. <varlistentry>
  423. <term>wurflapi.wurfl_config_array.persistence.provider</term>
  424. <listitem>
  425. <para>
  426. If using version 1.1 of the <acronym>WURFL</acronym> API, you can omit using
  427. a <varname>wurfl_config_file</varname>, and instead provide an associative
  428. array of configuration values. This particular value indicates the type of
  429. persistence provider used when caching discovered capabilities. See the
  430. <acronym>WURFL</acronym> documentation for potential values; "file" is a
  431. known good value.
  432. </para>
  433. </listitem>
  434. </varlistentry>
  435. <varlistentry>
  436. <term>wurflapi.wurfl_config_array.persistence.dir</term>
  437. <listitem>
  438. <para>
  439. If using version 1.1 of the <acronym>WURFL</acronym> API, you can omit using
  440. a <varname>wurfl_config_file</varname>, and instead provide an associative
  441. array of configuration values. This particular value indicates the location
  442. where the persistence provider will cache discovered capabilities.
  443. </para>
  444. </listitem>
  445. </varlistentry>
  446. </variablelist>
  447. </sect2>
  448. <sect2 id="zend.http.user-agent.methods">
  449. <title>Available Methods</title>
  450. <variablelist>
  451. <varlistentry id="zend.http.user-agent.methods.constructor">
  452. <term>
  453. <methodsynopsis>
  454. <methodname>__construct</methodname>
  455. <methodparam>
  456. <funcparams>$options = null</funcparams>
  457. </methodparam>
  458. </methodsynopsis>
  459. </term>
  460. <listitem>
  461. <para>
  462. The constructor attempts to determine the current User-Agent based on the
  463. options provided, the current request information, and/or previously discovered
  464. information persisted in storage. Once instantiated, the detected device is
  465. immediately available.
  466. </para>
  467. <para>
  468. Please see <link linkend="zend.http.user-agent.options">configuration
  469. options</link> section for details on the <varname>$options</varname> array.
  470. </para>
  471. </listitem>
  472. </varlistentry>
  473. <varlistentry id="zend.http.user-agent.methods.serialize">
  474. <term>
  475. <methodsynopsis>
  476. <methodname>serialize</methodname>
  477. <methodparam>
  478. <funcparams></funcparams>
  479. </methodparam>
  480. </methodsynopsis>
  481. </term>
  482. <listitem>
  483. <para>
  484. Defined by the <interfacename>Serializable</interfacename> interface, this
  485. method performs logic necessary to determine what within the object should be
  486. serialized when the object is serialized by a storage adapter.
  487. </para>
  488. </listitem>
  489. </varlistentry>
  490. <varlistentry id="zend.http.user-agent.methods.unserialize">
  491. <term>
  492. <methodsynopsis>
  493. <methodname>unserialize</methodname>
  494. <methodparam>
  495. <funcparams>$serialized</funcparams>
  496. </methodparam>
  497. </methodsynopsis>
  498. </term>
  499. <listitem>
  500. <para>
  501. Defined by the <interfacename>Serializable</interfacename> interface, this
  502. method performs logic necessary to determine how to unserialize a previously
  503. serialized instance.
  504. </para>
  505. </listitem>
  506. </varlistentry>
  507. <varlistentry id="zend.http.user-agent.methods.set-options">
  508. <term>
  509. <methodsynopsis>
  510. <methodname>setOptions</methodname>
  511. <methodparam>
  512. <funcparams>$options</funcparams>
  513. </methodparam>
  514. </methodsynopsis>
  515. </term>
  516. <listitem>
  517. <para>
  518. Initializes object state. Please see the <link
  519. linkend="zend.http.user-agent.options">configuration options</link> section
  520. for information on the <varname>$options</varname> array.
  521. </para>
  522. </listitem>
  523. </varlistentry>
  524. <varlistentry id="zend.http.user-agent.methods.get-user-agent">
  525. <term>
  526. <methodsynopsis>
  527. <methodname>getUserAgent</methodname>
  528. <methodparam>
  529. <funcparams></funcparams>
  530. </methodparam>
  531. </methodsynopsis>
  532. </term>
  533. <listitem>
  534. <para>
  535. Retrieve the discovered User-Agent string. Unless set explicitly, this will be
  536. autodiscovered from the server array.
  537. </para>
  538. </listitem>
  539. </varlistentry>
  540. <varlistentry id="zend.http.user-agent.methods.set-user-agent">
  541. <term>
  542. <methodsynopsis>
  543. <methodname>setUserAgent</methodname>
  544. <methodparam>
  545. <funcparams>$userAgent</funcparams>
  546. </methodparam>
  547. </methodsynopsis>
  548. </term>
  549. <listitem>
  550. <para>
  551. Set the User-Agent string explicitly. Once <methodname>getDevice()</methodname>
  552. has been called, this property is marked immutable, and calling this method will
  553. raise an exception.
  554. </para>
  555. </listitem>
  556. </varlistentry>
  557. <varlistentry id="zend.http.user-agent.methods.get-http-accept">
  558. <term>
  559. <methodsynopsis>
  560. <methodname>getHttpAccept</methodname>
  561. <methodparam>
  562. <funcparams>$httpAccept = null</funcparams>
  563. </methodparam>
  564. </methodsynopsis>
  565. </term>
  566. <listitem>
  567. <para>
  568. Retrieve the HTTP Accept header value.
  569. </para>
  570. </listitem>
  571. </varlistentry>
  572. <varlistentry id="zend.http.user-agent.methods.set-http-accept">
  573. <term>
  574. <methodsynopsis>
  575. <methodname>setHttpAccept</methodname>
  576. <methodparam>
  577. <funcparams>$httpAccept</funcparams>
  578. </methodparam>
  579. </methodsynopsis>
  580. </term>
  581. <listitem>
  582. <para>
  583. Explicitly set the HTTP Accept header value. Once
  584. <methodname>getDevice()</methodname> has been called, this property is marked
  585. immutable, and calling this method will raise an exception.
  586. </para>
  587. </listitem>
  588. </varlistentry>
  589. <varlistentry id="zend.http.user-agent.methods.get-storage">
  590. <term>
  591. <methodsynopsis>
  592. <methodname>getStorage</methodname>
  593. <methodparam>
  594. <funcparams>$browser = null</funcparams>
  595. </methodparam>
  596. </methodsynopsis>
  597. </term>
  598. <listitem>
  599. <para>
  600. Retrieves a persistent storage object for a given browser type.
  601. </para>
  602. </listitem>
  603. </varlistentry>
  604. <varlistentry id="zend.http.user-agent.methods.set-storage">
  605. <term>
  606. <methodsynopsis>
  607. <methodname>setStorage</methodname>
  608. <methodparam>
  609. <funcparams>Zend_Http_UserAgent_Storage $storage</funcparams>
  610. </methodparam>
  611. </methodsynopsis>
  612. </term>
  613. <listitem>
  614. <para>
  615. Use this to explicitly set the peristent storage object. Once
  616. <methodname>getDevice()</methodname> has been called, the storage is marked
  617. immutable (as in: you may not inject a new storage object), and calling this
  618. method will raise an exception.
  619. </para>
  620. </listitem>
  621. </varlistentry>
  622. <varlistentry id="zend.http.user-agent.methods.clear-storage">
  623. <term>
  624. <methodsynopsis>
  625. <methodname>clearStorage</methodname>
  626. <methodparam>
  627. <funcparams>$browser = null</funcparams>
  628. </methodparam>
  629. </methodsynopsis>
  630. </term>
  631. <listitem>
  632. <para>
  633. Clears any information in the persistent storage object.
  634. </para>
  635. </listitem>
  636. </varlistentry>
  637. <varlistentry id="zend.http.user-agent.methods.get-config">
  638. <term>
  639. <methodsynopsis>
  640. <methodname>getConfig</methodname>
  641. <methodparam>
  642. <funcparams></funcparams>
  643. </methodparam>
  644. </methodsynopsis>
  645. </term>
  646. <listitem>
  647. <para>
  648. Retrieve configuration parameters.
  649. </para>
  650. </listitem>
  651. </varlistentry>
  652. <varlistentry id="zend.http.user-agent.methods.get-device">
  653. <term>
  654. <methodsynopsis>
  655. <methodname>getDevice</methodname>
  656. <methodparam>
  657. <funcparams></funcparams>
  658. </methodparam>
  659. </methodsynopsis>
  660. </term>
  661. <listitem>
  662. <para>
  663. Use this method to get the User-Agent Device object; this is the object that
  664. will contain the various discovered device capabilities.
  665. </para>
  666. <para>
  667. Discovery of the User-Agent device occurs in this method. Once the device has
  668. been retrieved, the server array, browser type, user agent, http accept, and
  669. storage properties are marked as immutable.
  670. </para>
  671. </listitem>
  672. </varlistentry>
  673. <varlistentry id="zend.http.user-agent.methods.get-browser-type">
  674. <term>
  675. <methodsynopsis>
  676. <methodname>getBrowserType</methodname>
  677. <methodparam>
  678. <funcparams></funcparams>
  679. </methodparam>
  680. </methodsynopsis>
  681. </term>
  682. <listitem>
  683. <para>
  684. Retrieve the discovered browser type; usually one of:
  685. </para>
  686. <itemizedlist>
  687. <listitem><para>Bot</para></listitem>
  688. <listitem><para>Checker</para></listitem>
  689. <listitem><para>Console</para></listitem>
  690. <listitem><para>Desktop</para></listitem>
  691. <listitem><para>Email</para></listitem>
  692. <listitem><para>Feed</para></listitem>
  693. <listitem><para>Mobile</para></listitem>
  694. <listitem><para>Offline</para></listitem>
  695. <listitem><para>Probe</para></listitem>
  696. <listitem><para>Spam</para></listitem>
  697. <listitem><para>Text</para></listitem>
  698. <listitem><para>Validator</para></listitem>
  699. </itemizedlist>
  700. <para>
  701. Unless explicitly set, the browser type is unknown until
  702. <methodname>getDevice()</methodname> has been called.
  703. </para>
  704. </listitem>
  705. </varlistentry>
  706. <varlistentry id="zend.http.user-agent.methods.set-browser-type">
  707. <term>
  708. <methodsynopsis>
  709. <methodname>setBrowserType</methodname>
  710. <methodparam>
  711. <funcparams>$browserType</funcparams>
  712. </methodparam>
  713. </methodsynopsis>
  714. </term>
  715. <listitem>
  716. <para>
  717. Explicitly set the browser type to prepend to the identification sequence. Once
  718. <methodname>getDevice()</methodname> has been called, the browser type is marked
  719. immutable, and calling this method will raise an exception.
  720. </para>
  721. </listitem>
  722. </varlistentry>
  723. <varlistentry id="zend.http.user-agent.methods.get-server">
  724. <term>
  725. <methodsynopsis>
  726. <methodname>getServer</methodname>
  727. <methodparam>
  728. <funcparams></funcparams>
  729. </methodparam>
  730. </methodsynopsis>
  731. </term>
  732. <listitem>
  733. <para>
  734. Retrieve the array of HTTP headers and environment variables used to perform
  735. device discovery. If the array has not yet been set, it is seeded with the
  736. <varname>$_SERVER</varname> superglobal.
  737. </para>
  738. </listitem>
  739. </varlistentry>
  740. <varlistentry id="zend.http.user-agent.methods.set-server">
  741. <term>
  742. <methodsynopsis>
  743. <methodname>setServer</methodname>
  744. <methodparam>
  745. <funcparams>$server</funcparams>
  746. </methodparam>
  747. </methodsynopsis>
  748. </term>
  749. <listitem>
  750. <para>
  751. Explicitly set the "server" array of HTTP headers and environment variables to
  752. use during device discovery. Once <methodname>getDevice()</methodname> has been
  753. called, the server array is marked immutable, and calling this method will raise
  754. an exception.
  755. </para>
  756. </listitem>
  757. </varlistentry>
  758. <varlistentry id="zend.http.user-agent.methods.get-server-value">
  759. <term>
  760. <methodsynopsis>
  761. <methodname>getServerValue</methodname>
  762. <methodparam>
  763. <funcparams>$key</funcparams>
  764. </methodparam>
  765. </methodsynopsis>
  766. </term>
  767. <listitem>
  768. <para>
  769. Retrieve a single value from the server array by key.
  770. </para>
  771. </listitem>
  772. </varlistentry>
  773. <varlistentry id="zend.http.user-agent.methods.set-server-value">
  774. <term>
  775. <methodsynopsis>
  776. <methodname>setServerValue</methodname>
  777. <methodparam>
  778. <funcparams>$key, $value</funcparams>
  779. </methodparam>
  780. </methodsynopsis>
  781. </term>
  782. <listitem>
  783. <para>
  784. Overwrite or define a value in the internal server array. Once
  785. <methodname>getDevice()</methodname> has been called, the server array is marked
  786. immutable, and calling this method will raise an exception.
  787. </para>
  788. </listitem>
  789. </varlistentry>
  790. <varlistentry id="zend.http.user-agent.methods.set-plugin-loader">
  791. <term>
  792. <methodsynopsis>
  793. <methodname>setPluginLoader</methodname>
  794. <methodparam>
  795. <funcparams>$type, $loader</funcparams>
  796. </methodparam>
  797. </methodsynopsis>
  798. </term>
  799. <listitem>
  800. <para>
  801. <varname>$type</varname> may be one of "device" or "storage; the former is used
  802. when attempting to find device classes, the latter for finding storage classes.
  803. <varname>$loader</varname> may be a
  804. <classname>Zend_Loader_PluginLoader</classname> instance, or a string name
  805. containing the classname of a <classname>Zend_Loader_PluginLoader</classname>
  806. extension class.
  807. </para>
  808. </listitem>
  809. </varlistentry>
  810. <varlistentry id="zend.http.user-agent.methods.get-plugin-loader">
  811. <term>
  812. <methodsynopsis>
  813. <methodname>getPluginLoader</methodname>
  814. <methodparam>
  815. <funcparams>$type</funcparams>
  816. </methodparam>
  817. </methodsynopsis>
  818. </term>
  819. <listitem>
  820. <para>
  821. Retrieves either the "device" or "storage" plugin loader instance.
  822. </para>
  823. </listitem>
  824. </varlistentry>
  825. </variablelist>
  826. </sect2>
  827. <sect2 id="zend.http.user-agent.examples">
  828. <title>Examples</title>
  829. <para>
  830. Please see the <link linkend="zend.http.user-agent.quick-start">quick start</link> for
  831. examples at this time.
  832. </para>
  833. </sect2>
  834. </sect1>