Compatibilidad con tablets mejorada

This commit is contained in:
Juan Ferrer Toribio 2015-02-17 12:48:53 +01:00
parent 50ad4ad5ff
commit 77c9e9bde6
394 changed files with 428 additions and 17049 deletions

View File

@ -1 +0,0 @@
/etc/hedera-web/config.php

View File

@ -1,9 +0,0 @@
Package: hedera-web
Version: 1.0-4
Architecture: all
Maintainer: Juan Ferrer Toribio <juan@verdnatura.es>
Depends: apache2, php5-mysql
Section: misc
Priority: optional
Description: Verdnatura's web page
Verdnatura's web page.

View File

@ -1,4 +0,0 @@
#!/bin/bash
service apache2 reload

View File

@ -1,4 +0,0 @@
#!/bin/bash
service apache2 reload

View File

@ -1,9 +0,0 @@
Alias /hedera-web /usr/share/hedera-web/
<Directory /usr/share/hedera-web/>
Options Indexes
Options +FollowSymLinks
AllowOverride None
Order Allow,Deny
Allow From All
</Directory>

View File

@ -1,66 +0,0 @@
<?php
/**
* Configuration file. Be careful to respect the PHP syntax.
**/
$conf = array (
/**
* The default language.
**/
'defaultLang' => 'es'
/**
* Compatible browsers.
**/
,'browser' => array
(
'Firefox' => 4.0
,'Iceweasel' => 4.0
,'IE' => 10.0
,'Chrome' => 7.0
,'Opera' => 11.6
)
/**
* Database parameters.
**/
,'db' => array
(
'host' => 'db.verdnatura.es'
,'name' => 'hedera'
,'user' => 'root'
,'pass' => 'base64pass'
)
/**
* The guest user.
**/
,'guest' => array
(
'user' => 'visitor'
,'pass' => 'base64pass'
)
/**
* Whether to force the use of https on the client.
**/
,'https' => FALSE
/**
* The lifetime of the session cookie, in days.
**/
,'cookieLife' => 15
/**
* The module to load if none is specified.
**/
,'defaultModule' => 'home'
/**
* The directory where images are located.
**/
,'imageDir' => '/image/cache'
);
?>

View File

@ -1,5 +1,5 @@
Package: hedera-web Package: hedera-web
Version: 1.0-24 Version: 1.0-28
Architecture: all Architecture: all
Maintainer: Juan Ferrer Toribio <juan@verdnatura.es> Maintainer: Juan Ferrer Toribio <juan@verdnatura.es>
Depends: apache2, php5-mysql, php-vn-web Depends: apache2, php5-mysql, php-vn-web

View File

@ -6,12 +6,10 @@ $params = array
( (
'name' 'name'
,'surname' ,'surname'
,'pc'
,'phone'
,'email' ,'email'
,'message' ,'message'
,'address'
,'pc'
,'city'
,'phone'
,'captcha' ,'captcha'
); );

View File

@ -61,6 +61,6 @@ div.form-group
#captcha input #captcha input
{ {
margin-left: 1em; margin-left: 1em;
max-width: 10em; max-width: 8em;
} }

View File

@ -23,9 +23,9 @@
.new h2 .new h2
{ {
font-size: 1.3em; font-size: 1.6em;
color: black; color: black;
font-weight: bold; font-weight: normal;
} }
.new-info .new-info
{ {

View File

@ -23,9 +23,9 @@
.new h2 .new h2
{ {
font-size: 1.3em; font-size: 1.6em;
color: black; color: black;
font-weight: bold; font-weight: normal;
} }
.new-info .new-info
{ {

View File

@ -3,8 +3,15 @@ Vn.Catalog = new Class
({ ({
Extends: Vn.Module Extends: Vn.Module
,realmColor: null
,activate: function () ,activate: function ()
{ {
var model = this.get ('items');
model.setTableInfo ('m', 'order_row_view');
model.setFieldFlags ('id', Db.Conn.Flag.AI);
model.setFieldFlags ('Id_Article', Db.Conn.Flag.PRI_KEY);
$('basket-button').addEventListener ('click', this.basketClicked.bind (this)); $('basket-button').addEventListener ('click', this.basketClicked.bind (this));
$('catalog-menu-button').addEventListener ('click', this.showMenu.bind (this)); $('catalog-menu-button').addEventListener ('click', this.showMenu.bind (this));
$('catalog-menu').addEventListener ('click', this.onMenuClick.bind (this)); $('catalog-menu').addEventListener ('click', this.onMenuClick.bind (this));
@ -37,7 +44,10 @@ Vn.Catalog = new Class
,onRealmsReload: function (model, status) ,onRealmsReload: function (model, status)
{ {
if (status == Db.Model.Status.READY) if (status == Db.Model.Status.READY)
{
this.onRealmChanged (); this.onRealmChanged ();
this.onTypeChanged ();
}
} }
,onRealmChanged: function () ,onRealmChanged: function ()
@ -47,11 +57,9 @@ Vn.Catalog = new Class
var row = realms.search ('id', this.get ('realm').value); var row = realms.search ('id', this.get ('realm').value);
if (row != -1) if (row != -1)
color = '#'+ realms.get (row, 'color'); this.realmColor = '#'+ realms.get (row, 'color');
else else
color = null; this.realmColor = null;
$('realms-bar').style.backgroundColor = color;
} }
,onTypesReload: function (model, status) ,onTypesReload: function (model, status)
@ -70,7 +78,7 @@ Vn.Catalog = new Class
var color = null; var color = null;
if (this.get ('type').value) if (this.get ('type').value)
color = $('realms-bar').style.backgroundColor; color = this.realmColor;
$('catalog-header').style.backgroundColor = color; $('catalog-header').style.backgroundColor = color;

View File

@ -97,7 +97,6 @@
<vn-hash-link key="realm"/> <vn-hash-link key="realm"/>
</vn-param> </vn-param>
</htk-realm> </htk-realm>
<div id="realms-bar"/>
<div id="types-box"> <div id="types-box">
<htk-grid id="types-grid" empty-message="SelectFamily"> <htk-grid id="types-grid" empty-message="SelectFamily">
<db-model id="types-model"> <db-model id="types-model">

View File

@ -0,0 +1,13 @@
#catalog-menu-button
{
display: block;
}
#catalog-menu
{
display: none;
}
#catalog-center
{
right: 0;
}

View File

@ -50,14 +50,13 @@
float: left; float: left;
display: block; display: block;
background-color: white; background-color: white;
height: 2em; height: 2.2em;
padding: 0; padding: 0;
} }
#search-entry #search-entry
{ {
margin: 0; margin: 0;
border: none; border: none;
width: 11em;
width: 10em; width: 10em;
box-shadow: none; box-shadow: none;
} }
@ -67,7 +66,7 @@
} }
#catalog-search > img #catalog-search > img
{ {
margin: 0.3em; margin: 0.4em;
margin-top: 0; margin-top: 0;
vertical-align: middle; vertical-align: middle;
} }
@ -87,13 +86,6 @@
height: 1.8em; height: 1.8em;
} }
@media screen and (min-resolution: 100dpi)
{
#catalog-menu-button { display: block; }
#catalog-menu { display: none; }
#catalog-center { right: 0; }
}
/* Menu */ /* Menu */
#catalog-menu #catalog-menu
@ -115,14 +107,14 @@
} }
#catalog .form-group #catalog .form-group
{ {
margin: 1em; margin: 2em;
} }
#catalog .form-group select, #catalog .form-group select,
#catalog .form-group button #catalog .form-group button
{ {
display: block; display: block;
margin: 0 auto; margin: 0 auto;
width: 70%; width: 12em;
} }
/* Realms */ /* Realms */
@ -144,18 +136,13 @@
{ {
/* height: 4em; */ /* height: 4em; */
} }
#realms-bar
{
width: 100%;
height: 0.5em;
}
/* Types */ /* Types */
#types-box #types-box
{ {
position: absolute; position: absolute;
top: 14.4em; top: 17em;
bottom: 0em; bottom: 0em;
right: 0em; right: 0em;
left: 0em; left: 0em;
@ -200,7 +187,7 @@
#items-grid > thead > tr, #items-grid > thead > tr,
#realms-bar #realms-bar
{ {
background-color: #666; background-color: #777;
} }
#items-grid > thead th:hover #items-grid > thead th:hover
{ {

View File

@ -19,8 +19,8 @@
</db-model> </db-model>
<htk-column-button column="id" tip="EditNew" image="image/edit.svg" id="edit-new"/> <htk-column-button column="id" tip="EditNew" image="image/edit.svg" id="edit-new"/>
<htk-column-image column="id" directory="news" subdir="30x30" show-full="true" editable="true"/> <htk-column-image column="id" directory="news" subdir="30x30" show-full="true" editable="true"/>
<htk-column-text title="Author" column="Cliente"/>
<htk-column-text title="Title" column="title"/> <htk-column-text title="Title" column="title"/>
<htk-column-text title="Author" column="Cliente"/>
<htk-column-spin title="Priority" column="priority"/> <htk-column-spin title="Priority" column="priority"/>
</htk-grid> </htk-grid>
</div> </div>

View File

@ -0,0 +1,12 @@
/* Responsive */
@media screen and (max-device-width: 1200px) and (min-resolution: 100dpi) and (orientation: landscape)
{
* { font-size: 16pt; }
}
@media screen and (max-device-width: 800px) and (min-resolution: 100dpi)
{
* { font-size: 26pt; }
}

Binary file not shown.

View File

@ -9,14 +9,6 @@
{ {
* { font-size: 11pt; } * { font-size: 11pt; }
} }
@media screen and (max-device-width: 1200px) and (min-resolution: 100dpi) and (orientation: landscape)
{
* { font-size: 16pt; }
}
@media screen and (max-device-width: 800px) and (min-resolution: 100dpi)
{
* { font-size: 26pt; }
}
/* Global */ /* Global */
@ -112,16 +104,16 @@ select
{ {
background-color: white; background-color: white;
} }
input[type=text],
input[type=password]
{
height: 1.6em;
}
textarea textarea
{ {
height: 3.5em; height: 3.5em;
width: 20em; width: 20em;
} }
input[type=submit],
input[type=button]
{
background-color: #EEF;
}
input[type=text]:focus, input[type=text]:focus,
input[type=password]:focus, input[type=password]:focus,
textarea:focus textarea:focus
@ -129,19 +121,18 @@ textarea:focus
background-color: #EEF; background-color: #EEF;
border-color: #BBC; border-color: #BBC;
} }
input[type=submit]:hover,
input[type=button]:hover
{
cursor: pointer;
background-color: #DDE;
}
input[type=checkbox], input[type=checkbox],
input[type=radio] input[type=radio]
{ {
width: 0.8em; width: 0.8em;
height: 0.8em; height: 0.8em;
} }
button
/* Buttons */
button,
input[type=submit],
input[type=button]
{ {
border: none; border: none;
background-color: #009688; background-color: #009688;
@ -149,6 +140,13 @@ button
padding: 0.5em; padding: 0.5em;
cursor: pointer; cursor: pointer;
} }
button:hover,
input[type=submit]:hover,
input[type=button]:hover
{
cursor: pointer;
background-color: #076;
}
button.vn button.vn
{ {
border: none; border: none;
@ -175,8 +173,9 @@ button.vn:hover
background-color: white; background-color: white;
color: black; color: black;
text-align: left; text-align: left;
min-width: 8em; min-width: 9em;
min-height: 2.3em; min-height: 2.3em;
text-align: center;
} }
/* Float */ /* Float */
@ -205,8 +204,8 @@ div.box .header
div.box .header h1 div.box .header h1
{ {
text-align: left; text-align: left;
font-size: 1.5em; font-size: 1.6em;
line-height: 1.7em; line-height: 2em;
font-weight: normal; font-weight: normal;
display: inline; display: inline;
} }
@ -391,6 +390,11 @@ button.cell-button img
{ {
border-top: none /* 1px solid #CCD */; border-top: none /* 1px solid #CCD */;
} }
.calendar th.button:hover
{
cursor: pointer;
background-color: #076;
}
.calendar col .calendar col
{ {
width: 14.2%; width: 14.2%;
@ -405,8 +409,7 @@ button.cell-button img
padding-right: 0.5em; padding-right: 0.5em;
} }
.calendar td.highlight, .calendar td.highlight,
.calendar td:hover, .calendar td:hover
.button:hover
{ {
cursor: pointer; cursor: pointer;
background-color: #DDE; background-color: #DDE;
@ -442,32 +445,62 @@ img.editable
{ {
cursor: pointer; cursor: pointer;
} }
div.image-editor .htk-image-editor
{ {
width: 20em;
background-color: white; background-color: white;
border: 1px solid #999; margin: 0 auto;
border-radius: 0.1em; border-radius: 0.1em;
padding: 1.2em; box-shadow: 0 0 0.4em #AAA;
width: 35em;
} }
div.image-editor h3 .htk-image-editor h2
{ {
text-align: center; color: white;
padding-bottom: 1em; background-color: #009688;
text-align: left;
font-size: 1.3em;
line-height: 1.7em;
font-weight: normal;
padding: 0.6em 0.8em;
margin: 0;
} }
div.image-editor iframe .htk-image-editor iframe
{ {
display: none; display: none;
} }
div.image-editor button .htk-image-editor form
{ {
margin-left: 0.5em; padding: 1.5em;
margin-right: 0.5em;
} }
div.image-editor img .htk-image-editor .form-group
{
margin-bottom: 0.5em;
}
.htk-image-editor .form-group label
{
display: block;
margin-bottom: 0.3em;
}
.htk-image-editor .form-group input
{
width: 95%;
height: 1.8em;
}
.htk-image-editor .footer
{
margin-top: 1em;
text-align: center;
}
.htk-image-editor .footer img
{ {
visibility: hidden; visibility: hidden;
vertical-align: middle; vertical-align: middle;
padding-right: 1em; padding-right: 1em;
} }
.htk-image-editor .footer input
{
display: inline;
margin-left: 0.5em;
margin-right: 0.5em;
}

View File

@ -7,17 +7,19 @@ require_once ('vn/hedera/util.php');
use Vn\Hedera\Web; use Vn\Hedera\Web;
use Vn\Lib\Locale; use Vn\Lib\Locale;
Web::init (); try {
Web::init ();
if ($conf['https'] && (!isset ($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')) }
catch (Exception $e)
{ {
header ("Location: https://${_SERVER['SERVER_NAME']}${_SERVER['REQUEST_URI']}"); header ('Location: unavailable.html');
exit (0); exit (0);
} }
if (!Web::$sysConn->isOpen ()) if (!isset ($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on')
if (Web::$sysConn->getValue ('SELECT https FROM config'))
{ {
header ('Location: unavailable.html'); header ("Location: https://${_SERVER['SERVER_NAME']}${_SERVER['REQUEST_URI']}");
exit (0); exit (0);
} }
@ -56,11 +58,14 @@ if (!isset ($_SESSION['skipBrowser']) && $page != 'update-browser')
$_SESSION['skipBrowser'] = TRUE; $_SESSION['skipBrowser'] = TRUE;
} }
// Setting the version
setcookie ('hedera_version', $_SESSION['version']);
// Loading the requested page // Loading the requested page
$basePath = 'pages/'. $page; $basePath = 'pages/'. $page;
setcookie ('hedera_version', $_SESSION['version']);
header ('Content-Type: text/html; charset=utf-8'); header ('Content-Type: text/html; charset=utf-8');
if (file_exists ($basePath)) if (file_exists ($basePath))

View File

@ -189,7 +189,7 @@ Db.Conn.implement
this.signalEmit ('loading-changed', false); this.signalEmit ('loading-changed', false);
if (!success) if (!success)
error = new Vn.Error ('Conn', 'connError', _('ConnError')); error = new Vn.Error ('Http', 'connError', _('ConnError'));
else else
try { try {
var json = httpRequest.getJson (); var json = httpRequest.getJson ();
@ -232,7 +232,7 @@ Db.Conn.implement
} }
} }
catch (e) { catch (e) {
error = new Vn.Error ('Conn', 'badReply', e.message /*_('BadServerReply')*/); error = new Vn.Error ('Http', 'badReply', e.message);
} }
if (callback) if (callback)

View File

@ -624,7 +624,7 @@ Db.Model.implement
if (index) if (index)
{ {
if (index[value]) if (index[value] !== undefined)
return index[value]; return index[value];
return -1; return -1;

View File

@ -8,16 +8,11 @@ Htk.ImageEditor = new Class
,initialize: function () ,initialize: function ()
{ {
this.createElement ('div'); this.createElement ('div');
this.node.className = 'image-editor'; this.node.className = 'htk-image-editor';
var h3 = document.createElement ('h3'); var title = document.createElement ('h2');
h3.appendChild (document.createTextNode (_('UpdateImage'))); title.appendChild (document.createTextNode (_('UpdateImage')));
this.node.appendChild (h3); this.node.appendChild (title);
var iframe = document.createElement ('iframe');
iframe.name = 'image-editor';
iframe.addEventListener ('load', this.imageUploaded.bind (this, iframe));
this.node.appendChild (iframe);
var form = document.createElement ('form'); var form = document.createElement ('form');
form.method = 'post'; form.method = 'post';
@ -27,6 +22,52 @@ Htk.ImageEditor = new Class
form.addEventListener ('submit', this.formSubmit.bind (this)); form.addEventListener ('submit', this.formSubmit.bind (this));
this.node.appendChild (form); this.node.appendChild (form);
var div = document.createElement ('div');
div.className = 'form-group';
form.appendChild (div);
var label = document.createElement ('label');
label.appendChild (document.createTextNode (_('FileName') + ':'));
div.appendChild (label);
var nameInput = document.createElement ('input');
nameInput.type = 'text';
nameInput.name = 'name';
nameInput.addEventListener ('change', this.nameChanged.bind (this));
div.appendChild (nameInput);
var div = document.createElement ('div');
div.className = 'form-group';
form.appendChild (div);
var label = document.createElement ('label');
label.appendChild (document.createTextNode (_('File') + ':'));
div.appendChild (label);
var fileInput = document.createElement ('input');
fileInput.type = 'file';
fileInput.name = 'image';
div.appendChild (fileInput);
var div = document.createElement ('div');
div.className = 'footer';
form.appendChild (div);
var loader = document.createElement ('img');
loader.alt = _('Loading');
loader.src = 'image/loader-black.gif';
div.appendChild (loader);
var submitButton = document.createElement ('input');
submitButton.type = 'submit';
submitButton.appendChild (document.createTextNode (_('UploadFile')));
div.appendChild (submitButton);
var iframe = document.createElement ('iframe');
iframe.name = 'image-editor';
iframe.addEventListener ('load', this.imageUploaded.bind (this, iframe));
this.node.appendChild (iframe);
var schemaInput = document.createElement ('input'); var schemaInput = document.createElement ('input');
schemaInput.type = 'hidden'; schemaInput.type = 'hidden';
schemaInput.name = 'schema'; schemaInput.name = 'schema';
@ -38,64 +79,6 @@ Htk.ImageEditor = new Class
input.value = this.maxFileSize; input.value = this.maxFileSize;
form.appendChild (input); form.appendChild (input);
var table = document.createElement ('table');
table.cellSpacing = 5;
form.appendChild (table);
var tbody = document.createElement ('tbody');
table.appendChild (tbody);
var tr = document.createElement ('tr');
tbody.appendChild (tr);
var td = document.createElement ('td');
td.style.textAlign = 'right';
td.appendChild (document.createTextNode (_('FileName') + ':'));
tr.appendChild (td);
var td = document.createElement ('td');
tr.appendChild (td);
var nameInput = document.createElement ('input');
nameInput.type = 'text';
nameInput.name = 'name';
nameInput.addEventListener ('change', this.nameChanged.bind (this));
td.appendChild (nameInput);
var tr = document.createElement ('tr');
tbody.appendChild (tr);
var td = document.createElement ('td');
td.style.textAlign = 'right';
td.appendChild (document.createTextNode (_('File') + ':'));
tr.appendChild (td);
var td = document.createElement ('td');
tr.appendChild (td);
var fileInput = document.createElement ('input');
fileInput.type = 'file';
fileInput.name = 'image';
td.appendChild (fileInput);
var tr = document.createElement ('tr');
tbody.appendChild (tr);
var td = document.createElement ('td');
td.style.textAlign = 'center';
td.colSpan = 2;
tr.appendChild (td);
var loader = document.createElement ('img');
loader.alt = _('Loading');
loader.src = 'image/loader-black.gif';
td.appendChild (loader);
var submitButton = document.createElement ('input');
submitButton.type = 'submit';
submitButton.appendChild (document.createTextNode (_('UploadFile')));
td.appendChild (submitButton);
this.schemaInput = schemaInput; this.schemaInput = schemaInput;
this.fileInput = fileInput; this.fileInput = fileInput;
this.nameInput = nameInput; this.nameInput = nameInput;

View File

@ -28,16 +28,21 @@ Vn.Locale =
{ {
if (request.readyState != 4) if (request.readyState != 4)
return; return;
var success = false;
if (request.status == 200) if (request.status == 200)
try { {
this.add (eval ('('+ request.responseText +')')); try {
} this.add (eval ('('+ request.responseText +')'));
catch (e) { success = true;
console.log (e); }
} catch (e) {
console.log ('Locale: %s', e);
callback (); }
}
callback (success);
} }
,add: function (strings) ,add: function (strings)

View File

@ -90,7 +90,9 @@ var Vn =
includeData.callbacks.push (callback); includeData.callbacks.push (callback);
script.onload = script.onload =
this.jsLoaded.bind (this, includeData); this.jsLoaded.bind (this, includeData, true);
script.onerror =
this.jsLoaded.bind (this, includeData, false);
script.onreadystatechange = script.onreadystatechange =
this.jsStateChanged.bind (this, includeData); this.jsStateChanged.bind (this, includeData);
@ -109,17 +111,19 @@ var Vn =
,jsStateChanged: function (includeData) ,jsStateChanged: function (includeData)
{ {
console.log ('js: '+ includeData.script.readyState);
if (includeData.script.readyState == 'complete') if (includeData.script.readyState == 'complete')
this.jsLoaded (includeData); this.jsLoaded (includeData, true);
} }
,jsLoaded: function (includeData) ,jsLoaded: function (includeData, success)
{ {
if (includeData.loaded) if (includeData.loaded)
return; return;
for (var i = 0; i < includeData.callbacks.length; i++) for (var i = 0; i < includeData.callbacks.length; i++)
includeData.callbacks[i] (); includeData.callbacks[i] (success);
includeData.loaded = true; includeData.loaded = true;
includeData.callbacks = null; includeData.callbacks = null;
@ -133,14 +137,10 @@ var Vn =
,isMobile: function () ,isMobile: function ()
{ {
if (this.isMobileCached === null) if (this.isMobileCached === null)
this.isMobileCached = {
navigator.userAgent.match (/Android/i) var regExp = /(Android|webOS|iPhone|iPad|iPod|BlackBerry|Windows Phone)/i;
|| navigator.userAgent.match (/webOS/i) this.isMobileCached = navigator.userAgent.match (regExp);
|| navigator.userAgent.match (/iPhone/i) }
|| navigator.userAgent.match (/iPad/i)
|| navigator.userAgent.match (/iPod/i)
|| navigator.userAgent.match (/BlackBerry/i)
|| navigator.userAgent.match (/Windows Phone/i);
return this.isMobileCached; return this.isMobileCached;
} }

View File

@ -3,6 +3,17 @@
require_once ('global/metatags.php'); require_once ('global/metatags.php');
require_once ('js/vn/main.php'); require_once ('js/vn/main.php');
Vn\Hedera\Js::includeFile ('pages/login/login.js'); use Vn\Hedera\Js;
Js::includeFile ('pages/login/login.js');
Js::includeCss ('global/style.css');
Js::includeCss ('pages/login/style.css');
if (Js::isMobile ())
{
Js::includeCss ('global/mobile.css');
Js::includeCss ('pages/login/mobile.css');
}
?> ?>

View File

@ -3,17 +3,14 @@
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="user-scalable=no"/> <meta name="viewport" content="user-scalable=no"/>
<?php include ('pages/login/head.php') ?> <?php include ('pages/login/head.php') ?>
<link rel="shortcut icon" type="image/x-icon" href="image/favicon.ico"/> <link rel="shortcut icon" type="image/x-icon" href="image/favicon.ico"/>
<link rel="stylesheet" type="text/css" href="global/style.css"/>
<link rel="stylesheet" type="text/css" href="pages/login/style.css"/>
<title>Login - Verdnatura</title> <title>Login - Verdnatura</title>
</head> </head>
<body> <body>
<?php include ('global/analytics.php') ?>
<div id="header"> <div id="header">
<div> <div>
<a href="?page=web&amp;guest=true#!form=cms/about"><?=s('IWantToKnowMore')?></a> <a href="?page=web&amp;guest=true#!form=cms/about"><?=s('IWantToKnowMore')?></a>
@ -63,9 +60,9 @@
<img alt="YouTube" src="image/youtube.svg" title="YouTube"/> <img alt="YouTube" src="image/youtube.svg" title="YouTube"/>
</a> </a>
</div> </div>
</div>
</form> </form>
</div> </div>
</div>
</div> </div>
</body> </body>
</html> </html>

View File

@ -51,8 +51,9 @@ a
left: 0; left: 0;
right: 0; right: 0;
bottom: 0; bottom: 0;
background-image: url("background.png"); /* background-image: url("background.png");
background-repeat: repeat; background-repeat: repeat;
*/
} }
#column #column
{ {
@ -129,6 +130,7 @@ input[type=submit]
border: 1px solid #8B2; border: 1px solid #8B2;
height: 2.4em; height: 2.4em;
width: 8em; width: 8em;
color: #250;
} }
input[type=submit]:hover input[type=submit]:hover
{ {

View File

@ -8,4 +8,13 @@ require_once ('js/htk/main.php');
Js::includeFile ('pages/web/web.js'); Js::includeFile ('pages/web/web.js');
Js::includeFile ('pages/web/module.js'); Js::includeFile ('pages/web/module.js');
Js::includeCss ('global/style.css');
Js::includeCss ('pages/web/style.css');
if (Js::isMobile ())
{
Js::includeCss ('global/mobile.css');
Js::includeCss ('pages/web/mobile.css');
}
?> ?>

View File

@ -8,12 +8,9 @@
<?php include ('pages/web/head.php') ?> <?php include ('pages/web/head.php') ?>
<link rel="shortcut icon" type="image/x-icon" href="image/favicon.ico"/> <link rel="shortcut icon" type="image/x-icon" href="image/favicon.ico"/>
<link rel="stylesheet" type="text/css" href="global/style.css"/>
<link rel="stylesheet" type="text/css" href="pages/web/style.css?1"/>
<title>Verdnatura</title> <title>Verdnatura</title>
</head> </head>
<body> <body>
<?php include ('global/analytics.php') ?>
<div id="header"> <div id="header">
<div id="header-bar"> <div id="header-bar">
<button id="menu-button"> <button id="menu-button">

View File

@ -0,0 +1,22 @@
#menu-button
{
display: block;
}
#menu-box
{
display: none;
}
#form
{
left: 0;
}
ul.submenu
{
display: block;
position: relative;
border: none;
border-radius: 0;
background-color: white;
box-shadow: none;
}

View File

@ -251,20 +251,3 @@ ul.submenu a
overflow: auto; overflow: auto;
} }
@media screen and (min-resolution: 100dpi)
{
#menu-button { display: block; }
#menu-box { display: none; }
#form { left: 0; }
ul.submenu
{
display: block;
position: relative;
border: none;
border-radius: 0;
background-color: white;
box-shadow: none;
}
}

View File

@ -16,7 +16,6 @@ Vn.Web =
{ {
this.loadingCount = 0; this.loadingCount = 0;
this.loader = $('loader'); this.loader = $('loader');
this.formHolder = $('form'); this.formHolder = $('form');
this.hash = new Vn.Hash (); this.hash = new Vn.Hash ();
@ -274,20 +273,16 @@ Vn.Web =
,onFormChange: function () ,onFormChange: function ()
{ {
var formPath = this.hashLink.value; var formPath = this.hashLink.value;
this.openForm (formPath ? formPath : Vn.Config['default_form']); this.openForm (formPath ? formPath : Vn.Config['default_form'], null);
} }
,openForm: function (formPath) ,openForm: function (formPath, callback)
{ {
if (Vn.isMobile ()) if (Vn.isMobile ())
this.hideMenu (); this.hideMenu ();
this.requestedForm = formPath; this.requestedForm = formPath;
this.loadForm (formPath, null);
}
,loadForm: function (formPath, callback)
{
var formInfo = this.forms[formPath]; var formInfo = this.forms[formPath];
var path = 'forms/'+ formPath; var path = 'forms/'+ formPath;
@ -298,10 +293,19 @@ Vn.Web =
} }
if (this.activeCss) if (this.activeCss)
Vn.excludeCss (this.activeCss); {
Vn.excludeCss (this.activeCss +'/style.css');
if (Vn.isMobile ())
Vn.excludeCss (this.activeCss +'/mobile.css');
}
this.activeCss = path +'/style.css'; this.activeCss = path;
Vn.includeCss (this.activeCss);
Vn.includeCss (this.activeCss +'/style.css');
if (Vn.isMobile ())
Vn.includeCss (this.activeCss +'/mobile.css');
if (!formInfo) if (!formInfo)
{ {
@ -319,7 +323,9 @@ Vn.Web =
,klass: klass ,klass: klass
,localeReady: false ,localeReady: false
,jsReady: false ,jsReady: false
,uiReady: false
,xml: null ,xml: null
,error: false
,ready: false ,ready: false
,callbacks: [] ,callbacks: []
}; };
@ -353,47 +359,58 @@ Vn.Web =
if (callback) if (callback)
formInfo.callbacks.push (callback); formInfo.callbacks.push (callback);
if (formInfo.ready) if (formInfo.ready)
this.onFormDownload (formInfo); this.onFormReady (formInfo);
} }
,onFormLocaleReady: function (formInfo) ,onFormLocaleReady: function (formInfo, success)
{ {
formInfo.localeReady = true; formInfo.localeReady = true;
this.onFormDownload (formInfo); this.onFormReady (formInfo);
} }
,onFormJsReady: function (formInfo) ,onFormJsReady: function (formInfo, success)
{ {
formInfo.jsReady = true; formInfo.jsReady = true;
this.onFormDownload (formInfo); formInfo.error = !success;
this.onFormReady (formInfo);
} }
,onFormUiReady: function (formInfo, request) ,onFormUiReady: function (formInfo, request)
{ {
if (request.readyState != 4) if (request.readyState != 4)
return; return;
formInfo.uiReady = true;
if (request.status == 200) if (request.status == 200)
formInfo.xml = request; formInfo.xml = request;
else
formInfo.error = true;
this.onFormDownload (formInfo); this.onFormReady (formInfo);
} }
,onFormDownload: function (formInfo) ,onFormReady: function (formInfo)
{ {
if (!(formInfo.localeReady && formInfo.jsReady && formInfo.xml)) if (!(formInfo.localeReady && formInfo.jsReady && formInfo.uiReady))
return; return;
formInfo.ready = true; formInfo.ready = true;
if (formInfo.path == this.requestedForm) if (!formInfo.error)
try { {
var klass = eval (formInfo.klass); if (formInfo.path == this.requestedForm)
this.activeForm = new klass (this, formInfo); try {
this.activeForm.activate (); var klass = eval (formInfo.klass);
} this.activeForm = new klass (this, formInfo);
catch (e) { this.activeForm.activate ();
console.error (e); }
catch (e) {
console.error (e);
}
} }
else
console.error (_('ErrorDownloadingForm'));
var callbacks = formInfo.callbacks; var callbacks = formInfo.callbacks;
formInfo.callbacks = []; formInfo.callbacks = [];

View File

@ -8,9 +8,10 @@ use Vn\Rest;
use Vn\Hedera\Web; use Vn\Hedera\Web;
Rest\Service::init (); Rest\Service::init ();
Web::init ();
try { try {
Web::init ();
if (!Web::login ()) if (!Web::login ())
throw new Rest\Exception ('Auth', 'sessionExpired', s('SessionExpired')); throw new Rest\Exception ('Auth', 'sessionExpired', s('SessionExpired'));
@ -54,6 +55,8 @@ try {
else else
throw new Rest\Exception ('Rest', 'invalidAction', s('InvalidAction')); throw new Rest\Exception ('Rest', 'invalidAction', s('InvalidAction'));
} }
Web::deinit ();
} }
catch (Rest\Exception $e) catch (Rest\Exception $e)
{ {

View File

@ -23,10 +23,12 @@ class RestMod extends Rest\Module
{ {
$columns = $result->fetch_fields (); $columns = $result->fetch_fields ();
$resultMap = []; $resultMap =
$resultMap['data'] = []; [
$resultMap['field'] = []; 'data' => [],
'field' => []
];
for ($i = 0; $i < $result->field_count; $i++) for ($i = 0; $i < $result->field_count; $i++)
{ {
$column = $columns[$i]; $column = $columns[$i];
@ -60,6 +62,8 @@ class RestMod extends Rest\Module
default; default;
$type = TYPE_STRING; $type = TYPE_STRING;
} }
$default = $this->castValue ($column->def, $type);
$resultMap['field'][] = $resultMap['field'][] =
[ [
@ -67,54 +71,19 @@ class RestMod extends Rest\Module
'orgname' => $column->orgname, 'orgname' => $column->orgname,
'table' => $column->table, 'table' => $column->table,
'orgtable' => $column->orgtable, 'orgtable' => $column->orgtable,
'def' => $column->def, 'def' => $default,
'db' => $column->db, 'db' => $column->db,
'flags' => $column->flags, 'flags' => $column->flags,
'type' => $type 'type' => $type
]; ];
} }
$columns = $resultMap['field'];
while ($row = $result->fetch_row ()) while ($row = $result->fetch_row ())
{ {
for ($j = 0; $j < $result->field_count; $j++) for ($j = 0; $j < $result->field_count; $j++)
{ $this->castValue ($row[$j], $columns[$j]['type']);
$cell = &$row[$j];
if ($cell !== NULL)
switch ($columns[$j]->type)
{
case MYSQLI_TYPE_DATE:
case MYSQLI_TYPE_DATETIME:
case MYSQLI_TYPE_TIMESTAMP:
$cell = mktime
(
substr ($cell, 11 , 2)
,substr ($cell, 14 , 2)
,substr ($cell, 17 , 2)
,substr ($cell, 5 , 2)
,substr ($cell, 8 , 2)
,substr ($cell, 0 , 4)
);
break;
case MYSQLI_TYPE_BIT:
$cell = (bool) $cell;
break;
case MYSQLI_TYPE_TINY:
case MYSQLI_TYPE_SHORT:
case MYSQLI_TYPE_LONG:
case MYSQLI_TYPE_LONGLONG:
case MYSQLI_TYPE_INT24:
case MYSQLI_TYPE_YEAR:
$cell = (int) $cell;
break;
case MYSQLI_TYPE_FLOAT:
case MYSQLI_TYPE_DOUBLE:
case MYSQLI_TYPE_DECIMAL:
case MYSQLI_TYPE_NEWDECIMAL:
$cell = (float) $cell;
break;
}
}
$resultMap['data'][] = $row; $resultMap['data'][] = $row;
} }
@ -134,6 +103,35 @@ class RestMod extends Rest\Module
return $results; return $results;
} }
function castValue (&$value, $type)
{
if ($value !== NULL)
switch ($type)
{
case TYPE_BOOLEAN:
$value = (bool) $value;
break;
case TYPE_INTEGER:
$value = (int) $value;
break;
case TYPE_DOUBLE:
$value = (float) $value;
break;
case TYPE_DATE:
case TYPE_DATE_TIME:
$value = mktime
(
substr ($value, 11 , 2)
,substr ($value, 14 , 2)
,substr ($value, 17 , 2)
,substr ($value, 5 , 2)
,substr ($value, 8 , 2)
,substr ($value, 0 , 4)
);
break;
}
}
} }
?> ?>

View File

@ -1,27 +1,28 @@
<?php <?php
require_once ('vn/web/auth.php');
require_once ('vn/hedera/init.php'); require_once ('vn/hedera/init.php');
use Vn\Web\Auth;
// Update the visit info using browscap // Update the visit info using browscap
if (TRUE) Auth::getCredentials ();
exit (); $conn = new mysqli
$db = new mysqli
( (
$conf['db']['host'] $conf['db']['host']
,$conf['db']['user'] ,Auth::getUser ()
,base64_decode ($conf['db']['pass']) ,Auth::getPassword ()
,$conf['db']['schema'] ,$conf['db']['schema']
); );
if ($db->connect_error) if ($conn->connect_error)
exit ($db->connect_error); exit ($conn->connect_error);
$result = $db->query ("SELECT id, agent FROM visit_agent " $result = $conn->query ("SELECT id, agent FROM visit_agent "
."WHERE version = '0.0' OR platform = 'unknown' OR cookies IS NULL ORDER BY id DESC"); ."WHERE version = '0.0' OR platform = 'unknown' OR cookies IS NULL ORDER BY id DESC");
$stmt = $db->prepare ( $stmt = $conn->prepare (
'UPDATE visit_agent SET platform = ?, browser = ?, version = ?, javascript = ?, cookies = ? WHERE id = ?'); 'UPDATE visit_agent SET platform = ?, browser = ?, version = ?, javascript = ?, cookies = ? WHERE id = ?');
if ($result && $stmt) if ($result && $stmt)
@ -40,7 +41,7 @@ if ($result && $stmt)
while ($row = $result->fetch_assoc ()) while ($row = $result->fetch_assoc ())
{ {
echo sprintf ("Processing row: %d\n", $row['id']); echo sprintf ("Processing row: %d\n", $row['id']);
$info = get_browser ($row['agent']); $info = get_browser ($row['agent']);
$platform = $info->platform; $platform = $info->platform;
$browser = $info->browser; $browser = $info->browser;
@ -56,7 +57,10 @@ if ($stmt)
$stmt->close (); $stmt->close ();
if ($result) if ($result)
$result->free (); $result->free ();
if ($conn->errno)
exit ($conn->error);
$db->close (); $conn->close ();
?> ?>

View File

@ -4,6 +4,8 @@ namespace Vn\Hedera;
class Js class Js
{ {
static $isMobile = NULL;
static function includeFile ($fileName) static function includeFile ($fileName)
{ {
echo '<script type="text/javascript" src="'.$fileName.'?'. $_SESSION['version'] .'"></script>'."\n\t"; echo '<script type="text/javascript" src="'.$fileName.'?'. $_SESSION['version'] .'"></script>'."\n\t";
@ -21,6 +23,22 @@ class Js
for ($i = 1; $i < count ($args); $i++) for ($i = 1; $i < count ($args); $i++)
self::includeFile ('js/'.$libName.'/'.$args[$i].'.js'); self::includeFile ('js/'.$libName.'/'.$args[$i].'.js');
} }
static function includeCss ($fileName)
{
echo '<link rel="stylesheet" type="text/css" href="'.$fileName.'?'. $_SESSION['version'] .'"/>'."\n\t";
}
static function isMobile ()
{
if (self::$isMobile === NULL)
{
$re = '/(Android|webOS|iPhone|iPad|iPod|BlackBerry|Windows Phone)/i';
self::$isMobile = preg_match ($re, $_SERVER['HTTP_USER_AGENT']);
}
return self::$isMobile;
}
} }
?> ?>

View File

@ -7,7 +7,7 @@ function checkToken ($token)
return preg_match ('/^[\w\-]+$/', $token); return preg_match ('/^[\w\-]+$/', $token);
} }
function ifNull ($map, $key) function nullIf ($map, $key)
{ {
return isset ($map[$key]) ? $map[$key] : NULL; return isset ($map[$key]) ? $map[$key] : NULL;
} }

View File

@ -15,43 +15,31 @@ use Vn\Web\Auth;
class Web class Web
{ {
static $sysConn; static $sysConn;
static $conn; static $conn = NULL;
static $newAccess = FALSE;
static function init () static function init ()
{ {
global $conf; global $conf;
session_start (); session_start ();
// Setting the locale
Locale::init ();
// Openning the main database connection
self::$sysConn = new Conn (); self::$sysConn = new Conn ();
$sysConn = self::$sysConn; self::$sysConn->open (
$sysConn->open (
'p:'. $conf['db']['host'] 'p:'. $conf['db']['host']
,$conf['db']['user'] ,$conf['db']['user']
,base64_decode ($conf['db']['pass']) ,base64_decode ($conf['db']['pass'])
,$conf['db']['schema'] ,$conf['db']['schema']
); );
self::$conn = new Conn ();
// Setting the locale
Locale::init ();
// Loading global configuration
if (!$sysConn->isOpen ())
return;
$dbConf = $sysConn->getRow (
'SELECT default_lang, https, cookie_life, guest_user, guest_pass FROM config'
);
$conf = array_merge ($conf, $dbConf);
// Setting the version // Setting the version
$_SESSION['version'] = $sysConn->getValue ('SELECT version FROM version LIMIT 1'); $_SESSION['version'] = Web::$sysConn->getValue ('SELECT version FROM version');
// Registering the visit // Registering the visit
@ -72,18 +60,18 @@ class Web
if (isset ($_SERVER['REMOTE_ADDR'])) if (isset ($_SERVER['REMOTE_ADDR']))
$ip = ip2long ($_SERVER['REMOTE_ADDR']); $ip = ip2long ($_SERVER['REMOTE_ADDR']);
$row = $sysConn->getRow ( $row = self::$sysConn->getRow (
'CALL visit_register (#, #, #, #, #, #, #, #, #)', 'CALL visit_register (#, #, #, #, #, #, #, #, #)',
[ [
ifNull ($_COOKIE, 'hedera_visit') nullIf ($_COOKIE, 'hedera_visit')
,ifNull ($browser, 'platform') ,nullIf ($browser, 'platform')
,ifNull ($browser, 'browser') ,nullIf ($browser, 'browser')
,ifNull ($browser, 'version') ,nullIf ($browser, 'version')
,ifNull ($browser, 'javascript') ,nullIf ($browser, 'javascript')
,ifNull ($browser, 'cookies') ,nullIf ($browser, 'cookies')
,isset ($agent) ? $agent : NULL ,isset ($agent) ? $agent : NULL
,isset ($ip) && $ip ? $ip : NULL ,isset ($ip) && $ip ? $ip : NULL
,ifNull ($_SERVER, 'HTTP_REFERER') ,nullIf ($_SERVER, 'HTTP_REFERER')
] ]
); );
@ -91,7 +79,6 @@ class Web
{ {
setcookie ('hedera_visit', $row['visit'], time () + 31536000); // 1 Year setcookie ('hedera_visit', $row['visit'], time () + 31536000); // 1 Year
$_SESSION['access'] = $row['access']; $_SESSION['access'] = $row['access'];
self::$newAccess = TRUE;
} }
else else
$_SESSION['skipVisit'] = TRUE; $_SESSION['skipVisit'] = TRUE;
@ -128,23 +115,19 @@ class Web
try { try {
Auth::getCredentials (); Auth::getCredentials ();
self::$conn = new Conn ();
self::$conn->open ( self::$conn->open (
$conf['db']['host'] $conf['db']['host']
,Auth::getUser () ,Auth::getUser ()
,Auth::getPassword () ,Auth::getPassword ()
,$conf['db']['schema'] ,$conf['db']['schema']
); );
Auth::login ($useCookies);
$row = self::$conn->getRow ( Auth::login ($useCookies);
'SELECT account.user_get_id () user, CONNECTION_ID() conn');
if (!$wasLoged)
unset ($_SESSION['visitUser']);
} }
catch (\Exception $e) catch (\Exception $e)
{ {
$row = NULL;
$success = FALSE; $success = FALSE;
} }
@ -152,13 +135,24 @@ class Web
if (isset ($_SESSION['access'])) if (isset ($_SESSION['access']))
{ {
$row = NULL;
if ($success)
{
if (!$wasLoged)
unset ($_SESSION['visitUser']);
$row = self::$conn->getRow (
'SELECT account.user_get_id () user, CONNECTION_ID() conn');
}
$_SESSION['visitUser'] = self::$sysConn->getValue ( $_SESSION['visitUser'] = self::$sysConn->getValue (
'CALL visit_user (#, #, #, #, #)', 'CALL visit_user (#, #, #, #, #)',
[ [
$_SESSION['access'] $_SESSION['access']
,ifNull ($_SESSION, 'visitUser') ,nullIf ($_SESSION, 'visitUser')
,ifNull ($row, 'user') ,nullIf ($row, 'user')
,ifNull ($row, 'conn') ,nullIf ($row, 'conn')
,session_id () ,session_id ()
] ]
); );
@ -177,10 +171,14 @@ class Web
,[session_id ()] ,[session_id ()]
); );
$_SESSION['visitUser'] = ifNull ($_SESSION, 'visitUnknown'); $_SESSION['visitUser'] = nullIf ($_SESSION, 'visitUnknown');
self::$conn->close ();
Auth::logout (); Auth::logout ();
if (self::$conn)
{
self::$conn->close ();
self::$conn = NULL;
}
} }
} }

View File

@ -1,14 +0,0 @@
<Files *.css>
SetOutputFilter DEFLATE
</Files>
<Files *.js>
SetOutputFilter DEFLATE
</Files>
<Files *.php>
SetOutputFilter DEFLATE
</Files>
<FilesMatch "\.(ttf|otf|eot|woff)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>

View File

@ -1,54 +0,0 @@
<?php
require_once ('php/web/hedera.php');
require_once ('php/web/json.php');
Hedera::init ();
JsonLib::init ();
if (Hedera::login ())
{
// Checking the client version
if (isset ($_COOKIE['hedera_version']))
{
$clientVersion = $_COOKIE['hedera_version'];
set_type ($clientVersion, TYPE_DOUBLE);
if ($clientVersion < $_SESSION['version'])
{
$row = Hedera::$sysConn->getRow ('SELECT critical, changelog FROM version LIMIT 1');
if (!$row || $row['critical'])
Error::trigger ('Version', 'criticalVersion', $row['changelog']);
else
Error::trigger ('Version', 'newVersion', $row['changelog']);
}
}
// Getting the action
$action = NULL;
if (isset ($_REQUEST['action']))
$action = $_REQUEST['action'];
if ($action && checkToken ($action))
{
$actionFile = 'ajax/'. $action .'.php';
if (file_exists ($actionFile))
{
Vn\Locale::loadFile ('ajax/'. $action);
require_once ($actionFile);
actionActivate (Hedera::$conn);
}
else
Error::trigger ('Ajax', 'invalidAction', s('InvalidAction'));
}
}
JsonLib::sendReply ();
Hedera::deinit ();
?>

View File

@ -1,179 +0,0 @@
<?php
const IMG_MAX_SIZE = 3;
const IMG_URL_BASE = '/var/www/image/cache';
const IMG_URL_FULL = 'full/';
const IMG_URL_ICON = 'icon/';
const IMG_FULL_HEIGHT = 650;
const IMG_FULL_WIDTH = 750;
const IMG_ICON_SIZE = 30;
function actionActivate ($conn)
{
$data = FALSE;
$query = "SELECT r.name = 'employee' "
.'FROM role r JOIN user_role u ON r.id = u.role_id '
.'WHERE u.user_id = account.user_get_id ()';
if (!$conn->getValue ($query))
JsonLib::setError ('Image', 'permissionDenied', s('PermissionDenied'));
else if (!isset ($_REQUEST['name']) || !isset ($_REQUEST['directory']))
JsonLib::setError ('Image', 'comError', s('ComError'));
else if (!(isset ($_FILES['image']['name']) && $_FILES['image']['name'] != ''))
JsonLib::setError ('Image', 'fileNotChoosed', s('FileNotChoosed'));
else if ($_FILES['image']['error'] != 0)
JsonLib::setError ('Image', 'uploadError', s('FileUploadError'));
else if ($_FILES['image']['size'] > IMG_MAX_SIZE * 1048576)
JsonLib::setError ('Image', 'fileSizeError', sprintf (s('FileSizeError'), IMG_MAX_SIZE));
else
{
$name = $_REQUEST['name'];
$directory = $_REQUEST['directory'];
$exp = '/[^a-z0-9_]/';
if (preg_match ($exp, $name) === 0 && preg_match ($exp, $directory) === 0)
{
$img = & $_FILES['image'];
$data = TRUE;
switch ($img['type'])
{
case 'image/png':
$image = imagecreatefrompng ($img['tmp_name']);
break;
case 'image/jpeg':
$image = imagecreatefromjpeg ($img['tmp_name']);
break;
case 'image/gif':
$image = imagecreatefromgif ($img['tmp_name']);
break;
default:
JsonLib::setError ('Image', 'badFileFormat', s('BadFileFormat'));
$data = FALSE;
}
}
else
JsonLib::setError ('Image', 'badFileName', s('BadFileName'));
if ($data)
{
$data = FALSE;
if (!$image)
JsonLib::setError ('Image', 'openError', s('ImageOpenError'));
else
{
list ($width, $height) = getimagesize ($img['tmp_name']);
$n = -1;
$max_height = array ();
$max_width = array ();
$url = array ();
++$n;
$max_height[$n] = IMG_ICON_SIZE;
$max_width[$n] = IMG_ICON_SIZE;
$url[$n] = IMG_URL_ICON;
++$n;
$max_height[$n] = IMG_FULL_HEIGHT;
$max_width[$n] = IMG_FULL_WIDTH;
$url[$n] = IMG_URL_FULL;
for ($n = 0; $n < count ($url); $n++)
{
$reduce = FALSE;
$w = $width;
$h = $height;
if ($h > $max_height[$n])
{
$reduce = $h / $max_height[$n];
$h = $max_height[$n];
$w = (int) ($w / $reduce);
}
if ($w > $max_width[$n])
{
$reduce = $w / $max_width[$n];
$w = $max_width[$n];
$h = (int) ($h / $reduce);
}
if ($reduce !== FALSE)
{
$image_new = imagecreatetruecolor ($w, $h);
imagecopyresized ($image_new, $image, 0, 0, 0, 0, $w, $h, $width, $height);
}
else
$image_new = $image;
imagealphablending ($image_new, FALSE);
imagesavealpha ($image_new, TRUE);
$dest_url = IMG_URL_BASE .'/'. $directory . '/' . $url[$n] . $name . '.png';
$data = imagepng ($image_new, $dest_url);
if (!$data)
JsonLib::setError ('Image', 'saveError', sprintf (s('FileSaveError'), $dest_url));
}
}
}
unlink ($img['tmp_name']);
}
JsonLib::$encoding = JsonLib::ENCODING_HTML;
JsonLib::setData ($data);
}
/*
// Script to reduce and change format for all images
define ('IMG_DIR_BASE', '/var/www/test/image/');
define ('IMG_DIR_OLD', IMG_DIR_BASE.'gallery/');
define ('IMG_DIR_NEW', IMG_DIR_BASE.'icon/');
define ('IMG_SIZE', 85);
if (TRUE)
{
$directorio = opendir (IMG_DIR_OLD);
$n = 1;
while ($filename = readdir ($directorio))
{
switch (strtolower(substr ($filename, -3, 3)))
{
case 'jpg':
$image = imagecreatefromjpeg (IMG_DIR_OLD.$filename);
break;
case 'png':
$image = imagecreatefrompng (IMG_DIR_OLD.$filename);
break;
}
if (isset ($image))
{
$n++;
list ($width, $height) = getimagesize (IMG_DIR_OLD.$filename);
$siz_max = ($width > $height) ? $width : $height;
$percent = ($siz_max > IMG_SIZE) ? IMG_SIZE / $siz_max : 1;
$width_new = $width * $percent;
$height_new = $height * $percent;
$image_new = imagecreatetruecolor ($width_new, $height_new);
imagecopyresized ($image_new, $image, 0, 0, 0, 0, $width_new, $height_new, $width, $height);
imagesavealpha ($image_new, TRUE);
imagepng ($image_new, IMG_DIR_NEW.substr ($filename, 0, -4).'.png');
}
}
JsonLib::setError ('Image', 'imagesResized', s('ImagesResized'));
}
*/
?>

View File

@ -1,8 +0,0 @@
<?php
function actionActivate ($conn)
{
JsonLib::setData (TRUE);
}
?>

View File

@ -1,9 +0,0 @@
<?php
function actionActivate ($conn)
{
Auth::logout ($conn);
JsonLib::setData (TRUE);
}
?>

View File

@ -1,88 +0,0 @@
<?php
class JsonResult
{
var $field;
var $data;
}
function actionActivate ($conn)
{
if (isset ($_REQUEST['sql']) && $_REQUEST['sql'] != '')
{
$results = array ();
if ($conn->multiQuery ($_REQUEST['sql']))
do {
$result = $conn->storeResult ();
if ($result !== FALSE)
{
$jsonResult = new JsonResult ();
$columns = $result->fetch_fields ();
$jsonResult->data = array ();
$jsonResult->field = $columns;
for ($i = 0; $row = $result->fetch_row (); $i++)
{
for ($j = 0; $j < $result->field_count; $j++)
{
$cell = & $row[$j];
if ($cell != NULL)
{
switch ($columns[$j]->type)
{
case MYSQLI_TYPE_DATE:
case MYSQLI_TYPE_DATETIME:
case MYSQLI_TYPE_TIMESTAMP:
$cell = mktime
(
substr ($cell, 11 , 2)
,substr ($cell, 14 , 2)
,substr ($cell, 17 , 2)
,substr ($cell, 5 , 2)
,substr ($cell, 8 , 2)
,substr ($cell, 0 , 4)
);
break;
case MYSQLI_TYPE_BIT:
set_type ($cell, TYPE_BOOLEAN);
break;
case MYSQLI_TYPE_TINY:
case MYSQLI_TYPE_SHORT:
case MYSQLI_TYPE_LONG:
case MYSQLI_TYPE_LONGLONG:
case MYSQLI_TYPE_INT24:
case MYSQLI_TYPE_YEAR:
set_type ($cell, TYPE_INTEGER);
break;
case MYSQLI_TYPE_FLOAT:
case MYSQLI_TYPE_DOUBLE:
case MYSQLI_TYPE_DECIMAL:
case MYSQLI_TYPE_NEWDECIMAL:
set_type ($cell, TYPE_DOUBLE);
break;
}
}
}
$jsonResult->data[$i] = $row;
}
$results[] = $jsonResult;
$result->free ();
}
else
$results[] = TRUE;
}
while ($conn->moreResults () && $conn->nextResult ());
JsonLib::setData ($results);
}
else
JsonLib::setError ('Query', 'emptyQuery', s('EmptyQuery'));
}
?>

View File

@ -1,16 +0,0 @@
Copyright (C) 2013 - Juan Ferrer Toribio
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this program; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.

View File

@ -1,9 +0,0 @@
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-49049601-1', 'verdnatura.es');
ga('send', 'pageview');
</script>

View File

@ -1,13 +0,0 @@
<?php
if ($result = Hedera::$sysConn->query ('SELECT name, content FROM metatag'))
{
echo '<meta name="content-language" content="'.$_SESSION['lang'].'"/>'."\n\t";
while ($row = $result->fetch_assoc ())
echo '<meta name="'.$row['name'].'" content="'.$row['content'].'"/>'."\n\t";
$result->free ();
}
?>

View File

@ -1,12 +0,0 @@
/* Global */
@font-face {
font-family: 'Open Sans';
src: url(opensans.ttf) format('truetype');
}
*
{
font-size: 13px;
font-family: 'Open Sans', 'Verdana', 'Sans';
}

View File

@ -1,321 +0,0 @@
/* Global */
@font-face {
font-family: 'Open Sans';
src: url(opensans.ttf) format('truetype');
}
body
{
margin: 0px;
}
body,
label,
button,
input,
textarea
{
font-size: 13px;
font-family: 'Open Sans', 'Verdana', 'Sans';
}
iframe
{
border: 0px;
}
fieldset,
div
{
margin: 0px;
}
form
{
padding: 0px;
margin: 0px;
}
table
{
width: 100%;
}
a:link,
a:visited,
a:active
{
color: #000;
text-decoration: none;
}
a:hover
{
text-decoration: none;
}
a img
{
padding: 1px;
border: 1px solid #EEE;
border-color: transparent;
}
a img:hover
{
border-color: #999;
}
h1, h2, h3, h4, h5, h6
{
margin: 0px;
padding: 2px;
}
h1
{
font-size: 22px;
}
h2
{
font-size: 20px;
}
p
{
margin: 0px;
margin-top: 16px;
margin-bottom: 16px;
}
/* Inputs */
input,
textarea,
button
{
border: 1px solid #CCD;
margin: 2px;
padding: 4px;
border-radius: 2px;
/* box-shadow: 0px 2px 2px #AAA; */
}
textarea
{
height: 40px;
width: 200px;
}
input[type=submit],
input[type=button],
button
{
background-color: #EEF;
margin: 6px;
padding: 4px;
}
input[type=text]:focus,
input[type=password]:focus,
textarea:focus
{
background-color: #EEF;
border-color: #BBC;
}
input[type=submit]:hover,
input[type=button]:hover,
button:hover
{
cursor: pointer;
background-color: #DDE;
}
/* Grid */
table.grid
{
width: 95%;
margin: auto;
border-collapse: collapse;
text-align: center;
margin-bottom: 15px;
}
table.grid thead tr,
table.grid tfoot tr
{
/* background-color: #C0CCB3;
background: url(image/gradient.png) repeat-x scroll 0;
*/
background-color: #EEF;
border: 1px solid #CCD;
color: black;
font-weight: bold;
vertical-align: middle;
text-align: center;
height: 30px;
}
table.grid thead th
{
cursor: pointer;
}
table.grid thead th:hover
{
background-color: #DDE;
}
table.grid tr
{
height: 35px;
}
table.grid tfoot a,
table.grid thead a
{
color: black;
}
table.grid tr.pair-row
{
background-color: transparent;
}
td.grid-message
{
height: 80px;
}
td.grid-message img
{
vertical-align: middle;
padding: 10px;
}
table.grid tbody td
{
padding-right: 8px;
padding-left: 8px;
}
input.cell-spin
{
width: 25px;
text-align: right;
}
/* Calendar */
.calendar
{
width: 220px;
background-color: white;
border: 1px solid #CCD;
border-radius: 2px;
box-shadow: 0px 2px 2px #AAA;
}
.calendar table
{
border-collapse: collapse;
}
.calendar thead tr,
.calendar tfoot tr
{
background-color: #EEF;
color: black;
font-weight: normal;
vertical-align: middle;
text-align: center;
height: 30px;
}
.calendar thead tr
{
border-bottom: 1px solid #CCD;
}
.calendar tfoot tr
{
border-top: 1px solid #CCD;
}
.calendar col
{
width: 14.2%;
}
.calendar tr
{
height: 22px;
}
.calendar tbody td
{
text-align: right;
padding-right: 6px;
}
.calendar td.highlight,
.calendar td:hover,
.button:hover
{
cursor: pointer;
background-color: #DDE;
}
/* Date chooser */
.date-chooser button
{
margin: 0px;
margin-right: 8px;
}
/* Full image */
div.full-image
{
position: fixed;
background-color: #FFF;
text-align: center;
border: 1px solid #999;
border-radius: 2px;
z-index: 2;
}
div.image-loader
{
position: fixed;
background-color: #FFF;
border: 1px solid #999;
border-radius: 2px;
z-index: 3;
}
div.image-loader img
{
padding: 10px;
}
/* Image editor */
img.editable
{
cursor: pointer;
}
div.image-editor
{
background-color: #FFF;
border: 1px solid #999;
border-radius: 2px;
padding: 12px;
width: 400px;
}
div.image-editor h3
{
text-align: center;
padding-bottom: 10px;
}
div.image-editor iframe
{
display: none;
}
div.image-editor button
{
margin-left: 5px;
margin-right: 5px;
}
div.image-editor img
{
visibility: hidden;
vertical-align: middle;
padding-right: 10px;
}
/* Form */
table.form
{
border-collapse: separate;
border-spacing: 4px;
}
table.form td.label
{
text-align: right;
}
table.form tr
{
height: 35px;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 597 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 590 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 825 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 708 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 790 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 935 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 397 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 784 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 141 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 984 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 965 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 795 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1005 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 290 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 786 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 510 B

View File

@ -1,73 +0,0 @@
<?php
require_once ('php/web/hedera.php');
require_once ('php/web/js.php');
Hedera::init ();
if ($conf['https'] && (!isset ($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on'))
{
header ('Location: https://'.$_SERVER['SERVER_NAME']);
exit (0);
}
if (!Hedera::$sysConn->isOpen ())
{
header ('Location: unavailable.html');
exit (0);
}
// Getting the section
if (isset ($_GET['section']) && checkToken ($_GET['section']))
$section = $_GET['section'];
else
$section = 'login';
// Checking the browser version
if (!isset ($_SESSION['skipBrowser']) && $section != 'update-browser')
{
$updateBrowser = FALSE;
if (!isset ($_GET['skipBrowser'])
&& ($browser = get_browser ($_SERVER['HTTP_USER_AGENT'])))
{
$browserVersion = $browser->version;
set_type ($browserVersion, TYPE_DOUBLE);
$updateBrowser = isset ($conf['browser'][$browser->browser])
&& $browserVersion < $conf['browser'][$browser->browser];
}
if ($updateBrowser)
{
header ('Location: ?section=update-browser');
exit (0);
}
else
$_SESSION['skipBrowser'] = TRUE;
}
// Loading the section
$basePath = 'sections/'. $section;
setcookie ('hedera_version', $_SESSION['version']);
header ('Content-Type: text/html;charset=utf-8');
if (file_exists ($basePath))
{
Vn\Locale::loadFile ($basePath);
$phpFile = $basePath .'/'. $section .'.php';
if (file_exists ($phpFile))
require ($phpFile);
require ($basePath .'/html.php');
}
Hedera::deinit ();
?>

View File

@ -1,59 +0,0 @@
/**
* Computes a sum of data in the model.
**/
Db.CalcSum = new Class
({
Extends: Db.Calc
,Tag: 'db-calc-sum'
,getRowValue: function (row)
{
var value;
if (this._func)
{
this.form.row = row;
value = this._func (this.form);
}
else
value = this._model.getByIndex (row, this.columnIndex);
return value;
}
,before: function (row)
{
var value = this.getRowValue (row)
if (value !== null)
{
this.sum -= value;
this.numbersCount--;
}
}
,after: function (row)
{
var value = this.getRowValue (row);
if (value !== null)
{
this.sum += value;
this.numbersCount++;
}
}
,init: function ()
{
this.sum = 0;
this.numbersCount = 0;
}
,done: function ()
{
if (this.numbersCount > 0)
this.value = this.sum;
else
this.value = null;
}
});

View File

@ -1,149 +0,0 @@
/**
* Interface for handle foreach operations on the model.
**/
Db.Calc = new Class
({
Extends: Vn.Param
,Tag: 'db-calc'
,Properties:
{
model:
{
type: Db.Model
,set: function (x)
{
this.link ({_model: x},
{
'status-changed': this.onModelChange
,'row-deleted-before': this.onRowDeleteBefore
,'row-updated': this.onRowUpdate
,'row-updated-before': this.onRowUpdateBefore
,'row-inserted': this.onRowInsert
});
this.form = new Db.Form ({model: x});
}
,get: function ()
{
return this._model;
}
},
columnIndex:
{
type: Number
,set: function (x)
{
this.reset ();
this._columnIndex = x;
this.onModelChange ();
}
,get: function ()
{
return this._columnIndex;
}
},
columnName:
{
type: String
,set: function (x)
{
this.reset ();
this._columnName = x;
this.onModelChange ();
}
,get: function ()
{
return this._columnName;
}
},
func:
{
type: Function
,set: function (x)
{
this.reset ();
this._func = x;
this.onModelChange ();
}
,get: function ()
{
return this._func;
}
}
}
,_model: null
,reset: function ()
{
delete this._columnIndex;
delete this._columnName;
delete this._func;
}
,onModelChange: function ()
{
this.init ();
if (this._model)
{
if (this._model.ready && this._columnName)
this._columnIndex = this._model.getColumnIndex (this._columnName);
var rows = this._model.numRows;
for (var i = 0; i < rows; i++)
this.after (i);
}
this.done ();
}
,onRowInsert: function (model, row)
{
this.after (row);
this.done ();
}
,onRowUpdateBefore: function (model, row)
{
this.before (row);
}
,onRowUpdate: function (model, row)
{
this.after (row);
this.done ();
}
,onRowDeleteBefore: function (model, row)
{
this.before (row);
this.done ();
}
/**
* Called before each update or delete row operation.
* You don't need to define it if model isn't updatable.
*
* @param {integer} row The row number
**/
,before: function (row) {}
/**
* Called after each update or insert row operation.
*
* @param {integer} row The row number
**/
,after: function (row) {}
/**
* Called before each model refresh.
**/
,init: function () {}
/**
* Called when an operation in the model is complete.
**/
,done: function () {}
});

View File

@ -1,241 +0,0 @@
/**
* Simulates a connection to a database by making asynchronous http requests to
* a remote PHP script 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.
**/
Db.Conn = new Class ().extend
({
Flag:
{
NOT_NULL : 1
,PRI_KEY : 2
,AI : 512 | 2 | 1
}
,Type:
{
TIMESTAMP : 7
,DATE : 10
,DATE_TIME : 12
}
});
Db.Conn.implement
({
Extends: Vn.Object
,connected: false
,requestsCount: 0
/**
* Initilizes the connection object.
**/
,initialize: function ()
{
this.parent ();
}
/**
* Opens the connection to the database.
*
* @param {string} user The user name
* @param {String} password The user password
* @param {Boolean} remember Specifies if the user should be remembered
* @param {Function} openCallback The function to call when operation is done
**/
,open: function (user, pass, remember, openCallback)
{
this.signalEmit ('loading-changed', true);
var request = new Db.HttpRequest ();
request.add ({'action': 'login'});
if (user != null)
{
request.add
({
'user': user
,'password': pass
,'remember': remember
});
}
request.send ('ajax.php',
this.opened.bind (this, request, openCallback));
}
/*
* Called when open operation is done.
*/
,opened: function (request, openCallback, success)
{
var openSuccess = false;
if (success)
try {
var json = request.getJson ();
openSuccess = true /* json.data */;
}
catch (e) {}
if (openSuccess)
this.connected = true;
this.signalEmit ('loading-changed', false);
if (openCallback)
openCallback (this, openSuccess);
}
/**
* Closes the connection to the database.
*
* @param {Function} closeCallback The function to call when operation is done
**/
,close: function (closeCallback)
{
this.signalEmit ('loading-changed', true);
var request = new Db.HttpRequest ();
request.addValue ({'action': 'close'});
request.send ('ajax.php',
this.closed.bind (this, closeCallback));
}
/*
* Called when close operation is done.
*/
,closed: function (closeCallback)
{
this.connected = false;
this.signalEmit ('closed');
this.signalEmit ('loading-changed', false);
if (closeCallback)
closeCallback (this);
}
/**
* Runs a SQL query on the database.
*
* @param {String} sql The SQL statement
* @param {Function} callback The function to call when operation is done
**/
,execSql: function (sql, callback)
{
this.requestsCount++;
if (this.requestsCount == 1)
this.signalEmit ('loading-changed', true);
var httpRequest = new Db.HttpRequest ()
httpRequest.add
({
'action': 'query'
,'sql': sql
});
httpRequest.send ('ajax.php',
this.execDone.bind (this, httpRequest, callback));
}
/**
* Runs a stmt on the database.
*
* @param {Sql.Stmt} stmt The statement
* @param {Function} callback The function to call when operation is done
* @param {Sql.Batch} batch The batch used to set the parameters
**/
,execStmt: function (stmt, callback, batch)
{
this.execSql (stmt.render (batch), callback);
}
/**
* Runs a query on the database.
*
* @param {String} query The SQL statement
* @param {Function} callback The function to call when operation is done
* @param {Sql.Batch} batch The batch used to set the parameters
**/
,execQuery: function (query, callback, batch)
{
this.execStmt (new Sql.String ({query: query}), callback, batch);
}
/*
* Parses a value to date.
*/
,valueToDate: function (value)
{
return new Date (value * 1000);
}
/*
* Called when a query is executed.
*/
,execDone: function (httpRequest, callback, success)
{
var error = null;
var results = null;
this.requestsCount--;
if (this.requestsCount == 0)
this.signalEmit ('loading-changed', false);
if (!success)
error = new Vn.Error ('Conn', 'connError', _('ConnError'));
else
try {
var json = httpRequest.getJson ();
results = json.data;
if (json.error !== null)
error = new Vn.Error (json.error.domain,
json.error.code, json.error.message);
if (results instanceof Array)
for (var i = 0; i < results.length; i++)
if (results[i] !== true)
{
var data = results[i].data;
var columns = results[i].field;
for (var j = 0; j < columns.length; j++)
{
var castFunc = null;
switch (columns[j].type)
{
case Db.Conn.Type.DATE:
case Db.Conn.Type.DATE_TIME:
case Db.Conn.Type.TIMESTAMP:
castFunc = this.valueToDate;
break;
}
if (castFunc !== null)
{
if (columns[j].def != null)
columns[j].def = castFunc (columns[j].def);
for (var k = 0; k < data.length; k++)
if (data[k][j] != null)
data[k][j] = castFunc (data[k][j]);
}
}
}
}
catch (e) {
error = new Vn.Error ('Conn', 'badReply', e.message /*_('BadServerReply')*/);
}
if (callback)
callback (new Db.ResultSet (results, error));
if (error)
this.signalEmit ('error', error);
}
});

View File

@ -1,212 +0,0 @@
Db.Form = new Class
({
Extends: Vn.Object
,Tag: 'db-form'
,Child: 'model'
,Properties:
{
/**
* The model associated to this form.
**/
model:
{
type: Db.Model
,set: function (x)
{
this.link ({_model: x},
{
'status-changed': this.onModelChange
,'row-updated': this.onRowUpdate
});
}
,get: function ()
{
return this._model;
}
},
/**
* The row where the form positioned, has -1 if the row is unselected.
**/
row:
{
type: Number
,set: function (x)
{
if (!this._model || this._model.numRows <= x || x < -1)
x = -1;
if (x == this._row)
return;
this._row = x;
this.iterChanged ();
}
,get: function ()
{
return this._row;
}
},
/**
* The number of rows in the form.
**/
numRows:
{
type: Number
,get: function ()
{
if (this._model)
return this._model.numRows;
return 0;
}
},
/**
* Checks if the form data is ready.
**/
ready:
{
type: Boolean
,get: function ()
{
return this._ready;
}
}
}
,lastRow: 0
,_model: null
,_row: -1
,_ready: false
,onModelChange: function ()
{
var ready = this._model && this._model.ready;
if (ready != this._ready)
{
if (this._row != -1)
this.lastRow = this._row;
this._ready = ready;
this.signalEmit ('status-changed');
if (this._row == -1)
this.row = this.lastRow;
}
}
,onRowUpdate: function (model, row, column)
{
if (row == this._row)
this.iterChanged ();
}
,refresh: function ()
{
if (this._model)
this._model.refresh ();
}
/**
* Emits the 'iter-changed' signal on the form.
**/
,iterChanged: function ()
{
this.signalEmit ('iter-changed');
}
/**
* Get the index of the column from its name.
*
* @param {String} columnName The column name
* @return {integer} The column index or -1 if column not exists
**/
,getColumnIndex: function (columnName)
{
if (this._model)
return this._model.getColumnIndex (columnName);
return -1;
}
,insertRow: function ()
{
if (this._model)
this.row = this._model.insertRow ();
}
,performOperations: function ()
{
if (this._model)
this._model.performOperations ();
}
/**
* Removes the current row.
**/
,deleteRow: function ()
{
if (this._row >= 0)
this._model.deleteRow (this._row);
}
/**
* Gets a value from the form.
*
* @param {String} columnName The column name
* @return {Object} The value
**/
,get: function (columnName)
{
return this._model.get (this._row, columnName);
}
/**
* Sets a value on the form.
*
* @param {String} columnName The column name
* @param {Object} value The new value
**/
,set: function (columnName, value)
{
return this._model.set (this._row, columnName, value);
}
/**
* Gets a value from the form using the column index.
*
* @param {String} columnName The column index
* @return {Object} The value
**/
,getByIndex: function (column)
{
return this._model.getByIndex (this._row, column);
}
/**
* Sets a value on the form using the column index.
*
* @param {String} columnName The column index
* @param {Object} value The new value
**/
,setByIndex: function (column, value)
{
return this._model.setByIndex (this._row, column, value);
}
/**
* Gets a param from the form.
*
* @param {String} columnName The column name
* @return {Db.Param} The new parameter
**/
,getParam: function (columnName)
{
return new Db.Param
({
form: this
,column: columnName
});
}
});

View File

@ -1,30 +0,0 @@
Db.HttpRequest = new Class
({
kvPairs: {}
,add: function (map)
{
for (var key in map)
this.kvPairs[key] = map[key];
}
,send: function (file, callback)
{
this.request = new XMLHttpRequest ();
this.request.open ('post', file, true);
this.request.setRequestHeader ('Content-Type', 'application/x-www-form-urlencoded');
this.request.onreadystatechange = this.requestStateChanged.bind (this, callback);
this.request.send (Vn.Url.makeUri (this.kvPairs));
}
,requestStateChanged: function (callback)
{
if (this.request.readyState == 4)
callback (this, this.request.status == 200);
}
,getJson: function ()
{
return eval (this.request.responseText);
}
});

Some files were not shown because too many files have changed in this diff Show More