From e7b3717614621f14695ab6ca6dda6dd17ba3d65c Mon Sep 17 00:00:00 2001 From: Antonio Gallo Date: Thu, 28 Jul 2011 20:27:23 +0000 Subject: added new easygiant library --- .../Application/Strings/Lang/It/DbCondStrings.php | 21 ++++- .../Application/Strings/Lang/It/ModelStrings.php | 19 ++++- .../Application/Strings/Lang/It/UploadStrings.php | 20 ++++- .../Application/Strings/Lang/It/ValCondStrings.php | 27 ++++++- h-source/Library/Array/Validate/Base.php | 4 +- h-source/Library/ArrayExt.php | 4 - h-source/Library/Call.php | 24 +++++- h-source/Library/Files/Upload.php | 19 +++-- h-source/Library/Form/Entry.php | 42 +++++++++- h-source/Library/Form/File.php | 7 ++ h-source/Library/Form/Form.php | 2 + h-source/Library/Form/Textarea.php | 12 +-- h-source/Library/Functions.php | 13 +++- h-source/Library/Helper/List.php | 78 +++++++++++++++---- h-source/Library/Helper/Popup.php | 4 +- h-source/Library/Image/Gd/Captcha.php | 5 +- h-source/Library/Image/Gd/Thumbnail.php | 24 +++++- h-source/Library/Lang/En/DbCondStrings.php | 32 ++++++++ h-source/Library/Lang/En/ModelStrings.php | 34 ++++++++ h-source/Library/Lang/En/UploadStrings.php | 42 ++++++++++ h-source/Library/Lang/En/ValCondStrings.php | 91 ++++++++++++++++++++++ h-source/Library/Lang/En/index.html | 1 + h-source/Library/Model/Base.php | 39 ++++++---- h-source/Library/Scaffold.php | 50 ++++++------ h-source/Public/Css/main.css | 4 +- 25 files changed, 528 insertions(+), 90 deletions(-) create mode 100644 h-source/Library/Lang/En/DbCondStrings.php create mode 100644 h-source/Library/Lang/En/ModelStrings.php create mode 100644 h-source/Library/Lang/En/UploadStrings.php create mode 100644 h-source/Library/Lang/En/ValCondStrings.php create mode 100644 h-source/Library/Lang/En/index.html diff --git a/h-source/Application/Strings/Lang/It/DbCondStrings.php b/h-source/Application/Strings/Lang/It/DbCondStrings.php index 4c985cd..98f0056 100644 --- a/h-source/Application/Strings/Lang/It/DbCondStrings.php +++ b/h-source/Application/Strings/Lang/It/DbCondStrings.php @@ -1,12 +1,27 @@ . if (!defined('EG')) die('Direct access not allowed!'); //error strings in the case database conditions are not satisfied -class Lang_It_DbCondStrings extends Lang_Eng_DbCondStrings { +class Lang_It_DbCondStrings extends 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) diff --git a/h-source/Application/Strings/Lang/It/ModelStrings.php b/h-source/Application/Strings/Lang/It/ModelStrings.php index e02013b..d4bdc4b 100644 --- a/h-source/Application/Strings/Lang/It/ModelStrings.php +++ b/h-source/Application/Strings/Lang/It/ModelStrings.php @@ -1,7 +1,22 @@ . if (!defined('EG')) die('Direct access not allowed!'); diff --git a/h-source/Application/Strings/Lang/It/UploadStrings.php b/h-source/Application/Strings/Lang/It/UploadStrings.php index 57bcda6..ad3e5be 100644 --- a/h-source/Application/Strings/Lang/It/UploadStrings.php +++ b/h-source/Application/Strings/Lang/It/UploadStrings.php @@ -1,7 +1,22 @@ . if (!defined('EG')) die('Direct access not allowed!'); @@ -14,6 +29,7 @@ class Lang_It_UploadStrings extends Lang_ResultStrings { "not-dir" => "
La cartella selezionata non è una directory
\n", "not-empty" => "
La cartella selezionata non è vuota
\n", "no-folder-specified" => "
Non è stata specificata alcuna cartella
\n", + "no-file-specified" => "
Non è stato specificato alcun file
\n", "not-writable" => "
La cartella non è scrivibile
\n", "not-writable-file" => "
Il file non è scrivibile
\n", "dir-exists" => "
Esiste già una directory con lo stesso nome
\n", diff --git a/h-source/Application/Strings/Lang/It/ValCondStrings.php b/h-source/Application/Strings/Lang/It/ValCondStrings.php index a54c650..2857182 100644 --- a/h-source/Application/Strings/Lang/It/ValCondStrings.php +++ b/h-source/Application/Strings/Lang/It/ValCondStrings.php @@ -1,11 +1,26 @@ . if (!defined('EG')) die('Direct access not allowed!'); -class Lang_It_ValCondStrings extends Lang_Eng_ValCondStrings { +class Lang_It_ValCondStrings extends Lang_En_ValCondStrings { //if the element is not defined public function getNotDefinedResultString($element) @@ -66,4 +81,10 @@ class Lang_It_ValCondStrings extends Lang_Eng_ValCondStrings { { return "
".$element." deve assumere uno dei seguenti valori: $stringList
\n"; } + + //if the element is not one of the strings indicated by $stringList (a comma-separated list of strings) + public function getDoesntMatchResultString($element,$regExp) + { + return "
".$element." deve soddisfare la seguente espressione regolare: $regExp
\n"; + } } diff --git a/h-source/Library/Array/Validate/Base.php b/h-source/Library/Array/Validate/Base.php index 17ccc89..7e25d07 100644 --- a/h-source/Library/Array/Validate/Base.php +++ b/h-source/Library/Array/Validate/Base.php @@ -31,13 +31,13 @@ class Array_Validate_Base protected $_resultString; //reference to the class arraycheckStrings containing all the result strings - public function __construct($lang = 'Eng') + public function __construct($lang = 'En') { $this->_lang = $lang; $stringClass = 'Lang_'.$this->_lang.'_ValCondStrings'; if (!class_exists($stringClass)) { - $stringClass = 'Lang_Eng_ValCondStrings'; + $stringClass = 'Lang_En_ValCondStrings'; } $this->_resultString = new $stringClass(); } diff --git a/h-source/Library/ArrayExt.php b/h-source/Library/ArrayExt.php index 1375f6d..528012c 100755 --- a/h-source/Library/ArrayExt.php +++ b/h-source/Library/ArrayExt.php @@ -55,10 +55,6 @@ class ArrayExt { } } } - else - { - $tempArray = $associativeArray; - } return call_user_func($func.'Deep',$tempArray); //clean the array values } diff --git a/h-source/Library/Call.php b/h-source/Library/Call.php index 092e59b..f941907 100755 --- a/h-source/Library/Call.php +++ b/h-source/Library/Call.php @@ -62,6 +62,8 @@ function checkRegisterGlobals() function callHook() { + $currentUrl = null; + if (MOD_REWRITE_MODULE === true) { $url = isset($_GET['url']) ? $_GET['url'] : DEFAULT_CONTROLLER . '/' . DEFAULT_ACTION; @@ -74,7 +76,9 @@ function callHook() // rewrite the URL if (Route::$rewrite === 'yes') { - $url = rewrite($url); + $res = rewrite($url); + $url = $res[0]; + $currentUrl = $res[1]; } // echo $url; @@ -178,7 +182,12 @@ function callHook() //pass the action to the controller object $dispatch->action = $action; + $dispatch->currPage = $dispatch->baseUrl.'/'.$dispatch->controller.'/'.$dispatch->action; + if (isset($currentUrl)) + { + $dispatch->currPage = $dispatch->baseUrl.'/'.$currentUrl; + } //require the file containing the set of actions to carry out after the initialization of the controller class Hooks::load(ROOT . DS . APPLICATION_PATH . DS . 'Hooks' . DS . 'AfterInitialization.php'); @@ -190,7 +199,11 @@ function callHook() //pass the action to the theme object $dispatch->theme->action = $action; $dispatch->theme->currPage = $dispatch->baseUrl.'/'.$dispatch->controller.'/'.$dispatch->action; - + if (isset($currentUrl)) + { + $dispatch->theme->currPage = $dispatch->baseUrl.'/'.$currentUrl; + } + call_user_func_array(array($dispatch,$action),$queryString); } else @@ -221,10 +234,13 @@ function rewrite($url) $key = str_replace('/','\/',$key); if (preg_match('/^'.$key.'/',$url)) { - return preg_replace('/^'.$key.'/',$address,$url); + $nurl = preg_replace('/^'.$key.'/',$address,$url); + return array($nurl,$key); +// return preg_replace('/^'.$key.'/',$address,$url); } } - return $url; +// return $url; + return array($url,null); } function getQueryString() diff --git a/h-source/Library/Files/Upload.php b/h-source/Library/Files/Upload.php index 0c459ff..53d88f2 100755 --- a/h-source/Library/Files/Upload.php +++ b/h-source/Library/Files/Upload.php @@ -56,7 +56,7 @@ class Files_Upload 'createFolderAction' => 'createFolderAction', 'uploadFileAction' => 'uploadFileAction', 'maxFileSize' => 3000000, - 'language' => 'Eng', + 'language' => 'En', 'allowedExtensions' => 'jpg,jpeg,png,gif,txt', 'fileUploadKey' => 'userfile', 'fileUploadBehaviour' => 'add_token', //can be none or add_token @@ -78,7 +78,7 @@ class Files_Upload $stringClass = 'Lang_'.$this->params['language'].'_UploadStrings'; if (!class_exists($stringClass)) { - $stringClass = 'Lang_Eng_UploadStrings'; + $stringClass = 'Lang_En_UploadStrings'; } $this->_resultString = new $stringClass(); @@ -157,6 +157,15 @@ class Files_Upload return $this->base; } + public function setBase($path) + { + $this->base = $this->addTrailingSlash($path); + + //set the match pattern + $tmp = str_replace(self::DS,'\\'.self::DS,$this->base); + $this->pattern = "/^(".$tmp.")/"; + } + public function getSubDir() { return $this->subDir; } @@ -213,13 +222,13 @@ class Files_Upload } //get the extension of the file - protected function getFileExtension($file) + public function getFileExtension($file) { return strtolower(end(explode('.', $file))); } //get the file name without the extension - protected function getNameWithoutFileExtension($file) + public function getNameWithoutFileExtension($file) { $copy = explode('.', $file); array_pop($copy); @@ -227,7 +236,7 @@ class Files_Upload } //get a not existing file name if the one retrieved from the upload process already exists in the current directory - protected function getUniqueName($file,$int = 0) + public function getUniqueName($file,$int = 0) { $fileNameWithoutExt = $this->getNameWithoutFileExtension($file); $extension = $this->getFileExtension($file); diff --git a/h-source/Library/Form/Entry.php b/h-source/Library/Form/Entry.php index 440ee2d..305f55f 100755 --- a/h-source/Library/Form/Entry.php +++ b/h-source/Library/Form/Entry.php @@ -32,6 +32,7 @@ abstract class Form_Entry { public $options = array(); //options (if the entry is a \n"; + } $returnString .= $wrap[3]; $returnString .="\n"; $returnString .= $wrap[4]; diff --git a/h-source/Library/Form/Form.php b/h-source/Library/Form/Form.php index 9aba086..a20327f 100755 --- a/h-source/Library/Form/Form.php +++ b/h-source/Library/Form/Form.php @@ -78,6 +78,7 @@ class Form_Form { $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; $this->entry[$name]->entryClass = $entryClass; $this->entry[$name]->labelString = $labelString; @@ -86,6 +87,7 @@ class Form_Form { $this->entry[$name]->labelClass = $labelClass; $this->entry[$name]->defaultValue = $defaultValue; $this->entry[$name]->wrap = $wrap; + $this->entry[$name]->deleteButton = $deleteButton; } } diff --git a/h-source/Library/Form/Textarea.php b/h-source/Library/Form/Textarea.php index 33b8bc3..ba51fe9 100755 --- a/h-source/Library/Form/Textarea.php +++ b/h-source/Library/Form/Textarea.php @@ -31,14 +31,16 @@ class Form_Textarea extends Form_Entry public function render($value = null) { - $wrap = $this->getWrapElements(); - $returnString = "
\n\t"; - $returnString .= $wrap[0]; - $returnString .= $this->getLabelTag(); + $wrap = $this->getWrapElements($value); + $returnString = $wrap[0]; + $returnString .= "
\n\t"; $returnString .= $wrap[1]; - $returnString .= Html_Form::textarea($this->entryName, $value, $this->className, $this->idName); + $returnString .= $this->getLabelTag(); $returnString .= $wrap[2]; + $returnString .= Html_Form::textarea($this->entryName, $value, $this->className, $this->idName); + $returnString .= $wrap[3]; $returnString .="
\n"; + $returnString .= $wrap[4]; return $returnString; } diff --git a/h-source/Library/Functions.php b/h-source/Library/Functions.php index 8384580..705c1c0 100755 --- a/h-source/Library/Functions.php +++ b/h-source/Library/Functions.php @@ -207,7 +207,18 @@ function wrap($string,$tag_class) {#wrap the string with the tag and its class if (is_array($tag_class)) { foreach ($tag_class as $tag => $class) { $tag = str_replace('+','',$tag); - $str_class=isset($class) ? " class=\"".$class."\"" : null; + if (!is_array($class)) + { + $str_class=isset($class) ? " class=\"".$class."\"" : null; + } + else + { + $str_class = null; + foreach ($class as $attr => $val) + { + $str_class .= " ".$attr."='".$val."' "; + } + } $str_front.="<".$tag.$str_class.">\n"; $str_rear.="\n"; } diff --git a/h-source/Library/Helper/List.php b/h-source/Library/Helper/List.php index ce811e2..61b3e7b 100755 --- a/h-source/Library/Helper/List.php +++ b/h-source/Library/Helper/List.php @@ -30,11 +30,11 @@ 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'); //type of items allowed + protected $_allowedItems = array('simpleLink','simpleText','delForm','editForm','associateForm','moveupForm','movedownForm','Form'); //type of items allowed //set if the submit buttons have to be images or not (it can be yse or not) public $submitImageType = 'no'; - + //set the files of the images public $submitImages = array( 'edit' => null, @@ -53,6 +53,9 @@ class Helper_List extends Helper_Html { 'link' => 'associate the record' ); + //properties of each column + public $colProperties = array(); + //$position: array. First element: page number, second element: number of pages public $position = array(); @@ -70,7 +73,7 @@ class Helper_List extends Helper_Html { } //add a list Item. $type: the type of the item, $field: the table.field to exctract (use colon to separate the table and the field),$action: controller/action,$value=if type == link->the value of the link - public function addItem($type, $action = '', $field = '', $name = '') { + public function addItem($type, $action = '', $field = '', $name = '', $value = '', $title = '') { if (!in_array($type,$this->_allowedItems)) { throw new Exception('"'.$type. '" argument not allowed in '.__METHOD__.' method'); } @@ -79,6 +82,8 @@ class Helper_List extends Helper_Html { $temp['action'] = $action; $temp['field'] = $field; $temp['name'] = $name; + $temp['value'] = $value; + $temp['title'] = $title; $this->_itemsList[] = $temp; //set the $this->_head array @@ -117,7 +122,15 @@ class Helper_List extends Helper_Html { public function replaceFields($string,$rowArray) { $stringArray = explode(';',$string); for ($i = 0; $i < count($stringArray); $i++) { - if (strstr($stringArray[$i],':')) { + if (strstr($stringArray[$i],':') or strstr($stringArray[$i],'.')) { + if (strstr($stringArray[$i],':')) + { + $char = ':'; + } + else + { + $char = '.'; + } //check if a function has been indicated if (strstr($stringArray[$i],'|')) { @@ -125,7 +138,7 @@ class Helper_List extends Helper_Html { $firstArray = explode('|',$stringArray[$i]); $func = $firstArray[0]; //replace the fields - $temp = explode(':',$firstArray[1]); + $temp = explode($char,$firstArray[1]); $stringArray[$i] = $rowArray[$temp[0]][$temp[1]]; if (!function_exists($func)) { @@ -136,7 +149,7 @@ class Helper_List extends Helper_Html { } else { - $temp = explode(':',$stringArray[$i]); + $temp = explode($char,$stringArray[$i]); $stringArray[$i] = $rowArray[$temp[0]][$temp[1]]; } } @@ -149,6 +162,8 @@ class Helper_List extends Helper_Html { $item['action'] = $this->replaceFields($item['action'],$rowArray); $item['field'] = $this->replaceFields($item['field'],$rowArray); $item['name'] = $this->replaceFields($item['name'],$rowArray); + $item['value'] = $this->replaceFields($item['value'],$rowArray); + $item['title'] = $this->replaceFields($item['title'],$rowArray); return $item; } @@ -169,9 +184,20 @@ class Helper_List extends Helper_Html { //method to create the HTML of the head of the table public function createHead() { $htmlHead = null; + + $count = 0; foreach ($this->_head as $item) { $temp = $item['action']; - $htmlHead .= $this->wrapColumn($temp,$item['type']); + + $prop = $item['type']; + if (isset($this->colProperties[$count])) + { + $prop = $this->colProperties[$count]; + } + + $htmlHead .= $this->wrapColumn($temp,$prop); + + $count++; } return $htmlHead; } @@ -179,18 +205,27 @@ class Helper_List extends Helper_Html { //create the HTML of a single row (values taken from the associative array $rowArray) public function getRowList($rowArray) { $htmlList = null; + + $count = 0; foreach ($this->_itemsList as $item) { $item = $this->replaceAll($item,$rowArray); + $prop = $item['type']; + if (isset($this->colProperties[$count])) + { + $prop = $this->colProperties[$count]; + } + if (($this->_boundaries === 'top' and $item['type'] === 'moveupForm') or ($this->_boundaries === 'bottom' and $item['type'] === 'movedownForm') or ($this->_boundaries === 'both' and ($item['type'] === 'moveupForm' or $item['type'] === 'movedownForm'))) { - $htmlList .= $this->wrapColumn(' ',$item['type']); + $htmlList .= $this->wrapColumn(' ',$prop); } else { $temp = call_user_func_array(array($this,$item['type']),array($item)); - $htmlList .= $this->wrapColumn($temp,$item['type']); + $htmlList .= $this->wrapColumn($temp,$prop); } + $count++; } return $htmlList; } @@ -239,15 +274,27 @@ class Helper_List extends Helper_Html { { $string = "
viewStatus."' method='POST'>\n"; $name = (strcmp($itemArray['name'],'') !== 0) ? $itemArray['name'] : $submitName; + $value = (strcmp($itemArray['value'],'') !== 0) ? $itemArray['value'] : $submitValue; + + if (strcmp($itemArray['title'],'') !== 0) + { + $title = "title='".$itemArray['title']."'"; + } + else + { + $title = isset($this->submitTitles[$value]) ? "title='".$this->submitTitles[$value]."'" : null; + } - if (strcmp($this->submitImageType,'yes') === 0) + if (strcmp($this->submitImageType,'yes') === 0 and isset($this->submitImages[$value])) { - $string .= "\n"; - $string .= "\n"; + $imgSrc = $this->submitImages[$value]; + + $string .= "\n"; + $string .= "\n"; } else { - $string .= "\n"; + $string .= "\n"; } $string .= "\n"; @@ -255,6 +302,11 @@ class Helper_List extends Helper_Html { return $string; } + public function Form($itemArray) + { + return $this->generalForm($itemArray, 'name_missing', 'value_missing'); + } + public function moveupForm($itemArray) { return $this->generalForm($itemArray, 'moveupAction', 'up'); diff --git a/h-source/Library/Helper/Popup.php b/h-source/Library/Helper/Popup.php index bf6400a..849dcf9 100755 --- a/h-source/Library/Helper/Popup.php +++ b/h-source/Library/Helper/Popup.php @@ -31,6 +31,8 @@ class Helper_Popup extends Helper_Html { //the type of the popup. If type !=exclusive, than each voice selected is added to the where clause. If type=exclusive, the selection of a popup voice causes the unselection of the other voices public $type = null; + + public $allString = 'All'; //list of popup names public $popupItems = array(); @@ -88,7 +90,7 @@ class Helper_Popup extends Helper_Html { } $this->viewArgs[$field] = Params::$nullQueryValue; $viewStatus = Url::createUrl(array_values($this->viewArgs)); - $returnString .= "
  • All
  • \n"; + $returnString .= "
  • ".$this->allString."
  • \n"; $returnString .= "\n\n\n"; $this->viewArgs[$field] = $tempArg; } diff --git a/h-source/Library/Image/Gd/Captcha.php b/h-source/Library/Image/Gd/Captcha.php index b414b13..8a128eb 100644 --- a/h-source/Library/Image/Gd/Captcha.php +++ b/h-source/Library/Image/Gd/Captcha.php @@ -39,7 +39,8 @@ class Image_Gd_Captcha 'fontPath' => $here.'/External/Fonts/FreeFont/FreeMono.ttf', 'undulation' => true, 'align' => false, - 'charHeight' => 28 + 'charHeight' => 28, + 'sessionKey' => 'captchaString', ); //set the $this->scaffold->params array @@ -91,7 +92,7 @@ class Image_Gd_Captcha imagefilledellipse($img, mt_rand(0,$this->params['boxWidth']), mt_rand(0,$this->params['boxHeight']), 1, 1, $noiseColor); } - $_SESSION['captchaString'] = $this->string; + $_SESSION[$this->params['sessionKey']] = $this->string; header('Content-Type: image/png'); imagepng($img); imagedestroy($img); diff --git a/h-source/Library/Image/Gd/Thumbnail.php b/h-source/Library/Image/Gd/Thumbnail.php index 742aa17..9bf2500 100644 --- a/h-source/Library/Image/Gd/Thumbnail.php +++ b/h-source/Library/Image/Gd/Thumbnail.php @@ -41,7 +41,9 @@ class Image_Gd_Thumbnail 'defaultImage' => null, 'cropImage' => 'no', 'horizAlign' => 'left', - 'vertAlign' => 'top' + 'vertAlign' => 'top', + 'resample' => 'yes', + 'function' => 'none', ); //set the $this->scaffold->params array @@ -144,10 +146,24 @@ class Image_Gd_Thumbnail //temp image $tmpImg = imagecreatetruecolor($newWidth, $newHeight); - //copy and resize - imagecopyresized($tmpImg, $img, 0, 0, $xSrc, $ySrc,$newWidth, $newHeight, $width, $height); + if ($this->params['resample'] === 'yes') + { + //copy and resample + imagecopyresampled($tmpImg, $img, 0, 0, $xSrc, $ySrc,$newWidth, $newHeight, $width, $height); + } + else + { + //copy and resize + imagecopyresized($tmpImg, $img, 0, 0, $xSrc, $ySrc,$newWidth, $newHeight, $width, $height); + } imagedestroy($img); $img = $tmpImg; + + if (!function_exists($this->params['function'])) { + throw new Exception('Error in '.__METHOD__.': function '.$this->params['function']. ' does not exist'); + } + + $img = call_user_func($this->params['function'],$img); } } @@ -159,7 +175,7 @@ class Image_Gd_Thumbnail //print the image header("Content-type: image/jpeg"); - imagejpeg($img); + imagejpeg($img,null,90); } diff --git a/h-source/Library/Lang/En/DbCondStrings.php b/h-source/Library/Lang/En/DbCondStrings.php new file mode 100644 index 0000000..0f65bd6 --- /dev/null +++ b/h-source/Library/Lang/En/DbCondStrings.php @@ -0,0 +1,32 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +//error strings in the case database conditions are not satisfied +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 "
    The value of ". $field ." is already present. Please choose a different value.
    \n"; + } + +} diff --git a/h-source/Library/Lang/En/ModelStrings.php b/h-source/Library/Lang/En/ModelStrings.php new file mode 100644 index 0000000..c1046b3 --- /dev/null +++ b/h-source/Library/Lang/En/ModelStrings.php @@ -0,0 +1,34 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +class Lang_En_ModelStrings extends Lang_ResultStrings { + + public $string = array( + "error" => "
    Query error: Contact the administrator!
    \n", + "executed" => "
    Operation executed!
    \n", + "associate" => "
    Referential integrity problem: record associated to some other record in a child table. Break the association before.
    \n", + "no-id" => "
    Alert: record identifier not defined!
    \n", + "not-linked" => "
    The Item is not associated : you can't dissociate it
    ", + "linked" => "
    The Item is already associated: you can't associate it another time
    " + ); + +} diff --git a/h-source/Library/Lang/En/UploadStrings.php b/h-source/Library/Lang/En/UploadStrings.php new file mode 100644 index 0000000..41f2703 --- /dev/null +++ b/h-source/Library/Lang/En/UploadStrings.php @@ -0,0 +1,42 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +class Lang_En_UploadStrings extends Lang_ResultStrings { + + public $string = array( + "error" => "
    Error: verify the permissions of the file/directory
    \n", + "executed" => "
    Operation executed!
    \n", + "not-child" => "
    The selected directory is not a child of the base directory
    \n", + "not-dir" => "
    The selected directory is not a directory
    \n", + "not-empty" => "
    The selected directory is not empty
    \n", + "no-folder-specified" => "
    No folder has been specified
    \n", + "no-file-specified" => "
    No file has been specified
    \n", + "not-writable" => "
    The folder is not writable
    \n", + "not-writable-file" => "
    The file is not writable
    \n", + "dir-exists" => "
    The directory is already present in the current folder
    \n", + "no-upload-file" => "
    There is no file to upload
    \n", + "size-over" => "
    The size of the file is too big
    \n", + "not-allowed-ext" => "
    The extension of the file you want to upload is not allowed
    \n", + "file-exists" => "
    The file is already present in the current folder
    \n" + ); + +} diff --git a/h-source/Library/Lang/En/ValCondStrings.php b/h-source/Library/Lang/En/ValCondStrings.php new file mode 100644 index 0000000..7b409e2 --- /dev/null +++ b/h-source/Library/Lang/En/ValCondStrings.php @@ -0,0 +1,91 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +class Lang_En_ValCondStrings { + + //if the element is not defined + public function getNotDefinedResultString($element) + { + return "
    ". $element ." not defined!
    \n"; + } + + //if the elements are not equal + public function getNotEqualResultString($element) + { + return "
    Different values: $element
    \n"; + } + + //if the element is not alphabetic + public function getNotAlphabeticResultString($element) + { + return "
    ".$element." has to be alphabetic
    \n"; + } + + //if the element is not alphanumeric + public function getNotAlphanumericResultString($element) + { + return "
    ".$element." has to be alphanumeric
    \n"; + } + + //if the element is not a decimal digit + public function getNotDecimalDigitResultString($element) + { + return "
    ".$element." has to be a decimal digit
    \n"; + } + + //if the element has the mail format + public function getNotMailFormatResultString($element) + { + return "
    ".$element." doesn't seem an e-mail address
    \n"; + } + + //if the element is numeric + public function getNotNumericResultString($element) + { + return "
    ".$element." has to be a numeric
    \n"; + } + + //if the element (string) length exceeds the value of characters (defined by $maxLength) + public function getLengthExceedsResultString($element,$maxLength) + { + return "
    ".$element." exceeds the value of $maxLength characters
    \n"; + } + + //if the element is one of the strings indicated by $stringList (a comma-separated list of strings) + public function getIsForbiddenStringResultString($element,$stringList) + { + return "
    ".$element." can't be one of the following strings: $stringList
    \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 "
    ".$element." has to be one of the following strings: $stringList
    \n"; + } + + //if the element is not one of the strings indicated by $stringList (a comma-separated list of strings) + public function getDoesntMatchResultString($element,$regExp) + { + return "
    ".$element." has to match the following regular expression: $regExp
    \n"; + } + +} diff --git a/h-source/Library/Lang/En/index.html b/h-source/Library/Lang/En/index.html new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/h-source/Library/Lang/En/index.html @@ -0,0 +1 @@ + diff --git a/h-source/Library/Model/Base.php b/h-source/Library/Model/Base.php index 753d93c..f420ad9 100755 --- a/h-source/Library/Model/Base.php +++ b/h-source/Library/Model/Base.php @@ -119,7 +119,7 @@ abstract class Model_Base protected $_arraySoftCheck; //Array_Validate_Soft object public $db; //reference to the database layer class - protected $_lang = 'Eng'; //language of notices + protected $_lang = 'En'; //language of notices public function __construct() { @@ -138,7 +138,7 @@ abstract class Model_Base $modelStringClass = 'Lang_'.$this->_lang.'_ModelStrings'; if (!class_exists($modelStringClass)) { - $modelStringClass = 'Lang_Eng_ModelStrings'; + $modelStringClass = 'Lang_En_ModelStrings'; } $this->_resultString = new $modelStringClass(); @@ -146,7 +146,7 @@ abstract class Model_Base $dbCondStringClass = 'Lang_'.$this->_lang.'_DbCondStrings'; if (!class_exists($dbCondStringClass)) { - $dbCondStringClass = 'Lang_Eng_DbCondStrings'; + $dbCondStringClass = 'Lang_En_DbCondStrings'; } $this->_dbCondString = new $dbCondStringClass(); @@ -168,7 +168,8 @@ abstract class Model_Base //sanitize all the $values property public function sanitize() { - $this->values = $this->arrayExt->subset($this->values,null,'sanitizeDb'); + $keys = implode(',',array_keys($this->values)); + $this->values = $this->arrayExt->subset($this->values,$keys,'sanitizeDb'); } //change a resulting string from a db query @@ -308,6 +309,18 @@ abstract class Model_Base //$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; @@ -331,11 +344,13 @@ abstract class Model_Base $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] : ''; - } +// foreach ($fieldsArray as $field) +// { +// $values[$field] = array_key_exists($field,$recordArray) ? $recordArray[$field] : ''; +// } $values[$idName] = $ident; @@ -359,7 +374,6 @@ abstract class Model_Base { if ($this->formStruct['entries'][$k]['type'] === 'File') { - session_start(); $_SESSION['form_'.$k] = $v; } } @@ -371,13 +385,13 @@ abstract class Model_Base $tempArray = is_array($defaultValues) ? $defaultValues : array(); - $values = $this->arrayExt->subset($tempArray,$this->fields,$func); + $values = $this->arrayExt->subset($tempArray,$this->fields,$funcPost); } } else { - $values = $this->arrayExt->subset($_POST,$this->fields,$func); + $values = $this->arrayExt->subset($_POST,$this->fields,$funcPost); if ($queryType === 'update') { @@ -392,7 +406,6 @@ abstract class Model_Base { if ($this->formStruct['entries'][$tempFieldArray[$i]]['type'] === 'File') { - session_start(); if (isset($_SESSION['form_'.$tempFieldArray[$i]])) { $values[$tempFieldArray[$i]] = $_SESSION['form_'.$tempFieldArray[$i]]; @@ -434,7 +447,7 @@ abstract class Model_Base $this->_backupFields = $this->fields; $this->_backupValues = $this->values; $this->values = $this->arrayExt->subsetComplementary($this->values,$list); - $this->fields = implode(',',array_keys($this->values)); +// $this->fields = implode(',',array_keys($this->values)); } //restore the fields and values saved in $_backupFields and $_backupValues diff --git a/h-source/Library/Scaffold.php b/h-source/Library/Scaffold.php index aa20a4b..b1941dc 100755 --- a/h-source/Library/Scaffold.php +++ b/h-source/Library/Scaffold.php @@ -101,32 +101,38 @@ class Scaffold { $this->_primaryKey = $primaryKey; - $recordListArray = explode(',',$recordList); - foreach ($recordListArray as $record) { - $this->itemList->addItem("simpleText",";$record;"); + if (strcmp($recordList,'') !== 0) + { + $recordListArray = explode(',',$recordList); + foreach ($recordListArray as $record) { + $this->itemList->addItem("simpleText",";$record;"); + } } $themeArray = explode(',',$theme); - foreach ($themeArray as $el) + if (strcmp($theme,'') !== 0) { - switch ($el) + foreach ($themeArray as $el) { - 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; + switch ($el) + { + 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; + } } } @@ -204,9 +210,9 @@ class Scaffold } //add an item to the list of items - public function addItem($type, $action = '', $field = '', $name = '') { + public function addItem($type, $action = '', $field = '', $name = '', $value = '', $title = '') { if ($this->_type === 'main') { - $this->itemList->addItem($type, $action, $field, $name); + $this->itemList->addItem($type, $action, $field, $name, $value, $title); } } diff --git a/h-source/Public/Css/main.css b/h-source/Public/Css/main.css index fc2b042..a159733 100644 --- a/h-source/Public/Css/main.css +++ b/h-source/Public/Css/main.css @@ -823,12 +823,12 @@ ins margin:20px 0px; } -.formEntry input,.formEntry textarea { +.form_input_text input,.form_textarea textarea { width:450px; padding:3px; border: 1px solid #CECECE; } -.formEntry textarea +.form_textarea textarea { height:100px; } -- cgit v1.2.3