+ add more and lite switch feature.
This commit is contained in:
@@ -21,7 +21,6 @@ $config->bug->search['fields']['assignedDate'] = $lang->bug->assignedDate;
|
||||
$config->bug->search['fields']['closedDate'] = $lang->bug->closedDate;
|
||||
$config->bug->search['fields']['lastEditedDate'] = $lang->bug->lastEditedDate;
|
||||
|
||||
$config->bug->search['groupItems'] = 3;
|
||||
$config->bug->search['params']['title'] = array('operator' => 'include', 'control' => 'input', 'values' => '');
|
||||
$config->bug->search['params']['product'] = array('operator' => '=', 'control' => 'select', 'values' => 'products');
|
||||
$config->bug->search['params']['assignedTo'] = array('operator' => '=', 'control' => 'select', 'values' => 'users');
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
$config->search->groupItems = 3;
|
||||
@@ -23,13 +23,13 @@
|
||||
*/
|
||||
class search extends control
|
||||
{
|
||||
public function buildForm($module, $searchFields, $groupItems, $fieldParams, $actionURL)
|
||||
public function buildForm($module, $searchFields, $fieldParams, $actionURL)
|
||||
{
|
||||
$this->search->initSession($module, $searchFields, $groupItems, $fieldParams);
|
||||
$this->search->initSession($module, $searchFields, $fieldParams);
|
||||
|
||||
$this->assign('module', $module);
|
||||
$this->assign('groupItems', $this->config->search->groupItems);
|
||||
$this->assign('searchFields', $searchFields);
|
||||
$this->assign('groupItems', $groupItems);
|
||||
$this->assign('actionURL', $actionURL);
|
||||
$this->assign('fieldParams', $this->search->setDefaultParams($searchFields, $fieldParams));
|
||||
$this->display();
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
* @link http://www.zentao.cn
|
||||
*/
|
||||
$lang->search->common = '搜索';
|
||||
$lang->search->advanced = '高级搜索';
|
||||
$lang->search->more = '更多';
|
||||
$lang->search->lite = '简洁';
|
||||
$lang->search->saveQuery = '保存';
|
||||
$lang->search->myQuery = '我的查询';
|
||||
$lang->search->group1 = '第一组';
|
||||
|
||||
@@ -30,7 +30,7 @@ class searchModel extends model
|
||||
{
|
||||
/* 初始化变量。*/
|
||||
$where = '';
|
||||
$groupItems = (int)$this->post->groupItems;
|
||||
$groupItems = $this->config->search->groupItems;
|
||||
$groupAndOr = strtoupper($this->post->groupAndOr);
|
||||
if($groupAndOr != 'AND' and $groupAndOr != 'OR') $groupAndOr = 'AND';
|
||||
|
||||
@@ -81,11 +81,11 @@ class searchModel extends model
|
||||
}
|
||||
|
||||
/* 初始化查询表单的session。*/
|
||||
public function initSession($module, $fields, $groupItems, $fieldParams)
|
||||
public function initSession($module, $fields, $fieldParams)
|
||||
{
|
||||
$formSessionName = $module . 'Form';
|
||||
if($this->session->$formSessionName != false) return;
|
||||
for($i = 1; $i <= $groupItems * 2; $i ++)
|
||||
for($i = 1; $i <= $this->config->search->groupItems * 2; $i ++)
|
||||
{
|
||||
/* 设定各个变量的名称。*/
|
||||
$fieldName = "field$i";
|
||||
|
||||
@@ -31,9 +31,29 @@ function setField(fieldName, fieldNO)
|
||||
htmlString = $('#box' + fieldName).html().replace(fieldName, 'value' + fieldNO).replace(fieldName, 'value' + fieldNO);
|
||||
$('#valueBox' + fieldNO).html(htmlString);
|
||||
}
|
||||
|
||||
function showmore()
|
||||
{
|
||||
for(i = 1; i <= 6; i++) $('#searchbox' + i).removeClass('hidden');
|
||||
$('#searchmore').addClass('hidden');
|
||||
$('#searchlite').removeClass('hidden');
|
||||
$('#searchgroup1').removeClass('hidden');
|
||||
$('#searchgroup2').removeClass('hidden');
|
||||
$('#searchType').val('more');
|
||||
}
|
||||
|
||||
function showlite()
|
||||
{
|
||||
for(i = 1; i <= 6; i++) $('#searchbox' + i).addClass('hidden');
|
||||
$('#searchmore').removeClass('hidden');
|
||||
$('#searchlite').addClass('hidden');
|
||||
$('#searchgroup1').addClass('hidden');
|
||||
$('#searchgroup2').addClass('hidden');
|
||||
$('#searchType').val('lite');
|
||||
}
|
||||
</script>
|
||||
|
||||
<div style='display:none'>
|
||||
<div class='hidden'>
|
||||
<?php
|
||||
/* 输出所有字段的控件代码,当触发setField事件的时候,拷贝控件的html代码。*/
|
||||
foreach($fieldParams as $fieldName => $param)
|
||||
@@ -47,9 +67,9 @@ foreach($fieldParams as $fieldName => $param)
|
||||
</div>
|
||||
<form method='post' action='<?php echo $this->createLink('search', 'buildQuery');?>' target='hiddenwin'>
|
||||
<table class='table-1'>
|
||||
<caption><?php echo $lang->search->common;?></caption>
|
||||
<tr valign='middle'>
|
||||
<td class='a-right' width='100'>
|
||||
<th width='10' class='bg-gray'><?php echo $lang->search->common;?></th>
|
||||
<td class='a-right' width='200'>
|
||||
<nobr>
|
||||
<?php
|
||||
$formSessionName = $module . 'Form';
|
||||
@@ -58,12 +78,15 @@ foreach($fieldParams as $fieldName => $param)
|
||||
$fieldNO = 1;
|
||||
for($i = 1; $i <= $groupItems; $i ++)
|
||||
{
|
||||
$spanClass = $i == 1 ? 'inline' : 'hidden';
|
||||
echo "<span id='searchbox$fieldNO' class='$spanClass'>";
|
||||
|
||||
/* 取当前字段的设置。*/
|
||||
$currentField = $formSession["field$fieldNO"];
|
||||
$param = $fieldParams[$currentField];
|
||||
|
||||
/* 打印and or。*/
|
||||
if($i == 1) echo "<strong>{$lang->search->group1}</strong>" . html::hidden("andOr$fieldNO", 'AND');
|
||||
if($i == 1) echo "<span id='searchgroup1' class='hidden'><strong>{$lang->search->group1}</strong></span>" . html::hidden("andOr$fieldNO", 'AND');
|
||||
if($i > 1) echo "<br />" . html::select("andOr$fieldNO", $lang->search->andor, $formSession["andOr$fieldNO"]);
|
||||
|
||||
/* 打印字段。*/
|
||||
@@ -79,22 +102,26 @@ foreach($fieldParams as $fieldName => $param)
|
||||
echo '</span>';
|
||||
|
||||
$fieldNO ++;
|
||||
echo '</span>';
|
||||
}
|
||||
?>
|
||||
</nobr>
|
||||
</td>
|
||||
<td class='a-center' width='20'><nobr><?php echo html::select('groupAndOr', $lang->search->andor, $formSession['groupAndOr'])?></nobr></td>
|
||||
<td class='a-right' width='100'>
|
||||
<td class='a-right' width='200'>
|
||||
<nobr>
|
||||
<?php
|
||||
for($i = 1; $i <= $groupItems; $i ++)
|
||||
{
|
||||
$spanClass = $i == 1 ? 'inline' : 'hidden';
|
||||
echo "<span id='searchbox$fieldNO' class='$spanClass'>";
|
||||
|
||||
/* 取当前字段的设置。*/
|
||||
$currentField = $formSession["field$fieldNO"];
|
||||
$param = $fieldParams[$currentField];
|
||||
|
||||
/* 打印and or。*/
|
||||
if($i == 1) echo "<strong>{$lang->search->group2}</strong>" . html::hidden("andOr$fieldNO", 'AND');
|
||||
if($i == 1) echo "<span id='searchgroup2' class='hidden'><strong>{$lang->search->group1}</strong></span>" . html::hidden("andOr$fieldNO", 'AND');
|
||||
if($i > 1) echo "<br />" . html::select("andOr$fieldNO", $lang->search->andor, $formSession["andOr$fieldNO"]);
|
||||
|
||||
/* 打印字段。*/
|
||||
@@ -110,22 +137,31 @@ foreach($fieldParams as $fieldName => $param)
|
||||
echo '</span>';
|
||||
|
||||
$fieldNO ++;
|
||||
echo '</span>';
|
||||
}
|
||||
?>
|
||||
</nobr>
|
||||
</td>
|
||||
<td width='20'>
|
||||
<td width='100'>
|
||||
<nobr>
|
||||
<?php
|
||||
echo html::hidden('module', $module);
|
||||
echo html::hidden('actionURL', $actionURL);
|
||||
echo html::hidden('groupItems', $groupItems);
|
||||
echo html::submitButton($lang->search->common) . '<br />';
|
||||
echo html::submitButton($lang->search->saveQuery);
|
||||
echo html::submitButton($lang->search->common);
|
||||
//echo html::submitButton($lang->search->saveQuery);
|
||||
?>
|
||||
</nobr>
|
||||
</td>
|
||||
<td><?php echo $lang->search->myQuery; ?></td>
|
||||
<th width='10' class='bg-gray' style='cursor:pointer'>
|
||||
<span id='searchmore' onclick='showmore()'><?php echo $lang->search->more;?></span>
|
||||
<span id='searchlite' onclick='showlite()' class='hidden'><?php echo $lang->search->lite;?></span>
|
||||
<?php echo html::hidden('searchType', 'lite');?>
|
||||
</th>
|
||||
<!--<td><?php echo $lang->search->myQuery; ?></td>-->
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<?php
|
||||
if(isset($formSession['searchType'])) echo "<script language='Javascript'>show{$formSession['searchType']}()</script>";
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user