Added posibility to set_order an set_limit method for use inside a where definition model, added a new DomainField too

This commit is contained in:
Antonio de la Rosa 2016-09-13 06:05:25 +02:00
parent 3a3addf7b0
commit 99ea628d1a
2 changed files with 45 additions and 4 deletions

View file

@ -0,0 +1,34 @@
<?php
namespace PhangoApp\PhaModels\CoreFields;
use PhangoApp\PhaModels\CoreFields\CharField;
use PhangoApp\PhaUtils\Utils;
class DomainField extends CharField {
public function check($value)
{
//Delete Javascript tags and simple quotes.
$pattern='/^(([a-zA-Z]{1})|([a-zA-Z]{1}[a-zA-Z]{1})|([a-zA-Z]{1}[0-9]{1})|([0-9]{1}[a-zA-Z]{1})|([a-zA-Z0-9][a-zA-Z0-9-_]{1,61}[a-zA-Z0-9]))\.([a-zA-Z]{2,6}|[a-zA-Z0-9-]{2,30}\.[a-zA-Z]{2,3})$/';
if(preg_match($pattern, $value))
{
return Utils::form_text($value);
}
else
{
$this->error=1;
return '';
}
}
}
?>

View file

@ -877,6 +877,8 @@ class Webmodel {
$this->order_by=$order_by;
}
return $this;
}
@ -908,6 +910,9 @@ class Webmodel {
$this->limit=$limit;
}
return $this;
}
/**
@ -1239,12 +1244,14 @@ class Webmodel {
$model_name_related=$this->components[$my_field]->related_model->name;
$alias_model_related=$my_field;
//Set the value for the component foreignkeyfield if name_field_to_field is set.
if($this->components[$my_field]->name_field_to_field!='')
{
$arr_select[$key]=$model_name_related.'.`'.$this->components[$my_field]->name_field_to_field.'` as `'.$my_field.'`';
$arr_select[$key]=$alias_model_related.'.`'.$this->components[$my_field]->name_field_to_field.'` as `'.$my_field.'`';
}
@ -1253,15 +1260,15 @@ class Webmodel {
foreach($this->components[$my_field]->fields_related_model as $fields_related)
{
$arr_select[]=$model_name_related.'.`'.$fields_related.'` as `'.$model_name_related.'_'.$fields_related.'`';
$arr_select[]=$alias_model_related.'.`'.$fields_related.'` as `'.$alias_model_related.'_'.$fields_related.'`';
}
$arr_model[]=$model_name_related;
$arr_model[]=$model_name_related.' as '.$alias_model_related;
//Set the where connection
$arr_where[]=$this->name.'.`'.$my_field.'`='.$model_name_related.'.`'.Webmodel::$model[$model_name_related]->idmodel.'`';
$arr_where[]=$this->name.'.`'.$my_field.'`='.$alias_model_related.'.`'.Webmodel::$model[$model_name_related]->idmodel.'`';
}