diff --git a/module/api/control.php b/module/api/control.php index a94ed749d2..6d002c717f 100755 --- a/module/api/control.php +++ b/module/api/control.php @@ -87,13 +87,24 @@ class api extends control $this->view->browseType = $browseType; $this->view->objectType = $objectType; $this->view->objectID = $objectID; - $this->view->libTree = $this->loadModel('doc')->getLibTree($libID, $libs, 'api', $objectID); + $this->view->libTree = $this->api->getLibTree($libID, $libs, $objectID); $this->view->users = $this->user->getPairs('noclosed,noletter'); $this->view->objectDropdown = $this->generateLibsDropMenu($libs[$libID], $release); $this->display(); } + /** + * View api. + * + * @param int $libID + * @param int $apiID + * @param int $moduleID + * @param int $release + * @param int $version + * @access public + * @return void + */ public function view($libID, $apiID, $moduleID = 0, $release = 0, $version = 0) { /* Get all api doc libraries. */ @@ -361,6 +372,8 @@ class api extends control */ public function createLib($type = 'product') { + if(empty($type)) $type = 'product'; + if(!empty($_POST)) { $libID = $this->doc->createApiLib(); diff --git a/module/api/model.php b/module/api/model.php index 2faf3916bf..a2206db76c 100644 --- a/module/api/model.php +++ b/module/api/model.php @@ -530,7 +530,7 @@ class apiModel extends model public function getReleaseByQuery($libID, $pager = '', $orderBy = '') { return $this->dao->select('*')->from(TABLE_API_LIB_RELEASE) - ->where('lib')->eq($libID) + ->where('lib')->in($libID) ->orderBy($orderBy) ->page($pager) ->fetchAll(); @@ -1036,4 +1036,36 @@ class apiModel extends model return array($normalObjects, $closedObjects); } + + /** + * Get lib tree. + * + * @param int $libID + * @param int $libs + * @param int $objectID + * @access public + * @return array + */ + public function getLibTree($libID, $libs, $objectID = 0) + { + $libTree = $this->loadModel('doc')->getLibTree($libID, $libs, 'api', $objectID); + $releases = $this->getReleaseByQuery(array_keys($libs), null, 'lib_asc, id_desc'); + + foreach($libTree as &$tree) + { + $tree->versions = array(); + $tree->lastVersion = ''; + foreach($releases as $index => $release) + { + if($tree->id == $release->lib) + { + if(empty($tree->versions)) $tree->lastVersion = $release->version; + + $tree->versions[] = $release->version; + unset($releases[$index]); + } + } + } + return $libTree; + } } diff --git a/module/api/view/index.html.php b/module/api/view/index.html.php index e9768ff457..e30f8c2de8 100644 --- a/module/api/view/index.html.php +++ b/module/api/view/index.html.php @@ -27,7 +27,7 @@ if(common::hasPriv('api', 'releases')) echo html::a($this->createLink('api', 'releases', "libID=$libID", 'html', true), " " . $lang->api->releases, '', "class='btn btn-link'"); if(common::hasPriv('api', 'createRelease')) echo html::a($this->createLink('api', 'createRelease', "libID=$libID", 'html', true), " " . $lang->api->createRelease, '', "class='btn btn-link iframe' data-width='800px'"); if(common::hasPriv('api', 'export')) echo html::a($this->createLink('api', 'export', "libID=$libID", 'html', true), " " . $lang->export, '', "class='btn btn-link export' id='export'"); - if(common::hasPriv('api', 'createLib')) echo html::a($this->createLink('api', 'createLib', "objectTpye=$objectType&objectID=$objectID"), ' ' . $lang->api->createLib, '', 'class="btn btn-secondary iframe" data-width="800px"'); + if(common::hasPriv('api', 'createLib')) echo html::a($this->createLink('api', 'createLib', "type=$objectType"), ' ' . $lang->api->createLib, '', 'class="btn btn-secondary iframe" data-width="800px"'); if(common::hasPriv('api', 'create')) echo html::a($this->createLink('api', 'create', "objectTpye=$objectType&objectID=$objectID"), ' ' . $lang->api->createApi, '', 'class="btn btn-primary"'); ?> @@ -38,7 +38,7 @@

doc->noLib;?> ' . $this->lang->doc->createLib, '', 'class="btn btn-info iframe"'); + if(common::hasPriv('api', 'createLib')) echo html::a(helper::createLink('api', 'createLib', "type=$objectType"), ' ' . $lang->api->createLib, '', 'class="btn btn-info iframe" data-width="800px"'); ?>