diff options
-rw-r--r-- | languages/en.php | 6 | ||||
-rw-r--r-- | lib/album.php | 23 | ||||
-rw-r--r-- | lib/image.php | 23 | ||||
-rw-r--r-- | start.php | 7 | ||||
-rw-r--r-- | thumbnail.php | 2 | ||||
-rw-r--r-- | upgrade.php | 38 | ||||
-rw-r--r-- | views/default/tidypics/settings.php | 12 |
7 files changed, 108 insertions, 3 deletions
diff --git a/languages/en.php b/languages/en.php index fb7fa7182..355f9660b 100644 --- a/languages/en.php +++ b/languages/en.php @@ -148,6 +148,8 @@ 'album:delete:confirm' => "Are you sure you want to delete this album?",
'album:created' => "Your new album has been created.",
'tidypics:settings:save:ok' => 'Successfully saved the Tidypics plugin settings',
+
+ 'tidypics:upgrade:success' => 'Upgrade of Tidypics a success',
//Error messages
@@ -169,7 +171,9 @@ 'album:none' => "No albums have been created yet.",
'album:uploadfailed' => "Sorry; we could not save your album.",
'album:deletefailed' => "Your album could not be deleted at this time.",
- 'album:blank' => "Please give this album a title and description."
+ 'album:blank' => "Please give this album a title and description.",
+
+ 'tidypics:upgrade:failed' => "The upgrade of Tidypics failed",
);
add_translation("en",$english);
diff --git a/lib/album.php b/lib/album.php new file mode 100644 index 000000000..7e03ed6eb --- /dev/null +++ b/lib/album.php @@ -0,0 +1,23 @@ +<?php + /** + * Tidypics Album class + * + */ + + + class TidypicsAlbum extends ElggObject + { + protected function initialise_attributes() + { + parent::initialise_attributes(); + + $this->attributes['subtype'] = "album"; + } + + public function __construct($guid = null) + { + parent::__construct($guid); + } + } + +?>
\ No newline at end of file diff --git a/lib/image.php b/lib/image.php new file mode 100644 index 000000000..3a23a1932 --- /dev/null +++ b/lib/image.php @@ -0,0 +1,23 @@ +<?php + /** + * Tidypics Image class + * + */ + + + class TidypicsImage extends ElggFile + { + protected function initialise_attributes() + { + parent::initialise_attributes(); + + $this->attributes['subtype'] = "image"; + } + + public function __construct($guid = null) + { + parent::__construct($guid); + } + } + +?>
\ No newline at end of file @@ -10,7 +10,8 @@ // include core libraries
include dirname(__FILE__) . "/lib/tidypics.php";
-
+ include dirname(__FILE__) . "/lib/image.php";
+ include dirname(__FILE__) . "/lib/album.php";
/**
* tidypics plugin initialisation functions.
@@ -44,6 +45,10 @@ register_entity_url_handler('tidypics_image_url', 'object', 'image');
register_entity_url_handler('tidypics_album_url', 'object', 'album');
+ // add the class files for image and album
+ add_subtype("object", "image", "TidypicsImage");
+ add_subtype("object", "album", "TidypicsAlbum");
+
// Register entity type
register_entity_type('object','image');
register_entity_type('object','album');
diff --git a/thumbnail.php b/thumbnail.php index 688d400af..eaca0849f 100644 --- a/thumbnail.php +++ b/thumbnail.php @@ -62,7 +62,7 @@ }
// Return the thumbnail and exit
- $mime = $file->mimetype;
+ $mime = $file->getMimeType();
header("Content-type: $mime");
echo $contents;
exit;
diff --git a/upgrade.php b/upgrade.php new file mode 100644 index 000000000..7fc3187d6 --- /dev/null +++ b/upgrade.php @@ -0,0 +1,38 @@ +<?php + +/******************************************** + * + * Upgrade from Tidypics 1.5 to 1.6 + * + *********************************************/ + + include_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + + $result = true; + + // add image class + $id = get_subtype_id("object", "image"); + if ($id != 0) { + $table = $CONFIG->dbprefix . 'entity_subtypes'; + $result = update_data("UPDATE {$table} set class='TidypicsImage' where id={$id}"); + if (!result) { + register_error(elgg_echo('tidypics:upgrade:failed')); + forward($_SERVER['HTTP_REFERER']); + } + } + + // add album class + $id = get_subtype_id("object", "album"); + if ($id != 0) { + $table = $CONFIG->dbprefix . 'entity_subtypes'; + $result = update_data("UPDATE {$table} set class='TidypicsAlbum' where id={$id}"); + if (!result) { + register_error(elgg_echo('tidypics:upgrade:failed')); + forward($_SERVER['HTTP_REFERER']); + } + } + + system_message(elgg_echo('tidypics:upgrade:success')); + + forward($_SERVER['HTTP_REFERER']); +?>
\ No newline at end of file diff --git a/views/default/tidypics/settings.php b/views/default/tidypics/settings.php index e69d6d306..c8d12d861 100644 --- a/views/default/tidypics/settings.php +++ b/views/default/tidypics/settings.php @@ -4,8 +4,20 @@ global $CONFIG;
$system_url = $CONFIG->wwwroot . 'mod/tidypics/system.php';
+ $upgrade_url = $CONFIG->wwwroot . 'mod/tidypics/upgrade.php';
+
+ $upgrade = false;
+ if (!get_subtype_class('object', 'image') || !get_subtype_class('object', 'album'))
+ $upgrade = true;
?>
<p>
+<?php
+ if ($upgrade) {
+?>
+<a href="<?php echo $upgrade_url; ?>">Upgrade</a><br />
+<?php
+ }
+?>
<a href="<?php echo $system_url; ?>">Run Server Analysis</a>
</p>
<?php
|