Zend_Http_UserAgent.xml 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012
  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 archive contains the most recent
  109. <filename>wurfl-latest.xml</filename> file and patches which constitute the
  110. actual <acronym>WURFL</acronym> database.
  111. </para>
  112. </listitem>
  113. </itemizedlist>
  114. <para>
  115. We suggest that you inflate this archive in your "library" directory. Inflating the
  116. archive will create a <filename>wurfl-php-1.1</filename> directory.
  117. </para>
  118. <programlisting language="text">
  119. library
  120. |-- wurfl-php-1.1
  121. | |-- COPYING
  122. | |-- docs
  123. | |-- examples
  124. | |-- README
  125. | |-- tests
  126. | `-- WURFL
  127. </programlisting>
  128. <para>
  129. Next, create a data and cache directory for the <acronym>WURFL</acronym> database and
  130. related cache files; this should be done from your project root (the directory
  131. containing the <filename>application</filename> and <filename>library</filename>
  132. directories). When you do so, make sure the directory is at least writable by the web
  133. server user; the following makes it writable for all users.
  134. </para>
  135. <programlisting language="sh"><![CDATA[
  136. mkdir -p data/wurfl/cache
  137. chmod -R o+rwX data/wurfl/cache
  138. ]]></programlisting>
  139. <para>
  140. Now, copy the <acronym>WURFL</acronym> data from the inflated archive into your data
  141. directory.
  142. </para>
  143. <programlisting language="sh"><![CDATA[
  144. cp library/wurfl-php-1.1/tests/resources/wurfl-latest.zip data/wurfl/
  145. cp library/wurfl-php-1.1/tests/resources/web_browsers_patch.xml data/wurfl/
  146. ]]></programlisting>
  147. <para>
  148. Create a <acronym>WURFL</acronym> configuration file named
  149. <filename>application/configs/wurfl-config.php</filename>, with the following contents:
  150. </para>
  151. <programlisting language="php"><![CDATA[
  152. <?php
  153. $resourcesDir = dirname(__FILE__) . '/../../data/wurfl/';
  154. $wurfl['main-file'] = $resourcesDir . 'wurfl-latest.zip';
  155. $wurfl['patches'] = array($resourcesDir . 'web_browsers_patch.xml');
  156. $persistence['provider'] = 'file';
  157. $persistence['dir'] = $resourcesDir . '/cache/';
  158. $cache['provider'] = null;
  159. $configuration['wurfl'] = $wurfl;
  160. $configuration['persistence'] = $persistence;
  161. $configuration['cache'] = $cache;
  162. ]]></programlisting>
  163. <para>
  164. Finally, edit your <filename>application.ini</filename> to add the following lines to your
  165. <varname>[production]</varname> section:
  166. </para>
  167. <programlisting language="ini">
  168. resources.useragent.wurflapi.wurfl_api_version = "1.1"
  169. resources.useragent.wurflapi.wurfl_lib_dir = APPLICATION_PATH "/../library/wurfl-php-1.1/WURFL/"
  170. resources.useragent.wurflapi.wurfl_config_file = APPLICATION_PATH "/configs/wurfl-config.php"
  171. </programlisting>
  172. <note>
  173. <para>
  174. The trailing directory separator on the <constant>wurfl_lib_dir</constant> setting
  175. is important. The <acronym>WURFL</acronym> API does no normalization, and expects
  176. it to be there.
  177. </para>
  178. </note>
  179. <para>
  180. At this point, everything is setup. The first request (from a mobile device) will populate the
  181. <acronym>WURFL</acronym> cache by parsing the <filename>resources/wurfl.xml</filename>
  182. file, and as such may take up to a minute. After that, lookups will be quite fast, and
  183. each request will contain detailed information on the user agent.
  184. </para>
  185. <para>
  186. You can access this information in a variety of ways. From within the MVC portion of
  187. your application, you can access it via the bootstrap. Within plugins, this is done by
  188. grabbing the bootstrap from the front controller.
  189. </para>
  190. <programlisting language="php"><![CDATA[
  191. $bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap');
  192. $userAgent = $bootstrap->getResource('useragent');
  193. ]]></programlisting>
  194. <para>
  195. From your action controller, use <methodname>getInvokeArg()</methodname> to grab the
  196. bootstrap, and from there, the user agent object.
  197. </para>
  198. <programlisting language="php"><![CDATA[
  199. $bootstrap = $this->getInvokeArg('bootstrap');
  200. $userAgent = $bootstrap->getResource('useragent');
  201. ]]></programlisting>
  202. <para>
  203. Within your view, you can grab it using the <classname>UserAgent</classname> view
  204. helper.
  205. </para>
  206. <programlisting language="php"><![CDATA[
  207. $userAgent = $this->userAgent();
  208. ]]></programlisting>
  209. <para>
  210. Once you have the user agent object, you can query it for different capabilities. As one
  211. example, you may want to use an alternate layout script based on the user agent
  212. capabilities.
  213. </para>
  214. <programlisting language="php"><![CDATA[
  215. $width = $userAgent->getDevice()->getPhysicalScreenWidth();
  216. switch (true) {
  217. case ($width <= 128):
  218. $layout->setLayout('layout-poor');
  219. break;
  220. case ($width <= 176):
  221. $layout->setLayout('layout-medium');
  222. break;
  223. case ($width <= 240):
  224. $layout->setLayout('layout-high');
  225. break;
  226. case ($width <= 320):
  227. $layout->setLayout('layout-ultra');
  228. break;
  229. default:
  230. // use default
  231. break;
  232. }
  233. ]]></programlisting>
  234. <para>
  235. Finally, each device will often have a large number of capabilities not immediately
  236. represented in the device interface. You can query these using the
  237. <methodname>hasFeature()</methodname> and <methodname>getFeature()</methodname> methods.
  238. </para>
  239. <programlisting language="php"><![CDATA[
  240. if ($userAgent->hasFeature('mp3') && $userAgent->getFeature('mp3')) {
  241. // embed HTML5 audio tag...
  242. }
  243. ]]></programlisting>
  244. </sect2>
  245. <sect2 id="zend.http.user-agent.options">
  246. <title>Configuration Options</title>
  247. <variablelist>
  248. <title>UserAgent Options</title>
  249. <para>
  250. The following options may be passed to the constructor or within your application
  251. configuration. A "." indicates another layer of depth in the configuration array; as
  252. an example, assigning "wurflapi.wurfl_config_array.wurfl.main-file" as part of a PHP
  253. configuration would require the following definition:
  254. </para>
  255. <programlisting language="php"><![CDATA[
  256. $config = array(
  257. 'wurflapi' => array(
  258. 'wurfl_config_array' => array(
  259. 'wurfl' => array(
  260. 'main-file' => 'path/to/some/file',
  261. ),
  262. ),
  263. ),
  264. );
  265. ]]></programlisting>
  266. <para>
  267. Each features adapter has its own options available as well, which may be mixed in
  268. with the general UserAgent options.
  269. </para>
  270. <varlistentry>
  271. <term>browser_type</term>
  272. <listitem>
  273. <para>
  274. Used to seed the list of devices the component will search. See also
  275. <varname>identification_sequence</varname>; this value will be prepended to
  276. that list during user agent device discovery.
  277. </para>
  278. </listitem>
  279. </varlistentry>
  280. <varlistentry>
  281. <term>http_accept</term>
  282. <listitem>
  283. <para>
  284. The value of the <varname>Accept</varname> <acronym>HTTP</acronym> header;
  285. used by some user agents to determine capabilities. Set this to seed the
  286. value explicitly.
  287. </para>
  288. </listitem>
  289. </varlistentry>
  290. <varlistentry>
  291. <term>identification_sequence</term>
  292. <listitem>
  293. <para>
  294. A comma-separated list of device types to scan for matches; defaults to
  295. "mobile,desktop".
  296. </para>
  297. </listitem>
  298. </varlistentry>
  299. <varlistentry>
  300. <term>storage.adapter</term>
  301. <listitem>
  302. <para>
  303. The name of a storage adapter used to persist the device capabilities,
  304. typically within a given user session. The value may either be a fully
  305. qualified class name, or a short name to resolve by the plugin loader for
  306. storage classes. By default, uses "Session" as the value, resolving to
  307. <classname>Zend_Http_UserAgent_Storage_Session</classname>.
  308. </para>
  309. </listitem>
  310. </varlistentry>
  311. <varlistentry>
  312. <term>storage.options[]</term>
  313. <listitem>
  314. <para>
  315. An array of options to pass to the constructor of a storage adapter. By
  316. default, the option <varname>browser_type</varname> will be present.
  317. </para>
  318. </listitem>
  319. </varlistentry>
  320. <varlistentry>
  321. <term>plugin_loader.[type] = [class]</term>
  322. <listitem>
  323. <para>
  324. Plugin loader configuration; allows you to specify a pre-configured
  325. <classname>Zend_Loader_PluginLoader</classname> extension class to use for
  326. one of the plugin loader types managed by <classname>UserAgent</classname>
  327. (currently "storage" and "device".
  328. </para>
  329. </listitem>
  330. </varlistentry>
  331. <varlistentry>
  332. <term>server[]</term>
  333. <listitem>
  334. <para>
  335. Typically, you will not set this; this simply allows injection of the
  336. <varname>$_SERVER</varname> superglobal (or a filtered version of it). The
  337. value should be an associative array.
  338. </para>
  339. </listitem>
  340. </varlistentry>
  341. <varlistentry>
  342. <term>user_agent</term>
  343. <listitem>
  344. <para>
  345. The actual <acronym>HTTP</acronym> User-Agent string you wish to try and
  346. match. Typically, this will be auto-discovered from the
  347. <varname>server</varname> array.
  348. </para>
  349. </listitem>
  350. </varlistentry>
  351. <varlistentry>
  352. <term>[browser_type].device.classname</term>
  353. <listitem>
  354. <para>
  355. The device class to use for a given browser type; typically,
  356. <varname>browser_type</varname> will be one of the supported browser
  357. devices, including:
  358. </para>
  359. <itemizedlist>
  360. <listitem><para>Bot</para></listitem>
  361. <listitem><para>Checker</para></listitem>
  362. <listitem><para>Console</para></listitem>
  363. <listitem><para>Desktop</para></listitem>
  364. <listitem><para>Email</para></listitem>
  365. <listitem><para>Feed</para></listitem>
  366. <listitem><para>Mobile</para></listitem>
  367. <listitem><para>Offline</para></listitem>
  368. <listitem><para>Probe</para></listitem>
  369. <listitem><para>Spam</para></listitem>
  370. <listitem><para>Text</para></listitem>
  371. <listitem><para>Validator</para></listitem>
  372. </itemizedlist>
  373. <para>
  374. The <varname>browser_type</varname> should be normalized to lowercase for
  375. configuration purposes.
  376. </para>
  377. </listitem>
  378. </varlistentry>
  379. <varlistentry>
  380. <term>[browser_type].device.path and [browser_type].device.prefix</term>
  381. <listitem>
  382. <para>
  383. An alternate way to specify the device class for a given browser type is to
  384. assume it is named after the device, and that all device classes are in the
  385. same path sharing the same prefix. Configure the prefix and path using these
  386. keys.
  387. </para>
  388. <para>
  389. As an example, the following would look for a class named
  390. "Mobile_Device_Bot" on the path "Mobile/Device/" under the application
  391. library.
  392. </para>
  393. <programlisting language="ini">
  394. resources.useragent.bot.device.path = APPLICATION_PATH '/../library/Mobile/Device"
  395. resources.useragent.bot.device.prefix = "Mobile_Device"
  396. </programlisting>
  397. </listitem>
  398. </varlistentry>
  399. <varlistentry>
  400. <term>[browser_type].features.path and [browser_type].features.classname</term>
  401. <listitem>
  402. <para>
  403. These settings are used to load the features capabilities detection class
  404. for a given browser type. The class will be named using the
  405. <varname>classname</varname> key, and is expected to exist in the file
  406. denoted by the <varname>path</varname> key. The class should implement
  407. <classname>Zend_Http_UserAgent_Features_Adapter</classname>.
  408. </para>
  409. </listitem>
  410. </varlistentry>
  411. <varlistentry>
  412. <term>wurflapi.wurfl_api_version</term>
  413. <listitem>
  414. <para>
  415. If using the <acronym>WURFL</acronym> API, use this key to specify which
  416. version you are using; typically, this will be either "1.0" or "1.1".
  417. </para>
  418. </listitem>
  419. </varlistentry>
  420. <varlistentry>
  421. <term>wurflapi.wurfl_lib_dir</term>
  422. <listitem>
  423. <para>
  424. If using the <acronym>WURFL</acronym> API, use this key to specify in which
  425. directory the library exists.
  426. </para>
  427. </listitem>
  428. </varlistentry>
  429. <varlistentry>
  430. <term>wurflapi.wurfl_config_file</term>
  431. <listitem>
  432. <para>
  433. If using the <acronym>WURFL</acronym> API, use this key to specify the
  434. location of the configuration file you will use; typically, this will be
  435. <filename>resources/wurfl-config.php</filename> within the
  436. <varname>wurfl_lib_dir</varname>.
  437. </para>
  438. </listitem>
  439. </varlistentry>
  440. <varlistentry>
  441. <term>wurflapi.wurfl_config_array.wurfl.main-file</term>
  442. <listitem>
  443. <para>
  444. If using version 1.1 of the <acronym>WURFL</acronym> API, you can omit using
  445. a <varname>wurfl_config_file</varname>, and instead provide an associative
  446. array of configuration values. This particular value indicates the location
  447. of the <filename>wurfl.xml</filename> file containing the actual
  448. <acronym>WURFL</acronym> database.
  449. </para>
  450. </listitem>
  451. </varlistentry>
  452. <varlistentry>
  453. <term>wurflapi.wurfl_config_array.wurfl.patches[]</term>
  454. <listitem>
  455. <para>
  456. If using version 1.1 of the <acronym>WURFL</acronym> API, you can omit using
  457. a <varname>wurfl_config_file</varname>, and instead provide an associative
  458. array of configuration values. This particular value is an array of file
  459. locations containing patchfiles for the <varname>wurfl.main-file</varname>
  460. (which are used to ammend and extend the primary database file).
  461. </para>
  462. </listitem>
  463. </varlistentry>
  464. <varlistentry>
  465. <term>wurflapi.wurfl_config_array.persistence.provider</term>
  466. <listitem>
  467. <para>
  468. If using version 1.1 of the <acronym>WURFL</acronym> API, you can omit using
  469. a <varname>wurfl_config_file</varname>, and instead provide an associative
  470. array of configuration values. This particular value indicates the type of
  471. persistence provider used when caching discovered capabilities. See the
  472. <acronym>WURFL</acronym> documentation for potential values; "file" is a
  473. known good value.
  474. </para>
  475. </listitem>
  476. </varlistentry>
  477. <varlistentry>
  478. <term>wurflapi.wurfl_config_array.persistence.dir</term>
  479. <listitem>
  480. <para>
  481. If using version 1.1 of the <acronym>WURFL</acronym> API, you can omit using
  482. a <varname>wurfl_config_file</varname>, and instead provide an associative
  483. array of configuration values. This particular value indicates the location
  484. where the persistence provider will cache discovered capabilities.
  485. </para>
  486. </listitem>
  487. </varlistentry>
  488. </variablelist>
  489. </sect2>
  490. <sect2 id="zend.http.user-agent.methods">
  491. <title>Available Methods</title>
  492. <variablelist>
  493. <varlistentry id="zend.http.user-agent.methods.constructor">
  494. <term>
  495. <methodsynopsis>
  496. <methodname>__construct</methodname>
  497. <methodparam>
  498. <funcparams>$options = null</funcparams>
  499. </methodparam>
  500. </methodsynopsis>
  501. </term>
  502. <listitem>
  503. <para>
  504. The constructor attempts to determine the current User-Agent based on the
  505. options provided, the current request information, and/or previously discovered
  506. information persisted in storage. Once instantiated, the detected device is
  507. immediately available.
  508. </para>
  509. <para>
  510. Please see <link linkend="zend.http.user-agent.options">configuration
  511. options</link> section for details on the <varname>$options</varname> array.
  512. </para>
  513. </listitem>
  514. </varlistentry>
  515. <varlistentry id="zend.http.user-agent.methods.serialize">
  516. <term>
  517. <methodsynopsis>
  518. <methodname>serialize</methodname>
  519. <methodparam>
  520. <funcparams></funcparams>
  521. </methodparam>
  522. </methodsynopsis>
  523. </term>
  524. <listitem>
  525. <para>
  526. Defined by the <interfacename>Serializable</interfacename> interface, this
  527. method performs logic necessary to determine what within the object should be
  528. serialized when the object is serialized by a storage adapter.
  529. </para>
  530. </listitem>
  531. </varlistentry>
  532. <varlistentry id="zend.http.user-agent.methods.unserialize">
  533. <term>
  534. <methodsynopsis>
  535. <methodname>unserialize</methodname>
  536. <methodparam>
  537. <funcparams>$serialized</funcparams>
  538. </methodparam>
  539. </methodsynopsis>
  540. </term>
  541. <listitem>
  542. <para>
  543. Defined by the <interfacename>Serializable</interfacename> interface, this
  544. method performs logic necessary to determine how to unserialize a previously
  545. serialized instance.
  546. </para>
  547. </listitem>
  548. </varlistentry>
  549. <varlistentry id="zend.http.user-agent.methods.set-options">
  550. <term>
  551. <methodsynopsis>
  552. <methodname>setOptions</methodname>
  553. <methodparam>
  554. <funcparams>$options</funcparams>
  555. </methodparam>
  556. </methodsynopsis>
  557. </term>
  558. <listitem>
  559. <para>
  560. Initializes object state. Please see the <link
  561. linkend="zend.http.user-agent.options">configuration options</link> section
  562. for information on the <varname>$options</varname> array.
  563. </para>
  564. </listitem>
  565. </varlistentry>
  566. <varlistentry id="zend.http.user-agent.methods.get-user-agent">
  567. <term>
  568. <methodsynopsis>
  569. <methodname>getUserAgent</methodname>
  570. <methodparam>
  571. <funcparams></funcparams>
  572. </methodparam>
  573. </methodsynopsis>
  574. </term>
  575. <listitem>
  576. <para>
  577. Retrieve the discovered User-Agent string. Unless set explicitly, this will be
  578. autodiscovered from the server array.
  579. </para>
  580. </listitem>
  581. </varlistentry>
  582. <varlistentry id="zend.http.user-agent.methods.set-user-agent">
  583. <term>
  584. <methodsynopsis>
  585. <methodname>setUserAgent</methodname>
  586. <methodparam>
  587. <funcparams>$userAgent</funcparams>
  588. </methodparam>
  589. </methodsynopsis>
  590. </term>
  591. <listitem>
  592. <para>
  593. Set the User-Agent string explicitly. Once <methodname>getDevice()</methodname>
  594. has been called, this property is marked immutable, and calling this method will
  595. raise an exception.
  596. </para>
  597. </listitem>
  598. </varlistentry>
  599. <varlistentry id="zend.http.user-agent.methods.get-http-accept">
  600. <term>
  601. <methodsynopsis>
  602. <methodname>getHttpAccept</methodname>
  603. <methodparam>
  604. <funcparams>$httpAccept = null</funcparams>
  605. </methodparam>
  606. </methodsynopsis>
  607. </term>
  608. <listitem>
  609. <para>
  610. Retrieve the HTTP Accept header value.
  611. </para>
  612. </listitem>
  613. </varlistentry>
  614. <varlistentry id="zend.http.user-agent.methods.set-http-accept">
  615. <term>
  616. <methodsynopsis>
  617. <methodname>setHttpAccept</methodname>
  618. <methodparam>
  619. <funcparams>$httpAccept</funcparams>
  620. </methodparam>
  621. </methodsynopsis>
  622. </term>
  623. <listitem>
  624. <para>
  625. Explicitly set the HTTP Accept header value. Once
  626. <methodname>getDevice()</methodname> has been called, this property is marked
  627. immutable, and calling this method will raise an exception.
  628. </para>
  629. </listitem>
  630. </varlistentry>
  631. <varlistentry id="zend.http.user-agent.methods.get-storage">
  632. <term>
  633. <methodsynopsis>
  634. <methodname>getStorage</methodname>
  635. <methodparam>
  636. <funcparams>$browser = null</funcparams>
  637. </methodparam>
  638. </methodsynopsis>
  639. </term>
  640. <listitem>
  641. <para>
  642. Retrieves a persistent storage object for a given browser type.
  643. </para>
  644. </listitem>
  645. </varlistentry>
  646. <varlistentry id="zend.http.user-agent.methods.set-storage">
  647. <term>
  648. <methodsynopsis>
  649. <methodname>setStorage</methodname>
  650. <methodparam>
  651. <funcparams>Zend_Http_UserAgent_Storage $storage</funcparams>
  652. </methodparam>
  653. </methodsynopsis>
  654. </term>
  655. <listitem>
  656. <para>
  657. Use this to explicitly set the peristent storage object. Once
  658. <methodname>getDevice()</methodname> has been called, the storage is marked
  659. immutable (as in: you may not inject a new storage object), and calling this
  660. method will raise an exception.
  661. </para>
  662. </listitem>
  663. </varlistentry>
  664. <varlistentry id="zend.http.user-agent.methods.clear-storage">
  665. <term>
  666. <methodsynopsis>
  667. <methodname>clearStorage</methodname>
  668. <methodparam>
  669. <funcparams>$browser = null</funcparams>
  670. </methodparam>
  671. </methodsynopsis>
  672. </term>
  673. <listitem>
  674. <para>
  675. Clears any information in the persistent storage object.
  676. </para>
  677. </listitem>
  678. </varlistentry>
  679. <varlistentry id="zend.http.user-agent.methods.get-config">
  680. <term>
  681. <methodsynopsis>
  682. <methodname>getConfig</methodname>
  683. <methodparam>
  684. <funcparams></funcparams>
  685. </methodparam>
  686. </methodsynopsis>
  687. </term>
  688. <listitem>
  689. <para>
  690. Retrieve configuration parameters.
  691. </para>
  692. </listitem>
  693. </varlistentry>
  694. <varlistentry id="zend.http.user-agent.methods.get-device">
  695. <term>
  696. <methodsynopsis>
  697. <methodname>getDevice</methodname>
  698. <methodparam>
  699. <funcparams></funcparams>
  700. </methodparam>
  701. </methodsynopsis>
  702. </term>
  703. <listitem>
  704. <para>
  705. Use this method to get the User-Agent Device object; this is the object that
  706. will contain the various discovered device capabilities.
  707. </para>
  708. <para>
  709. Discovery of the User-Agent device occurs in this method. Once the device has
  710. been retrieved, the server array, browser type, user agent, http accept, and
  711. storage properties are marked as immutable.
  712. </para>
  713. </listitem>
  714. </varlistentry>
  715. <varlistentry id="zend.http.user-agent.methods.get-browser-type">
  716. <term>
  717. <methodsynopsis>
  718. <methodname>getBrowserType</methodname>
  719. <methodparam>
  720. <funcparams></funcparams>
  721. </methodparam>
  722. </methodsynopsis>
  723. </term>
  724. <listitem>
  725. <para>
  726. Retrieve the discovered browser type; usually one of:
  727. </para>
  728. <itemizedlist>
  729. <listitem><para>Bot</para></listitem>
  730. <listitem><para>Checker</para></listitem>
  731. <listitem><para>Console</para></listitem>
  732. <listitem><para>Desktop</para></listitem>
  733. <listitem><para>Email</para></listitem>
  734. <listitem><para>Feed</para></listitem>
  735. <listitem><para>Mobile</para></listitem>
  736. <listitem><para>Offline</para></listitem>
  737. <listitem><para>Probe</para></listitem>
  738. <listitem><para>Spam</para></listitem>
  739. <listitem><para>Text</para></listitem>
  740. <listitem><para>Validator</para></listitem>
  741. </itemizedlist>
  742. <para>
  743. Unless explicitly set, the browser type is unknown until
  744. <methodname>getDevice()</methodname> has been called.
  745. </para>
  746. </listitem>
  747. </varlistentry>
  748. <varlistentry id="zend.http.user-agent.methods.set-browser-type">
  749. <term>
  750. <methodsynopsis>
  751. <methodname>setBrowserType</methodname>
  752. <methodparam>
  753. <funcparams>$browserType</funcparams>
  754. </methodparam>
  755. </methodsynopsis>
  756. </term>
  757. <listitem>
  758. <para>
  759. Explicitly set the browser type to prepend to the identification sequence. Once
  760. <methodname>getDevice()</methodname> has been called, the browser type is marked
  761. immutable, and calling this method will raise an exception.
  762. </para>
  763. </listitem>
  764. </varlistentry>
  765. <varlistentry id="zend.http.user-agent.methods.get-server">
  766. <term>
  767. <methodsynopsis>
  768. <methodname>getServer</methodname>
  769. <methodparam>
  770. <funcparams></funcparams>
  771. </methodparam>
  772. </methodsynopsis>
  773. </term>
  774. <listitem>
  775. <para>
  776. Retrieve the array of HTTP headers and environment variables used to perform
  777. device discovery. If the array has not yet been set, it is seeded with the
  778. <varname>$_SERVER</varname> superglobal.
  779. </para>
  780. </listitem>
  781. </varlistentry>
  782. <varlistentry id="zend.http.user-agent.methods.set-server">
  783. <term>
  784. <methodsynopsis>
  785. <methodname>setServer</methodname>
  786. <methodparam>
  787. <funcparams>$server</funcparams>
  788. </methodparam>
  789. </methodsynopsis>
  790. </term>
  791. <listitem>
  792. <para>
  793. Explicitly set the "server" array of HTTP headers and environment variables to
  794. use during device discovery. Once <methodname>getDevice()</methodname> has been
  795. called, the server array is marked immutable, and calling this method will raise
  796. an exception.
  797. </para>
  798. </listitem>
  799. </varlistentry>
  800. <varlistentry id="zend.http.user-agent.methods.get-server-value">
  801. <term>
  802. <methodsynopsis>
  803. <methodname>getServerValue</methodname>
  804. <methodparam>
  805. <funcparams>$key</funcparams>
  806. </methodparam>
  807. </methodsynopsis>
  808. </term>
  809. <listitem>
  810. <para>
  811. Retrieve a single value from the server array by key.
  812. </para>
  813. </listitem>
  814. </varlistentry>
  815. <varlistentry id="zend.http.user-agent.methods.set-server-value">
  816. <term>
  817. <methodsynopsis>
  818. <methodname>setServerValue</methodname>
  819. <methodparam>
  820. <funcparams>$key, $value</funcparams>
  821. </methodparam>
  822. </methodsynopsis>
  823. </term>
  824. <listitem>
  825. <para>
  826. Overwrite or define a value in the internal server array. Once
  827. <methodname>getDevice()</methodname> has been called, the server array is marked
  828. immutable, and calling this method will raise an exception.
  829. </para>
  830. </listitem>
  831. </varlistentry>
  832. <varlistentry id="zend.http.user-agent.methods.set-plugin-loader">
  833. <term>
  834. <methodsynopsis>
  835. <methodname>setPluginLoader</methodname>
  836. <methodparam>
  837. <funcparams>$type, $loader</funcparams>
  838. </methodparam>
  839. </methodsynopsis>
  840. </term>
  841. <listitem>
  842. <para>
  843. <varname>$type</varname> may be one of "device" or "storage; the former is used
  844. when attempting to find device classes, the latter for finding storage classes.
  845. <varname>$loader</varname> may be a
  846. <classname>Zend_Loader_PluginLoader</classname> instance, or a string name
  847. containing the classname of a <classname>Zend_Loader_PluginLoader</classname>
  848. extension class.
  849. </para>
  850. </listitem>
  851. </varlistentry>
  852. <varlistentry id="zend.http.user-agent.methods.get-plugin-loader">
  853. <term>
  854. <methodsynopsis>
  855. <methodname>getPluginLoader</methodname>
  856. <methodparam>
  857. <funcparams>$type</funcparams>
  858. </methodparam>
  859. </methodsynopsis>
  860. </term>
  861. <listitem>
  862. <para>
  863. Retrieves either the "device" or "storage" plugin loader instance.
  864. </para>
  865. </listitem>
  866. </varlistentry>
  867. </variablelist>
  868. </sect2>
  869. <sect2 id="zend.http.user-agent.examples">
  870. <title>Examples</title>
  871. <para>
  872. Please see the <link linkend="zend.http.user-agent.quick-start">quick start</link> for
  873. examples at this time.
  874. </para>
  875. </sect2>
  876. </sect1>