Elgg  Version 1.9
ElggPluginManifestParser17.php
Go to the documentation of this file.
1 <?php
13  protected $validAttributes = array(
14  'author', 'version', 'description', 'website',
15  'copyright', 'license', 'licence', 'elgg_version',
16 
17  // were never really used and not enforced in code.
18  'requires', 'recommends', 'conflicts',
19 
20  // not a 1.7 field, but we need it
21  'name',
22  );
23 
29  public function parse() {
30  if (!isset($this->manifestObject->children)) {
31  return false;
32  }
33 
34  $elements = array();
35 
36  foreach ($this->manifestObject->children as $element) {
37  $key = $element->attributes['key'];
38  $value = $element->attributes['value'];
39 
40  // create arrays if multiple fields are set
41  if (array_key_exists($key, $elements)) {
42  if (!is_array($elements[$key])) {
43  $orig = $elements[$key];
44  $elements[$key] = array($orig);
45  }
46 
47  $elements[$key][] = $value;
48  } else {
49  $elements[$key] = $value;
50  }
51  }
52 
53  if ($elements && !array_key_exists('name', $elements)) {
54  $elements['name'] = $this->caller->getName();
55  }
56 
57  $this->manifest = $elements;
58 
59  if (!$this->manifest) {
60  return false;
61  }
62 
63  return true;
64  }
65 
75  public function getAttribute($name) {
76  if (isset($this->manifest[$name])) {
77  return $this->manifest[$name];
78  }
79 
80  return false;
81  }
82 }
getAttribute($name)
Return an attribute in the manifest.
if($guid==elgg_get_logged_in_user_guid()) $name
Definition: delete.php:21
$value
Definition: longtext.php:29
$key
Definition: summary.php:34
parse()
Parse a manifest object from 1.7 or earlier.
$validAttributes
The valid top level attributes and defaults for a 1.7 manifest.