コード例 #1
0
ファイル: SafeHtml.php プロジェクト: packaged/glimpse
 public static function escape($string, $arrayGlue = ' ')
 {
     if ($string instanceof SafeHtml) {
         return $string;
     } else {
         if ($string instanceof ISafeHtmlProducer) {
             $result = $string->produceSafeHTML();
             if ($result instanceof SafeHtml) {
                 return $result;
             } else {
                 if (is_array($result)) {
                     return self::escape($result, $arrayGlue);
                 } else {
                     if ($result instanceof ISafeHtmlProducer) {
                         return self::escape($result, $arrayGlue);
                     } else {
                         try {
                             Strings::stringable($result);
                             return self::escape((string) $result);
                         } catch (\Exception $ex) {
                             $class = get_class($string);
                             throw new \Exception("Object (of class '{$class}') implements " . "ISafeHTMLProducer but did not return anything " . "renderable from produceSafeHTML().");
                         }
                     }
                 }
             }
         } else {
             if (is_array($string)) {
                 return implode($arrayGlue, array_map(['\\Packaged\\Glimpse\\Core\\SafeHtml', 'escape'], $string));
             }
         }
     }
     return Strings::escape($string);
 }
コード例 #2
0
 /**
  * Escape HTML String
  *
  * @param $string
  *
  * @return string
  *
  * @deprecated
  */
 function esc($string)
 {
     return \Packaged\Helpers\Strings::escape($string);
 }
コード例 #3
0
ファイル: FormElementRenderer.php プロジェクト: packaged/form
 public function renderTextarea(FormElement $element)
 {
     $out = '<textarea';
     $out .= $this->_renderAttributes($element);
     $out .= '>';
     $out .= Strings::escape($element->getValue());
     $out .= '</textarea>';
     return $out;
 }
コード例 #4
0
ファイル: StringsTest.php プロジェクト: PaulAntunes/gclf-paul
 public function testEscape()
 {
     $expectations = [['Strings', "Strings"], ['Stri"ngs', "Stri&quot;ngs"], ['Stri\'ngs', "Stri&#039;ngs"]];
     foreach ($expectations as $expect) {
         $this->assertEquals($expect[1], Strings::escape($expect[0]));
     }
 }