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


PHP Zend_View_Abstract::escape方法代码示例

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


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

示例1: _replace

 /**
  * Does the hard work for preg_replace_callback() in self::filter()
  * 
  * @param string $matches
  * @return string
  */
 protected function _replace($matches)
 {
     if ($this->_view instanceof Zend_View_Abstract) {
         $href = $this->_view->escape($matches[0]);
     } else {
         $href = htmlspecialchars($matches[0]);
     }
     return '<a' . ' href="' . $href . '"' . (null !== $this->_class ? ' class="' . $this->_class . '"' : '') . ' target="_blank" rel="nofollow"' . '>' . $matches[0] . '</a>';
 }
开发者ID:febryantosulistyo,项目名称:ClassicSocial,代码行数:15,代码来源:EnableLinks.php

示例2: escape

 /**
  * Overwrite escape() method
  *
  * The next part is an overwrite of the escape() method from Zend_View_Abstract. It works both for string and array values and also uses the escape() method from the Zend_View_Abstract. The advantage of this is that I don't have to care about each value of an array to get properly escaped.
  *
  * @param mixed $var
  * @return mixed
  */
 public function escape($var)
 {
     if (is_string($var)) {
         return parent::escape($var);
     } elseif (is_array($var)) {
         foreach ($var as $key => $val) {
             $var[$key] = $this->escape($val);
         }
     }
     return $var;
 }
开发者ID:iLoiLohas,项目名称:pinchshopper,代码行数:19,代码来源:Smarty.php

示例3: renderArray

 /**
  * Renders the $content so that it can be used as output for the $view,
  * including output escaping and encoding correction.
  *
  * This functions handles \MUtil_Html_HtmlInterface and \MUtil_Lazy_LazyInterface
  * objects natively, as well as array, scalar values and objects with a
  * __toString function.
  *
  * Other objects a definition should have a render function in getClassRenderList().
  *
  * All Lazy variabables are raised.
  *
  * @param \Zend_View_Abstract $view
  * @param mixed $content Anything HtmlInterface, number, string, array, object with __toString
  *                      or an object that has a defined render function in getClassRenderList().
  * @return string Output to echo to the user
  */
 public function renderArray(\Zend_View_Abstract $view, $content, $glue = '', $stack = null)
 {
     // \MUtil_Echo::timeFunctionStart(__FUNCTION__);
     $output = array();
     // \MUtil_Echo::countOccurences('render');
     foreach ($content as $key => $value) {
         // Resolve first as this function as recursion heavy enough as it is.
         if ($value instanceof \MUtil_Lazy_LazyInterface) {
             if (!$stack) {
                 $stack = \MUtil_Lazy::getStack();
             }
             // \MUtil_Echo::countOccurences('lazyIf');
             while ($value instanceof \MUtil_Lazy_LazyInterface) {
                 // \MUtil_Echo::countOccurences('lazyWhile');
                 $value = $value->__toValue($stack);
             }
         }
         if (is_scalar($value)) {
             // \MUtil_Echo::countOccurences('scalar');
             // \MUtil_Echo::timeFunctionStart('escape2');
             $output[$key] = $view->escape((string) $value);
             // \MUtil_Echo::timeFunctionStop('escape2');
         } elseif ($value instanceof \MUtil_Html_HtmlInterface) {
             // \MUtil_Echo::countOccurences('interface');
             $output[$key] = $value->render($view);
         } elseif (null === $value) {
             // \MUtil_Echo::countOccurences('null');
         } elseif (is_array($value)) {
             // \MUtil_Echo::countOccurences('array');
             $output[$key] = self::renderAny($view, $value, '', $stack);
         } elseif (is_object($value)) {
             $function = $this->_classRenderFunctions->get($value);
             if ($function) {
                 // \MUtil_Echo::countOccurences('function');
                 $output[$key] = call_user_func($function, $view, $value);
             } elseif (method_exists($value, '__toString')) {
                 // \MUtil_Echo::countOccurences('toString');
                 // \MUtil_Echo::countOccurences('toString.' . get_class($value));
                 $output[$key] = $view->escape($value->__toString());
             } else {
                 // $output[$key] = 'WARNING: Object of type ' . get_class($value) . ' cannot be converted to string.';
                 throw new \MUtil_Html_HtmlException('WARNING: Object of type ' . get_class($value) . ' cannot be converted to string.');
             }
         } elseif ($value instanceof \__PHP_Incomplete_Class) {
             \MUtil_Echo::r($value, __CLASS__ . '->' . __FUNCTION__);
             $output[$key] = '';
         } else {
             // Mop up, should not occur
             // \MUtil_Echo::countOccurences('scalar else');
             $output[$key] = $view->escape((string) $value);
         }
     }
     if (false === $glue || null === $glue) {
         // \MUtil_Echo::timeFunctionStop(__FUNCTION__);
         return $output;
     }
     $output = implode($glue, $output);
     // \MUtil_Echo::timeFunctionStop(__FUNCTION__);
     return $output;
 }
开发者ID:GemsTracker,项目名称:MUtil,代码行数:77,代码来源:Renderer.php


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