Skip to content

Commit

Permalink
Merge pull request #55 from exodus4d/develop
Browse files Browse the repository at this point in the history
v0.0.14
  • Loading branch information
exodus4d committed Oct 25, 2015
2 parents bc1e8e6 + 7d0a28f commit 167f9ad
Show file tree
Hide file tree
Showing 69 changed files with 886 additions and 197 deletions.
5 changes: 3 additions & 2 deletions app/main/controller/accesscontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ function __construct() {
* @param $f3
*/
function beforeroute($f3) {
parent::beforeroute($f3);

// Any CMS route of a child class of this one, requires a
// valid logged in user!
$loginCheck = $this->_checkLogIn();

if( !$loginCheck ){
// no user found or LogIn timer expired
$this->logOut($f3);
}

parent::beforeroute($f3);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions app/main/controller/api/map.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ function beforeroute($f3) {
public function init($f3){

// expire time in seconds
$expireTimeHead = 60 * 60 * 24;
$expireTimeSQL = 60 * 60 * 24;
$expireTimeHead = 60 * 60 * 12;
$expireTimeSQL = 60 * 60 * 12;

$f3->expire($expireTimeHead);

Expand Down
6 changes: 4 additions & 2 deletions app/main/controller/api/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class User extends Controller\Controller{
*/
private static $captchaReason = ['createAccount', 'deleteAccount'];


/**
* login function
* @param $f3
Expand Down Expand Up @@ -310,7 +309,7 @@ public function saveConfig($f3){
$settingsData = $data['settingsData'];

try{
$user = $this->_getUser();
$user = $this->_getUser(0);

// captcha is send -> check captcha
if(
Expand Down Expand Up @@ -433,6 +432,9 @@ public function saveConfig($f3){
foreach($apiModels as $apiModel){
$apiModel->delete();
}

// get fresh updated user object (API info may have has changed)
$user = $this->_getUser(0);
}

// set main character
Expand Down
10 changes: 6 additions & 4 deletions app/main/controller/ccpapicontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,14 @@ public function updateCharacters($userApiModel){
$newCharacter = true;

$characterId = (int)$attributeData['characterID'];
$characterModel->getById($characterId);
$characterModel->getById($characterId, 0);

$corporationModelTemp = null;
$allianceModelTemp = null;

// check if corporation already exists
if($attributeData['corporationID'] > 0){
$corporationModel->getById($attributeData['corporationID']);
$corporationModel->getById($attributeData['corporationID'], 0);
if( $corporationModel->dry() ){
$corporationModel->id = $attributeData['corporationID'];
$corporationModel->name = $attributeData['corporationName'];
Expand All @@ -125,7 +128,7 @@ public function updateCharacters($userApiModel){

// check if alliance already exists
if($attributeData['allianceID'] > 0){
$allianceModel->getById($attributeData['allianceID']);
$allianceModel->getById($attributeData['allianceID'], 0);
if( $allianceModel->dry() ){
$allianceModel->id = $attributeData['allianceID'];
$allianceModel->name = $attributeData['allianceName'];
Expand Down Expand Up @@ -153,7 +156,6 @@ public function updateCharacters($userApiModel){
$userApiModel->userCharacters->next();
}
}

$userApiModel->userCharacters->rewind();
}

Expand Down
12 changes: 11 additions & 1 deletion app/main/controller/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public function getTemplate(){
*/
function beforeroute($f3) {

// init user session
$this->initSession();

// check if user is in game
$f3->set('isIngame', self::isIGB() );

Expand All @@ -71,14 +74,21 @@ protected function getDB($database = 'PF'){
return DB\Database::instance()->getDB($database);
}

/**
* init new Session handler
*/
protected function initSession(){
// init DB Session (not file based)
new \DB\SQL\Session($this->getDB('PF'));
}

/**
* get current user model
* @param int $ttl
* @return bool|null
* @throws \Exception
*/
protected function _getUser($ttl = 5){

$user = false;

if( $this->f3->exists('SESSION.user.id') ){
Expand Down
4 changes: 3 additions & 1 deletion app/main/model/basicmodel.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,13 @@ protected function getCacheData($dataCacheKeyPrefix = ''){
*/
public function updateCacheData($cacheData, $dataCacheKeyPrefix = '', $data_ttl = 300){

$cacheDataTmp = (array)$cacheData;

// check if data should be cached
// and cacheData is not empty
if(
$data_ttl > 0 &&
!empty( (array)$cacheData )
!empty( $cacheDataTmp )
){
$cacheKey = $this->getCacheKey($dataCacheKeyPrefix);

Expand Down
4 changes: 2 additions & 2 deletions app/pathfinder.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[PATHFINDER]
NAME = "PATHFINDER"
; installed version (used for CSS/JS cache busting)
VERSION = "v0.0.13"
VERSION = "v0.0.14"
; contact information (DO NOT CHANGE)
CONTACT = "https://github.com/exodus4d"
; source code (DO NOT CHANGE)
Expand Down Expand Up @@ -100,7 +100,7 @@ INVITE_LIMIT = 50
; ======================================================================================================
; Lifetime for map types (days)
[PATHFINDER.MAP.PRIVATE]
LIFETIME = 2
LIFETIME = 7

[PATHFINDER.MAP.CORPORATION]
LIFETIME = 99999
Expand Down
11 changes: 10 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ var _src = {
JS_LIBS: './js/lib/**/*',
JS_BUILD: './build_js',
JS_DIST: './public/js',
PACKAGE: './package.json'
PACKAGE: './package.json',
CACHE: './tmp/**/*.*'
};

// Gulp plumber error handler
Expand Down Expand Up @@ -156,6 +157,14 @@ gulp.task('watch', function(tag) {

});

/**
* clear all backend (fat free framework) cache files
*/
gulp.task('clearCache', function() {
'use strict';
return gulp.src( _src.CACHE ).pipe( clean() );
});


/*******************************************/
// Default Tasks
Expand Down
4 changes: 4 additions & 0 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ requirejs.config({
velocityUI: 'lib/velocity.ui.min', // v5.0.4 plugin for velocity - http://julian.com/research/velocity/#uiPack
slidebars: 'lib/slidebars', // v0.10 Slidebars - side menu plugin http://plugins.adchsm.me/slidebars/
jsPlumb: 'lib/dom.jsPlumb-1.7.6-min', // v1.7.6 jsPlumb (Vanilla)- main map draw plugin https://jsplumbtoolkit.com/
farahey: 'lib/farahey-0.5', // v0.5 jsPlumb "magnetizing" extension - https://github.com/jsplumb/farahey
customScrollbar: 'lib/jquery.mCustomScrollbar.concat.min', // v3.0.9 Custom scroll bars - http://manos.malihu.gr/
datatables: 'lib/datatables/jquery.dataTables.min', // v1.10.7 DataTables - https://datatables.net/
//datatablesBootstrap: 'lib/datatables/dataTables.bootstrap', // DataTables - not used (bootstrap style)
Expand Down Expand Up @@ -70,6 +71,9 @@ requirejs.config({
bootstrap: {
deps: ['jquery']
},
farahey: {
deps: ['jsPlumb']
},
velocity: {
deps: ['jquery']
},
Expand Down
5 changes: 4 additions & 1 deletion js/app/landingpage.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ define([
// login error
if(data.error !== undefined){
$('.' + config.splashOverlayClass).hideSplashOverlay();
loginFormMessageContainer.showMessage({title: 'Login failed', text: ' Invalid username and password', type: 'error'});
loginFormMessageContainer.showMessage({title: 'Login failed', text: ' Invalid username or password', type: 'error'});

}else if(data.reroute !== undefined){
window.location = data.reroute;
Expand Down Expand Up @@ -147,6 +147,9 @@ define([

};

/**
* show "registration key" dialog (see "Invite" feature)
*/
var showRequestRegistrationKeyDialog = function(){
var data = {
id: config.signatureReaderDialogId,
Expand Down
156 changes: 156 additions & 0 deletions js/app/map/magnetizing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
/**
* Map "magnetizing" feature
* jsPlumb extension used: http://morrisonpitt.com/farahey/
*/

define([
'jquery',
'farahey'
], function($) {

'use strict';

var config = {
systemClass: 'pf-system' // class for all systems
};

/**
* Cached current "Magnetizer" object
* @type {Magnetizer}
*/
var m8 = null;

/**
* init a jsPlumb (map) Element for "magnetised" function.
* this is optional and prevents systems from being overlapped
*/
$.fn.initMagnetizer = function(){
var mapContainer = this;

var systemsOnMap = mapContainer.find('.' + config.systemClass);

/**
* helper function
* get current system offset
* @param system
* @returns {{left, top}}
* @private
*/
var _offset = function(system) {

var _ = function(p) {
var v = system.style[p];
return parseInt(v.substring(0, v.length - 2));
};

return {
left:_('left'),
top:_('top')
};
};

/**
* helper function
* set new syste offset
* @param system
* @param o
* @private
*/
var _setOffset = function(system, o) {

var markAsUpdated = false;

// new position must be within parent container
// no negative offset!
if(
o.left >= 0 &&
o.left <= 2300
){
markAsUpdated = true;
system.style.left = o.left + 'px';
}

if(
o.top >= 0 &&
o.top <= 498
){
markAsUpdated = true;
system.style.top = o.top + 'px';
}

if(markAsUpdated === true){
$(system).markAsChanged();
}
};

/**
* helper function
* exclude current dragged element(s) from position update
* @param id
* @returns {boolean}
* @private
*/
var _dragFilter = function(id) {

return !$('#' + id).hasClass('jsPlumb_dragged');
};

// main init for "magnetize" feature ------------------------------------------------------
m8 = new Magnetizer({
container: mapContainer,
getContainerPosition:function(c) {
return c.offset();
},
getPosition:_offset,
getSize: function(system) {
return [ $(system).outerWidth(), $(system).outerHeight() ];
},
getId : function(system) {
return $(system).attr('id');
},
setPosition:_setOffset,
elements: systemsOnMap,
filter:_dragFilter,
padding:[8, 8]
});

};

$.fn.destroyMagnetizer = function(){
var mapContainer = this;

// remove cached "magnetizer" instance
m8 = null;
};

/**
* update system positions for "all" systems that are effected by drag&drop
* @param map
* @param e
*/
var executeAtEvent = function(map, e){

// check if magnetizer is active
if(m8 !== null && e ){
m8.executeAtEvent(e);
map.repaintEverything();
}
};

/**
* rearrange all systems of a map
* needs "magnetization" to be active
* @param map
*/
var executeAtCenter = function(map){
if(m8 !== null){
m8.executeAtCenter();
map.repaintEverything();
}
};

return {
executeAtCenter: executeAtCenter,
executeAtEvent: executeAtEvent
};
});
Loading

0 comments on commit 167f9ad

Please sign in to comment.