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


PHP javascript_escape函数代码示例

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


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

示例1: PhpArrayToJsObject_Recurse

function PhpArrayToJsObject_Recurse($array){
   // Base case of recursion: when the passed value is not a PHP array, just output it (in quotes).
   if(! is_array($array) && !is_object($array) ){
       // Handle null specially: otherwise it becomes "".
       if ($array === null)
       {
           return 'null';
       }      
       return '"' . javascript_escape($array) . '"';
   }  
   // Open this JS object.
   $retVal = "{";
   // Output all key/value pairs as "$key" : $value
   // * Output a JS object (using recursion), if $value is a PHP array.
   // * Output the value in quotes, if $value is not an array (see above).
   $first = true;
   foreach($array as $key => $value){
       // Add a comma before all but the first pair.
       if (! $first ){
           $retVal .= ', ';
       }
       $first = false;      
       // Quote $key if it's a string.
       if (is_string($key) ){
           $key = '"' . $key . '"';
       }	         
       $retVal .= $key . ' : ' . PhpArrayToJsObject_Recurse($value);
   }   
   // Close and return the JS object.
   return $retVal . "}";
}
开发者ID:BenoitTalbot,项目名称:bungeni-portal,代码行数:31,代码来源:mv_data_proxy.php

示例2: js_escape

function js_escape($str, $keep = true)
{
    $str = html_entity_decode(str_replace("\\", "", $str), ENT_QUOTES);
    if ($keep) {
        $str = javascript_escape($str);
    } else {
        $str = str_replace("'", " ", $str);
        $str = str_replace('"', " ", $str);
    }
    return $str;
    //end function js_escape
}
开发者ID:razorinc,项目名称:sugarcrm-example,代码行数:12,代码来源:utils.php

示例3: showSpeaker

function showSpeaker($hinttext)
{
    global $clang, $imageurl, $max;
    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 = javascript_escape($hinttext, true, true);
    if (strlen(html_entity_decode($hinttext, ENT_QUOTES, 'UTF-8')) > $max + 3) {
        $shortstring = FlattenText($hinttext);
        $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);
        $reshtml = "<span title='" . $shortstring . "'> \"{$shortstring}\"</span>";
    }
    return $reshtml;
}
开发者ID:ddrmoscow,项目名称:queXS,代码行数:20,代码来源:conditionshandling.php

示例4: while

        $result2 = $connection->query('SELECT * FROM category WHERE id = ' . $row['category_id']);
        if ($result2->num_rows > 0) {
            while ($row2 = $result2->fetch_assoc()) {
                $topic[$row['id']]['category_name'] = $row2['name'];
            }
        }
        $result2 = $connection->query('SELECT * FROM comments WHERE topic_id = ' . $row['id']);
        if ($result2->num_rows > 0) {
            while ($row2 = $result2->fetch_assoc()) {
                $comments[$row2['id']] = $row2;
                $comments[$row2['id']]['content'] = $bbcode->parseCaseInsensitive(nl2br($row2['content']));
                $comments[$row2['id']]['raw_content'] = javascript_escape($row2['content']);
                $result3 = $connection->query('SELECT * FROM users WHERE id = ' . $row2['author_id']);
                if ($result3->num_rows > 0) {
                    while ($row3 = $result3->fetch_assoc()) {
                        $comments[$row2['id']]['author_name'] = $row3['name'];
                        $comments[$row2['id']]['author_name_safe'] = javascript_escape($row3['name']);
                    }
                }
            }
        }
    }
}
$additional_topic_admin_buttons = array();
$additional_topic_admin_buttons = hook_filter('add_topic_admin_buttons', $additional_topic_admin_buttons);
$additional_stuff_before_comments = array();
$additional_stuff_before_comments = hook_filter('add_stuff_before_comments', $additional_stuff_before_comments);
$additional_stuff_before_topiccontent = array();
$additional_stuff_before_topiccontent = hook_filter('add_stuff_before_topic_content', $additional_stuff_before_topiccontent);
echo $twig->render('topic.twig', array('site_name' => BOARD_NAME, 'isAdmin' => $isAdmin, 'isLoggedIn' => $loggedIn, 'topic' => $topic, 'comments' => $comments, 'additional_topic_admin_buttons', $additional_topic_admin_buttons, 'before_comments' => $additional_stuff_before_comments, 'additional_stuff_before_topiccontent' => $additional_stuff_before_topiccontent, 'currentURL' => "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}"));
include_once 'include/footer.php';
开发者ID:admicos,项目名称:ffaboard,代码行数:31,代码来源:topic.php

示例5: google_map_js

    function google_map_js($atts)
    {
        extract(shortcode_atts(array('id' => 'map_canvas', 'coordinates' => '1, 1', 'zoom' => 15, 'height' => '350px', 'zoomcontrol' => 'false', 'scrollwheel' => 'false', 'scalecontrol' => 'false', 'disabledefaultui' => 'false', 'infobox' => '', 'satellite' => '', 'tilt' => '', 'icon' => theme() . '/images/marker.png', 'streetview' => ''), $atts));
        $mapid = str_replace('-', '_', $id);
        $map = !$streetview ? '<div class="googlemap" id="' . $id . '" ' . ($height ? 'style="height:' . $height . '"' : '') . '></div><script>
    var ' . $mapid . ';
    function initialize_' . $mapid . '() {
        var myLatlng = new google.maps.LatLng(' . $coordinates . ');
        var mapOptions = {
            ' . ($satellite ? 'mapTypeId: google.maps.MapTypeId.SATELLITE,' : '') . '
            zoom: ' . $zoom . ',
            center: myLatlng,
            zoomControl: ' . $zoomcontrol . ',
            scrollwheel: ' . $scrollwheel . ',
            scaleControl: ' . $scalecontrol . ',
            disableDefaultUI: ' . $disabledefaultui . '
        };
        var ' . $mapid . ' = new google.maps.Map(document.getElementById("' . $id . '"), mapOptions);
        ' . ($tilt ? $mapid . '.setTilt(45);' : '') . '
        var marker = new google.maps.Marker({
            position: myLatlng,
            map: ' . $mapid . ',
            ' . ($icon ? 'icon:"' . $icon . '",' : '') . '
            animation: google.maps.Animation.DROP
        });
        ' . ($infobox ? 'marker.info = new google.maps.InfoWindow({content: \'' . javascript_escape($infobox) . '\'});
        google.maps.event.addListener(marker, "click", function() {marker.info.open(' . $mapid . ', marker);});' : '') . '

        google.maps.event.addListener(' . $mapid . ', "center_changed", function() {
            window.setTimeout(function() {
                ' . $mapid . '.panTo(marker.getPosition());
            }, 15000);
        });
    };
    google.maps.event.addDomListener(window, "load", initialize_' . $mapid . ');
    </script>' : do_streetView_map($id, $coordinates, $height, $streetview);
        return $map;
    }
开发者ID:nengineer,项目名称:WP-Anatomy,代码行数:38,代码来源:shortcodes.php

示例6: in_array

     if ( isset($_SESSION['token']) &&
     in_array(strtolower($comparedtokenattr[1]),GetTokenConditionsFieldNames($surveyid)))
     {
         $comparedtokenattrValue = GetAttributeValue($surveyid,strtolower($comparedtokenattr[1]),$_SESSION['token']);
         //if (in_array($cd[4],array("A","B","K","N","5",":")) || (in_array($cd[4],array("Q",";")) && $cqidattributes['other_numbers_only']==1 ))
         if (in_array($cd[6],array("<","<=",">",">=")))
         { // // Numerical comparizons
             $java .= "$JSsourceElt != null && parseFloat($JSsourceVal) $cd[6] parseFloat('".javascript_escape($comparedtokenattrValue)."')";
         }
         elseif(preg_match("/^a(.*)b$/",$cd[6],$matchmethods))
         { // Strings comparizon
             $java .= "$JSsourceElt != null && $JSsourceVal ".$matchmethods[1]." '".javascript_escape($comparedtokenattrValue)."'";
         }
         else
         {
             $java .= "$JSsourceElt != null && $JSsourceVal $cd[6] '".javascript_escape($comparedtokenattrValue)."'";
         }
     }
     else
     {
         $java .= " 'impossible to evaluate tokenAttr' == 'tokenAttr'";
     }
 }
 else
 {
     if ($cd[6] == 'RX')
     {
         $java .= "$JSsourceElt != null  && match_regex($JSsourceVal,'$cd[3]')";
     }
     else
     {
开发者ID:nmklong,项目名称:limesurvey-cdio3,代码行数:31,代码来源:survey.php

示例7: preg_replace

    $action = preg_replace("/[^_.a-zA-Z0-9-]/", "", $_GET['action']);
    $toolbarname = 'popup';
    $htmlformatoption = '';
    if ($fieldtype == 'email-inv' || $fieldtype == 'email-reg' || $fieldtype == 'email-conf' || $fieldtype == 'email-rem') {
        $htmlformatoption = ",fullPage:true";
    }
    $output = '
	<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
	<html>
	<head>
		<title>' . sprintf($clang->gT("Editing %s"), $fieldtext) . '</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="robots" content="noindex, nofollow" />
        <script type="text/javascript" src="' . $rooturl . '/scripts/jquery/jquery.js"></script>
		<script type="text/javascript" src="' . $sCKEditorURL . '/ckeditor.js"></script>
	</head>';
    $output .= "\n\t<body>\n\t<form method='post' onsubmit='saveChanges=true;'>\n\n\t\t\t<input type='hidden' name='checksessionbypost' value='" . $_SESSION['checksessionpost'] . "' />\n\t\t\t<script type='text/javascript'>\n\t<!--\n\tfunction closeme()\n\t{\n\t\twindow.onbeforeunload = new Function('var a = 1;');\n\t\tself.close();\n\t}\n\n\twindow.onbeforeunload= function (evt) {\n\t\tclose_editor();\n\t\tcloseme();\n\t}\n\n\n\tvar saveChanges = false;\n    \$(document).ready(function(){\n        CKEDITOR.on('instanceReady',CKeditor_OnComplete);\n    \tvar oCKeditor = CKEDITOR.replace( 'MyTextarea' ,  { height\t: '350',\n    \t                                            width\t: '98%',\n    \t                                            customConfig : \"" . $sCKEditorURL . "/limesurvey-config.js\",\n                                                    toolbarStartupExpanded : true,\n                                                    ToolbarCanCollapse : false,\n                                                    toolbar : '" . $toolbarname . "',\n                                                    LimeReplacementFieldsSID : \"" . $sid . "\",\n                                                    LimeReplacementFieldsGID : \"" . $gid . "\",\n                                                    LimeReplacementFieldsQID : \"" . $qid . "\",\n                                                    LimeReplacementFieldsType: \"" . $fieldtype . "\",\n                                                    LimeReplacementFieldsAction: \"" . $action . "\",\n                                                    smiley_path: \"" . $rooturl . "/upload/images/smiley/msn/\"\n                                                    {$htmlformatoption} });\n    });\n\n\tfunction CKeditor_OnComplete( evt )\n\t{\n        var editor = evt.editor;\n        editor.setData(window.opener.document.getElementsByName(\"" . $fieldname . "\")[0].value);\n        editor.execCommand('maximize');\n\t\twindow.status='LimeSurvey " . $clang->gT("Editing", "js") . " " . javascript_escape($fieldtext, true) . "';\n\t}\n\n\tfunction html_transfert()\n\t{\n\t\tvar oEditor = CKEDITOR.instances['MyTextarea'];\n";
    if ($fieldtype == 'editanswer' || $fieldtype == 'addanswer' || $fieldtype == 'editlabel' || $fieldtype == 'addlabel') {
        $output .= "\t\tvar editedtext = oEditor.getData().replace(new RegExp( \"\\n\", \"g\" ),'');\n";
        $output .= "\t\tvar editedtext = oEditor.getData().replace(new RegExp( \"\\r\", \"g\" ),'');\n";
    } else {
        //$output .= "\t\tvar editedtext = oEditor.GetXHTML();\n";
        $output .= "\t\tvar editedtext = oEditor.getData('no strip new line');\n";
        // adding a parameter avoids stripping \n
    }
    $output .= "\n\n\t\twindow.opener.document.getElementsByName('" . $fieldname . "')[0].value = editedtext;\n\t}\n\n\n\tfunction close_editor()\n\t{\n\t\t\t\thtml_transfert();\n\n\t\twindow.opener.document.getElementsByName('" . $fieldname . "')[0].readOnly= false;\n\t\twindow.opener.document.getElementsByName('" . $fieldname . "')[0].className='htmlinput';\n\t\twindow.opener.document.getElementById('" . $controlidena . "').style.display='';\n\t\twindow.opener.document.getElementById('" . $controliddis . "').style.display='none';\n\t\twindow.opener.focus();\n\t\treturn true;\n\t}\n\n\t//-->\n\t\t\t</script>";
    $output .= "<textarea id='MyTextarea' name='MyTextarea'></textarea>";
    $output .= "\n\t</form>\n\t</body>\n\t</html>";
}
echo $output;
// Yes, closing PHP tag was intentionally left out
开发者ID:ddrmoscow,项目名称:queXS,代码行数:31,代码来源:htmleditor-popup.php

示例8: display


//.........这里部分代码省略.........

function geocodePosition(pos) {
  geocoder.geocode({
    latLng: pos
  }, function(responses) {
    if (responses && responses.length > 0) {
      updateMarkerAddress(responses[0].formatted_address);
    } else {
      updateMarkerAddress('Cannot determine address at this location.');
    }
  });
}

function updateMarkerStatus(str) {
  document.getElementById('markerStatus').innerHTML = str;
}

function updateMarkerPosition(latLng) {
  document.getElementById('info').innerHTML = [
    latLng.lat(),
    latLng.lng()
  ].join(', ');
}

function updateMarkerAddress(str) {
  document.getElementById('address').innerHTML = str;
}

function initialize() {

  var latLng = new google.maps.LatLng(
    <?php 
        echo !empty($GLOBALS['loc']['lat']) ? $GLOBALS['loc']['lat'] : $GLOBALS['jjwg_config']['map_default_center_latitude'];
        ?>
, 
    <?php 
        echo !empty($GLOBALS['loc']['lng']) ? $GLOBALS['loc']['lng'] : $GLOBALS['jjwg_config']['map_default_center_longitude'];
        ?>
 
  );

  var map = new google.maps.Map(document.getElementById('mapCanvas'), {
    zoom: 4,
    center: latLng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  });

  var customImage = new google.maps.MarkerImage('<?php 
        echo $custom_markers_dir;
        ?>
/<?php 
        echo javascript_escape($GLOBALS['loc']['image']);
        ?>
.png',
    new google.maps.Size(32,37),
    new google.maps.Point(0,0),
    new google.maps.Point(16,37)
  );
  var shape = {coord: [1, 1, 1, 37, 32, 37, 32, 1],type: 'poly'};
  
  var marker = new google.maps.Marker({
    position: latLng,
    title: '<?php 
        echo javascript_escape($GLOBALS['loc']['name']);
        ?>
',
    map: map,
    icon: customImage,
    shape: shape,
    draggable: false
  });
  // Update current position info.
  updateMarkerPosition(latLng);
  geocodePosition(latLng);
}

// Onload handler to fire off the app.
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
  <div id="mapCanvas"></div>
  <div id="infoPanel"><b></b>
    <div id="markerStatus"><i></i></div>
    <b><?php 
        echo $GLOBALS['mod_strings']['LBL_MARKER_MARKER_POSITION'];
        ?>
</b>
    <div id="info"></div>
    <b><?php 
        echo $GLOBALS['mod_strings']['LBL_MARKER_CLOSEST_MATCHING_ADDRESS'];
        ?>
</b>
    <div id="address"></div>
  </div>
</body>
</html>

<?php 
    }
开发者ID:MexinaD,项目名称:SuiteCRM,代码行数:101,代码来源:view.marker_detail_map.php

示例9: do_multiplechoice_withcomments


//.........这里部分代码省略.........
                $maxanswscript .= "\tif (document.getElementById('answer".$myfname."').value != '' && document.getElementById('answer".$myfname2."').value != '') { count += 1; }\n";
            }
            else
            {
                $maxanswscript .= "\tif (document.getElementById('answer".$myfname."').value != '') { count += 1; }\n";
            }
        }

        if ($minansw > 0)
        {
            if ($qidattributes['other_comment_mandatory']==1)
            {
                $minanswscript .= "\tif (document.getElementById('answer".$myfname."').value != '' && document.getElementById('answer".$myfname2."').value != '') { count += 1; }\n";
            }
            else
            {
                $minanswscript .= "\tif (document.getElementById('answer".$myfname."').value != '') { count += 1; }\n";
            }
        }

        $answer_main .= "\t</label>\n</span>\n\t</li>\n";
        // --> END NEW FEATURE - SAVE

        $inputnames[]=$myfname;
        $inputnames[]=$myfname2;
    }
    $answer .= "<ul>\n".$answer_main."</ul>\n";


    if ( $maxansw > 0 )
    {
        $maxanswscript .= "\tif (count > max)\n"
        . "{\n"
        . "alert('".sprintf($clang->gT("Please choose at most %d answers for question \"%s\"","js"), $maxansw, trim(javascript_escape($ia[3],true,true)))."');\n"
        . "var commentname='answer'+me.name+'comment';\n"
        . "if (me.type == 'checkbox') {\n"
        . "\tme.checked = false;\n"
        . "\tvar commentname='answer'+me.name+'comment';\n"
        . "}\n"
        . "if (me.type == 'text') {\n"
        . "\tme.value = '';\n"
        . "\tif (document.getElementById(me.name + 'cbox') ){\n"
        . " document.getElementById(me.name + 'cbox').checked = false;\n"
        . "\t}\n"
        . "}"
        . "document.getElementById(commentname).value='';\n"
        . "return max;\n"
        . "}\n"
        . "\t}\n"
        . "\t//-->\n"
        . "\t</script>\n";
        $answer = $maxanswscript . $answer;
    }

    if ( $minansw > 0 )
    {
        $minanswscript .=
			"\tif (count < {$minansw} && document.getElementById('display{$ia[0]}').value == 'on'){\n"
        . "alert('".sprintf($clang->gT("Please choose at least %d answer(s) for question \"%s\"","js"),
        $minansw, trim(javascript_escape(str_replace(array("\n", "\r"), "",$ia[3]),true,true)))."');\n"
        . "return false;\n"
        . "\t} else {\n"
        . "if (oldonsubmit_{$ia[0]}){\n"
        . "\treturn oldonsubmit_{$ia[0]}();\n"
        . "}\n"
        . "return true;\n"
开发者ID:nmklong,项目名称:limesurvey-cdio3,代码行数:67,代码来源:qanda.php

示例10: display


//.........这里部分代码省略.........
        echo $num_grp_sep;
        ?>
';
    var local_lat = latLng.lat().toFixed(8).replace(/0+$/g, "").replace(/\,/, num_grp_sep).replace(/\./, dec_sep);
    var local_lng = latLng.lng().toFixed(8).replace(/0+$/g, "").replace(/\,/, num_grp_sep).replace(/\./, dec_sep);
    parent.document.getElementById('jjwg_maps_lat').value = local_lat;
    parent.document.getElementById('jjwg_maps_lng').value = local_lng;
}

function initialize() {

  var latLng = new google.maps.LatLng(
    <?php 
        echo !empty($GLOBALS['loc']['lat']) ? $GLOBALS['loc']['lat'] : $GLOBALS['jjwg_config']['map_default_center_latitude'];
        ?>
,
    <?php 
        echo !empty($GLOBALS['loc']['lng']) ? $GLOBALS['loc']['lng'] : $GLOBALS['jjwg_config']['map_default_center_longitude'];
        ?>
  );

  var map = new google.maps.Map(document.getElementById('mapCanvas'), {
    zoom: 4,
    center: latLng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  });
<?php 
        if (!empty($GLOBALS['loc']['image'])) {
            ?>
  var customImage = new google.maps.MarkerImage('<?php 
            echo $custom_markers_dir;
            ?>
/<?php 
            echo javascript_escape($GLOBALS['loc']['image']);
            ?>
.png',
    new google.maps.Size(32,37),
    new google.maps.Point(0,0),
    new google.maps.Point(16,37)
  );
  var shape = {coord: [1, 1, 1, 37, 32, 37, 32, 1],type: 'poly'};
<?php 
        }
        // empty image
        ?>

  var marker = new google.maps.Marker({
    position: latLng,
    title: '<?php 
        echo javascript_escape($GLOBALS['loc']['name']);
        ?>
',
    map: map,
    icon: customImage,
    shape: shape,
    draggable: true
  });

  // Update current position info.
  updateMarkerPosition(latLng);
  geocodePosition(latLng);

  // Add dragging event listeners.
  google.maps.event.addListener(marker, 'dragstart', function() {
    updateMarkerAddress('Dragging...');
  });
开发者ID:sacredwebsite,项目名称:SuiteCRM,代码行数:67,代码来源:view.marker_edit_map.php

示例11: do_multiplechoice


//.........这里部分代码省略.........
        $answer .= " onclick='cancelBubbleThis(event);if(this.checked===false){ document.getElementById(\"answer{$myfname}\").value=\"\"; document.getElementById(\"java{$myfname}\").value=\"\"; {$checkconditionFunction}(\"\", \"{$myfname}\", \"text\"); }";
        $answer .= " if(this.checked===true) { document.getElementById(\"answer{$myfname}\").focus(); }; LEMflagMandOther(\"{$myfname}\",this.checked);";
        $answer .= "' />\n\t\t<label for=\"answer{$myfname}\" class=\"answertext\">" . $othertext . "</label>\n\t\t<input class=\"text " . $kpclass . "\" type=\"text\" name=\"{$myfname}\" id=\"answer{$myfname}\"";
        if (isset($_SESSION[$myfname])) {
            $dispVal = $_SESSION[$myfname];
            if ($qidattributes['other_numbers_only'] == 1) {
                $dispVal = str_replace('.', $sSeperator, $dispVal);
            }
            $answer .= ' value="' . htmlspecialchars($dispVal, ENT_QUOTES) . '"';
        }
        $answer .= " onchange='\$(\"#java{$myfname}\").val(this.value);{$oth_checkconditionFunction}(this.value, this.name, this.type);if (\$.trim(\$(\"#java{$myfname}\").val())!=\"\") { \$(\"#answer{$myfname}cbox\").attr(\"checked\",\"checked\"); } else { \$(\"#answer{$myfname}cbox\").attr(\"checked\",\"\"); }; LEMflagMandOther(\"{$myfname}\",this.checked);' {$numbersonly} />";
        $answer .= '<input type="hidden" name="java' . $myfname . '" id="java' . $myfname . '" value="';
        //        if ($maxansw > 0)
        //        {
        //            // For multiplechoice question there is no DB field for the other Checkbox
        //            // I've added a javascript which will warn a user if no other comment is given while the other checkbox is checked
        //            // For the maxanswer script, I will alert the participant
        //            // if the limit is reached when he checks the other cbox
        //            // even if the -other- input field is still empty
        //            $maxanswscript .= "\tif (document.getElementById('answer".$myfname."cbox').checked ) { count += 1; }\n";
        //        }
        //        if ($minansw > 0)
        //        {
        //            //
        //            // For multiplechoice question there is no DB field for the other Checkbox
        //            // We only count the -other- as valid if both the cbox and the other text is filled
        //            $minanswscript .= "\tif (document.getElementById('answer".$myfname."').value != '' && document.getElementById('answer".$myfname."cbox').checked ) { count += 1; }\n";
        //        }
        if (isset($_SESSION[$myfname])) {
            $dispVal = $_SESSION[$myfname];
            if ($qidattributes['other_numbers_only'] == 1) {
                $dispVal = str_replace('.', $sSeperator, $dispVal);
            }
            $answer .= ' value="' . htmlspecialchars($dispVal, ENT_QUOTES) . '"';
        }
        $answer .= "\" />\n{$wrapper['item-end']}";
        $inputnames[] = $myfname;
        ++$anscount;
        ++$rowcounter;
        if ($rowcounter == $wrapper['maxrows'] && $colcounter < $wrapper['cols']) {
            if ($colcounter == $wrapper['cols'] - 1) {
                $answer .= $wrapper['col-devide-last'];
            } else {
                $answer .= $wrapper['col-devide'];
            }
            $rowcounter = 0;
            ++$colcounter;
        }
    }
    $answer .= $wrapper['whole-end'];
    //    if ( $maxansw > 0 )
    //    {
    //        $maxanswscript .= "
    //        if (count > max)
    //        {
    //            alert('".sprintf($clang->gT("Please choose at most %d answers for question \"%s\"","js"), $maxansw, trim(javascript_escape(str_replace(array("\n", "\r"), "", $ia[3]),true,true)))."');
    //            if (me.type == 'checkbox') { me.checked = false; }
    //            if (me.type == 'text') {
    //                me.value = '';
    //                if (document.getElementById('answer'+me.name + 'cbox') ){
    //                    document.getElementById('answer'+me.name + 'cbox').checked = false;
    //                }
    //            }
    //            return max;
    //        }
    //        }
    //        //-->
    //        </script>\n";
    //        $answer = $maxanswscript . $answer;
    //    }
    //    if ( $minansw > 0 )
    //    {
    //        $minanswscript .=
    //			"\tif (count < {$minansw} && document.getElementById('display{$ia[0]}').value == 'on'){\n"
    //        . "alert('".sprintf($clang->gT("Please choose at least %d answer(s) for question \"%s\"","js"),
    //        $minansw, trim(javascript_escape(str_replace(array("\n", "\r"), "",$ia[3]),true,true)))."');\n"
    //        . "return false;\n"
    //        . "\t} else {\n"
    //        . "if (oldonsubmit_{$ia[0]}){\n"
    //        . "\treturn oldonsubmit_{$ia[0]}();\n"
    //        . "}\n"
    //        . "return true;\n"
    //        . "\t}\n"
    //        . "}\n"
    //        . "document.limesurvey.onsubmit = ensureminansw_{$ia[0]}\n"
    //        . "-->\n"
    //        . "\t</script>\n";
    //        //$answer = $minanswscript . $answer;
    //    }
    $checkotherscript = "";
    if ($other == 'Y') {
        // Multiple choice with 'other' is a specific case as the checkbox isn't recorded into DB
        // this means that if it is cehcked We must force the end-user to enter text in the input
        // box
        $checkotherscript = "<script type='text/javascript'>\n" . "\t<!--\n" . "oldonsubmitOther_{$ia[0]} = document.limesurvey.onsubmit;\n" . "function ensureOther_{$ia[0]}()\n" . "{\n" . "\tothercboxval=document.getElementById('answer" . $myfname . "cbox').checked;\n" . "\totherval=document.getElementById('answer" . $myfname . "').value;\n" . "\tif (otherval != '' || othercboxval != true) {\n" . "if(typeof oldonsubmitOther_{$ia[0]} == 'function') {\n" . "\treturn oldonsubmitOther_{$ia[0]}();\n" . "}\n" . "\t}\n" . "\telse {\n" . "alert('" . sprintf($clang->gT("You've marked the \"other\" field for question \"%s\". Please also fill in the accompanying \"other comment\" field.", "js"), trim(javascript_escape($ia[3], true, true))) . "');\n" . "return false;\n" . "\t}\n" . "}\n" . "document.limesurvey.onsubmit = ensureOther_{$ia[0]};\n" . "\t-->\n" . "</script>\n";
    }
    $answer = $checkotherscript . $answer;
    $answer .= $postrow;
    return array($answer, $inputnames);
}
开发者ID:rkaldung,项目名称:LimeSurvey,代码行数:101,代码来源:qanda.php

示例12: elseif

 elseif ($thissurvey['anonymized'] == "N" && preg_match('/^{TOKEN:([^}]*)}$/', $cd[3], $targetconditiontokenattr))
 {
     if ( isset($_SESSION['token']) &&
     in_array(strtolower($targetconditiontokenattr[1]),GetTokenConditionsFieldNames($surveyid)))
     {
         $cvalue=GetAttributeValue($surveyid,strtolower($targetconditiontokenattr[1]),$_SESSION['token']);
         if ($conditionSourceOnPreviousPage === false)
         {
             if (in_array($cd[4],array("A","B","K","N","5",":"))  || (in_array($cd[4],array("Q",";")) && $cqidattributes['numbers_only']==1))
             {
                 $newjava .= "parseFloat($JSsourceVal) $cd[6] parseFloat('".javascript_escape($cvalue)."')";
             }
             else
             {
                 //$newjava .= "document.getElementById('$idname').value $cd[6] '".javascript_escape($cvalue)."'";
                 $newjava .= "$JSsourceVal $cd[6] '".javascript_escape($cvalue)."'";
             }
         }
         else
         { // note that source of condition is not a TokenAttr because this case is processed
             // earlier
             // get previous qecho "<pre>";print_r($_SESSION);echo "</pre>";die();uestion answer value: $cd[2]
             if (isset($_SESSION[$cd[2]]))
             {
                 $prevanswerToCompare=$_SESSION[$cd[2]];
                 if ($cd[6] != 'RX')
                 {
                     if (eval('if (trim($prevanswerToCompare) '.$cd[6].' trim($cvalue)) return true; else return false;'))
                     {
                         //$newjava .= "'tokenMatch' == 'tokenMatch'";
                         $newjava .= "true";
开发者ID:nmklong,项目名称:limesurvey-cdio3,代码行数:31,代码来源:group.php


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