cvs: pear /MP3_Playlist generate_package_xml.php package.xml /MP3_Playlist/MP3 Playlist.php /MP3_Playlist/MP3/Playlist Common.php M3U.php RSS.php
SMIL.php SQLite.php XHTML.php XML.php /MP3_Playlist/docs/examples index.php result.php /MP3_Playlist/docs/examples/include footer.php head.php
header.php
| From: | Firman Wandayandi | Date: | Sun, 02 Oct 2005 17:38:57 +0000 |
| Subject: | cvs: pear /MP3_Playlist generate_package_xml.php package.xml /MP3_Playlist/MP3 Playlist.php /MP3_Playlist/MP3/Playlist Common.php M3U.php RSS.php SMIL.php SQLite.php XHTML.php XML.php /MP3_Playlist/docs/examples index.php result.php /MP3_Playlist/docs/examples/include footer.php head.php header.php |
||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-35225@lists.php.net to get a copy of this message | ||
firman Sun Oct 2 13:38:57 2005 EDT
Added files:
/pear/MP3_Playlist/MP3 Playlist.php
/pear/MP3_Playlist/MP3/Playlist Common.php M3U.php RSS.php SMIL.php
SQLite.php XHTML.php XML.php
/pear/MP3_Playlist/docs/examples/include footer.php head.php
header.php
/pear/MP3_Playlist/docs/examples index.php result.php
/pear/MP3_Playlist generate_package_xml.php package.xml
Log:
Initial commit
http://cvs.php.net/co.php/pear/MP3_Playlist/MP3/Playlist.php?r=1.1&p=1 Index: pear/MP3_Playlist/MP3/Playlist.php +++ pear/MP3_Playlist/MP3/Playlist.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */ // {{{ Header /** * Class to generate playlists in m3u and other formats including smil, * sqlite, XHTML, RSS and raw XML * * PHP version 5 * * LICENSE: * * The PHP License, version 3.0 * * Copyright (c) 2004-2005 David Costa * * This source file is subject to version 3.0 of the PHP license, * that is bundled with this package in the file LICENSE, and is * available through the world-wide-web at the following url: * http://www.php.net/license/3_0.txt. * If you did not receive a copy of the PHP license and are unable to * obtain it through the world-wide-web, please send a note to * license@php.net so we can mail you a copy immediately. * * @category File Formats * @package MP3_Playlist * @author David Costa <gurugeek@php.net> * @author Ashley Hewson <morbidness@gmail.com> * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2004-2005 David Costa * @license http://www.php.net/license/3_0.txt * The PHP License, version 3.0 * @version CVS: $Id: Playlist.php,v 1.1 2005/10/02 17:38:56 firman Exp $ */ // }}} // {{{ Dependencies /** * Load PEAR_Exception for throw on error. */ require_once 'PEAR/Exception.php'; /** * Require MP3 ID for extensive support of tags within a playlist */ require_once 'MP3/Id.php'; /** * Load Net_URL for fix the given URL. */ require_once 'Net/URL.php'; // }}} // {{{ Class: MP3_Playlist /** * Class MP3_Playlist * * A playlist can be used for both local use and remote streaming. * * The m3u playlist format is supported by Winamp, XMMS, Noatunes and several * other players. * * The Smil playlist format is supported by Real Media Player, Quicktime and * others XHTML allows you to display a fully formatted page or just the tables * to be included in your own template. * * RSS allows you to syndicate the playlist on the fly. The Sqlite function * allows you to backup the list in an existing sqlite database or to create a * database and the table on the fly. * * @category File Formats * @package MP3_Playlist * @author David Costa <gurugeek@php.net> * @author Ashley Hewson <morbidness@gmail.com> * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2004-2005 David Costa * @license http://www.php.net/license/3_0.txt * The PHP License, version 3.0 * @version Release: @package_version@ */ class MP3_Playlist { // {{{ Object Constants /** * Error handling related Constants * Verbose error output in each of the cases */ const E_CANNOT_OPENDIR = 'Unable to open the directory'; const E_CANNOT_SAVEFILE = 'Unable to save file'; const E_CANNOT_OPENDB = 'Unable to open the database'; const E_CANNOT_CREATETABLE = 'Unable to create the playlist table'; const E_CANNOT_INSERT = 'Unable to insert into the playlist table'; const E_CANNOT_SENDHEADER = 'Unable to send HTTP header'; const E_INVALID_MERGE = 'Unable to merge'; const E_INVALID_PLAYLIST = 'Invalid playlist'; const E_UNKNOWN_TYPE = 'Unknown format type'; const E_UNSUPPORTED_TYPE = 'Unsupported format type'; const E_NOT_SAVEABLE = 'Playlist format is not saveable'; const E_NOT_SENDABLE = 'Playlist format is not sendable'; const E_REQUIRED_PARAM = 'Required parameter'; /** * Output type made by MP3_Playlist. */ const TYPE_M3U = 'M3U'; const TYPE_SMIL = 'SMIL'; const TYPE_XML = 'XML'; const TYPE_XHTML = 'XHTML'; const TYPE_RSS = 'RSS'; const TYPE_SQLITE = 'SQLITE'; // }}} // {{{ Static Properties public static $drivers = array( 'm3u' => array( 'file' => 'M3U.php', 'class' => 'MP3_Playlist_M3U' ), 'smil' => array( 'file' => 'SMIL.php', 'class' => 'MP3_Playlist_SMIL' ), 'xml' => array( 'file' => 'XML.php', 'class' => 'MP3_Playlist_XML' ), 'xhtml' => array( 'file' => 'XHTML.php', 'class' => 'MP3_Playlist_XHTML' ), 'rss' => array( 'file' => 'RSS.php', 'class' => 'MP3_Playlist_RSS' ), 'sqlite' => array( 'file' => 'SQLite.php', 'class' => 'MP3_Playlist_SQLite' ) ); // {{{ Object Variables /** * Name of the playlist. suffix is added automatically as per method used * @var string */ public $fileName = 'playlist'; /** * Debug value * @var string */ public $debug = false; /** * Directory to Parse * @var string */ private $parseDirectory; /** * Output directory, where the playlist is saved * @var string */ private $outputDirectory; /** * Url to append on the playlist * @var string */ private $baseUrl; /** * List of songs in an array, formatted after parsing * @var array */ private $list = array(); /** * MP3_ID Object * @var string */ private $mp3; /** * List of files including append directory, location and ID3 tags for XML * and other manipulation * @var array */ private $merged = array(); /** * private variable to check if the method Mergelist is called * @var string */ private $isMerged = false; /** * Driver object instance. * @var object */ private $playlist = null; // }}} // {{{ Constructor /** * Instantiate a new MP3_Playlist object. * * Expects a reading directory, the output directory where the playlist will * be saved and the directory or URL to be used within the playlist. * * @param string $dir The directory to scan * @param string $outdir The directory where to save the playlist file * @param string $baseurl The base url to append on the playlist file * @param bool $debug (optional) Whether print debug message or not, default FALSE * * @return TRUE|PEAR_Error * @see MP3_Playlist::fixPath() */ public function __construct ($dir, $outdir, $baseurl, $debug = false) { // Taking the values from the constructor and assigning it to the // private variables $this->parseDirectory = self::fixPath($dir); $this->outputDirectory = self::fixPath($outdir); // Fix the URL if needed. if (substr($baseurl, -1) != '/') { $baseurl .= '/'; } $url = new Net_URL($baseurl); if (!empty($url->path)) { $dirs = explode('/', $url->path); foreach ($dirs as $key => $value) { if (!empty($value)) { $dirs[$key] = rawurlencode($value); } } $url->path = Net_URL::resolvePath(implode('/', $dirs)); } $this->baseUrl = $url->getURL(); $this->list = array(); // Instantiate the new MP3_If object $this->mp3 = new MP3_Id(); $this->debug = $debug; $this->parse(); } // }}} // {{{ debug() /** * Output debug message. * * @param string $msg Message. */ private function debug($message) { if ($this->debug == true) { print 'MP3_Playlist Debug: ' . $message . "<br />\n"; } } // }}} // {{{ fixPath() /** * Convert Windows directory separator to Unix style and fix ending slash. * * @param string $dir Directory. * * @return string result. */ static public function fixPath($dir) { $dir = str_replace("\\", '/', $dir); if (substr($dir, -1) != '/') { if (PEAR_OS == 'Windows' && substr($dir, -1) != '\\') { $dir .= '/'; } else { $dir .= '/'; } } return $dir; } // }}} // {{{ generateURL() /** * Generates the URL from absolute path. * * @param string $absPath Absolute path. * * @return string URL. */ private function generateURL($absPath) { $absPath = str_replace($this->parseDirectory, '', $absPath); $paths = explode('/', $absPath); foreach ($paths as $key => $value) { if (empty($value)) { continue; } $paths[$key] = rawurlencode($value); } return $this->baseUrl . implode('/', $paths); } // }}} // {{{ parse() /** * Parses the MP3 directory defined in the constructor * * Appends to the files the append directory of MP3 files including * whitespace (necessary for streaming if the append path is a URL) adds * the basic list to the List and Merged Array List is used for basic * playlist writing while Merged will be used for XML and a more * complete output including the ID3 tags. * * @param bool $dir (optional) Directory to parse, this param use for recursive * purpose, default FALSE. * * @throws PEAR_Exception * @return bool TRUE * @see MP3_Playlist::fixPath() * @see MP3_Playlist::generateURL() */ private function parse($dir = false) { if ($dir == false) { $dir = $this->parseDirectory; } // Attempt to open directory. $dh = @opendir($dir); if (!$dh) { throw new PEAR_Exception(self::E_CANNOT_OPENDIR, -1); } while (($entry = readdir($dh)) !== false) { if ($entry == '.' || $entry == '..') { continue; } $abspath = self::fixPath($dir) . $entry; $this->debug('Got entry "' . $abspath . '"'); if (is_dir($abspath)) { $this->debug('Read subdirectory "' . $abspath . '"'); $this->parse($abspath); continue; } else if (strtolower(substr($entry, -4)) == '.mp3') { $url = $this->generateURL($abspath); $this->list[] = $url; // preparing the $this->merged array which will contain both the // $this->list basic information and more ID3 tags $this->merged[] = array( 'BaseName' => basename($entry), 'FullPath' => $abspath, 'URL' => $url, ); } } $this->debug('Merged list <pre>' . print_r($this->merged, true) . '</pre>'); return true; } // }}} // {{{ mergeList() /** * Merges the values from the parsed known elements like file location * and append URL with the ID3 tags * * Sets the value to Not Available if null in the ID3 tag. * Trims results to avoid error in the XML and XHTML display. * * @throws PEAR_Exception * @return bool TRUE * @see MP3_Id::read() */ private function mergeList() { // We will use this in case someone tries to call a method like // makeXHTML before merging $this->isMerged = true; foreach($this->merged as $id => $detail) { // input debug $this->debug('Read file "' . $detail['FullPath'] . '"'); // reading each of the files in our array using the fullpath $temp = $this->mp3->read($detail['FullPath']); //if for some reason mp3 returns an error we raise a pear error if (PEAR::isError($temp)) { throw new PEAR_Exception(self::MP3_PLAYLIST_INVALID_MERG, -1); } // Adding the tags name, artist, genre and album to the merged // array. If not available, which happens in many mp3 files // add not available. // We trim to avoid any kind of problem with the XML XHTML or // RSS generation $title = trim($this->mp3->getTag('name')); if ($title && !empty($title)) { $this->merged[$id]['title'] = trim($title); } else { $this->merged[$id]['title'] = $detail['BaseName']; } $artist = trim($this->mp3->getTag('artists')); if ($artist && !empty($artist)){ $this->merged[$id]['artist'] = $artist; } else { $this->merged[$id]['artist'] = 'Unknown Artist'; } $album = trim($this->mp3->getTag('album')); if ($album && !empty($album)) { $this->merged[$id]['album'] = $album; } else { $this->merged[$id]['album'] = 'Not Available'; } $genre = trim($this->mp3->getTag('genre')); if ($genre && !empty($genre)) { $this->merged[$id]['genre'] = $genre; } else { $this->merged[$id]['genre'] = 'Not Available'; } } // output debug $this->debug('Merged list <pre>' . print_r($this->merged, true) . '</pre>'); return true; } // }}} // {{{ getList() /** * Get list of songs in an array, formatted after parsing. * * @return array */ public function getList() { return $this->list; } // }}} // {{{ getMerged() /** * Get list of files including append directory, location and ID3 tags for XML * and other manipulation. * * @return array * @see MP3_Playlist::mergeList() */ public function getMerged() { if (!$this->isMerged) { $this->mergeList(); } return $this->merged; } // }}} // {{{ make() /** * Generates the playlist according to selected format. * * @param string $type Format type, use one of constants * <pre> * MP3_Playlist::TYPE_M3U M3U playlist * MP3_Playlist::TYPE_SMILL SMILL playlist * MP3_Playlist::TYPE_XML XML format * MP3_Playlist::TYPE_XHTML XHTML output * MP3_Playlist::TYPE_RSS RSS output * MP3_Playlist::TYPE_SQLITE Save to SQLite database * </pre> * @param array $params (optional) Parameters, an associative array contains * values depend on the format. * @param bool $shuffle (optional) Whether to shuffle the list or not. * This parameter only affect on formats * M3U, SMILL and XHTML * * @throws PEAR_Exception * @return bool TRUE * @see MP3_Playlist_Common::__construct() * @see MP3_Playlist_M3U::make() * @see MP3_Playlist_SMIL::make() * @see MP3_Playlist_XML::make() * @see MP3_Playlist_XHTML::make() * @see MP3_Playlist_RSS::make() * @see MP3_Playlist_SQLite::make() */ public function make($type, $params = array(), $shuffle = false) { $type = strtolower($type); if (!isset(self::$drivers[$type])) { throw new PEAR_Exception(self::E_UNSUPPORTED_TYPE); } $file = 'MP3/Playlist/' . self::$drivers[$type]['file']; $class = self::$drivers[$type]['class']; include_once($file); $this->playlist = new $class($this, $shuffle, $this->debug); return $this->playlist->make($params); } // }}} // {{{ save() /** * Save the generated playlist into file. * * @throws PEAR_Exception * @return bool TRUE * @see MP3_Playlist_Common::save() */ public function save() { if (!is_object($this->playlist) || !is_a($this->playlist, 'MP3_Playlist_Common')) { throw new PEAR_Exception(self::E_INVALID_PLAYLIST); } return $this->playlist->save($this->outputDirectory, $this->fileName); } // }}} // {{{ send() /** * Send the generated playlist to browser directly. * * @throws PEAR_Exception * @return bool TRUE * @see MP3_Playlist_Common::send() */ public function send() { if (!is_object($this->playlist) || !is_a($this->playlist, 'MP3_Playlist_Common')) { throw new PEAR_Exception(self::E_INVALID_PLAYLIST); } return $this->playlist->send($this->fileName); } // }}} // {{{ show() /** * Show the generated playlist result * * @throws PEAR_Exception * @see MP3_Playlist_Common::show() */ public function show() { if (!is_object($this->playlist) || !is_a($this->playlist, 'MP3_Playlist_Common')) { throw new PEAR_Exception(self::E_INVALID_PLAYLIST); } return $this->playlist->show(); } // }}} } // }}} /* * Local variables: * mode: php * tab-width: 4 * c-basic-offset: 4 * c-hanging-comment-ender-p: nil * End: */ ?> http://cvs.php.net/co.php/pear/MP3_Playlist/MP3/Playlist/Common.php?r=1.1&p=1 Index: pear/MP3_Playlist/MP3/Playlist/Common.php +++ pear/MP3_Playlist/MP3/Playlist/Common.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */ // {{{ Header /** * File contains MP3_Playlist_Common class. * * PHP version 5 * * LICENSE: * * The PHP License, version 3.0 * * Copyright (c) 2004-2005 David Costa * * This source file is subject to version 3.0 of the PHP license, * that is bundled with this package in the file LICENSE, and is * available through the world-wide-web at the following url: * http://www.php.net/license/3_0.txt. * If you did not receive a copy of the PHP license and are unable to * obtain it through the world-wide-web, please send a note to * license@php.net so we can mail you a copy immediately. * * @category File Formats * @package MP3_Playlist * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2004-2005 David Costa * @license http://www.php.net/license/3_0.txt * The PHP License, version 3.0 * @version CVS: $Id: Common.php,v 1.1 2005/10/02 17:38:56 firman Exp $ */ // }}} // {{{ Class: MP3_Playlist_Common /** * Abstract class of MP3_Playlist drivers class. * * @category File Formats * @package MP3_Playlist * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2004-2005 David Costa * @license http://www.php.net/license/3_0.txt * The PHP License, version 3.0 * @version Release: @package_version@ * @abstract */ abstract class MP3_Playlist_Common { // {{{ Object Variables /** * Debug flag. * @var bool */ protected $debug = false; /** * The playlist result just made. * @var string */ protected $result = ''; /** * Mime type of output. * @var string */ protected $mimeType = ''; /** * File extension (without dot). * @var string */ protected $fileExtension = ''; /** * Whether the result is viewable by browser or not. * @var bool */ protected $isViewable = true; /** * Whether the result is saveable or not. * @var bool */ protected $isSaveable = true; /** * Whether the result is sendable or not. * @var bool */ protected $isSendable = true; /** * Whether to create shuffle list or not. * @var bool */ protected $isShuffle = false; /** * List of song files. */ protected $list = array(); /** * Whether is required to merge list or not to generate * the playlist. * @var bool */ protected $isRequiredMerged = false; /** * List of files including append directory, location and ID3 tags for XML * and other manipulation * @var array */ protected $merged = array(); // }}} // {{{ Constructor /** * Constructor * * @param object $playlist An instance of MP3_Playlist object. * @param bool $shuffle Whether to shuffle the playlist or not. * @param bool $debug Whether to show debug message or not. * * @see MP3_Playlist::getList() * @see MP3_Playlist::getMerged() */ public function __construct(MP3_Playlist $playlist, $shuffle = false, $debug = false) { $this->playlist = $playlist; $this->isShuffle = $shuffle; $this->debug = $debug; $this->list = $this->playlist->getList(); if ($this->isRequiredMerged) { $this->merged = $this->playlist->getMerged(); } } // }}} // {{{ debug() /** * Output debug message. * * @param string $msg Message. */ final private function debug($message) { if ($this->debug == true) { print 'MP3_Playlist Debug: ' . $message . "<br />\n"; } } // }}} // {{{ make() /** * Generates the playlist. * * @param array $params Make parameters. */ public function make($params = array()) { // Should be implement by extends class. } // }}} // {{{ save() /** * Save the generates playlist into file. * * @param string $dir Directory * @param string $filename Filename * * @throws PEAR_Exception * @return bool TRUE */ final public function save($dir, $filename) { if (!$this->isSaveable) { throw new PEAR_Exception(MP3_Playlist::E_NOT_SAVEABLE); } $file = $dir . '/' . $filename . '.' . $this->fileExtension; // trying to create the file in the relevant output directory $fp = @fopen($file,'w+'); // checking if we cannot create the file return an error with details if (!@$fp) { throw new PEAR_Exception(MP3_Playlist::E_CANNOT_SAVEFILE . "filename: $file in " . $this->outputDirectory . ' ' . 'Possible Problem: Permissions', -1); } // writing and closing the file fwrite($fp, $this->result); fclose($fp); return true; } // }}} // {{{ send() /** * Send the generated playlist to browser direclty. * * @param string $filename Filename, if the format not viewable by browser * send method will be switch into download mode. * @throws PEAR_Exception * @return bool TRUE */ final public function send($filename) { if (!$this->isSendable) { throw new PEAR_Exception(MP3_Playlist::E_NOT_SENDABLE, -1); } if (headers_sent()) { throw new PEAR_Exception(MP3_Playlist::E_CANNOT_SENDHEADER, -1); } header('Content-Type: ' . $this->mimeType); if (!$this->isViewable) { header('Content-Disposition: attachment; filename="' . $filename . '.' . $this->fileExtension . '"'); header('Pragma: no-cache'); } print $this->result; return true; } // }}} // {{{ show() /** * Show the generated playlist result. */ public function show() { print htmlspecialchars($this->result); } // }}} } // }}} /* * Local variables: * mode: php * tab-width: 4 * c-basic-offset: 4 * c-hanging-comment-ender-p: nil * End: */ ?> http://cvs.php.net/co.php/pear/MP3_Playlist/MP3/Playlist/M3U.php?r=1.1&p=1 Index: pear/MP3_Playlist/MP3/Playlist/M3U.php +++ pear/MP3_Playlist/MP3/Playlist/M3U.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */ // {{{ Header /** * File contains MP3_Playlist_M3U class. * * PHP version 5 * * LICENSE: * * The PHP License, version 3.0 * * Copyright (c) 2004-2005 David Costa * * This source file is subject to version 3.0 of the PHP license, * that is bundled with this package in the file LICENSE, and is * available through the world-wide-web at the following url: * http://www.php.net/license/3_0.txt. * If you did not receive a copy of the PHP license and are unable to * obtain it through the world-wide-web, please send a note to * license@php.net so we can mail you a copy immediately. * * @category File Formats * @package MP3_Playlist * @author David Costa <gurugeek@php.net> * @author Ashley Hewson <morbidness@gmail.com> * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2004-2005 David Costa * @license http://www.php.net/license/3_0.txt * The PHP License, version 3.0 * @version CVS: $Id: M3U.php,v 1.1 2005/10/02 17:38:56 firman Exp $ */ // }}} // {{{ Dependencies /** * Load MP3_Playlist_Common as the base class. */ require_once 'MP3/Playlist/Common.php'; // }}} // {{{ Class: MP3_Playlist_M3U /** * Class MP3_Playlist_M3U, generates the M3U playlist format. * * The M3U playlist format is supported by Winamp, XMMS, Noatunes * and several other players. * * @category File Formats * @package MP3_Playlist * @author David Costa <gurugeek@php.net> * @author Ashley Hewson <morbidness@gmail.com> * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2004-2005 David Costa * @license http://www.php.net/license/3_0.txt * The PHP License, version 3.0 * @version Release: @package_version@ */ class MP3_Playlist_M3U extends MP3_Playlist_Common { // {{{ Object Properties /** * Mime type of output. * @var string */ protected $mimeType = 'audio/x-mpegurl'; /** * File extension (without dot). * @var string */ protected $fileExtension = 'm3u'; /** * Force M3U format is not viewable by browser. * @var bool */ protected $isViewable = false; // }}} // {{{ make() /** * Generates the M3U playlist format. * * @param array $params (optional) No parameters, ignore this. * * @return bool TRUE */ public function make($params = array()) { // checking if we need to shuffle the filelist inside the array or not if ($this->isShuffle == true) { shuffle($this->list); } // array glue keeping one file per line as per m3u standards $this->result = implode("\n", $this->list); return true; } // }}} } // }}} /* * Local variables: * mode: php * tab-width: 4 * c-basic-offset: 4 * c-hanging-comment-ender-p: nil * End: */ ?> http://cvs.php.net/co.php/pear/MP3_Playlist/MP3/Playlist/RSS.php?r=1.1&p=1 Index: pear/MP3_Playlist/MP3/Playlist/RSS.php +++ pear/MP3_Playlist/MP3/Playlist/RSS.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */ // {{{ Header /** * File contains MP3_Playlist_RSS class. * * PHP version 5 * * LICENSE: * * The PHP License, version 3.0 * * Copyright (c) 2004-2005 David Costa * * This source file is subject to version 3.0 of the PHP license, * that is bundled with this package in the file LICENSE, and is * available through the world-wide-web at the following url: * http://www.php.net/license/3_0.txt. * If you did not receive a copy of the PHP license and are unable to * obtain it through the world-wide-web, please send a note to * license@php.net so we can mail you a copy immediately. * * @category File Formats * @package MP3_Playlist * @author David Costa <gurugeek@php.net> * @author Ashley Hewson <morbidness@gmail.com> * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2004-2005 David Costa * @license http://www.php.net/license/3_0.txt * The PHP License, version 3.0 * @version CVS: $Id: RSS.php,v 1.1 2005/10/02 17:38:56 firman Exp $ */ // }}} // {{{ Dependencies /** * Load MP3_Playlist_Common as the base class. */ require_once 'MP3/Playlist/Common.php'; // }}} // {{{ Class: MP3_Playlist_RSS /** * Class MP3_Playlist_RSS, generates the playlist RSS feed. * * @category File Formats * @package MP3_Playlist * @author David Costa <gurugeek@php.net> * @author Ashley Hewson <morbidness@gmail.com> * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2004-2005 David Costa * @license http://www.php.net/license/3_0.txt * The PHP License, version 3.0 * @version Release: @package_version@ */ class MP3_Playlist_RSS extends MP3_Playlist_Common { // {{{ Object Properties /** * Mime type of output. * @var string */ protected $mimeType = 'application/xml'; /** * File extension (without dot). * @var string */ protected $fileExtension = 'rss'; /** * RSS required the merged list. * @var bool */ protected $isRequiredMerged = true; // }}} // {{{ make() /** * Generate a valid RSS feed from a playlist * * User should define as parameters the title of the feed description * and link for each song the rss produced will include the title and * link and keep within the description the other information available * namely the album, artist, and genre. * * @param array $params Make parameters. * <pre> * title string Feed main title * description string Feed description * link string Link main description * </pre> * * @return bool TRUE */ public function make($params = array()) { if (!isset($params['title'])) { throw new PEAR_Exception(MP3_Playlist::E_REQUIRED_PARAM . ' "title" as feed title', -1); } if (!isset($params['description'])) { throw new PEAR_Exception(MP3_Playlist::E_REQUIRED_PARAM . ' "description" as feed description', -1); } if (!isset($params['link'])) { throw new PEAR_Exception(MP3_Playlist::E_REQUIRED_PARAM . ' "link" as link main description', -1); } $title = $params['title']; $description = isset($params['description']) ? $params['description'] : ''; $link = isset($params['link']) ? $params['link'] : ''; $rssbody = ''; foreach ($this->merged as $prepared) { // formatting for RSS so we avoid errors with & and other signs $prepared['title'] = htmlspecialchars($prepared['title']); $prepared['URL'] = htmlspecialchars($prepared['URL']); $prepared['artist'] = htmlspecialchars($prepared['artist']); $prepared['album'] = htmlspecialchars($prepared['album']); $prepared['genre'] = htmlspecialchars($prepared['genre']); // basic RSS entry for each of the songs $rssbody .= <<<XMLBODY <item> <title>$prepared[title]</title> <link>$prepared[URL]</link> <description>$prepared[artist] - $prepared[album] - $prepared[genre]</description> </item> XMLBODY; } // standard RSS header with the parameters specified by the user $this->result = <<<XMLHEADER <?xml version="1.0" encoding="iso-8859-1"?> <rss version="0.91"> <channel> <title> $title </title> <description> $description </description> <link>$link</link> $rssbody </channel> </rss> XMLHEADER; return true; } // }}} } // }}} http://cvs.php.net/co.php/pear/MP3_Playlist/MP3/Playlist/SMIL.php?r=1.1&p=1 Index: pear/MP3_Playlist/MP3/Playlist/SMIL.php +++ pear/MP3_Playlist/MP3/Playlist/SMIL.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */ // {{{ Header /** * File contains MP3_Playlist_SMIL class. * * PHP version 5 * * LICENSE: * * The PHP License, version 3.0 * * Copyright (c) 2004-2005 David Costa * * This source file is subject to version 3.0 of the PHP license, * that is bundled with this package in the file LICENSE, and is * available through the world-wide-web at the following url: * http://www.php.net/license/3_0.txt. * If you did not receive a copy of the PHP license and are unable to * obtain it through the world-wide-web, please send a note to * license@php.net so we can mail you a copy immediately. * * @category File Formats * @package MP3_Playlist * @author David Costa <gurugeek@php.net> * @author Ashley Hewson <morbidness@gmail.com> * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2004-2005 David Costa * @license http://www.php.net/license/3_0.txt * The PHP License, version 3.0 * @version CVS: $Id: SMIL.php,v 1.1 2005/10/02 17:38:56 firman Exp $ */ // }}} // {{{ Dependencies /** * Load MP3_Playlist_Common as the base class. */ require_once 'MP3/Playlist/Common.php'; // }}} // {{{ Class: MP3_Playlist_SMIL /** * Class MP3_Playlist_SMILL, generates the SMIL (SMIL Multimedia Persentation) * playlist. * * The Smil playlist format is supported by Real Media Player, Quicktime. * * @category File Formats * @package MP3_Playlist * @author David Costa <gurugeek@php.net> * @author Ashley Hewson <morbidness@gmail.com> * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2004-2005 David Costa * @license http://www.php.net/license/3_0.txt * The PHP License, version 3.0 * @version Release: @package_version@ */ class MP3_Playlist_SMIL extends MP3_Playlist_Common { // {{{ Object Properties /** * Mime type of output. * @var string */ protected $mimeType = 'application/smil'; /** * File extension (without dot). * @var string */ protected $fileExtension = 'smil'; /** * Force M3U format is not viewable by browser. * @var bool */ protected $isViewable = false; // }}} // {{{ make() /** * Generates the SMIL (SMIL Multimedia Persentation) playlist. * * @param array $params (optional) No parameters, ignore this. * * @return bool TRUE */ public function make($params = array()) { if ($this->isShuffle == true) { shuffle($this->list); } $AudioTags = array(); foreach ($this->list as $entry) { // add a new <audio> line to the array $AudioTags[] = '<audio src="'.$entry.'" />'; } // Glue the array with \n so that we obtain a string of X lines // containing all files $AudioTags = implode("\n", $AudioTags); // put together the smil $this->result = <<<SMIL <smil> <body> <seq> $AudioTags </seq> </body> </smil> SMIL; return true; } // }}} } // }}} /* * Local variables: * mode: php * tab-width: 4 * c-basic-offset: 4 * c-hanging-comment-ender-p: nil * End: */ ?> http://cvs.php.net/co.php/pear/MP3_Playlist/MP3/Playlist/SQLite.php?r=1.1&p=1 Index: pear/MP3_Playlist/MP3/Playlist/SQLite.php +++ pear/MP3_Playlist/MP3/Playlist/SQLite.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */ // {{{ Header /** * File contains MP3_Playlist_SQLite class. * * PHP version 5 * * LICENSE: * * The PHP License, version 3.0 * * Copyright (c) 2004-2005 David Costa * * This source file is subject to version 3.0 of the PHP license, * that is bundled with this package in the file LICENSE, and is * available through the world-wide-web at the following url: * http://www.php.net/license/3_0.txt. * If you did not receive a copy of the PHP license and are unable to * obtain it through the world-wide-web, please send a note to * license@php.net so we can mail you a copy immediately. * * @category File Formats * @package MP3_Playlist * @author David Costa <gurugeek@php.net> * @author Ashley Hewson <morbidness@gmail.com> * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2004-2005 David Costa * @license http://www.php.net/license/3_0.txt * The PHP License, version 3.0 * @version CVS: $Id: SQLite.php,v 1.1 2005/10/02 17:38:56 firman Exp $ */ // }}} // {{{ Dependencies /** * Load MP3_Playlist_Common as the base class. */ require_once 'MP3/Playlist/Common.php'; // }}} // {{{ Class: MP3_Playlist_M3U /** * Class MP3_Playlist_SMILL for generate and stores an sqlite based * playlist. * * @category File Formats * @package MP3_Playlist * @author David Costa <gurugeek@php.net> * @author Ashley Hewson <morbidness@gmail.com> * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2004-2005 David Costa * @license http://www.php.net/license/3_0.txt * The PHP License, version 3.0 * @version Release: @package_version@ */ class MP3_Playlist_SQLite extends MP3_Playlist_Common { // {{{ Object Properties /** * Force SQLite format is not viewable by browser. * @var bool */ protected $isViewable = false; /** * Force SQLite format is not saveable. * @var bool */ protected $isSaveable = false; /** * Force SQLite format is not sendable. * @var bool */ protected $isSendable = false; /** * Default table columns. * @var array */ protected $columns = array( 'fullpath' => 'fullpath', 'url' => 'url', 'title' => 'title', 'artist' => 'artist', 'album' => 'album', 'genre' => 'genre' ); // }}} // {{{ make() /** * Generate and stores an sqlite based playlist * * Optionally creates a database and the table or can be set to * add the extended playlist in an existing database and table. * * @param array $params Make parameters. * <pre> * db string SQLite database name * table string SQLite database table name * maketable bool (optional) Should the table be created or not, * default is TRUE * columns array (optional) Define the 6 column names yourself. * </pre> * * @return bool TRUE */ public function make($params = array()) { if (!isset($params['db'])) { throw new PEAR_Exception(MP3_Playlist::E_REQUIRED_PARAM . ' "db" as database name', -1); } if (!isset($params['table'])) { throw new PEAR_Exception(MP3_Playlist::E_REQUIRED_PARAM . ' "table" as database table name', -1); } $dbname = $params['db']; $table = $params['table']; $maketable = isset($params['maketable']) ? $params['maketable'] : true; $columns = isset($params['columns']) ? $params['columns'] : false; // check if the user defined his own columns details if (is_array($columns)) { $this->columns = array_merge($this->columns, $columns); } $error =''; // attempt to open the database, if it doesn't exist it will be created $db = @sqlite_open($dbname, 0666, $error); // return an error if we cannot open the sqlite database if (!@$db) { throw new PEAR_Exception(MP3_Playlist::E_CANNOT_OPENDB . "more info: $error", -1); } // creating the table is optional so we check first if the the value is TRUE if ($maketable == true) { // if true we create the table $query = @sqlite_query($db, "CREATE table $table (" . ' id INTEGER PRIMARY KEY, ' . " {$this->columns['fullpath']} varchar(200), " . " {$this->columns['url']} varchar(200), " . " {$this->columns['title']} title varchar(200), " . " {$this->columns['artist']} varchar(200), " . " {$this->columns['album']} varchar (200), " . " {$this->columns['genre']} varchar(200) " . ')' ); // return an error in case that the table cannot be created if (!@$query) { throw new PEAR_Exception(MP3_Playlist::E_CANNOT_CREATETABLE, -1); } } foreach ($this->merged as $prepared){ // escaping each of the values $fullpath = sqlite_escape_string($prepared['FullPath']); $url = sqlite_escape_string($prepared['URL']); $title = sqlite_escape_string($prepared['title']); $artist = sqlite_escape_string($prepared['artist']); $album = sqlite_escape_string($prepared['album']); $genre = sqlite_escape_string($prepared['genre']); // insert query preparation $sql = "INSERT INTO $table ( {$this->columns['fullpath']}, {$this->columns['url']}, {$this->columns['title']}, {$this->columns['artist']}, {$this->columns['album']}, {$this->columns['genre']} ) VALUES ( '$fullpath', '$url', '$title', '$artist', '$album', '$genre' )"; // executing the query $query = @sqlite_query($db, $sql); // if we do have a problem with the query return an error with the // debug information this might occur if the user passes some invalid // values for the columns if (!@$query) { throw new PEAR_Exception(MP3_Playlist::E_CANNOT_INSERT . "debug info print_r ($sql)", -1); } } echo 'List saved on sqlite<br />'; return true; } // }}} } // }}} http://cvs.php.net/co.php/pear/MP3_Playlist/MP3/Playlist/XHTML.php?r=1.1&p=1 Index: pear/MP3_Playlist/MP3/Playlist/XHTML.php +++ pear/MP3_Playlist/MP3/Playlist/XHTML.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */ // {{{ Header /** * File contains MP3_Playlist_XHTML class. * * PHP version 5 * * LICENSE: * * The PHP License, version 3.0 * * Copyright (c) 2004-2005 David Costa * * This source file is subject to version 3.0 of the PHP license, * that is bundled with this package in the file LICENSE, and is * available through the world-wide-web at the following url: * http://www.php.net/license/3_0.txt. * If you did not receive a copy of the PHP license and are unable to * obtain it through the world-wide-web, please send a note to * license@php.net so we can mail you a copy immediately. * * @category File Formats * @package MP3_Playlist * @author David Costa <gurugeek@php.net> * @author Ashley Hewson <morbidness@gmail.com> * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2004-2005 David Costa * @license http://www.php.net/license/3_0.txt * The PHP License, version 3.0 * @version CVS: $Id: XHTML.php,v 1.1 2005/10/02 17:38:56 firman Exp $ */ // }}} // {{{ Dependencies /** * Load MP3_Playlist_Common as the base class. */ require_once 'MP3/Playlist/Common.php'; // }}} // {{{ Class: MP3_Playlist_XHMTL /** * Class MP3_Playlist_XHTML, generates the XHTML page for playlist. * * @category File Formats * @package MP3_Playlist * @author David Costa <gurugeek@php.net> * @author Ashley Hewson <morbidness@gmail.com> * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2004-2005 David Costa * @license http://www.php.net/license/3_0.txt * The PHP License, version 3.0 * @version Release: @package_version@ */ class MP3_Playlist_XHTML extends MP3_Playlist_Common { // {{{ Object Properties /** * Mime type of output. * @var string */ protected $mimeType = 'application/xhtml+xml'; /** * File extension (without dot). * @var string */ protected $fileExtension = 'html'; /** * XHTML required the merged list. * @var bool */ protected $isRequiredMerged = true; // }}} // {{{ make() /** * Generate a valid XHTML playlist with link to the given URL defined * on parsing * * It can also generates the mere tables and therefore allows the user * to customize the look and feel * * @param array $params Make parameters. * <pre> * title string Page title. * fullpage bool (optional) If TRUE it will generate a full XHTML page, * otherwise only tables, default is TRUE. * </pre> * * @return bool TRUE */ public function make($params = array()) { if (!isset($params['title'])) { throw new PEAR_Exception(MP3_Playlist::E_REQUIRED_PARAM . ' "title" as page title', -1); } $title = $params['title']; $fullpage = isset($params['fullpage']) ? $params['fullpage'] : true; // Preparing the numbers $numloop = 0; // Checking if we are producing a shuffled playlist if ($this->isShuffle == true) { shuffle($this->merged); } $xhtmlLoop = ''; // creating the tables foreach ($this->merged as $prepared) { $prepared['title'] = htmlspecialchars($prepared['title']); $prepared['artist'] = htmlspecialchars($prepared['artist']); $prepared['album'] = htmlspecialchars($prepared['album']); $prepared['genre'] = htmlspecialchars($prepared['genre']); // adding random colors in the list $tag = '<tr class="' .($numloop%2 ? 'wh' : 'bl' ) . '">'; $numloop++; $xhtmlLoop .= <<<LOOP $tag <td class="left" title="$numloop">$numloop</td> <td title="{$prepared['title']}"><div style="height:1.2em; width:100%; overflow:hidden;"><a href="{$prepared['URL']}">{$prepared['title']}</a></div></td> <td title="{$prepared['artist']}"><div style="height:1.2em; width:100%; overflow:hidden;">{$prepared['artist']}</div></td> <td title="{$prepared['album']}"><div style="height:1.2em; width:100%; overflow:hidden;">{$prepared['album']}</div></td> <td title="{$prepared['genre']}">{$prepared['genre']}</td> </tr> LOOP; } // XHTML standard headers plus the tables $xhtmlBody = <<<XML <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>$title</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css"> body {font-family:lucida grande, arial;} .box {margin:0 auto 0 auto; font-size:11px;} .header {text-align:center; font-size:13px;} table {border:1px solid #666; margin:0 auto 0 auto; font-size:11px;} td {border:1px #d9d9d9; border-style: none none none solid; padding:2px 5px 2px 5px;} .top {background:url(images/top.png);} .left {border:0px; text-align:right;} .right {text-align:right} .wh {background:#fff;} .bl {background:#edf3fe;} </style> </head> <body> <div class="box"> <div class="header" title="$title">$title</div><br/> <table cellspacing="0"> <tr class="top"> <td class="left"> </td> <td title ="Song Name">Song Name</td> <td title="Artist">Artist</td> <td title="Album">Album</td> <td title="Genre">Genre</td> </tr> $xhtmlLoop </table> <p> <a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml11" alt="Valid XHTML 1.1!" height="31" width="88" /></a> </p> <br/> </div> </body> </html> XML; if ($fullpage == true) { // display the page $this->result = $xhtmlBody; } else { // display the tables only $this->result = $xhtmlLoop; } return true; } // }}} } // }}} http://cvs.php.net/co.php/pear/MP3_Playlist/MP3/Playlist/XML.php?r=1.1&p=1 Index: pear/MP3_Playlist/MP3/Playlist/XML.php +++ pear/MP3_Playlist/MP3/Playlist/XML.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */ // {{{ Header /** * File contains MP3_Playlist_XML class. * * PHP version 5 * * LICENSE: * * The PHP License, version 3.0 * * Copyright (c) 2004-2005 David Costa * * This source file is subject to version 3.0 of the PHP license, * that is bundled with this package in the file LICENSE, and is * available through the world-wide-web at the following url: * http://www.php.net/license/3_0.txt. * If you did not receive a copy of the PHP license and are unable to * obtain it through the world-wide-web, please send a note to * license@php.net so we can mail you a copy immediately. * * @category File Formats * @package MP3_Playlist * @author David Costa <gurugeek@php.net> * @author Ashley Hewson <morbidness@gmail.com> * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2004-2005 David Costa * @license http://www.php.net/license/3_0.txt * The PHP License, version 3.0 * @version CVS: $Id: XML.php,v 1.1 2005/10/02 17:38:57 firman Exp $ */ // }}} // {{{ Dependencies /** * Load MP3_Playlist_Common as the base class. */ require_once 'MP3/Playlist/Common.php'; // }}} // {{{ Class: MP3_Playlist_XML /** * Class MP3_Playlist_XML, generate the XML document for playlist. * * @category File Formats * @package MP3_Playlist * @author David Costa <gurugeek@php.net> * @author Ashley Hewson <morbidness@gmail.com> * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2004-2005 David Costa * @license http://www.php.net/license/3_0.txt * The PHP License, version 3.0 * @version Release: @package_version@ */ class MP3_Playlist_XML extends MP3_Playlist_Common { // {{{ Object Properties /** * Mime type of output. * @var string */ protected $mimeType = 'application/xml'; /** * File extension (without dot). * @var string */ protected $fileExtension = 'xml'; /** * XML required the merged list. * @var bool */ protected $isRequiredMerged = true; // }}} // {{{ preXML() /** * Prepares the xml format for the loop used on makexml * * @param string $value character data that goes into the XML element * @param string $key the name of the XML element * * @return TRUE */ private function preXML($value, $key) { $this->result .= " <$key>" . htmlentities($value) . "</$key>\n"; return true; } // }}} // {{{ make() /** * Generates a valid XML with the playlist values. * * @param array $params (optional) No parameters, ignore this. * * @return bool TRUE */ public function make($params = array()) { // Defining XML headers $this->result = '<?xml version="1.0" encoding="ISO-8859-1" ?>'."\n"; $this->result .= "<playlist>\n"; // Adding the prexml formatted tags to each of the array members // adding also the track tag foreach ($this->merged as $list){ $this->result .= " <track>\n"; array_walk($list, array(&$this, 'preXML')); $this->result .= " </track>\n"; } $this->result .= "</playlist>"; return true; } // }}} } // }}} http://cvs.php.net/co.php/pear/MP3_Playlist/docs/examples/include/footer.php?r=1.1&p=1 Index: pear/MP3_Playlist/docs/examples/include/footer.php +++ pear/MP3_Playlist/docs/examples/include/footer.php </div> </body> </html> http://cvs.php.net/co.php/pear/MP3_Playlist/docs/examples/include/head.php?r=1.1&p=1 Index: pear/MP3_Playlist/docs/examples/include/head.php +++ pear/MP3_Playlist/docs/examples/include/head.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>PEAR::MP3_Playlist Usage Example</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <style type="text/css"> body, table, select, textarea, input { font-family: Arial, Verdana, Helvetica, sans-serif; font-size: 12px; color: #333333 } body { text-align: center; } ul { margin: 0 0 0 20px; } h1 { font-size:18px; color: #006600; } h2 { font-size: 16px; color: #006600; } h3 { font-size: 14px; color: #006600; } hr { border: 0; background: #006600; color: #006600; } td { vertical-align: top; } a:link { color: #006600 } a:visited { color: #030 } a:hover { color: #003300 } form { margin: 0; padding: 0; } img { border: 0; } #body { width: 760px; text-align: left; margin: auto; }..flag { font-style: italic; color: #ff3300; }..nav { text-align: right; padding: 4px; border-bottom: 1px solid black; }..code { border: 1px dashed grey; padding: 4px; background: #f8f8f8; } </style> </head> <body> <div id="body"> http://cvs.php.net/co.php/pear/MP3_Playlist/docs/examples/include/header.php?r=1.1&p=1 Index: pear/MP3_Playlist/docs/examples/include/header.php +++ pear/MP3_Playlist/docs/examples/include/header.php <h1>PEAR::MP3_Playlist Usage Example</h1> MP3_Playlist Copyright © 2004-2005 by David Costa. <hr /> http://cvs.php.net/co.php/pear/MP3_Playlist/docs/examples/index.php?r=1.1&p=1 Index: pear/MP3_Playlist/docs/examples/index.php +++ pear/MP3_Playlist/docs/examples/index.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker */ include_once 'include/head.php'; include_once 'include/header.php'; require_once 'Net/URL.php'; $url = new Net_URL; $url->path = dirname($url->path); ?> <script language="javascript" type="text/javascript"> function hideElement(id) { var obj = document.getElementById(id); if (obj != null) { obj.style.display = 'none'; } } function showElement(id) { var obj = document.getElementById(id); if (obj != null) { obj.style.display = ''; } } function showMakeParams(type) { var makeTypes = new Array('M3U', 'SMIL', 'XML', 'XHTML', 'RSS', 'SQLite'); showElement('Params' + type); for (var i = 0; i < makeTypes.length; i++) { if (makeTypes[i] == type) { continue; } hideElement('Params' + makeTypes[i]); } } function notify(obj, msg) { if (obj != null) { obj.style.backgroundColor = '#ADDBAD'; alert(msg); } } function validateParams() { var theForm = document.FormParams; if (theForm.InputDir.value == '') { notify(theForm.InputDir, 'Please type the Input Directory'); return false; } if (theForm.BaseURL.value == '') { notify(theForm.BaseURL, 'Please type the Base URL'); return false; } if (document.getElementById('output_save').checked) { if (theForm.OutputDir.value == '') { notify(theForm.OutputDir, 'Please type the Output Directory'); return false; } } if (document.getElementById('output_save').checked || document.getElementById('output_send').checked) { if (theForm.FileName.value == '') { notify(theForm.FileName, 'Please type the File Name'); return false; } } if (theForm.MakeType.value == '') { notify(theForm.MakeType, 'Please select the Type'); return false; } if (theForm.MakeType.value == 'XHTML') { if (document.getElementById('ParamsXHTML[title]').value == '') { notify(document.getElementById('ParamsXHTML[title]'), 'Please type the Title'); return false; } } if (theForm.MakeType.value == 'RSS') { if (document.getElementById('ParamsRSS[title]').value == '') { notify(document.getElementById('ParamsRSS[title]'), 'Please type the Feed Title'); return false; } if (document.getElementById('ParamsRSS[description]').value == '') { notify(document.getElementById('ParamsRSS[description]'), 'Please type the Feed Description'); return false; } if (document.getElementById('ParamsRSS[link]').value == '') { notify(document.getElementById('ParamsRSS[link]'), 'Please type the Feed Link'); return false; } } if (theForm.MakeType.value == 'SQLite') { if (document.getElementById('ParamsSQLite[db]').value == '') { notify(document.getElementById('ParamsSQLite[db]'), 'Please type the Database Name'); return false; } if (document.getElementById('ParamsSQLite[table]').value == '') { notify(document.getElementById('ParamsSQLite[table]'), 'Please type the Database Table Name'); return false; } } return true; } </script> Please specified the parameters, however by default this example assumed that your songs placed in <b><?php print dirname(__FILE__) . DIRECTORY_SEPARATOR . 'songs'; ?></b>. <h3>Main Parameters</h3> <form name="FormParams" id="FormParams" action="result.php" target="result" method="post" onSubmit="return validateParams();"> <b>Input Directory:</b><br /> <small>Make sure, this directory readable by Web server.</small><br /> <input type="text" name="InputDir" value="<?php print dirname(__FILE__) . DIRECTORY_SEPARATOR . 'songs'; ?>" size="80" /><br /> <b>Base URL:</b><br /> <small>The base URL where you placed your songs.</small><br /> <input type="text" name="BaseURL" value="<?php print $url->getURL() . '/songs'; ?>" size="80" /><br /> <div id="output_dir" style="display: none"> <b>Output Directory:</b><br /> <input type="text" name="OutputDir" value="<?php print dirname(__FILE__); ?>" size="80" /><br /> </div> <div id="filename" style="display: "> <b>File Name:</b><br /> <small>Name of the playlist (without file extension). Suffix is added automatically.</small> <input type="text" name="FileName" value="test" size="80" /><br /> </div> <b>Debug:</b><br /> <small>Show debug messages?</small><br /> <input type="radio" name="debug" id="debug_yes" value="1" /> <label for="debug_yes">Yes</label> <input type="radio" name="debug" id="debug_no" value="0" checked /> <label for="debug_no">No</label> <h3>Make Parameters</h3> <b>Make What?</b><br /> <select name="MakeType" onChange="showMakeParams(this.value);"> <option value="">Select ...</option> <option value="M3U">M3U</option> <option value="SMIL">SMIL</option> <option value="XML">XML</option> <option value="XHTML">XHTML</option> <option value="RSS">RSS</option> <option value="SQLite">SQLite</option> </select><br /> <div id="ParamsXHTML" style="display: none;"> <b>Title (title):</b><br /> <input type="text" name="ParamsXHTML[title]" id="ParamsXHTML[title]" value="Generated Playlist" size="80" /><br /> <b>Fullpage (fullpage):</b><br /> <input type="radio" name="ParamsXHTML[fullpage]" id="ParamsXHTML_fullpage_yes" value="1" checked /> <label for="ParamsXHTML_fullpage_yes">Yes</label> <input type="radio" name="ParamsXHTML[fullpage]" id="ParamsXHTML_fullpage_no" value="0" /> <label for="ParamsXHTML_fullpage_no">No</label> </div> <div id="ParamsRSS" style="display: none;"> <b>Feed Title (title):</b><br /> <input type="text" name="ParamsRSS[title]" id="ParamsRSS[title]" value="Generated Playlist" size="80" /><br /> <b>Feed Description (description):</b><br /> <input type="text" name="ParamsRSS[description]" id="ParamsRSS[description]" value="MP3_Playlist Usage Example" size="80" /><br /> <b>Feed Link (link):</b><br /> <input type="text" name="ParamsRSS[link]" id="ParamsRSS[link]" value="<?php print $url->getURL(); ?>" size="80" /><br /> </div> <div id="ParamsSQLite" style="display: none;"> <b>Database Name (db):</b><br /> <small>Absolute fullpath also allowed</small><br /> <input type="text" name="ParamsSQLite[db]" id="ParamsSQLite[db]" value="playlist.sqlite" size="80" /><br /> <b>Database Table Name (table):</b><br /> <input type="text" name="ParamsSQLite[table]" id="ParamsSQLite[table]" value="playlist" size="80" /><br /> <b>Create Table (maketable):</b><br /> <input type="radio" name="ParamsSQLite[maketable]" id="ParamsSQLite_maketable_yes" value="1" checked /> <label for="ParamsSQLite_maketable_yes">Yes</label> <input type="radio" name="ParamsSQLite[maketable]" id="ParamsSQLite_maketable_no" value="0" /> <label for="ParamsSQLite_maketable_no">No</label><br /> <b>Columns (columns):</b><br /> <small>6 columns, separated by commas (fullpath, url, title, artist, album, genre)</small><br /> <input type="text" name="ParamsSQLite[columns]" id="ParamsSQLite[columns]" value="fullpath, url, title, artist, album, genre" size="80" /><br /> </div> <b>Shuffle:</b><br /> <input type="radio" name="shuffle" id="shuffle_yes" value="1" /> <label for="shuffle_yes">Yes</label> <input type="radio" name="shuffle" id="shuffle_no" value="0" checked /> <label for="shuffle_no">No</label> <h3>Output</h3> <b>Options:</b><br /> <input type="radio" name="output" id="output_save" value="save" onClick="showElement('output_dir'); showElement('filename');" /> <label for="output_save">Save</label> <input type="radio" name="output" id="output_send" value="send" onClick="hideElement('output_dir'); showElement('filename');" checked /> <label for="output_send">Send</label> <input type="radio" name="output" id="output_show" value="show" onClick="hideElement('output_dir'); hideElement('filename');" /> <label for="output_show">Show</label><br /> <input type="submit" name="submit" value="Make It!"> </form> <h3>Result</h3> <b>Output Result (if available):</b> <iframe name="result" style="width:100%; height: 400px" frameborder="1"></iframe> <h3>Source</h3> <div class="code"> <?php highlight_file(dirname(__FILE__) . '/result.php'); ?> </div> <script language="javascript" type="text/javascript"> // Force browser saved form informations. document.getElementById('output_send').checked = true; document.FormParams.MakeType.options[0].selected = true; </script> <?php include_once 'include/footer.php'; /* * Local variables: * mode: php * tab-width: 4 * c-basic-offset: 4 * c-hanging-comment-ender-p: nil * End: */ ?> http://cvs.php.net/co.php/pear/MP3_Playlist/docs/examples/result.php?r=1.1&p=1 Index: pear/MP3_Playlist/docs/examples/result.php +++ pear/MP3_Playlist/docs/examples/result.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker */ /** * Load MP3_Playlist class. */ require_once 'MP3/Playlist.php'; if (isset($_POST['submit'])) { // Default make parameters $params = array(); // Pick the type. switch ($_POST['MakeType']) { case 'M3U': $type = MP3_Playlist::TYPE_M3U; break; case 'SMIL': $type = MP3_Playlist::TYPE_SMIL; break; case 'XML': $type = MP3_Playlist::TYPE_XML; break; case 'XHTML': $type = MP3_Playlist::TYPE_XHTML; $params = $_POST['ParamsXHTML']; break; case 'RSS': $type = MP3_Playlist::TYPE_RSS; $params = $_POST['ParamsRSS']; break; case 'SQLite': $type = MP3_Playlist::TYPE_SQLITE; $params = $_POST['ParamsSQLite']; break; } // Create new instance of MP3_Playlist. $playlist = new MP3_Playlist($_POST['InputDir'], $_POST['OutputDir'], $_POST['BaseURL'], $_POST['debug']); try { // Call make() method, where 3 parameters (type, params and shuffle). $playlist->make($type, $params, $_POST['shuffle']); $outputFunction = $_POST['output'] . '()'; // Decoration. if ($_POST['output'] == 'show') { print "<pre>\n"; } // Call output method. $playlist->$_POST['output'](); // Decoration. if ($_POST['output'] == 'show') { print "</pre>\n"; } } catch (PEAR_Exception $e) { print '<b>Error</b>: ' . $e->getMessage(); } } /* * Local variables: * mode: php * tab-width: 4 * c-basic-offset: 4 * c-hanging-comment-ender-p: nil * End: */ ?> http://cvs.php.net/co.php/pear/MP3_Playlist/generate_package_xml.php?r=1.1&p=1 Index: pear/MP3_Playlist/generate_package_xml.php +++ pear/MP3_Playlist/generate_package_xml.php <?php require_once('PEAR/PackageFileManager.php'); $pkg = new PEAR_PackageFileManager; $packagedir = dirname(__FILE__); $self = basename(__FILE__); $desc = "MP3_Playlist is a php library to facilitate the creation and to some extend the rendering of MP3 playlists. It scans a local folder with all the MP3 files and outputs the playlist in several formats including M3U, SMIL, XML, XHTML with the possibility to backup the lists on the fly with an SQLite DB."; $options = array( 'simpleoutput' => true, 'doctype' => 'D:\Net\www\htdocs\PEAR\PEAR\data\PEAR\package.dtd', 'package' => 'MP3_Playlist', 'license' => 'PHP License', 'baseinstalldir' => '', 'version' => '0.5.0alpha1', 'packagedirectory' => $packagedir, 'pathtopackagefile' => $packagedir, 'state' => 'alpha', 'filelistgenerator' => 'file', 'notes' => 'Initial release of MP3_Playlist', 'summary' => 'Library to create MP3 playlists on the fly, several formats supported including XML, RSS and XHTML', 'description' => $desc, 'dir_roles' => array( 'docs' => 'doc', 'data' => 'data' ), 'ignore' => array( 'package.xml', '*.tgz', $self ) ); $e = $pkg->setOptions($options); if (PEAR::isError($e)) { echo $e->getMessage(); die; } // hack until they get their shit in line with docroot role $pkg->addRole('tpl', 'php'); $pkg->addRole('png', 'php'); $pkg->addRole('gif', 'php'); $pkg->addRole('jpg', 'php'); $pkg->addRole('css', 'php'); $pkg->addRole('js', 'php'); $pkg->addRole('ini', 'php'); $pkg->addRole('inc', 'php'); $pkg->addRole('afm', 'php'); $pkg->addRole('pkg', 'doc'); $pkg->addRole('cls', 'doc'); $pkg->addRole('proc', 'doc'); $pkg->addRole('txt', 'doc'); $pkg->addRole('sh', 'script'); $pkg->addMaintainer('gurugeek', 'lead', 'David Costa', 'gurugeek@php.net'); $pkg->addMaintainer('firman', 'lead', 'Firman Wandayandi', 'firman@php.net'); $pkg->addDependency('PHP', '5.0.0', 'ge', 'php'); $pkg->addDependency('PEAR', '1.3.0', 'ge', 'pkg'); $pkg->addDependency('Net_URL', '1.0.14', 'ge', 'pkg'); $pkg->addDependency('MP3_Id', '1.1.4', 'ge', 'pkg'); $e = $pkg->addGlobalReplacement('package-info', '@package_version@', 'version'); $e = $pkg->writePackageFile(); if (PEAR::isError($e)) { echo $e->getMessage(); } ?> http://cvs.php.net/co.php/pear/MP3_Playlist/package.xml?r=1.1&p=1 Index: pear/MP3_Playlist/package.xml +++ pear/MP3_Playlist/package.xml <?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE package SYSTEM "http://pear.php.net/dtd/package-1.0"> <package version="1.0"> <name>MP3_Playlist</name> <summary>Library to create MP3 playlists on the fly, several formats supported including XML, RSS and XHTML</summary> <description>MP3_Playlist is a php library to facilitate the creation and to some extend the rendering of MP3 playlists. It scans a local folder with all the MP3 files and outputs the playlist in several formats including M3U, SMIL, XML, XHTML with the possibility to backup the lists on the fly with an SQLite DB.</description> <maintainers> <maintainer> <user>gurugeek</user> <name>David Costa</name> <email>gurugeek@php.net</email> <role>lead</role> </maintainer> <maintainer> <user>firman</user> <name>Firman Wandayandi</name> <email>firman@php.net</email> <role>lead</role> </maintainer> </maintainers> <release> <version>0.5.0alpha1</version> <date>2005-09-03</date> <license>PHP License</license> <state>alpha</state> <notes>Initial release of MP3_Playlist</notes> <deps> <dep type="php" rel="ge" version="5.0.0" optional="no"/> <dep type="pkg" rel="ge" version="1.3.0" optional="no">PEAR</dep> <dep type="pkg" rel="ge" version="1.0.14" optional="no">Net_URL</dep> <dep type="pkg" rel="ge" version="1.1.4" optional="no">MP3_Id</dep> </deps> <filelist> <dir baseinstalldir="" name="/"> <dir name="docs"> <dir name="examples"> <file role="doc" name="index.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> <file role="doc" name="result.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> <dir name="include"> <file role="doc" name="footer.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> <file role="doc" name="head.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> <file role="doc" name="header.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> </dir> <!-- docs/examples/include --> </dir> <!-- docs/examples --> </dir> <!-- docs --> <dir name="MP3"> <file role="php" name="Playlist.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> <dir name="Playlist"> <file role="php" name="Common.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> <file role="php" name="M3U.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> <file role="php" name="RSS.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> <file role="php" name="SMIL.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> <file role="php" name="SQLite.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> <file role="php" name="XHTML.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> <file role="php" name="XML.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> </dir> <!-- MP3/Playlist --> </dir> <!-- MP3 --> </dir> <!-- / --> </filelist> </release> <changelog> <release> <version>0.5.0alpha1</version> <date>2005-09-03</date> <license>PHP License</license> <state>alpha</state> <notes>Initial release of MP3_Playlist</notes> </release> </changelog> </package>
http://cvs.php.net/co.php/pear/MP3_Playlist/MP3/Playlist.php?r=1.1&p=1 Index: pear/MP3_Playlist/MP3/Playlist.php +++ pear/MP3_Playlist/MP3/Playlist.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */ // {{{ Header /** * Class to generate playlists in m3u and other formats including smil, * sqlite, XHTML, RSS and raw XML * * PHP version 5 * * LICENSE: * * The PHP License, version 3.0 * * Copyright (c) 2004-2005 David Costa * * This source file is subject to version 3.0 of the PHP license, * that is bundled with this package in the file LICENSE, and is * available through the world-wide-web at the following url: * http://www.php.net/license/3_0.txt. * If you did not receive a copy of the PHP license and are unable to * obtain it through the world-wide-web, please send a note to * license@php.net so we can mail you a copy immediately. * * @category File Formats * @package MP3_Playlist * @author David Costa <gurugeek@php.net> * @author Ashley Hewson <morbidness@gmail.com> * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2004-2005 David Costa * @license http://www.php.net/license/3_0.txt * The PHP License, version 3.0 * @version CVS: $Id: Playlist.php,v 1.1 2005/10/02 17:38:56 firman Exp $ */ // }}} // {{{ Dependencies /** * Load PEAR_Exception for throw on error. */ require_once 'PEAR/Exception.php'; /** * Require MP3 ID for extensive support of tags within a playlist */ require_once 'MP3/Id.php'; /** * Load Net_URL for fix the given URL. */ require_once 'Net/URL.php'; // }}} // {{{ Class: MP3_Playlist /** * Class MP3_Playlist * * A playlist can be used for both local use and remote streaming. * * The m3u playlist format is supported by Winamp, XMMS, Noatunes and several * other players. * * The Smil playlist format is supported by Real Media Player, Quicktime and * others XHTML allows you to display a fully formatted page or just the tables * to be included in your own template. * * RSS allows you to syndicate the playlist on the fly. The Sqlite function * allows you to backup the list in an existing sqlite database or to create a * database and the table on the fly. * * @category File Formats * @package MP3_Playlist * @author David Costa <gurugeek@php.net> * @author Ashley Hewson <morbidness@gmail.com> * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2004-2005 David Costa * @license http://www.php.net/license/3_0.txt * The PHP License, version 3.0 * @version Release: @package_version@ */ class MP3_Playlist { // {{{ Object Constants /** * Error handling related Constants * Verbose error output in each of the cases */ const E_CANNOT_OPENDIR = 'Unable to open the directory'; const E_CANNOT_SAVEFILE = 'Unable to save file'; const E_CANNOT_OPENDB = 'Unable to open the database'; const E_CANNOT_CREATETABLE = 'Unable to create the playlist table'; const E_CANNOT_INSERT = 'Unable to insert into the playlist table'; const E_CANNOT_SENDHEADER = 'Unable to send HTTP header'; const E_INVALID_MERGE = 'Unable to merge'; const E_INVALID_PLAYLIST = 'Invalid playlist'; const E_UNKNOWN_TYPE = 'Unknown format type'; const E_UNSUPPORTED_TYPE = 'Unsupported format type'; const E_NOT_SAVEABLE = 'Playlist format is not saveable'; const E_NOT_SENDABLE = 'Playlist format is not sendable'; const E_REQUIRED_PARAM = 'Required parameter'; /** * Output type made by MP3_Playlist. */ const TYPE_M3U = 'M3U'; const TYPE_SMIL = 'SMIL'; const TYPE_XML = 'XML'; const TYPE_XHTML = 'XHTML'; const TYPE_RSS = 'RSS'; const TYPE_SQLITE = 'SQLITE'; // }}} // {{{ Static Properties public static $drivers = array( 'm3u' => array( 'file' => 'M3U.php', 'class' => 'MP3_Playlist_M3U' ), 'smil' => array( 'file' => 'SMIL.php', 'class' => 'MP3_Playlist_SMIL' ), 'xml' => array( 'file' => 'XML.php', 'class' => 'MP3_Playlist_XML' ), 'xhtml' => array( 'file' => 'XHTML.php', 'class' => 'MP3_Playlist_XHTML' ), 'rss' => array( 'file' => 'RSS.php', 'class' => 'MP3_Playlist_RSS' ), 'sqlite' => array( 'file' => 'SQLite.php', 'class' => 'MP3_Playlist_SQLite' ) ); // {{{ Object Variables /** * Name of the playlist. suffix is added automatically as per method used * @var string */ public $fileName = 'playlist'; /** * Debug value * @var string */ public $debug = false; /** * Directory to Parse * @var string */ private $parseDirectory; /** * Output directory, where the playlist is saved * @var string */ private $outputDirectory; /** * Url to append on the playlist * @var string */ private $baseUrl; /** * List of songs in an array, formatted after parsing * @var array */ private $list = array(); /** * MP3_ID Object * @var string */ private $mp3; /** * List of files including append directory, location and ID3 tags for XML * and other manipulation * @var array */ private $merged = array(); /** * private variable to check if the method Mergelist is called * @var string */ private $isMerged = false; /** * Driver object instance. * @var object */ private $playlist = null; // }}} // {{{ Constructor /** * Instantiate a new MP3_Playlist object. * * Expects a reading directory, the output directory where the playlist will * be saved and the directory or URL to be used within the playlist. * * @param string $dir The directory to scan * @param string $outdir The directory where to save the playlist file * @param string $baseurl The base url to append on the playlist file * @param bool $debug (optional) Whether print debug message or not, default FALSE * * @return TRUE|PEAR_Error * @see MP3_Playlist::fixPath() */ public function __construct ($dir, $outdir, $baseurl, $debug = false) { // Taking the values from the constructor and assigning it to the // private variables $this->parseDirectory = self::fixPath($dir); $this->outputDirectory = self::fixPath($outdir); // Fix the URL if needed. if (substr($baseurl, -1) != '/') { $baseurl .= '/'; } $url = new Net_URL($baseurl); if (!empty($url->path)) { $dirs = explode('/', $url->path); foreach ($dirs as $key => $value) { if (!empty($value)) { $dirs[$key] = rawurlencode($value); } } $url->path = Net_URL::resolvePath(implode('/', $dirs)); } $this->baseUrl = $url->getURL(); $this->list = array(); // Instantiate the new MP3_If object $this->mp3 = new MP3_Id(); $this->debug = $debug; $this->parse(); } // }}} // {{{ debug() /** * Output debug message. * * @param string $msg Message. */ private function debug($message) { if ($this->debug == true) { print 'MP3_Playlist Debug: ' . $message . "<br />\n"; } } // }}} // {{{ fixPath() /** * Convert Windows directory separator to Unix style and fix ending slash. * * @param string $dir Directory. * * @return string result. */ static public function fixPath($dir) { $dir = str_replace("\\", '/', $dir); if (substr($dir, -1) != '/') { if (PEAR_OS == 'Windows' && substr($dir, -1) != '\\') { $dir .= '/'; } else { $dir .= '/'; } } return $dir; } // }}} // {{{ generateURL() /** * Generates the URL from absolute path. * * @param string $absPath Absolute path. * * @return string URL. */ private function generateURL($absPath) { $absPath = str_replace($this->parseDirectory, '', $absPath); $paths = explode('/', $absPath); foreach ($paths as $key => $value) { if (empty($value)) { continue; } $paths[$key] = rawurlencode($value); } return $this->baseUrl . implode('/', $paths); } // }}} // {{{ parse() /** * Parses the MP3 directory defined in the constructor * * Appends to the files the append directory of MP3 files including * whitespace (necessary for streaming if the append path is a URL) adds * the basic list to the List and Merged Array List is used for basic * playlist writing while Merged will be used for XML and a more * complete output including the ID3 tags. * * @param bool $dir (optional) Directory to parse, this param use for recursive * purpose, default FALSE. * * @throws PEAR_Exception * @return bool TRUE * @see MP3_Playlist::fixPath() * @see MP3_Playlist::generateURL() */ private function parse($dir = false) { if ($dir == false) { $dir = $this->parseDirectory; } // Attempt to open directory. $dh = @opendir($dir); if (!$dh) { throw new PEAR_Exception(self::E_CANNOT_OPENDIR, -1); } while (($entry = readdir($dh)) !== false) { if ($entry == '.' || $entry == '..') { continue; } $abspath = self::fixPath($dir) . $entry; $this->debug('Got entry "' . $abspath . '"'); if (is_dir($abspath)) { $this->debug('Read subdirectory "' . $abspath . '"'); $this->parse($abspath); continue; } else if (strtolower(substr($entry, -4)) == '.mp3') { $url = $this->generateURL($abspath); $this->list[] = $url; // preparing the $this->merged array which will contain both the // $this->list basic information and more ID3 tags $this->merged[] = array( 'BaseName' => basename($entry), 'FullPath' => $abspath, 'URL' => $url, ); } } $this->debug('Merged list <pre>' . print_r($this->merged, true) . '</pre>'); return true; } // }}} // {{{ mergeList() /** * Merges the values from the parsed known elements like file location * and append URL with the ID3 tags * * Sets the value to Not Available if null in the ID3 tag. * Trims results to avoid error in the XML and XHTML display. * * @throws PEAR_Exception * @return bool TRUE * @see MP3_Id::read() */ private function mergeList() { // We will use this in case someone tries to call a method like // makeXHTML before merging $this->isMerged = true; foreach($this->merged as $id => $detail) { // input debug $this->debug('Read file "' . $detail['FullPath'] . '"'); // reading each of the files in our array using the fullpath $temp = $this->mp3->read($detail['FullPath']); //if for some reason mp3 returns an error we raise a pear error if (PEAR::isError($temp)) { throw new PEAR_Exception(self::MP3_PLAYLIST_INVALID_MERG, -1); } // Adding the tags name, artist, genre and album to the merged // array. If not available, which happens in many mp3 files // add not available. // We trim to avoid any kind of problem with the XML XHTML or // RSS generation $title = trim($this->mp3->getTag('name')); if ($title && !empty($title)) { $this->merged[$id]['title'] = trim($title); } else { $this->merged[$id]['title'] = $detail['BaseName']; } $artist = trim($this->mp3->getTag('artists')); if ($artist && !empty($artist)){ $this->merged[$id]['artist'] = $artist; } else { $this->merged[$id]['artist'] = 'Unknown Artist'; } $album = trim($this->mp3->getTag('album')); if ($album && !empty($album)) { $this->merged[$id]['album'] = $album; } else { $this->merged[$id]['album'] = 'Not Available'; } $genre = trim($this->mp3->getTag('genre')); if ($genre && !empty($genre)) { $this->merged[$id]['genre'] = $genre; } else { $this->merged[$id]['genre'] = 'Not Available'; } } // output debug $this->debug('Merged list <pre>' . print_r($this->merged, true) . '</pre>'); return true; } // }}} // {{{ getList() /** * Get list of songs in an array, formatted after parsing. * * @return array */ public function getList() { return $this->list; } // }}} // {{{ getMerged() /** * Get list of files including append directory, location and ID3 tags for XML * and other manipulation. * * @return array * @see MP3_Playlist::mergeList() */ public function getMerged() { if (!$this->isMerged) { $this->mergeList(); } return $this->merged; } // }}} // {{{ make() /** * Generates the playlist according to selected format. * * @param string $type Format type, use one of constants * <pre> * MP3_Playlist::TYPE_M3U M3U playlist * MP3_Playlist::TYPE_SMILL SMILL playlist * MP3_Playlist::TYPE_XML XML format * MP3_Playlist::TYPE_XHTML XHTML output * MP3_Playlist::TYPE_RSS RSS output * MP3_Playlist::TYPE_SQLITE Save to SQLite database * </pre> * @param array $params (optional) Parameters, an associative array contains * values depend on the format. * @param bool $shuffle (optional) Whether to shuffle the list or not. * This parameter only affect on formats * M3U, SMILL and XHTML * * @throws PEAR_Exception * @return bool TRUE * @see MP3_Playlist_Common::__construct() * @see MP3_Playlist_M3U::make() * @see MP3_Playlist_SMIL::make() * @see MP3_Playlist_XML::make() * @see MP3_Playlist_XHTML::make() * @see MP3_Playlist_RSS::make() * @see MP3_Playlist_SQLite::make() */ public function make($type, $params = array(), $shuffle = false) { $type = strtolower($type); if (!isset(self::$drivers[$type])) { throw new PEAR_Exception(self::E_UNSUPPORTED_TYPE); } $file = 'MP3/Playlist/' . self::$drivers[$type]['file']; $class = self::$drivers[$type]['class']; include_once($file); $this->playlist = new $class($this, $shuffle, $this->debug); return $this->playlist->make($params); } // }}} // {{{ save() /** * Save the generated playlist into file. * * @throws PEAR_Exception * @return bool TRUE * @see MP3_Playlist_Common::save() */ public function save() { if (!is_object($this->playlist) || !is_a($this->playlist, 'MP3_Playlist_Common')) { throw new PEAR_Exception(self::E_INVALID_PLAYLIST); } return $this->playlist->save($this->outputDirectory, $this->fileName); } // }}} // {{{ send() /** * Send the generated playlist to browser directly. * * @throws PEAR_Exception * @return bool TRUE * @see MP3_Playlist_Common::send() */ public function send() { if (!is_object($this->playlist) || !is_a($this->playlist, 'MP3_Playlist_Common')) { throw new PEAR_Exception(self::E_INVALID_PLAYLIST); } return $this->playlist->send($this->fileName); } // }}} // {{{ show() /** * Show the generated playlist result * * @throws PEAR_Exception * @see MP3_Playlist_Common::show() */ public function show() { if (!is_object($this->playlist) || !is_a($this->playlist, 'MP3_Playlist_Common')) { throw new PEAR_Exception(self::E_INVALID_PLAYLIST); } return $this->playlist->show(); } // }}} } // }}} /* * Local variables: * mode: php * tab-width: 4 * c-basic-offset: 4 * c-hanging-comment-ender-p: nil * End: */ ?> http://cvs.php.net/co.php/pear/MP3_Playlist/MP3/Playlist/Common.php?r=1.1&p=1 Index: pear/MP3_Playlist/MP3/Playlist/Common.php +++ pear/MP3_Playlist/MP3/Playlist/Common.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */ // {{{ Header /** * File contains MP3_Playlist_Common class. * * PHP version 5 * * LICENSE: * * The PHP License, version 3.0 * * Copyright (c) 2004-2005 David Costa * * This source file is subject to version 3.0 of the PHP license, * that is bundled with this package in the file LICENSE, and is * available through the world-wide-web at the following url: * http://www.php.net/license/3_0.txt. * If you did not receive a copy of the PHP license and are unable to * obtain it through the world-wide-web, please send a note to * license@php.net so we can mail you a copy immediately. * * @category File Formats * @package MP3_Playlist * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2004-2005 David Costa * @license http://www.php.net/license/3_0.txt * The PHP License, version 3.0 * @version CVS: $Id: Common.php,v 1.1 2005/10/02 17:38:56 firman Exp $ */ // }}} // {{{ Class: MP3_Playlist_Common /** * Abstract class of MP3_Playlist drivers class. * * @category File Formats * @package MP3_Playlist * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2004-2005 David Costa * @license http://www.php.net/license/3_0.txt * The PHP License, version 3.0 * @version Release: @package_version@ * @abstract */ abstract class MP3_Playlist_Common { // {{{ Object Variables /** * Debug flag. * @var bool */ protected $debug = false; /** * The playlist result just made. * @var string */ protected $result = ''; /** * Mime type of output. * @var string */ protected $mimeType = ''; /** * File extension (without dot). * @var string */ protected $fileExtension = ''; /** * Whether the result is viewable by browser or not. * @var bool */ protected $isViewable = true; /** * Whether the result is saveable or not. * @var bool */ protected $isSaveable = true; /** * Whether the result is sendable or not. * @var bool */ protected $isSendable = true; /** * Whether to create shuffle list or not. * @var bool */ protected $isShuffle = false; /** * List of song files. */ protected $list = array(); /** * Whether is required to merge list or not to generate * the playlist. * @var bool */ protected $isRequiredMerged = false; /** * List of files including append directory, location and ID3 tags for XML * and other manipulation * @var array */ protected $merged = array(); // }}} // {{{ Constructor /** * Constructor * * @param object $playlist An instance of MP3_Playlist object. * @param bool $shuffle Whether to shuffle the playlist or not. * @param bool $debug Whether to show debug message or not. * * @see MP3_Playlist::getList() * @see MP3_Playlist::getMerged() */ public function __construct(MP3_Playlist $playlist, $shuffle = false, $debug = false) { $this->playlist = $playlist; $this->isShuffle = $shuffle; $this->debug = $debug; $this->list = $this->playlist->getList(); if ($this->isRequiredMerged) { $this->merged = $this->playlist->getMerged(); } } // }}} // {{{ debug() /** * Output debug message. * * @param string $msg Message. */ final private function debug($message) { if ($this->debug == true) { print 'MP3_Playlist Debug: ' . $message . "<br />\n"; } } // }}} // {{{ make() /** * Generates the playlist. * * @param array $params Make parameters. */ public function make($params = array()) { // Should be implement by extends class. } // }}} // {{{ save() /** * Save the generates playlist into file. * * @param string $dir Directory * @param string $filename Filename * * @throws PEAR_Exception * @return bool TRUE */ final public function save($dir, $filename) { if (!$this->isSaveable) { throw new PEAR_Exception(MP3_Playlist::E_NOT_SAVEABLE); } $file = $dir . '/' . $filename . '.' . $this->fileExtension; // trying to create the file in the relevant output directory $fp = @fopen($file,'w+'); // checking if we cannot create the file return an error with details if (!@$fp) { throw new PEAR_Exception(MP3_Playlist::E_CANNOT_SAVEFILE . "filename: $file in " . $this->outputDirectory . ' ' . 'Possible Problem: Permissions', -1); } // writing and closing the file fwrite($fp, $this->result); fclose($fp); return true; } // }}} // {{{ send() /** * Send the generated playlist to browser direclty. * * @param string $filename Filename, if the format not viewable by browser * send method will be switch into download mode. * @throws PEAR_Exception * @return bool TRUE */ final public function send($filename) { if (!$this->isSendable) { throw new PEAR_Exception(MP3_Playlist::E_NOT_SENDABLE, -1); } if (headers_sent()) { throw new PEAR_Exception(MP3_Playlist::E_CANNOT_SENDHEADER, -1); } header('Content-Type: ' . $this->mimeType); if (!$this->isViewable) { header('Content-Disposition: attachment; filename="' . $filename . '.' . $this->fileExtension . '"'); header('Pragma: no-cache'); } print $this->result; return true; } // }}} // {{{ show() /** * Show the generated playlist result. */ public function show() { print htmlspecialchars($this->result); } // }}} } // }}} /* * Local variables: * mode: php * tab-width: 4 * c-basic-offset: 4 * c-hanging-comment-ender-p: nil * End: */ ?> http://cvs.php.net/co.php/pear/MP3_Playlist/MP3/Playlist/M3U.php?r=1.1&p=1 Index: pear/MP3_Playlist/MP3/Playlist/M3U.php +++ pear/MP3_Playlist/MP3/Playlist/M3U.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */ // {{{ Header /** * File contains MP3_Playlist_M3U class. * * PHP version 5 * * LICENSE: * * The PHP License, version 3.0 * * Copyright (c) 2004-2005 David Costa * * This source file is subject to version 3.0 of the PHP license, * that is bundled with this package in the file LICENSE, and is * available through the world-wide-web at the following url: * http://www.php.net/license/3_0.txt. * If you did not receive a copy of the PHP license and are unable to * obtain it through the world-wide-web, please send a note to * license@php.net so we can mail you a copy immediately. * * @category File Formats * @package MP3_Playlist * @author David Costa <gurugeek@php.net> * @author Ashley Hewson <morbidness@gmail.com> * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2004-2005 David Costa * @license http://www.php.net/license/3_0.txt * The PHP License, version 3.0 * @version CVS: $Id: M3U.php,v 1.1 2005/10/02 17:38:56 firman Exp $ */ // }}} // {{{ Dependencies /** * Load MP3_Playlist_Common as the base class. */ require_once 'MP3/Playlist/Common.php'; // }}} // {{{ Class: MP3_Playlist_M3U /** * Class MP3_Playlist_M3U, generates the M3U playlist format. * * The M3U playlist format is supported by Winamp, XMMS, Noatunes * and several other players. * * @category File Formats * @package MP3_Playlist * @author David Costa <gurugeek@php.net> * @author Ashley Hewson <morbidness@gmail.com> * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2004-2005 David Costa * @license http://www.php.net/license/3_0.txt * The PHP License, version 3.0 * @version Release: @package_version@ */ class MP3_Playlist_M3U extends MP3_Playlist_Common { // {{{ Object Properties /** * Mime type of output. * @var string */ protected $mimeType = 'audio/x-mpegurl'; /** * File extension (without dot). * @var string */ protected $fileExtension = 'm3u'; /** * Force M3U format is not viewable by browser. * @var bool */ protected $isViewable = false; // }}} // {{{ make() /** * Generates the M3U playlist format. * * @param array $params (optional) No parameters, ignore this. * * @return bool TRUE */ public function make($params = array()) { // checking if we need to shuffle the filelist inside the array or not if ($this->isShuffle == true) { shuffle($this->list); } // array glue keeping one file per line as per m3u standards $this->result = implode("\n", $this->list); return true; } // }}} } // }}} /* * Local variables: * mode: php * tab-width: 4 * c-basic-offset: 4 * c-hanging-comment-ender-p: nil * End: */ ?> http://cvs.php.net/co.php/pear/MP3_Playlist/MP3/Playlist/RSS.php?r=1.1&p=1 Index: pear/MP3_Playlist/MP3/Playlist/RSS.php +++ pear/MP3_Playlist/MP3/Playlist/RSS.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */ // {{{ Header /** * File contains MP3_Playlist_RSS class. * * PHP version 5 * * LICENSE: * * The PHP License, version 3.0 * * Copyright (c) 2004-2005 David Costa * * This source file is subject to version 3.0 of the PHP license, * that is bundled with this package in the file LICENSE, and is * available through the world-wide-web at the following url: * http://www.php.net/license/3_0.txt. * If you did not receive a copy of the PHP license and are unable to * obtain it through the world-wide-web, please send a note to * license@php.net so we can mail you a copy immediately. * * @category File Formats * @package MP3_Playlist * @author David Costa <gurugeek@php.net> * @author Ashley Hewson <morbidness@gmail.com> * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2004-2005 David Costa * @license http://www.php.net/license/3_0.txt * The PHP License, version 3.0 * @version CVS: $Id: RSS.php,v 1.1 2005/10/02 17:38:56 firman Exp $ */ // }}} // {{{ Dependencies /** * Load MP3_Playlist_Common as the base class. */ require_once 'MP3/Playlist/Common.php'; // }}} // {{{ Class: MP3_Playlist_RSS /** * Class MP3_Playlist_RSS, generates the playlist RSS feed. * * @category File Formats * @package MP3_Playlist * @author David Costa <gurugeek@php.net> * @author Ashley Hewson <morbidness@gmail.com> * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2004-2005 David Costa * @license http://www.php.net/license/3_0.txt * The PHP License, version 3.0 * @version Release: @package_version@ */ class MP3_Playlist_RSS extends MP3_Playlist_Common { // {{{ Object Properties /** * Mime type of output. * @var string */ protected $mimeType = 'application/xml'; /** * File extension (without dot). * @var string */ protected $fileExtension = 'rss'; /** * RSS required the merged list. * @var bool */ protected $isRequiredMerged = true; // }}} // {{{ make() /** * Generate a valid RSS feed from a playlist * * User should define as parameters the title of the feed description * and link for each song the rss produced will include the title and * link and keep within the description the other information available * namely the album, artist, and genre. * * @param array $params Make parameters. * <pre> * title string Feed main title * description string Feed description * link string Link main description * </pre> * * @return bool TRUE */ public function make($params = array()) { if (!isset($params['title'])) { throw new PEAR_Exception(MP3_Playlist::E_REQUIRED_PARAM . ' "title" as feed title', -1); } if (!isset($params['description'])) { throw new PEAR_Exception(MP3_Playlist::E_REQUIRED_PARAM . ' "description" as feed description', -1); } if (!isset($params['link'])) { throw new PEAR_Exception(MP3_Playlist::E_REQUIRED_PARAM . ' "link" as link main description', -1); } $title = $params['title']; $description = isset($params['description']) ? $params['description'] : ''; $link = isset($params['link']) ? $params['link'] : ''; $rssbody = ''; foreach ($this->merged as $prepared) { // formatting for RSS so we avoid errors with & and other signs $prepared['title'] = htmlspecialchars($prepared['title']); $prepared['URL'] = htmlspecialchars($prepared['URL']); $prepared['artist'] = htmlspecialchars($prepared['artist']); $prepared['album'] = htmlspecialchars($prepared['album']); $prepared['genre'] = htmlspecialchars($prepared['genre']); // basic RSS entry for each of the songs $rssbody .= <<<XMLBODY <item> <title>$prepared[title]</title> <link>$prepared[URL]</link> <description>$prepared[artist] - $prepared[album] - $prepared[genre]</description> </item> XMLBODY; } // standard RSS header with the parameters specified by the user $this->result = <<<XMLHEADER <?xml version="1.0" encoding="iso-8859-1"?> <rss version="0.91"> <channel> <title> $title </title> <description> $description </description> <link>$link</link> $rssbody </channel> </rss> XMLHEADER; return true; } // }}} } // }}} http://cvs.php.net/co.php/pear/MP3_Playlist/MP3/Playlist/SMIL.php?r=1.1&p=1 Index: pear/MP3_Playlist/MP3/Playlist/SMIL.php +++ pear/MP3_Playlist/MP3/Playlist/SMIL.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */ // {{{ Header /** * File contains MP3_Playlist_SMIL class. * * PHP version 5 * * LICENSE: * * The PHP License, version 3.0 * * Copyright (c) 2004-2005 David Costa * * This source file is subject to version 3.0 of the PHP license, * that is bundled with this package in the file LICENSE, and is * available through the world-wide-web at the following url: * http://www.php.net/license/3_0.txt. * If you did not receive a copy of the PHP license and are unable to * obtain it through the world-wide-web, please send a note to * license@php.net so we can mail you a copy immediately. * * @category File Formats * @package MP3_Playlist * @author David Costa <gurugeek@php.net> * @author Ashley Hewson <morbidness@gmail.com> * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2004-2005 David Costa * @license http://www.php.net/license/3_0.txt * The PHP License, version 3.0 * @version CVS: $Id: SMIL.php,v 1.1 2005/10/02 17:38:56 firman Exp $ */ // }}} // {{{ Dependencies /** * Load MP3_Playlist_Common as the base class. */ require_once 'MP3/Playlist/Common.php'; // }}} // {{{ Class: MP3_Playlist_SMIL /** * Class MP3_Playlist_SMILL, generates the SMIL (SMIL Multimedia Persentation) * playlist. * * The Smil playlist format is supported by Real Media Player, Quicktime. * * @category File Formats * @package MP3_Playlist * @author David Costa <gurugeek@php.net> * @author Ashley Hewson <morbidness@gmail.com> * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2004-2005 David Costa * @license http://www.php.net/license/3_0.txt * The PHP License, version 3.0 * @version Release: @package_version@ */ class MP3_Playlist_SMIL extends MP3_Playlist_Common { // {{{ Object Properties /** * Mime type of output. * @var string */ protected $mimeType = 'application/smil'; /** * File extension (without dot). * @var string */ protected $fileExtension = 'smil'; /** * Force M3U format is not viewable by browser. * @var bool */ protected $isViewable = false; // }}} // {{{ make() /** * Generates the SMIL (SMIL Multimedia Persentation) playlist. * * @param array $params (optional) No parameters, ignore this. * * @return bool TRUE */ public function make($params = array()) { if ($this->isShuffle == true) { shuffle($this->list); } $AudioTags = array(); foreach ($this->list as $entry) { // add a new <audio> line to the array $AudioTags[] = '<audio src="'.$entry.'" />'; } // Glue the array with \n so that we obtain a string of X lines // containing all files $AudioTags = implode("\n", $AudioTags); // put together the smil $this->result = <<<SMIL <smil> <body> <seq> $AudioTags </seq> </body> </smil> SMIL; return true; } // }}} } // }}} /* * Local variables: * mode: php * tab-width: 4 * c-basic-offset: 4 * c-hanging-comment-ender-p: nil * End: */ ?> http://cvs.php.net/co.php/pear/MP3_Playlist/MP3/Playlist/SQLite.php?r=1.1&p=1 Index: pear/MP3_Playlist/MP3/Playlist/SQLite.php +++ pear/MP3_Playlist/MP3/Playlist/SQLite.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */ // {{{ Header /** * File contains MP3_Playlist_SQLite class. * * PHP version 5 * * LICENSE: * * The PHP License, version 3.0 * * Copyright (c) 2004-2005 David Costa * * This source file is subject to version 3.0 of the PHP license, * that is bundled with this package in the file LICENSE, and is * available through the world-wide-web at the following url: * http://www.php.net/license/3_0.txt. * If you did not receive a copy of the PHP license and are unable to * obtain it through the world-wide-web, please send a note to * license@php.net so we can mail you a copy immediately. * * @category File Formats * @package MP3_Playlist * @author David Costa <gurugeek@php.net> * @author Ashley Hewson <morbidness@gmail.com> * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2004-2005 David Costa * @license http://www.php.net/license/3_0.txt * The PHP License, version 3.0 * @version CVS: $Id: SQLite.php,v 1.1 2005/10/02 17:38:56 firman Exp $ */ // }}} // {{{ Dependencies /** * Load MP3_Playlist_Common as the base class. */ require_once 'MP3/Playlist/Common.php'; // }}} // {{{ Class: MP3_Playlist_M3U /** * Class MP3_Playlist_SMILL for generate and stores an sqlite based * playlist. * * @category File Formats * @package MP3_Playlist * @author David Costa <gurugeek@php.net> * @author Ashley Hewson <morbidness@gmail.com> * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2004-2005 David Costa * @license http://www.php.net/license/3_0.txt * The PHP License, version 3.0 * @version Release: @package_version@ */ class MP3_Playlist_SQLite extends MP3_Playlist_Common { // {{{ Object Properties /** * Force SQLite format is not viewable by browser. * @var bool */ protected $isViewable = false; /** * Force SQLite format is not saveable. * @var bool */ protected $isSaveable = false; /** * Force SQLite format is not sendable. * @var bool */ protected $isSendable = false; /** * Default table columns. * @var array */ protected $columns = array( 'fullpath' => 'fullpath', 'url' => 'url', 'title' => 'title', 'artist' => 'artist', 'album' => 'album', 'genre' => 'genre' ); // }}} // {{{ make() /** * Generate and stores an sqlite based playlist * * Optionally creates a database and the table or can be set to * add the extended playlist in an existing database and table. * * @param array $params Make parameters. * <pre> * db string SQLite database name * table string SQLite database table name * maketable bool (optional) Should the table be created or not, * default is TRUE * columns array (optional) Define the 6 column names yourself. * </pre> * * @return bool TRUE */ public function make($params = array()) { if (!isset($params['db'])) { throw new PEAR_Exception(MP3_Playlist::E_REQUIRED_PARAM . ' "db" as database name', -1); } if (!isset($params['table'])) { throw new PEAR_Exception(MP3_Playlist::E_REQUIRED_PARAM . ' "table" as database table name', -1); } $dbname = $params['db']; $table = $params['table']; $maketable = isset($params['maketable']) ? $params['maketable'] : true; $columns = isset($params['columns']) ? $params['columns'] : false; // check if the user defined his own columns details if (is_array($columns)) { $this->columns = array_merge($this->columns, $columns); } $error =''; // attempt to open the database, if it doesn't exist it will be created $db = @sqlite_open($dbname, 0666, $error); // return an error if we cannot open the sqlite database if (!@$db) { throw new PEAR_Exception(MP3_Playlist::E_CANNOT_OPENDB . "more info: $error", -1); } // creating the table is optional so we check first if the the value is TRUE if ($maketable == true) { // if true we create the table $query = @sqlite_query($db, "CREATE table $table (" . ' id INTEGER PRIMARY KEY, ' . " {$this->columns['fullpath']} varchar(200), " . " {$this->columns['url']} varchar(200), " . " {$this->columns['title']} title varchar(200), " . " {$this->columns['artist']} varchar(200), " . " {$this->columns['album']} varchar (200), " . " {$this->columns['genre']} varchar(200) " . ')' ); // return an error in case that the table cannot be created if (!@$query) { throw new PEAR_Exception(MP3_Playlist::E_CANNOT_CREATETABLE, -1); } } foreach ($this->merged as $prepared){ // escaping each of the values $fullpath = sqlite_escape_string($prepared['FullPath']); $url = sqlite_escape_string($prepared['URL']); $title = sqlite_escape_string($prepared['title']); $artist = sqlite_escape_string($prepared['artist']); $album = sqlite_escape_string($prepared['album']); $genre = sqlite_escape_string($prepared['genre']); // insert query preparation $sql = "INSERT INTO $table ( {$this->columns['fullpath']}, {$this->columns['url']}, {$this->columns['title']}, {$this->columns['artist']}, {$this->columns['album']}, {$this->columns['genre']} ) VALUES ( '$fullpath', '$url', '$title', '$artist', '$album', '$genre' )"; // executing the query $query = @sqlite_query($db, $sql); // if we do have a problem with the query return an error with the // debug information this might occur if the user passes some invalid // values for the columns if (!@$query) { throw new PEAR_Exception(MP3_Playlist::E_CANNOT_INSERT . "debug info print_r ($sql)", -1); } } echo 'List saved on sqlite<br />'; return true; } // }}} } // }}} http://cvs.php.net/co.php/pear/MP3_Playlist/MP3/Playlist/XHTML.php?r=1.1&p=1 Index: pear/MP3_Playlist/MP3/Playlist/XHTML.php +++ pear/MP3_Playlist/MP3/Playlist/XHTML.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */ // {{{ Header /** * File contains MP3_Playlist_XHTML class. * * PHP version 5 * * LICENSE: * * The PHP License, version 3.0 * * Copyright (c) 2004-2005 David Costa * * This source file is subject to version 3.0 of the PHP license, * that is bundled with this package in the file LICENSE, and is * available through the world-wide-web at the following url: * http://www.php.net/license/3_0.txt. * If you did not receive a copy of the PHP license and are unable to * obtain it through the world-wide-web, please send a note to * license@php.net so we can mail you a copy immediately. * * @category File Formats * @package MP3_Playlist * @author David Costa <gurugeek@php.net> * @author Ashley Hewson <morbidness@gmail.com> * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2004-2005 David Costa * @license http://www.php.net/license/3_0.txt * The PHP License, version 3.0 * @version CVS: $Id: XHTML.php,v 1.1 2005/10/02 17:38:56 firman Exp $ */ // }}} // {{{ Dependencies /** * Load MP3_Playlist_Common as the base class. */ require_once 'MP3/Playlist/Common.php'; // }}} // {{{ Class: MP3_Playlist_XHMTL /** * Class MP3_Playlist_XHTML, generates the XHTML page for playlist. * * @category File Formats * @package MP3_Playlist * @author David Costa <gurugeek@php.net> * @author Ashley Hewson <morbidness@gmail.com> * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2004-2005 David Costa * @license http://www.php.net/license/3_0.txt * The PHP License, version 3.0 * @version Release: @package_version@ */ class MP3_Playlist_XHTML extends MP3_Playlist_Common { // {{{ Object Properties /** * Mime type of output. * @var string */ protected $mimeType = 'application/xhtml+xml'; /** * File extension (without dot). * @var string */ protected $fileExtension = 'html'; /** * XHTML required the merged list. * @var bool */ protected $isRequiredMerged = true; // }}} // {{{ make() /** * Generate a valid XHTML playlist with link to the given URL defined * on parsing * * It can also generates the mere tables and therefore allows the user * to customize the look and feel * * @param array $params Make parameters. * <pre> * title string Page title. * fullpage bool (optional) If TRUE it will generate a full XHTML page, * otherwise only tables, default is TRUE. * </pre> * * @return bool TRUE */ public function make($params = array()) { if (!isset($params['title'])) { throw new PEAR_Exception(MP3_Playlist::E_REQUIRED_PARAM . ' "title" as page title', -1); } $title = $params['title']; $fullpage = isset($params['fullpage']) ? $params['fullpage'] : true; // Preparing the numbers $numloop = 0; // Checking if we are producing a shuffled playlist if ($this->isShuffle == true) { shuffle($this->merged); } $xhtmlLoop = ''; // creating the tables foreach ($this->merged as $prepared) { $prepared['title'] = htmlspecialchars($prepared['title']); $prepared['artist'] = htmlspecialchars($prepared['artist']); $prepared['album'] = htmlspecialchars($prepared['album']); $prepared['genre'] = htmlspecialchars($prepared['genre']); // adding random colors in the list $tag = '<tr class="' .($numloop%2 ? 'wh' : 'bl' ) . '">'; $numloop++; $xhtmlLoop .= <<<LOOP $tag <td class="left" title="$numloop">$numloop</td> <td title="{$prepared['title']}"><div style="height:1.2em; width:100%; overflow:hidden;"><a href="{$prepared['URL']}">{$prepared['title']}</a></div></td> <td title="{$prepared['artist']}"><div style="height:1.2em; width:100%; overflow:hidden;">{$prepared['artist']}</div></td> <td title="{$prepared['album']}"><div style="height:1.2em; width:100%; overflow:hidden;">{$prepared['album']}</div></td> <td title="{$prepared['genre']}">{$prepared['genre']}</td> </tr> LOOP; } // XHTML standard headers plus the tables $xhtmlBody = <<<XML <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>$title</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css"> body {font-family:lucida grande, arial;} .box {margin:0 auto 0 auto; font-size:11px;} .header {text-align:center; font-size:13px;} table {border:1px solid #666; margin:0 auto 0 auto; font-size:11px;} td {border:1px #d9d9d9; border-style: none none none solid; padding:2px 5px 2px 5px;} .top {background:url(images/top.png);} .left {border:0px; text-align:right;} .right {text-align:right} .wh {background:#fff;} .bl {background:#edf3fe;} </style> </head> <body> <div class="box"> <div class="header" title="$title">$title</div><br/> <table cellspacing="0"> <tr class="top"> <td class="left"> </td> <td title ="Song Name">Song Name</td> <td title="Artist">Artist</td> <td title="Album">Album</td> <td title="Genre">Genre</td> </tr> $xhtmlLoop </table> <p> <a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml11" alt="Valid XHTML 1.1!" height="31" width="88" /></a> </p> <br/> </div> </body> </html> XML; if ($fullpage == true) { // display the page $this->result = $xhtmlBody; } else { // display the tables only $this->result = $xhtmlLoop; } return true; } // }}} } // }}} http://cvs.php.net/co.php/pear/MP3_Playlist/MP3/Playlist/XML.php?r=1.1&p=1 Index: pear/MP3_Playlist/MP3/Playlist/XML.php +++ pear/MP3_Playlist/MP3/Playlist/XML.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */ // {{{ Header /** * File contains MP3_Playlist_XML class. * * PHP version 5 * * LICENSE: * * The PHP License, version 3.0 * * Copyright (c) 2004-2005 David Costa * * This source file is subject to version 3.0 of the PHP license, * that is bundled with this package in the file LICENSE, and is * available through the world-wide-web at the following url: * http://www.php.net/license/3_0.txt. * If you did not receive a copy of the PHP license and are unable to * obtain it through the world-wide-web, please send a note to * license@php.net so we can mail you a copy immediately. * * @category File Formats * @package MP3_Playlist * @author David Costa <gurugeek@php.net> * @author Ashley Hewson <morbidness@gmail.com> * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2004-2005 David Costa * @license http://www.php.net/license/3_0.txt * The PHP License, version 3.0 * @version CVS: $Id: XML.php,v 1.1 2005/10/02 17:38:57 firman Exp $ */ // }}} // {{{ Dependencies /** * Load MP3_Playlist_Common as the base class. */ require_once 'MP3/Playlist/Common.php'; // }}} // {{{ Class: MP3_Playlist_XML /** * Class MP3_Playlist_XML, generate the XML document for playlist. * * @category File Formats * @package MP3_Playlist * @author David Costa <gurugeek@php.net> * @author Ashley Hewson <morbidness@gmail.com> * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2004-2005 David Costa * @license http://www.php.net/license/3_0.txt * The PHP License, version 3.0 * @version Release: @package_version@ */ class MP3_Playlist_XML extends MP3_Playlist_Common { // {{{ Object Properties /** * Mime type of output. * @var string */ protected $mimeType = 'application/xml'; /** * File extension (without dot). * @var string */ protected $fileExtension = 'xml'; /** * XML required the merged list. * @var bool */ protected $isRequiredMerged = true; // }}} // {{{ preXML() /** * Prepares the xml format for the loop used on makexml * * @param string $value character data that goes into the XML element * @param string $key the name of the XML element * * @return TRUE */ private function preXML($value, $key) { $this->result .= " <$key>" . htmlentities($value) . "</$key>\n"; return true; } // }}} // {{{ make() /** * Generates a valid XML with the playlist values. * * @param array $params (optional) No parameters, ignore this. * * @return bool TRUE */ public function make($params = array()) { // Defining XML headers $this->result = '<?xml version="1.0" encoding="ISO-8859-1" ?>'."\n"; $this->result .= "<playlist>\n"; // Adding the prexml formatted tags to each of the array members // adding also the track tag foreach ($this->merged as $list){ $this->result .= " <track>\n"; array_walk($list, array(&$this, 'preXML')); $this->result .= " </track>\n"; } $this->result .= "</playlist>"; return true; } // }}} } // }}} http://cvs.php.net/co.php/pear/MP3_Playlist/docs/examples/include/footer.php?r=1.1&p=1 Index: pear/MP3_Playlist/docs/examples/include/footer.php +++ pear/MP3_Playlist/docs/examples/include/footer.php </div> </body> </html> http://cvs.php.net/co.php/pear/MP3_Playlist/docs/examples/include/head.php?r=1.1&p=1 Index: pear/MP3_Playlist/docs/examples/include/head.php +++ pear/MP3_Playlist/docs/examples/include/head.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>PEAR::MP3_Playlist Usage Example</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <style type="text/css"> body, table, select, textarea, input { font-family: Arial, Verdana, Helvetica, sans-serif; font-size: 12px; color: #333333 } body { text-align: center; } ul { margin: 0 0 0 20px; } h1 { font-size:18px; color: #006600; } h2 { font-size: 16px; color: #006600; } h3 { font-size: 14px; color: #006600; } hr { border: 0; background: #006600; color: #006600; } td { vertical-align: top; } a:link { color: #006600 } a:visited { color: #030 } a:hover { color: #003300 } form { margin: 0; padding: 0; } img { border: 0; } #body { width: 760px; text-align: left; margin: auto; }..flag { font-style: italic; color: #ff3300; }..nav { text-align: right; padding: 4px; border-bottom: 1px solid black; }..code { border: 1px dashed grey; padding: 4px; background: #f8f8f8; } </style> </head> <body> <div id="body"> http://cvs.php.net/co.php/pear/MP3_Playlist/docs/examples/include/header.php?r=1.1&p=1 Index: pear/MP3_Playlist/docs/examples/include/header.php +++ pear/MP3_Playlist/docs/examples/include/header.php <h1>PEAR::MP3_Playlist Usage Example</h1> MP3_Playlist Copyright © 2004-2005 by David Costa. <hr /> http://cvs.php.net/co.php/pear/MP3_Playlist/docs/examples/index.php?r=1.1&p=1 Index: pear/MP3_Playlist/docs/examples/index.php +++ pear/MP3_Playlist/docs/examples/index.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker */ include_once 'include/head.php'; include_once 'include/header.php'; require_once 'Net/URL.php'; $url = new Net_URL; $url->path = dirname($url->path); ?> <script language="javascript" type="text/javascript"> function hideElement(id) { var obj = document.getElementById(id); if (obj != null) { obj.style.display = 'none'; } } function showElement(id) { var obj = document.getElementById(id); if (obj != null) { obj.style.display = ''; } } function showMakeParams(type) { var makeTypes = new Array('M3U', 'SMIL', 'XML', 'XHTML', 'RSS', 'SQLite'); showElement('Params' + type); for (var i = 0; i < makeTypes.length; i++) { if (makeTypes[i] == type) { continue; } hideElement('Params' + makeTypes[i]); } } function notify(obj, msg) { if (obj != null) { obj.style.backgroundColor = '#ADDBAD'; alert(msg); } } function validateParams() { var theForm = document.FormParams; if (theForm.InputDir.value == '') { notify(theForm.InputDir, 'Please type the Input Directory'); return false; } if (theForm.BaseURL.value == '') { notify(theForm.BaseURL, 'Please type the Base URL'); return false; } if (document.getElementById('output_save').checked) { if (theForm.OutputDir.value == '') { notify(theForm.OutputDir, 'Please type the Output Directory'); return false; } } if (document.getElementById('output_save').checked || document.getElementById('output_send').checked) { if (theForm.FileName.value == '') { notify(theForm.FileName, 'Please type the File Name'); return false; } } if (theForm.MakeType.value == '') { notify(theForm.MakeType, 'Please select the Type'); return false; } if (theForm.MakeType.value == 'XHTML') { if (document.getElementById('ParamsXHTML[title]').value == '') { notify(document.getElementById('ParamsXHTML[title]'), 'Please type the Title'); return false; } } if (theForm.MakeType.value == 'RSS') { if (document.getElementById('ParamsRSS[title]').value == '') { notify(document.getElementById('ParamsRSS[title]'), 'Please type the Feed Title'); return false; } if (document.getElementById('ParamsRSS[description]').value == '') { notify(document.getElementById('ParamsRSS[description]'), 'Please type the Feed Description'); return false; } if (document.getElementById('ParamsRSS[link]').value == '') { notify(document.getElementById('ParamsRSS[link]'), 'Please type the Feed Link'); return false; } } if (theForm.MakeType.value == 'SQLite') { if (document.getElementById('ParamsSQLite[db]').value == '') { notify(document.getElementById('ParamsSQLite[db]'), 'Please type the Database Name'); return false; } if (document.getElementById('ParamsSQLite[table]').value == '') { notify(document.getElementById('ParamsSQLite[table]'), 'Please type the Database Table Name'); return false; } } return true; } </script> Please specified the parameters, however by default this example assumed that your songs placed in <b><?php print dirname(__FILE__) . DIRECTORY_SEPARATOR . 'songs'; ?></b>. <h3>Main Parameters</h3> <form name="FormParams" id="FormParams" action="result.php" target="result" method="post" onSubmit="return validateParams();"> <b>Input Directory:</b><br /> <small>Make sure, this directory readable by Web server.</small><br /> <input type="text" name="InputDir" value="<?php print dirname(__FILE__) . DIRECTORY_SEPARATOR . 'songs'; ?>" size="80" /><br /> <b>Base URL:</b><br /> <small>The base URL where you placed your songs.</small><br /> <input type="text" name="BaseURL" value="<?php print $url->getURL() . '/songs'; ?>" size="80" /><br /> <div id="output_dir" style="display: none"> <b>Output Directory:</b><br /> <input type="text" name="OutputDir" value="<?php print dirname(__FILE__); ?>" size="80" /><br /> </div> <div id="filename" style="display: "> <b>File Name:</b><br /> <small>Name of the playlist (without file extension). Suffix is added automatically.</small> <input type="text" name="FileName" value="test" size="80" /><br /> </div> <b>Debug:</b><br /> <small>Show debug messages?</small><br /> <input type="radio" name="debug" id="debug_yes" value="1" /> <label for="debug_yes">Yes</label> <input type="radio" name="debug" id="debug_no" value="0" checked /> <label for="debug_no">No</label> <h3>Make Parameters</h3> <b>Make What?</b><br /> <select name="MakeType" onChange="showMakeParams(this.value);"> <option value="">Select ...</option> <option value="M3U">M3U</option> <option value="SMIL">SMIL</option> <option value="XML">XML</option> <option value="XHTML">XHTML</option> <option value="RSS">RSS</option> <option value="SQLite">SQLite</option> </select><br /> <div id="ParamsXHTML" style="display: none;"> <b>Title (title):</b><br /> <input type="text" name="ParamsXHTML[title]" id="ParamsXHTML[title]" value="Generated Playlist" size="80" /><br /> <b>Fullpage (fullpage):</b><br /> <input type="radio" name="ParamsXHTML[fullpage]" id="ParamsXHTML_fullpage_yes" value="1" checked /> <label for="ParamsXHTML_fullpage_yes">Yes</label> <input type="radio" name="ParamsXHTML[fullpage]" id="ParamsXHTML_fullpage_no" value="0" /> <label for="ParamsXHTML_fullpage_no">No</label> </div> <div id="ParamsRSS" style="display: none;"> <b>Feed Title (title):</b><br /> <input type="text" name="ParamsRSS[title]" id="ParamsRSS[title]" value="Generated Playlist" size="80" /><br /> <b>Feed Description (description):</b><br /> <input type="text" name="ParamsRSS[description]" id="ParamsRSS[description]" value="MP3_Playlist Usage Example" size="80" /><br /> <b>Feed Link (link):</b><br /> <input type="text" name="ParamsRSS[link]" id="ParamsRSS[link]" value="<?php print $url->getURL(); ?>" size="80" /><br /> </div> <div id="ParamsSQLite" style="display: none;"> <b>Database Name (db):</b><br /> <small>Absolute fullpath also allowed</small><br /> <input type="text" name="ParamsSQLite[db]" id="ParamsSQLite[db]" value="playlist.sqlite" size="80" /><br /> <b>Database Table Name (table):</b><br /> <input type="text" name="ParamsSQLite[table]" id="ParamsSQLite[table]" value="playlist" size="80" /><br /> <b>Create Table (maketable):</b><br /> <input type="radio" name="ParamsSQLite[maketable]" id="ParamsSQLite_maketable_yes" value="1" checked /> <label for="ParamsSQLite_maketable_yes">Yes</label> <input type="radio" name="ParamsSQLite[maketable]" id="ParamsSQLite_maketable_no" value="0" /> <label for="ParamsSQLite_maketable_no">No</label><br /> <b>Columns (columns):</b><br /> <small>6 columns, separated by commas (fullpath, url, title, artist, album, genre)</small><br /> <input type="text" name="ParamsSQLite[columns]" id="ParamsSQLite[columns]" value="fullpath, url, title, artist, album, genre" size="80" /><br /> </div> <b>Shuffle:</b><br /> <input type="radio" name="shuffle" id="shuffle_yes" value="1" /> <label for="shuffle_yes">Yes</label> <input type="radio" name="shuffle" id="shuffle_no" value="0" checked /> <label for="shuffle_no">No</label> <h3>Output</h3> <b>Options:</b><br /> <input type="radio" name="output" id="output_save" value="save" onClick="showElement('output_dir'); showElement('filename');" /> <label for="output_save">Save</label> <input type="radio" name="output" id="output_send" value="send" onClick="hideElement('output_dir'); showElement('filename');" checked /> <label for="output_send">Send</label> <input type="radio" name="output" id="output_show" value="show" onClick="hideElement('output_dir'); hideElement('filename');" /> <label for="output_show">Show</label><br /> <input type="submit" name="submit" value="Make It!"> </form> <h3>Result</h3> <b>Output Result (if available):</b> <iframe name="result" style="width:100%; height: 400px" frameborder="1"></iframe> <h3>Source</h3> <div class="code"> <?php highlight_file(dirname(__FILE__) . '/result.php'); ?> </div> <script language="javascript" type="text/javascript"> // Force browser saved form informations. document.getElementById('output_send').checked = true; document.FormParams.MakeType.options[0].selected = true; </script> <?php include_once 'include/footer.php'; /* * Local variables: * mode: php * tab-width: 4 * c-basic-offset: 4 * c-hanging-comment-ender-p: nil * End: */ ?> http://cvs.php.net/co.php/pear/MP3_Playlist/docs/examples/result.php?r=1.1&p=1 Index: pear/MP3_Playlist/docs/examples/result.php +++ pear/MP3_Playlist/docs/examples/result.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker */ /** * Load MP3_Playlist class. */ require_once 'MP3/Playlist.php'; if (isset($_POST['submit'])) { // Default make parameters $params = array(); // Pick the type. switch ($_POST['MakeType']) { case 'M3U': $type = MP3_Playlist::TYPE_M3U; break; case 'SMIL': $type = MP3_Playlist::TYPE_SMIL; break; case 'XML': $type = MP3_Playlist::TYPE_XML; break; case 'XHTML': $type = MP3_Playlist::TYPE_XHTML; $params = $_POST['ParamsXHTML']; break; case 'RSS': $type = MP3_Playlist::TYPE_RSS; $params = $_POST['ParamsRSS']; break; case 'SQLite': $type = MP3_Playlist::TYPE_SQLITE; $params = $_POST['ParamsSQLite']; break; } // Create new instance of MP3_Playlist. $playlist = new MP3_Playlist($_POST['InputDir'], $_POST['OutputDir'], $_POST['BaseURL'], $_POST['debug']); try { // Call make() method, where 3 parameters (type, params and shuffle). $playlist->make($type, $params, $_POST['shuffle']); $outputFunction = $_POST['output'] . '()'; // Decoration. if ($_POST['output'] == 'show') { print "<pre>\n"; } // Call output method. $playlist->$_POST['output'](); // Decoration. if ($_POST['output'] == 'show') { print "</pre>\n"; } } catch (PEAR_Exception $e) { print '<b>Error</b>: ' . $e->getMessage(); } } /* * Local variables: * mode: php * tab-width: 4 * c-basic-offset: 4 * c-hanging-comment-ender-p: nil * End: */ ?> http://cvs.php.net/co.php/pear/MP3_Playlist/generate_package_xml.php?r=1.1&p=1 Index: pear/MP3_Playlist/generate_package_xml.php +++ pear/MP3_Playlist/generate_package_xml.php <?php require_once('PEAR/PackageFileManager.php'); $pkg = new PEAR_PackageFileManager; $packagedir = dirname(__FILE__); $self = basename(__FILE__); $desc = "MP3_Playlist is a php library to facilitate the creation and to some extend the rendering of MP3 playlists. It scans a local folder with all the MP3 files and outputs the playlist in several formats including M3U, SMIL, XML, XHTML with the possibility to backup the lists on the fly with an SQLite DB."; $options = array( 'simpleoutput' => true, 'doctype' => 'D:\Net\www\htdocs\PEAR\PEAR\data\PEAR\package.dtd', 'package' => 'MP3_Playlist', 'license' => 'PHP License', 'baseinstalldir' => '', 'version' => '0.5.0alpha1', 'packagedirectory' => $packagedir, 'pathtopackagefile' => $packagedir, 'state' => 'alpha', 'filelistgenerator' => 'file', 'notes' => 'Initial release of MP3_Playlist', 'summary' => 'Library to create MP3 playlists on the fly, several formats supported including XML, RSS and XHTML', 'description' => $desc, 'dir_roles' => array( 'docs' => 'doc', 'data' => 'data' ), 'ignore' => array( 'package.xml', '*.tgz', $self ) ); $e = $pkg->setOptions($options); if (PEAR::isError($e)) { echo $e->getMessage(); die; } // hack until they get their shit in line with docroot role $pkg->addRole('tpl', 'php'); $pkg->addRole('png', 'php'); $pkg->addRole('gif', 'php'); $pkg->addRole('jpg', 'php'); $pkg->addRole('css', 'php'); $pkg->addRole('js', 'php'); $pkg->addRole('ini', 'php'); $pkg->addRole('inc', 'php'); $pkg->addRole('afm', 'php'); $pkg->addRole('pkg', 'doc'); $pkg->addRole('cls', 'doc'); $pkg->addRole('proc', 'doc'); $pkg->addRole('txt', 'doc'); $pkg->addRole('sh', 'script'); $pkg->addMaintainer('gurugeek', 'lead', 'David Costa', 'gurugeek@php.net'); $pkg->addMaintainer('firman', 'lead', 'Firman Wandayandi', 'firman@php.net'); $pkg->addDependency('PHP', '5.0.0', 'ge', 'php'); $pkg->addDependency('PEAR', '1.3.0', 'ge', 'pkg'); $pkg->addDependency('Net_URL', '1.0.14', 'ge', 'pkg'); $pkg->addDependency('MP3_Id', '1.1.4', 'ge', 'pkg'); $e = $pkg->addGlobalReplacement('package-info', '@package_version@', 'version'); $e = $pkg->writePackageFile(); if (PEAR::isError($e)) { echo $e->getMessage(); } ?> http://cvs.php.net/co.php/pear/MP3_Playlist/package.xml?r=1.1&p=1 Index: pear/MP3_Playlist/package.xml +++ pear/MP3_Playlist/package.xml <?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE package SYSTEM "http://pear.php.net/dtd/package-1.0"> <package version="1.0"> <name>MP3_Playlist</name> <summary>Library to create MP3 playlists on the fly, several formats supported including XML, RSS and XHTML</summary> <description>MP3_Playlist is a php library to facilitate the creation and to some extend the rendering of MP3 playlists. It scans a local folder with all the MP3 files and outputs the playlist in several formats including M3U, SMIL, XML, XHTML with the possibility to backup the lists on the fly with an SQLite DB.</description> <maintainers> <maintainer> <user>gurugeek</user> <name>David Costa</name> <email>gurugeek@php.net</email> <role>lead</role> </maintainer> <maintainer> <user>firman</user> <name>Firman Wandayandi</name> <email>firman@php.net</email> <role>lead</role> </maintainer> </maintainers> <release> <version>0.5.0alpha1</version> <date>2005-09-03</date> <license>PHP License</license> <state>alpha</state> <notes>Initial release of MP3_Playlist</notes> <deps> <dep type="php" rel="ge" version="5.0.0" optional="no"/> <dep type="pkg" rel="ge" version="1.3.0" optional="no">PEAR</dep> <dep type="pkg" rel="ge" version="1.0.14" optional="no">Net_URL</dep> <dep type="pkg" rel="ge" version="1.1.4" optional="no">MP3_Id</dep> </deps> <filelist> <dir baseinstalldir="" name="/"> <dir name="docs"> <dir name="examples"> <file role="doc" name="index.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> <file role="doc" name="result.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> <dir name="include"> <file role="doc" name="footer.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> <file role="doc" name="head.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> <file role="doc" name="header.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> </dir> <!-- docs/examples/include --> </dir> <!-- docs/examples --> </dir> <!-- docs --> <dir name="MP3"> <file role="php" name="Playlist.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> <dir name="Playlist"> <file role="php" name="Common.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> <file role="php" name="M3U.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> <file role="php" name="RSS.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> <file role="php" name="SMIL.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> <file role="php" name="SQLite.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> <file role="php" name="XHTML.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> <file role="php" name="XML.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> </dir> <!-- MP3/Playlist --> </dir> <!-- MP3 --> </dir> <!-- / --> </filelist> </release> <changelog> <release> <version>0.5.0alpha1</version> <date>2005-09-03</date> <license>PHP License</license> <state>alpha</state> <notes>Initial release of MP3_Playlist</notes> </release> </changelog> </package>