bandeau_region via config.xml

This commit is contained in:
pvincent
2022-11-16 09:09:36 +04:00
parent c163807c96
commit f2c6c05a00
7 changed files with 146 additions and 93 deletions
+22 -20
View File
@@ -13,26 +13,28 @@ class BaseView implements Dynamic {
public function init() {
var app = App.current;
this.user = app.user;
this.session = app.session;
this.LANG = App.config.LANG;
this.HOST = App.config.HOST;
this.DATA_HOST = App.config.DATA_HOST;
this.DEBUG = App.config.DEBUG;
this.BANDEAU_REGION = App.config.BANDEAU_REGION;
this.NAME = App.config.NAME;
this.isAdmin = app.user != null && app.user.isAdmin();
//Access basic functions in views
this.Std = Std;
this.Math = Math;
if ( App.config.SQL_LOG ) {
this.Config = App.config;
if ( App.config.SQL_LOG ) {
this.sqlLog = untyped app.cnx == null ? null : app.cnx.log;
}
}
function getMessage() {
var session = App.current.session;
if ( session == null ) return null;
@@ -41,14 +43,14 @@ class BaseView implements Dynamic {
if( n == null ) return null;
return { text : n.text, error : n.error, next : session.messages.length > 0 };
}
function getMessages() {
var out = [];
var session = App.current.session;
if ( session == null ) return [];
if (session.messages == null) return [];
for ( m in session.messages) {
if( m == null ) continue;
out.push( { text : m.text, error : m.error } );
@@ -56,12 +58,12 @@ class BaseView implements Dynamic {
session.messages = [];
return out;
}
function urlEncode(str:String) {
return StringTools.urlEncode(str);
}
/**
* To safely print a string in javascript
* @param str
@@ -70,13 +72,13 @@ class BaseView implements Dynamic {
if (str == null) return "";
return str.split("\\").join("\\\\").split("'").join("\\'").split("\r").join("\\r").split("\n").join("\\n");
}
/**
* Get a value from the Variable table
* @param file
*/
function getVariable( file : String ) {
var v = _vcache.get(file);
if( v != null )
return v;
@@ -91,7 +93,7 @@ class BaseView implements Dynamic {
function getParam( p : String ) {
return App.current.params.get(p);
}
/**
* Return the url of a db.File record
*/
@@ -99,7 +101,7 @@ class BaseView implements Dynamic {
if (file == null) throw "file is null";
return "/file/"+sugoi.db.File.makeSign(file.id)+"."+file.getExtension();
}
/**
* Try to print an HTML table from any kind of object
* @param data
@@ -107,14 +109,14 @@ class BaseView implements Dynamic {
function table(data:Dynamic) {
return new sugoi.helper.Table("table table-bordered").toString(data);
}
/**
* newline to <br/>
* @param txt
*/
public function nl2br(txt:String):String {
public function nl2br(txt:String):String {
if (txt == null) return "";
return txt.split("\n").join("<br/>");
return txt.split("\n").join("<br/>");
}
@@ -125,7 +127,7 @@ class BaseView implements Dynamic {
return str;
}
}
//same function with params ( templo doesnt manage optionnal params in functions )
public function __(str:String, params:Dynamic){
return sugoi.i18n.Locale.texts.get(str, params);
@@ -136,7 +138,7 @@ class BaseView implements Dynamic {
neko.Web.logMessage("_call "+str);
return StringTools.rtrim( str.split("||")[0] );
}
//same function with params ( templo doesnt manage optionnal params in functions )
public function __(str:String, params:Dynamic):String {
neko.Web.logMessage("_call "+str);
@@ -159,5 +161,5 @@ class BaseView implements Dynamic {
}
return list;
}
}