Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Capitalize per caratteri italiani

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: Italian
View previous topic :: View next topic  
Author Message
devilmark84
Smarty n00b


Joined: 21 Feb 2008
Posts: 4

PostPosted: Thu Feb 21, 2008 10:49 am    Post subject: Capitalize per caratteri italiani Reply with quote

si presuppone che a questa funzione venga passata una stringa con entità html e questa restituisce la stringa capitalizzata con entità html.
Code:
function smarty_modifier_capitalize($string, $uc_digits = false)
{
    smarty_modifier_capitalize_ucfirst(null, $uc_digits);
    return htmlentities(preg_replace_callback('!\'?\b\w(\w|\')*\b!', 'smarty_modifier_capitalize_ucfirst', html_entity_decode($string,ENT_QUOTES)),ENT_QUOTES);
}

function smarty_modifier_capitalize_ucfirst($string, $uc_digits = null)
{
    static $_uc_digits = false;
   
    if(isset($uc_digits)) {
        $_uc_digits = $uc_digits;
        return;
    }
   
    if(substr($string[0],0,1) != "'" && !preg_match("!\d!",$string[0]) || $_uc_digits)
        return ucfirst($string[0]);
    else
        return $string[0];
}



Il testo restituito può essere inserito sia nel value di un input type (tra ""), sia nelle textarea.

Spero di avere fatto cosa gradita agli utilizzatori di smarty italiani.
Back to top
View user's profile Send private message
raoh980
Smarty Rookie


Joined: 13 May 2008
Posts: 7

PostPosted: Tue May 13, 2008 10:26 pm    Post subject: Reply with quote

Grazie !
Back to top
View user's profile Send private message
flatfield
Smarty Rookie


Joined: 30 Apr 2007
Posts: 18
Location: Genova (Italy)

PostPosted: Fri May 23, 2008 4:07 pm    Post subject: Reply with quote

Buono!!
Se puoi fai un esempio di utilizzo, con esempio di chiamata e l'output che produrrebbe
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: Italian All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP