diff --git a/module/api/control.php b/module/api/control.php index c71276c010..6c10a1a171 100755 --- a/module/api/control.php +++ b/module/api/control.php @@ -78,7 +78,7 @@ class api extends control $this->view->libID = $libID; $this->view->apiID = $apiID; $this->view->libs = $libs; - $this->view->moduleTree = $libID ? $this->doc->getApiModuleTree($libID, $apiID, 0, $moduleID) : ''; + $this->view->moduleTree = $libID ? $this->doc->getApiModuleTree($libID, $apiID, $release, $moduleID) : ''; $this->view->users = $this->user->getPairs('noclosed,noletter'); $this->display(); @@ -170,6 +170,8 @@ class api extends control /** * Api doc global struct page. * + * @param int $libID + * @param int $releaseID * @param string $orderBy * @param int $recTotal * @param int $recPerPage @@ -177,25 +179,34 @@ class api extends control * @access public * @return void */ - public function struct($libID = 0, $orderBy = 'id', $recTotal = 0, $recPerPage = 15, $pageID = 1) + public function struct($libID = 0, $releaseID = 0, $orderBy = 'id', $recTotal = 0, $recPerPage = 15, $pageID = 1) { $libs = $this->doc->getApiLibs(); $this->app->loadClass('pager', $static = true); - $this->lang->modulePageNav = $this->generateLibsDropMenu($libs, $libID); + $this->lang->modulePageNav = $this->generateLibsDropMenu($libs, $libID, $releaseID); $pager = new pager($recTotal, $recPerPage, $pageID); /* Append id for secend sort. */ $sort = common::appendOrder($orderBy); - $structs = $this->api->getStructByQuery($libID, $pager, $sort); + if($releaseID) + { + $release = $this->api->getRelease($libID, 'byId', $releaseID); + $structs = $this->api->getStructListByRelease($release, '1 = 1 ', $sort); + } + else + { + $structs = $this->api->getStructByQuery($libID, $pager, $sort); + } common::setMenuVars('doc', $libID); - $this->view->libID = $libID; - $this->view->structs = $structs; - $this->view->orderBy = $orderBy; - $this->view->title = $this->lang->api->struct; - $this->view->pager = $pager; + $this->view->libID = $libID; + $this->view->releaseID = $releaseID; + $this->view->structs = $structs; + $this->view->orderBy = $orderBy; + $this->view->title = $this->lang->api->struct; + $this->view->pager = $pager; $this->display(); } @@ -641,6 +652,8 @@ class api extends control if(empty($libs)) return ''; if(!isset($libs[$libID])) return ''; + $methodName = $this->app->rawMethod; + $libName = $libs[$libID]->name; $output = << @@ -659,7 +672,7 @@ EOT; foreach($libs as $key => $lib) { $selected = $key == $libID ? 'selected' : ''; - $output .= html::a(inlink('index', "libID=$key"), $lib->name, '', "class='$selected' data-app='{$this->app->tab}'"); + $output .= html::a(inlink($methodName, "libID=$key"), $lib->name, '', "class='$selected' data-app='{$this->app->tab}'"); } $output .= ""; @@ -682,12 +695,13 @@ EOT;
EOT; + $params = $methodName == 'index' ? "libID=$libID&moduleID=0&apiID=0&version=0" : "libID=$libID"; $selected = $version > 0 ? '' : 'selected'; - $output .= html::a(inlink('index', "libID=$libID&moduleID=0&apiID=0&version=0&release=0"), $this->lang->api->defaultVersion, '', "class='$selected'"); + $output .= html::a(inlink($methodName, $params . "&release=0"), $this->lang->api->defaultVersion, '', "class='$selected'"); foreach($versions as $key => $item) { $selected = $key == $version ? 'selected' : ''; - $output .= html::a(inlink('index', "libID=$libID&moduleID=0&apiID=0&version=0&release=$key"), $item->version, '', "class='$selected' data-app='{$this->app->tab}'"); + $output .= html::a(inlink($methodName, $params . "&release=$key"), $item->version, '', "class='$selected' data-app='{$this->app->tab}'"); } $output .= "
"; } diff --git a/module/api/model.php b/module/api/model.php index c9711dc67a..8b8c7e6a53 100644 --- a/module/api/model.php +++ b/module/api/model.php @@ -28,7 +28,9 @@ class apiModel extends model const PARAMS_TYPE_CUSTOM = 'custom'; /** - * @param object $data + * Create release. + * + * @param object $data * @access public * @return int */ @@ -370,7 +372,7 @@ class apiModel extends model * @access public * @return array */ - public function getApiListByRelease($release, $where = '') + public function getApiListByRelease($release, $where = '1 = 1 ') { $strJoin = array(); foreach($release->snap['apis'] as $api) @@ -483,6 +485,33 @@ class apiModel extends model ->fetchAll(); } + /** + * Get struct list by release. + * + * @param object $release + * @param string $where + * @param string $orderBy + * @access public + * @return array + */ + public function getStructListByRelease($release, $where = '1 = 1 ', $orderBy = 'id') + { + $strJoin = array(); + foreach($release->snap['structs'] as $struct) + { + $strJoin[] = "(object.id = {$struct['id']} and spec.version = {$struct['version']} )"; + } + + if($strJoin) $where .= 'and (' . implode(' or ', $strJoin) . ')'; + $list = $this->dao->select('object.lib,spec.name,spec.type,spec.desc,spec.attribute,spec.version,spec.addedBy,spec.addedDate,object.id,user.realname as addedName')->from(TABLE_APISTRUCT)->alias('object') + ->leftJoin(TABLE_APISTRUCT_SPEC)->alias('spec')->on('object.name = spec.name') + ->leftJoin(TABLE_USER)->alias('user')->on('user.account = spec.addedBy') + ->where($where) + ->orderBy($orderBy) + ->fetchAll(); + return $list; + } + /** * @param int $libID * @param string $pager diff --git a/module/api/view/struct.html.php b/module/api/view/struct.html.php index f1983a737b..15d5f30b6c 100644 --- a/module/api/view/struct.html.php +++ b/module/api/view/struct.html.php @@ -30,7 +30,7 @@ - recTotal}&recPerPage={$pager->recPerPage}";?> + recTotal}&recPerPage={$pager->recPerPage}";?> diff --git a/module/doc/model.php b/module/doc/model.php index f30ebb9f37..14742af383 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -2267,7 +2267,7 @@ EOT; if($release) { - $rel = $this->api->getReleaseById($release); + $rel = $this->api->getRelease($rootID, 'byId', $release); $docs = $this->api->getApiListByRelease($rel); } else @@ -2288,7 +2288,7 @@ EOT; $treeMenu = array(); if($release) { - foreach($release->snap['modules'] as $module) + foreach($rel->snap['modules'] as $module) { $this->buildTree($treeMenu, 'api', 0, $rootID, $module, $moduleDocs, $docID, $moduleID); }
idAB);?> api->structType);?> api->structName;?>