fix code style.
This commit is contained in:
@@ -57,9 +57,9 @@
|
||||
$methodName = 'view';
|
||||
$module = 'caselib';
|
||||
}
|
||||
if ($action->objectType == 'api')
|
||||
if($action->objectType == 'api')
|
||||
{
|
||||
$params = "libID=0&moduelID=0&apiID={$action->objectID}";
|
||||
$params = "libID=0&moduelID=0&apiID={$action->objectID}";
|
||||
$methodName = 'index';
|
||||
}
|
||||
if(isset($config->action->customFlows[$action->objectType]))
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* The control file of api of ZenTaoPMS.
|
||||
*
|
||||
@@ -683,7 +684,7 @@ class api extends control
|
||||
private function generateLibsDropMenu($libs, $libID, $version = 0)
|
||||
{
|
||||
if(empty($libs)) return '';
|
||||
if (!isset($libs[$libID])) return '';
|
||||
if(!isset($libs[$libID])) return '';
|
||||
|
||||
$libName = $libs[$libID]->name;
|
||||
$output = <<<EOT
|
||||
@@ -703,7 +704,7 @@ EOT;
|
||||
foreach($libs as $key => $lib)
|
||||
{
|
||||
$selected = $key == $libID ? 'selected' : '';
|
||||
$output .= html::a(inlink('index', "libID=$key"), $lib->name, '', "class='$selected' data-app='{$this->app->tab}'");
|
||||
$output .= html::a(inlink('index', "libID=$key"), $lib->name, '', "class='$selected' data-app='{$this->app->tab}'");
|
||||
}
|
||||
$output .= "</div></div></div></div></div>";
|
||||
|
||||
@@ -712,7 +713,7 @@ EOT;
|
||||
if(!empty($versions))
|
||||
{
|
||||
$versionName = $version > 0 ? $versions[$version]->version : $this->lang->api->defaultVersion;
|
||||
$output .= <<<EOT
|
||||
$output .= <<<EOT
|
||||
<div class='btn-group angle-btn'>
|
||||
<div class='btn-group'>
|
||||
<button id='currentBranch' data-toggle='dropdown' type='button' class='btn btn-limit'>{$versionName} <span class='caret'></span>
|
||||
|
||||
+35
-35
@@ -157,7 +157,7 @@ class apiModel extends model
|
||||
->where('id')->eq($id)
|
||||
->exec();
|
||||
|
||||
if (dao::isError()) return false;
|
||||
if(dao::isError()) return false;
|
||||
|
||||
/* Create a struct version */
|
||||
$version = array(
|
||||
@@ -251,7 +251,7 @@ class apiModel extends model
|
||||
->where('id')->eq($id)
|
||||
->fetch();
|
||||
|
||||
if ($model) $model->attribute = json_decode($model->attribute, true);
|
||||
if($model) $model->attribute = json_decode($model->attribute, true);
|
||||
|
||||
return $model;
|
||||
}
|
||||
@@ -271,7 +271,7 @@ class apiModel extends model
|
||||
->where('version')->eq($version)
|
||||
->andWhere('lib')->eq($libID)
|
||||
->fetch();
|
||||
if ($model) $model->snap = json_decode($model->snap, true);
|
||||
if($model) $model->snap = json_decode($model->snap, true);
|
||||
return $model;
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ class apiModel extends model
|
||||
->from(TABLE_API_LIB_RELEASE)
|
||||
->where('id')->eq($id)
|
||||
->fetch();
|
||||
if ($model) $model->snap = json_decode($model->snap, true);
|
||||
if($model) $model->snap = json_decode($model->snap, true);
|
||||
return $model;
|
||||
}
|
||||
|
||||
@@ -319,15 +319,15 @@ class apiModel extends model
|
||||
*/
|
||||
public function getLibById($id, $version = 0, $release = 0)
|
||||
{
|
||||
if ($release)
|
||||
if($release)
|
||||
{
|
||||
$rel = $this->getReleaseById($release);
|
||||
foreach ($rel->snap['apis'] as $api)
|
||||
foreach($rel->snap['apis'] as $api)
|
||||
{
|
||||
if ($api['id'] == $id) $version = $api['version'];
|
||||
if($api['id'] == $id) $version = $api['version'];
|
||||
}
|
||||
}
|
||||
if ($version)
|
||||
if($version)
|
||||
{
|
||||
$fields = 'spec.*,api.id,api.product,api.lib,api.version,doc.name as libName,module.name as moduleName,api.editedBy,api.editedDate';
|
||||
}
|
||||
@@ -346,7 +346,7 @@ class apiModel extends model
|
||||
->beginIF($version)->andWhere('spec.version')->eq($version)->fi()
|
||||
->fetch();
|
||||
|
||||
if ($model)
|
||||
if($model)
|
||||
{
|
||||
$model->params = json_decode($model->params, true);
|
||||
$model->response = json_decode($model->response, true);
|
||||
@@ -364,12 +364,12 @@ class apiModel extends model
|
||||
public function getApiListByRelease($release, $where = '')
|
||||
{
|
||||
$strJoin = array();
|
||||
foreach ($release->snap['apis'] as $api)
|
||||
foreach($release->snap['apis'] as $api)
|
||||
{
|
||||
$strJoin[] = "(spec.doc = {$api['id']} and spec.version = {$api['version']} )";
|
||||
}
|
||||
|
||||
if ($strJoin) $where .= 'and (' . implode(' or ', $strJoin) . ')';
|
||||
if($strJoin) $where .= 'and (' . implode(' or ', $strJoin) . ')';
|
||||
$list = $this->dao->select('api.lib,spec.*,api.id')->from(TABLE_API)->alias('api')
|
||||
->leftJoin(TABLE_API_SPEC)->alias('spec')->on('api.id = spec.doc')
|
||||
->where($where)
|
||||
@@ -389,30 +389,30 @@ class apiModel extends model
|
||||
public function getListByModuleId($libID = 0, $moduleID = 0, $release = 0)
|
||||
{
|
||||
/* Get release info. */
|
||||
if ($release > 0)
|
||||
if($release > 0)
|
||||
{
|
||||
$rel = $this->getReleaseById($release);
|
||||
|
||||
$where = "1=1 and lib = $libID ";
|
||||
if ($moduleID > 0)
|
||||
if($moduleID > 0)
|
||||
{
|
||||
$sub = array();
|
||||
foreach ($rel->snap['modules'] as $module)
|
||||
foreach($rel->snap['modules'] as $module)
|
||||
{
|
||||
$tmp = explode(',', $module['path']);
|
||||
if (in_array($moduleID, $tmp))
|
||||
if(in_array($moduleID, $tmp))
|
||||
{
|
||||
$sub[] = $module['id'];
|
||||
}
|
||||
}
|
||||
if ($sub) $where .= 'and module in (' . implode(',', $sub) . ')';
|
||||
if($sub) $where .= 'and module in (' . implode(',', $sub) . ')';
|
||||
}
|
||||
$list = $this->getApiListByRelease($rel, $where);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if ($moduleID > 0)
|
||||
if($moduleID > 0)
|
||||
{
|
||||
$sub = $this->dao->select('id')->from(TABLE_MODULE)->where('FIND_IN_SET(' . $moduleID . ', path)')->processSQL();
|
||||
$where = 'module in (' . $sub . ')';
|
||||
@@ -445,7 +445,7 @@ class apiModel extends model
|
||||
public static function getApiStatusText($status)
|
||||
{
|
||||
global $lang;
|
||||
switch ($status)
|
||||
switch($status)
|
||||
{
|
||||
case static::STATUS_DOING:
|
||||
{
|
||||
@@ -505,10 +505,10 @@ class apiModel extends model
|
||||
$list = $this->getStructListByLibID($libID);
|
||||
|
||||
$html = "<ul id='modules' class='tree' data-ride='tree' data-name='tree-lib'>";
|
||||
foreach ($list as $item)
|
||||
foreach($list as $item)
|
||||
{
|
||||
$class = array('catalog');
|
||||
if ($structID && $structID == $item->id)
|
||||
if($structID && $structID == $item->id)
|
||||
{
|
||||
$class[] = 'active';
|
||||
}
|
||||
@@ -538,7 +538,7 @@ class apiModel extends model
|
||||
{
|
||||
$fileName = dirname($filePath);
|
||||
$className = basename(dirname(dirname($filePath)));
|
||||
if (!class_exists($className)) helper::import($fileName);
|
||||
if(!class_exists($className)) helper::import($fileName);
|
||||
$methodName = basename($filePath);
|
||||
|
||||
$method = new ReflectionMethod($className . $ext, $methodName);
|
||||
@@ -553,9 +553,9 @@ class apiModel extends model
|
||||
$data->post = false;
|
||||
|
||||
$file = file($fileName);
|
||||
for ($i = $data->startLine - 1; $i <= $data->endLine; $i++)
|
||||
for($i = $data->startLine - 1; $i <= $data->endLine; $i++)
|
||||
{
|
||||
if (strpos($file[$i], '$this->post') or strpos($file[$i], 'fixer::input') or strpos($file[$i], '$_POST'))
|
||||
if(strpos($file[$i], '$this->post') or strpos($file[$i], 'fixer::input') or strpos($file[$i], '$_POST'))
|
||||
{
|
||||
$data->post = true;
|
||||
}
|
||||
@@ -576,11 +576,11 @@ class apiModel extends model
|
||||
{
|
||||
$host = common::getSysURL();
|
||||
$param = '';
|
||||
if ($action == 'extendModel')
|
||||
if($action == 'extendModel')
|
||||
{
|
||||
if (!isset($_POST['noparam']))
|
||||
if(!isset($_POST['noparam']))
|
||||
{
|
||||
foreach ($_POST as $key => $value) $param .= ',' . $key . '=' . $value;
|
||||
foreach($_POST as $key => $value) $param .= ',' . $key . '=' . $value;
|
||||
$param = ltrim($param, ',');
|
||||
}
|
||||
$url = rtrim($host, '/') . inlink('getModel', "moduleName=$moduleName&methodName=$methodName¶ms=$param", 'json');
|
||||
@@ -589,9 +589,9 @@ class apiModel extends model
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!isset($_POST['noparam']))
|
||||
if(!isset($_POST['noparam']))
|
||||
{
|
||||
foreach ($_POST as $key => $value) $param .= '&' . $key . '=' . $value;
|
||||
foreach($_POST as $key => $value) $param .= '&' . $key . '=' . $value;
|
||||
$param = ltrim($param, '&');
|
||||
}
|
||||
$url = rtrim($host, '/') . helper::createLink($moduleName, $methodName, $param, 'json');
|
||||
@@ -617,18 +617,18 @@ class apiModel extends model
|
||||
*/
|
||||
public function sql($sql, $keyField = '')
|
||||
{
|
||||
if (!$this->config->features->apiSQL) return sprintf($this->lang->api->error->disabled, '$config->features->apiSQL');
|
||||
if(!$this->config->features->apiSQL) return sprintf($this->lang->api->error->disabled, '$config->features->apiSQL');
|
||||
|
||||
$sql = trim($sql);
|
||||
if (strpos($sql, ';') !== false) $sql = substr($sql, 0, strpos($sql, ';'));
|
||||
if(strpos($sql, ';') !== false) $sql = substr($sql, 0, strpos($sql, ';'));
|
||||
|
||||
$result = array();
|
||||
$result['status'] = 'fail';
|
||||
$result['message'] = '';
|
||||
|
||||
if (empty($sql)) return $result;
|
||||
if(empty($sql)) return $result;
|
||||
|
||||
if (stripos($sql, 'select ') !== 0)
|
||||
if(stripos($sql, 'select ') !== 0)
|
||||
{
|
||||
$result['message'] = $this->lang->api->error->onlySelect;
|
||||
return $result;
|
||||
@@ -639,19 +639,19 @@ class apiModel extends model
|
||||
$stmt = $this->dbh->query($sql);
|
||||
|
||||
$rows = array();
|
||||
if (empty($keyField))
|
||||
if(empty($keyField))
|
||||
{
|
||||
$rows = $stmt->fetchAll();
|
||||
}
|
||||
else
|
||||
{
|
||||
while ($row = $stmt->fetch()) $rows[$row->$keyField] = $row;
|
||||
while($row = $stmt->fetch()) $rows[$row->$keyField] = $row;
|
||||
}
|
||||
|
||||
$result['status'] = 'success';
|
||||
$result['data'] = $rows;
|
||||
}
|
||||
catch (PDOException $e)
|
||||
catch(PDOException $e)
|
||||
{
|
||||
$result['status'] = 'fail';
|
||||
$result['message'] = $e->getMessage();
|
||||
|
||||
Reference in New Issue
Block a user