PageRenderTime 51ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 1ms

/zina/theme.php

https://bitbucket.org/helmespc/zina2
PHP | 2627 lines | 2098 code | 335 blank | 194 comment | 409 complexity | 40374136df0ede9f79ec5558f4bcf280 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  3. * ZINA2 (Zina2 is not Zina)
  4. *
  5. * Zina2 is a graphical interface to your MP3 collection, a personal
  6. * jukebox, an MP3 streamer. It can run on its own, embeded into an
  7. * existing website, or as a Drupal/Joomla/Wordpress/etc. module.
  8. *
  9. * https://bitbucket.org/helmespc/zina2
  10. * Author: Patrick Helmes <helmespc@gmail.com>
  11. * Support: https://bitbucket.org/helmespc/zina2/wiki/Home
  12. * License: GNU GPL2 <http://www.gnu.org/copyleft/gpl.html>
  13. *
  14. * This Software is a fork of Zina (is not Andromeda):
  15. * http://www.pancake.org/zina
  16. * Author: Ryan Lathouwers <ryanlath@pacbell.net>
  17. * Support: http://sourceforge.net/projects/zina/
  18. * License: GNU GPL2 <http://www.gnu.org/copyleft/gpl.html>
  19. *
  20. * TODO:
  21. * - organize this file
  22. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  23. /*
  24. * YOU SHOULD NOT MODIFY THIS FILE...
  25. *
  26. * You should override all these functions in your own theme:
  27. * 1) Copy a theme folder
  28. * 2) in MYTHEME/index.php copy any function you want to
  29. * override into that file
  30. * 3) rename that function to MYTHEME_function()
  31. * - e.g. ztheme_icon -> MYTHEME_icon
  32. * 4) modify that function to suit your needs
  33. * x) An easy way to see what a function is passing is zdbg($var);
  34. */
  35. /*
  36. * Complete Page (Standalone)
  37. */
  38. function ztheme_page_complete($zina) {
  39. $theme_path = $zina['theme_path'];
  40. $output = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'.
  41. '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><title>'.$zina['title'].'</title>'.
  42. '<meta http-equiv="Content-Type" content="text/html; charset='.$zina['charset'].'" />'.
  43. '<link rel="shortcut icon" href="'.$theme_path.'/zina.ico" type="image/x-icon" />'.
  44. '<link rel="stylesheet" href="'.$theme_path.'/index.css" type="text/css" />'.
  45. '<!--[if lt IE 7]><link type="text/css" rel="stylesheet" media="all" href="'.$theme_path.'/fix-ie.css" /><![endif]-->'.
  46. $zina['head_html'].$zina['head_css'].$zina['head_js'].'</head><body>';
  47. $output .= '<div id="header-region" class="clear-block"></div>'.
  48. '<div id="wrapper"><div id="container" class="clear-block">'.
  49. '<div id="header"><h1>'.$zina['title'].'</h1>'.
  50. '<div class="header-right">';
  51. if (isset($zina['dir_year']) || isset($zina['dir_genre'])) {
  52. $output .= '<span class="title_details">';
  53. if (isset($zina['dir_genre'])) $output .= $zina['dir_genre'];
  54. if (!empty($zina['dir_year'])) $output .= ' ('.$zina['dir_year'].')';
  55. $output .= '</span>';
  56. }
  57. $output .= '</div></div>'.
  58. '<div id="center"><div class="right-corner"><div class="left-corner">'.
  59. '<div class="breadcrumb">'.ztheme('breadcrumb',$zina['breadcrumb']).'</div>'.
  60. '<div class="breadcrumb-right">';
  61. if (isset($zina['admin_config'])) {
  62. $output .= zl(ztheme('icon','config.gif',zt('Settings')),$zina['admin_config']['path'],$zina['admin_config']['query']);
  63. }
  64. $lang['login'] = zt('Login');
  65. $lang['logout'] = zt('Logout');
  66. if (isset($zina['login'])) {
  67. $output .= zl(ztheme('icon',$zina['login']['type'].'.gif',$lang[$zina['login']['type']]), $zina['login']['path'], $zina['login']['query']);
  68. }
  69. $output .= '</div><div id="zina" class="clear-block">';
  70. if (!isset($zina['popup'])) {
  71. $output .= '<div class="subheader clear-block"><div class="subheader-left">'.$zina['searchform'].'</div>'.
  72. '<div class="subheader-right">'.$zina['randomplayform'].'</div></div>';
  73. if (!empty($zina['zinamp']) && (!isset($zina['page_main']) || isset($zina['category']))) {
  74. $output .= '<div style="text-align:right;">'.$zina['zinamp'].'</div>';
  75. }
  76. }
  77. $output .= '<div id="zina_messages">'.$zina['messages'].'</div>'.$zina['content'].ztheme('page_footer',$zina).
  78. '</div></div></div></div></div></div></body></html>';
  79. return $output;
  80. }
  81. function ztheme_page_main($zina) {
  82. $path = $zina['path'];
  83. $output = '';
  84. $lang['dir'] = zt('Edit Text');
  85. $lang['dir_opts'] = zt('Options');
  86. $lang['podcast'] = zt('Edit Podcast');
  87. $lang['rename'] = zt('Rename');
  88. $lang['images'] = zt('Edit Images');
  89. $lang['tags'] = zt('Edit Tags');
  90. if (isset($zina['category'])) {
  91. if (!empty($zina['description']) || isset($zina['dir_edit_opts'])) {
  92. $output .= '<table border="0" cellpadding="5" cellspacing="0" width="100%">'.
  93. '<tr><td valign="top" width="100%">';
  94. if (!empty($zina['description'])) $output .= '<p>'.$zina['description'].'</p>';
  95. # todo: dup with below...
  96. if (isset($zina['dir_edit_opts'])) {
  97. $options = array();
  98. foreach ($zina['dir_edit_opts'] as $opt => $opts) {
  99. $options[] = zl($lang[$opt],$opts['path'], $opts['query']);
  100. }
  101. $output .= '<p class="small">';
  102. $output .= implode(' | ', $options);
  103. $output .= '</p>';
  104. }
  105. $output .= '</td></tr></table>';
  106. }
  107. if (isset($zina['category']) && !empty($zina['category']['sort'])) {
  108. $output .= '<table width="100%"><tr><td class="quarterwidth">'.$zina['category']['sort'].'</td>';
  109. if (isset($zina['category']['navigation'])) {
  110. $output .= '<td class="halfwidth" align="center">'.$zina['category']['navigation'].'</td>'.
  111. '<td class="quarterwidth"></td>';
  112. }
  113. $output .= '</tr></table>';
  114. } else {
  115. if (isset($zina['category']['navigation'])) $output .= $zina['category']['navigation'];
  116. }
  117. $output .= ''.$zina['category']['content'];
  118. if (isset($zina['category']['navigation'])) $output .= $zina['category']['navigation'];
  119. } else {
  120. $output .= '<div class="section">';
  121. $subdirs = ($zina['subdir_num'] > 0);
  122. $altdirs = ($zina['alt_num'] > 0);
  123. if (($subdirs && $zina['dir_list']) || $altdirs || isset($zina['alt_list_edit']) || !empty($zina['zinamp']) || $zina['pls_included']) {
  124. $output .= '<div class="directory_list">';
  125. if (!empty($zina['zinamp'])) $output .= '<div style="margin-bottom:5px;">'.$zina['zinamp'].'</div>';
  126. $form_content = '';
  127. if ($subdirs && $zina['dir_list']) $form_content .= ztheme('directory_list', $zina['subdirs'], $zina['subdir_truncate']);
  128. if ($altdirs || isset($zina['alt_list_edit'])) {
  129. $form_content .= ztheme('directory_alt_list', $zina['alt_items'], $zina['subdir_truncate']);
  130. if (isset($zina['alt_list_edit'])) {
  131. $form_content .= '<div class="small">'.zl(zt('Edit "See Also"'),$path,$zina['alt_list_edit']['query']).'</div>';
  132. }
  133. }
  134. if ($zina['pls_included']) {
  135. $form_content .= '<div style="margin:10px 0 10px 0">'.ztheme('playlists_block', $zina['pls_included']['items'], $zina['subdir_truncate']);
  136. if (isset($zina['pls_included']['more'])) {
  137. $form_content .= '<div class="small">'.zl(zt('More'),$zina['pls_included']['more']['path'],$zina['pls_included']['more']['query']).'</div>';
  138. }
  139. $form_content .= '</div>';
  140. }
  141. $output .= (!empty($zina['list_form_opts'])) ? ztheme('form', $zina['list_form_opts'], $form_content.$zina['list_form']) : $form_content;
  142. if ($zina['amg']) {
  143. $output .= '<div class="amg">'.ztheme('amg',$zina).'</div>';
  144. }
  145. $output .= '</div>';
  146. }
  147. if (isset($zina['dir_image'])) $output .= '<div class="directory-image">'.$zina['dir_image'].'</div>';
  148. if (isset($zina['dir_opts'])) {
  149. $output .= '<p class="dir-opts">'.ztheme('dir_opts',$zina['dir_opts'],$zina['title_raw']).'</p>';
  150. }
  151. $votes = (isset($zina['dir_rating']) && $zina['dir_rating']['sum_votes'] > 0);
  152. if ($votes || isset($zina['dir_rate'])) {
  153. $output .= '<p class="small">';
  154. if ($votes) {
  155. $output .= ztheme('rating_display', $zina['dir_rating']['sum_rating']).
  156. ztheme('votes_display',$zina['dir_rating']['sum_votes']);
  157. if (isset($zina['dir_rate'])) $output .= '&nbsp; | ';
  158. }
  159. if (isset($zina['dir_rate'])) $output .= zt('Rate').': '.$zina['dir_rate'];
  160. $output .= '</p>';
  161. }
  162. if (isset($zina['description'])) $output .= $zina['description'];
  163. if (isset($zina['podcast'])) {
  164. $type = $zina['podcast']['type'];
  165. $icon_title = ($type == 'podcast') ? zt('Podcast') : zt('RSS Feed');
  166. $output .= '<p>'.zl(ztheme('icon',$type.'.gif', $icon_title),$zina['podcast']['url'],$zina['podcast']['query']).'</p>';
  167. }
  168. $output .= ztheme('addthis', $zina, 'bookmark');
  169. if (isset($zina['dir_edit_opts'])) {
  170. $options = array();
  171. foreach ($zina['dir_edit_opts'] as $opt => $opts) {
  172. $options[] = zl($lang[$opt],$opts['path'], $opts['query']);
  173. }
  174. $output .= '<p class="small">';
  175. $output .= implode(' | ', $options);
  176. $output .= '</p>';
  177. }
  178. $output .= '</div>';
  179. if ($subdirs && $zina['subdir_images']) {
  180. $output .= '<div class="section">'.ztheme('image_list', $zina['subdirs'], $zina['subdir_cols']).'</div>';
  181. }
  182. if ($altdirs) {
  183. $output .= '<div class="section">'.ztheme('image_alt_list', $zina['alt_items'], $zina['subdir_cols']).'</div>';
  184. }
  185. }
  186. if (isset($zina['songs'])) $output .= '<div class="section">'.$zina['songs'].'</div>';
  187. if (isset($zina['multimedia'])) {
  188. $output .= '<div class="section">'.
  189. ztheme('multimedia_section', ztheme('multimedia_list', $zina['multimedia'])).
  190. '</div>';
  191. }
  192. return $output;
  193. }
  194. #todo: try <ul>
  195. function ztheme_category($dirs, $cols, $images = false, $truncate = 25, $full_page_split = false) {
  196. $output = '';
  197. if (!empty($dirs)) {
  198. if ($images) {
  199. if ($full_page_split) {
  200. $output = '';
  201. foreach($dirs as $letter => $items) {
  202. if (strlen($letter) > 3) {
  203. $output .= '<h1 class="zina-cat-letter"><a name="'.strtolower($letter).'" href="'.zurl($letter).'" class="zina-cat-letter">'.$letter.'</a></h1>';
  204. } else {
  205. $letter = ($letter == 'zzz') ? zt('Other') : $letter;
  206. $output .= '<h1 class="zina-cat-letter">'.$letter.'<a name="'.strtolower($letter).'" class="zina-cat-letter" /></h1>';
  207. }
  208. $output .= '<br style="clear:both;"/>'.ztheme('image_list_category', $items, $cols);
  209. }
  210. return $output;
  211. } else {
  212. return ztheme('image_list_category', $dirs, $cols);
  213. }
  214. }
  215. $columns = $i = $row = 0;
  216. $letter_height = 3;
  217. $items = ($full_page_split) ? $full_page_split + (count($dirs)*$letter_height) : count($dirs);
  218. $rows_in_col = ceil($items/$cols);
  219. if ($rows_in_col < $cols) $cols = ceil($items/$rows_in_col);
  220. $col_width = round(100/$cols);
  221. $img_new = ztheme('icon','new.gif',zt('New'));
  222. zina_set_css('inline','.catcolwidth{width:'.$col_width.'%;}');
  223. $output .= '<table width="100%" class="category"><tr>';
  224. if ($full_page_split) {
  225. zina_set_css('inline', 'td.catcolwidth a{margin-left:5px;}');
  226. $first = true;
  227. foreach($dirs as $letter => $dir) {
  228. $count = count($dir) + $letter_height;
  229. $row += $count;
  230. if (($first || $row > $rows_in_col + ($letter_height*2)) && $columns < $cols) {
  231. $row = $count;
  232. if (!$first) $output .= '</td>';
  233. $output .= '<td class="catcolwidth'.(($cols != ++$i) ? ' category_cols' : '').'" valign="top">';
  234. $first = false;
  235. $columns++;
  236. } else {
  237. $output .= "<br/>\n";
  238. }
  239. if (strlen($letter) > 3) {
  240. $output .= '<h1 class="zina-cat-letter"><a name="'.strtolower($letter).'" href="'.zurl($letter).'" class="zina-cat-letter">'.$letter.'</a></h1>';
  241. } else {
  242. $letter = ($letter == 'zzz') ? zt('Other') : $letter;
  243. $output .= '<h1 class="zina-cat-letter">'.$letter.'<a name="'.strtolower($letter).'" class="zina-cat-letter" /></h1>';
  244. }
  245. foreach($dir as $key => $opts) {
  246. $title = ztheme('truncate', $opts['title'], $truncate);
  247. $output .= zl($title,$opts['path'],$opts['query']);
  248. if ($opts['new']) $output .= '&nbsp;'.$img_new;
  249. $output .= ' <br/>'."\n";
  250. }
  251. }
  252. $output .= '</td>'."\n";
  253. } else {
  254. foreach ($dirs as $opts) {
  255. if ($row == 0) {
  256. $output .= '<td class="catcolwidth'.(($cols != ++$i) ? ' category_cols' : '').'" valign="top">';
  257. }
  258. $title = ztheme('truncate', $opts['title'], $truncate);
  259. $output .= zl($title,$opts['path'],$opts['query']);
  260. if ($opts['new']) $output .= '&nbsp;'.$img_new;
  261. $output .= '<br/>'."\n";
  262. $row = ++$row % $rows_in_col;
  263. if ($row == 0) $output .= '</td>';
  264. }
  265. if ($row != 0) $output .= '</td>';
  266. }
  267. $output .= '</tr></table>';
  268. }
  269. return $output;
  270. }
  271. /*
  272. * Category Pages Navigation
  273. *
  274. * e.g. Start - First - 1 - 2 - Next - Last
  275. */
  276. function ztheme_category_pages($path, $current, $total, $query='') {
  277. $output = '';
  278. if ($total > 1) {
  279. $output .= '<div class="category_pages">';
  280. if ($current != 1) {
  281. $output .= zl(ztheme('icon','first.gif',zt('First')),$path,$query.'page=1');
  282. $output .= zl(ztheme('icon','back.gif',zt('Previous')),$path,$query.'page='.($current-1));
  283. } else {
  284. $output .= ztheme('icon','first_un.gif',zt('First'));
  285. $output .= ztheme('icon','back_un.gif',zt('Previous'));
  286. }
  287. $output .= '&nbsp;';
  288. for($i=1;$i<=$total;$i++) {
  289. $arr[] = ($current == $i) ? "<strong>$i</strong>" : zl($i,$path,$query.'page='.$i);
  290. }
  291. $output .= implode(' &middot; ',$arr);
  292. $output .= '&nbsp;';
  293. if ($current == $total) {
  294. $output .= ztheme('icon','forward_un.gif',zt('Next'));
  295. $output .= ztheme('icon','last_un.gif',zt('Last'));
  296. } else {
  297. $output .= zl(ztheme('icon','forward.gif',zt('Next')),$path,$query.'page='.($current+1));
  298. $output .= zl(ztheme('icon','last.gif',zt('Last')),$path,$query.'page='.$total);
  299. }
  300. $output .= '</div>';
  301. }
  302. return $output;
  303. }
  304. /*
  305. * Category Alphabet Navigation
  306. *
  307. * e.g. A - B - C - D...
  308. */
  309. function ztheme_category_alphabet($path, $current, $letters, $query='', $full_page = false) {
  310. $output = '<div class="category_pages">';
  311. if ($full_page) {
  312. foreach ($letters as $key) {
  313. $letter = ($key == 'zzz') ? zt('Other') : $key;
  314. $links[] = zl($letter,$path,$query,strtolower($letter));
  315. }
  316. } else {
  317. foreach ($letters as $key) {
  318. $letter = ($key == 'zzz') ? zt('Other') : $key;
  319. $links[] = ($current == $key) ? "<strong>$letter</strong>" : zl($letter,$path,$query.'page='.$key);
  320. }
  321. }
  322. $output .= implode(' &middot; ',$links);
  323. return $output.'</div>';
  324. }
  325. /*
  326. * Category Split by Alphabet helper
  327. */
  328. function ztheme_category_alphabet_split($dirs, $sort_ignore) {
  329. $splits = array();
  330. foreach ($dirs as $key=>$item) {
  331. $key = $item['title'];
  332. if ($item['person']) {
  333. if (($pos = strripos($key, ' ')) !== false) {
  334. $letter = zina_strtoupper(zcheck_utf8(zina_substr($key, $pos+1,1)));
  335. } else {
  336. $letter = zina_strtoupper(zcheck_utf8($key[0]));
  337. }
  338. } else if ($sort_ignore && preg_match('/^('.$sort_ignore.')\s/i',$key, $matches)) {
  339. # ignore certain thing like "the" and "a"
  340. $letter = zina_strtoupper(zina_substr($key, zina_strlen($matches[1])+1, 1));
  341. } elseif (preg_match('/^(\W|\d)/', $key, $matches)) {
  342. # non-alpha characters get grouped together...
  343. $letter = 'zzz';
  344. } else {
  345. # upper and lowercase are same
  346. $letter = zina_strtoupper(zcheck_utf8($key[0]));
  347. }
  348. $splits[$letter][$key] = $item;
  349. }
  350. ksort($splits);
  351. return $splits;
  352. }
  353. /*
  354. * Category Sort Alpha/Date
  355. */
  356. function ztheme_category_sort($path, $cat) {
  357. $lang['asc'] = zt('Sort Ascending');
  358. $lang['desc'] = zt('Sort Descending');
  359. return '<span class="small">'.zt('Sort').': '.
  360. zl(zt('Alpha'), $path, $cat['alpha']['query']).' '.
  361. zl(ztheme('icon','sort_'.$cat['alpha']['sort'].'.gif', $lang[$cat['alpha']['sort']]), $path,$cat['alpha']['query']).
  362. '&nbsp;'.
  363. zl(zt('Date'), $path, $cat['date']['query']).' '.
  364. zl(ztheme('icon','sort_'.$cat['date']['sort'].'.gif',$lang[$cat['date']['sort']]),$path,$cat['date']['query']).'</span>';
  365. }
  366. function ztheme_playlists_block($playlists, $truncate=25) {
  367. $output='';
  368. if ($playlists) {
  369. $output .= '<h3>'.zt('Tracks Appear On').'</h3>';
  370. $output .= ztheme('directory_list_helper', $playlists, $truncate);
  371. }
  372. return $output;
  373. }
  374. function ztheme_directory_list($dirs, $truncate=25) {
  375. $output='';
  376. if ($dirs) {
  377. $output .= '<h3>'.zt('Albums').'</h3>';
  378. $output .= ztheme('directory_list_helper', $dirs, $truncate);
  379. }
  380. return $output;
  381. }
  382. function ztheme_directory_alt_list($dirs, $truncate=25) {
  383. $output='';
  384. $output .= '<h3>'.zt('See Also').'</h3>';
  385. if ($dirs) {
  386. $output .= ztheme('directory_list_helper', $dirs, $truncate);
  387. }
  388. return $output;
  389. }
  390. function ztheme_directory_list_helper($dirs, $truncate=25) {
  391. global $zc;
  392. $lang['play'] = zt('Play');
  393. $lang['play_lofi'] = zt('Play Low Fidelity');
  394. $lang['download'] = zt('Download');
  395. $lang['play_rec'] = zt('Play recursively');
  396. $lang['play_rec_rand'] = zt('Play recursively random');
  397. $class = "zinamp";
  398. $img_new = ztheme('icon','new.gif',zt('New'));
  399. $output = '<ul>';
  400. foreach ($dirs as $opts) {
  401. $output .= '<li>';
  402. if (isset($opts['opts'])) {
  403. foreach ($opts['opts'] as $type=>$opt) {
  404. $attr = (substr($type,0,4) == 'play') ? 'class="'.$class.'"' : '';
  405. //$attr = (substr($type,0,4) == 'play') ? 'class="zinamp"' : '';
  406. $output .= zl(ztheme('icon',$type.'.gif',$lang[$type]),$opt['path'],$opt['query'], null, false, $attr);
  407. }
  408. }
  409. if (isset($opts['checkbox'])) $output .= ztheme('form_checkbox', $opts['checkbox']['name'], $opts['checkbox']['value'], $opts['checkbox']['checked']).'&nbsp;';
  410. $title = ztheme('truncate', $opts['title'], $truncate);
  411. $output .= zl($title,$opts['path'], isset($opts['query']) ? $opts['query'] : null);
  412. if (!empty($opts['info']->year)) $output .= ' ('.$opts['info']->year.')';
  413. if ($opts['new']) $output .= '&nbsp;'.$img_new;
  414. $output .= '</li>';
  415. }
  416. $output .= '</ul>';
  417. return $output;
  418. }
  419. function ztheme_image_list($dirs, $cols) {
  420. return '<h3>'.zt('Albums').'</h3>'.ztheme('image_list_helper', $dirs, $cols);
  421. }
  422. function ztheme_image_alt_list($dirs, $cols) {
  423. return '<h3>'.zt('See Also').'</h3>'.ztheme('image_list_helper', $dirs, $cols);
  424. }
  425. function ztheme_image_list_helper($dirs, $cols) {
  426. $col = 0;
  427. $col_width = round(100/$cols).'%';
  428. zina_set_css('inline', 'td.zinaimgcolwidth{width:'.$col_width.';}');
  429. $align[$cols - 1] = 'right';
  430. $align[0] = 'left';
  431. for($i=1; $i < $cols - 1; $i++) $align[$i] = 'center';
  432. $first = 1;
  433. $output = '<table cellpadding="5" width="100%">';
  434. foreach($dirs as $dir => $opts) {
  435. if ($col==0) {
  436. if ($first) {
  437. $output .= '<tr>';
  438. $first = false;
  439. } else {
  440. $output .= '</tr><tr>';
  441. }
  442. }
  443. #$title = $opts['title'];
  444. $output .= '<td class="zinaimgcolwidth" align="'.$align[$col].'" valign="top">'.$opts['image'].'</td>';
  445. /*
  446. * outputs a play icon over album covers
  447. $output .= '<td class="zinaimgcolwidth" align="'.$align[$col].'" valign="top">'.
  448. $opts['image'].'<span class="image-inner">'.zl(ztheme('icon','play.gif',zt('Play')),$dir,'l=8&amp;m=0').'</span></td>';
  449. */
  450. if ($col==$cols) $output .= '</tr>';
  451. $col = ++$col % $cols;
  452. }
  453. if ($col <> 0 ) {
  454. for ($i = $col; $i < $cols; $i++) $output .= '<td class="zinaimgcolwidth">&nbsp;</td>';
  455. }
  456. $output .= '</tr></table>';
  457. return $output;
  458. }
  459. function ztheme_image_list_category($dirs, $cols) {
  460. $col = 0;
  461. $col_width = round(100/$cols).'%';
  462. zina_set_css('inline','.imglistcatwidth{width:'.$col_width.';}');
  463. $output = '<table cellpadding="0" cellspacing="0" width="100%" class="image-list-category">';
  464. foreach($dirs as $dir => $opts) {
  465. if ($col==0) { $row = $row1 = '<tr>'; }
  466. $row .= '<td class="imglistcatwidth" align="center">'.$opts['image'].'</td>';
  467. $row1 .= '<td class="imglistcatwidth" align="center" valign="top"><h3>'.zl($opts['title'], $opts['path'], $opts['query']).'</h3></td>';
  468. if (++$col==$cols) { $output .= $row.'</tr>'."\n".$row1.'</tr>'."\n"; }
  469. $col = $col % $cols;
  470. }
  471. if ($col <> 0 ) {
  472. for ($i = $col; $i < $cols; $i++) {
  473. $row .= '<td class="imglistcatwidth">&nbsp;</td>';
  474. $row1 .= '<td class="imglistcatwidth">&nbsp;</td>';
  475. }
  476. $output .= $row.'</tr>'.$row1.'</tr>';
  477. }
  478. $output .= '</table>';
  479. return $output;
  480. }
  481. #TODO: rename? and then have song_list call "generic" func? use array for opts
  482. function ztheme_song_list($songs, $various = false, $images = false, $stats = false, $reorder = false, $song_info = true, $checkbox = true) {
  483. global $zc;
  484. if (empty($songs)) return '';
  485. $class = "zinamp";
  486. if ($reorder){
  487. zina_add_tabledrag('table-playlist', 'order', 'sibling', 'order');
  488. zina_set_css('file', 'extras/tabledrag.css');
  489. $table_id = ' id="table-playlist"';
  490. $row_class = 'draggable ';
  491. $row_id = ' id="order"';
  492. $row_order = true;
  493. } else {
  494. $table_id = $row_class = $row_id = '';
  495. $row_order = false;
  496. }
  497. $img_new = ztheme('icon','new.gif',zt('New'));
  498. $lang['download'] = zt('Download');
  499. $lang['play'] = zt('Play');
  500. $lang['play_lofi'] = zt('Play Low Fidelity');
  501. $lang['edit'] = zt('Edit');
  502. $lang['more'] = zt('More');
  503. #remove next two - > used to be for playlists...test?
  504. $lang['rename'] = zt('Rename');
  505. $lang['delete'] = zt('Delete');
  506. $lang['play_lofi'] = zt('Play low fidelity');
  507. $lang['play_lofi_custom'] = zt('Play custom low fidelity');
  508. $lang['play_rec'] = zt('Play recursively');
  509. $lang['play_rec_rand'] = zt('Play recursively random');
  510. $i = $stat_prev = 0;
  511. $p = 1;
  512. $output = '<table cellpadding="5" cellspacing="0" width="100%"'.$table_id.'>';
  513. foreach($songs as $song) {
  514. #todo: $class = ++$i % 2 == 0 ? 'even' : 'odd';
  515. $v = (isset($song['description']) && !$images) ? ' valign="top"' : '';
  516. $output .= '<tr class="'.$row_class.'row'.$i.'"'.$v.$row_id.'>';
  517. if ($row_order) $output .= '<td></td><td style="display:none;"><input type="hidden" name="order[]" value="'.($p).'" size="2" class="order" /></td>';
  518. $output .= '<td class="song'.$i.' nowrap">';
  519. if (isset($song['opts'])) {
  520. foreach ($song['opts'] as $type=>$opt) {
  521. $attr = (substr($type,0,4) == 'play') ? ' class="'.$class.'"' : '';
  522. $output .= zl(ztheme('icon',$type.'.gif',$lang[$type]),$opt['path'],$opt['query'], null, false, $attr);
  523. }
  524. }
  525. if (isset($song['extras'])) {
  526. foreach ($song['extras'] as $type=>$extra) {
  527. $output .= zl(ztheme('icon',$type.'.gif',$extra['text']),$extra['path'],$extra['query'],NULL,FALSE,$extra['attr']);
  528. }
  529. }
  530. $output .= '</td>';
  531. if (isset($song['opts_edit']) || isset($song['extras_edit'])) {
  532. $output .= '<td class="song'.$i.' nowrap">';
  533. if (isset($song['opts_edit'])) {
  534. foreach ($song['opts_edit'] as $type=>$opt) {
  535. $output .= zl(ztheme('icon',$type.'.gif',$lang[$type]),$opt['path'],$opt['query']);
  536. }
  537. }
  538. if (isset($song['extras_edit'])) {
  539. foreach ($song['extras_edit'] as $type=>$extra) {
  540. $output .= zl(ztheme('icon',$type.'_edit.gif',$extra['text']),$extra['path'],$extra['query'],NULL,FALSE,$extra['attr']);
  541. }
  542. }
  543. if (isset($song['delete'])) {
  544. $type = 'delete';
  545. $output .= zl(ztheme('icon',$type.'.gif',$lang[$type], $lang[$type], " onclick='return(confirm(\"".zt('Delete file?')."\"));'"),$song['delete']['path'],$song['delete']['query']);
  546. }
  547. $output .= '</td>';
  548. }
  549. if ($checkbox) {
  550. $output .= '<td class="song'.$i.' nowrap">';
  551. if (isset($song['checkbox']) && $song['checkbox']) {
  552. $output .= ztheme('form_checkbox', $song['checkbox']['name'], $song['checkbox']['value'], $song['checkbox']['checked']);
  553. }
  554. $output .= '</td>';
  555. }
  556. #if (isset($song['track'])) $output .= '</td><td align="right" class="song'.$i.' nowrap">'. $song['track'];
  557. if ($images) {
  558. $output .= '<td class="song'.$i.'"'.$v.'>';
  559. if (isset($song['image']) && !empty($song['image'])) {
  560. $output .= '<div class="search-results">';
  561. #if (isset($song['title_link'])) {
  562. # $output .= zl($song['image'],$song['title_link']['path'],$song['title_link']['query']);
  563. if (isset($song['image_link'])) {
  564. $output .= zl($song['image'],$song['image_link']['path'],$song['image_link']['query']);
  565. } else {
  566. $output .= $song['image'];
  567. }
  568. $output .= '</div>';
  569. }
  570. $output .= '</td>';
  571. }
  572. $td = '<td align="right" class="song_info'.$i.' nowrap"'.$v.'>';
  573. if ($stats) {
  574. $output .= $td.(($stat_prev == $song['stat']) ? '' : $p.'.').'</td>';
  575. $stat_prev = $song['stat'];
  576. }
  577. $output .= '<td class="song'.$i.' fullwidth"'.$v.'>';
  578. $title = $song['title'];
  579. if ($various) {
  580. if (isset($song['info']->artist)) $title = $song['info']->artist.' - '.$title;
  581. }
  582. if (isset($song['title_link'])) {
  583. $output .= zl($title,$song['title_link']['path'],$song['title_link']['query'], null, false, isset($song['title_link']['attr']) ? $song['title_link']['attr'] : '');
  584. } else {
  585. $output .= '<span class="song_title">'.$title.'</span>';
  586. }
  587. if ($song['new']) $output .= $img_new;
  588. if (isset($song['description']) && !empty($song['description'])) {
  589. $output .= '<br/><span class="song_blurb'.$i.'">'.$song['description'].'</span>';
  590. }
  591. if (isset($song['options'])) {
  592. $output .= '<br/><span class="song_blurb'.$i.'"><small>'.implode(' | ', $song['options']).'</small></span>';
  593. }
  594. $output .= '</td>';
  595. if ($stats) {
  596. if ($song['stat_type'] == 'votes' || $song['stat_type'] == 'rating') {
  597. $output .= $td.'<span class="zina-rating">'.ztheme('votes_display',$song['votes']).'</span></td>';
  598. $output .= '<td class="song_info'.$i.' nowrap"'.$v.'>'.ztheme('rating_display', $song['stat']).'</td>';
  599. } elseif ($song['stat_type'] == 'latest' || $song['stat_type'] == 'added') {
  600. $output .= $td.ztheme('stat_date', $song['stat']).'</td>';
  601. } else {
  602. $output .= $td.number_format($song['stat']).'</td>';
  603. }
  604. } else {
  605. if ($song['ratings']) {
  606. $output .= $td.'<span class="zina-rating">'.ztheme('votes_display',$song['sum_votes']).'</span></td>';
  607. $output .= '<td class="song_info'.$i.' nowrap"'.$v.'>'.
  608. '<div class="stars-song">'.ztheme('rating_display', $song['sum_rating']).'</div></td>';
  609. if (isset($song['full_path']))
  610. $output .= $td.'<div class="stars-song">'.ztheme('vote', zina_get_vote_url($song['full_path']), $song['user_rating']).'</div></td>';
  611. else
  612. $output .= $td.'&nbsp;'.'</td>';
  613. /*
  614. * If you are using statistics, there are also
  615. * $song['sum_plays'] & $songs['sum_downloads']
  616. */
  617. } else {
  618. $output .= $td.'&nbsp;'.'</td>';
  619. $output .= $td.'&nbsp;'.'</td>';
  620. $output .= $td.'&nbsp;'.'</td>';
  621. }
  622. if ($song_info) {
  623. if (isset($song['info']->info)) {
  624. $info = &$song['info'];
  625. $output .= $td.((isset($info->time) && !empty($info->time)) ? $info->time : '&nbsp;').'</td>';
  626. $output .= $td.((isset($info->bitrate) && !empty($info->bitrate)) ? $info->bitrate.' kbps' : '&nbsp;').'</td>';
  627. $output .= $td.((isset($info->frequency) && !empty($info->frequency)) ? round($info->frequency/1000,1).' kHz' : '&nbsp;').'</td>';
  628. $output .= $td.((isset($info->filesize) && !empty($info->filesize)) ? sprintf("%.2f", round($info->filesize/1000000,2)).' Mb' : '&nbsp;').'</td>';
  629. } else {
  630. $output .= $td.'</td>';
  631. $output .= $td.'</td>';
  632. $output .= $td.'</td>';
  633. $output .= $td.((isset($song['info']->filesize)) ? sprintf("%.2f", round($song['info']->filesize/1000000,2)).' Mb' : '&nbsp;').'</td>';
  634. }
  635. }
  636. }
  637. $output .= '</tr>'."\n";
  638. $i = ++$i % 2;
  639. $p++;
  640. }
  641. zevenodd($i);
  642. $output .= '</table>';
  643. return $output;
  644. }
  645. function ztheme_stats_form_select($action, $selects) {
  646. $form = '<form id="sform" method="post" action="'.$action.'" class="z_small"><div>';
  647. $form .= '<strong>'.zt('Statistic').': </strong>';
  648. foreach($selects as $name=>$select) {
  649. $form .= '<select class="z_form_select" name="'.$name.'" onchange=\'this.form.submit();\'>';
  650. foreach($select['options'] as $key=>$value) {
  651. $sel = ($key == $select['default']) ? ' selected="selected"' : '';
  652. $form .= '<option value="'.$key.'"'.$sel.'>'.$value.'</option>';
  653. }
  654. $form .= '</select>';
  655. }
  656. $form .= ' '.zl(ztheme('icon','more.gif',zt('More')),"javascript:document.forms.sform.submit();").'</div></form>';
  657. return $form;
  658. }
  659. function ztheme_stats_list($items, $various = false, $images = false) {
  660. return ztheme_song_list($items, $various, $images, true);
  661. }
  662. function ztheme_breadcrumb($links) {
  663. return (!empty($links)) ? implode(' &gt;&nbsp;',$links) : '';
  664. }
  665. function ztheme_breadcrumb_home($links) {
  666. return implode(' / ', $links);
  667. }
  668. function ztheme_page_title($links) {
  669. #return implode(' &#8226; ',$links);
  670. return implode(' &middot; ',$links);
  671. }
  672. function ztheme_search_song_titles($titles) {
  673. return implode(' / ', $titles);
  674. }
  675. /*
  676. * Theme file to use for missing image
  677. * $type is 'dir' or 'sub'
  678. */
  679. function ztheme_missing_image($type) {
  680. return 'missing_'.$type.'.jpg';
  681. }
  682. /*
  683. * Theme for rating (currently "stars")
  684. * $rating is float with one decimal place, e.g. 4.5
  685. */
  686. function ztheme_rating_display($rating) {
  687. $output='';
  688. if ($rating > 0) {
  689. $output .= '<span class="stars">';
  690. $star = ztheme('icon','star.gif','*');
  691. $rating = number_format($rating,1);
  692. $arr = explode('.',$rating);
  693. $output .= str_repeat($star, $arr[0]);
  694. if ($arr[1] >= 5) $output .= ztheme('icon','star-half.gif','½');
  695. $output .= '</span>';
  696. }
  697. return $output;
  698. }
  699. /*
  700. * Theme for voting
  701. *
  702. * currently "stars" and utilizes ajax
  703. */
  704. function ztheme_vote($url, $user_rating = 0) {
  705. static $num = 0;
  706. if ($num == 0) zina_set_js('vars', ztheme('vote_js').'var zv=new Array();');
  707. $pr = 'zv'.$num;
  708. zina_set_js('vars', 'zv['.$num.']=\''.$url.'\';');
  709. $remove = '';
  710. if ($user_rating > 0) {
  711. $remove = zl(ztheme('icon','delete.gif',zt('Remove Vote')),'javascript: void 0;', null, null, null, ' onclick="ajax(zv['.$num.']+\'0\',\'span'.$pr.'\');"');
  712. }
  713. $output = '<span id="span'.$pr.'">'.$remove.ztheme('icon','stars-0.gif',NULL,NULL,'id="'.$pr.'" height="14" width="70" usemap="#'.$pr.'map"').
  714. '</span>'.
  715. '<map name="'.$pr.'map" id="'.$pr.'map">';
  716. for($i=1;$i<=5;$i++) {
  717. $output .= '<area coords="'.(($i-1)*14).',0,'.($i*14).',14" onmouseover="imgOn(\''.$pr.'\','.$i.
  718. ');" onmouseout="imgOff(\''.$pr.'\');" title="'.$i.'" alt="'.$i.'" '.
  719. 'href="javascript: void 0;" onclick="vote(\''.$pr.'\','.$i.');ajax('.
  720. 'zv['.$num.']+\''.$i.'\',\'span'.$pr.'\');" />';
  721. }
  722. $output .= '</map>';
  723. if ($user_rating > 0) $output .= '<script type="text/javascript">vote(\''.$pr.'\','.$user_rating.');</script>';
  724. $num++;
  725. return $output;
  726. }
  727. /*
  728. * Star voting javascript
  729. *
  730. * gets put in html head
  731. */
  732. function ztheme_vote_js() {
  733. $theme = zpath_to_theme().'/icons/stars-';
  734. $output = '';
  735. for($i=0;$i<=5;$i++) {
  736. $output .= "onImgArr[$i]=new Image(70,14);onImgArr[$i].src=zImgBase+'$i.gif';";
  737. }
  738. return 'var onImgArr=new Array();var zImgBase=\''.$theme.'\';'.
  739. $output.'var aVote=new Array();'.
  740. 'function imgOn(img,i){if(aVote[img]==null)document.getElementById(img).src=onImgArr[i].src;}'.
  741. 'function imgOff(img){if(aVote[img]==null)document.getElementById(img).src=zImgBase+\'0.gif\';}'.
  742. 'function vote(img,i){aVote[img]=null;imgOn(img,i);aVote[img]=i;}';
  743. }
  744. /*
  745. * Voting plurality
  746. *
  747. * "(1 vote)" or "(2 votes)"
  748. */
  749. function ztheme_votes_display($votes) {
  750. if (!empty($votes)) {
  751. return ' ('.$votes.' '.(($votes == 1) ? zt('vote') : zt('votes')) .')';
  752. }
  753. return '';
  754. }
  755. function ztheme_genres($dirs, $cols, $images, $truncate, $zina, $navigation = false, $full_page_split = false) {
  756. $output = '';
  757. if (!empty($zina['messages'])) $output .= '<div id="zina_messages">'.$zina['messages'].'</div>';
  758. if ($navigation) $output .= $navigation;
  759. $output .= ztheme('category', $dirs, $cols, $images, $truncate, $full_page_split);
  760. return $output;
  761. }
  762. function ztheme_multimedia_section($list) {
  763. return '<h3>'.zt('Multimedia').'</h3>'.$list;
  764. }
  765. function ztheme_image_missing_nav($select, $close) {
  766. return zt('Directories with no image:').$select.zl(zt('Close'), $close['path'], $close['query']).'<br/><br/>';
  767. }
  768. function ztheme_edit_images_page($title, $images, $new, $missing_navigation = '') {
  769. $output = '';
  770. if (!empty($missing_navigation)) $output .= $missing_navigation;
  771. if (!empty($images)) {
  772. $output .= '<div class="section">'.
  773. '<h3>'.zt('Current Images').'</h3>'.
  774. ztheme('image_list_helper', $images, 3).
  775. '</div>';
  776. }
  777. if (!empty($new)) {
  778. $output .= '<div class="section"><h3>'.zt('Remote Images').'</h3>';
  779. foreach($new as $opt) {
  780. $output .= $opt['image'];
  781. }
  782. }
  783. return $output;
  784. }
  785. function ztheme_addthis($zina, $type = 'bookmark') {
  786. global $zc;
  787. static $first = true;
  788. $output = '';
  789. if ($zina['addthis']) {
  790. if ($first) {
  791. $output .= '<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js"></script>';
  792. zina_set_js('vars', 'var addthis_pub = "'.$zina['addthis_id'].'";');
  793. if (!empty($zina['site_name'])) zina_set_js('vars', 'var addthis_brand = "'.$zina['site_name'].'";');
  794. $first = false;
  795. }
  796. $source = zurl($zina['addthis_path'], $zina['addthis_query'], null, true);
  797. if ($type == 'feed') {
  798. $output .= ' <a href="http://www.addthis.com/feed.php" '.
  799. 'onclick="return addthis_open(this, \'feed\', \''.$source.'\')">' .
  800. '<img src="http://s7.addthis.com/static/btn/sm-rss-en.gif" width="83" height="16" alt="'.zt('Subscribe').'" title="'.zt('Subscribe using any feed reader!').'" class="icon"/></a>';
  801. } else { # bookmark
  802. $output .= '<p><a href="http://www.addthis.com/bookmark.php" '.
  803. 'onmouseover="return addthis_open(this,\'\',\''.$source.'\',\''.$zina['title'].'\');" '.
  804. 'onmouseout="addthis_close();" '.
  805. 'onclick="return addthis_sendto();"><img src="http://s7.addthis.com/static/btn/lg-share-en.gif" width="125" height="16" title="'.zt('Share').'" alt="'.zt('Share').'" /></a></p>';
  806. }
  807. }
  808. return $output;
  809. }
  810. function ztheme_stats_page($form_attr, $stats, $stat_opts, $zina) {
  811. $output = '';
  812. $output .= '<div class="clear-block" style="margin-bottom:20px;">'.$zina['statsformselect'].'</div>';
  813. if (empty($stats)) {
  814. $output .= '<h3>'.zt('No data found for this period.').'</h3>';
  815. } else {
  816. $output .= ztheme('form', $form_attr, $stats.'<div class="section">'.$stat_opts.'</div>');
  817. }
  818. return $output;
  819. }
  820. function ztheme_stats_section($title, $list, $type, $zina, $rss_title = '', $rss_path = false) {
  821. if ($rss_path) {
  822. $rss_icon = ($type == 'song') ? 'podcast.gif' : 'rss.png';
  823. $zina['addthis_path'] = $rss_path;
  824. $zina['addthis_query'] = null;
  825. $addthis = ztheme('addthis', $zina, 'feed');
  826. return '<div class="section"><div class="stats">'.
  827. '<div class="stats-left"><h3>'.$title.'</h3></div>'.
  828. '<div class="stats-right">'.zl(ztheme('icon', $rss_icon, $rss_title),$rss_path).$addthis.'</div></div>'.
  829. $list.'</div>';
  830. } else {
  831. return '<div class="section"><h3>'.$title.'</h3>'.$list.'</div>';
  832. }
  833. }
  834. function ztheme_stat_date($time) {
  835. return date("M j, Y g:i a", $time);
  836. }
  837. /*
  838. * NEXT THREE FUNCTIONS:
  839. * Take an array, expect an array back
  840. * - unset ones you don't want
  841. * - reorder, change text, etc.
  842. */
  843. function ztheme_stats_pages($pages) { return $pages; }
  844. function ztheme_stats_periods($periods) { return $periods; }
  845. function ztheme_stats_types($types) { return $types; }
  846. function ztheme_stats_list_opts($items, $form) {
  847. return ztheme('song_list_opts',$items, $form);
  848. }
  849. function ztheme_search_list($items, $images = false) {
  850. return ztheme('song_list',$items, false, $images);
  851. }
  852. function ztheme_playlist_list($items, $images = false, $reorder = false) {
  853. return ztheme('song_list',$items, false, $images, false, $reorder, false);
  854. }
  855. function ztheme_playlists_list_db($items, $count, $navigation, $action, $form_attr, $list_opts, $selected = false, $checkbox = false) {
  856. $output = '';
  857. if ($count > 0) {
  858. if ($navigation) $output .= $navigation;
  859. $output .= '<table class="search-header"><tr><td align="left">'.
  860. '<em>'.zt('@total Playlists', array('@total'=>$count)).'</em></td>';
  861. if ($selected) $output .= '<td align="right" style="text-align:right;">'.ztheme('playlist_header', $action, $selected).'</td>';
  862. $output .= '</tr></table>';
  863. }
  864. $list = ztheme('song_list',$items, false, true, false, false, false, $checkbox);
  865. return $output.ztheme('form', $form_attr, $list.$list_opts);
  866. #return $output.ztheme('song_list',$items, false, true, false, false, false, $checkbox);
  867. }
  868. function ztheme_playlists_list($items, $zina, $reorder = false) {
  869. global $zc;
  870. if (empty($items)) return '';
  871. if ($reorder) {
  872. zina_add_tabledrag('table-playlist', 'order', 'sibling', 'order');
  873. zina_set_css('file', 'extras/tabledrag.css');
  874. }
  875. $class = "zinamp";
  876. $songs = &$items;
  877. zina_set_css('inline', '.zinaplswidthA{width:90px;}.zinaplswidthB{width:20px}');
  878. $lang['download'] = zt('Download');
  879. $lang['play'] = zt('Play');
  880. $lang['more'] = zt('More');
  881. $lang['rename'] = zt('Rename');
  882. $lang['delete'] = zt('Delete');
  883. $lang['play_rec_rand'] = zt('Play random');
  884. $i = 0;
  885. $j = 1;
  886. $output = '';
  887. $output .= '<table cellpadding="5" cellspacing="0" id="table-playlist">';
  888. foreach($songs as $song) {
  889. $v = (isset($song['description'])) ? ' valign="top"' : '';
  890. $output .= '<tr class="draggable row'.$i.'"'.$v.' id="order'.($j).'"><td class="song'.$i.' zinaplswidthA nowrap">';
  891. if (isset($song['opts'])) {
  892. foreach ($song['opts'] as $type=>$opt) {
  893. $attr = (substr($type,0,4) == 'play') ? "class='$class'" : '';
  894. $output .= zl(ztheme('icon',$type.'.gif',$lang[$type]),$opt['path'],$opt['query'], null, false, $attr);
  895. }
  896. }
  897. if (isset($song['checkbox'])) {
  898. $output .= '</td><td class="song'.$i.' zinaplswidthB nowrap">'.
  899. ztheme('form_checkbox', $song['checkbox']['name'], $song['checkbox']['value'], $song['checkbox']['checked']).'</td>'.
  900. '<td style="display:none;"><input type="hidden" name="order[]" value="'.($j).'" size="2" class="order" />';
  901. }
  902. $output .= '</td><td class="song'.$i.'"'.$v.'>';
  903. $title = $song['title'];
  904. if (isset($song['title_link'])) {
  905. $output .= zl($title,$song['title_link']['path'],$song['title_link']['query']);
  906. } else {
  907. $output .= $title;
  908. }
  909. if (isset($song['description'])) $output.= '<br/>'.$song['description'];
  910. $output .= '</td>';
  911. $output .= '</tr>';
  912. $i = ++$i % 2;
  913. $j++;
  914. }
  915. zevenodd($i);
  916. $output .= '</table>';
  917. return $output;
  918. }
  919. function ztheme_form_checkbox($name, $value, $check = false) {
  920. $checked = ($check) ? ' checked="checked"' : '';
  921. return '<input type="checkbox" name="'.$name.'" value="'.$value.'"'.$checked.'/>';
  922. }
  923. function ztheme_form_hidden($name, $value) {
  924. return '<input type="hidden" name="'.$name.'" value="'.$value.'"/>';
  925. }
  926. function ztheme_multimedia_list($items) {
  927. if (empty($items)) return '';
  928. $img_new = ztheme('icon','new.gif',zt('New'));
  929. $lang['edit'] = zt('Edit');
  930. $i = 0;
  931. $output = '<table cellpadding="5" cellspacing="0" width="100%">';
  932. foreach($items as $song) {
  933. $v = (isset($song['description'])) ? ' valign="top"' : '';
  934. $output .= '<tr class="row'.$i.'"'.$v.'><td class="song'.$i.' nowrap">';
  935. if (isset($song['opts'])) {
  936. if (isset($song['opts']['play']) && $song['opts']['play']['local']) {
  937. $output .= zl(ztheme('icon','mm/'.$song['ext'].'.gif',zt('Play')),$song['opts']['play']['path'],$song['opts']['play']['query']);
  938. }
  939. if (isset($song['opts']['download'])) {
  940. $icon = (isset($song['opts']['play']) && $song['opts']['play']['local']) ? 'download' : 'mm/'.$song['ext'];
  941. $output .= zl(ztheme('icon',$icon.'.gif',zt('Download')),$song['opts']['download']['path'],$song['opts']['download']['query']);
  942. }
  943. }
  944. if (isset($song['opts_edit'])) {
  945. $output .= '</td><td class="song'.$i.' nowrap">';
  946. foreach ($song['opts_edit'] as $type=>$opt) {
  947. $output .= zl(ztheme('icon',$type.'.gif',$lang[$type]),$opt['path'],$opt['query']);
  948. }
  949. }
  950. $output .= '</td><td class="song'.$i.' fullwidth"'.$v.'>';
  951. $title = $song['title'];
  952. if (isset($song['title_link'])) {
  953. $output .= zl($title,$song['title_link']['path'],$song['title_link']['query']);
  954. } else {
  955. $output .= $title;
  956. }
  957. if ($song['new']) $output .= $img_new;
  958. if (isset($song['description'])) {
  959. $output .= '<br/><span class="song_blurb'.$i.'">'.$song['description'].'</span>';
  960. }
  961. $output .= '</td>';
  962. $output .= '</tr>';
  963. $i = ++$i % 2;
  964. }
  965. zevenodd($i);
  966. $output .= '</table>';
  967. return $output;
  968. }
  969. function ztheme_playlists_section($page,$form_attr,$list,$list_opts, $opts = array()) {
  970. $lang['play'] = zt('Play');
  971. $lang['playlist'] = zt('View Playlists');
  972. $lang['rename'] = zt('Rename');
  973. $lang['delete'] = zt('Delete');
  974. $output = '';
  975. $output .= '<div class="genre-page clear-block">';
  976. if ($page['image']) $output .= $page['image'];
  977. if ($opts['user']) {
  978. $lang['download'] = zt('Download');
  979. $lang['play'] = zt('Play');
  980. $lang['play_lofi'] = zt('Play Low Fidelity');
  981. $lang['play_rec_rand'] = zt('Play random');
  982. $output .= '<p>';
  983. $items = &$opts['user'];
  984. foreach($items as $type=>$opt) {
  985. $output.= zl(ztheme('icon',$type.'.gif',$lang[$type]),$items[$type]['path'],$items[$type]['query'],NULL,FALSE,$items[$type]['attr']);
  986. }
  987. $output .= zl(zt('Play @pls Playlist', array('@pls'=>$page['title'])),$items['play']['path'], $items['play']['query'], null, false, $items['play']['attr']).
  988. '</p>';
  989. }
  990. $votes = (isset($page['pls_ratings']) && $page['sum_votes'] > 0);
  991. if ($votes || isset($page['pls_rate_output'])) {
  992. $output .= '<p class="small">';
  993. if ($votes) {
  994. $output .= ztheme('rating_display', $page['sum_rating']).
  995. ztheme('votes_display',$page['sum_votes']);
  996. if (isset($page['pls_rate_output'])) $output .= '&nbsp; | ';
  997. }
  998. if (isset($page['pls_rate_output'])) $output .= zt('Rate').': '.$page['pls_rate_output'];
  999. $output .= '</p>';
  1000. }
  1001. if (isset($page['description']) && !empty($page['description'])) {
  1002. $output .= '<p>'.$page['description'].'</p>';
  1003. }
  1004. if (isset($page['podcast'])) {
  1005. $type = $page['podcast']['type'];
  1006. $icon_title = ($type == 'podcast') ? zt('Podcast') : zt('RSS Feed');
  1007. $output .= '<p>'.zl(ztheme('icon',$type.'.gif', $icon_title),$page['podcast']['url'],$page['podcast']['query']).'</p>';
  1008. }
  1009. $output .= ztheme('addthis', $page, 'bookmark');
  1010. $date = (!empty($page['date_created'])) ? zina_date('F j, Y', $page['date_created']) : null;
  1011. $output .= '<p class="small">';
  1012. if (isset($page['username'])) {
  1013. $name = (isset($page['profile_url'])) ? '<a href="'.$page['profile_url'].'">'.$page['username'].'</a>' : $page['username'];
  1014. if (!empty($date)) {
  1015. $output.= zt('Created by !name on @date.', array('!name'=>$name, '@date'=>$date));
  1016. }
  1017. } else {
  1018. if (!empty($date)) {
  1019. $output.= zt('Created on @date.', array('@date'=>$date));
  1020. }
  1021. }
  1022. if (isset($page['sum_views'])) $output .= ' '.zt('Viewed @num times.', array('@num'=>$page['sum_views']));
  1023. if (isset($page['sum_plays'])) $output .= ' '.zt('Played @num times.', array('@num'=>$page['sum_plays']));
  1024. $output .= '</p>';
  1025. $admin = &$opts['admin'];
  1026. if ($admin['edit'] || $admin['delete']) {
  1027. $output .= '<p class="small">';
  1028. if ($admin['edit']) $output .= zl(zt('Edit Playlist'),$admin['edit']['path'], $admin['edit']['query']).' | ';
  1029. if ($admin['delete']) $output .= zl(zt('Delete Playlist'),$admin['delete']['path'], $admin['delete']['query']);
  1030. $output .= '</p>';
  1031. }
  1032. $output .= '</div>';
  1033. if ($page['count'] > 0) {
  1034. $output .= '<table class="search-header"><tr><td align="left">'.
  1035. '<em>'.zt('@total Items', array('@total'=>$page['count'])).'</em></td>';
  1036. #if ($selected) $output .= '<td align="right">'.ztheme('search_header', 'XXX', $genre, $action, $selected).'</td>';
  1037. $output .= '</tr></table>';
  1038. }
  1039. $output .= ztheme('form', $form_attr, $list.$list_opts);
  1040. return $output;
  1041. }
  1042. function ztheme_form($attr, $content, $method = 'post') {
  1043. return '<form method="'.$method.'" '.$attr.'><div>'.$content.zina_get_form_token().'</div></form>';
  1044. }
  1045. function ztheme_song_section($form_attr,$song_list,$song_list_opts) {
  1046. return '<h3>'.zt('Songs').'</h3>'.ztheme('form', $form_attr, $song_list.$song_list_opts);
  1047. }
  1048. function ztheme_search_page($term, $results, $total, $navigation, $form_attr, $list, $list_opts, $action, $selected, $zina) {
  1049. $output = '';
  1050. $output .= '<h3>'.zt('Search Results').'</h3>';
  1051. if (empty($results)) {
  1052. $output .= '<p><em>'.zt('0 total items found').'</em></p>';
  1053. } else {
  1054. if ($navigation) $output .= $navigation;
  1055. $output .= '<table class="search-header"><tr><td align="left">';
  1056. $output .= '<em>'.zt('@total items found', array('@total'=>$total)).'</em>';
  1057. $output .= '</td>';
  1058. if ($selected) $output .= '<td align="right">'.ztheme('search_header', 'search', $term, $action, $selected).'</td>';
  1059. $output .= '</tr></table>';
  1060. $output .= ztheme('form', $form_attr, $list.$list_opts);
  1061. }
  1062. return $output;
  1063. }
  1064. function ztheme_year_page($term, $results, $total, $search_navigation, $navigation, $form_attr, $list, $list_opts, $opts, $action, $selected, $zina) {
  1065. return ztheme('genres_page',$term, $results, $total, $search_navigation, $navigation, $form_attr, $list, $list_opts, $opts, $action, $selected, $zina);
  1066. }
  1067. function ztheme_genres_page($genre, $results, $total, $navigation, $genre_navigation, $form_attr, $list, $list_opts, $opts, $action, $selected, $zina) {
  1068. global $zc;
  1069. $class="zinamp";
  1070. $output = '';
  1071. if (!empty($zina['messages'])) $output .= '<div id="zina_messages">'.$zina['messages'].'</div>';
  1072. $output .= '<div class="genre-page clear-block">';
  1073. if ($opts['image']) $output .= ztheme('image', zina_get_genre_image_path($genre), $genre, null, 'class="genre-image"');
  1074. if ($genre_navigation) $output .= '<div class="genre-select">'.$genre_navigation.'</div>';
  1075. $output .= '<p>'.
  1076. zl(ztheme('icon','play.gif',zt('Play')),'',$opts['play_query'], null, false, "class='$class'").
  1077. zl(zt('Play @genre', array('@genre'=>$genre)),'', $opts['play_query'], null, false, "class='$class'").
  1078. '</p>';
  1079. if ($opts['description'] && !empty($opts['description'])) {
  1080. $output .= '<p>'.$opts['description'].'</p>';
  1081. }
  1082. if ($opts['genre_edit']) {
  1083. $output .= '<p class="small">'.zl(zt('Edit Genre'),$opts['genre_edit']['path'], $opts['genre_edit']['query']).'</p>';
  1084. }
  1085. $output .= '</div>';
  1086. if (isset($zina['subgenres'])) {
  1087. $output .= '<table class="search-header"><tr><td align="left"><h3>'.zt('Genre Family').'</h3></td></tr></table>';
  1088. $output .= $zina['subgenres'];
  1089. }
  1090. $output .= '<table class="search-header"><tr><td align="left" width="30%">';
  1091. $output .= '<em>'.zt('@total items found', array('@total'=>$total)).'</em>';
  1092. $output .= '</td><td>'.(($navigation) ? $navigation : '').'</td>';
  1093. $output .= '<td align="right" width="30%">';
  1094. if ($selected) $output .= ztheme('search_header', $zina['search_page_type'], $genre, $action, $selected);
  1095. $output .= '</td></tr></table>';
  1096. if (empty($results) || $selected['type'] == 'artist') $list_opts = '';
  1097. $output .= ztheme('form', $form_attr, $list.$list_opts);
  1098. return $output;
  1099. }
  1100. function ztheme_playlist_list_opts($items, $form) {
  1101. if (empty($items)) return '';
  1102. if (empty($items['submit']) && empty($items['checkbox']) && !isset($items['playlist_form_elements'])) return '';
  1103. $submit = ($items['submit']) ? '<input type="submit" value="'.zt('Update Playlist').'"/>' : '';
  1104. if ($items['checkbox']) {
  1105. $checkbox = ' '.zt('Check').': &nbsp;'.
  1106. zl(zt('All'),'javascript: void 0;',NULL,NULL,FALSE,' onclick="CheckBoxes(\''.$form.'\',true);"').' | '.
  1107. zl(zt('None'),'javascript:void 0;',NULL,NULL,FALSE,' onclick="CheckBoxes(\''.$form.'\',false);"');
  1108. } else {
  1109. $checkbox = '';
  1110. }
  1111. $output = '<table cellpadding="5" cellspacing="0" width="100%"><tr class="row'.zevenodd().'">';
  1112. $output .= '<td>'.$submit.$checkbox.'</td>';
  1113. $output .= '<td align="right">'.((isset($items['playlist_form_elements'])) ? $items['playlist_form_elements'] : '&nbsp;').'</td>';
  1114. $output .= '</tr></table>';
  1115. return $output;
  1116. }
  1117. function ztheme_search_list_opts($items, $form) {
  1118. return ztheme('song_list_opts',$items, $form);
  1119. }
  1120. function ztheme_song_list_opts($items, $form) {
  1121. if (empty($items)) return '';
  1122. $output = '<table cellpadding="5" cellspacing="0" width="100%"><tr class="row'.zevenodd().'">';
  1123. if (isset($items['checkboxes'])) {
  1124. $submit = '';
  1125. if (isset($items['submit'])) {
  1126. $val = ($items['submit']['exists']) ? zt('Update custom playlist') : zt('Create custom playlist');
  1127. $submit = '<input type="submit" value="'.$val.'" onclick="'.$items['submit']['js'].'"/>&nbsp;';
  1128. }
  1129. $output .= '<td>'.$submit.zt('Check').': &nbsp;'.
  1130. zl(zt('All'),'javascript: void 0;',NULL,NULL,FALSE,' onclick="CheckBoxes(\''.$form.'\',true);"').' | '.
  1131. zl(zt('None'),'javascript:void 0;',NULL,NULL,FALSE,' onclick="CheckBoxes(\''.$form.'\',false);"').'</td>';
  1132. }
  1133. if (isset($items['opts'])) {
  1134. $lang['download'] = zt('Download');
  1135. $lang['play'] = zt('Play');
  1136. $lang['play_lofi'] = zt('Play Low Fidelity');
  1137. $lang['play_rec_rand'] = zt('Play random');
  1138. $output .= '<td >'.zt('Selected').': ';
  1139. foreach($items['opts'] as $type=>$opt) {
  1140. $output.= zl(ztheme('icon',$type.'.gif',$lang[$type]),$opt['path'],$opt['query'],NULL,FALSE,$opt['attr']);
  1141. }
  1142. $output .= '</td>';
  1143. }
  1144. $output .= '<td align="right">'.((isset($items['playlist_form_elements'])) ? $items['playlist_form_elements'] : '&nbsp;').'</td>';
  1145. $output .= '</tr></table>';
  1146. return $output;
  1147. }
  1148. function ztheme_song_extra($type, $title, $content, $url = false) {
  1149. if ($url) {
  1150. $content = zt('Loading...');
  1151. zina_set_js('jquery', '$("p#zina-'.$type.'").load("'.$url.'");');
  1152. …

Large files files are truncated, but you can click here to view the full file