1
0

Forum User bozek fix to cut back on the number of database queries used by EXIF_GPS ( http://gallery.menalto.com/node/109227#comment-399841 ).

This commit is contained in:
rWatcher 2012-12-11 19:46:31 -05:00
parent fe359ce21e
commit 73818d27ae

View File

@ -1,13 +1,21 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<? print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; ?>
<markers>
<? foreach ($items as $item) { ?>
<? $item_coordinates = ORM::factory("exif_coordinate")->where("item_id", "=", $item->id)->find(); ?>
<? $str_thumb_html = str_replace("&", "&amp;", $item->thumb_img(array("class" => "g-exif-gps-thumbnail"))); ?>
<? $str_thumb_html = str_replace("\'", "&apos;", $str_thumb_html); ?>
<? $str_thumb_html = str_replace("<", "&lt;", $str_thumb_html); ?>
<? $str_thumb_html = str_replace(">", "&gt;", $str_thumb_html); ?>
<? $str_thumb_html = str_replace("\"", "&quot;", $str_thumb_html); ?>
<marker lat="<?= $item_coordinates->latitude; ?>" lng="<?= $item_coordinates->longitude; ?>" url="<?= url::abs_site("exif_gps/item/{$item->id}"); ?>" thumb="<?=$str_thumb_html; ?>" />
<?
$thumb_arr=array();
$items_id=array();;
foreach ($items as $item) {
array_push($items_id, $item->id);
$thumb_arr[$item->id] = $item->thumb_img(array("class" => "g-exif-gps-thumbnail"));
}
$item_coordinates_all = ORM::factory("exif_coordinate")->where("item_id", "IN", $items_id)->find_all();
foreach ($item_coordinates_all as $item_coordinates) {
$str_thumb_html = str_replace("&", "&amp;", $thumb_arr[$item_coordinates->item_id]);
$str_thumb_html = str_replace("\'", "&apos;", $str_thumb_html);
$str_thumb_html = str_replace("<", "&lt;", $str_thumb_html);
$str_thumb_html = str_replace(">", "&gt;", $str_thumb_html);
$str_thumb_html = str_replace("\"", "&quot;", $str_thumb_html);
?>
<marker lat="<?= $item_coordinates->latitude; ?>" lng="<?= $item_coordinates->longitude; ?>" url="<?= url::abs_site("exif_gps/item/$item_coordinates->item_id"); ?>" thumb="<?=$str_thumb_html; ?>" />
<? } ?>
</markers>