1
0

Merge commit 'upstream/master'

This commit is contained in:
Romain LE DISEZ 2009-07-31 17:30:29 +02:00
commit 683995e4e0
32 changed files with 1354 additions and 53 deletions

View File

@ -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")

View File

@ -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"));

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -1,4 +1,9 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<style>
input[type="text"] {
width: 95%;
}
</style>
<? if (module::get_var("embedlinks", "HTMLCode")) { ?>
<table class="gMetadata">
<tbody>
@ -8,12 +13,12 @@
<tr>
<th><?= t("Text:") ?></th>
<td><textarea rows="2" cols="6" height="5" readonly><a href="<?= url::abs_site("{$item->type}s/{$item->id}") ?>">Click Here</a></textarea></td>
<td><input onclick="this.focus(); this.select();" name="forum" type="text" readonly="true" value="<a href=&quot;<?= url::abs_site("{$item->type}s/{$item->id}") ?>&quot;>Click Here</a>" /></td>
</tr>
<tr>
<th><?= t("Thumbnail:") ?></th>
<td><textarea rows="2" cols="6" height="5" readonly><a href="<?= url::abs_site("{$item->type}s/{$item->id}") ?>"><img src="<?= $item->thumb_url(true) ?>"></a></textarea></td>
<td><input onclick="this.focus(); this.select();" name="forum" type="text" readonly="true" value="<a href=&quot;<?= url::abs_site("{$item->type}s/{$item->id}") ?>&quot;><img src=&quot;<?= $item->thumb_url(true) ?>&quot;></a>" /></td>
</tr>
</tbody>
</table>
@ -28,12 +33,12 @@
<tr>
<th><?= t("Text:") ?></th>
<td><textarea rows="2" cols="6" height="5" readonly>[url=<?= url::abs_site("{$item->type}s/{$item->id}") ?>]Click Here[/url]</textarea></td>
<td><input onclick="this.focus(); this.select();" name="forum" type="text" readonly="true" value="[url=<?= url::abs_site("{$item->type}s/{$item->id}") ?>]Click Here[/url]" /></td>
</tr>
<tr>
<th><?= t("Thumbnail:") ?></th>
<td><textarea rows="2" cols="6" height="5" readonly>[url=<?= url::abs_site("{$item->type}s/{$item->id}") ?>][img]<?= $item->thumb_url(true) ?>[/img][/url]</textarea></td>
<td><input onclick="this.focus(); this.select();" name="forum" type="text" readonly="true" size="85" value="[url=<?= url::abs_site("{$item->type}s/{$item->id}") ?>][img]<?= $item->thumb_url(true) ?>[/img][/url]" /></td>
</tr>
</tbody>
</table>

View File

@ -1,20 +1,20 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<style>
#gExifData {font-size: .85em;}
.gOdd {background: #BDD2FF;}
.gEven {background: #DFEFFC;}
input[type="text"] {
width: 95%;
}
</style>
<h1 style="display: none;"><?= t("BBCode") ?></h1>
<div id="gExifData">
<div id="gEmbedLinksBBCodeData">
<? $counter = 0; ?>
<? for ($i = 0; $i < count($titles); $i++): ?>
<table class="gMetadata" >
<thead><tr><th cellspan="2"><?= t($titles[$i][0]) ?></th></thead>
<table class="gLinksBBCode" >
<thead><tr><th colspan="2"><?= t($titles[$i][0]) ?></th></thead>
<tbody>
<? for ($j = $counter; $j < $titles[$i][1]+$counter; $j++): ?>
<tr>
<td><?= t($details[$j][0]) ?></td>
<td><input type="text" value="<?= $details[$j][1] ?>" readonly></td>
<td width="100"><?= t($details[$j][0]) ?></td>
<td><input type="text" onclick="this.focus(); this.select();" value="<?= $details[$j][1] ?>" readonly></td>
</tr>
<? endfor ?>
<? $counter+= $titles[$i][1]; ?>

View File

@ -1,20 +1,20 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<style>
#gExifData {font-size: .85em;}
.gOdd {background: #BDD2FF;}
.gEven {background: #DFEFFC;}
input[type="text"] {
width: 95%;
}
</style>
<h1 style="display: none;"><?= t("HTML Code") ?></h1>
<div id="gExifData">
<div id="gEmbedLinksHTMLData">
<? $counter = 0; ?>
<? for ($i = 0; $i < count($titles); $i++): ?>
<table class="gMetadata" >
<thead><tr><th cellspan="2"><?= t($titles[$i][0]) ?></th></thead>
<table class="gLinksHTML" >
<thead><tr><th colspan="2"><?= t($titles[$i][0]) ?></th></thead>
<tbody>
<? for ($j = $counter; $j < $titles[$i][1]+$counter; $j++): ?>
<tr>
<td><?= t($details[$j][0]) ?></td>
<td><input type="text" value="<?= $details[$j][1] ?>" readonly></td>
<td width="100"><?= t($details[$j][0]) ?></td>
<td><input type="text" onclick="this.focus(); this.select();" value="<?= $details[$j][1] ?>" readonly></td>
</tr>
<? endfor ?>
<? $counter+= $titles[$i][1]; ?>

View File

@ -1,4 +1,9 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<style>
input[type="text"] {
width: 95%;
}
</style>
<? if (module::get_var("embedlinks", "HTMLCode")) { ?>
<h3 align="center"><?= t("HTML Links")?></h3>
@ -10,17 +15,17 @@
<tr>
<th><?= t("Text:") ?></th>
<td><input type="text" value="<a href=&quot;<?= url::abs_site("{$item->type}s/{$item->id}") ?>&quot;>Click Here</a>" readonly></td>
<td><input type="text" value="<a href=&quot;<?= url::abs_site("{$item->type}s/{$item->id}") ?>&quot;>Click Here</a>" onclick="this.focus(); this.select();" readonly></td>
</tr>
<tr>
<th><?= t("Thumbnail:") ?></th>
<td><input type="text" value="<a href=&quot;<?= url::abs_site("{$item->type}s/{$item->id}") ?>&quot;><img src=&quot;<?= $item->thumb_url(true) ?>&quot;></a>" readonly></td>
<td><input type="text" value="<a href=&quot;<?= url::abs_site("{$item->type}s/{$item->id}") ?>&quot;><img src=&quot;<?= $item->thumb_url(true) ?>&quot;></a>" onclick="this.focus(); this.select();" readonly></td>
</tr>
<tr>
<th><?= t("Resized:") ?></th>
<td><input type="text" value="<a href=&quot;<?= url::abs_site("{$item->type}s/{$item->id}") ?>&quot;><img src=&quot;<?= $item->resize_url(true) ?>&quot;></a>" readonly></td>
<td><input type="text" value="<a href=&quot;<?= url::abs_site("{$item->type}s/{$item->id}") ?>&quot;><img src=&quot;<?= $item->resize_url(true) ?>&quot;></a>" onclick="this.focus(); this.select();" readonly></td>
</tr>
<? if (access::can("view_full", $item)) { ?>
@ -30,17 +35,17 @@
<tr>
<th><?= t("Text:") ?></th>
<td><input type="text" value="<a href=&quot;<?= $item->file_url(true) ?>&quot;>Click Here</a>" readonly></td>
<td><input type="text" value="<a href=&quot;<?= $item->file_url(true) ?>&quot;>Click Here</a>" onclick="this.focus(); this.select();" readonly></td>
</tr>
<tr>
<th><?= t("Thumbnail:") ?></th>
<td><input type="text" value="<a href=&quot;<?= $item->file_url(true) ?>&quot;><img src=&quot;<?= $item->thumb_url(true) ?>&quot;></a>" readonly></td>
<td><input type="text" value="<a href=&quot;<?= $item->file_url(true) ?>&quot;><img src=&quot;<?= $item->thumb_url(true) ?>&quot;></a>" onclick="this.focus(); this.select();" readonly></td>
</tr>
<tr>
<th><?= t("Resized:") ?></th>
<td><input type="text" value="<a href=&quot;<?= $item->file_url(true) ?>&quot;><img src=&quot;<?= $item->resize_url(true) ?>&quot;></a>" readonly></td>
<td><input type="text" value="<a href=&quot;<?= $item->file_url(true) ?>&quot;><img src=&quot;<?= $item->resize_url(true) ?>&quot;></a>" onclick="this.focus(); this.select();" readonly></td>
</tr>
<? } ?>
@ -50,17 +55,17 @@
<tr>
<th><?= t("Text:") ?></th>
<td><input type="text" value="<a href=&quot;<?= $item->resize_url(true) ?>&quot;>Click Here</a>" readonly></td>
<td><input type="text" value="<a href=&quot;<?= $item->resize_url(true) ?>&quot;>Click Here</a>" onclick="this.focus(); this.select();" readonly></td>
</tr>
<tr>
<th><?= t("Thumbnail:") ?></th>
<td><input type="text" value="<a href=&quot;<?= $item->resize_url(true) ?>&quot;><img src=&quot;<?= $item->thumb_url(true) ?>&quot;></a>" readonly></td>
<td><input type="text" value="<a href=&quot;<?= $item->resize_url(true) ?>&quot;><img src=&quot;<?= $item->thumb_url(true) ?>&quot;></a>" onclick="this.focus(); this.select();" readonly></td>
</tr>
<tr>
<th><?= t("Image:") ?></th>
<td><input type="text" value="<img src=&quot;<?= $item->resize_url(true) ?>&quot;>" readonly></td>
<td><input type="text" value="<img src=&quot;<?= $item->resize_url(true) ?>&quot;>" onclick="this.focus(); this.select();" readonly></td>
</tr>
</tbody>
@ -77,17 +82,17 @@
<tr>
<th><?= t("Text:") ?></th>
<td><input type="text" value="[url=<?= url::abs_site("{$item->type}s/{$item->id}") ?>]Click Here[/url]" readonly></td>
<td><input type="text" value="[url=<?= url::abs_site("{$item->type}s/{$item->id}") ?>]Click Here[/url]" onclick="this.focus(); this.select();" readonly></td>
</tr>
<tr>
<th><?= t("Thumbnail:") ?></th>
<td><input type="text" value="[url=<?= url::abs_site("{$item->type}s/{$item->id}") ?>][img]<?= $item->thumb_url(true) ?>[/img][/url]" readonly></td>
<td><input type="text" value="[url=<?= url::abs_site("{$item->type}s/{$item->id}") ?>][img]<?= $item->thumb_url(true) ?>[/img][/url]" onclick="this.focus(); this.select();" readonly></td>
</tr>
<tr>
<th><?= t("Resized:") ?></th>
<td><input type="text" value="[url=<?= url::abs_site("{$item->type}s/{$item->id}") ?>][img]<?= $item->resize_url(true) ?>[/img][/url]" readonly></td>
<td><input type="text" value="[url=<?= url::abs_site("{$item->type}s/{$item->id}") ?>][img]<?= $item->resize_url(true) ?>[/img][/url]" onclick="this.focus(); this.select();" readonly></td>
</tr>
<? if (access::can("view_full", $item)) { ?>
@ -97,17 +102,17 @@
<tr>
<th><?= t("Text:") ?></th>
<td><input type="text" value="[url=<?= $item->file_url(true) ?>]Click Here[/url]" readonly></td>
<td><input type="text" value="[url=<?= $item->file_url(true) ?>]Click Here[/url]" onclick="this.focus(); this.select();" readonly></td>
</tr>
<tr>
<th><?= t("Thumbnail:") ?></th>
<td><input type="text" value="[url=<?= $item->file_url(true) ?>][img]<?= $item->thumb_url(true) ?>[/img][/url]" readonly></td>
<td><input type="text" value="[url=<?= $item->file_url(true) ?>][img]<?= $item->thumb_url(true) ?>[/img][/url]" onclick="this.focus(); this.select();" readonly></td>
</tr>
<tr>
<th><?= t("Resized:") ?></th>
<td><input type="text" value="[url=<?= $item->file_url(true) ?>][img]<?= $item->resize_url(true) ?>[/img][/url]" readonly></td>
<td><input type="text" value="[url=<?= $item->file_url(true) ?>][img]<?= $item->resize_url(true) ?>[/img][/url]" onclick="this.focus(); this.select();" readonly></td>
</tr>
<? } ?>
@ -117,17 +122,17 @@
<tr>
<th><?= t("Text:") ?></th>
<td><input type="text" value="[url=<?= $item->resize_url(true) ?>]Click Here[/url]" readonly></td>
<td><input type="text" value="[url=<?= $item->resize_url(true) ?>]Click Here[/url]" onclick="this.focus(); this.select();" readonly></td>
</tr>
<tr>
<th><?= t("Thumbnail:") ?></th>
<td><input type="text" value="[url=<?= $item->resize_url(true) ?>][img]<?= $item->thumb_url(true) ?>[/img][/url]" readonly></td>
<td><input type="text" value="[url=<?= $item->resize_url(true) ?>][img]<?= $item->thumb_url(true) ?>[/img][/url]" onclick="this.focus(); this.select();" readonly></td>
</tr>
<tr>
<th><?= t("Image:") ?></th>
<td><input type="text" value="[img]<?= $item->resize_url(true) ?>[/img]" readonly></td>
<td><input type="text" value="[img]<?= $item->resize_url(true) ?>[/img]" onclick="this.focus(); this.select();" readonly></td>
</tr>
</tbody>

View File

@ -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")

View File

@ -0,0 +1,62 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class keeporiginal_Controller extends Controller {
public function restore($id) {
// Allow the user to restore the original photo.
// Make sure the current user has suficient access to view and edit the item.
$item = ORM::factory("item", $id);
access::required("view", $item);
access::required("edit", $item);
// Figure out where the original was stashed at.
$original_image = VARPATH . "original/" . str_replace(VARPATH . "albums/", "", $item->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());
}
}
}

View File

@ -0,0 +1,423 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class graphics_Core {
private static $init;
/**
* Add a new graphics rule.
*
* Rules are applied to targets (thumbnails and resizes) in priority order. Rules are functions
* in the graphics class. So for example, the following rule:
*
* graphics::add_rule("gallery", "thumb", "resize",
* array("width" => 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. <a %attrs>Click here to fix it</a>",
"%count of your photos are out of date. <a %attrs>Click here to fix them</a>",
$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 <a href=\"%url\">choose a toolkit</a>",
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;
}
}

View File

@ -0,0 +1,72 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class keeporiginal_event_Core {
static function item_before_delete($item) {
// If deleting a photo, make sure the original is deleted as well, if it exists.
if ($item->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)));
}
}
}
}

View File

@ -0,0 +1,29 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class keeporiginal_installer {
static function install() {
@mkdir(VARPATH . "original");
module::set_version("keeporiginal", 1);
}
static function uninstall() {
module::delete("keeporiginal");
}
}

View File

@ -0,0 +1,3 @@
name = Keep Original
description = Make a copy of the original photo before rotating it.
version = 1

View File

@ -0,0 +1,24 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class metadescription_installer {
static function install() {
module::set_version("metadescription", 1);
}
}

View File

@ -0,0 +1,38 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class metadescription_theme_Core {
static function head($theme) {
// Make sure the current page belongs to an item.
if (!$theme->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;
}
}

View File

@ -0,0 +1,3 @@
name = MetaDescription
description = Automatically generates and inserts KEYWORD and DESCRIPTION meta tags into any theme.
version = 1

View File

@ -0,0 +1,16 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<?
$item = $theme->item;
$metaTags = "";
if (count($tags) > 0) {
for ($counter=0; $counter<count($tags); $counter++) {
if ($counter < count($tags)-1) {
$metaTags = $metaTags . p::clean($tags[$counter]->name) . ",";
} else {
$metaTags = $metaTags . p::clean($tags[$counter]->name);
}
}
}
?>
<META NAME="KEYWORDS" CONTENT="<?= $metaTags ?>">
<META NAME="DESCRIPTION" CONTENT="<?= nl2br(p::purify($item->description)) ?>">

View File

@ -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")

View File

@ -0,0 +1,238 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Admin_TagsMap_Controller extends Admin_Controller {
public function index() {
// Generate a new admin page.
$view = new Admin_View("admin.html");
$view->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");
}
}

View File

@ -0,0 +1,58 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class TagsMap_Controller extends Controller {
public function googlemap($fullsize) {
// Display all tags with GPS coordinates on a google map.
// Generate a list of GPS coordinates.
$tagsGPS = ORM::factory("tags_gps")->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;
}
}
}

View File

@ -0,0 +1,43 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class tagsmap_event_Core {
static function module_change($changes) {
// See if the Tags module is installed,
// tell the user to install it if it isn't.
if (!module::is_active("tag") || in_array("tag", $changes->deactivate)) {
site_status::warning(
t("The TagsMap module requires the Tags module. " .
"<a href=\"%url\">Activate the Tags module now</a>",
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")));
}
}

View File

@ -0,0 +1,48 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class tagsmap_installer {
static function install() {
// Create a table to store GPS data in.
$db = Database::instance();
$db->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");
}
}

View File

@ -0,0 +1,38 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class tagsmap_theme_Core {
static function sidebar_blocks($theme) {
// Display a link to the map in the Gallery sidebar
// Make sure the current page belongs to an item.
if (!$theme->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;
}
}

View File

@ -0,0 +1,21 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Tags_GPS_Model extends ORM {
}

View File

@ -0,0 +1,3 @@
name = TagsMap
description = Assign GPS coordinates to existing tags and display them on a map.
version = 1

View File

@ -0,0 +1,83 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<h2>
<?= t("TagsMap Admin") ?>
</h2>
<div class="gBlock">
<h3>
<?= t("Google Maps Settings") ?>
</h3>
<br/><div>You may sign up for a Google Maps API key <a href="http://code.google.com/apis/maps/signup.html" target="_new">here</a>.</div><br/>
<?= $googlemaps_form ?>
</div>
<div class="gBlock">
<h3>
<?= t("Assign GPS Coordinates") ?>
</h3>
<? $tags_per_column = $tags->count()/5 ?>
<? $column_tag_count = 0 ?>
<table id="gGPSTagAdmin" class="gBlockContent">
<caption class="understate">
<?= t2("There is one tag", "There are %count tags", $tags->count()) ?>
</caption>
<tr>
<td>
<? foreach ($tags as $i => $tag): ?>
<? $current_letter = strtoupper(mb_substr($tag->name, 0, 1)) ?>
<? if ($i == 0): /* first letter */ ?>
<strong><?= $current_letter ?></strong>
<ul>
<? elseif ($last_letter != $current_letter): /* new letter */ ?>
<? if ($column_tag_count > $tags_per_column): /* new column */ ?>
</td>
<td>
<? $column_tag_count = 0 ?>
<? endif ?>
</ul>
<strong><?= $current_letter ?></strong>
<ul>
<? endif ?>
<li>
<?= p::clean($tag->name) ?>
<span class="understate">(<?= $tag->count ?>)</span>
<a href="<?= url::site("admin/tagsmap/edit_gps/$tag->id") ?>"><?= t("Edit GPS") ?></a>
<?
// Check and see if this ID already has GPS data, display a delete button if it does.
$existingGPS = ORM::factory("tags_gps")
->where("tag_id", $tag->id)
->find_all();
if (count($existingGPS) > 0) {
?>
| <a href="<?= url::site("admin/tagsmap/confirm_delete_gps/$tag->id") ?>"><?= t("Delete GPS") ?></a>
<?
}
?>
</li>
<? $column_tag_count++ ?>
<? $last_letter = $current_letter ?>
<? endforeach /* $tags */ ?>
</ul>
</td>
</tr>
</table>
</div>
<div class="gBlock">
<h3>
<?= t("Remove Orphaned GPS Data") ?>
</h3>
<table id="gOrphanedTagAdmin" class="gBlockContent">
<tr><td>
<a href="<?= url::site("admin/tagsmap/orphaned_tags") ?>">
<?= t("Search For and Delete Orphaned Data") ?>
</a>
</td></tr>
</table>
</div>

View File

@ -0,0 +1,9 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<div id="gTagsMapDeleteAdmin">
<h2> <?= t("Delete GPS Data For Tag ") . $tag_name . "?" ?> </h2>
<?= t("Are you sure you wish to delete all GPS data associated with this tag?") ?> <br/><br/>
<a href="<?= url::site("admin/tagsmap/delete_gps/" . $tag_id) ?>">Delete</a>
<a href="<?= url::site("admin/tagsmap") ?>">Cancel</a>
<?= $tagsmapdelete_form ?>
</div>

View File

@ -0,0 +1,6 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<div id="gTagsMapEditAdmin">
<h2> <?= t("Edit GPS Data for Tag ") . $tag_name ?> </h2>
<?= $tagsmapedit_form ?>
</div>

View File

@ -0,0 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<ul id="gTagsMap">
<li>
<a href="<?= url::site("tagsmap/googlemap") ?>">
<?= t("Show Map") ?></a>
</li>
</ul>

View File

@ -0,0 +1,67 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<? if ($map_fullsize == true) { ?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Gallery: Map</title>
</head>
<body>
<? } ?>
<script src="http://www.google.com/jsapi?key=<?=$google_map_key ?>" type="text/javascript"></script>
<script type="text/javascript">
google.load("maps", "2.160");
function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(<?=$google_map_latitude ?>,
<?=$google_map_longitude ?>));
map.setZoom(<?=$google_map_zoom ?>);
map.setUIToDefault();
// Make Google Earth an Option.
map.addMapType(G_SATELLITE_3D_MAP);
var mapControl = new GMapTypeControl();
map.addControl(mapControl);
map.setMapType(<?=$google_map_type ?>);
<? foreach ($tags_gps as $oneGPS): ?>
{
var myGeographicCoordinates = new GLatLng(<?= $oneGPS->latitude ?>,
<?= $oneGPS->longitude ?>);
map.addOverlay(createMarker(myGeographicCoordinates,
"<?= $oneGPS->description ?>",
"<?= url::site("tags/$oneGPS->tag_id")?>",
"<?= ORM::factory("tag", $oneGPS->tag_id)->name ?>"
));
}
<? endforeach ?>
function createMarker(point, description, tagURL, tagName) {
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function() {
var myHtml = description + "<br/><br/>" +
"Tag: <a href=\"" + tagURL + "\">" + tagName + "</a>";
map.openInfoWindowHtml(point, myHtml);
});
return marker;
}
}
}
google.setOnLoadCallback(initialize);
</script>
<? if ($map_fullsize == true) { ?>
<div id="map_canvas" style="width: 100%; height: 100%"></div>
</body></html>
<? } else { ?>
<div id="map_canvas" style="width: 600px; height: 480px"></div> <br/>
<a href="<?= url::site("tagsmap/googlemap/fullsize/1")?>">
<?= t("View Fullsize")?>
</a><br/><br/>
<? } ?>