aboutsummaryrefslogtreecommitdiff
path: root/h-source/Library
diff options
context:
space:
mode:
authorYuchen Pei <me@ypei.me>2021-07-29 14:17:20 +1000
committerYuchen Pei <me@ypei.me>2021-07-29 14:17:20 +1000
commit3ff03dc4f0a72432b34c00da620272cf011e4ddd (patch)
tree5746711ba17a91aed56c6529ea8cceb06c3ad16a /h-source/Library
parentcd4534aa10ba3b122963992741721289fa50d0ab (diff)
Publishing h-node.org code.
- this is the h-node.org code, except - removed a js file (3x copies at three different locations) without license / copyright headers - /Js/linkToForm.js - /Public/Js/linkToForm.js - /admin/Public/Js/linkToForm.js - removed config files containing credentials - /Application/Include/params.php - /Config/Config.php - /admin/Application/Include/params.php - /admin/Config/Config.php - added license and copyright header to one php file - /admin/Library/ErrorReporting.php (almost identical to /Library/ErrorReporting.php which has the headers)
Diffstat (limited to 'h-source/Library')
-rw-r--r--h-source/Library/Array/Validate/Base.php106
-rw-r--r--h-source/Library/Array/Validate/Soft.php76
-rw-r--r--h-source/Library/Array/Validate/Strong.php90
-rw-r--r--h-source/Library/Array/Validate/Values.php36
-rwxr-xr-xh-source/Library/ArrayExt.php4
-rwxr-xr-xh-source/Library/Bootstrap.php2
-rw-r--r--h-source/Library/BoxParser.php2
-rwxr-xr-xh-source/Library/Call.php208
-rwxr-xr-xh-source/Library/Controller.php29
-rwxr-xr-xh-source/Library/Db/Mysql.php178
-rw-r--r--h-source/Library/Db/Mysqli.php264
-rw-r--r--h-source/Library/Email.php2
-rw-r--r--h-source/Library/ErrorReporting.php2
-rwxr-xr-xh-source/Library/Factory/Db.php2
-rw-r--r--h-source/Library/Factory/Strings.php2
-rw-r--r--h-source/Library/Files/Log.php2
-rwxr-xr-xh-source/Library/Files/Upload.php24
-rwxr-xr-xh-source/Library/Form/Checkbox.php4
-rwxr-xr-xh-source/Library/Form/Entry.php3
-rw-r--r--h-source/Library/Form/File.php4
-rwxr-xr-xh-source/Library/Form/Form.php120
-rwxr-xr-xh-source/Library/Form/Hidden.php4
-rw-r--r--h-source/Library/Form/Html.php2
-rwxr-xr-xh-source/Library/Form/InputText.php4
-rw-r--r--h-source/Library/Form/Password.php4
-rwxr-xr-xh-source/Library/Form/Radio.php4
-rwxr-xr-xh-source/Library/Form/Select.php4
-rwxr-xr-xh-source/Library/Form/Textarea.php4
-rwxr-xr-xh-source/Library/Functions.php186
-rw-r--r--h-source/Library/HeaderObj.php2
-rwxr-xr-xh-source/Library/Helper/Array.php2
-rwxr-xr-xh-source/Library/Helper/Html.php2
-rwxr-xr-xh-source/Library/Helper/List.php288
-rwxr-xr-xh-source/Library/Helper/Menu.php40
-rwxr-xr-xh-source/Library/Helper/Pages.php15
-rwxr-xr-xh-source/Library/Helper/Popup.php46
-rw-r--r--h-source/Library/Hooks.php2
-rw-r--r--h-source/Library/Html/Form.php48
-rw-r--r--h-source/Library/Image/Gd/Captcha.php2
-rw-r--r--h-source/Library/Image/Gd/Thumbnail.php246
-rw-r--r--h-source/Library/Lang/En/DbCondStrings.php6
-rw-r--r--h-source/Library/Lang/En/Formats/Fields.php46
-rw-r--r--h-source/Library/Lang/En/Formats/From/Mysql.php64
-rwxr-xr-xh-source/Library/Lang/En/Formats/From/index.html1
-rw-r--r--h-source/Library/Lang/En/Formats/To/Mysql.php62
-rwxr-xr-xh-source/Library/Lang/En/Formats/To/index.html1
-rwxr-xr-xh-source/Library/Lang/En/Formats/index.html1
-rw-r--r--h-source/Library/Lang/En/Generic.php5
-rw-r--r--h-source/Library/Lang/En/ModelStrings.php24
-rw-r--r--h-source/Library/Lang/En/UploadStrings.php2
-rw-r--r--h-source/Library/Lang/En/ValCondStrings.php68
-rw-r--r--h-source/Library/Lang/Eng/DbCondStrings.php2
-rw-r--r--h-source/Library/Lang/Eng/Generic.php21
-rw-r--r--h-source/Library/Lang/Eng/ModelStrings.php5
-rw-r--r--h-source/Library/Lang/Eng/UploadStrings.php2
-rw-r--r--h-source/Library/Lang/Eng/ValCondStrings.php52
-rw-r--r--h-source/Library/Lang/ResultStrings.php2
-rw-r--r--h-source/Library/ModAbstract.php2
-rwxr-xr-xh-source/Library/Model/#Base.php#1273
-rwxr-xr-xh-source/Library/Model/Base.php607
-rwxr-xr-xh-source/Library/Model/Map.php2
-rwxr-xr-xh-source/Library/Model/Tree.php560
-rw-r--r--h-source/Library/Params.php68
-rwxr-xr-xh-source/Library/Popup.php2
-rw-r--r--h-source/Library/Request.php2
-rwxr-xr-xh-source/Library/Scaffold.php123
-rw-r--r--h-source/Library/Strings/Functions.php2
-rwxr-xr-xh-source/Library/Theme.php40
-rwxr-xr-xh-source/Library/Url.php24
-rwxr-xr-xh-source/Library/Users/CheckAdmin.php12
70 files changed, 1988 insertions, 3158 deletions
diff --git a/h-source/Library/Array/Validate/Base.php b/h-source/Library/Array/Validate/Base.php
index f1a242e..fb4a66c 100644
--- a/h-source/Library/Array/Validate/Base.php
+++ b/h-source/Library/Array/Validate/Base.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -26,7 +26,6 @@ if (!defined('EG')) die('Direct access not allowed!');
class Array_Validate_Base
{
- public $strength;
public $errorString = null; //string containing the list fields not found
public $errorsNumb = null; //numbers of errors
@@ -45,40 +44,7 @@ class Array_Validate_Base
$this->_resultString = new $stringClass();
}
- public function checkNotEmpty($associativeArray,$keyString)
- {
- $errorString = null;
- $keyArray = explode(',',$keyString);
- $numb = 0;
- for ($i = 0; $i < count($keyArray); $i++)
- {
- if (array_key_exists($keyArray[$i],$associativeArray))
- {
- if (is_array($associativeArray[$keyArray[$i]]))
- {
- $errorString .= $this->_resultString->getNotDefinedResultString($keyArray[$i]);
- $numb++;
- }
- else
- {
- if (strcmp(trim($associativeArray[$keyArray[$i]]),'') === 0)
- {
- $errorString .= $this->_resultString->getNotDefinedResultString($keyArray[$i]);
- $numb++;
- }
- }
- }
- else
- {
- $errorString .= $this->_resultString->getNotDefinedResultString($keyArray[$i]);
- $numb++;
- }
- }
- $this->errorString = $errorString;
- $this->errorNumb = $numb;
- return $numb === 0 ? true : false;
- }
-
+
//verify that the values of the associative array ($associativeArray) indicated by the key string ($keyString) are not '' and are equal (===) to each other
public function checkEqual($associativeArray,$keyString)
{
@@ -150,13 +116,6 @@ class Array_Validate_Base
}
- //verify that the values of the associative array ($associativeArray) indicated by the key string ($keyString) are integer strings
- //$strength: hard or soft. If $strength is set equal to soft than non check is made upon array values equalt to '' or null
- public function checkInteger($associativeArray,$keyString,$strength = 'strong')
- {
- return $this->checkGeneric($associativeArray,$keyString,$strength,'checkInteger','getNotIntegerFormatResultString');
- }
-
//verify that the values of the associative array ($associativeArray) indicated by the key string ($keyString) is a number (integer or number). It makes use of the is_numeric PHP built-in function
//$strength: hard or soft. If $strength is set equal to soft than non check is made upon array values equalt to '' or null
public function checkNumeric($associativeArray,$keyString,$strength = 'strong')
@@ -164,12 +123,6 @@ class Array_Validate_Base
return $this->checkGeneric($associativeArray,$keyString,$strength,'is_numeric','getNotNumericResultString');
}
- //verify that the values of the associative array ($associativeArray) indicated by the key string ($keyString) are an ISO date.
- //$strength: hard or soft. If $strength is set equal to soft than non check is made upon array values equalt to '' or null
- public function checkIsoDate($associativeArray,$keyString,$strength = 'strong')
- {
- return $this->checkGeneric($associativeArray,$keyString,$strength,'checkIsoDate','getNotDateResultString');
- }
//apply a generic check function
//$strength: hard or soft. If $strength is set equal to soft than non check is made upon array values equalt to '' or null
@@ -186,7 +139,7 @@ class Array_Validate_Base
{
if (array_key_exists($keyArray[$i],$associativeArray))
{
- if (strcmp($associativeArray[$keyArray[$i]],'') !== 0 or $this->strength === 'strong')
+ if (strcmp($associativeArray[$keyArray[$i]],'') !== 0 or $strength === 'strong')
{
if (!call_user_func($func,$associativeArray[$keyArray[$i]]))
{
@@ -264,7 +217,7 @@ class Array_Validate_Base
{
if (array_key_exists($keyArray[$i],$associativeArray))
{
- if (strcmp($associativeArray[$keyArray[$i]],'') !== 0 or $this->strength === 'strong')
+ if (strcmp($associativeArray[$keyArray[$i]],'') !== 0 or $strength === 'strong')
{
if (!in_array($associativeArray[$keyArray[$i]],$stringsArray))
{
@@ -281,50 +234,25 @@ class Array_Validate_Base
//verify that the values of the associative array ($associativeArray) indicated by the key string ($keyString) match the regular expression $regExp
public function checkMatch($associativeArray,$keyString,$regExp = '/./',$strength = 'strong')
{
- $errorString = null;
- $keyArray = explode(',',$keyString);
- $numb = 0;
- for ($i = 0; $i < count($keyArray); $i++)
- {
- if (array_key_exists($keyArray[$i],$associativeArray))
- {
- if (strcmp($associativeArray[$keyArray[$i]],'') !== 0 or $this->strength === 'strong')
- {
- if (!preg_match($regExp,$associativeArray[$keyArray[$i]]))
- {
- $numb++;
- $errorString .= $this->_resultString->getDoesntMatchResultString($keyArray[$i],$regExp);
- }
- }
- }
- }
- $this->errorString = $errorString;
- return $numb === 0 ? true : false;
- }
-
- //verify that the values of the associative array ($associativeArray) indicated by the key string ($keyString) are decimal with the format indicated in $format
- //$format: M,D M is the maximum number of digits, D is the number of digits to the right of the decimal point
- public function checkDecimal($associativeArray,$keyString,$format = '10,2')
- {
- $errorString = null;
- $keyArray = explode(',',$keyString);
- $numb = 0;
- for ($i = 0; $i < count($keyArray); $i++)
- {
- if (array_key_exists($keyArray[$i],$associativeArray))
+ $errorString = null;
+ $keyArray = explode(',',$keyString);
+ $numb = 0;
+ for ($i = 0; $i < count($keyArray); $i++)
{
- if (strcmp($associativeArray[$keyArray[$i]],'') !== 0 or $this->strength === 'strong')
+ if (array_key_exists($keyArray[$i],$associativeArray))
{
- if (!checkDecimal($associativeArray[$keyArray[$i]],$format))
+ if (strcmp($associativeArray[$keyArray[$i]],'') !== 0 or $strength === 'strong')
{
- $numb++;
- $errorString .= $this->_resultString->getNotDecimalResultString($keyArray[$i],$format);
+ if (!preg_match($regExp,$associativeArray[$keyArray[$i]]))
+ {
+ $numb++;
+ $errorString .= $this->_resultString->getDoesntMatchResultString($keyArray[$i],$regExp);
+ }
}
}
}
- }
- $this->errorString = $errorString;
- return $numb === 0 ? true : false;
+ $this->errorString = $errorString;
+ return $numb === 0 ? true : false;
}
} \ No newline at end of file
diff --git a/h-source/Library/Array/Validate/Soft.php b/h-source/Library/Array/Validate/Soft.php
index d790652..b348bdc 100644
--- a/h-source/Library/Array/Validate/Soft.php
+++ b/h-source/Library/Array/Validate/Soft.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -26,11 +26,77 @@ if (!defined('EG')) die('Direct access not allowed!');
class Array_Validate_Soft extends Array_Validate_Base
{
- public function __construct($lang = 'En')
+ public function __construct($lang = 'Eng')
{
parent::__construct($lang);
-
- $this->strength = "soft";
+ }
+
+
+ //verify that the values of the associative array ($associativeArray) indicated by the key string ($keyString) are not '' and are equal (===) to each other
+ public function checkEqual($associativeArray,$keyString)
+ {
+ return parent::checkEqual($associativeArray,$keyString);
+ }
+
+ //verify that the values of the associative array ($associativeArray) indicated by the key string ($keyString) are alphabetic values
+ public function checkAlpha($associativeArray,$keyString)
+ {
+ return parent::checkAlpha($associativeArray,$keyString,'soft');
+ }
+
+
+ //verify that the values of the associative array ($associativeArray) indicated by the key string ($keyString) are alphanumeric values
+ public function checkAlphaNum($associativeArray,$keyString)
+ {
+ return parent::checkAlphaNum($associativeArray,$keyString,'soft');
+ }
+
+
+ //verify that the values of the associative array ($associativeArray) indicated by the key string ($keyString) are decimal digits
+ public function checkDigit($associativeArray,$keyString)
+ {
+ return parent::checkDigit($associativeArray,$keyString,'soft');
+ }
+
+
+ //verify that the values of the associative array ($associativeArray) indicated by the key string ($keyString) have mail format
+ public function checkMail($associativeArray,$keyString)
+ {
+ return parent::checkMail($associativeArray,$keyString,'soft');
+ }
+
+
+ //verify that the values of the associative array ($associativeArray) indicated by the key string ($keyString) is a number (integer or number). It makes use of the is_numeric PHP built-in function
+ public function checkNumeric($associativeArray,$keyString)
+ {
+ return parent::checkNumeric($associativeArray,$keyString,'soft');
+ }
+
+
+ //verify that the values of the associative array ($associativeArray) indicated by the key string ($keyString) have a number of chars smaller than $maxLenght
+ public function checkLength($associativeArray,$keyString,$maxLength = 10)
+ {
+ return parent::checkLength($associativeArray,$keyString,$maxLength);
+ }
+
+
+ //verify that the values of the associative array ($associativeArray) indicated by the key string ($keyString) are different from the values indicated in the argument $strings (a comma-separated list of words)
+ public function checkIsNotStrings($associativeArray,$keyString,$strings = '')
+ {
+ return parent::checkIsNotStrings($associativeArray,$keyString,$strings);
+ }
+
+
+ //verify that the values of the associative array ($associativeArray) indicated by the key string ($keyString) are one of the values indicated in the argument $strings (a comma-separated list of words)
+ public function checkIsStrings($associativeArray,$keyString,$strings = '')
+ {
+ return parent::checkIsStrings($associativeArray,$keyString,$strings,'soft');
+ }
+
+ //verify that the values of the associative array ($associativeArray) indicated by the key string ($keyString) match the regular expression $regExp
+ public function checkMatch($associativeArray,$keyString,$regExp = '/./')
+ {
+ return parent::checkMatch($associativeArray,$keyString,$regExp,'soft');
}
-}
+} \ No newline at end of file
diff --git a/h-source/Library/Array/Validate/Strong.php b/h-source/Library/Array/Validate/Strong.php
index d907d1d..ccdce74 100644
--- a/h-source/Library/Array/Validate/Strong.php
+++ b/h-source/Library/Array/Validate/Strong.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -22,17 +22,42 @@
if (!defined('EG')) die('Direct access not allowed!');
-//class to validate associative arrays
+//class to manage arrays
class Array_Validate_Strong extends Array_Validate_Base
{
- public function __construct($lang = 'En')
+ public function __construct($lang = 'Eng')
{
parent::__construct($lang);
-
- $this->strength = "strong";
}
+
+ public function checkNotEmpty($associativeArray,$keyString)
+ {
+ $errorString = null;
+ $keyArray = explode(',',$keyString);
+ $numb = 0;
+ for ($i = 0; $i < count($keyArray); $i++)
+ {
+ if (array_key_exists($keyArray[$i],$associativeArray))
+ {
+ if (strcmp(trim($associativeArray[$keyArray[$i]]),'') === 0)
+ {
+ $errorString .= $this->_resultString->getNotDefinedResultString($keyArray[$i]);
+ $numb++;
+ }
+ }
+ else
+ {
+ $errorString .= $this->_resultString->getNotDefinedResultString($keyArray[$i]);
+ $numb++;
+ }
+ }
+ $this->errorString = $errorString;
+ $this->errorNumb = $numb;
+ return $numb === 0 ? true : false;
+ }
+
//verify that the values of the associative array ($associativeArray) indicated by the key string ($keyString) are not '' and are equal (===) to each other
public function checkEqual($associativeArray,$keyString)
{
@@ -47,7 +72,7 @@ class Array_Validate_Strong extends Array_Validate_Base
}
//verify that the values of the associative array ($associativeArray) indicated by the key string ($keyString) are alphabetic values
- public function checkAlpha($associativeArray,$keyString,$strength = 'strong')
+ public function checkAlpha($associativeArray,$keyString)
{
if ($this->checkNotEmpty($associativeArray,$keyString))
{
@@ -61,7 +86,7 @@ class Array_Validate_Strong extends Array_Validate_Base
//verify that the values of the associative array ($associativeArray) indicated by the key string ($keyString) are alphanumeric values
- public function checkAlphaNum($associativeArray,$keyString,$strength = 'strong')
+ public function checkAlphaNum($associativeArray,$keyString)
{
if ($this->checkNotEmpty($associativeArray,$keyString))
{
@@ -75,7 +100,7 @@ class Array_Validate_Strong extends Array_Validate_Base
//verify that the values of the associative array ($associativeArray) indicated by the key string ($keyString) are decimal digits
- public function checkDigit($associativeArray,$keyString,$strength = 'strong')
+ public function checkDigit($associativeArray,$keyString)
{
if ($this->checkNotEmpty($associativeArray,$keyString))
{
@@ -89,7 +114,7 @@ class Array_Validate_Strong extends Array_Validate_Base
//verify that the values of the associative array ($associativeArray) indicated by the key string ($keyString) have mail format
- public function checkMail($associativeArray,$keyString,$strength = 'strong')
+ public function checkMail($associativeArray,$keyString)
{
if ($this->checkNotEmpty($associativeArray,$keyString))
{
@@ -102,21 +127,8 @@ class Array_Validate_Strong extends Array_Validate_Base
}
- //verify that the values of the associative array ($associativeArray) indicated by the key string ($keyString) are an ISO date.
- public function checkIsoDate($associativeArray,$keyString,$strength = 'strong')
- {
- if ($this->checkNotEmpty($associativeArray,$keyString))
- {
-
- return parent::checkIsoDate($associativeArray,$keyString,'strong');
-
- } else {
- return false;
- }
- }
-
//verify that the values of the associative array ($associativeArray) indicated by the key string ($keyString) is a number (integer or number). It makes use of the is_numeric PHP built-in function
- public function checkNumeric($associativeArray,$keyString,$strength = 'strong')
+ public function checkNumeric($associativeArray,$keyString)
{
if ($this->checkNotEmpty($associativeArray,$keyString))
{
@@ -128,18 +140,6 @@ class Array_Validate_Strong extends Array_Validate_Base
}
}
- //verify that the values of the associative array ($associativeArray) indicated by the key string ($keyString) is an integer string.
- public function checkInteger($associativeArray,$keyString,$strength = 'strong')
- {
- if ($this->checkNotEmpty($associativeArray,$keyString))
- {
-
- return parent::checkInteger($associativeArray,$keyString,'strong');
-
- } else {
- return false;
- }
- }
//verify that the values of the associative array ($associativeArray) indicated by the key string ($keyString) have a number of chars smaller than $maxLenght
public function checkLength($associativeArray,$keyString,$maxLength = 10)
@@ -170,7 +170,7 @@ class Array_Validate_Strong extends Array_Validate_Base
//verify that the values of the associative array ($associativeArray) indicated by the key string ($keyString) are one of the values indicated in the argument $strings (a comma-separated list of words)
- public function checkIsStrings($associativeArray,$keyString,$strings = '',$strength = 'strong')
+ public function checkIsStrings($associativeArray,$keyString,$strings = '')
{
if ($this->checkNotEmpty($associativeArray,$keyString))
{
@@ -183,7 +183,7 @@ class Array_Validate_Strong extends Array_Validate_Base
}
//verify that the values of the associative array ($associativeArray) indicated by the key string ($keyString) match the regular expression $regExp
- public function checkMatch($associativeArray,$keyString,$regExp = '/./',$strength = 'strong')
+ public function checkMatch($associativeArray,$keyString,$regExp = '/./')
{
if ($this->checkNotEmpty($associativeArray,$keyString))
{
@@ -194,18 +194,4 @@ class Array_Validate_Strong extends Array_Validate_Base
return false;
}
}
-
- //verify that the values of the associative array ($associativeArray) indicated by the key string ($keyString) are decimal with the format indicated in $format
- //$format: M,D M is the maximum number of digits, D is the number of digits to the right of the decimal point
- public function checkDecimal($associativeArray,$keyString,$format = '10,2')
- {
- if ($this->checkNotEmpty($associativeArray,$keyString))
- {
-
- return parent::checkDecimal($associativeArray,$keyString,$format);
-
- } else {
- return false;
- }
- }
-}
+} \ No newline at end of file
diff --git a/h-source/Library/Array/Validate/Values.php b/h-source/Library/Array/Validate/Values.php
deleted file mode 100644
index 9355949..0000000
--- a/h-source/Library/Array/Validate/Values.php
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-
-// EasyGiant is a PHP framework for creating and managing dynamic content
-//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
-// See COPYRIGHT.txt and LICENSE.txt.
-//
-// This file is part of EasyGiant
-//
-// EasyGiant is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// EasyGiant 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with EasyGiant. If not, see <http://www.gnu.org/licenses/>.
-
-if (!defined('EG')) die('Direct access not allowed!');
-
-//class to validate associative arrays
-class Array_Validate_Values extends Array_Validate_Soft
-{
-
- public function __construct($lang = 'En')
- {
- parent::__construct($lang);
-
- $this->strength = "strong";
- }
-
-}
diff --git a/h-source/Library/ArrayExt.php b/h-source/Library/ArrayExt.php
index d4300b4..2b02c9e 100755
--- a/h-source/Library/ArrayExt.php
+++ b/h-source/Library/ArrayExt.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -50,7 +50,7 @@ class ArrayExt {
if (!in_array($temp[1],explode(',',Params::$allowedSanitizeFunc))) {
throw new Exception('"'.$temp[1]. '" function not allowed');
}
- if (array_key_exists($temp[0],$associativeArray) and !is_array($associativeArray[$temp[0]])) {
+ if (array_key_exists($temp[0],$associativeArray)) {
$tempArray[$temp[0]] = call_user_func($temp[1],$associativeArray[$temp[0]]);
} else {
$tempArray[$temp[0]] = '';
diff --git a/h-source/Library/Bootstrap.php b/h-source/Library/Bootstrap.php
index aa32041..5d7a12f 100755
--- a/h-source/Library/Bootstrap.php
+++ b/h-source/Library/Bootstrap.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
diff --git a/h-source/Library/BoxParser.php b/h-source/Library/BoxParser.php
index 302439a..0e7e03f 100644
--- a/h-source/Library/BoxParser.php
+++ b/h-source/Library/BoxParser.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
diff --git a/h-source/Library/Call.php b/h-source/Library/Call.php
index 7f80841..c75508b 100755
--- a/h-source/Library/Call.php
+++ b/h-source/Library/Call.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -35,40 +35,19 @@ function sanitizeSuperGlobal()
$_SERVER = stripslashesDeep($_SERVER);
}
-function checkPostLength($checkArray = null)
+
+
+function checkPostLength()
{
- $a = isset($checkArray) ? $checkArray : $_POST;
-
if (MAX_POST_LENGTH !== 0)
{
- foreach ($a as $key => $value)
+ foreach ($_POST as $key => $value)
{
- if (is_array($value))
- {
- checkPostLength($value);
- }
- else
- {
- if (strlen($value) > MAX_POST_LENGTH) die('the length of some of the $_POST values is too large');
- }
+ if (strlen($value) > MAX_POST_LENGTH) die('the length of some of the $_POST values is too large');
}
}
}
-//remove elements that are arrays
-//applied to $_POST and $_GET
-function fixArray($array)
-{
- $temp = array();
-
- foreach ($array as $key => $value)
- {
- $temp[$key] = is_array($value) ? "" : $value;
- }
-
- return $temp;
-}
-
function checkRequestUriLength()
{
if (MAX_REQUEST_URI_LENGTH !== 0)
@@ -82,108 +61,20 @@ function checkRegisterGlobals()
if (ini_get('register_globals')) die('register globals is on: easyGiant works only with register globals off');
}
-//geth the name of the current application used
-function getApplicationName()
-{
- if (isset(Params::$currentApplication))
- {
- return Params::$currentApplication;
- }
- return null;
-}
-
-//geth the path of the current application used
-//add the trailing slash to the application name
-function getApplicationPath()
-{
- if (isset(Params::$currentApplication))
- {
- return "Apps".DS.ucfirst(Params::$currentApplication).DS;
- }
- return null;
-}
-
-function languageInUrl($url)
-{
- $url = trim($url,"/");
-
- if (in_array($url,Params::$frontEndLanguages))
- {
- return $url."/";
- }
- return false;
-}
-
function callHook()
{
-
+
$currentUrl = null;
if (MOD_REWRITE_MODULE === true)
{
- if (isset($_GET['url']))
- {
- if (!languageInUrl($_GET['url']))
- {
- $url = $_GET['url'];
- }
- else
- {
- $url = languageInUrl($_GET['url']) . DEFAULT_CONTROLLER . '/' . DEFAULT_ACTION;
- }
- }
- else
- {
- $url = DEFAULT_CONTROLLER . '/' . DEFAULT_ACTION;
- }
+ $url = isset($_GET['url']) ? $_GET['url'] : DEFAULT_CONTROLLER . '/' . DEFAULT_ACTION;
}
else
{
- if (strcmp(getQueryString(),"") !== 0)
- {
- if (!languageInUrl(getQueryString()))
- {
- $url = getQueryString();
- }
- else
- {
- $url = languageInUrl(getQueryString()) . DEFAULT_CONTROLLER . '/' . DEFAULT_ACTION;
- }
- }
- else
- {
- $url = DEFAULT_CONTROLLER . '/' . DEFAULT_ACTION;
- }
+ $url = (strcmp(getQueryString(),"") !== 0) ? getQueryString() : DEFAULT_CONTROLLER . '/' . DEFAULT_ACTION;
}
- $arriveUrl = $url;
-
- $urlArray = array();
- $urlArray = explode("/",$url);
-
- //get the language
- if (count(Params::$frontEndLanguages) > 0)
- {
- if (in_array($urlArray[0],Params::$frontEndLanguages))
- {
- Params::$lang = sanitizeAll($urlArray[0]);
- array_shift($urlArray);
- }
- else
- {
- Params::$lang = Params::$defaultFrontEndLanguage;
-/*
- if (isset($_GET['url']) and Params::$redirectToDefaultLanguage)
- {
- $h = new HeaderObj(DOMAIN_NAME);
-
- $h->redirect($arriveUrl);
- }*/
- }
- }
-
- $url = implode("/",$urlArray);
-
// rewrite the URL
if (Route::$rewrite === 'yes')
{
@@ -194,19 +85,12 @@ function callHook()
// echo $url;
+ $urlArray = array();
$urlArray = explode("/",$url);
+
$controller = DEFAULT_CONTROLLER;
$action = DEFAULT_ACTION;
-
- //check if an application name is found in the URL
- if (isset(Params::$installed) and isset($urlArray[0]) and strcmp($urlArray[0],'') !== 0 and in_array($urlArray[0],Params::$installed))
- {
- Params::$currentApplication = strtolower(trim($urlArray[0]));
-
- array_shift($urlArray);
- }
-
if (isset($urlArray[0]))
{
$controller = (strcmp($urlArray[0],'') !== 0) ? strtolower(trim($urlArray[0])) : DEFAULT_CONTROLLER;
@@ -224,30 +108,10 @@ function callHook()
$errorAction = ERROR_ACTION !== false ? ERROR_ACTION : DEFAULT_ACTION;
/*
- CHECK COUPLES CONTROLLER,ACTION
- */
- if (!in_array('all',Route::$allowed))
- {
- $couple = "$controller,$action";
- if (getApplicationName() !== null)
- {
- $couple = getApplicationName().",".$couple;
- }
- if (!in_array($couple,Route::$allowed))
- {
- Params::$currentApplication = null;
- $controller = $errorController;
- $action = $errorAction;
- $urlArray = array();
- }
- }
-
- /*
VERIFY THE ACTION NAME
- */
+ */
if (method_exists('Controller', $action) or !ctype_alnum($action) or (strcmp($action,'') === 0))
{
- Params::$currentApplication = null;
$controller = $errorController;
$action = $errorAction;
$urlArray = array();
@@ -258,7 +122,6 @@ function callHook()
*/
if (!ctype_alnum($controller) or (strcmp($controller,'') === 0))
{
- Params::$currentApplication = null;
$controller = $errorController;
$action = $errorAction;
$urlArray = array();
@@ -266,10 +129,8 @@ function callHook()
//check that the controller class belongs to the application/controllers folder
//otherwise set the controller to the default controller
- // if (!file_exists(ROOT.DS.APPLICATION_PATH.DS.'Controllers'.DS.ucwords($controller).'Controller.php') and !file_exists(ROOT.DS.APPLICATION_PATH.DS.getApplicationPath().'Controllers'.DS.ucwords($controller).'Controller.php'))
- if (!file_exists(ROOT.DS.APPLICATION_PATH.DS.getApplicationPath().'Controllers'.DS.ucwords($controller).'Controller.php'))
+ if (!file_exists(ROOT.DS.APPLICATION_PATH.DS.'Controllers'.DS.ucwords($controller).'Controller.php'))
{
- Params::$currentApplication = null;
$controller = $errorController;
$action = $errorAction;
$urlArray = array();
@@ -278,7 +139,6 @@ function callHook()
//set the controller class to DEFAULT_CONTROLLER if it doesn't exists
if (!class_exists(ucwords($controller).'Controller'))
{
- Params::$currentApplication = null;
$controller = $errorController;
$action = $errorAction;
$urlArray = array();
@@ -287,28 +147,40 @@ function callHook()
//set the action to DEFAULT_ACTION if it doesn't exists
if (!method_exists(ucwords($controller).'Controller', $action))
{
- Params::$currentApplication = null;
$controller = $errorController;
$action = $errorAction;
$urlArray = array();
}
+
+ /*
+ CHECK COUPLES CONTROLLER,ACTION
+ */
+ if (!in_array('all',Route::$allowed))
+ {
+ $couple = "$controller,$action";
+ if (!in_array($couple,Route::$allowed))
+ {
+ $controller = $errorController;
+ $action = $errorAction;
+ $urlArray = array();
+ }
+ }
array_shift($urlArray);
$queryString = $urlArray;
//set the name of the application
- $controllerName = $controller;
+ $application = $controller;
$controller = ucwords($controller);
$model = $controller;
$controller .= 'Controller';
$model .= 'Model';
-// echo $controller."-".$action;
//include the file containing the set of actions to carry out before the initialization of the controller class
Hooks::load(ROOT . DS . APPLICATION_PATH . DS . 'Hooks' . DS . 'BeforeInitialization.php');
if (class_exists($controller))
{
- $dispatch = new $controller($model,$controllerName,$queryString, getApplicationName());
+ $dispatch = new $controller($model,$application,$queryString);
//pass the action to the controller object
$dispatch->action = $action;
@@ -324,7 +196,7 @@ function callHook()
$templateFlag= true;
- if (method_exists($dispatch, $action))
+ if (method_exists($controller, $action))
{
//pass the action to the theme object
$dispatch->theme->action = $action;
@@ -363,10 +235,7 @@ function rewrite($url)
$oldKey = $key;
$key = str_replace('\/','/',$key);
$key = str_replace('/','\/',$key);
-
- $regExpr = Params::$exactUrlMatchRewrite ? '/^'.$key.'$/' : '/^'.$key.'/';
-
- if (preg_match($regExpr,$url))
+ if (preg_match('/^'.$key.'/',$url))
{
$nurl = preg_replace('/^'.$key.'/',$address,$url);
return array($nurl,$oldKey);
@@ -403,18 +272,10 @@ function __autoload($className)
{
require_once(ROOT . DS . 'Library' . DS . $className . '.php');
}
- else if (getApplicationName() and file_exists(ROOT . DS . APPLICATION_PATH . DS . getApplicationPath() . 'Controllers' . DS . $backupName . '.php'))
- {
- require_once(ROOT . DS . APPLICATION_PATH . DS . getApplicationPath() . 'Controllers' . DS . $backupName . '.php');
- }
else if (file_exists(ROOT . DS . APPLICATION_PATH . DS . 'Controllers' . DS . $backupName . '.php'))
{
require_once(ROOT . DS . APPLICATION_PATH . DS . 'Controllers' . DS . $backupName . '.php');
}
- else if (getApplicationName() and file_exists(ROOT . DS . APPLICATION_PATH . DS . getApplicationPath() . 'Models' . DS . $backupName . '.php'))
- {
- require_once(ROOT . DS . APPLICATION_PATH . DS . getApplicationPath() . 'Models' . DS . $backupName . '.php');
- }
else if (file_exists(ROOT . DS . APPLICATION_PATH . DS . 'Models' . DS . $backupName . '.php'))
{
require_once(ROOT . DS . APPLICATION_PATH . DS . 'Models' . DS . $backupName . '.php');
@@ -423,10 +284,6 @@ function __autoload($className)
{
require_once(ROOT . DS . APPLICATION_PATH . DS . 'Modules' . DS . $backupName . '.php');
}
- else if (getApplicationName() and file_exists(ROOT . DS . APPLICATION_PATH . DS . getApplicationPath() . 'Strings' . DS . $backupName . '.php'))
- {
- require_once(ROOT . DS . APPLICATION_PATH . DS . getApplicationPath() . 'Strings' . DS . $backupName . '.php');
- }
else if (file_exists(ROOT . DS . APPLICATION_PATH . DS . 'Strings' . DS . $className . '.php'))
{
require_once(ROOT . DS . APPLICATION_PATH . DS . 'Strings' . DS . $className . '.php');
@@ -436,9 +293,6 @@ function __autoload($className)
try {
- $_POST = fixArray($_POST);
- $_GET = fixArray($_GET);
-
//check the length of the $_POST values
checkPostLength();
diff --git a/h-source/Library/Controller.php b/h-source/Library/Controller.php
index bc1c229..b0eef53 100755
--- a/h-source/Library/Controller.php
+++ b/h-source/Library/Controller.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -31,8 +31,6 @@ class Controller {
protected $_queryString = array(); //the array of args coming from the url
- public $application = null;
- public $applicationUrl = null; //the url of the application
public $controller;
public $action;
public $currPage; //the URL of the current page
@@ -59,21 +57,17 @@ class Controller {
protected $scaffold = null; //the reference to the scaffold object
- function __construct($model, $controller, $queryString = array(), $application = null)
- {
- $this->application = $application;
+ function __construct($model, $controller, $queryString = array()) {
$this->controller = $controller;
$this->modelName = $model;
$this->_queryString = $queryString;
- $this->theme = new Theme($application, $controller);
+ $this->theme = new Theme($controller);
$this->baseUrl = $this->theme->baseUrl;
$this->baseUrlSrc = $this->theme->baseUrlSrc;
-
+
$this->headerObj = new HeaderObj(DOMAIN_NAME);
$this->request = new Request();
-
- $this->applicationUrl = isset($application) ? $application . "/" : null;
}
//redirect to $path after the time $time
@@ -142,8 +136,8 @@ class Controller {
{
if (class_exists($controller)) {
$model = str_replace('Controller',null,$controller).'Model';
- $application = $this->controller;
- $this->c[$controller] = new $controller($model,$application,$this->_queryString);
+ $application = strtolower(str_replace('Controller',null,$controller));
+ $this->c[$controller] = new $controller($model,$application,array());
$this->c[$controller]->theme = $this->theme;
}
}
@@ -240,7 +234,7 @@ class Controller {
}
$this->viewArgs[$this->argKeys[$i]] = $this->_queryString[$i];
}
- $this->viewStatus = Url::createUrl($this->viewArgs);
+ $this->viewStatus = Url::createUrl(array_values($this->viewArgs));
$this->updateHelpers();
//update the theme
@@ -288,7 +282,7 @@ class Controller {
//create the viewStatus property
final public function buildStatus()
{
- $this->viewStatus = Url::createUrl($this->viewArgs);
+ $this->viewStatus = Url::createUrl(array_values($this->viewArgs));
//update the theme
$this->theme->viewStatus = $this->viewStatus;
$this->theme->viewArgs = $this->viewArgs;
@@ -301,9 +295,9 @@ class Controller {
if (!in_array($type,$typeArray)) {
throw new Exception("the type '$type' is not allowed in ".__METHOD__);
}
- $this->scaffold = new Scaffold($type,$this->application,$this->controller,$this->m[$this->modelName],$this->viewArgs,$params);
+ $this->scaffold = new Scaffold($type,$this->controller,$this->m[$this->modelName],$this->viewArgs,$params);
- $this->helper('Menu',$this->applicationUrl.$this->controller,$this->scaffold->params['panelController']);
+ $this->helper('Menu',$this->controller,$this->scaffold->params['panelController']);
$this->scaffold->mainMenu = $this->h['Menu'];
$this->m[$this->modelName]->popupBuild();
@@ -311,8 +305,7 @@ class Controller {
if ($type === 'main') {
- $here = $this->applicationUrl.$this->controller.'/'.$this->scaffold->params['mainAction'];
-
+ $here = $this->controller.'/'.$this->scaffold->params['mainAction'];
$this->helper('Pages',$here,$this->scaffold->params['pageVariable']);
$this->helper('List',$this->m[$this->modelName]->identifierName,$here,$this->scaffold->params['pageVariable']);
diff --git a/h-source/Library/Db/Mysql.php b/h-source/Library/Db/Mysql.php
index e0dcfe0..4561a1b 100755
--- a/h-source/Library/Db/Mysql.php
+++ b/h-source/Library/Db/Mysql.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -24,34 +24,16 @@ if (!defined('EG')) die('Direct access not allowed!');
//class to manage the database
//singleton!
-class Db_Mysql
-{
-
- private $autocommit = true;
- private $transactionBatchSize = 100;
-
- public $transactionBatch = array();
+class Db_Mysql {
public $query = null; //the last query executed
- public $queries = array(); //array containing all the queries executed
-
public $charsetError = true; //true: non eccor occurred during the modification of the connection charset, false: one error occurred
public $charset = null; //the charset of the client connection
private static $instance = null; //instance of this class
private $dblink;
-
- private $charTypes = array('varchar','char');
- private $textTypes = array('tinytext','text','mediumtext','longtext');
- private $integerTypes = array('tinyint','smallint','int','mediumint','bigint');
- private $floatTypes = array('real','float','double');
- private $dateTypes = array('date');
- private $enumTypes = array('enum');
- private $decimalTypes = array('decimal');
- private $uniqueIndexStrings = array('UNI');
-
- private $fieldsType = array();
+ private $fieldsType = array('tinyint','smallint','int','mediumint','bigint','float','double');
/**
*connect to the database
@@ -69,8 +51,7 @@ class Db_Mysql
private function __construct($host,$user,$pwd,$db_name)
{
- $this->fieldsType = array_merge($this->integerTypes, $this->floatTypes);
-
+
$this->dblink = mysql_connect($host,$user,$pwd);
if ($this->dblink === FALSE) {
@@ -97,46 +78,7 @@ class Db_Mysql
return self::$instance;
}
- public function getUniqueIndexStrings()
- {
- return $this->uniqueIndexStrings;
- }
-
- public function getTextTypes()
- {
- return $this->textTypes;
- }
-
- public function getDecimalTypes()
- {
- return $this->decimalTypes;
- }
-
- public function getEnumTypes()
- {
- return $this->enumTypes;
- }
-
- public function getCharTypes()
- {
- return $this->charTypes;
- }
-
- public function getIntegerTypes()
- {
- return $this->integerTypes;
- }
-
- public function getFloatTypes()
- {
- return $this->floatTypes;
- }
-
- public function getDateTypes()
- {
- return $this->dateTypes;
- }
-
+
//close the connection
public function disconnect()
{
@@ -221,29 +163,16 @@ class Db_Mysql
public function get_num_rows($table,$where=null,$group_by=null,$on=array(),$using=array(),$join=array()) {
- $select = isset($group_by) ? "*" : 'count(*) as number';
-
- $query = $this->createSelectQuery($table,$select,$where,$group_by,null,null,$on,$using,$join);
+ $query = $this->createSelectQuery($table,'*',$where,$group_by,null,null,$on,$using,$join);
$this->query=$query;
- $this->queries[] = $query;
$ris = mysql_query($query);
if ($ris) {
-
- if (isset($group_by))
- {
- $num_rows = mysql_num_rows($ris);
- }
- else
- {
- $row = mysql_fetch_array($ris);
- $num_rows = $row['number'];
- }
-
- return (int)$num_rows;
+ $num_rows = mysql_num_rows($ris);
+ return $num_rows;
} else {
- return 0;
+ return false;
}
}
@@ -253,8 +182,6 @@ class Db_Mysql
$query = $this->createSelectQuery($table,"$func($field) AS m",$where,$group_by,null,null,$on,$using,$join);
$this->query = $query;
- $this->queries[] = $query;
-
$result = mysql_query($query);
if ($result)
{
@@ -296,8 +223,6 @@ class Db_Mysql
$query = $this->createSelectQuery($table,$fields,$where,$group_by,$order_by,$limit,$on,$using,$join);
$this->query = $query;
- $this->queries[] = $query;
-
$result = mysql_query($query);
return $this->getData($result);
}
@@ -334,73 +259,31 @@ class Db_Mysql
}
else
{
- return array();
+ return false;
}
}
-
- private function getFieldsFeature($feature, $table, $fields, $full = false, $associative = false)
+ //return an array containing all the types of the fields (indicated in $fields) of a table (indicated in $table)
+ public function getTypes($table, $fields)
{
$query = "DESCRIBE $table;";
$result = mysql_query($query);
$temp = array();
while ($row = mysql_fetch_assoc($result)) {
- if ($full)
- {
- $temp[$row['Field']] = $row[$feature];
- }
- else
- {
- $e = explode('(',$row[$feature]);
- $temp[$row['Field']] = strcmp($feature,"Type") === 0 ? strtolower(reset($e)) : reset($e);
- }
+ $temp[$row['Field']] = reset(explode('(',$row['Type']));
}
- $this->queries[] = $query;
-
- //return all fields types
- if ($fields === "*")
- {
- $fields = implode(",",array_keys($temp));
- }
-
$types = array();
$fields = explode(',',$fields);
for ($i = 0; $i < count($fields); $i++)
{
if (!array_key_exists($fields[$i],$temp)) return false;
-
- if ($associative)
- {
- $types[$fields[$i]] = $temp[$fields[$i]];
- }
- else
- {
- $types[] = $temp[$fields[$i]];
- }
+ $types[] = $temp[$fields[$i]];
}
return $types;
}
- //return an array containing all the keys of the fields (indicated in $fields) of a table (indicated in $table)
- public function getKeys($table, $fields, $full = false, $associative = false)
- {
- return $this->getFieldsFeature('Key', $table, $fields, $full, $associative);
- }
-
- //return an array containing all the default values of the fields (indicated in $fields) of a table (indicated in $table)
- public function getDefaultValues($table, $fields, $full = false, $associative = false)
- {
- return $this->getFieldsFeature('Default', $table, $fields, $full, $associative);
- }
-
- //return an array containing all the types of the fields (indicated in $fields) of a table (indicated in $table)
- public function getTypes($table, $fields, $full = false, $associative = false)
- {
- return $this->getFieldsFeature('Type', $table, $fields, $full, $associative);
- }
-
public function insert($table,$fields,$values) {
#$table is a string
@@ -428,8 +311,6 @@ class Db_Mysql
$values = implode(',',$values);
$query="INSERT INTO $table ($fields) VALUES ($values);";
$this->query = $query;
- $this->queries[] = $query;
-
$ris = mysql_query($query);
#check the result
@@ -438,34 +319,12 @@ class Db_Mysql
} else {
return false;
}
-
+
} else {
return false;
}
}
- //set the autocommit attribute
- public function setAutocommit($value)
- {
- }
-
- //set the transactionBatchSize attribute
- public function setTransactionBatchSize($size)
- {
- }
-
- //commit a batch of queries
- //$batch: array of queries
- public function commitBatch($batch)
- {
- }
-
- //commit the transaction
- public function commitTransaction()
- {
- return false;
- }
-
// Retrieves the ID generated for an AUTO_INCREMENT column by the previous query (usually INSERT).
public function lastId()
{
@@ -507,8 +366,6 @@ class Db_Mysql
$str=implode(',',$str);
$query="UPDATE $table SET $str $where;";
$this->query=$query;
- $this->queries[] = $query;
-
$ris = mysql_query($query);
#check the result
@@ -517,7 +374,6 @@ class Db_Mysql
} else {
return false;
}
-
} else {
return false;
}
@@ -533,8 +389,6 @@ class Db_Mysql
// }
$query="DELETE FROM $table $where;";
$this->query=$query;
- $this->queries[] = $query;
-
$ris = mysql_query($query);
#check the result
@@ -568,8 +422,6 @@ class Db_Mysql
public function query($query)
{
$this->query = $query;
- $this->queries[] = $query;
-
$result = mysql_query($query);
if ($result === false)
{
diff --git a/h-source/Library/Db/Mysqli.php b/h-source/Library/Db/Mysqli.php
index bd3ce1c..df57a54 100644
--- a/h-source/Library/Db/Mysqli.php
+++ b/h-source/Library/Db/Mysqli.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -27,31 +27,14 @@ if (!defined('EG')) die('Direct access not allowed!');
class Db_Mysqli
{
- private $autocommit = true;
- private $transactionBatchSize = 100;
-
- public $transactionBatch = array();
-
public $query = null; //the last query executed
- public $queries = array(); //array containing all the queries executed
-
public $charsetError = true; //true: non eccor occurred during the modification of the connection charset, false: one error occurred
public $charset = null; //the charset of the client connection
private static $instance = null; //instance of this class
private $db;
-
- private $charTypes = array('varchar','char');
- private $textTypes = array('tinytext','text','mediumtext','longtext');
- private $integerTypes = array('tinyint','smallint','int','mediumint','bigint');
- private $floatTypes = array('real','float','double');
- private $dateTypes = array('date');
- private $enumTypes = array('enum');
- private $decimalTypes = array('decimal');
- private $uniqueIndexStrings = array('UNI');
-
- private $fieldsType = array();
+ private $fieldsType = array('tinyint','smallint','int','mediumint','bigint','float','double');
//PHP-Mysql charset translation table
private $charsetTranslationTable = array(
@@ -70,8 +53,7 @@ class Db_Mysqli
private function __construct($host,$user,$pwd,$db_name)
{
- $this->fieldsType = array_merge($this->integerTypes, $this->floatTypes);
-
+
$this->db = new mysqli($host,$user,$pwd,$db_name);
if (mysqli_connect_error())
@@ -103,46 +85,7 @@ class Db_Mysqli
return self::$instance;
}
- public function getUniqueIndexStrings()
- {
- return $this->uniqueIndexStrings;
- }
-
- public function getTextTypes()
- {
- return $this->textTypes;
- }
-
- public function getDecimalTypes()
- {
- return $this->decimalTypes;
- }
-
- public function getEnumTypes()
- {
- return $this->enumTypes;
- }
-
- public function getCharTypes()
- {
- return $this->charTypes;
- }
-
- public function getIntegerTypes()
- {
- return $this->integerTypes;
- }
-
- public function getFloatTypes()
- {
- return $this->floatTypes;
- }
-
- public function getDateTypes()
- {
- return $this->dateTypes;
- }
-
+
//close the connection
public function disconnect()
{
@@ -227,30 +170,16 @@ class Db_Mysqli
public function get_num_rows($table,$where=null,$group_by=null,$on=array(),$using=array(),$join=array()) {
- $select = isset($group_by) ? "*" : 'count(*) as number';
-
- $query = $this->createSelectQuery($table,$select,$where,$group_by,null,null,$on,$using,$join);
+ $query = $this->createSelectQuery($table,'*',$where,$group_by,null,null,$on,$using,$join);
$this->query = $query;
- $this->queries[] = $query;
-
$ris = $this->db->query($query);
if ($ris) {
-
- if (isset($group_by))
- {
- $num_rows = $ris->num_rows;
- }
- else
- {
- $row = $ris->fetch_array();
- $num_rows = $row['number'];
- }
-
+ $num_rows = $ris->num_rows;
$ris->close();
- return (int)$num_rows;
+ return $num_rows;
} else {
- return 0;
+ return false;
}
}
@@ -259,8 +188,6 @@ class Db_Mysqli
$query = $this->createSelectQuery($table,"$func($field) AS m",$where,$group_by,null,null,$on,$using,$join);
$this->query = $query;
- $this->queries[] = $query;
-
$result = $this->db->query($query);
if ($result)
{
@@ -303,8 +230,6 @@ class Db_Mysqli
$query = $this->createSelectQuery($table,$fields,$where,$group_by,$order_by,$limit,$on,$using,$join);
$this->query = $query;
- $this->queries[] = $query;
-
$result = $this->db->query($query);
return $this->getData($result);
}
@@ -337,85 +262,44 @@ class Db_Mysqli
$result->close();
return $data;
} else {
- return array();
+ return false;
}
}
- private function getFieldsFeature($feature, $table, $fields, $full = false, $associative = false )
+ //return an array containing all the types of the fields (indicated in $fields) of a table (indicated in $table)
+ public function getTypes($table, $fields)
{
$query = "DESCRIBE $table;";
$result = $this->db->query($query);
$temp = array();
while ($row = $result->fetch_assoc()) {
- if ($full)
- {
- $temp[$row['Field']] = $row[$feature];
- }
- else
- {
- $e = explode('(',$row[$feature]);
- $temp[$row['Field']] = strcmp($feature,"Type") === 0 ? strtolower(reset($e)) : reset($e);
- }
+ $temp[$row['Field']] = reset(explode('(',$row['Type']));
}
$result->close();
- $this->queries[] = $query;
-
- //return all fields types
- if ($fields === "*")
- {
- $fields = implode(",",array_keys($temp));
- }
-
$types = array();
$fields = explode(',',$fields);
for ($i = 0; $i < count($fields); $i++)
{
if (!array_key_exists($fields[$i],$temp)) return false;
-
- if ($associative)
- {
- $types[$fields[$i]] = $temp[$fields[$i]];
- }
- else
- {
- $types[] = $temp[$fields[$i]];
- }
+ $types[] = $temp[$fields[$i]];
}
return $types;
}
- //return an array containing all the keys of the fields (indicated in $fields) of a table (indicated in $table)
- public function getKeys($table, $fields, $full = false, $associative = false)
- {
- return $this->getFieldsFeature('Key', $table, $fields, $full, $associative);
- }
-
- //return an array containing all the default values of the fields (indicated in $fields) of a table (indicated in $table)
- public function getDefaultValues($table, $fields, $full = false, $associative = false)
- {
- return $this->getFieldsFeature('Default', $table, $fields, $full, $associative);
- }
-
- //return an array containing all the types of the fields (indicated in $fields) of a table (indicated in $table)
- public function getTypes($table, $fields, $full = false, $associative = false)
- {
- return $this->getFieldsFeature('Type', $table, $fields, $full, $associative);
- }
-
public function insert($table,$fields,$values) {
+
#$table is a string
#$fields has to be a string with comma as separator: name1,name2,...
#$values has to be an array
-
$values = array_values($values);
if (strcmp($fields,'') !== 0)
{
//get the type of the fields
$types = $this->getTypes($table,$fields);
if (!$types) return false;
-
+
for($i = 0; $i < count($values); $i++)
{
if (!in_array($types[$i],$this->fieldsType))
@@ -431,103 +315,21 @@ class Db_Mysqli
$values = implode(',',$values);
$query="INSERT INTO $table ($fields) VALUES ($values);";
$this->query=$query;
- $this->queries[] = $query;
- if ($this->autocommit)
- {
- $ris = $this->db->query($query);
+ $ris = $this->db->query($query);
- #check the result
- if ($ris) {
- return true;
- } else {
- return false;
- }
- }
- else
- {
- $this->transactionBatch[] = $query;
+ #check the result
+ if ($ris) {
return true;
+ } else {
+ return false;
}
+
} else {
return false;
}
}
- //set the autocommit attribute
- public function setAutocommit($value)
- {
- if ($value === true or $value === false)
- {
- $this->autocommit = $value;
- $this->db->autocommit($value);
- }
- else
- {
- $this->autocommit = true;
- $this->db->autocommit(true);
- }
- }
-
- //set the transactionBatchSize attribute
- public function setTransactionBatchSize($size)
- {
- $this->transactionBatchSize = abs($size);
- }
-
- //commit a batch of queries
- //$batch: array of queries
- public function commitBatch($batch)
- {
- foreach ($batch as $sql)
- {
- $this->db->query($sql);
- }
-
- if (!$this->autocommit and $this->db->commit())
- {
- return true;
- }
- else
- {
- return false;
- }
- }
-
- //commit the transaction
- public function commitTransaction()
- {
- $returnArray = array();
-
- if (!$this->autocommit)
- {
- if (count($this->transactionBatch) > 0)
- {
- if ($this->transactionBatchSize === 0)
- {
- $returnArray[] = $this->commitBatch($this->transactionBatch);
- }
- else
- {
- $batchArray = array_chunk($this->transactionBatch, $this->transactionBatchSize);
-
- foreach ($batchArray as $batch)
- {
- $returnArray[] = $this->commitBatch($batch);
- }
- }
- }
- }
-
- if (count(array_filter($returnArray)) === count($returnArray))
- {
- $this->transactionBatch = array();
- return true;
- }
-
- return false;
- }
-
// Retrieves the ID generated for an AUTO_INCREMENT column by the previous query (usually INSERT).
public function lastId()
{
@@ -569,23 +371,13 @@ class Db_Mysqli
$str=implode(',',$str);
$query="UPDATE $table SET $str $where;";
$this->query=$query;
- $this->queries[] = $query;
-
- if ($this->autocommit)
- {
- $ris = $this->db->query($query);
+ $ris = $this->db->query($query);
- #check the result
- if ($ris) {
- return true;
- } else {
- return false;
- }
- }
- else
- {
- $this->transactionBatch[] = $query;
+ #check the result
+ if ($ris) {
return true;
+ } else {
+ return false;
}
} else {
return false;
@@ -602,8 +394,6 @@ class Db_Mysqli
// }
$query="DELETE FROM $table $where;";
$this->query=$query;
- $this->queries[] = $query;
-
$ris = $this->db->query($query);
#check the result
@@ -638,8 +428,6 @@ class Db_Mysqli
public function query($query)
{
$this->query = $query;
- $this->queries[] = $query;
-
$result = $this->db->query($query);
if ($result === true)
{
diff --git a/h-source/Library/Email.php b/h-source/Library/Email.php
index 369af20..9d2ff19 100644
--- a/h-source/Library/Email.php
+++ b/h-source/Library/Email.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
diff --git a/h-source/Library/ErrorReporting.php b/h-source/Library/ErrorReporting.php
index ab66091..2cb8aed 100644
--- a/h-source/Library/ErrorReporting.php
+++ b/h-source/Library/ErrorReporting.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
diff --git a/h-source/Library/Factory/Db.php b/h-source/Library/Factory/Db.php
index 17afa1a..32a82c1 100755
--- a/h-source/Library/Factory/Db.php
+++ b/h-source/Library/Factory/Db.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
diff --git a/h-source/Library/Factory/Strings.php b/h-source/Library/Factory/Strings.php
index 8917590..3e766bd 100644
--- a/h-source/Library/Factory/Strings.php
+++ b/h-source/Library/Factory/Strings.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
diff --git a/h-source/Library/Files/Log.php b/h-source/Library/Files/Log.php
index a060ba3..7eda7b7 100644
--- a/h-source/Library/Files/Log.php
+++ b/h-source/Library/Files/Log.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
diff --git a/h-source/Library/Files/Upload.php b/h-source/Library/Files/Upload.php
index 19b5fd1..7dbc7d1 100755
--- a/h-source/Library/Files/Upload.php
+++ b/h-source/Library/Files/Upload.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -230,8 +230,7 @@ class Files_Upload
{
if (strstr($file,'.'))
{
- $extArray = explode('.', $file);
- return strtolower(end($extArray));
+ return strtolower(end(explode('.', $file)));
}
return '';
}
@@ -269,23 +268,6 @@ class Files_Upload
}
- //get a not existing folder name
- public function getUniqueFolderName($folder,$int = 0)
- {
- $token = $int === 0 ? null : $this->params['fileUploadBeforeTokenChar'].$int;
-
- $newName = $folder.$token;
- if (!is_dir($this->base.$this->directory.$newName))
- {
- return $newName;
- }
- else
- {
- return $this->getUniqueFolderName($folder,$int+1);
- }
-
- }
-
protected function parentDir() { #individuo la cartella madre
$folders = explode(self::DS,$this->directory);
@@ -351,7 +333,7 @@ class Files_Upload
}
//check if the $name folder is empty or not
- public function isEmpty($name)
+ protected function isEmpty($name)
{
$items = scandir($name);
foreach( $items as $this_file ) {
diff --git a/h-source/Library/Form/Checkbox.php b/h-source/Library/Form/Checkbox.php
index 91191a9..497c097 100755
--- a/h-source/Library/Form/Checkbox.php
+++ b/h-source/Library/Form/Checkbox.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -39,7 +39,7 @@ class Form_Checkbox extends Form_Entry
$returnString .= $wrap[1];
$returnString .= $this->getLabelTag();
$returnString .= $wrap[2];
- $returnString .= Html_Form::checkbox($this->entryName, $value, $this->options, $this->className,$this->idName,$this->attributes);
+ $returnString .= Html_Form::checkbox($this->entryName, $value, $this->options, $this->className,$this->idName);
$returnString .= $wrap[3];
$returnString .="</div>\n";
$returnString .= $wrap[4];
diff --git a/h-source/Library/Form/Entry.php b/h-source/Library/Form/Entry.php
index fa3b84f..6f45557 100755
--- a/h-source/Library/Form/Entry.php
+++ b/h-source/Library/Form/Entry.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -33,7 +33,6 @@ abstract class Form_Entry {
public $labelClass = null; //the class of the tag of the label
public $options = array(); //options (if the entry is a <select> entry or a radio button). Associative array or comma-divided list.
public $reverse = null; //reverse label with value in select entries
- public $attributes = null; //attributes of the field
public $defaultValue = '';
public $wrap = array();
public $deleteButton = null;
diff --git a/h-source/Library/Form/File.php b/h-source/Library/Form/File.php
index f1e7d2d..ac9b8ab 100644
--- a/h-source/Library/Form/File.php
+++ b/h-source/Library/Form/File.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -39,7 +39,7 @@ class Form_File extends Form_Entry
$returnString .= $wrap[1];
$returnString .= $this->getLabelTag();
$returnString .= $wrap[2];
- $returnString .= Html_Form::fileUpload($this->entryName, $value, $this->className, $this->idName, $this->attributes);
+ $returnString .= Html_Form::fileUpload($this->entryName, $value, $this->className, $this->idName);
if (is_array($this->deleteButton))
{
$sname = isset($this->deleteButton[0]) ? $this->deleteButton[0] : 'delete_'.$this->entryName;
diff --git a/h-source/Library/Form/Form.php b/h-source/Library/Form/Form.php
index 9b05c51..a1a9fda 100755
--- a/h-source/Library/Form/Form.php
+++ b/h-source/Library/Form/Form.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -25,15 +25,6 @@ if (!defined('EG')) die('Direct access not allowed!');
//create the HTML of the whole form
class Form_Form {
- //default attributes of the entries
- public static $defaultEntryAttributes = array(
- "entryClass" => null,
- "className" => null,
- "idName" => null,
- "submitClass" => "btn btn-primary",
- "formWrap" => null,
- );
-
public $entry = array(); //associative array containing the entries of the form (objects that inherit the class form_entryModel). Each element of the array corresponds to one field of the table
public $action = null; //the action of the form
@@ -62,9 +53,8 @@ class Form_Form {
{
throw new Exception("class <b>$entryObjName</b> not defined: the entry <b>$entryName</b> can't be set");
}
-
$this->entry[$entryName] = new $entryObjName($entryName);
- $this->entry[$entryName]->labelString = getFieldLabel($entryName);
+ $this->entry[$entryName]->labelString = $entryName.':';
//set the type
$this->entry[$entryName]->type = $entryType;
if (isset($options))
@@ -82,18 +72,17 @@ class Form_Form {
$type = array_key_exists('type',$entry) ? $entry['type'] : 'InputText';
$options = array_key_exists('options',$entry) ? $entry['options'] : null;
$this->setEntry($name,$type,$options);
-
- $entryClass = array_key_exists('entryClass',$entry) ? $entry['entryClass'] : self::$defaultEntryAttributes['entryClass'];
- $labelString = array_key_exists('labelString',$entry) ? $entry['labelString'] : getFieldLabel($name);
- $idName = array_key_exists('idName',$entry) ? $entry['idName'] : self::$defaultEntryAttributes['idName'];
- $className = array_key_exists('className',$entry) ? $entry['className'] : self::$defaultEntryAttributes['className'];
+
+ $entryClass = array_key_exists('entryClass',$entry) ? $entry['entryClass'] : null;
+ $labelString = array_key_exists('labelString',$entry) ? $entry['labelString'] : "$name:";
+ $idName = array_key_exists('idName',$entry) ? $entry['idName'] : null;
+ $className = array_key_exists('className',$entry) ? $entry['className'] : null;
$labelClass = array_key_exists('labelClass',$entry) ? $entry['labelClass'] : null;
$defaultValue = array_key_exists('defaultValue',$entry) ? $entry['defaultValue'] : null;
$wrap = array_key_exists('wrap',$entry) ? $entry['wrap'] : array();
$deleteButton = array_key_exists('deleteButton',$entry) ? $entry['deleteButton'] : null;
$reverse = array_key_exists('reverse',$entry) ? $entry['reverse'] : null;
- $attributes = array_key_exists('attributes',$entry) ? $entry['attributes'] : null;
-
+
$this->entry[$name]->entryClass = $entryClass;
$this->entry[$name]->labelString = $labelString;
$this->entry[$name]->idName = $idName;
@@ -103,13 +92,12 @@ class Form_Form {
$this->entry[$name]->wrap = $wrap;
$this->entry[$name]->deleteButton = $deleteButton;
$this->entry[$name]->reverse = $reverse;
- $this->entry[$name]->attributes = $attributes;
}
}
//function to create the HTML of the form
//$values: an associative array ('entryName'=>'value')
- //$subset: subset to print (comma seprated list of string or array)
+ //$subset: subset to print
public function render($values = null, $subset = null)
{
@@ -125,99 +113,27 @@ class Form_Form {
$fid = isset($this->id) ? "id='".$this->id."'" : null;
$fname = isset($this->name) ? "name='".$this->name."'" : null;
$fclass = isset($this->className) ? "class='".$this->className."'" : null;
- $fenctype = isset($this->enctype) ? " enctype='".$this->enctype."' " : null;
+ $fenctype = isset($this->enctype) ? " enctype=".$this->enctype." " : null;
$htmlForm = "<form $fname $fclass $fid action='".Url::getRoot($this->action)."' method='".$this->method."' $fenctype>\n";
- if (!isset($subset))
- {
- $subset = array_keys($values);
- }
- else
- {
- $subset = !is_array($subset) ? explode(',',$subset) : $subset;
- }
-// $subset = (isset($subset)) ? explode(',',$subset) : array_keys($values);
-
- //first cicle: write the HTML of tabs if there are any
- $tabsHtml = null;
- $fCount = 0;
- foreach ($subset as $key => $entry)
- {
- if (is_array($entry))
- {
- $currClass = $fCount === 0 ? "current_tab" : null;
- $cleanKey = encode($key);
- $tabsHtml .= "\t<li class='form_tab_li $currClass'><a rel='tab_$cleanKey' class='form_tab_a form_tab_a_$cleanKey' href='#'>$key</a></li>\n";
- $fCount++;
- }
- }
- if (isset($tabsHtml))
- {
- $htmlForm .= "<ul class='form_tab_ul'>\n$tabsHtml\n</ul>\n";
- }
+ $subset = (isset($subset)) ? explode(',',$subset) : array_keys($values);
- $fCount = 0;
- foreach ($subset as $k => $entry)
+ foreach ($subset as $entry)
{
-
- $cleanK = encode($k);
- if (!is_array($entry))
- {
- if (array_key_exists($entry,$this->entry))
- {
- $value = array_key_exists($entry,$values) ? $values[$entry] : $this->entry[$entry]->defaultValue;
- $htmlForm .= $this->entry[$entry]->render($value);
- }
- }
- else
+
+ if (array_key_exists($entry,$this->entry))
{
- $tHtml = null;
- $displClass = $fCount === 0 ? null : "display_none";
- foreach ($entry as $e)
- {
- if (array_key_exists($e,$this->entry))
- {
- $value = array_key_exists($e,$values) ? $values[$e] : $this->entry[$e]->defaultValue;
- $tHtml .= $this->entry[$e]->render($value);
- }
- }
- $htmlForm .= "<div id='tab_$cleanK' class='tab_description_item $displClass'>$tHtml</div>";
- $fCount++;
+ $value = array_key_exists($entry,$values) ? $values[$entry] : $this->entry[$entry]->defaultValue;
+ $htmlForm .= $this->entry[$entry]->render($value);
}
+
}
- $htmlForm .= "<div class='submit_entry'>";
foreach ($this->submit as $name => $value)
{
- if (!is_array($value))
- {
- $submitClass= "";
- if (!is_array(self::$defaultEntryAttributes['submitClass']))
- {
- $submitClass = self::$defaultEntryAttributes['submitClass'];
- }
- else
- {
- if (array_key_exists($value,self::$defaultEntryAttributes['submitClass']))
- {
- $submitClass = self::$defaultEntryAttributes['submitClass'][$value];
- }
- }
- $htmlForm .= "<span class='submit_entry_$value'>".Html_Form::submit($name, $value, $submitClass, $name)."</span>";
- }
- else
- {
- array_unshift($value,$name);
- $htmlForm .= call_user_func_array(array("Html_Form","submit"),$value);
- }
+ $htmlForm .= "<div class='inputEntry'>\n<input id='".$name."' type='submit' name='$name' value='$value'>\n</div>\n";
}
- $htmlForm .= "</div>";
$htmlForm .= "</form>\n";
-
- if (isset(self::$defaultEntryAttributes["formWrap"]) and is_array(self::$defaultEntryAttributes["formWrap"]) and count(self::$defaultEntryAttributes["formWrap"]) === 2)
- {
- return self::$defaultEntryAttributes["formWrap"][0] . $htmlForm . self::$defaultEntryAttributes["formWrap"][1];
- }
return $htmlForm;
}
diff --git a/h-source/Library/Form/Hidden.php b/h-source/Library/Form/Hidden.php
index c2185b9..c589662 100755
--- a/h-source/Library/Form/Hidden.php
+++ b/h-source/Library/Form/Hidden.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -33,7 +33,7 @@ class Form_Hidden extends Form_Entry
public function render($value = null)
{
- $returnString = Html_Form::hidden($this->entryName, $value, $this->className, $this->idName, $this->attributes);
+ $returnString = Html_Form::hidden($this->entryName, $value);
return $returnString;
}
diff --git a/h-source/Library/Form/Html.php b/h-source/Library/Form/Html.php
index a7181cc..e5c9989 100644
--- a/h-source/Library/Form/Html.php
+++ b/h-source/Library/Form/Html.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
diff --git a/h-source/Library/Form/InputText.php b/h-source/Library/Form/InputText.php
index 086c0a1..344264e 100755
--- a/h-source/Library/Form/InputText.php
+++ b/h-source/Library/Form/InputText.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -39,7 +39,7 @@ class Form_InputText extends Form_Entry
$returnString .= $wrap[1];
$returnString .= $this->getLabelTag();
$returnString .= $wrap[2];
- $returnString .= Html_Form::input($this->entryName, $value, $this->className, $this->idName, $this->attributes);
+ $returnString .= Html_Form::input($this->entryName, $value, $this->className, $this->idName);
$returnString .= $wrap[3];
$returnString .="</div>\n";
$returnString .= $wrap[4];
diff --git a/h-source/Library/Form/Password.php b/h-source/Library/Form/Password.php
index 41fbc8e..9bfc68b 100644
--- a/h-source/Library/Form/Password.php
+++ b/h-source/Library/Form/Password.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -39,7 +39,7 @@ class Form_Password extends Form_Entry
$returnString .= $wrap[1];
$returnString .= $this->getLabelTag();
$returnString .= $wrap[2];
- $returnString .= Html_Form::password($this->entryName, null, $this->className, $this->idName, $this->attributes);
+ $returnString .= Html_Form::password($this->entryName, null, $this->className);
$returnString .= $wrap[3];
$returnString .="</div>\n";
$returnString .= $wrap[4];
diff --git a/h-source/Library/Form/Radio.php b/h-source/Library/Form/Radio.php
index 10154be..4f596ed 100755
--- a/h-source/Library/Form/Radio.php
+++ b/h-source/Library/Form/Radio.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -39,7 +39,7 @@ class Form_Radio extends Form_Entry
$returnString .= $wrap[1];
$returnString .= $this->getLabelTag();
$returnString .= $wrap[2];
- $returnString .= Html_Form::radio($this->entryName,$value,$this->options,$this->className, 'after', $this->idName, $this->attributes);
+ $returnString .= Html_Form::radio($this->entryName,$value,$this->options,$this->className, 'after', $this->idName);
$returnString .= $wrap[3];
$returnString .="</div>\n";
$returnString .= $wrap[4];
diff --git a/h-source/Library/Form/Select.php b/h-source/Library/Form/Select.php
index 8b2a634..53d7632 100755
--- a/h-source/Library/Form/Select.php
+++ b/h-source/Library/Form/Select.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -39,7 +39,7 @@ class Form_Select extends Form_Entry
$returnString .= $wrap[1];
$returnString .= $this->getLabelTag();
$returnString .= $wrap[2];
- $returnString .= Html_Form::select($this->entryName,$value,$this->options,$this->className, $this->idName, $this->reverse, $this->attributes);
+ $returnString .= Html_Form::select($this->entryName,$value,$this->options,$this->className, $this->idName, $this->reverse);
$returnString .= $wrap[3];
$returnString .="</div>\n";
$returnString .= $wrap[4];
diff --git a/h-source/Library/Form/Textarea.php b/h-source/Library/Form/Textarea.php
index f294b0a..aaaf19e 100755
--- a/h-source/Library/Form/Textarea.php
+++ b/h-source/Library/Form/Textarea.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -39,7 +39,7 @@ class Form_Textarea extends Form_Entry
$returnString .= $wrap[1];
$returnString .= $this->getLabelTag();
$returnString .= $wrap[2];
- $returnString .= Html_Form::textarea($this->entryName, $value, $this->className, $this->idName, $this->attributes);
+ $returnString .= Html_Form::textarea($this->entryName, $value, $this->className, $this->idName);
$returnString .= $wrap[3];
$returnString .="</div>\n";
$returnString .= $wrap[4];
diff --git a/h-source/Library/Functions.php b/h-source/Library/Functions.php
index ef86812..1477680 100755
--- a/h-source/Library/Functions.php
+++ b/h-source/Library/Functions.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -108,24 +108,12 @@ SANITIZE DEEP
function stripslashesDeep($value) {
if(get_magic_quotes_gpc()) {#if stripslashes
- return array_map_recursive('stripslashes', $value);
+ return array_map('stripslashes', $value);
}
return $value;
}
-//from http://www.php.net/array_map#112857
-function array_map_recursive($callback, $array) {
- foreach ($array as $key => $value) {
- if (is_array($array[$key])) {
- $array[$key] = array_map_recursive($callback, $array[$key]);
- }
- else {
- $array[$key] = call_user_func($callback, $array[$key]);
- }
- }
- return $array;
-}
-
+
function sanitizeHtmlDeep($value) {
return array_map('sanitizeHtml', $value);
}
@@ -175,9 +163,7 @@ function sha1Deep($value)
return array_map('sha1', $value);
}
-function strip_tagsDeep($value) {
- return array_map('strip_tags', $value);
-}
+
@@ -242,75 +228,6 @@ function wrap($string,$tag_class) {#wrap the string with the tag and its class
return $str_front.$string.$str_rear;
}
-//check that $date is a ISO date (YYYY-MM-DD)
-function checkIsoDate($date)
-{
- if (preg_match('/^[0-9]{4}\-[0-9]{2}\-[0-9]{2}$/',$date))
- {
- $dateArray = explode('-',$date);
- if ((int)$dateArray[1] <= 12 and (int)$dateArray[1] >= 1 )
- {
- if ((int)$dateArray[2] >= 1 and (int)$dateArray[2] <= 31)
- {
- return checkdate((int)$dateArray[1],(int)$dateArray[2],(int)$dateArray[0]);
- }
- }
- }
- return false;
-}
-
-//check if $string is an integer string
-function checkInteger($string)
-{
- if (preg_match('/^\-?[0-9]{1,}$/',$string))
- {
- return true;
- }
- return false;
-}
-
-//check if $string is decimal with the format indicated in $format
-//$format: M,D M is the maximum number of digits, D is the number of digits to the right of the decimal point
-function checkDecimal($string, $format)
-{
- $t = explode(",",$format);
- $M = (int)$t[0];
- $D = (int)$t[1];
- $I = $M - $D;
-
- if (preg_match("/^[0-9]{1,$I}(\.[0-9]{1,$D})?$/",$string))
- {
- return true;
- }
- return false;
-}
-
-//get label name from field name
-function getFieldLabel($fieldName)
-{
- if (class_exists("Lang_".Params::$language."_Formats_Fields"))
- {
- return call_user_func(array("Lang_".Params::$language."_Formats_Fields", "getLabel"), $fieldName);
- }
-
- return call_user_func(array("Lang_En_Formats_Fields", "getLabel"), $fieldName);
-
-// if (strstr($fieldName,","))
-// {
-// $temp = explode(",",$fieldName);
-// for ($i=0; $i< count($temp); $i++)
-// {
-// $temp[$i] = getFieldLabel($temp[$i]);
-// }
-// return implode (" and ",$temp);
-// }
-// else
-// {
-// $fieldName = str_replace("_"," ", $fieldName);
-// return ucfirst($fieldName);
-// }
-}
-
//generate a random password
//$start: start number of mt_rand
//$end: end number of mt_rand
@@ -349,7 +266,7 @@ function getIp()
$ip = sanitizeIp($_SERVER["HTTP_X_FORWARDED_FOR"]);
} else if (!empty($_SERVER["HTTP_CLIENT_IP"])) {
$ip = sanitizeIp($_SERVER["HTTP_CLIENT_IP"]);
- } else if (!empty($_SERVER["REMOTE_ADDR"])) {
+ } else {
$ip = sanitizeIp($_SERVER["REMOTE_ADDR"]);
}
} else {
@@ -357,7 +274,7 @@ function getIp()
$ip = sanitizeIp(getenv( 'HTTP_X_FORWARDED_FOR' ));
} else if ( getenv( 'HTTP_CLIENT_IP' ) !== false ) {
$ip = sanitizeIp(getenv( 'HTTP_CLIENT_IP' ));
- } else if ( getenv( 'REMOTE_ADDR' ) !== false ) {
+ } else {
$ip = sanitizeIp(getenv( 'REMOTE_ADDR' ));
}
}
@@ -377,76 +294,6 @@ function getUserAgent() {
}
}
-//encode a string to drop ugly characters
-function encode($url)
-{
- $url = utf8_decode(html_entity_decode($url,ENT_QUOTES,'UTF-8'));
-
- $temp = null;
-
- for ($i=0;$i<eg_strlen($url); $i++)
- {
-// echo substr($url,$i,1)."<br />";
- if (strcmp(substr($url,$i,1),' ') === 0)
- {
- $temp .= '_';
- }
- else if (strcmp(substr($url,$i,1),"'") === 0)
- {
- $temp .= '';
- }
- else
- {
- if (preg_match('/^[a-zA-Z\_0-9]$/',substr($url,$i,1)))
- {
- $temp .= substr($url,$i,1);
- }
- else
- {
- $temp .= '_';
- }
- }
- }
-
- $temp = urlencode($temp);
- return $temp;
-}
-
-function callFunction($function, $string, $caller = "CallFunction")
-{
- if (strstr($function,'::')) //static method
- {
- $temp = explode('::',$function);
-
- if (!method_exists($temp[0],$temp[1]))
- {
- throw new Exception('Error in <b>'.$caller.'</b>: method <b>'.$temp[1].'</b> of class <b>'.$temp[0].'</b> does not exists.');
- }
-
- return call_user_func(array($temp[0], $temp[1]),$string);
- }
- else if (strstr($function,'.')) //method
- {
- $temp = explode('.',$function);
-
- $obj = new $temp[0]; //new instance of the object
-
- if (!method_exists($obj,$temp[1]))
- {
- throw new Exception('Error in <b>'.$caller.'</b>: method <b>'.$temp[1].'</b> of class <b>'.$temp[0].'</b> does not exists.');
- }
-
- return call_user_func(array($obj, $temp[1]),$string);
- }
- else //function
- {
- if (!function_exists($function)) {
- throw new Exception('Error in <b>'.$caller.'</b>: function <b>'.$function.'</b> does not exists.');
- }
- //apply the function
- return call_user_func($function,$string);
- }
-}
function xml_encode($string)
{
@@ -457,23 +304,4 @@ function xml_encode($string)
}
return strtr($string, $trans);
-}
-
-//Convert Hex Color to RGB
-//http://bavotasan.com/2011/convert-hex-color-to-rgb-using-php/
-function hex2rgb($hex) {
- $hex = str_replace("#", "", $hex);
-
- if(strlen($hex) == 3) {
- $r = hexdec(substr($hex,0,1).substr($hex,0,1));
- $g = hexdec(substr($hex,1,1).substr($hex,1,1));
- $b = hexdec(substr($hex,2,1).substr($hex,2,1));
- } else {
- $r = hexdec(substr($hex,0,2));
- $g = hexdec(substr($hex,2,2));
- $b = hexdec(substr($hex,4,2));
- }
- $rgb = array($r, $g, $b);
- //return implode(",", $rgb); // returns the rgb values separated by commas
- return $rgb; // returns an array with the rgb values
-}
+} \ No newline at end of file
diff --git a/h-source/Library/HeaderObj.php b/h-source/Library/HeaderObj.php
index 2d52e1d..994eb16 100644
--- a/h-source/Library/HeaderObj.php
+++ b/h-source/Library/HeaderObj.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
diff --git a/h-source/Library/Helper/Array.php b/h-source/Library/Helper/Array.php
index dbdda4f..329463f 100755
--- a/h-source/Library/Helper/Array.php
+++ b/h-source/Library/Helper/Array.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
diff --git a/h-source/Library/Helper/Html.php b/h-source/Library/Helper/Html.php
index 9e25bb4..81a9bdd 100755
--- a/h-source/Library/Helper/Html.php
+++ b/h-source/Library/Helper/Html.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
diff --git a/h-source/Library/Helper/List.php b/h-source/Library/Helper/List.php
index 81b5345..ba59643 100755
--- a/h-source/Library/Helper/List.php
+++ b/h-source/Library/Helper/List.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -25,9 +25,6 @@ if (!defined('EG')) die('Direct access not allowed!');
//class to create the HTML of a list of records
class Helper_List extends Helper_Html {
- //table attributes
- static public $tableAttributes = array('class'=>'listTable','cellspacing'=>'0');
-
private $__rowArray = array(); //the current associative array representing the database record
protected $_itemsList = array(); //2-dimensional associative array containing the list items
@@ -37,7 +34,7 @@ class Helper_List extends Helper_Html {
protected $_recordNumber = null; //number of records from the table
- protected $_allowedItems = array('simpleLink','simpleText','delForm','editForm','associateForm','moveupForm','movedownForm','Form','ledit','link','text','checkbox','input'); //type of items allowed
+ protected $_allowedItems = array('simpleLink','simpleText','delForm','editForm','associateForm','moveupForm','movedownForm','Form','ledit','link','text'); //type of items allowed
//it can be: both, top, bottom, none
protected $_boundaries = 'none';
@@ -45,12 +42,6 @@ class Helper_List extends Helper_Html {
//array of filters
protected $_filters = array();
- //array of bulk actions
- protected $_bulkActions = array();
-
- //set to false if you don't want that the filters are created inside the table
- public $showFilters = true;
-
//set if the submit buttons have to be images or not (it can be yse or not)
public $submitImageType = 'yes';
@@ -63,6 +54,9 @@ class Helper_List extends Helper_Html {
//properties of columns
public $colProperties = array();
+ //table attributes
+ public $tableAttributes = array('class'=>'listTable','cellspacing'=>'0');
+
//$position: array. First element: page number, second element: number of pages
public $position = array();
@@ -74,15 +68,12 @@ class Helper_List extends Helper_Html {
public $pageArg = null; //the key of the viewArgs array representing the page number. $this->viewArgs[$this->pageArg] is set to 1 if $this->pageArg !== null
- //if the filter forms have to be aggregated in a unique form or if they have to be left separated
- public $aggregateFilters = false;
-
public function __construct() {
//get the generic language class
$this->strings = Factory_Strings::generic(Params::$language);
- $baseUrl = Url::getRoot().'Public/Img/Icons/elementary_2_5/';
+ $baseUrl = 'http://'.DOMAIN_NAME.'/Public/Img/Icons/elementary_2_5/';
//set the files of the images
$this->submitImages = array(
@@ -156,39 +147,17 @@ class Helper_List extends Helper_Html {
//set the filters
//$filters: array whose elements are the viewArgs to be used for the filters forms
- //or null
public function setFilters($filters)
{
$this->_filters = $filters;
}
-
- //set $this->aggregateFilters equal to true
- public function aggregateFilters()
- {
- $this->aggregateFilters = true;
- }
-
- //set the bulk actions
- //$bulkActions: associative array.
- //key: class of the inputs whose elements have to be selected and serialized by javascript in the following way: data-primary-key:value_attribute|data-primary-key:value_attribute|data-primary-key:value_attribute|...
- //value: array with two elements whose first element is the bulk action to be sent as a key of $_POST, second element is the human readable name of the action, third element can be the string "confirm" (if the user has to confirm the action) or undefined
- //example:
- // $bulkActions = array(
- // "input_category_id_order" => array("sortAction","Sort elements"),
- // "checkbox_category_id" => array("deleteAction","Delete elements","confirm"),
- // );
- public function setBulkActions($bulkActions)
- {
- $this->_bulkActions = $bulkActions;
- }
//check that the ViewArgs array is complete
public function checkViewArgs()
{
foreach ($this->_filters as $field)
{
- $key = !is_array($field) ? $field : $field[0];
- if (!array_key_exists($key,$this->viewArgs) and strcmp($key,null) !== 0) return false;
+ if (!array_key_exists($field,$this->viewArgs) and strcmp($field,null) !== 0) return false;
}
return true;
}
@@ -203,48 +172,47 @@ class Helper_List extends Helper_Html {
public function replaceFields($string,$rowArray) {
$this->__rowArray = $rowArray; //used by the replaceField method
- $string = preg_replace_callback('/(\;)(.*?)(\;)/', array($this, 'replaceField') ,$string);
+ $string = preg_replace_callback('/(\;)(.*?)(\;)/', 'Helper_List::replaceField' ,$string);
return $string;
}
- //get : or . as char used to separate table and field
- public function getChar($string)
- {
- return strstr($string,':') ? ':' : '.';
- }
-
//replace a single string wrapped by ; with its correspondent value taken by the $recordArray associative array (a row of the select query)
public function replaceField($match)
{
$string = $match[2];
- //check if a function has been indicated
- if (strstr($string,'|'))
- {
- //get the function
- $firstArray = explode('|',$string);
- if (strstr($firstArray[1],':') or strstr($firstArray[1],'.'))
+ if (strstr($string,':') or strstr($string,'.')) {
+ if (strstr($string,':'))
+ {
+ $char = ':';
+ }
+ else
{
+ $char = '.';
+ }
+ //check if a function has been indicated
+ if (strstr($string,'|'))
+ {
+ //get the function
+ $firstArray = explode('|',$string);
$func = $firstArray[0];
//replace the fields
- $char = $this->getChar($firstArray[1]);
$temp = explode($char,$firstArray[1]);
$string = $this->__rowArray[$temp[0]][$temp[1]];
- $string = callFunction($func,$string,__METHOD__);
+ if (!function_exists($func)) {
+ throw new Exception('Error in <b>'.__METHOD__.'</b>: function <b>'.$func.'</b> does not exists..');
+ }
+ //apply the function
+ $string = call_user_func($func,$string);
}
- }
- else
- {
- if (strstr($string,':') or strstr($string,'.'))
+ else
{
- $char = $this->getChar($string);
$temp = explode($char,$string);
$string = $this->__rowArray[$temp[0]][$temp[1]];
}
}
-
return $string;
}
@@ -259,8 +227,8 @@ class Helper_List extends Helper_Html {
}
//wrap the column with the tag td
- public function wrapColumn($string, $className = null, $tag = "td") {
- return wrap($string,array($tag=>$className));
+ public function wrapColumn($string, $className = null) {
+ return wrap($string,array('td'=>$className));
}
//wrap the row with the tag tr
@@ -269,7 +237,7 @@ class Helper_List extends Helper_Html {
}
public function wrapList($string) {
- return wrap($string,array('table'=>self::$tableAttributes));
+ return wrap($string,array('table'=>$this->tableAttributes));
}
//method to create the HTML of the head of the table
@@ -280,18 +248,13 @@ class Helper_List extends Helper_Html {
foreach ($this->_head as $item) {
$temp = $item['action'];
- if (preg_match('/\[\[bulkselect:(.*?)\]\]/',$temp,$matches))
- {
- $temp = Html_Form::checkbox("bulkselect_".$matches[1],"","BS","bulk_select_checkbox",null,"data-class='".$matches[1]."'");
- }
-
$prop = $item['type'];
if (isset($this->colProperties[$count]))
{
$prop = $this->colProperties[$count];
}
- $htmlHead .= $this->wrapColumn($temp, $prop, "th");
+ $htmlHead .= $this->wrapColumn($temp,$prop);
$count++;
}
@@ -299,27 +262,7 @@ class Helper_List extends Helper_Html {
return $htmlHead;
}
- //return an array with all the filters in a 1-dimensional array
- public function getFiltersList()
- {
- $filterList = array();
-
- foreach ($this->_filters as $f)
- {
- if (is_array($f))
- {
- $filterList[] = $f[0];
- }
- else
- {
- $filterList[] = $f;
- }
- }
-
- return $filterList;
- }
-
- //method to create the HTML of the filters input
+ //method to create the HTML of the head of the table
public function createFilters() {
$htmlFilters = null;
@@ -339,91 +282,18 @@ class Helper_List extends Helper_Html {
$html = '&nbsp';
if (isset($this->_filters[$count]))
{
- if (!is_array($this->_filters[$count]))
- {
- $html = $this->filterForm($this->_filters[$count]);
- }
- else
- {
- $html = call_user_func_array(array($this,"filterForm"),$this->_filters[$count]);
-// $html = $this->filterForm($this->_filters[$count][0],$this->_filters[$count][1]);
- }
- }
-
- //wrap single cell if filters doesn't have to be aggregate
- if (!$this->aggregateFilters)
- {
- $htmlFilters .= !$this->showFilters ? $html : $this->wrapColumn($html,$prop);
+ $html = $this->filterForm($this->_filters[$count]);
}
- else
- {
- $htmlFilters .= $html;
- }
-
+ $htmlFilters .= $this->wrapColumn($html,$prop);
+
$count++;
}
-
- //wrap an aggregate cell if filters have to be aggregate
- if ($this->aggregateFilters)
- {
- $colspan = count($this->_itemsList);
- $formTop = "<form class='list_filter_form' action='".Url::getRoot($this->url)."' method='GET'>\n";
- $imgSrc = Url::getRoot('Public/Img/Icons/elementary_2_5/find.png');
-
- $formBottom = "";
- $emptyFilterStatusArray = array();
- $filtersList = $this->getFiltersList();
- foreach ($this->viewArgs as $k => $v)
- {
- if (!in_array($k,$filtersList))
- {
- $emptyFilterStatusArray[] = "$k=$v";
- $formBottom .= "<input type='hidden' name='".$k."' value='$v' />";
- }
- }
- $emptyFilterStatus = implode("&",$emptyFilterStatusArray);
-
- $formBottom .= "<a class='list_filter_clear_link' title='".$this->strings->gtext('clear the filter')."' href='".Url::getRoot($this->url)."?".$emptyFilterStatus."'><img src='".Url::getRoot()."/Public/Img/Icons/elementary_2_5/clear_filter.png' /></a>";
-
- $formBottom .= "<input class='list_filter_submit' type='image' title='".$this->strings->gtext('filter')."' src='".$imgSrc."' value='trova'>\n";
-
- $formBottom .= "</form>";
-
- $htmlFilters = !$this->showFilters ? $formTop.$htmlFilters.$formBottom : $this->wrapColumn($formTop.$htmlFilters.$formBottom,array("class"=>"aggregate_filters_td","colspan"=>$colspan));
-
- }
}
}
return $htmlFilters;
}
- //create the HTML of the select of the bulk actions
- public function createBulkActionsSelect()
- {
- $htmlBulkSelect = null;
- $colspan = count($this->_itemsList);
-
- if (count($this->_bulkActions) > 0)
- {
- $htmlBulkSelect .= "<span class='bulk_actions_select_label'>".$this->strings->gtext('Actions')."</span>: <select data-url='".Url::getRoot(null).$this->url.$this->viewStatus."' class='bulk_actions_select' name='bulk_select'>";
-
- $htmlBulkSelect .= "<option data-class='0' value='0'>".$this->strings->gtext('-- Select bulk action --')."</option>";
-
- foreach ($this->_bulkActions as $class => $action)
- {
- $class = str_replace("+","",$class);
- $confirm = isset($action[2]) ? "data-confirm='Y'" : "data-confirm='N'";
- $htmlBulkSelect .= "<option $confirm data-class='$class' value='".$action[0]."'>".$action[1]."</option>";
- }
-
- $htmlBulkSelect .= "</select>";
- $htmlBulkSelect = $this->wrapColumn($htmlBulkSelect,array("class"=>"bulk_actions_td","colspan"=>$colspan));
- }
-
- return $htmlBulkSelect;
- }
-
//create the HTML of a single row (values taken from the associative array $rowArray)
public function getRowList($rowArray) {
$htmlList = null;
@@ -482,32 +352,16 @@ class Helper_List extends Helper_Html {
$this->_recordNumber = count($queryResult);
$htmlList = null;
//create the HTML of the head of the record list
- $htmlList .= "<thead>\n".$this->wrapRow($this->createHead(),'listHead')."</thead>\n";
+ $htmlList .= $this->wrapRow($this->createHead(),'listHead');
//create the HTML of the filters
- $htmlList .= "<tbody>\n";
-
- $bulkActionsHtml = $this->createBulkActionsSelect();
- if (isset($bulkActionsHtml))
- {
- $htmlList .= $this->wrapRow($bulkActionsHtml,'bulk_actions_tr');
- }
-
- if ($this->showFilters)
- {
- $filtersHtml = $this->createFilters();
- if (isset($filtersHtml))
- {
- $htmlList .= $this->wrapRow($filtersHtml,'listFilters');
- }
- }
-
+ $htmlList .= $this->wrapRow($this->createFilters(),'listFilters');
for ($i = 0; $i < count($queryResult); $i++)
{
$this->ifInBoundaries($i);
$temp = $this->getRowList($queryResult[$i]);
$htmlList .= $this->wrapRow($temp,'listRow');
}
- return $this->wrapList($htmlList."</tbody>\n");
+ return $this->wrapList($htmlList);
}
public function generalForm($itemArray, $submitName, $submitValue)
@@ -604,20 +458,8 @@ class Helper_List extends Helper_Html {
return $string;
}
- //create the HTML of a checkbox
- public function checkbox($itemArray)
- {
- return Html_Form::checkbox($itemArray['action'],$itemArray['field'],$itemArray['name'],"checkbox_".encode($itemArray['action']),null,"data-primary-key='".$itemArray['value']."'");
- }
-
- //create the HTML of an input text
- public function input($itemArray)
- {
- return Html_Form::input($itemArray['action'],$itemArray['field'],"input_".encode($itemArray['action']),null,"data-primary-key='".$itemArray['name']."'");
- }
-
//create the HTML of the filter
- public function filterForm($viewArgsName, $filterString = null, $filterValues = null)
+ public function filterForm($viewArgsName)
{
$cleanName = str_replace('n!',null,$viewArgsName);
$cleanName = str_replace('-',null,$cleanName);
@@ -632,15 +474,8 @@ class Helper_List extends Helper_Html {
if (Params::$nullQueryValue)
{
$this->viewArgs[$viewArgsName] = Params::$nullQueryValue;
- $viewStatus = Url::createUrl($this->viewArgs);
- if (strcmp($value,Params::$nullQueryValue) === 0 and !isset($filterValues))
- {
- $value = '';
- }
- }
- else
- {
- $viewStatus = $this->viewStatus;
+ $viewStatus = Url::createUrl(array_values($this->viewArgs));
+ if (strcmp($value,Params::$nullQueryValue) === 0) $value = '';
}
$this->viewArgs[$viewArgsName] = $temp;
@@ -649,42 +484,11 @@ class Helper_List extends Helper_Html {
$title = $this->strings->gtext('filter');
$clearLinkTitle = $this->strings->gtext('clear the filter');
- $html = null;
-
- if (!$this->aggregateFilters)
- {
- $html .= "<form class='list_filter_form list_filter_form_$cleanName' action='".$action."' method='GET'>\n";
- }
-
- $html .= isset($filterString) ? " <span class='list_filter_span list_filter_span_$cleanName'>".$filterString."</span> " : null;
-
- if (!isset($filterValues))
- {
- $html .= "<input class='list_filter_input list_filter_input_$cleanName' type='text' name='$viewArgsName' value='".$value."'>";
- }
- else
- {
- $filterValues = array_merge(array(Params::$nullQueryValue => $this->strings->gtext('All')),$filterValues);
- $html .= Html_Form::select($viewArgsName,$value,$filterValues,"list_filter_input list_filter_input_$cleanName",null,"yes");
- }
-
- if (!$this->aggregateFilters)
- {
- $html .= "<a class='list_filter_clear_link list_filter_clear_link_$cleanName' title='$clearLinkTitle' href='$action'><img src='".Url::getRoot()."/Public/Img/Icons/elementary_2_5/clear_filter.png' /></a>";
- $html .= "<input class='list_filter_submit list_filter_submit_$cleanName' type='image' title='$title' src='".$imgSrc."' value='trova'>\n";
-
- if (!Params::$rewriteStatusVariables)
- {
- foreach ($this->viewArgs as $k => $v)
- {
- if (strcmp($k,"$viewArgsName") !== 0)
- {
- $html .= "<input type='hidden' name='".$k."' value='$v' />";
- }
- }
- }
- $html .= "</form>\n";
- }
+ $html = "<form class='list_filter_form list_filter_form_$cleanName' action='".$action."' method='GET'>\n";
+ $html .= "<input class='list_filter_input list_filter_input_$cleanName' type='text' name='$viewArgsName' value='".$value."'>";
+ $html .= "<a class='list_filter_clear_link list_filter_clear_link_$cleanName' title='$clearLinkTitle' href='$action'><img src='".Url::getRoot()."/Public/Img/Icons/elementary_2_5/clear_filter.png' /></a>";
+ $html .= "<input class='list_filter_submit list_filter_submit_$cleanName' type='image' title='$title' src='".$imgSrc."' value='trova'>\n";
+ $html .= "</form>\n";
return $html;
}
diff --git a/h-source/Library/Helper/Menu.php b/h-source/Library/Helper/Menu.php
index 4b33261..8fd4bf4 100755
--- a/h-source/Library/Helper/Menu.php
+++ b/h-source/Library/Helper/Menu.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -25,8 +25,7 @@ if (!defined('EG')) die('Direct access not allowed!');
//class to write the top menù of the view files
class Helper_Menu extends Helper_Html
{
- public static $htmlLinks = array();
-
+
public $panelController; //panel controller
public $controller;
@@ -50,7 +49,6 @@ class Helper_Menu extends Helper_Html
'text' => $this->strings->gtext('Back'),
'url' => 'main',
'icon' => $baseUrl."left.png",
- 'queryString' => null,
),
'add' => array(
@@ -59,7 +57,6 @@ class Helper_Menu extends Helper_Html
'text' => $this->strings->gtext('Add'),
'url' => 'form/insert',
'icon' => $baseUrl."add.png",
- 'queryString' => null,
),
'panel' => array(
@@ -68,25 +65,9 @@ class Helper_Menu extends Helper_Html
'text' => $this->strings->gtext('Panel'),
'url' => 'main',
'icon' => $baseUrl."panel.png",
- 'queryString' => null,
)
);
-
- foreach (self::$htmlLinks as $k => $v)
- {
- if (!array_key_exists($k, $this->links))
- {
- $this->links[$k] = $v;
- }
- else
- {
- foreach ($v as $subK => $subV)
- {
- $this->links[$k][$subK] = $subV;
- }
- }
- }
}
public function build($controller = null, $panelController = null)
@@ -108,11 +89,8 @@ class Helper_Menu extends Helper_Html
//check that the text and the ure are defined
if (isset($this->links[$linkName]['text']) and isset($this->links[$linkName]['url']))
{
- $title = isset($this->links[$linkName]['title']) ? "title=\"".$this->links[$linkName]['title']."\"" : null;
-
+ $title = isset($this->links[$linkName]['title']) ? "title='".$this->links[$linkName]['title']."'" : null;
$class = isset($this->links[$linkName]['class']) ? "class='".$this->links[$linkName]['class']."'" : null;
- $class = isset(self::$htmlLinks[$linkName]["class"]) ? "class='".self::$htmlLinks[$linkName]["class"]."'" : $class;
-
$icon = isset($this->links[$linkName]['icon']) ? "<img class='top_menu_icon' src='".$this->links[$linkName]['icon']."'> " : null;
//choose the controller (current or panel)
@@ -120,18 +98,8 @@ class Helper_Menu extends Helper_Html
$viewStatus = (strcmp($linkName,'panel') === 0) ? null : $this->viewStatus;
$href = Url::getRoot($controller.$this->links[$linkName]['url'].$viewStatus);
-
- if (isset($this->links[$linkName]['queryString']))
- {
- $href .= $this->links[$linkName]['queryString'];
- }
-
$text = $this->links[$linkName]['text'];
- $htmlBefore = isset($this->links[$linkName]["htmlBefore"]) ? $this->links[$linkName]["htmlBefore"] : "<div $class>$icon ";
- $htmlAfter = isset($this->links[$linkName]["htmlAfter"]) ? $this->links[$linkName]["htmlAfter"] : "</div>";
- $attributes = isset($this->links[$linkName]["attributes"]) ? $this->links[$linkName]["attributes"] : null;
-
- $menu .= "$htmlBefore<a $title $attributes href='$href'>$text</a>$htmlAfter\n";
+ $menu .= "<div $class>$icon <a $title href='$href'>$text</a></div>\n";
}
}
}
diff --git a/h-source/Library/Helper/Pages.php b/h-source/Library/Helper/Pages.php
index 3826469..d8ac856 100755
--- a/h-source/Library/Helper/Pages.php
+++ b/h-source/Library/Helper/Pages.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -109,16 +109,9 @@ class Helper_Pages extends Helper_Html
public function html($pageNumber,$string = null) {
if (isset($string)) {
$strNumber = $string;
- if (strcmp($pageNumber,"1") === 0)
- {
- $strClass = "class='itemListPage previous_page'";
- }
- else
- {
- $strClass = "class='itemListPage next_page'";
- }
+ $strClass = "class='itemListPage'";
} else {
- if (strcmp($pageNumber,$this->_currentPage) === 0)
+ if ($pageNumber === $this->_currentPage)
{
$strNumber = $pageNumber;
$strClass = "class='currentPage'";
@@ -130,7 +123,7 @@ class Helper_Pages extends Helper_Html
}
}
$this->viewArgs[$this->_variableArg] = $pageNumber;
- $viewStatus = Url::createUrl($this->viewArgs);
+ $viewStatus = Url::createUrl(array_values($this->viewArgs));
$href= Url::getRoot(null) . $this->_urlViewAction .$viewStatus;
return $this->getATag($href,$strNumber,$strClass);
}
diff --git a/h-source/Library/Helper/Popup.php b/h-source/Library/Helper/Popup.php
index f3e6058..18bb00d 100755
--- a/h-source/Library/Helper/Popup.php
+++ b/h-source/Library/Helper/Popup.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -25,15 +25,6 @@ if (!defined('EG')) die('Direct access not allowed!');
//class to create the popup menu
class Helper_Popup extends Helper_Html {
- //the HTML of the popup
- public static $popupHtml = array(
- "before_loop" => "",
- "top" => "<div class='row col-md-2 ext_menu_block ext_menu_block_[[field]]'><ul class='menuBlock'><li class='innerItem inner_item_[[field]]'>[[name]]<ul class='innerList'>\n",
- "middle" => "</ul>\n</li>\n</ul>\n",
- "bottom" => "</div>",
- "after_loop" => "",
- );
-
public $popupArray = array(); //array of popup objects (see popup.php)
public $url = null; //the url (controller/action) to link by means of the popup menù
// public $fieldArg = null; //the key of the viewArgs array to set to the field in the where clause
@@ -94,17 +85,9 @@ class Helper_Popup extends Helper_Html {
}
}
- public function replacePlaceholders($string, $field, $name)
- {
- $string = str_replace("[[field]]",$field,$string);
- $string = str_replace("[[name]]",$name,$string);
-
- return $string;
- }
-
//create the HTML of the popup
public function render() {
- $returnString = self::$popupHtml["before_loop"];
+ $returnString = null;
if ($this->checkViewArgs())
{
if (isset($this->viewArgs[$this->pageArg]))
@@ -121,12 +104,11 @@ class Helper_Popup extends Helper_Html {
$tempArg = $this->viewArgs[$field];
$this->legend[$field] = $tempArg;
- $returnString .= $this->replacePlaceholders(self::$popupHtml["top"],$field,$popup->name);
-
+ $returnString .= "<ul onMouseOver='DisplayTag(this,\"block\");' onMouseOut='DisplayTag(this,\"none\");' id='menuBlock'><li class='innerItem'>".$popup->name."<ul class='innerList'>\n";
for ($i = 0; $i < count($popup->itemsValue); $i++)
{
$this->viewArgs[$field] = $popup->itemsValue[$i];
- $viewStatus = Url::createUrl($this->viewArgs);
+ $viewStatus = Url::createUrl(array_values($this->viewArgs));
$returnString .= "<li><a href='".Url::getRoot($this->url).$viewStatus."'>".$popup->itemsName[$i]."</a></li>\n";
//set the legend
@@ -136,20 +118,24 @@ class Helper_Popup extends Helper_Html {
}
}
$this->viewArgs[$field] = Params::$nullQueryValue;
- $viewStatus = Url::createUrl($this->viewArgs);
+ $viewStatus = Url::createUrl(array_values($this->viewArgs));
$returnString .= "<li><a href='".Url::getRoot($this->url).$viewStatus."'>".$this->allString."</a></li>\n";
- $returnString .= self::$popupHtml["middle"];
+ $returnString .= "</ul>\n</li>\n</ul>\n";
$this->viewArgs[$field] = $tempArg;
-
- if ($this->printLegend)
+ }
+ if ($this->printLegend)
+ {
+ $returnString .= "<div class='popup_legend'>\n";
+ foreach ($this->popupArray as $field => $popup)
{
- $returnString .= "<div class='popup_legend_item popup_legend_item_$field'>".$this->legend[$field]."</div>";
+ $returnString .= "<div class='popup_legend_item'>".$this->legend[$field]."</div>";
}
-
- $returnString .= self::$popupHtml["bottom"];
+ $returnString .= "</div>\n";
+ }
+ if (count($this->popupArray)>0) {
+ $returnString .= "<script type=\"text/javascript\" src=\"http://".DOMAIN_NAME."/Public/Js/DisplayTag.js\"></script>\n";
}
}
- $returnString .= self::$popupHtml["after_loop"];
return $returnString;
}
diff --git a/h-source/Library/Hooks.php b/h-source/Library/Hooks.php
index de46da8..b16b6d5 100644
--- a/h-source/Library/Hooks.php
+++ b/h-source/Library/Hooks.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
diff --git a/h-source/Library/Html/Form.php b/h-source/Library/Html/Form.php
index 91b2aa0..ec81cfb 100644
--- a/h-source/Library/Html/Form.php
+++ b/h-source/Library/Html/Form.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -70,10 +70,10 @@ class Html_Form {
$a = $optionValue;
}
- if (strcmp($optionValue,'optgroupOpen') === 0)
+ if (strcmp($b,'optgroupOpen') === 0)
{
if ($flag === 1) $returnString .= "</optgroup>\n";
- $returnString .= "<optgroup label='" . $optionName . "'>\n";
+ $returnString .= "<optgroup label='" . $a . "'>\n";
$flag = 1;
}
else
@@ -83,7 +83,7 @@ class Html_Form {
}
}
if ($flag === 1) $returnString .= "</optgroup>\n";
- $returnString .= "</select>";
+ $returnString .= "</select>\n";
return $returnString;
}
@@ -97,7 +97,7 @@ class Html_Form {
$strClass = isset($className) ? "class='".$className."'" : null;
$idStr = isset($idName) ? "id='".$idName."'" : null;
- $returnString ="<input $attributes ".$idStr." $strClass type='text' name='" .$name. "' value = '$value' />";
+ $returnString ="<input $attributes ".$idStr." $strClass type='text' name='" .$name. "' value = '$value' />\n";
return $returnString;
}
@@ -110,7 +110,7 @@ class Html_Form {
$strClass = isset($className) ? "class='".$className."'" : null;
$idStr = isset($idName) ? "id='".$idName."'" : null;
- $returnString ="<input $attributes ".$idStr." $strClass type='file' name='" .$name. "' />";
+ $returnString ="<input $attributes ".$idStr." $strClass type='file' name='" .$name. "' />\n";
return $returnString;
}
@@ -126,7 +126,7 @@ class Html_Form {
$idStr = isset($idName) ? "id='".$idName."'" : null;
$str = (strcmp($value,$option) === 0) ? "checked = 'checked'" : null;
- return "<input $attributes ".$idStr." $strClass type='checkbox' name='".$name."' value='".$option."' $str />";
+ return "<input $attributes ".$idStr." $strClass type='checkbox' name='".$name."' value='".$option."' $str />\n";
}
//return the HTML of a hidden entry
@@ -137,7 +137,7 @@ class Html_Form {
$strClass = isset($className) ? "class='".$className."'" : null;
$idStr = isset($idName) ? "id='".$idName."'" : null;
- return "<input $attributes ".$idStr." $strClass type='hidden' name='" .$name. "' value = '$value'>";
+ return "<input $attributes ".$idStr." $strClass type='hidden' name='" .$name. "' value = '$value'>\n";
}
//return the HTML of a password entry
@@ -149,7 +149,7 @@ class Html_Form {
$strClass = isset($className) ? "class='".$className."'" : null;
$idStr = isset($idName) ? "id='".$idName."'" : null;
- return "<input $attributes ".$idStr." $strClass type='password' name='" .$name. "' value='$value' />";
+ return "<input $attributes ".$idStr." $strClass type='password' name='" .$name. "' value='$value' />\n";
}
//return the HTML of a textarea
@@ -161,7 +161,7 @@ class Html_Form {
$strClass = isset($className) ? "class='".$className."'" : null;
$idStr = isset($idName) ? "id='".$idName."'" : null;
- return "<textarea $attributes ".$idStr." $strClass name='" .$name. "'>$value</textarea>";
+ return "<textarea $attributes ".$idStr." $strClass name='" .$name. "'>$value</textarea>\n";
}
//return the HTML of a radio button
@@ -202,33 +202,7 @@ class Html_Form {
}
$str= (strcmp($value,$optionValue) === 0) ? "checked='checked'" : null;
- $returnString .= "$before<input $attributes ".$idStr." $strClass type='radio' name='".$name."' value='".$optionValue."' $str />$after";
- }
-
- return $returnString;
- }
-
- //return the HTML of an <input type='submit' ...>
- //$name: the name of the input
- //$value: the value of the input
- //$className: the class name of the input
- //$idName: name of the id
- //$image: url of the image (if it is an image button)
- //$attributes: list of attributes
- static public function submit($name, $value, $className = null, $idName = null, $image = null, $attributes = null)
- {
- $strClass = isset($className) ? "class='".$className."'" : null;
- $idStr = isset($idName) ? "id='".$idName."'" : null;
-
- if (isset($image))
- {
- $returnString = "<input $attributes $idStr $strClass type='image' src='".$image."' value='$value'>";
- $returnString .= "<input type='hidden' name='".$name."' value='$value'>";
- }
- else
- {
- $returnString = '<button '.$idStr.' '.$attributes.' '.$strClass.' type="submit" name="' .$name. '">'.$value.'</button>';
- $returnString .= "<input type='hidden' name='".$name."' value='$value'>";
+ $returnString .= "$before<input $attributes ".$idStr." $strClass type='radio' name='".$name."' value='".$optionValue."' $str />$after\n";
}
return $returnString;
diff --git a/h-source/Library/Image/Gd/Captcha.php b/h-source/Library/Image/Gd/Captcha.php
index d4285c2..1e8d706 100644
--- a/h-source/Library/Image/Gd/Captcha.php
+++ b/h-source/Library/Image/Gd/Captcha.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
diff --git a/h-source/Library/Image/Gd/Thumbnail.php b/h-source/Library/Image/Gd/Thumbnail.php
index bb69891..22e501e 100644
--- a/h-source/Library/Image/Gd/Thumbnail.php
+++ b/h-source/Library/Image/Gd/Thumbnail.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -47,10 +47,9 @@ class Image_Gd_Thumbnail
'resample' => 'yes',
'function' => 'none',
'outputFormat' => 'jpeg',
- 'backgroundColor' => null, //must be hex color
);
- //set the $this->params array
+ //set the $this->scaffold->params array
if (is_array($params))
{
foreach ($params as $key => $value)
@@ -61,46 +60,6 @@ class Image_Gd_Thumbnail
$this->params = $defaultParams;
}
- public function getSourceCoordinates($direction, $oldDim, $dim)
- {
- if ($direction === "x")
- {
- switch ($this->params['horizAlign'])
- {
- case 'left':
- $coordSrc = 0;
- break;
- case 'right':
- $coordSrc = floor(($oldDim-$dim));
- break;
- case 'center':
- $coordSrc = floor(($oldDim-$dim)/2);
- break;
- default:
- $coordSrc = $this->params['horizAlign'];
- }
- }
- else
- {
- switch ($this->params['vertAlign'])
- {
- case 'top':
- $coordSrc = 0;
- break;
- case 'bottom':
- $coordSrc = floor(($oldDim-$dim));
- break;
- case 'center':
- $coordSrc = floor(($oldDim-$dim)/2);
- break;
- default:
- $coordSrc = $this->params['vertAlign'];
- }
- }
-
- return $coordSrc;
- }
-
//create the thumbnail
//$imageName: the name of the file inside $this->basePath
//$outputFile: the name of the output file
@@ -116,8 +75,7 @@ class Image_Gd_Thumbnail
if (file_exists($imagePath))
{
- $extArray = explode('.', $imagePath);
- $ext = strtolower(end($extArray));
+ $ext = strtolower(end(explode('.', $imagePath)));
if (strcmp($ext,'jpg') === 0 or strcmp($ext,'jpeg') === 0) {
$img = @imagecreatefromjpeg($imagePath);
@@ -153,172 +111,81 @@ class Image_Gd_Thumbnail
$scale = max($this->params['imgWidth']/$width, $this->params['imgHeight']/$height);
}
- $xSrc = 0; //x coordinate of source image
- $ySrc = 0; //y coordinate of source image
-
- $xDst = 0; //x coordinate of destination image
- $yDst = 0; //y coordinate of destination image
-
- if ($this->params['cropImage'] === 'no')
- {
- if ($scale <= 1)
+ if ($scale < 1) {
+
+ $xSrc = 0;
+ $ySrc = 0;
+
+ if ($this->params['cropImage'] === 'no')
{
- $newWidth = $backWidth = floor($scale*$width);
- $newHeight = $backHeight = floor($scale*$height);
-
- if ($this->params['backgroundColor'])
- {
- $backWidth = $this->params['imgWidth'];
- $backHeight = $this->params['imgHeight'];
-
- if ($backWidth > $newWidth)
- {
- $xDst = floor(($backWidth-$newWidth)/2);
- }
- else if ($backHeight > $newHeight)
- {
- $yDst = floor(($backHeight-$newHeight)/2);
- }
- }
- }
- else
- {
- $newWidth = $backWidth = $width;
- $newHeight = $backHeight = $height;
-
- if ($this->params['backgroundColor'])
- {
- $backWidth = $this->params['imgWidth'];
- $backHeight = $this->params['imgHeight'];
-
- $xDst = floor(($backWidth-$newWidth)/2);
- $yDst = floor(($backHeight-$newHeight)/2);
- }
+ $newWidth = floor($scale*$width);
+ $newHeight = floor($scale*$height);
}
- }
- else if ($this->params['cropImage'] === 'yes')
- {
- if ($scale < 1)
+ else if ($this->params['cropImage'] === 'yes')
{
- $newWidth = $backWidth = $this->params['imgWidth'];
- $newHeight = $backHeight = $this->params['imgHeight'];
+
+ $newWidth = $this->params['imgWidth'];
+ $newHeight = $this->params['imgHeight'];
$oldWidth = $width;
$oldHeight = $height;
$width = floor($newWidth/$scale);
$height = floor($newHeight/$scale);
- $xSrc = $this->getSourceCoordinates("x",$oldWidth,$width);
- $ySrc = $this->getSourceCoordinates("y",$oldHeight,$height);
-
- }
- else
- {
- $oldWidth = $width;
- $oldHeight = $height;
-
- if ($width <= $this->params['imgWidth'] and $height <= $this->params['imgHeight'])
+ switch ($this->params['horizAlign'])
{
- $newWidth = $backWidth = $width;
- $newHeight = $backHeight = $height;
-
- if ($this->params['backgroundColor'])
- {
- $backWidth = $this->params['imgWidth'];
- $backHeight = $this->params['imgHeight'];
-
- $xDst = floor(($backWidth-$newWidth)/2);
- $yDst = floor(($backHeight-$newHeight)/2);
- }
-
- }
- else if ($width <= $this->params['imgWidth'])
- {
- $newWidth = $backWidth = $width;
- $newHeight = $backHeight = $height = $this->params['imgHeight'];
-
- $ySrc = $this->getSourceCoordinates("y",$oldHeight,$height);
-
- if ($this->params['backgroundColor'])
- {
- $backWidth = $this->params['imgWidth'];
- $backHeight = $this->params['imgHeight'];
-
- $xDst = floor(($backWidth-$newWidth)/2);
- }
-
+ case 'left':
+ $xSrc = 0;
+ break;
+ case 'right':
+ $xSrc = floor(($oldWidth-$width));
+ break;
+ case 'center':
+ $xSrc = floor(($oldWidth-$width)/2);
+ break;
+ default:
+ $xSrc = $this->params['horizAlign'];
}
- else if ($height <= $this->params['imgHeight'])
+
+ switch ($this->params['vertAlign'])
{
- $newHeight = $backHeight = $height;
- $newWidth = $backWidth = $width = $this->params['imgWidth'];
-
- $xSrc = $this->getSourceCoordinates("x",$oldWidth,$width);
-
- if ($this->params['backgroundColor'])
- {
- $backWidth = $this->params['imgWidth'];
- $backHeight = $this->params['imgHeight'];
-
- $yDst = floor(($backHeight-$newHeight)/2);
- }
-
+ case 'top':
+ $ySrc = 0;
+ break;
+ case 'bottom':
+ $ySrc = floor(($oldHeight-$height));
+ break;
+ case 'center':
+ $ySrc = floor(($oldHeight-$height)/2);
+ break;
+ default:
+ $ySrc = $this->params['vertAlign'];
}
- }
- }
- //temp image
- $tmpImg = imagecreatetruecolor($backWidth, $backHeight);
-
- //set background color if backgroundColor param is not null (hex value)
- if ($this->params['backgroundColor'])
- {
- if (strcmp($this->params['backgroundColor'],"transparent") !== 0)
- {
- $rgbColor = hex2rgb($this->params['backgroundColor']);
-
- $backgroundC = imagecolorallocate($tmpImg,$rgbColor[0],$rgbColor[1],$rgbColor[2]);
- }
- else
- {
- $backgroundC = imagecolortransparent($tmpImg);
}
-
- imagefill($tmpImg, 0, 0, $backgroundC);
- }
-
- if(strcmp($type,'png') === 0 or strcmp($type,'gif') === 0){
-
- if ($this->params['backgroundColor'])
+
+ //temp image
+ $tmpImg = imagecreatetruecolor($newWidth, $newHeight);
+
+ if ($this->params['resample'] === 'yes')
{
- imagealphablending($tmpImg, true);
+ //copy and resample
+ imagecopyresampled($tmpImg, $img, 0, 0, $xSrc, $ySrc,$newWidth, $newHeight, $width, $height);
}
else
{
- imagealphablending($tmpImg, false);
+ //copy and resize
+ imagecopyresized($tmpImg, $img, 0, 0, $xSrc, $ySrc,$newWidth, $newHeight, $width, $height);
}
-
- imagesavealpha($tmpImg, true);
- }
+ imagedestroy($img);
+ $img = $tmpImg;
- if ($this->params['resample'] === 'yes')
- {
- //copy and resample
- imagecopyresampled($tmpImg, $img, $xDst, $yDst, $xSrc, $ySrc,$newWidth, $newHeight, $width, $height);
- }
- else
- {
- //copy and resize
- imagecopyresized($tmpImg, $img, $xDst, $yDst, $xSrc, $ySrc,$newWidth, $newHeight, $width, $height);
- }
- imagedestroy($img);
- $img = $tmpImg;
+ if (!function_exists($this->params['function'])) {
+ throw new Exception('Error in <b>'.__METHOD__.'</b>: function <b>'.$this->params['function']. '</b> does not exist');
+ }
- if (!function_exists($this->params['function']))
- {
- throw new Exception('Error in <b>'.__METHOD__.'</b>: function <b>'.$this->params['function']. '</b> does not exist');
+ $img = call_user_func($this->params['function'],$img);
}
-
- $img = call_user_func($this->params['function'],$img);
+
}
if (!$img)
@@ -328,7 +195,6 @@ class Image_Gd_Thumbnail
$img = imagecreate($imgWidth, $imgHeight);
imagecolorallocate($img,200,200,200);
-
}
//print the image
diff --git a/h-source/Library/Lang/En/DbCondStrings.php b/h-source/Library/Lang/En/DbCondStrings.php
index 0c72d95..bfc5867 100644
--- a/h-source/Library/Lang/En/DbCondStrings.php
+++ b/h-source/Library/Lang/En/DbCondStrings.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -23,12 +23,12 @@
if (!defined('EG')) die('Direct access not allowed!');
//error strings in the case database conditions are not satisfied
-class Lang_En_DbCondStrings extends Lang_En_ValCondStrings {
+class Lang_En_DbCondStrings {
//get the error string in the case that the value of the field $field is already present in the table $table
public function getNotUniqueString($field)
{
- return "<div class='alert'>The value of <i>". getFieldLabel($field) ."</i> is already present. Please choose a different value.</div>\n".$this->getHiddenAlertElement($field);
+ return "<div class='alert'>The value of <i>". $field ."</i> is already present. Please choose a different value.</div>\n";
}
}
diff --git a/h-source/Library/Lang/En/Formats/Fields.php b/h-source/Library/Lang/En/Formats/Fields.php
deleted file mode 100644
index c91a1f0..0000000
--- a/h-source/Library/Lang/En/Formats/Fields.php
+++ /dev/null
@@ -1,46 +0,0 @@
-<?php
-
-// EasyGiant is a PHP framework for creating and managing dynamic content
-//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
-// See COPYRIGHT.txt and LICENSE.txt.
-//
-// This file is part of EasyGiant
-//
-// EasyGiant is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// EasyGiant 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with EasyGiant. If not, see <http://www.gnu.org/licenses/>.
-
-if (!defined('EG')) die('Direct access not allowed!');
-
-class Lang_En_Formats_Fields
-{
-
- public static function getLabel($fieldName)
- {
- if (strstr($fieldName,","))
- {
- $temp = explode(",",$fieldName);
- for ($i=0; $i< count($temp); $i++)
- {
- $temp[$i] = self::getLabel($temp[$i]);
- }
- return implode (" and ",$temp);
- }
- else
- {
- $fieldName = str_replace("_"," ", $fieldName);
- return ucfirst($fieldName);
- }
- }
-
-}
diff --git a/h-source/Library/Lang/En/Formats/From/Mysql.php b/h-source/Library/Lang/En/Formats/From/Mysql.php
deleted file mode 100644
index 5e4ea07..0000000
--- a/h-source/Library/Lang/En/Formats/From/Mysql.php
+++ /dev/null
@@ -1,64 +0,0 @@
-<?php
-
-// EasyGiant is a PHP framework for creating and managing dynamic content
-//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
-// See COPYRIGHT.txt and LICENSE.txt.
-//
-// This file is part of EasyGiant
-//
-// EasyGiant is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// EasyGiant 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with EasyGiant. If not, see <http://www.gnu.org/licenses/>.
-
-if (!defined('EG')) die('Direct access not allowed!');
-
-class Lang_En_Formats_From_Mysql
-{
-
- //convert the string from MySQL decimal format to En decimal format
- public function decimal($string)
- {
- return $string;
- }
-
- //convert the string from MySQL float format to En float format
- public function float($string)
- {
- return $string;
- }
-
- //convert the string from MySQL double format to En double format
- public function double($string)
- {
- return $string;
- }
-
-
- //convert the string from MySQL date format to En date format
- public function date($date)
- {
- if (preg_match('/^[0-9]{4}\-[0-9]{2}\-[0-9]{2}$/',$date))
- {
- $dateArray = explode('-',$date);
- return $dateArray[1]."-".$dateArray[2]."-".$dateArray[0];
- }
- return $date;
- }
-
- //convert the string from MySQL enum format to En enum format
- public function enum($string)
- {
- return $string;
- }
-
-} \ No newline at end of file
diff --git a/h-source/Library/Lang/En/Formats/From/index.html b/h-source/Library/Lang/En/Formats/From/index.html
deleted file mode 100755
index 8d1c8b6..0000000
--- a/h-source/Library/Lang/En/Formats/From/index.html
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/h-source/Library/Lang/En/Formats/To/Mysql.php b/h-source/Library/Lang/En/Formats/To/Mysql.php
deleted file mode 100644
index 31daab8..0000000
--- a/h-source/Library/Lang/En/Formats/To/Mysql.php
+++ /dev/null
@@ -1,62 +0,0 @@
-<?php
-
-// EasyGiant is a PHP framework for creating and managing dynamic content
-//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
-// See COPYRIGHT.txt and LICENSE.txt.
-//
-// This file is part of EasyGiant
-//
-// EasyGiant is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// EasyGiant 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with EasyGiant. If not, see <http://www.gnu.org/licenses/>.
-
-if (!defined('EG')) die('Direct access not allowed!');
-
-class Lang_En_Formats_To_Mysql
-{
-
- //convert the string from En decimal format to MySQL decimal format
- public function decimal($string)
- {
- return $string;
- }
-
- //convert the string from En float format to MySQL float format
- public function float($string)
- {
- return $string;
- }
-
- //convert the string from En double format to MySQL double format
- public function double($string)
- {
- return $string;
- }
-
- //convert the string from En date format to MySQL date format
- public function date($date)
- {
- if (preg_match('/^[0-9]{2}\-[0-9]{2}\-[0-9]{4}$/',$date))
- {
- $dateArray = explode('-',$date);
- return $dateArray[2]."-".$dateArray[0]."-".$dateArray[1];
- }
- return $date;
- }
-
- //convert the string from En enum format to MySQL enum format
- public function enum($string)
- {
- return $string;
- }
-} \ No newline at end of file
diff --git a/h-source/Library/Lang/En/Formats/To/index.html b/h-source/Library/Lang/En/Formats/To/index.html
deleted file mode 100755
index 8d1c8b6..0000000
--- a/h-source/Library/Lang/En/Formats/To/index.html
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/h-source/Library/Lang/En/Formats/index.html b/h-source/Library/Lang/En/Formats/index.html
deleted file mode 100755
index 8d1c8b6..0000000
--- a/h-source/Library/Lang/En/Formats/index.html
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/h-source/Library/Lang/En/Generic.php b/h-source/Library/Lang/En/Generic.php
index 8df27a9..3268270 100644
--- a/h-source/Library/Lang/En/Generic.php
+++ b/h-source/Library/Lang/En/Generic.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -49,9 +49,6 @@ class Lang_En_Generic
'pages' => 'pages',
'filter' => 'filter',
'clear the filter' => 'clear the filter',
- 'Save' => 'Save',
- 'Actions' => 'Actions',
- '-- Select bulk action --' => '-- Select bulk action --',
);
public function gtext($string)
diff --git a/h-source/Library/Lang/En/ModelStrings.php b/h-source/Library/Lang/En/ModelStrings.php
index 266b1d2..cf26b8f 100644
--- a/h-source/Library/Lang/En/ModelStrings.php
+++ b/h-source/Library/Lang/En/ModelStrings.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -24,19 +24,13 @@ if (!defined('EG')) die('Direct access not allowed!');
class Lang_En_ModelStrings extends Lang_ResultStrings {
- public function __construct() {
-
- $this->string = array(
- "error" => "<div class='".Params::$errorStringClassName."'>Query error: Contact the administrator!</div>\n",
- "executed" => "<div class='".Params::$infoStringClassName."'>Operation executed!</div>\n",
- "associate" => "<div class='".Params::$errorStringClassName."'>Referential integrity problem: record associated to some other record in a child table. Break the association before.</div>\n",
- "no-id" => "<div class='".Params::$errorStringClassName."'>Alert: record identifier not defined!</div>\n",
- "not-linked" => "<div class='".Params::$errorStringClassName."'>The Item is not associated : you can't dissociate it</div>",
- "linked" => "<div class='".Params::$errorStringClassName."'>The Item is already associated: you can't associate it another time</div>",
- "not-existing-fields" => "<div class='".Params::$errorStringClassName."'>Some fields in the query do not exist</div>\n",
- "no-fields" => "<div class='".Params::$errorStringClassName."'>There are no values in the insert/update query</div>\n",
- );
-
- }
+ public $string = array(
+ "error" => "<div class='alert'>Query error: Contact the administrator!</div>\n",
+ "executed" => "<div class='executed'>Operation executed!</div>\n",
+ "associate" => "<div class='alert'>Referential integrity problem: record associated to some other record in a child table. Break the association before.</div>\n",
+ "no-id" => "<div class='alert'>Alert: record identifier not defined!</div>\n",
+ "not-linked" => "<div class='alert'>The Item is not associated : you can't dissociate it</div>",
+ "linked" => "<div class='alert'>The Item is already associated: you can't associate it another time</div>"
+ );
}
diff --git a/h-source/Library/Lang/En/UploadStrings.php b/h-source/Library/Lang/En/UploadStrings.php
index 572f7bb..61bc0c5 100644
--- a/h-source/Library/Lang/En/UploadStrings.php
+++ b/h-source/Library/Lang/En/UploadStrings.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
diff --git a/h-source/Library/Lang/En/ValCondStrings.php b/h-source/Library/Lang/En/ValCondStrings.php
index 8742c23..7f4e7ea 100644
--- a/h-source/Library/Lang/En/ValCondStrings.php
+++ b/h-source/Library/Lang/En/ValCondStrings.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -24,106 +24,70 @@ if (!defined('EG')) die('Direct access not allowed!');
class Lang_En_ValCondStrings {
- //get the HTMl of the hidden alert notices
- public function getHiddenAlertElement($element)
- {
- $html = "";
- $t = explode(",",$element);
-
- foreach ($t as $el)
- {
- $html .= "<div style='display:none;' rel='hidden_alert_notice'>$el</div>";
- }
-
- return $html;
- }
-
//if the element is not defined
public function getNotDefinedResultString($element)
{
- return "<div class='".Params::$errorStringClassName."'>Please fill the field <i>". getFieldLabel($element) ."</i>.</div>\n".$this->getHiddenAlertElement($element);
+ return "<div class='alert'>". $element ." not defined!</div>\n";
}
//if the elements are not equal
public function getNotEqualResultString($element)
{
- return "<div class='".Params::$errorStringClassName."'>Please check that the fields <i>".getFieldLabel($element)."</i> are equal</div>\n".$this->getHiddenAlertElement($element);
+ return "<div class='alert'>Different values: $element</div>\n";
}
//if the element is not alphabetic
public function getNotAlphabeticResultString($element)
{
- return "<div class='".Params::$errorStringClassName."'>Please check that the field <i>".getFieldLabel($element)."</i> is alphabetic</div>\n".$this->getHiddenAlertElement($element);
+ return "<div class='alert'>".$element." has to be alphabetic</div>\n";
}
//if the element is not alphanumeric
public function getNotAlphanumericResultString($element)
{
- return "<div class='".Params::$errorStringClassName."'>Please check that the field <i>".getFieldLabel($element)."</i> has to be alphanumeric</div>\n".$this->getHiddenAlertElement($element);
+ return "<div class='alert'>".$element." has to be alphanumeric</div>\n";
}
//if the element is not a decimal digit
public function getNotDecimalDigitResultString($element)
{
- return "<div class='".Params::$errorStringClassName."'>Please check that the field <i>".getFieldLabel($element)."</i> is a decimal digit</div>\n".$this->getHiddenAlertElement($element);
+ return "<div class='alert'>".$element." has to be a decimal digit</div>\n";
}
-
- //if the element hasn't the mail format
+
+ //if the element has the mail format
public function getNotMailFormatResultString($element)
{
- return "<div class='".Params::$errorStringClassName."'>Please check that the field <i>".getFieldLabel($element)."</i> is an e-mail address</div>\n".$this->getHiddenAlertElement($element);
+ return "<div class='alert'>".$element." doesn't seem an e-mail address</div>\n";
}
- //if the element is not numeric
+ //if the element is numeric
public function getNotNumericResultString($element)
{
- return "<div class='".Params::$errorStringClassName."'>Please check that the field <i>".getFieldLabel($element)."</i> is numeric</div>\n".$this->getHiddenAlertElement($element);
- }
-
- //if the element is not an integer
- public function getNotIntegerFormatResultString($element)
- {
- return "<div class='".Params::$errorStringClassName."'>Please check that the field <i>".getFieldLabel($element)."</i> is an integer number</div>\n".$this->getHiddenAlertElement($element);
- }
-
- //if the element is not a real date
- public function getNotDateResultString($element)
- {
- return "<div class='".Params::$errorStringClassName."'>Please check that the field <i>".getFieldLabel($element)."</i> is a real date</div>\n".$this->getHiddenAlertElement($element);
+ return "<div class='alert'>".$element." has to be a numeric</div>\n";
}
//if the element (string) length exceeds the value of characters (defined by $maxLength)
public function getLengthExceedsResultString($element,$maxLength)
{
- return "<div class='".Params::$errorStringClassName."'>Please check that the field <i>".getFieldLabel($element)."</i> does not exceed the value of $maxLength characters</div>\n".$this->getHiddenAlertElement($element);
+ return "<div class='alert'>".$element." exceeds the value of $maxLength characters</div>\n";
}
//if the element is one of the strings indicated by $stringList (a comma-separated list of strings)
public function getIsForbiddenStringResultString($element,$stringList)
{
- return "<div class='".Params::$errorStringClassName."'>Please check that the field <i>".getFieldLabel($element)."</i> is not one of the following strings: $stringList</div>\n".$this->getHiddenAlertElement($element);
+ return "<div class='alert'>".$element." can't be one of the following strings: $stringList</div>\n";
}
//if the element is not one of the strings indicated by $stringList (a comma-separated list of strings)
public function getIsNotStringResultString($element,$stringList)
{
- return "<div class='".Params::$errorStringClassName."'>Please check that the field <i>".getFieldLabel($element)."</i> is one of the following strings: $stringList</div>\n".$this->getHiddenAlertElement($element);
+ return "<div class='alert'>".$element." has to be one of the following strings: $stringList</div>\n";
}
- //if the element does not match the reg expr indicated by $regExp
+ //if the element is not one of the strings indicated by $stringList (a comma-separated list of strings)
public function getDoesntMatchResultString($element,$regExp)
{
- return "<div class='".Params::$errorStringClassName."'>Please check that the field <i>".getFieldLabel($element)."</i> matchs the following regular expression: $regExp</div>\n".$this->getHiddenAlertElement($element);
- }
-
- //if the element is not decimal
- public function getNotDecimalResultString($element, $format)
- {
- $t = explode(",",$format);
- $M = (int)$t[0];
- $D = (int)$t[1];
- $I = $M - $D;
- return "<div class='".Params::$errorStringClassName."'>Please check that the field <i>".getFieldLabel($element)."</i> is a decimal number (maximum number of integer digits:$I, maximum number of decimal digits: $D)</div>\n".$this->getHiddenAlertElement($element);
+ return "<div class='alert'>".$element." has to match the following regular expression: $regExp</div>\n";
}
}
diff --git a/h-source/Library/Lang/Eng/DbCondStrings.php b/h-source/Library/Lang/Eng/DbCondStrings.php
index cd625af..e4196b6 100644
--- a/h-source/Library/Lang/Eng/DbCondStrings.php
+++ b/h-source/Library/Lang/Eng/DbCondStrings.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
diff --git a/h-source/Library/Lang/Eng/Generic.php b/h-source/Library/Lang/Eng/Generic.php
index 29947fd..bb0ab99 100644
--- a/h-source/Library/Lang/Eng/Generic.php
+++ b/h-source/Library/Lang/Eng/Generic.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -33,25 +33,6 @@ class Lang_Eng_Generic
'move up' => 'move up',
'move down' => 'move down',
'associate' => 'associate',
- 'up' => 'su',
- 'down' => 'down',
- 'link' => 'link',
- 'del' => 'del',
- 'back' => 'back',
- 'Back' => 'Back',
- 'add a new record' => 'add a new record',
- 'Add' => 'Add',
- 'back to the Panel' => 'back to the Panel',
- 'Panel' => 'Panel',
- 'previous' => 'previous',
- 'next' => 'next',
- 'All' => 'All',
- 'pages' => 'pages',
- 'filter' => 'filter',
- 'clear the filter' => 'clear the filter',
- 'Save' => 'Save',
- 'Actions' => 'Actions',
- '-- Select bulk action --' => '-- Select bulk action --',
);
public function gtext($string)
diff --git a/h-source/Library/Lang/Eng/ModelStrings.php b/h-source/Library/Lang/Eng/ModelStrings.php
index 20b8173..fa741a2 100644
--- a/h-source/Library/Lang/Eng/ModelStrings.php
+++ b/h-source/Library/Lang/Eng/ModelStrings.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -30,8 +30,7 @@ class Lang_Eng_ModelStrings extends Lang_ResultStrings {
"associate" => "<div class='alert'>Referential integrity problem: record associated to some other record in a child table. Break the association before.</div>\n",
"no-id" => "<div class='alert'>Alert: record identifier not defined!</div>\n",
"not-linked" => "<div class='alert'>The Item is not associated : you can't dissociate it</div>",
- "linked" => "<div class='alert'>The Item is already associated: you can't associate it another time</div>",
- "not-existing-fields" => "<div class='alert'>Some fields in the query do not exist</div>\n",
+ "linked" => "<div class='alert'>The Item is already associated: you can't associate it another time</div>"
);
}
diff --git a/h-source/Library/Lang/Eng/UploadStrings.php b/h-source/Library/Lang/Eng/UploadStrings.php
index ca0332b..2ae4c9b 100644
--- a/h-source/Library/Lang/Eng/UploadStrings.php
+++ b/h-source/Library/Lang/Eng/UploadStrings.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
diff --git a/h-source/Library/Lang/Eng/ValCondStrings.php b/h-source/Library/Lang/Eng/ValCondStrings.php
index f5d40a2..42e70d8 100644
--- a/h-source/Library/Lang/Eng/ValCondStrings.php
+++ b/h-source/Library/Lang/Eng/ValCondStrings.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -27,89 +27,67 @@ class Lang_Eng_ValCondStrings {
//if the element is not defined
public function getNotDefinedResultString($element)
{
- return "<div class='".Params::$errorStringClassName."'>". $element ." not defined!</div>\n";
+ return "<div class='alert'>". $element ." not defined!</div>\n";
}
//if the elements are not equal
public function getNotEqualResultString($element)
{
- return "<div class='".Params::$errorStringClassName."'>Different values: $element</div>\n";
+ return "<div class='alert'>Different values: $element</div>\n";
}
//if the element is not alphabetic
public function getNotAlphabeticResultString($element)
{
- return "<div class='".Params::$errorStringClassName."'>".$element." has to be alphabetic</div>\n";
+ return "<div class='alert'>".$element." has to be alphabetic</div>\n";
}
//if the element is not alphanumeric
public function getNotAlphanumericResultString($element)
{
- return "<div class='".Params::$errorStringClassName."'>".$element." has to be alphanumeric</div>\n";
+ return "<div class='alert'>".$element." has to be alphanumeric</div>\n";
}
//if the element is not a decimal digit
public function getNotDecimalDigitResultString($element)
{
- return "<div class='".Params::$errorStringClassName."'>".$element." has to be a decimal digit</div>\n";
+ return "<div class='alert'>".$element." has to be a decimal digit</div>\n";
}
- //if the element hasn't the mail format
+ //if the element has the mail format
public function getNotMailFormatResultString($element)
{
- return "<div class='".Params::$errorStringClassName."'>".$element." doesn't seem an e-mail address</div>\n";
+ return "<div class='alert'>".$element." doesn't seem an e-mail address</div>\n";
}
- //if the element is not numeric
+ //if the element is numeric
public function getNotNumericResultString($element)
{
- return "<div class='".Params::$errorStringClassName."'>".$element." has to be a numeric</div>\n";
- }
-
- //if the element is not an integer
- public function getNotIntegerFormatResultString($element)
- {
- return "<div class='".Params::$errorStringClassName."'>".$element." has to be an integer</div>\n";
- }
-
- //if the element is not a real date
- public function getNotDateResultString($element)
- {
- return "<div class='".Params::$errorStringClassName."'>".$element." has to be a real date (YYYY-MM-DD)</div>\n";
+ return "<div class='alert'>".$element." has to be a numeric</div>\n";
}
//if the element (string) length exceeds the value of characters (defined by $maxLength)
public function getLengthExceedsResultString($element,$maxLength)
{
- return "<div class='".Params::$errorStringClassName."'>".$element." exceeds the value of $maxLength characters</div>\n";
+ return "<div class='alert'>".$element." exceeds the value of $maxLength characters</div>\n";
}
//if the element is one of the strings indicated by $stringList (a comma-separated list of strings)
public function getIsForbiddenStringResultString($element,$stringList)
{
- return "<div class='".Params::$errorStringClassName."'>".$element." can't be one of the following strings: $stringList</div>\n";
+ return "<div class='alert'>".$element." can't be one of the following strings: $stringList</div>\n";
}
//if the element is not one of the strings indicated by $stringList (a comma-separated list of strings)
public function getIsNotStringResultString($element,$stringList)
{
- return "<div class='".Params::$errorStringClassName."'>".$element." has to be one of the following strings: $stringList</div>\n";
+ return "<div class='alert'>".$element." has to be one of the following strings: $stringList</div>\n";
}
- //if the element does not match the reg expr indicated by $regExp
+ //if the element is not one of the strings indicated by $stringList (a comma-separated list of strings)
public function getDoesntMatchResultString($element,$regExp)
{
- return "<div class='".Params::$errorStringClassName."'>".$element." has to match the following regular expression: $regExp</div>\n";
- }
-
- //if the element is not decimal
- public function getNotDecimalResultString($element, $format)
- {
- $t = explode(",",$format);
- $M = (int)$t[0];
- $D = (int)$t[1];
- $I = $M - $D;
- return "<div class='".Params::$errorStringClassName."'><i>".$element."</i> has to be a decimal number (maximum number of integer digits:$I, maximum number of decimal digits: $D)</div>\n";
+ return "<div class='alert'>".$element." has to match the following regular expression: $regExp</div>\n";
}
}
diff --git a/h-source/Library/Lang/ResultStrings.php b/h-source/Library/Lang/ResultStrings.php
index 6f84090..2181b90 100644
--- a/h-source/Library/Lang/ResultStrings.php
+++ b/h-source/Library/Lang/ResultStrings.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
diff --git a/h-source/Library/ModAbstract.php b/h-source/Library/ModAbstract.php
index de4f68f..f576c10 100644
--- a/h-source/Library/ModAbstract.php
+++ b/h-source/Library/ModAbstract.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
diff --git a/h-source/Library/Model/#Base.php# b/h-source/Library/Model/#Base.php#
new file mode 100755
index 0000000..4162a56
--- /dev/null
+++ b/h-source/Library/Model/#Base.php#
@@ -0,0 +1,1273 @@
+<?php
+
+// EasyGiant is a PHP framework for creating and managing dynamic content
+//
+// Copyright (C) 2009 - 2011 Antonio Gallo
+// See COPYRIGHT.txt and LICENSE.txt.
+//
+// This file is part of EasyGiant
+//
+// EasyGiant is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// EasyGiant 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 General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with EasyGiant. If not, see <http://www.gnu.org/licenses/>.
+
+if (!defined('EG')) die('Direct access not allowed!');
+
+abstract class Model_Base
+{
+
+ public $fields = ''; //the fields that have to be manipulated by the update and insert query
+ public $values = array(); //the values that corresponding to the $this->fields fields
+ public $form = null; //reference to a Form_Form object
+ public $formStruct = null; //the form structure
+
+ public $submitName = null; //the current submitName (from the form)
+ public $identifierName = 'identifier';
+
+ public $notice = null; //a string explaining the result of the query applied (or not if an error occured): executed, error, etc
+ public $result = true; //the result of validate conditions, database conditions and query. It can be 'true' or 'false'
+ public $queryResult = false; //the result of the query
+
+ //conditions that have to be satisfied before applying the query
+ //Ex: 'update'=>'checkEmpty:titolo,autore','submitName'=>'conditions'
+ public $strongConditions = array();
+
+ //conditions that have to be satisfied before applying the query
+ //Ex: 'update'=>'checkEmpty:titolo,autore','submitName'=>'conditions'
+ //do not return error if a value is equal to '' or null
+ public $softConditions = array();
+
+ //conditions that have to be satisfied before applying the query
+ //check that the new values inserted satisfy some conditions
+ //Ex: 'update'=>'checkUniqueCompl:titolo,autore;checkUnique:titolo','insert'=>'checkUnique:titolo'
+ public $databaseConditions = array();
+
+ public $popupArray = array(); //array of popup objects (see popup.php)
+
+ public $supplInsertValues = array(); //associative array defining supplementary values to be inserted on each insert query. It has to have the following form: array(field1 => value1,field2 => value2, ...)
+
+ public $supplUpdateValues = array(); //associative array defining supplementary values to be inserted on each update query. It has to have the following form: array(field1 => value1,field2 => value2, ...)
+
+ public $select = null; //fields that have to be selected in select queries
+ public $where = array(); //associative array containing all the where clauses ($field => $value)
+ //group by, order by and limit clauses
+ public $groupBy = null;
+ public $orderBy = null;
+ public $limit = null;
+
+ public $from = null; //from clause of the select queries
+ public $on = array(); //on array
+ public $using = array(); //using array
+ public $join = array(); //join array
+
+ public $toList = false; //if the result have to be given in a list format
+ public $listArray = array(); //array containing the $key and the $value to be used to extract a list from a resultSet
+
+ //logic operator between statements in the where clause of select queries
+ public $logicalOperators = array('AND');
+
+ public $files = null; //reference to the Files_Upload class
+
+ protected $_tables='itemTable,boxTable,item_boxTable';
+ protected $_idFields='id_item,id_box';
+ protected $_tablesArray=array();
+ protected $_idFieldsArray=array();
+ protected $_where = array();
+
+ //the name of the field that has to be used to order the rows of the main table of the model
+ protected $_idOrder = null;
+
+ protected $_onDelete = 'check'; //can be 'nocheck' or 'check'. check: referential integrity check. nocheck: no referential integrity check
+ protected $_reference = null; //array containing the child table that have a reference to this table and the foreign key of the child table-> array($childTable,$foreignKey)
+
+ protected $_popupItemNames = array(); //the fields to be used as names in the popupArray elements. Associative array ($itemNameField1 => $itemNameValue1, ...)
+
+ //the labels of the pop-up menus
+ protected $_popupLabels = array();
+
+ //functions that have to be applied upon the label fields of the popup menu
+ protected $_popupFunctions = array();
+
+ protected $_popupWhere = array(); //where clause for the pupup menu
+
+ protected $_resultString; //reference to the class containing all the result strings of the db queries
+ protected $_dbCondString; //reference to the class containing all the result strings of the database conditions
+
+ protected $_backupFields = ''; //field saved after the delFields method has been applied
+ protected $_backupValues = array(); //values saved after the delFields method has been applied
+ protected $_allowedDbMethods = array('update','insert','del','moveup','movedown'); //methods that can be called by the updateTable method
+
+ protected $submitNames = array(
+ 'update' => 'updateAction',
+ 'insert' => 'insertAction',
+ 'del' =>'delAction',
+ 'moveup' =>'moveupAction',
+ 'movedown' =>'movedownAction'
+ );
+
+ protected $identifierValue = null; //the value of the identifier ($_POST[$this->identifier])
+ protected $arrayExt; //arrayExt object (see library/arrayExt.php)
+
+ protected $_arrayStrongCheck; //Array_Validate_Strong object
+ protected $_arraySoftCheck; //Array_Validate_Soft object
+
+ public $db; //reference to the database layer class
+ protected $_lang = null; //language of notices
+
+
+ public function __construct() {
+ $this->_tablesArray = explode(',',$this->_tables);
+ $this->_idFieldsArray = explode(',',$this->_idFields);
+ $this->_where[$this->_idFieldsArray[0]] = $this->_tablesArray[0];
+ $this->arrayExt = new ArrayExt();
+
+ //initialize the validate objects
+ $this->_arrayStrongCheck = new Array_Validate_Strong($this->_lang);
+ $this->_arraySoftCheck = new Array_Validate_Soft($this->_lang);
+
+ $this->identifierName = $this->_idFieldsArray[0];
+
+ //set the language of notices
+ $this->_lang = Params::$language;
+
+ //create the $_resultString object (result strings of the db queries)
+ $modelStringClass = 'Lang_'.$this->_lang.'_ModelStrings';
+ if (!class_exists($modelStringClass))
+ {
+ $modelStringClass = 'Lang_En_ModelStrings';
+ }
+ $this->_resultString = new $modelStringClass();
+
+ //create the $_dbCondString object (result strings of the database conditions)
+ $dbCondStringClass = 'Lang_'.$this->_lang.'_DbCondStrings';
+ if (!class_exists($dbCondStringClass))
+ {
+ $dbCondStringClass = 'Lang_En_DbCondStrings';
+ }
+ $this->_dbCondString = new $dbCondStringClass();
+
+ //instantiate the database class
+ $this->db = Factory_Db::getInstance(DATABASE_TYPE);
+
+ //instantiate the Files_Upload class
+ $params = array(
+ 'filesPermission' => 0777,
+ 'language' => $this->_lang,
+ 'allowedExtensions' => 'png,jpg,jpeg,gif',
+ 'maxFileSize' => 20000000,
+ 'fileUploadKey' => 'userfile'
+ );
+
+ $this->files = new Files_Upload(ROOT."/media/",$params);
+ }
+
+ //sanitize all the $values property
+ public function sanitize()
+ {
+ $keys = implode(',',array_keys($this->values));
+ $this->values = $this->arrayExt->subset($this->values,$keys,'sanitizeDb');
+ }
+
+ //change a resulting string from a db query
+ public function setString($key,$value)
+ {
+ $this->_resultString->string[$key] = $value;
+ }
+
+ //set the submitNames property (array)
+ //$methodName : the method name, $submitName: the submit name of the submit action of the form
+ public function setSubmitNames($methodName,$submitName)
+ {
+ if (!in_array($methodName,$this->_allowedDbMethods))
+ {
+ throw new Exception('query type <b>"'.$methodName. '"</b> not allowed in '. __METHOD__);
+ }
+ $this->submitNames[$methodName] = $submitName;
+ }
+
+ //get the last query executed
+ public function getQuery()
+ {
+ return $this->db->query;
+ }
+
+ //get the where clause of the select query
+ public function getWhereQueryClause()
+ {
+ return $this->where;
+ }
+
+ //set the where clause of the select query
+ //whereArray = array ($table_field => $value)
+ public function setWhereQueryClause($whereArray)
+ {
+ $this->where = $whereArray;
+ }
+
+ //append the whereArray clause to $this_->whereClause
+ //whereArray = array ($table_field => $value)
+ public function appendWhereQueryClause($whereArray)
+ {
+ $this->where = array_merge($this->where,$whereArray);
+ }
+
+ //drop the char $char from the beginning of the string $string
+ public function dropStartChar($string,$char)
+ {
+ while(strcmp($string[0],$char) === 0)
+ {
+ $string = substr($string,1);
+ }
+ return $string;
+ }
+
+ //get the table name from $this->_where. If the table is not present then return $this->_tablesArray[0]
+ public function getTableName($field)
+ {
+ return isset($this->_where[$field]) ? $this->_where[$field] : $this->_tablesArray[0];
+ }
+
+ //method to create the where clause of the select query from the $this->where array
+ //$level: level of the ricorsion
+ //$whereClauseLevel: array containing the field=>value statements of the where clause. If $whereClause = null than $this->where is considered
+ public function createWhereClause($level = 0, $whereClauseLevel = null, $operator = null)
+ {
+ $whereClause = null;
+ $whereClauseArray = array();
+
+ $whereClause = isset($whereClauseLevel) ? $whereClauseLevel : $this->where;
+
+ foreach ($whereClause as $field => $value)
+ {
+ if (is_array($value))
+ {
+ if (strstr($field,"OR"))
+ {
+ $op = " OR ";
+ }
+ else if (strstr($field,"AND"))
+ {
+ $op = " AND ";
+ }
+ else
+ {
+ $op = null;
+ }
+ $newValue = $this->createWhereClause($level+1, $value, $op);
+ if (isset($newValue)) $whereClauseArray[] = $newValue;
+ }
+ else
+ {
+ $flag = 0; //equal where clause
+ if (isset($field))
+ {
+ //drop the 'n:' and '-' chars from $field
+ $fieldClean = str_replace('n!',null,$field);
+ $fieldClean = $this->dropStartChar($fieldClean,'-');
+ if (strcmp($value,Params::$nullQueryValue) !== 0 or (Params::$nullQueryValue === false))
+ {
+ foreach (params::$whereClauseSymbolArray as $symbol)
+ {
+ if (strstr($value,$symbol))
+ {
+ //check if write or not the table name
+ $tableName = strstr($field,'n!') ? null : $this->getTableName($field).'.';
+ $whereClauseArray[] = $tableName.$fieldClean.' '.$value;
+ $flag = 1; //not equal where clause
+ break;
+ }
+ }
+ if ($flag === 0)
+ {
+ $value = '"'.$value.'"';
+ //check if write or not the table name
+ $tableName = strstr($field,'n!') ? null : $this->getTableName($field).'.';
+ $whereClauseArray[] = $tableName.$fieldClean.'='.$value;
+ }
+ }
+ }
+ }
+ }
+ //get the logic operator at the current level
+ if (isset($operator))
+ {
+ $logicOper = $operator;
+ }
+ else
+ {
+ $logicOper = isset($this->logicalOperators[$level]) ? ' '.$this->logicalOperators[$level].' ' : ' AND ';
+ }
+ $whereClause = !empty($whereClauseArray) ? implode($logicOper,$whereClauseArray) : null;
+ $whereClause = (isset($whereClause) and $level>0) ? '('.$whereClause.')' : $whereClause;
+ return $whereClause;
+ }
+
+
+ //get the submitName having its key (the method name)
+ public function getSubmitName($key)
+ {
+ if (!array_key_exists($key,$this->submitNames))
+ {
+ return 'generalAction';
+// throw new Exception('query type <b>"'.$key. '"</b> not allowed in '.__METHOD__);
+ }
+ return $this->submitNames[$key];
+
+ }
+
+
+ //return the values, taken from the $_POST array, to be inserted inside the forms
+ //$queryType: insert or update
+ //$func: sanitize function to apply upon each value
+ //$id: if $queryType='update' that the values are taken from the record (of the main table of this model) having the primary key equal to $id
+ //$defaultValues = associative array of the form: array($entry=>$defaultValue)
+ //$functionsIfFromDb = associative array of the form: array($entry=>$function_to_be_applied)
+ public function getFormValues($queryType = 'insert', $func = 'sanitizeHtml',$id = null,$defaultValues = array(),$functionsIfFromDb = array())
+ {
+ @session_start();
+ if (is_array($func))
+ {
+ $funcPost = $func[0];
+ $funcDb = $func[1];
+ }
+ else
+ {
+ $funcPost = $func;
+ $funcDb = 'none';
+ }
+
+ $arrayType = array('update','insert');
+ $values = array();
+ $idName = $this->identifierName;
+ if (in_array($queryType,$arrayType))
+ {
+ $ident = null;
+ if (isset($id))
+ {
+ $ident = (int)$id;
+ }
+ else if (isset($_POST[$idName]))
+ {
+ $ident = (int)$_POST[$idName];
+ }
+ if ($this->result)
+ {
+ if ($queryType === 'update')
+ {
+ if (isset($ident))
+ {
+ $recordArray = $this->selectId($ident);
+
+ $fieldsArray = explode(',',$this->fields);
+
+ $values = $this->arrayExt->subset($recordArray,$this->fields,$funcDb);
+
+// foreach ($fieldsArray as $field)
+// {
+// $values[$field] = array_key_exists($field,$recordArray) ? $recordArray[$field] : '';
+// }
+
+ $values[$idName] = $ident;
+
+ //apply the functions upon entries
+ foreach ($functionsIfFromDb as $entry => $funcUponEntry)
+ {
+ if (array_key_exists($entry,$values))
+ {
+ if (!function_exists($funcUponEntry)) {
+ throw new Exception('Error in <b>'.__METHOD__.'</b>: function <b>'.$funcUponEntry. '</b> does not exist');
+ }
+
+ $values[$entry] = call_user_func($funcUponEntry,$values[$entry]);
+ }
+ }
+
+ //set values of $_SESSION array
+ foreach ($values as $k => $v)
+ {
+ if (isset($this->formStruct['entries'][$k]['type']))
+ {
+ if ($this->formStruct['entries'][$k]['type'] === 'File')
+ {
+ $_SESSION['form_'.$k] = $v;
+ }
+ }
+ }
+ }
+ }
+ else if ($queryType === 'insert')
+ {
+
+ $tempArray = is_array($defaultValues) ? $defaultValues : array();
+
+ $values = $this->arrayExt->subset($tempArray,$this->fields,$funcPost);
+
+ }
+ }
+ else
+ {
+ $values = $this->arrayExt->subset($_POST,$this->fields,$funcPost);
+
+ if ($queryType === 'update')
+ {
+ $values[$idName] = $ident;
+
+ //take values from $_SESSION array
+ $tempFieldArray = explode(',',$this->fields);
+
+ for ($i = 0; $i < count($tempFieldArray); $i++)
+ {
+ if (isset($this->formStruct['entries'][$tempFieldArray[$i]]['type']))
+ {
+ if ($this->formStruct['entries'][$tempFieldArray[$i]]['type'] === 'File')
+ {
+ if (isset($_SESSION['form_'.$tempFieldArray[$i]]))
+ {
+ $values[$tempFieldArray[$i]] = $_SESSION['form_'.$tempFieldArray[$i]];
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return $values;
+ }
+
+
+ //method to set the properties $this->fields and $this->values
+ public function setFields($fields,$func = 'sanitizeAll')
+ {
+ $this->values = $this->arrayExt->subset($_POST,$fields,$func);
+ $this->fields = $this->extractFields($fields);
+
+ //set the backup variables
+ $this->_backupFields = $this->fields;
+ $this->_backupValues = $this->values;
+ }
+
+
+ //clear the fields list
+ public function clearFields()
+ {
+ $this->_backupFields = $this->fields;
+ $this->_backupValues = $this->values;
+ $this->fields = '';
+ $this->values = array();
+ }
+
+ //del the fields written in the $list argument. The $list argument has to be of the type: field1,field2,...
+ public function delFields($list)
+ {
+ $this->_backupFields = $this->fields;
+ $this->_backupValues = $this->values;
+ $this->values = $this->arrayExt->subsetComplementary($this->values,$list);
+// $this->fields = implode(',',array_keys($this->values));
+ }
+
+ //restore the fields and values saved in $_backupFields and $_backupValues
+ public function restoreFields()
+ {
+ $this->fields = $this->_backupFields;
+ $this->values = $this->_backupValues;
+ }
+
+ //method to clean the $fields string deleting the colons (and the word after the colon)
+ public function extractFields($fields) {
+ $fieldsArray = explode(',',$fields);
+ $resultString = array();
+ foreach ($fieldsArray as $field) {
+ if (strstr($field,':')) {
+ $temp = explode(':',$field);
+ $resultString[] = $temp[0];
+ } else {
+ $resultString[] = $field;
+ }
+ }
+ return implode(',',$resultString);
+ }
+
+ //add the supplementary value on insert and update queries
+ //$queryType: insert or update
+ public function setSupplValues($queryType)
+ {
+ if ($queryType === 'insert')
+ {
+ $supplValues = $this->supplInsertValues;
+ }
+ else if ($queryType === 'update')
+ {
+ $supplValues = $this->supplUpdateValues;
+ }
+
+ $baseFields = implode(',',array_keys($this->values));
+
+ $supplFields = implode(',',array_keys($supplValues));
+ $supplFields = (strcmp($supplFields,'') === 0) ? $supplFields : ',' . $supplFields;
+
+ $fields = $baseFields . $supplFields;
+ $values = array_merge(array_values($this->values),array_values($supplValues));
+
+ return array($fields,$values);
+ }
+
+
+ //method to call the update query (overriding of the base_db del method)
+ //update the record with the primary key equal to $id (default)
+ //if $whereClause is set then use $whereClause as where clause of the update query
+ public function update($id = null, $whereClause = null)
+ {
+ if (!is_array($this->supplUpdateValues))
+ {
+ throw new Exception('error in <b>' . __METHOD__ . '</b>: the <b>supplUpdateValues</b> property has to be an array.');
+ }
+ $el = $this->setSupplValues('update');
+ $this->queryResult = false;
+
+ if (isset($whereClause))
+ {
+ $result = $this->db->update($this->_tablesArray[0],$el[0],$el[1],$whereClause);
+ $this->setNotice($result);
+ return $result;
+ }
+ else
+ {
+ if (isset($id))
+ {
+ $where = $this->_idFieldsArray[0].'='.(int)($id);
+ $result = $this->db->update($this->_tablesArray[0],$el[0],$el[1],$where);
+ $this->setNotice($result);
+ return $result;
+ }
+ else
+ {
+ $this->notice = $this->_resultString->getString('no-id');
+ $this->result = false;
+ $this->identifierValue = null;
+ return false;
+ }
+ }
+ }
+
+ //method to call the insert query (overriding of the base_db del method)
+ public function insert() {
+
+ $this->queryResult = false;
+ if (!is_array($this->supplInsertValues)) {
+ throw new Exception('error in <b>' . __METHOD__ . '</b>: the <b>supplInsertValues</b> property has to be an array.');
+ }
+
+ if (isset($this->_idOrder))
+ {
+ $maxValue = $this->db->getMax($this->_tablesArray[0],$this->_idOrder);
+ $this->supplInsertValues[$this->_idOrder] = (int)$maxValue + 1;
+ }
+
+ $el = $this->setSupplValues('insert');
+
+ $result = $this->db->insert($this->_tablesArray[0],$el[0],$el[1]);
+ $this->setNotice($result);
+ return $result;
+ }
+
+ //method to call the delete query (overriding of the base_db del method)
+ public function del($id = null, $whereClause = null) {
+
+ $this->queryResult = false;
+
+ if (isset($whereClause))
+ {
+ $result = $this->db->del($this->_tablesArray[0],$whereClause);
+ $this->setNotice($result);
+ return $result;
+ }
+ else
+ {
+ if (isset($id)) {
+ $where = $this->_idFieldsArray[0].'='.(int)$id;
+ $result = $this->db->del($this->_tablesArray[0],$where);
+ $this->setNotice($result);
+ return $result;
+ } else {
+ $this->notice = $this->_resultString->getString('no-id');
+ $this->result = false;
+ $this->identifierValue = null;
+ return false;
+ }
+ }
+ }
+
+ //move to the top the record having $this->_idOrder = $id
+ //where clause
+ public function moveup($id)
+ {
+ return $this->move($id,'up');
+ }
+
+ //move to the top the record having $this->_idOrder = $id
+ //where clause
+ public function movedown($id)
+ {
+ return $this->move($id,'down');
+ }
+
+ //move the record having $this->_tablesArray[0] = $id
+ //$par: 'up' or 'down'
+ //where clause
+ public function move($id,$par = 'up')
+ {
+ $this->queryResult = false;
+ if (isset($id))
+ {
+ $increm = ($par === 'up') ? 1 : -1;
+
+ $backupLimit = $this->limit;
+ $this->limit = null;
+
+ $data = $this->getFields($this->_tablesArray[0].'.'.$this->_idFieldsArray[0].','.$this->_tablesArray[0].'.'.$this->_idOrder);
+
+ for($i = 0; $i < count($data); $i++)
+ {
+ if (strcmp($data[$i][$this->_tablesArray[0]][$this->_idFieldsArray[0]],$id) === 0)
+ {
+ if (($par === 'up' and $i !== 0) or ($par === 'down' and $i !== (count($data)-1)))
+ {
+ $prevOrder = $data[$i-$increm][$this->_tablesArray[0]][$this->_idOrder];
+ $prevId = $data[$i-$increm][$this->_tablesArray[0]][$this->_idFieldsArray[0]];
+ $currentOrder = $data[$i][$this->_tablesArray[0]][$this->_idOrder];
+ $currentId = $data[$i][$this->_tablesArray[0]][$this->_idFieldsArray[0]];
+
+ //exchange the id_order of the two record
+ $res1 = $this->db->update($this->_tablesArray[0],$this->_idOrder,array($prevOrder),$this->_idFieldsArray[0]."='$currentId'");
+ $res2 = $this->db->update($this->_tablesArray[0],$this->_idOrder,array($currentOrder),$this->_idFieldsArray[0]."='$prevId'");
+ $result = ($res1 and $res2);
+ $this->setNotice($result);
+ return $result;
+ }
+ }
+ }
+
+ $this->limit = $backupLimit;
+ }
+ else
+ {
+ $this->notice = $this->_resultString->getString('no-id');
+ $this->result = false;
+ $this->identifierValue = null;
+ return false;
+ }
+ return false;
+ }
+
+ public function setNotice($result) {
+ if ($result) {
+ $this->notice = $this->_resultString->getString('executed');
+ $this->result = true;
+ $this->queryResult = true;
+ } else {
+ $this->notice = $this->_resultString->getString('error');
+ $this->result = false;
+ $this->queryResult = false;
+ }
+ }
+
+ //method used to verify that the value of a field is not duplicated
+ //$fieldsList: list of fields to check. Ex: field1,field2,...
+ //$where: the where clause
+ public function checkUnique($fieldsList,$where = null)
+ {
+ $errorString = null;
+ $numb = 0;
+ $fieldsArray = explode(',',$fieldsList);
+ $queryFieldsArray = explode(',',$this->fields);
+ foreach ($fieldsArray as $field)
+ {
+ if (in_array($field,$queryFieldsArray))
+ {
+ if ($this->db->recordExists($this->_tablesArray[0],$field,$this->values[$field],$where))
+ {
+ $errorString .= $this->_dbCondString->getNotUniqueString($field);
+ $numb++;
+ }
+ }
+ }
+ $this->notice = $errorString;
+ return $numb === 0 ? true : false;
+ }
+
+ //like checkUnique: check all the records of the table apart from the record that has to be modified
+ public function checkUniqueCompl($fieldsList,$id = null)
+ {
+ if (isset($id))
+ {
+ $where = $this->_idFieldsArray[0].'!='.(int)($id);
+ return $this->checkUnique($fieldsList,$where);
+ } else {
+ $this->notice = $this->_resultString->getString('no-id');
+ return false;
+ }
+ }
+
+ //method to apply the database conditions listed in the $this->databaseConditions associative array
+ //$queryType: indicates what set of validate conditions has to be considered (it's the key of the associative array)
+ public function applyDatabaseConditions($queryType,$id = null)
+ {
+ if (array_key_exists($queryType,$this->databaseConditions))
+ {
+ if (!is_array($this->databaseConditions[$queryType]))
+ {
+ throw new Exception('error in method <b>'.__METHOD__.'</b> : <b>databaseConditions['.$queryType.']</b> has to be an associative array');
+ }
+
+ foreach ($this->databaseConditions[$queryType] as $key => $values)
+ {
+
+ //personalized error string
+ $altErrorString = null;
+
+ //delete all the '+' chars
+ $key = $this->dropStartChar($key,'+');
+
+ if (strcmp($values,'all') === 0 or strstr($values,'all|'))
+ {
+ if (strstr($values,'all|'))
+ {
+ $values = str_replace('all|',$this->fields.'|',$values);
+ }
+ else
+ {
+ $values = $this->fields;
+ }
+ }
+
+ if (strstr($values,'|'))
+ {
+ $temp = explode('|',$values);
+ $altErrorString = "<div class='".Params::$errorStringClassName."'>".$temp[1]."</div>\n";
+ $values = $temp[0];
+ }
+
+ $allowedMethod = array('checkUnique','checkUniqueCompl');
+ if (!in_array($key,$allowedMethod))
+ {
+ throw new Exception('error in method '.__METHOD__.' : method "'.$key. '" not allowed in the property named databaseConditions');
+ }
+ if (!call_user_func_array(array($this,$key),array($values,$id)))
+ {
+ if (isset($altErrorString)) $this->notice = $altErrorString;
+ $this->result = false;
+ $this->queryResult = false;
+ return false;
+ }
+ }
+ return true;
+ } else {
+ return true;
+ }
+ }
+
+
+ //method to apply the validate conditions listed in the $this->strongConditions associative array
+ //$queryType: indicates what set of validate conditions has to be considered (it's the key of the associative array)
+ //$strength: 'strong' or 'soft'
+ public function applyValidateConditions($queryType,$strength = 'strong')
+ {
+ if ($strength === 'strong')
+ {
+ $validateObj = $this->_arrayStrongCheck;
+ $conditions = $this->strongConditions;
+ $errString = 'strongConditions';
+ }
+ else
+ {
+ $validateObj = $this->_arraySoftCheck;
+ $conditions = $this->softConditions;
+ $errString = 'softConditions';
+
+ if (Params::$nullQueryValue !== false)
+ {
+ $conditions['insert']['+++++checkIsNotStrings|'.Params::$nullQueryValue] = 'all';
+ $conditions['update']['+++++checkIsNotStrings|'.Params::$nullQueryValue] = 'all';
+ }
+ }
+
+ if (array_key_exists($queryType,$conditions))
+ {
+ if (!is_array($conditions[$queryType]))
+ {
+ throw new Exception('error in method <b>'.__METHOD__.'</b> : <b>'.$errString.'['.$queryType.']</b> has to be an associative array');
+ }
+
+ foreach ($conditions[$queryType] as $key => $values)
+ {
+
+ //personalized error string
+ $altErrorString = null;
+
+ //delete all the '+' chars
+ $key = $this->dropStartChar($key,'+');
+
+ if (strcmp($values,'all') === 0 or strstr($values,'all|'))
+ {
+ if (strstr($values,'all|'))
+ {
+ $values = str_replace('all|',$this->fields.'|',$values);
+ }
+ else
+ {
+ $values = $this->fields;
+ }
+ }
+
+ if (strstr($values,'|'))
+ {
+ $temp = explode('|',$values);
+ $altErrorString = "<div class='".Params::$errorStringClassName."'>".$temp[1]."</div>\n";
+ $values = $temp[0];
+ }
+
+ $baseArgs = array($_POST,$values);
+
+ if (strstr($key,'|'))
+ {
+ $funcArray = explode('|',$key);
+ $funcName = $funcArray[0];
+ array_shift($funcArray);
+ $funcArgs = array_merge($baseArgs,$funcArray);
+ }
+ else
+ {
+ $funcName = $key;
+ $funcArgs = $baseArgs;
+ }
+
+ if (!method_exists($validateObj,$funcName) or $funcName === 'checkGeneric')
+ {
+ throw new Exception('error in method '.__METHOD__.' :method "'.$funcName. '" not allowed in '.$errString);
+ }
+ if (!call_user_func_array(array($validateObj,$funcName),$funcArgs))
+ {
+ $this->notice .= (isset($altErrorString)) ? $altErrorString : $validateObj->errorString;
+ $this->result = false;
+ $this->queryResult = false;
+ return false;
+ }
+ }
+ return true;
+ } else {
+ return true;
+ }
+ }
+
+
+ //apply, in sequence, the strong,soft and database conditions
+ //$methodName: insert,update
+ //$id: the id of the record. It is necessary for database conditions
+ public function checkConditions($methodName,$id = null)
+ {
+ if ($this->applyValidateConditions($methodName,'strong'))
+ {
+ if ($this->applyValidateConditions($methodName,'soft'))
+ {
+ if ($this->applyDatabaseConditions($methodName,$id))
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ //method that calls the function indicated in $this->submitNames. Ex: if $_POST['delAction'] is found, then the "del" method is called.
+ public function updateTable($methodsList = '',$id = null) {
+
+ $allowedMethodsArray = explode(',',$methodsList);
+ $resultArray = array();
+ $this->identifierValue = null;
+ if (isset($id))
+ {
+ $this->identifierValue = (int)$id;
+ }
+ else if (isset($_POST[$this->identifierName]))
+ {
+ $this->identifierValue = (int)$_POST[$this->identifierName];
+ }
+ foreach ($this->submitNames as $methodName => $submitName)
+ {
+ if (array_key_exists($submitName,$_POST))
+ {
+ $this->submitName = $submitName;
+ if (method_exists($this,$methodName))
+ {
+ //if the method is allowed
+ if (in_array($methodName,$allowedMethodsArray))
+ {
+ if ($this->checkConditions($methodName,$this->identifierValue))
+ {
+ $this->notice = null;
+ call_user_func_array(array($this,$methodName),array($this->identifierValue));
+ }
+ }
+ }
+ else
+ {
+ throw new Exception('method <b>'.$methodName.'</b> not defined in class <b>'.__CLASS__.'</b>; error in method <b>'.__METHOD__.'</b>');
+ }
+ return; //only one cycle!
+ }
+ }
+ }
+
+ //method to build the array of popup objects
+ public function popupBuild()
+ {
+ foreach ($this->_popupItemNames as $field => $itemName)
+ {
+// if (array_key_exists($field,$this->_where))
+// {
+ $fieldClean = str_replace('n!',null,$field);
+ $itemNameClean = str_replace('n!',null,$itemName);
+ $fieldClean = $this->dropStartChar($fieldClean,'-');
+ $itemNameClean = $this->dropStartChar($itemNameClean,'-');
+
+ //fields that have to be extracted
+ $queryFields = ($fieldClean === $itemNameClean) ? $fieldClean : $fieldClean.','.$itemNameClean;
+
+ $table = $this->getTableName($field);
+ $this->popupArray[$field] = new Popup();
+
+ $popupWhereClause = array_key_exists($field,$this->_popupWhere) ? $this->_popupWhere[$field] : null;
+
+ $result = $this->db->select($table,$queryFields,$popupWhereClause,$fieldClean);
+
+ if ($result and $result !== false)
+ {
+ //get the label of the popup menu
+ $label = array_key_exists($field,$this->_popupLabels) ? $this->_popupLabels[$field] : $table.' : '.$itemNameClean;
+ $this->popupArray[$field]->name = $label;
+
+ //get the table name
+ $fieldTable = isset($result[0][$table][$fieldClean]) ? $table : Params::$aggregateKey;
+ $itemNameTable = isset($result[0][$table][$itemNameClean]) ? $table : Params::$aggregateKey;
+
+ foreach ($result as $row)
+ {
+ $this->popupArray[$field]->itemsValue[] = $row[$fieldTable][$fieldClean];
+
+ if (array_key_exists($field,$this->_popupFunctions))
+ {
+ if (!function_exists($this->_popupFunctions[$field]))
+ {
+ throw new Exception('Error in <b>'.__METHOD__.'</b>: function <b>'.$this->_popupFunctions[$field]. '</b> does not exist');
+ }
+
+ $tempName = call_user_func($this->_popupFunctions[$field],$row[$itemNameTable][$itemNameClean]);
+ }
+ else
+ {
+ $tempName = $row[$itemNameTable][$itemNameClean];
+ }
+
+ $this->popupArray[$field]->itemsName[] = $tempName;
+ }
+ }
+// }
+ }
+ }
+
+
+ //get the element before and after the current one
+ //$key: the key of the self::$where array that indicates the field to be used in order to find out the records before and after
+ //$fields: the fields that have to be extracted
+ public function getNeighbours($key,$fields = '')
+ {
+ //backup of the values
+ $tempWhere = $this->where;
+ $tempLimit = $this->limit;
+ $tempOrderBy = $this->orderBy;
+ $this->limit = 1;
+ //before
+ $this->where[$key] = '<'.$tempWhere[$key];
+ $this->orderBy = $this->getTableName($key).'.'.$key.' DESC';
+ $dataAfter = $this->getFields($fields);
+ //after
+ $this->where[$key] = '>'.$tempWhere[$key];
+ $this->orderBy = $this->getTableName($key).'.'.$key;
+ $dataBefore = $this->getFields($fields);
+ //restore the previous values
+ $this->where = $tempWhere;
+ $this->limit = $tempLimit;
+ $this->orderBy = $tempOrderBy;
+ $result[0] = isset($dataBefore[0]) ? $dataBefore[0] : null;
+ $result[1] = isset($dataAfter[0]) ? $dataAfter[0] : null;
+ return $result;
+ }
+
+ //set the $select property and return the current object
+ public function select($fields = null)
+ {
+ $this->select = $fields;
+ return $this;
+ }
+
+ //set the $from property and return the current object
+ public function from($tables = null)
+ {
+ $this->from = isset($tables) ? $tables : $this->_tables;
+ return $this;
+ }
+
+ //set the on property and return the current object
+ public function on($joinClause = '-')
+ {
+ $this->on[] = $joinClause;
+ $this->using[] = null;
+ return $this;
+ }
+
+ //set the $using property and return the current object
+ public function using($using = null)
+ {
+ $this->using[] = $using;
+ $this->on[] = null;
+ return $this;
+ }
+
+ //set the $join property and return the current object
+ public function left($string = null)
+ {
+ $this->join[] = "l:$string";
+ return $this;
+ }
+
+ //set the $join property and return the current object
+ public function right($string = null)
+ {
+ $this->join[] = "r:$string";
+ return $this;
+ }
+
+ //set the $join property and return the current object
+ public function inner($string = null)
+ {
+ $this->join[] = "i:$string";
+ return $this;
+ }
+
+ //set the $where property and return the current object
+ public function where($where = array())
+ {
+ $this->where = $where;
+ return $this;
+ }
+
+ //append the $where array to the ::where property and return the current object
+ public function aWhere($where = array())
+ {
+ $this->appendWhereQueryClause($where);
+ return $this;
+ }
+
+ //set the $groupBy property and return the current object
+ public function groupBy($groupBy = null)
+ {
+ $this->groupBy = $groupBy;
+ return $this;
+ }
+
+ //set the $orderBy property and return the current object
+ public function orderBy($orderBy = null)
+ {
+ $this->orderBy = $orderBy;
+ return $this;
+ }
+
+ //set the $limit property and return the current object
+ public function limit($limit = null)
+ {
+ $this->limit = $limit;
+ return $this;
+ }
+
+ //set the $listArray property
+ public function toList($key, $value = null)
+ {
+ $this->listArray = array($key,$value);
+ $this->toList = true;
+ return $this;
+ }
+
+ //reset all the clauses of the select query
+ public function clear()
+ {
+ $this->select = null;
+ $this->where = array();
+ $this->groupBy = null;
+ $this->orderBy = null;
+ $this->limit = null;
+ $this->from = null;
+ $this->on = array();
+ $this->using = array();
+ $this->join = array();
+ $this->toList = false;
+ return $this;
+ }
+
+ //initialize and populate the ::form property (reference to a Form_Form object)
+ public function setForm($defAction = null, $defSubmit = array(), $defMethod = 'POST', $defEnctype = null)
+ {
+ if (isset($this->formStruct))
+ {
+ $action = array_key_exists('action',$this->formStruct) ? $this->formStruct['action'] : $defAction;
+ $submit = array_key_exists('submit',$this->formStruct) ? $this->formStruct['submit'] : $defSubmit;
+ $entries = array_key_exists('entries',$this->formStruct) ? $this->formStruct['entries'] : null;
+ $method = array_key_exists('post',$this->formStruct) ? $this->formStruct['post'] : $defMethod;
+ $enctype = array_key_exists('enctype',$this->formStruct) ? $this->formStruct['enctype'] : $defEnctype;
+
+ $this->form = new Form_Form($action,$submit,$method,$enctype);
+
+ if (isset($entries))
+ {
+ $this->form->setEntries($entries);
+ }
+
+ $copy = $this->form->entry;
+
+ foreach ($copy as $name => $entry)
+ {
+ if (strcmp($entry->type,'Select') === 0 and isset($entry->options))
+ {
+ if (!is_array($entry->options))
+ {
+ if (strstr($entry->options,'foreign::'))
+ {
+ $elements = explode('::',$entry->options);
+
+ for ($i = 0; $i < count($elements); $i++)
+ {
+ if (strcmp($elements[$i],'--') === 0) $elements[$i] = null;
+ }
+ //send the query
+ array_shift($elements);
+ $resultSet = call_user_func_array(array($this->db,'select'),$elements);
+
+ $single = true;
+
+ if (strstr($elements[1],','))
+ {
+ $args = explode(',',$elements[1]);
+ //add the table name
+ $args[0] = $elements[0].'.'.$args[0];
+ $args[1] = $elements[0].'.'.$args[1];
+ //associative array
+ $single = false;
+ }
+ else
+ {
+ $args[0] = $elements[0].'.'.$elements[1];
+ $args[1] = null;
+ }
+
+ $list = $this->getList($resultSet,$args[0],$args[1]);
+
+ $this->form->entry[$name]->options = ($single) ? implode(',',array_values($list)) : $list;
+ }
+ }
+ }
+ }
+
+ }
+ else
+ {
+ $this->form = new Form_Form($defAction,$defSubmit,$defMethod,$defEnctype);
+ }
+ }
+
+ //get a list from a result set
+ //$resultSet: the result set coming from a select query
+ public function getList($resultSet, $key, $value = null)
+ {
+ $list = array();
+
+ if (strstr($key,'.'))
+ {
+ $arr = explode('.',$key);
+ $keyTable = $arr[0];
+ $keyField = $arr[1];
+ }
+ else
+ {
+ $keyTable = $this->_tablesArray[0];
+ $keyField = $key;
+ }
+
+ if (!isset($value))
+ {
+ foreach ($resultSet as $row)
+ {
+ $list[] = $row[$keyTable][$keyField];
+ }
+ }
+ else
+ {
+ if (strstr($value,'.'))
+ {
+ $arr = explode('.',$value);
+ $valueTable = $arr[0];
+ $valueField = $arr[1];
+ }
+ else
+ {
+ $valueTable = $this->_tablesArray[0];
+ $valueField = $value;
+ }
+
+ foreach ($resultSet as $row)
+ {
+ $list[$row[$keyTable][$keyField]] = $row[$valueTable][$valueField];
+ }
+
+ }
+ return $list;
+ }
+
+ // Retrieves the ID generated for an AUTO_INCREMENT column by the previous query (usually INSERT).
+ public function lastId()
+ {
+ return $this->db->lastId();
+ }
+
+ //send a free query
+ public function query($query)
+ {
+ return $this->db->query($query);
+ }
+
+ //the text of the error message from previous MySQL operation
+ public function getError()
+ {
+ return $this->db->getError();
+ }
+
+ //the numerical value of the error message from previous MySQL operation
+ public function getErrno()
+ {
+ return $this->db->getErrno();
+ }
+
+ //define the abstract method to get the value of the record $id of the main table
+ abstract public function selectId($id);
+
+ //define the abstract method to get the fields from the tables
+ abstract public function getFields();
+
+} \ No newline at end of file
diff --git a/h-source/Library/Model/Base.php b/h-source/Library/Model/Base.php
index 67bd91c..4162a56 100755
--- a/h-source/Library/Model/Base.php
+++ b/h-source/Library/Model/Base.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -25,12 +25,10 @@ if (!defined('EG')) die('Direct access not allowed!');
abstract class Model_Base
{
- public $foreignKeys = array(); //list of foreign keys
-
public $fields = ''; //the fields that have to be manipulated by the update and insert query
public $values = array(); //the values that corresponding to the $this->fields fields
public $form = null; //reference to a Form_Form object
- public $formStruct = array("entries" => array()); //the form structure
+ public $formStruct = null; //the form structure
public $submitName = null; //the current submitName (from the form)
public $identifierName = 'identifier';
@@ -39,18 +37,15 @@ abstract class Model_Base
public $result = true; //the result of validate conditions, database conditions and query. It can be 'true' or 'false'
public $queryResult = false; //the result of the query
- //conditions that the $_POST array has to satisfy (strong)
+ //conditions that have to be satisfied before applying the query
+ //Ex: 'update'=>'checkEmpty:titolo,autore','submitName'=>'conditions'
public $strongConditions = array();
- //conditions that the $_POST array has to satisfy (soft)
+ //conditions that have to be satisfied before applying the query
+ //Ex: 'update'=>'checkEmpty:titolo,autore','submitName'=>'conditions'
+ //do not return error if a value is equal to '' or null
public $softConditions = array();
- //conditions that $this->values has to satisfy (strong)
- public $valuesConditions = array();
-
- //array where the conditions are temporary saved when the saveConditions is called
- public $backupConditions = array();
-
//conditions that have to be satisfied before applying the query
//check that the new values inserted satisfy some conditions
//Ex: 'update'=>'checkUniqueCompl:titolo,autore;checkUnique:titolo','insert'=>'checkUnique:titolo'
@@ -62,17 +57,13 @@ abstract class Model_Base
public $supplUpdateValues = array(); //associative array defining supplementary values to be inserted on each update query. It has to have the following form: array(field1 => value1,field2 => value2, ...)
- public $backupSelect = array(); //where the status of the where clause is stored when the save() method is called
public $select = null; //fields that have to be selected in select queries
- public $sWhere = null; //string: free where clause
public $where = array(); //associative array containing all the where clauses ($field => $value)
//group by, order by and limit clauses
public $groupBy = null;
public $orderBy = null;
public $limit = null;
- public $convert = false; //It can be tru or false. If true the extracted values are converted from MySQL format to $_lang format
-
public $from = null; //from clause of the select queries
public $on = array(); //on array
public $using = array(); //using array
@@ -108,14 +99,9 @@ abstract class Model_Base
protected $_popupWhere = array(); //where clause for the pupup menu
- protected $_popupOrderBy = array(); //order by clause for the pupup menu
-
protected $_resultString; //reference to the class containing all the result strings of the db queries
protected $_dbCondString; //reference to the class containing all the result strings of the database conditions
- protected $_conversionToDbObject = null; //reference to the class to convert the values from current lang formats to MySQL formats
- protected $_conversionFromDbObject = null; //reference to the class to convert the values from MySQL formats to current lang formats
-
protected $_backupFields = ''; //field saved after the delFields method has been applied
protected $_backupValues = array(); //values saved after the delFields method has been applied
protected $_allowedDbMethods = array('update','insert','del','moveup','movedown'); //methods that can be called by the updateTable method
@@ -133,7 +119,6 @@ abstract class Model_Base
protected $_arrayStrongCheck; //Array_Validate_Strong object
protected $_arraySoftCheck; //Array_Validate_Soft object
- protected $_arrayValuesCheck; //Array_Validate_Values object
public $db; //reference to the database layer class
protected $_lang = null; //language of notices
@@ -145,16 +130,15 @@ abstract class Model_Base
$this->_where[$this->_idFieldsArray[0]] = $this->_tablesArray[0];
$this->arrayExt = new ArrayExt();
- //set the language of notices
- $this->_lang = Params::$language;
-
//initialize the validate objects
$this->_arrayStrongCheck = new Array_Validate_Strong($this->_lang);
$this->_arraySoftCheck = new Array_Validate_Soft($this->_lang);
- $this->_arrayValuesCheck = new Array_Validate_Values($this->_lang);
$this->identifierName = $this->_idFieldsArray[0];
+ //set the language of notices
+ $this->_lang = Params::$language;
+
//create the $_resultString object (result strings of the db queries)
$modelStringClass = 'Lang_'.$this->_lang.'_ModelStrings';
if (!class_exists($modelStringClass))
@@ -171,24 +155,6 @@ abstract class Model_Base
}
$this->_dbCondString = new $dbCondStringClass();
- //create the references of the classes to convert to e from MySQL formats
- if (DATABASE_TYPE === "Mysqli" or DATABASE_TYPE === "Mysql")
- {
- $_conversionToDbObject = 'Lang_'.$this->_lang.'_Formats_To_Mysql';
- if (!class_exists($_conversionToDbObject))
- {
- $_conversionToDbObject = 'Lang_En_Formats_To_Mysql';
- }
- $this->_conversionToDbObject = new $_conversionToDbObject();
-
- $_conversionFromDbObject = 'Lang_'.$this->_lang.'_Formats_From_Mysql';
- if (!class_exists($_conversionFromDbObject))
- {
- $_conversionFromDbObject = 'Lang_En_Formats_From_Mysql';
- }
- $this->_conversionFromDbObject = new $_conversionFromDbObject();
- }
-
//instantiate the database class
$this->db = Factory_Db::getInstance(DATABASE_TYPE);
@@ -205,22 +171,12 @@ abstract class Model_Base
}
//sanitize all the $values property
- public function sanitize($function = "sanitizeDb")
+ public function sanitize()
{
- if (!function_exists($function)) {
- throw new Exception('Error in <b>'.__METHOD__.'</b>: function <b>'.$function.'</b> does not exists.');
- }
-
$keys = implode(',',array_keys($this->values));
- $this->values = $this->arrayExt->subset($this->values,$keys,$function);
+ $this->values = $this->arrayExt->subset($this->values,$keys,'sanitizeDb');
}
- //return the name of the primary key
- public function getPrimaryKey()
- {
- return $this->_idFields;
- }
-
//change a resulting string from a db query
public function setString($key,$value)
{
@@ -321,11 +277,11 @@ abstract class Model_Base
{
foreach (params::$whereClauseSymbolArray as $symbol)
{
- if (stristr($value,$symbol))
+ if (strstr($value,$symbol))
{
//check if write or not the table name
$tableName = strstr($field,'n!') ? null : $this->getTableName($field).'.';
- $whereClauseArray[] = strstr($field,'n!n!') ? $value : $tableName.$fieldClean.' '.$value;
+ $whereClauseArray[] = $tableName.$fieldClean.' '.$value;
$flag = 1; //not equal where clause
break;
}
@@ -335,7 +291,7 @@ abstract class Model_Base
$value = '"'.$value.'"';
//check if write or not the table name
$tableName = strstr($field,'n!') ? null : $this->getTableName($field).'.';
- $whereClauseArray[] = strstr($field,'n!n!') ? $value : $tableName.$fieldClean.'='.$value;
+ $whereClauseArray[] = $tableName.$fieldClean.'='.$value;
}
}
}
@@ -368,129 +324,7 @@ abstract class Model_Base
}
- //converts values from MySQl to $_lang format when filling the form with values coming from the DB
- public function convertFromMysql($values)
- {
- if (Params::$automaticConversionFromDbFormat)
- {
- if (isset($this->_conversionFromDbObject))
- {
- //get all types as associative array
- $types = $this->db->getTypes($this->_tables, "*", false, true);
-
- if ($types)
- {
- $values = $this->convertFromMysqlT($types, $values, $this->db->getEnumTypes());
- }
- }
- }
-
- return $values;
- }
-
- //convert an array associaive from MySQL format to $_lang format
- //$values: array associative to convert
- //$types: types of the elements of the associative array
- //$excludeTypes: array of type whose conversion has to be avoided
- public function convertFromMysqlT($types, $values, $excludeTypes = array())
- {
- foreach ($values as $field => $value)
- {
- if (array_key_exists($field, $types))
- {
- if (!in_array(strtolower($types[$field]),$excludeTypes))
- {
- if (method_exists($this->_conversionFromDbObject,strtolower($types[$field])))
- {
- $values[$field] = call_user_func(array($this->_conversionFromDbObject, strtolower($types[$field])), $values[$field]);
- }
- }
- }
- }
- return $values;
- }
-
- //set the default values taking it from DB or from type definition
- public function setDefaultFormValues($fields)
- {
- $returnDefaultValues = array();
-
- if (Params::$automaticallySetFormDefaultValues)
- {
- if (isset($this->_conversionFromDbObject))
- {
- //get all types as associative array
- $types = $this->db->getTypes($this->_tables, "*", true, true);
-
- //get all default values as associative array
- $defaultValues = $this->db->getDefaultValues($this->_tables, "*", false, true);
-
- $fieldsArray = explode(",",$fields);
-
- foreach ($fieldsArray as $field)
- {
- if (array_key_exists($field,$defaultValues))
- {
- if (preg_match('/^('.implode("|",$this->db->getCharTypes()).')/i',$types[$field],$matches) or preg_match('/^('.implode("|",$this->db->getTextTypes()).')/i',$types[$field],$matches))
- {
- if (strcmp($defaultValues[$field],"") !== 0)
- {
- $returnDefaultValues[$field] = $defaultValues[$field];
- }
- }
- else if (preg_match('/^('.implode("|",$this->db->getIntegerTypes()).')/i',$types[$field],$matches) or preg_match('/^('.implode("|",$this->db->getFloatTypes()).')$/i',$types[$field],$matches) or preg_match('/^('.implode("|",$this->db->getDecimalTypes()).')/i',$types[$field],$matches))
- {
- if (strcmp($defaultValues[$field],"") !== 0)
- {
- $returnDefaultValues[$field] = method_exists($this->_conversionFromDbObject,strtolower($matches[1])) ? call_user_func(array($this->_conversionFromDbObject, strtolower($matches[1])), $defaultValues[$field]) : $defaultValues[$field];
- }
- else
- {
- $returnDefaultValues[$field] = 0;
- }
- }
- else if (preg_match('/^('.implode("|",$this->db->getDateTypes()).')$/i',$types[$field],$matches))
- {
- $defDate = Params::$useCurrentDateAsDefaultDate ? date("Y-m-d") : "";
- if (strcmp($defaultValues[$field],"") !== 0)
- {
- $defDate = $defaultValues[$field];
- }
-
- if (method_exists($this->_conversionFromDbObject,strtolower($types[$field])))
- {
- $returnDefaultValues[$field] = call_user_func(array($this->_conversionFromDbObject, strtolower($types[$field])), $defDate);
- }
- else
- {
- $returnDefaultValues[$field] = $defDate;
- }
- }
- else if (preg_match('/^('.implode("|",$this->db->getEnumTypes()).')\((.*?)\)$/i',$types[$field],$matches))
- {
- if (strcmp($defaultValues[$field],"") !== 0)
- {
- $returnDefaultValues[$field] = $defaultValues[$field];
- }
- else
- {
- $temp = array();
- $strings = explode(",",$matches[2]);
- for ($i=0;$i<count($strings);$i++)
- {
- $returnDefaultValues[$field] = trim($strings[$i],"'\"");
- break;
- }
- }
- }
- }
- }
- }
- }
-
- return $returnDefaultValues;
- }
-
+
//return the values, taken from the $_POST array, to be inserted inside the forms
//$queryType: insert or update
//$func: sanitize function to apply upon each value
@@ -533,12 +367,15 @@ abstract class Model_Base
{
$recordArray = $this->selectId($ident);
- $recordArray = $this->convertFromMysql($recordArray);
-
$fieldsArray = explode(',',$this->fields);
-
+
$values = $this->arrayExt->subset($recordArray,$this->fields,$funcDb);
+// foreach ($fieldsArray as $field)
+// {
+// $values[$field] = array_key_exists($field,$recordArray) ? $recordArray[$field] : '';
+// }
+
$values[$idName] = $ident;
//apply the functions upon entries
@@ -569,16 +406,8 @@ abstract class Model_Base
}
else if ($queryType === 'insert')
{
- //set the default values taking it from DB or from type definition
- $tempArray = $this->setDefaultFormValues($this->fields);
- if (is_array($defaultValues))
- {
- foreach ($defaultValues as $field => $value)
- {
- $tempArray[$field] = $value;
- }
- }
+ $tempArray = is_array($defaultValues) ? $defaultValues : array();
$values = $this->arrayExt->subset($tempArray,$this->fields,$funcPost);
@@ -697,8 +526,6 @@ abstract class Model_Base
//if $whereClause is set then use $whereClause as where clause of the update query
public function update($id = null, $whereClause = null)
{
- $this->notice = null;
-
if (!is_array($this->supplUpdateValues))
{
throw new Exception('error in <b>' . __METHOD__ . '</b>: the <b>supplUpdateValues</b> property has to be an array.');
@@ -706,70 +533,50 @@ abstract class Model_Base
$el = $this->setSupplValues('update');
$this->queryResult = false;
- if (count($this->values) > 0)
+ if (isset($whereClause))
+ {
+ $result = $this->db->update($this->_tablesArray[0],$el[0],$el[1],$whereClause);
+ $this->setNotice($result);
+ return $result;
+ }
+ else
{
- if (isset($whereClause))
+ if (isset($id))
{
- $result = $this->db->update($this->_tablesArray[0],$el[0],$el[1],$whereClause);
+ $where = $this->_idFieldsArray[0].'='.(int)($id);
+ $result = $this->db->update($this->_tablesArray[0],$el[0],$el[1],$where);
$this->setNotice($result);
return $result;
}
else
{
- if (isset($id))
- {
- $where = $this->_idFieldsArray[0].'='.(int)($id);
- $result = $this->db->update($this->_tablesArray[0],$el[0],$el[1],$where);
- $this->setNotice($result);
- return $result;
- }
- else
- {
- $this->notice .= $this->_resultString->getString('no-id');
- $this->result = false;
- $this->identifierValue = null;
- return false;
- }
+ $this->notice = $this->_resultString->getString('no-id');
+ $this->result = false;
+ $this->identifierValue = null;
+ return false;
}
}
- else
- {
- $this->notice .= $this->_resultString->getString('no-fields');
- $this->result = true;
- $this->queryResult = true;
- return false;
- }
}
//method to call the insert query (overriding of the base_db del method)
public function insert() {
- $this->notice = null;
+
$this->queryResult = false;
if (!is_array($this->supplInsertValues)) {
throw new Exception('error in <b>' . __METHOD__ . '</b>: the <b>supplInsertValues</b> property has to be an array.');
}
- if (count($this->values) > 0)
+ if (isset($this->_idOrder))
{
- if (isset($this->_idOrder))
- {
- $maxValue = $this->db->getMax($this->_tablesArray[0],$this->_idOrder);
- $this->supplInsertValues[$this->_idOrder] = (int)$maxValue + 1;
- }
-
- $el = $this->setSupplValues('insert');
-
- $result = $this->db->insert($this->_tablesArray[0],$el[0],$el[1]);
- $this->setNotice($result);
- return $result;
- }
- else
- {
- $this->notice .= $this->_resultString->getString('no-fields');
- $this->result = true;
- $this->queryResult = true;
- return false;
+ $maxValue = $this->db->getMax($this->_tablesArray[0],$this->_idOrder);
+ $this->supplInsertValues[$this->_idOrder] = (int)$maxValue + 1;
}
+
+ $el = $this->setSupplValues('insert');
+
+ $result = $this->db->insert($this->_tablesArray[0],$el[0],$el[1]);
+ $this->setNotice($result);
+ return $result;
}
//method to call the delete query (overriding of the base_db del method)
@@ -791,7 +598,7 @@ abstract class Model_Base
$this->setNotice($result);
return $result;
} else {
- $this->notice .= $this->_resultString->getString('no-id');
+ $this->notice = $this->_resultString->getString('no-id');
$this->result = false;
$this->identifierValue = null;
return false;
@@ -818,8 +625,6 @@ abstract class Model_Base
//where clause
public function move($id,$par = 'up')
{
- $this->notice = null;
-
$this->queryResult = false;
if (isset($id))
{
@@ -855,7 +660,7 @@ abstract class Model_Base
}
else
{
- $this->notice .= $this->_resultString->getString('no-id');
+ $this->notice = $this->_resultString->getString('no-id');
$this->result = false;
$this->identifierValue = null;
return false;
@@ -865,11 +670,11 @@ abstract class Model_Base
public function setNotice($result) {
if ($result) {
- $this->notice .= $this->_resultString->getString('executed');
+ $this->notice = $this->_resultString->getString('executed');
$this->result = true;
$this->queryResult = true;
} else {
- $this->notice .= $this->_resultString->getString('error');
+ $this->notice = $this->_resultString->getString('error');
$this->result = false;
$this->queryResult = false;
}
@@ -932,6 +737,18 @@ abstract class Model_Base
//delete all the '+' chars
$key = $this->dropStartChar($key,'+');
+ if (strcmp($values,'all') === 0 or strstr($values,'all|'))
+ {
+ if (strstr($values,'all|'))
+ {
+ $values = str_replace('all|',$this->fields.'|',$values);
+ }
+ else
+ {
+ $values = $this->fields;
+ }
+ }
+
if (strstr($values,'|'))
{
$temp = explode('|',$values);
@@ -958,140 +775,29 @@ abstract class Model_Base
}
}
- //add a condition
- //$condArray: it can be $this->strongConditions, $this->softConditions or $this->databaseConditions
- //$queryType: insert, update
- //$condition: the condition
- //$field: comma separated list of fields
- private function addCondition(&$condArray,$queryType,$condition,$field)
- {
- if (isset($condArray[$queryType]) and array_key_exists($condition,$condArray[$queryType]))
- {
- $condition = "+".$condition;
- $this->addCondition($condArray,$queryType,$condition,$field);
- }
- else
- {
- $condArray[$queryType][$condition] = $field;
- }
- }
-
- //choose if to apply insert, update or both conditions
- private function addChooseCondition(&$condArray,$queryType,$condition,$field)
- {
- if ($queryType === "both")
- {
- $this->addCondition($condArray,"insert",$condition,$field);
- $this->addCondition($condArray,"update",$condition,$field);
- }
- else
- {
- $this->addCondition($condArray,$queryType,$condition,$field);
- }
- }
-
- //add a condition to the strongCondition array
- public function addDatabaseCondition($queryType,$condition,$field)
- {
- if ($queryType === "both")
- {
- $this->addChooseCondition($this->databaseConditions,"insert",$condition,$field);
- $this->addChooseCondition($this->databaseConditions,"update",$condition."Compl",$field);
- }
- else
- {
- $this->addChooseCondition($this->databaseConditions,$queryType,$condition,$field);
- }
- }
-
- //add a condition to the strongCondition array
- public function addStrongCondition($queryType,$condition,$field)
- {
- $this->addChooseCondition($this->strongConditions,$queryType,$condition,$field);
- }
-
- //add a condition to the softCondition array
- public function addSoftCondition($queryType,$condition,$field)
- {
- $this->addChooseCondition($this->softConditions,$queryType,$condition,$field);
- }
-
- //add a condition to the valuesCondition array
- public function addValuesCondition($queryType,$condition,$field)
- {
- $this->addChooseCondition($this->valuesConditions,$queryType,$condition,$field);
- }
-
- //return the correct conditions array
- //$strength: strong,soft,values
- public function &getConditions($strength)
- {
- if ($strength === 'strong')
- {
- return $this->strongConditions;
- }
- else if ($strength === 'values')
- {
- return $this->valuesConditions;
- }
- else if ($strength === 'database')
- {
- return $this->databaseConditions;
- }
-
- return $this->softConditions;
- }
-
- //save the conditions
- //$strength: strong,soft,values
- public function saveConditions($strength)
- {
- $this->backupConditions[$strength] = $this->getConditions($strength);
- }
-
- //restore the conditions taking them from $this->backupConditions
- public function restoreConditions($strength)
- {
- $c = &$this->getConditions($strength);
-
- if (isset($this->backupConditions[$strength]))
- {
- $c = $this->backupConditions[$strength];
- }
- }
-
- //clear the conditions
- //$strength: strong,soft,values
- public function clearConditions($strength)
- {
- $c = &$this->getConditions($strength);
- $c = array();
- }
//method to apply the validate conditions listed in the $this->strongConditions associative array
//$queryType: indicates what set of validate conditions has to be considered (it's the key of the associative array)
- //$strength: strong,soft,values
+ //$strength: 'strong' or 'soft'
public function applyValidateConditions($queryType,$strength = 'strong')
{
- $arrayToCheck = $_POST;
if ($strength === 'strong')
{
$validateObj = $this->_arrayStrongCheck;
$conditions = $this->strongConditions;
$errString = 'strongConditions';
}
- else if ($strength === 'values')
- {
- $validateObj = $this->_arrayValuesCheck;
- $conditions = $this->valuesConditions;
- $errString = 'valuesConditions';
- $arrayToCheck = $this->values;
- }
else
{
$validateObj = $this->_arraySoftCheck;
$conditions = $this->softConditions;
$errString = 'softConditions';
+
+ if (Params::$nullQueryValue !== false)
+ {
+ $conditions['insert']['+++++checkIsNotStrings|'.Params::$nullQueryValue] = 'all';
+ $conditions['update']['+++++checkIsNotStrings|'.Params::$nullQueryValue] = 'all';
+ }
}
if (array_key_exists($queryType,$conditions))
@@ -1109,6 +815,18 @@ abstract class Model_Base
//delete all the '+' chars
$key = $this->dropStartChar($key,'+');
+
+ if (strcmp($values,'all') === 0 or strstr($values,'all|'))
+ {
+ if (strstr($values,'all|'))
+ {
+ $values = str_replace('all|',$this->fields.'|',$values);
+ }
+ else
+ {
+ $values = $this->fields;
+ }
+ }
if (strstr($values,'|'))
{
@@ -1117,7 +835,7 @@ abstract class Model_Base
$values = $temp[0];
}
- $baseArgs = array($arrayToCheck,$values);
+ $baseArgs = array($_POST,$values);
if (strstr($key,'|'))
{
@@ -1150,6 +868,7 @@ abstract class Model_Base
}
}
+
//apply, in sequence, the strong,soft and database conditions
//$methodName: insert,update
//$id: the id of the record. It is necessary for database conditions
@@ -1189,10 +908,6 @@ abstract class Model_Base
$this->submitName = $submitName;
if (method_exists($this,$methodName))
{
- if (strcmp($methodName,"insert") === 0)
- {
- $this->identifierValue = null;
- }
//if the method is allowed
if (in_array($methodName,$allowedMethodsArray))
{
@@ -1232,9 +947,7 @@ abstract class Model_Base
$popupWhereClause = array_key_exists($field,$this->_popupWhere) ? $this->_popupWhere[$field] : null;
- $popupOrderBy = array_key_exists($field,$this->_popupOrderBy) ? $this->_popupOrderBy[$field] : null;
-
- $result = $this->db->select($table,$queryFields,$popupWhereClause,$fieldClean,$popupOrderBy);
+ $result = $this->db->select($table,$queryFields,$popupWhereClause,$fieldClean);
if ($result and $result !== false)
{
@@ -1306,13 +1019,6 @@ abstract class Model_Base
return $this;
}
- //set the $convert property and return the current object
- public function convert($convert = true)
- {
- $this->convert = $convert;
- return $this;
- }
-
//set the $from property and return the current object
public function from($tables = null)
{
@@ -1371,12 +1077,6 @@ abstract class Model_Base
return $this;
}
- public function sWhere($sWhere)
- {
- $this->sWhere = $sWhere;
- return $this;
- }
-
//set the $groupBy property and return the current object
public function groupBy($groupBy = null)
{
@@ -1411,7 +1111,6 @@ abstract class Model_Base
{
$this->select = null;
$this->where = array();
- $this->sWhere = null;
$this->groupBy = null;
$this->orderBy = null;
$this->limit = null;
@@ -1420,84 +1119,9 @@ abstract class Model_Base
$this->using = array();
$this->join = array();
$this->toList = false;
- $this->convert = false;
return $this;
}
- //save all the clauses of the select query
- public function save()
- {
- $this->backupSelect["select"] = $this->select;
- $this->backupSelect["where"] = $this->where;
- $this->backupSelect["sWhere"] = $this->sWhere;
- $this->backupSelect["groupBy"] = $this->groupBy;
- $this->backupSelect["orderBy"] = $this->orderBy;
- $this->backupSelect["limit"] = $this->limit;
- $this->backupSelect["from"] = $this->from;
- $this->backupSelect["on"] = $this->on;
- $this->backupSelect["using"] = $this->using;
- $this->backupSelect["join"] = $this->join;
- $this->backupSelect["toList"] = $this->toList;
- $this->backupSelect["convert"] = $this->convert;
- return $this;
- }
-
- //restored all the saved clauses of the select query
- public function restore()
- {
- if (count($this->backupSelect) > 0)
- {
- $this->select = $this->backupSelect["select"];
- $this->where = $this->backupSelect["where"];
- $this->sWhere = $this->backupSelect["sWhere"];
- $this->groupBy = $this->backupSelect["groupBy"];
- $this->orderBy = $this->backupSelect["orderBy"];
- $this->limit = $this->backupSelect["limit"];
- $this->from = $this->backupSelect["from"];
- $this->on = $this->backupSelect["on"];
- $this->using = $this->backupSelect["using"];
- $this->join = $this->backupSelect["join"];
- $this->toList = $this->backupSelect["toList"];
- $this->convert = $this->backupSelect["convert"];
- }
- return $this;
- }
-
- public function getSelectArrayFromEnumField($fieldName)
- {
- $types = $this->db->getTypes($this->_tables, $fieldName, true, true);
-
- if ($types)
- {
- if (preg_match('/^('.implode("|",$this->db->getEnumTypes()).')\((.*?)\)/i',$types[$fieldName],$matches))
- {
- return $this->getSelectArrayFromEnumValues($matches[1], $matches[2]);
- }
- }
- }
-
- public function getSelectArrayFromEnumValues($enumFunc, $enumValues)
- {
- $enumFunc = strtolower($enumFunc);
-
- $temp = array();
- $strings = explode(",",$enumValues);
- for ($i=0;$i<count($strings);$i++)
- {
- $val = trim($strings[$i],"'\"");
-
- if (isset($this->_conversionFromDbObject) and method_exists($this->_conversionFromDbObject, $enumFunc))
- {
- $temp[$val] = call_user_func(array($this->_conversionFromDbObject, $enumFunc), $val);
- }
- else
- {
- $temp[$val] = $val;
- }
- }
- return $temp;
- }
-
//initialize and populate the ::form property (reference to a Form_Form object)
public function setForm($defAction = null, $defSubmit = array(), $defMethod = 'POST', $defEnctype = null)
{
@@ -1511,67 +1135,6 @@ abstract class Model_Base
$this->form = new Form_Form($action,$submit,$method,$enctype);
- //get the entries from DB definition
- $types = $this->db->getTypes($this->_tables, "*", true, true);
-
- foreach ($types as $field => $type)
- {
- $entryType = "InputText";
- $classType = "varchar_input";
- $options = null;
-
- if (strcmp($field, $this->_idFieldsArray[0]) === 0)
- {
- $entryType = "Hidden";
- }
- else if (preg_match('/^('.implode("|",$this->db->getTextTypes()).')/i',$type,$matches))
- {
- $entryType = "Textarea";
- $classType = "text_input";
- }
- else if (preg_match('/^('.implode("|",$this->db->getDateTypes()).')/i',$type,$matches))
- {
- $classType = "date_input";
- }
- else if (preg_match('/^('.implode("|",$this->db->getEnumTypes()).')\((.*?)\)/i',$type,$matches))
- {
- $entryType = "Select";
- $classType = "select_input";
- $options = $this->getSelectArrayFromEnumValues($matches[1], $matches[2]);
- }
-
- if (array_key_exists($field,$entries))
- {
- if (!array_key_exists("type",$entries[$field]))
- {
- $entries[$field]["type"] = $entryType;
- }
-
- if ($entryType === "Select" and !array_key_exists("options",$entries[$field]))
- {
- $entries[$field]["options"] = $options;
- $entries[$field]["reverse"] = "yes";
- }
-
- if (!array_key_exists("className",$entries[$field]))
- {
- $entries[$field]["className"] = $classType." ".Form_Form::$defaultEntryAttributes['className'];
- }
- }
- else
- {
- $entries[$field]["type"] = $entryType;
-
- if ($entryType === "Select")
- {
- $entries[$field]["options"] = $options;
- $entries[$field]["reverse"] = "yes";
- }
-
- $entries[$field]["className"] = $classType." ".Form_Form::$defaultEntryAttributes['className'];
- }
- }
-
if (isset($entries))
{
$this->form->setEntries($entries);
diff --git a/h-source/Library/Model/Map.php b/h-source/Library/Model/Map.php
index e6d9f6b..7a093e1 100755
--- a/h-source/Library/Model/Map.php
+++ b/h-source/Library/Model/Map.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
diff --git a/h-source/Library/Model/Tree.php b/h-source/Library/Model/Tree.php
index 849fd7d..f7f95ea 100755
--- a/h-source/Library/Model/Tree.php
+++ b/h-source/Library/Model/Tree.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -28,54 +28,54 @@ class Model_Tree extends Model_Base {
parent::__construct();
}
-// //method to create the first part of where clause
-// //$index: the index of $this->_tablesArray
-// public function createTreeWhere($index) {
-// if (!empty($this->on))
-// {
-// return $this->on;
-// }
-// else
-// {
-// $whereArray = array();
-// for ($i = $index; $i < (count($this->_tablesArray)-1); $i++)
-// {
-// $whereArray[] = $this->_tablesArray[$i].'.'.$this->_idFieldsArray[$i+1].'='.$this->_tablesArray[$i+1].'.'.$this->_idFieldsArray[$i+1];
-// }
-// $whereString = !empty($whereArray) ? implode(' and ',$whereArray) : null;
-// return $whereString;
-// }
-// }
+ //method to create the first part of where clause
+ //$index: the index of $this->_tablesArray
+ public function createTreeWhere($index) {
+ if (!empty($this->on))
+ {
+ return $this->on;
+ }
+ else
+ {
+ $whereArray = array();
+ for ($i = $index; $i < (count($this->_tablesArray)-1); $i++)
+ {
+ $whereArray[] = $this->_tablesArray[$i].'.'.$this->_idFieldsArray[$i+1].'='.$this->_tablesArray[$i+1].'.'.$this->_idFieldsArray[$i+1];
+ }
+ $whereString = !empty($whereArray) ? implode(' and ',$whereArray) : null;
+ return $whereString;
+ }
+ }
-// //create the list of tables of the select query
-// //$index: the index of $this->_tablesArray
-// public function createTablesList($index) {
-// if (isset($this->from))
-// {
-// return $this->from;
-// }
-// else
-// {
-// $tablesString = null;
-// for ($i = $index; $i < (count($this->_tablesArray)-1); $i++)
-// {
-// $tablesString .= $this->_tablesArray[$i] . ',';
-// }
-// $tablesString .= $this->_tablesArray[count($this->_tablesArray)-1];
-// return $tablesString;
-// }
-// }
-//
-// //method to create the list of fields of the select query
-// public function createFieldsList($index) {
-// $fieldsString = null;
-// for ($i = $index; $i < (count($this->_tablesArray)-1); $i++)
-// {
-// $fieldsString .= $this->_tablesArray[$i] . '.*,';
-// }
-// $fieldsString .= $this->_tablesArray[count($this->_tablesArray)-1].'.*';
-// return $fieldsString;
-// }
+ //create the list of tables of the select query
+ //$index: the index of $this->_tablesArray
+ public function createTablesList($index) {
+ if (isset($this->from))
+ {
+ return $this->from;
+ }
+ else
+ {
+ $tablesString = null;
+ for ($i = $index; $i < (count($this->_tablesArray)-1); $i++)
+ {
+ $tablesString .= $this->_tablesArray[$i] . ',';
+ }
+ $tablesString .= $this->_tablesArray[count($this->_tablesArray)-1];
+ return $tablesString;
+ }
+ }
+
+ //method to create the list of fields of the select query
+ public function createFieldsList($index) {
+ $fieldsString = null;
+ for ($i = $index; $i < (count($this->_tablesArray)-1); $i++)
+ {
+ $fieldsString .= $this->_tablesArray[$i] . '.*,';
+ }
+ $fieldsString .= $this->_tablesArray[count($this->_tablesArray)-1].'.*';
+ return $fieldsString;
+ }
//method to create the where clause and the list of tables and fields of the select query
@@ -84,51 +84,32 @@ class Model_Tree extends Model_Base {
//return: $elements = array('tables'=>$tables,'where'=>$where,'fields'=>$fields)
public function treeQueryElements($tableName,$choice = 'all')
{
-// $index = array_search($tableName,$this->_tablesArray);
-// $subArray = ($choice === 'all') ? array_slice($this->_tablesArray,$index) : array($tableName); //this array is necessary to verify that the where clause makes sense
-// $tables = ($choice === 'all') ? $this->createTablesList($index) : $tableName;
-// $where = ($choice === 'all') ? $this->createTreeWhere($index) : null;
-// $fields = ($choice === 'all') ? $this->createFieldsList($index) : $tableName.'.*';
-//
-// $wherePlus = $this->createWhereClause();
-//
-// if (empty($this->on))
-// {
-// $on = array();
-//
-// if (isset($where) and isset($wherePlus))
-// {
-// $where .= ' AND ' . $wherePlus;
-// }
-// else if (!isset($where) and isset($wherePlus))
-// {
-// $where .= $wherePlus;
-// }
-// }
-// else
-// {
-// $on = $where;
-// $where = $wherePlus;
-// }
-
- $where = $this->createWhereClause();
-
- if (isset($where))
+ $index = array_search($tableName,$this->_tablesArray);
+ $subArray = ($choice === 'all') ? array_slice($this->_tablesArray,$index) : array($tableName); //this array is necessary to verify that the where clause makes sense
+ $tables = ($choice === 'all') ? $this->createTablesList($index) : $tableName;
+ $where = ($choice === 'all') ? $this->createTreeWhere($index) : null;
+ $fields = ($choice === 'all') ? $this->createFieldsList($index) : $tableName.'.*';
+
+ $wherePlus = $this->createWhereClause();
+
+ if (empty($this->on))
{
- if (isset($this->sWhere))
+ $on = array();
+
+ if (isset($where) and isset($wherePlus))
{
- $where .= " AND " . $this->sWhere;
+ $where .= ' AND ' . $wherePlus;
+ }
+ else if (!isset($where) and isset($wherePlus))
+ {
+ $where .= $wherePlus;
}
}
else
{
- $where = $this->sWhere;
+ $on = $where;
+ $where = $wherePlus;
}
-
- $tables = isset($this->from) ? $this->from : $tableName;
-
- $fields = $tableName.".*";
- $on = $this->on;
return array('tables' => $tables,'where' => $where,'fields'=>$fields,'on'=>$on);
}
@@ -146,37 +127,10 @@ class Model_Tree extends Model_Base {
public function getFields($fields = '',$choice = 'all')
{
$elements = $this->treeQueryElements($this->_tablesArray[0],$choice);
-
- $queryFields = (strcmp($fields,'') === 0) ? $elements['fields'] : $fields;
- $row = $this->db->select($elements['tables'],$queryFields,$elements['where'],$this->groupBy,$this->orderBy,$this->limit,$elements['on'],$this->using,$this->join);
-
- //convert from MySQL values
- if ($this->convert)
- {
- if (count($row) > 0)
- {
- $types = array();
-
- $tablesList = array_keys($row[0]);
-
- foreach ($tablesList as $table)
- {
- $types[$table] = $this->db->getTypes($table, "*", false, true);
- }
-
- for ($i=0;$i< count ($row); $i++)
- {
- foreach ($tablesList as $table)
- {
- $row[$i][$table] = $this->convertFromMysqlT($types[$table], $row[$i][$table]);
- }
-
- }
- }
- }
+ $queryFields = (strcmp($fields,'') === 0) ? $elements['fields'] : $fields;
- return $row;
+ return $row = $this->db->select($elements['tables'],$queryFields,$elements['where'],$this->groupBy,$this->orderBy,$this->limit,$elements['on'],$this->using,$this->join);
}
public function send()
@@ -206,8 +160,8 @@ class Model_Tree extends Model_Base {
//$id: the id (primary key) of the record
//$fields: the comma separated list of fields that have to be extracted
public function selectId($id,$fields = null) {
-
- $this->save()->clear()->setWhereQueryClause(array($this->_idFieldsArray[0] => (int)$id));
+ $tempWhere = $this->where;
+ $this->setWhereQueryClause(array($this->_idFieldsArray[0] => (int)$id));
$this->using = null;
@@ -220,7 +174,7 @@ class Model_Tree extends Model_Base {
$values = $this->getAll('other');
}
- $this->restore();
+ $this->where = $tempWhere;
return (count($values) > 0) ? $values[0][$this->_tablesArray[0]] : array();
@@ -264,374 +218,50 @@ class Model_Tree extends Model_Base {
return $this->db->recordExists($elements['tables'],$field,$value,$elements['where'],$this->groupBy,$elements['on'],$this->using,$this->join);
}
- //check referential integrity during delete
- public function checkOnDeleteIntegrity($id = null, $whereClause = null)
- {
- $this->save();
-
- $result = true;
-
- if (count($this->foreignKeys) > 0)
- {
- foreach ($this->foreignKeys as $f)
- {
- if (preg_match('/^(.*?)\s(parent of)\s(.*?)\((.*?)\)(\s(on delete)\s(cascade|restrict)\s\((.*?)\))?$/i',$f,$matches))
- {
- $parentKey = $matches[1];
- $childModel = $matches[3];
- $childField = $matches[4];
-
- if (isset($whereClause))
- {
- $this->clear()->sWhere($whereClause);
- }
- else
- {
- $this->clear()->where(array($this->_idFields=>(int)$id));
- }
-
- $keys = sanitizeDbDeep($this->toList($parentKey)->send());
- $this->restore();
-
- if (count($keys) > 0)
- {
- $child = new $childModel();
- $childrenIds = $child->clear()->where(array($childField=>"in('".implode("','",$keys)."')"))->toList($child->getPrimaryKey())->send();
-
- if (count($childrenIds) > 0)
- {
- if (isset($matches[7]) and strcmp($matches[7],"cascade") === 0)
- {
- foreach ($childrenIds as $childId)
- {
- $child->del((int)$childId);
- }
-
- if (strcmp($matches[8],"") !== 0)
- {
- $this->notice .= "<div class='".Params::$infoStringClassName."'>".$matches[8]."</div>";
- }
- }
- else
- {
- $this->notice .= isset($matches[8]) ? "<div class='".Params::$errorStringClassName."'>".$matches[8]."</div>" : $this->_resultString->getString('associate');
- $result = false;
- }
- }
- }
+// //get the number of records of the table $this->_tablesArray[0]
+// public function rowNumber() {
+// return $this->recordNumber($this->_tablesArray[0]);
+// }
- }
- }
- }
-
- return $result;
- }
-
- //check referential integrity during insert or update
- public function checkOnUpdateIntegrity($queryType)
- {
- $result = true;
-
- if (count($this->foreignKeys) > 0)
- {
- foreach ($this->foreignKeys as $f)
- {
- if (preg_match('/^(.*?)\s(child of)\s(.*?)\((.*?)\)(\s(on update)\s(restrict)\s\((.*?)\))?$/i',$f,$matches))
- {
- $childKey = $matches[1];
- $ParentModel = $matches[3];
- $ParentField = $matches[4];
-
- $notice = isset($matches[8]) ? "<div class='".Params::$errorStringClassName."'>".$matches[8]."</div>" : "";
-
- if (array_key_exists($childKey,$this->values))
- {
- $parent = new $ParentModel();
- $res = $parent->clear()->where(array($ParentField=>sanitizeDb($this->values[$childKey])))->send();
-
- if (count($res) === 0)
- {
- $this->notice .= $notice;
- $this->result = false;
- $result = false;
- }
- }
- else if ($queryType === "insert")
- {
- $this->notice .= $notice;
- $this->result = false;
- $result = false;
- }
- }
- }
- }
-
- return $result;
- }
-
- //get the first extracted full record
- public function record()
- {
- $res = $this->getFields($this->select);
-
- if (count($res) > 0)
- {
- return $res[0][$this->_tables];
- }
- return array();
- }
-
- //get a single field from the first extracted record
- public function field($fieldName)
+ //method to call the delete query (overriding of the del method of Model.php)
+ //check the referential integrity
+ public function del($id = null, $whereClause = null)
{
- $res = $this->save()->select($fieldName)->send();
- $this->restore();
+ $this->queryResult = false;
- if (count($res) > 0 and isset($res[0][$this->_tables][$fieldName]))
+ if (isset($whereClause))
{
- return $res[0][$this->_tables][$fieldName];
+ return parent::del(null,$whereClause);
}
- return "";
- }
-
- //get the types of the fields in $this->values
- public function getTypes($full = false)
- {
- return $types = $this->db->getTypes($this->_tables,implode(",",array_keys($this->values)),$full);
- }
-
- //automatically set the values conditions
- public function setValuesConditionsFromDbFields($queryType)
- {
- $fields = array_keys($this->values);
- $fieldsAsString = implode(",",$fields);
-
- $types = $this->getTypes(true);
- $fieldKeys = $this->db->getKeys($this->_tables,$fieldsAsString,true,false);
-
- if (count($this->values) > 0)
+ else
{
- if (!$types)
+ if ($this->_onDelete === 'check' and isset($this->_reference))
{
- $this->notice .= $this->_resultString->getString('not-existing-fields');
- $this->result = false;
- return false;
- }
- else
- {
- $this->saveConditions("values");
- $this->saveConditions("database");
-
- if (Params::$setValuesConditionsFromDbTableStruct)
+ if (isset($this->_reference[0]) and isset($this->_reference[1]))
{
- foreach ($types as $index => $t)
- {
- if (preg_match('/^('.implode("|",$this->db->getCharTypes()).')\(([0-9]*?)\)$/i',$t,$matches))
- {
- $this->addValuesCondition($queryType,'checkLength|'.$matches[2],$fields[$index]);
- }
- else if (preg_match('/^('.implode("|",$this->db->getIntegerTypes()).')/i',$t,$matches))
- {
- $this->addValuesCondition($queryType,'checkInteger',$fields[$index]);
- }
- else if (preg_match('/^('.implode("|",$this->db->getFloatTypes()).')$/i',$t,$matches))
- {
- $this->addValuesCondition($queryType,'checkNumeric',$fields[$index]);
- }
- else if (preg_match('/^('.implode("|",$this->db->getDateTypes()).')$/i',$t,$matches))
- {
- $this->addValuesCondition($queryType,'checkIsoDate',$fields[$index]);
- }
- else if (preg_match('/^('.implode("|",$this->db->getEnumTypes()).')\((.*?)\)$/i',$t,$matches))
- {
- $temp = array();
- $strings = explode(",",$matches[2]);
- for ($i=0;$i<count($strings);$i++)
- {
- $temp[] = trim($strings[$i],"'\"");
- }
- $this->addValuesCondition($queryType,'checkIsStrings|'.implode(",",$temp),$fields[$index]);
- }
- else if (preg_match('/^('.implode("|",$this->db->getDecimalTypes()).')\((.*?)\)$/i',$t,$matches))
- {
- $this->addValuesCondition($queryType,'checkDecimal|'.$matches[2],$fields[$index]);
- }
- }
-
- //set unique conditions
- foreach ($fieldKeys as $index => $fk)
+ if ($this->db->recordExists($this->_reference[0],$this->_reference[1],(int)$id))
{
- if (preg_match('/^('.implode("|",$this->db->getUniqueIndexStrings()).')$/i',$fk,$matches))
- {
- if ($queryType === "insert")
- {
- $this->addDatabaseCondition($queryType,'checkUnique',$fields[$index]);
- }
- else
- {
- $this->addDatabaseCondition($queryType,'checkUniqueCompl',$fields[$index]);
- }
- }
+ $this->notice = $this->_resultString->getString('associate');
+ $this->identifierValue = null;
+ $this->result = false;
}
- }
-
- foreach (Params::$valuesConditionsFromFormatsOfFieldsNames as $regExpr => $function)
- {
- foreach ($fields as $f)
+ else
{
- if (preg_match($regExpr,$f,$matches))
- {
- $this->addValuesCondition($queryType,$function,$f);
- }
+ return parent::del((int)$id);
}
-
}
- }
- }
-
-// print_r($fields);
-// print_r($types);
-
- return true;
- }
-
- //convert values of the $this->values to MySQL formats
- public function convertValuesToDb()
- {
- if (Params::$automaticConversionToDbFormat)
- {
- if (isset($this->_conversionToDbObject))
- {
- $types = $this->getTypes();
-
- if ($types)
+ else
{
- $fields = array_keys($this->values);
-
- foreach ($types as $index => $t)
- {
- if (method_exists($this->_conversionToDbObject,strtolower($t)))
- {
- $this->values[$fields[$index]] = call_user_func(array($this->_conversionToDbObject, strtolower($t)), $this->values[$fields[$index]]);
- }
- }
+ throw new Exception('you have forgotten to set \'$this->_reference\' or you have forgotten to set $this->_onDelete = \'nocheck\'');
}
}
- }
- }
-
- public function insert()
- {
- $this->db->setAutocommit(true);
-
- $this->notice = null;
- $this->queryResult = false;
-
- $this->convertValuesToDb();
-
- if ($this->checkOnUpdateIntegrity("insert"))
- {
- //set the values conditions from the table description
- if ($this->setValuesConditionsFromDbFields("insert"))
- {
- if ($this->applyDatabaseConditions("insert",null))
- {
- $this->restoreConditions("database");
- if ($this->applyValidateConditions("insert",'values'))
- {
- $this->restoreConditions("values");
- return parent::insert();
- }
- $this->restoreConditions("values");
- }
- $this->restoreConditions("database");
- }
- }
-
- return false;
-
- }
-
- public function update($id = null, $whereClause = null)
- {
- $this->db->setAutocommit(true);
-
- $this->notice = null;
- $this->queryResult = false;
-
- $this->convertValuesToDb();
-
- if ($this->checkOnUpdateIntegrity("update"))
- {
- //set the values conditions from the table description
- if ($this->setValuesConditionsFromDbFields("update"))
+ else
{
- if (!isset($id) or $this->applyDatabaseConditions("update",(int)$id))
- {
- $this->restoreConditions("database");
- //check the values conditions
- if ($this->applyValidateConditions("update",'values'))
- {
- $this->restoreConditions("values");
- return parent::update($id, $whereClause);
- }
- $this->restoreConditions("values");
- }
- $this->restoreConditions("database");
+ return parent::del((int)$id);
}
}
-
return false;
}
-
- //method to call the delete query (overriding of the del method of Model.php)
- //check the referential integrity
- public function del($id = null, $whereClause = null)
- {
- $this->notice = null;
- $this->queryResult = false;
-
- if ($this->checkOnDeleteIntegrity($id, $whereClause))
- {
- return parent::del($id, $whereClause);
- }
- else
- {
- return false;
- }
-// if (isset($whereClause))
-// {
-// return parent::del(null,$whereClause);
-// }
-// else
-// {
-// if ($this->_onDelete === 'check' and isset($this->_reference))
-// {
-// if (isset($this->_reference[0]) and isset($this->_reference[1]))
-// {
-// if ($this->db->recordExists($this->_reference[0],$this->_reference[1],(int)$id))
-// {
-// $this->notice = $this->_resultString->getString('associate');
-// $this->identifierValue = null;
-// $this->result = false;
-// }
-// else
-// {
-// return parent::del((int)$id);
-// }
-// }
-// else
-// {
-// throw new Exception('you have forgotten to set \'$this->_reference\' or you have forgotten to set $this->_onDelete = \'nocheck\'');
-// }
-// }
-// else
-// {
-// return parent::del((int)$id);
-// }
-// }
-// return false;
- }
//method to obtain one columns from the tables $this->_tablesArray as an associative array
//$valueField: the column that have to be extracted (array_values of the resulting associative array), $keyField: the column that have to play the role of array_keys
diff --git a/h-source/Library/Params.php b/h-source/Library/Params.php
index e22c1bf..e5f5ab7 100644
--- a/h-source/Library/Params.php
+++ b/h-source/Library/Params.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -26,24 +26,24 @@ if (!defined('EG')) die('Direct access not allowed!');
class Params
{
- public static $allowedDb = array('Mysql','Mysqli','None'); //allowed database type
+ //allowed database type
+ public static $allowedDb = array('Mysql','Mysqli','None');
- public static $allowedSanitizeFunc = 'sanitizeAll,sanitizeDb,sanitizeHtml,forceInt,forceNat,none,md5,sha1,strip_tags'; //allowed sanitize functions
+ //allowed sanitize functions
+ public static $allowedSanitizeFunc = 'sanitizeAll,sanitizeDb,sanitizeHtml,forceInt,forceNat,none,md5,sha1';
- public static $allowedHashFunc = array('md5','sha1'); //allowed hash functions
+ //allowed hash functions
+ public static $allowedHashFunc = array('md5','sha1');
//conventional null value for the value of the field in the createWhereClause method of the Model class
public static $nullQueryValue = false;
//use HTTPS for links or not
public static $useHttps = false;
-
+
//class name of the div that contains the error strings
public static $errorStringClassName = 'alert';
- //class name of the div that contains the error strings
- public static $infoStringClassName = 'executed';
-
//table name in the returning structure of the select queries in the case of an aggregate function. Ex count(*),sum(*)
public static $aggregateKey = 'aggregate';
@@ -52,59 +52,15 @@ class Params
public static $htmlentititiesCharset = DEFAULT_CHARSET;
//list of symbols used in the statements of the where clause of the select queries
- public static $whereClauseSymbolArray = array('<','>','!=','<=','>=','in(','not in(','like','between');
+ public static $whereClauseSymbolArray = array('<','>','!=','<=','>=','in(','not in(','like');
//is the mbstring extension enabled?
public static $mbStringLoaded = false;
-
+
//subfolder of the View folder where to look for view files
public static $viewSubfolder = null;
- //global website language used by the models and by the helpers for reporting
+ //global website language used by the models and by the helpers
public static $language = 'It';
-
- //array of languages allowed for the website front-end
- public static $frontEndLanguages = array();
-
- //default front-end language
- public static $defaultFrontEndLanguage = "it";
-
- //current front-end language
- public static $lang = null;
-
- //if true, it redirect to current language if language is expected ($frontEndLanguages not empty) but not present
- public static $redirectToDefaultLanguage = false;
-
- //if the URL status variables have to be rewritten or left in the standard query string form
- public static $rewriteStatusVariables = true;
-
- //if the URL has to be rewritten only if an exact match has been found (true) or if a match has been found starting from the beginning (false)
- public static $exactUrlMatchRewrite = false;
-
- //list of installed applications
- //the name of the applications has to match a subfolder of tha Apps folder
- public static $installed = array();
-
- //the application called
- public static $currentApplication = null;
-
- //if true, automatically set the values conditions from the table types
- public static $setValuesConditionsFromDbTableStruct = false;
-
- //if true, automatically convert values to MySQL format during insert and update queries (using types taken from table definition)
- public static $automaticConversionToDbFormat = false;
-
- //if true, convert values from MySQl to $_lang format when filling the form with values coming from the DB
- public static $automaticConversionFromDbFormat = false;
-
- //if true, set the default value for each field when filling the form
- //default values are taken from DB where present or from type definition
- public static $automaticallySetFormDefaultValues = false;
-
- //if true, set date("Y-m-d") as default date when setting the default values of the form or of the $this->values array
- public static $useCurrentDateAsDefaultDate = true;
-
- //definition of values conditions from the formats of the fields names
- public static $valuesConditionsFromFormatsOfFieldsNames = array();
-} \ No newline at end of file
+}
diff --git a/h-source/Library/Popup.php b/h-source/Library/Popup.php
index d2d51a7..186e4b3 100755
--- a/h-source/Library/Popup.php
+++ b/h-source/Library/Popup.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
diff --git a/h-source/Library/Request.php b/h-source/Library/Request.php
index 8ad9226..d99585d 100644
--- a/h-source/Library/Request.php
+++ b/h-source/Library/Request.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
diff --git a/h-source/Library/Scaffold.php b/h-source/Library/Scaffold.php
index a418b7c..7e43134 100755
--- a/h-source/Library/Scaffold.php
+++ b/h-source/Library/Scaffold.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -32,9 +32,6 @@ class Scaffold
protected $_primaryKey = null; //the primary key of the table
protected $_controller = null; //the name of the controller
- public $application = null; //the name of the application
- public $applicationUrl = null; //the url of the application
- public $controller = null; //the name of the controller
public $model = null; //the reference to the model associated with the controller
public $viewArgs = array(); //the associative array representing the status args of the main action of the controller.
@@ -57,37 +54,30 @@ class Scaffold
//instance of Lang_{language}_Generic
public $strings = null;
- public static $autoParams = array(
- 'mainAction' => 'main',
- 'modifyAction' => 'form/update',
- 'associateAction' => 'associate',
- 'panelController' => 'panel',
- 'pageList' => true,
- 'pageVariable' => 'page',
- 'recordPerPage' => 20,
- 'mainMenu' => 'panel,add',
- 'formMenu' => 'panel,back',
- 'popup' => false,
- 'popupType' => 'exclusive'
- );
-
- public function __construct($type,$application, $controller,$model,$viewArgs,$params = null) {
+ public function __construct($type,$controller,$model,$viewArgs,$params = null) {
$this->_type = $type;
- $this->application = $application;
- $this->controller = $controller;
+ $this->_controller = $controller;
$this->model = $model;
$this->viewArgs = $viewArgs;
//get the generic language class
$this->strings = Factory_Strings::generic(Params::$language);
- $autoParams = self::$autoParams;
-
- if (!array_key_exists("postSubmitValue",$autoParams))
- {
- $autoParams['postSubmitValue'] = $this->strings->gtext('Save');
- }
+ $autoParams = array(
+ 'mainAction' => 'main',
+ 'modifyAction' => 'form/update',
+ 'associateAction' => 'associate',
+ 'panelController' => 'panel',
+ 'pageList' => true,
+ 'pageVariable' => 'page',
+ 'recordPerPage' => 10,
+ 'mainMenu' => 'panel,add',
+ 'formMenu' => 'panel,back',
+ 'postSubmitValue' => 'Save',
+ 'popup' => false,
+ 'popupType' => 'exclusive'
+ );
//set the $this->scaffold->params array
if (is_array($params)) {
@@ -97,7 +87,6 @@ class Scaffold
}
$this->params = $autoParams;
- $this->applicationUrl = isset($application) ? $application . "/" : null;
}
//ad some clauses to the select query
@@ -120,35 +109,11 @@ class Scaffold
{
$this->_primaryKey = $primaryKey;
- if (is_array($recordList) or strcmp($recordList,'') !== 0)
+ if (strcmp($recordList,'') !== 0)
{
- $recordListArray = is_array($recordList) ? $recordList : explode(',',$recordList);
-
+ $recordListArray = explode(',',$recordList);
foreach ($recordListArray as $record) {
- if (preg_match('/\[\[checkbox\]\](\;)(.*?)(\;)/',$record,$matches))
- {
- $this->itemList->addItem("checkbox",encode($matches[2]),";".$matches[2].";","",";".$primaryKey.";");
- }
- else if (preg_match('/\[\[checkbox\:(.*?)\]\](\;)(.*?)(\;)/',$record,$matches))
- {
- $this->itemList->addItem("checkbox",encode($matches[3]),";".$matches[3].";",$matches[1],";".$primaryKey.";");
- }
- else if (preg_match('/\[\[input\]\](\;)(.*?)(\;)/',$record,$matches))
- {
- $this->itemList->addItem("input",encode($matches[2]),";".$matches[2].";",";".$primaryKey.";");
- }
- else if (preg_match('/\[\[ledit\]\](\;)(.*?)(\;)/',$record,$matches))
- {
- $this->itemList->addItem("link",$this->applicationUrl . $this->controller.'/'.$this->params['modifyAction']."/;$primaryKey;","",";".$matches[2].";");
- }
- else if (strstr($record, ';'))
- {
- $this->itemList->addItem("simpleText","$record");
- }
- else
- {
- $this->itemList->addItem("simpleText",";$record;");
- }
+ $this->itemList->addItem("simpleText",";$record;");
}
}
@@ -158,33 +123,26 @@ class Scaffold
{
foreach ($themeArray as $el)
{
- if (preg_match('/ledit\|(.*)/',$el,$matches))
+ switch ($el)
{
- $this->itemList->addItem('ledit',$matches[1],'Edit','Edit');
- }
- else
- {
- switch ($el)
- {
- case 'moveup':
- $this->itemList->addItem('moveupForm',$this->applicationUrl . $this->controller.'/'.$this->params['mainAction'],";".$primaryKey.";");
- break;
- case 'movedown':
- $this->itemList->addItem('movedownForm',$this->applicationUrl . $this->controller.'/'.$this->params['mainAction'],";".$primaryKey.";");
- break;
- case 'link':
- $this->itemList->addItem('associateForm',$this->applicationUrl . $this->controller.'/'.$this->params['associateAction'],";".$primaryKey.";");
- break;
- case 'edit':
- $this->itemList->addItem('editForm',$this->applicationUrl . $this->controller.'/'.$this->params['modifyAction'],";".$primaryKey.";");
- break;
- case 'del':
- $this->itemList->addItem('delForm',$this->applicationUrl . $this->controller.'/'.$this->params['mainAction'],";".$primaryKey.";");
- break;
- case 'ledit':
- $this->itemList->addItem('ledit',$this->applicationUrl . $this->controller.'/'.$this->params['modifyAction'].'/;'.$primaryKey.';','Edit','Edit');
- break;
- }
+ case 'moveup':
+ $this->itemList->addItem('moveupForm',$this->_controller.'/'.$this->params['mainAction'],";".$primaryKey.";");
+ break;
+ case 'movedown':
+ $this->itemList->addItem('movedownForm',$this->_controller.'/'.$this->params['mainAction'],";".$primaryKey.";");
+ break;
+ case 'link':
+ $this->itemList->addItem('associateForm',$this->_controller.'/'.$this->params['associateAction'],";".$primaryKey.";");
+ break;
+ case 'edit':
+ $this->itemList->addItem('editForm',$this->_controller.'/'.$this->params['modifyAction'],";".$primaryKey.";");
+ break;
+ case 'del':
+ $this->itemList->addItem('delForm',$this->_controller.'/'.$this->params['mainAction'],";".$primaryKey.";");
+ break;
+ case 'ledit':
+ $this->itemList->addItem('ledit',$this->_controller.'/'.$this->params['mainAction'].'/;'.$primaryKey.';','Edit','Edit');
+ break;
}
}
}
@@ -199,8 +157,7 @@ class Scaffold
$this->queryType = $queryType;
$submitName = $this->model->getSubmitName($queryType);
$value = $this->params['postSubmitValue'];
- $viewStatus = Url::createUrl($this->viewArgs);
-
+ $viewStatus = Url::createUrl(array_values($this->viewArgs));
$this->model->setForm($action.$viewStatus,array($submitName => $value),$method,$enctype);
$this->form = $this->model->form;
}
diff --git a/h-source/Library/Strings/Functions.php b/h-source/Library/Strings/Functions.php
index c63d165..1ee17af 100644
--- a/h-source/Library/Strings/Functions.php
+++ b/h-source/Library/Strings/Functions.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
diff --git a/h-source/Library/Theme.php b/h-source/Library/Theme.php
index 1ddec92..10c0fce 100755
--- a/h-source/Library/Theme.php
+++ b/h-source/Library/Theme.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -34,20 +34,15 @@ class Theme {
public $viewArgs = array();
public $viewStatus = '';
public $controller = 'controller';
- public $application = null;
public $action = '';
public $currPage; //the URL of the current page
- function __construct($application, $controller) {
-
- $this->controller = $controller;
- $this->application = $application;
-
- $langUrl = isset(Params::$lang) ? "/".Params::$lang : null;
+ function __construct($controller) {
+
$protocol = Params::$useHttps ? "https" : "http";
-
- $this->baseUrl = MOD_REWRITE_MODULE === true ? "$protocol://" . DOMAIN_NAME . $langUrl : "$protocol://" . DOMAIN_NAME . '/index.php' . $langUrl;
-
+
+ $this->controller = $controller;
+ $this->baseUrl = MOD_REWRITE_MODULE === true ? "$protocol://" . DOMAIN_NAME : "$protocol://" . DOMAIN_NAME . '/index.php';
$this->baseUrlSrc = "$protocol://" . DOMAIN_NAME;
}
@@ -79,22 +74,15 @@ class Theme {
}
}
+
public function render() {
extract($this->_data);
-
+
//find the View subfolder where to look for view files
$subfolder = isset(Params::$viewSubfolder) ? Params::$viewSubfolder . DS : null;
foreach ($this->_viewFiles as $file) {
- if (isset($this->application) and file_exists(ROOT . DS . APPLICATION_PATH . DS . "Apps" . DS . ucfirst($this->application). DS . 'Views' . DS .$subfolder. ucwords($this->controller) . DS . $file . '.php'))
- {
- include (ROOT . DS . APPLICATION_PATH . DS . "Apps" . DS . ucfirst($this->application). DS . 'Views' . DS . $subfolder. ucwords($this->controller) . DS . $file . '.php');
- }
- else if (isset($this->application) and file_exists(ROOT . DS . APPLICATION_PATH . DS . "Apps" . DS . ucfirst($this->application). DS . 'Views' . DS . $subfolder. $file . '.php'))
- {
- include (ROOT . DS . APPLICATION_PATH . DS . "Apps" . DS . ucfirst($this->application). DS . 'Views' . DS .$subfolder. $file . '.php');
- }
- else if (file_exists(ROOT . DS . APPLICATION_PATH . DS . 'Views' . DS .$subfolder. ucwords($this->controller) . DS . $file . '.php')) {
+ if (file_exists(ROOT . DS . APPLICATION_PATH . DS . 'Views' . DS .$subfolder. ucwords($this->controller) . DS . $file . '.php')) {
include (ROOT . DS . APPLICATION_PATH . DS . 'Views' . DS .$subfolder. ucwords($this->controller) . DS . $file . '.php');
} else {
include (ROOT . DS . APPLICATION_PATH . DS . 'Views' . DS .$subfolder. $file . '.php');
@@ -102,15 +90,7 @@ class Theme {
}
if (isset($this->_lastView)) {
- if (isset($this->application) and file_exists(ROOT . DS . APPLICATION_PATH . DS . "Apps" . DS . ucfirst($this->application). DS . 'Views' . DS .$subfolder. ucwords($this->controller) . DS . $this->_lastView . '.php'))
- {
- include (ROOT . DS . APPLICATION_PATH . DS . "Apps" . DS . ucfirst($this->application). DS . 'Views' . DS .$subfolder. ucwords($this->controller) . DS . $this->_lastView . '.php');
- }
- else if (isset($this->application) and file_exists(ROOT . DS . APPLICATION_PATH . DS . "Apps" . DS . ucfirst($this->application). DS . 'Views' . DS . $subfolder . $this->_lastView . '.php'))
- {
- include (ROOT . DS . APPLICATION_PATH . DS . "Apps" . DS . ucfirst($this->application). DS . 'Views' . DS .$subfolder . $this->_lastView . '.php');
- }
- else if (file_exists(ROOT . DS . APPLICATION_PATH . DS . 'Views' . DS .$subfolder. ucwords($this->controller) . DS . $this->_lastView . '.php')) {
+ if (file_exists(ROOT . DS . APPLICATION_PATH . DS . 'Views' . DS .$subfolder. ucwords($this->controller) . DS . $this->_lastView . '.php')) {
include (ROOT . DS . APPLICATION_PATH . DS . 'Views' . DS .$subfolder. ucwords($this->controller) . DS . $this->_lastView . '.php');
} else {
include (ROOT . DS . APPLICATION_PATH . DS . 'Views' . DS .$subfolder. $this->_lastView . '.php');
diff --git a/h-source/Library/Url.php b/h-source/Library/Url.php
index 26ff3df..efb8e6e 100755
--- a/h-source/Library/Url.php
+++ b/h-source/Library/Url.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -26,35 +26,31 @@ class Url {
//get the url starting from the root folder
public static function getRoot($pathFromRootFolder = null) {
-
- $langUrl = isset(Params::$lang) ? "/".Params::$lang : null;
-
+
$protocol = Params::$useHttps ? "https" : "http";
-
- $url = MOD_REWRITE_MODULE === true ? "$protocol://" . DOMAIN_NAME . $langUrl . '/' . $pathFromRootFolder : "$protocol://" . DOMAIN_NAME . '/index.php/' . $langUrl . $pathFromRootFolder;
+
+ $url = MOD_REWRITE_MODULE === true ? "$protocol://" . DOMAIN_NAME . '/' . $pathFromRootFolder : "$protocol://" . DOMAIN_NAME . '/index.php/' . $pathFromRootFolder;
return $url;
}
- //create an url string (element1/element2/element4) from the values of the array $valuesArray considering only the elements indicated in the numeric string $numericString
- //$forceRewrite: if true it always rewrite the status variables
- public static function createUrl($variablesArray, $numericString = null, $forceRewrite = false) {
+ //create an url string (element1/element2/element4) from the values of the array $valuesArray considering only the elements indicated in the numeric string $numericString (in this case '1,2,4')
+ public static function createUrl($valuesArray,$numericString = null) {
$elementsArray = explode(',',$numericString);
- $valuesArray = array_values($variablesArray);
- $keysArray = array_keys($variablesArray);
+ $valuesArray = array_values($valuesArray);
$urlString = null;
for ($i = 0; $i < count($valuesArray); $i++)
{
if (isset($numericString)) {
if (isset($valuesArray[$i]) and in_array($i,$elementsArray)) {
- $urlString .= (Params::$rewriteStatusVariables or $forceRewrite) ? "/".$valuesArray[$i] : "&".$keysArray[$i]."=".$valuesArray[$i];
+ $urlString .= "/".$valuesArray[$i];
}
} else {
if (isset($valuesArray[$i])) {
- $urlString .= (Params::$rewriteStatusVariables or $forceRewrite) ? "/".$valuesArray[$i] : "&".$keysArray[$i]."=".$valuesArray[$i];
+ $urlString .= "/".$valuesArray[$i];
}
}
}
- return (Params::$rewriteStatusVariables or $forceRewrite) ? $urlString : "?".ltrim($urlString,"&");
+ return $urlString;
}
}
diff --git a/h-source/Library/Users/CheckAdmin.php b/h-source/Library/Users/CheckAdmin.php
index aa4e33f..54deb2a 100755
--- a/h-source/Library/Users/CheckAdmin.php
+++ b/h-source/Library/Users/CheckAdmin.php
@@ -2,7 +2,7 @@
// EasyGiant is a PHP framework for creating and managing dynamic content
//
-// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com)
+// Copyright (C) 2009 - 2011 Antonio Gallo
// See COPYRIGHT.txt and LICENSE.txt.
//
// This file is part of EasyGiant
@@ -60,16 +60,6 @@ class Users_CheckAdmin {
$this->uid = isset($_COOKIE[$this->_params['cookie_name']]) ? sanitizeAlnum($_COOKIE[$this->_params['cookie_name']]) : null;
}
- public function setParam($key, $value)
- {
- $this->_params[$key] = $value;
- }
-
- public function getUid()
- {
- return $this->uid;
- }
-
private function cleanSessions()
{
#cancello le sessioni scadute