MP3_Playlist
[ class tree: MP3_Playlist ] [ index: MP3_Playlist ] [ all elements ]

Source for file index.php

Documentation is available at index.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker */
  3.  
  4. include_once 'include/head.php';
  5. include_once 'include/header.php';
  6.  
  7. require_once 'Net/URL.php';
  8. $url = new Net_URL;
  9. $url->path = dirname($url->path);
  10.  
  11. ?>
  12. <script language="javascript" type="text/javascript">
  13. function hideElement(id)
  14. {
  15.     var obj = document.getElementById(id);
  16.     if (obj != null) {
  17.         obj.style.display = 'none';
  18.     }
  19. }
  20. function showElement(id)
  21. {
  22.     var obj = document.getElementById(id);
  23.     if (obj != null) {
  24.         obj.style.display = '';
  25.     }
  26. }
  27.  
  28. function showMakeParams(type)
  29. {
  30.     var makeTypes = new Array('M3U', 'SMIL', 'XML', 'XHTML', 'RSS', 'SQLite');
  31.  
  32.     showElement('Params' + type);
  33.  
  34.     for (var i = 0; i < makeTypes.length; i++) {
  35.         if (makeTypes[i] == type) {
  36.             continue;
  37.         }
  38.  
  39.         hideElement('Params' + makeTypes[i]);
  40.     }
  41. }
  42.  
  43. function notify(obj, msg)
  44. {
  45.     if (obj != null) {
  46.         obj.style.backgroundColor = '#ADDBAD';
  47.         alert(msg);
  48.     }
  49. }
  50.  
  51. function validateParams()
  52. {
  53.     var theForm = document.FormParams;
  54.  
  55.     if (theForm.InputDir.value == '') {
  56.         notify(theForm.InputDir, 'Please type the Input Directory');
  57.         return false;
  58.     }
  59.     if (theForm.BaseURL.value == '') {
  60.         notify(theForm.BaseURL, 'Please type the Base URL');
  61.         return false;
  62.     }
  63.     if (document.getElementById('output_save').checked) {
  64.         if (theForm.OutputDir.value == '') {
  65.             notify(theForm.OutputDir, 'Please type the Output Directory');
  66.             return false;
  67.         }
  68.     }
  69.     if (document.getElementById('output_save').checked ||
  70.         document.getElementById('output_send').checked) {
  71.         if (theForm.FileName.value == '') {
  72.             notify(theForm.FileName, 'Please type the File Name');
  73.             return false;
  74.         }
  75.     }
  76.     if (theForm.MakeType.value == '') {
  77.         notify(theForm.MakeType, 'Please select the Type');
  78.         return false;
  79.     }
  80.  
  81.     if (theForm.MakeType.value == 'XHTML') {
  82.         if (document.getElementById('ParamsXHTML[title]').value == '') {
  83.             notify(document.getElementById('ParamsXHTML[title]'), 'Please type the Title');
  84.             return false;
  85.         }
  86.     }
  87.  
  88.     if (theForm.MakeType.value == 'RSS') {
  89.         if (document.getElementById('ParamsRSS[title]').value == '') {
  90.             notify(document.getElementById('ParamsRSS[title]'), 'Please type the Feed Title');
  91.             return false;
  92.         }
  93.         if (document.getElementById('ParamsRSS[description]').value == '') {
  94.             notify(document.getElementById('ParamsRSS[description]'), 'Please type the Feed Description');
  95.             return false;
  96.         }
  97.         if (document.getElementById('ParamsRSS[link]').value == '') {
  98.             notify(document.getElementById('ParamsRSS[link]'), 'Please type the Feed Link');
  99.             return false;
  100.         }
  101.     }
  102.  
  103.     if (theForm.MakeType.value == 'SQLite') {
  104.         if (document.getElementById('ParamsSQLite[db]').value == '') {
  105.             notify(document.getElementById('ParamsSQLite[db]'), 'Please type the Database Name');
  106.             return false;
  107.         }
  108.  
  109.         if (document.getElementById('ParamsSQLite[table]').value == '') {
  110.             notify(document.getElementById('ParamsSQLite[table]'), 'Please type the Database Table Name');
  111.             return false;
  112.         }
  113.     }
  114.  
  115.     return true;
  116. }
  117. </script>
  118. Please specified the parameters, however by default this example assumed that your songs placed in <b><?php print dirname(__FILE__. DIRECTORY_SEPARATOR . 'songs'?></b>.
  119. <h3>Main Parameters</h3>
  120. <form name="FormParams" id="FormParams" action="result.php" target="result" method="post" onSubmit="return validateParams();">
  121. <b>Input Directory:</b><br />
  122. <small>Make sure, this directory readable by Web server.</small><br />
  123. <input type="text" name="InputDir" value="<?php print dirname(__FILE__. DIRECTORY_SEPARATOR . 'songs'?>" size="80" /><br />
  124. <b>Base URL:</b><br />
  125. <small>The base URL where you placed your songs.</small><br />
  126. <input type="text" name="BaseURL" value="<?php print $url->getURL('/songs'?>" size="80" /><br />
  127. <div id="output_dir" style="display: none">
  128. <b>Output Directory:</b><br />
  129. <input type="text" name="OutputDir" value="<?php print dirname(__FILE__)?>" size="80" /><br />
  130. </div>
  131. <div id="filename" style="display: ">
  132. <b>File Name:</b><br />
  133. <small>Name of the playlist (without file extension). Suffix is added automatically.</small>
  134. <input type="text" name="FileName" value="test" size="80" /><br />
  135. </div>
  136. <b>Debug:</b><br />
  137. <small>Show debug messages?</small><br />
  138. <input type="radio" name="debug" id="debug_yes" value="1" />
  139. <label for="debug_yes">Yes</label>
  140. <input type="radio" name="debug" id="debug_no" value="0" checked />
  141. <label for="debug_no">No</label>
  142. <h3>Make Parameters</h3>
  143. <b>Make What?</b><br />
  144. <select name="MakeType" onChange="showMakeParams(this.value);">
  145. <option value="">Select ...</option>
  146. <option value="M3U">M3U</option>
  147. <option value="SMIL">SMIL</option>
  148. <option value="XML">XML</option>
  149. <option value="XHTML">XHTML</option>
  150. <option value="RSS">RSS</option>
  151. <option value="SQLite">SQLite</option>
  152. </select><br />
  153. <div id="ParamsXHTML" style="display: none;">
  154. <b>Title (title):</b><br />
  155. <input type="text" name="ParamsXHTML[title]" id="ParamsXHTML[title]" value="Generated Playlist" size="80" /><br />
  156. <b>Fullpage (fullpage):</b><br />
  157. <input type="radio" name="ParamsXHTML[fullpage]" id="ParamsXHTML_fullpage_yes" value="1" checked />
  158. <label for="ParamsXHTML_fullpage_yes">Yes</label>
  159. <input type="radio" name="ParamsXHTML[fullpage]" id="ParamsXHTML_fullpage_no" value="0" />
  160. <label for="ParamsXHTML_fullpage_no">No</label>
  161. </div>
  162. <div id="ParamsRSS" style="display: none;">
  163. <b>Feed Title (title):</b><br />
  164. <input type="text" name="ParamsRSS[title]" id="ParamsRSS[title]" value="Generated Playlist" size="80" /><br />
  165. <b>Feed Description (description):</b><br />
  166. <input type="text" name="ParamsRSS[description]" id="ParamsRSS[description]" value="MP3_Playlist Usage Example" size="80" /><br />
  167. <b>Feed Link (link):</b><br />
  168. <input type="text" name="ParamsRSS[link]" id="ParamsRSS[link]" value="<?php print $url->getURL()?>" size="80" /><br />
  169. </div>
  170. <div id="ParamsSQLite" style="display: none;">
  171. <b>Database Name (db):</b><br />
  172. <small>Absolute fullpath also allowed</small><br />
  173. <input type="text" name="ParamsSQLite[db]" id="ParamsSQLite[db]" value="playlist.sqlite" size="80" /><br />
  174. <b>Database Table Name (table):</b><br />
  175. <input type="text" name="ParamsSQLite[table]" id="ParamsSQLite[table]" value="playlist" size="80" /><br />
  176. <b>Create Table (maketable):</b><br />
  177. <input type="radio" name="ParamsSQLite[maketable]" id="ParamsSQLite_maketable_yes" value="1" checked />
  178. <label for="ParamsSQLite_maketable_yes">Yes</label>
  179. <input type="radio" name="ParamsSQLite[maketable]" id="ParamsSQLite_maketable_no" value="0" />
  180. <label for="ParamsSQLite_maketable_no">No</label><br />
  181. <b>Columns (columns):</b><br />
  182. <small>6 columns, separated by commas (fullpath, url, title, artist, album, genre)</small><br />
  183. <input type="text" name="ParamsSQLite[columns]" id="ParamsSQLite[columns]" value="fullpath, url, title, artist, album, genre" size="80" /><br />
  184. </div>
  185. <b>Shuffle:</b><br />
  186. <input type="radio" name="shuffle" id="shuffle_yes" value="1" />
  187. <label for="shuffle_yes">Yes</label>
  188. <input type="radio" name="shuffle" id="shuffle_no" value="0" checked />
  189. <label for="shuffle_no">No</label>
  190. <h3>Output</h3>
  191. <b>Options:</b><br />
  192. <input type="radio" name="output" id="output_save" value="save" onClick="showElement('output_dir'); showElement('filename');" />
  193. <label for="output_save">Save</label>
  194. <input type="radio" name="output" id="output_send" value="send" onClick="hideElement('output_dir'); showElement('filename');" checked />
  195. <label for="output_send">Send</label>
  196. <input type="radio" name="output" id="output_show" value="show" onClick="hideElement('output_dir'); hideElement('filename');" />
  197. <label for="output_show">Show</label><br />
  198. <input type="submit" name="submit" value="Make It!">
  199. </form>
  200. <h3>Result</h3>
  201. <b>Output Result (if available):</b>
  202. <iframe name="result" style="width:100%; height: 400px" frameborder="1"></iframe>
  203. <h3>Source</h3>
  204. <div class="code">
  205. <?php
  206. highlight_file(dirname(__FILE__'/result.php');
  207. ?>
  208. </div>
  209. <script language="javascript" type="text/javascript">
  210. // Force browser saved form informations.
  211. document.getElementById('output_send').checked = true;
  212. document.FormParams.MakeType.options[0].selected = true;
  213. </script>
  214. <?php
  215. include_once 'include/footer.php';
  216.  
  217. /*
  218.  * Local variables:
  219.  * mode: php
  220.  * tab-width: 4
  221.  * c-basic-offset: 4
  222.  * c-hanging-comment-ender-p: nil
  223.  * End:
  224.  */
  225. ?>

Documentation generated on Mon, 11 Mar 2019 15:39:05 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.