From 720cb18b4c2f8a42f310fbef2cd17db5619f3910 Mon Sep 17 00:00:00 2001 From: sebastian Date: Thu, 17 Feb 2005 19:23:48 +0000 Subject: [PATCH] *** empty log message *** --- livesupport/modules/htmlUI/var/conf.php | 9 ++- .../htmlUI/var/html/templates/ScratchPad.tpl | 4 +- .../var/html/templates/editMetaData.tpl | 12 ++-- .../htmlUI/var/html/templates/masterpanel.tpl | 2 +- .../htmlUI/var/html/templates/objects.tpl | 2 +- .../var/html/templates/script/search.js.tpl | 13 ++-- .../htmlUI/var/html/templates/search.tpl | 6 +- .../modules/htmlUI/var/html/ui_browser.php | 11 ++- .../modules/htmlUI/var/html/ui_handler.php | 10 ++- .../modules/htmlUI/var/ui_base.inc.php | 65 +++++++++++------- .../modules/htmlUI/var/ui_browser.class.php | 67 +++++-------------- .../modules/htmlUI/var/ui_fmask.inc.php | 23 ++++--- .../modules/htmlUI/var/ui_handler.class.php | 44 +++++++++--- 13 files changed, 143 insertions(+), 125 deletions(-) diff --git a/livesupport/modules/htmlUI/var/conf.php b/livesupport/modules/htmlUI/var/conf.php index 7bdaac493..c93cda9d6 100644 --- a/livesupport/modules/htmlUI/var/conf.php +++ b/livesupport/modules/htmlUI/var/conf.php @@ -23,7 +23,7 @@ Author : $Author: sebastian $ - Version : $Revision: 1.10 $ + Version : $Revision: 1.11 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/htmlUI/var/Attic/conf.php,v $ ------------------------------------------------------------------------------*/ @@ -126,6 +126,9 @@ define('UI_REGEX_URL', '/^(ht|f)tps?:\/\/[^ ]+$/'); define('UI_SCRATCHPAD_KEY', 'djBagContents'); define('UI_SCRATCHPAD_MAXLENGTH_KEY', 'djBagMaxlength'); #define('UI_SCRATCHPAD_REGEX', '/^[0-9a-f]{16}:[0-9]{4}-[0-9]{2}-[0-9]{2}$/'); -define('UI_SCRATCHPAD_SESSNAME', 'SP'); -define('UI_STATIONINFO_SESSNAME', 'SInfo'); + +## session keys +define('UI_SCRATCHPAD_SESSNAME', 'SCRATCHPAD'); +define('UI_STATIONINFO_SESSNAME', 'STATIONINFO'); +define('UI_SEARCH_SESSNAME', 'SEARCH'); ?> \ No newline at end of file diff --git a/livesupport/modules/htmlUI/var/html/templates/ScratchPad.tpl b/livesupport/modules/htmlUI/var/html/templates/ScratchPad.tpl index 44569601f..6c3e980d7 100755 --- a/livesupport/modules/htmlUI/var/html/templates/ScratchPad.tpl +++ b/livesupport/modules/htmlUI/var/html/templates/ScratchPad.tpl @@ -21,7 +21,7 @@ {$i.title} {$i.duration} {$i.type} - X + X {/foreach} @@ -43,7 +43,7 @@ function SP_submit() for (n=0; n < (document.forms['SP'].elements.length-1); n++) { if (document.forms['SP'].elements[n].checked) { - href = href + '&SPid[]=' + document.forms['SP'].elements[n].name; + href = href + '&id[]=' + document.forms['SP'].elements[n].name; } } hpopup(href, 'SP'); diff --git a/livesupport/modules/htmlUI/var/html/templates/editMetaData.tpl b/livesupport/modules/htmlUI/var/html/templates/editMetaData.tpl index 30ad68196..bd04bd416 100755 --- a/livesupport/modules/htmlUI/var/html/templates/editMetaData.tpl +++ b/livesupport/modules/htmlUI/var/html/templates/editMetaData.tpl @@ -31,12 +31,12 @@ function switchMDataLang() } function spread(element, name) -{ - if (document.forms['editMetaData'].elements['Main__' + name]) document.forms['editMetaData'].elements['Main__' + name].value = element.value; - if (document.forms['editMetaData'].elements['Music_Basic__' + name]) document.forms['editMetaData'].elements['Music_Basic__' + name].value = element.value; - if (document.forms['editMetaData'].elements['Music_Advanced__' + name]) document.forms['editMetaData'].elements['Music_Advanced__' + name].value = element.value; - if (document.forms['editMetaData'].elements['Talk_Basic__' + name]) document.forms['editMetaData'].elements['Talk_Basic__' + name].value = element.value; - if (document.forms['editMetaData'].elements['Talk_Advanced__' + name]) document.forms['editMetaData'].elements['Talk_Advanced__' + name].value = element.value; +{ + if (document.forms['editMetaData'].elements['Main___' + name]) document.forms['editMetaData'].elements['Main___' + name].value = element.value; + if (document.forms['editMetaData'].elements['Music_Basic___' + name]) document.forms['editMetaData'].elements['Music_Basic___' + name].value = element.value; + if (document.forms['editMetaData'].elements['Music_Advanced___' + name]) document.forms['editMetaData'].elements['Music_Advanced___' + name].value = element.value; + if (document.forms['editMetaData'].elements['Talk_Basic___' + name]) document.forms['editMetaData'].elements['Talk_Basic___' + name].value = element.value; + if (document.forms['editMetaData'].elements['Talk_Advanced___' + name]) document.forms['editMetaData'].elements['Talk_Advanced___' + name].value = element.value; } function showMain() diff --git a/livesupport/modules/htmlUI/var/html/templates/masterpanel.tpl b/livesupport/modules/htmlUI/var/html/templates/masterpanel.tpl index a9dee568c..d17a46130 100644 --- a/livesupport/modules/htmlUI/var/html/templates/masterpanel.tpl +++ b/livesupport/modules/htmlUI/var/html/templates/masterpanel.tpl @@ -44,7 +44,7 @@ {include file="editMetaData.tpl"} {/if} -{if $systemPrefs} +{if $editSystemPrefs} {include file="systemPrefs.tpl"} {/if} diff --git a/livesupport/modules/htmlUI/var/html/templates/objects.tpl b/livesupport/modules/htmlUI/var/html/templates/objects.tpl index 00339db30..b287dde8f 100644 --- a/livesupport/modules/htmlUI/var/html/templates/objects.tpl +++ b/livesupport/modules/htmlUI/var/html/templates/objects.tpl @@ -44,7 +44,7 @@  [Analyze]  [Edit]  [eMData] -  [SP] +  [SP] {/if}   diff --git a/livesupport/modules/htmlUI/var/html/templates/script/search.js.tpl b/livesupport/modules/htmlUI/var/html/templates/script/search.js.tpl index 7497dceb1..d45ec0e4e 100644 --- a/livesupport/modules/htmlUI/var/html/templates/script/search.js.tpl +++ b/livesupport/modules/htmlUI/var/html/templates/script/search.js.tpl @@ -1,17 +1,17 @@ diff --git a/livesupport/modules/htmlUI/var/html/templates/search.tpl b/livesupport/modules/htmlUI/var/html/templates/search.tpl index c44043151..bff59ccae 100644 --- a/livesupport/modules/htmlUI/var/html/templates/search.tpl +++ b/livesupport/modules/htmlUI/var/html/templates/search.tpl @@ -22,16 +22,16 @@ {if $showSearchRes}
- {if ( is_array($searchres.search))} + {if is_array($searchres)} - {foreach from=$searchres.search item=s} + {foreach from=$searchres item=s} diff --git a/livesupport/modules/htmlUI/var/html/ui_browser.php b/livesupport/modules/htmlUI/var/html/ui_browser.php index ee72b4082..9dc1ff1f8 100644 --- a/livesupport/modules/htmlUI/var/html/ui_browser.php +++ b/livesupport/modules/htmlUI/var/html/ui_browser.php @@ -99,13 +99,12 @@ if ($uiBrowser->userid) { case "search": - if($_REQUEST['doSearch']) { - $Smarty->assign('searchres', $uiBrowser->getSearchRes($uiBrwoser->id, $_REQUEST)); + if (is_array($uiBrowser->search['result']) ){ + $Smarty->assign('searchres', $uiBrowser->search['result']); $Smarty->assign('showSearchRes', TRUE); - } + }; - - $Smarty->assign('searchform', $uiBrowser->getSearchForm($uiBrowser->id, $_REQUEST, $ui_fmask)); + $Smarty->assign('searchform', $uiBrowser->getSearchForm($_REQUEST['id'], $ui_fmask)); $Smarty->assign('showSearchForm', TRUE); break; @@ -143,7 +142,7 @@ if ($uiBrowser->userid) { break; case "editMetaData": - $Smarty->assign('editMetaData', $uiBrowser->editMetaData($uiBrowser->id, $ui_fmask['editMetaData'], TRUE)); + $Smarty->assign('editMetaData', $uiBrowser->editMetaData($uiBrowser->id, $ui_fmask['metaData'], TRUE)); break; case "_analyzeFile": diff --git a/livesupport/modules/htmlUI/var/html/ui_handler.php b/livesupport/modules/htmlUI/var/html/ui_handler.php index f7cb1a389..6ba8db1a6 100644 --- a/livesupport/modules/htmlUI/var/html/ui_handler.php +++ b/livesupport/modules/htmlUI/var/html/ui_handler.php @@ -89,16 +89,16 @@ switch($_REQUEST['act']){ break; case "editMetaData": - $uiHandler->editMetaData($uiHandler->id, $_REQUEST, $ui_fmask["editMetaData"]); + $uiHandler->editMetaData($uiHandler->id, $_REQUEST, $ui_fmask["metaData"]); break; case "SP.addItem": - $uiHandler->SP->addItem($_REQUEST['SPid']); + $uiHandler->SP->addItem($_REQUEST['id']); $uiHandler->SP->setReload(); break; case "SP.removeItem": - $uiHandler->SP->removeItems($_REQUEST['SPid']); + $uiHandler->SP->removeItems($_REQUEST['id']); $uiHandler->SP->setReload(); break; @@ -107,6 +107,10 @@ switch($_REQUEST['act']){ $uiHandler->SP->setReload(); break; + case "search": + $uiHandler->search($_REQUEST); + break; + default: $_SESSION["alertMsg"] = tra("Unknown method: $1", $_REQUEST["act"]); header("Location: ".UI_BROWSER); diff --git a/livesupport/modules/htmlUI/var/ui_base.inc.php b/livesupport/modules/htmlUI/var/ui_base.inc.php index dd85033e3..85231f617 100644 --- a/livesupport/modules/htmlUI/var/ui_base.inc.php +++ b/livesupport/modules/htmlUI/var/ui_base.inc.php @@ -31,6 +31,28 @@ function tra($input) } +function _getDArr($format) +{ + #$arr[''] = '00'; + switch($format) { + case 'h': + for($n=0; $n<=23; $n++) { + $arr[$this->_twoDigits($n)] = $this->_twoDigits($n); + } + break; + + case 'm': + case 's': + for($n=0; $n<=59; $n++) { + $arr[$this->_twoDigits($n)] = $this->_twoDigits($n); + } + break; + } + + return $arr; +} + + /** * uiBase class * @@ -68,8 +90,9 @@ class uiBase $this->InputTextStandardAttrib = array('size' =>UI_INPUT_STANDARD_SIZE, 'maxlength'=>UI_INPUT_STANDARD_MAXLENGTH); - $this->SP =& new uiScratchPad(&$this); - $this->systemPrefs =& $_SESSION[UI_STATIONINFO_SESSNAME]; ; + $this->SP =& new uiScratchPad(&$this); + $this->systemPrefs =& $_SESSION[UI_STATIONINFO_SESSNAME]; + $this->search =& $_SESSION[UI_SEARCH_SESSNAME]; } @@ -250,28 +273,6 @@ class uiBase } - function _getDArr($format) - { - #$arr[''] = '00'; - switch($format) { - case 'h': - for($n=0; $n<=23; $n++) { - $arr[$this->_twoDigits($n)] = $this->_twoDigits($n); - } - break; - - case 'm': - case 's': - for($n=0; $n<=59; $n++) { - $arr[$this->_twoDigits($n)] = $this->_twoDigits($n); - } - break; - } - - return $arr; - } - - function _toHex($gunid) { $res = $this->dbc->query("SELECT to_hex($gunid)"); @@ -354,5 +355,21 @@ class uiBase } return TRUE; } + + + function _formElementEncode($str) + { + $str = str_replace(':', '__', $str); + $str = str_replace('.', '_', $str); + return $str; + } + + + function _formElementDecode($str) + { + $str = str_replace('__', ':', $str); + $str = str_replace('_', '.', $str); + return $str; + } } ?> \ No newline at end of file diff --git a/livesupport/modules/htmlUI/var/ui_browser.class.php b/livesupport/modules/htmlUI/var/ui_browser.class.php index 1d533bb1f..5f9a3ca4b 100644 --- a/livesupport/modules/htmlUI/var/ui_browser.class.php +++ b/livesupport/modules/htmlUI/var/ui_browser.class.php @@ -337,18 +337,18 @@ class uiBrowser extends uiBase { * * @return string (html) */ - function getSearchForm($id, &$formdata, &$mask) + function getSearchForm($id, &$mask) { - $form = new HTML_QuickForm('search', 'get', UI_BROWSER); - $form->setConstants(array('id'=>$id, 'counter'=>($formdata['counter'] ? $formdata['counter'] : UI_SEARCH_MIN_ROWS))); + $form = new HTML_QuickForm('search', UI_STANDARD_FORM_METHOD, UI_HANDLER); + $form->setConstants(array('id'=>$id, 'counter'=>UI_SEARCH_MIN_ROWS)); - foreach ($mask['mData']['tabs']['group']['group'] as $k=>$v) { - foreach ($mask['mData']['pages'][$v] as $val){ - $col1[$val['element']] = $val['element']; + foreach ($mask['metaData']['tabs']['group']['group'] as $k=>$v) { + foreach ($mask['metaData']['pages'][$v] as $val){ + $col1[$this->_formElementEncode($val['element'])] = $val['label']; if (isset($val['relation'])) - $col2[$val['element']] = $mask['relations'][$val['relation']]; + $col2[$this->_formElementEncode($val['element'])] = $mask['relations'][$val['relation']]; else - $col2[$val['element']] = $mask['relations']['standard']; + $col2[$this->_formElementEncode($val['element'])] = $mask['relations']['standard']; }; }; @@ -357,20 +357,18 @@ class uiBrowser extends uiBase { $form->addElement('static', 's1', NULL, "
"); - if ($n>($formdata['counter'] ? $formdata['counter'] : UI_SEARCH_MIN_ROWS)) $form->addElement('static', 's1_style', NULL, ""); + if ($n > UI_SEARCH_MIN_ROWS) $form->addElement('static', 's1_style', NULL, ""); $sel = &$form->createElement('hierselect', "row_$n", NULL); $sel->setOptions(array($col1, $col2)); $group[] = &$sel; - $group[] = &$form->createElement('text', 'row_'.$n.'[2]', NULL); - $group[] = &$form->createElement('button', "dropRow_$n", 'Drop', array('onClick' => "dropRow('$n')")); + $group[] = &$form->createElement('text', "row_$n".'[2]', NULL); + $group[] = &$form->createElement('button', "dropRow_$n", 'Drop', array('onClick' => "SearchForm_dropRow('$n')")); $form->addGroup($group); - $form->addElement('static', 's2', NULL, "
"); } - - $this->_parseArr2Form($form, $mask['searchform']); + $form->setConstants($this->search['criteria']); $form->validate(); $renderer =& new HTML_QuickForm_Renderer_Array(true, true); @@ -381,41 +379,6 @@ class uiBrowser extends uiBase { } - /** - * getSearchRes - * - * get Search Result - * - * @param $id int local ID (file/folder) to search in - * @param $serach string - * @return array - */ - function getSearchRes($id, &$formdata) - { - foreach ($formdata as $key=>$val) { - if (is_array($val) && strlen($val[2])) { - $critArr[] = array('cat' => $val[0], - 'op' => $val[1], - 'val' => $val[2] - ); - } - } - $searchCriteria = array('filetype' => $formdata['filetype'], - 'operator' => $formdata['operator'], - 'conditions'=> $critArr - ); - - $results = $this->gb->localSearch($searchCriteria, $this->sessid); - foreach ($results['results'] as $rec) { - $res[] = $this->_getMetaInfo($this->gb->_idFromGunid($rec)); - } - - return array('search' => $res, - 'id' => $id - ); - - } - /** * getFile * @@ -474,12 +437,12 @@ class uiBrowser extends uiBase { ## convert element names to be unique over different forms-parts, add javascript to spread values over parts, add existing values from database foreach ($mask['tabs']['group']['group'] as $key) { foreach ($mask['pages'][$key] as $k=>$v) { - $mask['pages'][$key][$k]['element'] = $key.'__'.$v['element']; - $mask['pages'][$key][$k]['attributes'] = array_merge($mask['pages'][$key][$k]['attributes'], array('onChange' => "spread(this, '".$v['element']."')")); + $mask['pages'][$key][$k]['element'] = $key.'___'.$this->_formElementEncode($v['element']); + $mask['pages'][$key][$k]['attributes'] = array_merge($mask['pages'][$key][$k]['attributes'], array('onChange' => "spread(this, '".$this->_formElementEncode($v['element'])."')")); ## recive data from GreenBox if ($get) { - $mask['pages'][$key][$k]['default'] = $this->_getMDataValue($id, strtr($v['element'], '_', '.')); + $mask['pages'][$key][$k]['default'] = $this->_getMDataValue($id, $v['element']); } ## get data from parameter diff --git a/livesupport/modules/htmlUI/var/ui_fmask.inc.php b/livesupport/modules/htmlUI/var/ui_fmask.inc.php index 676da9a95..0815f7e99 100644 --- a/livesupport/modules/htmlUI/var/ui_fmask.inc.php +++ b/livesupport/modules/htmlUI/var/ui_fmask.inc.php @@ -91,7 +91,7 @@ $ui_fmask = array( ), /* =========================================================== Matadata-Mask */ - 'editMetaData' => array( + 'metaData' => array( 'basics' => array( array( 'element' => 'act', @@ -225,19 +225,19 @@ $ui_fmask = array( array( 'element' => 'Format_Extent_h', 'type' => 'select', - 'options' => $uiBase->_getDArr('h'), + 'options' => getDArr('h'), 'groupit' => TRUE ), array( 'element' => 'Format_Extent_m', 'type' => 'select', - 'options' => $uiBase->_getDArr('m'), + 'options' => getDArr('m'), 'groupit' => TRUE ), array( 'element' => 'Format_Extent_s', 'type' => 'select', - 'options' => $uiBase->_getDArr('h'), + 'options' => getDArr('h'), 'groupit' => TRUE ), array( @@ -471,7 +471,6 @@ $ui_fmask = array( 'element' => 'dc:title', 'type' => 'text', 'label' => 'Title', - 'relation' => 1 ), array( 'element' => 'Coverage', @@ -792,23 +791,31 @@ $ui_fmask = array( 'options' => array( 'File' => '*', 'audioclip' => 'Audioclip', + 'webstream' => 'Webstream', 'playlist' => 'Playlist' ) ), + array( + 'element' => 'clear', + 'type' => 'button', + 'label' => 'Clear', + 'attributes' => array('onClick' => "hpopup('".UI_HANDLER."?act=search', 'SF')"), + 'groupit' => TRUE, + ), array( 'element' => 'addrow', 'type' => 'button', 'label' => 'One more Row', - 'attributes' => array('onClick' => 'addRow()'), + 'attributes' => array('onClick' => 'SearchForm_addRow()'), 'groupit' => TRUE, ), array( - 'element' => 'doSearch', + 'element' => 'submit', 'type' => 'submit', 'label' => 'Submit', 'groupit' => TRUE, ), - array('group' => array('addrow', 'doSearch') + array('group' => array('clear', 'addrow', 'submit') ), ), 'relations' => array( diff --git a/livesupport/modules/htmlUI/var/ui_handler.class.php b/livesupport/modules/htmlUI/var/ui_handler.class.php index a18b2de28..97443ed58 100644 --- a/livesupport/modules/htmlUI/var/ui_handler.class.php +++ b/livesupport/modules/htmlUI/var/ui_handler.class.php @@ -512,7 +512,7 @@ class uiHandler extends uiBase { foreach ($mask['tabs']['group']['group'] as $key) { foreach ($mask['pages'][$key] as $k=>$v) { - $formdata[$key.'__'.$v['element']] ? $mData[strtr($v['element'], '_', '.')] = $formdata[$key.'__'.$v['element']] : NULL; + $formdata[$key.'___'.$this->_formElementEncode($v['element'])] ? $mData[$this->_formElementDecode($v['element'])] = $formdata[$key.'___'.$this->_formElementEncode($v['element'])] : NULL; } } $data = $this->_dateArr2Str($mData); @@ -590,16 +590,42 @@ class uiHandler extends uiBase { } } - /* - function _isTextInput($input) - { - $test = array('text' =>0, 'textarea' =>0, 'select'=>0, 'radio'=>0, 'checkbox'=>0); - if (array_key_exists($input, $test)) - return TRUE; - return FALSE; + /** + * search + * + * get Search Result and tore them in session + * + * @param $id int local ID (file/folder) to search in + * @param $serach string + */ + function search(&$formdata) + { + $this->search = FALSE;; + $this->search['criteria']['operator'] = $formdata['operator']; + $this->search['criteria']['filetype'] = $formdata['filetype']; + + foreach ($formdata as $key=>$val) { + if (is_array($val) && strlen($val[2])) { + $critArr[] = array('cat' => $this->_formElementDecode($val[0]), + 'op' => $val[1], + 'val' => $val[2] + ); + $this->search['criteria'][$key] = $val; + } + } + $searchCriteria = array('filetype' => $formdata['filetype'], + 'operator' => $formdata['operator'], + 'conditions'=> $critArr + ); + + $results = $this->gb->localSearch($searchCriteria, $this->sessid); + foreach ($results['results'] as $rec) { + $this->search['result'][] = $this->_getMetaInfo($this->gb->_idFromGunid($rec)); + } + + $this->redirUrl = UI_BROWSER.'?act=search&id='.$formdata['id']; } - */ } ?> \ No newline at end of file
{tra 0=Title}{tra 0=Duration}
{$s.title} {$s.duration} [XML] [Form] - [SP] + [SP]