Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
design_area_asset_lineage_edit_fns.inc
1 <?php
18 require_once SQ_CORE_PACKAGE_PATH.'/designs/design_area/design_area_edit_fns.inc';
19 
32 {
33 
34 
39  function __construct()
40  {
41  parent::__construct();
42 
43  }//end constructor
44 
45 
55  public function _processContents(Design_Area_Asset_Lineage $asset, Array &$contents)
56  {
57  if (!$this->_setVariables($asset, $contents)) {
58  return FALSE;
59  }
60 
61  $asset_index = -1;
62  $divider_index = -1;
63  // see if our page element has any sub's in it
64  foreach ($contents as $index => $element) {
65  if ($element['_type'] != 'TAG') continue;
66 
67  switch ($element['operation']) {
68  case 'asset' :
69  $asset_index = $index;
70  break;
71 
72  case 'divider' :
73  $divider_index = $index;
74  break;
75 
76  }//end switch
77 
78  }//end foreach
79 
80  // OK, so we have some asset contents, so extract it
81  if ($asset_index >= 0) {
82 
83  // if there is no contents, then see if there is a default
84  if (empty($contents[$asset_index]['contents'])) {
85  $contents[$asset_index]['contents'] = $this->_getDefaultContents($asset, 'asset');
86  }
87 
88  if (!$asset->setAttrValue('asset_contents', $contents[$asset_index]['contents'])) {
89  return FALSE;
90  }
91 
92  // Now what we do is morph it so that this element doesn't contain all the un-necessary contents stuff
93  $contents[$asset_index] = Array(
94  '_type' => 'TAG',
95  'attributes' => Array(),
96  'operation' => 'asset',
97  'self_terminating' => 1,
98  );
99 
100  }//end if
101 
102  // OK, so we have some divider contents, so extract it
103  if ($divider_index >= 0) {
104 
105  if (!$asset->setAttrValue('divider_contents', $contents[$divider_index]['contents'])) {
106  return FALSE;
107  }
108 
109  // Now we want to remove the divider section
110  array_splice($contents, $divider_index, 1);
111 
112  } else {
113  // we dont have a tag, so lets use the default value instead
114  if (!$asset->setAttrValue('divider_contents', $this->_getDefaultContents($asset, 'divider'))) {
115  return FALSE;
116  }
117  }
118 
119  $GLOBALS['SQ_PROCESSED_DESIGN_AREAS'][$asset->attr('id_name')] = TRUE;
120  return $asset->setAttrValue('contents', $contents);
121 
122  }//end _processContents()
123 
124 
136  {
137  $excluded_types = $asset->attr('unwanted_asset_types');
138  if ($asset->writeAccess('attributes')) {
139  asset_type_chooser($prefix.'_excluded_types', TRUE, $excluded_types);
140  } else {
141  if (empty($excluded_types)) {
142  echo 'No types are excluded';
143  } else {
144  ?>
145  <ul>
146  <?php
147  foreach ($GLOBALS['SQ_SYSTEM']->am->getTypeInfo($excluded_types, 'name') as $type_name) {
148  ?>
149  <li><?php echo $type_name; ?></li>
150  <?php
151  }
152  ?>
153  </ul>
154  <?php
155  }
156  }
157 
158  }//end paintExcludedTypes()
159 
160 
172  {
173  if ($asset->writeAccess('attributes')) {
174  // bug #2712: asset chooser returns an array of empty strings
175  // instead of an empty array
176  $exclude_list = Array();
177  foreach ($_POST[$prefix.'_excluded_types'] as $type) {
178  if ($type != '') $exclude_list[] = $type;
179  }
180  return $asset->setAttrValue('unwanted_asset_types', $exclude_list);
181  } else {
182  return FALSE;
183  }
184 
185  }//end processExcludedTypes()
186 
187 
188 }//end class
189 ?>