Zend_Http_UserAgent.xml 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862
  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-browscap">Zend_Http_UserAgent_Features_Adapter_Browscap</link>
  75. utilizes PHP's native <ulink url="http://php.net/get_browser"><function>get_browser()</function></ulink>
  76. in conjunction with <ulink url="http://browsers.garykeith.com/">browscap</ulink>.
  77. While the database featureset is not as fine-grained as other projects, for the
  78. majority of purposes, it provides reliable, fast results.
  79. </para>
  80. </listitem>
  81. <listitem>
  82. <para>
  83. <link
  84. linkend="zend.http.user-agent-features-tera-wurfl">Zend_Http_UserAgent_Features_Adapter_TeraWurfl</link>
  85. consumes the TeraWurfl API, which is built on top of <ulink
  86. url="http://wurfl.sourceforge.net/"><acronym>WURFL</acronym></ulink>,
  87. and aimed at providing a highly available, highly performant lookup mechanism.
  88. </para>
  89. </listitem>
  90. <listitem>
  91. <para>
  92. <link
  93. linkend="zend.http.user-agent-features-device-atlas">Zend_Http_UserAgent_Features_Adapter_DeviceAtlas</link>
  94. consumes the DeviceAtlas API, which is a paid, Enterprise-grade mobile device
  95. capabilities database.
  96. </para>
  97. </listitem>
  98. </itemizedlist>
  99. </sect2>
  100. <sect2 id="zend.http.user-agent.quick-start">
  101. <title>Quick Start</title>
  102. <para>
  103. First, you will need to download the <filename>php_browscap.ini</filename> if you do not
  104. already have it installed on your system:
  105. </para>
  106. <itemizedlist>
  107. <listitem>
  108. <para>
  109. <ulink url="http://browsers.garykeith.com/stream.asp?PHP_BrowsCapINI">php_browscap.ini</ulink>
  110. </para>
  111. </listitem>
  112. </itemizedlist>
  113. <para>
  114. We suggest that you put the file in the same directory as your
  115. <filename>php.ini</filename>.
  116. </para>
  117. <para>
  118. Next, notify PHP of the browscap file via the <varname>browscap</varname> setting.
  119. Because this setting is of type <constant>PHP_INI_SYSTEM</constant>, this must be done
  120. either in your <filename>php.ini</filename> or web server configuration; it cannot be
  121. done in <filename>htaccess</filename> or via <function>ini_set()</function>. We
  122. recommend adding it to your <filename>php.ini</filename>.
  123. </para>
  124. <programlisting language="ini"><![CDATA[
  125. browscap = /path/to/php_browscap.ini
  126. ]]></programlisting>
  127. <para>
  128. If you put <varname>php_browscap.ini</varname> in the same directory as your
  129. <filename>php.ini</filename>, this can be reduced to simply:
  130. </para>
  131. <programlisting language="ini"><![CDATA[
  132. browscap = php_browscap.ini
  133. ]]></programlisting>
  134. <para>
  135. Now, edit your <filename>application.ini</filename> to add the following lines to your
  136. <varname>[production]</varname> section:
  137. </para>
  138. <programlisting language="ini"><![CDATA[
  139. resources.useragent.mobile.features.classname = "Zend_Http_UserAgent_Device_Features_Browscap"
  140. ]]></programlisting>
  141. <para>
  142. At this point, everything is setup. Each request will contain detailed information on
  143. the user agent.
  144. </para>
  145. <para>
  146. You can access this information in a variety of ways. From within the MVC portion of
  147. your application, you can access it via the bootstrap. Within plugins, this is done by
  148. grabbing the bootstrap from the front controller.
  149. </para>
  150. <programlisting language="php"><![CDATA[
  151. $bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap');
  152. $userAgent = $bootstrap->getResource('useragent');
  153. ]]></programlisting>
  154. <para>
  155. From your action controller, use <methodname>getInvokeArg()</methodname> to grab the
  156. bootstrap, and from there, the user agent object.
  157. </para>
  158. <programlisting language="php"><![CDATA[
  159. $bootstrap = $this->getInvokeArg('bootstrap');
  160. $userAgent = $bootstrap->getResource('useragent');
  161. ]]></programlisting>
  162. <para>
  163. Within your view, you can grab it using the <classname>UserAgent</classname> view
  164. helper.
  165. </para>
  166. <programlisting language="php"><![CDATA[
  167. $userAgent = $this->userAgent();
  168. ]]></programlisting>
  169. <para>
  170. Once you have the user agent object, you can query it for different capabilities. As one
  171. example, you may want to use an alternate layout script based on the user agent
  172. capabilities.
  173. </para>
  174. <programlisting language="php"><![CDATA[
  175. $device = $userAgent->getDevice();
  176. $cssSupport = $device->getFeature('cssversion');
  177. $jsSupport = $device->getFeature('javascript');
  178. switch (true) {
  179. case ($jsSupport && $cssSupport >= 3):
  180. $layout->setLayout('layout-html5');
  181. break;
  182. case ($jsSupport && $cssSupport < 3):
  183. $layout->setLayout('layout-xhtml');
  184. break;
  185. case (!$jsSupport && $cssSupport < 3):
  186. $layout->setLayout('layout-html-transitional');
  187. break;
  188. default:
  189. $layout->setLayout('layout-web-1');
  190. break;
  191. }
  192. ]]></programlisting>
  193. <para>
  194. Finally, each device will often have a large number of capabilities not immediately
  195. represented in the device interface. You can query these using the
  196. <methodname>hasFeature()</methodname> and <methodname>getFeature()</methodname> methods,
  197. or simply grab all of them with <methodname>getAllFeatures()</methodname>.
  198. </para>
  199. <programlisting language="php"><![CDATA[
  200. if ($userAgent->hasFeature('mp3') && $userAgent->getFeature('mp3')) {
  201. // embed HTML5 audio tag...
  202. }
  203. ]]></programlisting>
  204. </sect2>
  205. <sect2 id="zend.http.user-agent.options">
  206. <title>Configuration Options</title>
  207. <variablelist>
  208. <title>UserAgent Options</title>
  209. <para>
  210. The following options may be passed to the constructor or within your application
  211. configuration. A "." indicates another layer of depth in the configuration array.
  212. </para>
  213. <para>
  214. Each features adapter has its own options available as well, which may be mixed in
  215. with the general UserAgent options.
  216. </para>
  217. <varlistentry>
  218. <term>browser_type</term>
  219. <listitem>
  220. <para>
  221. Used to seed the list of devices the component will search. See also
  222. <varname>identification_sequence</varname>; this value will be prepended to
  223. that list during user agent device discovery.
  224. </para>
  225. </listitem>
  226. </varlistentry>
  227. <varlistentry>
  228. <term>http_accept</term>
  229. <listitem>
  230. <para>
  231. The value of the <varname>Accept</varname> <acronym>HTTP</acronym> header;
  232. used by some user agents to determine capabilities. Set this to seed the
  233. value explicitly.
  234. </para>
  235. </listitem>
  236. </varlistentry>
  237. <varlistentry>
  238. <term>identification_sequence</term>
  239. <listitem>
  240. <para>
  241. A comma-separated list of device types to scan for matches; defaults to
  242. "mobile,desktop".
  243. </para>
  244. </listitem>
  245. </varlistentry>
  246. <varlistentry>
  247. <term>storage.adapter</term>
  248. <listitem>
  249. <para>
  250. The name of a storage adapter used to persist the device capabilities,
  251. typically within a given user session. The value may either be a fully
  252. qualified class name, or a short name to resolve by the plugin loader for
  253. storage classes. By default, uses "Session" as the value, resolving to
  254. <classname>Zend_Http_UserAgent_Storage_Session</classname>.
  255. </para>
  256. </listitem>
  257. </varlistentry>
  258. <varlistentry>
  259. <term>storage.options[]</term>
  260. <listitem>
  261. <para>
  262. An array of options to pass to the constructor of a storage adapter. By
  263. default, the option <varname>browser_type</varname> will be present.
  264. </para>
  265. </listitem>
  266. </varlistentry>
  267. <varlistentry>
  268. <term>plugin_loader.[type] = [class]</term>
  269. <listitem>
  270. <para>
  271. Plugin loader configuration; allows you to specify a pre-configured
  272. <classname>Zend_Loader_PluginLoader</classname> extension class to use for
  273. one of the plugin loader types managed by <classname>UserAgent</classname>
  274. (currently "storage" and "device".
  275. </para>
  276. </listitem>
  277. </varlistentry>
  278. <varlistentry>
  279. <term>server[]</term>
  280. <listitem>
  281. <para>
  282. Typically, you will not set this; this simply allows injection of the
  283. <varname>$_SERVER</varname> superglobal (or a filtered version of it). The
  284. value should be an associative array.
  285. </para>
  286. </listitem>
  287. </varlistentry>
  288. <varlistentry>
  289. <term>user_agent</term>
  290. <listitem>
  291. <para>
  292. The actual <acronym>HTTP</acronym> User-Agent string you wish to try and
  293. match. Typically, this will be auto-discovered from the
  294. <varname>server</varname> array.
  295. </para>
  296. </listitem>
  297. </varlistentry>
  298. <varlistentry>
  299. <term>[browser_type].device.classname</term>
  300. <listitem>
  301. <para>
  302. The device class to use for a given browser type; typically,
  303. <varname>browser_type</varname> will be one of the supported browser
  304. devices, including:
  305. </para>
  306. <itemizedlist>
  307. <listitem><para>Bot</para></listitem>
  308. <listitem><para>Checker</para></listitem>
  309. <listitem><para>Console</para></listitem>
  310. <listitem><para>Desktop</para></listitem>
  311. <listitem><para>Email</para></listitem>
  312. <listitem><para>Feed</para></listitem>
  313. <listitem><para>Mobile</para></listitem>
  314. <listitem><para>Offline</para></listitem>
  315. <listitem><para>Probe</para></listitem>
  316. <listitem><para>Spam</para></listitem>
  317. <listitem><para>Text</para></listitem>
  318. <listitem><para>Validator</para></listitem>
  319. </itemizedlist>
  320. <para>
  321. The <varname>browser_type</varname> should be normalized to lowercase for
  322. configuration purposes.
  323. </para>
  324. </listitem>
  325. </varlistentry>
  326. <varlistentry>
  327. <term>[browser_type].device.path and [browser_type].device.prefix</term>
  328. <listitem>
  329. <para>
  330. An alternate way to specify the device class for a given browser type is to
  331. assume it is named after the device, and that all device classes are in the
  332. same path sharing the same prefix. Configure the prefix and path using these
  333. keys.
  334. </para>
  335. <para>
  336. As an example, the following would look for a class named
  337. "Mobile_Device_Bot" on the path "Mobile/Device/" under the application
  338. library.
  339. </para>
  340. <programlisting language="ini"><![CDATA[
  341. resources.useragent.bot.device.path = APPLICATION_PATH '/../library/Mobile/Device"
  342. resources.useragent.bot.device.prefix = "Mobile_Device"
  343. ]]></programlisting>
  344. </listitem>
  345. </varlistentry>
  346. <varlistentry>
  347. <term>[browser_type].features.path and [browser_type].features.classname</term>
  348. <listitem>
  349. <para>
  350. These settings are used to load the features capabilities detection class
  351. for a given browser type. The class will be named using the
  352. <varname>classname</varname> key, and is expected to exist in the file
  353. denoted by the <varname>path</varname> key. The class should implement
  354. <classname>Zend_Http_UserAgent_Features_Adapter</classname>.
  355. </para>
  356. </listitem>
  357. </varlistentry>
  358. </variablelist>
  359. </sect2>
  360. <sect2 id="zend.http.user-agent.methods">
  361. <title>Available Methods</title>
  362. <variablelist>
  363. <varlistentry id="zend.http.user-agent.methods.constructor">
  364. <term>
  365. <methodsynopsis>
  366. <methodname>__construct</methodname>
  367. <methodparam>
  368. <funcparams>$options = null</funcparams>
  369. </methodparam>
  370. </methodsynopsis>
  371. </term>
  372. <listitem>
  373. <para>
  374. The constructor attempts to determine the current User-Agent based on the
  375. options provided, the current request information, and/or previously discovered
  376. information persisted in storage. Once instantiated, the detected device is
  377. immediately available.
  378. </para>
  379. <para>
  380. Please see <link linkend="zend.http.user-agent.options">configuration
  381. options</link> section for details on the <varname>$options</varname> array.
  382. </para>
  383. </listitem>
  384. </varlistentry>
  385. <varlistentry id="zend.http.user-agent.methods.serialize">
  386. <term>
  387. <methodsynopsis>
  388. <methodname>serialize</methodname>
  389. <methodparam>
  390. <funcparams></funcparams>
  391. </methodparam>
  392. </methodsynopsis>
  393. </term>
  394. <listitem>
  395. <para>
  396. Defined by the <interfacename>Serializable</interfacename> interface, this
  397. method performs logic necessary to determine what within the object should be
  398. serialized when the object is serialized by a storage adapter.
  399. </para>
  400. </listitem>
  401. </varlistentry>
  402. <varlistentry id="zend.http.user-agent.methods.unserialize">
  403. <term>
  404. <methodsynopsis>
  405. <methodname>unserialize</methodname>
  406. <methodparam>
  407. <funcparams>$serialized</funcparams>
  408. </methodparam>
  409. </methodsynopsis>
  410. </term>
  411. <listitem>
  412. <para>
  413. Defined by the <interfacename>Serializable</interfacename> interface, this
  414. method performs logic necessary to determine how to unserialize a previously
  415. serialized instance.
  416. </para>
  417. </listitem>
  418. </varlistentry>
  419. <varlistentry id="zend.http.user-agent.methods.set-options">
  420. <term>
  421. <methodsynopsis>
  422. <methodname>setOptions</methodname>
  423. <methodparam>
  424. <funcparams>$options</funcparams>
  425. </methodparam>
  426. </methodsynopsis>
  427. </term>
  428. <listitem>
  429. <para>
  430. Initializes object state. Please see the <link
  431. linkend="zend.http.user-agent.options">configuration options</link> section
  432. for information on the <varname>$options</varname> array.
  433. </para>
  434. </listitem>
  435. </varlistentry>
  436. <varlistentry id="zend.http.user-agent.methods.get-user-agent">
  437. <term>
  438. <methodsynopsis>
  439. <methodname>getUserAgent</methodname>
  440. <methodparam>
  441. <funcparams></funcparams>
  442. </methodparam>
  443. </methodsynopsis>
  444. </term>
  445. <listitem>
  446. <para>
  447. Retrieve the discovered User-Agent string. Unless set explicitly, this will be
  448. autodiscovered from the server array.
  449. </para>
  450. </listitem>
  451. </varlistentry>
  452. <varlistentry id="zend.http.user-agent.methods.set-user-agent">
  453. <term>
  454. <methodsynopsis>
  455. <methodname>setUserAgent</methodname>
  456. <methodparam>
  457. <funcparams>$userAgent</funcparams>
  458. </methodparam>
  459. </methodsynopsis>
  460. </term>
  461. <listitem>
  462. <para>
  463. Set the User-Agent string explicitly. Once <methodname>getDevice()</methodname>
  464. has been called, this property is marked immutable, and calling this method will
  465. raise an exception.
  466. </para>
  467. </listitem>
  468. </varlistentry>
  469. <varlistentry id="zend.http.user-agent.methods.get-http-accept">
  470. <term>
  471. <methodsynopsis>
  472. <methodname>getHttpAccept</methodname>
  473. <methodparam>
  474. <funcparams>$httpAccept = null</funcparams>
  475. </methodparam>
  476. </methodsynopsis>
  477. </term>
  478. <listitem>
  479. <para>
  480. Retrieve the HTTP Accept header value.
  481. </para>
  482. </listitem>
  483. </varlistentry>
  484. <varlistentry id="zend.http.user-agent.methods.set-http-accept">
  485. <term>
  486. <methodsynopsis>
  487. <methodname>setHttpAccept</methodname>
  488. <methodparam>
  489. <funcparams>$httpAccept</funcparams>
  490. </methodparam>
  491. </methodsynopsis>
  492. </term>
  493. <listitem>
  494. <para>
  495. Explicitly set the HTTP Accept header value. Once
  496. <methodname>getDevice()</methodname> has been called, this property is marked
  497. immutable, and calling this method will raise an exception.
  498. </para>
  499. </listitem>
  500. </varlistentry>
  501. <varlistentry id="zend.http.user-agent.methods.get-storage">
  502. <term>
  503. <methodsynopsis>
  504. <methodname>getStorage</methodname>
  505. <methodparam>
  506. <funcparams>$browser = null</funcparams>
  507. </methodparam>
  508. </methodsynopsis>
  509. </term>
  510. <listitem>
  511. <para>
  512. Retrieves a persistent storage object for a given browser type.
  513. </para>
  514. </listitem>
  515. </varlistentry>
  516. <varlistentry id="zend.http.user-agent.methods.set-storage">
  517. <term>
  518. <methodsynopsis>
  519. <methodname>setStorage</methodname>
  520. <methodparam>
  521. <funcparams>Zend_Http_UserAgent_Storage $storage</funcparams>
  522. </methodparam>
  523. </methodsynopsis>
  524. </term>
  525. <listitem>
  526. <para>
  527. Use this to explicitly set the peristent storage object. Once
  528. <methodname>getDevice()</methodname> has been called, the storage is marked
  529. immutable (as in: you may not inject a new storage object), and calling this
  530. method will raise an exception.
  531. </para>
  532. </listitem>
  533. </varlistentry>
  534. <varlistentry id="zend.http.user-agent.methods.clear-storage">
  535. <term>
  536. <methodsynopsis>
  537. <methodname>clearStorage</methodname>
  538. <methodparam>
  539. <funcparams>$browser = null</funcparams>
  540. </methodparam>
  541. </methodsynopsis>
  542. </term>
  543. <listitem>
  544. <para>
  545. Clears any information in the persistent storage object.
  546. </para>
  547. </listitem>
  548. </varlistentry>
  549. <varlistentry id="zend.http.user-agent.methods.get-config">
  550. <term>
  551. <methodsynopsis>
  552. <methodname>getConfig</methodname>
  553. <methodparam>
  554. <funcparams></funcparams>
  555. </methodparam>
  556. </methodsynopsis>
  557. </term>
  558. <listitem>
  559. <para>
  560. Retrieve configuration parameters.
  561. </para>
  562. </listitem>
  563. </varlistentry>
  564. <varlistentry id="zend.http.user-agent.methods.get-device">
  565. <term>
  566. <methodsynopsis>
  567. <methodname>getDevice</methodname>
  568. <methodparam>
  569. <funcparams></funcparams>
  570. </methodparam>
  571. </methodsynopsis>
  572. </term>
  573. <listitem>
  574. <para>
  575. Use this method to get the User-Agent Device object; this is the object that
  576. will contain the various discovered device capabilities.
  577. </para>
  578. <para>
  579. Discovery of the User-Agent device occurs in this method. Once the device has
  580. been retrieved, the server array, browser type, user agent, http accept, and
  581. storage properties are marked as immutable.
  582. </para>
  583. </listitem>
  584. </varlistentry>
  585. <varlistentry id="zend.http.user-agent.methods.get-browser-type">
  586. <term>
  587. <methodsynopsis>
  588. <methodname>getBrowserType</methodname>
  589. <methodparam>
  590. <funcparams></funcparams>
  591. </methodparam>
  592. </methodsynopsis>
  593. </term>
  594. <listitem>
  595. <para>
  596. Retrieve the discovered browser type; usually one of:
  597. </para>
  598. <itemizedlist>
  599. <listitem><para>Bot</para></listitem>
  600. <listitem><para>Checker</para></listitem>
  601. <listitem><para>Console</para></listitem>
  602. <listitem><para>Desktop</para></listitem>
  603. <listitem><para>Email</para></listitem>
  604. <listitem><para>Feed</para></listitem>
  605. <listitem><para>Mobile</para></listitem>
  606. <listitem><para>Offline</para></listitem>
  607. <listitem><para>Probe</para></listitem>
  608. <listitem><para>Spam</para></listitem>
  609. <listitem><para>Text</para></listitem>
  610. <listitem><para>Validator</para></listitem>
  611. </itemizedlist>
  612. <para>
  613. Unless explicitly set, the browser type is unknown until
  614. <methodname>getDevice()</methodname> has been called.
  615. </para>
  616. </listitem>
  617. </varlistentry>
  618. <varlistentry id="zend.http.user-agent.methods.set-browser-type">
  619. <term>
  620. <methodsynopsis>
  621. <methodname>setBrowserType</methodname>
  622. <methodparam>
  623. <funcparams>$browserType</funcparams>
  624. </methodparam>
  625. </methodsynopsis>
  626. </term>
  627. <listitem>
  628. <para>
  629. Explicitly set the browser type to prepend to the identification sequence. Once
  630. <methodname>getDevice()</methodname> has been called, the browser type is marked
  631. immutable, and calling this method will raise an exception.
  632. </para>
  633. </listitem>
  634. </varlistentry>
  635. <varlistentry id="zend.http.user-agent.methods.get-server">
  636. <term>
  637. <methodsynopsis>
  638. <methodname>getServer</methodname>
  639. <methodparam>
  640. <funcparams></funcparams>
  641. </methodparam>
  642. </methodsynopsis>
  643. </term>
  644. <listitem>
  645. <para>
  646. Retrieve the array of HTTP headers and environment variables used to perform
  647. device discovery. If the array has not yet been set, it is seeded with the
  648. <varname>$_SERVER</varname> superglobal.
  649. </para>
  650. </listitem>
  651. </varlistentry>
  652. <varlistentry id="zend.http.user-agent.methods.set-server">
  653. <term>
  654. <methodsynopsis>
  655. <methodname>setServer</methodname>
  656. <methodparam>
  657. <funcparams>$server</funcparams>
  658. </methodparam>
  659. </methodsynopsis>
  660. </term>
  661. <listitem>
  662. <para>
  663. Explicitly set the "server" array of HTTP headers and environment variables to
  664. use during device discovery. Once <methodname>getDevice()</methodname> has been
  665. called, the server array is marked immutable, and calling this method will raise
  666. an exception.
  667. </para>
  668. </listitem>
  669. </varlistentry>
  670. <varlistentry id="zend.http.user-agent.methods.get-server-value">
  671. <term>
  672. <methodsynopsis>
  673. <methodname>getServerValue</methodname>
  674. <methodparam>
  675. <funcparams>$key</funcparams>
  676. </methodparam>
  677. </methodsynopsis>
  678. </term>
  679. <listitem>
  680. <para>
  681. Retrieve a single value from the server array by key.
  682. </para>
  683. </listitem>
  684. </varlistentry>
  685. <varlistentry id="zend.http.user-agent.methods.set-server-value">
  686. <term>
  687. <methodsynopsis>
  688. <methodname>setServerValue</methodname>
  689. <methodparam>
  690. <funcparams>$key, $value</funcparams>
  691. </methodparam>
  692. </methodsynopsis>
  693. </term>
  694. <listitem>
  695. <para>
  696. Overwrite or define a value in the internal server array. Once
  697. <methodname>getDevice()</methodname> has been called, the server array is marked
  698. immutable, and calling this method will raise an exception.
  699. </para>
  700. </listitem>
  701. </varlistentry>
  702. <varlistentry id="zend.http.user-agent.methods.set-plugin-loader">
  703. <term>
  704. <methodsynopsis>
  705. <methodname>setPluginLoader</methodname>
  706. <methodparam>
  707. <funcparams>$type, $loader</funcparams>
  708. </methodparam>
  709. </methodsynopsis>
  710. </term>
  711. <listitem>
  712. <para>
  713. <varname>$type</varname> may be one of "device" or "storage; the former is used
  714. when attempting to find device classes, the latter for finding storage classes.
  715. <varname>$loader</varname> may be a
  716. <classname>Zend_Loader_PluginLoader</classname> instance, or a string name
  717. containing the classname of a <classname>Zend_Loader_PluginLoader</classname>
  718. extension class.
  719. </para>
  720. </listitem>
  721. </varlistentry>
  722. <varlistentry id="zend.http.user-agent.methods.get-plugin-loader">
  723. <term>
  724. <methodsynopsis>
  725. <methodname>getPluginLoader</methodname>
  726. <methodparam>
  727. <funcparams>$type</funcparams>
  728. </methodparam>
  729. </methodsynopsis>
  730. </term>
  731. <listitem>
  732. <para>
  733. Retrieves either the "device" or "storage" plugin loader instance.
  734. </para>
  735. </listitem>
  736. </varlistentry>
  737. </variablelist>
  738. </sect2>
  739. <sect2 id="zend.http.user-agent.examples">
  740. <title>Examples</title>
  741. <para>
  742. Please see the <link linkend="zend.http.user-agent.quick-start">quick start</link> for
  743. examples at this time.
  744. </para>
  745. </sect2>
  746. </sect1>