From 5cbf6e74edff94f1b1478bbf6bf4b961bdafee8b Mon Sep 17 00:00:00 2001 From: wangyidong Date: Sat, 30 Apr 2011 05:28:30 +0000 Subject: [PATCH] * adjust ajaxGetOptionMenu and delete ajaxGetModules method. --- module/tree/control.php | 41 ++++++++++---------------------- module/tree/js/browse.js | 2 +- module/tree/view/browse.html.php | 2 +- 3 files changed, 15 insertions(+), 30 deletions(-) diff --git a/module/tree/control.php b/module/tree/control.php index 64709381f7..87d9335f8f 100644 --- a/module/tree/control.php +++ b/module/tree/control.php @@ -52,20 +52,17 @@ class tree extends control if($viewType == 'story') { + $this->lang->set('menugroup.tree', 'product'); + $this->product->setMenu($this->product->getPairs(), $rootID, 'story'); $products = $this->product->getPairs(); - $allProduct = array(); - foreach($products as $key => $productVal) - { - if($key == $rootID) continue; - $allProduct[$key] = $productVal; - } - $this->view->allProduct =$allProduct; - $keys = array_keys($allProduct); - $this->view->key = $keys[0]; - $this->view->productModules = $this->tree->getOptionMenu($keys[0], 'story'); - $this->lang->tree->menu = $this->lang->product->menu; - $this->lang->set('menugroup.tree', 'product'); + unset($products[$rootID]); + $key = key($products); + + $this->view->allProduct = $products; + $this->view->key = $key; + $this->view->productModules = $this->tree->getOptionMenu($key, 'story'); + $this->lang->tree->menu = $this->lang->product->menu; $header['title'] = $this->lang->tree->manageProduct . $this->lang->colon . $product->name; $position[] = html::a($this->createLink('product', 'browse', "product=$rootID"), $product->name); @@ -209,12 +206,13 @@ class tree extends control * @access public * @return string the html select string. */ - public function ajaxGetOptionMenu($rootID, $viewType = 'story', $rootModuleID = 0) + public function ajaxGetOptionMenu($rootID, $viewType = 'story', $rootModuleID = 0, $returnType = 'html') { - $this->view->productModules = $this->tree->getOptionMenu($rootID, 'story'); + $this->view->productModules = $this->tree->getOptionMenu($rootID, 'story'); $optionMenu = $this->tree->getOptionMenu($rootID, $viewType, $rootModuleID); - die( html::select("module", $optionMenu, '', 'onchange=setAssignedTo()')); + if($returnType == 'html') die( html::select("module", $optionMenu, '', 'onchange=setAssignedTo()')); + if($returnType == 'json') die(json_encode($optionMenu)); } /** @@ -236,17 +234,4 @@ class tree extends control foreach($modules as $key => $name) $modules[$key] = str_replace(" "," ","$name"); die(json_encode($modules)); } - /** - * AJAX: get modules. - * - * @param int $moduleID - * @param int $rootID - * @access public - * @return string json_encoded modules. - */ - public function ajaxGetModules($rootID = 0, $type='story') - { - $modules = $this->tree->getOptionMenu($rootID, 'story'); - die(json_encode($modules)); - } } diff --git a/module/tree/js/browse.js b/module/tree/js/browse.js index 7b821d7b75..e63455bede 100644 --- a/module/tree/js/browse.js +++ b/module/tree/js/browse.js @@ -22,7 +22,7 @@ function syncModule(rootID) function syncProduct(obj) { - link = createLink('tree', 'ajaxGetModules', 'rootID=' + obj.value); + link = createLink('tree', 'ajaxGetOptionMenu', 'rootID=' + obj.value + "&viewType=story&rootModuleID=0&returnType=json"); $.getJSON(link, function(modules) { $('.helplink').addClass('hidden'); diff --git a/module/tree/view/browse.html.php b/module/tree/view/browse.html.php index 5b1d54c1ae..6e4800d603 100644 --- a/module/tree/view/browse.html.php +++ b/module/tree/view/browse.html.php @@ -59,7 +59,7 @@ } else if($viewType == 'story') { - echo html::select('allProduct', $allProduct, 'onchange=syncProduct(this)'); + echo html::select('allProduct', $allProduct, '', 'onchange=syncProduct(this)'); echo html::select('productModule', $productModules, ''); echo html::commonButton($lang->tree->syncFromProduct, 'id=copyModule onclick=syncModule('.$key.')'); echo '
';