List.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Markup
  17. * @subpackage Renderer_Html
  18. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * @see Zend_Markup_Renderer_Html_HtmlAbstract
  24. */
  25. require_once 'Zend/Markup/Renderer/Html/HtmlAbstract.php';
  26. /**
  27. * Tag interface
  28. *
  29. * @category Zend
  30. * @package Zend_Markup
  31. * @subpackage Renderer_Html
  32. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  33. * @license http://framework.zend.com/license/new-bsd New BSD License
  34. */
  35. class Zend_Markup_Renderer_Html_List extends Zend_Markup_Renderer_Html_HtmlAbstract
  36. {
  37. /**
  38. * Convert the token
  39. *
  40. * @param Zend_Markup_Token $token
  41. * @param string $text
  42. *
  43. * @return string
  44. */
  45. public function convert(Zend_Markup_Token $token, $text)
  46. {
  47. $type = null;
  48. if ($token->hasAttribute('list')) {
  49. // because '01' == '1'
  50. if ($token->getAttribute('list') === '01') {
  51. $type = 'decimal-leading-zero';
  52. } else {
  53. switch ($token->getAttribute('list')) {
  54. case '1':
  55. $type = 'decimal';
  56. break;
  57. case 'i':
  58. $type = 'lower-roman';
  59. break;
  60. case 'I':
  61. $type = 'upper-roman';
  62. break;
  63. case 'a':
  64. $type = 'lower-alpha';
  65. break;
  66. case 'A':
  67. $type = 'upper-alpha';
  68. break;
  69. // the following type is unsupported by IE (including IE8)
  70. case 'alpha':
  71. $type = 'lower-greek';
  72. break;
  73. // the CSS names itself
  74. case 'armenian': // unsupported by IE (including IE8)
  75. case 'decimal':
  76. case 'decimal-leading-zero': // unsupported by IE (including IE8)
  77. case 'georgian': // unsupported by IE (including IE8)
  78. case 'lower-alpha':
  79. case 'lower-greek': // unsupported by IE (including IE8)
  80. case 'lower-latin': // unsupported by IE (including IE8)
  81. case 'lower-roman':
  82. case 'upper-alpha':
  83. case 'upper-latin': // unsupported by IE (including IE8)
  84. case 'upper-roman':
  85. $type = $token->getAttribute('list');
  86. break;
  87. }
  88. }
  89. }
  90. if (null !== $type) {
  91. return "<ol style=\"list-style-type: {$type}\">{$text}</ol>";
  92. } else {
  93. return "<ul>{$text}</ul>";
  94. }
  95. }
  96. }