Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
page_site_map_edit_fns.inc
1 <?php
18 require_once SQ_CORE_PACKAGE_PATH.'/page/page_edit_fns.inc';
19 
32 {
33 
34 
39  function __construct()
40  {
41  parent::__construct();
42  $this->static_screens['details']['force_unlock'] = FALSE;
43  $this->static_screens['details']['lock_type'] = 'content';
44 
45  }//end constructor
46 
47 
58  function paintRootNode(&$asset, &$o, $prefix)
59  {
60  $root_link = $GLOBALS['SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_NOTICE, '', FALSE, 'root');
61  $write_access = $asset->writeAccess('links');
62 
63  if (!$write_access) {
64  $root_asset = NULL;
65  if (!empty($root_link)) {
66  echo get_asset_tag_line($root_link['minorid']);
67  } else {
68  echo translate('cms_no_root_node');
69  }
70  } else {
71  asset_finder($prefix.'_rootid', (!empty($root_link)) ? $root_link['minorid'] : '');
72  }
73 
74  return $write_access;
75 
76  }//end paintRootNode()
77 
78 
89  function processRootNode(&$asset, &$o, $prefix)
90  {
91  if (!isset($_POST[$prefix.'_rootid']['assetid']) || (isset($asset->_tmp['reverting_to_system_version']) && $asset->_tmp['reverting_to_system_version'])) {
92  return FALSE;
93  }
94  $new_root = $_POST[$prefix.'_rootid']['assetid'];
95 
96  // getting existing root link
97  $root_link = $GLOBALS['SQ_SYSTEM']->am->getLink($asset->id, SQ_LINK_NOTICE, '', FALSE, 'root');
98 
99  // dont process anything if the root node has not changed
100  if (!empty($root_link) && $root_link['minorid'] == $new_root) {
101  return FALSE;
102  }
103 
104  $ok = TRUE;
105 
106  $GLOBALS['SQ_SYSTEM']->changeDatabaseConnection('db2');
107  $GLOBALS['SQ_SYSTEM']->doTransaction('BEGIN');
108 
109  // deleting old root link if any found...
110  if (!empty($root_link) && !$GLOBALS['SQ_SYSTEM']->am->deleteAssetLink($root_link['linkid'])) {
111  $ok = FALSE;
112  } else if ($new_root) {
113  $root = $GLOBALS['SQ_SYSTEM']->am->getAsset($new_root);
114  if (!is_null($root)) {
115  if (!$asset->createLink($root, SQ_LINK_NOTICE, 'root')) {
116  $ok = FALSE;
117  trigger_localised_error('CMS0016', E_USER_WARNING, $root->name, $root->id);
118  }
119  }
120  }
121 
122  if ($ok) {
123  $GLOBALS['SQ_SYSTEM']->doTransaction('COMMIT');
124  } else {
125  $GLOBALS['SQ_SYSTEM']->doTransaction('ROLLBACK');
126  }
127 
128  $GLOBALS['SQ_SYSTEM']->restoreDatabaseConnection();
129  return $ok;
130 
131  }//end processRootNode()
132 
133 
144  function paintExcludeList(&$asset, &$o, $prefix)
145  {
146  $write_access = $asset->writeAccess('attributes');
147  $curr_list = $asset->attr('exclude_list');
148 
149  if ($write_access) {
150  multiple_asset_finder($prefix.'_exclude_list', $curr_list, Array('asset' => 'D'));
151  } else {
152  if (empty($curr_list)) {
153  echo translate('cms_no_assets_excluded');
154  } else {
155  ?><ul style="margin:1px 15px;"><?php
156  foreach ($curr_list as $assetid) {
157  echo '<li>'.get_asset_tag_line($assetid).'</li>';
158  }
159  ?></ul><?php
160  }
161  }
162 
163  return $write_access;
164 
165  }//end paintExcludeList()
166 
167 
178  function processExcludeList(&$asset, &$o, $prefix)
179  {
180  $exclude_post = array_get_index($_POST, $prefix.'_exclude_list', Array());
181  $exclude_list = Array();
182 
183  foreach ($exclude_post as $exclude_item) {
184  if (!empty($exclude_item['assetid'])) {
185  $exclude_list[$exclude_item['assetid']] = $exclude_item['assetid'];
186  }
187  }
188 
189  return $asset->setAttrValue('exclude_list', $exclude_list);
190 
191  }//end processExcludeList()
192 
193 
204  function paintTypeIncludeList(&$asset, &$o, $prefix)
205  {
206  $write_access = $asset->writeAccess('attributes');
207  $curr_list = $asset->attr('include_types');
208 
209  if ($write_access) {
210  asset_type_chooser($prefix.'_include_types', TRUE, $curr_list, NULL, TRUE, TRUE);
211  } else {
212  if (empty($curr_list)) {
213  echo translate('cms_page_site_map_all_asset_types_included');
214  } else {
215  ?><ul style="margin:1px 15px;"><?php
216 
217  $type_inherit = Array();
218  if (isset($curr_list['inherit'])) {
219  $type_inherit = $curr_list['inherit'];
220  }
221 
222  foreach ($curr_list['type_code'] as $type_code) {
223  if (!empty($type_code)) {
224  $inherit = FALSE;
225  if (!empty($type_inherit)) {
226  $inherit = array_shift($type_inherit);
227  }
228 
229  $type_name = $GLOBALS['SQ_SYSTEM']->am->getTypeInfo($type_code, 'name');
230  echo '<li>';
231  get_asset_type_icon($type_code);
232  echo ' '.$type_name;
233 
234  if ($inherit) {
235  echo ' ('.translate('cms_page_site_map_inherits_child_types').')';
236  }
237 
238  echo '</li>';
239  }
240  }
241  ?></ul><?php
242  }
243  }//end else
244 
245  return $write_access;
246 
247  }//end paintTypeIncludeList()
248 
249 
260  function processTypeIncludeList(&$asset, &$o, $prefix)
261  {
262  $exclude_types = Array();
263  if (isset($_POST[$prefix.'_include_types']) && !empty($_POST[$prefix.'_include_types']['type_code'][0])) {
264  $exclude_types = $_POST[$prefix.'_include_types'];
265  }
266 
267  return $asset->setAttrValue('include_types', $exclude_types);
268 
269  }//end processTypeIncludeList()
270 
271 
282  function paintTypeFormats(&$asset, &$o, $prefix)
283  {
284  $write_access = $asset->writeAccess('attributes');
285 
286  $formats = $asset->attr('display_formats');
287 
288 
289  if ($write_access) {
290  $formats[] = Array();
291  } else if (empty($formats)) {
292  echo translate('cms_page_site_map_no_display_formats');
293  return;
294  }
295 
296 
297  ?>
298  <table class="sq-backend-table">
299  <tr>
300  <th><?php echo translate('asset_type'); ?></th><?php echo (!$write_access ? '<th>'.translate('inherit').'</th>' : ''); ?><th><?php echo translate('format'); ?></th><?php echo ($write_access ? '<th>'.translate('delete').'</th>' : ''); ?>
301  </tr>
302  <?php
303  foreach ($formats as $key => $format) {
304  $row_prefix = $prefix.'_display_formats['.$key.']';
305  if (empty($format)) {
306  $current_type = Array();
307  } else {
308  $current_type = Array(
309  'type_code' => $key,
310  'inherit' => $format['inherit'],
311  );
312  }
313  ?>
314  <tr>
315  <?php
316  if ($write_access) {
317  ?>
318  <td class="sq-backend-table-cell"><?php asset_type_chooser($row_prefix.'[type]', FALSE, $current_type, NULL, FALSE, TRUE); ?></td>
319  <td class="sq-backend-table-cell"><?php text_box($row_prefix.'[format]', array_get_index($format,'format', ''), 70); ?></td>
320  <td class="sq-backend-table-cell"><?php check_box($row_prefix.'[delete]'); ?></td>
321  <?php
322  } else {
323  ?>
324  <td class="sq-backend-table-cell"><?php get_asset_type_icon($key); echo $GLOBALS['SQ_SYSTEM']->am->getTypeInfo($key, 'name'); ?></td>
325  <td class="sq-backend-table-cell"><?php echo ($format['inherit'] ? translate('yes') : translate('no')); ?></td>
326  <td class="sq-backend-table-cell"><?php echo $format['format']; ?></td>
327  <?php
328  }
329  ?>
330 
331  </tr>
332  <?php
333  }
334  ?>
335  </table>
336  <?php
337 
338  }//end paintTypeFormats()
339 
340 
351  function processTypeFormats(&$asset, &$o, $prefix)
352  {
353 
354  if (isset($_POST[$prefix.'_display_formats'])) {
355  $formats = Array();
356 
357  foreach ($_POST[$prefix.'_display_formats'] as $type => $format) {
358  if (isset($format['delete']) || empty($format['format'])) {
359  continue;
360  }
361 
362  $formats[$format['type']['type_code']] = Array(
363  'inherit' => $format['type']['inherit'],
364  'format' => $format['format'],
365  );
366  }
367 
368  if ($asset->setAttrValue('display_formats', $formats)) {
369  return TRUE;
370  }
371  }
372 
373  return FALSE;
374 
375  }//end processTypeFormats()
376 
377 
378 }//end class
379 
380 ?>