Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
RelatedListView.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  {
42  protected $params;
43  protected $viewData;
44  protected $uniqueLayoutId;
45 
50  protected $renderViewToolBarDuringRenderContent = false;
51 
56  const GRID_VIEW_TYPE_NORMAL = 1;
57 
62  const GRID_VIEW_TYPE_STACKED = 2;
63 
64  public function __construct($viewData, $params, $uniqueLayoutId)
65  {
66  assert('isset($params["controllerId"])');
67  assert('isset($params["relationModuleId"])');
68  assert('$params["relationModel"] instanceof RedBeanModel || $params["relationModel"] instanceof ModelForm');
69  assert('isset($params["portletId"])');
70  assert('isset($params["redirectUrl"])');
71  assert('$this->getRelationAttributeName() != null');
72  $this->modelClassName = $this->getModelClassName();
73  $this->viewData = $viewData;
74  $this->params = $params;
75  $this->uniqueLayoutId = $uniqueLayoutId;
76  $this->gridIdSuffix = $uniqueLayoutId;
77  $this->rowsAreSelectable = false;
78  $this->gridId = 'list-view';
79  $this->controllerId = $this->resolveControllerId();
80  $this->moduleId = $this->resolveModuleId();
81  }
82 
83  public function getPortletParams()
84  {
85  return array();
86  }
87 
88  protected function getShowTableOnEmpty()
89  {
90  return false;
91  }
92 
93  protected static function getGridTemplate()
94  {
95  $preloader = '<div class="list-preloader"><span class="z-spinner"></span></div>';
96  return "<div class=\"RelatedListViewItemsPager\">\n{items}\n{pager}</div>" . $preloader;
97  }
98 
99  protected function getEmptyText()
100  {
101  $moduleClassName = static::getModuleClassName();
102  $moduleLabel = $moduleClassName::getModuleLabelByTypeAndLanguage('PluralLowerCase');
103  return Zurmo::t('Core', 'No {moduleLabelPluralLowerCase} found', array('{moduleLabelPluralLowerCase}' => $moduleLabel));
104  }
105 
106  protected function getGridViewWidgetPath()
107  {
108  $resolvedMetadata = $this->getResolvedMetadata();
109  if (isset($resolvedMetadata['global']['gridViewType']) &&
110  $resolvedMetadata['global']['gridViewType'] == RelatedListView::GRID_VIEW_TYPE_STACKED)
111  {
112  return 'application.core.widgets.StackedExtendedGridView';
113  }
114 
115  return parent::getGridViewWidgetPath();
116  }
117 
118  protected function makeSearchAttributeData()
119  {
120  $searchAttributeData = array();
121  $searchAttributeData['clauses'] = array(
122  1 => array(
123  'attributeName' => $this->getRelationAttributeName(),
124  'relatedAttributeName' => 'id',
125  'operatorType' => 'equals',
126  'value' => (int)$this->params['relationModel']->id,
127  )
128  );
129  $searchAttributeData['structure'] = '1';
130  return $searchAttributeData;
131  }
132 
133  protected function makeDataProviderBySearchAttributeData($searchAttributeData)
134  {
135  assert('is_array($searchAttributeData)');
136  $sortAttribute = SearchUtil::resolveSortAttributeFromArray($this->modelClassName, $_GET);
137  $sortDescending = SearchUtil::resolveSortDescendingFromArray($this->modelClassName, $_GET);
138  if ($sortAttribute === null)
139  {
140  $sortAttribute = $this->getSortAttributeForDataProvider();
141  $sortDescending = $this->resolveSortDescendingForDataProvider();
142  }
143  return new RedBeanModelDataProvider( $this->modelClassName, $sortAttribute, (bool)$sortDescending,
144  $searchAttributeData, $this->resolveConfigForDataProvider());
145  }
146 
147  protected function getSortAttributeForDataProvider()
148  {
149  return null;
150  }
151 
152  protected function resolveSortDescendingForDataProvider()
153  {
154  return false;
155  }
156 
157  public function renderPortletHeadContent()
158  {
159  return $this->renderViewToolBar();
160  }
161 
162  public function isUniqueToAPage()
163  {
164  return false;
165  }
166 
167  protected function getCreateLinkRouteParameters()
168  {
169  return array(
170  'relationAttributeName' => $this->getRelationAttributeName(),
171  'relationModelId' => $this->params['relationModel']->id,
172  'relationModuleId' => $this->params['relationModuleId'],
173  'redirectUrl' => $this->params['redirectUrl'],
174  );
175  }
176 
177  protected static function getPagerCssClass()
178  {
179  return 'pager horizontal';
180  }
181 
182  protected function getCGridViewPagerParams()
183  {
184  return array(
185  'firstPageLabel' => '<span>first</span>',
186  'prevPageLabel' => '<span>previous</span>',
187  'nextPageLabel' => '<span>next</span>',
188  'lastPageLabel' => '<span>last</span>',
189  'class' => 'SimpleListLinkPager',
190  'paginationParams' => $this->resolvePaginationParams(),
191  'route' => 'defaultPortlet/details',
192  );
193  }
194 
200  protected function getCGridViewAfterAjaxUpdate()
201  {
202  // Begin Not Coding Standard
203  return 'js:function(id, data) {
204  processAjaxSuccessError(id, data);
205  }';
206  // End Not Coding Standard
207  }
208 
209  public function getTitle()
210  {
211  if (!empty($this->viewData['title']))
212  {
213  return $this->viewData['title'];
214  }
215  else
216  {
217  return static::getDefaultTitle();
218  }
219  }
220 
221  public static function getDefaultTitle()
222  {
223  $metadata = self::getMetadata();
224  $title = $metadata['perUser']['title'];
226  return $title;
227  }
228 
229  public static function canUserConfigure()
230  {
231  return false;
232  }
233 
234  public static function getDesignerRulesType()
235  {
236  return 'RelatedListView';
237  }
238 
244  public static function getDisplayDescription()
245  {
246  return null;
247  }
248 
249  public function getModelClassName()
250  {
251  $moduleClassName = $this->getActionModuleClassName();
252  return $moduleClassName::getPrimaryModelName();
253  }
254 
259  public static function getPortletRulesType()
260  {
261  return 'RelatedList';
262  }
263 
267  protected function resolveControllerId()
268  {
269  return 'default';
270  }
271 
275  private function resolveModuleId()
276  {
277  $moduleClassName = $this->getActionModuleClassName();
278  return $moduleClassName::getDirectoryName();
279  }
280 
284  protected function getActionModuleClassName()
285  {
286  $calledClass = get_called_class();
287  return $calledClass::getModuleClassName();
288  }
289 
290  protected function getDataProvider()
291  {
292  if ($this->dataProvider == null)
293  {
294  $this->dataProvider = $this->makeDataProviderBySearchAttributeData($this->makeSearchAttributeData());
295  }
296  return $this->dataProvider;
297  }
298 
299  abstract protected function getRelationAttributeName();
300 
301  public static function getAllowedOnPortletViewClassNames()
302  {
303  return array();
304  }
305 
306  public static function allowMultiplePlacement()
307  {
308  return false;
309  }
310 
314  public static function getPortletDescription()
315  {
316  }
317 
322  protected function resolvePaginationParams()
323  {
324  return array_merge(GetUtil::getData(),
325  array('portletId' => $this->params['portletId'],
326  'redirectUrl' => $this->params['redirectUrl']));
327  }
328 
333  protected function resolveConfigForDataProvider()
334  {
335  $pageSize = Yii::app()->pagination->resolveActiveForCurrentUserByType('subListPageSize');
336  return array(
337  'pagination' => array(
338  'pageSize' => $pageSize,
339  )
340  );
341  }
342  }
343 ?>
static resolveEvaluateSubString(&$subString, $resolveVariableName=null, $params=null, $defaultValue=null)
renderViewToolBar($renderInForm=true)
static resolveSortAttributeFromArray($getArrayPrefixName, $sourceData)
Definition: SearchUtil.php:173
static resolveSortDescendingFromArray($getArrayPrefixName, $sourceData)
Definition: SearchUtil.php:190
Generated on Wed Sep 30 2020 07:10:29
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.