From 8c6cddcd876430834d09b39ced4d60cf1d5d66e8 Mon Sep 17 00:00:00 2001 From: naomiaro Date: Wed, 25 Aug 2010 12:06:47 -0700 Subject: [PATCH] CC-1152 added refresh button to refresh the meta data and rerun the search. --- src/modules/getid3/var/module.tag.id3v2.php | 4 +- .../htmlUI/var/formmask/generic.inc.php | 5 +- src/modules/htmlUI/var/html/ui_browser.php | 2 - src/modules/htmlUI/var/html/ui_handler.php | 4 + .../htmlUI/var/templates/library/main.tpl | 35 ++++++++ src/modules/htmlUI/var/ui_browse.class.php | 79 ++++++++++++++++--- 6 files changed, 112 insertions(+), 17 deletions(-) diff --git a/src/modules/getid3/var/module.tag.id3v2.php b/src/modules/getid3/var/module.tag.id3v2.php index 397671141..d9cc4b49e 100644 --- a/src/modules/getid3/var/module.tag.id3v2.php +++ b/src/modules/getid3/var/module.tag.id3v2.php @@ -429,7 +429,7 @@ class getid3_id3v2 } } - if (!isset($thisfile_id3v2['comments']['year']) && ereg('^([0-9]{4})', trim(@$thisfile_id3v2['comments']['recording_time'][0]), $matches)) { + if (!isset($thisfile_id3v2['comments']['year']) && preg_match('/^([0-9]{4})/', trim(@$thisfile_id3v2['comments']['recording_time'][0]), $matches)) { $thisfile_id3v2['comments']['year'] = array($matches[1]); } @@ -461,7 +461,7 @@ class getid3_id3v2 $unprocessed = substr($unprocessed, $endpos + 1); } unset($unprocessed); - } elseif (eregi('^([0-9]+|CR|RX)$', $genrestring)) { + } elseif (preg_match('/^([0-9]+|CR|RX)$/', $genrestring)) { // some tagging program (including some that use TagLib) fail to include null byte after numeric genre $genrestring = '('.$genrestring.')'; } diff --git a/src/modules/htmlUI/var/formmask/generic.inc.php b/src/modules/htmlUI/var/formmask/generic.inc.php index 23c43151a..2de204d62 100644 --- a/src/modules/htmlUI/var/formmask/generic.inc.php +++ b/src/modules/htmlUI/var/formmask/generic.inc.php @@ -32,7 +32,7 @@ $ui_fmask = array( 'isPref' => TRUE, 'type' => 'hidden', 'label' => 'Station logo path', - 'default' => 'img/stationlogo.image', + 'default' => 'img/logo.png', 'required' => TRUE, ), array( @@ -440,7 +440,7 @@ $ui_fmask = array( 'attributes'=> array( 'onChange' => 'this.form.act.value="'.$tmpAct.'.setCategory"; this.form.submit()', 'style' => 'width: 180px;', - 'id' => 'category_1' + 'id' => 'category_' ) ), 'value' => array( @@ -450,6 +450,7 @@ $ui_fmask = array( 'attributes'=> array( 'size' => 10, 'class' => 'area_browse', + 'id' => 'category_value_', 'onChange' => 'this.form.act.value="'.$tmpAct.'.setValue"; this.form.submit()' ) ) diff --git a/src/modules/htmlUI/var/html/ui_browser.php b/src/modules/htmlUI/var/html/ui_browser.php index afcf1af15..99b8c3558 100644 --- a/src/modules/htmlUI/var/html/ui_browser.php +++ b/src/modules/htmlUI/var/html/ui_browser.php @@ -341,8 +341,6 @@ if ($uiBrowser->userid) { break; case "HUBBROWSE": - //$HUBBROWSE = new uiHubBrowse($uiBrowser); - //$Smarty->assign('hubBrowseForm', $HUBBROWSE->browseForm($uiBrowser->id, $ui_fmask)); $Smarty->assign('hubBrowseForm', $uiBrowser->HUBBROWSE->browseForm($uiBrowser->id, $ui_fmask)); $Smarty->assign('showLibrary', TRUE); $Smarty->assign('isHub', TRUE); diff --git a/src/modules/htmlUI/var/html/ui_handler.php b/src/modules/htmlUI/var/html/ui_handler.php index 9e6978ba7..88059c045 100644 --- a/src/modules/htmlUI/var/html/ui_handler.php +++ b/src/modules/htmlUI/var/html/ui_handler.php @@ -144,6 +144,10 @@ switch ($_REQUEST['act']) { case "SEARCH.setOffset": $uiHandler->SEARCH->setOffset($_REQUEST['page']); break; + + case "BROWSE.refresh": + $uiHandler->BROWSE->refresh($_REQUEST); + break; case "BROWSE.setCategory": $uiHandler->BROWSE->setCategory($_REQUEST); diff --git a/src/modules/htmlUI/var/templates/library/main.tpl b/src/modules/htmlUI/var/templates/library/main.tpl index 1fa2ddde9..b6d185ccf 100644 --- a/src/modules/htmlUI/var/templates/library/main.tpl +++ b/src/modules/htmlUI/var/templates/library/main.tpl @@ -42,6 +42,41 @@

##Browse##

+ + {literal} + + {/literal} + +
+ + + + + + + + +
+ {assign var="_act_prefix" value="BROWSE"} {include file="library/browseForm.tpl"} {BROWSE->getResult assign=_results} diff --git a/src/modules/htmlUI/var/ui_browse.class.php b/src/modules/htmlUI/var/ui_browse.class.php index 3f45436b6..4be845b22 100644 --- a/src/modules/htmlUI/var/ui_browse.class.php +++ b/src/modules/htmlUI/var/ui_browse.class.php @@ -117,8 +117,8 @@ class uiBrowse * @return array */ public function getCriteria() - { - return $this->criteria; + { + return $this->criteria; } // fn getCriteria @@ -128,7 +128,7 @@ class uiBrowse public function getResult() { $this->searchDB(); - return $this->results; + return $this->results; } // fn getResult @@ -140,16 +140,21 @@ class uiBrowse if (isset($v['type']) && $v['type']) { $tmp = uiBase::formElementEncode($v['element']); $mask2['browse_columns']['category']['options'][$tmp] = tra($v['label']); + } } } - + for ($n = 1; $n <= 3; $n++) { $form = new HTML_QuickForm('col'.$n, UI_STANDARD_FORM_METHOD, UI_HANDLER); $form->setConstants(array('id' => $id, 'col' => $n, 'category' => uiBase::formElementEncode($this->col[$n]['category']))); + $mask2['browse_columns']['value']['options'] = $this->options($this->col[$n]['values']['results']); + $mask2['browse_columns']['category']['attributes']['id'] = "category_" . $n; + $mask2['browse_columns']['value']['attributes']['id'] = "category_value_" . $n; + $mask2['browse_columns']['value']['default'] = $this->col[$n]['form_value']; uiBase::parseArrayToForm($form, $mask2['browse_columns']); $form->validate(); @@ -170,7 +175,6 @@ class uiBrowse return $output; } // fn browseForm - /** * Set the category for audio file browser. There are three columns * you can set the category for. All columns greater than the current @@ -182,7 +186,7 @@ class uiBrowse * string ['category'] - the category for the given column * @return void */ - public function setCategory($p_param) + public function setCategory($p_param, $redirect="true") { // input values $columnNumber = $p_param['col']; @@ -205,7 +209,7 @@ class uiBrowse // way too many values. $tmpCriteria["limit"] = 1000; $tmpCriteria["offset"] = 0; - + // For this column and all columns above this one, // reload the values. for ($i = $columnNumber; $i <= 3; $i++) { @@ -217,7 +221,9 @@ class uiBrowse $browseValues = null; } - $this->Base->redirUrl = UI_BROWSER.'?act='.$this->prefix; + if($redirect) { + $this->Base->redirUrl = UI_BROWSER.'?act='.$this->prefix; + } } // fn setCategory @@ -234,10 +240,10 @@ class uiBrowse * See the top of that file for a description of the search * criteria structure. */ - public function setValue($p_param) + public function setValue($p_param, $redirect="true") { $columnNumber = $p_param['col']; - $value = $p_param['value'][0]; + $value = $p_param['value'][0]; $category = $p_param['category']; $this->criteria['offset'] = 0; @@ -275,9 +281,60 @@ class uiBrowse $this->col[$tmpColNum]['values'] = $browseValues; } } - $this->Base->redirUrl = UI_BROWSER.'?act='.$this->prefix; + + if($redirect) { + $this->Base->redirUrl = UI_BROWSER.'?act='.$this->prefix; + } } // fn setValue + public function refresh($p_param){ + $category_1 = array( + 'col' => 1, + 'category' => $p_param['cat1'] + ); + + $value_1 = array( + 'col' => 1, + 'category' => $p_param['cat1'], + 'value' => array( + 0 => $p_param['val1'] + ) + ); + + $category_2 = array( + 'col' => 2, + 'category' => $p_param['cat2'] + ); + + $value_2 = array( + 'col' => 2, + 'category' => $p_param['cat2'], + 'value' => array( + 0 => $p_param['val2'] + ) + ); + + $category_3 = array( + 'col' => 3, + 'category' => $p_param['cat3'] + ); + + $value_3 = array( + 'col' => 3, + 'category' => $p_param['cat3'], + 'value' => array( + 0 => $p_param['val3'] + ) + ); + + $this->setCategory($category_1, false); + $this->setCategory($category_2, false); + $this->setCategory($category_3, false); + + $this->setValue($value_1, false); + $this->setValue($value_2, false); + $this->setValue($value_3, true); + } /** * Given an array of category values, prepare the array for display: