diff options
| author | Antonio Gallo <tonicucoz@gmail.com> | 2013-10-14 16:06:56 +0000 | 
|---|---|---|
| committer | Antonio Gallo <tonicucoz@gmail.com> | 2013-10-14 16:06:56 +0000 | 
| commit | a93461b231fb94f3a6a9df09a30557732201ddcc (patch) | |
| tree | f278951ee7746da2a618ec57043c57fafe779c1d /h-source/Library | |
| parent | 6fa0219202ce4ccc5c4592e66031bb0f7f8be2b0 (diff) | |
added new EasyGiant Library
Diffstat (limited to 'h-source/Library')
| -rw-r--r-- | h-source/Library/Array/Validate/Soft.php | 35 | ||||
| -rw-r--r-- | h-source/Library/Array/Validate/Strong.php | 35 | ||||
| -rwxr-xr-x | h-source/Library/Db/Mysql.php | 3 | ||||
| -rw-r--r-- | h-source/Library/Db/Mysqli.php | 3 | ||||
| -rwxr-xr-x | h-source/Library/Files/Upload.php | 22 | ||||
| -rwxr-xr-x | h-source/Library/Form/Form.php | 73 | ||||
| -rwxr-xr-x | h-source/Library/Form/Hidden.php | 2 | ||||
| -rwxr-xr-x | h-source/Library/Functions.php | 74 | ||||
| -rwxr-xr-x | h-source/Library/Helper/List.php | 45 | ||||
| -rwxr-xr-x | h-source/Library/Helper/Popup.php | 4 | ||||
| -rw-r--r-- | h-source/Library/Html/Form.php | 25 | ||||
| -rw-r--r-- | h-source/Library/Image/Gd/Thumbnail.php | 19 | ||||
| -rw-r--r-- | h-source/Library/Lang/En/Generic.php | 1 | ||||
| -rwxr-xr-x | h-source/Library/Model/Base.php | 99 | ||||
| -rw-r--r-- | h-source/Library/Params.php | 32 | ||||
| -rwxr-xr-x | h-source/Library/Scaffold.php | 4 | ||||
| -rwxr-xr-x | h-source/Library/Url.php | 2 | ||||
| -rwxr-xr-x | h-source/Library/Users/CheckAdmin.php | 5 | 
18 files changed, 326 insertions, 157 deletions
diff --git a/h-source/Library/Array/Validate/Soft.php b/h-source/Library/Array/Validate/Soft.php index b348bdc..d0c7646 100644 --- a/h-source/Library/Array/Validate/Soft.php +++ b/h-source/Library/Array/Validate/Soft.php @@ -1,24 +1,7 @@  <?php -// EasyGiant is a PHP framework for creating and managing dynamic content -// -// Copyright (C) 2009 - 2011  Antonio Gallo +// 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. -// -// 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!'); @@ -39,35 +22,35 @@ class Array_Validate_Soft 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) +	public function checkAlpha($associativeArray,$keyString,$strength = 'soft')  	{  		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) +	public function checkAlphaNum($associativeArray,$keyString,$strength = 'soft')  	{  		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) +	public function checkDigit($associativeArray,$keyString,$strength = 'soft')  	{  		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) +	public function checkMail($associativeArray,$keyString,$strength = 'soft')  	{  		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) +	public function checkNumeric($associativeArray,$keyString,$strength = 'soft')  	{  		return parent::checkNumeric($associativeArray,$keyString,'soft');  	} @@ -88,15 +71,15 @@ class Array_Validate_Soft 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 = '') +	public function checkIsStrings($associativeArray,$keyString,$strings = '',$strength = 'soft')  	{  		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 = '/./') +	public function checkMatch($associativeArray,$keyString,$regExp = '/./',$strength = 'soft')  	{  		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 ccdce74..d105319 100644 --- a/h-source/Library/Array/Validate/Strong.php +++ b/h-source/Library/Array/Validate/Strong.php @@ -1,24 +1,7 @@  <?php -// EasyGiant is a PHP framework for creating and managing dynamic content -// -// Copyright (C) 2009 - 2011  Antonio Gallo +// 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. -// -// 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!'); @@ -72,7 +55,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) +	public function checkAlpha($associativeArray,$keyString,$strength = 'strong')  	{  		if ($this->checkNotEmpty($associativeArray,$keyString))  		{ @@ -86,7 +69,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) +	public function checkAlphaNum($associativeArray,$keyString,$strength = 'strong')  	{  		if ($this->checkNotEmpty($associativeArray,$keyString))  		{ @@ -100,7 +83,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) +	public function checkDigit($associativeArray,$keyString,$strength = 'strong')  	{  		if ($this->checkNotEmpty($associativeArray,$keyString))  		{ @@ -114,7 +97,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) +	public function checkMail($associativeArray,$keyString,$strength = 'strong')  	{  		if ($this->checkNotEmpty($associativeArray,$keyString))  		{ @@ -128,7 +111,7 @@ class Array_Validate_Strong extends Array_Validate_Base  	//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) +	public function checkNumeric($associativeArray,$keyString,$strength = 'strong')  	{  		if ($this->checkNotEmpty($associativeArray,$keyString))  		{ @@ -170,7 +153,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 = '') +	public function checkIsStrings($associativeArray,$keyString,$strings = '',$strength = 'strong')  	{  		if ($this->checkNotEmpty($associativeArray,$keyString))  		{ @@ -183,7 +166,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 = '/./') +	public function checkMatch($associativeArray,$keyString,$regExp = '/./',$strength = 'strong')  	{  		if ($this->checkNotEmpty($associativeArray,$keyString))  		{ @@ -194,4 +177,4 @@ class Array_Validate_Strong extends Array_Validate_Base  			return false;  		}  	} -}
\ No newline at end of file +} diff --git a/h-source/Library/Db/Mysql.php b/h-source/Library/Db/Mysql.php index 4561a1b..d19d24a 100755 --- a/h-source/Library/Db/Mysql.php +++ b/h-source/Library/Db/Mysql.php @@ -270,7 +270,8 @@ class Db_Mysql {  		$result = mysql_query($query);  		$temp = array();  		while ($row = mysql_fetch_assoc($result)) { -			$temp[$row['Field']] = reset(explode('(',$row['Type'])); +			$e = explode('(',$row['Type']); +			$temp[$row['Field']] = reset($e);  		}  		$types = array(); diff --git a/h-source/Library/Db/Mysqli.php b/h-source/Library/Db/Mysqli.php index df57a54..b65f470 100644 --- a/h-source/Library/Db/Mysqli.php +++ b/h-source/Library/Db/Mysqli.php @@ -273,7 +273,8 @@ class Db_Mysqli  		$result = $this->db->query($query);  		$temp = array();  		while ($row = $result->fetch_assoc()) { -			$temp[$row['Field']] = reset(explode('(',$row['Type'])); +			$e = explode('(',$row['Type']); +			$temp[$row['Field']] = reset($e);  		}  		$result->close(); diff --git a/h-source/Library/Files/Upload.php b/h-source/Library/Files/Upload.php index 7dbc7d1..00a0afe 100755 --- a/h-source/Library/Files/Upload.php +++ b/h-source/Library/Files/Upload.php @@ -230,7 +230,8 @@ class Files_Upload  	{  		if (strstr($file,'.'))  		{ -			return strtolower(end(explode('.', $file))); +			$extArray = explode('.', $file); +			return strtolower(end($extArray));  		}  		return '';  	} @@ -268,6 +269,23 @@ 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); @@ -333,7 +351,7 @@ class Files_Upload  	}  	//check if the $name folder is empty or not -	protected function isEmpty($name) +	public function isEmpty($name)  	{  		$items = scandir($name);  		foreach( $items as $this_file ) { diff --git a/h-source/Library/Form/Form.php b/h-source/Library/Form/Form.php index a1a9fda..d1899a4 100755 --- a/h-source/Library/Form/Form.php +++ b/h-source/Library/Form/Form.php @@ -97,7 +97,7 @@ class Form_Form {  	//function to create the HTML of the form  	//$values: an associative array ('entryName'=>'value') -	//$subset: subset to print +	//$subset: subset to print (comma seprated list of string or array)  	public function render($values = null, $subset = null)  	{ @@ -116,23 +116,78 @@ class Form_Form {  		$fenctype = isset($this->enctype) ? " enctype=".$this->enctype." " : null;  		$htmlForm = "<form $fname $fclass $fid action='".Url::getRoot($this->action)."' method='".$this->method."' $fenctype>\n"; -		$subset = (isset($subset)) ? explode(',',$subset) : array_keys($values); +		if (!isset($subset)) +		{ +			$subset = array_keys($values); +		} +		else +		{ +			$subset = !is_array($subset) ? explode(',',$subset) : $subset; +		} +// 		$subset = (isset($subset)) ? explode(',',$subset) : array_keys($values); -		foreach ($subset as $entry) +		//first cicle: write the HTML of tabs if there are any +		$tabsHtml = null; +		$fCount = 0; +		foreach ($subset as $key => $entry)  		{ - -			if (array_key_exists($entry,$this->entry)) +			if (is_array($entry))  			{ -				$value = array_key_exists($entry,$values) ? $values[$entry] : $this->entry[$entry]->defaultValue; -				$htmlForm .= $this->entry[$entry]->render($value); +				$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"; +		} +		 +		$fCount = 0; +		foreach ($subset as $k => $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 +			{ +				$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++;  			} -  		} +		$htmlForm .= "<div class='submit_entry'>";  		foreach ($this->submit as $name => $value)  		{ -			$htmlForm .= "<div class='inputEntry'>\n<input id='".$name."' type='submit' name='$name' value='$value'>\n</div>\n"; +			if (!is_array($value)) +			{ +				$htmlForm .= "<span class='submit_entry_$value'>".Html_Form::submit($name, $value, null, $name)."</span>"; +			} +			else +			{ +				array_unshift($value,$name); +				$htmlForm .= call_user_func_array(array("Html_Form","submit"),$value); +			}  		} +		$htmlForm .= "</div>";  		$htmlForm .= "</form>\n";  		return $htmlForm;  	} diff --git a/h-source/Library/Form/Hidden.php b/h-source/Library/Form/Hidden.php index c589662..db86713 100755 --- a/h-source/Library/Form/Hidden.php +++ b/h-source/Library/Form/Hidden.php @@ -33,7 +33,7 @@ class Form_Hidden extends Form_Entry  	public function render($value = null)  	{ -		$returnString = Html_Form::hidden($this->entryName, $value); +		$returnString = Html_Form::hidden($this->entryName, $value, $this->className, $this->idName);  		return $returnString;  	} diff --git a/h-source/Library/Functions.php b/h-source/Library/Functions.php index 1477680..62a1838 100755 --- a/h-source/Library/Functions.php +++ b/h-source/Library/Functions.php @@ -163,7 +163,9 @@ function sha1Deep($value)  	return array_map('sha1', $value);  } - +function strip_tagsDeep($value) { +	return array_map('strip_tags', $value); +} @@ -294,6 +296,76 @@ 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)  { diff --git a/h-source/Library/Helper/List.php b/h-source/Library/Helper/List.php index ba59643..7f8fb77 100755 --- a/h-source/Library/Helper/List.php +++ b/h-source/Library/Helper/List.php @@ -172,47 +172,48 @@ class Helper_List extends Helper_Html {  	public function replaceFields($string,$rowArray) {  		$this->__rowArray = $rowArray; //used by the replaceField  method -		$string = preg_replace_callback('/(\;)(.*?)(\;)/', 'Helper_List::replaceField' ,$string); +		$string = preg_replace_callback('/(\;)(.*?)(\;)/', array($this, '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]; -		if (strstr($string,':') or strstr($string,'.')) { -			if (strstr($string,':')) -			{ -				$char = ':'; -			} -			else -			{ -				$char = '.'; -			} -			//check if a function has been indicated -			if (strstr($string,'|')) +		//check if a function has been indicated +		if (strstr($string,'|')) +		{ +			//get the function +			$firstArray = explode('|',$string); +			if (strstr($firstArray[1],':') or strstr($firstArray[1],'.'))  			{ -				//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]]; -				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); +				$string = callFunction($func,$string,__METHOD__);  			} -			else +		} +		else +		{ +			if (strstr($string,':') or strstr($string,'.'))  			{ +				$char = $this->getChar($string);  				$temp = explode($char,$string);  				$string = $this->__rowArray[$temp[0]][$temp[1]];  			}  		} +  		return $string;  	} @@ -477,6 +478,10 @@ class Helper_List extends Helper_Html {  			$viewStatus = Url::createUrl(array_values($this->viewArgs));  			if (strcmp($value,Params::$nullQueryValue) === 0) $value = '';  		} +		else +		{ +			$viewStatus = $this->viewStatus; +		}  		$this->viewArgs[$viewArgsName] = $temp;  		$action = Url::getRoot($this->url).$viewStatus; diff --git a/h-source/Library/Helper/Popup.php b/h-source/Library/Helper/Popup.php index 18bb00d..4f67a5c 100755 --- a/h-source/Library/Helper/Popup.php +++ b/h-source/Library/Helper/Popup.php @@ -104,7 +104,7 @@ class Helper_Popup extends Helper_Html {  				$tempArg = $this->viewArgs[$field];  				$this->legend[$field] = $tempArg; -				$returnString .= "<ul onMouseOver='DisplayTag(this,\"block\");' onMouseOut='DisplayTag(this,\"none\");' id='menuBlock'><li class='innerItem'>".$popup->name."<ul class='innerList'>\n"; +				$returnString .= "<ul onMouseOver='DisplayTag(this,\"block\");' onMouseOut='DisplayTag(this,\"none\");' id='menuBlock'><li class='innerItem inner_item_$field'>".$popup->name."<ul class='innerList'>\n";  				for ($i = 0; $i < count($popup->itemsValue); $i++)  				{  					$this->viewArgs[$field] = $popup->itemsValue[$i]; @@ -128,7 +128,7 @@ class Helper_Popup extends Helper_Html {  				$returnString .= "<div class='popup_legend'>\n";  				foreach ($this->popupArray as $field => $popup)  				{ -					$returnString .= "<div class='popup_legend_item'>".$this->legend[$field]."</div>"; +					$returnString .= "<div class='popup_legend_item popup_legend_item_$field'>".$this->legend[$field]."</div>";  				}  				$returnString .= "</div>\n";  			} diff --git a/h-source/Library/Html/Form.php b/h-source/Library/Html/Form.php index ec81cfb..64c501f 100644 --- a/h-source/Library/Html/Form.php +++ b/h-source/Library/Html/Form.php @@ -208,4 +208,29 @@ class Html_Form {  		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'>\n"; +			$returnString .= "<input type='hidden' name='".$name."' value='$value'>\n"; +		} +		else +		{ +			$returnString ="<input $attributes $idStr $strClass type='submit' name='" .$name. "' value = '$value' />\n"; +		} +		 +		return $returnString; +	} +	  }
\ No newline at end of file diff --git a/h-source/Library/Image/Gd/Thumbnail.php b/h-source/Library/Image/Gd/Thumbnail.php index 22e501e..1fd7796 100644 --- a/h-source/Library/Image/Gd/Thumbnail.php +++ b/h-source/Library/Image/Gd/Thumbnail.php @@ -75,7 +75,8 @@ class Image_Gd_Thumbnail  		if (file_exists($imagePath))  		{ -			$ext = strtolower(end(explode('.', $imagePath))); +			$extArray = explode('.', $imagePath); +			$ext = strtolower(end($extArray));  			if (strcmp($ext,'jpg') === 0 or strcmp($ext,'jpeg') === 0) {  				$img = @imagecreatefromjpeg($imagePath); @@ -112,7 +113,7 @@ class Image_Gd_Thumbnail  			}  			if ($scale < 1) { -    +  				$xSrc = 0;  				$ySrc = 0; @@ -166,6 +167,11 @@ class Image_Gd_Thumbnail  				//temp image  				$tmpImg = imagecreatetruecolor($newWidth, $newHeight); +				if(strcmp($type,'png') === 0 or strcmp($type,'gif') === 0){ +					imagealphablending($tmpImg, false); +					imagesavealpha($tmpImg, true); +				} +    				if ($this->params['resample'] === 'yes')  				{  					//copy and resample @@ -185,7 +191,13 @@ class Image_Gd_Thumbnail  				$img = call_user_func($this->params['function'],$img);  			} -			 +			else +			{ +				if(strcmp($type,'png') === 0 or strcmp($type,'gif') === 0){ +					imagealphablending($img, false); +					imagesavealpha($img, true); +				} +			}  		}  		if (!$img) @@ -195,6 +207,7 @@ class Image_Gd_Thumbnail  			$img = imagecreate($imgWidth, $imgHeight);  			imagecolorallocate($img,200,200,200); +			  		}  		//print the image diff --git a/h-source/Library/Lang/En/Generic.php b/h-source/Library/Lang/En/Generic.php index 3268270..c940949 100644 --- a/h-source/Library/Lang/En/Generic.php +++ b/h-source/Library/Lang/En/Generic.php @@ -49,6 +49,7 @@ class Lang_En_Generic  		'pages'		=>	'pages',  		'filter'	=>	'filter',  		'clear the filter'	=>	'clear the filter', +		'Save'		=>	'Save',  	);  	public function gtext($string) diff --git a/h-source/Library/Model/Base.php b/h-source/Library/Model/Base.php index 4162a56..cdd1843 100755 --- a/h-source/Library/Model/Base.php +++ b/h-source/Library/Model/Base.php @@ -99,6 +99,8 @@ 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  @@ -130,15 +132,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->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)) @@ -277,11 +279,11 @@ abstract class Model_Base  					{  						foreach (params::$whereClauseSymbolArray as $symbol)  						{ -							if (strstr($value,$symbol)) +							if (stristr($value,$symbol))  							{  								//check if write or not the table name  								$tableName = strstr($field,'n!') ? null : $this->getTableName($field).'.'; -								$whereClauseArray[] = $tableName.$fieldClean.' '.$value; +								$whereClauseArray[] = strstr($field,'n!n!') ? $value : $tableName.$fieldClean.' '.$value;  								$flag = 1; //not equal where clause  								break;  							} @@ -291,7 +293,7 @@ abstract class Model_Base  							$value = '"'.$value.'"';  							//check if write or not the table name  							$tableName = strstr($field,'n!') ? null : $this->getTableName($field).'.'; -							$whereClauseArray[] = $tableName.$fieldClean.'='.$value; +							$whereClauseArray[] = strstr($field,'n!n!') ? $value : $tableName.$fieldClean.'='.$value;  						}					  					}  				} @@ -737,18 +739,6 @@ 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); @@ -775,6 +765,49 @@ 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 addStrongCondition($queryType,$condition,$field) +	{ +		$this->addChooseCondition($this->strongConditions,$queryType,$condition,$field); +	} +	 +	//add a condition to the strongCondition array +	public function addSoftCondition($queryType,$condition,$field) +	{ +		$this->addChooseCondition($this->softConditions,$queryType,$condition,$field); +	}  	//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) @@ -793,11 +826,11 @@ abstract class Model_Base  			$conditions = $this->softConditions;  			$errString = 'softConditions'; -			if (Params::$nullQueryValue !== false) -			{ -				$conditions['insert']['+++++checkIsNotStrings|'.Params::$nullQueryValue] = 'all'; -				$conditions['update']['+++++checkIsNotStrings|'.Params::$nullQueryValue] = 'all'; -			} +// 			if (Params::$nullQueryValue !== false) +// 			{ +// 				$conditions['insert']['+++++checkIsNotStrings|'.Params::$nullQueryValue] = 'all'; +// 				$conditions['update']['+++++checkIsNotStrings|'.Params::$nullQueryValue] = 'all'; +// 			}  		}  		if (array_key_exists($queryType,$conditions)) @@ -815,18 +848,6 @@ 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,'|'))  				{ @@ -908,6 +929,10 @@ 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))  					{ @@ -947,7 +972,9 @@ abstract class Model_Base  			$popupWhereClause = array_key_exists($field,$this->_popupWhere) ? $this->_popupWhere[$field] : null; -			$result = $this->db->select($table,$queryFields,$popupWhereClause,$fieldClean); +			$popupOrderBy = array_key_exists($field,$this->_popupOrderBy) ? $this->_popupOrderBy[$field] : null; +			 +			$result = $this->db->select($table,$queryFields,$popupWhereClause,$fieldClean,$popupOrderBy);  			if ($result and $result !== false)  			{ diff --git a/h-source/Library/Params.php b/h-source/Library/Params.php index d98c3b4..433a952 100644 --- a/h-source/Library/Params.php +++ b/h-source/Library/Params.php @@ -1,24 +1,7 @@  <?php -// EasyGiant is a PHP framework for creating and managing dynamic content -// -// Copyright (C) 2009 - 2011  Antonio Gallo +// 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. -// -// 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!'); @@ -26,14 +9,11 @@ if (!defined('EG')) die('Direct access not allowed!');  class Params  { -	//allowed database type -	public static $allowedDb = array('Mysql','Mysqli','None'); +	public static $allowedDb = array('Mysql','Mysqli','None'); //allowed database type -	//allowed sanitize functions -	public static $allowedSanitizeFunc = 'sanitizeAll,sanitizeDb,sanitizeHtml,forceInt,forceNat,none,md5,sha1'; +	public static $allowedSanitizeFunc = 'sanitizeAll,sanitizeDb,sanitizeHtml,forceInt,forceNat,none,md5,sha1,strip_tags'; //allowed sanitize functions -	//allowed hash functions -	public static $allowedHashFunc = array('md5','sha1'); +	public static $allowedHashFunc = array('md5','sha1'); //allowed hash functions  	//conventional null value for the value of the field in the createWhereClause method of the Model class  	public static $nullQueryValue = false; @@ -49,11 +29,11 @@ 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'); +	public static $whereClauseSymbolArray = array('<','>','!=','<=','>=','in(','not in(','like','between');  	//is the mbstring extension enabled?  	public static $mbStringLoaded = false; - +	  	//subfolder of the View folder where to look for view files  	public static $viewSubfolder = null; diff --git a/h-source/Library/Scaffold.php b/h-source/Library/Scaffold.php index 7e43134..4c5b46c 100755 --- a/h-source/Library/Scaffold.php +++ b/h-source/Library/Scaffold.php @@ -74,7 +74,7 @@ class Scaffold  			'recordPerPage'		=>	10,  			'mainMenu'			=>	'panel,add',  			'formMenu'			=>	'panel,back', -			'postSubmitValue'	=>	'Save', +			'postSubmitValue'	=>	$this->strings->gtext('Save'),  			'popup'				=>	false,  			'popupType'			=>	'exclusive'  		); @@ -141,7 +141,7 @@ class Scaffold  						$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'); +						$this->itemList->addItem('ledit',$this->_controller.'/'.$this->params['modifyAction'].'/;'.$primaryKey.';','Edit','Edit');  						break;  				}  			} diff --git a/h-source/Library/Url.php b/h-source/Library/Url.php index 9f73291..da312b1 100755 --- a/h-source/Library/Url.php +++ b/h-source/Library/Url.php @@ -31,7 +31,7 @@ class 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 (in this case '1,2,4') -	public function createUrl($valuesArray,$numericString = null) { +	public static function createUrl($valuesArray,$numericString = null) {  		$elementsArray = explode(',',$numericString);  		$valuesArray = array_values($valuesArray);  		$urlString = null; diff --git a/h-source/Library/Users/CheckAdmin.php b/h-source/Library/Users/CheckAdmin.php index 54deb2a..701b47e 100755 --- a/h-source/Library/Users/CheckAdmin.php +++ b/h-source/Library/Users/CheckAdmin.php @@ -60,6 +60,11 @@ 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; +	} +  	private function cleanSessions()  	{  		#cancello le sessioni scadute  | 
