Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
report_incomplete_metadata.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_Incomplete_Metadata 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 
65  if (!is_file($report_path)) return Array();
66 
67  try {
68  $root = new SimpleXMLElement($report_path, LIBXML_NOCDATA, TRUE);
69  } catch (Exception $e) {
70  return Array();
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  'is_dependant' => 0,
94  );
95 
96  $sort_order++;
97  }
98 
99  $this->_tmp['getAssetMapLinks'] = $links;
100 
101  }//end if not cached
102 
103  return $this->_tmp['getAssetMapLinks'];
104 
105  }//end getAssetMapLinks()
106 
107 
131  public function getLinks($assetid, $link_types, $type_code='', $strict_type_code=TRUE, $side_of_link='major', $sort_by=NULL, $dependant=NULL, $exclusive=NULL)
132  {
133  assert_equals($assetid, $this->id, 'The Asset Statuses Report can only get its own links');
134  if ($dependant || $exclusive) {
135  return Array();
136  }
137 
138  if (!isset($this->_tmp['getLinks'])) {
139 
140  $am = $GLOBALS['SQ_SYSTEM']->am;
141  require_once SQ_INCLUDE_PATH.'/general_occasional.inc';
142  $report_path = $this->data_path.'/report.xml';
143  if (!is_file($report_path)) return Array();
144 
145  try {
146  $root = new SimpleXMLElement($report_path, LIBXML_NOCDATA, TRUE);
147  } catch (Exception $e) {
148  return Array();
149  }
150 
151  $links = Array();
152  $sort_order = 0;
153  foreach ($root->asset as $asset) {
154  if (is_null($asset->attributes()->type_code)) {
155  // old xml format, needs regenerating before it can act as a bridge
156  return Array();
157  }
158 
159  $links[] = Array(
160  'linkid' => 0,
161  'majorid' => $this->id,
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 Asset Statuses 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 Asset Statuses 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 
258  public function deleteAssetLink($linkid, $moving=FALSE)
259  {
260  return FALSE;
261 
262  }//end deleteAssetLink()
263 
264 
280  public function getAllowedAssetTypeMap()
281  {
282  if (isset($this->_tmp['allowed_asset_map'])) {
283  return $this->_tmp['allowed_asset_map'];
284  }
285 
286  $wanted_types = $this->attr('types');
287  if (empty($wanted_types)) return Array();
288 
289  $allowed_asset_map = Array();
290  foreach ($wanted_types as $allowed_parent_type => $inherit) {
291  if (trim($allowed_parent_type) == '') {
292  continue;
293  } else if (!$inherit) {
294  $allowed_asset_map[$allowed_parent_type] = $allowed_parent_type;
295  } else {
296  $descendants = $GLOBALS['SQ_SYSTEM']->am->getTypeDescendants($allowed_parent_type, TRUE);
297  foreach ($descendants as $allowed_type) {
298  if (!isset($allowed_asset_map[$allowed_type])) {
299  $allowed_asset_map[$allowed_type] = $allowed_parent_type;
300  }
301  }
302  }
303  }
304 
305  $this->_tmp['allowed_asset_map'] = $allowed_asset_map;
306  return $allowed_asset_map;
307 
308  }//end getAllowedAssetTypeMap()
309 
310 
332  public function countLinks($assetid, $side_of_link='major', $link_types=0, $type_code='', $strict_type_code=TRUE, $ignore_linkid=0)
333  {
334  return 0;
335 
336  }//end countLinks()
337 
338 
347  public function getAssetMapAssetInfo($assetid)
348  {
349  return Array();
350 
351  }//end getAssetMapAssetInfo()
352 
353 
371  public function getAsset($shadowid, $type_code='', $mute_errors=FALSE)
372  {
373  return NULL;
374 
375  }//end getAsset()
376 
377 
378 }//end class
379 
380 ?>