* Modify tree data.

This commit is contained in:
caoyanyi
2023-03-28 17:07:18 +08:00
parent 68bbb4471f
commit 3829a3232b
3 changed files with 49 additions and 4 deletions
+14 -1
View File
@@ -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();
+33 -1
View File
@@ -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;
}
}
+2 -2
View File
@@ -27,7 +27,7 @@
if(common::hasPriv('api', 'releases')) echo html::a($this->createLink('api', 'releases', "libID=$libID", 'html', true), "<i class='icon-version muted'> </i>" . $lang->api->releases, '', "class='btn btn-link'");
if(common::hasPriv('api', 'createRelease')) echo html::a($this->createLink('api', 'createRelease', "libID=$libID", 'html', true), "<i class='icon-publish muted'> </i>" . $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), "<i class='icon-export muted'> </i>" . $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"), '<i class="icon icon-plus"></i> ' . $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"), '<i class="icon icon-plus"></i> ' . $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"), '<i class="icon icon-plus"></i> ' . $lang->api->createApi, '', 'class="btn btn-primary"');
?>
</div>
@@ -38,7 +38,7 @@
<p>
<span class="text-muted"><?php echo $lang->doc->noLib;?></span>
<?php
echo html::a(helper::createLink('doc', 'createLib', "type=$objectType&objectID=$objectID"), '<i class="icon icon-plus"></i> ' . $this->lang->doc->createLib, '', 'class="btn btn-info iframe"');
if(common::hasPriv('api', 'createLib')) echo html::a(helper::createLink('api', 'createLib', "type=$objectType"), '<i class="icon icon-plus"></i> ' . $lang->api->createLib, '', 'class="btn btn-info iframe" data-width="800px"');
?>
</p>
</div>