PageRenderTime 37ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-includes/SimplePie/Caption.php

https://bitbucket.org/abnopanda/wordpress
PHP | 210 lines | 76 code | 14 blank | 120 comment | 5 complexity | bdbabcdcca426a4dadf6675bc4c4ebe9 MD5 | raw file
  1. <?php
  2. /**
  3. * SimplePie
  4. *
  5. * A PHP-Based RSS and Atom Feed Framework.
  6. * Takes the hard work out of managing a complete RSS/Atom solution.
  7. *
  8. * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
  9. * All rights reserved.
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification, are
  12. * permitted provided that the following conditions are met:
  13. *
  14. * * Redistributions of source code must retain the above copyright notice, this list of
  15. * conditions and the following disclaimer.
  16. *
  17. * * Redistributions in binary form must reproduce the above copyright notice, this list
  18. * of conditions and the following disclaimer in the documentation and/or other materials
  19. * provided with the distribution.
  20. *
  21. * * Neither the name of the SimplePie Team nor the names of its contributors may be used
  22. * to endorse or promote products derived from this software without specific prior
  23. * written permission.
  24. *
  25. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  26. * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  27. * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
  28. * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  29. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  31. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  32. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  33. * POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. * @package SimplePie
  36. * @version 1.3.1
  37. * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  38. * @author Ryan Parman
  39. * @author Geoffrey Sneddon
  40. * @author Ryan McCue
  41. * @link http://simplepie.org/ SimplePie
  42. * @license http://www.opensource.org/licenses/bsd-license.php BSD License
  43. */
  44. /**
  45. * Handles `<media:text>` captions as defined in Media RSS.
  46. *
  47. * Used by {@see SimplePie_Enclosure::get_caption()} and {@see SimplePie_Enclosure::get_captions()}
  48. *
  49. * This class can be overloaded with {@see SimplePie::set_caption_class()}
  50. *
  51. * @package SimplePie
  52. * @subpackage API
  53. */
  54. class SimplePie_Caption
  55. {
  56. /**
  57. * Content type
  58. *
  59. * @var string
  60. * @see get_type()
  61. */
  62. var $type;
  63. /**
  64. * Language
  65. *
  66. * @var string
  67. * @see get_language()
  68. */
  69. var $lang;
  70. /**
  71. * Start time
  72. *
  73. * @var string
  74. * @see get_starttime()
  75. */
  76. var $startTime;
  77. /**
  78. * End time
  79. *
  80. * @var string
  81. * @see get_endtime()
  82. */
  83. var $endTime;
  84. /**
  85. * Caption text
  86. *
  87. * @var string
  88. * @see get_text()
  89. */
  90. var $text;
  91. /**
  92. * Constructor, used to input the data
  93. *
  94. * For documentation on all the parameters, see the corresponding
  95. * properties and their accessors
  96. */
  97. public function __construct($type = null, $lang = null, $startTime = null, $endTime = null, $text = null)
  98. {
  99. $this->type = $type;
  100. $this->lang = $lang;
  101. $this->startTime = $startTime;
  102. $this->endTime = $endTime;
  103. $this->text = $text;
  104. }
  105. /**
  106. * String-ified version
  107. *
  108. * @return string
  109. */
  110. public function __toString()
  111. {
  112. // There is no $this->data here
  113. return md5(serialize($this));
  114. }
  115. /**
  116. * Get the end time
  117. *
  118. * @return string|null Time in the format 'hh:mm:ss.SSS'
  119. */
  120. public function get_endtime()
  121. {
  122. if ($this->endTime !== null)
  123. {
  124. return $this->endTime;
  125. }
  126. else
  127. {
  128. return null;
  129. }
  130. }
  131. /**
  132. * Get the language
  133. *
  134. * @link http://tools.ietf.org/html/rfc3066
  135. * @return string|null Language code as per RFC 3066
  136. */
  137. public function get_language()
  138. {
  139. if ($this->lang !== null)
  140. {
  141. return $this->lang;
  142. }
  143. else
  144. {
  145. return null;
  146. }
  147. }
  148. /**
  149. * Get the start time
  150. *
  151. * @return string|null Time in the format 'hh:mm:ss.SSS'
  152. */
  153. public function get_starttime()
  154. {
  155. if ($this->startTime !== null)
  156. {
  157. return $this->startTime;
  158. }
  159. else
  160. {
  161. return null;
  162. }
  163. }
  164. /**
  165. * Get the text of the caption
  166. *
  167. * @return string|null
  168. */
  169. public function get_text()
  170. {
  171. if ($this->text !== null)
  172. {
  173. return $this->text;
  174. }
  175. else
  176. {
  177. return null;
  178. }
  179. }
  180. /**
  181. * Get the content type (not MIME type)
  182. *
  183. * @return string|null Either 'text' or 'html'
  184. */
  185. public function get_type()
  186. {
  187. if ($this->type !== null)
  188. {
  189. return $this->type;
  190. }
  191. else
  192. {
  193. return null;
  194. }
  195. }
  196. }