37 private $depsStructPlugin = [
47 private $depsStructPriority = [
56 private $depsStructElgg = [
65 private $depsStructPhpVersion = [
74 private $depsStructPhpIni = [
84 private $depsStructPhpExtension = [
94 private $depsConflictsStruct = [
104 private $depsProvidesStruct = [
113 private $screenshotStruct = [
121 private $contributorStruct = [
159 $manifest_obj = $manifest;
162 if (substr(trim($manifest), 0, 1) ==
'<') {
164 $raw_xml = $manifest;
165 }
elseif (is_file($manifest)) {
167 $raw_xml = file_get_contents($manifest);
170 $manifest_obj = new \ElggXMLElement($raw_xml);
172 $manifest_obj = null;
176 if (!$manifest_obj) {
182 if (isset($manifest_obj->attributes[
'xmlns'])) {
183 $namespace = $manifest_obj->attributes[
'xmlns'];
184 $version = str_replace($this->namespace_root,
'', $namespace);
191 $parser_class_name =
'\ElggPluginManifestParser' . str_replace(
'.',
'', $this->apiVersion);
195 $class_exists = class_exists($parser_class_name);
197 $class_exists =
false;
201 $this->parser =
new $parser_class_name($manifest_obj, $this);
203 $msg =
elgg_echo(
'PluginException:NoAvailableParser', [$this->apiVersion, $this->
getPluginID()]);
207 if (!$this->parser->parse()) {
228 if ($this->pluginID) {
244 return $this->parser->getManifest();
257 $name = $this->parser->getAttribute(
'name');
259 if (!
$name && $this->pluginID) {
260 $name = ucwords(str_replace(
'_',
' ', $this->pluginID));
273 return trim((
string) $this->parser->getAttribute(
'id'));
283 return (
string) $this->parser->getAttribute(
'description');
292 $blurb = $this->parser->getAttribute(
'blurb');
308 $en_us = $this->parser->getAttribute(
'license');
310 return (
string) ($en_us ?: $this->parser->getAttribute(
'licence'));
319 return (
string) $this->parser->getAttribute(
'repository');
328 return (
string) $this->parser->getAttribute(
'bugtracker');
337 return (
string) $this->parser->getAttribute(
'donations');
346 return $this->parser->getAttribute(
'version');
355 return (
string) $this->parser->getAttribute(
'author');
364 return (
string) $this->parser->getAttribute(
'copyright');
373 return (
string) $this->parser->getAttribute(
'website');
396 'friends_collections',
410 'site_notifications',
414 'uservalidationbyemail',
418 $cats = $this->parser->getAttribute(
'category');
424 if (in_array(
'bundled', $cats) && !in_array($this->
getPluginID(), $bundled_plugins)) {
425 unset($cats[array_search(
'bundled', $cats)]);
437 $ss = $this->parser->getAttribute(
'screenshot');
444 foreach ($ss as $s) {
445 $normalized[] = $this->
buildStruct($this->screenshotStruct, $s);
457 $ss = $this->parser->getAttribute(
'contributor');
464 foreach ($ss as $s) {
465 $normalized[] = $this->
buildStruct($this->contributorStruct, $s);
481 $provides = $this->parser->getAttribute(
'provides');
489 if ($this->pluginID) {
498 foreach ($provides as $provide) {
499 $normalized[] = $this->
buildStruct($this->depsProvidesStruct, $provide);
511 $reqs = $this->parser->getAttribute(
'requires');
518 foreach ($reqs as $req) {
519 $normalized[] = $this->normalizeDep($req);
531 $suggests = $this->parser->getAttribute(
'suggests');
538 foreach ($suggests as $suggest) {
539 $normalized[] = $this->normalizeDep($suggest);
552 private function normalizeDep($dep) {
556 switch ($dep[
'type']) {
558 $struct = $this->depsStructElgg;
562 $struct = $this->depsStructPlugin;
566 $struct = $this->depsStructPriority;
570 $struct = $this->depsStructPhpVersion;
573 case 'php_extension':
574 $struct = $this->depsStructPhpExtension;
578 $struct = $this->depsStructPhpIni;
581 if (isset($dep[
'value'])) {
582 switch (strtolower($dep[
'value'])) {
605 $normalized_dep = $this->
buildStruct($struct, $dep);
608 if (isset($normalized_dep[
'comparison'])) {
609 switch ($normalized_dep[
'comparison']) {
611 $normalized_dep[
'comparison'] =
'lt';
615 $normalized_dep[
'comparison'] =
'le';
619 $normalized_dep[
'comparison'] =
'gt';
623 $normalized_dep[
'comparison'] =
'ge';
628 $normalized_dep[
'comparison'] =
'=';
633 $normalized_dep[
'comparison'] =
'!=';
638 return $normalized_dep;
651 $conflicts = $this->parser->getAttribute(
'conflicts');
660 foreach ($conflicts as $conflict) {
661 $normalized[] = $this->
buildStruct($this->depsConflictsStruct, $conflict);
673 $activate = $this->parser->getAttribute(
'activate_on_install');
674 if ($activate ===
false) {
679 switch (strtolower($activate)) {
718 $cat_raw_string =
"admin:plugins:category:$category";
719 if (
_elgg_services()->translator->languageKeyExists($cat_raw_string)) {
723 $category = str_replace([
'-',
'_'],
' ', $category);
724 return ucwords($category);
getCopyright()
Return the copyright.
if(!$user||!$user->canDelete()) $name
getLicense()
Returns the license.
getName()
Returns the plugin name.
getRepositoryURL()
Returns the repository url.
getApiVersion()
Returns the API version in use.
getScreenshots()
Return the screenshots listed.
elgg_echo($message_key, array $args=[], $language="")
Given a message key, returns an appropriately translated full-text string.
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.
static factory($reason, ElggPlugin $plugin=null, $message=null, Throwable $previous=null)
Create a new plugin exception.
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.
if($item instanceof\ElggEntity) elseif($item instanceof\ElggRiverItem) elseif(is_callable([$item, 'getType']))
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.
_elgg_services()
Get the global service provider.
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.