Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
GridView.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  class GridView extends View
41  {
42  private $rows;
43  private $columns;
44  private $columnWidths;
45  private $containedViews;
46  private $containerWrapperTag;
47 
52  public function __construct($rows, $columns, $containerWrapperTag = 'div',
53  $makeDefaultClassesFromClassHeirarchy = true)
54  {
55  assert('is_int($rows) && $rows > 0');
56  assert('is_int($columns) && $columns > 0');
57  assert('is_string($containerWrapperTag) || $containerWrapperTag == null');
58  assert('is_bool($makeDefaultClassesFromClassHeirarchy)');
59  $this->rows = $rows;
60  $this->columns = $columns;
61  $this->columnWidths = array_pad(array(), $columns, 0);
62  // $containedViews = array_pad(array(), $rows, null);
63  for ($row = 0; $row < $rows; $row++)
64  {
65  $this->containedViews[] = array_pad(array(), $columns, null);
66  }
67  $this->containerWrapperTag = $containerWrapperTag;
68  $this->makeDefaultClassesFromClassHeirarchy = $makeDefaultClassesFromClassHeirarchy;
69  }
70 
76  public function isUniqueToAPage()
77  {
78  return false;
79  }
80 
85  protected function getContainerWrapperTag()
86  {
87  return $this->containerWrapperTag;
88  }
89 
94  public function setView(View $view, $row, $column)
95  {
96  assert('is_int($row) && $row >= 0 && $row < $this->rows');
97  assert('is_int($column) && $column >= 0 && $column < $this->columns');
98  $this->containedViews[$row][$column] = $view;
99  }
100 
104  public function setColumnWidth($column, $width)
105  {
106  assert('is_int($column) && $column >= 0 && $column < $this->columns');
107  assert('is_int($width) && $width > 0');
108  $this->columnWidths[$column] = $width;
109  }
110 
111  protected function renderContent()
112  {
113  // The if ($this->rows > 1) and if ($this->columns > 1)
114  // checks make it only generate as many divs as it needs
115  // to. If there is only one row or one columns it wont
116  // wrap it in another div.
117  $content = null;
118  for ($row = 0; $row < $this->rows; $row++)
119  {
120  $rowContent = null;
121  if ($this->rows > 1)
122  {
123  //$rowContent .= "<div>\n";
124  }
125  $totalColumnsWidth = null;
126  for ($column = 0; $column < $this->columns; $column++)
127  {
128  $columnContent = null;
129  if ($this->columns > 1)
130  {
131  $styles = array();
132  if ($column < $this->columns - 1)
133  {
134  $styles[] = 'float: left;';
135  }
136  if (isset($totalColumnsWidth))
137  {
138  $styles[] = "margin-left: {$totalColumnsWidth}px;";
139  }
140  if ($this->columnWidths[$column] > 0)
141  {
142  $styles[] = 'width: ' . $this->columnWidths[$column] . 'px;';
143  $totalColumnsWidth += $this->columnWidths[$column];
144  }
145  if (count($styles) > 0)
146  {
147  // $style = ' style="' . join($styles, ' ') . '"';
148  }
149  else
150  {
151  $style = '';
152  }
153  // $columnContent .= "<div$style>\n";
154  }
155  $columnContent .= $this->containedViews[$row][$column]->render();
156  if ($this->columns > 1)
157  {
158  // $columnContent .= "</div>\n";
159  }
160  $rowContent .= $columnContent;
161  }
162  if ($this->rows > 1)
163  {
164  // $rowContent .= "</div>\n";
165  }
166  $content .= $rowContent;
167  }
168  return $content;
169  }
170  }
171 ?>
Definition: View.php:43
getContainerWrapperTag()
Definition: GridView.php:85
isUniqueToAPage()
Definition: GridView.php:76
setView(View $view, $row, $column)
Definition: GridView.php:94
__construct($rows, $columns, $containerWrapperTag= 'div', $makeDefaultClassesFromClassHeirarchy=true)
Definition: GridView.php:52
setColumnWidth($column, $width)
Definition: GridView.php:104
Generated on Sun Aug 9 2020 07:10:28
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.