1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35:
36:
37: 38: 39:
40: abstract class ProfileGridViewWidget extends GridViewWidget {
41:
42: public $viewFile = '_gridViewProfileWidget';
43:
44: private static $_JSONPropertiesStructure;
45:
46: 47: 48:
49: protected $_model;
50:
51: 52: 53:
54: protected $_dataProvider;
55:
56: 57: 58:
59: private $_gridViewConfig;
60:
61: 62: 63:
64: abstract protected function getModel ();
65:
66: 67: 68:
69: protected function afterGetModel () {}
70:
71: 72: 73:
74: public static function getJSONPropertiesStructure () {
75: if (!isset (self::$_JSONPropertiesStructure)) {
76: self::$_JSONPropertiesStructure = array_merge (
77: parent::getJSONPropertiesStructure (),
78: array (
79: 'dbPersistentGridSettings' => false,
80: )
81: );
82: }
83: return self::$_JSONPropertiesStructure;
84: }
85:
86: public function getTemplate () {
87: $model = $this->getModel ();
88: $moduleName = strtolower (X2Model::getModuleName (get_class ($model)));
89: return "<div class='submenu-title-bar widget-title-bar $moduleName'>{widgetLabel}{closeButton}{minimizeButton}{settingsMenu}</div>{widgetContents}";
90: }
91:
92: 93: 94:
95: public function getGridViewConfig () {
96: if (!isset ($this->_gridViewConfig)) {
97: $this->_gridViewConfig = array_merge (parent::getGridViewConfig (), array (
98: 'sortableWidget' => $this,
99: 'id'=>$this->getWidgetKey (),
100: 'enableScrollOnPageChange' => false,
101: 'possibleResultsPerPage' => array(5, 10, 20, 30, 40, 50, 75, 100),
102: 'buttons'=>array('advancedSearch','clearFilters','columnSelector','autoResize'),
103: 'template'=>
104: CHtml::openTag ('div', X2Html::mergeHtmlOptions (array (
105: 'class' => 'page-title'
106: ), array (
107: 'style' =>
108: !CPropertyValue::ensureBoolean (
109: $this->getWidgetProperty('showHeader')) &&
110: !CPropertyValue::ensureBoolean (
111: $this->getWidgetProperty('hideFullHeader')) ?
112: 'display: none;' : ''
113:
114: ))).
115: '<h2 class="grid-widget-title-bar-dummy-element">'.
116: '</h2>{buttons}{filterHint}'.
117:
118: '{summary}{topPager}<div class="clear"></div></div>{items}{pager}',
119: 'fixedHeader'=>false,
120: 'dataProvider'=>$this->dataProvider,
121: 'filter'=>$this->model,
122: 'pager'=>array('class'=>'CLinkPager','maxButtonCount'=>10),
123: 'modelName'=> get_class ($this->model),
124: 'viewName'=>'profile',
125: 'gvSettingsName'=> get_called_class ().$this->widgetUID,
126: 'enableControls'=>true,
127: 'fullscreen'=>false,
128: 'enableSelectAllOnAllPages' => false,
129: ));
130: }
131: return $this->_gridViewConfig;
132: }
133:
134: protected function () {
135: return
136: '<li class="grid-settings-button">'.
137: X2Html::fa('fa-gear').
138: Yii::t('profile', 'Widget Grid Settings').'
139: </li>'.parent::getSettingsMenuContentEntries ();
140: }
141:
142: 143: 144: 145: 146:
147: protected function getCss () {
148: if (!isset ($this->_css)) {
149: $this->_css = array_merge (
150: parent::getCss (),
151: array (
152: 'gridViewWidgetCss' => "
153: .sortable-widget-container .x2grid-header-container {
154: width: 100% !important;
155: }
156:
157: .sortable-widget-container .page-title {
158: border-radius: 0 !important;
159: }
160:
161: .sortable-widget-container .pager {
162: float: none;
163: -moz-border-radius: 0px 0px 4px 4px;
164: -o-border-radius: 0px 0px 4px 4px;
165: -webkit-border-radius: 0px 0px 4px 4px;
166: border-radius: 0px 0px 4px 4px;
167: }
168:
169: .sortable-widget-container div.page-title {
170: background:#cfcfcf;
171: border-bottom: 1px solid #cfcfcf;
172: }
173:
174: .sortable-widget-container div.page-title .x2-minimal-select {
175: border:1px solid #cfcfcf !important;
176: }
177:
178: .sortable-widget-container div.page-title .x2-minimal-select:hover,
179: .sortable-widget-container div.page-title .x2-minimal-select:focus {
180: border: 1px solid #A0A0A0;
181: background: rgb(221, 221, 221);
182: }
183:
184: .sortable-widget-container div.page-title .x2-minimal-select:hover + .after-x2-minimal-select-outer > .after-x2-minimal-select,
185: .sortable-widget-container div.page-title .x2-minimal-select:focus + .after-x2-minimal-select-outer > .after-x2-minimal-select {
186:
187: background: rgb(221, 221, 221);
188: background-image: url(".Yii::app()->theme->getBaseUrl ()."/images/icons/Collapse_Widget.png) !important;
189: background-repeat: no-repeat !important;
190: background-position: 7px !important;
191: }
192:
193: .grid-widget-title-bar-dummy-element {
194: height: 33px;
195: display: none !important;
196: }
197:
198: @media (max-width: 657px) {
199: .grid-widget-title-bar-dummy-element {
200: display: block !important;
201: }
202: .sortable-widget-container .x2-gridview-mass-action-buttons {
203: top: -41px;
204: right: -20px;
205: }
206: .sortable-widget-container .show-top-buttons .x2-gridview-mass-action-buttons {
207: right: -24px;
208: }
209: }
210:
211: .sortable-widget-container .grid-view .page-title {
212: min-height: 34px;
213: height: auto;
214: }
215: "
216: )
217: );
218: }
219: return $this->_css;
220: }
221:
222: 223: 224:
225: protected function getDataProvider () {
226: if (!isset ($this->_dataProvider)) {
227: $resultsPerPage = $this->getWidgetProperty (
228: 'resultsPerPage');
229: $this->_dataProvider = $this->model->search (
230: $resultsPerPage, get_called_class ().$this->widgetUID);
231: }
232: return $this->_dataProvider;
233: }
234:
235: protected function () {
236: return
237: '<div id="grid-settings-dialog-'.$this->widgetKey.'"
238: style="display: none;">'.
239: '<div>'.Yii::t('profile', 'Use persistent filter and sort settings?').'</div>'.
240: CHtml::checkbox (
241: 'dbPersistentGridSettings',
242: self::getJSONProperty (
243: $this->profile, 'dbPersistentGridSettings', $this->widgetType,
244: $this->widgetUID),
245: array (
246: 'id' => 'dbPersistentGridSettings-'.$this->widgetKey,
247: )
248: ).
249: X2Html::hint (
250: Yii::t(
251: 'profile', 'Leaving this box checked will prevent your grid filter and '.
252: 'sort settings from being reset when you log out of the app.'),
253: false, null, true, true).
254: '</div>'.parent::getSettingsMenuContentDialogs ();
255: }
256:
257: }
258: ?>
259: