diff --git a/src/CoreFields/BooleanField.php b/src/CoreFields/BooleanField.php index 862b587..886722a 100644 --- a/src/CoreFields/BooleanField.php +++ b/src/CoreFields/BooleanField.php @@ -24,7 +24,7 @@ class BooleanField extends PhangoField { { $this->size=1; - $this->form='PhangoApp\PhaModels\CoreForms::SelectForm'; + $this->form=public $form='PhangoApp\PhaModels\Forms\SelectForm'; } diff --git a/src/CoreFields/CharField.php b/src/CoreFields/CharField.php index 4bb0b77..01ca582 100644 --- a/src/CoreFields/CharField.php +++ b/src/CoreFields/CharField.php @@ -31,7 +31,7 @@ class CharField extends PhangoField { { $this->size=$size; - $this->form='PhangoApp\PhaModels\CoreForms::TextForm'; + $this->form='PhangoApp\PhaModels\Forms\BaseForm'; } diff --git a/src/CoreFields/ChoiceField.php b/src/CoreFields/ChoiceField.php index f4e7952..62e97e2 100644 --- a/src/CoreFields/ChoiceField.php +++ b/src/CoreFields/ChoiceField.php @@ -3,6 +3,7 @@ namespace PhangoApp\PhaModels\CoreFields; use PhangoApp\PhaUtils\Utils; use PhangoApp\PhaI18n\I18n; +use PhangoApp\PhaModels\Forms\SelectForm; /** * @@ -14,7 +15,6 @@ class ChoiceField extends PhangoField { public $value=0; public $label=""; public $required=0; - public $form=""; public $quot_open='\''; public $quot_close='\''; public $std_error=''; @@ -22,18 +22,18 @@ class ChoiceField extends PhangoField { public $arr_values=array(); public $arr_formatted=array(); public $default_value=''; - + public $form='PhangoApp\PhaModels\Forms\SelectForm'; function __construct($size=11, $type='integer', $arr_values=array(), $default_value='') { $this->size=$size; - $this->form='PhangoApp\PhaModels\CoreForms::SelectForm'; $this->type=$type; $this->arr_values=$arr_values; $this->default_value=$default_value; - $this->arr_formatted['']=''; + $this->arr_formatted['']=I18n::lang('common', 'none_selected', 'None selected'); + foreach($arr_values as $value) { @@ -119,11 +119,13 @@ class ChoiceField extends PhangoField { public function show_formatted($value) { + + $this->restart_formatted(); return $this->arr_formatted[$value]; } - + /* function get_parameters_default() { @@ -145,13 +147,26 @@ class ChoiceField extends PhangoField { else { - $arr_values=array(0, 'Option 1', 0, 'Option 2', 1); + $arr_values=array(0 => 'Option 1', 1 => 'Option 2'); } return array($this->name_component, '', $arr_values); - } + }*/ + /* + public function create_form() + { + + $form=new SelectForm($this->name_component, $this->value); + $form->default_value=$this->default_value; + $form->required=$this->required; + $form->label=$this->label; + $form->arr_select=$this->arr_formatted; + + return $form; + + }*/ } diff --git a/src/CoreFields/DateField.php b/src/CoreFields/DateField.php index 157724f..8d5310c 100644 --- a/src/CoreFields/DateField.php +++ b/src/CoreFields/DateField.php @@ -23,7 +23,7 @@ class DateField extends PhangoField { { $this->size=$size; - $this->form='PhangoApp\PhaModels\CoreForms::DateForm'; + $this->form='PhangoApp\PhaModels\CoreForms\DateForm'; } diff --git a/src/CoreFields/DoubleField.php b/src/CoreFields/DoubleField.php index 57ba60c..ea14404 100644 --- a/src/CoreFields/DoubleField.php +++ b/src/CoreFields/DoubleField.php @@ -22,7 +22,7 @@ class DoubleField extends PhangoField { { $this->size=$size; - $this->form='PhangoApp\PhaModels\CoreForms::TextForm'; + $this->form='PhangoApp\PhaModels\Forms\BaseForm'; } diff --git a/src/CoreFields/EmailField.php b/src/CoreFields/EmailField.php index e6192f2..073019b 100644 --- a/src/CoreFields/EmailField.php +++ b/src/CoreFields/EmailField.php @@ -12,7 +12,7 @@ class EmailField extends PhangoField { public $size=200; public $value=""; public $label=""; - public $form="PhangoApp\PhaModels\CoreForms::TextForm"; + public $form='PhangoApp\PhaModels\Forms\BaseForm'; public $class=""; public $required=0; public $quot_open='\''; diff --git a/src/CoreFields/FileField.php b/src/CoreFields/FileField.php index 9709a76..950af99 100644 --- a/src/CoreFields/FileField.php +++ b/src/CoreFields/FileField.php @@ -12,7 +12,7 @@ class FileField extends PhangoField { public $value=""; public $label=""; public $required=0; - public $form="PhangoApp\PhaModels\CoreForms::FileForm"; + public $form='PhangoApp\PhaModels\Forms\BaseForm'; public $name_file=""; public $path=""; public $url_path=""; diff --git a/src/CoreFields/ForeignKeyField.php b/src/CoreFields/ForeignKeyField.php index e9851a2..69f91dc 100644 --- a/src/CoreFields/ForeignKeyField.php +++ b/src/CoreFields/ForeignKeyField.php @@ -28,7 +28,7 @@ class ForeignKeyField extends IntegerField{ { $this->size=$size; - $this->form='PhangoApp\PhaModels\CoreForms::SelectForm'; + $this->form='PhangoApp\PhaModels\Forms\SelectForm'; $this->related_model=&$related_model; $this->container_model=$this->related_model->name; //Fields obtained from related_model if you make a query... @@ -76,7 +76,9 @@ class ForeignKeyField extends IntegerField{ //Need checking if the value exists with a select_count - $num_rows=$this->related_model->select_count('where '.$this->related_model.'.'.$this->related_model->idmodel.'='.$value, $this->related_model->idmodel); + $this->related_model->set_conditions('where '.$this->related_model->name.'.'.$this->related_model->idmodel.'='.$value); + + $num_rows=$this->related_model->select_count(); if($num_rows>0) { diff --git a/src/CoreFields/ImageField.php b/src/CoreFields/ImageField.php index 9d72a9b..97ddfad 100644 --- a/src/CoreFields/ImageField.php +++ b/src/CoreFields/ImageField.php @@ -15,7 +15,7 @@ class ImageField extends PhangoField { public $value=""; public $label=""; public $required=0; - public $form="PhangoApp\PhaModels\CoreForms::ImageForm"; + public $form='PhangoApp\PhaModels\Forms\BaseForm'; public $name_file=""; public $path=""; public $url_path=""; diff --git a/src/CoreFields/IntegerField.php b/src/CoreFields/IntegerField.php index 2f8b92e..864f4c7 100644 --- a/src/CoreFields/IntegerField.php +++ b/src/CoreFields/IntegerField.php @@ -22,7 +22,7 @@ class IntegerField extends PhangoField { { $this->size=$size; - $this->form='PhangoApp\PhaModels\CoreForms::TextForm'; + $this->form='PhangoApp\PhaModels\Forms\BaseForm'; $this->only_positive=$only_positive; $this->min_num=$min_num; $this->max_num=$max_num; diff --git a/src/CoreFields/KeyField.php b/src/CoreFields/KeyField.php index 23fb6d2..215ab72 100644 --- a/src/CoreFields/KeyField.php +++ b/src/CoreFields/KeyField.php @@ -26,7 +26,7 @@ class KeyField extends PhangoField { { $this->size=$size; - $this->form='PhangoApp\PhaModels\CoreForms::TextForm'; + $this->form='PhangoApp\PhaModels\Forms\BaseForm'; } diff --git a/src/CoreFields/ParentField.php b/src/CoreFields/ParentField.php index 62aea58..a6517ef 100644 --- a/src/CoreFields/ParentField.php +++ b/src/CoreFields/ParentField.php @@ -17,7 +17,7 @@ class ParentField extends IntegerField{ $this->parent_model=&$parent_model; $this->size=$size; - $this->form='PhangoApp\PhaModels\CoreForms::SelectForm'; + $this->form='PhangoApp\PhaModels\Forms\BaseForm'; } diff --git a/src/CoreFields/PasswordField.php b/src/CoreFields/PasswordField.php index a40a3c1..97be817 100644 --- a/src/CoreFields/PasswordField.php +++ b/src/CoreFields/PasswordField.php @@ -20,7 +20,7 @@ class PasswordField extends CharField { { $this->min_length=5; $this->size=$size; - $this->form='PhangoApp\PhaModels\CoreForms::PasswordForm'; + $this->form='PhangoApp\PhaModels\Forms\PasswordForm'; } diff --git a/src/CoreFields/PhangoField.php b/src/CoreFields/PhangoField.php index f4a0818..ec42922 100644 --- a/src/CoreFields/PhangoField.php +++ b/src/CoreFields/PhangoField.php @@ -88,7 +88,7 @@ class PhangoField { * Form define the function for use in forms... */ - public $form="PhangoApp\PhaModels\CoreForms::TextForm"; + public $form='PhangoApp\PhaModels\Forms\BaseForm'; /** * Array for create initial parameters for form.. @@ -108,6 +108,7 @@ class PhangoField { public $default_value=''; + /** * Method used for internal tasks related with searchs. You can overwrite this method in your PhangoField object if you need translate the value that the user want search to a real value into the database. */ @@ -168,7 +169,7 @@ class PhangoField { /** * Method for create a form, you only need subclass the field if you want another form different to default */ - + /* public function create_form() { @@ -179,7 +180,7 @@ class PhangoField { return $form; - } + }*/ } diff --git a/src/CoreFields/PrimaryField.php b/src/CoreFields/PrimaryField.php index fdbd373..8d91adb 100644 --- a/src/CoreFields/PrimaryField.php +++ b/src/CoreFields/PrimaryField.php @@ -34,7 +34,7 @@ class PrimaryField extends PhangoField { * By default, the form used for this field is HiddenForm. */ - public $form="PhangoApp\PhaModels\CoreForms::HiddenForm"; + public $form='PhangoApp\PhaModels\Forms\BaseForm'; /** * By default this field is protected. @@ -82,7 +82,7 @@ class PrimaryField extends PhangoField { /** * By default primaryfield use a hidden form */ - + /* public function create_form() { @@ -94,7 +94,7 @@ class PrimaryField extends PhangoField { return $form; - } + }*/ } diff --git a/src/CoreFields/SerializeField.php b/src/CoreFields/SerializeField.php index f162a75..321526b 100644 --- a/src/CoreFields/SerializeField.php +++ b/src/CoreFields/SerializeField.php @@ -12,7 +12,7 @@ class SerializeField extends PhangoField { public $value=""; public $label=""; public $required=0; - public $form="TextForm"; + public $form='PhangoApp\PhaModels\Forms\BaseForm'; public $quot_open='\''; public $quot_close='\''; public $std_error=''; diff --git a/src/CoreFields/TextField.php b/src/CoreFields/TextField.php index 62b1d4e..7d4b296 100644 --- a/src/CoreFields/TextField.php +++ b/src/CoreFields/TextField.php @@ -22,7 +22,7 @@ class TextField extends PhangoField { function __construct($multilang=0) { - $this->form='PhangoApp\PhaModels\CoreForms::TextAreaForm'; + $this->form='PhangoApp\PhaModels\Forms\BaseForm'; $this->multilang=$multilang; } diff --git a/src/CoreFields/TextHTMLField.php b/src/CoreFields/TextHTMLField.php index 1db8cec..c0c787e 100644 --- a/src/CoreFields/TextHTMLField.php +++ b/src/CoreFields/TextHTMLField.php @@ -25,7 +25,7 @@ class TextHTMLField extends PhangoField { function __construct($multilang=0) { - $this->form='PhangoApp\PhaModels\CoreForms::TextAreaForm'; + $this->form='PhangoApp\PhaModels\Forms\BaseForm'; $this->multilang=$multilang; $this->set_safe_html_tags(); diff --git a/src/ExtraModels/UserPhangoModel.php b/src/ExtraModels/UserPhangoModel.php index 5bdc673..7629ccc 100644 --- a/src/ExtraModels/UserPhangoModel.php +++ b/src/ExtraModels/UserPhangoModel.php @@ -66,6 +66,15 @@ class UserPhangoModel extends Webmodel { if(isset($post[$this->username]) && $post[$this->email]) { + if(!isset($post['IdUser_admin'])) + { + + settype($_GET['IdUser_admin'], 'integer'); + + $post['IdUser_admin']=$_GET['IdUser_admin']; + + } + if($this->check_user_exists($post[$this->username], $post[$this->email], $post['IdUser_admin'])) { @@ -87,7 +96,7 @@ class UserPhangoModel extends Webmodel { unset($post[$this->password]); } - + return parent::update($post, $safe_query); } diff --git a/src/Forms/SelectForm.php b/src/Forms/SelectForm.php index cdddec8..d9d45e9 100644 --- a/src/Forms/SelectForm.php +++ b/src/Forms/SelectForm.php @@ -26,7 +26,7 @@ class SelectForm extends BaseForm{ foreach($this->arr_select as $value => $select) { - + settype($arr_selected[$value], 'string'); ?> diff --git a/src/Webmodel.php b/src/Webmodel.php index 5399db6..95d7141 100644 --- a/src/Webmodel.php +++ b/src/Webmodel.php @@ -242,21 +242,21 @@ class Webmodel { * */ - protected $conditions='WHERE 1=1'; + public $conditions='WHERE 1=1'; /** * A string where is set the order of query * */ - protected $order_by=''; + public $order_by=''; /** * A string where is saved the limit of rows in query * */ - protected $limit=''; + public $limit=''; /** * A string where is saved the limit of rows in query @@ -572,6 +572,13 @@ class Webmodel { } + public function show_conditions() + { + + return $this->conditions; + + } + /** * This method insert a row in database using model how mirage of table. * @@ -742,7 +749,7 @@ class Webmodel { } else { - + return 1; } @@ -1573,7 +1580,15 @@ class Webmodel { public function create_form($component_name) { - $this->forms[$component_name]=$this->components[$component_name]->create_form(); + $component=$this->components[$component_name]; + + $form_class=$component->form; + + $this->forms[$component_name]=new $form_class($component_name, $component->value); + + $this->forms[$component_name]->default_value=$component->default_value; + $this->forms[$component_name]->required=$component->required; + $this->forms[$component_name]->label=$component->label; }