/** * Process a string to a string without whitespaces or special characters * * @param string $input * @return string */ public static function mangle($input) { // Create an array with words that need to be stripped $elim = "en:van:bij:tot:u:uw:de:een:door:voor:het:in:is:et:la:le:un:une:du:n:est:ce:ca:par:les:d:a:l:op:sur:des:mijn:mon"; $kill = explode(":", $elim); $ss = preg_replace(array("/&/", "/&/", "/\\?/", "/'/", '/"/', "/`/", "/'/", "/’/", "/’/", "/’/"), " ", $input); $ss = preg_replace("/@/", " at ", $ss); // iso2ascii must be done prior to strtolower to avoid problems due to encoding $ss = One_Form_Helper::iso2ascii($ss); // 20080922 TR removed lowercasing because of saving-problems with tablenames with uppercase letters // $ss = strtolower($ss)." "; // Replace unacceptable characters // $ss = preg_replace("@&#(\d+);@e", 'chr(\1)', $ss); // $ss = preg_replace("@(&\w+;)@e", 'html_entity_decode("\1")', $ss); $ss = preg_replace_callback("@&#(\\d+);@", function ($m) { return chr($m[1]); }, $ss); $ss = preg_replace_callback("@(&\\w+;)@", function ($m) { return html_entity_decode($m[1]); }, $ss); $ss = preg_replace("/\\W/", " ", $ss); // Strip earlier defined words foreach ($kill as $w) { $ss = preg_replace("/(^|\\s){$w}\\s/", " ", $ss); } $ss = preg_replace("/(\\s)+/", "_", trim($ss)); if (substr($ss, strlen($ss) - 1, 1) == "_") { $ss = substr($ss, 0, strlen($ss) - 1); } return $ss; }
/** * Class constructor * * @param array $config */ public function __construct(array $config = array()) { parent::__construct('token', 'token', $config); $this->_type = 'token'; $value = One_Form_Helper::createToken(); $_SESSION['OneToken'] = $value; $this->token = $_SESSION['OneToken']; }
/** * Set the name of this widget * * @return string */ public function setName($name) { $this->_originalName = $name; $this->_name = One_Form_Helper::mangle(trim($name)); }
/** * Mangle the input given, take out all special characters, lowercasing, ... * @param string $input * @return string */ public static function mangle($input) { return One_Form_Helper::mangle($input); }