This commit is contained in:
tianshujie
2023-03-24 11:29:31 +08:00
parent baa6921905
commit 852cedea13
6 changed files with 75 additions and 81 deletions
+2
View File
@@ -480,6 +480,8 @@ class api extends control
if($api === false) return $this->sendError(dao::getError());
$this->action->create('api', $api->id, 'Created');
if(isonlybody()) return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'parent'));
return $this->sendSuccess(array('locate' => helper::createLink('api', 'index', "libID={$api->lib}&moduleID=0&apiID={$api->id}")));
}
+2 -1
View File
@@ -1303,6 +1303,7 @@ class doc extends control
$apiObjectType = $type == 'product' || $type == 'project' ? $type : '';
$apiObjectID = $apiObjectType ? $objectID : 0;
$apiLibs = $apiObjectType ? $this->doc->getApiLibs(0, $apiObjectType, $apiObjectID) : array();
$this->view->title = $title;
$this->view->type = $type;
@@ -1320,7 +1321,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 = $type == 'execution' ? array() : $this->doc->getApiLibs(0, $apiObjectType, $apiObjectID);
$this->view->apiLibID = key($apiLibs);
$this->display();
}
+11 -6
View File
@@ -14,15 +14,20 @@ $(function()
*/
function redirectParentWindow(objectType, libID, docType)
{
config.onlybody = 'no';
if(objectType == 'api')
{
var link = createLink('api', 'create', 'libID=' + libID) + '#app=doc';
}
else
{
var link = createLink('doc', 'create', 'objectType=' + objectType + '&objectID=0&libID=' + libID + '&moduleID=0&docType=' + docType + '&fromGlobal=true') + '#app=doc';
parent.$.closeModal(function()
{
new parent.$.zui.ModalTrigger({
iframe : createLink('api', 'create', 'libID=' + libID),
width: '85%'
}).show();
});
return false;
}
config.onlybody = 'no';
var link = createLink('doc', 'create', 'objectType=' + objectType + '&objectID=0&libID=' + libID + '&moduleID=0&docType=' + docType + '&fromGlobal=true') + '#app=doc';
window.parent.$.apps.open(link);
}
+56
View File
@@ -2906,4 +2906,60 @@ class docModel extends model
$libTree = array_values($libTree[$type]);
return $libTree;
}
/**
* Print create document button.
*
* @param object $lib
* @param type $type project|product|custom
* @param int $objectID
* @param int $moduleID
* @param int $apiLibID
* @param string $from list
* @access public
* @return string
*/
public function printCreateBtn($lib, $type, $objectID, $moduleID, $apiLibID = 0, $from = '')
{
$libType = isset($lib->type) && $lib->type == 'api' ? 'api' : 'lib';
$class = $from == 'list' ? 'btn-info' : 'btn-primary';
$html = "<div class='dropdown btn-group createDropdown'>";
$html .= html::a(helper::createLink('doc', 'createBasicInfo', "objectType={$lib->type}&objectID=$objectID&libID={$lib->id}&moduleID=$moduleID&type=html", '', true), "<i class='icon icon-plus'></i> {$this->lang->doc->create}", '', "class='btn $class iframe'");
$html .= "<button type='button' class='btn $class dropdown-toggle' data-toggle='dropdown'><span class='caret'></span></button>";
$html .= "<ul class='dropdown-menu pull-right'>";
foreach($this->lang->doc->createList as $typeKey => $typeName)
{
if($this->config->edition != 'max' and $typeKey == 'template') continue;
if($typeKey == 'api' and (!common::hasPriv('api', 'create') or !$apiLibID)) continue;
if($typeKey != 'api' and !common::hasPriv('doc', 'create')) continue;
$class = ($typeKey != 'template') ? 'iframe' : '';
$attr = "data-app='{$this->app->tab}'";
$module = $typeKey == 'api' ? 'api' : 'doc';
$method = strpos($this->config->doc->textTypes, $typeKey) !== false ? 'createBasicInfo' : 'create';
$params = "objectType={$lib->type}&objectID=$objectID&libID={$lib->id}&moduleID=$moduleID&type=$typeKey";
if($typeKey == 'api')
{
$attr .= " data-width=85%";
$params = "libID=$apiLibID&moduleID=$moduleID";
}
if($typeKey == 'template') $params = "objectType=$type&objectID=$objectID&libID={$lib->id}&moduleID=$moduleID&type=html&fromGlobal=&from=template";
$html .= "<li>";
$html .= html::a(helper::createLink($module, $method, $params, '', $class ? true : false), $typeName, '', "class='$class' $attr");
$html .= "</li>";
$printDivider = false;
if($typeKey == 'template') $printDivider = true;
if($this->config->edition != 'max' and $typeKey == 'api') $printDivider = true;
if($this->config->edition != 'max' and !$apiLibID and $typeKey == 'html') $printDivider = true;
if($printDivider) $html .= '<li class="divider"></li>';
}
$html .= '</ul></div>';
return $html;
}
}
+2 -37
View File
@@ -27,44 +27,9 @@
<p>
<span class="text-muted"><?php echo $lang->doc->noDoc;?></span>
<?php
if($browseType != 'bySearch' and (common::hasPriv('doc', 'create') or (common::hasPriv('api', 'create') and !empty($apiLibs))))
if($browseType != 'bySearch' and $libID and (common::hasPriv('doc', 'create') or (common::hasPriv('api', 'create') and !$apiLibID)))
{
if($libID)
{
$html = "<div class='dropdown btn-group createDropdown'>";
$html .= html::a($this->createLink('doc', 'createBasicInfo', "objectType={$lib->type}&objectID=$objectID&libID=$libID&moduleID=$moduleID&type=html", '', true), "<i class='icon icon-plus'></i> {$lang->doc->create}", '', "class='btn btn-info iframe'");
$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={$lib->type}&objectID=$objectID&libID=$libID&moduleID=$moduleID&type=$typeKey";
if($typeKey == 'api') $params = "libID=$apiLibID&moduleID=$moduleID";
if($typeKey == 'template') $params = "objectType={$lib->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>";
$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>';
echo $html;
}
echo $this->doc->printCreateBtn($lib, $type, $objectID, $moduleID, $apiLibID, 'list');
}
?>
</p>
+2 -37
View File
@@ -35,44 +35,9 @@
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') or (common::hasPriv('api', 'create') and !empty($apiLibs)))
if($libID and (common::hasPriv('doc', 'create') or (common::hasPriv('api', 'create') and !$apiLibID)))
{
if($libID)
{
$html = "<div class='dropdown btn-group createDropdown'>";
$html .= html::a($this->createLink('doc', 'createBasicInfo', "objectType={$lib->type}&objectID=$objectID&libID=$libID&moduleID=$moduleID&type=html", '', true), "<i class='icon icon-plus'></i> {$lang->doc->create}", '', "class='btn btn-primary iframe'");
$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={$lib->type}&objectID=$objectID&libID=$libID&moduleID=$moduleID&type=$typeKey";
if($typeKey == 'api') $params = "libID=$apiLibID&moduleID=$moduleID";
if($typeKey == 'template') $params = "objectType={$libType}&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>";
$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>';
echo $html;
}
echo $this->doc->printCreateBtn($lib, $type, $objectID, $moduleID, $apiLibID);
}
?>
</div>