aboutsummaryrefslogtreecommitdiff
path: root/h-source/Library/Model/Base.php
diff options
context:
space:
mode:
authorAntonio Gallo <tonicucoz@gmail.com>2011-05-08 15:26:22 +0000
committerAntonio Gallo <tonicucoz@gmail.com>2011-05-08 15:26:22 +0000
commitafc02bc1c3db9ffe8c9bf660c8aa08666752edfb (patch)
tree9a02b06b390dd0c1e796474b888e92c245473424 /h-source/Library/Model/Base.php
parent7fdac301801bc44f6fdb343187413bdfd2d5366c (diff)
h-source:added new EasyGiant SVN version
Diffstat (limited to 'h-source/Library/Model/Base.php')
-rwxr-xr-xh-source/Library/Model/Base.php97
1 files changed, 83 insertions, 14 deletions
diff --git a/h-source/Library/Model/Base.php b/h-source/Library/Model/Base.php
index 4f2e783..753d93c 100755
--- a/h-source/Library/Model/Base.php
+++ b/h-source/Library/Model/Base.php
@@ -63,14 +63,17 @@ abstract class Model_Base
public $limit = null;
public $from = null; //from clause of the select queries
- public $on = null; //join part of the where clause of the select queries
- public $using = null; //using clause
+ public $on = array(); //on array
+ public $using = array(); //using array
+ public $join = array(); //join array
public $toList = false; //if the result have to be given in a list format
public $listArray = array(); //array containing the $key and the $value to be used to extract a list from a resultSet
//logic operator between statements in the where clause of select queries
public $logicalOperators = array('AND');
+
+ public $files = null; //reference to the Files_Upload class
protected $_tables='itemTable,boxTable,item_boxTable';
protected $_idFields='id_item,id_box';
@@ -149,9 +152,20 @@ abstract class Model_Base
//instantiate the database class
$this->db = Factory_Db::getInstance(DATABASE_TYPE);
+
+ //instantiate the Files_Upload class
+ $params = array(
+ 'filesPermission' => 0777,
+ 'language' => $this->_lang,
+ 'allowedExtensions' => 'png,jpg,jpeg,gif',
+ 'maxFileSize' => 20000000,
+ 'fileUploadKey' => 'userfile'
+ );
+
+ $this->files = new Files_Upload(ROOT."/media/",$params);
}
- //sanitize all the $values proprierty
+ //sanitize all the $values property
public function sanitize()
{
$this->values = $this->arrayExt->subset($this->values,null,'sanitizeDb');
@@ -331,13 +345,25 @@ abstract class Model_Base
if (array_key_exists($entry,$values))
{
if (!function_exists($funcUponEntry)) {
- throw new Exception('Error in <b>'.__METHOD__.'</b>: function <b>'.$funcUponEntry. '</b> does not exists');
+ throw new Exception('Error in <b>'.__METHOD__.'</b>: function <b>'.$funcUponEntry. '</b> does not exist');
}
$values[$entry] = call_user_func($funcUponEntry,$values[$entry]);
}
}
-
+
+ //set values of $_SESSION array
+ foreach ($values as $k => $v)
+ {
+ if (isset($this->formStruct['entries'][$k]['type']))
+ {
+ if ($this->formStruct['entries'][$k]['type'] === 'File')
+ {
+ session_start();
+ $_SESSION['form_'.$k] = $v;
+ }
+ }
+ }
}
}
else if ($queryType === 'insert')
@@ -356,6 +382,24 @@ abstract class Model_Base
if ($queryType === 'update')
{
$values[$idName] = $ident;
+
+ //take values from $_SESSION array
+ $tempFieldArray = explode(',',$this->fields);
+
+ for ($i = 0; $i < count($tempFieldArray); $i++)
+ {
+ if (isset($this->formStruct['entries'][$tempFieldArray[$i]]['type']))
+ {
+ if ($this->formStruct['entries'][$tempFieldArray[$i]]['type'] === 'File')
+ {
+ session_start();
+ if (isset($_SESSION['form_'.$tempFieldArray[$i]]))
+ {
+ $values[$tempFieldArray[$i]] = $_SESSION['form_'.$tempFieldArray[$i]];
+ }
+ }
+ }
+ }
}
}
}
@@ -886,7 +930,7 @@ abstract class Model_Base
{
if (!function_exists($this->_popupFunctions[$field]))
{
- throw new Exception('Error in <b>'.__METHOD__.'</b>: function <b>'.$this->_popupFunctions[$field]. '</b> does not exists');
+ throw new Exception('Error in <b>'.__METHOD__.'</b>: function <b>'.$this->_popupFunctions[$field]. '</b> does not exist');
}
$tempName = call_user_func($this->_popupFunctions[$field],$row[$itemNameTable][$itemNameClean]);
@@ -945,17 +989,40 @@ abstract class Model_Base
return $this;
}
- //set the $on property and return the current object
+ //set the on property and return the current object
public function on($joinClause = '-')
{
- $this->on = $joinClause;
+ $this->on[] = $joinClause;
+ $this->using[] = null;
return $this;
}
//set the $using property and return the current object
public function using($using = null)
{
- $this->using = $using;
+ $this->using[] = $using;
+ $this->on[] = null;
+ return $this;
+ }
+
+ //set the $join property and return the current object
+ public function left($string = null)
+ {
+ $this->join[] = "l:$string";
+ return $this;
+ }
+
+ //set the $join property and return the current object
+ public function right($string = null)
+ {
+ $this->join[] = "r:$string";
+ return $this;
+ }
+
+ //set the $join property and return the current object
+ public function inner($string = null)
+ {
+ $this->join[] = "i:$string";
return $this;
}
@@ -1011,14 +1078,15 @@ abstract class Model_Base
$this->orderBy = null;
$this->limit = null;
$this->from = null;
- $this->on = null;
- $this->using = null;
+ $this->on = array();
+ $this->using = array();
+ $this->join = array();
$this->toList = false;
return $this;
}
//initialize and populate the ::form property (reference to a Form_Form object)
- public function setForm($defAction = null, $defSubmit = array(), $defMethod = 'POST')
+ public function setForm($defAction = null, $defSubmit = array(), $defMethod = 'POST', $defEnctype = null)
{
if (isset($this->formStruct))
{
@@ -1026,8 +1094,9 @@ abstract class Model_Base
$submit = array_key_exists('submit',$this->formStruct) ? $this->formStruct['submit'] : $defSubmit;
$entries = array_key_exists('entries',$this->formStruct) ? $this->formStruct['entries'] : null;
$method = array_key_exists('post',$this->formStruct) ? $this->formStruct['post'] : $defMethod;
+ $enctype = array_key_exists('enctype',$this->formStruct) ? $this->formStruct['enctype'] : $defEnctype;
- $this->form = new Form_Form($action,$submit,$method);
+ $this->form = new Form_Form($action,$submit,$method,$enctype);
if (isset($entries))
{
@@ -1082,7 +1151,7 @@ abstract class Model_Base
}
else
{
- $this->form = new Form_Form($defAction,$defSubmit,$defMethod);
+ $this->form = new Form_Form($defAction,$defSubmit,$defMethod,$defEnctype);
}
}