diff --git a/app.js b/app.js new file mode 100644 index 00000000..5009b804 --- /dev/null +++ b/app.js @@ -0,0 +1,9 @@ + +//Vn.includeCss ('pages/main/style.css'); + +var Hedera = require ('./js/hedera/main'); +var App = require ('./js/hedera/app'); + +hederaWeb = new App (); +hederaWeb.run (); +window.hederaWeb = hederaWeb; diff --git a/cli.php b/cli.php index e626490c..acc4bd45 100755 --- a/cli.php +++ b/cli.php @@ -1,6 +1,6 @@ run (); diff --git a/configure.php b/configure.php index cd206f86..74e1f384 100644 --- a/configure.php +++ b/configure.php @@ -2,11 +2,9 @@ require_once (__DIR__.'/../php-vn-lib/configure.php'); -set_include_path -( - get_include_path () - .PATH_SEPARATOR.__DIR__ -); +set_include_path (__DIR__.PATH_SEPARATOR.get_include_path ()); + +$vnAutoloadMap['vn/web'] = __DIR__.'/web'; const _DEBUG_MODE = TRUE; const _CONFIG_DIR = '/home/juan/.config'; diff --git a/forms/admin/photos/photos.js b/forms/admin/photos/photos.js index a391a31d..e158aad2 100644 --- a/forms/admin/photos/photos.js +++ b/forms/admin/photos/photos.js @@ -10,23 +10,20 @@ Vn.Photos = new Class var self = this; this.$('html-form').onsubmit = function () - { self.onSubmit (); return false; }; + { self._onSubmit (); return false; }; } - ,onSubmit: function () + ,_onSubmit: function () { this.$('schema-field').value = this.$('schema').value; this.$('submit').disabled = true; - this.gui.loaderPush (); - var request = new Vn.JsonRequest (); - request.sendFormMultipart (this.$('html-form'), - this.onResponse.bind (this)); + this.conn.sendFormMultipart (this.$('html-form'), + this._onResponse.bind (this)); } - ,onResponse: function (request, json, error) + ,_onResponse: function (request, json, error) { - this.gui.loaderPop (); this.$('submit').disabled = false; if (json) diff --git a/forms/cms/contact/contact.js b/forms/cms/contact/contact.js index 8dee47e2..c95892a8 100644 --- a/forms/cms/contact/contact.js +++ b/forms/cms/contact/contact.js @@ -7,7 +7,7 @@ Vn.Contact = new Class { var self = this; this.$('contact-form').onsubmit = function () - { self.onSubmit (); return false; }; + { self._onSubmit (); return false; }; this.refreshCaptcha (); } @@ -19,18 +19,15 @@ Vn.Contact = new Class 'stamp': new Date ().getTime () }; this.$('captcha-img').src = '?'+ Vn.Url.makeUri (params); - - Vn.Url.makeUri (params) } - ,onSubmit: function () + ,_onSubmit: function () { - var request = new Vn.JsonRequest (); - request.sendForm (this.$('contact-form'), - this.onResponse.bind (this)); + this.conn.sendForm (this.$('contact-form'), + this._onResponse.bind (this)); } - ,onResponse: function (request, json, error) + ,_onResponse: function (json, error) { var form = this.$('contact-form'); diff --git a/forms/ecomerce/catalog/ui.xml b/forms/ecomerce/catalog/ui.xml index dc0eb5ce..4722fd6b 100755 --- a/forms/ecomerce/catalog/ui.xml +++ b/forms/ecomerce/catalog/ui.xml @@ -152,6 +152,7 @@ directory="catalog" subdir="200x200" form="item" + conn="conn" column="Foto" full-dir="900x900"/>
diff --git a/forms/ecomerce/orders/ui.xml b/forms/ecomerce/orders/ui.xml index d3fb343a..b8f53fa1 100755 --- a/forms/ecomerce/orders/ui.xml +++ b/forms/ecomerce/orders/ui.xml @@ -15,11 +15,13 @@
@@ -37,7 +39,7 @@ Info diff --git a/forms/news/news/ui.xml b/forms/news/news/ui.xml index 8724e636..cf11a2c7 100755 --- a/forms/news/news/ui.xml +++ b/forms/news/news/ui.xml @@ -40,7 +40,8 @@ directory="news" subdir="200x200" full-dir="full" - editable="true"/> + editable="true" + conn="conn"/>

diff --git a/image/icon/dark/logo.png b/image/icon/dark/logo.png deleted file mode 100644 index 6c485352..00000000 Binary files a/image/icon/dark/logo.png and /dev/null differ diff --git a/image/icon/dark/logo.svg b/image/logo-dark.svg similarity index 100% rename from image/icon/dark/logo.svg rename to image/logo-dark.svg diff --git a/index.php b/index.php index 8461c7d7..a8619318 100755 --- a/index.php +++ b/index.php @@ -1,6 +1,6 @@ run (); diff --git a/js/db/conn.js b/js/db/connection.js similarity index 81% rename from js/db/conn.js rename to js/db/connection.js index 3cb637af..b18e99be 100644 --- a/js/db/conn.js +++ b/js/db/connection.js @@ -1,10 +1,14 @@ /** - * Simulates a connection to a database by making asynchronous http requests to - * a remote PHP script that returns the results in JSON format. + * Simulates a connection to a database by making asynchronous requests to a + * remote REST service that returns the results in JSON format. * Using this class can perform any operation that can be done with a database, * like open/close a connection or selecion/updating queries. + * + * Warning! You should set a well defined dababase level privileges to use this + * class or you could have a serious security hole in you application becasuse + * the user can send any statement to the server. For example: DROP DATABASE **/ -Db.Conn = new Class ().extend +Db.Connection = new Class ().extend ({ Flag: { @@ -24,7 +28,7 @@ Db.Conn = new Class ().extend } }); -Db.Conn.implement +Db.Connection.implement ({ Extends: Vn.JsonConnection @@ -92,9 +96,9 @@ Db.Conn.implement switch (columns[j].type) { - case Db.Conn.Type.DATE: - case Db.Conn.Type.DATE_TIME: - case Db.Conn.Type.TIMESTAMP: + case Db.Connection.Type.DATE: + case Db.Connection.Type.DATE_TIME: + case Db.Connection.Type.TIMESTAMP: castFunc = this.valueToDate; break; } diff --git a/js/db/main.js b/js/db/main.js index 16692b54..2897d938 100644 --- a/js/db/main.js +++ b/js/db/main.js @@ -3,7 +3,7 @@ Vn.include ('js/sql/main'); Vn.includeLib ('db', [ 'db' - ,'conn' + ,'connection' ,'result' ,'result-set' ,'model' diff --git a/js/db/model.js b/js/db/model.js index 3afde179..f610a297 100644 --- a/js/db/model.js +++ b/js/db/model.js @@ -45,7 +45,7 @@ Db.Model.implement **/ conn: { - type: Db.Conn + type: Db.Connection ,set: function (x) { this._conn = x; diff --git a/js/hedera/app.js b/js/hedera/app.js index 61a3adda..ecbeb266 100644 --- a/js/hedera/app.js +++ b/js/hedera/app.js @@ -1,7 +1,18 @@ Vn.App = new Class ({ - Extends: Vn.Object + Extends: Vn.Object, + Properties: + { + conn: + { + type: Db.Connection + ,get: function () + { + return this._conn; + } + } + } ,initialize: function () { @@ -16,18 +27,18 @@ Vn.App = new Class }); this._isGuest.on ('changed', this._onGuestChange, this); - var conn = new Db.Conn (); + var conn = new Db.Connection (); this.link ({_conn: conn}, {'error': this._onConnError}); } ,run: function () { - var guest = Vn.Cookie.check ('hedera_guest'); + var guest = localStorage.getItem ('hederaGuest'); if (guest) - Vn.Cookie.unset ('hedera_guest'); + localStorage.removeItem ('hederaGuest'); - if (Vn.Cookie.check ('vn_pass')) + if (localStorage.getItem ('vnToken')) { this._conn.open (null, null, null, this._onAutoLogin.bind (this)); @@ -67,7 +78,7 @@ Vn.App = new Class if (success) { - Vn.Cookie.set ('hedera_guest', true); + localStorage.setItem ('hederaGuest', true); this._onLogin (); } else @@ -77,10 +88,7 @@ Vn.App = new Class ,_onAutoLogin: function (success) { if (!success) - { - Vn.Cookie.unset ('vn_pass'); this.run (); - } else this._onLogin (); } @@ -97,8 +105,7 @@ Vn.App = new Class ,_onLogout: function (gui) { this._freeGui (); - Vn.Cookie.unset ('hedera_guest'); - Vn.Cookie.unset ('vn_pass'); + localStorage.removeItem ('hederaGuest'); this.run (); } @@ -119,10 +126,13 @@ Vn.App = new Class { if (error instanceof Vn.JsonException) { - var exception = error.exception - .replace (/\\/g, '.') - .replace (/Exception$/, '') - .replace (/^Vn\.Web\./, ''); + if (error.exception) + var exception = error.exception + .replace (/\\/g, '.') + .replace (/Exception$/, '') + .replace (/^Vn\.Web\./, ''); + else + var exception = null; switch (exception) { diff --git a/js/hedera/gui.js b/js/hedera/gui.js index b28a5fda..75f1903e 100644 --- a/js/hedera/gui.js +++ b/js/hedera/gui.js @@ -9,7 +9,7 @@ Vn.Gui = new Class { conn: { - type: Db.Conn + type: Db.Connection ,set: function (x) { this.link ({_conn: x}, diff --git a/js/hedera/gui.xml b/js/hedera/gui.xml index 2576bf32..0a825ded 100755 --- a/js/hedera/gui.xml +++ b/js/hedera/gui.xml @@ -11,10 +11,10 @@
diff --git a/js/hedera/login.js b/js/hedera/login.js index 2e640484..149e19fa 100644 --- a/js/hedera/login.js +++ b/js/hedera/login.js @@ -10,12 +10,13 @@ Vn.Login = new Class { conn: { - type: Db.Conn + type: Db.Connection ,set: function (x) { this.link ({_conn: x}, {'loading-changed': this._onConnLoadChange}); x.execQuery ( - 'SELECT title, link, icon FROM social ORDER BY priority', + 'SELECT title, link, icon FROM social ' + +'WHERE priority ORDER BY priority', this._onSocialQueryDone.bind (this)); } ,get: function () @@ -60,8 +61,10 @@ Vn.Login = new Class { document.body.appendChild (this.node); - if (Vn.Cookie.check ('vn_user')) - this.$('user').value = Vn.Cookie.get ('vn_user'); + var lastUser = localStorage.getItem ('hederaLastUser'); + + if (lastUser) + this.$('user').value = lastUser; this._focusUserInput (); } @@ -93,7 +96,10 @@ Vn.Login = new Class this.$('pass').value = ''; if (success) + { + localStorage.setItem ('hederaLastUser', this.$('user').value); this.signalEmit ('login'); + } else this._focusUserInput (); } @@ -130,7 +136,7 @@ Vn.Login = new Class social.appendChild (a); var img = document.createElement ('img'); - imt.src = 'image/social/'+ res.get ('icon'); + img.src = 'image/social/'+ res.get ('icon'); img.alt = res.get ('title'); img.title = res.get ('title'); a.appendChild (img); diff --git a/js/hedera/login.xml b/js/hedera/login.xml index 2f2d2014..ed3f51c8 100755 --- a/js/hedera/login.xml +++ b/js/hedera/login.xml @@ -50,32 +50,7 @@