Example #1
0
 function testSlugifyWithCustomSeparator()
 {
     $backup = $GLOBALS['_PX_config'];
     $GLOBALS['_PX_config']['slug-separator'] = '_';
     $slug = Pluf_DB_Field_Slug::slugify('ceondo pluf');
     $this->assertEqual('ceondo_pluf', $slug);
     $slug = Pluf_DB_Field_Slug::slugify('ceondo   pluf');
     $this->assertEqual('ceondo_pluf', $slug);
     $GLOBALS['_PX_config'] = $backup;
 }
Example #2
0
 /**
  * Removes any character not allowed and valid the size of the field.
  *
  * @see Pluf_Form_Field::clean()
  * @throws Pluf_Form_Invalid If the lenght of the field has not a valid size.
  */
 public function clean($value)
 {
     parent::clean($value);
     if ($value) {
         $value = Pluf_DB_Field_Slug::slugify($value);
         $len = mb_strlen($value, Pluf::f('encoding', 'UTF-8'));
         if ($this->max_size < $len) {
             throw new Pluf_Form_Invalid(sprintf($this->_error_messages['max_size'], $this->max_size, $len));
         }
         if ($this->min_size > $len) {
             throw new Pluf_Form_Invalid(sprintf($this->_error_messages['min_size'], $this->min_size, $len));
         }
     } else {
         $value = '';
     }
     return $value;
 }
Example #3
0
File: DB.php Project: burbuja/pluf
function Pluf_DB_SlugToDB($val, $db)
{
    return $db->esc(Pluf_DB_Field_Slug::slugify($val));
}