Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
View.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 
43  abstract class View
44  {
49  protected $cssClasses = array();
50 
51  protected $title;
52 
56  protected $makeDefaultClassesFromClassHeirarchy = true;
57 
66  public function isUniqueToAPage()
67  {
68  return true;
69  }
70 
83  public function render()
84  {
85  $theme = Yii::app()->theme->name;
86  $name = get_class($this);
87  $templateName = $this->resolveCustomViewTemplateFileName($theme, $name);
88  $content = $this->renderContent();
89  if (file_exists($templateName))
90  {
91  $span = "<span class=\"$name\" />";
92  $templateSource = file_get_contents($templateName);
93  if (strpos($templateSource, $span))
94  {
95  $content = str_replace($span, $content, $templateSource);
96  }
97  $content = "<!-- Start of $templateName -->$content<!-- End of $templateName -->";
98  }
99  $classes = $this->resolveDefaultClasses();
100  if ($this->isUniqueToAPage() && $this->renderContainerWrapperId())
101  {
102  $id = " id=\"$name\"";
103  unset($classes[0]);
104  }
105  elseif ($this->renderContainerWrapperId())
106  {
107  $id = $this->getId();
108  if ($id != null)
109  {
110  $id = " id=\"$id\"";
111  }
112  }
113  else
114  {
115  $id = null;
116  }
117  $classes = join(' ', array_merge($this->getCssClasses(), $classes));
118  if ($classes != '')
119  {
120  $classes = " class=\"$classes\"";
121  }
122  $containerWrapperTag = $this->getContainerWrapperTag();
123  if ($containerWrapperTag == null)
124  {
125  return $content;
126  }
127  else
128  {
129  return "<" . $this->getContainerWrapperTag() . $id . $classes . $this->getViewStyle() . ">$content</" . $this->getContainerWrapperTag() . ">";
130  }
131  }
132 
133  protected function resolveDefaultClasses()
134  {
135  if ($this->makeDefaultClassesFromClassHeirarchy)
136  {
137  return RuntimeUtil::getClassHierarchy(get_class($this), 'View');
138  }
139  return array();
140  }
141 
142  protected function renderContainerWrapperId()
143  {
144  return true;
145  }
146 
147  protected function getContainerWrapperTag()
148  {
149  return 'div';
150  }
151 
155  protected function getId()
156  {
157  }
158 
162  protected abstract function renderContent();
163 
164  public function setCssClasses(array $classes)
165  {
166  $this->cssClasses = $classes;
167  }
168 
169  public function getCssClasses()
170  {
171  return $this->cssClasses;
172  }
173 
174  protected function getViewStyle()
175  {
176  return null;
177  }
178 
179  protected function renderTitleContent()
180  {
181  if ($this->getTitle() == '')
182  {
183  return null;
184  }
185  return StringUtil::renderFluidTitleContent($this->getTitle(), $this->getPostTruncatedTitleContent());
186  }
187 
188  public function getTitle()
189  {
190  return $this->title;
191  }
192 
193  public function getPostTruncatedTitleContent()
194  {
195  return null;
196  }
197 
203  protected function resolveCustomViewTemplateFileName($theme, $view)
204  {
205  $templateName = "themes/$theme/templates/Custom" . $view . ".xhtml";
206  if (!file_exists($templateName))
207  {
208  $templateName = "themes/$theme/templates/$view.xhtml";
209  if (!file_exists($templateName))
210  {
211  $templateName = "themes/default/templates/$view.xhtml";
212  }
213  }
214  return $templateName;
215  }
216  }
217 ?>
getId()
Definition: View.php:155
Definition: View.php:43
renderContent()
resolveCustomViewTemplateFileName($theme, $view)
Definition: View.php:203
static getClassHierarchy($className, $upToAndNotIncludingClassName)
Definition: RuntimeUtil.php:54
isUniqueToAPage()
Definition: View.php:66
render()
Definition: View.php:83
Generated on Tue Jul 14 2020 07:10:29
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.