aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/photos/image/save.php40
-rw-r--r--classes/TidypicsAlbum.php11
-rw-r--r--classes/TidypicsImage.php17
-rw-r--r--languages/en.php1
-rw-r--r--lib/resize.php16
-rw-r--r--lib/upload.php4
-rw-r--r--pages/photos/album/edit.php1
-rw-r--r--pages/photos/all.php5
-rw-r--r--pages/photos/friends.php5
-rw-r--r--pages/photos/image/edit.php54
-rw-r--r--pages/photos/owner.php6
-rw-r--r--start.php74
-rw-r--r--views/default/forms/photos/image/save.php48
13 files changed, 242 insertions, 40 deletions
diff --git a/actions/photos/image/save.php b/actions/photos/image/save.php
new file mode 100644
index 000000000..535ae8bbb
--- /dev/null
+++ b/actions/photos/image/save.php
@@ -0,0 +1,40 @@
+<?php
+/**
+ * Save image action
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+// Get input data
+$title = get_input('title');
+$description = get_input('description');
+$tags = get_input('tags');
+$access_id = get_input('access_id');
+$guid = get_input('guid');
+
+elgg_make_sticky_form('tidypics');
+
+if (empty($title)) {
+ register_error(elgg_echo("album:blank"));
+ forward(REFERER);
+}
+
+$image = get_entity($guid);
+
+$image->access_id = $access_id;
+$image->title = $title;
+$image->description = $description;
+if ($tags) {
+ $image->tags = string_to_tag_array($tags);
+}
+
+if (!$image->save()) {
+ register_error(elgg_echo("image:error"));
+ forward(REFERER);
+}
+
+elgg_clear_sticky_form('tidypics');
+
+system_message(elgg_echo("image:saved"));
+forward($image->getURL());
diff --git a/classes/TidypicsAlbum.php b/classes/TidypicsAlbum.php
index f1fd20669..f85b66d72 100644
--- a/classes/TidypicsAlbum.php
+++ b/classes/TidypicsAlbum.php
@@ -72,6 +72,17 @@ class TidypicsAlbum extends ElggObject {
}
/**
+ * Get the URL for this album
+ *
+ * @return string
+ */
+ public function getURL() {
+ $title = elgg_get_friendly_title($this->getTitle());
+ $url = "photos/album/$this->guid/$title";
+ return elgg_normalize_url($url);
+ }
+
+ /**
* Get an array of image objects
*
* @param int $limit
diff --git a/classes/TidypicsImage.php b/classes/TidypicsImage.php
index c604d869e..926bc386b 100644
--- a/classes/TidypicsImage.php
+++ b/classes/TidypicsImage.php
@@ -9,8 +9,8 @@
class TidypicsImage extends ElggFile {
- protected function initialise_attributes() {
- parent::initialise_attributes();
+ protected function initializeAttributes() {
+ parent::initializeAttributes();
$this->attributes['subtype'] = "image";
}
@@ -52,6 +52,17 @@ class TidypicsImage extends ElggFile {
}
/**
+ * Get the URL for the web page of this image
+ *
+ * @return string
+ */
+ public function getURL() {
+ $title = elgg_get_friendly_title($this->getTitle());
+ $url = "photos/image/$this->guid/$title";
+ return elgg_normalize_url($url);
+ }
+
+ /**
* Get the src URL for the image
*
* @return string
@@ -312,7 +323,7 @@ class TidypicsImage extends ElggFile {
* @param $viewer_guid the guid of the viewer (0 if not logged in)
* @return array with number of views, number of unique viewers, and number of views for this viewer
*/
- public function getViews($viewer_guid) {
+ public function getViewCount($viewer_guid) {
$views = get_annotations($this->getGUID(), "object", "image", "tp_view", "", 0, 99999);
if ($views) {
$total_views = count($views);
diff --git a/languages/en.php b/languages/en.php
index 58055039c..96b63c170 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -53,6 +53,7 @@ $english = array(
'tidypics:nophotosingroup' => 'This groups does not have any photos yet',
'tidypics:upgrade' => 'Upgrade',
'tidypics:sort' => 'Sorting the %s album',
+ 'tidypics:none' => 'No photo albums',
//settings
'tidypics:settings' => 'Settings',
diff --git a/lib/resize.php b/lib/resize.php
index 857d0ba1c..78b5290e6 100644
--- a/lib/resize.php
+++ b/lib/resize.php
@@ -19,11 +19,11 @@ include dirname(__FILE__) . "/watermark.php";
function tp_create_gd_thumbnails($file, $prefix, $filestorename) {
global $CONFIG;
- $image_sizes = get_plugin_setting('image_sizes', 'tidypics');
+ $image_sizes = elgg_get_plugin_setting('image_sizes', 'tidypics');
if (!$image_sizes) {
// move this out of library
register_error(elgg_echo('tidypics:nosettings'));
- forward($_SERVER['HTTP_REFERER']);
+ forward(REFERER);
return FALSE;
}
$image_sizes = unserialize($image_sizes);
@@ -38,8 +38,8 @@ function tp_create_gd_thumbnails($file, $prefix, $filestorename) {
$rtn_code = tp_gd_resize( $file->getFilenameOnFilestore(),
$thumbname,
FALSE,
- $image_sizes['thumb_image_width'],
- $image_sizes['thumb_image_height'],
+ $image_sizes['tiny_image_width'],
+ $image_sizes['tiny_image_height'],
TRUE);
if (!$rtn_code) {
return FALSE;
@@ -209,8 +209,8 @@ function tp_create_imagick_thumbnails($file, $prefix, $filestorename) {
$thumbname = $thumb->getFilenameOnFilestore();
$rtn_code = tp_imagick_resize( $file->getFilenameOnFilestore(),
$thumbname,
- $image_sizes['thumb_image_width'],
- $image_sizes['thumb_image_height'],
+ $image_sizes['tiny_image_width'],
+ $image_sizes['tiny_image_height'],
TRUE);
if (!$rtn_code) {
return FALSE;
@@ -335,8 +335,8 @@ function tp_create_im_cmdline_thumbnails($file, $prefix, $filestorename) {
$thumbname = $thumb->getFilenameOnFilestore();
$rtn_code = tp_im_cmdline_resize( $file->getFilenameOnFilestore(),
$thumbname,
- $image_sizes['thumb_image_width'],
- $image_sizes['thumb_image_height'],
+ $image_sizes['tiny_image_width'],
+ $image_sizes['tiny_image_height'],
TRUE);
if (!$rtn_code) {
return FALSE;
diff --git a/lib/upload.php b/lib/upload.php
index 30540dced..0b034517c 100644
--- a/lib/upload.php
+++ b/lib/upload.php
@@ -82,7 +82,7 @@ function tp_upload_memory_check($image_lib, $num_pixels) {
* @return bool false = too large
*/
function tp_upload_check_max_size($image_size) {
- $max_file_size = (float) get_plugin_setting('maxfilesize','tidypics');
+ $max_file_size = (float) elgg_get_plugin_setting('maxfilesize', 'tidypics');
if (!$max_file_size) {
// default to 5 MB if not set
$max_file_size = 5;
@@ -103,7 +103,7 @@ function tp_upload_check_quota($image_size, $owner_guid) {
static $quota;
if (!isset($quota)) {
- $quota = get_plugin_setting('quota','tidypics');
+ $quota = elgg_get_plugin_setting('quota', 'tidypics');
$quota = 1024 * 1024 * $quota;
}
diff --git a/pages/photos/album/edit.php b/pages/photos/album/edit.php
index 6fff50b29..7efb05ce1 100644
--- a/pages/photos/album/edit.php
+++ b/pages/photos/album/edit.php
@@ -33,6 +33,7 @@ if (elgg_instanceof($owner, 'user')) {
} else {
elgg_push_breadcrumb($owner->name, "photos/group/$owner->guid/all");
}
+elgg_push_breadcrumb($entity->getTitle(), $entity->getURL());
elgg_push_breadcrumb($title);
$vars = tidypics_prepare_form_vars($entity);
diff --git a/pages/photos/all.php b/pages/photos/all.php
index edda65ce0..aef7f11c6 100644
--- a/pages/photos/all.php
+++ b/pages/photos/all.php
@@ -10,7 +10,6 @@ elgg_push_breadcrumb(elgg_echo('photos'));
$num_albums = 16;
-elgg_push_context('tidypics:main');
$offset = (int)get_input('offset', 0);
$content = elgg_list_entities(array(
'type' => 'object',
@@ -21,7 +20,9 @@ $content = elgg_list_entities(array(
'list_type_toggle' => false,
'gallery_class' => 'tidypics-gallery',
));
-elgg_pop_context();
+if (!$content) {
+ $content = elgg_echo('tidypics:none');
+}
$title = elgg_echo('album:all');
diff --git a/pages/photos/friends.php b/pages/photos/friends.php
index b7b6178c5..e6ac49cc6 100644
--- a/pages/photos/friends.php
+++ b/pages/photos/friends.php
@@ -17,10 +17,11 @@ $title = elgg_echo('album:friends');
$num_albums = 16;
-elgg_push_context('tidypics:main');
set_input('list_type', 'gallery');
$content = list_user_friends_objects($owner->guid, 'album', $num_albums, false);
-elgg_pop_context();
+if (!$content) {
+ $content = elgg_echo('tidypics:none');
+}
elgg_register_title_button();
diff --git a/pages/photos/image/edit.php b/pages/photos/image/edit.php
new file mode 100644
index 000000000..76c1381c9
--- /dev/null
+++ b/pages/photos/image/edit.php
@@ -0,0 +1,54 @@
+<?php
+/**
+ * Edit an image
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+$guid = (int) get_input('guid');
+
+if (!$entity = get_entity($guid)) {
+ // @todo either deleted or do not have access
+ forward('photos/all');
+}
+
+if (!$entity->canEdit()) {
+ // @todo cannot change it
+ forward($entity->getContainerEntity()->getURL());
+}
+
+$album = $entity->getContainerEntity();
+if (!$album) {
+
+}
+
+elgg_set_page_owner_guid($album->getContainerGUID());
+$owner = elgg_get_page_owner_entity();
+
+gatekeeper();
+group_gatekeeper();
+
+$title = elgg_echo('image:edit');
+
+// set up breadcrumbs
+elgg_push_breadcrumb(elgg_echo('photos'), "photos/all");
+if (elgg_instanceof($owner, 'user')) {
+ elgg_push_breadcrumb($owner->name, "photos/owner/$owner->username");
+} else {
+ elgg_push_breadcrumb($owner->name, "photos/group/$owner->guid/all");
+}
+elgg_push_breadcrumb($album->getTitle(), $album->getURL());
+elgg_push_breadcrumb($entity->getTitle(), $entity->getURL());
+elgg_push_breadcrumb($title);
+
+$vars = tidypics_prepare_form_vars($entity);
+$content = elgg_view_form('photos/image/save', array('method' => 'post'), $vars);
+
+$body = elgg_view_layout('content', array(
+ 'content' => $content,
+ 'title' => $title,
+ 'filter' => '',
+));
+
+echo elgg_view_page($title, $body);
diff --git a/pages/photos/owner.php b/pages/photos/owner.php
index 214cd2e37..506cb569b 100644
--- a/pages/photos/owner.php
+++ b/pages/photos/owner.php
@@ -10,7 +10,6 @@ group_gatekeeper();
$owner = elgg_get_page_owner_entity();
-//set the title
$title = elgg_echo('album:user', array($owner->name));
// set up breadcrumbs
@@ -20,7 +19,6 @@ elgg_push_breadcrumb($owner->name);
$num_albums = 16;
-elgg_push_context('tidypics:main');
$content = elgg_list_entities(array(
'type' => 'object',
'subtype' => 'album',
@@ -31,7 +29,9 @@ $content = elgg_list_entities(array(
'list_type_toggle' => false,
'gallery_class' => 'tidypics-gallery',
));
-elgg_pop_context();
+if (!$content) {
+ $content = elgg_echo('tidypics:none');
+}
elgg_register_title_button();
diff --git a/start.php b/start.php
index 056c1739a..1c548b90b 100644
--- a/start.php
+++ b/start.php
@@ -23,6 +23,9 @@ function tidypics_init() {
'text' => elgg_echo('photos'),
));
+ // Register a page handler so we can have nice URLs
+ elgg_register_page_handler('photos', 'tidypics_page_handler');
+
// Extend CSS
elgg_extend_view('css/elgg', 'tidypics/css');
elgg_extend_view('css/admin', 'tidypics/css');
@@ -33,6 +36,13 @@ function tidypics_init() {
// Add admin menu item
elgg_register_admin_menu_item('configure', 'tidypics', 'settings');
+ // Register for search
+ elgg_register_entity_type('object', 'image');
+ elgg_register_entity_type('object', 'album');
+
+ // Register for the entity menu
+ elgg_register_plugin_hook_handler('register', 'menu:entity', 'tidypics_entity_menu_setup');
+
/*
// Extend hover-over and profile menu
elgg_extend_view('profile/menu/links','tidypics/hover_menu');
@@ -44,8 +54,6 @@ function tidypics_init() {
elgg_extend_view('extensions/xmlns', 'extensions/tidypics/xmlns');
elgg_extend_view('extensions/channel', 'extensions/tidypics/channel');
- // Register a page handler so we can have nice URLs
- elgg_register_page_handler('photos', 'tidypics_page_handler');
// register for menus
//register_elgg_event_handler('pagesetup', 'system', 'tidypics_submenus');
@@ -59,14 +67,6 @@ function tidypics_init() {
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');
-
add_group_tool_option('photos', elgg_echo('tidypics:enablephotos'), true);
if (get_plugin_setting('grp_perm_override', 'tidypics') != "disabled") {
@@ -88,21 +88,22 @@ function tidypics_init() {
elgg_register_action("photos/album/save", "$base_dir/album/save.php");
elgg_register_action("photos/delete", "$base_dir/delete.php");
elgg_register_action("photos/image/upload", "$base_dir/image/upload.php");
+ elgg_register_action("photos/image/save", "$base_dir/image/save.php");
elgg_register_action("photos/batch/edit", "$base_dir/batch/edit.php");
- register_action("tidypics/ajax_upload", true, "$base_dir/ajax_upload.php");
- register_action("tidypics/ajax_upload_complete", true, "$base_dir/ajax_upload_complete.php");
- register_action("tidypics/sortalbum", false, "$base_dir/sortalbum.php");
- register_action("tidypics/edit", false, "$base_dir/edit.php");
- register_action("tidypics/addtag", false, "$base_dir/addtag.php");
- register_action("tidypics/deletetag", false, "$base_dir/deletetag.php");
+ //register_action("tidypics/ajax_upload", true, "$base_dir/ajax_upload.php");
+ //register_action("tidypics/ajax_upload_complete", true, "$base_dir/ajax_upload_complete.php");
+ //register_action("tidypics/sortalbum", false, "$base_dir/sortalbum.php");
+ //register_action("tidypics/edit", false, "$base_dir/edit.php");
+ //register_action("tidypics/addtag", false, "$base_dir/addtag.php");
+ //register_action("tidypics/deletetag", false, "$base_dir/deletetag.php");
elgg_register_action("photos/admin/settings", "$base_dir/admin/settings.php", 'admin');
- register_action("tidypics/admin/upgrade", false, "$base_dir/admin/upgrade.php", true);
+ //register_action("tidypics/admin/upgrade", false, "$base_dir/admin/upgrade.php", true);
// Register libraries
$base_dir = elgg_get_plugins_path() . 'tidypics/lib';
- elgg_register_library('tidypics:upload', "$base/upload.php");
- elgg_register_library('tidypics:resize', "$base/resize.php");
+ elgg_register_library('tidypics:upload', "$base_dir/upload.php");
+ elgg_register_library('tidypics:resize', "$base_dir/resize.php");
}
/**
@@ -264,7 +265,7 @@ function tidypics_page_handler($page) {
}
$base = elgg_get_plugins_path() . 'tidypics/pages/photos';
- switch($page[0]) {
+ switch ($page[0]) {
case "all": // all site albums
case "world":
require "$base/all.php";
@@ -301,6 +302,9 @@ function tidypics_page_handler($page) {
case 'album':
require "$base/album/edit.php";
break;
+ case 'image':
+ require "$base/image/edit.php";
+ break;
case 'tidypics_batch':
require "$base/batch/edit.php";
break;
@@ -415,6 +419,36 @@ function tidypics_owner_block_menu($hook, $type, $return, $params) {
}
/**
+ * Add particular blog links/info to entity menu
+ */
+function tidypics_entity_menu_setup($hook, $type, $return, $params) {
+ if (elgg_in_context('widgets')) {
+ return $return;
+ }
+
+ $entity = $params['entity'];
+ $handler = elgg_extract('handler', $params, false);
+ if ($handler != 'photos') {
+ return $return;
+ }
+
+ if (elgg_instanceof($entity, 'object', 'image')) {
+ if (elgg_get_plugin_setting('view_count', 'tidypics')) {
+ $status_text = '27 views';
+ $options = array(
+ 'name' => 'published_status',
+ 'text' => "<span>$status_text</span>",
+ 'href' => false,
+ 'priority' => 90,
+ );
+ $return[] = ElggMenuItem::factory($options);
+ }
+ }
+
+ return $return;
+}
+
+/**
* Override permissions for group albums and images
*
* @param string $hook
diff --git a/views/default/forms/photos/image/save.php b/views/default/forms/photos/image/save.php
new file mode 100644
index 000000000..47a08640a
--- /dev/null
+++ b/views/default/forms/photos/image/save.php
@@ -0,0 +1,48 @@
+<?php
+/**
+ * Save image form body
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+$title = elgg_extract('title', $vars, '');
+$description = elgg_extract('description', $vars, '');
+$tags = elgg_extract('tags', $vars, '');
+$access_id = elgg_extract('access_id', $vars, get_default_access());
+$container_guid = elgg_extract('container_guid', $vars, elgg_get_page_owner_guid());
+$guid = elgg_extract('guid', $vars, 0);
+
+?>
+
+<div>
+ <label><?php echo elgg_echo('album:title'); ?></label>
+ <?php echo elgg_view('input/text', array('name' => 'title', 'value' => $title)); ?>
+</div>
+<div>
+ <label><?php echo elgg_echo('album:desc'); ?></label>
+ <?php echo elgg_view('input/longtext', array('name' => 'description', 'value' => $description)); ?>
+</div>
+<div>
+ <label><?php echo elgg_echo('tags'); ?></label>
+ <?php echo elgg_view('input/tags', array('name' => 'tags', 'value' => $tags)); ?>
+</div>
+<?php
+
+$categories = elgg_view('input/categories', $vars);
+if ($categories) {
+ echo $categories;
+}
+
+?>
+<div>
+ <label><?php echo elgg_echo('access'); ?></label>
+ <?php echo elgg_view('input/access', array('name' => 'access_id', 'value' => $access_id)); ?>
+</div>
+<div class="elgg-foot">
+<?php
+echo elgg_view('input/hidden', array('name' => 'guid', 'value' => $guid));
+echo elgg_view('input/hidden', array('name' => 'container_guid', 'value' => $container_guid));
+echo elgg_view('input/submit', array('value' => elgg_echo('save')));
+?>
+</div>