diff --git a/modules/contactowner/helpers/contactowner_menu.php b/modules/contactowner/helpers/contactowner_event.php similarity index 93% rename from modules/contactowner/helpers/contactowner_menu.php rename to modules/contactowner/helpers/contactowner_event.php index 3a00bf1e..6ebfccd9 100644 --- a/modules/contactowner/helpers/contactowner_menu.php +++ b/modules/contactowner/helpers/contactowner_event.php @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -class contactowner_menu_Core { - static function admin($menu, $theme) { +class contactowner_event_Core { + static function admin_menu($menu, $theme) { $menu->get("settings_menu") ->append(Menu::factory("link") ->id("contactowner") diff --git a/modules/developer/helpers/developer_menu.php b/modules/developer/helpers/developer_event.php similarity index 97% rename from modules/developer/helpers/developer_menu.php rename to modules/developer/helpers/developer_event.php index e5a39b5c..0e3ed49d 100644 --- a/modules/developer/helpers/developer_menu.php +++ b/modules/developer/helpers/developer_event.php @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -class developer_menu_Core { - static function admin($menu, $theme) { +class developer_event_Core { + static function admin_menu($menu, $theme) { $developer_menu = Menu::factory("submenu") ->id("developer_menu") ->label(t("Developer Tools")); diff --git a/modules/downloadfullsize/helpers/downloadfullsize_menu.php b/modules/downloadfullsize/helpers/downloadfullsize_event.php similarity index 92% rename from modules/downloadfullsize/helpers/downloadfullsize_menu.php rename to modules/downloadfullsize/helpers/downloadfullsize_event.php index d7095cc5..99bf42bd 100644 --- a/modules/downloadfullsize/helpers/downloadfullsize_menu.php +++ b/modules/downloadfullsize/helpers/downloadfullsize_event.php @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -class downloadfullsize_menu_Core { - static function photo($menu, $theme) { +class downloadfullsize_event_Core { + static function photo_menu($menu, $theme) { if (access::can("view_full", $theme->item)) { if (module::get_var("downloadfullsize", "fButton")) { $downloadLink = url::site("downloadfullsize/send/$theme->item"); @@ -32,7 +32,7 @@ class downloadfullsize_menu_Core { } } - static function admin($menu, $theme) { + static function admin_menu($menu, $theme) { $menu->get("settings_menu") ->append(Menu::factory("link") ->id("downloadfullsize") diff --git a/modules/dynamic/helpers/dynamic_menu.php b/modules/dynamic/helpers/dynamic_event.php similarity index 93% rename from modules/dynamic/helpers/dynamic_menu.php rename to modules/dynamic/helpers/dynamic_event.php index b2c73d6f..d03943a2 100644 --- a/modules/dynamic/helpers/dynamic_menu.php +++ b/modules/dynamic/helpers/dynamic_event.php @@ -16,8 +16,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -class dynamic_menu { - static function admin($menu, $theme) { +class dynamic_event_Core { + static function admin_menu($menu, $theme) { $menu->get("content_menu") ->append(Menu::factory("link") ->id("dynamic_menu") diff --git a/modules/embedlinks/helpers/embedlinks_menu.php b/modules/embedlinks/helpers/embedlinks_event.php similarity index 93% rename from modules/embedlinks/helpers/embedlinks_menu.php rename to modules/embedlinks/helpers/embedlinks_event.php index 64698e7f..83b461e1 100644 --- a/modules/embedlinks/helpers/embedlinks_menu.php +++ b/modules/embedlinks/helpers/embedlinks_event.php @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -class embedlinks_menu_Core { - static function admin($menu, $theme) { +class embedlinks_event_Core { + static function admin_menu($menu, $theme) { $menu->get("settings_menu") ->append(Menu::factory("link") ->id("embedlinks") diff --git a/modules/embedlinks/views/embedlinks_album_block.html.php b/modules/embedlinks/views/embedlinks_album_block.html.php index dafca2ec..210b13bd 100644 --- a/modules/embedlinks/views/embedlinks_album_block.html.php +++ b/modules/embedlinks/views/embedlinks_album_block.html.php @@ -1,4 +1,9 @@ + @@ -8,12 +13,12 @@ - + - +
type}s/{$item->id}") ?>">Click Here" />
type}s/{$item->id}") ?>">thumb_url(true) ?>">" />
@@ -28,12 +33,12 @@ - + type}s/{$item->id}") ?>]Click Here[/url]" /> - + type}s/{$item->id}") ?>][img]thumb_url(true) ?>[/img][/url]" /> diff --git a/modules/embedlinks/views/embedlinks_bbcodedialog.html.php b/modules/embedlinks/views/embedlinks_bbcodedialog.html.php index 43f4a72f..ea83bb0f 100644 --- a/modules/embedlinks/views/embedlinks_bbcodedialog.html.php +++ b/modules/embedlinks/views/embedlinks_bbcodedialog.html.php @@ -1,20 +1,20 @@

-
+
- - + + - - + + diff --git a/modules/embedlinks/views/embedlinks_htmldialog.html.php b/modules/embedlinks/views/embedlinks_htmldialog.html.php index 93dfacd9..2524648a 100644 --- a/modules/embedlinks/views/embedlinks_htmldialog.html.php +++ b/modules/embedlinks/views/embedlinks_htmldialog.html.php @@ -1,20 +1,20 @@

-
+
-
- + + - - + + diff --git a/modules/embedlinks/views/embedlinks_photo_block.html.php b/modules/embedlinks/views/embedlinks_photo_block.html.php index 9d50c32a..08a9b387 100644 --- a/modules/embedlinks/views/embedlinks_photo_block.html.php +++ b/modules/embedlinks/views/embedlinks_photo_block.html.php @@ -1,4 +1,9 @@ +

@@ -10,17 +15,17 @@ - + - + - + @@ -30,17 +35,17 @@ - + - + - + @@ -50,17 +55,17 @@ - + - + - + @@ -77,17 +82,17 @@ - + - + - + @@ -97,17 +102,17 @@ - + - + - + @@ -117,17 +122,17 @@ - + - + - + diff --git a/modules/google_analytics/helpers/google_analytics_menu.php b/modules/google_analytics/helpers/google_analytics_event.php similarity index 93% rename from modules/google_analytics/helpers/google_analytics_menu.php rename to modules/google_analytics/helpers/google_analytics_event.php index 203af868..e1f2b146 100644 --- a/modules/google_analytics/helpers/google_analytics_menu.php +++ b/modules/google_analytics/helpers/google_analytics_event.php @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -class google_analytics_menu { - static function admin($menu, $theme) { +class google_analytics_event_Core { + static function admin_menu($menu, $theme) { $menu->get("settings_menu") ->append(Menu::factory("link") ->id("google_analytics_menu") diff --git a/modules/keeporiginal/controllers/keeporiginal.php b/modules/keeporiginal/controllers/keeporiginal.php new file mode 100644 index 00000000..b364db75 --- /dev/null +++ b/modules/keeporiginal/controllers/keeporiginal.php @@ -0,0 +1,62 @@ +file_path()); + + // Make sure the current item is a photo and that an original exists. + if ($item->is_photo() && file_exists($original_image)) { + + // Delete the modified version and move the original over in place of it. + unlink($item->file_path()); + rename($original_image, $item->file_path()); + + // Re-generate the items resize and thumbnail. + $item_data = model_cache::get("item", $id); + $item_data->resize_dirty= 1; + $item_data->thumb_dirty= 1; + $item_data->save(); + graphics::generate($item_data); + + // If the item is the thumbnail for the parent album, + // fix the parent's thumbnail as well. + $parent = $item_data->parent(); + if ($parent->album_cover_item_id == $item_data->id) { + copy($item_data->thumb_path(), $parent->thumb_path()); + $parent->thumb_width = $item_data->thumb_width; + $parent->thumb_height = $item_data->thumb_height; + $parent->save(); + } + + // Display a success message and redirect to the items page. + message::success(t("Your Original Image Has Been Restored.")); + url::redirect($item->url()); + } + } +} diff --git a/modules/keeporiginal/helpers/graphics.php b/modules/keeporiginal/helpers/graphics.php new file mode 100644 index 00000000..6f22d23e --- /dev/null +++ b/modules/keeporiginal/helpers/graphics.php @@ -0,0 +1,423 @@ + 200, "height" => 200, "master" => Image::AUTO), 100); + * + * Specifies that "gallery" is adding a rule to resize thumbnails down to a max of 200px on + * the longest side. The gallery module adds default rules at a priority of 100. You can set + * higher and lower priorities to perform operations before or after this fires. + * + * @param string $module_name the module that added the rule + * @param string $target the target for this operation ("thumb" or "resize") + * @param string $operation the name of the operation + * @param array $args arguments to the operation + * @param integer $priority the priority for this rule (lower priorities are run first) + */ + static function add_rule($module_name, $target, $operation, $args, $priority) { + $rule = ORM::factory("graphics_rule"); + $rule->module_name = $module_name; + $rule->target = $target; + $rule->operation = $operation; + $rule->priority = $priority; + $rule->args = serialize($args); + $rule->active = true; + $rule->save(); + + self::mark_dirty($target == "thumb", $target == "resize"); + } + + /** + * Remove any matching graphics rules + * @param string $module_name the module that added the rule + * @param string $target the target for this operation ("thumb" or "resize") + * @param string $operation the name of the operation + */ + static function remove_rule($module_name, $target, $operation) { + ORM::factory("graphics_rule") + ->where("module_name", $module_name) + ->where("target", $target) + ->where("operation", $operation) + ->delete_all(); + + self::mark_dirty($target == "thumb", $target == "resize"); + } + + /** + * Remove all rules for this module + * @param string $module_name + */ + static function remove_rules($module_name) { + $status = Database::instance()->delete("graphics_rules", array("module_name" => $module_name)); + if (count($status)) { + self::mark_dirty(true, true); + } + } + + /** + * Activate the rules for this module, typically done when the module itself is deactivated. + * Note that this does not mark images as dirty so that if you deactivate and reactivate a + * module it won't cause all of your images to suddenly require a rebuild. + */ + static function activate_rules($module_name) { + Database::instance() + ->update("graphics_rules",array("active" => true), array("module_name" => $module_name)); + } + + /** + * Deactivate the rules for this module, typically done when the module itself is deactivated. + * Note that this does not mark images as dirty so that if you deactivate and reactivate a + * module it won't cause all of your images to suddenly require a rebuild. + */ + static function deactivate_rules($module_name) { + Database::instance() + ->update("graphics_rules",array("active" => false), array("module_name" => $module_name)); + } + + /** + * Rebuild the thumb and resize for the given item. + * @param Item_Model $item + * @return true on successful generation + */ + static function generate($item) { + if ($item->is_album()) { + if (!$cover = $item->album_cover()) { + return false; + } + $input_file = $cover->file_path(); + $input_item = $cover; + } else { + $input_file = $item->file_path(); + $input_item = $item; + } + + if ($item->thumb_dirty) { + $ops["thumb"] = $item->thumb_path(); + } + if ($item->resize_dirty && !$item->is_album() && !$item->is_movie()) { + $ops["resize"] = $item->resize_path(); + } + + if (empty($ops)) { + $item->thumb_dirty = 0; + $item->resize_dirty = 0; + $item->save(); + return true; + } + + try { + foreach ($ops as $target => $output_file) { + if ($input_item->is_movie()) { + // Convert the movie to a JPG first + $output_file = preg_replace("/...$/", "jpg", $output_file); + try { + movie::extract_frame($input_file, $output_file); + } catch (Exception $e) { + // Assuming this is MISSING_FFMPEG for now + copy(MODPATH . "gallery/images/missing_movie.png", $output_file); + } + $working_file = $output_file; + } else { + $working_file = $input_file; + } + + foreach (ORM::factory("graphics_rule") + ->where("target", $target) + ->where("active", true) + ->orderby("priority", "asc") + ->find_all() as $rule) { + $args = array($working_file, $output_file, unserialize($rule->args)); + call_user_func_array(array("graphics", $rule->operation), $args); + $working_file = $output_file; + } + } + + if (!empty($ops["thumb"])) { + $dims = getimagesize($item->thumb_path()); + $item->thumb_width = $dims[0]; + $item->thumb_height = $dims[1]; + $item->thumb_dirty = 0; + } + + if (!empty($ops["resize"])) { + $dims = getimagesize($item->resize_path()); + $item->resize_width = $dims[0]; + $item->resize_height = $dims[1]; + $item->resize_dirty = 0; + } + $item->save(); + } catch (Exception $e) { + // Something went wrong rebuilding the image. Leave it dirty and move on. + // @todo we should handle this better. + Kohana::log("error", "Caught exception rebuilding image: {$item->title}\n" . + $e->getMessage() . "\n" . $e->getTraceAsString()); + return false; + } + + return true; + } + + /** + * Resize an image. Valid options are width, height and master. Master is one of the Image + * master dimension constants. + * + * @param string $input_file + * @param string $output_file + * @param array $options + */ + static function resize($input_file, $output_file, $options) { + if (!self::$init) { + self::init_toolkit(); + } + + if (@filesize($input_file) == 0) { + throw new Exception("@todo EMPTY_INPUT_FILE"); + } + + $dims = getimagesize($input_file); + if (max($dims[0], $dims[1]) < min($options["width"], $options["height"])) { + // Image would get upscaled; do nothing + copy($input_file, $output_file); + } else { + Image::factory($input_file) + ->resize($options["width"], $options["height"], $options["master"]) + ->quality(module::get_var("gallery", "image_quality")) + ->save($output_file); + } + } + + /** + * Rotate an image. Valid options are degrees + * + * @param string $input_file + * @param string $output_file + * @param array $options + */ + static function rotate($input_file, $output_file, $options) { + if (!self::$init) { + self::init_toolkit(); + } + + // BEGIN rWatcher MOD: + // If $input_file is located in VARPATH/albums/ then assume its a fullsize photo. + if (strncmp($input_file, VARPATH . "albums/", strlen(VARPATH . "albums/")) == 0) { + // Figure out where the original copy should be stashed at. + $temp_path = str_replace(VARPATH . "albums/", "", $input_file); + $original_image = VARPATH . "original/" . $temp_path; + $individual_dirs = split("[/\]", $temp_path); + // If any original file does not already exist, then create a folder structure + // similar to that found in VARPATH/albums/ and copy the photo over before + // rotating it. + if (!file_exists($original_image)) { + $new_img_path = VARPATH . "original/"; + for($i = 0; $i < count($individual_dirs)-1; $i++) { + $new_img_path = $new_img_path . "/" . $individual_dirs[$i]; + if(!file_exists($new_img_path)) { + @mkdir($new_img_path); + } + } + copy($input_file, $original_image); + } + } + // END rWatcher MOD. + + Image::factory($input_file) + ->quality(module::get_var("gallery", "image_quality")) + ->rotate($options["degrees"]) + ->save($output_file); + } + + /** + * Overlay an image on top of the input file. + * + * Valid options are: file, mime_type, position, transparency_percent, padding + * + * Valid positions: northwest, north, northeast, + * west, center, east, + * southwest, south, southeast + * + * padding is in pixels + * + * @param string $input_file + * @param string $output_file + * @param array $options + */ + static function composite($input_file, $output_file, $options) { + if (!self::$init) { + self::init_toolkit(); + } + + list ($width, $height) = getimagesize($input_file); + list ($w_width, $w_height) = getimagesize($options["file"]); + + $pad = isset($options["padding"]) ? $options["padding"] : 10; + $top = $pad; + $left = $pad; + $y_center = max($height / 2 - $w_height / 2, $pad); + $x_center = max($width / 2 - $w_width / 2, $pad); + $bottom = max($height - $w_height - $pad, $pad); + $right = max($width - $w_width - $pad, $pad); + + switch ($options["position"]) { + case "northwest": $x = $left; $y = $top; break; + case "north": $x = $x_center; $y = $top; break; + case "northeast": $x = $right; $y = $top; break; + case "west": $x = $left; $y = $y_center; break; + case "center": $x = $x_center; $y = $y_center; break; + case "east": $x = $right; $y = $y_center; break; + case "southwest": $x = $left; $y = $bottom; break; + case "south": $x = $x_center; $y = $bottom; break; + case "southeast": $x = $right; $y = $bottom; break; + } + + Image::factory($input_file) + ->composite($options["file"], $x, $y, $options["transparency"]) + ->quality(module::get_var("gallery", "image_quality")) + ->save($output_file); + } + + /** + * Return a query result that locates all items with dirty images. + * @return Database_Result Query result + */ + static function find_dirty_images_query() { + return Database::instance()->query( + "SELECT `id` FROM {items} " . + "WHERE ((`thumb_dirty` = 1 AND (`type` <> 'album' OR `album_cover_item_id` IS NOT NULL))" . + " OR (`resize_dirty` = 1 AND `type` = 'photo')) " . + " AND `id` != 1"); + } + + /** + * Mark thumbnails and resizes as dirty. They will have to be rebuilt. + */ + static function mark_dirty($thumbs, $resizes) { + if ($thumbs || $resizes) { + $db = Database::instance(); + $fields = array(); + if ($thumbs) { + $fields["thumb_dirty"] = 1; + } + if ($resizes) { + $fields["resize_dirty"] = 1; + } + $db->update("items", $fields, true); + } + + $count = self::find_dirty_images_query()->count(); + if ($count) { + site_status::warning( + t2("One of your photos is out of date. Click here to fix it", + "%count of your photos are out of date. Click here to fix them", + $count, + array("attrs" => sprintf( + 'href="%s" class="gDialogLink"', + url::site("admin/maintenance/start/gallery_task::rebuild_dirty_images?csrf=__CSRF__")))), + "graphics_dirty"); + } + } + + /** + * Detect which graphics toolkits are available on this system. Return an array of key value + * pairs where the key is one of gd, imagemagick, graphicsmagick and the value is information + * about that toolkit. For GD we return the version string, and for ImageMagick and + * GraphicsMagick we return the path to the directory containing the appropriate binaries. + */ + static function detect_toolkits() { + $gd = function_exists("gd_info") ? gd_info() : array(); + $exec = function_exists("exec"); + if (!isset($gd["GD Version"])) { + $gd["GD Version"] = false; + } + putenv("PATH=" . getenv("PATH") . ":/usr/local/bin:/opt/local/bin:/opt/bin"); + return array("gd" => $gd, + "imagemagick" => $exec ? dirname(exec("which convert")) : false, + "graphicsmagick" => $exec ? dirname(exec("which gm")) : false); + } + + /** + * This needs to be run once, after the initial install, to choose a graphics toolkit. + */ + static function choose_default_toolkit() { + // Detect a graphics toolkit + $toolkits = graphics::detect_toolkits(); + foreach (array("imagemagick", "graphicsmagick", "gd") as $tk) { + if ($toolkits[$tk]) { + module::set_var("gallery", "graphics_toolkit", $tk); + module::set_var("gallery", "graphics_toolkit_path", $tk == "gd" ? "" : $toolkits[$tk]); + break; + } + } + if (!module::get_var("gallery", "graphics_toolkit")) { + site_status::warning( + t("Graphics toolkit missing! Please choose a toolkit", + array("url" => url::site("admin/graphics"))), + "missing_graphics_toolkit"); + } + } + + /** + * Choose which driver the Kohana Image library uses. + */ + static function init_toolkit() { + switch(module::get_var("gallery", "graphics_toolkit")) { + case "gd": + Kohana::config_set("image.driver", "GD"); + break; + + case "imagemagick": + Kohana::config_set("image.driver", "ImageMagick"); + Kohana::config_set( + "image.params.directory", module::get_var("gallery", "graphics_toolkit_path")); + break; + + case "graphicsmagick": + Kohana::config_set("image.driver", "GraphicsMagick"); + Kohana::config_set( + "image.params.directory", module::get_var("gallery", "graphics_toolkit_path")); + break; + } + + self::$init = 1; + } + + /** + * Verify that a specific graphics function is available with the active toolkit. + * @param string $func (eg rotate, resize) + * @return boolean + */ + static function can($func) { + if (module::get_var("gallery", "graphics_toolkit") == "gd" && + $func == "rotate" && + !function_exists("imagerotate")) { + return false; + } + + return true; + } +} diff --git a/modules/keeporiginal/helpers/keeporiginal_event.php b/modules/keeporiginal/helpers/keeporiginal_event.php new file mode 100644 index 00000000..3228c6f2 --- /dev/null +++ b/modules/keeporiginal/helpers/keeporiginal_event.php @@ -0,0 +1,72 @@ +is_photo()) { + $original_file = VARPATH . "original/" . str_replace(VARPATH . "albums/", "", $item->file_path()); + if (file_exists($original_file)) { + unlink($original_file); + } + } + + // When deleting an album, make sure its corresponding location in + // VARPATH/original/ is deleted as well, if it exists. + if ($item->is_album()) { + $original_file = VARPATH . "original/" . str_replace(VARPATH . "albums/", "", $item->file_path()); + if (file_exists($original_file)) { + @dir::unlink($original_file); + } + } + } + + static function item_updated($old, $new) { + // When updating an item, check and see if the file name is being changed. + // If so, check for and modify any corresponding file/folder in + // VARPATH/original/ as well. + if ($old->is_photo() || $old->is_album()) { + if ($old->file_path() != $new->file_path()) { + $old_original = VARPATH . "original/" . str_replace(VARPATH . "albums/", "", $old->file_path()); + $new_original = VARPATH . "original/" . str_replace(VARPATH . "albums/", "", $new->file_path()); + if (file_exists($old_original)) { + rename($old_original, $new_original); + } + } + } + } + + static function site_menu($menu, $theme) { + // Create a menu option to restore the original photo. + $item = $theme->item(); + + if ((access::can("view", $item)) && (access::can("edit", $item))) { + $original_image = VARPATH . "original/" . str_replace(VARPATH . "albums/", "", $item->file_path()); + + if ($item->is_photo() && file_exists($original_image)) { + $menu->get("options_menu") + ->append(Menu::factory("link") + ->id("restore") + ->label("Restore Original") + ->css_id("gKeepOriginalLink") + ->url(url::site("keeporiginal/restore/" . $item->id))); + } + } + } +} \ No newline at end of file diff --git a/modules/keeporiginal/helpers/keeporiginal_installer.php b/modules/keeporiginal/helpers/keeporiginal_installer.php new file mode 100644 index 00000000..e4a0c8b3 --- /dev/null +++ b/modules/keeporiginal/helpers/keeporiginal_installer.php @@ -0,0 +1,29 @@ +item()) { + return; + } + + // Create an array of all the tags for the current item. + $tagsItem = ORM::factory("tag") + ->join("items_tags", "tags.id", "items_tags.tag_id") + ->where("items_tags.item_id", $theme->item->id) + ->find_all(); + + $metaView = new View("metadescription_block.html"); + $metaView->tags = $tagsItem; + return $metaView; + } + +} diff --git a/modules/metadescription/module.info b/modules/metadescription/module.info new file mode 100644 index 00000000..3935288f --- /dev/null +++ b/modules/metadescription/module.info @@ -0,0 +1,3 @@ +name = MetaDescription +description = Automatically generates and inserts KEYWORD and DESCRIPTION meta tags into any theme. +version = 1 diff --git a/modules/metadescription/views/metadescription_block.html.php b/modules/metadescription/views/metadescription_block.html.php new file mode 100644 index 00000000..665eb9dc --- /dev/null +++ b/modules/metadescription/views/metadescription_block.html.php @@ -0,0 +1,16 @@ + +item; + $metaTags = ""; + if (count($tags) > 0) { + for ($counter=0; $countername) . ","; + } else { + $metaTags = $metaTags . p::clean($tags[$counter]->name); + } + } + } +?> + + diff --git a/modules/phpmailer/helpers/phpmailer_menu.php b/modules/phpmailer/helpers/phpmailer_event.php similarity index 93% rename from modules/phpmailer/helpers/phpmailer_menu.php rename to modules/phpmailer/helpers/phpmailer_event.php index 55e5280f..e5de5170 100644 --- a/modules/phpmailer/helpers/phpmailer_menu.php +++ b/modules/phpmailer/helpers/phpmailer_event.php @@ -17,8 +17,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -class phpmailer_menu_Core { - static function admin($menu, $theme) { +class phpmailer_event_Core { + static function admin_menu($menu, $theme) { $menu->get("settings_menu") ->append(Menu::factory("link") ->id("phpmailer") diff --git a/modules/tagsmap/controllers/admin_tagsmap.php b/modules/tagsmap/controllers/admin_tagsmap.php new file mode 100644 index 00000000..34ccf7bc --- /dev/null +++ b/modules/tagsmap/controllers/admin_tagsmap.php @@ -0,0 +1,238 @@ +content = new View("admin_tagsmap.html"); + + // Generate a form for Google Maps Settings. + $view->content->googlemaps_form = $this->_get_googlemaps_form(); + + // Generate a list of tags to display. + $query = ORM::factory("tag"); + $view->content->tags = $query->orderby("name", "ASC")->find_all(); + + // Display the page. + print $view; + } + + public function edit_gps($tag_id) { + // Generate a new admin page to edit gps data for the tag specified by $tag_id. + + // Determine the name of the tag. + $tagName = ORM::factory("tag") + ->where("id", $tag_id) + ->find_all(); + + // Set up the admin page. + $view = new Admin_View("admin.html"); + $view->content = new View("admin_tagsmap_edit.html"); + $view->content->tagsmapedit_form = $this->_get_tagsgpsedit_form($tag_id); + $view->content->tag_name = $tagName[0]->name; + print $view; + } + + public function orphaned_tags() { + // Locate and delete any orphaned GPS data. + $int_deleted_records = 0; + + // Generate a list of all tags with GPS data. + $existingGPS = ORM::factory("tags_gps") + ->find_all(); + + // Loop through each record and see if a corresponding tag exists. + foreach ($existingGPS as $oneGPS) { + $oneTag = ORM::factory("tag") + ->where("id", $oneGPS->tag_id) + ->find_all(); + + // If the tag no longer exists then delete the record. + if (count($oneTag) == 0) { + // Delete the record. + ORM::factory("tags_gps") + ->where("tag_id", $oneGPS->tag_id) + ->delete_all(); + $int_deleted_records++; + } + } + + // Redirect back to the main screen and display a "success" message. + message::success($int_deleted_records . t(" Orphaned Record(s) have been deleted.")); + url::redirect("admin/tagsmap"); + } + + public function confirm_delete_gps($tag_id) { + // Make sure the user meant to hit the delete button. + $view = new Admin_View("admin.html"); + $view->content = new View("admin_tagsmap_delete.html"); + $view->content->tag_id = $tag_id; + + // Determine the name of the tag. + $tagName = ORM::factory("tag") + ->where("id", $tag_id) + ->find_all(); + $view->content->tag_name = $tagName[0]->name; + + print $view; + } + + public function delete_gps($tag_id) { + // Delete the GSP data associated with a tag. + + // Delete the record. + ORM::factory("tags_gps") + ->where("tag_id", $tag_id) + ->delete_all(); + + // Redirect back to the main screen and display a "success" message. + message::success(t("Your Settings Have Been Saved.")); + url::redirect("admin/tagsmap"); + } + + private function _get_tagsgpsedit_form($tag_id) { + // Make a new form for editing GPS data associated with a tag ($tag_id). + $form = new Forge("admin/tagsmap/savegps", "", "post", + array("id" => "gTagsMapAdminForm")); + + // Add a few input boxes for GPS and Description + $tagsgps_group = $form->group("TagsMapGPS"); + $tagsgps_group->hidden("tag_id")->value($tag_id); + + // Check and see if this ID already has GPS data, then create + // input boxes to either update it or enter in new information. + $existingGPS = ORM::factory("tags_gps") + ->where("tag_id", $tag_id) + ->find_all(); + if (count($existingGPS) == 0) { + $tagsgps_group->input("gps_latitude")->label(t("Latitude"))->value(); + $tagsgps_group->input("gps_longitude")->label(t("Longitude"))->value(); + $tagsgps_group->textarea("gps_description")->label(t("Description"))->value(); + } else { + $tagsgps_group->input("gps_latitude")->label(t("Latitude"))->value($existingGPS[0]->latitude); + $tagsgps_group->input("gps_longitude")->label(t("Longitude"))->value($existingGPS[0]->longitude); + $tagsgps_group->textarea("gps_description")->label(t("Description"))->value($existingGPS[0]->description); + } + + // Add a save button to the form. + $tagsgps_group->submit("SaveGPS")->value(t("Save")); + + // Return the newly generated form. + return $form; + } + + public function savegps() { + // Save the GPS coordinates to the database. + + // Prevent Cross Site Request Forgery + access::verify_csrf(); + + // Figure out the values of the text boxes + $str_tagid = Input::instance()->post("tag_id"); + $str_latitude = Input::instance()->post("gps_latitude"); + $str_longitude = Input::instance()->post("gps_longitude"); + $str_description = Input::instance()->post("gps_description"); + + // Save to database. + // Check and see if this ID already has GPS data, + // Update it if it does, create a new record if it doesn't. + $existingGPS = ORM::factory("tags_gps") + ->where("tag_id", $str_tagid) + ->find_all(); + if (count($existingGPS) == 0) { + $newgps = ORM::factory("tags_gps"); + $newgps->tag_id = $str_tagid; + $newgps->latitude = $str_latitude; + $newgps->longitude = $str_longitude; + $newgps->description = $str_description; + $newgps->save(); + } else { + $updatedGPS = ORM::factory("tags_gps", $existingGPS[0]->id); + $updatedGPS->tag_id = $str_tagid; + $updatedGPS->latitude = $str_latitude; + $updatedGPS->longitude = $str_longitude; + $updatedGPS->description = $str_description; + $updatedGPS->save(); + } + + // Redirect back to the main screen and display a "success" message. + message::success(t("Your Settings Have Been Saved.")); + url::redirect("admin/tagsmap"); + } + + private function _get_googlemaps_form() { + // Make a new form for inputing information associated with google maps. + $form = new Forge("admin/tagsmap/savemapprefs", "", "post", + array("id" => "gTagsMapAdminForm")); + + // Input box for the Maps API Key + $googlemap_group = $form->group("GoogleMapsKey"); + $googlemap_group->input("google_api_key") + ->label(t("Google Maps API Key")) + ->value(module::get_var("tagsmap", "googlemap_api_key")); + + // Input boxes for the Maps starting location map type and zoom. + $startingmap_group = $form->group("GoogleMapsPos"); + $startingmap_group->input("google_starting_latitude") + ->label(t("Starting Latitude")) + ->value(module::get_var("tagsmap", "googlemap_latitude")); + $startingmap_group->input("google_starting_longitude") + ->label(t("Starting Longitude")) + ->value(module::get_var("tagsmap", "googlemap_longitude")); + $startingmap_group->input("google_default_zoom") + ->label(t("Default Zoom Level")) + ->value(module::get_var("tagsmap", "googlemap_zoom")); + $startingmap_group->input("google_default_type") + ->label(t("Default Map Type") . " (G_NORMAL_MAP, G_SATELLITE_MAP, G_HYBRID_MAP, G_PHYSICAL_MAP, G_SATELLITE_3D_MAP)") + ->value(module::get_var("tagsmap", "googlemap_type")); + + // Add a save button to the form. + $form->submit("SaveSettings")->value(t("Save")); + + // Return the newly generated form. + return $form; + } + + public function savemapprefs() { + // Save information associated with Google Maps to the database. + + // Prevent Cross Site Request Forgery + access::verify_csrf(); + + // Figure out the values of the text boxes + $str_googlekey = Input::instance()->post("google_api_key"); + $str_googlelatitude = Input::instance()->post("google_starting_latitude"); + $str_googlelongitude = Input::instance()->post("google_starting_longitude"); + $str_googlezoom = Input::instance()->post("google_default_zoom"); + $str_googlemaptype = Input::instance()->post("google_default_type"); + + // Save Settings. + module::set_var("tagsmap", "googlemap_api_key", $str_googlekey); + module::set_var("tagsmap", "googlemap_latitude", $str_googlelatitude); + module::set_var("tagsmap", "googlemap_longitude", $str_googlelongitude); + module::set_var("tagsmap", "googlemap_zoom", $str_googlezoom); + module::set_var("tagsmap", "googlemap_type", $str_googlemaptype); + + // Display a success message and redirect back to the TagsMap admin page. + message::success(t("Your Settings Have Been Saved.")); + url::redirect("admin/tagsmap"); + } +} \ No newline at end of file diff --git a/modules/tagsmap/controllers/tagsmap.php b/modules/tagsmap/controllers/tagsmap.php new file mode 100644 index 00000000..9e95a872 --- /dev/null +++ b/modules/tagsmap/controllers/tagsmap.php @@ -0,0 +1,58 @@ +find_all(); + + // Set up and display the actual page. + // If fullsize is true, allow the map to take up the entire browser window, + // if not, then display the map in the gallery theme. + if ($fullsize == true) { + $view = new View("tagsmap_googlemap.html"); + $view->map_fullsize = true; + + // Load in module preferences. + $view->tags_gps = $tagsGPS; + $view->google_map_key = module::get_var("tagsmap", "googlemap_api_key"); + $view->google_map_latitude = module::get_var("tagsmap", "googlemap_latitude"); + $view->google_map_longitude = module::get_var("tagsmap", "googlemap_longitude"); + $view->google_map_zoom = module::get_var("tagsmap", "googlemap_zoom"); + $view->google_map_type = module::get_var("tagsmap", "googlemap_type"); + + print $view; + } else { + $template = new Theme_View("page.html", "Contact"); + $template->content = new View("tagsmap_googlemap.html"); + + // Load in module preferences. + $template->content->tags_gps = $tagsGPS; + $template->content->google_map_key = module::get_var("tagsmap", "googlemap_api_key"); + $template->content->google_map_latitude = module::get_var("tagsmap", "googlemap_latitude"); + $template->content->google_map_longitude = module::get_var("tagsmap", "googlemap_longitude"); + $template->content->google_map_zoom = module::get_var("tagsmap", "googlemap_zoom"); + $template->content->google_map_type = module::get_var("tagsmap", "googlemap_type"); + + print $template; + } + } +} diff --git a/modules/tagsmap/helpers/tagsmap_event.php b/modules/tagsmap/helpers/tagsmap_event.php new file mode 100644 index 00000000..27b47ca6 --- /dev/null +++ b/modules/tagsmap/helpers/tagsmap_event.php @@ -0,0 +1,43 @@ +deactivate)) { + site_status::warning( + t("The TagsMap module requires the Tags module. " . + "Activate the Tags module now", + array("url" => url::site("admin/modules"))), + "tagsmap_needs_tag"); + } else { + site_status::clear("tagsmap_needs_tag"); + } + } + + static function admin_menu($menu, $theme) { + // Add a link to the TagsMap admin page to the Content menu. + $menu->get("content_menu") + ->append(Menu::factory("link") + ->id("tagsmap") + ->label(t("TagsMap Settings")) + ->url(url::site("admin/tagsmap"))); + } +} \ No newline at end of file diff --git a/modules/tagsmap/helpers/tagsmap_installer.php b/modules/tagsmap/helpers/tagsmap_installer.php new file mode 100644 index 00000000..5fd7b754 --- /dev/null +++ b/modules/tagsmap/helpers/tagsmap_installer.php @@ -0,0 +1,48 @@ +query("CREATE TABLE IF NOT EXISTS {tags_gpses} ( + `id` int(9) NOT NULL auto_increment, + `tag_id` int(9) NOT NULL, + `latitude` varchar(128) NOT NULL, + `longitude` varchar(128) NOT NULL, + `description` varchar(2048) default NULL, + PRIMARY KEY (`id`), + KEY(`tag_id`, `id`)) + ENGINE=InnoDB DEFAULT CHARSET=utf8;"); + + // Set the module's version number. + module::set_version("tagsmap", 1); + } + + static function deactivate() { + site_status::clear("tagsmap_needs_tag"); + } + + static function uninstall() { + // Delete the GPS table before uninstalling. + $db = Database::instance(); + $db->query("DROP TABLE IF EXISTS {tags_gpses};"); + module::delete("tagsmap"); + } +} diff --git a/modules/tagsmap/helpers/tagsmap_theme.php b/modules/tagsmap/helpers/tagsmap_theme.php new file mode 100644 index 00000000..5f3fb1e7 --- /dev/null +++ b/modules/tagsmap/helpers/tagsmap_theme.php @@ -0,0 +1,38 @@ +item()) { + return; + } + + // Create a new block to display the link in. + $block = new Block(); + $block->css_id = "gTagsMap"; + $block->title = t("Map:"); + $block->content = new View("tagsmap_block.html"); + + return $block; + } +} diff --git a/modules/tagsmap/models/tags_gps.php b/modules/tagsmap/models/tags_gps.php new file mode 100644 index 00000000..c9fda760 --- /dev/null +++ b/modules/tagsmap/models/tags_gps.php @@ -0,0 +1,21 @@ + +

+ +

+
+

+ +

+
You may sign up for a Google Maps API key here.

+ +
+ +
+

+ +

+ count()/5 ?> + + +
type}s/{$item->id}") ?>">Click Here" readonly>type}s/{$item->id}") ?>">Click Here" onclick="this.focus(); this.select();" readonly>
type}s/{$item->id}") ?>">thumb_url(true) ?>">" readonly>type}s/{$item->id}") ?>">thumb_url(true) ?>">" onclick="this.focus(); this.select();" readonly>
type}s/{$item->id}") ?>">resize_url(true) ?>">" readonly>type}s/{$item->id}") ?>">resize_url(true) ?>">" onclick="this.focus(); this.select();" readonly>
type}s/{$item->id}") ?>]Click Here[/url]" readonly>type}s/{$item->id}") ?>]Click Here[/url]" onclick="this.focus(); this.select();" readonly>
type}s/{$item->id}") ?>][img]thumb_url(true) ?>[/img][/url]" readonly>type}s/{$item->id}") ?>][img]thumb_url(true) ?>[/img][/url]" onclick="this.focus(); this.select();" readonly>
type}s/{$item->id}") ?>][img]resize_url(true) ?>[/img][/url]" readonly>type}s/{$item->id}") ?>][img]resize_url(true) ?>[/img][/url]" onclick="this.focus(); this.select();" readonly>
+ + + + + +
+ count()) ?> +
+ $tag): ?> + name, 0, 1)) ?> + + + +
    + + $tags_per_column): /* new column */ ?> +
+ + + + + +
    + + +
  • + name) ?> + (count ?>) + + id") ?>"> + + where("tag_id", $tag->id) + ->find_all(); + if (count($existingGPS) > 0) { + ?> + | id") ?>"> + +
  • + + + + +
+
+
+ +
+

+ +

+ + +
+ "> + + +
+
diff --git a/modules/tagsmap/views/admin_tagsmap_delete.html.php b/modules/tagsmap/views/admin_tagsmap_delete.html.php new file mode 100644 index 00000000..b85641e5 --- /dev/null +++ b/modules/tagsmap/views/admin_tagsmap_delete.html.php @@ -0,0 +1,9 @@ + +
+

+

+">Delete +">Cancel + +
+ diff --git a/modules/tagsmap/views/admin_tagsmap_edit.html.php b/modules/tagsmap/views/admin_tagsmap_edit.html.php new file mode 100644 index 00000000..c5a2afa5 --- /dev/null +++ b/modules/tagsmap/views/admin_tagsmap_edit.html.php @@ -0,0 +1,6 @@ + +
+

+ +
+ diff --git a/modules/tagsmap/views/tagsmap_block.html.php b/modules/tagsmap/views/tagsmap_block.html.php new file mode 100644 index 00000000..812352c9 --- /dev/null +++ b/modules/tagsmap/views/tagsmap_block.html.php @@ -0,0 +1,7 @@ + + diff --git a/modules/tagsmap/views/tagsmap_googlemap.html.php b/modules/tagsmap/views/tagsmap_googlemap.html.php new file mode 100644 index 00000000..55b0a272 --- /dev/null +++ b/modules/tagsmap/views/tagsmap_googlemap.html.php @@ -0,0 +1,67 @@ + + + + + + Gallery: Map + + + + + + + + +
+ + +

+ "> + +

+