* fix bug and adjust doc search.

This commit is contained in:
wangyidong
2016-11-10 15:12:38 +08:00
parent f0b8d17c63
commit 29bf12312c
6 changed files with 36 additions and 37 deletions
+3 -3
View File
@@ -23,11 +23,11 @@ $config->doc->markdown->create = array('id' => 'contentMarkdown', 'tools' => 'wi
$config->doc->search['module'] = 'doc';
$config->doc->search['fields']['title'] = $lang->doc->title;
$config->doc->search['fields']['id'] = $lang->doc->id;
$config->doc->search['fields']['keywords'] = $lang->doc->keywords;
$config->doc->search['fields']['product'] = $lang->doc->product;
$config->doc->search['fields']['project'] = $lang->doc->project;
$config->doc->search['fields']['module'] = $lang->doc->module;
$config->doc->search['fields']['lib'] = $lang->doc->lib;
$config->doc->search['fields']['module'] = $lang->doc->module;
$config->doc->search['fields']['keywords'] = $lang->doc->keywords;
$config->doc->search['fields']['addedBy'] = $lang->doc->addedBy;
$config->doc->search['fields']['addedDate'] = $lang->doc->addedDate;
$config->doc->search['fields']['editedBy'] = $lang->doc->editedBy;
@@ -37,7 +37,7 @@ $config->doc->search['fields']['version'] = $lang->doc->version;
$config->doc->search['params']['title'] = array('operator' => 'include', 'control' => 'input', 'values' => '');
$config->doc->search['params']['keywords'] = array('operator' => 'include', 'control' => 'input', 'values' => '');
$config->doc->search['params']['product'] = array('operator' => '=', 'control' => 'select', 'values' => '');
$config->doc->search['params']['module'] = array('operator' => '=', 'control' => 'select', 'values' => '');
$config->doc->search['params']['module'] = array('operator' => 'belong', 'control' => 'select', 'values' => '');
$config->doc->search['params']['project'] = array('operator' => '=', 'control' => 'select', 'values' => '');
$config->doc->search['params']['lib'] = array('operator' => '=', 'control' => 'select', 'values' => '' );
$config->doc->search['params']['addedBy'] = array('operator' => '=', 'control' => 'select', 'values' => 'users');
+13 -17
View File
@@ -221,11 +221,21 @@ class docModel extends model
{
if($this->session->docQuery == false) $this->session->set('docQuery', ' 1 = 1');
}
$docQuery = str_replace("`product` = 'all'", '1', $this->session->docQuery); // Search all producti.
$libCond = strpos($this->session->docQuery, "`lib` = ") !== false;
$allLibCond = strpos($this->session->docQuery, "`lib` = 'all'") !== false;
$docQuery = str_replace("`product` = 'all'", '1', $this->session->docQuery); // Search all product.
$docQuery = str_replace("`project` = 'all'", '1', $docQuery); // Search all project.
$docQuery = str_replace("`lib` = 'all'", '1', $docQuery); // Search all lib.
$condition = $this->buildConditionSQL();
$docs = $this->dao->select('*')->from(TABLE_DOC)->where($docQuery)
$libIdList = $this->dao->select('id')->from(TABLE_DOCLIB)->beginIF($condition)->where("($condition)")->fi()->get();
$docs = $this->dao->select('*')->from(TABLE_DOC)->where($docQuery)
->beginIF($condition)->andWhere("($condition)")->fi()
->beginIF(!$libCond)->andWhere("lib")->eq($libID)->fi()
->beginIF($allLibCond and $condition)->andWhere("lib in ($libIdList)")->fi()
->andWhere('deleted')->eq(0)
->orderBy($sort)->page($pager)
->fetchAll();
@@ -464,7 +474,7 @@ class docModel extends model
$this->config->doc->search['queryID'] = $queryID;
$this->config->doc->search['params']['product']['values'] = array(''=>'') + $this->loadModel('product')->getPairs('nocode') + array('all'=>$this->lang->doc->allProduct);
$this->config->doc->search['params']['project']['values'] = array(''=>'') + $this->loadModel('project')->getPairs('nocode') + array('all'=>$this->lang->doc->allProject);
$this->config->doc->search['params']['lib']['values'] = array(''=>'') + $libs;
$this->config->doc->search['params']['lib']['values'] = array(''=>'', $libID => $libs[$libID], 'all' => $this->lang->doclib->all);
/* Get the modules. */
$moduleOptionMenu = $this->loadModel('tree')->getOptionMenu($libID . 'doc', $startModuleID = 0);
@@ -606,20 +616,6 @@ class docModel extends model
return false;
}
/**
* Get doc link.
*
* @param string $module
* @param string $method
* @param string $extra
* @access public
* @return string
*/
public function getDocLink($module, $method, $extra = '')
{
return helper::createLink($module, $method, "libID=%s");
}
/**
* Get all libs by type.
*
+6 -5
View File
@@ -13,12 +13,13 @@
<?php include '../../common/view/header.html.php';?>
<div id='libs'>
<?php
$libs = array();
$libs['product'] = $products;
$libs['project'] = $projects;
$libs['custom'] = $customLibs;
$allLibs = array();
$allLibs['product'] = $products;
$allLibs['project'] = $projects;
$allLibs['custom'] = $customLibs;
?>
<?php foreach ($libs as $libsName => $libs):?>
<?php foreach($allLibs as $libsName => $libs):?>
<?php if(empty($libs)) continue;?>
<?php if($libsName === 'product'): ?>
<div class='row'>
<?php
+1 -1
View File
@@ -22,7 +22,7 @@
if($libID == 'project' and $from != 'doc') continue;
$libLink = inlink('browse', "libID=$libID&browseType=all&param=0&orderBy=id_desc&from=$from");
if($libID == 'project') $libLink = inlink('allLibs', "type=project&extra=product=$object->id");
if($libID == 'project') $libLink = inlink('allLibs', "type=project&product=$object->id");
if($libID == 'files') $libLink = inlink('showFiles', "type=$type&objectID=$object->id");
?>
<a class='lib' title='<?php echo $libName?>' href='<?php echo $libLink?>'>
+1
View File
@@ -269,6 +269,7 @@ class projectModel extends model
}
/* Create doc lib. */
$this->app->loadLang('doc');
$lib = new stdclass();
$lib->project = $projectID;
$lib->name = $this->lang->doclib->main['project'];
+12 -11
View File
@@ -68,10 +68,6 @@ class searchModel extends model
/* Set and or. */
$andOr = strtoupper($this->post->$andOrName);
if($andOr != 'AND' and $andOr != 'OR') $andOr = 'AND';
$where .= " $andOr ";
/* Set filed name. */
$where .= '`' . $this->post->$fieldName . '` ';
/* Set operator. */
$value = $this->post->$valueName;
@@ -81,35 +77,40 @@ class searchModel extends model
/* Escape char. */
$value = str_replace(array('\\', '%', '_'), array('\\\\', '\\%', '\\_'), $value);
/* Set condition. */
$condition = '';
if($operator == "include")
{
$where .= ' LIKE ' . $this->dbh->quote("%$value%");
$condition = ' LIKE ' . $this->dbh->quote("%$value%");
}
elseif($operator == "notinclude")
{
$where .= ' NOT LIKE ' . $this->dbh->quote("%$value%");
$condition = ' NOT LIKE ' . $this->dbh->quote("%$value%");
}
elseif($operator == 'belong')
{
if($this->post->$fieldName == 'module')
{
$allModules = $this->loadModel('tree')->getAllChildId($value);
if($allModules) $where .= helper::dbIN($allModules);
if($allModules) $condition = helper::dbIN($allModules);
}
elseif($this->post->$fieldName == 'dept')
{
$allDepts = $this->loadModel('dept')->getAllChildId($value);
$where .= helper::dbIN($allDepts);
$condition = helper::dbIN($allDepts);
}
else
{
$where .= ' = ' . $this->dbh->quote($value) . ' ';
$condition = ' = ' . $this->dbh->quote($value) . ' ';
}
}
else
{
$where .= $operator . ' ' . $this->dbh->quote($value) . ' ';
$condition = $operator . ' ' . $this->dbh->quote($value) . ' ';
}
/* Set filed name. */
if($condition) $where .= " $andOr " . '`' . $this->post->$fieldName . '` ' . $condition;
}
$where .=" ))";
@@ -334,7 +335,7 @@ class searchModel extends model
}
/**
* Get records by the conditon.
* Get records by the condition.
*
* @param string $module
* @param string $moduleIdList