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; }
/** * 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; }
function Pluf_DB_SlugToDB($val, $db) { return $db->esc(Pluf_DB_Field_Slug::slugify($val)); }