Initial commit
This commit is contained in:
32
pluf/src/Pluf/DB/Field/Boolean.php
Normal file
32
pluf/src/Pluf/DB/Field/Boolean.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# This file is part of Plume Framework, a simple PHP Application Framework.
|
||||
# Copyright (C) 2001-2007 Loic d'Anterroches and contributors.
|
||||
#
|
||||
# Plume Framework is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Plume Framework 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 Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# ***** END LICENSE BLOCK ***** */
|
||||
|
||||
class Pluf_DB_Field_Boolean extends Pluf_DB_Field
|
||||
{
|
||||
public $type = 'boolean';
|
||||
|
||||
function formField($def, $form_field='Pluf_Form_Field_Boolean')
|
||||
{
|
||||
return parent::formField($def, $form_field);
|
||||
}
|
||||
}
|
42
pluf/src/Pluf/DB/Field/Compressed.php
Normal file
42
pluf/src/Pluf/DB/Field/Compressed.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# This file is part of Plume Framework, a simple PHP Application Framework.
|
||||
# Copyright (C) 2001-2007 Loic d'Anterroches and contributors.
|
||||
#
|
||||
# Plume Framework is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Plume Framework 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 Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/**
|
||||
* This field will automatically inflate/deflate its content.
|
||||
*
|
||||
* This can be used to store large text bodies where you do not need
|
||||
* to directly search into the content using the standard SQL
|
||||
* functions.
|
||||
*/
|
||||
class Pluf_DB_Field_Compressed extends Pluf_DB_Field
|
||||
{
|
||||
public $type = 'blob';
|
||||
|
||||
function formField($def, $form_field='Pluf_Form_Field_Varchar')
|
||||
{
|
||||
if (!isset($def['widget'])) {
|
||||
$def['widget'] = 'Pluf_Form_Widget_TextareaInput';
|
||||
}
|
||||
return parent::formField($def, $form_field);
|
||||
}
|
||||
}
|
32
pluf/src/Pluf/DB/Field/Date.php
Normal file
32
pluf/src/Pluf/DB/Field/Date.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# This file is part of Plume Framework, a simple PHP Application Framework.
|
||||
# Copyright (C) 2001-2007 Loic d'Anterroches and contributors.
|
||||
#
|
||||
# Plume Framework is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Plume Framework 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 Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# ***** END LICENSE BLOCK ***** */
|
||||
|
||||
class Pluf_DB_Field_Date extends Pluf_DB_Field
|
||||
{
|
||||
public $type = 'date';
|
||||
|
||||
function formField($def, $form_field='Pluf_Form_Field_Date')
|
||||
{
|
||||
return parent::formField($def, $form_field);
|
||||
}
|
||||
}
|
32
pluf/src/Pluf/DB/Field/Datetime.php
Normal file
32
pluf/src/Pluf/DB/Field/Datetime.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# This file is part of Plume Framework, a simple PHP Application Framework.
|
||||
# Copyright (C) 2001-2007 Loic d'Anterroches and contributors.
|
||||
#
|
||||
# Plume Framework is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Plume Framework 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 Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# ***** END LICENSE BLOCK ***** */
|
||||
|
||||
class Pluf_DB_Field_Datetime extends Pluf_DB_Field
|
||||
{
|
||||
public $type = 'datetime';
|
||||
|
||||
function formField($def, $form_field='Pluf_Form_Field_Datetime')
|
||||
{
|
||||
return parent::formField($def, $form_field);
|
||||
}
|
||||
}
|
33
pluf/src/Pluf/DB/Field/Email.php
Normal file
33
pluf/src/Pluf/DB/Field/Email.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# This file is part of Plume Framework, a simple PHP Application Framework.
|
||||
# Copyright (C) 2001-2007 Loic d'Anterroches and contributors.
|
||||
#
|
||||
# Plume Framework is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Plume Framework 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 Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# ***** END LICENSE BLOCK ***** */
|
||||
|
||||
class Pluf_DB_Field_Email extends Pluf_DB_Field
|
||||
{
|
||||
public $type = 'varchar';
|
||||
public $extra = array('size' => 200);
|
||||
|
||||
function formField($def, $form_field='Pluf_Form_Field_Email')
|
||||
{
|
||||
return parent::formField($def, $form_field);
|
||||
}
|
||||
}
|
76
pluf/src/Pluf/DB/Field/File.php
Normal file
76
pluf/src/Pluf/DB/Field/File.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# This file is part of Plume Framework, a simple PHP Application Framework.
|
||||
# Copyright (C) 2001-2007 Loic d'Anterroches and contributors.
|
||||
#
|
||||
# Plume Framework is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Plume Framework 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 Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# ***** END LICENSE BLOCK ***** */
|
||||
|
||||
class Pluf_DB_Field_File extends Pluf_DB_Field
|
||||
{
|
||||
/**
|
||||
* See definition in Pluf_DB_Field.
|
||||
*/
|
||||
public $type = 'file';
|
||||
public $column = '';
|
||||
public $value;
|
||||
public $extra = array();
|
||||
public $methods = array();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param mixed Value ('')
|
||||
* @param string Column name ('')
|
||||
*/
|
||||
function __construct($value='', $column='', $extra=array())
|
||||
{
|
||||
parent::__construct($value, $column, $extra);
|
||||
$this->methods = array(array(strtolower($column).'_url', 'Pluf_DB_Field_File_Url'),
|
||||
array(strtolower($column).'_path', 'Pluf_DB_Field_File_Path')
|
||||
);
|
||||
}
|
||||
|
||||
function formField($def, $form_field='Pluf_Form_Field_File')
|
||||
{
|
||||
return parent::formField($def, $form_field);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the url to access the file.
|
||||
*/
|
||||
function Pluf_DB_Field_File_Url($field, $method, $model, $args=null)
|
||||
{
|
||||
if (strlen($model->$field) != 0) {
|
||||
return Pluf::f('upload_url').'/'.$model->$field;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path to access the file.
|
||||
*/
|
||||
function Pluf_DB_Field_File_Path($field, $method, $model, $args=null)
|
||||
{
|
||||
if (strlen($model->$field) != 0) {
|
||||
return Pluf::f('upload_path').'/'.$model->$field;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
27
pluf/src/Pluf/DB/Field/Float.php
Normal file
27
pluf/src/Pluf/DB/Field/Float.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# This file is part of Plume Framework, a simple PHP Application Framework.
|
||||
# Copyright (C) 2001-2007 Loic d'Anterroches and contributors.
|
||||
#
|
||||
# Plume Framework is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Plume Framework 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 Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# ***** END LICENSE BLOCK ***** */
|
||||
|
||||
class Pluf_DB_Field_Float extends Pluf_DB_Field
|
||||
{
|
||||
public $type = 'float';
|
||||
}
|
38
pluf/src/Pluf/DB/Field/Foreignkey.php
Normal file
38
pluf/src/Pluf/DB/Field/Foreignkey.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# This file is part of Plume Framework, a simple PHP Application Framework.
|
||||
# Copyright (C) 2001-2007 Loic d'Anterroches and contributors.
|
||||
#
|
||||
# Plume Framework is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Plume Framework 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 Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# ***** END LICENSE BLOCK ***** */
|
||||
|
||||
class Pluf_DB_Field_Foreignkey extends Pluf_DB_Field
|
||||
{
|
||||
public $type = 'foreignkey';
|
||||
|
||||
function formField($def, $form_field='Pluf_Form_Field_Varchar')
|
||||
{
|
||||
$gmodel = new $def['model']();
|
||||
$choices = array();
|
||||
foreach ($gmodel->getList() as $item) {
|
||||
$choices[(string) $item] = $item->id;
|
||||
}
|
||||
$def['choices'] = $choices;
|
||||
return parent::formField($def, $form_field);
|
||||
}
|
||||
}
|
27
pluf/src/Pluf/DB/Field/Integer.php
Normal file
27
pluf/src/Pluf/DB/Field/Integer.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# This file is part of Plume Framework, a simple PHP Application Framework.
|
||||
# Copyright (C) 2001-2007 Loic d'Anterroches and contributors.
|
||||
#
|
||||
# Plume Framework is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Plume Framework 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 Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# ***** END LICENSE BLOCK ***** */
|
||||
|
||||
class Pluf_DB_Field_Integer extends Pluf_DB_Field
|
||||
{
|
||||
public $type = 'integer';
|
||||
}
|
45
pluf/src/Pluf/DB/Field/Manytomany.php
Normal file
45
pluf/src/Pluf/DB/Field/Manytomany.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# This file is part of Plume Framework, a simple PHP Application Framework.
|
||||
# Copyright (C) 2001-2007 Loic d'Anterroches and contributors.
|
||||
#
|
||||
# Plume Framework is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Plume Framework 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 Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# ***** END LICENSE BLOCK ***** */
|
||||
|
||||
class Pluf_DB_Field_Manytomany extends Pluf_DB_Field
|
||||
{
|
||||
public $type = 'manytomany';
|
||||
|
||||
function formField($def, $form_field='Pluf_Form_Field_Integer')
|
||||
{
|
||||
$method = 'get_'.$def['name'].'_list';
|
||||
$def['multiple'] = true;
|
||||
$def['initial'] = array();
|
||||
foreach ($def['model_instance']->$method() as $item) {
|
||||
$def['initial'][(string) $item] = $item->id;
|
||||
}
|
||||
$def['choices'] = array();
|
||||
foreach (Pluf::factory($def['model'])->getList() as $item) {
|
||||
$def['choices'][(string) $item] = $item->id;
|
||||
}
|
||||
if (!isset($def['widget'])) {
|
||||
$def['widget'] = 'Pluf_Form_Widget_SelectMultipleInput';
|
||||
}
|
||||
return parent::formField($def, $form_field);
|
||||
}
|
||||
}
|
33
pluf/src/Pluf/DB/Field/Password.php
Normal file
33
pluf/src/Pluf/DB/Field/Password.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# This file is part of Plume Framework, a simple PHP Application Framework.
|
||||
# Copyright (C) 2001-2007 Loic d'Anterroches and contributors.
|
||||
#
|
||||
# Plume Framework is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Plume Framework 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 Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# ***** END LICENSE BLOCK ***** */
|
||||
|
||||
class Pluf_DB_Field_Password extends Pluf_DB_Field
|
||||
{
|
||||
public $type = 'varchar';
|
||||
|
||||
function formField($def, $form_field='Pluf_Form_Field_Varchar')
|
||||
{
|
||||
$def['widget'] = 'Pluf_Form_Widget_PasswordInput';
|
||||
return parent::formField($def, $form_field);
|
||||
}
|
||||
}
|
36
pluf/src/Pluf/DB/Field/Sequence.php
Normal file
36
pluf/src/Pluf/DB/Field/Sequence.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# This file is part of Plume Framework, a simple PHP Application Framework.
|
||||
# Copyright (C) 2001-2007 Loic d'Anterroches and contributors.
|
||||
#
|
||||
# Plume Framework is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Plume Framework 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 Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# ***** END LICENSE BLOCK ***** */
|
||||
|
||||
class Pluf_DB_Field_Sequence extends Pluf_DB_Field
|
||||
{
|
||||
public $type = 'sequence';
|
||||
|
||||
/**
|
||||
* It is never possible to manually set the id of a model, this
|
||||
* should be passed through the URL.
|
||||
*/
|
||||
function formField($def, $form_field='')
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
35
pluf/src/Pluf/DB/Field/Serialized.php
Normal file
35
pluf/src/Pluf/DB/Field/Serialized.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# This file is part of Plume Framework, a simple PHP Application Framework.
|
||||
# Copyright (C) 2001-2007 Loic d'Anterroches and contributors.
|
||||
#
|
||||
# Plume Framework is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Plume Framework 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 Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# ***** END LICENSE BLOCK ***** */
|
||||
|
||||
class Pluf_DB_Field_Serialized extends Pluf_DB_Field
|
||||
{
|
||||
public $type = 'text';
|
||||
|
||||
function formField($def, $form_field='Pluf_Form_Field_Varchar')
|
||||
{
|
||||
if (!isset($def['widget'])) {
|
||||
$def['widget'] = 'Pluf_Form_Widget_TextareaInput';
|
||||
}
|
||||
return parent::formField($def, $form_field);
|
||||
}
|
||||
}
|
71
pluf/src/Pluf/DB/Field/Slug.php
Normal file
71
pluf/src/Pluf/DB/Field/Slug.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# This file is part of Plume Framework, a simple PHP Application Framework.
|
||||
# Copyright (C) 2001-2010 Loic d'Anterroches and contributors.
|
||||
#
|
||||
# Plume Framework is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Plume Framework 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 Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/**
|
||||
* This field will automatically slugify its content.
|
||||
*
|
||||
* A slug is a short label for something, containing only letters,
|
||||
* numbers, underscores or hyphens. They're generally used in URLs.
|
||||
*
|
||||
* In your model, you can specify `max_length` in the `widget_attrs`
|
||||
* parameter. If `max_length` is not specified, Pluf will use a
|
||||
* default length of 50.
|
||||
*/
|
||||
class Pluf_DB_Field_Slug extends Pluf_DB_Field
|
||||
{
|
||||
public $type = 'varchar';
|
||||
|
||||
/**
|
||||
* @see Pluf_DB_Field::formField()
|
||||
*/
|
||||
function formField($def, $form_field = 'Pluf_Form_Field_Slug')
|
||||
{
|
||||
return parent::formField($def, $form_field);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a "URL friendly" version in lowercase.
|
||||
*
|
||||
* Define the words separator with the configuration
|
||||
* option <code>slug-separator</code>. Default to <code>-</code>.
|
||||
*
|
||||
* @param $value string Value to convert
|
||||
* @return string The slugify version.
|
||||
*/
|
||||
public static function slugify($value)
|
||||
{
|
||||
$separator = Pluf::f('slug-separator', '-');
|
||||
$value = Pluf_Text_UTF8::romanize(Pluf_Text_UTF8::deaccent($value));
|
||||
$value = preg_replace('#[^'.$separator.'\w]#u',
|
||||
$separator,
|
||||
mb_strtolower($value, Pluf::f('encoding', 'UTF-8')));
|
||||
|
||||
// remove redundant
|
||||
$value = preg_replace('#'.$separator.'{2,}#u',
|
||||
$separator,
|
||||
trim($value, $separator));
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
}
|
35
pluf/src/Pluf/DB/Field/Text.php
Normal file
35
pluf/src/Pluf/DB/Field/Text.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# This file is part of Plume Framework, a simple PHP Application Framework.
|
||||
# Copyright (C) 2001-2007 Loic d'Anterroches and contributors.
|
||||
#
|
||||
# Plume Framework is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Plume Framework 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 Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# ***** END LICENSE BLOCK ***** */
|
||||
|
||||
class Pluf_DB_Field_Text extends Pluf_DB_Field
|
||||
{
|
||||
public $type = 'text';
|
||||
|
||||
function formField($def, $form_field='Pluf_Form_Field_Varchar')
|
||||
{
|
||||
if (!isset($def['widget'])) {
|
||||
$def['widget'] = 'Pluf_Form_Widget_TextareaInput';
|
||||
}
|
||||
return parent::formField($def, $form_field);
|
||||
}
|
||||
}
|
27
pluf/src/Pluf/DB/Field/Varchar.php
Normal file
27
pluf/src/Pluf/DB/Field/Varchar.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# This file is part of Plume Framework, a simple PHP Application Framework.
|
||||
# Copyright (C) 2001-2007 Loic d'Anterroches and contributors.
|
||||
#
|
||||
# Plume Framework is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Plume Framework 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 Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# ***** END LICENSE BLOCK ***** */
|
||||
|
||||
class Pluf_DB_Field_Varchar extends Pluf_DB_Field
|
||||
{
|
||||
public $type = 'varchar';
|
||||
}
|
Reference in New Issue
Block a user