From 6ce057f5162e18cd5190717145a13e7c29fe9da7 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sun, 21 Jun 2009 22:42:39 +0000 Subject: added in skeleton for image and album classes --- languages/en.php | 6 +++++- lib/album.php | 23 ++++++++++++++++++++++ lib/image.php | 23 ++++++++++++++++++++++ start.php | 7 ++++++- thumbnail.php | 2 +- upgrade.php | 38 +++++++++++++++++++++++++++++++++++++ views/default/tidypics/settings.php | 12 ++++++++++++ 7 files changed, 108 insertions(+), 3 deletions(-) create mode 100644 lib/album.php create mode 100644 lib/image.php create mode 100644 upgrade.php 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 @@ +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 @@ +attributes['subtype'] = "image"; + } + + public function __construct($guid = null) + { + parent::__construct($guid); + } + } + +?> \ No newline at end of file diff --git a/start.php b/start.php index 24423dafd..e2a87a8e8 100644 --- a/start.php +++ b/start.php @@ -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 @@ +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; ?>

+ +Upgrade
+ Run Server Analysis