From 51da1904c74b83f6db87e3fa911b0f99bae88898 Mon Sep 17 00:00:00 2001 From: sebastian Date: Sun, 24 Apr 2005 19:26:09 +0000 Subject: [PATCH] *** empty log message *** --- .../htmlUI/var/SmartyExtensions.inc.php | 26 +++ .../htmlUI/var/formmask/generic.inc.php | 39 ++++- .../modules/htmlUI/var/html/ui_handler.php | 2 +- .../htmlUI/var/templates/library/results.tpl | 2 +- .../var/templates/popup/SCHEDULER.addItem.tpl | 68 ++++++++ .../var/templates/scheduler/context_week.tpl | 1 + .../htmlUI/var/templates/scheduler/day.tpl | 5 +- .../htmlUI/var/templates/scheduler/week.tpl | 2 +- .../templates/scratchpad/actionhandler.tpl | 72 ++++---- .../htmlUI/var/templates/scratchpad/main.tpl | 158 +++++++++--------- .../var/templates/script/contextmenu.js.tpl | 4 - .../modules/htmlUI/var/ui_base.inc.php | 24 +-- .../modules/htmlUI/var/ui_browser.class.php | 5 +- .../modules/htmlUI/var/ui_scheduler.class.php | 81 ++++++--- 14 files changed, 309 insertions(+), 180 deletions(-) create mode 100755 livesupport/modules/htmlUI/var/templates/scheduler/context_week.tpl diff --git a/livesupport/modules/htmlUI/var/SmartyExtensions.inc.php b/livesupport/modules/htmlUI/var/SmartyExtensions.inc.php index 8baaa2aa3..3dc02e507 100644 --- a/livesupport/modules/htmlUI/var/SmartyExtensions.inc.php +++ b/livesupport/modules/htmlUI/var/SmartyExtensions.inc.php @@ -14,6 +14,7 @@ $Smarty->register_function('tra', 'S_tra'); $Smarty->register_function('getHour', 'S_getHour'); $Smarty->register_function('getMinute', 'S_getMinute'); $Smarty->register_function('getSecond', 'S_getSecond'); +$Smarty->register_function('niceTime', 'S_niceTime'); // --- Smarty Extensions --- /** @@ -83,6 +84,7 @@ function S_getHour($param) ## input format is HH:MM:SS.dddddd extract ($param); list ($h, $m, $s) = explode (':', $time); + settype($h, 'integer'); return $h; } @@ -91,6 +93,7 @@ function S_getMinute($param) ## input format is HH:MM:SS.dddddd extract ($param); list ($h, $m, $s) = explode (':', $time); + settype($m, 'integer'); return $m; } @@ -99,6 +102,29 @@ function S_getSecond($param) ## input format is HH:MM:SS.dddddd extract ($param); list ($h, $m, $s) = explode (':', $time); + if ($plus) $s += $plus; + settype($s, 'integer'); return $s; } + + + +function S_niceTime($param) +{ + extract($param); + + if (strpos($in, '.')) list ($in, $lost) = explode('.', $in); + $in = str_replace(' ', '', $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 ($all || $h > 0) $H = sprintf('%02d', $h).':'; + else $H = '   '; + $I = sprintf('%02d', $i).':'; + $S = sprintf('%02d', $s); + + return $H.$I.$S; +} ?> \ No newline at end of file diff --git a/livesupport/modules/htmlUI/var/formmask/generic.inc.php b/livesupport/modules/htmlUI/var/formmask/generic.inc.php index c9d660903..3afa71e56 100755 --- a/livesupport/modules/htmlUI/var/formmask/generic.inc.php +++ b/livesupport/modules/htmlUI/var/formmask/generic.inc.php @@ -710,6 +710,10 @@ $ui_fmask = array( 'type' => 'hidden', 'constant' => 'SCHEDULER.addItem' ), + array( + 'element' => 'playlist', + 'type' => 'hidden' + ), 'date' => array( 'element' => 'date', 'type' => 'date', @@ -722,12 +726,36 @@ $ui_fmask = array( 'label' => 'Time', 'options' => array('format' => 'His'), ), - 'playlist' => array( - 'element' => 'playlist', + 'gunid_duration' => array( + 'element' => 'gunid_duration', 'type' => 'select', 'label' => 'Playlist', 'required' => TRUE, ), + array( + 'element' => 'snap2Prev', + 'type' => 'button', + 'label' => 'Snap to previous', + 'attributes'=> array('onClick' => 'SCHEDULE_snap2Prev()'), + 'groupit' => TRUE + ), + array( + 'element' => 'snap2Hour', + 'type' => 'button', + 'label' => 'Snap to hour', + 'attributes'=> array('onClick' => 'SCHEDULE_snap2Hour()'), + 'groupit' => TRUE + ), + array( + 'element' => 'snap2Next', + 'type' => 'button', + 'label' => 'Snap to next', + 'attributes'=> array('onClick' => 'SCHEDULE_snap2Next()'), + 'groupit' => TRUE + ), + array( + 'group' => array('snap2Prev', 'snap2Hour', 'snap2Next') + ), array( 'element' => 'cancel', 'type' => 'button', @@ -742,13 +770,14 @@ $ui_fmask = array( 'groupit' => TRUE ), array( - 'element' => 'submit', - 'type' => 'submit', + 'element' => 'submitter', + 'type' => 'button', 'label' => 'Submit', + 'attributes'=> array('onClick' => 'SCHEDULE_submit()'), 'groupit' => TRUE ), array( - 'group' => array('cancel', 'reset', 'submit') + 'group' => array('cancel', 'reset', 'submitter') ) ) ); \ No newline at end of file diff --git a/livesupport/modules/htmlUI/var/html/ui_handler.php b/livesupport/modules/htmlUI/var/html/ui_handler.php index ecf640fff..fb313e44c 100644 --- a/livesupport/modules/htmlUI/var/html/ui_handler.php +++ b/livesupport/modules/htmlUI/var/html/ui_handler.php @@ -257,7 +257,7 @@ switch($_REQUEST['act']){ break; case "SCHEDULER.setScheduleTime": - $uiHandler->SCHEDULER->setScheduleTime($_REQUEST); + $uiHandler->SCHEDULER->setScheduleAt($_REQUEST); $uiHandler->SCHEDULER->setClose(); break; diff --git a/livesupport/modules/htmlUI/var/templates/library/results.tpl b/livesupport/modules/htmlUI/var/templates/library/results.tpl index 1fc46afa1..8cb0ec391 100755 --- a/livesupport/modules/htmlUI/var/templates/library/results.tpl +++ b/livesupport/modules/htmlUI/var/templates/library/results.tpl @@ -25,7 +25,7 @@ {/if} {$i.creator} - {$i.duration} + {assign var="_duration" value=$i.duration}{niceTime in=$_duration} {$i.type|lower|capitalize} diff --git a/livesupport/modules/htmlUI/var/templates/popup/SCHEDULER.addItem.tpl b/livesupport/modules/htmlUI/var/templates/popup/SCHEDULER.addItem.tpl index 02091f1e7..75d524829 100755 --- a/livesupport/modules/htmlUI/var/templates/popup/SCHEDULER.addItem.tpl +++ b/livesupport/modules/htmlUI/var/templates/popup/SCHEDULER.addItem.tpl @@ -21,6 +21,74 @@ {/if} + + diff --git a/livesupport/modules/htmlUI/var/templates/scheduler/context_week.tpl b/livesupport/modules/htmlUI/var/templates/scheduler/context_week.tpl new file mode 100755 index 000000000..14343a936 --- /dev/null +++ b/livesupport/modules/htmlUI/var/templates/scheduler/context_week.tpl @@ -0,0 +1 @@ +onClick="return contextmenu('year={$_day.year}&month={$_day.month}&day={$_day.day}&hour={$_hour}&minute=0&second=0', 'SCHEDULER.addItem')" diff --git a/livesupport/modules/htmlUI/var/templates/scheduler/day.tpl b/livesupport/modules/htmlUI/var/templates/scheduler/day.tpl index 8fa98840f..5a0673681 100755 --- a/livesupport/modules/htmlUI/var/templates/scheduler/day.tpl +++ b/livesupport/modules/htmlUI/var/templates/scheduler/day.tpl @@ -33,7 +33,7 @@ {if is_array($_entrys[$_hour])} - {$_hour|string_format:"%02d"}:00 + {$_hour|string_format:"%02d"}:00 {foreach from=$_entrys[$_hour] item="i"} {* hier werden die Einträge welche in der jeweil. h beginnen durchlaufen *} @@ -42,12 +42,13 @@ {$i.start}-{$i.end} {$i.creator} +
{/foreach} {else} - + {$_hour|string_format:"%02d"}:00 diff --git a/livesupport/modules/htmlUI/var/templates/scheduler/week.tpl b/livesupport/modules/htmlUI/var/templates/scheduler/week.tpl index 3b9b3954f..bd4ebffac 100755 --- a/livesupport/modules/htmlUI/var/templates/scheduler/week.tpl +++ b/livesupport/modules/htmlUI/var/templates/scheduler/week.tpl @@ -54,7 +54,7 @@

{$i.start|truncate:5:""} - {$i.end|truncate:5:""}

{$i.creator}

-
+
{/foreach} {else} diff --git a/livesupport/modules/htmlUI/var/templates/scratchpad/actionhandler.tpl b/livesupport/modules/htmlUI/var/templates/scratchpad/actionhandler.tpl index d6f3c7859..3a8f9d1cb 100755 --- a/livesupport/modules/htmlUI/var/templates/scratchpad/actionhandler.tpl +++ b/livesupport/modules/htmlUI/var/templates/scratchpad/actionhandler.tpl @@ -1,36 +1,36 @@ -{include file="sub/mouseover.tpl"} -onClick="hidealttextnow(); return contextmenu('{$i.id}' - , 'SP.removeItem' - - {if $i.type === 'audioclip'} - , 'listen', '{$i.gunid}' - {if $_PL_activeId} - , 'PL.addItem' - {else} - , 'PL.create' - {/if} - , 'edit', 'delete' - {/if} - - {if $i.type === 'webstream'} - {if $_PL_activeId} - , 'PL.addItem' - {else} - , 'PL.create' - {/if} - , 'edit', 'delete' - {/if} - - {if $i.type === 'playlist'} - {if $_PL_activeId} - {if $_PL_activeId === $i.id} - , 'PL.release' - {elseif $PL->isAvailable($i.id) === TRUE} - , 'PL.addItem', 'delete' - {/if} - {elseif $PL->isAvailable($i.id) === TRUE} - , 'PL.activate', 'PL.create', 'delete' - {/if} - {/if} -)" - +{include file="sub/mouseover.tpl"} +onClick="hidealttextnow(); return contextmenu('{$i.id}' + , 'SP.removeItem' + + {if $i.type == 'audioclip'} + , 'listen', '{$i.gunid}' + {if $_PL_activeId} + , 'PL.addItem' + {else} + , 'PL.create' + {/if} + , 'edit', 'delete' + {/if} + + {if $i.type == 'webstream'} + {if $_PL_activeId} + , 'PL.addItem' + {else} + , 'PL.create' + {/if} + , 'edit', 'delete' + {/if} + + {if $i.type == 'playlist'} + {if $_PL_activeId} + {if $_PL_activeId == $i.id} + , 'PL.release' + {elseif $PL->isAvailable($i.id) == TRUE} + , 'PL.addItem', 'delete' + {/if} + {elseif $PL->isAvailable($i.id) == TRUE} + , 'PL.activate', 'PL.create', 'delete' + {/if} + {/if} +)" + diff --git a/livesupport/modules/htmlUI/var/templates/scratchpad/main.tpl b/livesupport/modules/htmlUI/var/templates/scratchpad/main.tpl index a5575792d..d82812f49 100755 --- a/livesupport/modules/htmlUI/var/templates/scratchpad/main.tpl +++ b/livesupport/modules/htmlUI/var/templates/scratchpad/main.tpl @@ -1,79 +1,79 @@ -{assign var="_PL_activeId" value=$PL->getActiveId()} -{assign var="SCRATCHPAD" value=$SCRATCHPAD->get()} - - -
-
-

##ScratchPad##

-
 
-
- - - - - - - - - - - - {if count($SCRATCHPAD) >= 1} - {foreach from=$SCRATCHPAD item=i} - - - - - - - - - {/foreach} - {else} - - - - {/if} -
##Title####Duration####Type##
- {if $i.type === "playlist"} - {if $PL->isAvailable($i.id) === FALSE} -
- {else} -
- {/if} - {if $_PL_activeId === $i.id} -
- {else} -
- {/if} - {$i.title|truncate:12} -
- {else} - {$i.title|truncate:12} - {/if} -
{$i.duration}{$i.type|capitalize}
##empty##
-
- - - -
-
- - -{assign var="_PL_activeId" value=NULL} +{assign var="_PL_activeId" value=$PL->getActiveId()} +{assign var="SCRATCHPAD" value=$SCRATCHPAD->get()} + + +
+
+

##ScratchPad##

+
 
+
+ + + + + + + + + + + + {if count($SCRATCHPAD) >= 1} + {foreach from=$SCRATCHPAD item=i} + + + + {assign var="_duration" value=$i.duration} + + + + + {/foreach} + {else} + + + + {/if} +
##Title####Duration####Type##
+ {if $i.type == "playlist"} + {if $PL->isAvailable($i.id) == FALSE} +
+ {else} +
+ {/if} + {if $_PL_activeId == $i.id} +
+ {else} +
+ {/if} + {$i.title|truncate:12} +
+ {else} + {$i.title|truncate:12} + {/if} {* on some reason object call doesn´t like usage of array *} +
{niceTime in=$_duration}{$i.type|capitalize}
##empty##
+
+ + + +
+
+ + +{assign var="_PL_activeId" value=NULL} \ No newline at end of file diff --git a/livesupport/modules/htmlUI/var/templates/script/contextmenu.js.tpl b/livesupport/modules/htmlUI/var/templates/script/contextmenu.js.tpl index daf035770..daa928ee1 100755 --- a/livesupport/modules/htmlUI/var/templates/script/contextmenu.js.tpl +++ b/livesupport/modules/htmlUI/var/templates/script/contextmenu.js.tpl @@ -97,10 +97,6 @@ contextmenuHtml = contextmenuHtml + "
  •  ##Insert Playlist here## 
  • "; break; - case "SCHEDULER.addNextItem": - contextmenuHtml = contextmenuHtml + "
  •  ##Insert Playlist after previous## 
  • "; - break; - case "SCHEDULER.removeItem": contextmenuHtml = contextmenuHtml + "
  •  ##Remove Playlist## 
  • "; break; diff --git a/livesupport/modules/htmlUI/var/ui_base.inc.php b/livesupport/modules/htmlUI/var/ui_base.inc.php index 9adc5ac5c..329d5d25e 100644 --- a/livesupport/modules/htmlUI/var/ui_base.inc.php +++ b/livesupport/modules/htmlUI/var/ui_base.inc.php @@ -331,34 +331,14 @@ class uiBase 'gunid' => $this->gb->_gunidFromId($id), 'title' => $this->_getMDataValue($id, UI_MDATA_KEY_TITLE), 'creator' => $this->_getMDataValue($id, UI_MDATA_KEY_CREATOR), - 'duration' => $this->_niceTime($this->_getMDataValue($id, UI_MDATA_KEY_DURATION)), + 'duration' => $this->_getMDataValue($id, UI_MDATA_KEY_DURATION), 'type' => $type, #'isAvailable' => $type == 'playlist' ? $this->gb->playlistIsAvailable($id, $this->sessid) : NULL, ); return ($data); } - - function _niceTime($in, $all=FALSE) - { - if(is_array($in)) $in = current($in); - - if (strpos($in, '.')) list ($in, $lost) = explode('.', $in); - $in = str_replace(' ', '', $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 ($all || $h > 0) $H = sprintf('%02d', $h).':'; - else $H = '   '; - $I = sprintf('%02d', $i).':'; - $S = sprintf('%02d', $s); - - return $H.$I.$S; - } - - + function _getMDataValue($id, $key, $langid=UI_DEFAULT_LANGID) { if (is_array($arr = $this->gb->getMDataValue($id, $key, $this->sessid, $langid))) { diff --git a/livesupport/modules/htmlUI/var/ui_browser.class.php b/livesupport/modules/htmlUI/var/ui_browser.class.php index e5b8c81cc..c6667cfc8 100644 --- a/livesupport/modules/htmlUI/var/ui_browser.class.php +++ b/livesupport/modules/htmlUI/var/ui_browser.class.php @@ -205,8 +205,9 @@ class uiBrowser extends uiBase { 'act' => 'editWebstream', 'title' => $id ? $this->_getMDataValue($id, UI_MDATA_KEY_TITLE) : NULL, 'url' => $id ? $this->_getMDataValue($id, UI_MDATA_KEY_URL) : 'http://', - 'length' => $id ? $this->_niceTime($this->_getMDataValue($id, UI_MDATA_KEY_DURATION), TRUE) : NULL + 'length' => $id ? preg_replace("/\.[0-9]{1,6}/", "", $this->_getMDataValue($id, UI_MDATA_KEY_DURATION)) : NULL ); + $form->setConstants($const); $this->_parseArr2Form($form, $mask); $renderer =& new HTML_QuickForm_Renderer_Array(true, true); @@ -317,7 +318,7 @@ class uiBrowser extends uiBase { * @return array */ function permissions($id) - { + { return array('pathdata' => $this->gb->getPath($id), 'perms' => $this->gb->getObjPerms($id), 'actions' => $this->gb->getAllowedActions($this->gb->getObjType($id)), diff --git a/livesupport/modules/htmlUI/var/ui_scheduler.class.php b/livesupport/modules/htmlUI/var/ui_scheduler.class.php index 2c625f2a7..40ccc0c78 100755 --- a/livesupport/modules/htmlUI/var/ui_scheduler.class.php +++ b/livesupport/modules/htmlUI/var/ui_scheduler.class.php @@ -3,19 +3,21 @@ class uiScheduler extends uiCalendar { function uiScheduler(&$uiBase) { - $this->curr =& $_SESSION[UI_CALENDAR_SESSNAME]['current']; - $this->scheduleAt =& $_SESSION[UI_CALENDAR_SESSNAME]['schedule']; + $this->curr =& $_SESSION[UI_CALENDAR_SESSNAME]['current']; + $this->scheduleAt =& $_SESSION[UI_CALENDAR_SESSNAME]['scheduleAt']; + $this->schedulePrev =& $_SESSION[UI_CALENDAR_SESSNAME]['schedulePrev']; + $this->scheduleNext =& $_SESSION[UI_CALENDAR_SESSNAME]['scheduleNext']; if (!is_array($this->curr)) { - $this->curr['view'] = 'month'; - $this->curr['year'] = strftime("%Y"); - $this->curr['month'] = strftime("%m"); - $this->curr['week'] = strftime("%V"); - $this->curr['day'] = strftime("%d"); - $this->curr['hour'] = strftime("%H"); - $this->curr['dayname'] = strftime("%A"); - $this->curr['monthname']= strftime("%B"); - $this->curr['isToday'] = TRUE; + $this->curr['view'] = 'month'; + $this->curr['year'] = strftime("%Y"); + $this->curr['month'] = strftime("%m"); + $this->curr['week'] = strftime("%V"); + $this->curr['day'] = strftime("%d"); + $this->curr['hour'] = strftime("%H"); + $this->curr['dayname'] = strftime("%A"); + $this->curr['monthname'] = strftime("%B"); + $this->curr['isToday'] = TRUE; } $this->Base =& $uiBase; @@ -69,13 +71,13 @@ class uiScheduler extends uiCalendar if ($today) $stampTarget = time(); - $this->curr['year'] = strftime("%Y", $stampTarget); - $this->curr['month'] = strftime("%m", $stampTarget); - $this->curr['week'] = strftime("%V", $stampTarget); - $this->curr['day'] = strftime("%d", $stampTarget); - $this->curr['hour'] = strftime("%H", $stampTarget); - $this->curr['dayname'] = strftime("%A", $stampTarget); - $this->curr['monthname']= strftime("%B", $stampTarget); + $this->curr['year'] = strftime("%Y", $stampTarget); + $this->curr['month'] = strftime("%m", $stampTarget); + $this->curr['week'] = strftime("%V", $stampTarget); + $this->curr['day'] = strftime("%d", $stampTarget); + $this->curr['hour'] = strftime("%H", $stampTarget); + $this->curr['dayname'] = strftime("%A", $stampTarget); + $this->curr['monthname'] = strftime("%B", $stampTarget); if ($this->curr['year'] === strftime("%Y") && $this->curr['month'] === strftime("%m") && $this->curr['day'] === strftime("%d")) $this->curr['isToday'] = TRUE; @@ -85,7 +87,7 @@ class uiScheduler extends uiCalendar } - function setscheduleAt($arr) + function setScheduleAt($arr) { extract($arr); #print_r($arr); @@ -96,6 +98,27 @@ class uiScheduler extends uiCalendar if (is_numeric($hour)) $this->scheduleAt['hour'] = sprintf('%02d', $hour); if (is_numeric($minute)) $this->scheduleAt['minute'] = sprintf('%02d', $minute); if (is_numeric($second)) $this->scheduleAt['second'] = sprintf('%02d', $second); + + $week = $this->getWeekEntrys(); + ## search for next entry + foreach ($week[$this->scheduleAt['day']] as $entry) { + if (strtotime($entry[0]['start']) >= strtotime($this->scheduleAt['hour'].':'.$this->scheduleAt['minute'].':'.$this->scheduleAt['second'])) { + list($this->scheduleNext['hour'], $this->scheduleNext['minute'], $this->scheduleNext['second']) = explode(':', strftime('%H:%M:%S', strtotime($entry[0]['start'])-1)); + break; + } + } + + reset ($week); + ## search for previous entry + foreach (array_reverse($week[$this->scheduleAt['day']]) as $entry) { + if (strtotime($entry[0]['end']) <= strtotime($this->scheduleAt['hour'].':'.$this->scheduleAt['minute'].':'.$this->scheduleAt['second'])) { + list($this->schedulePrev['hour'], $this->schedulePrev['minute'], $this->schedulePrev['second']) = explode(':', strftime('%H:%M:%S', strtotime($entry[0]['end'])+1)); + break; + } + } + #print_r($this->schedulePrev); + #print_r($this->scheduleNext); + } function getWeekEntrys() @@ -265,22 +288,26 @@ class uiScheduler extends uiCalendar function getScheduleForm() { global $ui_fmask; + #print_r($this->availablePlaylists); + foreach ($this->availablePlaylists as $val) { + $ui_fmask['schedule']['gunid_duration']['options'][$val['gunid'].'|'.$val['duration']] = $val['title']; + } + #print_r($ui_fmask['schedule']); - foreach ($this->availablePlaylists as $val) - $ui_fmask['schedule']['playlist']['options'][$val['gunid']] = $val['title']; - #print_r($ui_fmask); $form = new HTML_QuickForm('schedule', UI_STANDARD_FORM_METHOD, UI_HANDLER); $this->Base->_parseArr2Form($form, $ui_fmask['schedule']); $settime = array('H' => $this->scheduleAt['hour'], 'i' => $this->scheduleAt['minute'], 's' => $this->scheduleAt['second'] - ); + ); $setdate = array('Y' => $this->scheduleAt['year'], 'm' => $this->scheduleAt['month'], - 'd' => $this->scheduleAt['day']); - $form->setDefaults(array('time' => $settime, - 'date' => $setdate, - 'playlist' => $setplaylist)); + 'd' => $this->scheduleAt['day'] + ); + $form->setDefaults(array('time' => $settime, + 'date' => $setdate, + )); + $renderer =& new HTML_QuickForm_Renderer_Array(true, true); $form->accept($renderer); $output = $renderer->toArray();