* Code review.

This commit is contained in:
liumengyi
2022-06-24 14:18:31 +08:00
parent 5b84f06092
commit 3cbc219ad5
10 changed files with 31 additions and 33 deletions
+8 -9
View File
@@ -28,12 +28,12 @@ class api extends control
* @param int $version
* @param int $release
* @param int $appendLib
* @param int $queryID
* @param string $param
* @param string $browseType
* @param int $param
* @access public
* @return void
*/
public function index($libID = 0, $moduleID = 0, $apiID = 0, $version = 0, $release = 0, $appendLib = 0, $queryID = 0, $param = '')
public function index($libID = 0, $moduleID = 0, $apiID = 0, $version = 0, $release = 0, $appendLib = 0, $browseType = '', $param = 0)
{
/* Get an api doc. */
if($apiID > 0)
@@ -76,14 +76,13 @@ class api extends control
$this->lang->TRActions = '<a class="btn btn-link querybox-toggle" id="bysearchTab"><i class="icon icon-search muted"></i> ' . $this->lang->api->search . '</a>' . $this->lang->TRActions;
/* Build the search form. */
$queryID = $param == 'bySearch' ? (int)$queryID : 0;
$actionURL = $this->createLink('api', 'index', "libID=$libID&moduleID=0&apiID=0&version=0&release=0&appendLib=0&queryID=myQueryID&param=bySearch");
$queryID = $browseType == 'bySearch' ? (int)$param : 0;
$actionURL = $this->createLink('api', 'index', "libID=$libID&moduleID=0&apiID=0&version=0&release=0&appendLib=0&browseType=bySearch&queryID=myQueryID");
$this->api->buildSearchForm($lib,$queryID, $actionURL);
if($param == 'bySearch')
if($browseType == 'bySearch')
{
$apiList = $this->api->getApiListBySearch($libID, $queryID);
$this->view->apiList = $apiList;
$this->view->apiList = $this->api->getApiListBySearch($libID, $queryID);
$this->view->typeList = $this->api->getTypeList($libID);
}
@@ -94,7 +93,7 @@ class api extends control
$this->view->libID = $libID;
$this->view->apiID = $apiID;
$this->view->libs = $libs;
$this->view->param = $param;
$this->view->browseType = $browseType;
$this->view->moduleTree = $libID ? $this->doc->getApiModuleTree($libID, $apiID, $release, $moduleID) : '';
$this->view->users = $this->user->getPairs('noclosed,noletter');
+4 -4
View File
@@ -907,11 +907,10 @@ class apiModel extends model
*/
public function buildSearchForm($lib, $queryID, $actionURL)
{
$lib = array($lib->id => $lib->name);
$this->config->api->search['module'] = 'api';
$this->config->api->search['queryID'] = $queryID;
$this->config->api->search['actionURL'] = $actionURL;
$this->config->api->search['params']['lib']['values'] = $lib + array('all' => $this->lang->api->allLibs);
$this->config->api->search['params']['lib']['values'] = array($lib->id => $lib->name) + array('all' => $this->lang->api->allLibs);
$this->loadModel('search')->setSearchParams($this->config->api->search);
}
@@ -945,11 +944,12 @@ class apiModel extends model
}
$apiQuery = $this->session->apiQuery;
$apiQuery = strpos($apiQuery, "`lib` = 'all'") === false ? "$apiQuery and lib = $libID" : str_replace("`lib` = 'all'", '1', $apiQuery);
$list = $this->dao->select('*')
->from(TABLE_API)
->where('deleted')->eq(0)
->andWhere(str_replace("`lib` = 'all'", '1', $apiQuery))
->beginIF(strpos($apiQuery, "`lib` = 'all'") === false)->andWhere('lib')->eq($libID)->fi()
->andWhere($apiQuery)
->fetchAll();
return $list;
+1 -1
View File
@@ -12,7 +12,7 @@
?>
<?php include '../../common/view/header.html.php';?>
<?php js::set('confirmDelete', $lang->api->confirmDelete);?>
<div class="cell<?php if($param == 'bySearch') echo ' show';?>" id="queryBox" data-module=<?php echo 'api';?>></div>
<div class="cell<?php if($browseType == 'bySearch') echo ' show';?>" id="queryBox" data-module=<?php echo 'api';?>></div>
<div class="fade main-row split-row" id="mainRow">
<?php if($libID):?>
<?php $sideWidth = common::checkNotCN() ? '270' : '238';?>
+10 -8
View File
@@ -1161,15 +1161,15 @@ class doc extends control
* @param string $type
* @param int $objectID
* @param int $libID
* @param int $queryID
* @param string $param
* @param string $browseType
* @param int $param
* @param int $recTotal
* @param int $recPerPage
* @param int $pageID
* @access public
* @return void
*/
public function tableContents($type, $objectID = 0, $libID = 0, $queryID = 0, $param = '', $recTotal = 0, $recPerPage = 20, $pageID = 1)
public function tableContents($type, $objectID = 0, $libID = 0, $browseType = '', $param = 0, $recTotal = 0, $recPerPage = 20, $pageID = 1)
{
list($libs, $libID, $object, $objectID) = $this->doc->setMenuByType($type, $objectID, $libID);
$this->session->set('createProjectLocate', $this->app->getURI(true), 'doc');
@@ -1181,16 +1181,16 @@ class doc extends control
$title = ($type == 'book' or $type == 'custom') ? $this->lang->doc->tableContents : $object->name . $this->lang->colon . $this->lang->doc->tableContents;
/* Build the search form. */
$queryID = $param == 'bySearch' ? (int)$queryID : 0;
$actionURL = $this->createLink('doc', 'tableContents', "type=$type&objectID=$objectID&libID=$libID&queryID=myQueryID&param=bySearch");
$queryID = $browseType == 'bySearch' ? (int)$param : 0;
$actionURL = $this->createLink('doc', 'tableContents', "type=$type&objectID=$objectID&libID=$libID&browseType=bySearch&param=myQueryID");
$this->doc->buildSearchForm($libID, $libs, $queryID, $actionURL, $type);
$this->view->title = $title;
$this->view->type = $type;
$this->view->param = $param;
$this->view->queryID = $queryID;
$this->view->browseType = $browseType;
$this->view->param = $queryID;
$this->view->users = $this->user->getPairs('noletter');
if($param == 'bySearch')
if($browseType == 'bySearch')
{
/* Load pager. */
$rawMethod = $this->app->rawMethod;
@@ -1238,6 +1238,8 @@ class doc extends control
/**
* Sort libs.
* @param string $type
* @param int $objectID
*
* @access public
* @return void
+1 -1
View File
@@ -9,7 +9,7 @@
.no-content-button a:nth-child(2) {margin-left: 20px;}
.cell .detail .detail-title {padding-left: 5px; list-style: none;}
.menu-actions {position: absolute; top: 7px; right: 45px; padding: 7px 8px;}
.menu-actions {position: relative; float: right; top: -34px; right: -15px; padding: 7px 8px;}
.detail ul {position: relative;}
.tail-info {position: absolute; right: 0; padding-left: 10px; padding-top: 1px;}
.tail-info, .doc-title, span.item {background: #fff;}
+1 -1
View File
@@ -34,7 +34,7 @@ $(function()
{
orders += $(this).attr('data-id') + ',';
});
$('#libs #libIdList').attr('value', orders);
$('#libIdList').attr('value', orders);
}
});
});
-4
View File
@@ -96,7 +96,3 @@ $(function()
}
});
})
$(document).on("click", '#bysearchTab', function()
{
$('.main-content > .cell > .detail > .menu-actions').remove();
});
+4 -4
View File
@@ -2411,8 +2411,8 @@ EOT;
}
if(count($libs) >= 2 and common::hasPriv('doc', 'sortLibs'))
{
$output .= '<li class="divider"></li>';
$output .= html::a(inlink('sortLibs', "type=$type&objectID=$objectID", '', true), "<i class='icon-move'></i> {$this->lang->doc->sortLibs}", '', "data-title='{$this->lang->doc->sortLibs}' data-toggle='modal' data-type='iframe' data-width='400px' data-app='{$this->app->tab}'");
$output .= '<li class="divider"></li>';
$output .= html::a(inlink('sortLibs', "type=$type&objectID=$objectID", '', true), "<i class='icon-move'></i> {$this->lang->doc->sortLibs}", '', "data-title='{$this->lang->doc->sortLibs}' data-toggle='modal' data-type='iframe' data-width='400px' data-app='{$this->app->tab}'");
}
$output .= "</div></div></div></div></div>";
}
@@ -2903,10 +2903,10 @@ EOT;
$libs = $this->getLibsByObject($type, $objectID);
$query = $this->session->$queryName;
$query = strpos($query, "`lib` = 'all'") === false ? "$query and lib = $libID" : str_replace("`lib` = 'all'", '1', $query);
$docs = $this->dao->select('*')->from(TABLE_DOC)
->where('deleted')->eq(0)
->andWhere(str_replace("`lib` = 'all'", '1', $query))
->beginIF(strpos($query, "`lib` = 'all'") === false)->andWhere('lib')->eq($libID)->fi()
->andWhere($query)
->andWhere('lib')->in(array_keys($libs))
->beginIF($this->config->doc->notArticleType)->andWhere('type')->notIN($this->config->doc->notArticleType)->fi()
->orderBy('id_desc')
+1
View File
@@ -26,6 +26,7 @@
<?php echo html::a($this->createLink('doc', 'view', "docID=$doc->id"), $doc->title, '', "title='$doc->title'");?>
<small> <?php echo $lang->arrow . ' ' . $lang->doc->edit;?></small>
</h2>
<div class='pull-right'><?php echo html::a('###', $lang->save, '', 'id="top-submit" class="btn btn-primary"');?></div>
</div>
<form class='load-indicator main-form form-ajax' method='post' enctype='multipart/form-data' id='dataform'>
<table class='table table-form'>
+1 -1
View File
@@ -28,7 +28,7 @@ if($this->methodName != 'browse')
}
if(empty($type)) $type = 'product';
?>
<div class="cell<?php if($param == 'bySearch') echo ' show';?>" id="queryBox" data-module=<?php echo $type . 'Doc';?>></div>
<div class="cell<?php if($browseType == 'bySearch') echo ' show';?>" id="queryBox" data-module=<?php echo $type . 'Doc';?>></div>
<div class="main-content">
<div class="cell" id="<?php echo $type;?>">
<div class="detail">