diff options
author | Cash Costello <cash.costello@gmail.com> | 2010-07-25 02:01:36 +0000 |
---|---|---|
committer | Cash Costello <cash.costello@gmail.com> | 2010-07-25 02:01:36 +0000 |
commit | 73403645808a81425381f43c25e0ea2c92705312 (patch) | |
tree | 83fb73e9a122054f6f4c2e1c44e399572ee13e28 | |
parent | 791ec4925346cb38ecca9a2f2574b012ab64a88a (diff) | |
download | elgg-73403645808a81425381f43c25e0ea2c92705312.tar.gz elgg-73403645808a81425381f43c25e0ea2c92705312.tar.bz2 |
first go at brining tidypics up to code standards
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 @@ <?php - /** - * Tidypics Add New Album Action - * - */ +/** + * Tidypics Add New Album Action + * + */ - // Make sure we're logged in - gatekeeper(); +// Make sure we're logged in +gatekeeper(); - // 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', $_SESSION['user']->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 @@ <?php - /** - * Tidypics Add Photo Tag - * - */ +/** + * Tidypics Add Photo Tag + * + */ - gatekeeper(); - action_gatekeeper(); +gatekeeper(); +action_gatekeeper(); - $coordinates_str = get_input('coordinates'); +$coordinates_str = get_input('coordinates'); - $user_id = get_input('user_id'); - $image_guid = get_input('image_guid'); - $word = get_input('word'); +$user_id = get_input('user_id'); +$image_guid = get_input('image_guid'); +$word = get_input('word'); - if ($image_guid == 0) { - register_error(elgg_echo("tidypics:phototagging:error")); - forward($_SERVER['HTTP_REFERER']); - } +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']); - } +$image = get_entity($image_guid); +if (!$image) { + register_error(elgg_echo("tidypics:phototagging:error")); + forward($_SERVER['HTTP_REFERER']); +} + +// test for empty tag +if ($user_id == 0 && empty($word)) { + register_error(elgg_echo("tidypics:phototagging:error")); + forward($_SERVER['HTTP_REFERER']); +} - // test for empty tag - if ($user_id == 0 && empty($word)) { - register_error(elgg_echo("tidypics:phototagging:error")); - forward($_SERVER['HTTP_REFERER']); - } +$new_word_tag = false; +if ($user_id != 0) { + $relationships_type = 'user'; + $value = $user_id; +} else { + $relationships_type = 'word'; + $value = $word; - $new_word_tag = false; - if ($user_id != 0) { - $relationships_type = 'user'; - $value = $user_id; + // 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 { - $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 @@ <?php - /** - * Tidypics Thumbnail Creation Test - * - * Called through ajax - */ - - include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php"; - include dirname(dirname(__FILE__)) . "/lib/resize.php"; - - global $CONFIG; - - $guid = $_GET['guid']; - - $image = get_entity($guid); - if (!$image || !($image instanceof TidypicsImage)) { - echo "Unable to get original image"; - return; +/** + * Tidypics Thumbnail Creation Test + * + * Called through ajax + */ + +include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php"; +include dirname(dirname(__FILE__)) . "/lib/resize.php"; + +global $CONFIG; + +$guid = get_input('guid'); + +$image = get_entity($guid); +if (!$image || !($image instanceof TidypicsImage)) { + echo "Unable to get original image"; + return; +} + +$filename = $image->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 "<img id=\"tidypics_image\" src=\"{$CONFIG->wwwroot}mod/tidypics/thumbnail.php?file_guid={$guid}&size=large\" alt=\"{$title}\" />"; - -?> + +} // end of image library selector + +echo "<img id=\"tidypics_image\" src=\"{$CONFIG->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 @@ <?php - /** - * Tidypics Delete Action for Images and Albums - * - */ +/** + * Tidypics Delete Action for Images and Albums + * + */ - // must be logged in - gatekeeper(); +// must be logged in +gatekeeper(); - $forward_url = 'pg/photos/world'; // by default forward to world photos +$forward_url = 'pg/photos/world'; // by default forward to world photos - $guid = (int) get_input('guid'); +$guid = (int) get_input('guid'); - $entity = get_entity($guid); - if (!$entity) { // unable to get Elgg entity - 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); - } +$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 @@ <?php - /** - * Tidypics Delete Photo Tag - * - */ - - 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']); - } +/** + * Tidypics Delete Photo Tag + * + */ - $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; - } - } 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 @@ <?php - /** - * Tidypics edit album/image action - * - */ - - // Make sure we're logged in - gatekeeper(); +/** + * Tidypics edit album/image action + * + */ - // 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]; - - $container_guid = get_input('container_guid'); +// Make sure we're logged in +gatekeeper(); - // Make sure we actually have permission to edit - $entity = get_entity($guid); - if (!$entity->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 @@ <?php - /** - * Elgg album: multi image edit action - * - * This is called when uploading images - */ - - // Make sure we're logged in - gatekeeper(); +/** + * Elgg album: multi image edit action + * + * This is called when uploading images + */ - // 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(); +// Make sure we're logged in +gatekeeper(); - foreach($image_guid_array as $key => $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 "<pre>"; var_dump( array($flickr_username, $return_url )); echo "</pre>"; - -?>
\ 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 @@ <?php - /** - * 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."; - } -?> +/** + * 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 @@ <?php - /** - * Save settings of Tidypics - * - */ +/** + * Save settings of Tidypics + * + */ - global $CONFIG; +global $CONFIG; - admin_gatekeeper(); - action_gatekeeper(); +admin_gatekeeper(); +action_gatekeeper(); - // 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']); - } +// 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 @@ <?php - $english = array( +$english = array( // hack for core bug 'untitled' => "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 @@ <?xml version="1.0" encoding="UTF-8"?> <plugin_manifest> - <field key="author" value="The Tidypics team" /> - <field key="version" value="1.6.8" /> - <field key="description" value="Tidypics Photo Gallery" /> - <field key="website" value="http://code.google.com/p/tidypics/" /> - <field key="copyright" value="2008-2010 Cash Costello and the Tidypics Team" /> - <field key="licence" value="GNU General Public License version 2" /> - <field key="elgg_version" value="2009022701" /> + <field key="author" value="The Tidypics team" /> + <field key="version" value="1.6.8" /> + <field key="description" value="Tidypics Photo Gallery" /> + <field key="website" value="http://code.google.com/p/tidypics/" /> + <field key="copyright" value="2008-2010 Cash Costello and the Tidypics Team" /> + <field key="licence" value="GNU General Public License version 2" /> + <field key="elgg_version" value="2009022701" /> </plugin_manifest> diff --git a/mostvieweddashboard.php b/mostvieweddashboard.php index 5e7dc41c2..e98e784da 100644 --- a/mostvieweddashboard.php +++ b/mostvieweddashboard.php @@ -1,22 +1,22 @@ <?php - /** - * 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 +/** + * 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 @@ <?php - /****************************************************************** +/****************************************************************** * * Tidypics Admin Settings * *******************************************************************/ - 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(); - set_context('admin'); - - $tab = isset($_GET['tab']) ? $_GET['tab'] : 'settings'; +admin_gatekeeper(); +set_context('admin'); - $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)); +$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 @@ <?php - /** - * 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; - } - - 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 @@ <?php - /** - * Tidypics Edit for Albums and Single Photos - * - */ +/** + * Tidypics Edit for Albums and Single Photos + * + */ - include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php"; +include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php"; - // make sure the user is logged_in - gatekeeper(); - - set_context('photos'); - $guid = (int) get_input('guid'); +// make sure the user is logged_in +gatekeeper(); - if (!$entity = get_entity($guid)) - forward(); +set_context('photos'); +$guid = (int) get_input('guid'); - if (!$entity->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 @@ <?php - /** - * Tidypics: Edit the properties of multiple images - * - * Called after upload only - */ +/** + * Tidypics: Edit the properties of multiple images + * + * Called after upload only + */ - include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php"; +include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php"; - gatekeeper(); - set_context('photos'); +gatekeeper(); +set_context('photos'); - // parse out photo guids - $file_string = get_input('files'); - $file_array_sent = explode('-', $file_string); - $new_file_array = array(); +// parse out photo guids +$file_string = get_input('files'); +$file_array_sent = explode('-', $file_string); +$new_file_array = array(); - // set owner of page based on first photo guid - $photo_guid = (int)$file_array_sent[0]; - $photo = get_entity($photo_guid); +// set owner of page based on first photo guid +$photo_guid = (int)$file_array_sent[0]; +$photo = get_entity($photo_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); +// 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 @@ <?php - /** - * 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); -?>
\ 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 @@ <?php - /** - * 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 +/** + * 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 @@ <?php - /** - * 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); - } - } 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 @@ <?php - /** - * Most viewed images - either for a user or all site - * - */ +/** + * Most viewed images - either for a user or all site + * + */ - // Load Elgg engine - include_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/engine/start.php"; +// Load Elgg engine +include_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/engine/start.php"; - 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); +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 @@ <?php - /** - * Images recently commented on - world view only - * - */ +/** + * Images recently commented on - world view only + * + */ - // Load Elgg engine - include_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/engine/start.php"; +// Load Elgg engine +include_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/engine/start.php"; - // 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 +// 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 "<pre>"; - var_dump( $sql); -// var_dump( $result ); - echo "</pre>"; + 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 @@ <?php - /** - * Most recently viewed images - world view only right now - * - */ +/** + * Most recently viewed images - world view only right now + * + */ - // Load Elgg engine - include_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/engine/start.php"; +// Load Elgg engine +include_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/engine/start.php"; - // 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 +// 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 @@ <?php - /** - * Tidypics Create New Album Page - * - */ +/** + * Tidypics Create New Album Page + * + */ - // Load Elgg engine - include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php"; - - // 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 = $_SESSION['user']; - set_page_owner($_SESSION['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", $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 @@ <?php - /** - * 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'); - } +/** + * 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); ?> <div class="contentWrapper"> <table width="100%"> @@ -130,9 +131,8 @@ </div> <?php - $content = ob_get_clean(); +$content = ob_get_clean(); - $body = elgg_view_layout('two_column_left_sidebar', '', $content); +$body = elgg_view_layout('two_column_left_sidebar', '', $content); - echo page_draw($title, $body); -?>
\ 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 @@ <?php - /** - * 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); - -?>
\ 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 @@ <?php - /** - * Tidypics Thumbnail - * - */ - - // Get file GUID - $file_guid = (int) get_input('file_guid'); - - // 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(); +/** + * 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 @@ <?php - /** - * 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 ) ); +/** + * 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 @@ <?php - /** - * Tidypics Album View Page - * - * This displays a listing of all the photos that belong to an album - */ +/** + * Tidypics Album View Page + * + * This displays a listing of all the photos that belong to an album + */ - include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php"; +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(); +// 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 - $album_guid = (int) get_input('guid'); - $album = get_entity($album_guid); +// get the album entity +$album_guid = (int) get_input('guid'); +$album = get_entity($album_guid); - // panic if we can't get it - if (!$album) forward(); +// panic if we can't get it +if (!$album) { + forward(); +} - // 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); +// 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 @@ <?php - /** - * 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); +/** + * 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 @@ <?php - /** - * 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); -?>
\ 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); @@ -1,446 +1,468 @@ <?php - /** - * 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); - } - - // 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 @@ <?php - /** - * Tidypics Thumbnail - * - */ +/** + * Tidypics Thumbnail + * + */ - include_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); - - // Get file GUID - $file_guid = (int) get_input('file_guid'); - - // 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(); +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 @@ <?php - /* - * Overriding core view to work around bug dealing with empty titles - */ +/* + * Overriding core view to work around bug dealing with empty titles + */ - $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'); +$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 = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>"; - $string = sprintf(elgg_echo("river:posted:generic"),$url) . " "; - $string .= elgg_echo("{$subtype}:river:annotate") . " <a href=\"" . $object->getURL() . "\">" . $title . "</a>"; +$url = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>"; +$string = sprintf(elgg_echo("river:posted:generic"),$url) . " "; +$string .= elgg_echo("{$subtype}:river:annotate") . " <a href=\"" . $object->getURL() . "\">" . $title . "</a>"; -?> - -<?php echo $string; ?>
\ 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 @@ <?php - /** - * Tidypics Album Gallery View - */ +/** + * Tidypics Album Gallery View + */ - global $CONFIG; - - $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; +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 = '<img src="' . $vars['url'] . 'pg/photos/thumbnail/' . $album->cover . '/small/" class="tidypics_album_cover" alt="' . $title . '"/>'; - else - $album_cover = '<img src="' . $vars['url'] . 'mod/tidypics/graphics/empty_album.png" class="tidypics_album_cover" alt="new album">'; - + //get album cover if one was set + if ($album->cover) { + $album_cover = '<img src="' . $vars['url'] . 'pg/photos/thumbnail/' . $album->cover . '/small/" class="tidypics_album_cover" alt="' . $title . '"/>'; + } else { + $album_cover = '<img src="' . $vars['url'] . 'mod/tidypics/graphics/empty_album.png" class="tidypics_album_cover" alt="new album">'; + } ?> <div class="tidypics_album_gallery_item"> <div class="tidypics_gallery_title"> <a href="<?php echo $album->getURL();?>"><?php echo $title;?></a> </div> <a href="<?php echo $album->getURL();?>"><?php echo $album_cover;?></a><br> - <small><a href="<?php echo $vars['url'];?>pg/profile/<?php echo $owner->username;?>"><?php echo $owner->name;?></a> - <br /><?php echo $friendlytime;?><br /> -<?php - //get the number of comments - $numcomments = elgg_count_comments($album); - if ($numcomments) - echo "<a href=\"{$album->getURL()}\">" . sprintf(elgg_echo("comments")) . " (" . $numcomments . ")</a>"; + <small><a href="<?php echo $vars['url'];?>pg/profile/<?php echo $owner->username;?>"><?php echo $owner->name;?></a> + <br /><?php echo $friendlytime;?><br /> + <?php + //get the number of comments + $numcomments = elgg_count_comments($album); + if ($numcomments) { + echo "<a href=\"{$album->getURL()}\">" . sprintf(elgg_echo("comments")) . " (" . $numcomments . ")</a>"; + } ?> </small> </div> <?php - } else { + } else { /****************************************************************************** * * List view of an album object @@ -60,22 +61,23 @@ * *****************************************************************************/ - $info = '<p><a href="' . $album->getURL() . '">' . $title . '</a></p>'; - $info .= "<p class=\"owner_timestamp\"><a href=\"{$vars['url']}pg/profile/{$owner->username}\">{$owner->name}</a> {$friendlytime}"; - $numcomments = elgg_count_comments($album); - if ($numcomments) - $info .= ", <a href=\"{$album->getURL()}\">" . sprintf(elgg_echo("comments")) . " (" . $numcomments . ")</a>"; - $info .= "</p>"; - - //get album cover if one was set - if ($album->cover) - $icon = "<a href=\"{$album->getURL()}\">" . '<img src="' . $vars['url'] . 'mod/tidypics/thumbnail.php?file_guid=' . $album->cover . '&size=thumb" alt="thumbnail" /></a>'; - else - $icon = "<a href=\"{$album->getURL()}\">" . '<img src="' . $vars['url'] . 'mod/tidypics/graphics/image_error_thumb.png" alt="new album"></a>'; - - echo elgg_view_listing($icon, $info); + $info = '<p><a href="' . $album->getURL() . '">' . $title . '</a></p>'; + $info .= "<p class=\"owner_timestamp\"><a href=\"{$vars['url']}pg/profile/{$owner->username}\">{$owner->name}</a> {$friendlytime}"; + $numcomments = elgg_count_comments($album); + if ($numcomments) { + $info .= ", <a href=\"{$album->getURL()}\">" . sprintf(elgg_echo("comments")) . " (" . $numcomments . ")</a>"; } - } else { + $info .= "</p>"; + + //get album cover if one was set + if ($album->cover) { + $icon = "<a href=\"{$album->getURL()}\">" . '<img src="' . $vars['url'] . 'mod/tidypics/thumbnail.php?file_guid=' . $album->cover . '&size=thumb" alt="thumbnail" /></a>'; + } else { + $icon = "<a href=\"{$album->getURL()}\">" . '<img src="' . $vars['url'] . 'mod/tidypics/graphics/image_error_thumb.png" alt="new album"></a>'; + } + 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); ?> <div class="contentWrapper"> <div id="tidypics_breadcrumbs"> - <?php echo elgg_view('tidypics/breadcrumbs', array() ); ?> + <?php echo elgg_view('tidypics/breadcrumbs', array() ); ?> </div> -<?php - echo '<div id="tidypics_desc">' . autop($desc) . '</div>'; - - $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 '<div class="tidypics_info">' . elgg_echo('image:none') . '</div>'; - $num_images = 0; +<?php + echo '<div id="tidypics_desc">' . autop($desc) . '</div>'; + + $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 '<div class="tidypics_info">' . elgg_echo('image:none') . '</div>'; + $num_images = 0; + } + ?> <div class="clearfloat"></div> <div class="tidypics_info"> -<?php +<?php - if (!is_null($tags)) { + if (!is_null($tags)) { ?> <div class="object_tag_string"><?php echo elgg_view('output/tags',array('value' => $tags));?></div> -<?php - } +<?php + } ?> - <?php echo elgg_echo('album:by');?> <b><a href="<?php echo $vars['url'] ;?>pg/profile/<?php echo $owner->username; ?>"><?php echo $owner->name; ?></a></b> <?php echo $friendlytime; ?><br> - <?php echo elgg_echo('image:total');?> <b><?php echo $num_images; ?></b><br> + <?php echo elgg_echo('album:by');?> <b><a href="<?php echo $vars['url'] ;?>pg/profile/<?php echo $owner->username; ?>"><?php echo $owner->name; ?></a></b> <?php echo $friendlytime; ?><br> + <?php echo elgg_echo('image:total');?> <b><?php echo $num_images; ?></b><br> <?php - $categories = elgg_view('categories/view',$vars); - if (!empty($categories)) { + $categories = elgg_view('categories/view',$vars); + if (!empty($categories)) { ?> <br /> -<b><?php echo elgg_echo('categories'); ?>:</b> - <?php + <b><?php echo elgg_echo('categories'); ?>:</b> +<?php - echo $categories; + echo $categories; - } + } ?> </div> <?php - if ($vars['full']) { - echo elgg_view_comments($album); - } - - echo '</div>'; - } // end of individual album view -?> + if ($vars['full']) { + echo elgg_view_comments($album); + } + + echo '</div>'; +} // 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 @@ <?php - /** - * - * Tidypics image object views - */ +/** + * + * Tidypics image object views + */ - global $CONFIG; - include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/lib/exif.php"; +global $CONFIG; +include_once dirname(dirname(dirname(dirname(__FILE__)))) . "/lib/exif.php"; - $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); +$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") { - ?> - <div class="tidypics_album_images"> - <a href="<?php echo $image->getURL();?>"><img src="<?php echo $vars['url'];?>mod/tidypics/thumbnail.php?file_guid=<?php echo $image_guid;?>&size=small" alt="thumbnail"/></a> - </div> - <?php - } - else{ - // list view displays a thumbnail icon of the image, its title, and the number of comments - $info = '<p><a href="' .$image->getURL(). '">'.$title.'</a></p>'; - $info .= "<p class=\"owner_timestamp\"><a href=\"{$vars['url']}pg/profile/{$owner->username}\">{$owner->name}</a> {$friendlytime}"; - $numcomments = elgg_count_comments($image); - if ($numcomments) - $info .= ", <a href=\"{$image->getURL()}\">" . sprintf(elgg_echo("comments")) . " (" . $numcomments . ")</a>"; - $info .= "</p>"; - $icon = "<a href=\"{$image->getURL()}\">" . '<img src="' . $vars['url'] . 'mod/tidypics/thumbnail.php?file_guid=' . $image_guid . '&size=thumb" alt="' . $title . '" /></a>'; - - echo elgg_view_listing($icon, $info); + // gallery view is a matrix view showing just the image - size: small + if (get_input('search_viewtype') == "gallery") { +?> +<div class="tidypics_album_images"> + <a href="<?php echo $image->getURL();?>"><img src="<?php echo $vars['url'];?>mod/tidypics/thumbnail.php?file_guid=<?php echo $image_guid;?>&size=small" alt="thumbnail"/></a> +</div> +<?php + } else { + // list view displays a thumbnail icon of the image, its title, and the number of comments + $info = '<p><a href="' .$image->getURL(). '">'.$title.'</a></p>'; + $info .= "<p class=\"owner_timestamp\"><a href=\"{$vars['url']}pg/profile/{$owner->username}\">{$owner->name}</a> {$friendlytime}"; + $numcomments = elgg_count_comments($image); + if ($numcomments) { + $info .= ", <a href=\"{$image->getURL()}\">" . sprintf(elgg_echo("comments")) . " (" . $numcomments . ")</a>"; } + $info .= "</p>"; + $icon = "<a href=\"{$image->getURL()}\">" . '<img src="' . $vars['url'] . 'mod/tidypics/thumbnail.php?file_guid=' . $image_guid . '&size=thumb" alt="' . $title . '" /></a>'; + + 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 ?> <a href="<?php echo $image->getURL(); ?>"> -<img src="<?php echo $vars['url'];?>mod/tidypics/thumbnail.php?file_guid=<?php echo $image_guid;?>&size=thumb" class="tidypics_album_cover" alt="<?php echo $title; ?>" title="<?php echo $title; ?>" /> + <img src="<?php echo $vars['url'];?>mod/tidypics/thumbnail.php?file_guid=<?php echo $image_guid;?>&size=thumb" class="tidypics_album_cover" alt="<?php echo $title; ?>" title="<?php echo $title; ?>" /> </a> -<?php - } else { + <?php +} else { /******************************************************************** * * listing of photos in an album * *********************************************************************/ - if (!$vars['full']) { - -?> -<?php - // plugins can override the image link to add lightbox code here - $image_html = false; - $image_html = trigger_plugin_hook('tp_thumbnail_link', 'album', array('image' => $image), $image_html); - - if ($image_html) { - echo $image_html; - } else { - // default link to image if no one overrides -?> - <div class="tidypics_album_images"> - <a href="<?php echo $image->getURL();?>"><img src="<?php echo $vars['url'];?>pg/photos/thumbnail/<?php echo $image_guid;?>/small/" alt="<?php echo $image->title; ?>"/></a> - </div> -<?php - } + if (!$vars['full']) { + + // plugins can override the image link to add lightbox code here + $image_html = false; + $image_html = trigger_plugin_hook('tp_thumbnail_link', 'album', array('image' => $image), $image_html); + + if ($image_html) { + echo $image_html; + } else { + // default link to image if no one overrides ?> +<div class="tidypics_album_images"> + <a href="<?php echo $image->getURL();?>"><img src="<?php echo $vars['url'];?>pg/photos/thumbnail/<?php echo $image_guid;?>/small/" alt="<?php echo $image->title; ?>"/></a> +</div> <?php - } else { + } + } else { /******************************************************************** * @@ -91,66 +87,68 @@ * *********************************************************************/ - - $viewer = get_loggedin_user(); - - // Build back and next links - $back = ''; - $next = ''; + $viewer = get_loggedin_user(); - $album = get_entity($image->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 = '<a href="' .$vars['url'] . 'pg/photos/view/' . $_SESSION['image_sort'][$current-1] . '">« ' . elgg_echo('image:back') . '</a>'; + if ($_SESSION['image_sort']) { + $current = array_search($image_guid, $_SESSION['image_sort']); + } + } - if (sizeof($_SESSION['image_sort']) > $current + 1) - $next = '<a href="' . $vars['url'] . 'pg/photos/view/' . $_SESSION['image_sort'][$current+1] . '">' . elgg_echo('image:next') . ' »</a>'; + if ($current != 0) { + $back = '<a href="' .$vars['url'] . 'pg/photos/view/' . $_SESSION['image_sort'][$current-1] . '">« ' . elgg_echo('image:back') . '</a>'; + } + if (sizeof($_SESSION['image_sort']) > $current + 1) { + $next = '<a href="' . $vars['url'] . 'pg/photos/view/' . $_SESSION['image_sort'][$current+1] . '">' . elgg_echo('image:next') . ' »</a>'; + } ?> <div class="contentWrapper"> <div id="tidypics_wrapper"> <div id="tidypics_breadcrumbs"> - <?php echo elgg_view('tidypics/breadcrumbs', array('album' => $album,) ); ?> <br /> - <?php - if (get_plugin_setting('view_count', 'tidypics') != "disabled") { - - $image->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']); + <?php echo elgg_view('tidypics/breadcrumbs', array('album' => $album,) ); ?> <br /> +<?php + if (get_plugin_setting('view_count', 'tidypics') != "disabled") { + + $image->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']); + } + } } } - } - ?> +?> </div> <div id="tidypics_desc"> - <?php echo autop($desc); ?> + <?php echo autop($desc); ?> </div> <div id="tidypics_image_nav"> <ul> @@ -159,73 +157,74 @@ </ul> </div> <div id="tidypics_image_wrapper"> - <?php - // this code controls whether the photo is a hyperlink or not and what it links to - if (get_plugin_setting('download_link', 'tidypics') != "disabled") { - // admin allows downloads so default to inline download link - $image_html = "<a href=\"{$vars['url']}pg/photos/download/{$image_guid}/inline/\" title=\"{$title}\" >"; - $image_html .= "<img id=\"tidypics_image\" src=\"{$vars['url']}pg/photos/thumbnail/{$image_guid}/large/\" alt=\"{$title}\" />"; - $image_html .= "</a>"; - } else { - $image_html = "<img id=\"tidypics_image\" src=\"{$vars['url']}pg/photos/thumbnail/{$image_guid}/large/\" alt=\"{$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; - ?> + <?php + // this code controls whether the photo is a hyperlink or not and what it links to + if (get_plugin_setting('download_link', 'tidypics') != "disabled") { + // admin allows downloads so default to inline download link + $image_html = "<a href=\"{$vars['url']}pg/photos/download/{$image_guid}/inline/\" title=\"{$title}\" >"; + $image_html .= "<img id=\"tidypics_image\" src=\"{$vars['url']}pg/photos/thumbnail/{$image_guid}/large/\" alt=\"{$title}\" />"; + $image_html .= "</a>"; + } else { + $image_html = "<img id=\"tidypics_image\" src=\"{$vars['url']}pg/photos/thumbnail/{$image_guid}/large/\" alt=\"{$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; + ?> <div class="clearfloat"></div> </div> -<?php - // image menu (start tagging, download, etc.) - - echo '<div id="tidypics_controls"><ul>'; - echo elgg_view('tidypics/image_menu', array('image_guid' => $image_guid, - 'viewer' => $viewer, - 'owner' => $owner, - 'anytags' => $image->isPhotoTagged(), - 'album' => $album, ) ); - echo '</ul></div>'; - - // 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") { + <?php + // image menu (start tagging, download, etc.) + + echo '<div id="tidypics_controls"><ul>'; + echo elgg_view('tidypics/image_menu', array( + 'image_guid' => $image_guid, + 'viewer' => $viewer, + 'owner' => $owner, + 'anytags' => $image->isPhotoTagged(), + 'album' => $album, ) ); + echo '</ul></div>'; + + // 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)); + } ?> - <?php echo elgg_view('tidypics/exif', array('guid'=> $image_guid)); ?> -<?php } ?> <div class="tidypics_info"> -<?php if (!is_null($tags)) { ?> +<?php + if (!is_null($tags)) { +?> <div class="object_tag_string"><?php echo elgg_view('output/tags',array('value' => $tags));?></div> -<?php } - if (get_plugin_setting('photo_ratings', 'tidypics') == "enabled") { +<?php + } + if (get_plugin_setting('photo_ratings', 'tidypics') == "enabled") { ?> <div id="rate_container"> - <?php echo elgg_view('rate/rate', array('entity'=> $vars['entity'])); ?> -</div> + <?php echo elgg_view('rate/rate', array('entity'=> $vars['entity'])); ?> + </div> <?php - } - - echo elgg_echo('image:by');?> <b><a href="<?php echo $vars['url']; ?>pg/profile/<?php echo $owner->username; ?>"><?php echo $owner->name; ?></a></b> <?php echo $friendlytime; + } + + echo elgg_echo('image:by');?> <b><a href="<?php echo $vars['url']; ?>pg/profile/<?php echo $owner->username; ?>"><?php echo $owner->name; ?></a></b> <?php echo $friendlytime; ?> </div> </div> <!-- tidypics wrapper--> <?php - echo elgg_view_comments($image); - - echo '<div class="clearfloat"></div>'; - - echo '</div>'; // content wrapper + echo elgg_view_comments($image); - } // end of individual image display + echo '<div class="clearfloat"></div>'; - } - -?> + echo '</div>'; // 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 @@ <?php - $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(); +$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 = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>"; +$string = sprintf(elgg_echo("album:river:created"), $url) . " "; +$string .= "<a href=\"" . $album->getURL() . "\">" . $album->title . "</a>"; +if ($group_album) { + $string .= ' ' . elgg_echo('album:river:group') . ' ' . "<a href=\"{$group_link}\" >{$group_name}</a>"; +} + +$album_river_view = get_plugin_setting('album_river_view', 'tidypics'); + +if ($album_river_view == "cover") { + if ($album->cover) { + $string .= "<div class=\"river_content\"> <img src=\"" . $CONFIG->wwwroot . 'mod/tidypics/thumbnail.php?file_guid=' . $album->cover . '&size=thumb" class="tidypics_album_cover" alt="thumbnail"/>' . "</div>"; } - - $url = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>"; - $string = sprintf(elgg_echo("album:river:created"),$url) . " "; - $string .= "<a href=\"" . $album->getURL() . "\">" . $album->title . "</a>"; - if ($group_album) - $string .= ' ' . elgg_echo('album:river:group') . ' ' . "<a href=\"{$group_link}\" >{$group_name}</a>"; - - $album_river_view = get_plugin_setting('album_river_view', 'tidypics'); - - if ($album_river_view == "cover") { - if ($album->cover) { - $string .= "<div class=\"river_content\"> <img src=\"" . $CONFIG->wwwroot . 'mod/tidypics/thumbnail.php?file_guid=' . $album->cover . '&size=thumb" class="tidypics_album_cover" alt="thumbnail"/>' . "</div>"; - } - } else { +} else { - $string .= "<div class=\"river_content\">"; - - $images = get_entities("object", "image", $album->guid, 'time_created desc', 7); + $string .= "<div class=\"river_content\">"; - if (count($images)) { - foreach($images as $image){ - $string .= "<a href=\"" . $image->getURL() . "\"> <img src=\"" . $CONFIG->wwwroot . 'mod/tidypics/thumbnail.php?file_guid=' . $image->guid . '&size=thumb" class="tidypics_album_cover" alt="thumbnail"/> </a>'; - } - } + $images = get_entities("object", "image", $album->guid, 'time_created desc', 7); - $string .= "</div>"; + if (count($images)) { + foreach($images as $image) { + $string .= "<a href=\"" . $image->getURL() . "\"> <img src=\"" . $CONFIG->wwwroot . 'mod/tidypics/thumbnail.php?file_guid=' . $image->guid . '&size=thumb" class="tidypics_album_cover" alt="thumbnail"/> </a>'; + } } -echo $string; + $string .= "</div>"; +} -?> +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 @@ <?php - $performed_by = get_entity($vars['item']->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 = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>"; - $album = get_entity($image->container_guid); +$url = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>"; +$album = get_entity($image->container_guid); - $album_link = "<a href='". $album->getURL() . "'>" . $album->title . "</a>"; - $image_link = "<a href=\"" . $image->getURL() . "\">" . $title . "</a>"; - - $string = sprintf(elgg_echo("image:river:created"), $url, $image_link, $album_link); - - $string .= "<div class=\"river_content\">"; +$album_link = "<a href='". $album->getURL() . "'>" . $album->title . "</a>"; +$image_link = "<a href=\"" . $image->getURL() . "\">" . $title . "</a>"; + +$string = sprintf(elgg_echo("image:river:created"), $url, $image_link, $album_link); + +$string .= "<div class=\"river_content\">"; /* // this adds the album cover to the river display $string .= "<a href=\"" . $album->getURL() . "\"> <img src=\"" . $CONFIG->wwwroot . 'mod/tidypics/thumbnail.php?file_guid=' . $album->cover . '&size=thumb" class="tidypics_album_cover" alt="thumbnail"/> </a>'; */ - $string .= "<a href=\"" . $image->getURL() . "\"> <img src=\"" . $CONFIG->wwwroot . 'mod/tidypics/thumbnail.php?file_guid=' . $image->guid . '&size=thumb" class="tidypics_album_cover" alt="thumbnail"/> </a>'; - $string .= "</div>"; - - echo $string; +$string .= "<a href=\"" . $image->getURL() . "\"> <img src=\"" . $CONFIG->wwwroot . 'mod/tidypics/thumbnail.php?file_guid=' . $image->guid . '&size=thumb" class="tidypics_album_cover" alt="thumbnail"/> </a>'; +$string .= "</div>"; -?>
\ 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 @@ <?php - $image = get_entity($vars['item']->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 = "<a href=\"{$image->getURL()}\">{$title}</a>"; - $person_url = "<a href=\"{$person_tagged->getURL()}\">{$person_tagged->name}</a>"; - - $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 = "<a href=\"{$image->getURL()}\">{$title}</a>"; +$person_url = "<a href=\"{$person_tagged->getURL()}\">{$person_tagged->name}</a>"; + +$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 @@ <?php - global $CONFIG; - $system_url = $CONFIG->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'; ?> <p> 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 @@ <?php - $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; - - $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'); ?> <br /> <h3>Overview</h3> <p> -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 <a href="http://www.php.net/manual/en/book.image.php">GD</a>, -<a href="http://www.imagemagick.org/">ImageMagick</a> called via a system call, and the PHP extension -<a href="http://pecl.php.net/package/imagick/">imagick</a>. 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 <a href="http://www.php.net/manual/en/book.image.php">GD</a>, + <a href="http://www.imagemagick.org/">ImageMagick</a> called via a system call, and the PHP extension + <a href="http://pecl.php.net/package/imagick/">imagick</a>. 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. </p> <h3>Testing ImageMagick Commandline</h3> <p> -To use the ImageMagick executables, PHP must be configured to allow calls to exec(). You can check our -<a href="<?php echo $CONFIG->wwwroot . 'mod/tidypics/pages/server_analysis.php'; ?>">server analysis page</a> 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 + <a href="<?php echo $CONFIG->wwwroot . 'mod/tidypics/pages/server_analysis.php'; ?>">server analysis page</a> 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. </p> <br /> <p> -<?php echo elgg_echo('tidypics:settings:im_path'); ?><br /> -<input name="im_location" type="text" /> -<input type="submit" value="Submit" onclick="TestImageMagickLocation();" /> + <?php echo elgg_echo('tidypics:settings:im_path'); ?><br /> + <input name="im_location" type="text" /> + <input type="submit" value="Submit" onclick="TestImageMagickLocation();" /> </p> <div id="im_results"></div> <script type="text/javascript"> -function TestImageMagickLocation() -{ - var loc = $('input[name=im_location]').val(); - $("#im_results").html(""); - $.ajax({ - type: "GET", - url: "<?php echo $CONFIG->wwwroot . 'mod/tidypics/actions/imtest.php'; ?>", - data: {location: loc}, - cache: false, - success: function(html){ - $("#im_results").html(html); - } - }); -} + function TestImageMagickLocation() + { + var loc = $('input[name=im_location]').val(); + $("#im_results").html(""); + $.ajax({ + type: "GET", + url: "<?php echo $CONFIG->wwwroot . 'mod/tidypics/actions/imtest.php'; ?>", + data: {location: loc}, + cache: false, + success: function(html){ + $("#im_results").html(html); + } + }); + } </script>
\ 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 @@ <?php - 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; +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; +} ?> <p> -<?php + <?php if ($upgrade) { -?> -<a href="<?php echo $upgrade_url; ?>">Upgrade</a><br /> -<?php + ?> + <a href="<?php echo $upgrade_url; ?>">Upgrade</a><br /> + <?php } -?> -<a href="<?php echo $system_url; ?>">Run Server Analysis</a> + ?> + <a href="<?php echo $system_url; ?>">Run Server Analysis</a> </p> <?php - echo elgg_view("tidypics/forms/settings"); -?>
\ 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 @@ <?php - $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; - - $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'); +} ?> <p> -<br /> -Photos: <?php echo $num_images; ?><br /> -Albums: <?php echo $num_albums; ?><br /> -Comments on photos: <?php echo $num_comments_photos; ?><br /> -Comments on albums: <?php echo $num_comments_albums; ?><br /> -Total views: <?php echo $num_views; ?><br /> + <br /> + Photos: <?php echo $num_images; ?><br /> + Albums: <?php echo $num_albums; ?><br /> + Comments on photos: <?php echo $num_comments_photos; ?><br /> + Comments on albums: <?php echo $num_comments_albums; ?><br /> + Total views: <?php echo $num_views; ?><br /> <?php - if ($num_tags) { +if ($num_tags) { ?> -Photo tags: <?php echo $num_tags; ?><br /> + Photo tags: <?php echo $num_tags; ?><br /> <?php - } +} ?> </p>
\ 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 @@ <?php - global $CONFIG; - - $tab = $vars['tab']; - - $settingsselect = ''; - $statsselect = ''; - $imagelibselect = ''; - $thumbnailselect = ''; - $helpselect = ''; - switch($tab) { - case 'settings': - $settingsselect = 'class="selected"'; - break; - case 'stats': - $statsselect = 'class="selected"'; - break; - case 'imagelib': - $imagelibselect = 'class="selected"'; - break; - case 'thumbnail': - $thumbnailselect = 'class="selected"'; - break; - case 'help': - $helpselect = 'class="selected"'; - break; - } - +global $CONFIG; + +$tab = $vars['tab']; + +$settingsselect = ''; +$statsselect = ''; +$imagelibselect = ''; +$thumbnailselect = ''; +$helpselect = ''; +switch($tab) { + case 'settings': + $settingsselect = 'class="selected"'; + break; + case 'stats': + $statsselect = 'class="selected"'; + break; + case 'imagelib': + $imagelibselect = 'class="selected"'; + break; + case 'thumbnail': + $thumbnailselect = 'class="selected"'; + break; + case 'help': + $helpselect = 'class="selected"'; + break; +} + ?> <div class="contentWrapper"> <div id="elgg_horizontal_tabbed_nav"> @@ -38,7 +38,7 @@ <li <?php echo $helpselect; ?>><a href="<?php echo $CONFIG->wwwroot . 'mod/tidypics/pages/admin.php?tab=help'; ?>"><?php echo elgg_echo('tidypics:settings:help'); ?></a></li> </ul> </div> -<?php + <?php switch($tab) { case 'settings': echo elgg_view("tidypics/admin/settings"); @@ -56,5 +56,5 @@ echo elgg_view("tidypics/admin/help"); break; } -?> + ?> </div> 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 @@ <?php - //the number of albums to display - $number = (int)$vars['num_albums']; - if (!$number) - $number = 5; +//the number of albums to display +$number = (int)$vars['num_albums']; +if (!$number) { + $number = 5; +} - $owner = page_owner_entity(); - $owner_albums = get_entities("object", "album", page_owner(), "", $number, 0, false); +$owner = page_owner_entity(); +$owner_albums = get_entities("object", "album", page_owner(), "", $number, 0, false); - echo '<div id="tidypics_album_widget_container">'; +echo '<div id="tidypics_album_widget_container">'; - if ($owner_albums) { - foreach($owner_albums as $album) { +if ($owner_albums) { + foreach ($owner_albums as $album) { - if($album->cover) - $album_cover = '<img src="'.$vars['url'].'mod/tidypics/thumbnail.php?file_guid='.$album->cover.'&size=small" class="tidypics_album_cover" alt="' . $album->title . '"/>'; - else - $album_cover = '<img src="'.$vars['url'].'mod/tidypics/graphics/empty_album.png" class="tidypics_album_cover" alt="' . $album->title . '">'; + if ($album->cover) { + $album_cover = '<img src="'.$vars['url'].'mod/tidypics/thumbnail.php?file_guid='.$album->cover.'&size=small" class="tidypics_album_cover" alt="' . $album->title . '"/>'; + } else { + $album_cover = '<img src="'.$vars['url'].'mod/tidypics/graphics/empty_album.png" class="tidypics_album_cover" alt="' . $album->title . '">'; + } ?> - <div class="tidypics_album_widget_single_item"> - <div class="tidypics_album_widget_title"><a href="<?php echo $album->getURL();?>"><?php echo $album->title;?></a></div> - <div class="tidypics_album_widget_timestamp"> <?php echo elgg_echo("album:created:on") . ' ' . friendly_time($album->time_created);?></div> -<?php +<div class="tidypics_album_widget_single_item"> + <div class="tidypics_album_widget_title"><a href="<?php echo $album->getURL();?>"><?php echo $album->title;?></a></div> + <div class="tidypics_album_widget_timestamp"> <?php echo elgg_echo("album:created:on") . ' ' . friendly_time($album->time_created);?></div> + <?php //get the number of comments $numcomments = elgg_count_comments($album); - if ($numcomments) + if ($numcomments) { echo "<a href=\"{$album->getURL()}\">" . sprintf(elgg_echo("comments")) . " (" . $numcomments . ")</a><br>"; + } ?> - <a href="<?php echo $album->getURL();?>"><?php echo $album_cover;?></a> - </div> -<?php - } //end of foreach loop - - // bottom link to all group/user albums - if (is_null($owner->username) || empty($owner->username)) { - echo '<p class="profile_info_edit_buttons"><a href="' . $vars['url'] . 'pg/photos/world">' . elgg_echo('album:all') . '</a></p>'; - } else { - echo '<p class="tidypics_download"><a href="' . $vars['url'] . 'pg/photos/owned/' . $owner->username . '">' . elgg_echo('album:more') . '</a></p>'; - } - + <a href="<?php echo $album->getURL();?>"><?php echo $album_cover;?></a> +</div> + <?php + } //end of foreach loop + + // bottom link to all group/user albums + if (is_null($owner->username) || empty($owner->username)) { + echo '<p class="profile_info_edit_buttons"><a href="' . $vars['url'] . 'pg/photos/world">' . elgg_echo('album:all') . '</a></p>'; + } else { + echo '<p class="tidypics_download"><a href="' . $vars['url'] . 'pg/photos/owned/' . $owner->username . '">' . elgg_echo('album:more') . '</a></p>'; } - if (can_write_to_container(0, $owner->guid)) { - echo '<p class="tidypics_download"><a href=' . $CONFIG->wwwroot .'pg/photos/new/' . $owner->username . '>' . elgg_echo("album:create") . '</a></p>'; - } +} + +if (can_write_to_container(0, $owner->guid)) { + echo '<p class="tidypics_download"><a href=' . $CONFIG->wwwroot .'pg/photos/new/' . $owner->username . '>' . elgg_echo("album:create") . '</a></p>'; +} - //close album_widget_container div - echo "</div>"; -?>
\ No newline at end of file +//close album_widget_container div +echo "</div>"; 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 @@ <?php - $file_guid = $vars['file_guid']; - $page_owner = page_owner_entity(); +$file_guid = $vars['file_guid']; +$page_owner = page_owner_entity(); - $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); +$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); +} ?> <a href="<?php echo $first_level_link; ?>"><?php echo $first_level_text; ?></a> <?php - $second_level_text = ''; - if (isset($vars['album'])) { - $second_level_text = $vars['album']->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(); + ?> >> <a href="<?php echo $second_level_link; ?>"><?php echo $second_level_text; ?></a> -<?php - } -?> + <?php +} + diff --git a/views/default/tidypics/exif.php b/views/default/tidypics/exif.php index 0100ac575..f21e2eff7 100644 --- a/views/default/tidypics/exif.php +++ b/views/default/tidypics/exif.php @@ -1,14 +1,14 @@ <?php - $guid = $vars['guid']; - - $exif = tp_exif_formatted($guid); - if ($exif) { - echo '<div id="tidypics_exif">'; - foreach ($exif as $name => $value) { - echo $name . ': ' . $value . '<br />'; - } - echo '</div>'; +$guid = $vars['guid']; + +$exif = tp_exif_formatted($guid); +if ($exif) { + echo '<div id="tidypics_exif">'; + foreach ($exif as $name => $value) { + echo $name . ': ' . $value . '<br />'; } - + echo '</div>'; +} + ?>
\ 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 @@ <?php - /** - * 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']; +/** + * 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(); ?> <div class="contentWrapper"> @@ -48,79 +45,79 @@ <label><?php echo elgg_echo('album:title'); ?></label> <?php echo elgg_view("input/text", array("internalname" => "tidypicstitle", "value" => $title,)); ?> </p> -<?php + <?php if ($subtype == 'album') { -?> + ?> <p> <label><?php echo elgg_echo('album:desc'); ?></label> - <?php echo elgg_view("input/longtext",array("internalname" => "tidypicsbody","value" => $body,)); ?> + <?php echo elgg_view("input/longtext",array("internalname" => "tidypicsbody","value" => $body,)); ?> </p> -<?php + <?php } else { -?> + ?> <p> <label><?php echo elgg_echo('caption'); ?></label> - <?php echo elgg_view("input/longtext",array("internalname" => "tidypicsbody","value" => $body,"class" => 'tidypics_caption_input')); ?> + <?php echo elgg_view("input/longtext",array("internalname" => "tidypicsbody","value" => $body,"class" => 'tidypics_caption_input')); ?> </p> -<?php - } -?> + <?php + } + ?> <p> <label><?php echo elgg_echo("tags"); ?></label> <?php echo elgg_view("input/tags", array( "internalname" => "tidypicstags","value" => $tags,)); ?> </p> -<?php + <?php if ($subtype == 'image') { $container_guid = $vars['entity']->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) { + + ?> <p> -<?php echo elgg_view('input/checkboxes', array('internalname' => "cover", - 'options' => array(elgg_echo("album:cover")), - )); -?> + <?php echo elgg_view('input/checkboxes', array('internalname' => "cover", + 'options' => array(elgg_echo("album:cover")), + )); + ?> </p> -<?php + <?php } - + } else { // album so display access control $categories = elgg_view('categories',$vars); if (!empty($categories)) { -?> + ?> <p> - <?php echo $categories; ?> + <?php echo $categories; ?> </p> -<?php - } -?> - <p> - <label><?php echo elgg_echo('access'); ?></label> + <?php + } + ?> + <p> + <label><?php echo elgg_echo('access'); ?></label> <?php echo elgg_view('input/access', array('internalname' => 'access_id','value' => $access_id)); ?> - </p> + </p> -<?php + <?php } - - if (isset($vars['entity'])) { -?> - <input type="hidden" name="guid" value="<?php echo $vars['entity']->getGUID(); ?>" /> -<?php + + if (isset($vars['entity'])) { + ?> + <input type="hidden" name="guid" value="<?php echo $vars['entity']->getGUID(); ?>" /> + <?php } echo elgg_view('input/securitytoken'); -?> + ?> <input type="hidden" name="container_guid" value="<?php echo $container_guid; ?>" /> <input type="hidden" name="subtype" value="<?php echo $subtype; ?>" /> <p><input type="submit" name="submit" value="<?php echo elgg_echo('save'); ?>" /></p> 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 @@ <?php - /** - * form for mass editing all uploaded images - */ +/** + * form for mass editing all uploaded images + */ ?> <div class="contentWrapper"> <form action="<?php echo $vars['url']; ?>action/tidypics/edit_multi" method="post"> @@ -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 @@ <?php - /** - * 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'); +/** + * 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 = '<h3>' . elgg_echo('tidypics:settings:heading:main') . '</h3>'; + +// Tagging +$tagging = $plugin->tagging; +if (!$tagging) { + $tagging = "enabled"; +} +$form_body .= '<p class="admin_debug">' . elgg_view("input/checkboxes", array('options' => array(elgg_echo('tidypics:settings:tagging') => 'enabled'), 'internalname' => 'tagging', 'value' => $tagging )) . "</p>"; + +// Download Link +$download_link = $plugin->download_link; +if (!$download_link) { + $download_link = "enabled"; +} +$form_body .= '<p class="admin_debug">' . elgg_view("input/checkboxes", array('options' => array(elgg_echo('tidypics:settings:download_link') => 'enabled'), 'internalname' => 'download_link', 'value' => $download_link )) . "</p>"; + +// Ratings +$photo_ratings = $plugin->photo_ratings; +if (!$photo_ratings) { + $photo_ratings = "disabled"; +} +$form_body .= '<p class="admin_debug">' . elgg_view("input/checkboxes", array('options' => array(elgg_echo('tidypics:settings:photo_ratings') => 'enabled'), 'internalname' => 'photo_ratings', 'value' => $photo_ratings )) . "</p>"; + +// Show EXIF +$exif = $plugin->exif; +if (!$exif) { + $exif = "disabled"; +} +$form_body .= '<p class="admin_debug">' . elgg_view("input/checkboxes", array('options' => array(elgg_echo('tidypics:settings:exif') => 'enabled'), 'internalname' => 'exif', 'value' => $exif )) . "</p>"; + +// Show View count +$view_count = $plugin->view_count; +if (!$view_count) { + $view_count = "enabled"; +} +$form_body .= '<p class="admin_debug">' . elgg_view("input/checkboxes", array('options' => array(elgg_echo('tidypics:settings:view_count') => 'enabled'), 'internalname' => 'view_count', 'value' => $view_count )) . "</p>"; + +// Watermark Text +$form_body .= "<p>" . elgg_echo('tidypics:settings:watermark') . "<br />"; +$form_body .= elgg_view("input/text",array('internalname' => 'params[watermark_text]', 'value' => $plugin->watermark_text)) . "</p>"; + +// Max Image Size +$maxfilesize = $plugin->maxfilesize; +if (!$maxfilesize) { + $maxfilesize = (int)5; // 5 MB +} +$form_body .= "<p>" . elgg_echo('tidypics:settings:maxfilesize') . "<br />"; +$form_body .= elgg_view("input/text",array('internalname' => 'params[maxfilesize]', 'value' => $maxfilesize)) . "</p>"; + +// Quota Size +$quota = $plugin->quota; +if (!$quota) { + $quota = 0; +} +$form_body .= "<p>" . elgg_echo('tidypics:settings:quota') . "<br />"; +$form_body .= elgg_view("input/text",array('internalname' => 'params[quota]', 'value' => $quota)) . "</p>"; + +// 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 .= '<h3>' . elgg_echo('tidypics:settings:heading:img_lib') . '</h3>'; +$image_lib = $plugin->image_lib; +if (!$image_lib) { + $image_lib = 'GD'; +} +$form_body .= '<p>' . 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 .= '<br/>Note: If you want to select ImageMagick Command Line, first confirm that it is installed on your server.</p>'; + +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 = '<h3>' . elgg_echo('tidypics:settings:heading:main') . '</h3>'; - - // Tagging - $tagging = $plugin->tagging; - if(!$tagging) $tagging = "enabled"; - $form_body .= '<p class="admin_debug">' . elgg_view("input/checkboxes", array('options' => array(elgg_echo('tidypics:settings:tagging') => 'enabled'), 'internalname' => 'tagging', 'value' => $tagging )) . "</p>"; - - // Download Link - $download_link = $plugin->download_link; - if(!$download_link) $download_link = "enabled"; - $form_body .= '<p class="admin_debug">' . elgg_view("input/checkboxes", array('options' => array(elgg_echo('tidypics:settings:download_link') => 'enabled'), 'internalname' => 'download_link', 'value' => $download_link )) . "</p>"; - - // Ratings - $photo_ratings = $plugin->photo_ratings; - if(!$photo_ratings) $photo_ratings = "disabled"; - $form_body .= '<p class="admin_debug">' . elgg_view("input/checkboxes", array('options' => array(elgg_echo('tidypics:settings:photo_ratings') => 'enabled'), 'internalname' => 'photo_ratings', 'value' => $photo_ratings )) . "</p>"; - - // Show EXIF - $exif = $plugin->exif; - if(!$exif) $exif = "disabled"; - $form_body .= '<p class="admin_debug">' . elgg_view("input/checkboxes", array('options' => array(elgg_echo('tidypics:settings:exif') => 'enabled'), 'internalname' => 'exif', 'value' => $exif )) . "</p>"; - - // Show View count - $view_count = $plugin->view_count; - if(!$view_count) $view_count = "enabled"; - $form_body .= '<p class="admin_debug">' . elgg_view("input/checkboxes", array('options' => array(elgg_echo('tidypics:settings:view_count') => 'enabled'), 'internalname' => 'view_count', 'value' => $view_count )) . "</p>"; - - // Watermark Text - $form_body .= "<p>" . elgg_echo('tidypics:settings:watermark') . "<br />"; - $form_body .= elgg_view("input/text",array('internalname' => 'params[watermark_text]', 'value' => $plugin->watermark_text)) . "</p>"; - - // Max Image Size - $maxfilesize = $plugin->maxfilesize; - if (!$maxfilesize) $maxfilesize = (int)5; // 5 MB - $form_body .= "<p>" . elgg_echo('tidypics:settings:maxfilesize') . "<br />"; - $form_body .= elgg_view("input/text",array('internalname' => 'params[maxfilesize]', 'value' => $maxfilesize)) . "</p>"; - - // Quota Size - $quota = $plugin->quota; - if (!$quota) $quota = 0; - $form_body .= "<p>" . elgg_echo('tidypics:settings:quota') . "<br />"; - $form_body .= elgg_view("input/text",array('internalname' => 'params[quota]', 'value' => $quota)) . "</p>"; - - // 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 .= '<h3>' . elgg_echo('tidypics:settings:heading:img_lib') . '</h3>'; - $image_lib = $plugin->image_lib; - if (!$image_lib) $image_lib = 'GD'; - $form_body .= '<p>' . 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 .= '<br/>Note: If you want to select ImageMagick Command Line, first confirm that it is installed on your server.</p>'; - - 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 .= "<p>" . elgg_echo('tidypics:settings:im_path') . "<br />"; - $form_body .= elgg_view("input/text",array('internalname' => 'params[im_path]', 'value' => $im_path)) . "</p>"; - } - - - // River Image options - $form_body .= '<h3>' . elgg_echo('tidypics:settings:heading:river') . '</h3>'; - $img_river_view = $plugin->img_river_view; - if (!$img_river_view) $img_river_view = '1'; - $form_body .= '<p>' . 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 .= '</p>'; - - // River Album options - $album_river_view = $plugin->album_river_view; - if (!$album_river_view) $album_river_view = 'set'; - $form_body .= '<p>' . 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 .= '</p>'; - - // Thumbnail sizes - $form_body .= '<h3>' . elgg_echo('tidypics:settings:heading:sizes') . '</h3>'; - $form_body .= "<h6>You must edit the css if you change the default sizes</h6>"; - $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 .= "<p>" . elgg_echo('tidypics:settings:largesize') . "<br />"; - $form_body .= 'width: <input style="width: 20%;" type="text" name="large_thumb_width" value=' . "\"{$image_sizes['large_image_width']}\"" . ' class="input-text" /> '; - $form_body .= 'height: <input style="width: 20%;" type="text" name="large_thumb_height" value=' . "\"{$image_sizes['large_image_height']}\"" . ' class="input-text" /></p>'; - - $form_body .= "<p>" . elgg_echo('tidypics:settings:smallsize') . "<br />"; - $form_body .= 'width and height: <input style="width: 20%;" type="text" name="small_thumb_width" value=' . "\"{$image_sizes['small_image_width']}\"" . ' class="input-text" /> '; - //$form_body .= 'height: <input style="width: 20%;" type="text" name="small_thumb_height" value=' . "\"{$image_sizes['small_image_height']}\"" . ' class="input-text" /></p>'; - - $form_body .= "<p>" . elgg_echo('tidypics:settings:thumbsize') . "<br />"; - $form_body .= 'width and height: <input style="width: 20%;" type="text" name="thumb_width" value=' . "\"{$image_sizes['thumb_image_width']}\"" . ' class="input-text" /> '; - //$form_body .= 'height: <input style="width: 20%;" type="text" name="thumb_height" value=' . "\"{$image_sizes['thumb_image_height']}\"" . ' class="input-text" /></p>'; - - - // Group permission override - $form_body .= '<h3>' . elgg_echo('tidypics:settings:heading:groups') . '</h3>'; - $grp_perm_override = $plugin->grp_perm_override; - if(!$grp_perm_override) $grp_perm_override = "enabled"; - $form_body .= '<p class="admin_debug">' . elgg_view("input/checkboxes", array('options' => array(elgg_echo('tidypics:settings:grp_perm_override') => 'enabled'), 'internalname' => 'grp_perm_override', 'value' => $grp_perm_override )) . "</p>"; - - $form_body .= elgg_view('input/submit', array('value' => elgg_echo("save"))); - - echo elgg_view('input/form', array('action' => $action, 'body' => $form_body)); + $form_body .= "<p>" . elgg_echo('tidypics:settings:im_path') . "<br />"; + $form_body .= elgg_view("input/text",array('internalname' => 'params[im_path]', 'value' => $im_path)) . "</p>"; +} + + +// River Image options +$form_body .= '<h3>' . elgg_echo('tidypics:settings:heading:river') . '</h3>'; +$img_river_view = $plugin->img_river_view; +if (!$img_river_view) { + $img_river_view = '1'; +} +$form_body .= '<p>' . 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 .= '</p>'; + +// River Album options +$album_river_view = $plugin->album_river_view; +if (!$album_river_view) { + $album_river_view = 'set'; +} +$form_body .= '<p>' . 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 .= '</p>'; + +// Thumbnail sizes +$form_body .= '<h3>' . elgg_echo('tidypics:settings:heading:sizes') . '</h3>'; +$form_body .= "<h6>You must edit the css if you change the default sizes</h6>"; +$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 .= "<p>" . elgg_echo('tidypics:settings:largesize') . "<br />"; +$form_body .= 'width: <input style="width: 20%;" type="text" name="large_thumb_width" value=' . "\"{$image_sizes['large_image_width']}\"" . ' class="input-text" /> '; +$form_body .= 'height: <input style="width: 20%;" type="text" name="large_thumb_height" value=' . "\"{$image_sizes['large_image_height']}\"" . ' class="input-text" /></p>'; + +$form_body .= "<p>" . elgg_echo('tidypics:settings:smallsize') . "<br />"; +$form_body .= 'width and height: <input style="width: 20%;" type="text" name="small_thumb_width" value=' . "\"{$image_sizes['small_image_width']}\"" . ' class="input-text" /> '; +//$form_body .= 'height: <input style="width: 20%;" type="text" name="small_thumb_height" value=' . "\"{$image_sizes['small_image_height']}\"" . ' class="input-text" /></p>'; + +$form_body .= "<p>" . elgg_echo('tidypics:settings:thumbsize') . "<br />"; +$form_body .= 'width and height: <input style="width: 20%;" type="text" name="thumb_width" value=' . "\"{$image_sizes['thumb_image_width']}\"" . ' class="input-text" /> '; +//$form_body .= 'height: <input style="width: 20%;" type="text" name="thumb_height" value=' . "\"{$image_sizes['thumb_image_height']}\"" . ' class="input-text" /></p>'; + + +// Group permission override +$form_body .= '<h3>' . elgg_echo('tidypics:settings:heading:groups') . '</h3>'; +$grp_perm_override = $plugin->grp_perm_override; +if (!$grp_perm_override) { + $grp_perm_override = "enabled"; +} +$form_body .= '<p class="admin_debug">' . elgg_view("input/checkboxes", array('options' => array(elgg_echo('tidypics:settings:grp_perm_override') => 'enabled'), 'internalname' => 'grp_perm_override', 'value' => $grp_perm_override )) . "</p>"; + +$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 @@ <?php - global $CONFIG; - - //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; +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; } +} ?> <div id="tidypics_ref"></div> <div class="contentWrapper"> -<?php + <?php ob_start(); -?> -<p style="line-height:1.6em;"> - <label><?php echo elgg_echo("images:upload"); ?></label><br /> - <i><?php echo elgg_echo("tidypics:settings:maxfilesize") . ' ' . $maxfilesize; ?></i><br /> -<?php - if ($quota) { -?> - <i><?php echo elgg_echo("tidypics:quota") . ' ' . $image_repo_size . '/' . $quota . " MB ({$quote_percentage}%)"; ?></i><br /> -<?php - } -?> + ?> + <p style="line-height:1.6em;"> + <label><?php echo elgg_echo("images:upload"); ?></label><br /> + <i><?php echo elgg_echo("tidypics:settings:maxfilesize") . ' ' . $maxfilesize; ?></i><br /> + <?php + if ($quota) { + ?> + <i><?php echo elgg_echo("tidypics:quota") . ' ' . $image_repo_size . '/' . $quota . " MB ({$quote_percentage}%)"; ?></i><br /> + <?php + } + ?> <div class="tidypics_popup"> - <?php echo elgg_echo("tidypics:uploading:images"); ?><br /> + <?php echo elgg_echo("tidypics:uploading:images"); ?><br /> <div style="margin:20px 0px 20px 80px;"><img id="progress" alt="..." border="0" src="<?php echo $vars['url'].'mod/tidypics/graphics/loader.gif' ?>" /></div> </div> <ol id="tidypics_image_upload_list"> -<?php + <?php for ($x = 0; $x < 10; $x++) { echo '<li>' . elgg_view("input/file",array('internalname' => "upload_$x")) . '</li>'; - } -?> + } + ?> </ol> </p> <p> -<?php - if ($container_guid) - echo '<input type="hidden" name="container_guid" value="' . $container_guid . '" />'; - if ($access_id) - echo '<input type="hidden" name="access_id" value="' . $access_id . '" />'; -?> + <?php + if ($container_guid) { + echo '<input type="hidden" name="container_guid" value="' . $container_guid . '" />'; + } + if ($access_id) { + echo '<input type="hidden" name="access_id" value="' . $access_id . '" />'; + } + ?> <input type="submit" value="<?php echo elgg_echo("save"); ?>" onclick="displayProgress();" /> </p> <?php - $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',)); +$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',) +); ?> </div> <script type="text/javascript"> @@ -81,11 +86,11 @@ { offsetY = 60; offsetX = 120; - + divWidth = $('#tidypics_ref').width(); imgOffset = $('#tidypics_ref').offset(); imgWidth = $('#tidypics_ref').width(); - + _top = imgOffset.top + offsetY; _left = imgOffset.left + offsetX; @@ -93,7 +98,7 @@ "top": _top + "px", "left": _left + "px" }); - - setTimeout('document.images["progress"].src = "<?php echo $vars['url'].'mod/tidypics/graphics/loader.gif' ?>"', 200); + + setTimeout('document.images["progress"].src = "<?php echo $vars['url'].'mod/tidypics/graphics/loader.gif' ?>"', 200); } </script>
\ 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 '</div>'; } -?>
\ 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 @@ <?php - /************************************************************************** - * - * 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) { +/************************************************************************** + * + * 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) { ?> <li id="start_tagging"><a id="tidypics_tag_control" href="javascript:void(0)" onclick="startTagging()"><?php echo elgg_echo('tidypics:tagthisphoto'); ?></a></li> <?php - } - - // only owner can delete tags - if ($anytags && $viewer && $viewer->guid == $owner->guid) { + } + + // only owner can delete tags + if ($anytags && $viewer && $viewer->guid == $owner->guid) { ?> <li id="delete_tags"><a href="javascript:void(0)" onclick="deleteTags()"><?php echo elgg_echo('tidypics:deletetag'); ?></a></li> <?php - } } - - if (get_plugin_setting('download_link', 'tidypics') != "disabled") { - $download_url = $vars['url'] . "pg/photos/download/{$image_guid}/"; +} + +if (get_plugin_setting('download_link', 'tidypics') != "disabled") { + $download_url = $vars['url'] . "pg/photos/download/{$image_guid}/"; ?> <li id="download_image"><a href="<?php echo $download_url; ?>"><?php echo elgg_echo("image:download"); ?></a></li> <?php - } -?>
\ 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 @@ <?php - $image = $vars['image']; - $viewer = $vars['viewer']; - $owner = $vars['owner']; +$image = $vars['image']; +$viewer = $vars['viewer']; +$owner = $vars['owner']; - // get photo tags - $tag_info = $image->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) { ?> <div id="tidypics_phototags_list"> <h3><?php echo elgg_echo('tidypics:inthisphoto') ?></h3> <ul> <?php - foreach ($tag_info['links'] as $id=>$link) { - echo "<li><a class='tidypics_phototag_links' id='taglink{$id}' href='{$link['url']}'>{$link['text']}</a></li>"; - } + foreach ($tag_info['links'] as $id=>$link) { + echo "<li><a class='tidypics_phototag_links' id='taglink{$id}' href='{$link['url']}'>{$link['text']}</a></li>"; + } ?> </ul> </div> <?php - } +} ?> <div id='tidypics_tag_instructions'> <div id='tidypics_tag_instruct_text'><?php echo elgg_echo('tidypics:taginstruct'); ?></div> @@ -34,10 +34,10 @@ </div> <div id="tidypics_tag_menu" class="tidypics_popup"> <div class='tidypics_popup_header'><h3><?php echo elgg_echo('tidypics:tagthisphoto'); ?></h3></div> -<?php + <?php if ($viewer) { - + $people_list = tp_get_tag_list($viewer); $content = "<div id='tidypics_tagmenu_left'>"; @@ -45,30 +45,30 @@ $content .= "<input type='hidden' name='coordinates' id='coordinates' value='' />"; $content .= "<input type='hidden' name='user_id' id='user_id' value='' />"; $content .= "<input type='hidden' name='word' id='word' value='' />"; - + $content .= "<ul id='tidypics_phototag_list'>"; $content .= "<li><a href='javascript:void(0)' onclick='selectUser({$viewer->getGUID()},\"{$viewer->name}\")'> {$viewer->name} (" . elgg_echo('me') . ")</a></li>"; - + if ($people_list) { foreach($people_list as $friend_guid => $friend_name) { $content .= "<li><a href='javascript:void(0)' onclick='selectUser({$friend_guid}, \"{$friend_name}\")'>{$friend_name}</a></li>"; } } - + $content .= "</ul></div>"; - + $content .= "<div id='tidypics_tagmenu_right'><input type='submit' value='" . elgg_echo('tidypics:actiontag') . "' class='submit_button' /></div>"; - + echo elgg_view('input/form', array('internalid' => 'quicksearch', 'internalname' => 'tidypics_phototag_form', 'class' => 'quicksearch', 'action' => "{$vars['url']}action/tidypics/addtag", 'method' => 'post', 'body' => $content)); } -?> -<div class="clearfloat"></div> + ?> + <div class="clearfloat"></div> </div> <div id="tidypics_delete_tag_menu" class="tidypics_popup"> <div class='tidypics_popup_header'><h3><?php echo elgg_echo('tidypics:deltag_title'); ?></h3></div> -<?php + <?php if ($tag_info) { $content = "<input type='hidden' name='image_guid' value='{$image->guid}' />"; foreach ($tag_info['links'] as $id => $link) { @@ -77,7 +77,7 @@ } $content .= "<input type='submit' value='" . elgg_echo('tidypics:actiondelete') . "' class='submit_button' />"; - $content .= "<input type='button' value='" . elgg_echo('cancel') . "' class='cancel_button' onclick='hideDeleteMenu();' />"; + $content .= "<input type='button' value='" . elgg_echo('cancel') . "' class='cancel_button' onclick='hideDeleteMenu();' />"; echo elgg_view('input/form', array('internalname' => 'phototag_deletetag_form', 'action' => "{$vars['url']}action/tidypics/deletetag", 'method' => 'post', 'body' => $content)); @@ -85,5 +85,4 @@ ?> </div> <?php - echo elgg_view('tidypics/js/tagging', array('photo_tags_json' => $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 @@ <p> <?php - echo elgg_echo("tidypics:widget:num_albums") . ": "; - - - if($vars['entity']->num_display == '') $vars['entity']->num_display = 5; - +echo elgg_echo("tidypics:widget:num_albums") . ": "; + + +if ($vars['entity']->num_display == '') { + $vars['entity']->num_display = 5; +} ?> <select name="params[num_display]"> <option value="1" <?php if($vars['entity']->num_display == 1) echo "SELECTED"; ?>>1</option> diff --git a/views/default/widgets/album_view/view.php b/views/default/widgets/album_view/view.php index b4248df35..1b980aa8b 100644 --- a/views/default/widgets/album_view/view.php +++ b/views/default/widgets/album_view/view.php @@ -1,13 +1,14 @@ <div class="contentWrapper"> <?php - //the number of files to display - $number = (int) $vars['entity']->num_display; - //if no number has been set, default to 5 - if (!$number) - $number = 5; +//the number of files to display +$number = (int) $vars['entity']->num_display; +//if no number has been set, default to 5 +if (!$number) { + $number = 5; +} - echo elgg_view('tidypics/albums', array('num_albums' => $number)); +echo elgg_view('tidypics/albums', array('num_albums' => $number)); ?> </div>
\ No newline at end of file diff --git a/views/default/widgets/latest_photos/edit.php b/views/default/widgets/latest_photos/edit.php index 3b334d722..06693648d 100644 --- a/views/default/widgets/latest_photos/edit.php +++ b/views/default/widgets/latest_photos/edit.php @@ -1,9 +1,11 @@ <p> <?php - echo elgg_echo("tidypics:widget:num_latest") . ": "; +echo elgg_echo("tidypics:widget:num_latest") . ": "; + +if ($vars['entity']->num_display == '') { + $vars['entity']->num_display = 6; +} - if($vars['entity']->num_display == '') $vars['entity']->num_display = 6; - ?> <select name="params[num_display]"> <option value="6" <?php if($vars['entity']->num_display == 6) echo "SELECTED"; ?>>6</option> 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 @@ <div class="contentWrapper"> <?php - //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; +//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 '<div class="tidypics_widget_latest">'; - echo tp_get_latest_photos($number, page_owner()); - echo '</div>'; +echo '<div class="tidypics_widget_latest">'; +echo tp_get_latest_photos($number, page_owner()); +echo '</div>'; ?> </div>
\ 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 @@ <?php - /** - * Tidypics RSS file object view - need to look into removing download link based on settings - */ +/** + * Tidypics RSS file object view - need to look into removing download link based on settings + */ - $title = $vars['entity']->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 .= " ..."; } - +} ?> <item> 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 @@ <?php - /** - * Tidypics Listing RSS View - */ +/** + * Tidypics Listing RSS View + */ $context = $vars['context']; $entities = $vars['entities']; @@ -14,5 +14,3 @@ if (is_array($entities) && sizeof($entities) > 0) { echo elgg_view_entity($entity); } } - -?>
\ No newline at end of file |