/**
* 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;
    }
}
 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;
 }
 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;
 }
    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;
    }
Example #5
0
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));