Zend_Http_UserAgent.xml 40 KB

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