/[drupal]/contributions/modules/playlist/playlist.theme
ViewVC logotype

Contents of /contributions/modules/playlist/playlist.theme

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Mon Jun 26 09:26:04 2006 UTC (3 years, 5 months ago) by zirafa
Branch: MAIN
CVS Tags: HEAD
File MIME type: text/x-php
Initial commit to main playlist CVS (moving from zirafa's sandbox)
1 <?php
2 // $Id: playlist.theme,v 1.10 2006/06/25 09:10:12 zirafa Exp $
3 /**
4 * This file contains theme functions and various interface callbacks that may be useful when writing playlist type modules.
5 * You can either choose to use these functions directly in your module or use them as a template for your own.
6 *
7 **/
8
9 drupal_set_html_head('<style type="text/css">@import "/'.PLAYLIST_PATH.'/playlist.css";</style>');
10
11
12 /**
13 * Outputs a drag and drop sortable playlist
14 **/
15 function theme_playlist_sortable($parent_id, $type) {
16 drupal_add_js(PLAYLIST_PATH .'/scripts/prototype.js');
17 drupal_add_js(PLAYLIST_PATH .'/scripts/effects.js');
18 drupal_add_js(PLAYLIST_PATH .'/scripts/dragdrop.js');
19 drupal_add_js(PLAYLIST_PATH .'/scripts/control.js');
20
21 $children = playlist_get_children($parent_id, $type);
22 $output = "<ol id=\"list\" >\n";
23 $count = 0;
24 if (count($children) > 0) {
25 foreach($children as $child_id) {
26 // for the up and down arrows we have to a) figure out the weight of the current item, and b) figure out the playlist items above and below to perform the swap.
27 $weight = playlist_get_weight($parent_id, $child_id);
28 $up = $children[$count - 1] ? $children[$count-1] : $child_id;
29 $down = $children[$count + 1] ? $children[$count+1] : $child_id;
30
31 // icons for deleting, dragging, and swapping the items
32 $manage = l(theme('image',PLAYLIST_PATH.'/images/icon_delete.gif'),"playlist/manage/{$type}/{$parent_id}/delete/{$child_id}", array(), NULL, NULL, FALSE, TRUE) . " " . theme('image',PLAYLIST_PATH.'/images/drag_me.gif') . "<noscript> " . l(theme('image',PLAYLIST_PATH.'/images/go-down.png'),"playlist/manage/{$type}/{$parent_id}/swap/{$child_id}/" .$down, array(), NULL, NULL, FALSE, TRUE) ." ". l(theme('image',PLAYLIST_PATH.'/images/go-up.png'),"playlist/manage/{$type}/{$parent_id}/swap/{$child_id}/" . $up, array(), NULL, NULL, FALSE, TRUE) ."</noscript> ";
33 // output the final list item
34 $playlist_item = node_load($child_id);
35 $output .= "<li id=\"item_$child_id\" > ". $manage . l($playlist_item->title,'node/'.$playlist_item->nid). "</li>\n";
36 $count++;
37 }
38 }
39 else {
40 $output .= t('No items have been added yet.');
41 }
42 $output .= "</ol>\n";
43
44 $output .= '<p id="list-info"></p>';
45 $output .= "<script type=\"text/javascript\">Sortable.create('list', {onUpdate:function(){new Ajax.Updater('list-info', '".url('playlist/ajax/order/'.$parent_id, null,null,true)."', {onComplete:function(request){new Effect.Highlight('list',{});}, parameters:Sortable.serialize('list'), evalScripts:true, asynchronous:true})}})</script>";
46
47 return theme('fieldset', array('#title'=> 'Manage '.node_get_name($type) ,'#value' => $output, '#collapsible' => TRUE));
48 }
49
50
51 /**
52 * Outputs a playlist as a simple list
53 **/
54 function theme_playlist_get_list($playlist_id, $type) {
55 $children = playlist_get_children($playlist_id, $type);
56 $output = "<ol id=\"list\" >\n";
57 foreach($children as $child_id) {
58 $playlist_item = node_load($child_id);
59 $output .= "<li id=\"item_$child_id\" > " .l($playlist_item->title,'node/'.$playlist_item->nid). "</li>\n";
60 }
61 $output .= "</ol>\n";
62
63 return theme('fieldset', array('#title'=> ucfirst(node_get_name($type)) ,'#value' => $output));
64 }

  ViewVC Help
Powered by ViewVC 1.1.2