Zend_View-Helpers-Gravatar.xml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect3 id="zend.view.helpers.initial.gravatar">
  4. <title>Gravatar View Helper</title>
  5. <para>
  6. The <classname>Gravatar</classname> view helper is used to received avatars from Gravatar's
  7. service.
  8. </para>
  9. <example id="zend.view.helpers.initial.gravatar.usage">
  10. <title>Basic Usage of Gravatar View Helper</title>
  11. <programlisting language="php"><![CDATA[
  12. // From a view script (using XHTML DOCTYPE):
  13. echo $this->gravatar('example@example.com');
  14. /* results in the following output:
  15. <img src="http://www.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8?s=80&d=mm&r=g" />
  16. */
  17. ]]></programlisting>
  18. </example>
  19. <note role="info">
  20. <para>
  21. Of course we can configure this helper. We can change height of image (by default it is
  22. 80px), and add <acronym>CSS</acronym> class or other attributes to image tag. The above
  23. simply shows the most basic usage.
  24. </para>
  25. </note>
  26. <warning>
  27. <title>Use a valid email address!</title>
  28. <para>
  29. The email address you provide the helper should be valid. This class does not validate
  30. the address (only the rating parameter). It is recommended to validate your email
  31. address within your model layer.
  32. </para>
  33. </warning>
  34. <example id="zend.view.helpers.initial.gravatar.advanced">
  35. <title>Advanced Usage of Gravatar View Helper</title>
  36. <para>
  37. There are several ways to configure the returned gravatar. In most cases, you may either
  38. pass an array of options as a second argument to the helper, or call methods on the
  39. returned object in order to configure it.
  40. </para>
  41. <itemizedlist>
  42. <listitem>
  43. <para>
  44. The <varname>img_size</varname> option can be used to specify an alternate
  45. height; alternately, call <methodname>setImgSize()</methodname>.
  46. </para>
  47. </listitem>
  48. <listitem>
  49. <para>
  50. The <varname>secure</varname> option can be used to force usage of SSL in
  51. the returned image URI by passing a boolean <constant>true</constant> value (or
  52. disabling SSL usage by passing <constant>false</constant>). Alternately, call
  53. the <methodname>setSecure()</methodname> method. (By default, the setting
  54. follows the same security as the current page request.)
  55. </para>
  56. </listitem>
  57. <listitem>
  58. <para>
  59. To add attributes to the image, pass an array of key/value pairs as the
  60. <emphasis>third</emphasis> argument to the helper, or call the
  61. <methodname>setAttribs()</methodname> method.
  62. </para>
  63. </listitem>
  64. </itemizedlist>
  65. <programlisting language="php"><![CDATA[
  66. // Within the view script (using HTML DOCTYPE)
  67. echo $this->gravatar('example@example.com',
  68. array('imgSize' => 90, 'defaultImg' => 'monsterid', 'secure' => true),
  69. array('class' => 'avatar', 'title' => 'Title for this image')
  70. );
  71. // Or use mutator methods
  72. $this->gravatar()
  73. ->setEmail('example@example.com')
  74. ->setImgSize(90)
  75. ->setDefaultImg(Zend_View_Helper_Gravatar::DEFAULT_MONSTERID)
  76. ->setSecure(true)
  77. ->setAttribs(array('class' => 'avatar', 'title' => 'Title for this image'));
  78. /* Both generate the following output:
  79. <img class="avatar" title="Title for this image"
  80. src="https://secure.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8?s=90&d=monsterid&r=g" >
  81. */
  82. ]]></programlisting>
  83. </example>
  84. <sect4 id="zend.view.helper.gravatar.options">
  85. <title>Options</title>
  86. <variablelist>
  87. <title>Zend_Service_Gravatar Options</title>
  88. <varlistentry>
  89. <term>img_size</term>
  90. <listitem>
  91. <para>
  92. An integer describing the height of the avatar, in pixels; defaults to "80".
  93. </para>
  94. </listitem>
  95. </varlistentry>
  96. <varlistentry>
  97. <term>default_img</term>
  98. <listitem>
  99. <para>
  100. Image to return if the gravatar service is unable to match the email address
  101. provided. Defaults to "mm", the "mystery man" image.
  102. </para>
  103. </listitem>
  104. </varlistentry>
  105. <varlistentry>
  106. <term>rating</term>
  107. <listitem>
  108. <para>
  109. Audience rating to confine returned images to. Defaults to "g"; may be one
  110. of "g", "pg", "r", or "x", in order of least offensive to most offensive.
  111. </para>
  112. </listitem>
  113. </varlistentry>
  114. <varlistentry>
  115. <term>secure</term>
  116. <listitem>
  117. <para>
  118. Whether or not to load the image via an SSL connection. Defaults to the what
  119. is detected from the current request.
  120. </para>
  121. </listitem>
  122. </varlistentry>
  123. </variablelist>
  124. </sect4>
  125. </sect3>