-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed url manager issue with parameterized routes, crawler uses active
data provider #1244, remove click data
- Loading branch information
Showing
10 changed files
with
233 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,14 +5,64 @@ | |
use Yii; | ||
use luya\crawler\models\Index; | ||
use yii\helpers\Html; | ||
use yii\data\ActiveDataProvider; | ||
use luya\crawler\models\Searchdata; | ||
use yii\data\ArrayDataProvider; | ||
|
||
/** | ||
* Crawler Index Controller. | ||
* | ||
* Returns an {{\yii\data\ActiveDataProvider}} within $provider. | ||
* | ||
* @author Basil Suter <[email protected]> | ||
*/ | ||
class DefaultController extends \luya\web\Controller | ||
{ | ||
public function actionIndex($query = null) | ||
/** | ||
* Get search overview. | ||
* | ||
* The index action will return an active data provider object inside the $provider variable: | ||
* | ||
* ```php | ||
* foreach ($provider->models as $item) { | ||
* var_dump($item); | ||
* } | ||
* ``` | ||
* | ||
* @return string | ||
*/ | ||
public function actionIndex($query = null, $page = null) | ||
{ | ||
$language = Yii::$app->composition->getKey('langShortCode'); | ||
|
||
if (empty($query)) { | ||
$provider = new ArrayDataProvider(); | ||
} else { | ||
$activeQuery = Index::activeQuerySearch($query, $language); | ||
|
||
$provider = new ActiveDataProvider([ | ||
'query' => $activeQuery, | ||
'pagination' => [ | ||
'defaultPageSize' => $this->module->searchResultPageSize, | ||
'route' => '/crawler/default', | ||
'params' => ['query' => $query, 'page' => $page] | ||
], | ||
]); | ||
|
||
$searchData = new Searchdata(); | ||
$searchData->detachBehavior('LogBehavior'); | ||
$searchData->attributes = [ | ||
'query' => $query, | ||
'results' => $provider->totalCount, | ||
'timestamp' => time(), | ||
'language' => $language, | ||
]; | ||
$searchData->save(false); | ||
} | ||
|
||
return $this->render('index', [ | ||
'query' => Html::encode($query), | ||
'results' => Index::searchByQuery($query, Yii::$app->composition->getKey('langShortCode')), | ||
'provider' => $provider, | ||
]); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.