1
0
mirror of https://github.com/monstra-cms/monstra.git synced 2025-08-04 04:07:59 +02:00

Update Gelato to 1.0.3

This commit is contained in:
Awilum
2013-04-04 19:03:37 +03:00
parent f4f699b73a
commit ee1fd08621
4 changed files with 69 additions and 3 deletions

View File

@@ -18,7 +18,7 @@
/**
* The version of Gelato
*/
define('GELATO_VERSION', '1.0.2');
define('GELATO_VERSION', '1.0.3');
/**
* Define __DIR__ constant for PHP 5.2.x

View File

@@ -28,6 +28,13 @@ class Html
'accept', 'tabindex', 'accesskey', 'alt', 'title', 'class',
'style', 'selected', 'checked', 'readonly', 'disabled',
);
/**
* The registered custom macros.
*
* @var array
*/
public static $macros = array();
/**
* Protected constructor since this is a static class.
@@ -279,7 +286,56 @@ class Html
$attributes['alt'] = (isset($attributes['alt'])) ? $attributes['alt'] : pathinfo($file, PATHINFO_FILENAME);
return '<img'.Html::attributes($attributes).' />';
}
}
/**
* Obfuscate an e-mail address to prevent spam-bots from sniffing it.
*
* <code>
* echo Html::email('gelato@monstra.org');
* </code>
*
* @param string $email
* @return string
*/
public static function email($email)
{
return str_replace('@', '&#64;', Html::obfuscate($email));
}
/**
* Obfuscate a string to prevent spam-bots from sniffing it.
*
* This method obfuscate the value, randomly convert each
* letter to its entity or hexadecimal representation, keeping a
* bot from sniffing the randomly obfuscated letters.
*
* <code>
* echo Html::obfuscate('gelato@monstra.org');
* </code>
*
* @param string $value
* @return string
*/
public static function obfuscate($value)
{
$safe = '';
foreach (str_split($value) as $letter) {
switch (rand(1, 3)) {
case 1:
$safe .= '&#'.ord($letter).';';
break;
case 2:
$safe .= '&#x'.dechex(ord($letter)).';';
break;
case 3:
$safe .= $letter;
}
}
return $safe;
}
/**
* Convert html to plain text

View File

@@ -4,6 +4,6 @@ Gelato is a PHP5 library for kickass Web Applications.
## Links
- [Site](http://gelato.monstra.org)
- [Github Repository](https://github.com/Monstra/gelato)
- [Github Repository](https://github.com/MonstrLab/gelato)
Copyright (C) 2013 Romanenko Sergey / Awilum [awilum@msn.com]

View File

@@ -1,3 +1,13 @@
Gelato 1.0.3, 2013-04-03
------------------------
- Html Class: obfuscate() method added.
- Html Class: email() method added.
- Html Class: missing $macros var added.
Gelato 1.0.2, 2013-03-17
------------------------
- Added support for PHP 5.2.3
Gelato 1.0.1, 2013-03-05
------------------------
- New constant GELATO_CLASS_LOADER instead of GELATO_AUTOLOADER