From 3cbc219ad5d163cbfabccaf576b318dae9275b49 Mon Sep 17 00:00:00 2001 From: liumengyi Date: Fri, 24 Jun 2022 14:18:31 +0800 Subject: [PATCH] * Code review. --- module/api/control.php | 17 ++++++++--------- module/api/model.php | 8 ++++---- module/api/view/index.html.php | 2 +- module/doc/control.php | 18 ++++++++++-------- module/doc/css/tablecontents.css | 2 +- module/doc/js/sortlibs.js | 2 +- module/doc/js/tablecontents.js | 4 ---- module/doc/model.php | 8 ++++---- module/doc/view/edit.html.php | 1 + module/doc/view/tablecontents.html.php | 2 +- 10 files changed, 31 insertions(+), 33 deletions(-) diff --git a/module/api/control.php b/module/api/control.php index 99dd6072c4..1301a1edee 100755 --- a/module/api/control.php +++ b/module/api/control.php @@ -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 = ' ' . $this->lang->api->search . '' . $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¶m=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'); diff --git a/module/api/model.php b/module/api/model.php index 31ce67d7f8..539132b98a 100644 --- a/module/api/model.php +++ b/module/api/model.php @@ -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; diff --git a/module/api/view/index.html.php b/module/api/view/index.html.php index c234ad623b..c20d0f8602 100644 --- a/module/api/view/index.html.php +++ b/module/api/view/index.html.php @@ -12,7 +12,7 @@ ?> api->confirmDelete);?> -
>
+
>
diff --git a/module/doc/control.php b/module/doc/control.php index 8f20746715..9a9f1ee051 100755 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -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¶m=bySearch"); + $queryID = $browseType == 'bySearch' ? (int)$param : 0; + $actionURL = $this->createLink('doc', 'tableContents', "type=$type&objectID=$objectID&libID=$libID&browseType=bySearch¶m=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 diff --git a/module/doc/css/tablecontents.css b/module/doc/css/tablecontents.css index 8e12dc7d0f..01fc3e2ab6 100644 --- a/module/doc/css/tablecontents.css +++ b/module/doc/css/tablecontents.css @@ -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;} diff --git a/module/doc/js/sortlibs.js b/module/doc/js/sortlibs.js index cede49cb80..7086d79cf0 100644 --- a/module/doc/js/sortlibs.js +++ b/module/doc/js/sortlibs.js @@ -34,7 +34,7 @@ $(function() { orders += $(this).attr('data-id') + ','; }); - $('#libs #libIdList').attr('value', orders); + $('#libIdList').attr('value', orders); } }); }); diff --git a/module/doc/js/tablecontents.js b/module/doc/js/tablecontents.js index 09bb656611..d11c77d92a 100644 --- a/module/doc/js/tablecontents.js +++ b/module/doc/js/tablecontents.js @@ -96,7 +96,3 @@ $(function() } }); }) -$(document).on("click", '#bysearchTab', function() -{ - $('.main-content > .cell > .detail > .menu-actions').remove(); -}); diff --git a/module/doc/model.php b/module/doc/model.php index 355551f50f..a35e816143 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -2411,8 +2411,8 @@ EOT; } if(count($libs) >= 2 and common::hasPriv('doc', 'sortLibs')) { - $output .= '
  • '; - $output .= html::a(inlink('sortLibs', "type=$type&objectID=$objectID", '', true), " {$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 .= '
  • '; + $output .= html::a(inlink('sortLibs', "type=$type&objectID=$objectID", '', true), " {$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 .= "
    "; } @@ -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') diff --git a/module/doc/view/edit.html.php b/module/doc/view/edit.html.php index 1db36a519b..e4ab46d201 100644 --- a/module/doc/view/edit.html.php +++ b/module/doc/view/edit.html.php @@ -26,6 +26,7 @@ createLink('doc', 'view', "docID=$doc->id"), $doc->title, '', "title='$doc->title'");?> arrow . ' ' . $lang->doc->edit;?> +
    save, '', 'id="top-submit" class="btn btn-primary"');?>
    diff --git a/module/doc/view/tablecontents.html.php b/module/doc/view/tablecontents.html.php index 5935ef3acf..5b0225f5de 100644 --- a/module/doc/view/tablecontents.html.php +++ b/module/doc/view/tablecontents.html.php @@ -28,7 +28,7 @@ if($this->methodName != 'browse') } if(empty($type)) $type = 'product'; ?> -
    >
    +
    >