|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* _ __ __ _____ _____ ___ ____ _____ |
|
5
|
|
|
* | | / // // ___//_ _// || __||_ _| |
|
6
|
|
|
* | |/ // /(__ ) / / / /| || | | | |
|
7
|
|
|
* |___//_//____/ /_/ /_/ |_||_| |_| |
|
8
|
|
|
* @link https://vistart.me/ |
|
9
|
|
|
* @copyright Copyright (c) 2016 - 2017 vistart |
|
10
|
|
|
* @license https://vistart.me/license/ |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace rhosocial\user\widgets; |
|
14
|
|
|
|
|
15
|
|
|
use rhosocial\user\UserSearch; |
|
16
|
|
|
use yii\base\InvalidConfigException; |
|
17
|
|
|
use yii\base\Widget; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @version 1.0 |
|
21
|
|
|
* @author vistart <[email protected]> |
|
22
|
|
|
*/ |
|
23
|
|
|
class UserProfileSearchWidget extends Widget |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* @var string |
|
27
|
|
|
*/ |
|
28
|
|
|
public $formId = 'user-profile-search-form'; |
|
29
|
|
|
/** |
|
30
|
|
|
* @var null|array |
|
31
|
|
|
*/ |
|
32
|
|
|
public $formConfig = null; |
|
33
|
|
|
/** |
|
34
|
|
|
* @var UserSearch |
|
35
|
|
|
*/ |
|
36
|
|
|
public $model; |
|
37
|
|
|
/** |
|
38
|
|
|
* @var string The filename of view which displays all the search fields. |
|
39
|
|
|
*/ |
|
40
|
|
|
public $fieldsView = 'user-profile-search-fields'; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @throws InvalidConfigException |
|
44
|
|
|
*/ |
|
45
|
|
|
public function init() |
|
46
|
|
|
{ |
|
47
|
|
|
if ($this->model == null) { |
|
48
|
|
|
throw new InvalidConfigException("The search model should not be empty."); |
|
49
|
|
|
} |
|
50
|
|
|
if ($this->formConfig == null) { |
|
51
|
|
|
$this->formConfig = [ |
|
52
|
|
|
'id' => !empty($this->formId) ? $this->formId : 'user-profile-search-form', |
|
53
|
|
|
'action' => ['index'], |
|
54
|
|
|
'method' => 'get', |
|
55
|
|
|
]; |
|
56
|
|
|
} |
|
57
|
|
|
if (empty($this->fieldsView)) { |
|
58
|
|
|
$this->fieldsView = 'user-profile-search-fields'; |
|
59
|
|
|
} |
|
60
|
|
|
parent::init(); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @return string |
|
65
|
|
|
*/ |
|
66
|
|
|
public function run() |
|
67
|
|
|
{ |
|
68
|
|
|
return $this->render('user-profile-search', [ |
|
69
|
|
|
'model' => $this->model, |
|
70
|
|
|
'formId' => $this->formId, |
|
71
|
|
|
'formConfig' => $this->formConfig, |
|
72
|
|
|
'fieldsView' => $this->fieldsView, |
|
73
|
|
|
]); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|