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',
422 $cats = $this->parser->getAttribute(
'category');
428 if (in_array(
'bundled', $cats) && !in_array($this->
getPluginID(), $bundled_plugins)) {
429 unset($cats[array_search(
'bundled', $cats)]);
441 $ss = $this->parser->getAttribute(
'screenshot');
447 $normalized = array();
448 foreach ($ss as $s) {
449 $normalized[] = $this->
buildStruct($this->screenshotStruct, $s);
461 $ss = $this->parser->getAttribute(
'contributor');
467 $normalized = array();
468 foreach ($ss as $s) {
469 $normalized[] = $this->
buildStruct($this->contributorStruct, $s);
485 $provides = $this->parser->getAttribute(
'provides');
493 if ($this->pluginID) {
501 $normalized = array();
502 foreach ($provides as $provide) {
503 $normalized[] = $this->
buildStruct($this->depsProvidesStruct, $provide);
515 $reqs = $this->parser->getAttribute(
'requires');
521 $normalized = array();
522 foreach ($reqs as $req) {
523 $normalized[] = $this->normalizeDep($req);
535 $suggests = $this->parser->getAttribute(
'suggests');
541 $normalized = array();
542 foreach ($suggests as $suggest) {
543 $normalized[] = $this->normalizeDep($suggest);
556 private function normalizeDep($dep) {
557 switch ($dep[
'type']) {
559 $struct = $this->depsStructElgg;
563 $struct = $this->depsStructPlugin;
567 $struct = $this->depsStructPriority;
571 $struct = $this->depsStructPhpVersion;
574 case 'php_extension':
575 $struct = $this->depsStructPhpExtension;
579 $struct = $this->depsStructPhpIni;
582 if (isset($dep[
'value'])) {
583 switch (strtolower($dep[
'value'])) {
607 $normalized_dep = $this->
buildStruct($struct, $dep);
610 if (isset($normalized_dep[
'comparison'])) {
611 switch ($normalized_dep[
'comparison']) {
613 $normalized_dep[
'comparison'] =
'lt';
617 $normalized_dep[
'comparison'] =
'le';
621 $normalized_dep[
'comparison'] =
'gt';
625 $normalized_dep[
'comparison'] =
'ge';
630 $normalized_dep[
'comparison'] =
'=';
635 $normalized_dep[
'comparison'] =
'!=';
640 return $normalized_dep;
651 $conflicts = array();
653 $conflicts = $this->parser->getAttribute(
'conflicts');
657 $conflicts = array();
660 $normalized = array();
662 foreach ($conflicts as $conflict) {
663 $normalized[] = $this->
buildStruct($this->depsConflictsStruct, $conflict);
675 $activate = $this->parser->getAttribute(
'activate_on_install');
676 switch (strtolower($activate)) {
720 $cat_raw_string =
"admin:plugins:category:$category";
721 if (
_elgg_services()->translator->languageKeyExists($cat_raw_string)) {
725 $category = str_replace([
'-',
'_'],
' ', $category);
726 return ucwords($category);
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.
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.
_elgg_services(\Elgg\Di\ServiceProvider $services=null)
Get the global service provider.
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
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.