diff --git a/livesupport/modules/htmlUI/var/html/ui_browser.php b/livesupport/modules/htmlUI/var/html/ui_browser.php index 1405cdc5c..6d766b1e1 100644 --- a/livesupport/modules/htmlUI/var/html/ui_browser.php +++ b/livesupport/modules/htmlUI/var/html/ui_browser.php @@ -148,7 +148,7 @@ if ($uiBrowser->userid) { $Smarty->assign('changeStationPrefs', TRUE); break; - case "PL.simpleManagement": + case "PL.simpleManagement": if ($_REQUEST['createNew']) { $uiBrowser->PLAYLIST->testNew(); #$Smarty->assign('PLAYLIST', $uiBrowser->PLAYLIST->get()); diff --git a/livesupport/modules/htmlUI/var/html/ui_handler.php b/livesupport/modules/htmlUI/var/html/ui_handler.php index 9e57babb2..b8bb321d6 100644 --- a/livesupport/modules/htmlUI/var/html/ui_handler.php +++ b/livesupport/modules/htmlUI/var/html/ui_handler.php @@ -178,6 +178,11 @@ switch($_REQUEST['act']){ $uiHandler->PLAYLIST->setReload(); break; + case "PL.revert": + $uiHandler->PLAYLIST->revert(); + $uiHandler->PLAYLIST->setReload(); + break; + default: $_SESSION["alertMsg"] = tra("Unknown method: $1", $_REQUEST["act"]); header("Location: ".UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close'); diff --git a/livesupport/modules/htmlUI/var/templates/playlist/editor.tpl b/livesupport/modules/htmlUI/var/templates/playlist/editor.tpl new file mode 100755 index 000000000..f930108c4 --- /dev/null +++ b/livesupport/modules/htmlUI/var/templates/playlist/editor.tpl @@ -0,0 +1,23 @@ +<tr><th colspan="4">active Playlist: {$PL.children.0.children.0.content}</th></tr> +<tr align="center" style="background-color: {cycle values='#eeeeee, #dadada'}"><td></td><td>Title</td><td>Duration</td><td>Type</td></tr> + +{PL->getFlat assign='FLAT'} +{foreach from=$FLAT item='i'} + {* {uiBrowser->_niceTime p1=$i.playlength assign='nicelength'} *} + <tr onMouseOver="highlight()" onMouseOut="darklight()" onContextmenu="return menu('{$i.id}', 'PL.removeItem')" style="background-color: {cycle values='#eeeeee, #dadada'}"> + <td><input type="checkbox" name="{$i.id}"></td> + <td>{$i.title}</td> + <td>{$i.duration}</td> + <td>{$i.type}</td> + </tr> +{/foreach} +<tr style="background-color: {cycle values='#eeeeee, #dadada'}"> + <td><input type="checkbox" name="all" onClick="form_switchAll('PL')"></th> + <td align="center" colspan="2"><a href="#" onClick="form_submit('PL')">[Remove Selected]</a></th> + <td align="center" colspan="2"><a href="#" onClick="form_clearAll('PL')">[Clear]</a></th> +</tr> + +<tr> + <td colspan="2"><input type="button" value="Save & Release" onClick="hpopup('{$UI_HANDLER}?act=PL.release')"></td> + <td colspan="2"><input type="button" value="Revert all Changes" onClick="hpopup('{$UI_HANDLER}?act=PL.revert')"></td> +</tr> diff --git a/livesupport/modules/htmlUI/var/templates/playlist/simpleManagement.tpl b/livesupport/modules/htmlUI/var/templates/playlist/simpleManagement.tpl index 75a42e191..2c18e12fc 100755 --- a/livesupport/modules/htmlUI/var/templates/playlist/simpleManagement.tpl +++ b/livesupport/modules/htmlUI/var/templates/playlist/simpleManagement.tpl @@ -5,36 +5,15 @@ <center> <form name="PL"> -<table border="1"> +<table border="0"> <tr><th colspan="4">Simple Playlist Management</th></tr> {PL->get assign='PL'} -{if is_array($PL)} {* already activated Playlist *} - - <tr><th colspan="4">active Playlist: {$PL.children.0.children.0.content}</th></tr> - <tr align="center"><td></td><td>Title</td><td>Duration</td><td>Type</td></tr> - - {PL->getFlat assign='FLAT'} - {foreach from=$FLAT item='i'} - {uiBrowser->_niceTime p1=$i.playlength assign='nicelength'} - <tr onMouseOver="highlight()" onMouseOut="darklight()" onContextmenu="return menu('{$i.id}', 'PL.removeItem')"> - <td><input type="checkbox" name="{$i.id}"></td> - <td>{$i.title}</td> - <td>{$nicelength}</td> - <td>{$i.type}</td> - </tr> - {/foreach} - <tr style="background-color: {cycle values='#eeeeee, #dadada'}"> - <td><input type="checkbox" name="all" onClick="form_switchAll('PL')"></th> - <td align="center" colspan="2"><a href="#" onClick="form_submit('PL')">[Remove Selected]</a></th> - <td align="center" colspan="2"><a href="#" onClick="form_clearAll('PL')">[Clear]</a></th> - </tr> - </table> - +{if is_array($PL)} {* already activated Playlist *} + {include file="playlist/editor.tpl"} {else} {* no active Playlist *} - No active Playlist! - <br> - <input type="button" value="Make new Playlist" onClick="hpopup('{$UI_HANDLER}?act=PL.create')"> + <tr><td colspan="4">No active Playlist!</td></tr> + <tr><td colspan="4"><input type="button" value="Make new Playlist" onClick="hpopup('{$UI_HANDLER}?act=PL.create')"></td></tr> {/if} </table> diff --git a/livesupport/modules/htmlUI/var/ui_base.inc.php b/livesupport/modules/htmlUI/var/ui_base.inc.php index 31b1481c6..8db3f968d 100644 --- a/livesupport/modules/htmlUI/var/ui_base.inc.php +++ b/livesupport/modules/htmlUI/var/ui_base.inc.php @@ -325,23 +325,16 @@ class uiBase function _niceTime($in) { - if(is_array($in)) { - $in = current($in); - } - list ($in, $lost) = explode('.', $in); - if (preg_match('/^[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}$/', $in)) - list($h, $i, $s) = explode(':', $in); - elseif (preg_match('/^[0-9]{1,2}:[0-9]{1,2}$/', $in)) - list($i, $s) = explode(':', $in); - else - $s = $in; + if(is_array($in)) $in = current($in); + if (strpos($in, '.')) list ($in, $lost) = explode('.', $in); + $in = str_replace(' ', '', $in); - if ($h > 0) { - $H = $this->_twoDigits($h).':'; - } else { - $H = ' '; - } + if (preg_match('/^[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}$/', $in)) list($h, $i, $s) = explode(':', $in); + elseif (preg_match('/^[0-9]{1,2}:[0-9]{1,2}$/', $in)) list($i, $s) = explode(':', $in); + else $s = $in; + if ($h > 0) $H = $this->_twoDigits($h).':'; + else $H = ' '; $I = $this->_twoDigits($i).':'; $S = $this->_twoDigits($s); diff --git a/livesupport/modules/htmlUI/var/ui_playlist.class.php b/livesupport/modules/htmlUI/var/ui_playlist.class.php index 26ad8f22a..796520331 100755 --- a/livesupport/modules/htmlUI/var/ui_playlist.class.php +++ b/livesupport/modules/htmlUI/var/ui_playlist.class.php @@ -56,6 +56,10 @@ class uiPlaylist return FALSE; } $plgunid = $this->Base->gb->releaseLockedPlaylist($this->token, $this->Base->sessid); + if (PEAR::isError($plgunid)) { + $this->Base->_retMsg('Unable to release Playlist'); + return FALSE; + } $this->Base->_retMsg('Playlist "$1" released', $this->Base->_getMDataValue($this->Base->gb->_idFromGunid($plgunid), UI_MDATA_KEY_TITLE)); $this->activeId = NULL; $this->token = NULL; @@ -63,6 +67,26 @@ class uiPlaylist return TRUE; } + + function revert() + { + if(!$this->token) { + $this->Base->_retMsg('No Playlist is looked by You'); + return FALSE; + } + $plgunid = $this->Base->gb->revertEditedPlaylist($this->token, $this->Base->sessid); + if (PEAR::isError($plgunid)) { + $this->Base->_retMsg('Unable to revert to looked state'); + return FALSE; + } + $this->Base->_retMsg('Playlist "$1" reverted and released', $this->Base->_getMDataValue($this->Base->gb->_idFromGunid($plgunid), UI_MDATA_KEY_TITLE)); + $this->activeId = NULL; + $this->token = NULL; + $this->Base->gb->delPref($this->Base->sessid, UI_PL_ACCESSTOKEN_KEY); + return TRUE; + } + + function testForLooked() { if(is_string($this->token = $this->Base->gb->loadPref($this->Base->sessid, UI_PL_ACCESSTOKEN_KEY))) { @@ -140,8 +164,10 @@ class uiPlaylist if ($sub['elementname']=='playlistelement') { $this->plwalk($sub, $node); } - if ($sub['elementname']=='audioclip') { - $this->flat["$parent.$node"] = $sub['attrs']; + if ($sub['elementname']=='audioclip' || $sub['elementname']=='webstream') { + #$this->flat["$parent.$node"] = $sub['attrs']; + #$this->flat["$parent.$node"]['type'] = $sub['elementname']; + $this->flat["$parent.$node"] = $this->Base->_getMetaInfo($this->Base->gb->_idFromGunid($sub['attrs']['id'])); } } }