Overview

Packages

  • ClipIt
    • clipit
      • api
    • urjc
      • backend
  • Elgg
    • Core
      • Access
      • Authentication
      • Cache
      • Caches
      • Core
      • DataMode
        • Site
      • DataModel
        • Annotations
        • Entities
        • Extender
        • File
        • Importable
        • Loggable
        • Notable
        • Object
        • User
      • DataStorage
      • Exception
      • Exceptions
        • Stub
      • FileStore
        • Disk
      • Groups
      • Helpers
      • HMAC
      • Memcache
      • Metadata
      • Navigation
      • ODD
      • Output
      • Plugins
        • Settings
      • Sessions
      • SocialModel
        • Friendable
        • Locatable
      • WebServicesAPI
      • Widgets
      • XML
      • XMLRPC
    • Exceptions
      • Stub
  • None
  • PHP

Classes

  • ElggPluginManifest
  • ElggPluginManifestParser
  • ElggPluginManifestParser17
  • ElggPluginManifestParser18
  • ElggPluginPackage
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * Plugin manifest.xml parser for Elgg 1.7 and lower.
 4:  *
 5:  * @package    Elgg.Core
 6:  * @subpackage Plugins
 7:  * @since      1.8
 8:  */
 9: class ElggPluginManifestParser17 extends ElggPluginManifestParser {
10:     /**
11:      * The valid top level attributes and defaults for a 1.7 manifest
12:      */
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: 
24:     /**
25:      * Parse a manifest object from 1.7 or earlier.
26:      *
27:      * @return void
28:      */
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: 
66:     /**
67:      * Return an attribute in the manifest.
68:      *
69:      * Overrides ElggPluginManifestParser::getAttribute() because before 1.8
70:      * there were no rules...weeeeeeeee!
71:      *
72:      * @param string $name Attribute name
73:      * @return mixed
74:      */
75:     public function getAttribute($name) {
76:         if (isset($this->manifest[$name])) {
77:             return $this->manifest[$name];
78:         }
79: 
80:         return false;
81:     }
82: }
83: 
API documentation generated by ApiGen 2.8.0