Example #1
0
 /**
  * This function translates strings to their according language
  * 
  * @param string $string The string to translate
  * @param mixed $escapemode Different uses require the string to be escaped accordinlgy. Possible values are 'html'(default),'js' and 'unescaped'
  * @return string Translated string
  */
 function gT($string, $escapemode = 'html')
 {
     if ($this->gettextclass) {
         $basestring = str_replace('‘', '\'', $this->gettextclass->translate($string));
         switch ($escapemode) {
             case 'html':
                 return html_escape($basestring);
                 break;
             case 'js':
                 return javascript_escape($basestring);
                 break;
             case 'unescaped':
                 return $basestring;
                 break;
             default:
                 return "Unsupported EscapeMode in gT method";
                 break;
         }
     } else {
         switch ($escapemode) {
             case 'html':
                 return html_escape($string);
                 break;
             case 'js':
                 return javascript_escape($string);
                 break;
             case 'unescaped':
                 return $string;
                 break;
             default:
                 return "Unsupported EscapeMode in gT method";
                 break;
         }
     }
 }
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 . "}";
}
Example #3
0
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
}
Example #4
0
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;
}
Example #5
0
        $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';
Example #6
0
    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;
    }
Example #7
0
     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
     {
Example #8
0
    $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
    function display()
    {
        $custom_markers_dir = 'custom/themes/default/images/jjwg_Markers/';
        ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml"> 
  <head> 
  <title><?php 
        echo $GLOBALS['mod_strings']['LBL_MARKER_DISPLAY'];
        ?>
</title> 
  <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
  <meta http-equiv="content-type" content="text/html; charset=utf-8"/> 
  <link rel="stylesheet" type="text/css" href="cache/themes/<?php 
        echo $GLOBALS['theme'];
        ?>
/css/style.css" />
  <style type="text/css">
    html { height: 100% }
    body { height: 100%; margin: 0px; padding: 0px }
    #mapCanvas {
      width: 700px;
      height: 500px;
      float: left;
    }
    #infoPanel {
      width: 450px;
      float: left;
      margin-left: 10px;
    }
    #mapCanvas, #infoPanel, #markerStatus, #info, #address {
      font-size: 12px;
      line-height: 16px;
      font-family:Arial,Verdana,Helvetica,sans-serif;
      color: #444444;
      margin-bottom: 5px;
    }
    b {
      font-weight: normal;
      color: #000000;
    }
  </style>
  
  <script type="text/javascript" src="//maps.google.com/maps/api/js?sensor=false"></script>

  <script type="text/javascript">

var geocoder = new google.maps.Geocoder();

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 
    }
Example #10
0
     $idname2 = retrieveJSidname(array('', $qid_from_sgq, $comparedfieldname[1], 'Y', $q2type, $sgq_from_sgqa));
     $cqidattributes = getQuestionAttributes($cd[1]);
     if (in_array($cd[4], array("A", "B", "K", "N", "5", ":")) || in_array($cd[4], array("Q", ";")) && $cqidattributes['other_numbers_only'] == 1) {
         // Numerical questions
         $java .= "{$JSsourceElt} != null && document.getElementById('" . $idname2 . "') !=null && parseFloat({$JSsourceVal}) {$cd['6']} parseFloat(document.getElementById('" . $idname2 . "').value)";
     } else {
         $java .= "{$JSsourceElt} != null && document.getElementById('" . $idname2 . "') !=null && {$JSsourceVal} {$cd['6']} document.getElementById('" . $idname2 . "').value";
     }
 } elseif ($thissurvey['private'] == "N" && preg_match('/^{TOKEN:([^}]*)}$/', $cd[3], $comparedtokenattr)) {
     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) {
             // Numerical questions
             $java .= "{$JSsourceElt} != null && parseFloat({$JSsourceVal}) {$cd['6']} parseFloat('" . 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 {
         $cqidattributes = getQuestionAttributes($cd[1]);
         if (in_array($cd[4], array("A", "B", "K", "N", "5", ":")) || in_array($cd[4], array("Q", ";")) && $cqidattributes['other_numbers_only'] == 1) {
             // Numerical questions
             $java .= "{$JSsourceElt} != null && parseFloat({$JSsourceVal}) {$cd['6']} parseFloat('{$cd['3']}')";
         } else {
             $java .= "{$JSsourceElt} != null && {$JSsourceVal} {$cd['6']} '{$cd['3']}'";
         }
Example #11
0
function do_multiplechoice_withcomments($ia)
{
    global $dbprefix, $clang, $thissurvey;

    $attribute_ref=false;
    $qaquery = "SELECT qid,attribute FROM ".db_table_name('question_attributes')." WHERE value LIKE '".strtolower($ia[2])."'";
    $qaresult = db_execute_assoc($qaquery);     //Checked
    $attribute_ref=false;
    while($qarow = $qaresult->FetchRow())
    {
        $qquery = "SELECT qid FROM ".db_table_name('questions')." WHERE sid=".$thissurvey['sid']." AND qid=".$qarow['qid'];
        $qresult = db_execute_assoc($qquery);     //Checked
        if ($qresult->RecordCount() > 0)
        {
            $attribute_ref = true;
        }
    }

    if ($ia[8] == 'Y' || $attribute_ref == true)
    {
        $checkconditionFunction = "checkconditions";
    }
    else
    {
        $checkconditionFunction = "noop_checkconditions";
    }

    $qidattributes=getQuestionAttributes($ia[0],$ia[4]);

    if ($qidattributes['other_numbers_only']==1)
    {
        $sSeperator = getRadixPointData($thissurvey['surveyls_numberformat']);
        $sSeperator = $sSeperator['seperator'];
        $numbersonly = 'onkeypress="return goodchars(event,\'-0123456789'.$sSeperator.'\')"';
    }
    else
    {
        $numbersonly = '';
    }

    if (trim($qidattributes['other_replace_text'])!='')
    {
        $othertext=$qidattributes['other_replace_text'];
    }
    else
    {
        $othertext=$clang->gT('Other:');
    }
    // Check if the max_answers attribute is set
    $maxansw=0;
    $callmaxanswscriptcheckbox = '';
    $callmaxanswscriptcheckbox2 = '';
    $callmaxanswscriptother = '';
    $maxanswscript = '';
    if (trim($qidattributes['max_answers'])!='') {
        $maxansw=$qidattributes['max_answers'];
        $callmaxanswscriptcheckbox = "limitmaxansw_{$ia[0]}(this);";
        $callmaxanswscriptcheckbox2= "limitmaxansw_{$ia[0]}";
        $callmaxanswscriptother = "onkeyup=\"limitmaxansw_{$ia[0]}(this)\"";

        $maxanswscript = "\t<script type='text/javascript'>\n"
        . "\t<!--\n"
        . "function limitmaxansw_{$ia[0]}(me)\n"
        . "\t{\n"
        . "\tmax=$maxansw\n"
        . "\tcount=0;\n"
        . "\tif (max == 0) { return count; }\n";
    }

    // Check if the min_answers attribute is set
    $minansw=0;
    $minanswscript = "";
    if (trim($qidattributes["min_answers"])!='')
    {
        $minansw=trim($qidattributes["min_answers"]);
        $minanswscript = "<script type='text/javascript'>\n"
        . "\t<!--\n"
        . "oldonsubmit_{$ia[0]} = document.limesurvey.onsubmit;\n"
        . "function ensureminansw_{$ia[0]}()\n"
        . "{\n"
        . "\tcount=0;\n"
        ;
    }

    $qquery = "SELECT other FROM {$dbprefix}questions
               WHERE qid=".$ia[0]." AND language='".$_SESSION['s_lang']."' and parent_qid=0";
    $qresult = db_execute_assoc($qquery);     //Checked
    while ($qrow = $qresult->FetchRow()) {$other = $qrow['other'];}
    if ($qidattributes['random_order']==1) {
        $ansquery = "SELECT * FROM {$dbprefix}questions
                     WHERE parent_qid=$ia[0]  AND language='".$_SESSION['s_lang']."'
                     ORDER BY ".db_random();
    } else {
        $ansquery = "SELECT * FROM {$dbprefix}questions
                     WHERE parent_qid=$ia[0]  AND language='".$_SESSION['s_lang']."'
                     ORDER BY question_order";
    }
    $ansresult = db_execute_assoc($ansquery);  //Checked
    $anscount = $ansresult->RecordCount()*2;

    $answer = "<input type='hidden' name='MULTI$ia[1]' value='$anscount' />\n";
    $answer_main = '';

    $fn = 1;
    if($other == 'Y')
    {
        $label_width = 25;
    }
    else
    {
        $label_width = 0;
    }

    while ($ansrow = $ansresult->FetchRow())
    {
        $myfname = $ia[1].$ansrow['title'];
        $trbc='';
        /* Check for array_filter */

        list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $qidattributes, $thissurvey, $ansrow, $myfname, $trbc, $myfname, "li");

        if($label_width < strlen(trim(strip_tags($ansrow['question']))))
        {
            $label_width = strlen(trim(strip_tags($ansrow['question'])));
        }

        $myfname2 = $myfname."comment";
        $startitem = "\t$htmltbody2\n";
        /* Print out the checkbox */
        $answer_main .= $startitem;
        $answer_main .= "\t$hiddenfield\n";
        $answer_main .= "<span class=\"option\">\n"
        . "\t<label for=\"answer$myfname\" class=\"answertext\">\n"
        . "\t<input class=\"checkbox\" type=\"checkbox\" name=\"$myfname\" id=\"answer$myfname\" value=\"Y\"";

        /* If the question has already been ticked, check the checkbox */
        if (isset($_SESSION[$myfname]))
        {
            if ($_SESSION[$myfname] == 'Y')
            {
                $answer_main .= CHECKED;
            }
        }
        $answer_main .=" onclick='cancelBubbleThis(event);".$callmaxanswscriptcheckbox."$checkconditionFunction(this.value, this.name, this.type);' "
        . " onchange='document.getElementById(\"answer$myfname2\").value=\"\";' />\n"
        . $ansrow['question']."</label>\n";

        if ($maxansw > 0) {$maxanswscript .= "\tif (document.getElementById('answer".$myfname."').checked) { count += 1; }\n";}
        if ($minansw > 0) {$minanswscript .= "\tif (document.getElementById('answer".$myfname."').checked) { count += 1; }\n";}

        $answer_main .= "<input type='hidden' name='java$myfname' id='java$myfname' value='";
        if (isset($_SESSION[$myfname]))
        {
            $answer_main .= $_SESSION[$myfname];
        }
        $answer_main .= "' />\n";
        $fn++;
        $answer_main .= "</span>\n<span class=\"comment\">\n\t<label for='answer$myfname2' class=\"answer-comment\">\n"
        ."<input class='text' type='text' size='40' id='answer$myfname2' name='$myfname2' title='".$clang->gT("Make a comment on your choice here:")."' value='";
        if (isset($_SESSION[$myfname2])) {$answer_main .= htmlspecialchars($_SESSION[$myfname2],ENT_QUOTES);}
        // --> START NEW FEATURE - SAVE
        $answer_main .= "'  onclick='cancelBubbleThis(event);' onkeyup='if (jQuery.trim($(\"#answer{$myfname2}\").val())!=\"\") { document.getElementById(\"answer{$myfname}\").checked=true;$checkconditionFunction(document.getElementById(\"answer{$myfname}\").value,\"$myfname\",\"checkbox\");}' onkeyup='".$callmaxanswscriptcheckbox2."(document.getElementById(\"answer{$myfname}\"))' />\n\t</label>\n</span>\n"

        . "\t</li>\n";
        // --> END NEW FEATURE - SAVE

        $fn++;
        $inputnames[]=$myfname;
        $inputnames[]=$myfname2;
    }
    if ($other == 'Y')
    {
        $myfname = $ia[1].'other';
        $myfname2 = $myfname.'comment';
        $anscount = $anscount + 2;
        $answer_main .= "\t<li class=\"other\">\n<span class=\"option\">\n"
        . "\t<label for=\"answer$myfname\" class=\"answertext\">\n".$othertext."\n<input class=\"text other\" $numbersonly type=\"text\" name=\"$myfname\" id=\"answer$myfname\" title=\"".$clang->gT('Other').'" size="10"';
        if (isset($_SESSION[$myfname]) && $_SESSION[$myfname])
        {
            $answer_main .= ' value="'.htmlspecialchars($_SESSION[$myfname],ENT_QUOTES).'"';
        }
        $fn++;
        // --> START NEW FEATURE - SAVE
        $answer_main .= "  $callmaxanswscriptother />\n\t</label>\n</span>\n"
        . "<span class=\"comment\">\n\t<label for=\"answer$myfname2\" class=\"answer-comment\">\n"
        . '
				<input class="text" type="text" size="40" name="'.$myfname2.'" id="answer'.$myfname2.'" title="'.$clang->gT('Make a comment on your choice here:').'" value="';
        // --> END NEW FEATURE - SAVE

        if (isset($_SESSION[$myfname2])) {$answer_main .= htmlspecialchars($_SESSION[$myfname2],ENT_QUOTES);}
        // --> START NEW FEATURE - SAVE
        $answer_main .= '" onkeyup="'.$callmaxanswscriptcheckbox2.'(document.getElementById(\'answer'.$myfname."'))\" />\n";

        if ($maxansw > 0)
        {
            if ($qidattributes['other_comment_mandatory']==1)
            {
                $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"
        . "\t}\n"
        . "}\n"
        . "document.limesurvey.onsubmit = ensureminansw_{$ia[0]}\n"
        . "-->\n"
        . "\t</script>\n";
        //$answer = $minanswscript . $answer;
    }

    $checkotherscript = "";
    //if ($other == 'Y' && $qidattributes['other_comment_mandatory']==1) //TIBO
    if ($other == 'Y' && $qidattributes['other_comment_mandatory']==1) //TIBO
    {
        // 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"
        . "\tothercommentval=document.getElementById('answer".$myfname2."').value;\n"
        . "\totherval=document.getElementById('answer".$myfname."').value;\n"
        . "\tif (otherval != '' && othercommentval == '') {\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"
        . "\telse {\n"
        . "if(typeof oldonsubmitOther_{$ia[0]} == 'function') {\n"
        . "\treturn oldonsubmitOther_{$ia[0]}();\n"
        . "}\n"
        . "\t}\n"
        . "}\n"
        . "document.limesurvey.onsubmit = ensureOther_{$ia[0]};\n"
        . "\t-->\n"
        . "</script>\n";
    }

    $answer = $minanswscript . $checkotherscript . $answer;

    return array($answer, $inputnames);
}
    function display()
    {
        // Users local settings for decimal seperator and number grouping seperator
        $dec_sep = $GLOBALS['sugar_config']['default_decimal_seperator'];
        $user_dec_sep = $GLOBALS['current_user']->getPreference('dec_sep');
        $dec_sep = empty($user_dec_sep) ? $GLOBALS['sugar_config']['default_decimal_seperator'] : $user_dec_sep;
        $num_grp_sep = $GLOBALS['sugar_config']['default_number_grouping_seperator'];
        $user_num_grp_sep = $GLOBALS['current_user']->getPreference('num_grp_sep');
        $num_grp_sep = empty($user_num_grp_sep) ? $GLOBALS['sugar_config']['default_number_grouping_seperator'] : $user_num_grp_sep;
        $custom_markers_dir = 'themes/default/images/jjwg_Markers/';
        ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
  <title><?php 
        echo $GLOBALS['mod_strings']['LBL_MARKER_DISPLAY'];
        ?>
</title>
  <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
  <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
  <link rel="stylesheet" type="text/css" href="cache/themes/<?php 
        echo $GLOBALS['theme'];
        ?>
/css/style.css" />
  <style type="text/css">
    html { height: 100% }
    body { height: 100%; margin: 0px; padding: 0px }
    #mapCanvas {
      width: 700px;
      height: 500px;
      float: left;
    }
    #infoPanel {
      width: 450px;
      float: left;
      margin-left: 10px;
    }
    #mapCanvas, #infoPanel, #markerStatus, #info, #address {
      font-size: 12px;
      line-height: 16px;
      font-family:Arial,Verdana,Helvetica,sans-serif;
      color: #444444;
      margin-bottom: 5px;
    }
    b {
      font-weight: normal;
      color: #000000;
    }
  </style>

  <script type="text/javascript" src="//maps.google.com/maps/api/js?sensor=false"></script>

  <script type="text/javascript">

var geocoder = new google.maps.Geocoder();

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().toFixed(8).replace(/0+$/g, ""),
    latLng.lng().toFixed(8).replace(/0+$/g, "")
  ].join(',');
}

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

function updateEditFormLatLng(latLng) {
    // For Users Locale Conversion
    var dec_sep = '<?php 
        echo $dec_sep;
        ?>
';
    var num_grp_sep = '<?php 
        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...');
  });

  google.maps.event.addListener(marker, 'drag', function() {
    updateMarkerStatus('Dragging...');
    updateMarkerPosition(marker.getPosition());
  });

  google.maps.event.addListener(marker, 'dragend', function() {
    updateMarkerStatus('Drag ended');
    geocodePosition(marker.getPosition());
    // Update the parent window edit view form lat/lng
    updateEditFormLatLng(marker.getPosition());
  });

}

// 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><?php 
        echo $GLOBALS['mod_strings']['LBL_MARKER_MARKER_STATUS'];
        ?>
</b>
    <div id="markerStatus"><i><?php 
        echo $GLOBALS['mod_strings']['LBL_MARKER_EDIT_DESCRIPTION'];
        ?>
</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 
    }
Example #13
0
function do_multiplechoice($ia)
{
    global $dbprefix, $clang, $connect, $thissurvey;
    if ($thissurvey['nokeyboard'] == 'Y') {
        vIncludeKeypad();
        $kpclass = "text-keypad";
    } else {
        $kpclass = "";
    }
    // Find out if any questions have attributes which reference this questions
    // based on value of attribute. This could be array_filter and array_filter_exclude
    $attribute_ref = false;
    $inputnames = array();
    $qaquery = "SELECT qid,attribute FROM " . db_table_name('question_attributes') . " WHERE value LIKE '" . strtolower($ia[2]) . "' and (attribute='array_filter' or attribute='array_filter_exclude')";
    $qaresult = db_execute_assoc($qaquery);
    //Checked
    while ($qarow = $qaresult->FetchRow()) {
        $qquery = "SELECT qid FROM " . db_table_name('questions') . " WHERE sid=" . $thissurvey['sid'] . " AND scale_id=0 AND qid=" . $qarow['qid'];
        $qresult = db_execute_assoc($qquery);
        //Checked
        if ($qresult->RecordCount() > 0) {
            $attribute_ref = true;
        }
    }
    $checkconditionFunction = "checkconditions";
    $qidattributes = getQuestionAttributes($ia[0], $ia[4]);
    if (trim($qidattributes['other_replace_text']) != '') {
        $othertext = $qidattributes['other_replace_text'];
    } else {
        $othertext = $clang->gT('Other:');
    }
    if (trim($qidattributes['display_columns']) != '') {
        $dcols = $qidattributes['display_columns'];
    } else {
        $dcols = 1;
    }
    if ($qidattributes['other_numbers_only'] == 1) {
        $sSeperator = getRadixPointData($thissurvey['surveyls_numberformat']);
        $sSeperator = $sSeperator['seperator'];
        $numbersonly = " onkeypress='return goodchars(event,\"-0123456789{$sSeperator}\")'";
        $oth_checkconditionFunction = "fixnum_checkconditions";
    } else {
        $numbersonly = '';
        $oth_checkconditionFunction = "checkconditions";
    }
    // Check if the max_answers attribute is set
    //    $maxansw = 0;
    //    $callmaxanswscriptcheckbox = '';
    //    $callmaxanswscriptother = '';
    //    $maxanswscript = '';
    $exclude_all_others_auto = trim($qidattributes["exclude_all_others_auto"]);
    if ($exclude_all_others_auto == '1') {
        $autoArray['list'][] = $ia[1];
        $autoArray[$ia[1]]['parent'] = $ia[1];
    }
    //    if (((int)$qidattributes['max_answers']>0) && $exclude_all_others_auto=='0')
    //    {
    //        $maxansw=$qidattributes['max_answers'];
    //        $callmaxanswscriptcheckbox = "limitmaxansw_{$ia[0]}(this);";
    //        $callmaxanswscriptother = "onkeyup='limitmaxansw_{$ia[0]}(this)'";
    //        $maxanswscript = "\t<script type='text/javascript'>\n"
    //        . "\t<!--\n"
    //        . "function limitmaxansw_{$ia[0]}(me)\n"
    //        . "{\n"
    //        . "\tmax=$maxansw\n"
    //        . "\tcount=0;\n"
    //        . "\tif (max == 0) { return count; }\n";
    //    }
    //    // Check if the min_answers attribute is set
    //    $minansw=0;
    //    $minanswscript = "";
    //
    //    if ((int)$qidattributes['min_answers']>0)
    //    {
    //        $minansw=trim($qidattributes["min_answers"]);
    //        $minanswscript = "<script type='text/javascript'>\n"
    //        . "\t<!--\n"
    //        . "oldonsubmit_{$ia[0]} = document.limesurvey.onsubmit;\n"
    //        . "function ensureminansw_{$ia[0]}()\n"
    //        . "{\n"
    //        . "\tcount=0;\n"
    //        ;
    //    }
    $qquery = "SELECT other FROM " . db_table_name('questions') . " WHERE qid=" . $ia[0] . " AND language='" . $_SESSION['s_lang'] . "' and parent_qid=0";
    $qresult = db_execute_assoc($qquery);
    //Checked
    while ($qrow = $qresult->FetchRow()) {
        $other = $qrow['other'];
    }
    if ($qidattributes['random_order'] == 1) {
        $ansquery = "SELECT * FROM " . db_table_name('questions') . " WHERE parent_qid={$ia['0']} AND scale_id=0 AND language='" . $_SESSION['s_lang'] . "' ORDER BY " . db_random();
    } else {
        $ansquery = "SELECT * FROM " . db_table_name('questions') . " WHERE parent_qid={$ia['0']} AND scale_id=0 AND language='" . $_SESSION['s_lang'] . "' ORDER BY question_order";
    }
    $ansresult = $connect->GetAll($ansquery);
    //Checked
    $anscount = count($ansresult);
    if (trim($qidattributes['exclude_all_others']) != '' && $qidattributes['random_order'] == 1) {
        //if  exclude_all_others is set then the related answer should keep its position at all times
        //thats why we have to re-position it if it has been randomized
        $position = 0;
        foreach ($ansresult as $answer) {
            if (trim($qidattributes['exclude_all_others']) != '' && $answer['title'] == trim($qidattributes['exclude_all_others'])) {
                if ($position == $answer['question_order'] - 1) {
                    break;
                }
                //already in the right position
                $tmp = array_splice($ansresult, $position, 1);
                array_splice($ansresult, $answer['question_order'] - 1, 0, $tmp);
                break;
            }
            $position++;
        }
    }
    if ($other == 'Y') {
        $anscount++;
        //COUNT OTHER AS AN ANSWER FOR MANDATORY CHECKING!
    }
    $wrapper = setup_columns($dcols, $anscount);
    $answer = '<input type="hidden" name="MULTI' . $ia[1] . '" value="' . $anscount . "\" />\n\n" . $wrapper['whole-start'];
    $fn = 1;
    if (!isset($multifields)) {
        $multifields = '';
    }
    $rowcounter = 0;
    $colcounter = 1;
    $startitem = '';
    $postrow = '';
    $trbc = '';
    foreach ($ansresult as $ansrow) {
        $myfname = $ia[1] . $ansrow['title'];
        if ($exclude_all_others_auto == 1) {
            if ($ansrow['title'] == trim($qidattributes['exclude_all_others'])) {
                $autoArray[$ia[1]]['focus'] = $ia[1] . trim($qidattributes['exclude_all_others']);
            } else {
                $autoArray[$ia[1]]['children'][] = $myfname;
            }
        }
        $trbc = '';
        /* Check for array_filter */
        list($htmltbody2, $hiddenfield) = return_array_filter_strings($ia, $qidattributes, $thissurvey, $ansrow, $myfname, $trbc, $myfname, "li");
        if ($wrapper['item-start'] == "\t<li>\n") {
            $startitem = "\t{$htmltbody2}\n";
        } else {
            $startitem = $wrapper['item-start'];
        }
        /* Print out the checkbox */
        $answer .= $startitem;
        $answer .= "\t{$hiddenfield}\n";
        $answer .= '		<input class="checkbox" type="checkbox" name="' . $ia[1] . $ansrow['title'] . '" id="answer' . $ia[1] . $ansrow['title'] . '" value="Y"';
        /* If the question has already been ticked, check the checkbox */
        if (isset($_SESSION[$myfname])) {
            if ($_SESSION[$myfname] == 'Y') {
                $answer .= CHECKED;
            }
        }
        $answer .= " onclick='cancelBubbleThis(event);";
        $answer .= '' . "{$checkconditionFunction}(this.value, this.name, this.type)' />\n" . "<label for=\"answer{$ia['1']}{$ansrow['title']}\" class=\"answertext\">" . $ansrow['question'] . "</label>\n";
        //        if ($maxansw > 0) {$maxanswscript .= "\tif (document.getElementById('answer".$myfname."').checked) { count += 1; }\n";}
        //        if ($minansw > 0) {$minanswscript .= "\tif (document.getElementById('answer".$myfname."').checked) { count += 1; }\n";}
        ++$fn;
        /* Now add the hidden field to contain information about this answer */
        $answer .= '		<input type="hidden" name="java' . $myfname . '" id="java' . $myfname . '" value="';
        if (isset($_SESSION[$myfname])) {
            $answer .= $_SESSION[$myfname];
        }
        $answer .= "\" />\n{$wrapper['item-end']}";
        $inputnames[] = $myfname;
        ++$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;
        }
    }
    if ($exclude_all_others_auto == 1) {
        $answer .= "<script type='text/javascript'>autoArray = " . json_encode($autoArray) . ";</script>";
    }
    if ($other == 'Y') {
        $myfname = $ia[1] . 'other';
        list($htmltbody2, $hiddenfield) = return_array_filter_strings($ia, $qidattributes, $thissurvey, array("code" => "other"), $myfname, $trbc, $myfname, "li");
        if ($wrapper['item-start'] == "\t<li>\n") {
            $startitem = "\t{$htmltbody2}\n";
        } else {
            $startitem = $wrapper['item-start'];
        }
        $answer .= $startitem;
        $answer .= $hiddenfield . '
		<input class="checkbox" type="checkbox" name="' . $myfname . 'cbox" alt="' . $clang->gT('Other') . '" id="answer' . $myfname . 'cbox"';
        if (isset($_SESSION[$myfname]) && trim($_SESSION[$myfname]) != '') {
            $answer .= CHECKED;
        }
        $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);
}
Example #14
0
    $qid = sanitize_int($_GET['qid']);
    $fieldtype = preg_replace("/[^_.a-zA-Z0-9-]/", "", $_GET['fieldtype']);
    $action = preg_replace("/[^_.a-zA-Z0-9-]/", "", $_GET['action']);
    $toolbarname = 'LimeSurveyToolbarfullPopup';
    $htmlformatoption = '';
    if ($fieldtype == 'email-inv' || $fieldtype == 'email-reg' || $fieldtype == 'email-conf' || $fieldtype == 'email-rem') {
        $htmlformatoption = "oFCKeditor.Config[\"FullPage\"]=true;";
    }
    $output = '
	<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
	<html>
	<head>
		<title>' . $clang->gT("Editing") . ' ' . $fieldtext . '</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="robots" content="noindex, nofollow" />
		<script type="text/javascript" src="' . $sFCKEditorURL . '/fckeditor.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('return true;');\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\n\tvar oFCKeditor = new FCKeditor( 'MyTextarea' );\n\toFCKeditor.BasePath\t= '" . $sFCKEditorURL . "/';\n\toFCKeditor.Height\t= '350';\n\toFCKeditor.Width\t= '98%';\n\toFCKeditor.Value      = window.opener.document.getElementsByName(\"" . $fieldname . "\")[0].value;\n\toFCKeditor.Config[\"CustomConfigurationsPath\"] = \"" . $sFCKEditorURL . "/limesurvey-config.js\";\n\toFCKeditor.Config[\"ToolbarStartExpanded\"] = true;\n\toFCKeditor.Config[\"ToolbarCanCollapse\"] = false;\n\toFCKeditor.ToolbarSet = '" . $toolbarname . "';\n\toFCKeditor.Config[\"LimeReplacementFieldsSID\"] = \"" . $sid . "\";\n\toFCKeditor.Config[\"LimeReplacementFieldsGID\"] = \"" . $gid . "\";\n\toFCKeditor.Config[\"LimeReplacementFieldsQID\"] = \"" . $qid . "\";\n\toFCKeditor.Config[\"LimeReplacementFieldsType\"] = \"" . $fieldtype . "\";\n\toFCKeditor.Config[\"LimeReplacementFieldsAction\"] = \"" . $action . "\";\n\toFCKeditor.Config[\"SmileyPath\"] = \"" . $rooturl . "/upload/images/smiley/msn/\";\n\t{$htmlformatoption}\n\toFCKeditor.Create();\n\n\tfunction FCKeditor_OnComplete( editorInstance )\n\t{\n\t\t//editorInstance.Events.AttachEvent( 'OnSelectionChange', DoSomething ) ;\n\t\teditorInstance.ToolbarSet.CurrentInstance.Commands.GetCommand('FitWindow').Execute();\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 = FCKeditorAPI.GetInstance('MyTextarea');\n";
    if ($fieldtype == 'editanswer' || $fieldtype == 'addanswer' || $fieldtype == 'editlabel' || $fieldtype == 'addlabel') {
        $output .= "\t\tvar editedtext = oEditor.GetXHTML().replace(new RegExp( \"\\n\", \"g\" ),'');\n";
        $output .= "\t\tvar editedtext = oEditor.GetXHTML().replace(new RegExp( \"\\r\", \"g\" ),'');\n";
    } else {
        //$output .= "\t\tvar editedtext = oEditor.GetXHTML();\n";
        $output .= "\t\tvar editedtext = oEditor.GetXHTML('no strip new line');\n";
        // adding a parameter avoids stripping \n
    }
    $output .= "\n\t\twindow.opener.document.getElementsByName('" . $fieldname . "')[0].value = editedtext;\n\t}\n\n\tfunction close_editor()\n\t{\n\t\tif (saveChanges == false)\n\t\t{\n\t\t\tif (confirm('" . $clang->gT("Do you want to save your changes ?", "js") . "'))\n\t\t\t{\n\t\t\t\thtml_transfert();\n\t\t\t}\t\n\t\t}\n\n\t\tif (saveChanges == true)\n\t\t{\n\t\t\thtml_transfert();\n\t\t}\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>\n\t</form>";
    //$output .= "<textarea id='MyTextarea' name='MyTextarea'></textarea>";
    $output .= "\n\t</body>\n\t</html>";
}
echo $output;
Example #15
0
         // Numerical questions
         //$newjava .= "(parseFloat(document.getElementById('" . $idname. "').value) $cd[6] parseFloat(document.getElementById('".$idname2."').value))";
         $newjava .= "(parseFloat({$JSsourceVal}) {$cd['6']} parseFloat(document.getElementById('{$idname2}').value))";
     } else {
         //				$newjava .= "(document.getElementById('" . $idname. "').value $cd[6] document.getElementById('".$idname2."').value)";
         $newjava .= "({$JSsourceVal} {$cd['6']} document.getElementById('{$idname2}').value)";
     }
 } elseif ($thissurvey['private'] == "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 question 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";
                     } else {
                         //$newjava .= "'tokenNoMatch' == 'tokenMatchNot'";
                         $newjava .= "false";
                     }
Example #16
0
 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";