function action_locationmap() { if (!$this->_testAdmin()) { return; } $id = @(int) $_GET['id']; if (!$id) { echo 'Error! No ID given!<script type="text/javascript">window.close();</script>'; exit; } $location = new Model_Kwalbum_Location(); $location->load($id); $this->template = new View('kwalbum/admin/locationmap'); $this->template->location = $location; }
function action_SaveMapLocation() { $this->_testPermission(); $loc = new Model_Kwalbum_Location(); $loc->load($_POST['id']); $loc->latitude = (double) $_POST['lat']; $loc->longitude = (double) $_POST['lon']; $loc->save(); echo 1; exit; }
echo html::anchor($kwalbum_url . '/~browse', '<b>browse all the pictures</b>'); ?> or search below to find something specific. </p> <form method='get' action='<?php echo $kwalbum_url . '/~browse/'; ?> '> <table><tr> <td> Location:<br/> <select name="location" size="10"> <option value='' selected></option> <?php $locations = Model_Kwalbum_Location::getNameArray($user); foreach ($locations as $name) { echo "<option value='{$name}'>{$name}</option>"; } ?> </select> </td> <td> Tags:<br/> <select name="tags" multiple size="10"> <option value='' selected></option> <?php $tags = Model_Kwalbum_Tag::getNameArray(); foreach ($tags as $name) { echo "<option value='{$name}'>{$name}</option>"; }
/** * Save location changes by either inserting or updating the location table in the database * * @return Model_Kwalbum_Location */ public function save() { $id = $this->id; $parent_id = 0; if ($this->parent_name) { if ($this->parent_name != $this->_original_name) { $result = DB::query(Database::SELECT, "SELECT id\n\t\t\t\t\tFROM kwalbum_locations\n\t\t\t\t\tWHERE name = :name")->param(':name', $this->parent_name)->execute(); } if (isset($result) and count($result) == 1) { $parent_id = $result[0]['id']; } else { $parent = clone $this; $parent->id = 0; $parent->name = '_____temporary name_____' . time(); $parent->parent_name = ''; $parent_id = $parent->save()->id; $parent->name = $this->parent_name; $parent->save(); } } if ($id == 0) { $result = DB::query(Database::SELECT, "SELECT id, latitude, longitude, count, child_count\n\t\t\t\tFROM kwalbum_locations\n\t\t\t\tWHERE name = :name AND parent_location_id = :parent_id\n\t\t\t\tLIMIT 1")->param(':name', $this->name)->param(':parent_id', (int) $parent_id)->execute(); if ($result->count() == 0) { $result = DB::query(Database::INSERT, "INSERT INTO kwalbum_locations\n\t\t\t\t\t(name, latitude, longitude, count, child_count, thumbnail_item_id, parent_location_id,\n\t\t\t\t\t\tname_hide_level, coordinate_hide_level, description)\n\t\t\t\t\tVALUES (:name, :latitude, :longitude, :count, :child_count, :thumbnail_item_id, :parent_id,\n\t\t\t\t\t\t:name_hide_level, :coordinate_hide_level, :description)")->param(':name', $this->name)->param(':latitude', $this->latitude ? $this->latitude : 0)->param(':longitude', $this->longitude ? $this->longitude : 0)->param(':count', (int) $this->count)->param(':child_count', (int) $this->child_count)->param(':thumbnail_item_id', $this->thumbnail_item_id ? $this->thumbnail_item_id : 0)->param(':parent_id', (int) $parent_id)->param(':name_hide_level', (int) $this->name_hide_level)->param(':coordinate_hide_level', (int) $this->coordinate_hide_level)->param(':description', $this->description ? $this->description : '')->execute(); $this->id = $result[0]; Model_Kwalbum_Location::updateCounts(); return $this; } $row = $result[0]; $this->id = $id = (int) $row['id']; if (!$this->latitude) { $this->latitude = (double) $row['latitude']; } if (!$this->longitude) { $this->longitude = (double) $row['longitude']; } if (!$this->count) { $this->count = (int) $row['count']; } if (!$this->child_count) { $this->child_count = (int) $row['child_count']; } } else { $query = DB::query(Database::UPDATE, "UPDATE kwalbum_locations\n\t\t\t\tSET name = :name, latitude = :latitude, longitude = :longitude, count = :count, child_count = :child_count,\n\t\t\t\t\tthumbnail_item_id = :thumbnail_item_id, parent_location_id = :parent_id,\n\t\t\t\t\tname_hide_level = :name_hide_level, coordinate_hide_level = :coordinate_hide_level,\n\t\t\t\t\tdescription = :description\n\t\t\t\tWHERE id = :id")->param(':id', $id)->param(':name', $this->name)->param(':latitude', $this->latitude ? $this->latitude : 0)->param(':longitude', $this->longitude ? $this->longitude : 0)->param(':count', (int) $this->count)->param(':child_count', (int) $this->child_count)->param(':thumbnail_item_id', (int) $this->thumbnail_item_id)->param(':parent_id', (int) $parent_id)->param(':name_hide_level', (int) $this->name_hide_level)->param(':coordinate_hide_level', (int) $this->coordinate_hide_level)->param(':description', $this->description ? $this->description : ''); $query->execute(); } Model_Kwalbum_Location::updateCounts(); return $this; }
<?php $config = Kohana::$config->load('kwalbum'); $all_locations = Model_Kwalbum_Location::getAllArray(); $locations = array(); foreach ($all_locations as $loc) { $locations[$loc['id']] = $loc; } $all_locations = $locations; $locations = array(); foreach ($all_locations as $loc) { $loc_parent = ''; if ($loc['parent_location_id']) { $loc_parent = $all_locations[$loc['parent_location_id']]['name'] . $config->location_separator_1; } $locations[$loc_parent . $loc['name']] = $loc; } uksort($locations, 'strnatcasecmp'); $hide_levels = Model_Kwalbum_Item::$hide_level_names; echo html::script($kwalbum_url . '/media/ajax/jquery.jeditable.mini.js') . html::script($kwalbum_url . '/media/ajax/admin/locations.js'); ?> <div class="box"> <big><b>Editing Locations</b></big> <table border="1"> <tr> <th>Count</th> <th style="width:255px;">Name</th> <th style="width:150px;">Name Visibility</th> <th>Delete?</th> <th>Mapping Coordinates</th>
public function action_GetMapLocations() { //$zoom = (int)$_GET["z"]; $data = array(); Model_Kwalbum_Location::getMarkers((double) $_GET["l"], (double) $_GET["r"], (double) $_GET["t"], (double) $_GET["b"], $data); echo "point\ttype\ttitle\tdescription"; foreach ($data as $d) { echo "\n{$d['lon']},{$d['lat']}\tl\t{$d['name']}\t{$this->url}/" . urlencode($d['name']); } }