Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
ConfigurableDetailsAndRelationsView.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  {
47  public function __construct($controllerId, $moduleId, $params)
48  {
49  assert('isset($params["controllerId"])');
50  assert('isset($params["relationModuleId"])');
51  assert('isset($params["relationModel"])');
52  $this->controllerId = $controllerId;
53  $this->moduleId = $moduleId;
54  $this->uniqueLayoutId = get_class($this);
55  $this->params = $params;
56  $this->modelId = $params["relationModel"]->id;
57  }
58 
62  protected function renderContent()
63  {
64  $metadata = self::getMetadata();
65  $portletsAreRemovable = true;
66  $portletsAreMovable = true;
67  $this->resolvePortletConfigurableParams($portletsAreMovable, $portletsAreRemovable);
68  $content = $this->renderActionElementBar(true);
69  $viewClassName = static::getModelRelationsSecuredPortletFrameViewClassName();
70  $configurableView = new $viewClassName( $this->controllerId,
71  $this->moduleId,
72  $this->uniqueLayoutId,
73  $this->params,
74  $metadata,
75  false,
76  $portletsAreMovable,
77  false,
78  static::getDefaultLayoutType(), // This could be driven by a db value based on layout type id
79  $portletsAreRemovable);
80  $content .= $configurableView->render();
81  $content .= $this->renderScripts();
82  return $content;
83  }
84 
89  protected function renderActionElementBar($renderedInForm)
90  {
91  $getData = GetUtil::getData();
92  if (isset($getData['kanbanBoard']) && $getData['kanbanBoard'] == 1)
93  {
94  $isKanbanActive = true;
95  }
96  else
97  {
98  $isKanbanActive = false;
99  }
100  $toolbarContent = null;
101  if (Yii::app()->userInterface->isMobile() === false)
102  {
104  $this->controllerId, $this->moduleId, $this->modelId, $isKanbanActive);
105  if ($isKanbanActive)
106  {
107  $content = parent::renderActionElementBar($renderedInForm) . $kanbanToggleLink;
108  }
109  else
110  {
111  $content = $kanbanToggleLink. $this->resolveAndRenderLockingLink($renderedInForm);
112  }
113  $content .= $this->resolveExtraToolbarContent();
114  $toolbarContent = ZurmoHtml::tag('nav', array('class' => 'pillbox clearfix'), $content);
115  }
116  $toolbarContent = ZurmoHtml::tag('div', array('class' => 'view-toolbar-container widgets-lock clearfix '), $toolbarContent);
117  return $toolbarContent;
118  }
119 
120  protected function resolveAndRenderLockingLink($renderedInForm)
121  {
122  $isViewLocked = ZurmoDefaultViewUtil::getLockKeyForDetailsAndRelationsView('lockPortletsForDetailsAndRelationsView');
123  if ($isViewLocked === false)
124  {
125  $title = Zurmo::t('Core', 'Lock and prevent layout changes to this screen');
126  $url = $this->resolveLockPortletUrl($this->params["relationModel"]->id, true);
127  $icon = ZurmoHtml::tag('i', array('class' => 'icon-unlock'), '<!--' . Zurmo::t('Core', 'Lock') . '-->');
128  $link = ZurmoHtml::link($icon, $url, array('title' => $title));
129  $content = ZurmoHtml::tag('nav', array('class' => 'default-button'), $link);
130  $content = parent::renderActionElementBar($renderedInForm) . $this->renderPushLayoutButton() . $content;
131  }
132  else
133  {
134  $title = Zurmo::t('Core', 'Unlock to edit this screen\'s layout');
135  $url = $this->resolveLockPortletUrl($this->params["relationModel"]->id, false);
136  $icon = ZurmoHtml::tag('i', array('class' => 'icon-lock'), '<!--' . Zurmo::t('Core', 'Unlock') . '-->');
137  $content = ZurmoHtml::link($icon, $url, array('title' => $title));
138  $content = ZurmoHtml::tag('nav', array('class' => 'default-button'), $content);
139  }
140  return $content;
141  }
142 
143  protected function renderPushLayoutButton()
144  {
146  {
147  $pushLayoutLinkActionElement = new PushLayoutLinkActionElement(
148  $this->controllerId, $this->moduleId, $this->modelId,
149  array('htmlOptions' => array('id' => 'PushLayoutLink'),
150  'iconClass' => 'icon-change-dashboard'));
151  return $pushLayoutLinkActionElement->render();
152  }
153  }
154 
158  protected static function resolveAjaxOptionsForAddPortlet()
159  {
160  $title = Zurmo::t('HomeModule', 'Add Portlet');
161  return ModalView::getAjaxOptionsForModalLink($title);
162  }
163 
170  private function resolveLockPortletUrl($id, $lockPortlets)
171  {
172  assert('is_bool($lockPortlets)');
173  assert('is_int($id)');
174  $url = Yii::app()->createUrl($this->moduleId . '/' . $this->controllerId . '/details',
175  array('id' => $id, 'lockPortlets' => $lockPortlets));
176  return $url;
177  }
178 
184  protected function resolvePortletConfigurableParams(& $portletsAreMovable, & $portletsAreRemovable)
185  {
186  assert('is_bool($portletsAreMovable)');
187  assert('is_bool($portletsAreRemovable)');
188  $getData = GetUtil::getData();
189  if (isset($getData['lockPortlets']))
190  {
191  $lockPortlets = (bool)$getData['lockPortlets'];
192  if ($lockPortlets)
193  {
194  ZurmoDefaultViewUtil::setLockKeyForDetailsAndRelationsView('lockPortletsForDetailsAndRelationsView', true);
195  }
196  else
197  {
198  ZurmoDefaultViewUtil::setLockKeyForDetailsAndRelationsView('lockPortletsForDetailsAndRelationsView', false);
199  }
200  }
201  $isViewLocked = ZurmoDefaultViewUtil::getLockKeyForDetailsAndRelationsView('lockPortletsForDetailsAndRelationsView');
202  //Default case for the first time
203  if ($isViewLocked === null)
204  {
205  ZurmoDefaultViewUtil::setLockKeyForDetailsAndRelationsView('lockPortletsForDetailsAndRelationsView', true);
206  $isViewLocked = true;
207  }
208  if ($isViewLocked == true)
209  {
210  $portletsAreRemovable = false;
211  $portletsAreMovable = false;
212  }
213  }
214 
219  public static function getLayoutTypesData()
220  {
221  return array(
222  '100' => Zurmo::t('HomeModule', '{number} Column', array('{number}' => 1)),
223  '50,50' => Zurmo::t('HomeModule', '{number} Columns', array('{number}' => 2)), // Not Coding Standard
224  '75,25' => Zurmo::t('HomeModule', '{number} Columns Left Strong', array('{number}' => 2)), // Not Coding Standard
225  );
226  }
227 
232  public static function getDefaultLayoutType()
233  {
234  return '75,25'; // Not Coding Standard
235  }
236 
241  protected function resolveExtraToolbarContent()
242  {
243  return Yii::app()->custom->resolveExtraToolbarContentForView(get_class($this), $this->controllerId, $this->moduleId, $this->modelId);
244  }
245  }
246 ?>
static setLockKeyForDetailsAndRelationsView($key, $value)
resolvePortletConfigurableParams(&$portletsAreMovable, &$portletsAreRemovable)
static canCurrentUserPushDashboardOrLayout()
static getLockKeyForDetailsAndRelationsView($key)
static renderActionBarLinksForKanbanBoard($controllerId, $moduleId, $modelId, $kanbanIsActive)
Generated on Fri Jul 3 2020 07:10:37
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.