Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
report_safe_trash.inc
1 <?php
18 require_once SQ_CORE_PACKAGE_PATH.'/report/report.inc';
19 require_once SQ_CORE_PACKAGE_PATH.'/interfaces/bridge/bridge.inc';
20 
32 class Report_Safe_Trash extends Report implements Bridge
33 {
34 
35 
42  function __construct($assetid=0)
43  {
44  $this->_ser_attrs = TRUE;
45  parent::__construct($assetid);
46 
47  }//end constructor
48 
49 
56  public function getAssetMapLinks()
57  {
58  if (!isset($this->_tmp['getAssetMapLinks'])) {
59 
60  $am = $GLOBALS['SQ_SYSTEM']->am;
61  require_once SQ_INCLUDE_PATH.'/general_occasional.inc';
62 
63  $report_path = $this->data_path.'/report.xml';
64  if (!is_file($report_path)) return Array();
65 
66  try {
67  $root = new SimpleXMLElement($report_path, LIBXML_NOCDATA, TRUE);
68  } catch (Exception $e) {
69  return Array();
70  }
71 
72  $links = Array();
73  $sort_order = 0;
74  foreach ($root->asset as $result) {
75  if (is_null($result->attributes()->type_code)) {
76  // old xml format, needs regenerating before it can act as a bridge
77  return Array();
78  }
79 
80  $links[] = Array(
81  'assetid' => (String) $result->attributes()->assetid,
82  'short_name' => (String) $result->attributes()->short_name,
83  'name' => (String) $result->attributes()->name,
84  'accessible' => 1,
85  'type_code' => (String) $result->attributes()->type_code,
86  'status' => (String) $result->attributes()->status,
87  'linkid' => '0',
88  'link_type' => SQ_LINK_TYPE_1,
89  'num_kids' => 0,
90  'sort_order' => $sort_order,
91  'url' => '',
92  'path' => '',
93  'locked' => 0,
94  'is_dependant' => 0,
95  );
96 
97  $sort_order++;
98  }
99 
100  $this->_tmp['getAssetMapLinks'] = $links;
101 
102  }//end if not cached
103 
104  return $this->_tmp['getAssetMapLinks'];
105 
106  }//end getAssetMapLinks()
107 
108 
132  public function getLinks($assetid, $link_types, $type_code='', $strict_type_code=TRUE, $side_of_link='major', $sort_by=NULL, $dependant=NULL, $exclusive=NULL)
133  {
134  assert_equals($assetid, $this->id, 'The Safe Trash Report can only get its own links');
135  if ($dependant || $exclusive) {
136  return Array();
137  }
138 
139  if (!isset($this->_tmp['getLinks'])) {
140 
141  $am = $GLOBALS['SQ_SYSTEM']->am;
142  require_once SQ_INCLUDE_PATH.'/general_occasional.inc';
143  $report_path = $this->data_path.'/report.xml';
144  if (!is_file($report_path)) return Array();
145 
146  try {
147  $root = new SimpleXMLElement($report_path, LIBXML_NOCDATA, TRUE);
148  } catch (Exception $e) {
149  return Array();
150  }
151 
152  $links = Array();
153  $sort_order = 0;
154  foreach ($root->asset as $asset) {
155  if (is_null($asset->attributes()->type_code)) {
156  // old xml format, needs regenerating before it can act as a bridge
157  return Array();
158  }
159 
160  $links[] = Array(
161  'linkid' => 0,
162  'minorid' => (String) $asset->attributes()->assetid,
163  'value' => '',
164  'link_type' => SQ_LINK_TYPE_1,
165  'minor_type_code' => (String) $asset->attributes()->type_code,
166  'sort_order' => $sort_order,
167  'is_dependant' => '0',
168  'is_exclusive' => '0',
169  'locked' => 0,
170  );
171 
172  $sort_order++;
173  }
174 
175  $this->_tmp['getLinks'] = $links;
176 
177  }//end if not cached
178 
179  return $this->_tmp['getLinks'];
180 
181  }//end getLinks()
182 
183 
197  public function getParents($assetid, $type_code='', $strict_type_code=TRUE)
198  {
199  assert_equals($assetid, $this->id, 'The Safe Trash Report can only get its own links');
200  return Array();
201 
202  }//end getParents()
203 
204 
225  public function getChildren($assetid, $type_code='', $strict_type_code=TRUE, $dependant=NULL, $sort_by=NULL)
226  {
227  assert_equals($assetid, $this->id, 'The Safe Trash Report can only get its own links');
228  return Array();
229 
230  }//end getChildren()
231 
232 
243  public function getLineageFromURL($assetid, $protocol, $url)
244  {
245 
246  }//end getLineageFromURL()
247 
248 
264  public function getAllowedAssetTypeMap()
265  {
266  if (isset($this->_tmp['allowed_asset_map'])) {
267  return $this->_tmp['allowed_asset_map'];
268  }
269 
270  $wanted_types = $this->attr('types');
271  if (empty($wanted_types)) return Array();
272 
273  $allowed_asset_map = Array();
274  foreach ($wanted_types as $allowed_parent_type => $inherit) {
275  if (trim($allowed_parent_type) == '') {
276  continue;
277  } else if (!$inherit) {
278  $allowed_asset_map[$allowed_parent_type] = $allowed_parent_type;
279  } else {
280  $descendants = $GLOBALS['SQ_SYSTEM']->am->getTypeDescendants($allowed_parent_type, TRUE);
281  foreach ($descendants as $allowed_type) {
282  if (!isset($allowed_asset_map[$allowed_type])) {
283  $allowed_asset_map[$allowed_type] = $allowed_parent_type;
284  }
285  }
286  }
287  }
288 
289  $this->_tmp['allowed_asset_map'] = $allowed_asset_map;
290  return $allowed_asset_map;
291 
292  }//end getAllowedAssetTypeMap()
293 
294 
316  public function countLinks($assetid, $side_of_link='major', $link_types=0, $type_code='', $strict_type_code=TRUE, $ignore_linkid=0)
317  {
318  return 0;
319 
320  }//end countLinks()
321 
322 
331  public function getAssetMapAssetInfo($assetid)
332  {
333  return Array();
334 
335  }//end getAssetMapAssetInfo()
336 
337 
355  public function getAsset($shadowid, $type_code='', $mute_errors=FALSE)
356  {
357  return NULL;
358 
359  }//end getAsset()
360 
361 
371  public function deleteAssetLink($linkid, $moving=FALSE)
372  {
373  return FALSE;
374 
375  }//end deleteAssetLink()
376 
377 
378 }//end class
379 
380 ?>