This commit is contained in:
tianshujie
2023-03-23 16:17:47 +08:00
parent 9fec0d5890
commit dc4a0cc915
4 changed files with 34 additions and 11 deletions
+5 -1
View File
@@ -1288,7 +1288,6 @@ class doc extends control
$pager = new pager($recTotal, $recPerPage, $pageID);
$this->app->rawMethod = $rawMethod;
$this->view->libID = $libID;
if($libType == 'api')
{
$this->loadModel('api');
@@ -1306,12 +1305,16 @@ class doc extends control
$this->view->docs = $browseType == 'bySearch' ? $this->doc->getDocsBySearch($type, $objectID, $libID, $queryID, $orderBy, $pager) : $this->doc->getDocs($libID, $moduleID, $orderBy, $pager);
}
$apiObjectType = $type == 'product' || $type == 'project' ? $type : '';
$apiObjectID = $apiObjectType ? $objectID : 0;
$this->view->title = $title;
$this->view->type = $type;
$this->view->browseType = $browseType;
$this->view->param = $queryID;
$this->view->users = $this->user->getPairs('noletter');
$this->view->libTree = $libTree;
$this->view->libID = $libID;
$this->view->moduleID = $moduleID;
$this->view->objectDropdown = $objectDropdown;
$this->view->libType = $libType;
@@ -1320,6 +1323,7 @@ class doc extends control
$this->view->orderBy = $orderBy;
$this->view->exportMethod = $type . '2export';
$this->view->canExport = common::hasPriv('doc', $type . '2export');
$this->view->apiLibs = $this->doc->getApiLibs(0, $apiObjectType, $apiObjectID);
$this->display();
}
+5 -2
View File
@@ -39,17 +39,20 @@ class docModel extends model
* Get api Libraries.
*
* @param int $appendLib
* @param string $appendLib
* @param int $objectID
* @return array
* @author thanatos thanatos915@163.com
*/
public function getApiLibs($appendLib = 0)
public function getApiLibs($appendLib = 0, $objectType = '', $objectID = 0)
{
$libs = $this->dao->select('*')->from(TABLE_DOCLIB)
->where('deleted')->eq(0)
->andWhere('type')->eq('api')
->beginIF(!empty($appendLib))->orWhere('id')->eq($appendLib)->fi()
->beginIF(!empty($objectType))->andWhere($objectType)->eq($objectID)->fi()
->orderBy('`order`_asc, id_desc')
->fetchAll('id');
$libs = array_filter($libs, array($this, 'checkPrivLib'));
return $libs;
}
+12 -4
View File
@@ -27,7 +27,7 @@
<p>
<span class="text-muted"><?php echo $lang->doc->noDoc;?></span>
<?php
if(common::hasPriv('doc', 'create') and $browseType != 'bySearch')
if($browseType != 'bySearch' and (common::hasPriv('doc', 'create') or (common::hasPriv('api', 'create') and !empty($apiLibs))))
{
if($libID)
{
@@ -36,22 +36,30 @@
$html .= "<button type='button' class='btn btn-info dropdown-toggle' data-toggle='dropdown'><span class='caret'></span></button>";
$html .= "<ul class='dropdown-menu pull-right'>";
$apiLibID = key($apiLibs);
foreach($this->lang->doc->createList as $typeKey => $typeName)
{
if($config->edition != 'max' and $typeKey == 'template') continue;
if($typeKey == 'api' and (!common::hasPriv('api', 'create') or empty($apiLibs))) continue;
if($typeKey != 'api' and !common::hasPriv('doc', 'create')) continue;
$class = (strpos($this->config->doc->officeTypes, $typeKey) !== false or strpos($this->config->doc->textTypes, $typeKey) !== false) ? 'iframe' : '';
$module = $typeKey == 'api' ? 'api' : 'doc';
$method = strpos($this->config->doc->textTypes, $typeKey) !== false ? 'createBasicInfo' : 'create';
$params = "objectType=$type&objectID=$objectID&libID=$libID&moduleID=$moduleID&type=$typeKey";
if($typeKey == 'api') $params = "libID=$libID&moduleID=$moduleID";
if($typeKey == 'api') $params = "libID=$apiLibID&moduleID=$moduleID";
if($typeKey == 'template') $params = "objectType=$type&objectID=$objectID&libID=$libID&moduleID=$moduleID&type=html&fromGlobal=&from=template";
$html .= "<li>";
$html .= html::a(helper::createLink($module, $method, $params, '', $class ? true : false), $typeName, '', "class='$class' data-app='{$this->app->tab}'");
$html .= "</li>";
if($typeKey == 'template') $html .= '<li class="divider"></li>';
if($config->edition != 'max' and $typeKey == 'api') $html .= '<li class="divider"></li>';
$printDivider = false;
if($typeKey == 'template') $printDivider = true;
if($config->edition != 'max' and $typeKey == 'api') $printDivider = true;
if($config->edition != 'max' and empty($apiLibs) and $typeKey == 'html') $printDivider = true;
if($printDivider) $html .= '<li class="divider"></li>';
}
$html .= '</ul></div>';
+12 -4
View File
@@ -33,7 +33,7 @@
echo html::a(helper::createLink('doc', 'createLib', "type=$type&objectID=$objectID"), '<i class="icon icon-plus"></i> ' . $this->lang->doc->createLib, '', 'class="btn btn-secondary iframe"');
}
if(common::hasPriv('doc', 'create'))
if(common::hasPriv('doc', 'create') or (common::hasPriv('api', 'create') and !empty($apiLibs)))
{
if($libID)
{
@@ -42,22 +42,30 @@
$html .= "<button type='button' class='btn btn-primary dropdown-toggle' data-toggle='dropdown'><span class='caret'></span></button>";
$html .= "<ul class='dropdown-menu pull-right'>";
$apiLibID = key($apiLibs);
foreach($this->lang->doc->createList as $typeKey => $typeName)
{
if($config->edition != 'max' and $typeKey == 'template') continue;
if($typeKey == 'api' and (!common::hasPriv('api', 'create') or empty($apiLibs))) continue;
if($typeKey != 'api' and !common::hasPriv('doc', 'create')) continue;
$class = (strpos($this->config->doc->officeTypes, $typeKey) !== false or strpos($this->config->doc->textTypes, $typeKey) !== false) ? 'iframe' : '';
$module = $typeKey == 'api' ? 'api' : 'doc';
$method = strpos($this->config->doc->textTypes, $typeKey) !== false ? 'createBasicInfo' : 'create';
$params = "objectType=$type&objectID=$objectID&libID=$libID&moduleID=$moduleID&type=$typeKey";
if($typeKey == 'api') $params = "libID=$libID&moduleID=$moduleID";
if($typeKey == 'api') $params = "libID=$apiLibID&moduleID=$moduleID";
if($typeKey == 'template') $params = "objectType=$type&objectID=$objectID&libID=$libID&moduleID=$moduleID&type=html&fromGlobal=&from=template";
$html .= "<li>";
$html .= html::a(helper::createLink($module, $method, $params, '', $class ? true : false), $typeName, '', "class='$class' data-app='{$this->app->tab}'");
$html .= "</li>";
if($typeKey == 'template') $html .= '<li class="divider"></li>';
if($config->edition != 'max' and $typeKey == 'api') $html .= '<li class="divider"></li>';
$printDivider = false;
if($typeKey == 'template') $printDivider = true;
if($config->edition != 'max' and $typeKey == 'api') $printDivider = true;
if($config->edition != 'max' and empty($apiLibs) and $typeKey == 'html') $printDivider = true;
if($printDivider) $html .= '<li class="divider"></li>';
}
$html .= '</ul></div>';