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


PHP javascriptEscape函数代码示例

本文整理汇总了PHP中javascriptEscape函数的典型用法代码示例。如果您正苦于以下问题:PHP javascriptEscape函数的具体用法?PHP javascriptEscape怎么用?PHP javascriptEscape使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: quoteText

/**
* Quotes a translation according to purpose
* if sEscapeMode is null, we use HTML method because probably we had to specify null as sEscapeMode upstream
*
* @param mixed $sText Text to quote
* @param string $sEscapeMode Optional - One of the values 'html','js' or 'unescaped' - defaults to 'html'
*/
function quoteText($sText, $sEscapeMode = 'html')
{
    if ($sEscapeMode === null) {
        $sEscapeMode = 'html';
    }
    switch ($sEscapeMode) {
        case 'html':
            return HTMLEscape($sText);
            break;
        case 'js':
            return javascriptEscape($sText);
            break;
        case 'unescaped':
            return $sText;
            break;
        default:
            return "Unsupported EscapeMode in gT method";
            break;
    }
}
开发者ID:GuillaumeSmaha,项目名称:LimeSurvey,代码行数:27,代码来源:common_helper.php

示例2: _showSpeaker

 private function _showSpeaker($hinttext)
 {
     global $max;
     $clang = Yii::app()->lang;
     $imageurl = Yii::app()->getConfig("adminimageurl");
     if (!isset($max)) {
         $max = 20;
     }
     $htmlhinttext = str_replace("'", ''', $hinttext);
     //the string is already HTML except for single quotes so we just replace these only
     $jshinttext = javascriptEscape($hinttext, true, true);
     if (strlen(html_entity_decode($hinttext, ENT_QUOTES, 'UTF-8')) > $max + 3) {
         $shortstring = flattenText($hinttext, true);
         $shortstring = htmlspecialchars(mb_strcut(html_entity_decode($shortstring, ENT_QUOTES, 'UTF-8'), 0, $max, 'UTF-8'));
         //output with hoover effect
         $reshtml = "<span style='cursor: hand' alt='" . $htmlhinttext . "' title='" . $htmlhinttext . "' " . " onclick=\"alert('" . $clang->gT("Question", "js") . ": {$jshinttext}')\" />" . " \"{$shortstring}...\" </span>" . "<img style='cursor: hand' src='{$imageurl}/speaker.png' align='bottom' alt='{$htmlhinttext}' title='{$htmlhinttext}' " . " onclick=\"alert('" . $clang->gT("Question", "js") . ": {$jshinttext}')\" />";
     } else {
         $shortstring = flattenText($hinttext, true);
         $reshtml = "<span title='" . $shortstring . "'> \"{$shortstring}\"</span>";
     }
     return $reshtml;
 }
开发者ID:ryu1inaba,项目名称:LimeSurvey,代码行数:22,代码来源:conditionsaction.php

示例3: _showSpeaker

 public static function _showSpeaker($hinttext)
 {
     global $maxchars;
     //Where does this come from? can it be replaced? passed with function call?
     if (!isset($maxchars)) {
         $maxchars = 70;
     }
     $htmlhinttext = str_replace("'", '&#039;', $hinttext);
     //the string is already HTML except for single quotes so we just replace these only
     $jshinttext = javascriptEscape($hinttext, true, true);
     //Build a javascript safe version of the string
     if (strlen($hinttext) > $maxchars) {
         $shortstring = flattenText($hinttext);
         $shortstring = htmlspecialchars(mb_strcut(html_entity_decode($shortstring, ENT_QUOTES, 'UTF-8'), 0, $maxchars, 'UTF-8'));
         $sTextToShow = gT("Question", "js") . ': ' . $jshinttext;
         $reshtml = '<span>' . $shortstring . '...</span>';
         $reshtml .= '<span  class="show_speaker icon-assessments text-success" style="cursor: pointer" title="' . $sTextToShow . '"  data-toggle="tooltip" data-placement="bottom"  >';
         $reshtml .= '</span>';
     } else {
         $reshtml = "<span style='cursor: pointer' title='" . $htmlhinttext . "'> \"{$htmlhinttext}\"</span>";
     }
     return $reshtml;
 }
开发者ID:mfavetti,项目名称:LimeSurvey,代码行数:23,代码来源:statistics_helper.php

示例4: _showSpeaker

    function _showSpeaker($hinttext)
    {
        global $maxchars; //Where does this come from? can it be replaced? passed with function call?
        
        $sImageURL = Yii::app()->getConfig('adminimageurl');
        if(!isset($maxchars))
        {
            $maxchars = 100;
        }
        $htmlhinttext=str_replace("'",'&#039;',$hinttext);  //the string is already HTML except for single quotes so we just replace these only
        $jshinttext=javascriptEscape($hinttext,true,true);  //Build a javascript safe version of the string

        if(strlen($hinttext) > ($maxchars))
        {
            $shortstring = flattenText($hinttext);

            $shortstring = htmlspecialchars(mb_strcut(html_entity_decode($shortstring,ENT_QUOTES,'UTF-8'), 0, $maxchars, 'UTF-8'));

            //output with hoover effect
            $reshtml= "<span style='cursor: pointer' title='".$htmlhinttext."' "
            ." onclick=\"alert('".gT("Question","js").": $jshinttext')\">"
            ." \"$shortstring...\" </span>"
            ."<img style='cursor: pointer' src='$sImageURL/speaker.png' align='bottom' alt='$htmlhinttext' title='$htmlhinttext' "
            ." onclick=\"alert('".gT("Question","js").": $jshinttext')\" />";
        }
        else
        {
            $reshtml= "<span style='cursor: pointer' title='".$htmlhinttext."'> \"$htmlhinttext\"</span>";
        }
        return $reshtml;
    }
开发者ID:jgianpiere,项目名称:lime-survey,代码行数:31,代码来源:statistics_view.php

示例5: javascriptEscape

function javascriptEscape($value)
{
    $search = array("\\", "", "\n", "\r", "'", '"', "", "/");
    $replace = array("\\\\", "\\0", "\\n", "\\r", "\\'", '\\"', "\\Z", "\\/");
    return str_replace($search, $replace, $value);
}
function singleQuotes($value)
{
    return str_replace("\"", "'", $value);
}
function protocollLess($value)
{
    $search = array("https:", "http:", "ftp:");
    return str_replace($search, "", $value);
}
function lbr($value)
{
    $value = str_replace("://", "://\n", $value);
    return str_replace(".com", "\n.com", $value);
}
file_put_contents("urlencoded_2.txt", urlencode($string));
file_put_contents("urlencoded.txt", rawurlencode($string));
// file_put_contents("urlencoded.txt", encodeURI($string)); // Blah%20blah%20blah%20123%20%22http://kitdriver.com%22%20hello%20world.
file_put_contents("unicode.txt", escape($string));
file_put_contents("sql_escape.txt", mres($string));
file_put_contents("single_quotes.txt", singleQuotes($string));
file_put_contents("protocol_less.txt", protocollLess($string));
file_put_contents("javascript_escape.txt", javascriptEscape($string));
file_put_contents("normal.txt", $string);
file_put_contents("linebreaks.txt", lbr($string));
file_put_contents("html_escape.txt", htmlentities($string));
开发者ID:phpMussel,项目名称:extras,代码行数:31,代码来源:URLScannerTestFiles.php


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