From 73403645808a81425381f43c25e0ea2c92705312 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sun, 25 Jul 2010 02:01:36 +0000 Subject: first go at brining tidypics up to code standards --- actions/addalbum.php | 128 ++-- actions/addtag.php | 170 +++--- actions/create_thumbnails.php | 115 ++-- actions/delete.php | 211 ++++--- actions/deletetag.php | 97 ++- actions/edit.php | 135 ++-- actions/edit_multi.php | 113 ++-- actions/flickrImportPhotoset.php | 7 +- actions/flickrSetup.php | 2 - actions/imtest.php | 35 +- actions/settings.php | 135 ++-- actions/upgrade.php | 55 +- contributions.txt | 12 + languages/en.php | 8 +- lib/flickr.php | 2 - manifest.xml | 14 +- mostvieweddashboard.php | 65 +- pages/admin.php | 24 +- pages/download.php | 96 ++- pages/edit.php | 79 +-- pages/edit_multiple.php | 72 +-- pages/friends.php | 80 +-- pages/lists/mostcommentedimages.php | 63 +- pages/lists/mostrecentimages.php | 102 ++-- pages/lists/mostviewedimages.php | 121 ++-- pages/lists/recentlycommented.php | 111 ++-- pages/lists/recentlyviewed.php | 105 ++-- pages/newalbum.php | 54 +- pages/ownedalbums.php | 102 ++-- pages/server_analysis.php | 62 +- pages/tagged.php | 96 ++- pages/thumbnail.php | 146 ++--- pages/upload.php | 82 +-- pages/viewalbum.php | 114 ++-- pages/viewimage.php | 104 ++-- pages/world.php | 55 +- start.php | 812 +++++++++++++------------ thumbnail.php | 148 ++--- views/default/annotation/annotate.php | 31 +- views/default/object/album.php | 192 +++--- views/default/object/image.php | 295 +++++---- views/default/river/object/album/create.php | 65 +- views/default/river/object/image/create.php | 38 +- views/default/river/object/image/tag.php | 39 +- views/default/settings/tidypics/edit.php | 6 +- views/default/tidypics/admin/imagelib.php | 88 +-- views/default/tidypics/admin/settings.php | 36 +- views/default/tidypics/admin/stats.php | 51 +- views/default/tidypics/admin/tidypics.php | 58 +- views/default/tidypics/albums.php | 74 +-- views/default/tidypics/breadcrumbs.php | 33 +- views/default/tidypics/exif.php | 20 +- views/default/tidypics/forms/edit.php | 145 +++-- views/default/tidypics/forms/edit_multi.php | 12 +- views/default/tidypics/forms/settings.php | 336 +++++----- views/default/tidypics/forms/setupFlickr.php | 1 - views/default/tidypics/forms/upload.php | 123 ++-- views/default/tidypics/groupprofile_albums.php | 1 - views/default/tidypics/image_menu.php | 77 ++- views/default/tidypics/tagging.php | 57 +- views/default/widgets/album_view/edit.php | 11 +- views/default/widgets/album_view/view.php | 13 +- views/default/widgets/latest_photos/edit.php | 8 +- views/default/widgets/latest_photos/view.php | 17 +- views/rss/object/album.php | 1 - views/rss/object/file.php | 18 +- views/rss/tidypics/gallery.php | 8 +- 67 files changed, 2923 insertions(+), 2863 deletions(-) diff --git a/actions/addalbum.php b/actions/addalbum.php index 8df488a92..accdd082b 100644 --- a/actions/addalbum.php +++ b/actions/addalbum.php @@ -1,74 +1,72 @@ getGUID()); +// Get input data +$title = get_input('tidypicstitle'); +$body = get_input('tidypicsbody'); +$tags = get_input('tidypicstags'); +$access = get_input('access_id'); +$container_guid = get_input('container_guid', get_loggedin_userid()); - // Cache to the session - $_SESSION['tidypicstitle'] = $title; - $_SESSION['tidypicsbody'] = $body; - $_SESSION['tidypicstags'] = $tags; +// 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']); +// 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 { - // plugins can register to be told when a new Tidypics album has been created - trigger_elgg_event('add', 'tp_album', $album); + // Initialise a new ElggObject + $album = new ElggObject(); + // Tell the system it's an album + $album->subtype = "album"; - forward("pg/photos/upload/" . $album->guid); + // 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 } -?> \ No newline at end of file + // 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); +} diff --git a/actions/addtag.php b/actions/addtag.php index 56268783e..115a81bc6 100644 --- a/actions/addtag.php +++ b/actions/addtag.php @@ -1,104 +1,106 @@ tags)) { + if ($image->tags != $word) { + $new_word_tag = true; + $tagarray = $image->tags . ',' . $word; + $tagarray = string_to_tag_array($tagarray); + } } else { - $relationships_type = 'word'; - $value = $word; - - // check to see if the photo has this tag and add if not - if (!is_array($image->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; - } + 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; - } +} + +// 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(); - // 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'), +//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() - ) - ); + elgg_echo('tidypics:tag:body'), + $image->title, + $tagger->name, + $image->getURL() + ) + ); } } - - system_message(elgg_echo("tidypics:phototagging:success")); } + system_message(elgg_echo("tidypics:phototagging:success")); +} - forward($_SERVER['HTTP_REFERER']); -?> +forward($_SERVER['HTTP_REFERER']); diff --git a/actions/create_thumbnails.php b/actions/create_thumbnails.php index 09743eef6..18dae6b78 100644 --- a/actions/create_thumbnails.php +++ b/actions/create_thumbnails.php @@ -1,61 +1,60 @@ 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"; } - - $filename = $image->getFilename(); - $container_guid = $image->container_guid; - if (!$filename || !$container_guid) { - echo "Error retrieving information about the image"; - return; + +} 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"; } - - $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}\" />"; - -?> + +} // 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 cab996ec5..c1e0ed59e 100644 --- a/actions/delete.php +++ b/actions/delete.php @@ -1,121 +1,120 @@ canEdit()) { // user doesn't have permissions - register_error(elgg_echo("tidypics:deletefailed")); - forward($forward_url); - } +$entity = get_entity($guid); +if (!$entity) { // unable to get Elgg entity + register_error(elgg_echo("tidypics: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("tidypics:deletefailed")); - forward($forward_url); - } +if (!$entity->canEdit()) { // user doesn't have permissions + register_error(elgg_echo("tidypics: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("tidypics: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; - $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); +//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(); - // 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("tidypics:deletefailed")); //unable to delete object - } else { - if ($subtype=='image') system_message(elgg_echo("tidypics: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("tidypics:deletefailed")); //unable to delete object + if (!$delfile->delete()) { + if ($subtype=='image') register_error(elgg_echo("tidypics:deletefailed")); //unable to delete object } else { - system_message(elgg_echo("tidypics:deleted")); //successfully deleted object + if ($subtype=='image') system_message(elgg_echo("tidypics:deleted")); //successfully deleted object } - } //end of delete album + } //end delete actual image file +} //end looping through each image to delete it - create_metadata($owner_guid, "image_repo_size", $image_repo_size, 'integer', $owner_guid); +//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); + } - forward($forward_url); + //delete object from database + if (!$entity->delete()) { + register_error(elgg_echo("tidypics:deletefailed")); //unable to delete object + } else { + system_message(elgg_echo("tidypics:deleted")); //successfully deleted object + } +} //end of delete album + +create_metadata($owner_guid, "image_repo_size", $image_repo_size, 'integer', $owner_guid); -?> \ No newline at end of file +forward($forward_url); diff --git a/actions/deletetag.php b/actions/deletetag.php index becf1fedb..97c1081f8 100644 --- a/actions/deletetag.php +++ b/actions/deletetag.php @@ -1,57 +1,54 @@ $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'); - } +gatekeeper(); +action_gatekeeper(); + +$image_guid = get_input('image_guid'); +$tags = get_input('tags'); + + +if ($image_guid == 0) { + register_error(elgg_echo("tidypics:phototagging:error")); + forward($_SERVER['HTTP_REFERER']); +} + +$image = get_entity($image_guid); +if (!$image) { + register_error(elgg_echo("tidypics:phototagging:error")); + forward($_SERVER['HTTP_REFERER']); +} + +foreach ($tags as $id => $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; } - - // 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); + } else { + if ($value === $image->tags) { + $image->clearMetadata('tags'); } - - // delete the photo tag annotation - delete_annotation($id); } - - system_message(elgg_echo("tidypics:deletetag:success")); - forward($_SERVER['HTTP_REFERER']); + // 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 cdf9420b2..db6e26ab9 100644 --- a/actions/edit.php +++ b/actions/edit.php @@ -1,81 +1,82 @@ canEdit()) { - forward(); - } +// Get input data +$guid = (int) get_input('guid'); // guid of image or album +$title = get_input('tidypicstitle'); +$body = get_input('tidypicsbody'); +$access = get_input('access_id'); +$tags = get_input('tidypicstags'); +$subtype = get_input('subtype'); +$cover = get_input('cover'); +if (is_array($cover)) { + $cover = $cover[0]; +} - // Get owning user/group - $owner = get_entity($entity->getOwner()); +$container_guid = get_input('container_guid'); - // 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(); - } - } +// Make sure we actually have permission to edit +$entity = get_entity($guid); +if (!$entity->canEdit()) { + forward(); +} +// Get owning user/group +$owner = get_entity($entity->getOwner()); - // Set its title and description appropriately - $entity->title = $title; - $entity->description = $body; +// change access only if access is different from current +if ($subtype == 'album' && $entity->access_id != $access) { + $entity->access_id = $access; - // 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 + //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(); } +} - // 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; - } +// Set its title and description appropriately +$entity->title = $title; +$entity->description = $body; - // 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); - } +// 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()); -?> +forward($entity->getURL()); diff --git a/actions/edit_multi.php b/actions/edit_multi.php index c7099e6db..c938e6065 100644 --- a/actions/edit_multi.php +++ b/actions/edit_multi.php @@ -1,66 +1,65 @@ $im) { - $image = get_entity($im); - - if ($image->canEdit()) { - - // Convert string of tags into a preformatted array - $tagarray = string_to_tag_array($tags_array[$key]); +// Get input data +$title_array = get_input('title'); +$caption_array = get_input('caption'); +$tags_array = get_input('tags'); +$image_guid_array = get_input('image_guid'); +$container_guid = get_input('container_guid'); +$album_entity = get_entity($container_guid); +$cover = get_input('cover'); +$not_updated = array(); - //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]; +foreach($image_guid_array as $key => $im) { + $image = get_entity($im); - // Before we can set metadata, we need to save the image - if (!$image->save()) { - array_push($not_updated, $image->guid); - } + if ($image->canEdit()) { - // 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; - } + // 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()); +} + +// Success message +if (count($not_updated) > 0) { + register_error(elgg_echo("images:notedited")); +} else { + system_message(elgg_echo("images:edited")); +} -?> \ No newline at end of file +// Forward to the main album page +forward($album_entity->getURL()); diff --git a/actions/flickrImportPhotoset.php b/actions/flickrImportPhotoset.php index ec0d65b5d..fd6769e3a 100644 --- a/actions/flickrImportPhotoset.php +++ b/actions/flickrImportPhotoset.php @@ -28,11 +28,11 @@ $photos_url = $f->urls_getUserPhotos( $flickr_id->value ); $photos = $f->photosets_getPhotos( $set_id, null, null, 10, $page_pp ); $photos_to_upload = array(); -foreach( $photos["photoset"]["photo"] as $photo ) { +foreach ($photos["photoset"]["photo"] as $photo) { //check if we already have this image $meta = get_metadata_byname( $user->guid, $photo["id"] ); - if( $meta->value == 1 ) { //we've downloaded this already + if ($meta->value == 1) { //we've downloaded this already register_error( elgg_echo( 'flickr:errorimageimport' )); continue; } @@ -41,7 +41,7 @@ foreach( $photos["photoset"]["photo"] as $photo ) { $photo_info = $f->photos_getInfo( $photo["id"], $photo["secret"] ); $tags = array(); - foreach( $photo_info["tags"]["tag"] as $tag ) { + foreach ($photo_info["tags"]["tag"] as $tag) { $tags[] = $tag["raw"]; } $tags = implode( ", ", $tags ); @@ -337,4 +337,3 @@ trigger_elgg_event('upload', 'tp_album', $album); $url = $CONFIG->wwwroot . 'mod/tidypics/pages/edit_multiple.php?files=' . implode('-', $uploaded_images); forward($url); -?> diff --git a/actions/flickrSetup.php b/actions/flickrSetup.php index fbc519b02..ee31b8c34 100644 --- a/actions/flickrSetup.php +++ b/actions/flickrSetup.php @@ -34,5 +34,3 @@ if( empty( $flickr_username )) { forward($_SERVER['HTTP_REFERER']); //echo "
"; var_dump( array($flickr_username, $return_url )); echo "
"; - -?> \ No newline at end of file diff --git a/actions/imtest.php b/actions/imtest.php index cbe15a1c1..293a9b2e8 100644 --- a/actions/imtest.php +++ b/actions/imtest.php @@ -1,19 +1,18 @@ +/** + * Tidypics ImageMagick Location Test + * + * Called through ajax + */ + +$location = $_GET['location']; + +$command = $location . "convert -version"; + +$result = system($command, $return_val); + +if ($return_val == 0) { + echo $result; +} else { + echo "Unable to run ImageMagick. Please check the path."; +} diff --git a/actions/settings.php b/actions/settings.php index a4f102b89..2c529d950 100644 --- a/actions/settings.php +++ b/actions/settings.php @@ -1,72 +1,77 @@ $v) { - if (!set_plugin_setting($k, $v, 'tidypics')) { - register_error(sprintf(elgg_echo('plugins:settings:save:fail'), 'tidypics')); - forward($_SERVER['HTTP_REFERER']); - } +// Params array (text boxes and drop downs) +$params = get_input('params'); +$result = false; +foreach ($params as $k => $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['small_image_height'] = get_input('small_thumb_width'); - $image_sizes['thumb_image_width'] = get_input('thumb_width'); - //$image_sizes['thumb_image_height'] = get_input('thumb_height'); - $image_sizes['thumb_image_height'] = get_input('thumb_width'); - set_plugin_setting('image_sizes', serialize($image_sizes), 'tidypics'); - - - - system_message(elgg_echo('tidypics:settings:save:ok')); - - 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['small_image_height'] = get_input('small_thumb_width'); +$image_sizes['thumb_image_width'] = get_input('thumb_width'); +//$image_sizes['thumb_image_height'] = get_input('thumb_height'); +$image_sizes['thumb_image_height'] = get_input('thumb_width'); +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/upgrade.php b/actions/upgrade.php index cb200380a..596b90a22 100644 --- a/actions/upgrade.php +++ b/actions/upgrade.php @@ -6,35 +6,34 @@ * *********************************************/ - include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php"; - - admin_gatekeeper(); - - $result = true; - - // add image class - $id = get_subtype_id("object", "image"); - if ($id != 0) { - $table = $CONFIG->dbprefix . 'entity_subtypes'; - $result = update_data("UPDATE {$table} set class='TidypicsImage' where id={$id}"); - if (!result) { - register_error(elgg_echo('tidypics:upgrade:failed')); - forward($_SERVER['HTTP_REFERER']); - } +include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php"; + +admin_gatekeeper(); + +$result = true; + +// add image class +$id = get_subtype_id("object", "image"); +if ($id != 0) { + $table = $CONFIG->dbprefix . 'entity_subtypes'; + $result = update_data("UPDATE {$table} set class='TidypicsImage' where id={$id}"); + if (!result) { + register_error(elgg_echo('tidypics:upgrade:failed')); + forward($_SERVER['HTTP_REFERER']); } +} - // add album class - $id = get_subtype_id("object", "album"); - if ($id != 0) { - $table = $CONFIG->dbprefix . 'entity_subtypes'; - $result = update_data("UPDATE {$table} set class='TidypicsAlbum' where id={$id}"); - if (!result) { - register_error(elgg_echo('tidypics:upgrade:failed')); - forward($_SERVER['HTTP_REFERER']); - } +// add album class +$id = get_subtype_id("object", "album"); +if ($id != 0) { + $table = $CONFIG->dbprefix . 'entity_subtypes'; + $result = update_data("UPDATE {$table} set class='TidypicsAlbum' where id={$id}"); + if (!result) { + register_error(elgg_echo('tidypics:upgrade:failed')); + forward($_SERVER['HTTP_REFERER']); } +} + +system_message(elgg_echo('tidypics:upgrade:success')); - system_message(elgg_echo('tidypics:upgrade:success')); - - forward($_SERVER['HTTP_REFERER']); -?> \ No newline at end of file +forward($_SERVER['HTTP_REFERER']); diff --git a/contributions.txt b/contributions.txt index 3cea54bd9..947f2b069 100644 --- a/contributions.txt +++ b/contributions.txt @@ -1,5 +1,17 @@ Changelog and contributors list +------------------------------------------------------------------------ +Version 1.6.9 Change List +Release Date: 07/25/2010 +------------------------------------------------------------------------ +BEGIN VERSION 1.6.9 CHANGES +------------------------------------------------------------------------ + * Fixed bug where old installs of Tidypics would not upgrade + * Fixed bug in activity river with link on image entry + * +------------------------------------------------------------------------ +END VERSION 1.6.9 CHANGES +------------------------------------------------------------------------ ------------------------------------------------------------------------ Version 1.6.8 Change List diff --git a/languages/en.php b/languages/en.php index 934c8ae5a..2ee3a6e5e 100644 --- a/languages/en.php +++ b/languages/en.php @@ -1,11 +1,10 @@ "untitled", // Menu items and titles - 'image' => "Image", 'images' => "Images", 'caption' => "Caption", @@ -225,7 +224,6 @@ The photo can be viewed here: %s", '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); -?> +add_translation("en", $english); diff --git a/lib/flickr.php b/lib/flickr.php index effd186c4..7f91b0f01 100644 --- a/lib/flickr.php +++ b/lib/flickr.php @@ -4,5 +4,3 @@ function flickr_menu() { add_submenu_item( elgg_echo( 'flickr:menusetup' ), "/mod/tidypics/pages/flickr/setup.php"); add_submenu_item( elgg_echo( 'flickr:menuimport' ), "/mod/tidypics/pages/flickr/importPhotosets.php" ); } - -?> \ No newline at end of file diff --git a/manifest.xml b/manifest.xml index d630e9601..f19991546 100644 --- a/manifest.xml +++ b/manifest.xml @@ -1,10 +1,10 @@ - - - - - - - + + + + + + + diff --git a/mostvieweddashboard.php b/mostvieweddashboard.php index 5e7dc41c2..e98e784da 100644 --- a/mostvieweddashboard.php +++ b/mostvieweddashboard.php @@ -1,22 +1,22 @@ dbprefix; - $max = 24; - - //this works but is wildly inefficient - //$annotations = get_annotations(0, "object", "image", "tp_view", "", "", 5000); - - $sql = "SELECT ent.guid, count( * ) AS views +/** + * Tidypics full view of an image + * Given a GUID, this page will try and display any entity + * + */ + +// Load Elgg engine +include_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); + +global $CONFIG; +$prefix = $CONFIG->dbprefix; +$max = 24; + +//this works but is wildly inefficient +//$annotations = get_annotations(0, "object", "image", "tp_view", "", "", 5000); + +$sql = "SELECT ent.guid, count( * ) AS views FROM " . $prefix . "entities ent INNER JOIN " . $prefix . "entity_subtypes sub ON ent.subtype = sub.id AND sub.subtype = 'image' @@ -26,19 +26,18 @@ GROUP BY ent.guid ORDER BY views DESC LIMIT $max"; - - $result = get_data($sql); - - $entities = array(); - foreach($result as $entity) { - $entities[] = get_entity($entity->guid); - } - - tidypics_mostviewed_submenus(); - - $title = elgg_echo("tidypics:mostvieweddashboard"); - $area2 = elgg_view_title($title); - $area2 .= elgg_view_entity_list($entities, $max, 0, $max); - $body = elgg_view_layout('two_column_left_sidebar', '', $area2); - page_draw($title, $body); -?> + +$result = get_data($sql); + +$entities = array(); +foreach($result as $entity) { + $entities[] = get_entity($entity->guid); +} + +tidypics_mostviewed_submenus(); + +$title = elgg_echo("tidypics:mostvieweddashboard"); +$area2 = elgg_view_title($title); +$area2 .= elgg_view_entity_list($entities, $max, 0, $max); +$body = elgg_view_layout('two_column_left_sidebar', '', $area2); +page_draw($title, $body); diff --git a/pages/admin.php b/pages/admin.php index d3e810351..4013e55ac 100644 --- a/pages/admin.php +++ b/pages/admin.php @@ -1,23 +1,21 @@ $tab)); - - page_draw(elgg_echo('tidypics:administration'), elgg_view_layout("two_column_left_sidebar", '', $body)); +$tab = get_input('tab', 'settings'); -?> \ No newline at end of file +$body = elgg_view_title(elgg_echo('tidypics:administration')); + +$body .= elgg_view("tidypics/admin/tidypics", array('tab' => $tab)); + +page_draw(elgg_echo('tidypics:administration'), elgg_view_layout("two_column_left_sidebar", '', $body)); diff --git a/pages/download.php b/pages/download.php index e4ad2e855..23c3e39f4 100644 --- a/pages/download.php +++ b/pages/download.php @@ -1,52 +1,50 @@ 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; +/** + * Tidypics Download Photos + * + * do not call this directly - call through page handler + */ + +global $CONFIG; + +$file_guid = (int) get_input("file_guid"); +$file = get_entity($file_guid); + +$type = get_input("type"); + +if ($file) { + $filename = $file->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; } - else - register_error(elgg_echo("image:downloadfailed")); -?> \ No newline at end of file + 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 abf1a0fdd..06d3dd9c4 100644 --- a/pages/edit.php +++ b/pages/edit.php @@ -1,51 +1,54 @@ canEdit()) - forward(); +if (!$entity = get_entity($guid)) { + forward(); +} - $subtype = $entity->getSubtype(); - - if ($subtype == 'album') { - $title = elgg_echo('album:edit'); +if (!$entity->canEdit()) { + forward(); +} - if ($container = $entity->container_guid) - set_page_owner($container); +$subtype = $entity->getSubtype(); - } else if ($subtype == 'image') { - $title = elgg_echo('image:edit'); +if ($subtype == 'album') { + $title = elgg_echo('album:edit'); - if ($container = get_entity($entity->container_guid)->container_guid) - set_page_owner($container); - - } else { - forward(); + if ($container = $entity->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); + +} else if ($subtype == 'image') { + $title = elgg_echo('image:edit'); + + if ($container = get_entity($entity->container_guid)->container_guid) { + set_page_owner($container); } - - $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); +} 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 +page_draw($title, $body); diff --git a/pages/edit_multiple.php b/pages/edit_multiple.php index 49b7dd6f3..ec507ba4b 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); +// set page owner based on owner of photo album +set_page_owner($photo->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; - +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); -?> +$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 03ae1300a..d5dfdba5c 100644 --- a/pages/friends.php +++ b/pages/friends.php @@ -1,41 +1,41 @@ guid == get_loggedin_userid()) - $title = elgg_echo('album:yours:friends'); - else - $title = sprintf(elgg_echo('album:friends'), $user->name); - - $area2 = elgg_view_title($title); - - $albums = get_user_friends_objects($user->guid, 'album', 12); - - // get html for viewing list of photo albums - set_context('search'); - set_input('search_viewtype', 'gallery'); // need to force gallery view - $content = tp_view_entity_list($albums, count($albums), 0, 12, false, false, true); - - $area2 = elgg_view('tidypics/content_wrapper', array('title' => $title, 'content' => $content,)); - - $body = elgg_view_layout('two_column_left_sidebar', '', $area2); - - page_draw($title, $body); -?> \ No newline at end of file +/** + * Tidypics Friends Albums Listing + * + * List all the albums of someone's friends + */ + +include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php"; + +$username = get_input('username'); + +// if no username, redirect to world photo albums +if (!$username) { + forward('pg/photos/world'); +} + +// setup title +$user = get_user_by_username($username); +if (!$user) { + forward('pg/photos/world'); +} +if ($user->guid == get_loggedin_userid()) { + $title = elgg_echo('album:yours:friends'); +} else { + $title = sprintf(elgg_echo('album:friends'), $user->name); +} + +$area2 = elgg_view_title($title); + +$albums = get_user_friends_objects($user->guid, 'album', 12); + +// get html for viewing list of photo albums +set_context('search'); +set_input('search_viewtype', 'gallery'); // need to force gallery view +$content = tp_view_entity_list($albums, count($albums), 0, 12, false, false, true); + +$area2 = elgg_view('tidypics/content_wrapper', array('title' => $title, 'content' => $content,)); + +$body = elgg_view_layout('two_column_left_sidebar', '', $area2); + +page_draw($title, $body); diff --git a/pages/lists/mostcommentedimages.php b/pages/lists/mostcommentedimages.php index 801409fdc..0a4eb9622 100644 --- a/pages/lists/mostcommentedimages.php +++ b/pages/lists/mostcommentedimages.php @@ -1,22 +1,22 @@ dbprefix; - $max = 24; - - //this works but is wildly inefficient - //$annotations = get_annotations(0, "object", "image", "tp_view", "", "", 5000); - - $sql = "SELECT ent.guid, count( * ) AS views +/** + * Tidypics full view of an image + * Given a GUID, this page will try and display any entity + * + */ + +// Load Elgg engine +include_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/engine/start.php"; + +global $CONFIG; +$prefix = $CONFIG->dbprefix; +$max = 24; + +//this works but is wildly inefficient +//$annotations = get_annotations(0, "object", "image", "tp_view", "", "", 5000); + +$sql = "SELECT ent.guid, count( * ) AS views FROM " . $prefix . "entities ent INNER JOIN " . $prefix . "entity_subtypes sub ON ent.subtype = sub.id AND sub.subtype = 'image' @@ -26,18 +26,17 @@ GROUP BY ent.guid ORDER BY views DESC LIMIT $max"; - - $result = get_data($sql); - - $entities = array(); - foreach($result as $entity) { - $entities[] = get_entity($entity->guid); - } - - tidypics_mostviewed_submenus(); - $title = elgg_echo("tidypics:mostcommented"); - $area2 = elgg_view_title($title); - $area2 .= elgg_view_entity_list($entities, $max, 0, $max, false); - $body = elgg_view_layout('two_column_left_sidebar', '', $area2); - page_draw($title, $body); -?> \ No newline at end of file + +$result = get_data($sql); + +$entities = array(); +foreach ($result as $entity) { + $entities[] = get_entity($entity->guid); +} + +tidypics_mostviewed_submenus(); +$title = elgg_echo("tidypics:mostcommented"); +$area2 = elgg_view_title($title); +$area2 .= elgg_view_entity_list($entities, $max, 0, $max, false); +$body = elgg_view_layout('two_column_left_sidebar', '', $area2); +page_draw($title, $body); \ No newline at end of file diff --git a/pages/lists/mostrecentimages.php b/pages/lists/mostrecentimages.php index 178e3c722..722f1fc32 100644 --- a/pages/lists/mostrecentimages.php +++ b/pages/lists/mostrecentimages.php @@ -1,56 +1,58 @@ guid; - - if ($user_id == get_loggedin_userid()) - $title = elgg_echo('tidypics:yourmostrecent'); - else - $title = sprintf(elgg_echo("tidypics:friendmostrecent"), $user->name); - } - } else { - // world view - set page owner to logged in user - if (isloggedin()) { - set_page_owner(get_loggedin_userid()); +/** + * Most recently uploaded images - individual or world + * + */ + +// Load Elgg engine +include_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/engine/start.php"; + +// start with assumption this is for all site photos +$title = elgg_echo('tidypics:mostrecent'); +$user_id = 0; + +// is this all site or an individuals images +$username = get_input('username'); +if ($username) { + $user = get_user_by_username($username); + if ($user) { + $user_id = $user->guid; + + if ($user_id == get_loggedin_userid()) { + $title = elgg_echo('tidypics:yourmostrecent'); + } else { + $title = sprintf(elgg_echo("tidypics:friendmostrecent"), $user->name); } } - - // allow other plugins to override the slideshow - $slideshow_link = trigger_plugin_hook('tp_slideshow', 'album', array(), null); - if ($slideshow_link) { - add_submenu_item(elgg_echo('album:slideshow'), - $slideshow_link, - 'photos' ); +} else { + // world view - set page owner to logged in user + if (isloggedin()) { + set_page_owner(get_loggedin_userid()); } +} + +// allow other plugins to override the slideshow +$slideshow_link = trigger_plugin_hook('tp_slideshow', 'album', array(), null); +if ($slideshow_link) { + add_submenu_item(elgg_echo('album:slideshow'), + $slideshow_link, + 'photos' ); +} + +// how many do we display +$max = 12; + +// grab the html to display the images +$images = tp_list_entities("object", "image", $user_id, null, $max, false, false, true); + + +// this view takes care of the title on the main column and the content wrapper +$area2 = elgg_view('tidypics/content_wrapper', array('title' => $title, 'content' => $images,)); +if (empty($area2)) { + $area2 = $images; +} + +$body = elgg_view_layout('two_column_left_sidebar', '', $area2); - // how many do we display - $max = 12; - - // grab the html to display the images - $images = tp_list_entities("object", "image", $user_id, null, $max, false, false, true); - - - // this view takes care of the title on the main column and the content wrapper - $area2 = elgg_view('tidypics/content_wrapper', array('title' => $title, 'content' => $images,)); - if( empty( $area2 )) $area2 = $images; - - $body = elgg_view_layout('two_column_left_sidebar', '', $area2); - - page_draw($title, $body); -?> \ No newline at end of file +page_draw($title, $body); diff --git a/pages/lists/mostviewedimages.php b/pages/lists/mostviewedimages.php index d945680f1..eb87bc17c 100644 --- a/pages/lists/mostviewedimages.php +++ b/pages/lists/mostviewedimages.php @@ -1,33 +1,33 @@ dbprefix; - $max = 24; - - $owner_guid = page_owner(); - - //$start = microtime(true); - $photos = tp_get_entities_from_annotations_calculate_x( - 'count', - 'object', - 'image', - 'tp_view', - '', - '', - $owner_guid, - $max); - //error_log("elgg query is " . (float)(microtime(true) - $start)); - - //this works but is wildly inefficient - //$annotations = get_annotations(0, "object", "image", "tp_view", "", "", 5000); +global $CONFIG; +$prefix = $CONFIG->dbprefix; +$max = 24; + +$owner_guid = page_owner(); + +//$start = microtime(true); +$photos = tp_get_entities_from_annotations_calculate_x( + 'count', + 'object', + 'image', + 'tp_view', + '', + '', + $owner_guid, + $max); +//error_log("elgg query is " . (float)(microtime(true) - $start)); + +//this works but is wildly inefficient +//$annotations = get_annotations(0, "object", "image", "tp_view", "", "", 5000); /* $start = microtime(true); $sql = "SELECT ent.guid, count( * ) AS views @@ -48,39 +48,40 @@ $entities[] = get_entity($entity->guid); } */ - //error_log("custom query is " . (float)(microtime(true) - $start)); - - // allow other plugins to override the slideshow - $slideshow_link = trigger_plugin_hook('tp_slideshow', 'album', array(), null); - if ($slideshow_link) { - add_submenu_item(elgg_echo('album:slideshow'), - $slideshow_link, - 'photos' ); - } - - if ($owner_guid) { - if ($owner_guid == get_loggedin_userid()) { - $title = elgg_echo("tidypics:yourmostviewed"); - } else { - $title = sprintf(elgg_echo("tidypics:friendmostviewed"), page_owner_entity()->name); - } +//error_log("custom query is " . (float)(microtime(true) - $start)); + +// allow other plugins to override the slideshow +$slideshow_link = trigger_plugin_hook('tp_slideshow', 'album', array(), null); +if ($slideshow_link) { + add_submenu_item(elgg_echo('album:slideshow'), + $slideshow_link, + 'photos' ); +} + +if ($owner_guid) { + if ($owner_guid == get_loggedin_userid()) { + $title = elgg_echo("tidypics:yourmostviewed"); } else { - // world view - set page owner to logged in user - if (isloggedin()) { - set_page_owner(get_loggedin_userid()); - } - - $title = elgg_echo("tidypics:mostviewed"); + $title = sprintf(elgg_echo("tidypics:friendmostviewed"), page_owner_entity()->name); } - $area2 = elgg_view_title($title); - - // grab the html to display the images - $content = tp_view_entity_list($photos, $max, 0, $max, false); - - // this view takes care of the title on the main column and the content wrapper - $area2 = elgg_view('tidypics/content_wrapper', array('title' => $title, 'content' => $content,)); - if( empty( $area2 )) $area2 = $content; - - $body = elgg_view_layout('two_column_left_sidebar', '', $area2); - page_draw($title, $body); -?> \ No newline at end of file +} else { + // world view - set page owner to logged in user + if (isloggedin()) { + set_page_owner(get_loggedin_userid()); + } + + $title = elgg_echo("tidypics:mostviewed"); +} +$area2 = elgg_view_title($title); + +// grab the html to display the images +$content = tp_view_entity_list($photos, $max, 0, $max, false); + +// this view takes care of the title on the main column and the content wrapper +$area2 = elgg_view('tidypics/content_wrapper', array('title' => $title, 'content' => $content,)); +if (empty($area2)) { + $area2 = $content; +} + +$body = elgg_view_layout('two_column_left_sidebar', '', $area2); +page_draw($title, $body); diff --git a/pages/lists/recentlycommented.php b/pages/lists/recentlycommented.php index 1d5f7aea7..f070e8563 100644 --- a/pages/lists/recentlycommented.php +++ b/pages/lists/recentlycommented.php @@ -1,36 +1,36 @@ dbprefix; - $max_limit = 200; //get extra because you'll have multiple views per image in the result set - $max = 16; //controls how many actually show on screen - - //this works but is wildly inefficient - //$annotations = get_annotations(0, "object", "image", "tp_view", "", "", 5000); - - $sql = "SELECT distinct (ent.guid), ann1.time_created +// world view - set page owner to logged in user +if (isloggedin()) { + set_page_owner(get_loggedin_userid()); +} + +// allow other plugins to override the slideshow +$slideshow_link = trigger_plugin_hook('tp_slideshow', 'album', array(), null); +if ($slideshow_link) { + add_submenu_item(elgg_echo('album:slideshow'), + $slideshow_link, + 'photos' ); +} + + +global $CONFIG; +$prefix = $CONFIG->dbprefix; +$max_limit = 200; //get extra because you'll have multiple views per image in the result set +$max = 16; //controls how many actually show on screen + +//this works but is wildly inefficient +//$annotations = get_annotations(0, "object", "image", "tp_view", "", "", 5000); + +$sql = "SELECT distinct (ent.guid), ann1.time_created FROM " . $prefix . "entities ent INNER JOIN " . $prefix . "entity_subtypes sub ON ent.subtype = sub.id AND sub.subtype = 'image' @@ -39,34 +39,31 @@ AND ms.string = 'generic_comment' ORDER BY ann1.time_created DESC LIMIT $max_limit"; - - $result = get_data($sql); - $entities = array(); - foreach($result as $entity) { - if(!$entities[$entity->guid]) { - $entities[$entity->guid] = get_entity($entity->guid); - } - if(count($entities) >= $max) break; +$result = get_data($sql); + +$entities = array(); +foreach ($result as $entity) { + if (!$entities[$entity->guid]) { + $entities[$entity->guid] = get_entity($entity->guid); } - - $user = get_loggedin_user(); - if( $user->guid == 9 ) { - echo "
";
-		var_dump( $sql);
-//		var_dump( $result );
-		echo "
"; + if (count($entities) >= $max) { + break; } - $title = elgg_echo("tidypics:recentlycommented"); - $area2 = elgg_view_title($title); - - // grab the html to display the images - $images = tp_view_entity_list($entities, $max, 0, $max, false); - - // this view takes care of the title on the main column and the content wrapper - $area2 = elgg_view('tidypics/content_wrapper', array('title' => $title, 'content' => $images,)); - if( empty( $area2 )) $area2 = $images; - - $body = elgg_view_layout('two_column_left_sidebar', '', $area2); - page_draw($title, $body); -?> \ No newline at end of file +} + +$user = get_loggedin_user(); +$title = elgg_echo("tidypics:recentlycommented"); +$area2 = elgg_view_title($title); + +// grab the html to display the images +$images = tp_view_entity_list($entities, $max, 0, $max, false); + +// this view takes care of the title on the main column and the content wrapper +$area2 = elgg_view('tidypics/content_wrapper', array('title' => $title, 'content' => $images,)); +if (empty($area2)) { + $area2 = $images; +} + +$body = elgg_view_layout('two_column_left_sidebar', '', $area2); +page_draw($title, $body); diff --git a/pages/lists/recentlyviewed.php b/pages/lists/recentlyviewed.php index 16ad474df..419576d8e 100644 --- a/pages/lists/recentlyviewed.php +++ b/pages/lists/recentlyviewed.php @@ -1,36 +1,36 @@ dbprefix; - $max_limit = 200; //get extra because you'll have multiple views per image in the result set - $max = 16; //controls how many actually show on screen - - //this works but is wildly inefficient - //$annotations = get_annotations(0, "object", "image", "tp_view", "", "", 5000); - - $sql = "SELECT distinct ent.guid, ann1.time_created +// world view - set page owner to logged in user +if (isloggedin()) { + set_page_owner(get_loggedin_userid()); +} + +// allow other plugins to override the slideshow +$slideshow_link = trigger_plugin_hook('tp_slideshow', 'album', array(), null); +if ($slideshow_link) { + add_submenu_item(elgg_echo('album:slideshow'), + $slideshow_link, + 'photos' ); +} + + +global $CONFIG; +$prefix = $CONFIG->dbprefix; +$max_limit = 200; //get extra because you'll have multiple views per image in the result set +$max = 16; //controls how many actually show on screen + +//this works but is wildly inefficient +//$annotations = get_annotations(0, "object", "image", "tp_view", "", "", 5000); + +$sql = "SELECT distinct ent.guid, ann1.time_created FROM " . $prefix . "entities ent INNER JOIN " . $prefix . "entity_subtypes sub ON ent.subtype = sub.id AND sub.subtype = 'image' @@ -39,27 +39,30 @@ AND ms.string = 'tp_view' ORDER BY ann1.id DESC LIMIT $max_limit"; - - $result = get_data($sql); - $entities = array(); - foreach($result as $entity) { - if(!$entities[$entity->guid]) { - $entities[$entity->guid] = get_entity($entity->guid); - } - if(count($entities) >= $max) break; +$result = get_data($sql); + +$entities = array(); +foreach ($result as $entity) { + if (!$entities[$entity->guid]) { + $entities[$entity->guid] = get_entity($entity->guid); + } + if (count($entities) >= $max) { + break; } - - $title = elgg_echo("tidypics:recentlyviewed"); - $area2 = elgg_view_title($title); - - // grab the html to display the images - $images = tp_view_entity_list($entities, $max, 0, $max, false); - - // this view takes care of the title on the main column and the content wrapper - $area2 = elgg_view('tidypics/content_wrapper', array('title' => $title, 'content' => $images,)); - if( empty( $area2 )) $area2 = $images; - - $body = elgg_view_layout('two_column_left_sidebar', '', $area2); - page_draw($title, $body); -?> \ No newline at end of file +} + +$title = elgg_echo("tidypics:recentlyviewed"); +$area2 = elgg_view_title($title); + +// grab the html to display the images +$images = tp_view_entity_list($entities, $max, 0, $max, false); + +// this view takes care of the title on the main column and the content wrapper +$area2 = elgg_view('tidypics/content_wrapper', array('title' => $title, 'content' => $images,)); +if (empty($area2)) { + $area2 = $images; +} + +$body = elgg_view_layout('two_column_left_sidebar', '', $area2); +page_draw($title, $body); diff --git a/pages/newalbum.php b/pages/newalbum.php index fda886d52..535116237 100644 --- a/pages/newalbum.php +++ b/pages/newalbum.php @@ -1,32 +1,30 @@ 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 )); +// Load Elgg engine +include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php"; -?> \ No newline at end of file +// must be logged in to create a new album +gatekeeper(); + +// Get the current page's owner +$page_owner = page_owner_entity(); +if ($page_owner === false || is_null($page_owner)) { + $page_owner = get_loggedin_user(); + set_page_owner($page_owner->guid); +} + +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(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", '', $area2)); diff --git a/pages/ownedalbums.php b/pages/ownedalbums.php index d22c6d44a..67583c65c 100644 --- a/pages/ownedalbums.php +++ b/pages/ownedalbums.php @@ -1,53 +1,55 @@ username) || empty($owner->username)) { - forward('pg/photos/world'); - } +/** + * tidypics photo gallery album listing page for a person/group + * + * Shows all the albums that belong to that person or group + */ + +include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php"; + +// if this page belongs to a closed group, prevent anyone outside group from seeing +if (is_callable('group_gatekeeper')) { + group_gatekeeper(); +} + +//get the owner of the current page +$owner = page_owner_entity(); + + +//if page owner cannot be found, forward to world album list +if (is_null($owner->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'); - } + +// 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) - $content .= tp_list_entities("object", "album", 0, $owner->guid, 12, false); - else - $content .= tp_list_entities("object", "album", $owner->guid, $owner->guid, 12, false); - - $area2 = elgg_view('tidypics/content_wrapper', array('title' => $title, 'content' => $content,)); - - 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 +} + +//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) { + $content .= tp_list_entities("object", "album", 0, $owner->guid, 12, false); +} else { + $content .= tp_list_entities("object", "album", $owner->guid, $owner->guid, 12, false); +} + +$area2 = elgg_view('tidypics/content_wrapper', array('title' => $title, 'content' => $content,)); + +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/server_analysis.php b/pages/server_analysis.php index ccffc1632..db3aed5f6 100644 --- a/pages/server_analysis.php +++ b/pages/server_analysis.php @@ -8,48 +8,49 @@ * ********************************************************************/ - include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php"; +include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php"; - global $CONFIG; +global $CONFIG; - admin_gatekeeper(); +admin_gatekeeper(); - set_context('admin'); +set_context('admin'); - $title = 'TidyPics Server Analysis'; +$title = 'TidyPics Server Analysis'; - function tp_readable_size($bytes) - { - if (strpos($bytes, 'M')) - return $bytes . 'B'; - - $size = $bytes / 1024; +function tp_readable_size($bytes) { + if (strpos($bytes, 'M')) { + return $bytes . 'B'; + } + + $size = $bytes / 1024; + if ($size < 1024) { + $size = number_format($size, 2); + $size .= ' KB'; + } else { + $size = $size / 1024; if ($size < 1024) { $size = number_format($size, 2); - $size .= ' KB'; + $size .= ' MB'; } else { $size = $size / 1024; - if($size < 1024) { - $size = number_format($size, 2); - $size .= ' MB'; - } else { - $size = $size / 1024; - $size = number_format($size, 2); - $size .= ' GB'; - } + $size = number_format($size, 2); + $size .= ' GB'; } - return $size; } + return $size; +} - $disablefunc = explode(',', ini_get('disable_functions')); - $exec_avail = "Disabled"; - if (is_callable('exec') && !in_array('exec',$disablefunc)) - $exec_avail = "Enabled"; +$disablefunc = explode(',', ini_get('disable_functions')); +$exec_avail = "Disabled"; +if (is_callable('exec') && !in_array('exec',$disablefunc)) { + $exec_avail = "Enabled"; +} - ob_start(); +ob_start(); - echo elgg_view_title($title); +echo elgg_view_title($title); ?>
@@ -130,9 +131,8 @@ \ No newline at end of file +echo page_draw($title, $body); \ No newline at end of file diff --git a/pages/tagged.php b/pages/tagged.php index b5a879809..34ea8a709 100644 --- a/pages/tagged.php +++ b/pages/tagged.php @@ -1,50 +1,48 @@ 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 +/** + * Tidypics Tagged Listing + * + * List all photos tagged with a user + */ + +include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php"; + + +// Get user guid +$guid = get_input('guid'); + +$user = get_entity($guid); + +if ($user) { + $title = sprintf(elgg_echo('tidypics:usertag'), $user->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); diff --git a/pages/thumbnail.php b/pages/thumbnail.php index 3aad5969d..9daa2f9c0 100644 --- a/pages/thumbnail.php +++ b/pages/thumbnail.php @@ -1,76 +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(); +/** + * Tidypics Thumbnail + * + */ - // 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; +// Get file GUID +$file_guid = (int) get_input('file_guid'); - // 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; - \ No newline at end of file +// Get file thumbnail size +$size = get_input('size'); +// only 3 possibilities +if ($size != 'small' && $size != 'thumb') { + $size = 'large'; +} + +$error_image = ''; +switch ($size) { + case 'thumb': + $error_image = "image_error_thumb.png"; + break; + case 'small': + $error_image = "image_error_small.png"; + break; + case 'large': + $error_image = "image_error_large.png"; + break; +} + +// Get file entity +$file = get_entity($file_guid); +if (!$file) { + forward('mod/tidypics/graphics/' . $error_image); +} + +if ($file->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/pages/upload.php b/pages/upload.php index 5c123537e..6f8db288d 100644 --- a/pages/upload.php +++ b/pages/upload.php @@ -1,44 +1,44 @@ 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 ) ); +/** + * Tidypics Upload Images Page + * + */ + +include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php"; + +// must be logged in to upload images +gatekeeper(); + +$album_guid = (int) get_input('container_guid'); +if (!$album_guid) { + forward(); +} + +$album = get_entity($album_guid); + +//if album does not exist or user does not have access +if (!$album || !$album->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 ) ); // $area2 .= elgg_view("tidypics/forms/flash_upload", array('album' => $album_guid ) ); - $body = elgg_view_layout('two_column_left_sidebar', '', $area2); - - page_draw($title, $body); -?> \ No newline at end of file +$body = elgg_view_layout('two_column_left_sidebar', '', $area2); + +page_draw($title, $body); diff --git a/pages/viewalbum.php b/pages/viewalbum.php index 050b124cb..fe3c5bc62 100644 --- a/pages/viewalbum.php +++ b/pages/viewalbum.php @@ -1,68 +1,72 @@ container_guid) - set_page_owner($album->container_guid); - else - set_page_owner($album->owner_guid); +// container should always be set, but just in case +if ($album->container_guid) { + set_page_owner($album->container_guid); +} else { + set_page_owner($album->owner_guid); +} - $owner = page_owner_entity(); +$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', array('album' => $album), null); - if ($slideshow_link) { - add_submenu_item(elgg_echo('album:slideshow'), - $slideshow_link, - 'photos' ); - } +// setup group menu +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, $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); +// allow other plugins to override the slideshow +$slideshow_link = trigger_plugin_hook('tp_slideshow', 'album', array('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); +// 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 +page_draw($album->title, $body); diff --git a/pages/viewimage.php b/pages/viewimage.php index 025c1ad3b..890f7e8c4 100644 --- a/pages/viewimage.php +++ b/pages/viewimage.php @@ -1,58 +1,62 @@ owner_guid); - $album = get_entity($photo->container_guid); - if ($album) { - $owner_guid = $album->container_guid; - if ($owner_guid) - set_page_owner($owner_guid); +/** + * Tidypics image view + * + * Display a view of a single image + */ + +// Load Elgg engine +include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php"; + +// if this page belongs to a closed group, prevent anyone outside group from seeing +if (is_callable('group_gatekeeper')) { + group_gatekeeper(); +} + +// get the album entity +$photo_guid = (int) get_input('guid'); +$photo = get_entity($photo_guid); + +// panic if we can't get it +if (!$photo) { + forward(); +} + +// set page owner based on owner of photo album +set_page_owner($photo->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); - } +$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); +$title = $photo->title; +$area2 = elgg_view_title($title); +$area2 .= elgg_view_entity($photo, true); - $body = elgg_view_layout('two_column_left_sidebar', '', $area2); +$body = elgg_view_layout('two_column_left_sidebar', '', $area2); - page_draw($title, $body); -?> \ No newline at end of file +page_draw($title, $body); diff --git a/pages/world.php b/pages/world.php index 48a3345d4..fe97a882d 100644 --- a/pages/world.php +++ b/pages/world.php @@ -1,29 +1,28 @@ $title, 'content' => $content,)); - - $body = elgg_view_layout('two_column_left_sidebar', '', $area2); - - page_draw($title, $body); -?> \ No newline at end of file +/** + * Tidypics View All Albums on Site + * + */ + +include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php"; + +// set page owner to logged in user +if (isloggedin()) { + set_page_owner(get_loggedin_userid()); +} + +$num_albums = 16; + +$title = elgg_echo('album:all'); +$area2 = elgg_view_title($title); + +set_context('search'); +set_input('search_viewtype', 'gallery'); +$content .= tp_list_entities('object','album', 0, null, $num_albums, false); +set_context('photos'); + +$area2 = elgg_view('tidypics/content_wrapper', array('title' => $title, 'content' => $content,)); + +$body = elgg_view_layout('two_column_left_sidebar', '', $area2); + +page_draw($title, $body); diff --git a/start.php b/start.php index dc7debcd6..baaf33f2b 100644 --- a/start.php +++ b/start.php @@ -1,446 +1,468 @@ wwwroot . "pg/photos/owned/" . $_SESSION['user']->username); - } - - // Extend CSS - elgg_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'); +/** + * Elgg tidypics + * + */ + +// set some simple defines +define('TP_OLD_ALBUM', 0); +define('TP_NEW_ALBUM', 1); + +// include core libraries +include dirname(__FILE__) . "/lib/tidypics.php"; +include dirname(__FILE__) . "/lib/image.php"; +include dirname(__FILE__) . "/lib/album.php"; + +/** + * tidypics plugin initialisation functions. + */ +function tidypics_init() { + global $CONFIG; + + // Set up menu for logged in users + if (isloggedin()) { + add_menu(elgg_echo('photos'), $CONFIG->wwwroot . "pg/photos/owned/" . $_SESSION['user']->username); } - - /** - * 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); - } + + // 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 recent", "your most viewed" - 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'); - - add_submenu_item( elgg_echo('tidypics:yourmostrecent'), - $CONFIG->wwwroot . "pg/photos/mostrecent/{$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'); - } - - } 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 recent", "your most viewed" - add_submenu_item( elgg_echo("album:yours"), - $CONFIG->wwwroot . "pg/photos/owned/{$user->username}/", - 'tidypics-b' ); - - add_submenu_item( elgg_echo('tidypics:yourmostrecent'), - $CONFIG->wwwroot . "pg/photos/mostrecent/{$user->username}/", - 'tidypics-b'); - - if ($view_count != 'disabled') { - add_submenu_item( elgg_echo('tidypics:yourmostviewed'), - $CONFIG->wwwroot . "pg/photos/mostviewed/{$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'); + } + // 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 recent", "your most viewed" + 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'); + + add_submenu_item( elgg_echo('tidypics:yourmostrecent'), + $CONFIG->wwwroot . "pg/photos/mostrecent/{$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'); } - - // 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'); - + + } 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 recent", "your most viewed" + add_submenu_item( elgg_echo("album:yours"), + $CONFIG->wwwroot . "pg/photos/owned/{$user->username}/", + 'tidypics-b' ); + + add_submenu_item( elgg_echo('tidypics:yourmostrecent'), + $CONFIG->wwwroot . "pg/photos/mostrecent/{$user->username}/", + 'tidypics-b'); + 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:yourmostviewed'), + $CONFIG->wwwroot . "pg/photos/mostviewed/{$user->username}/", + 'tidypics-b'); } - add_submenu_item( elgg_echo('tidypics:recentlycommented'), - $CONFIG->wwwroot . 'pg/photos/recentlycommented/', - 'tidypics-z'); -/* + + 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 tidypics admin menu. Triggered on pagesetup. + */ +function tidypics_adminmenu() { + global $CONFIG; - /** - * 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/'); + 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) { - /** - * 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"); + 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"); + 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"); + 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"); + 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"); + 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"); + 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"); + 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"); + 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"); + + 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 "thumbnail": // tidypics thumbnail - if (isset($page[1])) set_input('file_guid', $page[1]); - if (isset($page[2])) set_input('size', $page[2]); - include($CONFIG->pluginspath . "tidypics/pages/thumbnail.php"); + + case "thumbnail": // tidypics thumbnail + if (isset($page[1])) { + set_input('file_guid', $page[1]); + } + if (isset($page[2])) { + set_input('size', $page[2]); + } + include($CONFIG->pluginspath . "tidypics/pages/thumbnail.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"); + + 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"); + 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"); + + 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"); + + 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"); + + 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"); + + 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"); + + 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"); } - + } + 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; +/** + * 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); } - function tidypics_album_url($entity) { - global $CONFIG; - $title = $entity->title; - $title = friendly_title($title); - return $CONFIG->url . "pg/photos/album/" . $entity->getGUID() . "/" . $title; + 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); } - - - /** - * 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 - arry containing 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; +} + + +/** + * 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; } - - $slideshow_link = "javascript:PicLensLite.start({maxScale:0,feedUrl:location.href+'?view=rss'})"; - - // add the slideshow javascript to the header - extend_view('metatags', 'tidypics/js/slideshow'); - - return $slideshow_link; + + $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(); } - - function tp_mostrecentimages($max = 8, $pagination = true) { - return list_entities("object", "image", 0, $max, false, false, $pagination); + 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 - arry containing 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; } - - - // 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 + + $slideshow_link = "javascript:PicLensLite.start({maxScale:0,feedUrl:location.href+'?view=rss'})"; + + // add the slideshow javascript to the header + extend_view('metatags', 'tidypics/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 initialization +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"); diff --git a/thumbnail.php b/thumbnail.php index 79d487210..f9f9d1e5f 100644 --- a/thumbnail.php +++ b/thumbnail.php @@ -1,78 +1,80 @@ 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(); +include_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); - // 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; +// Get file GUID +$file_guid = (int) get_input('file_guid'); - // 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; -?> +// Get file thumbnail size +$size = get_input('size'); +// only 3 possibilities +if ($size != 'small' && $size != 'thumb') { + $size = 'large'; +} + +$error_image = ''; +switch ($size) { + case 'thumb': + $error_image = "image_error_thumb.png"; + break; + case 'small': + $error_image = "image_error_small.png"; + break; + case 'large': + $error_image = "image_error_large.png"; + break; +} + +// Get file entity +$file = get_entity($file_guid); +if (!$file) { + forward('mod/tidypics/graphics/' . $error_image); +} + +if ($file->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 8156a4bb4..f81f2b55c 100644 --- a/views/default/annotation/annotate.php +++ b/views/default/annotation/annotate.php @@ -1,21 +1,20 @@ 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'); +$performed_by = get_entity($vars['item']->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 . ""; +$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 +echo $string; diff --git a/views/default/object/album.php b/views/default/object/album.php index 85dd69ac9..0db0d3e49 100644 --- a/views/default/object/album.php +++ b/views/default/object/album.php @@ -1,22 +1,22 @@ getGUID(); - $owner = $album->getOwnerEntity(); - $tags = $album->tags; - $title = $album->title; - $desc = $album->description; - $friendlytime = friendly_time($album->time_created); - $mime = $album->mimetype; +global $CONFIG; - if (get_context() == "search") { +$album = $vars['entity']; +$album_guid = $album->getGUID(); +$owner = $album->getOwnerEntity(); +$tags = $album->tags; +$title = $album->title; +$desc = $album->description; +$friendlytime = friendly_time($album->time_created); +$mime = $album->mimetype; - if (get_input('search_viewtype') == "gallery") { +if (get_context() == "search") { + + if (get_input('search_viewtype') == "gallery") { /****************************************************************************** * @@ -27,30 +27,31 @@ * *****************************************************************************/ - //get album cover if one was set - if ($album->cover) - $album_cover = '' . $title . ''; - else - $album_cover = 'new album'; - + //get album cover if one was set + if ($album->cover) { + $album_cover = '' . $title . ''; + } else { + $album_cover = 'new album'; + } ?> ' . $title . '

'; - $info .= "

username}\">{$owner->name} {$friendlytime}"; - $numcomments = elgg_count_comments($album); - if ($numcomments) - $info .= ", getURL()}\">" . sprintf(elgg_echo("comments")) . " (" . $numcomments . ")"; - $info .= "

"; - - //get album cover if one was set - if ($album->cover) - $icon = "getURL()}\">" . 'thumbnail'; - else - $icon = "getURL()}\">" . 'new album'; - - echo elgg_view_listing($icon, $info); + $info = '

' . $title . '

'; + $info .= "

username}\">{$owner->name} {$friendlytime}"; + $numcomments = elgg_count_comments($album); + if ($numcomments) { + $info .= ", getURL()}\">" . sprintf(elgg_echo("comments")) . " (" . $numcomments . ")"; } - } else { + $info .= "

"; + + //get album cover if one was set + if ($album->cover) { + $icon = "getURL()}\">" . 'thumbnail'; + } else { + $icon = "getURL()}\">" . 'new album'; + } + echo elgg_view_listing($icon, $info); + } +} else { /****************************************************************************** * @@ -86,76 +88,76 @@ * *****************************************************************************/ - $page = get_input("page"); - list($album_placeholder, $album_id, $album_title) = split("/", $page); - - $photo_ratings = get_plugin_setting('photo_ratings', 'tidypics'); - if ($photo_ratings == "enabled") - add_submenu_item( elgg_echo("tidypics:highestrated"), - $CONFIG->wwwroot . "pg/photos/highestrated/group:" . $album_id, - 'photos'); - - echo elgg_view_title($title); + $page = get_input("page"); + list($album_placeholder, $album_id, $album_title) = split("/", $page); + + $photo_ratings = get_plugin_setting('photo_ratings', 'tidypics'); + if ($photo_ratings == "enabled") { + add_submenu_item( elgg_echo("tidypics:highestrated"), + $CONFIG->wwwroot . "pg/photos/highestrated/group:" . $album_id, + 'photos'); + } + echo elgg_view_title($title); ?>
- +
-' . autop($desc) . '
'; - - $images = get_entities("object", "image", $album_guid, '', 999); - - //build array for back | next links - $_SESSION['image_sort'] = array(); - - if (is_array($images)) { - foreach ($images as $image) { - array_push($_SESSION['image_sort'], $image->guid); - } - - // display the simple image views. Uses 'object/image' view - echo list_entities("object", "image", $album_guid, 24, false); - - $num_images = count($images); - } else { - echo '
' . elgg_echo('image:none') . '
'; - $num_images = 0; +' . autop($desc) . ''; + + $images = get_entities("object", "image", $album_guid, '', 999); + + //build array for back | next links + $_SESSION['image_sort'] = array(); + + if (is_array($images)) { + foreach ($images as $image) { + array_push($_SESSION['image_sort'], $image->guid); } - + + // display the simple image views. Uses 'object/image' view + echo list_entities("object", "image", $album_guid, 24, false); + + $num_images = count($images); + } else { + echo '
' . elgg_echo('image:none') . '
'; + $num_images = 0; + } + ?>
-
$tags));?>
- - name; ?>
-
+ name; ?>
+

-: - : +
'; - } // end of individual album view -?> + if ($vars['full']) { + echo elgg_view_comments($album); + } + + echo ''; +} // end of individual album view + diff --git a/views/default/object/image.php b/views/default/object/image.php index ee81d800f..cd53120de 100644 --- a/views/default/object/image.php +++ b/views/default/object/image.php @@ -1,19 +1,19 @@ getGUID(); - $tags = $image->tags; - $title = $image->title; - $desc = $image->description; - $owner = $image->getOwnerEntity(); - $friendlytime = friendly_time($image->time_created); +$image = $vars['entity']; +$image_guid = $image->getGUID(); +$tags = $image->tags; +$title = $image->title; +$desc = $image->description; +$owner = $image->getOwnerEntity(); +$friendlytime = friendly_time($image->time_created); /******************************************************************** @@ -21,69 +21,65 @@ * search view of an image * ********************************************************************/ - if (get_context() == "search") { +if (get_context() == "search") { - // gallery view is a matrix view showing just the image - size: small - if (get_input('search_viewtype') == "gallery") { - ?> -
- thumbnail -
- '.$title.'

'; - $info .= "

username}\">{$owner->name} {$friendlytime}"; - $numcomments = elgg_count_comments($image); - if ($numcomments) - $info .= ", getURL()}\">" . sprintf(elgg_echo("comments")) . " (" . $numcomments . ")"; - $info .= "

"; - $icon = "getURL()}\">" . '' . $title . ''; - - echo elgg_view_listing($icon, $info); + // gallery view is a matrix view showing just the image - size: small + if (get_input('search_viewtype') == "gallery") { +?> +
+ thumbnail +
+'.$title.'

'; + $info .= "

username}\">{$owner->name} {$friendlytime}"; + $numcomments = elgg_count_comments($image); + if ($numcomments) { + $info .= ", getURL()}\">" . sprintf(elgg_echo("comments")) . " (" . $numcomments . ")"; } + $info .= "

"; + $icon = "getURL()}\">" . '' . $title . ''; + + echo elgg_view_listing($icon, $info); + } /*************************************************************** * * front page view * ****************************************************************/ - } else if (get_context() == "front") { - // the front page view is a clikcable thumbnail of the image +} else if (get_context() == "front") { + // the front page view is a clickable thumbnail of the image ?> -<?php echo $title; ?> + <?php echo $title; ?> - - $image), $image_html); - - if ($image_html) { - echo $image_html; - } else { - // default link to image if no one overrides -?> -
- <?php echo $image->title; ?> -
- $image), $image_html); + + if ($image_html) { + echo $image_html; + } else { + // default link to image if no one overrides ?> +
+ <?php echo $image->title; ?> +
container_guid); - $current = array_search($image_guid, $_SESSION['image_sort']); + // Build back and next links + $back = ''; + $next = ''; - if (!$current) { // means we are no longer using the correct album array + $album = get_entity($image->container_guid); - //rebuild the array - $count = get_entities("object","image", $album->guid, '', 999); - $_SESSION['image_sort'] = array(); + $current = array_search($image_guid, $_SESSION['image_sort']); - foreach ($count as $img) { - array_push($_SESSION['image_sort'], $img->guid); - } + if (!$current) { // means we are no longer using the correct album array - if ($_SESSION['image_sort']) - $current = array_search($image_guid, $_SESSION['image_sort']); + //rebuild the array + $count = get_entities("object","image", $album->guid, '', 999); + $_SESSION['image_sort'] = array(); + + foreach ($count as $img) { + array_push($_SESSION['image_sort'], $img->guid); } - if ($current != 0) - $back = '« ' . elgg_echo('image:back') . ''; + if ($_SESSION['image_sort']) { + $current = array_search($image_guid, $_SESSION['image_sort']); + } + } - if (sizeof($_SESSION['image_sort']) > $current + 1) - $next = '' . elgg_echo('image:next') . ' »'; + if ($current != 0) { + $back = '« ' . elgg_echo('image:back') . ''; + } + if (sizeof($_SESSION['image_sort']) > $current + 1) { + $next = '' . elgg_echo('image:next') . ' »'; + } ?>
- $album,) ); ?>
- addView($viewer->guid); - $views = $image->getViews($viewer->guid); - if (is_array($views)) { - echo sprintf(elgg_echo("tidypics:views"), $views['total']); - if ($owner->guid == $viewer->guid) { - echo ' ' . sprintf(elgg_echo("tidypics:viewsbyowner"), $views['unique']); - } - else { - if ($views['mine']) - echo ' ' . sprintf(elgg_echo("tidypics:viewsbyothers"), $views['mine']); + $album,) ); ?>
+addView($viewer->guid); + $views = $image->getViews($viewer->guid); + if (is_array($views)) { + echo sprintf(elgg_echo("tidypics:views"), $views['total']); + if ($owner->guid == $viewer->guid) { + echo ' ' . sprintf(elgg_echo("tidypics:viewsbyowner"), $views['unique']); + } else { + if ($views['mine']) { + echo ' ' . sprintf(elgg_echo("tidypics:viewsbyothers"), $views['mine']); + } + } } } - } - ?> +?>
- +
    @@ -159,73 +157,74 @@
- "; - $image_html .= "\"{$title}\""; - $image_html .= ""; - } else { - $image_html = "\"{$title}\""; - } - // does any plugin want to override the link - $image_html = trigger_plugin_hook('tp_thumbnail_link', 'image', array('image' => $image), $image_html); - echo $image_html; - ?> + "; + $image_html .= "\"{$title}\""; + $image_html .= ""; + } else { + $image_html = "\"{$title}\""; + } + // does any plugin want to override the link + $image_html = trigger_plugin_hook('tp_thumbnail_link', 'image', array('image' => $image), $image_html); + echo $image_html; + ?>
-
    '; - echo elgg_view('tidypics/image_menu', array('image_guid' => $image_guid, - 'viewer' => $viewer, - 'owner' => $owner, - 'anytags' => $image->isPhotoTagged(), - 'album' => $album, ) ); - echo '
'; - - // tagging code - photo tags on images, photo tag listing and hidden divs used in tagging - if (get_plugin_setting('tagging', 'tidypics') != "disabled") { - echo elgg_view('tidypics/tagging', array( 'image' => $image, - 'viewer' => $viewer, - 'owner' => $owner, ) ); - } - - - if (get_plugin_setting('exif', 'tidypics') == "enabled") { +
    '; + echo elgg_view('tidypics/image_menu', array( + 'image_guid' => $image_guid, + 'viewer' => $viewer, + 'owner' => $owner, + 'anytags' => $image->isPhotoTagged(), + 'album' => $album, ) ); + echo '
'; + + // tagging code - photo tags on images, photo tag listing and hidden divs used in tagging + if (get_plugin_setting('tagging', 'tidypics') != "disabled") { + echo elgg_view('tidypics/tagging', array( + 'image' => $image, + 'viewer' => $viewer, + 'owner' => $owner, ) ); + } + + + if (get_plugin_setting('exif', 'tidypics') == "enabled") { + echo elgg_view('tidypics/exif', array('guid'=> $image_guid)); + } ?> - $image_guid)); ?> -
- +
$tags));?>
-
- $vars['entity'])); ?> -
+ $vars['entity'])); ?> +
name; ?> name; ?> '; - - echo ''; // content wrapper + echo elgg_view_comments($image); - } // end of individual image display + echo '
'; - } - -?> + echo ''; // content wrapper + } // end of individual image display +} diff --git a/views/default/river/object/album/create.php b/views/default/river/object/album/create.php index 20f9293d7..ef50f9988 100644 --- a/views/default/river/object/album/create.php +++ b/views/default/river/object/album/create.php @@ -1,42 +1,41 @@ 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(); +$performed_by = get_entity($vars['item']->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"/>' . "
"; } - - $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 { +} else { - $string .= "
"; - - $images = get_entities("object", "image", $album->guid, 'time_created desc', 7); + $string .= "
"; - 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"/> '; - } - } + $images = get_entities("object", "image", $album->guid, 'time_created desc', 7); - $string .= "
"; + 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"/> '; + } } -echo $string; + $string .= "
"; +} -?> +echo $string; diff --git a/views/default/river/object/image/create.php b/views/default/river/object/image/create.php index cd2351a2e..188fc6ff1 100644 --- a/views/default/river/object/image/create.php +++ b/views/default/river/object/image/create.php @@ -1,29 +1,27 @@ subject_guid); - $image = get_entity($vars['item']->object_guid); - if($image->title) { - $title = $image->title; - } else { - $title = "untitled"; - } +$performed_by = get_entity($vars['item']->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); +$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"), $url, $image_link, $album_link); - - $string .= ""; -?> \ No newline at end of file +echo $string; diff --git a/views/default/river/object/image/tag.php b/views/default/river/object/image/tag.php index 1b3589afb..961761c99 100644 --- a/views/default/river/object/image/tag.php +++ b/views/default/river/object/image/tag.php @@ -1,23 +1,22 @@ 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; +$image = get_entity($vars['item']->subject_guid); +$person_tagged = get_entity($vars['item']->object_guid); +if ($image->title) { + $title = $image->title; +} else { + $title = "untitled"; +} -?> \ No newline at end of file +// 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; diff --git a/views/default/settings/tidypics/edit.php b/views/default/settings/tidypics/edit.php index eb391c8bc..a6b2c2d0c 100644 --- a/views/default/settings/tidypics/edit.php +++ b/views/default/settings/tidypics/edit.php @@ -1,7 +1,7 @@ wwwroot . 'mod/tidypics/pages/server_analysis.php'; - $settings_url = $CONFIG->wwwroot . 'mod/tidypics/pages/admin.php'; +global $CONFIG; +$system_url = $CONFIG->wwwroot . 'mod/tidypics/pages/server_analysis.php'; +$settings_url = $CONFIG->wwwroot . 'mod/tidypics/pages/admin.php'; ?>

diff --git a/views/default/tidypics/admin/imagelib.php b/views/default/tidypics/admin/imagelib.php index b4656afe1..a0d0c19e7 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; +$img_type = get_subtype_id('object', 'image'); +$query = "SELECT count(guid) as total from {$CONFIG->dbprefix}entities where subtype={$img_type}"; +$total = get_data_row($query); +$num_images = $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'); +$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. + 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. + 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 ce5652c16..bc0befa16 100644 --- a/views/default/tidypics/admin/settings.php +++ b/views/default/tidypics/admin/settings.php @@ -1,26 +1,26 @@ 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_url = elgg_add_action_tokens_to_url($upgrade_url); - - $upgrade = false; - if (!get_subtype_class('object', 'image') || !get_subtype_class('object', 'album')) - $upgrade = true; +echo elgg_view('output/longtext', array('value' => 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_url = elgg_add_action_tokens_to_url($upgrade_url); + +$upgrade = false; +if (!get_subtype_class('object', 'image') || !get_subtype_class('object', 'album')) { + $upgrade = true; +} ?>

- -Upgrade
- + Upgrade
+ -Run Server Analysis + ?> + Run Server Analysis

\ No newline at end of file +echo elgg_view("tidypics/forms/settings"); diff --git a/views/default/tidypics/admin/stats.php b/views/default/tidypics/admin/stats.php index aea5e75ba..0b088dc2e 100644 --- a/views/default/tidypics/admin/stats.php +++ b/views/default/tidypics/admin/stats.php @@ -1,35 +1,36 @@ 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; +$img_type = get_subtype_id('object', 'image'); +$query = "SELECT count(guid) as total from {$CONFIG->dbprefix}entities where subtype={$img_type}"; +$total = get_data_row($query); +$num_images = $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'); +$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:
+
+ Photos:
+ Albums:
+ Comments on photos:
+ Comments on albums:
+ Total views:
-Photo tags:
+ Photo tags:

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

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

    '; - } else { - echo '

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

    '; - } - + +
    + 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") . '

    '; - } +} + +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 +//close album_widget_container div +echo ""; diff --git a/views/default/tidypics/breadcrumbs.php b/views/default/tidypics/breadcrumbs.php index c4d347e6e..e9f491b38 100644 --- a/views/default/tidypics/breadcrumbs.php +++ b/views/default/tidypics/breadcrumbs.php @@ -1,22 +1,23 @@ 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); +$first_level_text = ''; +$first_level_link = $CONFIG->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(); -?> +$second_level_text = ''; +if (isset($vars['album'])) { + $second_level_text = $vars['album']->title; + $second_level_link = $vars['album']->getURL(); + ?> >> - + '; - foreach ($exif as $name => $value) { - echo $name . ': ' . $value . '
    '; - } - echo ''; +$guid = $vars['guid']; + +$exif = tp_exif_formatted($guid); +if ($exif) { + 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 1758d14f4..74d8e85ec 100644 --- a/views/default/tidypics/forms/edit.php +++ b/views/default/tidypics/forms/edit.php @@ -1,45 +1,42 @@ title; - $body = $vars['entity']->description; - $tags = $vars['entity']->tags; - $access_id = $vars['entity']->access_id; - $subtype = $vars['subtype']; +/** + * Tidypics images edit/add form + * This form is used to: + * - create albums + * - edit albums + * - edit images + */ + +//set stuff if we are editing existing album or image +if (isset($vars['entity'])) { + $action = "tidypics/edit"; + $title = $vars['entity']->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(); +} else { + $action = "tidypics/addalbum"; + $tags = ""; + $title = ""; + $body = ""; + $access_id = ACCESS_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(); ?>
    @@ -48,79 +45,79 @@ "tidypicstitle", "value" => $title,)); ?>

    - + ?>

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

    - + ?>

    - "tidypicsbody","value" => $body,"class" => 'tidypics_caption_input')); ?> + "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) { - -?> + + if ($cover_guid != $img_guid) { + + ?>

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

    - + ?>

    - +

    - -

    - + +

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

    +

    - - - + + + ?>

    diff --git a/views/default/tidypics/forms/edit_multi.php b/views/default/tidypics/forms/edit_multi.php index 4031b7968..c16c8eea9 100644 --- a/views/default/tidypics/forms/edit_multi.php +++ b/views/default/tidypics/forms/edit_multi.php @@ -1,7 +1,7 @@
    @@ -11,9 +11,11 @@ // make sure one of the images becomes the cover if there isn't one already $album_entity = get_entity($vars['album_guid']); - if (!$album_entity->cover) $no_cover = true; + if (!$album_entity->cover) { + $no_cover = true; + } - foreach ($file_array as $key => $file_guid){ + foreach ($file_array as $key => $file_guid) { $entity = get_entity($file_guid); $guid = $entity->guid; $body = $entity->description; diff --git a/views/default/tidypics/forms/settings.php b/views/default/tidypics/forms/settings.php index 0729b536b..e7d05adcc 100644 --- a/views/default/tidypics/forms/settings.php +++ b/views/default/tidypics/forms/settings.php @@ -1,158 +1,182 @@ version) { - set_plugin_setting('version', 1.62, 'tidypics'); +/** + * Tidypics admin settings form + */ + + + +$action = $vars['url'] . 'action/tidypics/settings'; + +$plugin = find_plugin_settings('tidypics'); + + +// bootstrap the plugin version here for now +if (!$plugin->version) { + set_plugin_setting('version', 1.62, 'tidypics'); +} + + +// Main settings +$form_body = '

    ' . elgg_echo('tidypics:settings:heading:main') . '

    '; + +// 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)) . "

    "; + +// Image Library +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'; + +$form_body .= '

    ' . elgg_echo('tidypics:settings:heading:img_lib') . '

    '; +$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/"; } - - - // Main settings - $form_body = '

    ' . elgg_echo('tidypics:settings:heading:main') . '

    '; - - // 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)) . "

    "; - - // Image Library - 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'; - - $form_body .= '

    ' . elgg_echo('tidypics:settings:heading:img_lib') . '

    '; - $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)) . "

    "; - } - - - // River Image options - $form_body .= '

    ' . elgg_echo('tidypics:settings:heading:river') . '

    '; - $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 - $form_body .= '

    ' . elgg_echo('tidypics:settings:heading:sizes') . '

    '; - $form_body .= "
    You must edit the css if you change the default 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 and height:    '; - //$form_body .= 'height:

    '; - - $form_body .= "

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

    '; - - - // Group permission override - $form_body .= '

    ' . elgg_echo('tidypics:settings:heading:groups') . '

    '; - $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)); + $form_body .= "

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

    "; +} + + +// River Image options +$form_body .= '

    ' . elgg_echo('tidypics:settings:heading:river') . '

    '; +$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 +$form_body .= '

    ' . elgg_echo('tidypics:settings:heading:sizes') . '

    '; +$form_body .= "
    You must edit the css if you change the default 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 and height:    '; +//$form_body .= 'height:

    '; + +$form_body .= "

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

    '; + + +// Group permission override +$form_body .= '

    ' . elgg_echo('tidypics:settings:heading:groups') . '

    '; +$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/forms/setupFlickr.php b/views/default/tidypics/forms/setupFlickr.php index 8c31d0883..3a9c76d11 100644 --- a/views/default/tidypics/forms/setupFlickr.php +++ b/views/default/tidypics/forms/setupFlickr.php @@ -39,4 +39,3 @@ $form_body .= elgg_view('input/submit', array('value' => elgg_echo("save"))); flickr_menu(); echo elgg_view('input/form', array('action' => $action, 'body' => $form_body)); -?> \ No newline at end of file diff --git a/views/default/tidypics/forms/upload.php b/views/default/tidypics/forms/upload.php index 6e755612c..691d9701b 100644 --- a/views/default/tidypics/forms/upload.php +++ b/views/default/tidypics/forms/upload.php @@ -1,78 +1,83 @@ access_id; +global $CONFIG; - $maxfilesize = (float) get_plugin_setting('maxfilesize','tidypics'); - if (!$maxfilesize) - $maxfilesize = 5; - - $quota = get_plugin_setting('quota','tidypics'); - if ($quota) { - $image_repo_size_md = get_metadata_byname($album->container_guid, "image_repo_size"); - $image_repo_size = (int)$image_repo_size_md->value; - $image_repo_size = $image_repo_size / 1024 / 1024; - $quote_percentage = round(100 * ($image_repo_size / $quota)); - // for small quotas, so one decimal place - if ($quota < 10) { - $image_repo_size = sprintf('%.1f', $image_repo_size); - } else { - $image_repo_size = round($image_repo_size); - } - if ($image_repo_size > $quota) { - $image_repo_size = $quota; - } +//this is for image uploads only. Image edits are handled by edit.php form + +$container_guid = get_input('container_guid'); +$album = get_entity($vars['album']); +$access_id = $album->access_id; + +$maxfilesize = (float) get_plugin_setting('maxfilesize','tidypics'); +if (!$maxfilesize) { + $maxfilesize = 5; +} + +$quota = get_plugin_setting('quota','tidypics'); +if ($quota) { + $image_repo_size_md = get_metadata_byname($album->container_guid, "image_repo_size"); + $image_repo_size = (int)$image_repo_size_md->value; + $image_repo_size = $image_repo_size / 1024 / 1024; + $quote_percentage = round(100 * ($image_repo_size / $quota)); + // for small quotas, so one decimal place + if ($quota < 10) { + $image_repo_size = sprintf('%.1f', $image_repo_size); + } else { + $image_repo_size = round($image_repo_size); + } + if ($image_repo_size > $quota) { + $image_repo_size = $quota; } +} ?>
    - -

    -
    -
    - -
    - + ?> +

    +
    +
    + +
    +

    -
    +
    ...
      -' . elgg_view("input/file",array('internalname' => "upload_$x")) . ''; - } -?> + } + ?>

    -'; - if ($access_id) - echo ''; -?> + '; + } + if ($access_id) { + echo ''; + } + ?> " onclick="displayProgress();" />

    "{$vars['url']}action/tidypics/upload", - 'body' => $form_body, - 'internalid' => 'tidypicsUpload', - 'enctype' => 'multipart/form-data', - 'method' => 'post',)); +$form_body = ob_get_clean(); + +echo elgg_view('input/form', array( + 'action' => "{$vars['url']}action/tidypics/upload", + 'body' => $form_body, + 'internalid' => 'tidypicsUpload', + 'enctype' => 'multipart/form-data', + 'method' => 'post',) +); ?>
    \ No newline at end of file diff --git a/views/default/tidypics/groupprofile_albums.php b/views/default/tidypics/groupprofile_albums.php index 7cb89bf1c..85b32425e 100644 --- a/views/default/tidypics/groupprofile_albums.php +++ b/views/default/tidypics/groupprofile_albums.php @@ -15,4 +15,3 @@ if ($vars['entity']->photos_enable != 'no') { echo elgg_view('tidypics/albums', array('num_albums' => 5)); echo '
    '; } -?> \ No newline at end of file diff --git a/views/default/tidypics/image_menu.php b/views/default/tidypics/image_menu.php index 498cfe724..50ada2193 100644 --- a/views/default/tidypics/image_menu.php +++ b/views/default/tidypics/image_menu.php @@ -1,51 +1,50 @@ 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) { +/************************************************************************** + * + * Tidypics Image Menu + * + * This is the menu that appears below an image. Admins can override the + * menu with a different view to provide a look and feel that matches + * their themes. The view can be extended to provide additional controls. + * + **************************************************************************/ + +$image_guid = $vars['image_guid']; +$viewer = $vars['viewer']; +$owner = $vars['owner']; +$anytags = $vars['anytags']; +$album = $vars['album']; + +if (get_plugin_setting('tagging', 'tidypics') != "disabled") { + + $can_tag = false; + + $container = get_entity($album->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) { + } + + // only owner can delete tags + if ($anytags && $viewer && $viewer->guid == $owner->guid) { ?>
  • \ No newline at end of file +} diff --git a/views/default/tidypics/tagging.php b/views/default/tidypics/tagging.php index 251534b80..2993fe71b 100644 --- a/views/default/tidypics/tagging.php +++ b/views/default/tidypics/tagging.php @@ -1,32 +1,32 @@ getPhotoTags(); +// get photo tags +$tag_info = $image->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) { +// 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) { ?>

    @@ -34,10 +34,10 @@

    -"; @@ -45,30 +45,30 @@ $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) { @@ -77,7 +77,7 @@ } $content .= ""; - $content .= ""; + $content .= ""; echo elgg_view('input/form', array('internalname' => 'phototag_deletetag_form', 'action' => "{$vars['url']}action/tidypics/deletetag", 'method' => 'post', 'body' => $content)); @@ -85,5 +85,4 @@ ?>
    $photo_tags_json,) ); -?> \ No newline at end of file +echo elgg_view('tidypics/js/tagging', array('photo_tags_json' => $photo_tags_json,) ); diff --git a/views/default/widgets/album_view/edit.php b/views/default/widgets/album_view/edit.php index 992699cb0..9068ffe17 100644 --- a/views/default/widgets/album_view/edit.php +++ b/views/default/widgets/album_view/edit.php @@ -1,11 +1,12 @@

    num_display == '') $vars['entity']->num_display = 5; - +echo elgg_echo("tidypics:widget:num_albums") . ": "; + + +if ($vars['entity']->num_display == '') { + $vars['entity']->num_display = 5; +} ?> diff --git a/views/default/widgets/latest_photos/view.php b/views/default/widgets/latest_photos/view.php index 0c3193907..d6bc4a0df 100644 --- a/views/default/widgets/latest_photos/view.php +++ b/views/default/widgets/latest_photos/view.php @@ -1,15 +1,16 @@

    num_display; - //if no number has been set, default to 6 - if (!$number) - $number = 6; +//the number of files to display +$number = (int) $vars['entity']->num_display; +//if no number has been set, default to 6 +if (!$number) { + $number = 6; +} - echo '
    '; - echo tp_get_latest_photos($number, page_owner()); - echo '
    '; +echo '
    '; +echo tp_get_latest_photos($number, page_owner()); +echo '
    '; ?>
    \ No newline at end of file diff --git a/views/rss/object/album.php b/views/rss/object/album.php index 8542b95f4..34cf58395 100644 --- a/views/rss/object/album.php +++ b/views/rss/object/album.php @@ -51,4 +51,3 @@ if (get_context() == "search" && get_input('search_viewtype') == "gallery") { } } -?> \ No newline at end of file diff --git a/views/rss/object/file.php b/views/rss/object/file.php index 36740f003..1ede661ad 100644 --- a/views/rss/object/file.php +++ b/views/rss/object/file.php @@ -1,16 +1,16 @@ title; - if (empty($title)) { - $title = substr($vars['entity']->description,0,32); - if (strlen($vars['entity']->description) > 32) - $title .= " ..."; +$title = $vars['entity']->title; +if (empty($title)) { + $title = substr($vars['entity']->description,0,32); + if (strlen($vars['entity']->description) > 32) { + $title .= " ..."; } - +} ?> diff --git a/views/rss/tidypics/gallery.php b/views/rss/tidypics/gallery.php index 2c285fca5..0e90a8c44 100644 --- a/views/rss/tidypics/gallery.php +++ b/views/rss/tidypics/gallery.php @@ -1,7 +1,7 @@ 0) { echo elgg_view_entity($entity); } } - -?> \ No newline at end of file -- cgit v1.2.3