Little fixes and added new features for fields
This commit is contained in:
parent
f0f8b6c9cd
commit
a2e0b89f1a
5 changed files with 34 additions and 28 deletions
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @author Antonio de la Rosa <webmaster@web-t-sys.com>
|
||||
* @file
|
||||
* @package Core/ModelExtraMethods
|
||||
* @package PhaModels
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -14,17 +14,12 @@ use Intervention\Image\ImageManager;
|
|||
|
||||
class ImageField extends PhangoField {
|
||||
|
||||
public $value="";
|
||||
public $label="";
|
||||
public $required=0;
|
||||
public $form='PhangoApp\PhaModels\Forms\FileForm';
|
||||
public $path="";
|
||||
public $url_path="";
|
||||
public $type='';
|
||||
public $thumb=0;
|
||||
public $img_width=array('mini' => 150);
|
||||
public $quot_open='\'';
|
||||
public $quot_close='\'';
|
||||
public $std_error='';
|
||||
public $quality_jpeg=85;
|
||||
public $min_size=array(0, 0);
|
||||
|
|
@ -35,13 +30,12 @@ class ImageField extends PhangoField {
|
|||
public $size=255;
|
||||
public $driver='gd';
|
||||
|
||||
function __construct($path, $url_path, $type, $thumb=0, $img_width=array('mini' => 150), $quality_jpeg=85)
|
||||
function __construct($path, $url_path, $thumb=0, $img_width=array('mini' => 150), $quality_jpeg=85)
|
||||
{
|
||||
|
||||
#$this->name_file=$this->name_component;
|
||||
$this->path=$path;
|
||||
$this->url_path=$url_path;
|
||||
$this->type=$type;
|
||||
$this->thumb=$thumb;
|
||||
$this->img_width=$img_width;
|
||||
$this->quality_jpeg=$quality_jpeg;
|
||||
|
|
|
|||
|
|
@ -37,6 +37,12 @@ class PhangoField {
|
|||
|
||||
public $name_model='';
|
||||
|
||||
/**
|
||||
* The model where this component or field live
|
||||
*/
|
||||
|
||||
public $model_instance=false;
|
||||
|
||||
/**
|
||||
* Name of the field or component.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -6,22 +6,25 @@ namespace PhangoApp\PhaModels\CoreFields;
|
|||
*
|
||||
*/
|
||||
|
||||
class SlugifyField extends PhangoField {
|
||||
class SlugifyField extends CharField {
|
||||
|
||||
public $form='PhangoApp\PhaModels\Forms\HiddenForm';
|
||||
public $field_related='';
|
||||
|
||||
public $value="";
|
||||
public $label="";
|
||||
public $required=0;
|
||||
public $form="TextForm";
|
||||
public $quot_open='\'';
|
||||
public $quot_close='\'';
|
||||
public $std_error='';
|
||||
public $type='TEXT';
|
||||
|
||||
static function check($value)
|
||||
public function check($value)
|
||||
{
|
||||
|
||||
$value=slugify($value);
|
||||
if($this->field_related!='')
|
||||
{
|
||||
|
||||
if(isset($this->post[$this->field_related]))
|
||||
{
|
||||
|
||||
$value=slugify($this->post[$this->field_related]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($value=='')
|
||||
{
|
||||
|
|
@ -32,14 +35,6 @@ class SlugifyField extends PhangoField {
|
|||
|
||||
return $value;
|
||||
}
|
||||
|
||||
function get_type_sql()
|
||||
{
|
||||
|
||||
return $this->type.' NOT NULL DEFAULT ""';
|
||||
|
||||
|
||||
}
|
||||
|
||||
static function add_slugify_i18n_fields($model_name, $field)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -410,6 +410,13 @@ class Webmodel {
|
|||
*/
|
||||
|
||||
public $fields_to_update=array();
|
||||
|
||||
/**
|
||||
* Property that save the post values used in update and insert
|
||||
*/
|
||||
|
||||
public $post=array();
|
||||
|
||||
|
||||
//Construct the model
|
||||
|
||||
|
|
@ -856,6 +863,8 @@ class Webmodel {
|
|||
public function insert($post, $safe_query=0, $cache_name='')
|
||||
{
|
||||
|
||||
$this->post=&$post;
|
||||
|
||||
$this->set_phango_connection();
|
||||
|
||||
//Make conversion from post
|
||||
|
|
@ -935,6 +944,7 @@ class Webmodel {
|
|||
|
||||
public function update($post, $safe_query=0, $cache_name='')
|
||||
{
|
||||
$this->post=&$post;
|
||||
|
||||
$this->set_phango_connection();
|
||||
|
||||
|
|
@ -2196,6 +2206,7 @@ class Webmodel {
|
|||
//Set first label...
|
||||
$this->components[$name]->label=Webmodel::set_name_default($name);
|
||||
$this->components[$name]->name_model=$this->name;
|
||||
$this->components[$name]->model_instance=&$this;
|
||||
$this->components[$name]->name_component=$name;
|
||||
$this->components[$name]->required=$required;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue