From 621177abc2bc60e9edb3ca723a4afaa9d9e713ef Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sat, 12 Dec 2009 19:51:49 +0000 Subject: convert line endings to Unix --- actions/addalbum.php | 146 ++-- actions/addtag.php | 208 ++--- actions/create_thumbnails.php | 122 +-- actions/delete.php | 240 +++--- actions/deletetag.php | 114 +-- actions/edit.php | 162 ++-- actions/edit_multi.php | 130 +-- actions/imtest.php | 38 +- actions/settings.php | 140 +-- actions/upload.php | 510 +++++------ languages/en.php | 440 +++++----- lib/resize.php | 1092 ++++++++++++------------ lib/tidypics.php | 596 ++++++------- pages/admin.php | 46 +- pages/download.php | 102 +-- pages/edit.php | 100 +-- pages/edit_multiple.php | 94 +- pages/friends.php | 74 +- pages/newalbum.php | 62 +- pages/ownedalbums.php | 100 +-- pages/tagged.php | 98 +-- pages/upload.php | 82 +- pages/viewalbum.php | 134 +-- pages/viewimage.php | 114 +-- pages/world.php | 60 +- start.php | 872 +++++++++---------- thumbnail.php | 156 ++-- views/default/annotation/annotate.php | 40 +- views/default/js/tagging.php | 604 ++++++------- views/default/river/object/album/create.php | 84 +- views/default/river/object/image/create.php | 56 +- views/default/river/object/image/tag.php | 44 +- views/default/tidypics/admin/help.php | 48 +- views/default/tidypics/admin/imagelib.php | 122 +-- views/default/tidypics/admin/settings.php | 48 +- views/default/tidypics/admin/stats.php | 68 +- views/default/tidypics/admin/thumbnails.php | 64 +- views/default/tidypics/albums.php | 100 +-- views/default/tidypics/breadcrumbs.php | 44 +- views/default/tidypics/exif.php | 26 +- views/default/tidypics/forms/edit.php | 234 ++--- views/default/tidypics/forms/edit_multi.php | 114 +-- views/default/tidypics/forms/settings.php | 288 +++---- views/default/tidypics/gallery.php | 126 +-- views/default/tidypics/groupprofile_albums.php | 28 +- views/default/tidypics/hover_menu.php | 22 +- views/default/tidypics/image_menu.php | 100 +-- views/default/tidypics/tagging.php | 172 ++-- views/default/widgets/album_view/edit.php | 46 +- views/default/widgets/latest_photos/edit.php | 28 +- views/rss/object/album.php | 88 +- views/rss/object/file.php | 46 +- views/rss/object/image.php | 36 +- views/rss/tidypics/gallery.php | 34 +- 54 files changed, 4371 insertions(+), 4371 deletions(-) diff --git a/actions/addalbum.php b/actions/addalbum.php index ffc7ec9c7..8df488a92 100644 --- a/actions/addalbum.php +++ b/actions/addalbum.php @@ -1,74 +1,74 @@ -getGUID()); - - // Cache to the session - $_SESSION['tidypicstitle'] = $title; - $_SESSION['tidypicsbody'] = $body; - $_SESSION['tidypicstags'] = $tags; - - // Convert string of tags into a preformatted array - $tagarray = string_to_tag_array($tags); - // Make sure the title isn't blank - if (empty($title)) { - register_error(elgg_echo("album:blank")); - forward($_SERVER['HTTP_REFERER']); //failed, so forward to previous page - // Otherwise, save the album - } else { - - // Initialise a new ElggObject - $album = new ElggObject(); - // Tell the system it's an album - $album->subtype = "album"; - - // Set its owner to the current user - $album->container_guid = $container_guid; - $album->owner_guid = $_SESSION['user']->getGUID(); - $album->access_id = $access; - // Set its title and description appropriately - $album->title = $title; - $album->description = $body; - - // we catch the adding images to new albums in the upload action and throw a river new album event - $album->new_album = TP_NEW_ALBUM; - - // Before we can set metadata, we need to save the album - if (!$album->save()) { - register_error(elgg_echo("album:error")); - forward(get_input('forward_url', $_SERVER['HTTP_REFERER'])); //failed, so forward to previous page - } - - // Now let's add tags - if (is_array($tagarray)) { - $album->tags = $tagarray; - } - - - - // Success message - system_message(elgg_echo("album:created")); - - // Remove the album post cache - unset($_SESSION['tidypicstitle']); - unset($_SESSION['tidypicsbody']); - unset($_SESSION['tidypicstags']); - - // plugins can register to be told when a new Tidypics album has been created - trigger_elgg_event('add', 'tp_album', $album); - - forward("pg/photos/upload/" . $album->guid); - } - +getGUID()); + + // Cache to the session + $_SESSION['tidypicstitle'] = $title; + $_SESSION['tidypicsbody'] = $body; + $_SESSION['tidypicstags'] = $tags; + + // Convert string of tags into a preformatted array + $tagarray = string_to_tag_array($tags); + // Make sure the title isn't blank + if (empty($title)) { + register_error(elgg_echo("album:blank")); + forward($_SERVER['HTTP_REFERER']); //failed, so forward to previous page + // Otherwise, save the album + } else { + + // Initialise a new ElggObject + $album = new ElggObject(); + // Tell the system it's an album + $album->subtype = "album"; + + // Set its owner to the current user + $album->container_guid = $container_guid; + $album->owner_guid = $_SESSION['user']->getGUID(); + $album->access_id = $access; + // Set its title and description appropriately + $album->title = $title; + $album->description = $body; + + // we catch the adding images to new albums in the upload action and throw a river new album event + $album->new_album = TP_NEW_ALBUM; + + // Before we can set metadata, we need to save the album + if (!$album->save()) { + register_error(elgg_echo("album:error")); + forward(get_input('forward_url', $_SERVER['HTTP_REFERER'])); //failed, so forward to previous page + } + + // Now let's add tags + if (is_array($tagarray)) { + $album->tags = $tagarray; + } + + + + // Success message + system_message(elgg_echo("album:created")); + + // Remove the album post cache + unset($_SESSION['tidypicstitle']); + unset($_SESSION['tidypicsbody']); + unset($_SESSION['tidypicstags']); + + // plugins can register to be told when a new Tidypics album has been created + trigger_elgg_event('add', 'tp_album', $album); + + forward("pg/photos/upload/" . $album->guid); + } + ?> \ No newline at end of file diff --git a/actions/addtag.php b/actions/addtag.php index 2c258db84..56268783e 100644 --- a/actions/addtag.php +++ b/actions/addtag.php @@ -1,104 +1,104 @@ -tags)) { - if ($image->tags != $word) { - $new_word_tag = true; - $tagarray = $image->tags . ',' . $word; - $tagarray = string_to_tag_array($tagarray); - } - } else { - if (!in_array($word, $image->tags)) { - $new_word_tag = true; - $tagarray = $image->tags; - $tagarray[] = $word; - } - } - } - - // add new tag now so it is available in search - if ($new_word_tag) { - $image->clearMetadata('tags'); - $image->tags = $tagarray; - } - - // create string for javascript tag object - $tag->coords = $coordinates_str; - $tag->type = $relationships_type; - $tag->value = $value; - - $access_id = $image->getAccessID(); - $owner_id = get_loggedin_userid(); - $tagger = get_loggedin_user(); - - //Save annotation - if ($image->annotate('phototag', serialize($tag), $access_id, $owner_id)) { - // if tag is a user id, add relationship for searching (find all images with user x) - if ($relationships_type === 'user') { - if (!check_entity_relationship($user_id, 'phototag', $image_guid)) { - add_entity_relationship($user_id, 'phototag', $image_guid); - - // also add this to the river - subject is image, object is the tagged user - if (function_exists('add_to_river')) - add_to_river('river/object/image/tag', 'tag', $image_guid, $user_id, $access_id); - - // notify user of tagging as long as not self - if ($owner_id != $user_id) - notify_user($user_id, $owner_id, elgg_echo('tidypics:tag:subject'), - sprintf( - elgg_echo('tidypics:tag:body'), - $image->title, - $tagger->name, - $image->getURL() - ) - ); - } - } - - system_message(elgg_echo("tidypics:phototagging:success")); - } - - - forward($_SERVER['HTTP_REFERER']); - -?> +tags)) { + if ($image->tags != $word) { + $new_word_tag = true; + $tagarray = $image->tags . ',' . $word; + $tagarray = string_to_tag_array($tagarray); + } + } else { + if (!in_array($word, $image->tags)) { + $new_word_tag = true; + $tagarray = $image->tags; + $tagarray[] = $word; + } + } + } + + // add new tag now so it is available in search + if ($new_word_tag) { + $image->clearMetadata('tags'); + $image->tags = $tagarray; + } + + // create string for javascript tag object + $tag->coords = $coordinates_str; + $tag->type = $relationships_type; + $tag->value = $value; + + $access_id = $image->getAccessID(); + $owner_id = get_loggedin_userid(); + $tagger = get_loggedin_user(); + + //Save annotation + if ($image->annotate('phototag', serialize($tag), $access_id, $owner_id)) { + // if tag is a user id, add relationship for searching (find all images with user x) + if ($relationships_type === 'user') { + if (!check_entity_relationship($user_id, 'phototag', $image_guid)) { + add_entity_relationship($user_id, 'phototag', $image_guid); + + // also add this to the river - subject is image, object is the tagged user + if (function_exists('add_to_river')) + add_to_river('river/object/image/tag', 'tag', $image_guid, $user_id, $access_id); + + // notify user of tagging as long as not self + if ($owner_id != $user_id) + notify_user($user_id, $owner_id, elgg_echo('tidypics:tag:subject'), + sprintf( + elgg_echo('tidypics:tag:body'), + $image->title, + $tagger->name, + $image->getURL() + ) + ); + } + } + + system_message(elgg_echo("tidypics:phototagging:success")); + } + + + forward($_SERVER['HTTP_REFERER']); + +?> diff --git a/actions/create_thumbnails.php b/actions/create_thumbnails.php index 3869e2dcf..09743eef6 100644 --- a/actions/create_thumbnails.php +++ b/actions/create_thumbnails.php @@ -1,61 +1,61 @@ -getFilename(); - $container_guid = $image->container_guid; - if (!$filename || !$container_guid) { - echo "Error retrieving information about the image"; - return; - } - - $title = $image->title; - $prefix = "image/" . $container_guid . "/"; - $filestorename = substr($filename, strlen($prefix)); - - $image_lib = get_plugin_setting('image_lib', 'tidypics'); - if (!$image_lib) - $image_lib = "GD"; - - if ($image_lib == 'ImageMagick') { // ImageMagick command line - - if (tp_create_im_cmdline_thumbnails($image, $prefix, $filestorename) != true) { - trigger_error('Tidypics warning: failed to create thumbnails - ImageMagick command line', E_USER_WARNING); - echo "Failed to create thumbnails"; - } - - } else if ($image_lib == 'ImageMagickPHP') { // imagick PHP extension - - if (tp_create_imagick_thumbnails($image, $prefix, $filestorename) != true) { - trigger_error('Tidypics warning: failed to create thumbnails - ImageMagick PHP', E_USER_WARNING); - echo "Failed to create thumbnails"; - } - - } else { - - if (tp_create_gd_thumbnails($image, $prefix, $filestorename) != true) { - trigger_error('Tidypics warning: failed to create thumbnails - GD', E_USER_WARNING); - echo "Failed to create thumbnails"; - } - - } // end of image library selector - - echo "wwwroot}mod/tidypics/thumbnail.php?file_guid={$guid}&size=large\" alt=\"{$title}\" />"; - -?> +getFilename(); + $container_guid = $image->container_guid; + if (!$filename || !$container_guid) { + echo "Error retrieving information about the image"; + return; + } + + $title = $image->title; + $prefix = "image/" . $container_guid . "/"; + $filestorename = substr($filename, strlen($prefix)); + + $image_lib = get_plugin_setting('image_lib', 'tidypics'); + if (!$image_lib) + $image_lib = "GD"; + + if ($image_lib == 'ImageMagick') { // ImageMagick command line + + if (tp_create_im_cmdline_thumbnails($image, $prefix, $filestorename) != true) { + trigger_error('Tidypics warning: failed to create thumbnails - ImageMagick command line', E_USER_WARNING); + echo "Failed to create thumbnails"; + } + + } else if ($image_lib == 'ImageMagickPHP') { // imagick PHP extension + + if (tp_create_imagick_thumbnails($image, $prefix, $filestorename) != true) { + trigger_error('Tidypics warning: failed to create thumbnails - ImageMagick PHP', E_USER_WARNING); + echo "Failed to create thumbnails"; + } + + } else { + + if (tp_create_gd_thumbnails($image, $prefix, $filestorename) != true) { + trigger_error('Tidypics warning: failed to create thumbnails - GD', E_USER_WARNING); + echo "Failed to create thumbnails"; + } + + } // end of image library selector + + echo "wwwroot}mod/tidypics/thumbnail.php?file_guid={$guid}&size=large\" alt=\"{$title}\" />"; + +?> diff --git a/actions/delete.php b/actions/delete.php index 1a518af9e..5506c2303 100644 --- a/actions/delete.php +++ b/actions/delete.php @@ -1,121 +1,121 @@ -canEdit()) { // user doesn't have permissions - register_error(elgg_echo("file:deletefailed")); - forward($forward_url); - } - - $subtype = $entity->getSubtype(); - $container = get_entity($entity->container_guid); - - if ($subtype != 'image' && $subtype != 'album') { // how did we even get here? - register_error(elgg_echo("file:deletefailed")); - forward($forward_url); - } - - $owner_guid = 0; // group or user - if ($subtype == 'image') { //deleting an image - $album = get_entity($entity->container_guid); - $owner_guid = $album->container_guid; - $forward_url = $container->getURL(); //forward back to album after deleting pictures - $images = array($entity); - // plugins can register to be told when a Tidypics image has been deleted - trigger_elgg_event('delete', 'tp_image', $entity); - } else { //deleting an album - $owner_guid = $entity->container_guid; - $forward_url = 'pg/photos/owned/' . $container->username; - //get all the images from this album as long as less than 999 images - $images = get_entities("object", "image", $guid, '', 999); - // plugins can register to be told when a Tidypics album has been deleted - trigger_elgg_event('delete', 'tp_album', $entity); - } - - // make sure we decrease the repo size for the size quota - $image_repo_size_md = get_metadata_byname($owner_guid, "image_repo_size"); - $image_repo_size = (int)$image_repo_size_md->value; - - //loop through all images and delete them - foreach($images as $im) { - $thumbnail = $im->thumbnail; - $smallthumb = $im->smallthumb; - $largethumb = $im->largethumb; - - if ($thumbnail) { //delete standard thumbnail image - $delfile = new ElggFile(); - $delfile->owner_guid = $im->getOwner(); - $delfile->setFilename($thumbnail); - $delfile->delete(); - } - if ($smallthumb) { //delete small thumbnail image - $delfile = new ElggFile(); - $delfile->owner_guid = $im->getOwner(); - $delfile->setFilename($smallthumb); - $delfile->delete(); - } - if ($largethumb) { //delete large thumbnail image - $delfile = new ElggFile(); - $delfile->owner_guid = $im->getOwner(); - $delfile->setFilename($largethumb); - $delfile->delete(); - } - if ($im) { //delete actual image file - $delfile = new ElggFile($im->getGUID()); - $delfile->owner_guid = $im->getOwner(); - //$delfile->setFilename($im->originalfilename); - $image_repo_size -= $delfile->size(); - - if (!$delfile->delete()) { - if ($subtype=='image') register_error(elgg_echo("file:deletefailed")); //unable to delete object - } else { - if ($subtype=='image') system_message(elgg_echo("file:deleted")); //successfully deleted object - } - } //end delete actual image file - } //end looping through each image to delete it - - //now that all images have been deleted, delete the album - if ($subtype == 'album') { - //delete the album's directory manually; first create a temp file to get the directory path - $tmpfile = new ElggFile(); - $tmpfile->setFilename('image/' . $guid . '/._tmp_del_tidypics_album_'); - $tmpfile->subtype = 'image'; - $tmpfile->container_guid = $guid; - $tmpfile->open("write"); - $tmpfile->write(''); - $tmpfile->close(); - $tmpfile->save(); - $albumdir = eregi_replace('/._tmp_del_tidypics_album_', '', $tmpfile->getFilenameOnFilestore()); - $tmpfile->delete(); - if (is_dir($albumdir)) - rmdir($albumdir); - - //delete object from database - if (!$entity->delete()) { - register_error(elgg_echo("file:deletefailed")); //unable to delete object - } else { - system_message(elgg_echo("file:deleted")); //successfully deleted object - } - } //end of delete album - - create_metadata($owner_guid, "image_repo_size", $image_repo_size, 'integer', $owner_guid); - - forward($forward_url); - +canEdit()) { // user doesn't have permissions + register_error(elgg_echo("file:deletefailed")); + forward($forward_url); + } + + $subtype = $entity->getSubtype(); + $container = get_entity($entity->container_guid); + + if ($subtype != 'image' && $subtype != 'album') { // how did we even get here? + register_error(elgg_echo("file:deletefailed")); + forward($forward_url); + } + + $owner_guid = 0; // group or user + if ($subtype == 'image') { //deleting an image + $album = get_entity($entity->container_guid); + $owner_guid = $album->container_guid; + $forward_url = $container->getURL(); //forward back to album after deleting pictures + $images = array($entity); + // plugins can register to be told when a Tidypics image has been deleted + trigger_elgg_event('delete', 'tp_image', $entity); + } else { //deleting an album + $owner_guid = $entity->container_guid; + $forward_url = 'pg/photos/owned/' . $container->username; + //get all the images from this album as long as less than 999 images + $images = get_entities("object", "image", $guid, '', 999); + // plugins can register to be told when a Tidypics album has been deleted + trigger_elgg_event('delete', 'tp_album', $entity); + } + + // make sure we decrease the repo size for the size quota + $image_repo_size_md = get_metadata_byname($owner_guid, "image_repo_size"); + $image_repo_size = (int)$image_repo_size_md->value; + + //loop through all images and delete them + foreach($images as $im) { + $thumbnail = $im->thumbnail; + $smallthumb = $im->smallthumb; + $largethumb = $im->largethumb; + + if ($thumbnail) { //delete standard thumbnail image + $delfile = new ElggFile(); + $delfile->owner_guid = $im->getOwner(); + $delfile->setFilename($thumbnail); + $delfile->delete(); + } + if ($smallthumb) { //delete small thumbnail image + $delfile = new ElggFile(); + $delfile->owner_guid = $im->getOwner(); + $delfile->setFilename($smallthumb); + $delfile->delete(); + } + if ($largethumb) { //delete large thumbnail image + $delfile = new ElggFile(); + $delfile->owner_guid = $im->getOwner(); + $delfile->setFilename($largethumb); + $delfile->delete(); + } + if ($im) { //delete actual image file + $delfile = new ElggFile($im->getGUID()); + $delfile->owner_guid = $im->getOwner(); + //$delfile->setFilename($im->originalfilename); + $image_repo_size -= $delfile->size(); + + if (!$delfile->delete()) { + if ($subtype=='image') register_error(elgg_echo("file:deletefailed")); //unable to delete object + } else { + if ($subtype=='image') system_message(elgg_echo("file:deleted")); //successfully deleted object + } + } //end delete actual image file + } //end looping through each image to delete it + + //now that all images have been deleted, delete the album + if ($subtype == 'album') { + //delete the album's directory manually; first create a temp file to get the directory path + $tmpfile = new ElggFile(); + $tmpfile->setFilename('image/' . $guid . '/._tmp_del_tidypics_album_'); + $tmpfile->subtype = 'image'; + $tmpfile->container_guid = $guid; + $tmpfile->open("write"); + $tmpfile->write(''); + $tmpfile->close(); + $tmpfile->save(); + $albumdir = eregi_replace('/._tmp_del_tidypics_album_', '', $tmpfile->getFilenameOnFilestore()); + $tmpfile->delete(); + if (is_dir($albumdir)) + rmdir($albumdir); + + //delete object from database + if (!$entity->delete()) { + register_error(elgg_echo("file:deletefailed")); //unable to delete object + } else { + system_message(elgg_echo("file:deleted")); //successfully deleted object + } + } //end of delete album + + create_metadata($owner_guid, "image_repo_size", $image_repo_size, 'integer', $owner_guid); + + forward($forward_url); + ?> \ No newline at end of file diff --git a/actions/deletetag.php b/actions/deletetag.php index 3a76f6e99..becf1fedb 100644 --- a/actions/deletetag.php +++ b/actions/deletetag.php @@ -1,57 +1,57 @@ - $value) { - // delete normal tag if it exists - if (is_array($image->tags)) { - $index = array_search($value, $image->tags); - if ($index !== false) { - $tagarray = $image->tags; - unset($tagarray[$index]); - $image->clearMetadata('tags'); - $image->tags = $tagarray; - } - } else { - if ($value === $image->tags) { - $image->clearMetadata('tags'); - } - } - - // delete relationship if this tag is a user - $annotation = get_annotation($id); - $photo_tag = unserialize($annotation->value); - if ($photo_tag->type == 'user') { - remove_entity_relationship($photo_tag->value, 'phototag', $image_guid); - } - - // delete the photo tag annotation - delete_annotation($id); - } - - system_message(elgg_echo("tidypics:deletetag:success")); - - forward($_SERVER['HTTP_REFERER']); - -?> + $value) { + // delete normal tag if it exists + if (is_array($image->tags)) { + $index = array_search($value, $image->tags); + if ($index !== false) { + $tagarray = $image->tags; + unset($tagarray[$index]); + $image->clearMetadata('tags'); + $image->tags = $tagarray; + } + } else { + if ($value === $image->tags) { + $image->clearMetadata('tags'); + } + } + + // delete relationship if this tag is a user + $annotation = get_annotation($id); + $photo_tag = unserialize($annotation->value); + if ($photo_tag->type == 'user') { + remove_entity_relationship($photo_tag->value, 'phototag', $image_guid); + } + + // delete the photo tag annotation + delete_annotation($id); + } + + system_message(elgg_echo("tidypics:deletetag:success")); + + forward($_SERVER['HTTP_REFERER']); + +?> diff --git a/actions/edit.php b/actions/edit.php index 91c465828..cdf9420b2 100644 --- a/actions/edit.php +++ b/actions/edit.php @@ -1,81 +1,81 @@ -canEdit()) { - forward(); - } - - // Get owning user/group - $owner = get_entity($entity->getOwner()); - - // change access only if access is different from current - if ($subtype == 'album' && $entity->access_id != $access) { - $entity->access_id = $access; - - //get images from album and update access on image entities - $images = get_entities("object","image", $guid, '', 999, '', false); - foreach ($images as $im) { - $im->access_id = $access; - $im->save(); - } - } - - - // Set its title and description appropriately - $entity->title = $title; - $entity->description = $body; - - // Before we can set metadata, we need to save the entity - if (!$entity->save()) { - register_error(elgg_echo("album:error")); - $entity->delete(); - forward($_SERVER['HTTP_REFERER']); //failed, so forward to previous page - } - - // Now let's add tags - $tagarray = string_to_tag_array($tags); - $entity->clearMetadata('tags'); - if (is_array($tagarray)) { - $entity->tags = $tagarray; - } - - //if cover meta is sent from image save as metadata - if ($subtype == 'image' && $cover == elgg_echo('album:cover')) { - $album = get_entity($container_guid); - $album->cover = $entity->guid; - } - - // Success message - if ($subtype == 'album') { - system_message(elgg_echo("album:edited")); - // plugins can register to be told when a Tidypics album has been updated - trigger_elgg_event('update', 'tp_album', $entity); - } else { - system_message(elgg_echo('images:edited')); - // plugins can register to be told when a Tidypics image has been updated - trigger_elgg_event('update', 'tp_image', $entity); - } - - forward($entity->getURL()); -?> +canEdit()) { + forward(); + } + + // Get owning user/group + $owner = get_entity($entity->getOwner()); + + // change access only if access is different from current + if ($subtype == 'album' && $entity->access_id != $access) { + $entity->access_id = $access; + + //get images from album and update access on image entities + $images = get_entities("object","image", $guid, '', 999, '', false); + foreach ($images as $im) { + $im->access_id = $access; + $im->save(); + } + } + + + // Set its title and description appropriately + $entity->title = $title; + $entity->description = $body; + + // Before we can set metadata, we need to save the entity + if (!$entity->save()) { + register_error(elgg_echo("album:error")); + $entity->delete(); + forward($_SERVER['HTTP_REFERER']); //failed, so forward to previous page + } + + // Now let's add tags + $tagarray = string_to_tag_array($tags); + $entity->clearMetadata('tags'); + if (is_array($tagarray)) { + $entity->tags = $tagarray; + } + + //if cover meta is sent from image save as metadata + if ($subtype == 'image' && $cover == elgg_echo('album:cover')) { + $album = get_entity($container_guid); + $album->cover = $entity->guid; + } + + // Success message + if ($subtype == 'album') { + system_message(elgg_echo("album:edited")); + // plugins can register to be told when a Tidypics album has been updated + trigger_elgg_event('update', 'tp_album', $entity); + } else { + system_message(elgg_echo('images:edited')); + // plugins can register to be told when a Tidypics image has been updated + trigger_elgg_event('update', 'tp_image', $entity); + } + + forward($entity->getURL()); +?> diff --git a/actions/edit_multi.php b/actions/edit_multi.php index 92252b6dd..c7099e6db 100644 --- a/actions/edit_multi.php +++ b/actions/edit_multi.php @@ -1,66 +1,66 @@ - $im) { - $image = get_entity($im); - - if ($image->canEdit()) { - - // Convert string of tags into a preformatted array - $tagarray = string_to_tag_array($tags_array[$key]); - - //set title appropriately - if ($title_array[$key]) - $image->title = $title_array[$key]; - else - $image->title = substr($image->originalfilename, 0, strrpos($image->originalfilename, '.')); - - //set description appropriately - $image->description = $caption_array[$key]; - - // Before we can set metadata, we need to save the image - if (!$image->save()) { - array_push($not_updated, $image->guid); - } - - // Now let's add tags. We can pass an array directly to the object property! Easy. - $image->clearMetadata('tags'); - if (is_array($tagarray)) { - $image->tags = $tagarray; - } - - //if cover meta is sent from image save as metadata - if ($cover == $im) { - $album_entity->cover = $im; - } - } - } - - // Success message - if (count($not_updated) > 0) { - register_error(elgg_echo("images:notedited")); - } else { - system_message(elgg_echo("images:edited")); - } - - // Forward to the main album page - forward($album_entity->getURL()); - + $im) { + $image = get_entity($im); + + if ($image->canEdit()) { + + // Convert string of tags into a preformatted array + $tagarray = string_to_tag_array($tags_array[$key]); + + //set title appropriately + if ($title_array[$key]) + $image->title = $title_array[$key]; + else + $image->title = substr($image->originalfilename, 0, strrpos($image->originalfilename, '.')); + + //set description appropriately + $image->description = $caption_array[$key]; + + // Before we can set metadata, we need to save the image + if (!$image->save()) { + array_push($not_updated, $image->guid); + } + + // Now let's add tags. We can pass an array directly to the object property! Easy. + $image->clearMetadata('tags'); + if (is_array($tagarray)) { + $image->tags = $tagarray; + } + + //if cover meta is sent from image save as metadata + if ($cover == $im) { + $album_entity->cover = $im; + } + } + } + + // Success message + if (count($not_updated) > 0) { + register_error(elgg_echo("images:notedited")); + } else { + system_message(elgg_echo("images:edited")); + } + + // Forward to the main album page + forward($album_entity->getURL()); + ?> \ No newline at end of file diff --git a/actions/imtest.php b/actions/imtest.php index 8d5171785..cbe15a1c1 100644 --- a/actions/imtest.php +++ b/actions/imtest.php @@ -1,19 +1,19 @@ - + diff --git a/actions/settings.php b/actions/settings.php index 6b115b049..e16e7960e 100644 --- a/actions/settings.php +++ b/actions/settings.php @@ -1,70 +1,70 @@ - $v) { - if (!set_plugin_setting($k, $v, 'tidypics')) { - register_error(sprintf(elgg_echo('plugins:settings:save:fail'), 'tidypics')); - forward($_SERVER['HTTP_REFERER']); - } - } - - // check boxes - if (is_array(get_input('download_link'))) // this can be done due to way Elgg uses checkboxes - set_plugin_setting('download_link', 'enabled', 'tidypics'); - else - set_plugin_setting('download_link', 'disabled', 'tidypics'); - - if (is_array(get_input('tagging'))) - set_plugin_setting('tagging', 'enabled', 'tidypics'); - else - set_plugin_setting('tagging', 'disabled', 'tidypics'); - - if (is_array(get_input('photo_ratings'))) - set_plugin_setting('photo_ratings', 'enabled', 'tidypics'); - else - set_plugin_setting('photo_ratings', 'disabled', 'tidypics'); - - if (is_array(get_input('exif'))) - set_plugin_setting('exif', 'enabled', 'tidypics'); - else - set_plugin_setting('exif', 'disabled', 'tidypics'); - - if (is_array(get_input('view_count'))) - set_plugin_setting('view_count', 'enabled', 'tidypics'); - else - set_plugin_setting('view_count', 'disabled', 'tidypics'); - - if (is_array(get_input('grp_perm_override'))) - set_plugin_setting('grp_perm_override', 'enabled', 'tidypics'); - else - set_plugin_setting('grp_perm_override', 'disabled', 'tidypics'); - - - // image sizes - $image_sizes = array(); - $image_sizes['large_image_width'] = get_input('large_thumb_width'); - $image_sizes['large_image_height'] = get_input('large_thumb_height'); - $image_sizes['small_image_width'] = get_input('small_thumb_width'); - $image_sizes['small_image_height'] = get_input('small_thumb_height'); - $image_sizes['thumb_image_width'] = get_input('thumb_width'); - $image_sizes['thumb_image_height'] = get_input('thumb_height'); - set_plugin_setting('image_sizes', serialize($image_sizes), 'tidypics'); - - - - system_message(elgg_echo('tidypics:settings:save:ok')); - - forward($_SERVER['HTTP_REFERER']); -?> + $v) { + if (!set_plugin_setting($k, $v, 'tidypics')) { + register_error(sprintf(elgg_echo('plugins:settings:save:fail'), 'tidypics')); + forward($_SERVER['HTTP_REFERER']); + } + } + + // check boxes + if (is_array(get_input('download_link'))) // this can be done due to way Elgg uses checkboxes + set_plugin_setting('download_link', 'enabled', 'tidypics'); + else + set_plugin_setting('download_link', 'disabled', 'tidypics'); + + if (is_array(get_input('tagging'))) + set_plugin_setting('tagging', 'enabled', 'tidypics'); + else + set_plugin_setting('tagging', 'disabled', 'tidypics'); + + if (is_array(get_input('photo_ratings'))) + set_plugin_setting('photo_ratings', 'enabled', 'tidypics'); + else + set_plugin_setting('photo_ratings', 'disabled', 'tidypics'); + + if (is_array(get_input('exif'))) + set_plugin_setting('exif', 'enabled', 'tidypics'); + else + set_plugin_setting('exif', 'disabled', 'tidypics'); + + if (is_array(get_input('view_count'))) + set_plugin_setting('view_count', 'enabled', 'tidypics'); + else + set_plugin_setting('view_count', 'disabled', 'tidypics'); + + if (is_array(get_input('grp_perm_override'))) + set_plugin_setting('grp_perm_override', 'enabled', 'tidypics'); + else + set_plugin_setting('grp_perm_override', 'disabled', 'tidypics'); + + + // image sizes + $image_sizes = array(); + $image_sizes['large_image_width'] = get_input('large_thumb_width'); + $image_sizes['large_image_height'] = get_input('large_thumb_height'); + $image_sizes['small_image_width'] = get_input('small_thumb_width'); + $image_sizes['small_image_height'] = get_input('small_thumb_height'); + $image_sizes['thumb_image_width'] = get_input('thumb_width'); + $image_sizes['thumb_image_height'] = get_input('thumb_height'); + set_plugin_setting('image_sizes', serialize($image_sizes), 'tidypics'); + + + + system_message(elgg_echo('tidypics:settings:save:ok')); + + forward($_SERVER['HTTP_REFERER']); +?> diff --git a/actions/upload.php b/actions/upload.php index 3aa739414..0913ed937 100644 --- a/actions/upload.php +++ b/actions/upload.php @@ -1,255 +1,255 @@ -getGUID(); - - $album = get_entity($container_guid); - - $maxfilesize = (float) get_plugin_setting('maxfilesize','tidypics'); - if (!$maxfilesize) - $maxfilesize = 5; // default to 5 MB if not set - $maxfilesize = 1024 * 1024 * $maxfilesize; // convert to bytes from MBs - - $quota = get_plugin_setting('quota','tidypics'); - $quota = 1024 * 1024 * $quota; - $image_repo_size_md = get_metadata_byname($album->container_guid, "image_repo_size"); - $image_repo_size = (int)$image_repo_size_md->value; - - $image_lib = get_plugin_setting('image_lib', 'tidypics'); - if (!$image_lib) - $image_lib = "GD"; - - // post limit exceeded - if (count($_FILES) == 0) { - trigger_error('Tidypics warning: user exceeded post limit on image upload', E_USER_WARNING); - register_error(elgg_echo('tidypics:exceedpostlimit')); - forward(get_input('forward_url', $_SERVER['HTTP_REFERER'])); - } - - // test to make sure at least 1 image was selected by user - $num_images = 0; - foreach($_FILES as $key => $sent_file) { - if (!empty($sent_file['name'])) - $num_images++; - } - if ($num_images == 0) { - // have user try again - register_error(elgg_echo('tidypics:noimages')); - forward(get_input('forward_url', $_SERVER['HTTP_REFERER'])); - } - - $uploaded_images = array(); - $not_uploaded = array(); - $error_msgs = array(); - - $img_river_view = get_plugin_setting('img_river_view', 'tidypics'); - - $accepted_formats = array( - 'image/jpeg', - 'image/png', - 'image/gif', - 'image/pjpeg', - 'image/x-png', - ); - - - foreach($_FILES as $key => $sent_file) { - - // skip empty entries - if (empty($sent_file['name'])) - continue; - - $name = $sent_file['name']; - $mime = $sent_file['type']; - - if ($sent_file['error']) { - array_push($not_uploaded, $sent_file['name']); - if ($sent_file['error'] == 1) { - trigger_error('Tidypics warning: image exceed server php upload limit', E_USER_WARNING); - array_push($error_msgs, elgg_echo('tidypics:image_mem')); - } - else { - array_push($error_msgs, elgg_echo('tidypics:unk_error')); - } - continue; - } - - //make sure file is an image - if (!in_array($mime, $accepted_formats)) { - array_push($not_uploaded, $sent_file['name']); - array_push($error_msgs, elgg_echo('tidypics:not_image')); - continue; - } - - // check quota - if ($quota) { - if ($image_repo_size + $sent_file['size'] > $quota) { - array_push($not_uploaded, $sent_file['name']); - array_push($error_msgs, elgg_echo('tidypics:exceed_quota')); - continue; - } - } - - // make sure file does not exceed memory limit - if ($sent_file['size'] > $maxfilesize) { - array_push($not_uploaded, $sent_file['name']); - array_push($error_msgs, elgg_echo('tidypics:image_mem')); - continue; - } - - // make sure the in memory image size does not exceed memory available - GD only - $imginfo = getimagesize($sent_file['tmp_name']); - $mem_avail = ini_get('memory_limit'); - $mem_avail = rtrim($mem_avail, 'M'); - $mem_avail = $mem_avail * 1024 * 1024; - if ($image_lib == 'GD') { - $mem_required = ceil(5.35 * $imginfo[0] * $imginfo[1]); - - $mem_used = memory_get_usage(); - - $mem_avail = $mem_avail - $mem_used - 2097152; // 2 MB buffer - if ($mem_required > $mem_avail) { - array_push($not_uploaded, $sent_file['name']); - array_push($error_msgs, elgg_echo('tidypics:image_pixels')); - trigger_error('Tidypics warning: image memory size too large for resizing so rejecting', E_USER_WARNING); - continue; - } - } else if ($image_lib == 'ImageMagickPHP') { - // haven't been able to determine a limit like there is for GD - } - - //this will save to users folder in /image/ and organize by photo album - $prefix = "image/" . $container_guid . "/"; - $file = new ElggFile(); - $filestorename = strtolower(time().$name); - $file->setFilename($prefix.$filestorename); - $file->setMimeType($mime); - $file->originalfilename = $name; - $file->subtype="image"; - $file->simpletype="image"; - $file->access_id = $access_id; - if ($container_guid) { - $file->container_guid = $container_guid; - } - $file->open("write"); - $file->write(get_uploaded_file($key)); - $file->close(); - $result = $file->save(); - - if (!$result) { - array_push($not_uploaded, $sent_file['name']); - array_push($error_msgs, elgg_echo('tidypics:save_error')); - continue; - } - - //get and store the exif data - td_get_exif($file); - - - // resize photos to create thumbnails - if ($image_lib == 'ImageMagick') { // ImageMagick command line - - if (tp_create_im_cmdline_thumbnails($file, $prefix, $filestorename) != true) { - trigger_error('Tidypics warning: failed to create thumbnails - ImageMagick command line', E_USER_WARNING); - } - - } else if ($image_lib == 'ImageMagickPHP') { // imagick php extension - - if (tp_create_imagick_thumbnails($file, $prefix, $filestorename) != true) { - trigger_error('Tidypics warning: failed to create thumbnails - ImageMagick PHP', E_USER_WARNING); - } - - } else { - - if (tp_create_gd_thumbnails($file, $prefix, $filestorename) != true) { - trigger_error('Tidypics warning: failed to create thumbnails - GD', E_USER_WARNING); - } - - } // end of image library selector - - //keep one file handy so we can add a notice to the river if single image option selected - if(!$file_for_river) { - $file_for_river = $file; - } - - array_push($uploaded_images, $file->guid); - - // update user/group size for checking quota - $image_repo_size += $sent_file['size']; - - // plugins can register to be told when a new image has been uploaded - trigger_elgg_event('upload', 'tp_image', $file); - - // successful upload so check if this is a new album and throw river event/notification if so - if ($album->new_album == TP_NEW_ALBUM) { - $album->new_album = TP_OLD_ALBUM; - - // we throw the notification manually here so users are not told about the new album until there - // is at least a few photos in it - object_notifications('create', 'object', $album); - - if (function_exists('add_to_river')) - add_to_river('river/object/album/create', 'create', $album->owner_guid, $album->guid); - } - - if ($img_river_view == "all") { - add_to_river('river/object/image/create', 'create', $file->getObjectOwnerGUID(), $file->getGUID()); - } - unset($file); // may not be needed but there seems to be a memory leak - - } //end of for loop - - if (count($not_uploaded) > 0) { - if (count($uploaded_images) > 0) - $error = sprintf(elgg_echo("tidypics:partialuploadfailure"), count($not_uploaded), count($not_uploaded) + count($uploaded_images)) . '
'; - else - $error = elgg_echo("tidypics:completeuploadfailure") . '
'; - - $num_failures = count($not_uploaded); - for ($i = 0; $i < $num_failures; $i++) { - $error .= "{$not_uploaded[$i]}: {$error_msgs[$i]}
"; - } - register_error($error); - - if (count($uploaded_images) == 0) - forward(get_input('forward_url', $_SERVER['HTTP_REFERER'])); //upload failed, so forward to previous page - else { - // some images did upload so we fall through - } - } else { - system_message(elgg_echo('tidypics:upl_success')); - } - - - if (count($uploaded_images) && $img_river_view == "1") { - if (function_exists('add_to_river')) { - add_to_river('river/object/image/create', 'create', $file_for_river->getObjectOwnerGUID(), $file_for_river->getGUID()); - } - } - - // update image repo size - create_metadata($album->container_guid, "image_repo_size", $image_repo_size, 'integer', $album->container_guid); - - // plugins can register to be told when a Tidypics album has had images added - trigger_elgg_event('upload', 'tp_album', $album); - - - //forward to multi-image edit page - forward($CONFIG->wwwroot . 'mod/tidypics/pages/edit_multiple.php?files=' . implode('-', $uploaded_images)); - -?> +getGUID(); + + $album = get_entity($container_guid); + + $maxfilesize = (float) get_plugin_setting('maxfilesize','tidypics'); + if (!$maxfilesize) + $maxfilesize = 5; // default to 5 MB if not set + $maxfilesize = 1024 * 1024 * $maxfilesize; // convert to bytes from MBs + + $quota = get_plugin_setting('quota','tidypics'); + $quota = 1024 * 1024 * $quota; + $image_repo_size_md = get_metadata_byname($album->container_guid, "image_repo_size"); + $image_repo_size = (int)$image_repo_size_md->value; + + $image_lib = get_plugin_setting('image_lib', 'tidypics'); + if (!$image_lib) + $image_lib = "GD"; + + // post limit exceeded + if (count($_FILES) == 0) { + trigger_error('Tidypics warning: user exceeded post limit on image upload', E_USER_WARNING); + register_error(elgg_echo('tidypics:exceedpostlimit')); + forward(get_input('forward_url', $_SERVER['HTTP_REFERER'])); + } + + // test to make sure at least 1 image was selected by user + $num_images = 0; + foreach($_FILES as $key => $sent_file) { + if (!empty($sent_file['name'])) + $num_images++; + } + if ($num_images == 0) { + // have user try again + register_error(elgg_echo('tidypics:noimages')); + forward(get_input('forward_url', $_SERVER['HTTP_REFERER'])); + } + + $uploaded_images = array(); + $not_uploaded = array(); + $error_msgs = array(); + + $img_river_view = get_plugin_setting('img_river_view', 'tidypics'); + + $accepted_formats = array( + 'image/jpeg', + 'image/png', + 'image/gif', + 'image/pjpeg', + 'image/x-png', + ); + + + foreach($_FILES as $key => $sent_file) { + + // skip empty entries + if (empty($sent_file['name'])) + continue; + + $name = $sent_file['name']; + $mime = $sent_file['type']; + + if ($sent_file['error']) { + array_push($not_uploaded, $sent_file['name']); + if ($sent_file['error'] == 1) { + trigger_error('Tidypics warning: image exceed server php upload limit', E_USER_WARNING); + array_push($error_msgs, elgg_echo('tidypics:image_mem')); + } + else { + array_push($error_msgs, elgg_echo('tidypics:unk_error')); + } + continue; + } + + //make sure file is an image + if (!in_array($mime, $accepted_formats)) { + array_push($not_uploaded, $sent_file['name']); + array_push($error_msgs, elgg_echo('tidypics:not_image')); + continue; + } + + // check quota + if ($quota) { + if ($image_repo_size + $sent_file['size'] > $quota) { + array_push($not_uploaded, $sent_file['name']); + array_push($error_msgs, elgg_echo('tidypics:exceed_quota')); + continue; + } + } + + // make sure file does not exceed memory limit + if ($sent_file['size'] > $maxfilesize) { + array_push($not_uploaded, $sent_file['name']); + array_push($error_msgs, elgg_echo('tidypics:image_mem')); + continue; + } + + // make sure the in memory image size does not exceed memory available - GD only + $imginfo = getimagesize($sent_file['tmp_name']); + $mem_avail = ini_get('memory_limit'); + $mem_avail = rtrim($mem_avail, 'M'); + $mem_avail = $mem_avail * 1024 * 1024; + if ($image_lib == 'GD') { + $mem_required = ceil(5.35 * $imginfo[0] * $imginfo[1]); + + $mem_used = memory_get_usage(); + + $mem_avail = $mem_avail - $mem_used - 2097152; // 2 MB buffer + if ($mem_required > $mem_avail) { + array_push($not_uploaded, $sent_file['name']); + array_push($error_msgs, elgg_echo('tidypics:image_pixels')); + trigger_error('Tidypics warning: image memory size too large for resizing so rejecting', E_USER_WARNING); + continue; + } + } else if ($image_lib == 'ImageMagickPHP') { + // haven't been able to determine a limit like there is for GD + } + + //this will save to users folder in /image/ and organize by photo album + $prefix = "image/" . $container_guid . "/"; + $file = new ElggFile(); + $filestorename = strtolower(time().$name); + $file->setFilename($prefix.$filestorename); + $file->setMimeType($mime); + $file->originalfilename = $name; + $file->subtype="image"; + $file->simpletype="image"; + $file->access_id = $access_id; + if ($container_guid) { + $file->container_guid = $container_guid; + } + $file->open("write"); + $file->write(get_uploaded_file($key)); + $file->close(); + $result = $file->save(); + + if (!$result) { + array_push($not_uploaded, $sent_file['name']); + array_push($error_msgs, elgg_echo('tidypics:save_error')); + continue; + } + + //get and store the exif data + td_get_exif($file); + + + // resize photos to create thumbnails + if ($image_lib == 'ImageMagick') { // ImageMagick command line + + if (tp_create_im_cmdline_thumbnails($file, $prefix, $filestorename) != true) { + trigger_error('Tidypics warning: failed to create thumbnails - ImageMagick command line', E_USER_WARNING); + } + + } else if ($image_lib == 'ImageMagickPHP') { // imagick php extension + + if (tp_create_imagick_thumbnails($file, $prefix, $filestorename) != true) { + trigger_error('Tidypics warning: failed to create thumbnails - ImageMagick PHP', E_USER_WARNING); + } + + } else { + + if (tp_create_gd_thumbnails($file, $prefix, $filestorename) != true) { + trigger_error('Tidypics warning: failed to create thumbnails - GD', E_USER_WARNING); + } + + } // end of image library selector + + //keep one file handy so we can add a notice to the river if single image option selected + if(!$file_for_river) { + $file_for_river = $file; + } + + array_push($uploaded_images, $file->guid); + + // update user/group size for checking quota + $image_repo_size += $sent_file['size']; + + // plugins can register to be told when a new image has been uploaded + trigger_elgg_event('upload', 'tp_image', $file); + + // successful upload so check if this is a new album and throw river event/notification if so + if ($album->new_album == TP_NEW_ALBUM) { + $album->new_album = TP_OLD_ALBUM; + + // we throw the notification manually here so users are not told about the new album until there + // is at least a few photos in it + object_notifications('create', 'object', $album); + + if (function_exists('add_to_river')) + add_to_river('river/object/album/create', 'create', $album->owner_guid, $album->guid); + } + + if ($img_river_view == "all") { + add_to_river('river/object/image/create', 'create', $file->getObjectOwnerGUID(), $file->getGUID()); + } + unset($file); // may not be needed but there seems to be a memory leak + + } //end of for loop + + if (count($not_uploaded) > 0) { + if (count($uploaded_images) > 0) + $error = sprintf(elgg_echo("tidypics:partialuploadfailure"), count($not_uploaded), count($not_uploaded) + count($uploaded_images)) . '
'; + else + $error = elgg_echo("tidypics:completeuploadfailure") . '
'; + + $num_failures = count($not_uploaded); + for ($i = 0; $i < $num_failures; $i++) { + $error .= "{$not_uploaded[$i]}: {$error_msgs[$i]}
"; + } + register_error($error); + + if (count($uploaded_images) == 0) + forward(get_input('forward_url', $_SERVER['HTTP_REFERER'])); //upload failed, so forward to previous page + else { + // some images did upload so we fall through + } + } else { + system_message(elgg_echo('tidypics:upl_success')); + } + + + if (count($uploaded_images) && $img_river_view == "1") { + if (function_exists('add_to_river')) { + add_to_river('river/object/image/create', 'create', $file_for_river->getObjectOwnerGUID(), $file_for_river->getGUID()); + } + } + + // update image repo size + create_metadata($album->container_guid, "image_repo_size", $image_repo_size, 'integer', $album->container_guid); + + // plugins can register to be told when a Tidypics album has had images added + trigger_elgg_event('upload', 'tp_album', $album); + + + //forward to multi-image edit page + forward($CONFIG->wwwroot . 'mod/tidypics/pages/edit_multiple.php?files=' . implode('-', $uploaded_images)); + +?> diff --git a/languages/en.php b/languages/en.php index 87c431f75..7fa5f2e73 100644 --- a/languages/en.php +++ b/languages/en.php @@ -1,221 +1,221 @@ - "untitled", - - // Menu items and titles - - 'image' => "Image", - 'images' => "Images", - 'caption' => "Caption", - 'photos' => "Photos", - 'images:upload' => "Upload Images", - 'images:multiupload' => "Flash Multi Upload Tool", - 'images:multiupload:todo' => "Choose one or more files for upload.", - 'album' => "Photo Album", - 'albums' => "Photo Albums", - 'album:slideshow' => "View slideshow", - 'album:yours' => "Your photo albums", - 'album:yours:friends' => "Your friends' photo albums", - 'album:user' => "%s's photo albums", - 'album:friends' => "%s's friends' photo albums", - 'album:all' => "All site photo albums", - 'album:group' => "Group albums", - 'item:object:image' => "Photos", - 'item:object:album' => "Albums", - 'tidypics:uploading:images' => "Please wait. Uploading images.", - 'tidypics:enablephotos' => 'Enable group photo albums', - 'tidypics:editprops' => 'Edit Image Properties', - 'tidypics:mostcommented' => 'Most commented images', - 'tidypics:mostcommentedthismonth' => 'Most commented this month', - 'tidypics:mostcommentedtoday' => 'Most commented today', - 'tidypics:mostviewed' => 'Most viewed images', - 'tidypics:mostvieweddashboard' => 'Most viewed dashboard', - 'tidypics:mostviewedthisyear' => 'Most viewed this year', - 'tidypics:mostviewedthismonth' => 'Most viewed this month', - 'tidypics:mostviewedlastmonth' => 'Most viewed last month', - 'tidypics:mostviewedtoday' => 'Most viewed today', - 'tidypics:recentlyviewed' => 'Recently viewed images', - 'tidypics:recentlycommented' => 'Recently commented images', - 'tidypics:mostrecent' => 'Most recent images', - 'tidypics:yourmostviewed' => 'Your most viewed images', - 'tidypics:yourmostrecent' => 'Your most recent images', - 'tidypics:friendmostviewed' => "%s's most viewed images", - 'tidypics:friendmostrecent' => "%s's most recent images", - 'tidypics:highestrated' => "Highest rated images", - 'tidypics:views' => "Views: %s", - 'tidypics:viewsbyowner' => "by %s users (not including you)", - 'tidypics:viewsbyothers' => "(%s by you)", - 'tidypics:administration' => 'Tidypics Administration', - 'tidypics:stats' => 'Stats', - 'flickr:setup' => 'Flickr Setup', - 'flickr:usernamesetup' => 'Please enter your Flickr username here:', - 'flickr:selectalbum' => 'Select album to import photos into', - 'flickr:albumdesc' => 'Album to import photos to:', - 'flickr:importmanager' => 'Photoset Import Manager', - 'flickr:desc' => 'Click on the set you wish to import into this site.
Copies of the photos will be made and stored on this site where they can be viewed and commented on.', - 'flickr:intro' => 'Flickr Integration allows you to import photos from your flickr account into this Elgg site. By entering your username and choosing an album to import into, you can begin the process.
When you have saved your username and album selection, click on the ' . elgg_echo( 'flickr:menuimport' ) . ' link to the left to select which Flickr set you would like to import photos from.', - 'flickr:menusetup' => 'Flickr Setup', - 'flickr:menuimport' => 'Import Flickr Photos', - - //settings - 'tidypics:settings' => 'Settings', - 'tidypics:admin:instructions' => 'These are the core Tidypics settings. Change them for your setup and then click save.', - 'tidypics:settings:image_lib' => "Image Library", - 'tidypics:settings:thumbnail' => "Thumbnail Creation", - 'tidypics:settings:help' => "Help", - 'tidypics:settings:download_link' => "Show download link", - 'tidypics:settings:tagging' => "Enable photo tagging", - 'tidypics:settings:photo_ratings' => "Enable photo ratings (requires rate plugin of Miguel Montes or compatible)", - 'tidypics:settings:exif' => "Show EXIF data", - 'tidypics:settings:view_count' => "View counter", - 'tidypics:settings:grp_perm_override' => "Allow group members full access to group albums", - 'tidypics:settings:maxfilesize' => "Maximum image size in megabytes (MB):", - 'tidypics:settings:quota' => "User/Group Quota (MB) - 0 equals no quota", - 'tidypics:settings:watermark' => "Enter text to appear in the watermark - not for production sites yet", - 'tidypics:settings:im_path' => "Enter the path to your ImageMagick commands (with trailing slash)", - 'tidypics:settings:img_river_view' => "How many entries in river for each batch of uploaded images", - 'tidypics:settings:album_river_view' => "Show the album cover or a set of photos for new album", - 'tidypics:settings:largesize' => "Primary image size", - 'tidypics:settings:smallsize' => "Album view image size", - 'tidypics:settings:thumbsize' => "Thumbnail image size", - 'tidypics:settings:im_id' => "Image ID", - - //actions - - 'album:create' => "Create new album", - 'album:add' => "Add Photo Album", - 'album:addpix' => "Add photos to album", - 'album:edit' => "Edit album", - 'album:delete' => "Delete album", - - 'image:edit' => "Edit image", - 'image:delete' => "Delete image", - 'image:download' => "Download image", - - //forms - - 'album:title' => "Title", - 'album:desc' => "Description", - 'album:tags' => "Tags", - 'album:cover' => "Make image album cover?", - 'tidypics:quota' => "Quota usage:", - - //views - - 'image:total' => "Images in album:", - 'image:by' => "Image added by", - 'album:by' => "Album created by", - 'album:created:on' => "Created", - 'image:none' => "No images have been added yet.", - 'image:back' => "Previous", - 'image:next' => "Next", - - // tagging - 'tidypics:taginstruct' => 'Select area that you want to tag', - 'tidypics:deltag_title' => 'Select tags to delete', - 'tidypics:finish_tagging' => 'Stop tagging', - 'tidypics:tagthisphoto' => 'Tag this photo', - 'tidypics:deletetag' => 'Delete a photo tag', - 'tidypics:actiontag' => 'Tag', - 'tidypics:actiondelete' => 'Delete', - 'tidypics:actioncancel' => 'Cancel', - 'tidypics:inthisphoto' => 'In this photo', - 'tidypics:usertag' => "Photos tagged with user %s", - 'tidypics:phototagging:success' => 'Photo tag was successfully added', - 'tidypics:phototagging:error' => 'Unexpected error occurred during tagging', - 'tidypics:deletetag:success' => 'Selected tags were successfully deleted', - - 'tidypics:tag:subject' => "You have been tagged in a photo", - 'tidypics:tag:body' => "You have been tagged in the photo %s by %s. - -The photo can be viewed here: %s", - - - //rss - 'tidypics:posted' => 'posted a photo:', - - //widgets - - 'tidypics:widget:albums' => "Photo Albums", - 'tidypics:widget:album_descr' => "Showcase your photo albums", - 'tidypics:widget:num_albums' => "Number of albums to display", - 'tidypics:widget:latest' => "Latest Photos", - 'tidypics:widget:latest_descr' => "Display your latest photos", - 'tidypics:widget:num_latest' => "Number of images to display", - 'album:more' => "View all albums", - - // river - - //images - 'image:river:created' => "%s added the photo %s to album %s", - 'image:river:item' => "an photo", - 'image:river:annotate' => "a comment on the photo", - 'image:river:tagged' => "was tagged in the photo", - - //albums - 'album:river:created' => "%s created a new photo album", - 'album:river:group' => "in the group", - 'album:river:item' => "an album", - 'album:river:annotate' => "a comment on the photo album", - - // notifications - 'tidypics:newalbum' => 'New photo album', - - - // Status messages - - 'tidypics:upl_success' => "Your images uploaded successfully.", - 'image:saved' => "Your image was successfully saved.", - 'images:saved' => "All images were successfully saved.", - 'image:deleted' => "Your image was successfully deleted.", - 'image:delete:confirm' => "Are you sure you want to delete this image?", - - 'images:edited' => "Your images were successfully updated.", - 'album:edited' => "Your album was successfully updated.", - 'album:saved' => "Your album was successfully saved.", - 'album:deleted' => "Your album was successfully deleted.", - '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', - - 'flickr:enterusername' => 'You must enter a username', - 'flickr:savedusername' => 'Successfully saved username of %s', - 'flickr:saveduserid' => 'Successfully saved userid of %s', - 'flickr:savedalbum' => 'Album saved - %s', - - //Error messages - - 'tidypics:partialuploadfailure' => "There were errors uploading some of the images (%s of %s images).", - 'tidypics:completeuploadfailure' => "Upload of images failed.", - 'tidypics:exceedpostlimit' => "Too many large images - try to upload fewer or smaller images.", - 'tidypics:noimages' => "No images were selected.", - 'tidypics:image_mem' => "Image is too large - too many bytes", - 'tidypics:image_pixels' => "Image has too many pixels", - 'tidypics:unk_error' => "Unknown upload error", - 'tidypics:save_error' => "Unknown error saving the image on server", - 'tidypics:not_image' => "This is not a recognized image type", - 'image:deletefailed' => "Your image could not be deleted at this time.", - 'image:downloadfailed' => "Sorry; this image is not available at this time.", - 'tidypics:nosettings' => "Admin of this site has not set photo album settings.", - 'tidypics:exceed_quota' => "You have exceeded the quota set by the administrator", - 'images:notedited' => "Not all images were successfully updated", - - '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.", - - 'tidypics:upgrade:failed' => "The upgrade of Tidypics failed", - - 'flickr:errorusername' => 'Username %s not found on Flickr', - 'flickr:errorusername2' => 'You must enter a username', - 'flickr:errorimageimport' => 'This image has already been imported', - 'flickr:errornoalbum' => "No album selected. Please choose and save an album: %s" - ); - - add_translation("en",$english); + "untitled", + + // Menu items and titles + + 'image' => "Image", + 'images' => "Images", + 'caption' => "Caption", + 'photos' => "Photos", + 'images:upload' => "Upload Images", + 'images:multiupload' => "Flash Multi Upload Tool", + 'images:multiupload:todo' => "Choose one or more files for upload.", + 'album' => "Photo Album", + 'albums' => "Photo Albums", + 'album:slideshow' => "View slideshow", + 'album:yours' => "Your photo albums", + 'album:yours:friends' => "Your friends' photo albums", + 'album:user' => "%s's photo albums", + 'album:friends' => "%s's friends' photo albums", + 'album:all' => "All site photo albums", + 'album:group' => "Group albums", + 'item:object:image' => "Photos", + 'item:object:album' => "Albums", + 'tidypics:uploading:images' => "Please wait. Uploading images.", + 'tidypics:enablephotos' => 'Enable group photo albums', + 'tidypics:editprops' => 'Edit Image Properties', + 'tidypics:mostcommented' => 'Most commented images', + 'tidypics:mostcommentedthismonth' => 'Most commented this month', + 'tidypics:mostcommentedtoday' => 'Most commented today', + 'tidypics:mostviewed' => 'Most viewed images', + 'tidypics:mostvieweddashboard' => 'Most viewed dashboard', + 'tidypics:mostviewedthisyear' => 'Most viewed this year', + 'tidypics:mostviewedthismonth' => 'Most viewed this month', + 'tidypics:mostviewedlastmonth' => 'Most viewed last month', + 'tidypics:mostviewedtoday' => 'Most viewed today', + 'tidypics:recentlyviewed' => 'Recently viewed images', + 'tidypics:recentlycommented' => 'Recently commented images', + 'tidypics:mostrecent' => 'Most recent images', + 'tidypics:yourmostviewed' => 'Your most viewed images', + 'tidypics:yourmostrecent' => 'Your most recent images', + 'tidypics:friendmostviewed' => "%s's most viewed images", + 'tidypics:friendmostrecent' => "%s's most recent images", + 'tidypics:highestrated' => "Highest rated images", + 'tidypics:views' => "Views: %s", + 'tidypics:viewsbyowner' => "by %s users (not including you)", + 'tidypics:viewsbyothers' => "(%s by you)", + 'tidypics:administration' => 'Tidypics Administration', + 'tidypics:stats' => 'Stats', + 'flickr:setup' => 'Flickr Setup', + 'flickr:usernamesetup' => 'Please enter your Flickr username here:', + 'flickr:selectalbum' => 'Select album to import photos into', + 'flickr:albumdesc' => 'Album to import photos to:', + 'flickr:importmanager' => 'Photoset Import Manager', + 'flickr:desc' => 'Click on the set you wish to import into this site.
Copies of the photos will be made and stored on this site where they can be viewed and commented on.', + 'flickr:intro' => 'Flickr Integration allows you to import photos from your flickr account into this Elgg site. By entering your username and choosing an album to import into, you can begin the process.
When you have saved your username and album selection, click on the ' . elgg_echo( 'flickr:menuimport' ) . ' link to the left to select which Flickr set you would like to import photos from.', + 'flickr:menusetup' => 'Flickr Setup', + 'flickr:menuimport' => 'Import Flickr Photos', + + //settings + 'tidypics:settings' => 'Settings', + 'tidypics:admin:instructions' => 'These are the core Tidypics settings. Change them for your setup and then click save.', + 'tidypics:settings:image_lib' => "Image Library", + 'tidypics:settings:thumbnail' => "Thumbnail Creation", + 'tidypics:settings:help' => "Help", + 'tidypics:settings:download_link' => "Show download link", + 'tidypics:settings:tagging' => "Enable photo tagging", + 'tidypics:settings:photo_ratings' => "Enable photo ratings (requires rate plugin of Miguel Montes or compatible)", + 'tidypics:settings:exif' => "Show EXIF data", + 'tidypics:settings:view_count' => "View counter", + 'tidypics:settings:grp_perm_override' => "Allow group members full access to group albums", + 'tidypics:settings:maxfilesize' => "Maximum image size in megabytes (MB):", + 'tidypics:settings:quota' => "User/Group Quota (MB) - 0 equals no quota", + 'tidypics:settings:watermark' => "Enter text to appear in the watermark - not for production sites yet", + 'tidypics:settings:im_path' => "Enter the path to your ImageMagick commands (with trailing slash)", + 'tidypics:settings:img_river_view' => "How many entries in river for each batch of uploaded images", + 'tidypics:settings:album_river_view' => "Show the album cover or a set of photos for new album", + 'tidypics:settings:largesize' => "Primary image size", + 'tidypics:settings:smallsize' => "Album view image size", + 'tidypics:settings:thumbsize' => "Thumbnail image size", + 'tidypics:settings:im_id' => "Image ID", + + //actions + + 'album:create' => "Create new album", + 'album:add' => "Add Photo Album", + 'album:addpix' => "Add photos to album", + 'album:edit' => "Edit album", + 'album:delete' => "Delete album", + + 'image:edit' => "Edit image", + 'image:delete' => "Delete image", + 'image:download' => "Download image", + + //forms + + 'album:title' => "Title", + 'album:desc' => "Description", + 'album:tags' => "Tags", + 'album:cover' => "Make image album cover?", + 'tidypics:quota' => "Quota usage:", + + //views + + 'image:total' => "Images in album:", + 'image:by' => "Image added by", + 'album:by' => "Album created by", + 'album:created:on' => "Created", + 'image:none' => "No images have been added yet.", + 'image:back' => "Previous", + 'image:next' => "Next", + + // tagging + 'tidypics:taginstruct' => 'Select area that you want to tag', + 'tidypics:deltag_title' => 'Select tags to delete', + 'tidypics:finish_tagging' => 'Stop tagging', + 'tidypics:tagthisphoto' => 'Tag this photo', + 'tidypics:deletetag' => 'Delete a photo tag', + 'tidypics:actiontag' => 'Tag', + 'tidypics:actiondelete' => 'Delete', + 'tidypics:actioncancel' => 'Cancel', + 'tidypics:inthisphoto' => 'In this photo', + 'tidypics:usertag' => "Photos tagged with user %s", + 'tidypics:phototagging:success' => 'Photo tag was successfully added', + 'tidypics:phototagging:error' => 'Unexpected error occurred during tagging', + 'tidypics:deletetag:success' => 'Selected tags were successfully deleted', + + 'tidypics:tag:subject' => "You have been tagged in a photo", + 'tidypics:tag:body' => "You have been tagged in the photo %s by %s. + +The photo can be viewed here: %s", + + + //rss + 'tidypics:posted' => 'posted a photo:', + + //widgets + + 'tidypics:widget:albums' => "Photo Albums", + 'tidypics:widget:album_descr' => "Showcase your photo albums", + 'tidypics:widget:num_albums' => "Number of albums to display", + 'tidypics:widget:latest' => "Latest Photos", + 'tidypics:widget:latest_descr' => "Display your latest photos", + 'tidypics:widget:num_latest' => "Number of images to display", + 'album:more' => "View all albums", + + // river + + //images + 'image:river:created' => "%s added the photo %s to album %s", + 'image:river:item' => "an photo", + 'image:river:annotate' => "a comment on the photo", + 'image:river:tagged' => "was tagged in the photo", + + //albums + 'album:river:created' => "%s created a new photo album", + 'album:river:group' => "in the group", + 'album:river:item' => "an album", + 'album:river:annotate' => "a comment on the photo album", + + // notifications + 'tidypics:newalbum' => 'New photo album', + + + // Status messages + + 'tidypics:upl_success' => "Your images uploaded successfully.", + 'image:saved' => "Your image was successfully saved.", + 'images:saved' => "All images were successfully saved.", + 'image:deleted' => "Your image was successfully deleted.", + 'image:delete:confirm' => "Are you sure you want to delete this image?", + + 'images:edited' => "Your images were successfully updated.", + 'album:edited' => "Your album was successfully updated.", + 'album:saved' => "Your album was successfully saved.", + 'album:deleted' => "Your album was successfully deleted.", + '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', + + 'flickr:enterusername' => 'You must enter a username', + 'flickr:savedusername' => 'Successfully saved username of %s', + 'flickr:saveduserid' => 'Successfully saved userid of %s', + 'flickr:savedalbum' => 'Album saved - %s', + + //Error messages + + 'tidypics:partialuploadfailure' => "There were errors uploading some of the images (%s of %s images).", + 'tidypics:completeuploadfailure' => "Upload of images failed.", + 'tidypics:exceedpostlimit' => "Too many large images - try to upload fewer or smaller images.", + 'tidypics:noimages' => "No images were selected.", + 'tidypics:image_mem' => "Image is too large - too many bytes", + 'tidypics:image_pixels' => "Image has too many pixels", + 'tidypics:unk_error' => "Unknown upload error", + 'tidypics:save_error' => "Unknown error saving the image on server", + 'tidypics:not_image' => "This is not a recognized image type", + 'image:deletefailed' => "Your image could not be deleted at this time.", + 'image:downloadfailed' => "Sorry; this image is not available at this time.", + 'tidypics:nosettings' => "Admin of this site has not set photo album settings.", + 'tidypics:exceed_quota' => "You have exceeded the quota set by the administrator", + 'images:notedited' => "Not all images were successfully updated", + + '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.", + + 'tidypics:upgrade:failed' => "The upgrade of Tidypics failed", + + 'flickr:errorusername' => 'Username %s not found on Flickr', + 'flickr:errorusername2' => 'You must enter a username', + 'flickr:errorimageimport' => 'This image has already been imported', + 'flickr:errornoalbum' => "No album selected. Please choose and save an album: %s" + ); + + add_translation("en",$english); ?> \ No newline at end of file diff --git a/lib/resize.php b/lib/resize.php index 7885a52df..c35eb09ea 100644 --- a/lib/resize.php +++ b/lib/resize.php @@ -1,547 +1,547 @@ -owner_guid = $file->owner_guid; - $thumb->container_guid = $file->container_guid; - - // tiny thumbail - $thumb->setFilename($prefix."thumb".$filestorename); - $thumbname = $thumb->getFilenameOnFilestore(); - $rtn_code = tp_gd_resize( $file->getFilenameOnFilestore(), - $thumbname, - false, - $image_sizes['thumb_image_width'], - $image_sizes['thumb_image_height'], - true); - if (!$rtn_code) - return false; - $file->thumbnail = $prefix."thumb".$filestorename; - - - // album thumbnail - $thumb->setFilename($prefix."smallthumb".$filestorename); - $thumbname = $thumb->getFilenameOnFilestore(); - $rtn_code = tp_gd_resize( $file->getFilenameOnFilestore(), - $thumbname, - false, - $image_sizes['small_image_width'], - $image_sizes['small_image_height'], - true); - if (!$rtn_code) - return false; - $file->smallthumb = $prefix."smallthumb".$filestorename; - - - // main image - $thumb->setFilename($prefix."largethumb".$filestorename); - $thumbname = $thumb->getFilenameOnFilestore(); - $rtn_code = tp_gd_resize( $file->getFilenameOnFilestore(), - $thumbname, - true, - $image_sizes['large_image_width'], - $image_sizes['large_image_height'], - false); - if (!$rtn_code) - return false; - $file->largethumb = $prefix."largethumb".$filestorename; - - - unset($thumb); - - return true; - } - - /** - * Writes resized version of an already uploaded image - original from Elgg filestore.php - * Saves it in the same format as uploaded - * - * @param string $input_name The name of the file on the disk - * @param string $output_name The name of the file to be written - * @param bool - watermark this image? - * @param int $maxwidth The maximum width of the resized image - * @param int $maxheight The maximum height of the resized image - * @param true|false $square If set to true, will take the smallest of maxwidth and maxheight and use it to set the dimensions on all size; the image will be cropped. - * @return bool true on success or false on failure - */ - function tp_gd_resize($input_name, $output_name, $watermark, $maxwidth, $maxheight, $square = false, $x1 = 0, $y1 = 0, $x2 = 0, $y2 = 0) { - - // Get the size information from the image - $imgsizearray = getimagesize($input_name); - if (!imgsizearray) - return false; - - // Get width and height - $width = $imgsizearray[0]; - $height = $imgsizearray[1]; - $newwidth = $width; - $newheight = $height; - - // Square the image dimensions if we're wanting a square image - if ($square) { - if ($width < $height) { - $height = $width; - } else { - $width = $height; - } - - $newwidth = $width; - $newheight = $height; - - } - - if ($width > $maxwidth) { - $newheight = floor($height * ($maxwidth / $width)); - $newwidth = $maxwidth; - } - if ($newheight > $maxheight) { - $newwidth = floor($newwidth * ($maxheight / $newheight)); - $newheight = $maxheight; - } - - $accepted_formats = array( - 'image/jpeg' => 'jpeg', - 'image/pjpeg' => 'jpeg', - 'image/png' => 'png', - 'image/x-png' => 'png', - 'image/gif' => 'gif' - ); - - // make sure the function is available - $function = "imagecreatefrom" . $accepted_formats[$imgsizearray['mime']]; - if (!is_callable($function)) - return false; - - - // load old image - $oldimage = $function($input_name); - if (!$oldimage) - return false; - - // allocate the new image - $newimage = imagecreatetruecolor($newwidth, $newheight); - if (!$newimage) - return false; - - // Crop the image if we need a square - if ($square) { - if ($x1 == 0 && $y1 == 0 && $x2 == 0 && $y2 ==0) { - $widthoffset = floor(($imgsizearray[0] - $width) / 2); - $heightoffset = floor(($imgsizearray[1] - $height) / 2); - } else { - $widthoffset = $x1; - $heightoffset = $y1; - $width = ($x2 - $x1); - $height = $width; - } - } else { - if ($x1 == 0 && $y1 == 0 && $x2 == 0 && $y2 ==0) { - $widthoffset = 0; - $heightoffset = 0; - } else { - $widthoffset = $x1; - $heightoffset = $y1; - $width = ($x2 - $x1); - $height = ($y2 - $y1); - } - } - - if ($square) { - $newheight = $maxheight; - $newwidth = $maxwidth; - } - - $rtn_code = imagecopyresampled($newimage, $oldimage, 0,0,$widthoffset,$heightoffset,$newwidth,$newheight,$width,$height); - if (!rtn_code) - return $rtn_code; - - if ($watermark) - tp_gd_watermark($newimage); - - switch ($imgsizearray['mime']) { - case 'image/jpeg': - case 'image/pjpeg': - $rtn_code = imagejpeg($newimage, $output_name, 85); - break; - case 'image/png': - case 'image/x-png': - $rtn_code = imagepng($newimage, $output_name); - break; - case 'image/gif': - $rtn_code = imagegif($newimage, $output_name); - break; - } - - imagedestroy($newimage); - imagedestroy($oldimage); - - return $rtn_code; - } - - - /** - * Create thumbnails using PHP imagick extension - * - * @param ElggFile holds the image that was uploaded - * @param string folder to store thumbnail in - * @param string name of the thumbnail - * @return bool true on success - */ - function tp_create_imagick_thumbnails($file, $prefix, $filestorename) - { - $image_sizes = get_plugin_setting('image_sizes', 'tidypics'); - if (!$image_sizes) { - register_error(elgg_echo('tidypics:nosettings')); - return false; - } - $image_sizes = unserialize($image_sizes); - - $thumb = new ElggFile(); - $thumb->owner_guid = $file->owner_guid; - $thumb->container_guid = $file->container_guid; - - // tiny thumbnail - $thumb->setFilename($prefix."thumb".$filestorename); - $thumbname = $thumb->getFilenameOnFilestore(); - $rtn_code = tp_imagick_resize( $file->getFilenameOnFilestore(), - $thumbname, - $image_sizes['thumb_image_width'], - $image_sizes['thumb_image_height'], - true); - if (!$rtn_code) - return false; - $file->thumbnail = $prefix."thumb".$filestorename; - - - // album thumbnail - $thumb->setFilename($prefix."smallthumb".$filestorename); - $thumbname = $thumb->getFilenameOnFilestore(); - $rtn_code = tp_imagick_resize( $file->getFilenameOnFilestore(), - $thumbname, - $image_sizes['small_image_width'], - $image_sizes['small_image_height'], - true); - if (!$rtn_code) - return false; - $file->smallthumb = $prefix."smallthumb".$filestorename; - - - // main image - $thumb->setFilename($prefix."largethumb".$filestorename); - $thumbname = $thumb->getFilenameOnFilestore(); - $rtn_code = tp_imagick_resize( $file->getFilenameOnFilestore(), - $thumbname, - $image_sizes['large_image_width'], - $image_sizes['large_image_height'], - false); - if (!$rtn_code) - return false; - $file->largethumb = $prefix."largethumb".$filestorename; - - tp_imagick_watermark($thumbname); - - unset($thumb); - - return true; - } - - - /** - * Resize using PHP imagick extension - * - * Writes resized version of an already uploaded image - * - * - * @param string $input_name The name of the file input field on the submission form - * @param string $output_name The name of the file to be written - * @param int $maxwidth The maximum width of the resized image - * @param int $maxheight The maximum height of the resized image - * @param true|false $square If set to true, will take the smallest of maxwidth and maxheight and use it to set the dimensions on all size; the image will be cropped. - * @return bool true on success - */ - function tp_imagick_resize($input_name, $output_name, $maxwidth, $maxheight, $square = false, $x1 = 0, $y1 = 0, $x2 = 0, $y2 = 0) { - - // Get the size information from the image - $imgsizearray = getimagesize($input_name); - if (!$imgsizearray) - return false; - - - // Get width and height - $width = $imgsizearray[0]; - $height = $imgsizearray[1]; - $newwidth = $width; - $newheight = $height; - - // initial guess at final dimensions for new image (doesn't check for squareness yet - if ($newwidth > $maxwidth) { - $newheight = floor($newheight * ($maxwidth / $newwidth)); - $newwidth = $maxwidth; - } - if ($newheight > $maxheight) { - $newwidth = floor($newwidth * ($maxheight / $newheight)); - $newheight = $maxheight; - } - - // Handle squareness for both original and new image - if ($square) { - if ($width < $height) { - $height = $width; - } else { - $width = $height; - } - - if ($maxheight == $maxwidth) { - // if input arguments = square, no need to use above calculations (which can have round-off errors) - $newwidth = $maxwidth; - $newheight = $maxheight; - } else { - if ($newwidth < $newheight) { - $newheight = $newwidth; - } else { - $newwidth = $newheight; - } - } - } - - - // Crop the original image - this needs to be checked over - if ($square) { - if ($x1 == 0 && $y1 == 0 && $x2 == 0 && $y2 ==0) { - $xoffset = floor(($imgsizearray[0] - $width) / 2); - $yoffset = floor(($imgsizearray[1] - $height) / 2); - } else { // assume we're being passed good croping coordinates - $xoffset = $x1; - $yoffset = $y1; - $width = ($x2 - $x1); - $height = $width; - } - } else { - if ($x1 == 0 && $y1 == 0 && $x2 == 0 && $y2 ==0) { - $xoffset = 0; - $yoffset = 0; - } else { - $xoffset = $x1; - $yoffset = $y1; - $width = ($x2 - $x1); - $height = ($y2 - $y1); - } - } - - - try { - $img = new Imagick($input_name); - } catch (ImagickException $e) { - return false; - } - - $img->cropImage($width, $height, $xoffset, $yoffset); - - // use the default IM filter (windowing filter), I think 1 means default blurring or number of lobes - $img->resizeImage($newwidth, $newheight, imagick::FILTER_LANCZOS, 1); - $img->setImagePage($newwidth, $newheight, 0, 0); - - if ($img->writeImage($output_name) != true) { - $img->destroy(); - return false; - } - - $img->destroy(); - - return true; - } - - /** - * Create thumbnails using ImageMagick executables - * - * @param ElggFile holds the image that was uploaded - * @param string folder to store thumbnail in - * @param string name of the thumbnail - * @return bool true on success - */ - function tp_create_im_cmdline_thumbnails($file, $prefix, $filestorename) - { - $image_sizes = get_plugin_setting('image_sizes', 'tidypics'); - if (!$image_sizes) { - register_error(elgg_echo('tidypics:nosettings')); - return false; - } - $image_sizes = unserialize($image_sizes); - - $thumb = new ElggFile(); - $thumb->owner_guid = $file->owner_guid; - $thumb->container_guid = $file->container_guid; - - // tiny thumbnail - $thumb->setFilename($prefix."thumb".$filestorename); - $thumbname = $thumb->getFilenameOnFilestore(); - $rtn_code = tp_im_cmdline_resize( $file->getFilenameOnFilestore(), - $thumbname, - $image_sizes['thumb_image_width'], - $image_sizes['thumb_image_height'], - true); - if (!$rtn_code) - return false; - $file->thumbnail = $prefix."thumb".$filestorename; - - - // album thumbnail - $thumb->setFilename($prefix."smallthumb".$filestorename); - $thumbname = $thumb->getFilenameOnFilestore(); - $rtn_code = tp_im_cmdline_resize( $file->getFilenameOnFilestore(), - $thumbname, - $image_sizes['small_image_width'], - $image_sizes['small_image_height'], - true); - if (!$rtn_code) - return false; - $file->smallthumb = $prefix."smallthumb".$filestorename; - - - // main image - $thumb->setFilename($prefix."largethumb".$filestorename); - $thumbname = $thumb->getFilenameOnFilestore(); - $rtn_code = tp_im_cmdline_resize( $file->getFilenameOnFilestore(), - $thumbname, - $image_sizes['large_image_width'], - $image_sizes['large_image_height'], - false); - if (!$rtn_code) - return false; - $file->largethumb = $prefix."largethumb".$filestorename; - - - tp_im_cmdline_watermark($thumbname); - - - - unset($thumb); - - return true; - } - - /* - * Gets the jpeg contents of the resized version of an already uploaded image - * (Returns false if the uploaded file was not an image) - * - * @param string $input_name The name of the file input field on the submission form - * @param string $output_name The name of the file to be written - * @param int $maxwidth The maximum width of the resized image - * @param int $maxheight The maximum height of the resized image - * @param true|false $square If set to true, will take the smallest of maxwidth and maxheight and use it to set the dimensions on all size; the image will be cropped. - * @return bool - */ - function tp_im_cmdline_resize($input_name, $output_name, $maxwidth, $maxheight, $square = false, $x1 = 0, $y1 = 0, $x2 = 0, $y2 = 0) { - - - // Get the size information from the image - if ($imgsizearray = getimagesize($input_name)) { - - // Get width and height - $width = $imgsizearray[0]; - $height = $imgsizearray[1]; - $newwidth = $width; - $newheight = $height; - - // Square the image dimensions if we're wanting a square image - if ($square) { - if ($width < $height) { - $height = $width; - } else { - $width = $height; - } - - $newwidth = $width; - $newheight = $height; - - } - - if ($width > $maxwidth) { - $newheight = floor($height * ($maxwidth / $width)); - $newwidth = $maxwidth; - } - if ($newheight > $maxheight) { - $newwidth = floor($newwidth * ($maxheight / $newheight)); - $newheight = $maxheight; - } - - $accepted_formats = array( - 'image/jpeg' => 'jpeg', - 'image/pjpeg' => 'jpeg', - 'image/png' => 'png', - 'image/x-png' => 'png', - 'image/gif' => 'gif' - ); - // If it's a file we can manipulate ... - if (array_key_exists($imgsizearray['mime'],$accepted_formats)) { - - // Crop the image if we need a square - if ($square) { - if ($x1 == 0 && $y1 == 0 && $x2 == 0 && $y2 ==0) { - $widthoffset = floor(($imgsizearray[0] - $width) / 2); - $heightoffset = floor(($imgsizearray[1] - $height) / 2); - } else { - $widthoffset = $x1; - $heightoffset = $y1; - $width = ($x2 - $x1); - $height = $width; - } - } else { - if ($x1 == 0 && $y1 == 0 && $x2 == 0 && $y2 ==0) { - $widthoffset = 0; - $heightoffset = 0; - } else { - $widthoffset = $x1; - $heightoffset = $y1; - $width = ($x2 - $x1); - $height = ($y2 - $y1); - } - } - - // Resize and return the image contents! - if ($square) { - $newheight = $maxheight; - $newwidth = $maxwidth; - } - $im_path = get_plugin_setting('im_path', 'tidypics'); - if(!$im_path) { - $im_path = "/usr/bin/"; - } - if(substr($im_path, strlen($im_path)-1, 1) != "/") $im_path .= "/"; - $command = $im_path . "convert \"$input_name\" -resize ".$newwidth."x".$newheight."^ -gravity center -extent ".$newwidth."x".$newheight." \"$output_name\""; - exec($command); - return true; - - } - } - - return false; - } - +owner_guid = $file->owner_guid; + $thumb->container_guid = $file->container_guid; + + // tiny thumbail + $thumb->setFilename($prefix."thumb".$filestorename); + $thumbname = $thumb->getFilenameOnFilestore(); + $rtn_code = tp_gd_resize( $file->getFilenameOnFilestore(), + $thumbname, + false, + $image_sizes['thumb_image_width'], + $image_sizes['thumb_image_height'], + true); + if (!$rtn_code) + return false; + $file->thumbnail = $prefix."thumb".$filestorename; + + + // album thumbnail + $thumb->setFilename($prefix."smallthumb".$filestorename); + $thumbname = $thumb->getFilenameOnFilestore(); + $rtn_code = tp_gd_resize( $file->getFilenameOnFilestore(), + $thumbname, + false, + $image_sizes['small_image_width'], + $image_sizes['small_image_height'], + true); + if (!$rtn_code) + return false; + $file->smallthumb = $prefix."smallthumb".$filestorename; + + + // main image + $thumb->setFilename($prefix."largethumb".$filestorename); + $thumbname = $thumb->getFilenameOnFilestore(); + $rtn_code = tp_gd_resize( $file->getFilenameOnFilestore(), + $thumbname, + true, + $image_sizes['large_image_width'], + $image_sizes['large_image_height'], + false); + if (!$rtn_code) + return false; + $file->largethumb = $prefix."largethumb".$filestorename; + + + unset($thumb); + + return true; + } + + /** + * Writes resized version of an already uploaded image - original from Elgg filestore.php + * Saves it in the same format as uploaded + * + * @param string $input_name The name of the file on the disk + * @param string $output_name The name of the file to be written + * @param bool - watermark this image? + * @param int $maxwidth The maximum width of the resized image + * @param int $maxheight The maximum height of the resized image + * @param true|false $square If set to true, will take the smallest of maxwidth and maxheight and use it to set the dimensions on all size; the image will be cropped. + * @return bool true on success or false on failure + */ + function tp_gd_resize($input_name, $output_name, $watermark, $maxwidth, $maxheight, $square = false, $x1 = 0, $y1 = 0, $x2 = 0, $y2 = 0) { + + // Get the size information from the image + $imgsizearray = getimagesize($input_name); + if (!imgsizearray) + return false; + + // Get width and height + $width = $imgsizearray[0]; + $height = $imgsizearray[1]; + $newwidth = $width; + $newheight = $height; + + // Square the image dimensions if we're wanting a square image + if ($square) { + if ($width < $height) { + $height = $width; + } else { + $width = $height; + } + + $newwidth = $width; + $newheight = $height; + + } + + if ($width > $maxwidth) { + $newheight = floor($height * ($maxwidth / $width)); + $newwidth = $maxwidth; + } + if ($newheight > $maxheight) { + $newwidth = floor($newwidth * ($maxheight / $newheight)); + $newheight = $maxheight; + } + + $accepted_formats = array( + 'image/jpeg' => 'jpeg', + 'image/pjpeg' => 'jpeg', + 'image/png' => 'png', + 'image/x-png' => 'png', + 'image/gif' => 'gif' + ); + + // make sure the function is available + $function = "imagecreatefrom" . $accepted_formats[$imgsizearray['mime']]; + if (!is_callable($function)) + return false; + + + // load old image + $oldimage = $function($input_name); + if (!$oldimage) + return false; + + // allocate the new image + $newimage = imagecreatetruecolor($newwidth, $newheight); + if (!$newimage) + return false; + + // Crop the image if we need a square + if ($square) { + if ($x1 == 0 && $y1 == 0 && $x2 == 0 && $y2 ==0) { + $widthoffset = floor(($imgsizearray[0] - $width) / 2); + $heightoffset = floor(($imgsizearray[1] - $height) / 2); + } else { + $widthoffset = $x1; + $heightoffset = $y1; + $width = ($x2 - $x1); + $height = $width; + } + } else { + if ($x1 == 0 && $y1 == 0 && $x2 == 0 && $y2 ==0) { + $widthoffset = 0; + $heightoffset = 0; + } else { + $widthoffset = $x1; + $heightoffset = $y1; + $width = ($x2 - $x1); + $height = ($y2 - $y1); + } + } + + if ($square) { + $newheight = $maxheight; + $newwidth = $maxwidth; + } + + $rtn_code = imagecopyresampled($newimage, $oldimage, 0,0,$widthoffset,$heightoffset,$newwidth,$newheight,$width,$height); + if (!rtn_code) + return $rtn_code; + + if ($watermark) + tp_gd_watermark($newimage); + + switch ($imgsizearray['mime']) { + case 'image/jpeg': + case 'image/pjpeg': + $rtn_code = imagejpeg($newimage, $output_name, 85); + break; + case 'image/png': + case 'image/x-png': + $rtn_code = imagepng($newimage, $output_name); + break; + case 'image/gif': + $rtn_code = imagegif($newimage, $output_name); + break; + } + + imagedestroy($newimage); + imagedestroy($oldimage); + + return $rtn_code; + } + + + /** + * Create thumbnails using PHP imagick extension + * + * @param ElggFile holds the image that was uploaded + * @param string folder to store thumbnail in + * @param string name of the thumbnail + * @return bool true on success + */ + function tp_create_imagick_thumbnails($file, $prefix, $filestorename) + { + $image_sizes = get_plugin_setting('image_sizes', 'tidypics'); + if (!$image_sizes) { + register_error(elgg_echo('tidypics:nosettings')); + return false; + } + $image_sizes = unserialize($image_sizes); + + $thumb = new ElggFile(); + $thumb->owner_guid = $file->owner_guid; + $thumb->container_guid = $file->container_guid; + + // tiny thumbnail + $thumb->setFilename($prefix."thumb".$filestorename); + $thumbname = $thumb->getFilenameOnFilestore(); + $rtn_code = tp_imagick_resize( $file->getFilenameOnFilestore(), + $thumbname, + $image_sizes['thumb_image_width'], + $image_sizes['thumb_image_height'], + true); + if (!$rtn_code) + return false; + $file->thumbnail = $prefix."thumb".$filestorename; + + + // album thumbnail + $thumb->setFilename($prefix."smallthumb".$filestorename); + $thumbname = $thumb->getFilenameOnFilestore(); + $rtn_code = tp_imagick_resize( $file->getFilenameOnFilestore(), + $thumbname, + $image_sizes['small_image_width'], + $image_sizes['small_image_height'], + true); + if (!$rtn_code) + return false; + $file->smallthumb = $prefix."smallthumb".$filestorename; + + + // main image + $thumb->setFilename($prefix."largethumb".$filestorename); + $thumbname = $thumb->getFilenameOnFilestore(); + $rtn_code = tp_imagick_resize( $file->getFilenameOnFilestore(), + $thumbname, + $image_sizes['large_image_width'], + $image_sizes['large_image_height'], + false); + if (!$rtn_code) + return false; + $file->largethumb = $prefix."largethumb".$filestorename; + + tp_imagick_watermark($thumbname); + + unset($thumb); + + return true; + } + + + /** + * Resize using PHP imagick extension + * + * Writes resized version of an already uploaded image + * + * + * @param string $input_name The name of the file input field on the submission form + * @param string $output_name The name of the file to be written + * @param int $maxwidth The maximum width of the resized image + * @param int $maxheight The maximum height of the resized image + * @param true|false $square If set to true, will take the smallest of maxwidth and maxheight and use it to set the dimensions on all size; the image will be cropped. + * @return bool true on success + */ + function tp_imagick_resize($input_name, $output_name, $maxwidth, $maxheight, $square = false, $x1 = 0, $y1 = 0, $x2 = 0, $y2 = 0) { + + // Get the size information from the image + $imgsizearray = getimagesize($input_name); + if (!$imgsizearray) + return false; + + + // Get width and height + $width = $imgsizearray[0]; + $height = $imgsizearray[1]; + $newwidth = $width; + $newheight = $height; + + // initial guess at final dimensions for new image (doesn't check for squareness yet + if ($newwidth > $maxwidth) { + $newheight = floor($newheight * ($maxwidth / $newwidth)); + $newwidth = $maxwidth; + } + if ($newheight > $maxheight) { + $newwidth = floor($newwidth * ($maxheight / $newheight)); + $newheight = $maxheight; + } + + // Handle squareness for both original and new image + if ($square) { + if ($width < $height) { + $height = $width; + } else { + $width = $height; + } + + if ($maxheight == $maxwidth) { + // if input arguments = square, no need to use above calculations (which can have round-off errors) + $newwidth = $maxwidth; + $newheight = $maxheight; + } else { + if ($newwidth < $newheight) { + $newheight = $newwidth; + } else { + $newwidth = $newheight; + } + } + } + + + // Crop the original image - this needs to be checked over + if ($square) { + if ($x1 == 0 && $y1 == 0 && $x2 == 0 && $y2 ==0) { + $xoffset = floor(($imgsizearray[0] - $width) / 2); + $yoffset = floor(($imgsizearray[1] - $height) / 2); + } else { // assume we're being passed good croping coordinates + $xoffset = $x1; + $yoffset = $y1; + $width = ($x2 - $x1); + $height = $width; + } + } else { + if ($x1 == 0 && $y1 == 0 && $x2 == 0 && $y2 ==0) { + $xoffset = 0; + $yoffset = 0; + } else { + $xoffset = $x1; + $yoffset = $y1; + $width = ($x2 - $x1); + $height = ($y2 - $y1); + } + } + + + try { + $img = new Imagick($input_name); + } catch (ImagickException $e) { + return false; + } + + $img->cropImage($width, $height, $xoffset, $yoffset); + + // use the default IM filter (windowing filter), I think 1 means default blurring or number of lobes + $img->resizeImage($newwidth, $newheight, imagick::FILTER_LANCZOS, 1); + $img->setImagePage($newwidth, $newheight, 0, 0); + + if ($img->writeImage($output_name) != true) { + $img->destroy(); + return false; + } + + $img->destroy(); + + return true; + } + + /** + * Create thumbnails using ImageMagick executables + * + * @param ElggFile holds the image that was uploaded + * @param string folder to store thumbnail in + * @param string name of the thumbnail + * @return bool true on success + */ + function tp_create_im_cmdline_thumbnails($file, $prefix, $filestorename) + { + $image_sizes = get_plugin_setting('image_sizes', 'tidypics'); + if (!$image_sizes) { + register_error(elgg_echo('tidypics:nosettings')); + return false; + } + $image_sizes = unserialize($image_sizes); + + $thumb = new ElggFile(); + $thumb->owner_guid = $file->owner_guid; + $thumb->container_guid = $file->container_guid; + + // tiny thumbnail + $thumb->setFilename($prefix."thumb".$filestorename); + $thumbname = $thumb->getFilenameOnFilestore(); + $rtn_code = tp_im_cmdline_resize( $file->getFilenameOnFilestore(), + $thumbname, + $image_sizes['thumb_image_width'], + $image_sizes['thumb_image_height'], + true); + if (!$rtn_code) + return false; + $file->thumbnail = $prefix."thumb".$filestorename; + + + // album thumbnail + $thumb->setFilename($prefix."smallthumb".$filestorename); + $thumbname = $thumb->getFilenameOnFilestore(); + $rtn_code = tp_im_cmdline_resize( $file->getFilenameOnFilestore(), + $thumbname, + $image_sizes['small_image_width'], + $image_sizes['small_image_height'], + true); + if (!$rtn_code) + return false; + $file->smallthumb = $prefix."smallthumb".$filestorename; + + + // main image + $thumb->setFilename($prefix."largethumb".$filestorename); + $thumbname = $thumb->getFilenameOnFilestore(); + $rtn_code = tp_im_cmdline_resize( $file->getFilenameOnFilestore(), + $thumbname, + $image_sizes['large_image_width'], + $image_sizes['large_image_height'], + false); + if (!$rtn_code) + return false; + $file->largethumb = $prefix."largethumb".$filestorename; + + + tp_im_cmdline_watermark($thumbname); + + + + unset($thumb); + + return true; + } + + /* + * Gets the jpeg contents of the resized version of an already uploaded image + * (Returns false if the uploaded file was not an image) + * + * @param string $input_name The name of the file input field on the submission form + * @param string $output_name The name of the file to be written + * @param int $maxwidth The maximum width of the resized image + * @param int $maxheight The maximum height of the resized image + * @param true|false $square If set to true, will take the smallest of maxwidth and maxheight and use it to set the dimensions on all size; the image will be cropped. + * @return bool + */ + function tp_im_cmdline_resize($input_name, $output_name, $maxwidth, $maxheight, $square = false, $x1 = 0, $y1 = 0, $x2 = 0, $y2 = 0) { + + + // Get the size information from the image + if ($imgsizearray = getimagesize($input_name)) { + + // Get width and height + $width = $imgsizearray[0]; + $height = $imgsizearray[1]; + $newwidth = $width; + $newheight = $height; + + // Square the image dimensions if we're wanting a square image + if ($square) { + if ($width < $height) { + $height = $width; + } else { + $width = $height; + } + + $newwidth = $width; + $newheight = $height; + + } + + if ($width > $maxwidth) { + $newheight = floor($height * ($maxwidth / $width)); + $newwidth = $maxwidth; + } + if ($newheight > $maxheight) { + $newwidth = floor($newwidth * ($maxheight / $newheight)); + $newheight = $maxheight; + } + + $accepted_formats = array( + 'image/jpeg' => 'jpeg', + 'image/pjpeg' => 'jpeg', + 'image/png' => 'png', + 'image/x-png' => 'png', + 'image/gif' => 'gif' + ); + // If it's a file we can manipulate ... + if (array_key_exists($imgsizearray['mime'],$accepted_formats)) { + + // Crop the image if we need a square + if ($square) { + if ($x1 == 0 && $y1 == 0 && $x2 == 0 && $y2 ==0) { + $widthoffset = floor(($imgsizearray[0] - $width) / 2); + $heightoffset = floor(($imgsizearray[1] - $height) / 2); + } else { + $widthoffset = $x1; + $heightoffset = $y1; + $width = ($x2 - $x1); + $height = $width; + } + } else { + if ($x1 == 0 && $y1 == 0 && $x2 == 0 && $y2 ==0) { + $widthoffset = 0; + $heightoffset = 0; + } else { + $widthoffset = $x1; + $heightoffset = $y1; + $width = ($x2 - $x1); + $height = ($y2 - $y1); + } + } + + // Resize and return the image contents! + if ($square) { + $newheight = $maxheight; + $newwidth = $maxwidth; + } + $im_path = get_plugin_setting('im_path', 'tidypics'); + if(!$im_path) { + $im_path = "/usr/bin/"; + } + if(substr($im_path, strlen($im_path)-1, 1) != "/") $im_path .= "/"; + $command = $im_path . "convert \"$input_name\" -resize ".$newwidth."x".$newheight."^ -gravity center -extent ".$newwidth."x".$newheight." \"$output_name\""; + exec($command); + return true; + + } + } + + return false; + } + ?> \ No newline at end of file diff --git a/lib/tidypics.php b/lib/tidypics.php index e24e4d77e..b0a8a70d2 100644 --- a/lib/tidypics.php +++ b/lib/tidypics.php @@ -1,299 +1,299 @@ - - -
-

-
- -
-
- - - * Good luck - */ - function tp_get_latest_photos($num_images, $owner_guid = 0) - { - $prev_context = set_context('front'); - $image_html = tp_list_entities('object', 'image', $owner_guid, $num_images, false, false, false); - set_context($prev_context); - return $image_html; - } - - - /** - * Get image directory path - * - * Each album gets a subdirectory based on its container id - * - * @return string path to image directory - */ - function tp_get_img_dir() - { - $file = new ElggFile(); - return $file->getFilenameOnFilestore() . 'image/'; - } - - - - /********************************************************************* - * the functions below replace broken core functions or add functions - * that could/should exist in the core - */ - - /** - * - */ - function tp_get_entities($type = "", $subtype = "", $owner_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0, $container_guid = null, $timelower = 0, $timeupper = 0) - { - global $CONFIG; - - if ($subtype === false || $subtype === null || $subtype === 0) - return false; - - if ($order_by == "") $order_by = "time_created desc"; - $order_by = sanitise_string($order_by); - $limit = (int)$limit; - $offset = (int)$offset; - $site_guid = (int) $site_guid; - $timelower = (int) $timelower; - $timeupper = (int) $timeupper; - if ($site_guid == 0) - $site_guid = $CONFIG->site_guid; - - $where = array(); - - if (is_array($subtype)) { - $tempwhere = ""; - if (sizeof($subtype)) - foreach($subtype as $typekey => $subtypearray) { - foreach($subtypearray as $subtypeval) { - $typekey = sanitise_string($typekey); - if (!empty($subtypeval)) { - if (!$subtypeval = (int) get_subtype_id($typekey, $subtypeval)) - return false; - } else { - // @todo: Setting subtype to 0 when $subtype = '' returns entities with - // no subtype. This is different to the non-array behavior - // but may be required in some cases. - $subtypeval = 0; - } - if (!empty($tempwhere)) $tempwhere .= " or "; - $tempwhere .= "(type = '{$typekey}' and subtype = {$subtypeval})"; - } - } - if (!empty($tempwhere)) $where[] = "({$tempwhere})"; - - } else { - - $type = sanitise_string($type); - if ($subtype !== "" AND !$subtype = get_subtype_id($type, $subtype)) - return false; - - if ($type != "") - $where[] = "type='$type'"; - if ($subtype!=="") - $where[] = "subtype=$subtype"; - } - - if ($owner_guid != "") { - if (!is_array($owner_guid)) { - $owner_array = array($owner_guid); - $owner_guid = (int) $owner_guid; - $where[] = "owner_guid = '$owner_guid'"; - } else if (sizeof($owner_guid) > 0) { - $owner_array = array_map('sanitise_int', $owner_guid); - // Cast every element to the owner_guid array to int - $owner_guid = array_map("sanitise_int", $owner_guid); - $owner_guid = implode(",",$owner_guid); - $where[] = "owner_guid in ({$owner_guid})"; - } - } - if ($site_guid > 0) - $where[] = "site_guid = {$site_guid}"; - - if (!is_null($container_guid)) { - if (is_array($container_guid)) { - foreach($container_guid as $key => $val) $container_guid[$key] = (int) $val; - $where[] = "container_guid in (" . implode(",",$container_guid) . ")"; - } else { - $container_guid = (int) $container_guid; - $where[] = "container_guid = {$container_guid}"; - } - } - if ($timelower) - $where[] = "time_created >= {$timelower}"; - if ($timeupper) - $where[] = "time_created <= {$timeupper}"; - - if (!$count) { - $query = "SELECT * from {$CONFIG->dbprefix}entities where "; - } else { - $query = "SELECT count(guid) as total from {$CONFIG->dbprefix}entities where "; - } - foreach ($where as $w) - $query .= " $w and "; - $query .= get_access_sql_suffix(); // Add access controls - if (!$count) { - $query .= " order by $order_by"; - if ($limit) $query .= " limit $offset, $limit"; // Add order and limit - $dt = get_data($query, "entity_row_to_elggstar"); - return $dt; - } else { - $total = get_data_row($query); - return $total->total; - } - } - - function tp_list_entities($type= "", $subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $viewtypetoggle = false, $pagination = true) { - - $offset = (int) get_input('offset'); - $count = tp_get_entities($type, $subtype, $owner_guid, "", $limit, $offset, true); - $entities = tp_get_entities($type, $subtype, $owner_guid, "", $limit, $offset); - - return tp_view_entity_list($entities, $count, $offset, $limit, $fullview, $viewtypetoggle, $pagination); - } - - function tp_view_entity_list($entities, $count, $offset, $limit, $fullview = true, $viewtypetoggle = false, $pagination = true) { - $context = get_context(); - - $html = elgg_view('tidypics/gallery',array( - 'entities' => $entities, - 'count' => $count, - 'offset' => $offset, - 'limit' => $limit, - 'baseurl' => $_SERVER['REQUEST_URI'], - 'fullview' => $fullview, - 'context' => $context, - 'viewtypetoggle' => $viewtypetoggle, - 'viewtype' => get_input('search_viewtype','list'), - 'pagination' => $pagination - )); - - return $html; - } - - function tp_get_entities_from_annotations_calculate_x($sum = "sum", $entity_type = "", $entity_subtype = "", $name = "", $mdname = '', $mdvalue = '', $owner_guid = 0, $limit = 10, $offset = 0, $orderdir = 'desc', $count = false) - { - global $CONFIG; - - $sum = sanitise_string($sum); - $entity_type = sanitise_string($entity_type); - $entity_subtype = get_subtype_id($entity_type, $entity_subtype); - $name = get_metastring_id($name); - $limit = (int) $limit; - $offset = (int) $offset; - $owner_guid = (int) $owner_guid; - if (!empty($mdname) && !empty($mdvalue)) { - $meta_n = get_metastring_id($mdname); - $meta_v = get_metastring_id($mdvalue); - } - - if (empty($name)) return 0; - - $where = array(); - - if ($entity_type!="") - $where[] = "e.type='$entity_type'"; - if ($owner_guid > 0) - $where[] = "e.owner_guid = $owner_guid"; - if ($entity_subtype) - $where[] = "e.subtype=$entity_subtype"; - if ($name!="") - $where[] = "a.name_id='$name'"; - - if (!empty($mdname) && !empty($mdvalue)) { - if ($mdname!="") - $where[] = "m.name_id='$meta_n'"; - if ($mdvalue!="") - $where[] = "m.value_id='$meta_v'"; - } - - if ($sum != "count") - $where[] = "a.value_type='integer'"; // Limit on integer types - - if (!$count) { - $query = "SELECT distinct e.*, $sum(ms.string) as sum "; - } else { - $query = "SELECT count(distinct e.guid) as num, $sum(ms.string) as sum "; - } - $query .= " from {$CONFIG->dbprefix}entities e JOIN {$CONFIG->dbprefix}annotations a on a.entity_guid = e.guid JOIN {$CONFIG->dbprefix}metastrings ms on a.value_id=ms.id "; - - if (!empty($mdname) && !empty($mdvalue)) { - $query .= " JOIN {$CONFIG->dbprefix}metadata m on m.entity_guid = e.guid "; - } - - $query .= " WHERE "; - foreach ($where as $w) - $query .= " $w and "; - $query .= get_access_sql_suffix("a"); // now add access - $query .= ' and ' . get_access_sql_suffix("e"); // now add access - if (!$count) $query .= ' group by e.guid'; - - if (!$count) { - $query .= ' order by sum ' . $orderdir; - $query .= ' limit ' . $offset . ' , ' . $limit; - return get_data($query, "entity_row_to_elggstar"); - } else { - if ($row = get_data_row($query)) { - return $row->num; - } - } - return false; - } - - /** - * Is page owner a group - convenience function - * - * @return true/false - */ - function tp_is_group_page() { - - if ($group = page_owner_entity()) { - if ($group instanceof ElggGroup) - return true; - } - - return false; - } - - - /** - * Is the request from a known browser - * - * @return true/false - */ - function tp_is_person() - { - $known = array('msie', 'mozilla', 'firefox', 'safari', 'webkit', 'opera', 'netscape', 'konqueror', 'gecko'); - - $agent = strtolower($_SERVER['HTTP_USER_AGENT']); - - foreach ($known as $browser) - { - if (strpos($agent, $browser) !== false) { - return true; - } - } - - return false; - } + + +
+

+
+ +
+
+ + + * Good luck + */ + function tp_get_latest_photos($num_images, $owner_guid = 0) + { + $prev_context = set_context('front'); + $image_html = tp_list_entities('object', 'image', $owner_guid, $num_images, false, false, false); + set_context($prev_context); + return $image_html; + } + + + /** + * Get image directory path + * + * Each album gets a subdirectory based on its container id + * + * @return string path to image directory + */ + function tp_get_img_dir() + { + $file = new ElggFile(); + return $file->getFilenameOnFilestore() . 'image/'; + } + + + + /********************************************************************* + * the functions below replace broken core functions or add functions + * that could/should exist in the core + */ + + /** + * + */ + function tp_get_entities($type = "", $subtype = "", $owner_guid = 0, $order_by = "", $limit = 10, $offset = 0, $count = false, $site_guid = 0, $container_guid = null, $timelower = 0, $timeupper = 0) + { + global $CONFIG; + + if ($subtype === false || $subtype === null || $subtype === 0) + return false; + + if ($order_by == "") $order_by = "time_created desc"; + $order_by = sanitise_string($order_by); + $limit = (int)$limit; + $offset = (int)$offset; + $site_guid = (int) $site_guid; + $timelower = (int) $timelower; + $timeupper = (int) $timeupper; + if ($site_guid == 0) + $site_guid = $CONFIG->site_guid; + + $where = array(); + + if (is_array($subtype)) { + $tempwhere = ""; + if (sizeof($subtype)) + foreach($subtype as $typekey => $subtypearray) { + foreach($subtypearray as $subtypeval) { + $typekey = sanitise_string($typekey); + if (!empty($subtypeval)) { + if (!$subtypeval = (int) get_subtype_id($typekey, $subtypeval)) + return false; + } else { + // @todo: Setting subtype to 0 when $subtype = '' returns entities with + // no subtype. This is different to the non-array behavior + // but may be required in some cases. + $subtypeval = 0; + } + if (!empty($tempwhere)) $tempwhere .= " or "; + $tempwhere .= "(type = '{$typekey}' and subtype = {$subtypeval})"; + } + } + if (!empty($tempwhere)) $where[] = "({$tempwhere})"; + + } else { + + $type = sanitise_string($type); + if ($subtype !== "" AND !$subtype = get_subtype_id($type, $subtype)) + return false; + + if ($type != "") + $where[] = "type='$type'"; + if ($subtype!=="") + $where[] = "subtype=$subtype"; + } + + if ($owner_guid != "") { + if (!is_array($owner_guid)) { + $owner_array = array($owner_guid); + $owner_guid = (int) $owner_guid; + $where[] = "owner_guid = '$owner_guid'"; + } else if (sizeof($owner_guid) > 0) { + $owner_array = array_map('sanitise_int', $owner_guid); + // Cast every element to the owner_guid array to int + $owner_guid = array_map("sanitise_int", $owner_guid); + $owner_guid = implode(",",$owner_guid); + $where[] = "owner_guid in ({$owner_guid})"; + } + } + if ($site_guid > 0) + $where[] = "site_guid = {$site_guid}"; + + if (!is_null($container_guid)) { + if (is_array($container_guid)) { + foreach($container_guid as $key => $val) $container_guid[$key] = (int) $val; + $where[] = "container_guid in (" . implode(",",$container_guid) . ")"; + } else { + $container_guid = (int) $container_guid; + $where[] = "container_guid = {$container_guid}"; + } + } + if ($timelower) + $where[] = "time_created >= {$timelower}"; + if ($timeupper) + $where[] = "time_created <= {$timeupper}"; + + if (!$count) { + $query = "SELECT * from {$CONFIG->dbprefix}entities where "; + } else { + $query = "SELECT count(guid) as total from {$CONFIG->dbprefix}entities where "; + } + foreach ($where as $w) + $query .= " $w and "; + $query .= get_access_sql_suffix(); // Add access controls + if (!$count) { + $query .= " order by $order_by"; + if ($limit) $query .= " limit $offset, $limit"; // Add order and limit + $dt = get_data($query, "entity_row_to_elggstar"); + return $dt; + } else { + $total = get_data_row($query); + return $total->total; + } + } + + function tp_list_entities($type= "", $subtype = "", $owner_guid = 0, $limit = 10, $fullview = true, $viewtypetoggle = false, $pagination = true) { + + $offset = (int) get_input('offset'); + $count = tp_get_entities($type, $subtype, $owner_guid, "", $limit, $offset, true); + $entities = tp_get_entities($type, $subtype, $owner_guid, "", $limit, $offset); + + return tp_view_entity_list($entities, $count, $offset, $limit, $fullview, $viewtypetoggle, $pagination); + } + + function tp_view_entity_list($entities, $count, $offset, $limit, $fullview = true, $viewtypetoggle = false, $pagination = true) { + $context = get_context(); + + $html = elgg_view('tidypics/gallery',array( + 'entities' => $entities, + 'count' => $count, + 'offset' => $offset, + 'limit' => $limit, + 'baseurl' => $_SERVER['REQUEST_URI'], + 'fullview' => $fullview, + 'context' => $context, + 'viewtypetoggle' => $viewtypetoggle, + 'viewtype' => get_input('search_viewtype','list'), + 'pagination' => $pagination + )); + + return $html; + } + + function tp_get_entities_from_annotations_calculate_x($sum = "sum", $entity_type = "", $entity_subtype = "", $name = "", $mdname = '', $mdvalue = '', $owner_guid = 0, $limit = 10, $offset = 0, $orderdir = 'desc', $count = false) + { + global $CONFIG; + + $sum = sanitise_string($sum); + $entity_type = sanitise_string($entity_type); + $entity_subtype = get_subtype_id($entity_type, $entity_subtype); + $name = get_metastring_id($name); + $limit = (int) $limit; + $offset = (int) $offset; + $owner_guid = (int) $owner_guid; + if (!empty($mdname) && !empty($mdvalue)) { + $meta_n = get_metastring_id($mdname); + $meta_v = get_metastring_id($mdvalue); + } + + if (empty($name)) return 0; + + $where = array(); + + if ($entity_type!="") + $where[] = "e.type='$entity_type'"; + if ($owner_guid > 0) + $where[] = "e.owner_guid = $owner_guid"; + if ($entity_subtype) + $where[] = "e.subtype=$entity_subtype"; + if ($name!="") + $where[] = "a.name_id='$name'"; + + if (!empty($mdname) && !empty($mdvalue)) { + if ($mdname!="") + $where[] = "m.name_id='$meta_n'"; + if ($mdvalue!="") + $where[] = "m.value_id='$meta_v'"; + } + + if ($sum != "count") + $where[] = "a.value_type='integer'"; // Limit on integer types + + if (!$count) { + $query = "SELECT distinct e.*, $sum(ms.string) as sum "; + } else { + $query = "SELECT count(distinct e.guid) as num, $sum(ms.string) as sum "; + } + $query .= " from {$CONFIG->dbprefix}entities e JOIN {$CONFIG->dbprefix}annotations a on a.entity_guid = e.guid JOIN {$CONFIG->dbprefix}metastrings ms on a.value_id=ms.id "; + + if (!empty($mdname) && !empty($mdvalue)) { + $query .= " JOIN {$CONFIG->dbprefix}metadata m on m.entity_guid = e.guid "; + } + + $query .= " WHERE "; + foreach ($where as $w) + $query .= " $w and "; + $query .= get_access_sql_suffix("a"); // now add access + $query .= ' and ' . get_access_sql_suffix("e"); // now add access + if (!$count) $query .= ' group by e.guid'; + + if (!$count) { + $query .= ' order by sum ' . $orderdir; + $query .= ' limit ' . $offset . ' , ' . $limit; + return get_data($query, "entity_row_to_elggstar"); + } else { + if ($row = get_data_row($query)) { + return $row->num; + } + } + return false; + } + + /** + * Is page owner a group - convenience function + * + * @return true/false + */ + function tp_is_group_page() { + + if ($group = page_owner_entity()) { + if ($group instanceof ElggGroup) + return true; + } + + return false; + } + + + /** + * Is the request from a known browser + * + * @return true/false + */ + function tp_is_person() + { + $known = array('msie', 'mozilla', 'firefox', 'safari', 'webkit', 'opera', 'netscape', 'konqueror', 'gecko'); + + $agent = strtolower($_SERVER['HTTP_USER_AGENT']); + + foreach ($known as $browser) + { + if (strpos($agent, $browser) !== false) { + return true; + } + } + + return false; + } ?> \ No newline at end of file diff --git a/pages/admin.php b/pages/admin.php index 0668ac324..33d44b6c4 100644 --- a/pages/admin.php +++ b/pages/admin.php @@ -1,24 +1,24 @@ - $tab)); - - page_draw(elgg_echo('tidypics:administration'), elgg_view_layout("two_column_left_sidebar", '', $body)); - + $tab)); + + page_draw(elgg_echo('tidypics:administration'), elgg_view_layout("two_column_left_sidebar", '', $body)); + ?> \ No newline at end of file diff --git a/pages/download.php b/pages/download.php index f5530cebc..e4ad2e855 100644 --- a/pages/download.php +++ b/pages/download.php @@ -1,52 +1,52 @@ -originalfilename; - $mime = $file->mimetype; - - header("Content-Type: $mime"); - if ($type == "inline") - header("Content-Disposition: inline; filename=\"$filename\""); - else - header("Content-Disposition: attachment; filename=\"$filename\""); - - - $readfile = new ElggFile($file_guid); - $readfile->owner_guid = $file->owner_guid; - - $contents = $readfile->grabFile(); - - if (empty($contents)) { - echo file_get_contents(dirname(dirname(__FILE__)) . "/graphics/image_error_large.png" ); - } else { - - // expires every 60 days - $expires = 60 * 60*60*24; - - header("Content-Length: " . strlen($contents)); - header("Cache-Control: public", true); - header("Pragma: public", true); - header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT', true); - - - echo $contents; - } - - exit; - } - else - register_error(elgg_echo("image:downloadfailed")); - +originalfilename; + $mime = $file->mimetype; + + header("Content-Type: $mime"); + if ($type == "inline") + header("Content-Disposition: inline; filename=\"$filename\""); + else + header("Content-Disposition: attachment; filename=\"$filename\""); + + + $readfile = new ElggFile($file_guid); + $readfile->owner_guid = $file->owner_guid; + + $contents = $readfile->grabFile(); + + if (empty($contents)) { + echo file_get_contents(dirname(dirname(__FILE__)) . "/graphics/image_error_large.png" ); + } else { + + // expires every 60 days + $expires = 60 * 60*60*24; + + header("Content-Length: " . strlen($contents)); + header("Cache-Control: public", true); + header("Pragma: public", true); + header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT', true); + + + echo $contents; + } + + exit; + } + else + register_error(elgg_echo("image:downloadfailed")); + ?> \ No newline at end of file diff --git a/pages/edit.php b/pages/edit.php index 3f13abae9..abf1a0fdd 100644 --- a/pages/edit.php +++ b/pages/edit.php @@ -1,51 +1,51 @@ -canEdit()) - forward(); - - $subtype = $entity->getSubtype(); - - if ($subtype == 'album') { - $title = elgg_echo('album:edit'); - - if ($container = $entity->container_guid) - set_page_owner($container); - - } else if ($subtype == 'image') { - $title = elgg_echo('image:edit'); - - if ($container = get_entity($entity->container_guid)->container_guid) - set_page_owner($container); - - } else { - forward(); - } - - $page_owner = page_owner_entity(); - if ($page_owner instanceof ElggGroup) { - add_submenu_item( sprintf(elgg_echo('album:group'),$page_owner->name), - $CONFIG->wwwroot . "pg/photos/owned/" . $page_owner->username); - } - - - $area2 .= elgg_view_title($title); - $area2 .= elgg_view('tidypics/forms/edit', array('entity' => $entity, 'subtype' => $subtype)); - $body = elgg_view_layout('two_column_left_sidebar', $area1, $area2); - - page_draw($title, $body); +canEdit()) + forward(); + + $subtype = $entity->getSubtype(); + + if ($subtype == 'album') { + $title = elgg_echo('album:edit'); + + if ($container = $entity->container_guid) + set_page_owner($container); + + } else if ($subtype == 'image') { + $title = elgg_echo('image:edit'); + + if ($container = get_entity($entity->container_guid)->container_guid) + set_page_owner($container); + + } else { + forward(); + } + + $page_owner = page_owner_entity(); + if ($page_owner instanceof ElggGroup) { + add_submenu_item( sprintf(elgg_echo('album:group'),$page_owner->name), + $CONFIG->wwwroot . "pg/photos/owned/" . $page_owner->username); + } + + + $area2 .= elgg_view_title($title); + $area2 .= elgg_view('tidypics/forms/edit', array('entity' => $entity, 'subtype' => $subtype)); + $body = elgg_view_layout('two_column_left_sidebar', $area1, $area2); + + page_draw($title, $body); ?> \ No newline at end of file diff --git a/pages/edit_multiple.php b/pages/edit_multiple.php index 0c9295054..49b7dd6f3 100644 --- a/pages/edit_multiple.php +++ b/pages/edit_multiple.php @@ -1,47 +1,47 @@ -owner_guid); - $album = get_entity($photo->container_guid); - if ($album) { - $owner_guid = $album->container_guid; - if ($owner_guid) - set_page_owner($owner_guid); - } - - foreach ($file_array_sent as $file_guid) { - if ($entity = get_entity($file_guid)) { - if ($entity->canEdit()){ - array_push($new_file_array, $file_guid); - } - if (!$album_guid) - $album_guid = $entity->container_guid; - - } - } - - $title = elgg_echo('tidypics:editprops'); - $area2 .= elgg_view_title($title); - $area2 .= elgg_view("tidypics/forms/edit_multi", array('file_array' => $new_file_array, 'album_guid' => $album_guid)); - $body = elgg_view_layout('two_column_left_sidebar', $area1, $area2); - page_draw($title, $body); -?> +owner_guid); + $album = get_entity($photo->container_guid); + if ($album) { + $owner_guid = $album->container_guid; + if ($owner_guid) + set_page_owner($owner_guid); + } + + foreach ($file_array_sent as $file_guid) { + if ($entity = get_entity($file_guid)) { + if ($entity->canEdit()){ + array_push($new_file_array, $file_guid); + } + if (!$album_guid) + $album_guid = $entity->container_guid; + + } + } + + $title = elgg_echo('tidypics:editprops'); + $area2 .= elgg_view_title($title); + $area2 .= elgg_view("tidypics/forms/edit_multi", array('file_array' => $new_file_array, 'album_guid' => $album_guid)); + $body = elgg_view_layout('two_column_left_sidebar', $area1, $area2); + page_draw($title, $body); +?> diff --git a/pages/friends.php b/pages/friends.php index 8ac1e21d0..e35adce04 100644 --- a/pages/friends.php +++ b/pages/friends.php @@ -1,38 +1,38 @@ -guid == get_loggedin_userid()) - $title = elgg_echo('album:yours:friends'); - else - $title = sprintf(elgg_echo('album:friends'), $user->name); - - $area2 = elgg_view_title($title); - - // get html for viewing list of photo albums - set_context('search'); - set_input('search_viewtype', 'gallery'); // need to force gallery view - $area2 .= list_user_friends_objects($user->guid, 'album', 10, true, false); - - - $body = elgg_view_layout('two_column_left_sidebar', '', $area2); - - page_draw($title, $body); +guid == get_loggedin_userid()) + $title = elgg_echo('album:yours:friends'); + else + $title = sprintf(elgg_echo('album:friends'), $user->name); + + $area2 = elgg_view_title($title); + + // get html for viewing list of photo albums + set_context('search'); + set_input('search_viewtype', 'gallery'); // need to force gallery view + $area2 .= list_user_friends_objects($user->guid, 'album', 10, true, false); + + + $body = elgg_view_layout('two_column_left_sidebar', '', $area2); + + page_draw($title, $body); ?> \ No newline at end of file diff --git a/pages/newalbum.php b/pages/newalbum.php index 006c61b54..fda886d52 100644 --- a/pages/newalbum.php +++ b/pages/newalbum.php @@ -1,32 +1,32 @@ -name), - $CONFIG->wwwroot . "pg/photos/owned/" . $page_owner->username); - } - - $area2 = elgg_view_title(elgg_echo('album:add')); - $area2 .= elgg_view("tidypics/forms/edit"); - - // Display page - page_draw(elgg_echo('album:add'),elgg_view_layout("two_column_left_sidebar", $area1, $area2, $area3 )); - +name), + $CONFIG->wwwroot . "pg/photos/owned/" . $page_owner->username); + } + + $area2 = elgg_view_title(elgg_echo('album:add')); + $area2 .= elgg_view("tidypics/forms/edit"); + + // Display page + page_draw(elgg_echo('album:add'),elgg_view_layout("two_column_left_sidebar", $area1, $area2, $area3 )); + ?> \ No newline at end of file diff --git a/pages/ownedalbums.php b/pages/ownedalbums.php index c3dc54d24..f43c2c5eb 100644 --- a/pages/ownedalbums.php +++ b/pages/ownedalbums.php @@ -1,51 +1,51 @@ -username) || empty($owner->username)) { - forward('pg/photos/world'); - } - - - // setup group menu for album index - if ($owner instanceof ElggGroup) { - add_submenu_item( sprintf(elgg_echo('album:group'),$owner->name), - $CONFIG->wwwroot . "pg/photos/owned/" . $owner->username); - if (can_write_to_container(0, $owner->guid)) { - add_submenu_item( elgg_echo('album:create'), - $CONFIG->wwwroot . 'pg/photos/new/' . $owner->username, - 'tidypics'); - } - } - - //set the title - $title = sprintf(elgg_echo('album:user'), $owner->name); - $area2 = elgg_view_title($title); - - // Get objects - set_context('search'); - set_input('search_viewtype', 'gallery'); - if ($owner instanceof ElggGroup) - $area2 .= list_entities("object", "album", $owner->guid, 12, false); - else - $area2 .= list_entities("object", "album", $owner->guid, 12, false); - - set_context('photos'); - $body = elgg_view_layout('two_column_left_sidebar', '', $area2); - - // Finally draw the page - page_draw($title, $body); +username) || empty($owner->username)) { + forward('pg/photos/world'); + } + + + // setup group menu for album index + if ($owner instanceof ElggGroup) { + add_submenu_item( sprintf(elgg_echo('album:group'),$owner->name), + $CONFIG->wwwroot . "pg/photos/owned/" . $owner->username); + if (can_write_to_container(0, $owner->guid)) { + add_submenu_item( elgg_echo('album:create'), + $CONFIG->wwwroot . 'pg/photos/new/' . $owner->username, + 'tidypics'); + } + } + + //set the title + $title = sprintf(elgg_echo('album:user'), $owner->name); + $area2 = elgg_view_title($title); + + // Get objects + set_context('search'); + set_input('search_viewtype', 'gallery'); + if ($owner instanceof ElggGroup) + $area2 .= list_entities("object", "album", $owner->guid, 12, false); + else + $area2 .= list_entities("object", "album", $owner->guid, 12, false); + + set_context('photos'); + $body = elgg_view_layout('two_column_left_sidebar', '', $area2); + + // Finally draw the page + page_draw($title, $body); ?> \ No newline at end of file diff --git a/pages/tagged.php b/pages/tagged.php index fb07b392c..b5a879809 100644 --- a/pages/tagged.php +++ b/pages/tagged.php @@ -1,50 +1,50 @@ -name); - else - $title = "User does not exist"; - - - - // create main column - $body = elgg_view_title($title); - - set_context('search'); - set_input('search_viewtype', 'gallery'); // need to force gallery view - $body .= list_entities_from_relationship('phototag', $guid, false, 'object', 'image', 0, 10, false); - - // Set up submenus - if (isloggedin()) { - add_submenu_item( elgg_echo("album:yours"), - $CONFIG->wwwroot . "pg/photos/owned/" . $_SESSION['user']->username, - 'tidypics-b' ); - } - add_submenu_item( elgg_echo('album:all'), - $CONFIG->wwwroot . "pg/photos/world/", - 'tidypics-z'); - add_submenu_item( elgg_echo('tidypics:mostrecent'), - $CONFIG->wwwroot . 'pg/photos/mostrecent', - 'tidypics-z'); - - - - $body = elgg_view_layout('two_column_left_sidebar','',$body); - - - page_draw($title,$body); - +name); + else + $title = "User does not exist"; + + + + // create main column + $body = elgg_view_title($title); + + set_context('search'); + set_input('search_viewtype', 'gallery'); // need to force gallery view + $body .= list_entities_from_relationship('phototag', $guid, false, 'object', 'image', 0, 10, false); + + // Set up submenus + if (isloggedin()) { + add_submenu_item( elgg_echo("album:yours"), + $CONFIG->wwwroot . "pg/photos/owned/" . $_SESSION['user']->username, + 'tidypics-b' ); + } + add_submenu_item( elgg_echo('album:all'), + $CONFIG->wwwroot . "pg/photos/world/", + 'tidypics-z'); + add_submenu_item( elgg_echo('tidypics:mostrecent'), + $CONFIG->wwwroot . 'pg/photos/mostrecent', + 'tidypics-z'); + + + + $body = elgg_view_layout('two_column_left_sidebar','',$body); + + + page_draw($title,$body); + ?> \ No newline at end of file diff --git a/pages/upload.php b/pages/upload.php index 3550d5620..84d237287 100644 --- a/pages/upload.php +++ b/pages/upload.php @@ -1,42 +1,42 @@ -canEdit()) { - // throw warning and forward to previous page - forward($_SERVER['HTTP_REFERER']); - } - - // set page owner based on container (user or group) - $container = $album->container_guid; - set_page_owner($container); - - $page_owner = page_owner_entity(); - if ($page_owner instanceof ElggGroup) { - add_submenu_item( sprintf(elgg_echo('album:group'),$page_owner->name), - $CONFIG->wwwroot . "pg/photos/owned/" . $page_owner->username); - } - - set_context('photos'); - $title = elgg_echo('album:addpix') . ': ' . $album->title; - $area2 .= elgg_view_title($title); - - $area2 .= elgg_view("tidypics/forms/upload", array('album' => $album_guid ) ); - $body = elgg_view_layout('two_column_left_sidebar', '', $area2); - - page_draw($title, $body); +canEdit()) { + // throw warning and forward to previous page + forward($_SERVER['HTTP_REFERER']); + } + + // set page owner based on container (user or group) + $container = $album->container_guid; + set_page_owner($container); + + $page_owner = page_owner_entity(); + if ($page_owner instanceof ElggGroup) { + add_submenu_item( sprintf(elgg_echo('album:group'),$page_owner->name), + $CONFIG->wwwroot . "pg/photos/owned/" . $page_owner->username); + } + + set_context('photos'); + $title = elgg_echo('album:addpix') . ': ' . $album->title; + $area2 .= elgg_view_title($title); + + $area2 .= elgg_view("tidypics/forms/upload", array('album' => $album_guid ) ); + $body = elgg_view_layout('two_column_left_sidebar', '', $area2); + + page_draw($title, $body); ?> \ No newline at end of file diff --git a/pages/viewalbum.php b/pages/viewalbum.php index 402c2d7e6..9ebc31fae 100644 --- a/pages/viewalbum.php +++ b/pages/viewalbum.php @@ -1,68 +1,68 @@ -container_guid) - set_page_owner($album->container_guid); - else - set_page_owner($album->owner_guid); - - $owner = page_owner_entity(); - - // setup group menu - if ($owner instanceof ElggGroup) { - add_submenu_item( sprintf(elgg_echo('album:group'),$owner->name), - $CONFIG->wwwroot . "pg/photos/owned/" . $owner->username); - } - - // allow other plugins to override the slideshow - $slideshow_link = trigger_plugin_hook('tp_slideshow', 'album', $album, null); - if ($slideshow_link) { - add_submenu_item(elgg_echo('album:slideshow'), - $slideshow_link, - 'photos' ); - } - - if (can_write_to_container(0, $album->container_guid)) { - if ($owner instanceof ElggGroup) { - add_submenu_item( elgg_echo('album:create'), - $CONFIG->wwwroot . 'pg/photos/new/' . $owner->username, - 'photos'); - } - add_submenu_item( elgg_echo('album:addpix'), - $CONFIG->wwwroot . 'pg/photos/upload/' . $album_guid, - 'photos'); - add_submenu_item( elgg_echo('album:edit'), - $CONFIG->wwwroot . 'pg/photos/edit/' . $album_guid, - 'photos'); - $ts = time(); - $token = generate_action_token($ts); - add_submenu_item( elgg_echo('album:delete'), - $CONFIG->wwwroot . 'action/tidypics/delete?guid=' . $album_guid . '&__elgg_token=' . $token . '&__elgg_ts=' . $ts, - 'photos', - true); - } - - // create body - $area2 = elgg_view_entity($album, true); - $body = elgg_view_layout('two_column_left_sidebar', '', $area2); - - page_draw($album->title, $body); +container_guid) + set_page_owner($album->container_guid); + else + set_page_owner($album->owner_guid); + + $owner = page_owner_entity(); + + // setup group menu + if ($owner instanceof ElggGroup) { + add_submenu_item( sprintf(elgg_echo('album:group'),$owner->name), + $CONFIG->wwwroot . "pg/photos/owned/" . $owner->username); + } + + // allow other plugins to override the slideshow + $slideshow_link = trigger_plugin_hook('tp_slideshow', 'album', $album, null); + if ($slideshow_link) { + add_submenu_item(elgg_echo('album:slideshow'), + $slideshow_link, + 'photos' ); + } + + if (can_write_to_container(0, $album->container_guid)) { + if ($owner instanceof ElggGroup) { + add_submenu_item( elgg_echo('album:create'), + $CONFIG->wwwroot . 'pg/photos/new/' . $owner->username, + 'photos'); + } + add_submenu_item( elgg_echo('album:addpix'), + $CONFIG->wwwroot . 'pg/photos/upload/' . $album_guid, + 'photos'); + add_submenu_item( elgg_echo('album:edit'), + $CONFIG->wwwroot . 'pg/photos/edit/' . $album_guid, + 'photos'); + $ts = time(); + $token = generate_action_token($ts); + add_submenu_item( elgg_echo('album:delete'), + $CONFIG->wwwroot . 'action/tidypics/delete?guid=' . $album_guid . '&__elgg_token=' . $token . '&__elgg_ts=' . $ts, + 'photos', + true); + } + + // create body + $area2 = elgg_view_entity($album, true); + $body = elgg_view_layout('two_column_left_sidebar', '', $area2); + + page_draw($album->title, $body); ?> \ No newline at end of file diff --git a/pages/viewimage.php b/pages/viewimage.php index 5f23fc685..025c1ad3b 100644 --- a/pages/viewimage.php +++ b/pages/viewimage.php @@ -1,58 +1,58 @@ -owner_guid); - $album = get_entity($photo->container_guid); - if ($album) { - $owner_guid = $album->container_guid; - if ($owner_guid) - set_page_owner($owner_guid); - } - - - $page_owner = page_owner_entity(); - if ($page_owner instanceof ElggGroup) { - add_submenu_item( sprintf(elgg_echo('album:group'),$page_owner->name), - $CONFIG->wwwroot . "pg/photos/owned/" . $page_owner->username); - } - - if (can_write_to_container(0, $album->container_guid)) { - add_submenu_item( elgg_echo('image:edit'), - $CONFIG->wwwroot . 'pg/photos/edit/' . $photo_guid, - 'photos'); - $ts = time(); - $token = generate_action_token($ts); - add_submenu_item( elgg_echo('image:delete'), - $CONFIG->wwwroot . 'action/tidypics/delete?guid=' . $photo_guid . '&__elgg_token=' . $token . '&__elgg_ts=' . $ts, - 'photos', - true); - } - - - $title = $photo->title; - $area2 = elgg_view_title($title); - $area2 .= elgg_view_entity($photo, true); - - $body = elgg_view_layout('two_column_left_sidebar', '', $area2); - - page_draw($title, $body); +owner_guid); + $album = get_entity($photo->container_guid); + if ($album) { + $owner_guid = $album->container_guid; + if ($owner_guid) + set_page_owner($owner_guid); + } + + + $page_owner = page_owner_entity(); + if ($page_owner instanceof ElggGroup) { + add_submenu_item( sprintf(elgg_echo('album:group'),$page_owner->name), + $CONFIG->wwwroot . "pg/photos/owned/" . $page_owner->username); + } + + if (can_write_to_container(0, $album->container_guid)) { + add_submenu_item( elgg_echo('image:edit'), + $CONFIG->wwwroot . 'pg/photos/edit/' . $photo_guid, + 'photos'); + $ts = time(); + $token = generate_action_token($ts); + add_submenu_item( elgg_echo('image:delete'), + $CONFIG->wwwroot . 'action/tidypics/delete?guid=' . $photo_guid . '&__elgg_token=' . $token . '&__elgg_ts=' . $ts, + 'photos', + true); + } + + + $title = $photo->title; + $area2 = elgg_view_title($title); + $area2 .= elgg_view_entity($photo, true); + + $body = elgg_view_layout('two_column_left_sidebar', '', $area2); + + page_draw($title, $body); ?> \ No newline at end of file diff --git a/pages/world.php b/pages/world.php index 2683abc1d..9488f2620 100644 --- a/pages/world.php +++ b/pages/world.php @@ -1,31 +1,31 @@ - \ No newline at end of file diff --git a/start.php b/start.php index f56669c1f..472bf4881 100644 --- a/start.php +++ b/start.php @@ -1,437 +1,437 @@ -wwwroot . "pg/photos/owned/" . $_SESSION['user']->username); - } - - // Extend CSS - extend_view('css', 'tidypics/css'); - - // Extend hover-over and profile menu - extend_view('profile/menu/links','tidypics/hover_menu'); - - //group view ** psuedo widget view for group pages** - extend_view('groups/right_column','tidypics/groupprofile_albums'); - - // rss extensions - extend_view('extensions/xmlns', 'extensions/tidypics/xmlns'); - extend_view('extensions/channel', 'extensions/tidypics/channel'); - - // Register a page handler, so we can have nice URLs - register_page_handler('photos','tidypics_page_handler'); - - // Add a new tidypics widget - add_widget_type('album_view', elgg_echo("tidypics:widget:albums"), elgg_echo("tidypics:widget:album_descr"), 'profile'); - add_widget_type('latest_photos', elgg_echo("tidypics:widget:latest"), elgg_echo("tidypics:widget:latest_descr"), 'profile'); - - // Register a URL handler for files - 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'); - - if (function_exists('add_group_tool_option')) - add_group_tool_option('photos',elgg_echo('tidypics:enablephotos'),true); - - if (get_plugin_setting('grp_perm_override', 'tidypics') != "disabled") - register_plugin_hook('permissions_check', 'object', 'tidypics_permission_override'); - - // Register for notifications - if (is_callable('register_notification_object')) { - register_notification_object('object', 'album', elgg_echo('tidypics:newalbum')); - - register_plugin_hook('notify:entity:message', 'object', 'tidypics_notify_message'); - } - - // slideshow plugin hook - register_plugin_hook('tp_slideshow', 'album', 'tidypics_slideshow'); - } - - /** - * Sets up sidebar menus for tidypics. Triggered on pagesetup. - */ - function tidypics_submenus() { - - global $CONFIG; - - $page_owner = page_owner_entity(); - - if ($page_owner instanceof ElggGroup) { - if (get_context() == "groups") { - if ($page_owner->photos_enable != "no") { - add_submenu_item( sprintf(elgg_echo('album:group'),$page_owner->name), - $CONFIG->wwwroot . "pg/photos/owned/" . $page_owner->username); - } - } - } - // context is only set to photos on individual pages, not on group pages - else if (get_context() == "photos") { - - $view_count = get_plugin_setting('view_count', 'tidypics'); - - // owner gets "your albumn", "your friends albums", "your most viewed", "your most recent" - if (get_loggedin_userid() && get_loggedin_userid() == $page_owner->guid) { - - add_submenu_item( elgg_echo('album:create'), - $CONFIG->wwwroot . "pg/photos/new/{$page_owner->username}/", - 'tidypics-a' ); - - add_submenu_item( elgg_echo("album:yours"), - $CONFIG->wwwroot . "pg/photos/owned/{$page_owner->username}/", - 'tidypics-a' ); - - add_submenu_item( elgg_echo('album:yours:friends'), - $CONFIG->wwwroot . "pg/photos/friends/{$page_owner->username}/", - 'tidypics-a'); - - if ($view_count != 'disabled') { - add_submenu_item( elgg_echo('tidypics:yourmostviewed'), - $CONFIG->wwwroot . "pg/photos/mostviewed/{$page_owner->username}/", - 'tidypics-a'); - } - - add_submenu_item( elgg_echo('tidypics:yourmostrecent'), - $CONFIG->wwwroot . "pg/photos/mostrecent/{$page_owner->username}/", - 'tidypics-a'); - } else if (isloggedin()) { - - $user = get_loggedin_user(); - - // logged in not owner gets "page owners albums", "page owner's friends albums", "page owner's most viewed", "page owner's most recent" - // and then "your albums", "your most viewed", "your most recent" - add_submenu_item( elgg_echo("album:yours"), - $CONFIG->wwwroot . "pg/photos/owned/{$user->username}/", - 'tidypics-b' ); - - if ($view_count != 'disabled') { - add_submenu_item( elgg_echo('tidypics:yourmostviewed'), - $CONFIG->wwwroot . "pg/photos/mostviewed/{$user->username}/", - 'tidypics-b'); - } - - add_submenu_item( elgg_echo('tidypics:yourmostrecent'), - $CONFIG->wwwroot . "pg/photos/mostrecent/{$user->username}/", - 'tidypics-b'); - - if($page_owner->name) { // check to make sure the owner set their display name - add_submenu_item( sprintf(elgg_echo("album:user"), $page_owner->name), - $CONFIG->wwwroot . "pg/photos/owned/{$page_owner->username}/", - 'tidypics-a' ); - add_submenu_item( sprintf(elgg_echo('album:friends'),$page_owner->name), - $CONFIG->wwwroot . "pg/photos/friends/{$page_owner->username}/", - 'tidypics-a'); - - if ($view_count != 'disabled') { - add_submenu_item( sprintf(elgg_echo('tidypics:friendmostviewed'),$page_owner->name), - $CONFIG->wwwroot . "pg/photos/mostviewed/{$page_owner->username}/", - 'tidypics-a'); - } - - add_submenu_item( sprintf(elgg_echo('tidypics:friendmostrecent'),$page_owner->name), - $CONFIG->wwwroot . "pg/photos/mostrecent/{$page_owner->username}/", - 'tidypics-a'); - } - } else if ($page_owner->guid) { - // non logged in user gets "page owners albums", "page owner's friends albums" - add_submenu_item( sprintf(elgg_echo("album:user"), $page_owner->name), - $CONFIG->wwwroot . "pg/photos/owned/{$page_owner->username}/", - 'tidypics-a' ); - add_submenu_item( sprintf(elgg_echo('album:friends'),$page_owner->name), - $CONFIG->wwwroot . "pg/photos/friends/{$page_owner->username}/", - 'tidypics-a'); - } - - // everyone gets world albums, most recent, most viewed, most recently viewed, recently commented - add_submenu_item( elgg_echo('album:all'), - $CONFIG->wwwroot . "pg/photos/world/", - 'tidypics-z'); - add_submenu_item( elgg_echo('tidypics:mostrecent'), - $CONFIG->wwwroot . 'pg/photos/mostrecent/', - 'tidypics-z'); - - if ($view_count != 'disabled') { - add_submenu_item( elgg_echo('tidypics:mostviewed'), - $CONFIG->wwwroot . 'pg/photos/mostviewed/', - 'tidypics-z'); - add_submenu_item( elgg_echo('tidypics:recentlyviewed'), - $CONFIG->wwwroot . 'pg/photos/recentlyviewed/', - 'tidypics-z'); - } - add_submenu_item( elgg_echo('tidypics:recentlycommented'), - $CONFIG->wwwroot . 'pg/photos/recentlycommented/', - 'tidypics-z'); - add_submenu_item( 'Flickr Integration', - $CONFIG->wwwroot . 'mod/tidypics/pages/flickr/setup.php', - 'tidypics-z'); - - } - - } - - /** - * Sets up tidypics admin menu. Triggered on pagesetup. - */ - function tidypics_adminmenu() - { - global $CONFIG; - if (get_context() == 'admin' && isadminloggedin()) { - add_submenu_item(elgg_echo('tidypics:administration'), $CONFIG->url . "mod/tidypics/pages/admin.php"); - } - } - - /** - * Sets up submenus for tidypics most viewed pages - */ - function tidypics_mostviewed_submenus() { - - global $CONFIG; - - add_submenu_item(elgg_echo('tidypics:mostvieweddashboard'), $CONFIG->url . "mod/tidypics/mostvieweddashboard.php"); - add_submenu_item(elgg_echo('tidypics:mostviewedthisyear'), $CONFIG->url . "mod/tidypics/pages/lists/mostviewedimagesthisyear.php"); - add_submenu_item(elgg_echo('tidypics:mostviewedthismonth'), $CONFIG->url . "mod/tidypics/pages/lists/mostviewedimagesthismonth.php"); - add_submenu_item(elgg_echo('tidypics:mostviewedlastmonth'), $CONFIG->url . "mod/tidypics/pages/lists/mostviewedimageslastmonth.php"); - add_submenu_item(elgg_echo('tidypics:mostviewedtoday'), $CONFIG->url . "mod/tidypics/pages/lists/mostviewedimagestoday.php"); - add_submenu_item(elgg_echo('tidypics:mostcommented'), $CONFIG->url . "mod/tidypics/pages/lists/mostcommentedimages.php"); - add_submenu_item(elgg_echo('tidypics:mostcommentedthismonth'), $CONFIG->url . "mod/tidypics/pages/lists/mostcommentedimagesthismonth.php"); - add_submenu_item(elgg_echo('tidypics:mostcommentedtoday'), $CONFIG->url . "mod/tidypics/pages/lists/mostcommentedimagestoday.php"); - add_submenu_item(elgg_echo('tidypics:recentlycommented'), $CONFIG->wwwroot . 'pg/photos/recentlycommented/'); - } - - /** - * tidypics page handler - * - * @param array $page Array of page elements, forwarded by the page handling mechanism - */ - function tidypics_page_handler($page) { - - global $CONFIG; - - if (isset($page[0])) - { - switch($page[0]) - { - case "owned": //view list of albums owned by container - if (isset($page[1])) set_input('username',$page[1]); - include($CONFIG->pluginspath . "tidypics/pages/ownedalbums.php"); - break; - - case "view": //view an image individually - if (isset($page[1])) set_input('guid',$page[1]); - include($CONFIG->pluginspath . "tidypics/pages/viewimage.php"); - break; - - case "album": //view an album individually - if (isset($page[1])) set_input('guid',$page[1]); - include($CONFIG->pluginspath . "tidypics/pages/viewalbum.php"); - break; - - case "new": //create new album - if (isset($page[1])) set_input('username',$page[1]); - include($CONFIG->pluginspath . "tidypics/pages/newalbum.php"); - break; - - case "upload": //upload images to album - if (isset($page[1])) set_input('container_guid',$page[1]); - include($CONFIG->pluginspath . "tidypics/pages/upload.php"); - break; - - case "edit": //edit image or album - if (isset($page[1])) set_input('guid',$page[1]); - include($CONFIG->pluginspath . "tidypics/pages/edit.php"); - break; - - case "friends": // albums of friends - if (isset($page[1])) set_input('username',$page[1]); - include($CONFIG->pluginspath . "tidypics/pages/friends.php"); - break; - - case "world": // all site albums - include($CONFIG->pluginspath . "tidypics/pages/world.php"); - break; - - case "download": // download an image - if (isset($page[1])) set_input('file_guid', $page[1]); - if (isset($page[2])) set_input('type', $page[2]); - include($CONFIG->pluginspath . "tidypics/pages/download.php"); - break; - - case "tagged": // all photos tagged with user - if (isset($page[1])) set_input('guid',$page[1]); - include($CONFIG->pluginspath . "tidypics/pages/tagged.php"); - break; - - case "mostviewed": // images with the most views - if (isset($page[1])) set_input('username',$page[1]); - include($CONFIG->pluginspath . "tidypics/pages/lists/mostviewedimages.php"); - break; - - case "mostrecent": // images uploaded most recently - if (isset($page[1])) set_input('username',$page[1]); - include($CONFIG->pluginspath . "tidypics/pages/lists/mostrecentimages.php"); - break; - - case "recentlyviewed": // images most recently viewed - include($CONFIG->pluginspath . "tidypics/pages/lists/recentlyviewed.php"); - break; - - case "recentlycommented": // images with the most recent comments - include($CONFIG->pluginspath . "tidypics/pages/lists/recentlycommented.php"); - break; - - case "highestrated": // images with the highest average rating - include($CONFIG->pluginspath . "tidypics/pages/lists/highestrated.php"); - break; - - case "flickr": - if (isset($page[1])) set_input('username',$page[1]); - include($CONFIG->pluginspath . "tidypics/pages/flickr/setup.php"); - break; - } - } - else - { - // going to all site albums if something goes wrong with the page handler - include($CONFIG->pluginspath . "tidypics/pages/world.php"); - } - - } - - /** - * Override permissions for group albums and images - * - */ - function tidypics_permission_override($hook, $entity_type, $returnvalue, $params) - { - $entity = $params['entity']; - $user = $params['user']; - - if ($entity->subtype == get_subtype_id('object', 'album')) { - // test that the user can edit the container - return can_write_to_container(0, $entity->container_guid); - } - - if ($entity->subtype == get_subtype_id('object', 'image')) { - // test that the user can edit the container - return can_write_to_container(0, $entity->container_guid); - } - } - - - /** - * Notification message handler - */ - function tidypics_notify_message($hook, $entity_type, $returnvalue, $params) - { - $entity = $params['entity']; - $to_entity = $params['to_entity']; - $method = $params['method']; - if (($entity instanceof ElggEntity) && ($entity->getSubtype() == 'album')) - { - // block notification message when the album doesn't have any photos - if ($entity->new_album == TP_NEW_ALBUM) - return false; - - $descr = $entity->description; - $title = $entity->title; - $owner = $entity->getOwnerEntity(); - return sprintf(elgg_echo('album:river:created'), $owner->name) . ': ' . $title . "\n\n" . $descr . "\n\n" . $entity->getURL(); - } - return null; - } - - /** - * Populates the ->getUrl() method for file objects - * Registered in the init function - * - * @param ElggEntity $entity album/image entity - * @return string File URL - */ - function tidypics_image_url($entity) { - global $CONFIG; - $title = $entity->title; - $title = friendly_title($title); - return $CONFIG->url . "pg/photos/view/" . $entity->getGUID() . "/" . $title; - } - - function tidypics_album_url($entity) { - global $CONFIG; - $title = $entity->title; - $title = friendly_title($title); - return $CONFIG->url . "pg/photos/album/" . $entity->getGUID() . "/" . $title; - } - - - /** - * Catch the plugin hook and add the default album slideshow - * - * @param $hook - 'tidypics:slideshow' - * @param $entity_type - 'album' - * @param $returnvalue - if set, return because another plugin has used the hook - * @param $params - album entity - * @return unknown_type - */ - function tidypics_slideshow($hook, $entity_type, $returnvalue, $params) { - - if ($returnvalue !== null) { - // someone has already added a slideshow or requested that the slideshow is not used - return $returnvalue; - } - - $slideshow_link = 'javascript:PicLensLite.start({maxScale:0,feedUrl:PicLensLite.indexFeeds()[0].url})'; - - // add the slideshow javascript to the header - extend_view('metatags', 'js/slideshow'); - - return $slideshow_link; - } - - function tp_mostrecentimages($max = 8, $pagination = true) { - return list_entities("object", "image", 0, $max, false, false, $pagination); - } - - - // Make sure tidypics_init is called on initialisation - register_elgg_event_handler('init','system','tidypics_init'); - register_elgg_event_handler('pagesetup','system','tidypics_submenus'); - register_elgg_event_handler('pagesetup','system','tidypics_adminmenu'); - - // Register actions - register_action("tidypics/settings", false, $CONFIG->pluginspath . "tidypics/actions/settings.php"); - register_action("tidypics/upload", false, $CONFIG->pluginspath . "tidypics/actions/upload.php"); - register_action("tidypics/addalbum", false, $CONFIG->pluginspath. "tidypics/actions/addalbum.php"); - register_action("tidypics/edit", false, $CONFIG->pluginspath. "tidypics/actions/edit.php"); - register_action("tidypics/delete", false, $CONFIG->pluginspath. "tidypics/actions/delete.php"); - register_action("tidypics/edit_multi", false, $CONFIG->pluginspath. "tidypics/actions/edit_multi.php"); - register_action("tidypics/addtag", true, $CONFIG->pluginspath . "tidypics/actions/addtag.php"); - register_action("tidypics/deletetag", true, $CONFIG->pluginspath . "tidypics/actions/deletetag.php"); - register_action("tidypics/flickrSetup", true, $CONFIG->pluginspath . "tidypics/actions/flickrSetup.php"); - +wwwroot . "pg/photos/owned/" . $_SESSION['user']->username); + } + + // Extend CSS + extend_view('css', 'tidypics/css'); + + // Extend hover-over and profile menu + extend_view('profile/menu/links','tidypics/hover_menu'); + + //group view ** psuedo widget view for group pages** + extend_view('groups/right_column','tidypics/groupprofile_albums'); + + // rss extensions + extend_view('extensions/xmlns', 'extensions/tidypics/xmlns'); + extend_view('extensions/channel', 'extensions/tidypics/channel'); + + // Register a page handler, so we can have nice URLs + register_page_handler('photos','tidypics_page_handler'); + + // Add a new tidypics widget + add_widget_type('album_view', elgg_echo("tidypics:widget:albums"), elgg_echo("tidypics:widget:album_descr"), 'profile'); + add_widget_type('latest_photos', elgg_echo("tidypics:widget:latest"), elgg_echo("tidypics:widget:latest_descr"), 'profile'); + + // Register a URL handler for files + 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'); + + if (function_exists('add_group_tool_option')) + add_group_tool_option('photos',elgg_echo('tidypics:enablephotos'),true); + + if (get_plugin_setting('grp_perm_override', 'tidypics') != "disabled") + register_plugin_hook('permissions_check', 'object', 'tidypics_permission_override'); + + // Register for notifications + if (is_callable('register_notification_object')) { + register_notification_object('object', 'album', elgg_echo('tidypics:newalbum')); + + register_plugin_hook('notify:entity:message', 'object', 'tidypics_notify_message'); + } + + // slideshow plugin hook + register_plugin_hook('tp_slideshow', 'album', 'tidypics_slideshow'); + } + + /** + * Sets up sidebar menus for tidypics. Triggered on pagesetup. + */ + function tidypics_submenus() { + + global $CONFIG; + + $page_owner = page_owner_entity(); + + if ($page_owner instanceof ElggGroup) { + if (get_context() == "groups") { + if ($page_owner->photos_enable != "no") { + add_submenu_item( sprintf(elgg_echo('album:group'),$page_owner->name), + $CONFIG->wwwroot . "pg/photos/owned/" . $page_owner->username); + } + } + } + // context is only set to photos on individual pages, not on group pages + else if (get_context() == "photos") { + + $view_count = get_plugin_setting('view_count', 'tidypics'); + + // owner gets "your albumn", "your friends albums", "your most viewed", "your most recent" + if (get_loggedin_userid() && get_loggedin_userid() == $page_owner->guid) { + + add_submenu_item( elgg_echo('album:create'), + $CONFIG->wwwroot . "pg/photos/new/{$page_owner->username}/", + 'tidypics-a' ); + + add_submenu_item( elgg_echo("album:yours"), + $CONFIG->wwwroot . "pg/photos/owned/{$page_owner->username}/", + 'tidypics-a' ); + + add_submenu_item( elgg_echo('album:yours:friends'), + $CONFIG->wwwroot . "pg/photos/friends/{$page_owner->username}/", + 'tidypics-a'); + + if ($view_count != 'disabled') { + add_submenu_item( elgg_echo('tidypics:yourmostviewed'), + $CONFIG->wwwroot . "pg/photos/mostviewed/{$page_owner->username}/", + 'tidypics-a'); + } + + add_submenu_item( elgg_echo('tidypics:yourmostrecent'), + $CONFIG->wwwroot . "pg/photos/mostrecent/{$page_owner->username}/", + 'tidypics-a'); + } else if (isloggedin()) { + + $user = get_loggedin_user(); + + // logged in not owner gets "page owners albums", "page owner's friends albums", "page owner's most viewed", "page owner's most recent" + // and then "your albums", "your most viewed", "your most recent" + add_submenu_item( elgg_echo("album:yours"), + $CONFIG->wwwroot . "pg/photos/owned/{$user->username}/", + 'tidypics-b' ); + + if ($view_count != 'disabled') { + add_submenu_item( elgg_echo('tidypics:yourmostviewed'), + $CONFIG->wwwroot . "pg/photos/mostviewed/{$user->username}/", + 'tidypics-b'); + } + + add_submenu_item( elgg_echo('tidypics:yourmostrecent'), + $CONFIG->wwwroot . "pg/photos/mostrecent/{$user->username}/", + 'tidypics-b'); + + if($page_owner->name) { // check to make sure the owner set their display name + add_submenu_item( sprintf(elgg_echo("album:user"), $page_owner->name), + $CONFIG->wwwroot . "pg/photos/owned/{$page_owner->username}/", + 'tidypics-a' ); + add_submenu_item( sprintf(elgg_echo('album:friends'),$page_owner->name), + $CONFIG->wwwroot . "pg/photos/friends/{$page_owner->username}/", + 'tidypics-a'); + + if ($view_count != 'disabled') { + add_submenu_item( sprintf(elgg_echo('tidypics:friendmostviewed'),$page_owner->name), + $CONFIG->wwwroot . "pg/photos/mostviewed/{$page_owner->username}/", + 'tidypics-a'); + } + + add_submenu_item( sprintf(elgg_echo('tidypics:friendmostrecent'),$page_owner->name), + $CONFIG->wwwroot . "pg/photos/mostrecent/{$page_owner->username}/", + 'tidypics-a'); + } + } else if ($page_owner->guid) { + // non logged in user gets "page owners albums", "page owner's friends albums" + add_submenu_item( sprintf(elgg_echo("album:user"), $page_owner->name), + $CONFIG->wwwroot . "pg/photos/owned/{$page_owner->username}/", + 'tidypics-a' ); + add_submenu_item( sprintf(elgg_echo('album:friends'),$page_owner->name), + $CONFIG->wwwroot . "pg/photos/friends/{$page_owner->username}/", + 'tidypics-a'); + } + + // everyone gets world albums, most recent, most viewed, most recently viewed, recently commented + add_submenu_item( elgg_echo('album:all'), + $CONFIG->wwwroot . "pg/photos/world/", + 'tidypics-z'); + add_submenu_item( elgg_echo('tidypics:mostrecent'), + $CONFIG->wwwroot . 'pg/photos/mostrecent/', + 'tidypics-z'); + + if ($view_count != 'disabled') { + add_submenu_item( elgg_echo('tidypics:mostviewed'), + $CONFIG->wwwroot . 'pg/photos/mostviewed/', + 'tidypics-z'); + add_submenu_item( elgg_echo('tidypics:recentlyviewed'), + $CONFIG->wwwroot . 'pg/photos/recentlyviewed/', + 'tidypics-z'); + } + add_submenu_item( elgg_echo('tidypics:recentlycommented'), + $CONFIG->wwwroot . 'pg/photos/recentlycommented/', + 'tidypics-z'); + add_submenu_item( 'Flickr Integration', + $CONFIG->wwwroot . 'mod/tidypics/pages/flickr/setup.php', + 'tidypics-z'); + + } + + } + + /** + * Sets up tidypics admin menu. Triggered on pagesetup. + */ + function tidypics_adminmenu() + { + global $CONFIG; + if (get_context() == 'admin' && isadminloggedin()) { + add_submenu_item(elgg_echo('tidypics:administration'), $CONFIG->url . "mod/tidypics/pages/admin.php"); + } + } + + /** + * Sets up submenus for tidypics most viewed pages + */ + function tidypics_mostviewed_submenus() { + + global $CONFIG; + + add_submenu_item(elgg_echo('tidypics:mostvieweddashboard'), $CONFIG->url . "mod/tidypics/mostvieweddashboard.php"); + add_submenu_item(elgg_echo('tidypics:mostviewedthisyear'), $CONFIG->url . "mod/tidypics/pages/lists/mostviewedimagesthisyear.php"); + add_submenu_item(elgg_echo('tidypics:mostviewedthismonth'), $CONFIG->url . "mod/tidypics/pages/lists/mostviewedimagesthismonth.php"); + add_submenu_item(elgg_echo('tidypics:mostviewedlastmonth'), $CONFIG->url . "mod/tidypics/pages/lists/mostviewedimageslastmonth.php"); + add_submenu_item(elgg_echo('tidypics:mostviewedtoday'), $CONFIG->url . "mod/tidypics/pages/lists/mostviewedimagestoday.php"); + add_submenu_item(elgg_echo('tidypics:mostcommented'), $CONFIG->url . "mod/tidypics/pages/lists/mostcommentedimages.php"); + add_submenu_item(elgg_echo('tidypics:mostcommentedthismonth'), $CONFIG->url . "mod/tidypics/pages/lists/mostcommentedimagesthismonth.php"); + add_submenu_item(elgg_echo('tidypics:mostcommentedtoday'), $CONFIG->url . "mod/tidypics/pages/lists/mostcommentedimagestoday.php"); + add_submenu_item(elgg_echo('tidypics:recentlycommented'), $CONFIG->wwwroot . 'pg/photos/recentlycommented/'); + } + + /** + * tidypics page handler + * + * @param array $page Array of page elements, forwarded by the page handling mechanism + */ + function tidypics_page_handler($page) { + + global $CONFIG; + + if (isset($page[0])) + { + switch($page[0]) + { + case "owned": //view list of albums owned by container + if (isset($page[1])) set_input('username',$page[1]); + include($CONFIG->pluginspath . "tidypics/pages/ownedalbums.php"); + break; + + case "view": //view an image individually + if (isset($page[1])) set_input('guid',$page[1]); + include($CONFIG->pluginspath . "tidypics/pages/viewimage.php"); + break; + + case "album": //view an album individually + if (isset($page[1])) set_input('guid',$page[1]); + include($CONFIG->pluginspath . "tidypics/pages/viewalbum.php"); + break; + + case "new": //create new album + if (isset($page[1])) set_input('username',$page[1]); + include($CONFIG->pluginspath . "tidypics/pages/newalbum.php"); + break; + + case "upload": //upload images to album + if (isset($page[1])) set_input('container_guid',$page[1]); + include($CONFIG->pluginspath . "tidypics/pages/upload.php"); + break; + + case "edit": //edit image or album + if (isset($page[1])) set_input('guid',$page[1]); + include($CONFIG->pluginspath . "tidypics/pages/edit.php"); + break; + + case "friends": // albums of friends + if (isset($page[1])) set_input('username',$page[1]); + include($CONFIG->pluginspath . "tidypics/pages/friends.php"); + break; + + case "world": // all site albums + include($CONFIG->pluginspath . "tidypics/pages/world.php"); + break; + + case "download": // download an image + if (isset($page[1])) set_input('file_guid', $page[1]); + if (isset($page[2])) set_input('type', $page[2]); + include($CONFIG->pluginspath . "tidypics/pages/download.php"); + break; + + case "tagged": // all photos tagged with user + if (isset($page[1])) set_input('guid',$page[1]); + include($CONFIG->pluginspath . "tidypics/pages/tagged.php"); + break; + + case "mostviewed": // images with the most views + if (isset($page[1])) set_input('username',$page[1]); + include($CONFIG->pluginspath . "tidypics/pages/lists/mostviewedimages.php"); + break; + + case "mostrecent": // images uploaded most recently + if (isset($page[1])) set_input('username',$page[1]); + include($CONFIG->pluginspath . "tidypics/pages/lists/mostrecentimages.php"); + break; + + case "recentlyviewed": // images most recently viewed + include($CONFIG->pluginspath . "tidypics/pages/lists/recentlyviewed.php"); + break; + + case "recentlycommented": // images with the most recent comments + include($CONFIG->pluginspath . "tidypics/pages/lists/recentlycommented.php"); + break; + + case "highestrated": // images with the highest average rating + include($CONFIG->pluginspath . "tidypics/pages/lists/highestrated.php"); + break; + + case "flickr": + if (isset($page[1])) set_input('username',$page[1]); + include($CONFIG->pluginspath . "tidypics/pages/flickr/setup.php"); + break; + } + } + else + { + // going to all site albums if something goes wrong with the page handler + include($CONFIG->pluginspath . "tidypics/pages/world.php"); + } + + } + + /** + * Override permissions for group albums and images + * + */ + function tidypics_permission_override($hook, $entity_type, $returnvalue, $params) + { + $entity = $params['entity']; + $user = $params['user']; + + if ($entity->subtype == get_subtype_id('object', 'album')) { + // test that the user can edit the container + return can_write_to_container(0, $entity->container_guid); + } + + if ($entity->subtype == get_subtype_id('object', 'image')) { + // test that the user can edit the container + return can_write_to_container(0, $entity->container_guid); + } + } + + + /** + * Notification message handler + */ + function tidypics_notify_message($hook, $entity_type, $returnvalue, $params) + { + $entity = $params['entity']; + $to_entity = $params['to_entity']; + $method = $params['method']; + if (($entity instanceof ElggEntity) && ($entity->getSubtype() == 'album')) + { + // block notification message when the album doesn't have any photos + if ($entity->new_album == TP_NEW_ALBUM) + return false; + + $descr = $entity->description; + $title = $entity->title; + $owner = $entity->getOwnerEntity(); + return sprintf(elgg_echo('album:river:created'), $owner->name) . ': ' . $title . "\n\n" . $descr . "\n\n" . $entity->getURL(); + } + return null; + } + + /** + * Populates the ->getUrl() method for file objects + * Registered in the init function + * + * @param ElggEntity $entity album/image entity + * @return string File URL + */ + function tidypics_image_url($entity) { + global $CONFIG; + $title = $entity->title; + $title = friendly_title($title); + return $CONFIG->url . "pg/photos/view/" . $entity->getGUID() . "/" . $title; + } + + function tidypics_album_url($entity) { + global $CONFIG; + $title = $entity->title; + $title = friendly_title($title); + return $CONFIG->url . "pg/photos/album/" . $entity->getGUID() . "/" . $title; + } + + + /** + * Catch the plugin hook and add the default album slideshow + * + * @param $hook - 'tidypics:slideshow' + * @param $entity_type - 'album' + * @param $returnvalue - if set, return because another plugin has used the hook + * @param $params - album entity + * @return unknown_type + */ + function tidypics_slideshow($hook, $entity_type, $returnvalue, $params) { + + if ($returnvalue !== null) { + // someone has already added a slideshow or requested that the slideshow is not used + return $returnvalue; + } + + $slideshow_link = 'javascript:PicLensLite.start({maxScale:0,feedUrl:PicLensLite.indexFeeds()[0].url})'; + + // add the slideshow javascript to the header + extend_view('metatags', 'js/slideshow'); + + return $slideshow_link; + } + + function tp_mostrecentimages($max = 8, $pagination = true) { + return list_entities("object", "image", 0, $max, false, false, $pagination); + } + + + // Make sure tidypics_init is called on initialisation + register_elgg_event_handler('init','system','tidypics_init'); + register_elgg_event_handler('pagesetup','system','tidypics_submenus'); + register_elgg_event_handler('pagesetup','system','tidypics_adminmenu'); + + // Register actions + register_action("tidypics/settings", false, $CONFIG->pluginspath . "tidypics/actions/settings.php"); + register_action("tidypics/upload", false, $CONFIG->pluginspath . "tidypics/actions/upload.php"); + register_action("tidypics/addalbum", false, $CONFIG->pluginspath. "tidypics/actions/addalbum.php"); + register_action("tidypics/edit", false, $CONFIG->pluginspath. "tidypics/actions/edit.php"); + register_action("tidypics/delete", false, $CONFIG->pluginspath. "tidypics/actions/delete.php"); + register_action("tidypics/edit_multi", false, $CONFIG->pluginspath. "tidypics/actions/edit_multi.php"); + register_action("tidypics/addtag", true, $CONFIG->pluginspath . "tidypics/actions/addtag.php"); + register_action("tidypics/deletetag", true, $CONFIG->pluginspath . "tidypics/actions/deletetag.php"); + register_action("tidypics/flickrSetup", true, $CONFIG->pluginspath . "tidypics/actions/flickrSetup.php"); + ?> \ No newline at end of file diff --git a/thumbnail.php b/thumbnail.php index f310aee95..79d487210 100644 --- a/thumbnail.php +++ b/thumbnail.php @@ -1,78 +1,78 @@ -getSubtype() != "image") - forward('mod/tidypics/graphics/' . $error_image); - - // Get filename - if ($size == "thumb") { - $thumbfile = $file->thumbnail; - } else if ($size == "small") { - $thumbfile = $file->smallthumb; - } else { - $thumbfile = $file->largethumb; - } - - if (!$thumbfile) - forward('mod/tidypics/graphics/' . $error_image); - - // create Elgg File object - $readfile = new ElggFile(); - $readfile->owner_guid = $file->owner_guid; - $readfile->setFilename($thumbfile); - $contents = $readfile->grabFile(); - - // send error image if file could not be read - if (!$contents) { - forward('mod/tidypics/graphics/' . $error_image); - } - - // expires every 14 days - $expires = 14 * 60*60*24; - - // overwrite header caused by php session code so images can be cached - $mime = $file->getMimeType(); - header("Content-Type: $mime"); - header("Content-Length: " . strlen($contents)); - header("Cache-Control: public", true); - header("Pragma: public", true); - header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT', true); - - // Return the thumbnail and exit - echo $contents; - exit; -?> +getSubtype() != "image") + forward('mod/tidypics/graphics/' . $error_image); + + // Get filename + if ($size == "thumb") { + $thumbfile = $file->thumbnail; + } else if ($size == "small") { + $thumbfile = $file->smallthumb; + } else { + $thumbfile = $file->largethumb; + } + + if (!$thumbfile) + forward('mod/tidypics/graphics/' . $error_image); + + // create Elgg File object + $readfile = new ElggFile(); + $readfile->owner_guid = $file->owner_guid; + $readfile->setFilename($thumbfile); + $contents = $readfile->grabFile(); + + // send error image if file could not be read + if (!$contents) { + forward('mod/tidypics/graphics/' . $error_image); + } + + // expires every 14 days + $expires = 14 * 60*60*24; + + // overwrite header caused by php session code so images can be cached + $mime = $file->getMimeType(); + header("Content-Type: $mime"); + header("Content-Length: " . strlen($contents)); + header("Cache-Control: public", true); + header("Pragma: public", true); + header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT', true); + + // Return the thumbnail and exit + echo $contents; + exit; +?> diff --git a/views/default/annotation/annotate.php b/views/default/annotation/annotate.php index c0fb05d3a..8156a4bb4 100644 --- a/views/default/annotation/annotate.php +++ b/views/default/annotation/annotate.php @@ -1,21 +1,21 @@ -subject_guid); - $object = get_entity($vars['item']->object_guid); - $url = $object->getURL(); - $subtype = get_subtype_from_id($object->subtype); - $title = $object->title; - if (!$title) - $title = elgg_echo('untitled'); - - $url = "getURL()}\">{$performed_by->name}"; - $string = sprintf(elgg_echo("river:posted:generic"),$url) . " "; - $string .= elgg_echo("{$subtype}:river:annotate") . " getURL() . "\">" . $title . ""; - -?> - +subject_guid); + $object = get_entity($vars['item']->object_guid); + $url = $object->getURL(); + $subtype = get_subtype_from_id($object->subtype); + $title = $object->title; + if (!$title) + $title = elgg_echo('untitled'); + + $url = "getURL()}\">{$performed_by->name}"; + $string = sprintf(elgg_echo("river:posted:generic"),$url) . " "; + $string .= elgg_echo("{$subtype}:river:annotate") . " getURL() . "\">" . $title . ""; + +?> + \ No newline at end of file diff --git a/views/default/js/tagging.php b/views/default/js/tagging.php index bd6890502..d8abda24c 100644 --- a/views/default/js/tagging.php +++ b/views/default/js/tagging.php @@ -1,303 +1,303 @@ - - - - - + + + \ No newline at end of file diff --git a/views/default/river/object/album/create.php b/views/default/river/object/album/create.php index a9b261566..20f9293d7 100644 --- a/views/default/river/object/album/create.php +++ b/views/default/river/object/album/create.php @@ -1,42 +1,42 @@ -subject_guid); - $album = get_entity($vars['item']->object_guid); - - $group_album = ($album->owner_guid != $album->container_guid); - if ($group_album) { - $group = get_entity($album->container_guid); - $group_name = $group->name; - $group_link = $group->getURL(); - } - - $url = "getURL()}\">{$performed_by->name}"; - $string = sprintf(elgg_echo("album:river:created"),$url) . " "; - $string .= "getURL() . "\">" . $album->title . ""; - if ($group_album) - $string .= ' ' . elgg_echo('album:river:group') . ' ' . "{$group_name}"; - - $album_river_view = get_plugin_setting('album_river_view', 'tidypics'); - - if ($album_river_view == "cover") { - if ($album->cover) { - $string .= "
wwwroot . 'mod/tidypics/thumbnail.php?file_guid=' . $album->cover . '&size=thumb" class="tidypics_album_cover" alt="thumbnail"/>' . "
"; - } - } else { - - $string .= "
"; - - $images = get_entities("object", "image", $album->guid, 'time_created desc', 7); - - if (count($images)) { - foreach($images as $image){ - $string .= "getURL() . "\"> wwwroot . 'mod/tidypics/thumbnail.php?file_guid=' . $image->guid . '&size=thumb" class="tidypics_album_cover" alt="thumbnail"/> '; - } - } - - $string .= "
"; - } - -echo $string; - -?> +subject_guid); + $album = get_entity($vars['item']->object_guid); + + $group_album = ($album->owner_guid != $album->container_guid); + if ($group_album) { + $group = get_entity($album->container_guid); + $group_name = $group->name; + $group_link = $group->getURL(); + } + + $url = "getURL()}\">{$performed_by->name}"; + $string = sprintf(elgg_echo("album:river:created"),$url) . " "; + $string .= "getURL() . "\">" . $album->title . ""; + if ($group_album) + $string .= ' ' . elgg_echo('album:river:group') . ' ' . "{$group_name}"; + + $album_river_view = get_plugin_setting('album_river_view', 'tidypics'); + + if ($album_river_view == "cover") { + if ($album->cover) { + $string .= "
wwwroot . 'mod/tidypics/thumbnail.php?file_guid=' . $album->cover . '&size=thumb" class="tidypics_album_cover" alt="thumbnail"/>' . "
"; + } + } else { + + $string .= "
"; + + $images = get_entities("object", "image", $album->guid, 'time_created desc', 7); + + if (count($images)) { + foreach($images as $image){ + $string .= "getURL() . "\"> wwwroot . 'mod/tidypics/thumbnail.php?file_guid=' . $image->guid . '&size=thumb" class="tidypics_album_cover" alt="thumbnail"/> '; + } + } + + $string .= "
"; + } + +echo $string; + +?> diff --git a/views/default/river/object/image/create.php b/views/default/river/object/image/create.php index 5229e109a..2f1777f64 100644 --- a/views/default/river/object/image/create.php +++ b/views/default/river/object/image/create.php @@ -1,29 +1,29 @@ -subject_guid); - $image = get_entity($vars['item']->object_guid); - if($image->title) { - $title = $image->title; - } else { - $title = "untitled"; - } - - $url = "getURL()}\">{$performed_by->name}"; - $album = get_entity($image->container_guid); - - $album_link = "" . $album->title . ""; - $image_link = "getURL() . "\">" . $title . ""; - - $string = sprintf(elgg_echo("image:river:created"),$performed_by->name, $image_link, $album_link); - - $string .= "
"; - -/* // this adds the album cover to the river display - $string .= "getURL() . "\"> wwwroot . 'mod/tidypics/thumbnail.php?file_guid=' . $album->cover . '&size=thumb" class="tidypics_album_cover" alt="thumbnail"/> '; -*/ - $string .= "getURL() . "\"> wwwroot . 'mod/tidypics/thumbnail.php?file_guid=' . $image->guid . '&size=thumb" class="tidypics_album_cover" alt="thumbnail"/> '; - $string .= "
"; - - echo $string; - +subject_guid); + $image = get_entity($vars['item']->object_guid); + if($image->title) { + $title = $image->title; + } else { + $title = "untitled"; + } + + $url = "getURL()}\">{$performed_by->name}"; + $album = get_entity($image->container_guid); + + $album_link = "" . $album->title . ""; + $image_link = "getURL() . "\">" . $title . ""; + + $string = sprintf(elgg_echo("image:river:created"),$performed_by->name, $image_link, $album_link); + + $string .= "
"; + +/* // this adds the album cover to the river display + $string .= "getURL() . "\"> wwwroot . 'mod/tidypics/thumbnail.php?file_guid=' . $album->cover . '&size=thumb" class="tidypics_album_cover" alt="thumbnail"/> '; +*/ + $string .= "getURL() . "\"> wwwroot . 'mod/tidypics/thumbnail.php?file_guid=' . $image->guid . '&size=thumb" class="tidypics_album_cover" alt="thumbnail"/> '; + $string .= "
"; + + echo $string; + ?> \ No newline at end of file diff --git a/views/default/river/object/image/tag.php b/views/default/river/object/image/tag.php index 6e60d5af3..1b3589afb 100644 --- a/views/default/river/object/image/tag.php +++ b/views/default/river/object/image/tag.php @@ -1,23 +1,23 @@ -subject_guid); - $person_tagged = get_entity($vars['item']->object_guid); - if($image->title) { - $title = $image->title; - } else { - $title = "untitled"; - } - - // viewer may not have permission to view image - if (!$image) - return; - - - $image_url = "getURL()}\">{$title}"; - $person_url = "getURL()}\">{$person_tagged->name}"; - - $string = $person_url . ' ' . elgg_echo('image:river:tagged') . ' ' . $image_url; - - echo $string; - +subject_guid); + $person_tagged = get_entity($vars['item']->object_guid); + if($image->title) { + $title = $image->title; + } else { + $title = "untitled"; + } + + // viewer may not have permission to view image + if (!$image) + return; + + + $image_url = "getURL()}\">{$title}"; + $person_url = "getURL()}\">{$person_tagged->name}"; + + $string = $person_url . ' ' . elgg_echo('image:river:tagged') . ' ' . $image_url; + + echo $string; + ?> \ No newline at end of file diff --git a/views/default/tidypics/admin/help.php b/views/default/tidypics/admin/help.php index 4014be9ce..7f871598c 100644 --- a/views/default/tidypics/admin/help.php +++ b/views/default/tidypics/admin/help.php @@ -1,25 +1,25 @@ -
-

White screen when uploading images

-

-Tidypics tries to calculate the maximum size of an image that your server will support. If it -guesses incorrectly and someone uploads a photo that is too large, the script may crash when -resizing the image if you are using GD. The easiest way to test this is to set display_errors -to 1 in your .htaccess file and upload large images. If this causes a problem, a php memory error -should display on the screen. You can increased your php memory limit (see the docs directory). -A better option is to use ImageMagick if your server supports it (again see the docs directory). -

-If it is not a memory issue, you should see some other error appear. Once you have fixed the error, -change display_error back to 0. -

-

Question mark images appear

-

-If you see question mark images when you look at your albums, this means the resizing of the images -failed. This could be due to the memory limits as described above. There are other causes. Tidypics -tries to detect these problems and write the cause to the error log. You should check your server -error log right after an upload that results in a question mark for these error messages. The messages -will begin with "Tidypics warning:". It is possible if you have turned off php warnings that you will -not see these warnings. -

-Another possible cause is using ImageMagick when your server does not support it or specifying -the wrong path to the ImageMagick executables. +
+

White screen when uploading images

+

+Tidypics tries to calculate the maximum size of an image that your server will support. If it +guesses incorrectly and someone uploads a photo that is too large, the script may crash when +resizing the image if you are using GD. The easiest way to test this is to set display_errors +to 1 in your .htaccess file and upload large images. If this causes a problem, a php memory error +should display on the screen. You can increased your php memory limit (see the docs directory). +A better option is to use ImageMagick if your server supports it (again see the docs directory). +

+If it is not a memory issue, you should see some other error appear. Once you have fixed the error, +change display_error back to 0. +

+

Question mark images appear

+

+If you see question mark images when you look at your albums, this means the resizing of the images +failed. This could be due to the memory limits as described above. There are other causes. Tidypics +tries to detect these problems and write the cause to the error log. You should check your server +error log right after an upload that results in a question mark for these error messages. The messages +will begin with "Tidypics warning:". It is possible if you have turned off php warnings that you will +not see these warnings. +

+Another possible cause is using ImageMagick when your server does not support it or specifying +the wrong path to the ImageMagick executables.

\ No newline at end of file diff --git a/views/default/tidypics/admin/imagelib.php b/views/default/tidypics/admin/imagelib.php index deb32d0f3..b4656afe1 100644 --- a/views/default/tidypics/admin/imagelib.php +++ b/views/default/tidypics/admin/imagelib.php @@ -1,62 +1,62 @@ -dbprefix}entities where subtype={$img_type}"; - $total = get_data_row($query); - $num_images = $total->total; - - $img_type = get_subtype_id('object', 'album'); - $query = "SELECT count(guid) as total from {$CONFIG->dbprefix}entities where subtype={$img_type}"; - $total = get_data_row($query); - $num_albums = $total->total; - - $num_comments_photos = count_annotations(0, 'object', 'image', 'generic_comment'); - $num_comments_albums = count_annotations(0, 'object', 'album', 'generic_comment'); - - $num_views = count_annotations(0, 'object', 'image', 'tp_view'); - - if (get_plugin_setting('tagging', 'tidypics') != "disabled") - $num_tags = count_annotations(0, 'object', 'image', 'phototag'); -?> -
-

Overview

-

-An image library is required by Tidypics to perform various manipulations: resizing on upload, watermarking, rotation, and cropping. -There are three image library options with Tidypics: PHP extension GD, -ImageMagick called via a system call, and the PHP extension -imagick. GD is the most common of the three on hosted servers but suffers -from serious memory usage problems when resizing photos. If you have access to ImageMagick (whether through system calls or the -PHP extension), we recommend that you use that. -

-

Testing ImageMagick Commandline

-

-To use the ImageMagick executables, PHP must be configured to allow calls to exec(). You can check our -server analysis page to find out the -configuration of your server. Next, you need to determine the path to ImageMagick on your server. Your hosting service should -be able to provide this to you. You can test if the location is correct below. If successful, it should display the version of -ImageMagick installed on your server. -

-
-

-
- - -

-
- - \ No newline at end of file diff --git a/views/default/tidypics/admin/settings.php b/views/default/tidypics/admin/settings.php index 1b449cfc7..ff7d330e2 100644 --- a/views/default/tidypics/admin/settings.php +++ b/views/default/tidypics/admin/settings.php @@ -1,25 +1,25 @@ - elgg_echo("tidypics:admin:instructions"))); - - global $CONFIG; - $system_url = $CONFIG->wwwroot . 'mod/tidypics/pages/server_analysis.php'; - $upgrade_url = $CONFIG->wwwroot . 'mod/tidypics/actions/upgrade.php'; - - $upgrade = false; - if (!get_subtype_class('object', 'image') || !get_subtype_class('object', 'album')) - $upgrade = true; -?> -

- -Upgrade
- -Run Server Analysis -

- elgg_echo("tidypics:admin:instructions"))); + + global $CONFIG; + $system_url = $CONFIG->wwwroot . 'mod/tidypics/pages/server_analysis.php'; + $upgrade_url = $CONFIG->wwwroot . 'mod/tidypics/actions/upgrade.php'; + + $upgrade = false; + if (!get_subtype_class('object', 'image') || !get_subtype_class('object', 'album')) + $upgrade = true; +?> +

+ +Upgrade
+ +Run Server Analysis +

+ \ No newline at end of file diff --git a/views/default/tidypics/admin/stats.php b/views/default/tidypics/admin/stats.php index 8de3415a1..aea5e75ba 100644 --- a/views/default/tidypics/admin/stats.php +++ b/views/default/tidypics/admin/stats.php @@ -1,35 +1,35 @@ -dbprefix}entities where subtype={$img_type}"; - $total = get_data_row($query); - $num_images = $total->total; - - $img_type = get_subtype_id('object', 'album'); - $query = "SELECT count(guid) as total from {$CONFIG->dbprefix}entities where subtype={$img_type}"; - $total = get_data_row($query); - $num_albums = $total->total; - - $num_comments_photos = count_annotations(0, 'object', 'image', 'generic_comment'); - $num_comments_albums = count_annotations(0, 'object', 'album', 'generic_comment'); - - $num_views = count_annotations(0, 'object', 'image', 'tp_view'); - - if (get_plugin_setting('tagging', 'tidypics') != "disabled") - $num_tags = count_annotations(0, 'object', 'image', 'phototag'); -?> -

-
-Photos:
-Albums:
-Comments on photos:
-Comments on albums:
-Total views:
- -Photo tags:
- +dbprefix}entities where subtype={$img_type}"; + $total = get_data_row($query); + $num_images = $total->total; + + $img_type = get_subtype_id('object', 'album'); + $query = "SELECT count(guid) as total from {$CONFIG->dbprefix}entities where subtype={$img_type}"; + $total = get_data_row($query); + $num_albums = $total->total; + + $num_comments_photos = count_annotations(0, 'object', 'image', 'generic_comment'); + $num_comments_albums = count_annotations(0, 'object', 'album', 'generic_comment'); + + $num_views = count_annotations(0, 'object', 'image', 'tp_view'); + + if (get_plugin_setting('tagging', 'tidypics') != "disabled") + $num_tags = count_annotations(0, 'object', 'image', 'phototag'); +?> +

+
+Photos:
+Albums:
+Comments on photos:
+Comments on albums:
+Total views:
+ +Photo tags:
+

\ No newline at end of file diff --git a/views/default/tidypics/admin/thumbnails.php b/views/default/tidypics/admin/thumbnails.php index 0af59090e..ccd884005 100644 --- a/views/default/tidypics/admin/thumbnails.php +++ b/views/default/tidypics/admin/thumbnails.php @@ -1,33 +1,33 @@ -
-

Overview

-

-This page allows you to create thumbnails for images when the thumbnail creation failed during upload. -You may experience problems with thumbnail creation if your image library in not configured properly or -if there is not enough memory for the GD library to load and resize an image. If your users have -experienced problems with thumbnail creation and you have modified your setup, you can try to redo the -thumbnails. Find the unique identifier of the photo (it is the number near the end of the url when viewing -a photo) and enter it below. -

-

Thumbnail Creation

-

-: - - -

-
- \ No newline at end of file diff --git a/views/default/tidypics/albums.php b/views/default/tidypics/albums.php index 9c75bf024..42ac15afe 100644 --- a/views/default/tidypics/albums.php +++ b/views/default/tidypics/albums.php @@ -1,51 +1,51 @@ -'; - - if ($owner_albums) { - foreach($owner_albums as $album) { - - if($album->cover) - $album_cover = '' . $album->title . ''; - else - $album_cover = '' . $album->title . ''; -?> -
- -
time_created);?>
-getURL()}\">" . sprintf(elgg_echo("comments")) . " (" . $numcomments . ")
"; -?> - -
-username) || empty($owner->username)) { - echo '

' . elgg_echo('album:all') . '

'; - } else { - echo '

' . elgg_echo('album:more') . '

'; - } - - } - - if (can_write_to_container(0, $owner->guid)) { - echo '

username . '>' . elgg_echo("album:create") . '

'; - } - - - //close album_widget_container div - echo ""; +'; + + if ($owner_albums) { + foreach($owner_albums as $album) { + + if($album->cover) + $album_cover = '' . $album->title . ''; + else + $album_cover = '' . $album->title . ''; +?> +
+ +
time_created);?>
+getURL()}\">" . sprintf(elgg_echo("comments")) . " (" . $numcomments . ")
"; +?> + +
+username) || empty($owner->username)) { + echo '

' . elgg_echo('album:all') . '

'; + } else { + echo '

' . elgg_echo('album:more') . '

'; + } + + } + + if (can_write_to_container(0, $owner->guid)) { + echo '

username . '>' . elgg_echo("album:create") . '

'; + } + + + //close album_widget_container div + echo ""; ?> \ No newline at end of file diff --git a/views/default/tidypics/breadcrumbs.php b/views/default/tidypics/breadcrumbs.php index 1a96e921c..c4d347e6e 100644 --- a/views/default/tidypics/breadcrumbs.php +++ b/views/default/tidypics/breadcrumbs.php @@ -1,22 +1,22 @@ -wwwroot . "pg/photos/owned/" . $page_owner->username; - if (get_loggedin_userid() == $page_owner->guid) - $first_level_text = elgg_echo('album:yours'); - else - $first_level_text = sprintf(elgg_echo('album:user'), $page_owner->name); -?> - -title; - $second_level_link = $vars['album']->getURL(); -?> ->> - +wwwroot . "pg/photos/owned/" . $page_owner->username; + if (get_loggedin_userid() == $page_owner->guid) + $first_level_text = elgg_echo('album:yours'); + else + $first_level_text = sprintf(elgg_echo('album:user'), $page_owner->name); +?> + +title; + $second_level_link = $vars['album']->getURL(); +?> +>> + diff --git a/views/default/tidypics/exif.php b/views/default/tidypics/exif.php index 525665754..0100ac575 100644 --- a/views/default/tidypics/exif.php +++ b/views/default/tidypics/exif.php @@ -1,14 +1,14 @@ -'; - foreach ($exif as $name => $value) { - echo $name . ': ' . $value . '
'; - } - echo ''; - } - +'; + foreach ($exif as $name => $value) { + echo $name . ': ' . $value . '
'; + } + echo ''; + } + ?> \ No newline at end of file diff --git a/views/default/tidypics/forms/edit.php b/views/default/tidypics/forms/edit.php index cec1945f0..342ac8822 100644 --- a/views/default/tidypics/forms/edit.php +++ b/views/default/tidypics/forms/edit.php @@ -1,118 +1,118 @@ -title; - $body = $vars['entity']->description; - $tags = $vars['entity']->tags; - $access_id = $vars['entity']->access_id; - $subtype = $vars['subtype']; - - // if nothing is sent, create new, but only new albums are sent here - // new images are sent to upload.php - } else { - $action = "tidypics/addalbum"; - $tags = ""; - $title = ""; - $body = ""; - if (defined('ACCESS_DEFAULT')) - $access_id = ACCESS_DEFAULT; - else - $access_id = 1; // logged_in by default - $subtype = 'album'; - - $title = $_SESSION['tidypicstitle']; - $body = $_SESSION['tidypicsbody']; - $tags = $_SESSION['tidypicstags']; - - unset($_SESSION['tidypicstitle']); - unset($_SESSION['tidypicsbody']); - unset($_SESSION['tidypicstags']); - } - - // group or individual - $container_guid = page_owner(); - -?> -
-
-

- - "tidypicstitle", "value" => $title,)); ?> -

- -

- - "tidypicsbody","value" => $body,)); ?> -

- -

- - "tidypicsbody","value" => $body,"class" => 'tidypics_caption_input')); ?> -

- -

- - "tidypicstags","value" => $tags,)); ?> -

- -container_guid; - - // should this image be the cover for the album - only ask for non-cover photos - // determine if it is already the cover - $img_guid = $vars['entity']->guid; - $album = get_entity($container_guid); - $cover_guid = $album->cover; - - if ($cover_guid != $img_guid) { - -?> -

- "cover", - 'options' => array(elgg_echo("album:cover")), - )); -?> -

- -

- - 'access_id','value' => $access_id)); ?> -

- - - - - - -

-
+title; + $body = $vars['entity']->description; + $tags = $vars['entity']->tags; + $access_id = $vars['entity']->access_id; + $subtype = $vars['subtype']; + + // if nothing is sent, create new, but only new albums are sent here + // new images are sent to upload.php + } else { + $action = "tidypics/addalbum"; + $tags = ""; + $title = ""; + $body = ""; + if (defined('ACCESS_DEFAULT')) + $access_id = ACCESS_DEFAULT; + else + $access_id = 1; // logged_in by default + $subtype = 'album'; + + $title = $_SESSION['tidypicstitle']; + $body = $_SESSION['tidypicsbody']; + $tags = $_SESSION['tidypicstags']; + + unset($_SESSION['tidypicstitle']); + unset($_SESSION['tidypicsbody']); + unset($_SESSION['tidypicstags']); + } + + // group or individual + $container_guid = page_owner(); + +?> +
+
+

+ + "tidypicstitle", "value" => $title,)); ?> +

+ +

+ + "tidypicsbody","value" => $body,)); ?> +

+ +

+ + "tidypicsbody","value" => $body,"class" => 'tidypics_caption_input')); ?> +

+ +

+ + "tidypicstags","value" => $tags,)); ?> +

+ +container_guid; + + // should this image be the cover for the album - only ask for non-cover photos + // determine if it is already the cover + $img_guid = $vars['entity']->guid; + $album = get_entity($container_guid); + $cover_guid = $album->cover; + + if ($cover_guid != $img_guid) { + +?> +

+ "cover", + 'options' => array(elgg_echo("album:cover")), + )); +?> +

+ +

+ + 'access_id','value' => $access_id)); ?> +

+ + + + + + +

+
\ No newline at end of file diff --git a/views/default/tidypics/forms/edit_multi.php b/views/default/tidypics/forms/edit_multi.php index 4c4a111f5..4031b7968 100644 --- a/views/default/tidypics/forms/edit_multi.php +++ b/views/default/tidypics/forms/edit_multi.php @@ -1,58 +1,58 @@ - -
-
-cover) $no_cover = true; - - foreach ($file_array as $key => $file_guid){ - $entity = get_entity($file_guid); - $guid = $entity->guid; - $body = $entity->description; - $title = $entity->title; - $tags = $entity->tags; - $container_guid = $entity->container_guid; - - // first one is default cover if there isn't one already - if ($no_cover) { - $val = $guid; - $no_cover = false; - } - - echo '
'; - echo '' . $title . ''; - echo '
'; - echo '

'; - echo elgg_view("input/text", array("internalname" => "title[$key]", "value" => $title,)) . "\n"; - echo '

'; - echo '

"; - echo elgg_view("input/longtext",array("internalname" => "caption[$key]", "value" => $body, "class" => 'tidypics_caption_input',)) . "\n"; - echo "

"; - echo '

\n"; - echo elgg_view("input/tags", array( "internalname" => "tags[$key]","value" => $tags)) . "\n"; - echo '

'; - echo '' . "\n"; - echo elgg_view('input/securitytoken'); - - echo elgg_view("input/radio", array("internalname" => "cover", - "value" => $val, - 'options' => array( elgg_echo('album:cover') => $guid, - ), - )); - echo '
'; - echo '
'; - } - -?> - -

-
+ +
+
+cover) $no_cover = true; + + foreach ($file_array as $key => $file_guid){ + $entity = get_entity($file_guid); + $guid = $entity->guid; + $body = $entity->description; + $title = $entity->title; + $tags = $entity->tags; + $container_guid = $entity->container_guid; + + // first one is default cover if there isn't one already + if ($no_cover) { + $val = $guid; + $no_cover = false; + } + + echo '
'; + echo '' . $title . ''; + echo '
'; + echo '

'; + echo elgg_view("input/text", array("internalname" => "title[$key]", "value" => $title,)) . "\n"; + echo '

'; + echo '

"; + echo elgg_view("input/longtext",array("internalname" => "caption[$key]", "value" => $body, "class" => 'tidypics_caption_input',)) . "\n"; + echo "

"; + echo '

\n"; + echo elgg_view("input/tags", array( "internalname" => "tags[$key]","value" => $tags)) . "\n"; + echo '

'; + echo '' . "\n"; + echo elgg_view('input/securitytoken'); + + echo elgg_view("input/radio", array("internalname" => "cover", + "value" => $val, + 'options' => array( elgg_echo('album:cover') => $guid, + ), + )); + echo '
'; + echo '
'; + } + +?> + +

+
\ No newline at end of file diff --git a/views/default/tidypics/forms/settings.php b/views/default/tidypics/forms/settings.php index 6ab9dfcc9..6cfed661f 100644 --- a/views/default/tidypics/forms/settings.php +++ b/views/default/tidypics/forms/settings.php @@ -1,145 +1,145 @@ -version) { - set_plugin_setting('version', 1.62, 'tidypics'); - } - - if (extension_loaded('imagick')) - $img_lib_options['ImageMagickPHP'] = 'imagick PHP extension'; - - $disablefunc = explode(',', ini_get('disable_functions')); - if (is_callable('exec') && !in_array('exec',$disablefunc)) - $img_lib_options['ImageMagick'] = 'ImageMagick Cmdline'; - - $img_lib_options['GD'] = 'GD'; - - - // Image Library - $image_lib = $plugin->image_lib; - if (!$image_lib) $image_lib = 'GD'; - $form_body = '

' . elgg_echo('tidypics:settings:image_lib') . ': '; - $form_body .= elgg_view('input/pulldown', array( - 'internalname' => 'params[image_lib]', - 'options_values' => $img_lib_options, - 'value' => $image_lib - )); - $form_body .= '
Note: If you want to select ImageMagick Command Line, first confirm that it is installed on your server.

'; - - if (is_callable('exec') && !in_array('exec',$disablefunc)) { - // Image Magick Path - $im_path = $plugin->im_path; - if(!$im_path) $im_path = "/usr/bin/"; - $form_body .= "

" . elgg_echo('tidypics:settings:im_path') . "
"; - $form_body .= elgg_view("input/text",array('internalname' => 'params[im_path]', 'value' => $im_path)) . "

"; - } - - // Tagging - $tagging = $plugin->tagging; - if(!$tagging) $tagging = "enabled"; - $form_body .= '

' . elgg_view("input/checkboxes", array('options' => array(elgg_echo('tidypics:settings:tagging') => 'enabled'), 'internalname' => 'tagging', 'value' => $tagging )) . "

"; - - // Download Link - $download_link = $plugin->download_link; - if(!$download_link) $download_link = "enabled"; - $form_body .= '

' . elgg_view("input/checkboxes", array('options' => array(elgg_echo('tidypics:settings:download_link') => 'enabled'), 'internalname' => 'download_link', 'value' => $download_link )) . "

"; - - // Ratings - $photo_ratings = $plugin->photo_ratings; - if(!$photo_ratings) $photo_ratings = "disabled"; - $form_body .= '

' . elgg_view("input/checkboxes", array('options' => array(elgg_echo('tidypics:settings:photo_ratings') => 'enabled'), 'internalname' => 'photo_ratings', 'value' => $photo_ratings )) . "

"; - - // Show EXIF - $exif = $plugin->exif; - if(!$exif) $exif = "disabled"; - $form_body .= '

' . elgg_view("input/checkboxes", array('options' => array(elgg_echo('tidypics:settings:exif') => 'enabled'), 'internalname' => 'exif', 'value' => $exif )) . "

"; - - // Show View count - $view_count = $plugin->view_count; - if(!$view_count) $view_count = "enabled"; - $form_body .= '

' . elgg_view("input/checkboxes", array('options' => array(elgg_echo('tidypics:settings:view_count') => 'enabled'), 'internalname' => 'view_count', 'value' => $view_count )) . "

"; - - // Watermark Text - $form_body .= "

" . elgg_echo('tidypics:settings:watermark') . "
"; - $form_body .= elgg_view("input/text",array('internalname' => 'params[watermark_text]', 'value' => $plugin->watermark_text)) . "

"; - - // Max Image Size - $maxfilesize = $plugin->maxfilesize; - if (!$maxfilesize) $maxfilesize = (int)5; // 5 MB - $form_body .= "

" . elgg_echo('tidypics:settings:maxfilesize') . "
"; - $form_body .= elgg_view("input/text",array('internalname' => 'params[maxfilesize]', 'value' => $maxfilesize)) . "

"; - - // Quota Size - $quota = $plugin->quota; - if (!$quota) $quota = 0; - $form_body .= "

" . elgg_echo('tidypics:settings:quota') . "
"; - $form_body .= elgg_view("input/text",array('internalname' => 'params[quota]', 'value' => $quota)) . "

"; - - // River Image options - $img_river_view = $plugin->img_river_view; - if (!$img_river_view) $img_river_view = '1'; - $form_body .= '

' . elgg_echo('tidypics:settings:img_river_view'); - $form_body .= elgg_view('input/pulldown', array( - 'internalname' => 'params[img_river_view]', - 'options_values' => array( - 'all' => 'all', - '1' => '1', - 'none' => 'none', - ), - 'value' => $img_river_view - )); - $form_body .= '

'; - - // River Album options - $album_river_view = $plugin->album_river_view; - if (!$album_river_view) $album_river_view = 'set'; - $form_body .= '

' . elgg_echo('tidypics:settings:album_river_view'); - $form_body .= elgg_view('input/pulldown', array( - 'internalname' => 'params[album_river_view]', - 'options_values' => array( - 'cover' => 'cover', - 'set' => 'set', - ), - 'value' => $album_river_view - )); - $form_body .= '

'; - - // Thumbnail sizes - $image_sizes = $plugin->image_sizes; - if(!$image_sizes) { - $image_sizes = array(); // set default values - $image_sizes['large_image_width'] = $image_sizes['large_image_height'] = 600; - $image_sizes['small_image_width'] = $image_sizes['small_image_height'] = 153; - $image_sizes['thumb_image_width'] = $image_sizes['thumb_image_height'] = 60; - } else { - $image_sizes = unserialize($image_sizes); - } - $form_body .= "

" . elgg_echo('tidypics:settings:largesize') . "
"; - $form_body .= 'width:    '; - $form_body .= 'height:

'; - $form_body .= "

" . elgg_echo('tidypics:settings:smallsize') . "
"; - $form_body .= 'width:    '; - $form_body .= 'height:

'; - $form_body .= "

" . elgg_echo('tidypics:settings:thumbsize') . "
"; - $form_body .= 'width:    '; - $form_body .= 'height:

'; - - - // Group permission override - $grp_perm_override = $plugin->grp_perm_override; - if(!$grp_perm_override) $grp_perm_override = "enabled"; - $form_body .= '

' . elgg_view("input/checkboxes", array('options' => array(elgg_echo('tidypics:settings:grp_perm_override') => 'enabled'), 'internalname' => 'grp_perm_override', 'value' => $grp_perm_override )) . "

"; - - $form_body .= elgg_view('input/submit', array('value' => elgg_echo("save"))); - +version) { + set_plugin_setting('version', 1.62, 'tidypics'); + } + + if (extension_loaded('imagick')) + $img_lib_options['ImageMagickPHP'] = 'imagick PHP extension'; + + $disablefunc = explode(',', ini_get('disable_functions')); + if (is_callable('exec') && !in_array('exec',$disablefunc)) + $img_lib_options['ImageMagick'] = 'ImageMagick Cmdline'; + + $img_lib_options['GD'] = 'GD'; + + + // Image Library + $image_lib = $plugin->image_lib; + if (!$image_lib) $image_lib = 'GD'; + $form_body = '

' . elgg_echo('tidypics:settings:image_lib') . ': '; + $form_body .= elgg_view('input/pulldown', array( + 'internalname' => 'params[image_lib]', + 'options_values' => $img_lib_options, + 'value' => $image_lib + )); + $form_body .= '
Note: If you want to select ImageMagick Command Line, first confirm that it is installed on your server.

'; + + if (is_callable('exec') && !in_array('exec',$disablefunc)) { + // Image Magick Path + $im_path = $plugin->im_path; + if(!$im_path) $im_path = "/usr/bin/"; + $form_body .= "

" . elgg_echo('tidypics:settings:im_path') . "
"; + $form_body .= elgg_view("input/text",array('internalname' => 'params[im_path]', 'value' => $im_path)) . "

"; + } + + // Tagging + $tagging = $plugin->tagging; + if(!$tagging) $tagging = "enabled"; + $form_body .= '

' . elgg_view("input/checkboxes", array('options' => array(elgg_echo('tidypics:settings:tagging') => 'enabled'), 'internalname' => 'tagging', 'value' => $tagging )) . "

"; + + // Download Link + $download_link = $plugin->download_link; + if(!$download_link) $download_link = "enabled"; + $form_body .= '

' . elgg_view("input/checkboxes", array('options' => array(elgg_echo('tidypics:settings:download_link') => 'enabled'), 'internalname' => 'download_link', 'value' => $download_link )) . "

"; + + // Ratings + $photo_ratings = $plugin->photo_ratings; + if(!$photo_ratings) $photo_ratings = "disabled"; + $form_body .= '

' . elgg_view("input/checkboxes", array('options' => array(elgg_echo('tidypics:settings:photo_ratings') => 'enabled'), 'internalname' => 'photo_ratings', 'value' => $photo_ratings )) . "

"; + + // Show EXIF + $exif = $plugin->exif; + if(!$exif) $exif = "disabled"; + $form_body .= '

' . elgg_view("input/checkboxes", array('options' => array(elgg_echo('tidypics:settings:exif') => 'enabled'), 'internalname' => 'exif', 'value' => $exif )) . "

"; + + // Show View count + $view_count = $plugin->view_count; + if(!$view_count) $view_count = "enabled"; + $form_body .= '

' . elgg_view("input/checkboxes", array('options' => array(elgg_echo('tidypics:settings:view_count') => 'enabled'), 'internalname' => 'view_count', 'value' => $view_count )) . "

"; + + // Watermark Text + $form_body .= "

" . elgg_echo('tidypics:settings:watermark') . "
"; + $form_body .= elgg_view("input/text",array('internalname' => 'params[watermark_text]', 'value' => $plugin->watermark_text)) . "

"; + + // Max Image Size + $maxfilesize = $plugin->maxfilesize; + if (!$maxfilesize) $maxfilesize = (int)5; // 5 MB + $form_body .= "

" . elgg_echo('tidypics:settings:maxfilesize') . "
"; + $form_body .= elgg_view("input/text",array('internalname' => 'params[maxfilesize]', 'value' => $maxfilesize)) . "

"; + + // Quota Size + $quota = $plugin->quota; + if (!$quota) $quota = 0; + $form_body .= "

" . elgg_echo('tidypics:settings:quota') . "
"; + $form_body .= elgg_view("input/text",array('internalname' => 'params[quota]', 'value' => $quota)) . "

"; + + // River Image options + $img_river_view = $plugin->img_river_view; + if (!$img_river_view) $img_river_view = '1'; + $form_body .= '

' . elgg_echo('tidypics:settings:img_river_view'); + $form_body .= elgg_view('input/pulldown', array( + 'internalname' => 'params[img_river_view]', + 'options_values' => array( + 'all' => 'all', + '1' => '1', + 'none' => 'none', + ), + 'value' => $img_river_view + )); + $form_body .= '

'; + + // River Album options + $album_river_view = $plugin->album_river_view; + if (!$album_river_view) $album_river_view = 'set'; + $form_body .= '

' . elgg_echo('tidypics:settings:album_river_view'); + $form_body .= elgg_view('input/pulldown', array( + 'internalname' => 'params[album_river_view]', + 'options_values' => array( + 'cover' => 'cover', + 'set' => 'set', + ), + 'value' => $album_river_view + )); + $form_body .= '

'; + + // Thumbnail sizes + $image_sizes = $plugin->image_sizes; + if(!$image_sizes) { + $image_sizes = array(); // set default values + $image_sizes['large_image_width'] = $image_sizes['large_image_height'] = 600; + $image_sizes['small_image_width'] = $image_sizes['small_image_height'] = 153; + $image_sizes['thumb_image_width'] = $image_sizes['thumb_image_height'] = 60; + } else { + $image_sizes = unserialize($image_sizes); + } + $form_body .= "

" . elgg_echo('tidypics:settings:largesize') . "
"; + $form_body .= 'width:    '; + $form_body .= 'height:

'; + $form_body .= "

" . elgg_echo('tidypics:settings:smallsize') . "
"; + $form_body .= 'width:    '; + $form_body .= 'height:

'; + $form_body .= "

" . elgg_echo('tidypics:settings:thumbsize') . "
"; + $form_body .= 'width:    '; + $form_body .= 'height:

'; + + + // Group permission override + $grp_perm_override = $plugin->grp_perm_override; + if(!$grp_perm_override) $grp_perm_override = "enabled"; + $form_body .= '

' . elgg_view("input/checkboxes", array('options' => array(elgg_echo('tidypics:settings:grp_perm_override') => 'enabled'), 'internalname' => 'grp_perm_override', 'value' => $grp_perm_override )) . "

"; + + $form_body .= elgg_view('input/submit', array('value' => elgg_echo("save"))); + echo elgg_view('input/form', array('action' => $action, 'body' => $form_body)); diff --git a/views/default/tidypics/gallery.php b/views/default/tidypics/gallery.php index 29c706bb1..dd7c1cdcf 100644 --- a/views/default/tidypics/gallery.php +++ b/views/default/tidypics/gallery.php @@ -1,64 +1,64 @@ - 0 && $viewtypetoggle) { - $nav .= elgg_view('navigation/viewtype', array( - 'baseurl' => $baseurl, - 'offset' => $offset, - 'count' => $count, - 'viewtype' => $viewtype, - )); -} - -if ($pagination) { - $nav .= elgg_view('navigation/pagination',array( - 'baseurl' => $baseurl, - 'offset' => $offset, - 'count' => $count, - 'limit' => $limit, - )); -} - -$html .= $nav; -if ($viewtype == 'list') { - if (is_array($entities) && sizeof($entities) > 0) { - foreach($entities as $entity) { - $html .= elgg_view_entity($entity, $fullview); - } - } -} else { - if (is_array($entities) && sizeof($entities) > 0) { - $html .= elgg_view('entities/gallery', array('entities' => $entities)); - } -} - -$html .= '
'; - -if ($count) { - $html .= $nav; -} - + 0 && $viewtypetoggle) { + $nav .= elgg_view('navigation/viewtype', array( + 'baseurl' => $baseurl, + 'offset' => $offset, + 'count' => $count, + 'viewtype' => $viewtype, + )); +} + +if ($pagination) { + $nav .= elgg_view('navigation/pagination',array( + 'baseurl' => $baseurl, + 'offset' => $offset, + 'count' => $count, + 'limit' => $limit, + )); +} + +$html .= $nav; +if ($viewtype == 'list') { + if (is_array($entities) && sizeof($entities) > 0) { + foreach($entities as $entity) { + $html .= elgg_view_entity($entity, $fullview); + } + } +} else { + if (is_array($entities) && sizeof($entities) > 0) { + $html .= elgg_view('entities/gallery', array('entities' => $entities)); + } +} + +$html .= '
'; + +if ($count) { + $html .= $nav; +} + echo $html; \ No newline at end of file diff --git a/views/default/tidypics/groupprofile_albums.php b/views/default/tidypics/groupprofile_albums.php index 7f28705c7..a7e143ae9 100644 --- a/views/default/tidypics/groupprofile_albums.php +++ b/views/default/tidypics/groupprofile_albums.php @@ -1,15 +1,15 @@ -photos_enable != 'no') { - echo '
'; - echo '

' . elgg_echo('album:group') . '

'; - echo elgg_view('tidypics/albums', array('num_albums' => 5)); - echo '
'; -} +photos_enable != 'no') { + echo '
'; + echo '

' . elgg_echo('album:group') . '

'; + echo elgg_view('tidypics/albums', array('num_albums' => 5)); + echo '
'; +} ?> \ No newline at end of file diff --git a/views/default/tidypics/hover_menu.php b/views/default/tidypics/hover_menu.php index a36c4be17..240891f51 100644 --- a/views/default/tidypics/hover_menu.php +++ b/views/default/tidypics/hover_menu.php @@ -1,12 +1,12 @@ - - -

- + + +

+

\ No newline at end of file diff --git a/views/default/tidypics/image_menu.php b/views/default/tidypics/image_menu.php index 9e7a53969..983f900b4 100644 --- a/views/default/tidypics/image_menu.php +++ b/views/default/tidypics/image_menu.php @@ -1,51 +1,51 @@ -container_guid); - if ($container instanceof ElggGroup) { - $can_tag = $viewer && $container->isMember($viewer); - } else { - $can_tag = $viewer && $viewer->guid == $owner->guid || user_is_friend($owner->guid, $viewer->guid); - } - - // only owner and friends of owner can tag - if ($can_tag) { -?> -
  • -guid == $owner->guid) { -?> -
  • - -
  • -container_guid); + if ($container instanceof ElggGroup) { + $can_tag = $viewer && $container->isMember($viewer); + } else { + $can_tag = $viewer && $viewer->guid == $owner->guid || user_is_friend($owner->guid, $viewer->guid); + } + + // only owner and friends of owner can tag + if ($can_tag) { +?> +
  • +guid == $owner->guid) { +?> +
  • + +
  • + \ No newline at end of file diff --git a/views/default/tidypics/tagging.php b/views/default/tidypics/tagging.php index 9ebec7c1e..ae3fa2b27 100644 --- a/views/default/tidypics/tagging.php +++ b/views/default/tidypics/tagging.php @@ -1,87 +1,87 @@ -getPhotoTags(); - - // defining json text as "" makes sure the tagging javascript code doesn't throw errors if no tags - $photo_tags_json = "\"\""; - if ($tag_info) { - $photo_tags_json = $tag_info['json']; - } - - if ($tag_info) { -?> -
    -

    - -
    - -
    -
    -
    -
    -
    -

    -"; - $content .= ""; - $content .= ""; - $content .= ""; - $content .= ""; - - $content .= "
    "; - - $content .= "
    "; - - echo elgg_view('input/form', array('internalid' => 'quicksearch', 'internalname' => 'tidypics_phototag_form', 'class' => 'quicksearch', 'action' => "{$vars['url']}action/tidypics/addtag", 'method' => 'post', 'body' => $content)); - } - -?> -
    -
    -
    -

    -guid}' />"; - foreach ($tag_info['links'] as $id => $link) { - $text = htmlentities($link['text'], ENT_QUOTES, 'UTF-8'); - $content .= "
    "; - } - - $content .= ""; - $content .= ""; - - echo elgg_view('input/form', array('internalname' => 'phototag_deletetag_form', 'action' => "{$vars['url']}action/tidypics/deletetag", 'method' => 'post', 'body' => $content)); - - } - echo '
    '; // tidypics_delete_tag_menu - - echo elgg_view('js/tagging', array('photo_tags_json' => $photo_tags_json,) ); +getPhotoTags(); + + // defining json text as "" makes sure the tagging javascript code doesn't throw errors if no tags + $photo_tags_json = "\"\""; + if ($tag_info) { + $photo_tags_json = $tag_info['json']; + } + + if ($tag_info) { +?> +
    +

    + +
    + +
    +
    +
    +
    +
    +

    +"; + $content .= ""; + $content .= ""; + $content .= ""; + $content .= ""; + + $content .= "
    "; + + $content .= "
    "; + + echo elgg_view('input/form', array('internalid' => 'quicksearch', 'internalname' => 'tidypics_phototag_form', 'class' => 'quicksearch', 'action' => "{$vars['url']}action/tidypics/addtag", 'method' => 'post', 'body' => $content)); + } + +?> +
    +
    +
    +

    +guid}' />"; + foreach ($tag_info['links'] as $id => $link) { + $text = htmlentities($link['text'], ENT_QUOTES, 'UTF-8'); + $content .= "
    "; + } + + $content .= ""; + $content .= ""; + + echo elgg_view('input/form', array('internalname' => 'phototag_deletetag_form', 'action' => "{$vars['url']}action/tidypics/deletetag", 'method' => 'post', 'body' => $content)); + + } + echo '
    '; // tidypics_delete_tag_menu + + echo elgg_view('js/tagging', array('photo_tags_json' => $photo_tags_json,) ); ?> \ No newline at end of file diff --git a/views/default/widgets/album_view/edit.php b/views/default/widgets/album_view/edit.php index 1fea6764a..992699cb0 100644 --- a/views/default/widgets/album_view/edit.php +++ b/views/default/widgets/album_view/edit.php @@ -1,24 +1,24 @@ -

    -num_display == '') $vars['entity']->num_display = 5; - -?> - +

    +num_display == '') $vars['entity']->num_display = 5; + +?> +

    \ No newline at end of file diff --git a/views/default/widgets/latest_photos/edit.php b/views/default/widgets/latest_photos/edit.php index 15a56af82..3b334d722 100644 --- a/views/default/widgets/latest_photos/edit.php +++ b/views/default/widgets/latest_photos/edit.php @@ -1,15 +1,15 @@ -

    -num_display == '') $vars['entity']->num_display = 6; - -?> - +

    +num_display == '') $vars['entity']->num_display = 6; + +?> +

    \ No newline at end of file diff --git a/views/rss/object/album.php b/views/rss/object/album.php index 990322baf..2ad4ed9f7 100644 --- a/views/rss/object/album.php +++ b/views/rss/object/album.php @@ -1,45 +1,45 @@ -cover) { - // Set title - $vars['title'] = $album->title; - if (empty($vars['title'])) { - $title = $vars['config']->sitename; - } else if (empty($vars['config']->sitename)) { - $title = $vars['title']; - } else { - $title = $vars['config']->sitename . ": " . $vars['title']; - } - $album_cover_url = $vars['url'] . 'mod/tidypics/thumbnail.php?file_guid=' . $album->cover . '&size=thumb'; -?> - - <![CDATA[<?php echo $title; ?>]]> - getURL() . '?view=rss'; ?> - -guid); - - - foreach ($images as $image) { - echo elgg_view_entity($image); - } - -} +cover) { + // Set title + $vars['title'] = $album->title; + if (empty($vars['title'])) { + $title = $vars['config']->sitename; + } else if (empty($vars['config']->sitename)) { + $title = $vars['title']; + } else { + $title = $vars['config']->sitename . ": " . $vars['title']; + } + $album_cover_url = $vars['url'] . 'mod/tidypics/thumbnail.php?file_guid=' . $album->cover . '&size=thumb'; +?> + + <![CDATA[<?php echo $title; ?>]]> + getURL() . '?view=rss'; ?> + +guid); + + + foreach ($images as $image) { + echo elgg_view_entity($image); + } + +} ?> \ No newline at end of file diff --git a/views/rss/object/file.php b/views/rss/object/file.php index e40da4f69..36740f003 100644 --- a/views/rss/object/file.php +++ b/views/rss/object/file.php @@ -1,23 +1,23 @@ -title; - if (empty($title)) { - $title = substr($vars['entity']->description,0,32); - if (strlen($vars['entity']->description) > 32) - $title .= " ..."; - } - -?> - - - getURL(); ?> - time_created) ?> - getURL(); ?> - <![CDATA[<?php echo $title; ?>]]> - description)); ?>]]> - - +title; + if (empty($title)) { + $title = substr($vars['entity']->description,0,32); + if (strlen($vars['entity']->description) > 32) + $title .= " ..."; + } + +?> + + + getURL(); ?> + time_created) ?> + getURL(); ?> + <![CDATA[<?php echo $title; ?>]]> + description)); ?>]]> + + diff --git a/views/rss/object/image.php b/views/rss/object/image.php index dafc05f45..b93592081 100644 --- a/views/rss/object/image.php +++ b/views/rss/object/image.php @@ -1,19 +1,19 @@ -title; -$descr = $vars['entity']->description; -$download = $vars['url'] . 'pg/photos/download/' . $vars['entity']->guid . '/inline/'; -$base_url = $vars['url'] . 'mod/tidypics/thumbnail.php?file_guid='; -?> - - - <?php echo $title; ?> - guid . '&size=large'; ?> - - time_created); ?> - getURL(); ?> - - - - +title; +$descr = $vars['entity']->description; +$download = $vars['url'] . 'pg/photos/download/' . $vars['entity']->guid . '/inline/'; +$base_url = $vars['url'] . 'mod/tidypics/thumbnail.php?file_guid='; +?> + + + <?php echo $title; ?> + guid . '&size=large'; ?> + + time_created); ?> + getURL(); ?> + + + + \ No newline at end of file diff --git a/views/rss/tidypics/gallery.php b/views/rss/tidypics/gallery.php index 2fcf2ac76..2c285fca5 100644 --- a/views/rss/tidypics/gallery.php +++ b/views/rss/tidypics/gallery.php @@ -1,18 +1,18 @@ - 0) { - foreach($entities as $entity) { - echo elgg_view_entity($entity); - } -} - + 0) { + foreach($entities as $entity) { + echo elgg_view_entity($entity); + } +} + ?> \ No newline at end of file -- cgit v1.2.3