Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
MyListView.php
1 <?php
2  /*********************************************************************************
3  * Zurmo is a customer relationship management program developed by
4  * Zurmo, Inc. Copyright (C) 2017 Zurmo Inc.
5  *
6  * Zurmo is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY ZURMO, ZURMO DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  *
13  * Zurmo is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  *
23  * You can contact Zurmo, Inc. with a mailing address at 27 North Wacker Drive
24  * Suite 370 Chicago, IL 60606. or at email address contact@zurmo.com.
25  *
26  * The interactive user interfaces in original and modified versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  *
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the Zurmo
32  * logo and Zurmo copyright notice. If the display of the logo is not reasonably
33  * feasible for technical reasons, the Appropriate Legal Notices must display the words
34  * "Copyright Zurmo Inc. 2017. All rights reserved".
35  ********************************************************************************/
36 
41  abstract class MyListView extends ListView implements PortletViewInterface
42  {
43  protected $params;
44  protected $viewData;
45  protected $uniqueLayoutId;
46 
47  public function __construct($viewData, $params, $uniqueLayoutId)
48  {
49  assert('isset($params["portletId"])');
50  $this->viewData = $viewData;
51  $this->params = $params;
52  $this->uniqueLayoutId = $uniqueLayoutId;
53  $this->gridIdSuffix = $uniqueLayoutId;
54  $this->rowsAreSelectable = false;
55  $this->gridId = 'list-view';
56  $this->modelClassName = $this->getModelClassName();
57  $this->controllerId = $this->resolveControllerId();
58  $this->moduleId = $this->resolveModuleId();
59  }
60 
61  public function getPortletParams()
62  {
63  return array();
64  }
65 
66  public function renderPortletHeadContent()
67  {
68  return null;
69  }
70 
71  protected function getShowTableOnEmpty()
72  {
73  return false;
74  }
75 
76  protected static function getGridTemplate()
77  {
78  $preloader = '<div class="list-preloader"><span class="z-spinner"></span></div>';
79  return "<div class=\"MyListViewItemsPager\">\n{items}\n{pager}</div>" . $preloader;
80  }
81 
82  protected function getEmptyText()
83  {
84  $moduleClassName = static::getModuleClassName();
85  $moduleLabel = $moduleClassName::getModuleLabelByTypeAndLanguage('PluralLowerCase');
86  return Zurmo::t('Core', 'No {moduleLabelPluralLowerCase} found', array('{moduleLabelPluralLowerCase}' => $moduleLabel));
87  }
88 
89  protected function makeSearchAttributeData()
90  {
91  $metadataAdapter = new SearchDataProviderMetadataAdapter(
92  $this->getSearchModel(),
93  Yii::app()->user->userModel->id,
94  $this->getSearchAttributes()
95  );
96  $metadata = $metadataAdapter->getAdaptedMetadata();
97  $this->resolveSearchAttributesMetadataAgainstStateAdapter($metadata);
98  return $metadata;
99  }
100 
101  protected function resolveSearchAttributesMetadataAgainstStateAdapter(& $searchAttributesMetadata)
102  {
103  assert('is_array($searchAttributesMetadata)');
104  $moduleClassName = $this->getActionModuleClassName();
105  if (null != $stateMetadataAdapterClassName = $moduleClassName::getStateMetadataAdapterClassName())
106  {
107  $stateMetadataAdapter = new $stateMetadataAdapterClassName($searchAttributesMetadata);
108  $searchAttributesMetadata = $stateMetadataAdapter->getAdaptedDataProviderMetadata();
109  }
110  }
111 
112  protected function makeDataProviderBySearchAttributeData($searchAttributeData)
113  {
114  assert('is_array($searchAttributeData)');
115  list($sortAttribute, $sortDescending) =
116  SearchUtil::resolveSortFromStickyData($this->modelClassName, $this->uniqueLayoutId);
117  $pageSize = Yii::app()->pagination->resolveActiveForCurrentUserByType('dashboardListPageSize');
118  if ($sortAttribute === null)
119  {
120  $sortAttribute = $this->getSortAttributeForDataProvider();
121  $sortDescending = $this->resolveSortDescendingForDataProvider();
122  }
123  $dataProviderClassName = $this->getDataProviderClassName();
124  $redBeanModelDataProvider = new $dataProviderClassName($this->modelClassName, $sortAttribute, $sortDescending,
125  $searchAttributeData, array(
126  'pagination' => array(
127  'pageSize' => $pageSize,
128  )
129  ));
130  $sort = new RedBeanSort($redBeanModelDataProvider->modelClassName);
131  $sort->sortVar = $redBeanModelDataProvider->getId().'_sort';
132  $sort->route = 'defaultPortlet/myListDetails';
133  $sort->params = array_merge(GetUtil::getData(), array('portletId' => $this->params['portletId']));
134  $redBeanModelDataProvider->setSort($sort);
135  return $redBeanModelDataProvider;
136  }
137 
138  protected function getSortAttributeForDataProvider()
139  {
140  if (isset($this->viewData['sortAttribute']))
141  {
142  return $this->viewData['sortAttribute'];
143  }
144  else
145  {
146  return static::getDefaultSortAttribute();
147  }
148  }
149 
150  protected function resolveSortDescendingForDataProvider()
151  {
152  if (isset($this->viewData['sortDescending']))
153  {
154  return $this->viewData['sortDescending'];
155  }
156  else
157  {
158  return static::getDefaultSortDescending();
159  }
160  }
161 
162  public function isUniqueToAPage()
163  {
164  return false;
165  }
166 
167  protected function getSearchAttributes()
168  {
169  if ($this->viewData != null && isset($this->viewData['searchAttributes']))
170  {
171  return $this->viewData['searchAttributes'];
172  }
173  return static::getDefaultSearchAttributes();
174  }
175 
176  public function getConfigurationView()
177  {
178  $searchForm = $this->getSearchModel();
179  $searchForm->getModel()->setScenario('searchModel');
180  $formModel = new MyListForm();
181  if ($this->viewData != null)
182  {
183  if (isset($this->viewData['searchAttributes']))
184  {
185  $searchForm->setAttributes($this->viewData['searchAttributes']);
186  }
187  if (isset($this->viewData['title']))
188  {
189  $formModel->setAttributes(array('title' => $this->viewData['title']));
190  }
191  if (isset($this->viewData['sortAttribute']))
192  {
193  $formModel->setAttributes(array('sortAttribute' => $this->viewData['sortAttribute']));
194  }
195  if (isset($this->viewData['sortDescending']))
196  {
197  $formModel->setAttributes(array('sortDescending' => $this->viewData['sortDescending']));
198  }
199  }
200  else
201  {
202  $searchForm->setAttributes(static::getDefaultSearchAttributes());
203  $formModel->setAttributes(array('title' => static::getDefaultTitle()));
204  $formModel->setAttributes(array('sortAttribute' => static::getDefaultSortAttribute()));
205  $formModel->setAttributes(array('sortDescending' => static::getDefaultSortDescending()));
206  }
207  $configViewClassName = static::getConfigViewClassName();
208  return new $configViewClassName($formModel, $searchForm, $this->params);
209  }
210 
211  protected static function getPagerCssClass()
212  {
213  return 'pager horizontal';
214  }
215 
216  protected function getCGridViewPagerParams()
217  {
218  return array(
219  'firstPageLabel' => '<span>first</span>',
220  'prevPageLabel' => '<span>previous</span>',
221  'nextPageLabel' => '<span>next</span>',
222  'lastPageLabel' => '<span>last</span>',
223  'paginationParams' => array_merge(GetUtil::getData(), array('portletId' => $this->params['portletId'])),
224  'route' => 'defaultPortlet/myListDetails',
225  'class' => 'SimpleListLinkPager',
226  );
227  }
228 
234  protected function getCGridViewAfterAjaxUpdate()
235  {
236  // Begin Not Coding Standard
237  return 'js:function(id, data) {
238  processAjaxSuccessError(id, data);
239  }';
240  // End Not Coding Standard
241  }
242 
243  public function getTitle()
244  {
245  if (!empty($this->viewData['title']))
246  {
247  return $this->viewData['title'];
248  }
249  else
250  {
251  return static::getDefaultTitle();
252  }
253  }
254 
255  public static function getDefaultTitle()
256  {
257  $metadata = self::getMetadata();
258  $title = $metadata['perUser']['title'];
260  return $title;
261  }
262 
263  public static function getDefaultSortAttribute()
264  {
265  $metadata = self::getMetadata();
266  $sortAttribute = $metadata['perUser']['sortAttribute'];
267  return $sortAttribute;
268  }
269 
270  public static function getDefaultSortDescending()
271  {
272  $metadata = self::getMetadata();
273  $sortAttribute = $metadata['perUser']['sortDescending'];
274  return $sortAttribute;
275  }
276 
277  public static function getDefaultSearchAttributes()
278  {
279  $metadata = self::getMetadata();
280  if (isset($metadata['perUser']['searchAttributes']))
281  {
282  return $metadata['perUser']['searchAttributes'];
283  }
284  return array();
285  }
286 
287  public static function canUserConfigure()
288  {
289  return true;
290  }
291 
292  public static function getDesignerRulesType()
293  {
294  return 'MyListView';
295  }
296 
300  public static function getPortletDescription()
301  {
302  }
303 
309  public static function getDisplayDescription()
310  {
311  return null;
312  }
313 
314  public function getModelClassName()
315  {
316  $moduleClassName = $this->getActionModuleClassName();
317  return $moduleClassName::getPrimaryModelName();
318  }
319 
324  public static function getPortletRulesType()
325  {
326  return 'MyList';
327  }
328 
332  private function resolveControllerId()
333  {
334  return 'default';
335  }
336 
340  private function resolveModuleId()
341  {
342  $moduleClassName = $this->getActionModuleClassName();
343  return $moduleClassName::getDirectoryName();
344  }
345 
349  protected function getActionModuleClassName()
350  {
351  $calledClass = get_called_class();
352  return $calledClass::getModuleClassName();
353  }
354 
355  protected function getDataProvider()
356  {
357  if ($this->dataProvider == null)
358  {
359  $this->dataProvider = $this->makeDataProviderBySearchAttributeData($this->makeSearchAttributeData());
360  }
361  return $this->dataProvider;
362  }
363 
364  protected function getDataProviderClassName()
365  {
366  return "RedBeanModelDataProvider";
367  }
368 
373  protected function getSearchModel()
374  {
375  throw new NotImplementedException();
376  }
377 
382  protected static function getConfigViewClassName()
383  {
384  throw new NotImplementedException();
385  }
386  }
387 ?>
getActionModuleClassName()
Definition: MyListView.php:349
getAdaptedMetadata($appendStructureAsAnd=true, $clauseCount=1)
static resolveEvaluateSubString(&$subString, $resolveVariableName=null, $params=null, $defaultValue=null)
static getPortletDescription()
Definition: MyListView.php:300
static getConfigViewClassName()
Definition: MyListView.php:382
getCGridViewAfterAjaxUpdate()
Definition: MyListView.php:234
static getDisplayDescription()
Definition: MyListView.php:309
static getPortletRulesType()
Definition: MyListView.php:324
Generated on Sun Jul 12 2020 07:10:28
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.