当前位置: 首页>>代码示例>>PHP>>正文


PHP Spoon::getCharset方法代码示例

本文整理汇总了PHP中Spoon::getCharset方法的典型用法代码示例。如果您正苦于以下问题:PHP Spoon::getCharset方法的具体用法?PHP Spoon::getCharset怎么用?PHP Spoon::getCharset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Spoon的用法示例。


在下文中一共展示了Spoon::getCharset方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getValue

 /**
  * Retrieve the initial or submitted value.
  *
  * @return	string
  */
 public function getValue()
 {
     // redefine default value
     $value = $this->value;
     // form submitted
     if ($this->isSubmitted()) {
         // post/get data
         $data = $this->getMethod(true);
         // submitted by post (may be empty)
         if (isset($data[$this->getName()])) {
             $value = $data[$this->getName()];
             $value = is_array($value) ? 'Array' : (string) $value;
             // maximum length?
             if (isset($this->attributes['maxlength']) && $this->attributes['maxlength'] > 0) {
                 $value = mb_substr($value, 0, (int) $this->attributes['maxlength'], Spoon::getCharset());
             }
         }
     }
     return $value;
 }
开发者ID:jeroendesloovere,项目名称:library,代码行数:25,代码来源:password.php

示例2: getValue

 /**
  * Retrieve the initial or submitted value.
  *
  * @param	bool[optional] $allowHTML	Is HTML allowed?
  * @return	string
  */
 public function getValue($allowHTML = null)
 {
     // redefine default value
     $value = $this->value;
     // added to form
     if ($this->isSubmitted()) {
         // post/get data
         $data = $this->getMethod(true);
         // submitted by post/get (may be empty)
         if (isset($data[$this->attributes['name']])) {
             // value
             $value = $data[$this->getName()];
             $value = is_scalar($value) ? (string) $value : 'Array';
             if (!$allowHTML) {
                 $value = Spoon::getCharset() == 'utf-8' ? SpoonFilter::htmlspecialchars($value) : SpoonFilter::htmlentities($value);
             }
         }
     }
     return $value;
 }
开发者ID:jeroendesloovere,项目名称:library,代码行数:26,代码来源:hidden.php

示例3: dump

 /**
  * Dumps the output of a variable in a more readable manner.
  *
  * @param	mixed $var				The variable to dump.
  * @param	bool[optional] $exit	Should the code stop here?
  */
 public static function dump($var, $exit = true)
 {
     ob_start();
     var_dump($var);
     $output = ob_get_clean();
     // Make sure var_dump is not overridden by Xdebug before tweaking its output.
     // Note that all truthy INI values ("On", "true", 1) are returned as "1" by ini_get().
     $hasXdebugVarDump = extension_loaded('xdebug') && ini_get('xdebug.overload_var_dump') === '1';
     if (!$hasXdebugVarDump) {
         $output = preg_replace('/\\]\\=\\>\\n(\\s+)/m', '] => ', $output);
         $output = '<pre>' . htmlspecialchars($output, ENT_QUOTES, Spoon::getCharset()) . '</pre>';
     }
     echo $output;
     if ($exit) {
         exit;
     }
 }
开发者ID:jeroendesloovere,项目名称:library,代码行数:23,代码来源:spoon.php

示例4: parseForms

    /**
     * Parse the forms.
     *
     * @return	string				The updated content, containing the parsed form tags.
     * @param	string $content		The content that may contain the form tags.
     */
    protected function parseForms($content)
    {
        // regex pattern
        $pattern = '/\\{form:([a-z0-9_]+?)\\}?/siU';
        // find matches
        if (preg_match_all($pattern, $content, $matches)) {
            // loop matches
            foreach ($matches[1] as $name) {
                // init vars
                $search = array();
                $replace = array();
                // start & close tag
                $search = array('{form:' . $name . '}', '{/form:' . $name . '}');
                // using UTF-8 as charset
                if (Spoon::getCharset() == 'utf-8') {
                    $replace[0] = '<?php
					if(isset($this->forms[\'' . $name . '\']))
					{
						?><form accept-charset="UTF-8" action="<?php echo $this->forms[\'' . $name . '\']->getAction(); ?>" method="<?php echo $this->forms[\'' . $name . '\']->getMethod(); ?>"<?php echo $this->forms[\'' . $name . '\']->getParametersHTML(); ?>>
						<?php echo $this->forms[\'' . $name . '\']->getField(\'form\')->parse();
						if($this->forms[\'' . $name . '\']->getUseToken())
						{
							?><input type="hidden" name="form_token" id="<?php echo $this->forms[\'' . $name . '\']->getField(\'form_token\')->getAttribute(\'id\'); ?>" value="<?php echo htmlspecialchars($this->forms[\'' . $name . '\']->getField(\'form_token\')->getValue()); ?>" />
						<?php } ?>';
                } else {
                    $replace[0] = '<?php
					if(isset($this->forms[\'' . $name . '\']))
					{
						?><form action="<?php echo $this->forms[\'' . $name . '\']->getAction(); ?>" method="<?php echo $this->forms[\'' . $name . '\']->getMethod(); ?>"<?php echo $this->forms[\'' . $name . '\']->getParametersHTML(); ?>>
						<?php echo $this->forms[\'' . $name . '\']->getField(\'form\')->parse();
						if($this->forms[\'' . $name . '\']->getUseToken())
						{
							?><input type="hidden" name="form_token" id="<?php echo $this->forms[\'' . $name . '\']->getField(\'form_token\')->getAttribute(\'id\'); ?>" value="<?php echo htmlentities($this->forms[\'' . $name . '\']->getField(\'form_token\')->getValue()); ?>" />
						<?php } ?>';
                }
                $replace[1] = '</form>
				<?php } ?>';
                $content = str_replace($search, $replace, $content);
            }
        }
        return $content;
    }
开发者ID:jeroendesloovere,项目名称:library,代码行数:48,代码来源:compiler.php

示例5: uppercase

 /**
  * Transform the string to uppercase.
  *
  * @return	string			The string, completly uppercased.
  * @param	string $string	The string that you want to apply this method on.
  */
 public static function uppercase($string)
 {
     return mb_convert_case($string, MB_CASE_UPPER, Spoon::getCharset());
 }
开发者ID:jeroendesloovere,项目名称:library,代码行数:10,代码来源:modifiers.php

示例6: getValue

 /**
  * Retrieve the initial or submitted value.
  *
  * @return	string
  * @param	bool[optional] $allowHTML	Is HTML allowed?
  */
 public function getValue($allowHTML = null)
 {
     // redefine html & default value
     $allowHTML = $allowHTML !== null ? (bool) $allowHTML : $this->isHTML;
     $value = $this->value;
     // contains html
     if ($this->isHTML) {
         // set value
         $value = Spoon::getCharset() == 'utf-8' ? SpoonFilter::htmlspecialchars($value) : SpoonFilter::htmlentities($value);
     }
     // form submitted
     if ($this->isSubmitted()) {
         // post/get data
         $data = $this->getMethod(true);
         // submitted by post (may be empty)
         if (isset($data[$this->getName()])) {
             // value
             $value = isset($data[$this->getName()]) ? $data[$this->getName()] : '';
             if (is_array($value)) {
                 $value = 'Array';
             }
             // maximum length?
             if (isset($this->attributes['maxlength']) && $this->attributes['maxlength'] > 0) {
                 $value = mb_substr($value, 0, (int) $this->attributes['maxlength'], Spoon::getCharset());
             }
             // html allowed?
             if (!$allowHTML) {
                 $value = Spoon::getCharset() == 'utf-8' ? SpoonFilter::htmlspecialchars($value) : SpoonFilter::htmlentities($value);
             }
         }
     }
     return $value;
 }
开发者ID:jeroendesloovere,项目名称:library,代码行数:39,代码来源:textarea.php

示例7: setCharset

 /**
  * Changes the charset from standard utf-8 to your preferred value.
  *
  * @param	string[optional] $charset	The charset to use, default is utf-8.
  */
 public function setCharset($charset = 'utf-8')
 {
     $this->charset = $charset !== null ? SpoonFilter::getValue($charset, Spoon::getCharsets(), Spoon::getCharset()) : Spoon::getCharset();
 }
开发者ID:jeroendesloovere,项目名称:library,代码行数:9,代码来源:email.php

示例8: urlise

 /**
  * Prepares a string so that it can be used in urls.
  *
  * @return	string						The urlised string.
  * @param	string $value				The value that should be urlised.
  * @param	string[optional] $charset	The charset to use, default is based on Spoon::getCharset().
  */
 public static function urlise($value, $charset = null)
 {
     // define charset
     $charset = $charset !== null ? self::getValue($charset, Spoon::getCharsets(), Spoon::getCharset()) : Spoon::getCharset();
     // reserved characters (RFC 3986)
     $reservedCharacters = array('/', '?', ':', '@', '#', '[', ']', '!', '$', '&', '\'', '(', ')', '*', '+', ',', ';', '=');
     // remove reserved characters
     $value = str_replace($reservedCharacters, ' ', $value);
     // replace double quote, since this one might cause problems in html (e.g. <a href="double"quote">)
     $value = str_replace('"', ' ', $value);
     // replace spaces by dashes
     $value = str_replace(' ', '-', $value);
     // only urlencode if not yet urlencoded
     if (urldecode($value) == $value) {
         // to lowercase
         $value = mb_strtolower($value, $charset);
         // urlencode
         $value = urlencode($value);
     }
     // convert "--" to "-"
     $value = preg_replace('/\\-+/', '-', $value);
     // trim - signs
     return trim($value, '-');
 }
开发者ID:jeroendesloovere,项目名称:library,代码行数:31,代码来源:filter.php

示例9: getMethod

 /**
  * Retrieve the method post/get.
  *
  * @return	string
  */
 public function getMethod()
 {
     // prevent against xss
     $method = Spoon::getCharset() == 'utf-8' ? SpoonFilter::htmlspecialchars($this->method) : SpoonFilter::htmlentities($this->method);
     return $method;
 }
开发者ID:jeroendesloovere,项目名称:library,代码行数:11,代码来源:form.php

示例10: lowercase

 /**
  * Makes this string lowercase.
  *    syntax: {{ $string|lowercase }}.
  *
  *
  * @param string $string The string that you want to apply this method on.
  *
  * @return string The string, completely lowercased.
  */
 public static function lowercase($string)
 {
     return mb_convert_case($string, MB_CASE_LOWER, \Spoon::getCharset());
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:13,代码来源:BaseTwigModifiers.php


注:本文中的Spoon::getCharset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。