You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

125 line
3.0KB

  1. <?php
  2. /**
  3. * @link http://www.yiiframework.com/
  4. * @copyright Copyright (c) 2008 Yii Software LLC
  5. * @license http://www.yiiframework.com/license/
  6. */
  7. namespace yii\debug\models\search;
  8. use yii\data\ArrayDataProvider;
  9. use yii\debug\components\search\Filter;
  10. /**
  11. * Mail represents the model behind the search form about current send emails.
  12. *
  13. * @author Mark Jebri <mark.github@yandex.ru>
  14. * @since 2.0
  15. */
  16. class Mail extends Base
  17. {
  18. /**
  19. * @var string from attribute input search value
  20. */
  21. public $from;
  22. /**
  23. * @var string to attribute input search value
  24. */
  25. public $to;
  26. /**
  27. * @var string reply attribute input search value
  28. */
  29. public $reply;
  30. /**
  31. * @var string cc attribute input search value
  32. */
  33. public $cc;
  34. /**
  35. * @var string bcc attribute input search value
  36. */
  37. public $bcc;
  38. /**
  39. * @var string subject attribute input search value
  40. */
  41. public $subject;
  42. /**
  43. * @var string body attribute input search value
  44. */
  45. public $body;
  46. /**
  47. * @var string charset attribute input search value
  48. */
  49. public $charset;
  50. /**
  51. * @var string headers attribute input search value
  52. */
  53. public $headers;
  54. /**
  55. * @var string file attribute input search value
  56. */
  57. public $file;
  58. /**
  59. * @inheritdoc
  60. */
  61. public function rules()
  62. {
  63. return [
  64. [['from', 'to', 'reply', 'cc', 'bcc', 'subject', 'body', 'charset'], 'safe'],
  65. ];
  66. }
  67. /**
  68. * @inheritdoc
  69. */
  70. public function attributeLabels()
  71. {
  72. return [
  73. 'from' => 'From',
  74. 'to' => 'To',
  75. 'reply' => 'Reply',
  76. 'cc' => 'Copy receiver',
  77. 'bcc' => 'Hidden copy receiver',
  78. 'subject' => 'Subject',
  79. 'charset' => 'Charset'
  80. ];
  81. }
  82. /**
  83. * Returns data provider with filled models. Filter applied if needed.
  84. * @param array $params
  85. * @param array $models
  86. * @return \yii\data\ArrayDataProvider
  87. */
  88. public function search($params, $models)
  89. {
  90. $dataProvider = new ArrayDataProvider([
  91. 'allModels' => $models,
  92. 'pagination' => [
  93. 'pageSize' => 20,
  94. ],
  95. 'sort' => [
  96. 'attributes' => ['from', 'to', 'reply', 'cc', 'bcc', 'subject', 'body', 'charset'],
  97. ],
  98. ]);
  99. if (!($this->load($params) && $this->validate())) {
  100. return $dataProvider;
  101. }
  102. $filter = new Filter();
  103. $this->addCondition($filter, 'from', true);
  104. $this->addCondition($filter, 'to', true);
  105. $this->addCondition($filter, 'reply', true);
  106. $this->addCondition($filter, 'cc', true);
  107. $this->addCondition($filter, 'bcc', true);
  108. $this->addCondition($filter, 'subject', true);
  109. $this->addCondition($filter, 'body', true);
  110. $this->addCondition($filter, 'charset', true);
  111. $dataProvider->allModels = $filter->filter($models);
  112. return $dataProvider;
  113. }
  114. }