Skip to content
Permalink
Browse files

set default coordinates of new additional waypoints to cache coordinates

  • Loading branch information...
flopp committed May 19, 2013
1 parent de572aa commit 73efcb8286ea8017e6737a9f5f6a18baec2e75c0
Showing with 30 additions and 2 deletions.
  1. +10 −1 lib/classes/ChildWp/Controller.php
  2. +14 −0 lib/classes/ChildWp/Handler.php
  3. +6 −1 lib/classes/ChildWp/Presenter.php
@@ -46,7 +46,7 @@ public function createPresenter($template, $cacheManager, $childWpHandler)
if ($childId || $deleteId)
$presenter = $this->createEditDeletePresenter($template, $childWpHandler, $cacheId, $childId, $deleteId);
else
$presenter = new ChildWp_AddPresenter($this->request, $this->translator);
$presenter = $this->createAddPresenter($template, $childWpHandler, $cacheId);
$presenter->init($childWpHandler, $cacheId);
@@ -71,6 +71,15 @@ private function createEditDeletePresenter($template, $childWpHandler, $cacheId,
return $presenter;
}
private function createAddPresenter($template, $childWpHandler, $cacheId)
{
$presenter = new ChildWp_AddPresenter($this->request, $this->translator);
/* set default waypoint coordinates to cache coordinates */
$presenter->initCoordinates( $childWpHandler->getCacheCoordinates( $cacheId ) );
return $presenter;
}
private function verifyCacheId($template, $cacheId, $cacheManager)
{
if (!$cacheManager->exists($cacheId) || !$cacheManager->userMayModify($cacheId))
@@ -84,6 +84,20 @@ public function getChildNamesAndImages()
return $nameAndTypes;
}
public function getCacheCoordinates( $cacheid )
{
$rs = sql("SELECT latitude, longitude FROM caches WHERE cache_id = &1", $cacheid);
$r = sql_fetch_array($rs);
$ret = array();
$ret['latitude'] = $r['latitude'];
$ret['longitude'] = $r['longitude'];
mysql_free_result($rs);
return $ret;
}
private function recordToArray($r)
{
@@ -60,7 +60,12 @@ public function init($childWpHandler, $cacheId)
$this->childWpHandler = $childWpHandler;
$this->cacheId = $cacheId;
$this->waypointTypes = $childWpHandler->getChildWpIdAndNames();
$this->typeImages = $childWpHandler->getChildNamesAndImages();
$this->typeImages = $childWpHandler->getChildNamesAndImages();
}
public function initCoordinates( $coords )
{
$this->coordinate->init( $coords['latitude'], $coords['longitude'] );
}
public function initChildWp($childId, $childWp)

0 comments on commit 73efcb8

Please sign in to comment.
You can’t perform that action at this time.