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.8 and above.
 4:  *
 5:  * @package    Elgg.Core
 6:  * @subpackage Plugins
 7:  * @since      1.8
 8:  */
 9: class ElggPluginManifestParser18 extends ElggPluginManifestParser {
10:     /**
11:      * The valid top level attributes and defaults for a 1.8 manifest array.
12:      *
13:      * @var array
14:      */
15:     protected $validAttributes = array(
16:         'name', 'author', 'version', 'blurb', 'description','website',
17:         'repository', 'bugtracker', 'donations', 'copyright', 'license',
18:         'requires', 'suggests', 'conflicts', 'provides',
19:         'screenshot', 'category', 'activate_on_install'
20:     );
21: 
22:     /**
23:      * Required attributes for a valid 1.8 manifest
24:      *
25:      * @var array
26:      */
27:     protected $requiredAttributes = array(
28:         'name', 'author', 'version', 'description', 'requires'
29:     );
30: 
31:     /**
32:      * Parse a manifest object from 1.8 and later
33:      *
34:      * @return void
35:      */
36:     public function parse() {
37:         $parsed = array();
38:         foreach ($this->manifestObject->children as $element) {
39:             switch ($element->name) {
40:                 // single elements
41:                 case 'blurb':
42:                 case 'description':
43:                 case 'name':
44:                 case 'author':
45:                 case 'version':
46:                 case 'website':
47:                 case 'copyright':
48:                 case 'license':
49:                 case 'repository':
50:                 case 'bugtracker':
51:                 case 'donations':
52:                 case 'activate_on_install':
53:                     $parsed[$element->name] = $element->content;
54:                     break;
55: 
56:                 // arrays
57:                 case 'category':
58:                     $parsed[$element->name][] = $element->content;
59:                     break;
60: 
61:                 // 3d arrays
62:                 case 'screenshot':
63:                 case 'provides':
64:                 case 'conflicts':
65:                 case 'requires':
66:                 case 'suggests':
67:                     if (!isset($element->children)) {
68:                         return false;
69:                     }
70: 
71:                     $info = array();
72:                     foreach ($element->children as $child_element) {
73:                         $info[$child_element->name] = $child_element->content;
74:                     }
75: 
76:                     $parsed[$element->name][] = $info;
77:                     break;
78:             }
79:         }
80: 
81:         // check we have all the required fields
82:         foreach ($this->requiredAttributes as $attr) {
83:             if (!array_key_exists($attr, $parsed)) {
84:                 throw new PluginException(elgg_echo('PluginException:ParserErrorMissingRequiredAttribute',
85:                             array($attr, $this->caller->getPluginID())));
86:             }
87:         }
88: 
89:         $this->manifest = $parsed;
90: 
91:         if (!$this->manifest) {
92:             return false;
93:         }
94: 
95:         return true;
96:     }
97: }
98: 
API documentation generated by ApiGen 2.8.0