* Fix errrors of search widget.
This commit is contained in:
@@ -25,6 +25,8 @@ class searchToggle extends wg
|
||||
global $lang;
|
||||
$module = $this->prop('module');
|
||||
$formName = $this->prop('formName');
|
||||
$open = $this->prop('open');
|
||||
if(is_null($open) && !empty($_GET['browseType'])) $open = $_GET['browseType'] === 'bySearch';
|
||||
return btn
|
||||
(
|
||||
set::class('ghost search-form-toggle'),
|
||||
@@ -33,7 +35,7 @@ class searchToggle extends wg
|
||||
set('data-module', $this->prop('module')),
|
||||
set('data-on', 'click'),
|
||||
set('data-do', "window.toggleSearchForm('$module', '$formName');"),
|
||||
$this->prop('open') ? h::jsCall('~window.toggleSearchForm', $module, $formName, true) : null
|
||||
$open ? h::jsCall('~window.toggleSearchForm', $module, $formName, true) : null
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ $config->host->featureBar[0]['badge'] = $pager->recTotal != '' ? array('text' =
|
||||
featureBar
|
||||
(
|
||||
set::items($config->host->featureBar),
|
||||
li(searchToggle())
|
||||
li(searchToggle(set::open($browseType==='bySearch')))
|
||||
);
|
||||
|
||||
/* zin: Define the toolbar on main menu. */
|
||||
|
||||
@@ -151,7 +151,7 @@ class search extends control
|
||||
*/
|
||||
public function buildZinQuery()
|
||||
{
|
||||
if(!commonModel::hasPriv('search', 'buildForm')) $this->loadModel('common')->deny('search', 'buildForm', false);
|
||||
if(!commonModel::hasPriv('search', 'buildQuery')) $this->loadModel('common')->deny('search', 'buildQuery', false);
|
||||
|
||||
$this->search->buildZinQuery();
|
||||
|
||||
@@ -210,12 +210,12 @@ class search extends control
|
||||
*/
|
||||
public function saveZinQuery($module, $onMenuBar = 'no')
|
||||
{
|
||||
if(!commonModel::hasPriv('search', 'saveQuery')) $this->loadModel('common')->deny('search', 'buildForm', false);
|
||||
if(!commonModel::hasPriv('search', 'saveQuery')) $this->loadModel('common')->deny('search', 'saveQuery', false);
|
||||
|
||||
if($_POST)
|
||||
{
|
||||
$queryID = $this->search->saveZinQuery();
|
||||
if(!$queryID) return print(js::error(dao::getError()));
|
||||
if(!$queryID) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
|
||||
$data = fixer::input('post')->get();
|
||||
$shortcut = empty($data->onMenuBar) ? 0 : 1;
|
||||
@@ -225,7 +225,7 @@ class search extends control
|
||||
echo 'success';
|
||||
return;
|
||||
}
|
||||
return print(js::closeModal('parent.parent', '', "function(){parent.parent.loadQueries($queryID, $shortcut, '{$data->title}')}"));
|
||||
return $this->send(array('closeModal' => true, 'callback' => '$(\'#searchFormPanel form button[type="submit"]\').trigger("click")'));
|
||||
}
|
||||
|
||||
$this->view->module = $module;
|
||||
@@ -247,6 +247,21 @@ class search extends control
|
||||
echo 'success';
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete current search query.
|
||||
*
|
||||
* @param int $queryID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function deleteZinQuery($queryID)
|
||||
{
|
||||
if(!commonModel::hasPriv('search', 'deleteQuery')) $this->loadModel('common')->deny('search', 'deleteQuery', false);
|
||||
$this->search->deleteQuery($queryID);
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
echo $this->send(array('result' => 'success', 'load' => true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax get search query.
|
||||
*
|
||||
|
||||
@@ -289,6 +289,7 @@ class searchModel extends model
|
||||
|
||||
/* Fix bug #2704. */
|
||||
$field = $this->post->$fieldName;
|
||||
if(empty($field)) continue;
|
||||
if(isset($fieldParams->$field) and $fieldParams->$field->control == 'input' and $this->post->$valueName === '0') $this->post->$valueName = 'ZERO';
|
||||
if($field == 'id' and $this->post->$valueName === '0') $this->post->$valueName = 'ZERO';
|
||||
$queryForm[$formIndex]['field'] = $field;
|
||||
@@ -1852,7 +1853,7 @@ class searchModel extends model
|
||||
'data-toggle' => 'modal',
|
||||
'data-type' => 'ajax',
|
||||
'data-data-type' => 'html',
|
||||
'data-url' => helper::createLink('search', 'saveQuery', array('module' => $module)),
|
||||
'data-url' => helper::createLink('search', 'saveZinQuery', array('module' => $module)),
|
||||
);
|
||||
|
||||
return $result;
|
||||
@@ -1866,21 +1867,21 @@ class searchModel extends model
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public static function buildFormSavedQuery($queries, $account)
|
||||
public static function buildFormSavedQuery($queries, $actionURL)
|
||||
{
|
||||
$result = array();
|
||||
if(empty($queries)) return $result;
|
||||
|
||||
global $lang;
|
||||
$hasPriv = common::hasPriv('search', 'deleteQuery');
|
||||
foreach($queries as $query)
|
||||
{
|
||||
if(!is_object($query)) continue;
|
||||
|
||||
$item = new stdClass();
|
||||
$item->id = $query->id;
|
||||
$item->title = $query->title;
|
||||
$item->account = $query->account;
|
||||
$item->hasPriv = ($hasPriv && $account == $query->account);
|
||||
$item->text = $query->title;
|
||||
$item->applyURL = str_replace('myQueryID', $query->id, $actionURL);
|
||||
if($hasPriv) $item->deleteProps = array('className' => 'ajax-submit', 'data-confirm' => $lang->search->confirmDelete, 'href' => helper::createLink('search', 'deleteZinQuery', "queryID={$query->id}"));
|
||||
|
||||
$result[] = $item;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ namespace zin;
|
||||
|
||||
form
|
||||
(
|
||||
set::actions(null),
|
||||
set::actions(array()),
|
||||
set::action($_SERVER['REQUEST_URI']),
|
||||
set::method('post'),
|
||||
div
|
||||
@@ -34,7 +34,7 @@ form
|
||||
),
|
||||
btn(
|
||||
setClass('w-1/12 primary'),
|
||||
set::type('submit'),
|
||||
set::btnType('submit'),
|
||||
set('data-type', 'submit'),
|
||||
$lang->save
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user