[Beeframework-svn] SF.net SVN: beeframework:[135] trunk/framework/Bee
Brought to you by:
b_hartmann,
m_plomer
From: <m_p...@us...> - 2014-01-19 14:14:31
|
Revision: 135 http://sourceforge.net/p/beeframework/code/135 Author: m_plomer Date: 2014-01-19 14:14:28 +0000 (Sun, 19 Jan 2014) Log Message: ----------- - removed old Potiscom dependencies - added slug method to string utils - some minor cleanup Modified Paths: -------------- trunk/framework/Bee/MVC/Model.php trunk/framework/Bee/Security/Helper.php trunk/framework/Bee/Utils/Strings.php Modified: trunk/framework/Bee/MVC/Model.php =================================================================== --- trunk/framework/Bee/MVC/Model.php 2013-11-26 06:51:53 UTC (rev 134) +++ trunk/framework/Bee/MVC/Model.php 2014-01-19 14:14:28 UTC (rev 135) @@ -36,8 +36,6 @@ self::$modelValues = array_merge(self::$modelValues, $values); } - - /** * Add a single value to the model under the given key * @@ -48,8 +46,6 @@ self::$modelValues[$key] = $value; } - - /** * Clear the model, removing all * Modified: trunk/framework/Bee/Security/Helper.php =================================================================== --- trunk/framework/Bee/Security/Helper.php 2013-11-26 06:51:53 UTC (rev 134) +++ trunk/framework/Bee/Security/Helper.php 2014-01-19 14:14:28 UTC (rev 135) @@ -121,52 +121,7 @@ } return $auth; } - - /** - * @param $identityName - * @return mixed - * @throws Bee_Security_Exception_Authentication - */ - public static function getIdentity($identityName) { - $auth = self::$userDetailsService->getGroupByName($identityName); - if ($auth instanceof Potiscom_Auth_Doctrine_Group) { - return $auth; - } - $auth = self::$userDetailsService->getUserByName($identityName); - if ($auth instanceof Potiscom_Auth_Doctrine_User) { - return $auth; - } - throw new Bee_Security_Exception_Authentication('Not authenticated'); - } - - /** - * @param $identityName - * @param $configAttribute - * @param null $secureObject - * @return bool - */ - public static function checkAccessForIdentity($identityName, $configAttribute, $secureObject = null) { - $identity = self::getIdentity($identityName); - $auth = new Bee_Security_UsernamePasswordAuthenticationToken($username, $password); - self::$accessDecisionManager->decide($auth, $secureObject, new Bee_Security_ConfigAttributeDefinition($configAttribute)); - return true; - } - - /** - * @param $identityName - * @param $configAttribute - * @param null $secureObject - * @param null $returnedObject - * @return mixed - */ - public static function checkResultAccessForIdentity($identityName, $configAttribute, $secureObject = null, $returnedObject = null) { - $auth = self::getIdentity($identityName); - return self::$afterInvocationProviderManager->decide($auth, $secureObject, new Bee_Security_ConfigAttributeDefinition($configAttribute), $returnedObject); - } - } class SEC extends Bee_Security_Helper { -} - -?> \ No newline at end of file +} \ No newline at end of file Modified: trunk/framework/Bee/Utils/Strings.php =================================================================== --- trunk/framework/Bee/Utils/Strings.php 2013-11-26 06:51:53 UTC (rev 134) +++ trunk/framework/Bee/Utils/Strings.php 2014-01-19 14:14:28 UTC (rev 135) @@ -23,6 +23,16 @@ */ class Bee_Utils_Strings { + public static $DEFAULT_ASCII_REPLACEMENTS_TABLE = array( + 'ä' => 'ae', + 'ö' => 'oe', + 'ü' => 'ue', + 'Ä' => 'Ae', + 'Ö' => 'Oe', + 'Ü' => 'Ue', + 'ß' => 'ss' + ); + /** * Enter description here... * @@ -191,4 +201,26 @@ $sufTest = substr($string, (-strlen($suffix))); return $sufTest === $string || $sufTest === false ? "" === $suffix : $sufTest === $suffix; } + + /** + * Creates ascii-slug from any string. Make sure iconv is installed and setLocale() is called before using this + * E.g. setlocale(LC_ALL, 'en_US.UTF8'); + * + * @param $string + * @param array $table + * @param string $delimiter + * @param bool $toLowercase + * + * @return string + */ + public static function toAscii($string, $table=array(), $delimiter='-', $toLowercase=true) { + if (count($table)>0) { + $string = strtr($string, $table); + } + $ascii = iconv('UTF-8', 'ASCII//TRANSLIT', $string); + $ascii = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $ascii); + $ascii = trim($ascii, '-'); + $ascii = preg_replace("/[\/_|+ -]+/", $delimiter, $ascii); + return $toLowercase ? strtolower($ascii) : $ascii; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |