Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
ComponentForReportForm.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 
42  {
47 
51  const TYPE_FILTERS = 'Filters';
52 
56  const TYPE_DISPLAY_ATTRIBUTES = 'DisplayAttributes';
57 
61  const TYPE_ORDER_BYS = 'OrderBys';
62 
66  const TYPE_GROUP_BYS = 'GroupBys';
67 
71  const TYPE_DRILL_DOWN_DISPLAY_ATTRIBUTES = 'DrillDownDisplayAttributes';
72 
76  protected $moduleClassName;
77 
81  protected $modelClassName;
82 
86  protected $attributeAndRelationData;
87 
91  protected $reportType;
92 
96  private $attribute;
97 
101  private $_attributeIndexOrDerivedType;
102 
106  private $_rowKey;
107 
112  public static function getType()
113  {
114  throw new NotImplementedException();
115  }
116 
117  public function getRowKey()
118  {
119  return $this->_rowKey;
120  }
121 
125  public function attributeNames()
126  {
127  return array_merge(parent::attributeNames(), array('attributeIndexOrDerivedType'));
128  }
129 
136  public function __set($name, $value)
137  {
138  if ($name == 'attributeIndexOrDerivedType')
139  {
140  $this->_attributeIndexOrDerivedType = $value;
142  }
143  else
144  {
145  parent::__set($name, $value);
146  }
147  }
148 
152  public function rules()
153  {
154  return array(array('attributeIndexOrDerivedType', 'safe'));
155  }
156 
160  public function attributeLabels()
161  {
162  return array();
163  }
164 
170  public function __construct($moduleClassName, $modelClassName, $reportType, $rowKey = 0)
171  {
172  assert('is_string($moduleClassName)');
173  assert('is_string($modelClassName)');
174  assert('is_string($reportType)');
175  assert('is_int($rowKey)');
176  $this->moduleClassName = $moduleClassName;
177  $this->modelClassName = $modelClassName;
178  $this->reportType = $reportType;
179  $this->_rowKey = $rowKey;
180  }
181 
185  public function getModelClassName()
186  {
187  return $this->modelClassName;
188  }
189 
193  public function getModuleClassName()
194  {
195  return $this->moduleClassName;
196  }
197 
201  public function getReportType()
202  {
203  return $this->reportType;
204  }
205 
210  {
211  return $this->_attributeIndexOrDerivedType;
212  }
213 
219  public function getAttributeAndRelationData()
220  {
221  if ($this->attributeAndRelationData == null)
222  {
223  return $this->attribute;
224  }
225  return $this->attributeAndRelationData;
226  }
227 
233  public function hasRelatedData()
234  {
235  if ($this->attribute != null)
236  {
237  return false;
238  }
239  return true;
240  }
241 
247  public function getResolvedAttribute()
248  {
249  if ($this->attribute != null)
250  {
251  return $this->attribute;
252  }
253  return $this->resolveAttributeFromData($this->attributeAndRelationData);
254  }
255 
261  {
262  if ($this->attribute != null)
263  {
264  return $this->moduleClassName;
265  }
266  return $this->resolveAttributeModuleClassNameFromData($this->attributeAndRelationData,
267  $this->moduleClassName, $this->modelClassName);
268  }
269 
275  {
276  if ($this->attribute != null)
277  {
278  return $this->modelClassName;
279  }
280  return $this->resolveAttributeModelClassNameFromData($this->attributeAndRelationData, $this->moduleClassName, $this->modelClassName);
281  }
282 
290  {
291  $moduleClassName = $this->getResolvedAttributeModuleClassName();
292  $modelClassName = $this->getResolvedAttributeModelClassName();
293  $modelToReportAdapter = ModelRelationsAndAttributesToReportAdapter::
294  make($moduleClassName, $modelClassName, $this->reportType);
295  return $modelToReportAdapter->resolveRealAttributeName($this->getResolvedAttribute());
296  }
297 
304  {
305  if ($this->attribute != null)
306  {
307  throw new NotSupportedException();
308  }
309  return $this->resolvePenultimateModelClassNameFromData($this->attributeAndRelationData, $this->modelClassName);
310  }
311 
317  public function getPenultimateRelation()
318  {
319  if ($this->attribute != null)
320  {
321  throw new NotSupportedException();
322  }
323  return $this->resolvePenultimateRelationFromData($this->attributeAndRelationData);
324  }
325 
331  public function getDisplayLabel()
332  {
333  $modelClassName = $this->modelClassName;
334  $moduleClassName = $this->moduleClassName;
335  if ($this->attribute != null)
336  {
337  $modelToReportAdapter = ModelRelationsAndAttributesToReportAdapter::
338  make($moduleClassName, $modelClassName, $this->reportType);
339  return $modelToReportAdapter->getAttributeLabel($this->attribute);
340  }
341  else
342  {
343  $content = null;
344  foreach ($this->attributeAndRelationData as $relationOrAttribute)
345  {
346  if ($content != null)
347  {
348  $content .= ' ' . self::DISPLAY_LABEL_RELATION_DIVIDER . ' ';
349  }
350 
351  $modelToReportAdapter = ModelRelationsAndAttributesToReportAdapter::
352  make($moduleClassName, $modelClassName, $this->reportType);
353  if ($modelToReportAdapter->isReportedOnAsARelation($relationOrAttribute))
354  {
355  $modelClassName = $modelToReportAdapter->getRelationModelClassName($relationOrAttribute);
356  $moduleClassName = $modelToReportAdapter->getRelationModuleClassName($relationOrAttribute);
357  if ($modelToReportAdapter->isOwnedRelation($relationOrAttribute))
358  {
359  $content .= $modelToReportAdapter->getAttributeLabel($relationOrAttribute);
360  }
361  else
362  {
363  $typeToUse = 'Plural';
364  if ($modelToReportAdapter->isRelationASingularRelation($relationOrAttribute))
365  {
366  $typeToUse = 'Singular';
367  }
368  if ($moduleClassName != $modelClassName::getModuleClassName())
369  {
370  $content .= $moduleClassName::getModuleLabelByTypeAndLanguage($typeToUse);
371  }
372  else
373  {
374  $content .= $modelClassName::getModelLabelByTypeAndLanguage($typeToUse);
375  }
376  }
377  }
378  else
379  {
380  $content .= $modelToReportAdapter->getAttributeLabel($relationOrAttribute);
381  }
382  }
383  }
384  return $content;
385  }
386 
391  {
392  $moduleClassName = $this->getResolvedAttributeModuleClassName();
393  $modelClassName = $this->getResolvedAttributeModelClassName();
394  return ModelRelationsAndAttributesToReportAdapter::make($moduleClassName, $modelClassName, $this->reportType);
395  }
396 
402  public function getDisplayElementType()
403  {
404  if ($this->attributeIndexOrDerivedType == null)
405  {
406  throw new NotSupportedException();
407  }
409  return $modelToReportAdapter->getDisplayElementType($this->getResolvedAttribute());
410  }
411 
416  public function isATypeOfCurrencyValue()
417  {
418  $displayElementType = $this->getDisplayElementType();
419  if ($displayElementType == 'CalculatedCurrencyValue' ||
420  $displayElementType == 'CurrencyValue')
421  {
422  return true;
423  }
424  return false;
425  }
426 
434  {
435  $attributeOrRelationAndAttributeData = explode(FormModelUtil::RELATION_DELIMITER, $indexType);
436  if (count($attributeOrRelationAndAttributeData) == 1)
437  {
438  $attributeOrRelationAndAttributeData = $attributeOrRelationAndAttributeData[0];
439  }
440  $this->setAttributeAndRelationData($attributeOrRelationAndAttributeData);
441  }
442 
447  protected function resolveAttributeFromData(Array $attributeAndRelationData)
448  {
449  assert(count($attributeAndRelationData) > 0); // Not Coding Standard
450  return end($attributeAndRelationData);
451  }
452 
459  protected function resolveAttributeModuleClassNameFromData(Array $attributeAndRelationData, $moduleClassName,
460  $modelClassName)
461  {
462  assert(count($attributeAndRelationData) > 0); // Not Coding Standard
463  foreach ($attributeAndRelationData as $relationOrAttribute)
464  {
465  $modelToReportAdapter = ModelRelationsAndAttributesToReportAdapter::
466  make($moduleClassName, $modelClassName, $this->reportType);
467  if ($modelToReportAdapter->isReportedOnAsARelation($relationOrAttribute))
468  {
469  $moduleClassName = $modelToReportAdapter->getRelationModuleClassName($relationOrAttribute);
470  $modelClassName = $modelToReportAdapter->getRelationModelClassName($relationOrAttribute);
471  }
472  }
473  return $moduleClassName;
474  }
475 
482  protected function resolveAttributeModelClassNameFromData(Array $attributeAndRelationData, $moduleClassName,
483  $modelClassName)
484  {
485  assert(count($attributeAndRelationData) > 0); // Not Coding Standard
486  foreach ($attributeAndRelationData as $relationOrAttribute)
487  {
488  $modelToReportAdapter = ModelRelationsAndAttributesToReportAdapter::
489  make($moduleClassName, $modelClassName, $this->reportType);
490  if ($modelToReportAdapter->isReportedOnAsARelation($relationOrAttribute))
491  {
492  $moduleClassName = $modelToReportAdapter->getRelationModuleClassName($relationOrAttribute);
493  $modelClassName = $modelToReportAdapter->getRelationModelClassName($relationOrAttribute);
494  }
495  }
496  return $modelClassName;
497  }
498 
504  protected function resolvePenultimateModelClassNameFromData(Array $attributeAndRelationData, $modelClassName)
505  {
506  assert(count($attributeAndRelationData) > 0); // Not Coding Standard
507  array_pop($attributeAndRelationData);
508  foreach ($attributeAndRelationData as $relationOrAttribute)
509  {
510  $lastModelClassName = $modelClassName;
511  $modelToReportAdapter = ModelRelationsAndAttributesToReportAdapter::
512  make($modelClassName::getModuleClassName(), $modelClassName, $this->reportType);
513  if ($modelToReportAdapter->isReportedOnAsARelation($relationOrAttribute))
514  {
515  $modelClassName = $modelToReportAdapter->getRelationModelClassName($relationOrAttribute);
516  }
517  }
518  return $lastModelClassName;
519  }
520 
525  protected function resolvePenultimateRelationFromData(Array $attributeAndRelationData)
526  {
527  assert(count($attributeAndRelationData) > 0); // Not Coding Standard
528  array_pop($attributeAndRelationData);
529  return array_pop($attributeAndRelationData);
530  }
531 
535  private function setAttributeAndRelationData($attributeOrRelationAndAttributeData)
536  {
537  assert('is_string($attributeOrRelationAndAttributeData) || is_array($attributeOrRelationAndAttributeData)'); // Not Coding Standard
538  if (!is_array($attributeOrRelationAndAttributeData))
539  {
540  $this->attribute = $attributeOrRelationAndAttributeData;
541  $this->attributeAndRelationData = null;
542  }
543  else
544  {
545  $this->attribute = null;
546  $this->attributeAndRelationData = $attributeOrRelationAndAttributeData;
547  }
548  }
549  }
550 ?>
resolvePenultimateModelClassNameFromData(Array $attributeAndRelationData, $modelClassName)
resolveAttributeOrRelationAndAttributeDataByIndexType($indexType)
resolveAttributeFromData(Array $attributeAndRelationData)
const RELATION_DELIMITER
resolvePenultimateRelationFromData(Array $attributeAndRelationData)
resolveAttributeModelClassNameFromData(Array $attributeAndRelationData, $moduleClassName, $modelClassName)
static make($moduleClassName, $modelClassName, $reportType)
resolveAttributeModuleClassNameFromData(Array $attributeAndRelationData, $moduleClassName, $modelClassName)
__construct($moduleClassName, $modelClassName, $reportType, $rowKey=0)
Generated on Fri Jul 3 2020 07:10:35
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.