36 private $depsStructPlugin = array(
46 private $depsStructPriority = array(
55 private $depsStructElgg = array(
64 private $depsStructPhpVersion = array(
73 private $depsStructPhpIni = array(
83 private $depsStructPhpExtension = array(
93 private $depsConflictsStruct = array(
103 private $depsProvidesStruct = array(
112 private $screenshotStruct = array(
120 private $contributorStruct = array(
158 $manifest_obj = $manifest;
161 if (substr(trim($manifest), 0, 1) ==
'<') {
163 $raw_xml = $manifest;
164 } elseif (is_file($manifest)) {
166 $raw_xml = file_get_contents($manifest);
171 $manifest_obj =
null;
175 if (!$manifest_obj) {
181 if (isset($manifest_obj->attributes[
'xmlns'])) {
182 $namespace = $manifest_obj->attributes[
'xmlns'];
183 $version = str_replace($this->namespace_root,
'', $namespace);
190 $parser_class_name =
'ElggPluginManifestParser' . str_replace(
'.',
'', $this->apiVersion);
194 $class_exists = class_exists($parser_class_name);
195 }
catch (Exception
$e) {
196 $class_exists =
false;
200 $this->parser =
new $parser_class_name($manifest_obj, $this);
206 if (!$this->parser->parse()) {
227 if ($this->pluginID) {
243 return $this->parser->getManifest();
256 $name = $this->parser->getAttribute(
'name');
258 if (!
$name && $this->pluginID) {
259 $name = ucwords(str_replace(
'_',
' ', $this->pluginID));
272 return trim((
string) $this->parser->getAttribute(
'id'));
282 return $this->parser->getAttribute(
'description');
291 $blurb = $this->parser->getAttribute(
'blurb');
307 $en_us = $this->parser->getAttribute(
'license');
311 return $this->parser->getAttribute(
'licence');
321 return $this->parser->getAttribute(
'repository');
330 return $this->parser->getAttribute(
'bugtracker');
339 return $this->parser->getAttribute(
'donations');
348 return $this->parser->getAttribute(
'version');
357 return $this->parser->getAttribute(
'author');
366 return $this->parser->getAttribute(
'copyright');
375 return $this->parser->getAttribute(
'website');
384 $bundled_plugins = array(
'aalborg_theme',
'blog',
'bookmarks',
'categories',
'ckeditor',
385 'custom_index',
'dashboard',
'developers',
'diagnostics',
386 'embed',
'externalpages',
'file',
'garbagecollector',
387 'groups',
'htmlawed',
'invitefriends',
'legacy_urls',
'likes',
388 'logbrowser',
'logrotate',
'members',
'messageboard',
389 'messages',
'notifications',
'pages',
'profile',
390 'reportedcontent',
'search',
'site_notifications',
'tagcloud',
'thewire',
391 'twitter_api',
'uservalidationbyemail',
'web_services',
'zaudio',
394 $cats = $this->parser->getAttribute(
'category');
400 if (in_array(
'bundled', $cats) && !in_array($this->
getPluginID(), $bundled_plugins)) {
401 unset($cats[array_search(
'bundled', $cats)]);
413 $ss = $this->parser->getAttribute(
'screenshot');
419 $normalized = array();
420 foreach ($ss as $s) {
421 $normalized[] = $this->
buildStruct($this->screenshotStruct, $s);
433 $ss = $this->parser->getAttribute(
'contributor');
439 $normalized = array();
440 foreach ($ss as $s) {
441 $normalized[] = $this->
buildStruct($this->contributorStruct, $s);
457 $provides = $this->parser->getAttribute(
'provides');
465 if ($this->pluginID) {
473 $normalized = array();
474 foreach ($provides as $provide) {
475 $normalized[] = $this->
buildStruct($this->depsProvidesStruct, $provide);
488 if ($this->apiVersion < 1.8) {
489 $elgg_version = $this->parser->getAttribute(
'elgg_version');
493 'type' =>
'elgg_version',
494 'version' => $elgg_version,
502 $reqs = $this->parser->getAttribute(
'requires');
509 $normalized = array();
510 foreach ($reqs as $req) {
511 $normalized[] = $this->normalizeDep($req);
523 $suggests = $this->parser->getAttribute(
'suggests');
529 $normalized = array();
530 foreach ($suggests as $suggest) {
531 $normalized[] = $this->normalizeDep($suggest);
544 private function normalizeDep($dep) {
545 switch ($dep[
'type']) {
548 $struct = $this->depsStructElgg;
552 $struct = $this->depsStructPlugin;
556 $struct = $this->depsStructPriority;
560 $struct = $this->depsStructPhpVersion;
563 case 'php_extension':
564 $struct = $this->depsStructPhpExtension;
568 $struct = $this->depsStructPhpIni;
571 if (isset($dep[
'value'])) {
572 switch (strtolower($dep[
'value'])) {
596 $normalized_dep = $this->
buildStruct($struct, $dep);
599 if (isset($normalized_dep[
'comparison'])) {
600 switch ($normalized_dep[
'comparison']) {
602 $normalized_dep[
'comparison'] =
'lt';
606 $normalized_dep[
'comparison'] =
'le';
610 $normalized_dep[
'comparison'] =
'gt';
614 $normalized_dep[
'comparison'] =
'ge';
619 $normalized_dep[
'comparison'] =
'=';
624 $normalized_dep[
'comparison'] =
'!=';
629 return $normalized_dep;
640 $conflicts = array();
642 $conflicts = $this->parser->getAttribute(
'conflicts');
646 $conflicts = array();
649 $normalized = array();
651 foreach ($conflicts as $conflict) {
652 $normalized[] = $this->
buildStruct($this->depsConflictsStruct, $conflict);
664 $activate = $this->parser->getAttribute(
'activate_on_install');
665 switch (strtolower($activate)) {
692 foreach ($struct as $index =>
$default) {
709 $cat_raw_string =
"admin:plugins:category:$category";
710 $cat_display_string =
elgg_echo($cat_raw_string);
711 if ($cat_display_string == $cat_raw_string) {
712 $category = str_replace(array(
'-',
'_'),
' ', $category);
713 $cat_display_string = ucwords($category);
715 return $cat_display_string;
if($guid==elgg_get_logged_in_user_guid()) $name
getPluginID()
Returns the plugin ID.
getDonationsPageURL()
Returns the donations page.
getCategories()
Return the categories listed for this plugin.
getContributors()
Return the contributors listed.
getSuggests()
Returns the suggests elements.
getScreenshots()
Return the screenshots listed.
getActivateOnInstall()
Should this plugin be activated when Elgg is installed.
getManifest()
Returns the manifest array.
getLicense()
Returns the license.
getVersion()
Returns the version of the plugin.
getApiVersion()
Returns the API version in use.
static getFriendlyCategory($category)
Returns a category's friendly name.
getRepositoryURL()
Returns the repository url.
buildStruct(array $struct, array $array)
Normalizes an array into the structure specified.
getProvides()
Return the list of provides by this plugin.
getWebsite()
Return the website.
__construct($manifest, $plugin_id=null)
Load a manifest file, XmlElement or path to manifest.xml file.
$namespace_root
The root for plugin manifest namespaces.
getCopyright()
Return the copyright.
getName()
Returns the plugin name.
getID()
Return the plugin ID required by the author.
getBugTrackerURL()
Returns the bug tracker page.
getRequires()
Returns the dependencies listed.
getBlurb()
Return the short description.
getAuthor()
Returns the plugin author.
getConflicts()
Returns the conflicts listed.
getDescription()
Return the description.
elgg_extract($key, array $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
elgg_get_excerpt($text, $num_chars=250)
Returns an excerpt.