aboutsummaryrefslogtreecommitdiff
path: root/engine/classes
diff options
context:
space:
mode:
Diffstat (limited to 'engine/classes')
-rw-r--r--engine/classes/ElggFile.php41
-rw-r--r--engine/classes/ElggPlugin.php22
-rw-r--r--engine/classes/ElggPluginManifest.php38
-rw-r--r--engine/classes/ElggPluginPackage.php2
4 files changed, 71 insertions, 32 deletions
diff --git a/engine/classes/ElggFile.php b/engine/classes/ElggFile.php
index fe25491a8..f21621ffd 100644
--- a/engine/classes/ElggFile.php
+++ b/engine/classes/ElggFile.php
@@ -121,6 +121,47 @@ class ElggFile extends ElggObject {
}
/**
+ * Detects mime types based on filename or actual file.
+ *
+ * @param mixed $file The full path of the file to check. For uploaded files, use tmp_name.
+ * @param mixed $default A default. Useful to pass what the browser thinks it is.
+ * @since 1.7.12
+ *
+ * @return mixed Detected type on success, false on failure.
+ */
+ static function detectMimeType($file = null, $default = null) {
+ if (!$file) {
+ if (isset($this) && $this->filename) {
+ $file = $this->filename;
+ } else {
+ return false;
+ }
+ }
+
+ $mime = false;
+
+ // for PHP5 folks.
+ if (function_exists('finfo_file') && defined('FILEINFO_MIME_TYPE')) {
+ $resource = finfo_open(FILEINFO_MIME_TYPE);
+ if ($resource) {
+ $mime = finfo_file($resource, $file);
+ }
+ }
+
+ // for everyone else.
+ if (!$mime && function_exists('mime_content_type')) {
+ $mime = mime_content_type($file);
+ }
+
+ // default
+ if (!$mime) {
+ return $default;
+ }
+
+ return $mime;
+ }
+
+ /**
* Set the optional file description.
*
* @param string $description The description.
diff --git a/engine/classes/ElggPlugin.php b/engine/classes/ElggPlugin.php
index d837431fc..4aee1e898 100644
--- a/engine/classes/ElggPlugin.php
+++ b/engine/classes/ElggPlugin.php
@@ -116,6 +116,21 @@ class ElggPlugin extends ElggObject {
}
/**
+ * Returns the manifest's name if available, otherwise the ID.
+ *
+ * @return string
+ * @since 1.8.1
+ */
+ public function getFriendlyName() {
+ $manifest = $this->getManifest();
+ if ($manifest) {
+ return $manifest->getName();
+ }
+
+ return $this->getID();
+ }
+
+ /**
* Returns the plugin's full path with trailing slash.
*
* @return string
@@ -597,7 +612,12 @@ class ElggPlugin extends ElggObject {
*/
public function canActivate($site_guid = null) {
if ($this->getPackage()) {
- return $this->getPackage()->isValid() && $this->getPackage()->checkDependencies();
+ $result = $this->getPackage()->isValid() && $this->getPackage()->checkDependencies();
+ if (!$result) {
+ $this->errorMsg = $this->getPackage()->getError();
+ }
+
+ return $result;
}
return false;
diff --git a/engine/classes/ElggPluginManifest.php b/engine/classes/ElggPluginManifest.php
index 0f3b1d7a8..0e47f388d 100644
--- a/engine/classes/ElggPluginManifest.php
+++ b/engine/classes/ElggPluginManifest.php
@@ -224,20 +224,15 @@ class ElggPluginManifest {
/**
* Returns the plugin name
*
- * @param bool $elgg_echo Run the name through elgg_echo.
* @return string
*/
- public function getName($elgg_echo = true) {
+ public function getName() {
$name = $this->parser->getAttribute('name');
if (!$name && $this->pluginID) {
$name = ucwords(str_replace('_', ' ', $this->pluginID));
}
- if ($elgg_echo) {
- $name = elgg_echo($name);
- }
-
return $name;
}
@@ -245,33 +240,21 @@ class ElggPluginManifest {
/**
* Return the description
*
- * @param bool $elgg_echo Run the description through elgg_echo.
* @return string
*/
- public function getDescription($elgg_echo = true) {
- $desc = $this->parser->getAttribute('description');
-
- if ($elgg_echo) {
- return elgg_echo($desc);
- } else {
- return $desc;
- }
+ public function getDescription() {
+ return $this->parser->getAttribute('description');
}
/**
* Return the short description
*
- * @param bool $elgg_echo Run the blurb through elgg_echo.
* @return string
*/
- public function getBlurb($elgg_echo = true) {
+ public function getBlurb() {
$blurb = $this->parser->getAttribute('blurb');
- if ($blurb) {
- if ($elgg_echo) {
- $blurb = elgg_echo($blurb);
- }
- } else {
+ if (!$blurb) {
$blurb = elgg_get_excerpt($this->getDescription());
}
@@ -348,10 +331,9 @@ class ElggPluginManifest {
/**
* Return the screenshots listed.
*
- * @param bool $elgg_echo Run the screenshot's description through elgg_echo.
* @return array
*/
- public function getScreenshots($elgg_echo = true) {
+ public function getScreenshots() {
$ss = $this->parser->getAttribute('screenshot');
if (!$ss) {
@@ -360,13 +342,7 @@ class ElggPluginManifest {
$normalized = array();
foreach ($ss as $s) {
- $normalized_s = $this->buildStruct($this->screenshotStruct, $s);
-
- if ($elgg_echo) {
- $normalized_s['description'] = elgg_echo($normalized_s['description']);
- }
-
- $normalized[] = $normalized_s;
+ $normalized[] = $this->buildStruct($this->screenshotStruct, $s);
}
return $normalized;
diff --git a/engine/classes/ElggPluginPackage.php b/engine/classes/ElggPluginPackage.php
index 02b985285..145f71fcd 100644
--- a/engine/classes/ElggPluginPackage.php
+++ b/engine/classes/ElggPluginPackage.php
@@ -347,6 +347,7 @@ class ElggPluginPackage {
$conflict['name'] = $plugin->getManifest()->getName();
if (!$full_report && !$result['status']) {
+ $this->errorMsg = "Conflicts with plugin \"{$plugin->getManifest()->getName()}\".";
return $result['status'];
} else {
$report[] = array(
@@ -399,6 +400,7 @@ class ElggPluginPackage {
// unless we're doing a full report, break as soon as we fail.
if (!$full_report && !$result['status']) {
+ $this->errorMsg = "Missing dependencies.";
return $result['status'];
} else {
// build report element and comment