This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

CloCkWeRX

By: a guest on Jul 21st, 2008  |  syntax: None  |  size: 24.64 KB  |  views: 51  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Index: XSPF.php
  2. ===================================================================
  3. RCS file: /repository/pear/File_XSPF/File/XSPF.php,v
  4. retrieving revision 1.5
  5. diff -u -r1.5 XSPF.php
  6. --- XSPF.php    6 Feb 2006 13:20:53 -0000       1.5
  7. +++ XSPF.php    21 Jul 2008 15:18:32 -0000
  8.  -1,39 +1,34 @@
  9.  <?php
  10. -/* vim: set expandtab tabstop=4 shiftwidth=4: */
  11. -// +---------------------------------------------------------------------------+
  12. -// | File_XSPF PEAR Package for Manipulating XSPF Playlists                    |
  13. -// | Copyright (c) 2005 David Grant <david@grant.org.uk>                       |
  14. -// +---------------------------------------------------------------------------+
  15. -// | This library is free software; you can redistribute it and/or             |
  16. -// | modify it under the terms of the GNU Lesser General Public                |
  17. -// | License as published by the Free Software Foundation; either              |
  18. -// | version 2.1 of the License, or (at your option) any later version.        |
  19. -// |                                                                           |
  20. -// | This library is distributed in the hope that it will be useful,           |
  21. -// | but WITHOUT ANY WARRANTY; without even the implied warranty of            |
  22. -// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         |
  23. -// | Lesser General Public License for more details.                           |
  24. -// |                                                                           |
  25. -// | You should have received a copy of the GNU Lesser General Public          |
  26. -// | License along with this library; if not, write to the Free Software       |
  27. -// | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA |
  28. -// +---------------------------------------------------------------------------+
  29. -
  30.  /**
  31. - * PHP version 4
  32. + * +---------------------------------------------------------------------------+
  33. + * | File_XSPF PEAR Package for Manipulating XSPF Playlists                    |
  34. + * | Copyright (c) 2005 David Grant <david@grant.org.uk>                       |
  35. + * +---------------------------------------------------------------------------+
  36. + * | This library is free software; you can redistribute it and/or             |
  37. + * | modify it under the terms of the GNU Lesser General Public                |
  38. + * | License as published by the Free Software Foundation; either              |
  39. + * | version 2.1 of the License, or (at your option) any later version.        |
  40. + * |                                                                           |
  41. + * | This library is distributed in the hope that it will be useful,           |
  42. + * | but WITHOUT ANY WARRANTY; without even the implied warranty of            |
  43. + * | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         |
  44. + * | Lesser General Public License for more details.                           |
  45. + * |                                                                           |
  46. + * | You should have received a copy of the GNU Lesser General Public          |
  47. + * | License along with this library; if not, write to the Free Software       |
  48. + * | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA |
  49. + * +---------------------------------------------------------------------------+
  50.   *
  51. - * @author      David Grant <david@grant.org.uk>
  52. - * @copyright   Copyright (c) 2005 David Grant
  53. - * @license     http://www.gnu.org/copyleft/lesser.html GNU LGPL
  54. - * @link        http://www.xspf.org/
  55. - * @package     File_XSPF
  56. - * @version     CVS: $Id: XSPF.php,v 1.5 2006/02/06 13:20:53 djg Exp $
  57. - */
  58. -
  59. -/**
  60. + * PHP version 4
  61.   *
  62. + * @category  File
  63. + * @package   File_XSPF
  64. + * @author    David Grant <david@grant.org.uk>
  65. + * @copyright 2005 David Grant
  66. + * @license   http://www.gnu.org/copyleft/lesser.html GNU LGPL
  67. + * @version   CVS: $Id: XSPF.php,v 1.5 2006/02/06 13:20:53 djg Exp $
  68. + * @link      http://www.xspf.org/
  69.   */
  70. -//require_once 'PEAR.php';
  71.  
  72.  require_once 'File/XSPF/Extension.php';
  73.  require_once 'File/XSPF/Handler.php';
  74.  -57,7 +52,7 @@
  75.   *
  76.   * @link    File_XSPF::addAttribution()
  77.   */
  78. -define("FILE_XSPF_ATTRIBUTION_LOCATION",   1);
  79. +define("FILE_XSPF_ATTRIBUTION_LOCATION", 1);
  80.  /**
  81.   * Constant to identify an attribution as an identifier element.
  82.   *
  83.  -72,15 +67,15 @@
  84.  /**
  85.   * This constant signifies an error closing a file.
  86.   */
  87. -define('FILE_XSPF_ERROR_FILE_CLOSURE',    1);
  88. +define('FILE_XSPF_ERROR_FILE_CLOSURE', 1);
  89.  /**
  90.   * This constant signifies an error opening a file.
  91.   */
  92. -define('FILE_XSPF_ERROR_FILE_OPENING',    2);
  93. +define('FILE_XSPF_ERROR_FILE_OPENING', 2);
  94.  /**
  95.   * This constant signfies an error writing to a file.
  96.   */
  97. -define('FILE_XSPF_ERROR_FILE_WRITING',    3);
  98. +define('FILE_XSPF_ERROR_FILE_WRITING', 3);
  99.  /**
  100.   * This constant signifies an error parsing the XSPF file.
  101.   */
  102.  -93,11 +88,15 @@
  103.   * package, and provides the majority of manipulative methods for outputting
  104.   * the XSPF playlist.
  105.   *
  106. - * @example     examples/example_1.php  Generating a One Track Playlist
  107. - * @example     examples/example_2.php  Filtering an Existing Playlist
  108. - * @example     examples/example_3.php  Cataloging a Music Collection
  109. - * @example     examples/example_4.php  Retrieving Statistics from Audioscrobbler
  110. - * @package     File_XSPF
  111. + * @example  examples/example_1.php  Generating a One Track Playlist
  112. + * @example  examples/example_2.php  Filtering an Existing Playlist
  113. + * @example  examples/example_3.php  Cataloging a Music Collection
  114. + * @example  examples/example_4.php  Retrieving Statistics from Audioscrobbler
  115. + * @category File
  116. + * @package  File_XSPF
  117. + * @author   David Grant <david@grant.org.uk>
  118. + * @license  LGPL <http://www.gnu.org/licenses/lgpl.html>
  119. + * @link     http://pear.php.net/package/File_XSPF
  120.   */
  121.  class File_XSPF
  122.  {
  123.  -310,15 +309,17 @@
  124.      /**
  125.       * Parses an existing XSPF file.
  126.       *
  127. -     * This method parses an existing XSPF file into the current File_XSPF instance.  If
  128. -     * successful, this function returns true, otherwise it will return an instance of
  129. -     * PEAR_Error.
  130. +     * This method parses an existing XSPF file into the current File_XSPF instance.
  131. +     * If successful, this function returns true, otherwise it will return an
  132. +     * instance of PEAR_Error.
  133. +     *
  134. +     * @param string $path Path to file
  135.       *
  136.       * @access  public
  137. -     * @param   string $path
  138. -     * @return  mixed
  139. +     * @return  bool|PEAR_Error
  140.       */
  141. -    function parseFile($path) {
  142. +    function parseFile($path)
  143. +    {
  144.          $parser =& new XML_Parser();
  145.          $handle =& new File_XSPF_Handler($this);
  146.  
  147.  -332,7 +333,9 @@
  148.              return PEAR::raiseError($result->getMessage(), $result->getCode());
  149.          }
  150.          if (PEAR::isError($this->_parse_error)) {
  151. -            return PEAR::raiseError($this->_parse_error->getMessage(), $this->_parse_error->getCode());
  152. +            $message = $this->_parse_error->getMessage();
  153. +            $code    = $this->_parse_error->getCode();
  154. +            return PEAR::raiseError($message, $code);
  155.          }
  156.          return true;
  157.      }
  158.  -340,15 +343,17 @@
  159.      /**
  160.       * Parses an XSPF text stream.
  161.       *
  162. -     * This method parses an XSPF text stream into the current File_XSPF instance.  If
  163. -     * successful, this function returns true, otherwise it will return an instance of
  164. -     * PEAR_Error.
  165. +     * This method parses an XSPF text stream into the current File_XSPF instance.
  166. +     * If successful, this function returns true, otherwise it will return an
  167. +     * instance of PEAR_Error.
  168. +     *
  169. +     * @param string $text Text stream
  170.       *
  171.       * @access  public
  172. -     * @param   string $text
  173.       * @return  mixed
  174.       */
  175. -    function parse($text) {
  176. +    function parse($text)
  177. +    {
  178.          $parser =& new XML_Parser();
  179.          $handle =& new File_XSPF_Handler($this);
  180.  
  181.  -362,7 +367,9 @@
  182.              return PEAR::raiseError($result->getMessage(), $result->getCode());
  183.          }
  184.          if (PEAR::isError($this->_parse_error)) {
  185. -            return PEAR::raiseError($this->_parse_error->getMessage(), $this->_parse_error->getCode());
  186. +            $message = $this->_parse_error->getMessage();
  187. +            $code    = $this->_parse_error->getCode();
  188. +            return PEAR::raiseError($message, $code);
  189.          }
  190.          return true;
  191.      }
  192.  -380,13 +387,14 @@
  193.       * children of the attribution element should be in chronological order, so
  194.       * this parameter is included to make the job somewhat more simplistic.
  195.       *
  196. +     * @param object  $attribution File_XSPF_Identifier|File_XSPF_Location
  197. +     * @param boolean $append      true to append, or false to prepend.
  198. +     *
  199.       * @access  public
  200. -     * @param   object  $attribution    an instance of File_XSPF_Identifier or File_XSPF_Location.
  201. -     * @param   int     $type           the type of attribution element.
  202. -     * @param   boolean $append         true to append, or false to prepend.
  203.       * @see     File_XSPF::getLicense()
  204. +     * @return  void
  205.       */
  206. -    function addAttribution($attribution, $append = TRUE)
  207. +    function addAttribution($attribution, $append = true)
  208.      {
  209.          if ($append) {
  210.              array_push($this->_attributions, $attribution);
  211.  -402,8 +410,10 @@
  212.       * will only accept instances of the File_XSPF_Extension class, which is
  213.       * documented elsewhere.
  214.       *
  215. +     * @param File_XSPF_Extension $extension an instance of File_XSPF_Extension
  216. +     *
  217.       * @access  public
  218. -     * @param   File_XSPF_Extension $extension an instance of File_XSPF_Extension
  219. +     * @return  void
  220.       */
  221.      function addExtension($extension)
  222.      {
  223.  -419,8 +429,10 @@
  224.       * must be a instance of the {@link File_XSPF_Link File_XSPF_Link} class or
  225.       * the method will fail.
  226.       *
  227. +     * @param File_XSPF_Link $link an instance of File_XSPF_Link
  228. +     *
  229.       * @access  public
  230. -     * @param   File_XSPF_Link $link    an instance of File_XSPF_Link
  231. +     * @return  void
  232.       */
  233.      function addLink($link)
  234.      {
  235.  -436,8 +448,10 @@
  236.       * must be an instance of the {@link File_XSPF_Meta File_XSPF_Meta} class or
  237.       * the method will fail.
  238.       *
  239. +     * @param File_XSPF_Meta $meta an instance of File_XSPF_Meta.
  240. +     *
  241.       * @access  public
  242. -     * @param   File_XSPF_Meta $meta    an instance of File_XSPF_Meta.
  243. +     * @return  void
  244.       */
  245.      function addMeta($meta)
  246.      {
  247.  -454,8 +468,10 @@
  248.       * class, and should be the focus of the majority of attention for users
  249.       * building a XSPF playlist.
  250.       *
  251. +     * @param File_XSPF_Track $track an instance of File_XSPF_Track.
  252. +     *
  253.       * @access  public
  254. -     * @param   File_XSPF_Track $track  an instance of File_XSPF_Track.
  255. +     * @return  void
  256.       */
  257.      function addTrack($track)
  258.      {
  259.  -483,9 +499,11 @@
  260.       *
  261.       * This method returns an array of attribution elements.
  262.       *
  263. +     * @param int $offset the offset of the attribution to retrieve.
  264. +     *
  265.       * @access  public
  266. -     * @param   int $offset the offset of the attribution to retrieve.
  267. -     * @return  File_XSPF_Identifier|File_XSPF_Location an instance of either File_XSPF_Identifier or File_XSPF_Location
  268. +     * @return  File_XSPF_Identifier|File_XSPF_Location
  269. +     *
  270.       * @see     File_XSPF::getLicense()
  271.       */
  272.      function getAttribution($offset = 0)
  273.  -498,8 +516,10 @@
  274.      /**
  275.       * Get an array of attribution elements.
  276.       *
  277. -     * This method returns a list of attribution elements, which is either an instance
  278. -     * of File_XSPF_Identifier or File_XSPF_Location.
  279. +     * This method returns a list of attribution elements, which is either an
  280. +     * instance of File_XSPF_Identifier or File_XSPF_Location.
  281. +     *
  282. +     * @param unknown $filter Undocumented
  283.       *
  284.       * @access  public
  285.       * @return  array
  286.  -508,17 +528,20 @@
  287.      {
  288.          if (is_null($filter)) {
  289.              return $this->_attributions;
  290. -        } else {
  291. -            $attributions = array();
  292. -            foreach ($this->_attributions as $attribution) {
  293. -                if ($filter & FILE_XSPF_ATTRIBUTION_IDENTIFIER && is_a($attribution, 'file_xspf_identifier')) {
  294. -                    $attributions[] = $attribution;
  295. -                } elseif ($filter & FILE_XSPF_ATTRIBUTION_LOCATION && is_a($attribution, 'file_xspf_location')) {
  296. -                    $attributions[] = $attribution;
  297. -                }
  298. +        }
  299. +
  300. +        $attributions = array();
  301. +        foreach ($this->_attributions as $attribution) {
  302. +            $is_identifier = $filter & FILE_XSPF_ATTRIBUTION_IDENTIFIER;
  303. +            $is_location   = $filter & FILE_XSPF_ATTRIBUTION_LOCATION;
  304. +
  305. +            if ($is_identifier && is_a($attribution, 'file_xspf_identifier')) {
  306. +                $attributions[] = $attribution;
  307. +            } elseif ($is_location && is_a($attribution, 'file_xspf_location')) {
  308. +                $attributions[] = $attribution;
  309.              }
  310. -            return $attributions;
  311.          }
  312. +        return $attributions;
  313.      }
  314.  
  315.      /**
  316.  -714,8 +737,9 @@
  317.       * This method sets an annotation, or human-readable description of this
  318.       * playlist, e.g. "All the Radiohead tracks in my vast collection."
  319.       *
  320. +     * @param string $annotation a human-readable playlist description.
  321. +     *
  322.       * @access  public
  323. -     * @param   string $annotation a human-readable playlist description.
  324.       * @return  boolean
  325.       */
  326.      function setAnnotation($annotation)
  327.  -735,8 +759,10 @@
  328.       * human-readable name of the author of the resource, such as a person's
  329.       * name, or a company, or a group.
  330.       *
  331. +     * @param string $creator the name of the creator of this playlist.
  332. +     *
  333.       * @access  public
  334. -     * @param   string $creator the name of the creator of this playlist.
  335. +     * @return void
  336.       */
  337.      function setCreator($creator)
  338.      {
  339.  -750,8 +776,10 @@
  340.       * playlist.  If the $date parameter contains only digits, this method will
  341.       * assume it is a timestamp, and format it accordingly.
  342.       *
  343. +     * @param mixed $date either an XML schema dateTime or UNIX timestamp.
  344. +     *
  345.       * @access  public
  346. -     * @param   mixed $date either an XML schema dateTime or UNIX timestamp.
  347. +     * @return void
  348.       */
  349.      function setDate($date)
  350.      {
  351.  -772,8 +800,10 @@
  352.       * This method sets an identifier for this playlist, such as a SHA1 hash
  353.       * of the track listing.  The $identifier must be a valid URN.
  354.       *
  355. +     * @param string $identifier the URN of a resource to identify this playlist.
  356. +     *
  357.       * @access  public
  358. -     * @param   string $identifier the URN of a resource to identify this playlist.
  359. +     * @return  bool
  360.       */
  361.      function setIdentifier($identifier)
  362.      {
  363.  -792,8 +822,10 @@
  364.       * fallback image if individual tracks do not themselves have image URLs
  365.       * set.
  366.       *
  367. +     * @param string $image the URL to an image resource.
  368. +     *
  369.       * @access  public
  370. -     * @param   string $image  the URL to an image resource.
  371. +     * @return  bool
  372.       */
  373.      function setImage($image)
  374.      {
  375.  -811,8 +843,10 @@
  376.       * This method sets the URL of a web page containing information about this
  377.       * playlist, and possibly links to other playlists by the same author.
  378.       *
  379. +     * @param string $info the URL of a web page to describe this playlist.
  380. +     *
  381.       * @access  public
  382. -     * @param   string $info the URL of a web page to describe this playlist.
  383. +     * @return  bool
  384.       */
  385.      function setInfo($info)
  386.      {
  387.  -832,9 +866,11 @@
  388.       * Creative Commons licenses, such attributions can be added using
  389.       * the {@link File_XSPF::addAttribution() addAttribution} method.
  390.       *
  391. +     * @param string $license The URL of the license for this playlist.
  392. +     *
  393.       * @access  public
  394.       * @see     File_XSPF::addAttribution()
  395. -     * @param   string $license The URL of the license for this playlist.
  396. +     * @return  bool
  397.       */
  398.      function setLicense($license)
  399.      {
  400.  -854,8 +890,10 @@
  401.       * might add a URL to direct users to the original, such as
  402.       * http://www.example.org/list.xspf.
  403.       *
  404. +     * @param string $location the source URL of this playlist.
  405. +     *
  406.       * @access  public
  407. -     * @param   string $location the source URL of this playlist.
  408. +     * @return  bool
  409.       */
  410.      function setLocation($location)
  411.      {
  412.  -873,8 +911,10 @@
  413.       * This method sets the human-readable title of this playlist.  For example
  414.       * one might call a playlist 'Favourites', or the name of a band.
  415.       *
  416. +     * @param string $title the human-readable title of this playlist.
  417. +     *
  418.       * @access  public
  419. -     * @param   string $title the human-readable title of this playlist.
  420. +     * @return  void
  421.       */
  422.      function setTitle($title)
  423.      {
  424.  -886,13 +926,15 @@
  425.       *
  426.       * This method validates a URI against the allowed schemes for this class.
  427.       *
  428. +     * @param string $uri a URI to test for validity.
  429. +     *
  430.       * @access  private
  431. -     * @param   string  $uri a URI to test for validity.
  432.       * @return  boolean true if valid, false otherwise.
  433.       */
  434.      function _validateUri($uri)
  435.      {
  436. -        return (File_XSPF::_validateUrl($uri, array('strict' => 'false')) && File_XSPF::_validateUrn($uri));
  437. +        return File_XSPF::_validateUrl($uri, array('strict' => 'false'))
  438. +                    && File_XSPF::_validateUrn($uri);
  439.      }
  440.  
  441.      /**
  442.  -900,8 +942,9 @@
  443.       *
  444.       * This method validates a URL, such as http://www.example.org/.
  445.       *
  446. +     * @param string $url a URL to test for validity.
  447. +     *
  448.       * @access  private
  449. -     * @param   string $url a URL to test for validity.
  450.       * @return  boolean true if valid, false otherwise.
  451.       */
  452.      function _validateUrl($url)
  453.  -914,8 +957,9 @@
  454.       *
  455.       * This method validates a URN, such as md5://8b1a9953c4611296a827abf8c47804d7
  456.       *
  457. +     * @param string $urn a URN to test for validity.
  458. +     *
  459.       * @access  private
  460. -     * @param   string $urn a URN to test for validity.
  461.       * @return  boolean true if valid, false otherwise.
  462.       */
  463.      function _validateUrn($urn)
  464.  -932,8 +976,9 @@
  465.       * this function will return true, otherwise it will return an instance of a
  466.       * PEAR_Error object.
  467.       *
  468. +     * @param string $filename the file to which to write this XSPF playlist.
  469. +     *
  470.       * @access  public
  471. -     * @param   string $filename the file to which to write this XSPF playlist.
  472.       * @return  mixed either true for success, or an instance of PEAR_Error.
  473.       * @throws  PEAR_Error
  474.       */
  475.  -941,26 +986,30 @@
  476.      {
  477.          $fp = @fopen($filename, "w");
  478.          if (! $fp) {
  479. -            return (PEAR::raiseError("Could Not Open File", FILE_XSPF_ERROR_FILE_OPENING));
  480. +            return PEAR::raiseError("Could Not Open File",
  481. +                                    FILE_XSPF_ERROR_FILE_OPENING);
  482.          }
  483.          if (! fwrite($fp, $this->toString())) {
  484. -            return (PEAR::raiseError("Writing to File Failed", FILE_XSPF_ERROR_FILE_WRITING));
  485. +            return PEAR::raiseError("Writing to File Failed",
  486. +                                    FILE_XSPF_ERROR_FILE_WRITING);
  487.          }
  488.          if (! fclose($fp)) {
  489. -            return (PEAR::raiseError("Failed to Close File", FILE_XSPT_ERROR_FILE_CLOSURE));
  490. +            return PEAR::raiseError("Failed to Close File",
  491. +                                    FILE_XSPT_ERROR_FILE_CLOSURE);
  492.          }
  493. -        return TRUE;
  494. +        return true;
  495.      }
  496.  
  497.      /**
  498.       * Save this playlist as an M3U playlist.
  499.       *
  500. -     * This method saves the current XSPF playlist in M3U format, providing a one-way
  501. -     * conversion to the popular flat file playlist.  Reverse conversion is considered
  502. -     * to be beyond the scope of this package.
  503. +     * This method saves the current XSPF playlist in M3U format, providing
  504. +     * a one-way conversion to the popular flat file playlist.  Reverse conversion
  505. +     * is considered to be beyond the scope of this package.
  506. +     *
  507. +     * @param string $filename the file to which to write the M3U playlist.
  508.       *
  509.       * @access  public
  510. -     * @param   string $filename the file to which to write the M3U playlist.
  511.       * @return  mixed either true for success or an instance of PEAR_Error
  512.       * @throws  PEAR_Error
  513.       */
  514.  -968,31 +1017,37 @@
  515.      {
  516.          $fp = @fopen($filename, "w");
  517.          if (! $fp) {
  518. -            return (PEAR::raiseError("Could Not Open File", FILE_XSPF_ERROR_FILE_OPENING));
  519. +            return PEAR::raiseError("Could Not Open File",
  520. +                                    FILE_XSPF_ERROR_FILE_OPENING);
  521.          }
  522.          foreach ($this->_tracks as $track) {
  523.              $locations = $track->getLocation();
  524.              foreach ($locations as $location) {
  525.                  if (! fwrite($fp, $location . "\n")) {
  526. -                    return (PEAR::raiseError("Writing to File Failed", FILE_XSPF_ERROR_FILE_WRITING));
  527. +                    return PEAR::raiseError("Writing to File Failed",
  528. +                                            FILE_XSPF_ERROR_FILE_WRITING);
  529.                  }
  530.              }
  531.          }
  532.          if (! fclose($fp)) {
  533. -            return (PEAR::raiseError("Failed to Close File", FILE_XSPT_ERROR_FILE_CLOSURE));
  534. +            return PEAR::raiseError("Failed to Close File",
  535. +                                    FILE_XSPT_ERROR_FILE_CLOSURE);
  536.          }
  537. -        return TRUE;
  538. +        return true;
  539.      }
  540.  
  541.      /**
  542.       * Save this playlist as SMIL format.
  543.       *
  544. -     * This method saves this XSPF playlist as a SMIL file, which can be used as a playlist.
  545. -     * This is a one-way conversion, as reading SMIL files is considered beyond the scope
  546. -     * of this application.
  547. +     * This method saves this XSPF playlist as a SMIL file, which can be used as a
  548. +     * playlist.
  549. +     * This is a one-way conversion, as reading SMIL files is considered beyond the
  550. +     * scope of this application.
  551. +     *
  552. +     * @param string $filename the file to which to write the SMIL playlist.
  553.       *
  554.       * @access  public
  555. -     * @param   string  $filename the file to which to write the SMIL playlist.
  556. +     *
  557.       * @return  mixed   either true if successful, or an instance of PEAR_Error
  558.       * @throws  PEAR_Error
  559.       */
  560.  -1007,7 +1062,9 @@
  561.              $locations = $track->getLocation();
  562.              foreach ($locations as $location) {
  563.                  if ($tracl->getAnnotation()) {
  564. -                    $seq->addChild('audio', '', array('title' => $track->getAnnotation(), 'url' => $location));
  565. +                    $seq->addChild('audio', '',
  566. +                                            array('title' => $track->getAnnotation(),
  567. +                                                    'url' => $location));
  568.                  } else {
  569.                      $seq->addChild('audio', '', array('url' => $location));
  570.                  }
  571.  -1015,16 +1072,19 @@
  572.          }
  573.  
  574.          $fp = @fopen($filename, "w");
  575. -        if (! $fp) {
  576. -            return (PEAR::raiseError("Could Not Open File", FILE_XSPF_ERROR_FILE_OPENING));
  577. -        }
  578. -        if (! fwrite($fp, $tree->get())) {
  579. -            return (PEAR::raiseError("Writing to File Failed", FILE_XSPF_ERROR_FILE_WRITING));
  580. +        if (!$fp) {
  581. +            return PEAR::raiseError("Could Not Open File",
  582. +                                    FILE_XSPF_ERROR_FILE_OPENING);
  583. +        }
  584. +        if (!fwrite($fp, $tree->get())) {
  585. +            return PEAR::raiseError("Writing to File Failed",
  586. +                                    FILE_XSPF_ERROR_FILE_WRITING);
  587. +        }
  588. +        if (!fclose($fp)) {
  589. +            return PEAR::raiseError("Failed to Close File",
  590. +                                    FILE_XSPT_ERROR_FILE_CLOSURE);
  591.          }
  592. -        if (! fclose($fp)) {
  593. -            return (PEAR::raiseError("Failed to Close File", FILE_XSPT_ERROR_FILE_CLOSURE));
  594. -        }
  595. -        return TRUE;
  596. +        return true;
  597.      }
  598.  
  599.      /**
  600.  -1035,6 +1095,7 @@
  601.       * XSPF-aware application.
  602.       *
  603.       * @access  public
  604. +     * @return  void
  605.       */
  606.      function toStream()
  607.      {
  608.  -1053,7 +1114,9 @@
  609.      function toString()
  610.      {
  611.          $tree =& new XML_Tree();
  612. -        $root =& $tree->addRoot('playlist', '', array('version' => $this->_version, 'xmlns' => $this->_xmlns));
  613. +        $root =& $tree->addRoot('playlist', '',
  614. +                                    array('version' => $this->_version,
  615. +                                            'xmlns' => $this->_xmlns));
  616.          if ($this->_annotation) {
  617.              $root->addChild('annotation', $this->getAnnotation());
  618.          }
clone this paste RAW Paste Data