Zend_ProgressBar.xml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.progressbar.introduction" xmlns:xi="http://www.w3.org/2001/XInclude">
  4. <title>Zend_ProgressBar</title>
  5. <sect2 id="zend.progressbar.whatisit">
  6. <title>Introduction</title>
  7. <para>
  8. <classname>Zend_ProgressBar</classname> is a component to create and update
  9. progressbars in different environments. It consists of a single
  10. backend, which outputs the progress through one of the multiple
  11. adapters. On every update, it takes an absolute value and optionally
  12. a status message, and then calls the adapter with some precalculated
  13. values like percentage and estimated time left.
  14. </para>
  15. </sect2>
  16. <sect2 id="zend.progressbar.basic">
  17. <title>Basic Usage of Zend_Progressbar</title>
  18. <para>
  19. <classname>Zend_ProgressBar</classname> is quite easy in its usage. You
  20. simply create a new instance of <classname>Zend_Progressbar</classname>, defining a
  21. min- and a max-value, and choose an adapter to output the data. If
  22. you want to process a file, you would do something like:
  23. </para>
  24. <programlisting language="php"><![CDATA[
  25. $progressBar = new Zend_ProgressBar($adapter, 0, $fileSize);
  26. while (!feof($fp)) {
  27. // Do something
  28. $progressBar->update($currentByteCount);
  29. }
  30. $progressBar->finish();
  31. ]]></programlisting>
  32. <para>
  33. In the first step, an instance of <classname>Zend_ProgressBar</classname> is
  34. created, with a specific adapter, a min-value of 0 and a max-value
  35. of the total filesize. Then a file is processed and in every loop
  36. the progressbar is updated with the current byte count. At the end
  37. of the loop, the progressbar status is set to finished.
  38. </para>
  39. <para>
  40. You can also call the <methodname>update()</methodname> method of
  41. <classname>Zend_ProgressBar</classname> without arguments, which just
  42. recalculates ETA and notifies the adapter. This is useful when there
  43. is no data update but you want the progressbar to be updated.
  44. </para>
  45. </sect2>
  46. <sect2 id="zend.progressbar.persistent">
  47. <title>Persistent progress</title>
  48. <para>
  49. If you want the progressbar to be persistent over multiple requests,
  50. you can give the name of a session namespace as fourth argument
  51. to the constructor. In that case, the progressbar will not notify
  52. the adapter within the constructor, but only when you call
  53. <methodname>update()</methodname> or <methodname>finish()</methodname>. Also the current
  54. value, the status text and the start time for ETA calculation will
  55. be fetched in the next request run again.
  56. </para>
  57. </sect2>
  58. <sect2 id="zend.progressbar.adapters">
  59. <title>Standard adapters</title>
  60. <para>
  61. <classname>Zend_ProgressBar</classname> comes with the following three adapters:
  62. <itemizedlist mark="opencircle">
  63. <listitem>
  64. <para>
  65. <link
  66. linkend="zend.progressbar.adapter.console">Zend_ProgressBar_Adapter_Console</link>
  67. </para>
  68. </listitem>
  69. <listitem>
  70. <para>
  71. <link
  72. linkend="zend.progressbar.adapter.jspush">Zend_ProgressBar_Adapter_JsPush</link>
  73. </para>
  74. </listitem>
  75. <listitem>
  76. <para>
  77. <link
  78. linkend="zend.progressbar.adapter.jspull">Zend_ProgressBar_Adapter_JsPull</link>
  79. </para>
  80. </listitem>
  81. </itemizedlist>
  82. </para>
  83. <xi:include href="Zend_ProgressBar_Adapter_Console.xml" />
  84. <xi:include href="Zend_ProgressBar_Adapter_JsPush.xml" />
  85. <xi:include href="Zend_ProgressBar_Adapter_JsPull.xml" />
  86. </sect2>
  87. </sect1>
  88. <!--
  89. vim:se ts=4 sw=4 et:
  90. -->