diff options
Diffstat (limited to 'h-source')
25 files changed, 528 insertions, 90 deletions
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 @@ <?php -// All EasyGiant code 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. -// See COPYRIGHT.txt and LICENSE.txt. +// EasyGiant, a web software to build a community of people that want to share their hardware information. +// Copyright (C) 2009 - 2010 Antonio Gallo (h-source-copyright.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!'); //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 @@ <?php -// All EasyGiant code 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. -// See COPYRIGHT.txt and LICENSE.txt. +// EasyGiant, a web software to build a community of people that want to share their hardware information. +// Copyright (C) 2009 - 2010 Antonio Gallo (h-source-copyright.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!'); 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 @@ <?php -// All EasyGiant code 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. -// See COPYRIGHT.txt and LICENSE.txt. +// EasyGiant, a web software to build a community of people that want to share their hardware information. +// Copyright (C) 2009 - 2010 Antonio Gallo (h-source-copyright.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!'); @@ -14,6 +29,7 @@ class Lang_It_UploadStrings extends Lang_ResultStrings { "not-dir" => "<div class='alert'>La cartella selezionata non è una directory</div>\n", "not-empty" => "<div class='alert'>La cartella selezionata non è vuota</div>\n", "no-folder-specified" => "<div class='alert'>Non è stata specificata alcuna cartella</div>\n", + "no-file-specified" => "<div class='alert'>Non è stato specificato alcun file</div>\n", "not-writable" => "<div class='alert'>La cartella non è scrivibile</div>\n", "not-writable-file" => "<div class='alert'>Il file non è scrivibile</div>\n", "dir-exists" => "<div class='alert'>Esiste già una directory con lo stesso nome</div>\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 @@ <?php -// All EasyGiant code 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. -// See COPYRIGHT.txt and LICENSE.txt. +// EasyGiant, a web software to build a community of people that want to share their hardware information. +// Copyright (C) 2009 - 2010 Antonio Gallo (h-source-copyright.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_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 "<div class='alert'>".$element." deve assumere uno dei seguenti valori: $stringList</div>\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 "<div class='alert'>".$element." deve soddisfare la seguente espressione regolare: $regExp</div>\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 <select> entry or a radio button). Associative array or comma-divided list. public $defaultValue = ''; public $wrap = array(); + public $deleteButton = null; public $type = null; //the type of the entry //create the label of each entry of the form @@ -44,7 +45,32 @@ abstract class Form_Entry { //get the class of the entry public function getEntryClass() { - return isset($this->entryClass) ? $this->entryClass : 'formEntry'; + if (isset($this->entryClass)) + { + $class = $this->entryClass; + } + else + { + switch($this->type) + { + case 'InputText': + $class = 'form_input_text'; + break; + case 'File': + $class = 'form_input_file'; + break; + case 'Textarea': + $class = 'form_textarea'; + break; + case 'Password': + $class = 'form_input_text form_input_password'; + break; + default: + $class = 'form_input_text'; + break; + } + } + return $class; } public function getWrapElements($value = null) @@ -52,7 +78,19 @@ abstract class Form_Entry { //replace the ;;value;; variable for ($i = 0; $i < count($this->wrap); $i++) { - $this->wrap[$i] = str_replace(';;value;;',$value,$this->wrap[$i]); + if ( preg_match('/;;(.*)\|value;;/',$this->wrap[$i],$m) ) + { + if (!function_exists($m[1])) { + throw new Exception('Error in <b>'.__METHOD__.'</b>: function <b>'.$m[1].'</b> does not exists..'); + } + //apply the function + $v = call_user_func($m[1],$value); + $this->wrap[$i] = str_replace(";;".$m[1]."|value;;",$v,$this->wrap[$i]); + } + else if ( preg_match('/;;value;;/',$this->wrap[$i]) ) + { + $this->wrap[$i] = str_replace(';;value;;',$value,$this->wrap[$i]); + } } $wrap[0] = isset($this->wrap[0]) ? $this->wrap[0] : null; diff --git a/h-source/Library/Form/File.php b/h-source/Library/Form/File.php index 48030f7..951b3d4 100644 --- a/h-source/Library/Form/File.php +++ b/h-source/Library/Form/File.php @@ -38,6 +38,13 @@ class Form_File extends Form_Entry $returnString .= $this->getLabelTag(); $returnString .= $wrap[2]; $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; + $svalue = isset($this->deleteButton[1]) ? $this->deleteButton[1] : 'delete'; + $sclass = isset($this->deleteButton[2]) ? "class='".$this->deleteButton[2]."'" : null; + $returnString .= "<input $sclass type='submit' name='$sname' value='$svalue'>\n"; + } $returnString .= $wrap[3]; $returnString .="</div>\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 = "<div class='".$this->getEntryClass()."'>\n\t"; - $returnString .= $wrap[0]; - $returnString .= $this->getLabelTag(); + $wrap = $this->getWrapElements($value); + $returnString = $wrap[0]; + $returnString .= "<div class='".$this->getEntryClass()."'>\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 .="</div>\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.="</".$tag.">\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 = "<form class='listItemForm' action='".Url::getRoot(null).$itemArray['action'].$this->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 .= "<input type='image' title='".$this->submitTitles[$submitValue]."' src='".$this->submitImages[$submitValue]."' value='$submitValue'>\n"; - $string .= "<input type='hidden' name='".$name."' value='$submitValue'>\n"; + $imgSrc = $this->submitImages[$value]; + + $string .= "<input type='image' $title src='".$imgSrc."' value='$value'>\n"; + $string .= "<input type='hidden' name='".$name."' value='$value'>\n"; } else { - $string .= "<input type='submit' title='".$this->submitTitles[$submitValue]."' name='".$name."' value='$submitValue'>\n"; + $string .= "<input type='submit' $title name='".$name."' value='$value'>\n"; } $string .= "<input type='hidden' name='".$this->_identifierName."' value='".$itemArray['field']."'>\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 .= "<li><a href='".Url::getRoot($this->url).$viewStatus."'>All</a></li>\n"; + $returnString .= "<li><a href='".Url::getRoot($this->url).$viewStatus."'>".$this->allString."</a></li>\n"; $returnString .= "</ul>\n</li>\n</ul>\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 <b>'.__METHOD__.'</b>: function <b>'.$this->params['function']. '</b> 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 @@ +<?php + +// EasyGiant, a web software to build a community of people that want to share their hardware information. +// Copyright (C) 2009 - 2010 Antonio Gallo (h-source-copyright.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!'); + +//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 "<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/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 @@ +<?php + +// EasyGiant, a web software to build a community of people that want to share their hardware information. +// Copyright (C) 2009 - 2010 Antonio Gallo (h-source-copyright.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_ModelStrings extends Lang_ResultStrings { + + 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 new file mode 100644 index 0000000..41f2703 --- /dev/null +++ b/h-source/Library/Lang/En/UploadStrings.php @@ -0,0 +1,42 @@ +<?php + +// EasyGiant, a web software to build a community of people that want to share their hardware information. +// Copyright (C) 2009 - 2010 Antonio Gallo (h-source-copyright.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_UploadStrings extends Lang_ResultStrings { + + public $string = array( + "error" => "<div class='alert'>Error: verify the permissions of the file/directory</div>\n", + "executed" => "<div class='executed'>Operation executed!</div>\n", + "not-child" => "<div class='alert'>The selected directory is not a child of the base directory</div>\n", + "not-dir" => "<div class='alert'>The selected directory is not a directory</div>\n", + "not-empty" => "<div class='alert'>The selected directory is not empty</div>\n", + "no-folder-specified" => "<div class='alert'>No folder has been specified</div>\n", + "no-file-specified" => "<div class='alert'>No file has been specified</div>\n", + "not-writable" => "<div class='alert'>The folder is not writable</div>\n", + "not-writable-file" => "<div class='alert'>The file is not writable</div>\n", + "dir-exists" => "<div class='alert'>The directory is already present in the current folder</div>\n", + "no-upload-file" => "<div class='alert'>There is no file to upload</div>\n", + "size-over" => "<div class='alert'>The size of the file is too big</div>\n", + "not-allowed-ext" => "<div class='alert'>The extension of the file you want to upload is not allowed</div>\n", + "file-exists" => "<div class='alert'>The file is already present in the current folder</div>\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 @@ +<?php + +// EasyGiant, a web software to build a community of people that want to share their hardware information. +// Copyright (C) 2009 - 2010 Antonio Gallo (h-source-copyright.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_ValCondStrings { + + //if the element is not defined + public function getNotDefinedResultString($element) + { + return "<div class='alert'>". $element ." not defined!</div>\n"; + } + + //if the elements are not equal + public function getNotEqualResultString($element) + { + return "<div class='alert'>Different values: $element</div>\n"; + } + + //if the element is not alphabetic + public function getNotAlphabeticResultString($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='alert'>".$element." has to be alphanumeric</div>\n"; + } + + //if the element is not a decimal digit + public function getNotDecimalDigitResultString($element) + { + return "<div class='alert'>".$element." has to be a decimal digit</div>\n"; + } + + //if the element has the mail format + public function getNotMailFormatResultString($element) + { + return "<div class='alert'>".$element." doesn't seem an e-mail address</div>\n"; + } + + //if the element is numeric + public function getNotNumericResultString($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='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='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='alert'>".$element." has to 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 getDoesntMatchResultString($element,$regExp) + { + return "<div class='alert'>".$element." has to match the following regular expression: $regExp</div>\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; } |