Pushing map parameters to DB
This commit is contained in:
43
inc/Spot.php
43
inc/Spot.php
@@ -30,31 +30,16 @@ class Spot extends Main
|
||||
{
|
||||
//Database
|
||||
const POST_TABLE = 'posts';
|
||||
const MAP_TABLE = 'maps';
|
||||
const MAPPING_TABLE = 'mappings';
|
||||
|
||||
const FEED_CHUNK_SIZE = 15;
|
||||
const MAIL_CHUNK_SIZE = 5;
|
||||
|
||||
const DEFAULT_LANG = 'en';
|
||||
|
||||
/**
|
||||
* Active Project
|
||||
* @var Project
|
||||
*/
|
||||
private $oProject;
|
||||
|
||||
/**
|
||||
* Media Class
|
||||
* @var Media
|
||||
*/
|
||||
private $oMedia;
|
||||
|
||||
/**
|
||||
* User
|
||||
* @var User
|
||||
*/
|
||||
private $oUser;
|
||||
private Project $oProject;
|
||||
private Media $oMedia;
|
||||
private User $oUser;
|
||||
private Map $oMap;
|
||||
|
||||
public function __construct($sProcessPage, $sTimezone)
|
||||
{
|
||||
@@ -66,6 +51,8 @@ class Spot extends Main
|
||||
|
||||
$this->oProject = new Project($this->oDb);
|
||||
$this->oMedia = new Media($this->oDb, $this->oProject);
|
||||
|
||||
$this->oMap = new Map($this->oDb);
|
||||
}
|
||||
|
||||
protected function install()
|
||||
@@ -104,8 +91,8 @@ class Spot extends Main
|
||||
self::POST_TABLE => array(Db::getId(Project::PROJ_TABLE), Db::getId(User::USER_TABLE), 'name', 'content', 'site_time', 'timezone'),
|
||||
Media::MEDIA_TABLE => array(Db::getId(Project::PROJ_TABLE), 'filename', 'type', 'taken_on', 'posted_on', 'timezone', 'rotate', 'comment'),
|
||||
User::USER_TABLE => array('name', 'email', 'gravatar', 'language', 'timezone', 'active', 'clearance'),
|
||||
self::MAP_TABLE => array('codename', 'geo_name', 'tile_size', 'min_zoom', 'max_zoom', 'attribution'),
|
||||
self::MAPPING_TABLE => array(Db::getId(self::MAP_TABLE) , Db::getId(Project::PROJ_TABLE))
|
||||
Map::MAP_TABLE => array('codename', 'pattern', 'token', 'tile_size', 'min_zoom', 'max_zoom', 'attribution'),
|
||||
Map::MAPPING_TABLE => array(Db::getId(Map::MAP_TABLE) , Db::getId(Project::PROJ_TABLE))
|
||||
),
|
||||
'types' => array
|
||||
(
|
||||
@@ -127,6 +114,7 @@ class Spot extends Main
|
||||
'longitude' => "DECIMAL(8,5)",
|
||||
'model' => "VARCHAR(20)",
|
||||
'name' => "VARCHAR(100)",
|
||||
'pattern' => "VARCHAR(200) NOT NULL",
|
||||
'posted_on' => "TIMESTAMP DEFAULT 0",
|
||||
'ref_feed_id' => "VARCHAR(40)",
|
||||
'ref_msg_id' => "INT",
|
||||
@@ -136,9 +124,9 @@ class Spot extends Main
|
||||
'status' => "VARCHAR(10)",
|
||||
'taken_on' => "TIMESTAMP DEFAULT 0",
|
||||
'timezone' => "CHAR(64)", //see mysql.time_zone_name
|
||||
'token' => "VARCHAR(4096)",
|
||||
'type' => "VARCHAR(20)",
|
||||
'unix_time' => "INT",
|
||||
'geo_name' => "VARCHAR(100)",
|
||||
'min_zoom' => "TINYINT UNSIGNED",
|
||||
'max_zoom' => "TINYINT UNSIGNED",
|
||||
'attribution' => "VARCHAR(100)",
|
||||
@@ -155,14 +143,15 @@ class Spot extends Main
|
||||
Feed::SPOT_TABLE => array("UNIQUE KEY `uni_ref_spot_id` (`ref_spot_id`)", "INDEX(`ref_spot_id`)"),
|
||||
Project::PROJ_TABLE => "UNIQUE KEY `uni_proj_name` (`codename`)",
|
||||
Media::MEDIA_TABLE => "UNIQUE KEY `uni_file_name` (`filename`)",
|
||||
User::USER_TABLE => "UNIQUE KEY `uni_email` (`email`)"
|
||||
User::USER_TABLE => "UNIQUE KEY `uni_email` (`email`)",
|
||||
Map::MAP_TABLE => "UNIQUE KEY `uni_map_name` (`codename`)"
|
||||
),
|
||||
'cascading_delete' => array
|
||||
(
|
||||
Feed::SPOT_TABLE => array(Feed::FEED_TABLE),
|
||||
Feed::FEED_TABLE => array(Feed::MSG_TABLE),
|
||||
Project::PROJ_TABLE => array(Feed::FEED_TABLE, Media::MEDIA_TABLE, self::POST_TABLE),
|
||||
self::MAP_TABLE => array(self::MAPPING_TABLE)
|
||||
Map::MAP_TABLE => array(Map::MAPPING_TABLE)
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -185,7 +174,6 @@ class Spot extends Main
|
||||
),
|
||||
'consts' => array(
|
||||
'server' => $this->asContext['serv_name'],
|
||||
'geo_server' => Settings::GEO_SERVER,
|
||||
'modes' => Project::MODES,
|
||||
'clearances' => User::CLEARANCES,
|
||||
'default_timezone' => Settings::TIMEZONE
|
||||
@@ -236,7 +224,6 @@ class Spot extends Main
|
||||
|
||||
//Add Position
|
||||
$asLastMessage = array_shift($this->getSpotMessages(array($this->oProject->getLastMessageId($this->getFeedConstraints(Feed::MSG_TABLE)))));
|
||||
$asLastMessage['token'] = Settings::GEO_SERVER_TOKEN;
|
||||
$oEmail->oTemplate->setTags($asLastMessage);
|
||||
$oEmail->oTemplate->setTag('date_time', 'time:'.$asLastMessage['unix_time'], 'd/m/Y, H:i');
|
||||
|
||||
@@ -315,7 +302,7 @@ class Spot extends Main
|
||||
|
||||
$asResult = array(
|
||||
'messages' => $asMessages,
|
||||
'maps' => $this->oProject->getMaps(),
|
||||
'maps' => $this->oMap->getProjectMaps($this->oProject->getProjectId()),
|
||||
'last_update' => $asLastUpdate
|
||||
);
|
||||
|
||||
@@ -372,6 +359,8 @@ class Spot extends Main
|
||||
$asMessage['lat_dms'] = self::decToDms($asMessage['latitude'], 'lat');
|
||||
$asMessage['lon_dms'] = self::decToDms($asMessage['longitude'], 'lon');
|
||||
$asMessage['displayed_id'] = $asMessage[Db::getId(Feed::MSG_TABLE)];
|
||||
$asMessage['static_img_url'] = $this->oMap->getMapUrl('static', array('x'=>$asMessage['longitude'], 'y'=>$asMessage['latitude']));
|
||||
$asMessage['marker_img_url'] = $this->oMap->getMapUrl('static_marker', array('x'=>$asMessage['longitude'], 'y'=>$asMessage['latitude']));
|
||||
|
||||
$this->addTimeStamp($asMessage, $asMessage['unix_time'], $asMessage['timezone']);
|
||||
$asCombinedMessages[] = $asMessage;
|
||||
|
||||
Reference in New Issue
Block a user