Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
PortletFrameView.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 
40  abstract class PortletFrameView extends MetadataView
41  {
42  protected $portlets;
43  protected $uniqueLayoutId;
44  protected $params;
45  protected $layoutType;
46 
47  public function __construct($controllerId, $moduleId, $modelId, $params)
48  {
49  $this->controllerId = $controllerId;
50  $this->moduleId = $moduleId;
51  $this->modelId = $modelId;
52  $this->uniqueLayoutId = get_class($this);
53  $this->params = $params;
54  }
55 
56  protected function renderContent()
57  {
58  $this->portlets = $this->getPortlets($this->uniqueLayoutId, self::getMetadata());
59  return $this->renderPortlets($this->uniqueLayoutId);
60  }
61 
62  protected function getPortlets($uniqueLayoutId, $metadata)
63  {
64  assert('is_string($uniqueLayoutId)');
65  assert('is_array($metadata)');
66  $portlets = Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition($uniqueLayoutId, Yii::app()->user->userModel->id, $this->params);
67  if (empty($portlets))
68  {
69  $portlets = Portlet::makePortletsUsingMetadataSortedByColumnIdAndPosition($uniqueLayoutId, $metadata, Yii::app()->user->userModel, $this->params);
70  Portlet::savePortlets($portlets);
71  }
72  return $portlets;
73  }
74 
75  protected function renderPortlets($uniqueLayoutId, $portletsAreCollapsible = true, $portletsAreMovable = true, $portletsAreRemovable = true)
76  {
77  assert('is_string($uniqueLayoutId)');
78  assert('is_bool($portletsAreCollapsible)');
79  assert('is_bool($portletsAreMovable)');
80  assert('is_bool($portletsAreRemovable)');
81  $juiPortletsWidgetItems = array();
82  foreach ($this->portlets as $column => $columnPortlets)
83  {
84  foreach ($columnPortlets as $position => $portlet)
85  {
86  $className = get_class($portlet->getView());
87  if (method_exists($className, 'canUserRemove'))
88  {
89  $removable = $className::canUserRemove();
90  }
91  else
92  {
93  $removable = $portletsAreRemovable;
94  }
95  $additionalOptionMenuItems = array();
96  if (method_exists($className, 'getAdditionalOptionMenuItems'))
97  {
98  $additionalOptionMenuItems = $className::getAdditionalOptionMenuItems();
99  }
100  $juiPortletsWidgetItems[$column][$position] = array(
101  'id' => $portlet->id,
102  'uniqueId' => $portlet->getUniquePortletPageId(),
103  'title' => $portlet->getTitle(),
104  'content' => $portlet->renderContent(),
105  'headContent' => $portlet->renderHeadContent(),
106  'editable' => $portlet->isEditable(),
107  'collapsed' => $portlet->collapsed,
108  'removable' => $removable,
109  'uniqueClass' => $this->resolveUniqueClass($portlet),
110  'portletParams' => $portlet->getPortletParams(),
111  'additionalOptionMenuItems' => $additionalOptionMenuItems,
112  );
113  }
114  }
115  $cClipWidget = new CClipWidget();
116  $cClipWidget->beginClip("JuiPortlets");
117  $cClipWidget->widget('application.core.widgets.JuiPortlets', array(
118  'uniqueLayoutId' => $uniqueLayoutId,
119  'moduleId' => $this->moduleId,
120  'saveUrl' => Yii::app()->createUrl($this->moduleId . '/defaultPortlet/SaveLayout'),
121  'layoutType' => $this->getLayoutType(),
122  'items' => $juiPortletsWidgetItems,
123  'collapsible' => $portletsAreCollapsible,
124  'movable' => $portletsAreMovable,
125  ));
126  $cClipWidget->endClip();
127  return $cClipWidget->getController()->clips['JuiPortlets'];
128  }
129 
130  protected function resolveUniqueClass(Portlet $portlet)
131  {
132  $content = null;
133  $content .= get_class($portlet->getView());
134  foreach ($portlet->getCssClasses() as $cssClass)
135  {
136  $content .= ' ' . $cssClass;
137  }
138  $portletRules = PortletRulesFactory::createPortletRulesByView(get_class($portlet->getView()));
139  $content .= ' ' . $portletRules->resolveIconTypeName();
140  return $content;
141  }
142 
143  protected function getLayoutType()
144  {
145  return $this->layoutType;
146  }
147 
148  protected function arePortletsRemovable()
149  {
150  return true;
151  }
152  }
153 ?>
static createPortletRulesByView($viewClassName)
Generated on Wed Jul 1 2020 07:10:29
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.