state system fixed - empty variables are removed from the query string, including ${*} placeholders, system.css, system.js lang switcher included(simple)
This commit is contained in:
parent
49e18f1c3c
commit
9b30021029
0
files/sys/system.css
Normal file
0
files/sys/system.css
Normal file
@ -20,7 +20,7 @@ function SYSTEM(endpoint, group,start_state){
|
|||||||
//internal function to handle pagestate results
|
//internal function to handle pagestate results
|
||||||
SYSTEM.prototype.handle_call_pages = function (data,id) {
|
SYSTEM.prototype.handle_call_pages = function (data,id) {
|
||||||
if(data['status']){
|
if(data['status']){
|
||||||
system.log(system.LOG_INFO,'load pages: endpoint '+system.endpoint+':group '+system.group+':state '+id+' - success');
|
system.log_info('load pages: endpoint '+system.endpoint+' group:'+system.group+' state:'+id+' - success');
|
||||||
if(id !== system.cur_state()){
|
if(id !== system.cur_state()){
|
||||||
window.history.pushState(null, "", '#!'+id);}
|
window.history.pushState(null, "", '#!'+id);}
|
||||||
data['result'].forEach(function(entry) {
|
data['result'].forEach(function(entry) {
|
||||||
@ -50,16 +50,16 @@ SYSTEM.prototype.handle_call_pages = function (data,id) {
|
|||||||
if(call_func && typeof fn === 'function'){
|
if(call_func && typeof fn === 'function'){
|
||||||
call_func = false;
|
call_func = false;
|
||||||
fn();
|
fn();
|
||||||
system.log(system.LOG_INFO,'call func: '+entry['func']);
|
system.log_info('call func: '+entry['func']);
|
||||||
} else {
|
} else {
|
||||||
system.log(system.LOG_ERROR,'call func: '+entry['func']+' - fail');
|
system.log_error('call func: '+entry['func']+' - fail');
|
||||||
}}
|
}}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
system.log(system.LOG_INFO,'Problem with your Pages: '+data['result']['message']);
|
system.log_info('Problem with your Pages: '+data['result']['message']);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
//send a call to the endpoint
|
//send a call to the endpoint
|
||||||
@ -88,6 +88,10 @@ SYSTEM.prototype.log = function(type,msg){
|
|||||||
}
|
}
|
||||||
console.log(res+msg);
|
console.log(res+msg);
|
||||||
};
|
};
|
||||||
|
SYSTEM.prototype.log_info = function(msg){
|
||||||
|
this.log(this.LOG_INFO,msg);}
|
||||||
|
SYSTEM.prototype.log_error = function(msg){
|
||||||
|
this.log(this.LOG_ERROR,msg);}
|
||||||
//get the pages and save em
|
//get the pages and save em
|
||||||
SYSTEM.prototype.load_page = function(){
|
SYSTEM.prototype.load_page = function(){
|
||||||
result = false;
|
result = false;
|
||||||
@ -126,9 +130,14 @@ SYSTEM.prototype.go_state = function(default_state){
|
|||||||
};
|
};
|
||||||
|
|
||||||
SYSTEM.prototype.back = function(){
|
SYSTEM.prototype.back = function(){
|
||||||
window.history.back();
|
window.history.back();};
|
||||||
};
|
|
||||||
|
|
||||||
SYSTEM.prototype.forwad = function(){
|
SYSTEM.prototype.forwad = function(){
|
||||||
window.history.forward();
|
window.history.forward();};
|
||||||
|
|
||||||
|
SYSTEM.prototype.language = function(lang){
|
||||||
|
this.log_info('change language to '+lang);
|
||||||
|
//preserve the old parameters
|
||||||
|
//var search = location.search ? location.search.substring(1).split("&") : [];
|
||||||
|
var search = '_lang='+lang;
|
||||||
|
window.location.href = '/?' + search + location.hash;
|
||||||
};
|
};
|
||||||
@ -11,6 +11,10 @@ class State {
|
|||||||
$res = \SYSTEM\DBD\SYS_PAGE_GROUP::QQ(array($group,$state[0]));
|
$res = \SYSTEM\DBD\SYS_PAGE_GROUP::QQ(array($group,$state[0]));
|
||||||
while($row = $res->next()){
|
while($row = $res->next()){
|
||||||
$row['url'] = \SYSTEM\PAGE\replace::replace($row['url'], $vars);
|
$row['url'] = \SYSTEM\PAGE\replace::replace($row['url'], $vars);
|
||||||
|
$row['url'] = \SYSTEM\PAGE\replace::clean($row['url']);
|
||||||
|
//clean url of empty variables
|
||||||
|
$row['url'] = preg_replace('/&.*?=(&|$)/', '&', $row['url']);
|
||||||
|
$row['url'] = preg_replace('/&$/', '', $row['url']);
|
||||||
$row['css'] = $row['js'] = array();
|
$row['css'] = $row['js'] = array();
|
||||||
if(\class_exists($row['php_class']) && \method_exists($row['php_class'], 'css') && \is_callable($row['php_class'].'::css')){
|
if(\class_exists($row['php_class']) && \method_exists($row['php_class'], 'css') && \is_callable($row['php_class'].'::css')){
|
||||||
$row['css'] = array_merge($row['css'], call_user_func($row['php_class'].'::css'));}
|
$row['css'] = array_merge($row['css'], call_user_func($row['php_class'].'::css'));}
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace SYSTEM\PAGE;
|
namespace SYSTEM\PAGE;
|
||||||
class replace
|
class replace {
|
||||||
{
|
|
||||||
public static function replace($text, $vars){
|
public static function replace($text, $vars){
|
||||||
if(!$vars){
|
if(!$vars){
|
||||||
$vars = array();}
|
$vars = array();}
|
||||||
@ -18,4 +17,8 @@ class replace
|
|||||||
public static function replaceFile($path, $vars){
|
public static function replaceFile($path, $vars){
|
||||||
$buffer = file_get_contents($path);
|
$buffer = file_get_contents($path);
|
||||||
return self::replace($buffer, $vars);}
|
return self::replace($buffer, $vars);}
|
||||||
|
|
||||||
|
//removes all Variable Handles
|
||||||
|
public static function clean($text){
|
||||||
|
return preg_replace('/\${.*?}/', '', $text);}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user