init
This commit is contained in:
44
vendor/yiisoft/yii2-debug/models/search/Base.php
vendored
Normal file
44
vendor/yiisoft/yii2-debug/models/search/Base.php
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* @link http://www.yiiframework.com/
|
||||
* @copyright Copyright (c) 2008 Yii Software LLC
|
||||
* @license http://www.yiiframework.com/license/
|
||||
*/
|
||||
|
||||
namespace yii\debug\models\search;
|
||||
|
||||
use yii\base\Model;
|
||||
use yii\debug\components\search\Filter;
|
||||
use yii\debug\components\search\matchers;
|
||||
|
||||
/**
|
||||
* Base search model
|
||||
*
|
||||
* @author Mark Jebri <mark.github@yandex.ru>
|
||||
* @since 2.0
|
||||
*/
|
||||
class Base extends Model
|
||||
{
|
||||
/**
|
||||
* Adds filtering condition for a given attribute
|
||||
*
|
||||
* @param Filter $filter filter instance
|
||||
* @param string $attribute attribute to filter
|
||||
* @param bool $partial if partial match should be used
|
||||
*/
|
||||
public function addCondition(Filter $filter, $attribute, $partial = false)
|
||||
{
|
||||
$value = $this->$attribute;
|
||||
|
||||
if (mb_strpos($value, '>') !== false) {
|
||||
$value = (int) str_replace('>', '', $value);
|
||||
$filter->addMatcher($attribute, new matchers\GreaterThan(['value' => $value]));
|
||||
|
||||
} elseif (mb_strpos($value, '<') !== false) {
|
||||
$value = (int) str_replace('<', '', $value);
|
||||
$filter->addMatcher($attribute, new matchers\LowerThan(['value' => $value]));
|
||||
} else {
|
||||
$filter->addMatcher($attribute, new matchers\SameAs(['value' => $value, 'partial' => $partial]));
|
||||
}
|
||||
}
|
||||
}
|
||||
80
vendor/yiisoft/yii2-debug/models/search/Db.php
vendored
Normal file
80
vendor/yiisoft/yii2-debug/models/search/Db.php
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* @link http://www.yiiframework.com/
|
||||
* @copyright Copyright (c) 2008 Yii Software LLC
|
||||
* @license http://www.yiiframework.com/license/
|
||||
*/
|
||||
|
||||
namespace yii\debug\models\search;
|
||||
|
||||
use yii\data\ArrayDataProvider;
|
||||
use yii\debug\components\search\Filter;
|
||||
|
||||
/**
|
||||
* Search model for current request database queries.
|
||||
*
|
||||
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||
* @author Mark Jebri <mark.github@yandex.ru>
|
||||
* @since 2.0
|
||||
*/
|
||||
class Db extends Base
|
||||
{
|
||||
/**
|
||||
* @var string type of the input search value
|
||||
*/
|
||||
public $type;
|
||||
/**
|
||||
* @var integer query attribute input search value
|
||||
*/
|
||||
public $query;
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['type', 'query'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'type' => 'Type',
|
||||
'query' => 'Query',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns data provider with filled models. Filter applied if needed.
|
||||
*
|
||||
* @param array $models data to return provider for
|
||||
* @return \yii\data\ArrayDataProvider
|
||||
*/
|
||||
public function search($models)
|
||||
{
|
||||
$dataProvider = new ArrayDataProvider([
|
||||
'allModels' => $models,
|
||||
'pagination' => false,
|
||||
'sort' => [
|
||||
'attributes' => ['duration', 'seq', 'type', 'query', 'duplicate'],
|
||||
],
|
||||
]);
|
||||
|
||||
if (!$this->validate()) {
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
$filter = new Filter();
|
||||
$this->addCondition($filter, 'type', true);
|
||||
$this->addCondition($filter, 'query', true);
|
||||
$dataProvider->allModels = $filter->filter($models);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
||||
133
vendor/yiisoft/yii2-debug/models/search/Debug.php
vendored
Normal file
133
vendor/yiisoft/yii2-debug/models/search/Debug.php
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
/**
|
||||
* @link http://www.yiiframework.com/
|
||||
* @copyright Copyright (c) 2008 Yii Software LLC
|
||||
* @license http://www.yiiframework.com/license/
|
||||
*/
|
||||
|
||||
namespace yii\debug\models\search;
|
||||
|
||||
use yii\data\ArrayDataProvider;
|
||||
use yii\debug\components\search\Filter;
|
||||
|
||||
/**
|
||||
* Search model for requests manifest data.
|
||||
*
|
||||
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||
* @author Mark Jebri <mark.github@yandex.ru>
|
||||
* @since 2.0
|
||||
*/
|
||||
class Debug extends Base
|
||||
{
|
||||
/**
|
||||
* @var string tag attribute input search value
|
||||
*/
|
||||
public $tag;
|
||||
/**
|
||||
* @var string ip attribute input search value
|
||||
*/
|
||||
public $ip;
|
||||
/**
|
||||
* @var string method attribute input search value
|
||||
*/
|
||||
public $method;
|
||||
/**
|
||||
* @var integer ajax attribute input search value
|
||||
*/
|
||||
public $ajax;
|
||||
/**
|
||||
* @var string url attribute input search value
|
||||
*/
|
||||
public $url;
|
||||
/**
|
||||
* @var string status code attribute input search value
|
||||
*/
|
||||
public $statusCode;
|
||||
/**
|
||||
* @var integer sql count attribute input search value
|
||||
*/
|
||||
public $sqlCount;
|
||||
/**
|
||||
* @var integer total mail count attribute input search value
|
||||
*/
|
||||
public $mailCount;
|
||||
/**
|
||||
* @var array critical codes, used to determine grid row options.
|
||||
*/
|
||||
public $criticalCodes = [400, 404, 500];
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['tag', 'ip', 'method', 'ajax', 'url', 'statusCode', 'sqlCount', 'mailCount'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'tag' => 'Tag',
|
||||
'ip' => 'Ip',
|
||||
'method' => 'Method',
|
||||
'ajax' => 'Ajax',
|
||||
'url' => 'url',
|
||||
'statusCode' => 'Status code',
|
||||
'sqlCount' => 'Query Count',
|
||||
'mailCount' => 'Mail Count',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns data provider with filled models. Filter applied if needed.
|
||||
* @param array $params an array of parameter values indexed by parameter names
|
||||
* @param array $models data to return provider for
|
||||
* @return \yii\data\ArrayDataProvider
|
||||
*/
|
||||
public function search($params, $models)
|
||||
{
|
||||
$dataProvider = new ArrayDataProvider([
|
||||
'allModels' => $models,
|
||||
'sort' => [
|
||||
'attributes' => ['method', 'ip', 'tag', 'time', 'statusCode', 'sqlCount', 'mailCount'],
|
||||
],
|
||||
'pagination' => [
|
||||
'pageSize' => 50,
|
||||
],
|
||||
]);
|
||||
|
||||
if (!($this->load($params) && $this->validate())) {
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
$filter = new Filter();
|
||||
$this->addCondition($filter, 'tag', true);
|
||||
$this->addCondition($filter, 'ip', true);
|
||||
$this->addCondition($filter, 'method');
|
||||
$this->addCondition($filter, 'ajax');
|
||||
$this->addCondition($filter, 'url', true);
|
||||
$this->addCondition($filter, 'statusCode');
|
||||
$this->addCondition($filter, 'sqlCount');
|
||||
$this->addCondition($filter, 'mailCount');
|
||||
$dataProvider->allModels = $filter->filter($models);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if code is critical.
|
||||
*
|
||||
* @param int $code
|
||||
* @return bool
|
||||
*/
|
||||
public function isCodeCritical($code)
|
||||
{
|
||||
return in_array($code, $this->criticalCodes, false);
|
||||
}
|
||||
}
|
||||
90
vendor/yiisoft/yii2-debug/models/search/Log.php
vendored
Normal file
90
vendor/yiisoft/yii2-debug/models/search/Log.php
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
/**
|
||||
* @link http://www.yiiframework.com/
|
||||
* @copyright Copyright (c) 2008 Yii Software LLC
|
||||
* @license http://www.yiiframework.com/license/
|
||||
*/
|
||||
|
||||
namespace yii\debug\models\search;
|
||||
|
||||
use yii\data\ArrayDataProvider;
|
||||
use yii\debug\components\search\Filter;
|
||||
|
||||
/**
|
||||
* Search model for current request log.
|
||||
*
|
||||
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||
* @author Mark Jebri <mark.github@yandex.ru>
|
||||
* @since 2.0
|
||||
*/
|
||||
class Log extends Base
|
||||
{
|
||||
/**
|
||||
* @var string ip attribute input search value
|
||||
*/
|
||||
public $level;
|
||||
/**
|
||||
* @var string method attribute input search value
|
||||
*/
|
||||
public $category;
|
||||
/**
|
||||
* @var integer message attribute input search value
|
||||
*/
|
||||
public $message;
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['level', 'message', 'category'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'level' => 'Level',
|
||||
'category' => 'Category',
|
||||
'message' => 'Message',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns data provider with filled models. Filter applied if needed.
|
||||
*
|
||||
* @param array $params an array of parameter values indexed by parameter names
|
||||
* @param array $models data to return provider for
|
||||
* @return \yii\data\ArrayDataProvider
|
||||
*/
|
||||
public function search($params, $models)
|
||||
{
|
||||
$dataProvider = new ArrayDataProvider([
|
||||
'allModels' => $models,
|
||||
'pagination' => false,
|
||||
'sort' => [
|
||||
'attributes' => ['time', 'level', 'category', 'message'],
|
||||
'defaultOrder' => [
|
||||
'time' => SORT_ASC,
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
if (!($this->load($params) && $this->validate())) {
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
$filter = new Filter();
|
||||
$this->addCondition($filter, 'level');
|
||||
$this->addCondition($filter, 'category', true);
|
||||
$this->addCondition($filter, 'message', true);
|
||||
$dataProvider->allModels = $filter->filter($models);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
||||
124
vendor/yiisoft/yii2-debug/models/search/Mail.php
vendored
Normal file
124
vendor/yiisoft/yii2-debug/models/search/Mail.php
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
/**
|
||||
* @link http://www.yiiframework.com/
|
||||
* @copyright Copyright (c) 2008 Yii Software LLC
|
||||
* @license http://www.yiiframework.com/license/
|
||||
*/
|
||||
|
||||
namespace yii\debug\models\search;
|
||||
|
||||
use yii\data\ArrayDataProvider;
|
||||
use yii\debug\components\search\Filter;
|
||||
|
||||
/**
|
||||
* Mail represents the model behind the search form about current send emails.
|
||||
*
|
||||
* @author Mark Jebri <mark.github@yandex.ru>
|
||||
* @since 2.0
|
||||
*/
|
||||
class Mail extends Base
|
||||
{
|
||||
/**
|
||||
* @var string from attribute input search value
|
||||
*/
|
||||
public $from;
|
||||
/**
|
||||
* @var string to attribute input search value
|
||||
*/
|
||||
public $to;
|
||||
/**
|
||||
* @var string reply attribute input search value
|
||||
*/
|
||||
public $reply;
|
||||
/**
|
||||
* @var string cc attribute input search value
|
||||
*/
|
||||
public $cc;
|
||||
/**
|
||||
* @var string bcc attribute input search value
|
||||
*/
|
||||
public $bcc;
|
||||
/**
|
||||
* @var string subject attribute input search value
|
||||
*/
|
||||
public $subject;
|
||||
/**
|
||||
* @var string body attribute input search value
|
||||
*/
|
||||
public $body;
|
||||
/**
|
||||
* @var string charset attribute input search value
|
||||
*/
|
||||
public $charset;
|
||||
/**
|
||||
* @var string headers attribute input search value
|
||||
*/
|
||||
public $headers;
|
||||
/**
|
||||
* @var string file attribute input search value
|
||||
*/
|
||||
public $file;
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['from', 'to', 'reply', 'cc', 'bcc', 'subject', 'body', 'charset'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'from' => 'From',
|
||||
'to' => 'To',
|
||||
'reply' => 'Reply',
|
||||
'cc' => 'Copy receiver',
|
||||
'bcc' => 'Hidden copy receiver',
|
||||
'subject' => 'Subject',
|
||||
'charset' => 'Charset'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns data provider with filled models. Filter applied if needed.
|
||||
* @param array $params
|
||||
* @param array $models
|
||||
* @return \yii\data\ArrayDataProvider
|
||||
*/
|
||||
public function search($params, $models)
|
||||
{
|
||||
$dataProvider = new ArrayDataProvider([
|
||||
'allModels' => $models,
|
||||
'pagination' => [
|
||||
'pageSize' => 20,
|
||||
],
|
||||
'sort' => [
|
||||
'attributes' => ['from', 'to', 'reply', 'cc', 'bcc', 'subject', 'body', 'charset'],
|
||||
],
|
||||
]);
|
||||
|
||||
if (!($this->load($params) && $this->validate())) {
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
$filter = new Filter();
|
||||
$this->addCondition($filter, 'from', true);
|
||||
$this->addCondition($filter, 'to', true);
|
||||
$this->addCondition($filter, 'reply', true);
|
||||
$this->addCondition($filter, 'cc', true);
|
||||
$this->addCondition($filter, 'bcc', true);
|
||||
$this->addCondition($filter, 'subject', true);
|
||||
$this->addCondition($filter, 'body', true);
|
||||
$this->addCondition($filter, 'charset', true);
|
||||
$dataProvider->allModels = $filter->filter($models);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
||||
84
vendor/yiisoft/yii2-debug/models/search/Profile.php
vendored
Normal file
84
vendor/yiisoft/yii2-debug/models/search/Profile.php
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
* @link http://www.yiiframework.com/
|
||||
* @copyright Copyright (c) 2008 Yii Software LLC
|
||||
* @license http://www.yiiframework.com/license/
|
||||
*/
|
||||
|
||||
namespace yii\debug\models\search;
|
||||
|
||||
use yii\data\ArrayDataProvider;
|
||||
use yii\debug\components\search\Filter;
|
||||
|
||||
/**
|
||||
* Search model for current request profiling log.
|
||||
*
|
||||
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||
* @author Mark Jebri <mark.github@yandex.ru>
|
||||
* @since 2.0
|
||||
*/
|
||||
class Profile extends Base
|
||||
{
|
||||
/**
|
||||
* @var string method attribute input search value
|
||||
*/
|
||||
public $category;
|
||||
/**
|
||||
* @var integer info attribute input search value
|
||||
*/
|
||||
public $info;
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['category', 'info'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'category' => 'Category',
|
||||
'info' => 'Info',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns data provider with filled models. Filter applied if needed.
|
||||
*
|
||||
* @param array $params an array of parameter values indexed by parameter names
|
||||
* @param array $models data to return provider for
|
||||
* @return \yii\data\ArrayDataProvider
|
||||
*/
|
||||
public function search($params, $models)
|
||||
{
|
||||
$dataProvider = new ArrayDataProvider([
|
||||
'allModels' => $models,
|
||||
'pagination' => false,
|
||||
'sort' => [
|
||||
'attributes' => ['category', 'seq', 'duration', 'info'],
|
||||
'defaultOrder' => [
|
||||
'duration' => SORT_DESC,
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
if (!($this->load($params) && $this->validate())) {
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
$filter = new Filter();
|
||||
$this->addCondition($filter, 'category', true);
|
||||
$this->addCondition($filter, 'info', true);
|
||||
$dataProvider->allModels = $filter->filter($models);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
||||
116
vendor/yiisoft/yii2-debug/models/search/User.php
vendored
Normal file
116
vendor/yiisoft/yii2-debug/models/search/User.php
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
/**
|
||||
* @link http://www.yiiframework.com/
|
||||
* @copyright Copyright (c) 2008 Yii Software LLC
|
||||
* @license http://www.yiiframework.com/license/
|
||||
*/
|
||||
|
||||
namespace yii\debug\models\search;
|
||||
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use yii\db\ActiveRecord;
|
||||
|
||||
/**
|
||||
* Search model for implementation of IdentityInterface
|
||||
*
|
||||
* @author Semen Dubina <yii2debug@sam002.net>
|
||||
* @since 2.0.10
|
||||
*/
|
||||
class User extends Model
|
||||
{
|
||||
/**
|
||||
* @var Model implementation of IdentityInterface
|
||||
*/
|
||||
public $identityImplement = null;
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
if (\Yii::$app->user && \Yii::$app->user->identityClass) {
|
||||
$identityImplementation = new \Yii::$app->user->identityClass();
|
||||
if ($identityImplementation instanceof Model) {
|
||||
$this->identityImplement = $identityImplementation;
|
||||
}
|
||||
}
|
||||
parent::init();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
return $this->identityImplement->__get($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function __set($name, $value)
|
||||
{
|
||||
return $this->identityImplement->__set($name, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [[array_keys($this->identityImplement->getAttributes()), 'safe']];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributes()
|
||||
{
|
||||
return $this->identityImplement->attributes();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
if ($this->identityImplement instanceof ActiveRecord) {
|
||||
return $this->serachActiveDataProvider($params);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search method for ActiveRecord
|
||||
* @param array $params the data array to load model.
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
private function serachActiveDataProvider($params)
|
||||
{
|
||||
/** @var ActiveRecord $model */
|
||||
$model = $this->identityImplement;
|
||||
$query = $model::find();
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
]);
|
||||
|
||||
if (!($this->load($params) && $this->validate())) {
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
foreach ($model::getTableSchema()->columns as $attribute => $column) {
|
||||
if ($column->phpType === 'string') {
|
||||
$query->andFilterWhere(['like', $attribute, $model->getAttribute($attribute)]);
|
||||
} else {
|
||||
$query->andFilterWhere([$attribute => $model->getAttribute($attribute)]);
|
||||
}
|
||||
}
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
}
|
||||
28
vendor/yiisoft/yii2-debug/models/search/UserSearchInterface.php
vendored
Normal file
28
vendor/yiisoft/yii2-debug/models/search/UserSearchInterface.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* @link http://www.yiiframework.com/
|
||||
* @copyright Copyright (c) 2008 Yii Software LLC
|
||||
* @license http://www.yiiframework.com/license/
|
||||
*/
|
||||
|
||||
namespace yii\debug\models\search;
|
||||
|
||||
use yii\data\DataProviderInterface;
|
||||
use yii\web\IdentityInterface;
|
||||
|
||||
/**
|
||||
* UserSearchInterface is the interface that should be implemented by a class
|
||||
* providing identity information and search method.
|
||||
*
|
||||
* @author Semen Dubina <yii2debug@sam002.net>
|
||||
* @since 2.0.10
|
||||
*/
|
||||
interface UserSearchInterface extends IdentityInterface
|
||||
{
|
||||
/**
|
||||
* Creates data provider instance with search query applied.
|
||||
* @param array $params the data array to load model.
|
||||
* @return DataProviderInterface
|
||||
*/
|
||||
public function search($params);
|
||||
}
|
||||
Reference in New Issue
Block a user