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);
169 $manifest_obj = new \ElggXMLElement($raw_xml);
171 $manifest_obj = null;
175 if (!$manifest_obj) {
176 throw new \PluginException(
_elgg_services()->translator->translate(
'PluginException:InvalidManifest',
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);
196 $class_exists =
false;
200 $this->parser =
new $parser_class_name($manifest_obj, $this);
202 throw new \PluginException(
_elgg_services()->translator->translate(
'PluginException:NoAvailableParser',
206 if (!$this->parser->parse()) {
207 throw new \PluginException(
_elgg_services()->translator->translate(
'PluginException:ParserError',
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(
414 'site_notifications',
418 'uservalidationbyemail',
423 $cats = $this->parser->getAttribute(
'category');
429 if (in_array(
'bundled', $cats) && !in_array($this->
getPluginID(), $bundled_plugins)) {
430 unset($cats[array_search(
'bundled', $cats)]);
442 $ss = $this->parser->getAttribute(
'screenshot');
448 $normalized = array();
449 foreach ($ss as $s) {
450 $normalized[] = $this->
buildStruct($this->screenshotStruct, $s);
462 $ss = $this->parser->getAttribute(
'contributor');
468 $normalized = array();
469 foreach ($ss as $s) {
470 $normalized[] = $this->
buildStruct($this->contributorStruct, $s);
486 $provides = $this->parser->getAttribute(
'provides');
494 if ($this->pluginID) {
502 $normalized = array();
503 foreach ($provides as $provide) {
504 $normalized[] = $this->
buildStruct($this->depsProvidesStruct, $provide);
517 if ($this->apiVersion < 1.8) {
518 $elgg_version = $this->parser->getAttribute(
'elgg_version');
522 'type' =>
'elgg_version',
523 'version' => $elgg_version,
531 $reqs = $this->parser->getAttribute(
'requires');
538 $normalized = array();
539 foreach ($reqs as $req) {
540 $normalized[] = $this->normalizeDep($req);
552 $suggests = $this->parser->getAttribute(
'suggests');
558 $normalized = array();
559 foreach ($suggests as $suggest) {
560 $normalized[] = $this->normalizeDep($suggest);
573 private function normalizeDep($dep) {
574 switch ($dep[
'type']) {
577 $struct = $this->depsStructElgg;
581 $struct = $this->depsStructPlugin;
585 $struct = $this->depsStructPriority;
589 $struct = $this->depsStructPhpVersion;
592 case 'php_extension':
593 $struct = $this->depsStructPhpExtension;
597 $struct = $this->depsStructPhpIni;
600 if (isset($dep[
'value'])) {
601 switch (strtolower($dep[
'value'])) {
625 $normalized_dep = $this->
buildStruct($struct, $dep);
628 if (isset($normalized_dep[
'comparison'])) {
629 switch ($normalized_dep[
'comparison']) {
631 $normalized_dep[
'comparison'] =
'lt';
635 $normalized_dep[
'comparison'] =
'le';
639 $normalized_dep[
'comparison'] =
'gt';
643 $normalized_dep[
'comparison'] =
'ge';
648 $normalized_dep[
'comparison'] =
'=';
653 $normalized_dep[
'comparison'] =
'!=';
658 return $normalized_dep;
669 $conflicts = array();
671 $conflicts = $this->parser->getAttribute(
'conflicts');
675 $conflicts = array();
678 $normalized = array();
680 foreach ($conflicts as $conflict) {
681 $normalized[] = $this->
buildStruct($this->depsConflictsStruct, $conflict);
693 $activate = $this->parser->getAttribute(
'activate_on_install');
694 switch (strtolower($activate)) {
721 foreach ($struct as $index =>
$default) {
738 $cat_raw_string =
"admin:plugins:category:$category";
739 $cat_display_string =
_elgg_services()->translator->translate($cat_raw_string);
740 if ($cat_display_string == $cat_raw_string) {
741 $category = str_replace(array(
'-',
'_'),
' ', $category);
742 $cat_display_string = ucwords($category);
744 return $cat_display_string;
getCopyright()
Return the copyright.
getLicense()
Returns the license.
getName()
Returns the plugin name.
if($guid==elgg_get_logged_in_user_guid()) $name
getRepositoryURL()
Returns the repository url.
getApiVersion()
Returns the API version in use.
getScreenshots()
Return the screenshots listed.
elgg_extract($key, array $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
getDescription()
Return the description.
getID()
Return the plugin ID required by the author.
getPluginID()
Returns the plugin ID.
getSuggests()
Returns the suggests elements.
getBlurb()
Return the short description.
getAuthor()
Returns the plugin author.
getManifest()
Returns the manifest array.
getContributors()
Return the contributors listed.
$namespace_root
The root for plugin manifest namespaces.
getVersion()
Returns the version of the plugin.
getActivateOnInstall()
Should this plugin be activated when Elgg is installed.
getDonationsPageURL()
Returns the donations page.
getCategories()
Return the categories listed for this plugin.
static getFriendlyCategory($category)
Returns a category's friendly name.
getBugTrackerURL()
Returns the bug tracker page.
getProvides()
Return the list of provides by this plugin.
elgg_get_excerpt($text, $num_chars=250)
Returns an excerpt.
buildStruct(array $struct, array $array)
Normalizes an array into the structure specified.
getRequires()
Returns the dependencies listed.
__construct($manifest, $plugin_id=null)
Load a manifest file, XmlElement or path to manifest.xml file.
getWebsite()
Return the website.
getConflicts()
Returns the conflicts listed.