Commit ce5a3ed6 authored by Aster's avatar Aster Committed by waltermazza
Browse files

General Bug Fixes and Improvements

parent a0e17f0c
......@@ -22,4 +22,4 @@
"bower-asset-library": "vendor/bower"
}
}
}
\ No newline at end of file
}
......@@ -4,7 +4,7 @@
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @see http://example.com Developers'community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
......
......@@ -4,7 +4,7 @@
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @see http://example.com Developers'community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
......
......@@ -60,10 +60,11 @@ $(window).on('load', function () {
event.preventDefault();
var queryString = $('#formSearch').find('#queryString').val();
var filteredQueryString = queryString.replace(/(<([^>]+)>)/ig,"");
var tagValues = $('#formSearch').find('input[name^="GeneralSearch[tagValues]"]').serialize();
var message = $('#query-info').attr('data-i18n');
$('#query-info').html(message.replace('{queryString}',queryString));
$('#query-info').html(message.replace('{queryString}',filteredQueryString));
if (queryString.length >0 || tagValues.length > 0) {
history.pushState({}, '', '/search/search/index?queryString='+encodeURI(queryString)+'&'+tagValues);
......
......@@ -4,11 +4,11 @@
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @see http://example.com Developers'community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
* @package arter\amos\search\config
* @package arter\amos\search
* @category CategoryName
* @author Elite Division S.r.l.
*/
......
......@@ -4,7 +4,7 @@
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @see http://example.com Developers'community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
......
......@@ -4,7 +4,7 @@
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @see http://example.com Developers'community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
......@@ -80,6 +80,10 @@ class SearchController extends BackendController
public function actionIndex($layout = null, $queryString = null, $tagIds = null, $moduleName = null)
{
/*
pr('here');
die();
*/
Url::remember();
$modelSearch = new GeneralSearch();
......@@ -91,8 +95,22 @@ class SearchController extends BackendController
}
}
$modulesToSearch = $searchModule->modulesToSearch;
//controllo dentro la queryString se vengono passati tags o caratteri che eseguono codice esterno
//$toFilterRequest = \Yii::$app->request->get();
//$filteredRequest = $modelSearch->filterRequest($toFilterRequest);
/*
pr($filteredRequest);
die();
*/
//$modelSearch->load($filteredRequest);
$modelSearch->load(\Yii::$app->request->get());
/*
pr(\Yii::$app->request->get());
die();
*/
if (!empty($tagIds) && array_key_exists('admin', $modulesToSearch)) {
$admin['admin'] = $modulesToSearch['admin'];
$modulesToSearch = array_diff($modulesToSearch, $admin);
......@@ -120,11 +138,43 @@ class SearchController extends BackendController
public function actionDoSearch($layout = null, $queryString = null, $moduleName = null, $tagIds = null)
{
/*
pr('here');
die();
*/
/*
pr(\Yii::$app->request->get());
die();
*/
//pr($layout);
//pr($queryString, 'test');
//die();
Url::remember();
$modelSearch = new GeneralSearch();
$modelSearch->load(\Yii::$app->request->get());
/*
$toFilterRequest = \Yii::$app->request->get();
$filteredRequest = $modelSearch->filterRequest($toFilterRequest);
$queryString = $modelSearch->filterRequest();
*/
/*
pr($filteredRequest);
pr($queryString);
die();
*/
//$modelSearch->load($filteredRequest);
/*
pr($test, 'test2');
die();
*/
$modelSearch->load(\Yii::$app->request->get());
$searchModule = Yii::$app->getModule('search');
if(!$searchModule->enableNetworkScope) {
$moduleCwh = Yii::$app->getModule('cwh');
......@@ -133,6 +183,8 @@ class SearchController extends BackendController
}
}
$searchParamsArray = !empty($queryString) ? explode(" ", $queryString) : [];
$searchModelName = $searchModule->modulesToSearch[$moduleName];
......@@ -149,6 +201,7 @@ class SearchController extends BackendController
}
if (Yii::$app->request->isPjax) {
return $this->render('doSearch',
[
'dataProvider' => $dataProvider,
......@@ -159,6 +212,7 @@ class SearchController extends BackendController
'modelSearch' => $modelSearch
]);
} else {
//die('not pjax');
// La richiesta non è Pjax. Faccio redirect alla search index passando la query string.
return $this->redirect(['/search/search/index', 'queryString' => $queryString, 'tagIds' => $tagIds, 'moduleName' => $moduleName]);
}
......
......@@ -4,11 +4,11 @@
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @see http://example.com Developers'community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
* @package arter\amos\search\i18n\en-GB
* @package arter\amos\documenti\i18n\en-GB
* @category CategoryName
* @author Elite Division S.r.l.
*/
......
......@@ -4,11 +4,11 @@
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @see http://example.com Developers'community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
* @package arter\amos\search\i18n\en-GB
* @package arter\amos\documenti\i18n\en-GB
* @category CategoryName
* @author Elite Division S.r.l.
*/
......
......@@ -4,11 +4,11 @@
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @see http://example.com Developers'community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
* @package arter\amos\search\i18n\it-IT
* @package arter\amos\documenti\i18n\it-IT
* @category CategoryName
* @author Elite Division S.r.l.
*/
......
......@@ -8,10 +8,11 @@
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
* @package arter\amos\models
* @package arter
* @category CategoryName
* @author Elite Division S.r.l.
*/
/**
*/
......@@ -33,4 +34,41 @@ class GeneralSearch extends Model
['tagValues','safe']
];
}
public function filterRequest($toFilterRequest){
/*
pr('here');
die();
*/
/*
pr($toFilterQueryString);
die();
*/
$filteredRequest = [];
foreach($toFilterRequest as $index => $value){
$filteredRequest[$index] = $this->filterQueryString($value);
//pr($filteredRequest[$index]);
}
//pr($fileterdRequest);
//die();
return $filteredRequest;
}
public function filterQueryString($stringToFilter){
$stringToFilter = \yii\helpers\HtmlPurifier::process(trim($stringToFilter));
$stringToFilter = strip_tags($stringToFilter);
$stringToFilter = addslashes($stringToFilter);
/*
pr($stringToFilter);
die();
*/
return $stringToFilter;
}
}
\ No newline at end of file
......@@ -4,15 +4,14 @@
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @see http://example.com Developers'community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
* @package arter\amos\search\views\search
* @package arter\amos\search
* @category CategoryName
* @author Elite Division S.r.l.
*/
use arter\amos\core\icons\AmosIcons;
use arter\amos\core\module\BaseAmosModule;
use arter\amos\core\helpers\Html;
......
<?php
<form name="search" action="/search/search/do-search" data-pjax>
<?php
/**
* Copyright 2020 Art-ER S. Cons. P.A.
* EROI - Emilia Romagna Open Innovation is based on:
......@@ -8,15 +9,12 @@
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
* @package arter\amos\search\views\search
* @package arter
* @category CategoryName
* @author Elite Division S.r.l.
*/
?>
<form name="search" action="/search/search/do-search" data-pjax>
<input type="hidden" name="queryString" value="<?= $queryString ?>"/>
<input type="hidden" name="tagIds" value="<?= $tagIds ?>"/>
<input type="hidden" name="moduleName" value="<?= $moduleName ?>"/>
<input type="hidden" name="tagValues" value="<?= !empty($tagValues) ? implode(',', $tagValues ): ''?>"/>
echo \yii\helpers\Html::input("hidden", "queryString", $queryString); ?>
<?php echo \yii\helpers\Html::input("hidden", "tagIds", $tagIds ); ?>
<?php echo \yii\helpers\Html::input("hidden", "moduleName", $moduleName); ?>
<?php echo \yii\helpers\Html::input("hidden", "tagValues", $moduleName, (!empty($tagValues) ? implode(',', $tagValues ): '')) ?>
</form>
\ No newline at end of file
......@@ -4,11 +4,11 @@
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @see http://example.com Developers'community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
* @package arter\amos\search\views\search
* @package arter\amos\documenti
* @category CategoryName
* @author Elite Division S.r.l.
*/
......@@ -32,16 +32,16 @@ $js = <<<JS
JS;
$this->registerJs($js);
if($tagIds){
if ($tagIds) {
$arrayTagIds = explode(',', $tagIds);
$dataProvider = new \yii\data\ActiveDataProvider([
'query' => \arter\amos\tag\models\Tag::find()->andWhere(['id' => $arrayTagIds])
'query' => \arter\amos\tag\models\Tag::find()->andWhere(['id' => $arrayTagIds])
]);
$columns = [
[
'value' => function ($model) {
$tagName = Html::a($model->nome , '/search/search/index?tagIds='.$model->id);
return "<div class=\"tags-list-single\" data-tag='".$model->id."'>
'value' => function ($model) {
$tagName = Html::a($model->nome, '/search/search/index?tagIds=' . $model->id);
return "<div class=\"tags-list-single\" data-tag='" . $model->id . "'>
<div>" . \arter\amos\core\icons\AmosIcons::show('label') . "</div>
<div>
<p class=\"tag-label\">" . $tagName . "</p>
......@@ -55,29 +55,34 @@ if($tagIds){
}
$moduleLayout = Yii::$app->getModule('layout');
if(!is_null($moduleLayout)) {
if (!is_null($moduleLayout)) {
\arter\amos\layout\assets\SpinnerWaitAsset::register($this);
}
?>
<div class="loading" id="loader" hidden></div>
<?php $form = \arter\amos\core\forms\ActiveForm::begin(['method' => 'get', 'id'=>'formSearch']); ?>
<?php $form = \arter\amos\core\forms\ActiveForm::begin([
'method' => 'get', 'id' => 'formSearch',
'action' => '/'
]); ?>
<div class="toolbar-search">
<?php if(!$tagIds){ ?>
<p id="query-info" class="result_key" data-i18n="<?= AmosSearch::t('amossearch', 'Risultati della ricerca che contengono la parola: <strong>{queryString}</strong>') ?>">
<?php if($queryString){
echo AmosSearch::t('amossearch', 'Risultati della ricerca che contengono la parola: <strong>{queryString}</strong>',['queryString' => $queryString]);
}
<?php if (!$tagIds) { ?>
<p id="query-info" class="result_key"
data-i18n="<?= AmosSearch::t('amossearch', 'Risultati della ricerca che contengono la parola: <strong>{queryString}</strong>') ?>">
<?php if ($queryString) {
echo AmosSearch::t('amossearch', 'Risultati della ricerca che contengono la parola: <strong>{queryString}</strong>', ['queryString' => $queryString]);
}
?>
</p>
?>
</p>
<?php } else { ?>
<p id="query-info" class="result_key" data-i18n="<?= AmosSearch::t('amossearch', 'Risultati della ricerca che contengono i tag:') ?>">
<?= AmosSearch::t('amossearch', 'Risultati della ricerca che contengono i tag:') ?>
<p id="query-info" class="result_key"
data-i18n="<?= AmosSearch::t('amossearch', 'Risultati della ricerca che contengono i tag:') ?>">
<?= AmosSearch::t('amossearch', 'Risultati della ricerca che contengono i tag:') ?>
</p>
<?php echo \arter\amos\core\views\AmosGridView::widget([
<?php echo \arter\amos\core\views\AmosGridView::widget([
'dataProvider' => $dataProvider,
'showPageSummary' => false,
'showPager' => false,
......@@ -85,39 +90,49 @@ if(!is_null($moduleLayout)) {
]);
} ?>
<div class="row container-searchBar <?= $tagIds ? 'hidden' : ''?>">
<!-- <form id="formSearch">-->
<?php echo Html::hiddenInput("currentView", Yii::$app->request->getQueryParam('currentView')); ?>
<div class="col-sm-3"><p class="label-search"><?= AmosSearch::tHtml('amossearch', 'CERCA') ?></p></div>
<div class="col-sm-6">
<div class="form-group">
<input id="queryString" class="form-control" name="queryString" type="text" value="<?= $queryString ?>">
<input id="tagIds" class="form-control hidden" name="tagIds" type="hidden" value="<?= $tagIds ?>">
<div class="help-block"><?= AmosSearch::tHtml('amossearch', 'Inserisci una o più parole chiave per affinare ulteriormente la ricerca') ?></div>
<div class="help-block">
<?= \arter\amos\core\icons\AmosIcons::show('chevron-down',['id' => 'search-chevron'])?>
<a href='javascript:void(0)' id="showadvsearch"><?= AmosSearch::t('amossearch', 'Ricerca avanzata')?></a>
</div>
<div class="row container-searchBar <?= $tagIds ? 'hidden' : '' ?>">
<!-- <form id="formSearch">-->
<?php echo Html::hiddenInput("currentView", Yii::$app->request->getQueryParam('currentView')); ?>
<div class="col-sm-3"><p class="label-search"><?= AmosSearch::tHtml('amossearch', 'CERCA') ?></p></div>
<div class="col-sm-6">
<div class="form-group">
<?php echo Html::input("text", "queryString", $queryString, [
'class' => "form-control",
'id' => "queryString"
]);
?>
<?php echo Html::input("hidden", "tagIds", $tagIds, [
'class' => "form-control hidden",
'id' => "tagIds"
]);
?>
<div class="help-block"><?= AmosSearch::tHtml('amossearch', 'Inserisci una o più parole chiave per affinare ulteriormente la ricerca') ?></div>
<div class="help-block">
<?= \arter\amos\core\icons\AmosIcons::show('chevron-down', ['id' => 'search-chevron']) ?>
<a href='javascript:void(0)'
id="showadvsearch"><?= AmosSearch::t('amossearch', 'Ricerca avanzata') ?></a>
</div>
</div>
</div>
<div class="col-sm-3">
<div>
<?= Html::submitButton(AmosSearch::tHtml('amossearch', 'Cerca'), ['class' => 'btn btn-navigation-primary']) ?>
</div>
<div class="col-sm-3">
<div>
<?= Html::submitButton(AmosSearch::tHtml('amossearch', 'Cerca'), ['class' => 'btn btn-navigation-primary']) ?>
</div>
</div>
<!-- </form>-->
<!-- </form>-->
</div>
</div>
<div id='container-tag-search' class="col-xs-12 <?= $tagIds ? 'hidden' : ''?>" <?= \Yii::$app->request->get('advancedSearch') ? '' : 'hidden'?>>
<div id='container-tag-search'
class="col-xs-12 <?= $tagIds ? 'hidden' : '' ?>" <?= \Yii::$app->request->get('advancedSearch') ? '' : 'hidden' ?>>
<?php
$moduleTag = \Yii::$app->getModule('tag');
if (isset($moduleTag) && $moduleTag->behaviors && class_exists('\arter\amos\tag\widgets\TagGeneralSearchWidget')): ?>
<div class="col-xs-12">
<h3><?= AmosSearch::t('amossearch', 'Tag aree di interesse')?> </h3>
<h3><?= AmosSearch::t('amossearch', 'Tag aree di interesse') ?> </h3>
<?php
$params = \Yii::$app->request->getQueryParams();
......@@ -139,6 +154,6 @@ if(!is_null($moduleLayout)) {
</div>
<?php endif; ?>
<?php \arter\amos\core\forms\ActiveForm::end();?>
<?php \arter\amos\core\forms\ActiveForm::end(); ?>
</div>
......@@ -8,11 +8,12 @@
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
* @package arter\amos\search\views\search
* @package arter
* @category CategoryName
* @author Elite Division S.r.l.
*/
use arter\amos\core\views\ListView;
use arter\amos\core\icons\AmosIcons;
use arter\amos\search\AmosSearch;
......@@ -25,6 +26,17 @@ Pjax::begin([
$queryString = \yii\helpers\HtmlPurifier::process(trim($queryString));
$tagIds = \yii\helpers\HtmlPurifier::process(trim($tagIds));
$queryString = strip_tags($queryString);
$queryString = addslashes($queryString);
$tagIds = strip_tags($tagIds);
$tagIds = addslashes($tagIds);
/*
pr($queryString);
die();
*/
echo $this->render('_pjaxForm', [
'moduleName' => $moduleName,
'tagIds' => $tagIds,
......
......@@ -4,7 +4,7 @@
* EROI - Emilia Romagna Open Innovation is based on:
* https://www.open2.0.regione.lombardia.it
*
* @see https://repo.art-er.it Developers' community
* @see http://example.com Developers'community
* @license GPLv3
* @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3
*
......@@ -32,7 +32,14 @@ $this->params['breadcrumbs'][] = ['label' => Yii::$app->session->get('previousTi
$this->params['breadcrumbs'][] = AmosSearch::t('amossearch', '#search_title');
$queryString = \yii\helpers\HtmlPurifier::process(trim($queryString));
$queryString = strip_tags($queryString);
$queryString = addslashes($queryString);
$tagIds = \yii\helpers\HtmlPurifier::process(trim($tagIds));
$tagIds = strip_tags($tagIds);
$tagIds = addslashes($tagIds);
echo $this->render('_search', [
'tagIds' => $tagIds,
......@@ -40,6 +47,7 @@ echo $this->render('_search', [
'originAction' => Yii::$app->controller->action->id,
'modelSearch' => $modelSearch
]);
?>
<div class="row">
<div class="col-xs-12 results-info">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment