Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Swift_FailoverTransport
  • Swift_LoadBalancedTransport
  • Swift_MailTransport
  • Swift_Plugins_Loggers_ArrayLogger
  • Swift_Plugins_Loggers_EchoLogger
  • Swift_SendmailTransport
  • Swift_SmtpTransport
  • Swift_Transport_AbstractSmtpTransport
  • Swift_Transport_Esmtp_Auth_CramMd5Authenticator
  • Swift_Transport_Esmtp_Auth_LoginAuthenticator
  • Swift_Transport_Esmtp_Auth_PlainAuthenticator
  • Swift_Transport_Esmtp_AuthHandler
  • Swift_Transport_EsmtpTransport
  • Swift_Transport_FailoverTransport
  • Swift_Transport_LoadBalancedTransport
  • Swift_Transport_MailTransport
  • Swift_Transport_SendmailTransport
  • Swift_Transport_SimpleMailInvoker
  • Swift_Transport_StreamBuffer

Interfaces

  • Swift_Plugins_Logger
  • Swift_Plugins_Pop_Pop3Exception
  • Swift_Transport
  • Swift_Transport_Esmtp_Authenticator
  • Swift_Transport_EsmtpHandler
  • Swift_Transport_IoBuffer
  • Swift_Transport_MailInvoker
  • Swift_Transport_SmtpAgent
  • Swift_TransportException
  • Overview
  • Package
  • Function
  • Todo
  • Download
 1: <?php
 2: /**
 3:  * Smarty plugin
 4:  *
 5:  * @package    Smarty
 6:  * @subpackage PluginsModifier
 7:  */
 8: 
 9: /**
10:  * Smarty capitalize modifier plugin
11:  * Type:     modifier<br>
12:  * Name:     capitalize<br>
13:  * Purpose:  capitalize words in the string
14:  * {@internal {$string|capitalize:true:true} is the fastest option for MBString enabled systems }}
15:  *
16:  * @param string  $string    string to capitalize
17:  * @param boolean $uc_digits also capitalize "x123" to "X123"
18:  * @param boolean $lc_rest   capitalize first letters, lowercase all following letters "aAa" to "Aaa"
19:  *
20:  * @return string capitalized string
21:  * @author Monte Ohrt <monte at ohrt dot com>
22:  * @author Rodney Rehm
23:  */
24: function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = false)
25: {
26:     if (Smarty::$_MBSTRING) {
27:         if ($lc_rest) {
28:             // uppercase (including hyphenated words)
29:             $upper_string = mb_convert_case($string, MB_CASE_TITLE, Smarty::$_CHARSET);
30:         } else {
31:             // uppercase word breaks
32:             $upper_string = preg_replace_callback("!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_mbconvert_cb', $string);
33:         }
34:         // check uc_digits case
35:         if (!$uc_digits) {
36:             if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches, PREG_OFFSET_CAPTURE)) {
37:                 foreach ($matches[1] as $match) {
38:                     $upper_string = substr_replace($upper_string, mb_strtolower($match[0], Smarty::$_CHARSET), $match[1], strlen($match[0]));
39:                 }
40:             }
41:         }
42:         $upper_string = preg_replace_callback("!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_mbconvert2_cb', $upper_string);
43:         return $upper_string;
44:     }
45: 
46:     // lowercase first
47:     if ($lc_rest) {
48:         $string = strtolower($string);
49:     }
50:     // uppercase (including hyphenated words)
51:     $upper_string = preg_replace_callback("!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_ucfirst_cb', $string);
52:     // check uc_digits case
53:     if (!$uc_digits) {
54:         if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches, PREG_OFFSET_CAPTURE)) {
55:             foreach ($matches[1] as $match) {
56:                 $upper_string = substr_replace($upper_string, strtolower($match[0]), $match[1], strlen($match[0]));
57:             }
58:         }
59:     }
60:     $upper_string = preg_replace_callback("!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_ucfirst2_cb', $upper_string);
61:     return $upper_string;
62: }
63: 
64: /* 
65:  *
66:  * Bug: create_function() use exhausts memory when used in long loops
67:  * Fix: use declared functions for callbacks instead of using create_function()
68:  * Note: This can be fixed using anonymous functions instead, but that requires PHP >= 5.3
69:  *
70:  * @author Kyle Renfrow
71:  */
72: function smarty_mod_cap_mbconvert_cb($matches)
73: {
74:     return stripslashes($matches[1]) . mb_convert_case(stripslashes($matches[2]), MB_CASE_UPPER, Smarty::$_CHARSET);
75: }
76: 
77: function smarty_mod_cap_mbconvert2_cb($matches)
78: {
79:     return stripslashes($matches[1]) . mb_convert_case(stripslashes($matches[3]), MB_CASE_UPPER, Smarty::$_CHARSET);
80: }
81: 
82: function smarty_mod_cap_ucfirst_cb($matches)
83: {
84:     return stripslashes($matches[1]) . ucfirst(stripslashes($matches[2]));
85: }
86: 
87: function smarty_mod_cap_ucfirst2_cb($matches)
88: {
89:     return stripslashes($matches[1]) . ucfirst(stripslashes($matches[3]));
90: }
91: 
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen