Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
layout.inc
1 <?php
18 require_once SQ_CORE_PACKAGE_PATH.'/bodycopy/bodycopy/bodycopy.inc';
19 
31 class Layout extends Bodycopy
32 {
33 
34 
39  public $layout_keywords = Array();
40 
41 
48  function __construct($assetid=0)
49  {
50  $this->_ser_attrs = TRUE;
51  parent::__construct($assetid);
52 
53  }//end constructor
54 
55 
63  public function _getAllowedLinks()
64  {
65 
66  return Array(
67  SQ_LINK_TYPE_1 => Array(
68  'asset' => Array(
69  'card' => 'M',
70  'exclusive' => FALSE,
71  ),
72  ),
73  SQ_LINK_TYPE_2 => Array(
74  'asset' => Array(
75  'card' => 'M',
76  'exclusive' => FALSE,
77  ),
78  ),
79  SQ_LINK_TYPE_3 => Array(
80  'asset' => Array(
81  'card' => 'M',
82  'exclusive' => FALSE,
83  ),
84  ),
85  SQ_LINK_NOTICE => Array(
86  'asset' => Array(
87  'card' => 'M',
88  'exclusive' => FALSE,
89  ),
90  ),
91  );
92 
93  }//end _getAllowedLinks()
94 
95 
137  public function getLayoutKeywords()
138  {
139  if (empty($this->layout_keywords)) {
140 
141  $keywords = $this->getKeywords();
142  if (empty($keywords)) return Array();
143 
144  // initialize all parts of the array
145  $this->layout_keywords['screens'] = Array();
146  $this->layout_keywords['entire_screens'] = Array();
147  $this->layout_keywords['custom'] = Array();
148  $this->layout_keywords['layout'] = Array();
149 
150  $this->layout_keywords = $this->getLayoutKeywordsArray($keywords, $this->layout_keywords);
151 
152  }//end if
153 
154  return $this->layout_keywords;
155 
156  }//end getLayoutKeywords()
157 
158 
168  public function getLayoutKeywordsArray($keywords, $return_array = Array())
169  {
170  foreach ($keywords as $keyword) {
171  if (FALSE !== (strpos($keyword, '-'))) {
172  list($screen, $tag) = explode('-', $keyword);
173  $screen = strtolower($screen);
174  $tag = strtolower($tag);
175 
176  if ($screen == '__custom') {
177  // this is not acually a screen, but a custom keyword that we need to
178  // ask the owner of this layout at limbo time
179  $return_array['custom'][] = $tag;
180  }
181 
182  if ($tag) {
183  // get the first letter of the type
184  $type = $tag{0};
185  // check to see if we have a field or a section
186  if (strtoupper($type) != 'S' && strtoupper($type) != 'F') {
187  continue;
188  }
189  $tag = substr($tag, 2);
190 
191  if (!isset($return_array['screens'][$screen])) {
192  $return_array['screens'][$screen] = Array();
193  }
194 
195  // its a field
196  if (strtoupper($type) == 'F') {
197  if (!isset($return_array['screens'][$screen]['fields'])) {
198  $return_array['screens'][$screen]['fields'] = Array();
199  }
200  if (!in_array($tag, $return_array['screens'][$screen]['fields'])) {
201  $return_array['screens'][$screen]['fields'][$tag] = $keyword;
202  }
203  // its a section
204  } else {
205  if (!isset($return_array['screens'][$screen]['sections'])) {
206  $return_array['screens'][$screen]['sections'] = Array();
207  }
208  if (!in_array($tag, $return_array['screens'][$screen]['sections'])) {
209  $return_array['screens'][$screen]['sections'][$tag] = $keyword;
210  }
211  }//end if
212  // they want the entire screen
213  } else {
214  if (!in_array($screen, $return_array['entire_screens'])) {
215  $return_array['entire_screens'][$screen] = $keyword;
216  }
217  }
218 
219  } else {
220  // this keyword is a custom keyword for the layout
221  $return_array['layout'][] = $keyword;
222  }
223  }//end foreach
224 
225  return $return_array;
226 
227  }//end getLayoutKeywordsArray()
228 
229 
240  public function onRequestKeywords(Asset $broadcaster, $vars=Array())
241  {
242  if (!isset($vars['keywords'])) return;
243 
244  $parents = $GLOBALS['SQ_SYSTEM']->am->getParents($broadcaster->id, 'layout', TRUE);
245  if (!empty($parents) && isset($parents[$this->id])) {
246  $vars['keywords']['screen_menu'] = 'Screen Menu';
247  $vars['keywords']['context_switcher'] = 'Context Switcher';
248  $vars['keywords']['commit_button'] = 'Commit Button';
249  $vars['keywords']['commit_button_clean'] = 'Commit Button (without formatting)';
250  $vars['keywords']['release_locks_button'] = 'Release-locks button';
251  $vars['keywords']['xx-'] = 'All of screen xx';
252  $vars['keywords']['xx-S_yy'] = 'All of section yy of screen xx';
253  $vars['keywords']['xx-F_zz'] = 'Field zz of screen xx';
254  $vars['keywords']['__custom-pp'] = 'Custom limbo keyword pp of the current asset type';
255  }
256 
257  }//end onRequestKeywords()
258 
259 
260 }//end class
261 ?>