aboutsummaryrefslogtreecommitdiff
path: root/mod/lightpics/actions/photos/admin
diff options
context:
space:
mode:
Diffstat (limited to 'mod/lightpics/actions/photos/admin')
-rw-r--r--mod/lightpics/actions/photos/admin/create_thumbnails.php70
-rw-r--r--mod/lightpics/actions/photos/admin/imtest.php18
-rw-r--r--mod/lightpics/actions/photos/admin/settings.php29
-rw-r--r--mod/lightpics/actions/photos/admin/upgrade.php52
4 files changed, 169 insertions, 0 deletions
diff --git a/mod/lightpics/actions/photos/admin/create_thumbnails.php b/mod/lightpics/actions/photos/admin/create_thumbnails.php
new file mode 100644
index 000000000..dfb5d4ed1
--- /dev/null
+++ b/mod/lightpics/actions/photos/admin/create_thumbnails.php
@@ -0,0 +1,70 @@
+<?php
+/**
+ * Tidypics Thumbnail Creation Test
+ *
+ * Called through ajax, but registered as an Elgg action.
+ *
+ */
+
+elgg_load_library('tidypics:resize');
+
+$guid = get_input('guid');
+$image = get_entity($guid);
+
+if (!$image || !($image instanceof TidypicsImage)) {
+ register_error(elgg_echo('tidypics:thumbnail_tool:unknown_image'));
+ forward(REFERER);
+}
+
+$filename = $image->getFilename();
+$container_guid = $image->container_guid;
+if (!$filename || !$container_guid) {
+ register_error(elgg_echo('tidypics:thumbnail_tool:invalid_image_info'));
+ forward(REFERER);
+}
+
+$title = $image->getTitle();
+$prefix = "image/$container_guid/";
+$filestorename = substr($filename, strlen($prefix));
+
+$image_lib = elgg_get_plugin_setting('image_lib', 'tidypics');
+if (!$image_lib) {
+ $image_lib = "GD";
+}
+
+// ImageMagick command line
+if ($image_lib == 'ImageMagick') {
+ if (!tp_create_im_cmdline_thumbnails($image, $prefix, $filestorename)) {
+ trigger_error('Tidypics warning: failed to create thumbnails - ImageMagick command line', E_USER_WARNING);
+ register_error(elgg_echo('tidypics:thumbnail_tool:create_failed'));
+ forward(REFERER);
+ }
+
+// imagick PHP extension
+} else if ($image_lib == 'ImageMagickPHP') {
+ if (!tp_create_imagick_thumbnails($image, $prefix, $filestorename)) {
+ trigger_error('Tidypics warning: failed to create thumbnails - ImageMagick PHP', E_USER_WARNING);
+ register_error(elgg_echo('tidypics:thumbnail_tool:create_failed'));
+ forward(REFERER);
+ }
+// gd
+} else {
+ if (!tp_create_gd_thumbnails($image, $prefix, $filestorename)) {
+ trigger_error('Tidypics warning: failed to create thumbnails - GD', E_USER_WARNING);
+ register_error(elgg_echo('tidypics:thumbnail_tool:create_failed'));
+ forward(REFERER);
+ }
+}
+
+$url = elgg_normalize_url("photos/thumbnail/$guid/large");
+system_message(elgg_echo('tidypics:thumbnail_tool:created'));
+
+if (elgg_is_xhr()) {
+ echo json_encode(array(
+ 'guid' => $guid,
+ 'title' => $title,
+ 'thumbnail_src' => $url
+ ));
+}
+
+forward(REFERER); \ No newline at end of file
diff --git a/mod/lightpics/actions/photos/admin/imtest.php b/mod/lightpics/actions/photos/admin/imtest.php
new file mode 100644
index 000000000..a58643d0e
--- /dev/null
+++ b/mod/lightpics/actions/photos/admin/imtest.php
@@ -0,0 +1,18 @@
+<?php
+/**
+ * Tidypics ImageMagick Location Test
+ *
+ * Called through ajax. Not a registered Elgg action.
+ */
+
+$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/mod/lightpics/actions/photos/admin/settings.php b/mod/lightpics/actions/photos/admin/settings.php
new file mode 100644
index 000000000..aa607756d
--- /dev/null
+++ b/mod/lightpics/actions/photos/admin/settings.php
@@ -0,0 +1,29 @@
+<?php
+/**
+ * Save Tidypics plugin settings
+ *
+ * @author Cash Costello
+ * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License v2
+ */
+
+$params = get_input('params');
+foreach ($params as $k => $v) {
+ if (!elgg_set_plugin_setting($k, $v, 'lightpics')) {
+ register_error(elgg_echo('plugins:settings:save:fail', array('lightpics')));
+ forward(REFERER);
+ }
+}
+
+// image sizes
+$image_sizes = array();
+$image_sizes['large_image_width'] = get_input('large_image_width');
+$image_sizes['large_image_height'] = get_input('large_image_height');
+$image_sizes['small_image_width'] = get_input('small_image_width');
+$image_sizes['small_image_height'] = get_input('small_image_height');
+$image_sizes['tiny_image_width'] = get_input('tiny_image_width');
+$image_sizes['tiny_image_height'] = get_input('tiny_image_height');
+elgg_set_plugin_setting('image_sizes', serialize($image_sizes), 'lightpics');
+
+
+system_message(elgg_echo('tidypics:settings:save:ok'));
+forward(REFERER);
diff --git a/mod/lightpics/actions/photos/admin/upgrade.php b/mod/lightpics/actions/photos/admin/upgrade.php
new file mode 100644
index 000000000..db09ed035
--- /dev/null
+++ b/mod/lightpics/actions/photos/admin/upgrade.php
@@ -0,0 +1,52 @@
+<?php
+/**
+ * Tidypics upgrade action
+ */
+
+$plugins_path = elgg_get_plugins_path();
+
+require_once "{$plugins_path}lightpics/version.php";
+
+$local_version = elgg_get_plugin_setting('version', 'tidypics');
+
+$local_version = 2009082901;
+if ($version <= $local_version) {
+ register_error('No upgrade required');
+ forward(REFERER);
+}
+
+set_time_limit(0);
+
+$base_dir = "{$plugins_path}lightpics/upgrades";
+
+
+// taken from engine/lib/version.php
+if ($handle = opendir($base_dir)) {
+ $upgrades = array();
+
+ while ($updatefile = readdir($handle)) {
+ // Look for upgrades and add to upgrades list
+ if (!is_dir("$base_dir/$updatefile")) {
+ if (preg_match('/^([0-9]{10})\.(php)$/', $updatefile, $matches)) {
+ $plugin_version = (int) $matches[1];
+ if ($plugin_version > $local_version) {
+ $upgrades[] = "$base_dir/$updatefile";
+ }
+ }
+ }
+ }
+
+ // Sort and execute
+ asort($upgrades);
+
+ if (sizeof($upgrades) > 0) {
+ foreach ($upgrades as $upgrade) {
+ include($upgrade);
+ }
+ }
+}
+
+elgg_set_plugin_setting('version', $version, 'tidypics');
+
+system_message("Tidypics has been upgraded");
+forward(REFERER);