Skip to content

Commit

Permalink
Dev: W3C validation and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Jan 28, 2016
1 parent 638aa48 commit a6072a5
Show file tree
Hide file tree
Showing 20 changed files with 1,847 additions and 191 deletions.
9 changes: 9 additions & 0 deletions application/config/third_party.php
Expand Up @@ -44,6 +44,15 @@
)

),


'jquery-price-format' => array(
'baseUrl' => 'third_party/jquery-price-format/',
'js' => array(
'jquery_price_format.js'
),
),

'jqgrid.addons' => array(
'baseUrl' => 'third_party/jqgrid/plugins/',
'js' => array(
Expand Down
10 changes: 8 additions & 2 deletions application/helpers/expressions/em_manager_helper.php
Expand Up @@ -4884,7 +4884,7 @@ static function StartSurvey($surveyid,$surveyMode='group',$aSurveyOptions=NULL,$
}
else
{
// We don't really validate date here, anyone can send anything : forced too
// We don't really validate date here, anyone can send anything : forced too
$dateformatdatat=getDateFormatData($LEM->surveyOptions['surveyls_dateformat']);
$datetimeobj = new Date_Time_Converter($value, $dateformatdatat['phpdate']);
$value=$datetimeobj->convert("Y-m-d H:i");
Expand Down Expand Up @@ -6527,8 +6527,14 @@ function _ValidateQuestion($questionSeq,$force=false)
$stringToParse = '';
foreach ($LEM->qid2validationEqn[$qid]['tips'] as $vclass=>$vtip)
{
$stringToParse .= "<div id='vmsg_" . $qid . '_' . $vclass . "' class='em_" . $vclass . " emtip text-info'><span class='glyphicon glyphicon-info-sign'></span> &nbsp" . $vtip . "</div>\n";
$tipsDatas = array(
'qid' =>$qid,
'vclass'=>$vclass,
'vtip' =>$vtip,
);
$stringToParse .= Yii::app()->getController()->renderPartial('/survey/system/questionhelp/tips', $tipsDatas, true);
}

$prettyPrintValidTip = $stringToParse;
$validTip = $LEM->ProcessString($stringToParse, $qid,NULL,false,1,1,false,false);
// TODO check for errors?
Expand Down
35 changes: 21 additions & 14 deletions application/helpers/qanda_helper.php
Expand Up @@ -1139,9 +1139,10 @@ function do_date($ia)
'dateoutput'=>htmlspecialchars($dateoutput,ENT_QUOTES,'utf-8'),
'checkconditionFunction'=>$checkconditionFunction.'(this.value, this.name, this.type)',
'dateformatdetails'=>$dateformatdetails['jsdate'],
'dateformat'=>$dateformatdetails['dateformat'],
);

$answer .= Yii::app()->getController()->renderPartial('/survey/questions/date/dropdown/data_footer', $footerData, true);
//
$answer .= Yii::app()->getController()->renderPartial('/survey/questions/date/dropdown/date_footer', $footerData, true);
App()->getClientScript()->registerScript("doDropDownDate{$ia[0]}","doDropDownDate({$ia[0]});",CClientScript::POS_HEAD);
// MayDo:
// add js code to
Expand All @@ -1164,8 +1165,7 @@ function do_date($ia)
// Format the date for output
$dateoutput=trim($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]]);
if ($dateoutput!='' & $dateoutput!='INVALID')
{
$datetimeobj = new Date_Time_Converter($dateoutput , "Y-m-d H:i");
{ $datetimeobj = new Date_Time_Converter($dateoutput , "Y-m-d H:i");
$dateoutput = $datetimeobj->convert($dateformatdetails['phpdate']);
}

Expand All @@ -1187,6 +1187,8 @@ function do_date($ia)
'checkconditionFunction'=>$checkconditionFunction.'(this.value, this.name, this.type)',
'language'=>App()->language,
'hidetip'=>trim($aQuestionAttributes['hide_tip'])==0,
'dateoutput'=>$dateoutput,
'qid' => $ia[0],
);

// HTML for date question using datepicker
Expand Down Expand Up @@ -2034,10 +2036,10 @@ function do_ranking($ia)
$myfname=$ia[1].$i;
if($i==1)
{
$labeltext .=gT('First choice');
$labeltext =gT('First choice');
}else
{
$labeltext .=sprintf(gT('Choice of rank %s'),$i);
$labeltext = sprintf(gT('Choice of rank %s'),$i);
}
$itemListHeaderDatas = array(
'myfname'=>$myfname,
Expand Down Expand Up @@ -2076,6 +2078,7 @@ function do_ranking($ia)
'id'=> '',
'optiontext'=>flattenText($ansrow['answer']),
);

$answer .= Yii::app()->getController()->renderPartial('/survey/questions/ranking/item', $itemDatas, true);
}
$itemlistfooterDatas = array(
Expand Down Expand Up @@ -2684,7 +2687,7 @@ function upload_$ia[1]() {
Yii::app()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts')."modaldialog.js");
Yii::app()->getClientScript()->registerCssFile(Yii::app()->getConfig('publicstyleurl') . "uploader-files.css");
// Modal dialog
$answer .= $uploadbutton;
//$answer .= $uploadbutton;

$filecountvalue = '0';
if (array_key_exists($ia[1]."_filecount", $_SESSION['survey_'.Yii::app()->getConfig('surveyID')]))
Expand Down Expand Up @@ -2986,7 +2989,7 @@ function do_multiplenumeric($ia)
//Must turn on the "numbers only javascript"
$extraclass .=" numberonly";
if ($aQuestionAttributes['thousands_separator'] == 1) {
//App()->clientScript->registerPackage('jquery-price-format');
App()->clientScript->registerPackage('jquery-price-format');
App()->clientScript->registerScriptFile(Yii::app()->getConfig('generalscripts').'numerical_input.js');
$extraclass .= " thousandsseparator";
}
Expand Down Expand Up @@ -3124,6 +3127,7 @@ function do_multiplenumeric($ia)
}

// color code missing mandatory questions red
$alert='';
if ($ia[6]=='Y' && $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname] === '')
{
$alert = true;
Expand Down Expand Up @@ -3162,6 +3166,7 @@ function do_multiplenumeric($ia)
'myfname'=>$myfname,
'dispVal'=>$dispVal,
'maxlength'=>$maxlength,
'labelText'=>$ansrow['question'],
'checkconditionFunction'=>$checkconditionFunction.'(this.value, this.name, this.type)',
);
$answer .= Yii::app()->getController()->renderPartial('/survey/questions/multiplenumeric/item', $itemDatas, true);
Expand All @@ -3188,15 +3193,16 @@ function do_multiplenumeric($ia)
'equals_num_value'=>$equals_num_value,
'id'=>$ia[0],
'prefix'=>$prefix,
'sumRemainingEqn'=>$qinfo['sumRemainingEqn'],
'sumRemainingEqn'=>(isset($qinfo))?$qinfo['sumRemainingEqn']:'',
'displaytotal'=>$displaytotal,
'sumEqn'=>$qinfo['sumEqn']
'sumEqn'=>(isset($qinfo))?$qinfo['sumEqn']:'',
);
$answer .= Yii::app()->getController()->renderPartial('/survey/questions/multiplenumeric/footer', $footerDatas, true);
}

if($aQuestionAttributes['slider_layout']==1)
{
Yii::app()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts')."bootstrap-slider.js");
Yii::app()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts')."numeric-slider.js");
Yii::app()->getClientScript()->registerCssFile(Yii::app()->getConfig('publicstyleurl') . "numeric-slider.css");
if ($slider_default != "")
Expand Down Expand Up @@ -3234,6 +3240,7 @@ function do_multiplenumeric($ia)
'slider_reset' => $slider_reset,
'lang'=> $aJsLang,
);

$answer .= "<script type='text/javascript'><!--\n"
. " doNumericSlider({$ia[0]},".ls_json_encode($aJsVar).");\n"
. " //--></script>";
Expand Down Expand Up @@ -3269,7 +3276,7 @@ function do_numerical($ia)
$prefix = '';
}
if ($aQuestionAttributes['thousands_separator'] == 1) {
//App()->clientScript->registerPackage('jquery-price-format');
App()->clientScript->registerPackage('jquery-price-format');
App()->clientScript->registerScriptFile(Yii::app()->getConfig('generalscripts').'numerical_input.js');
$extraclass .= " thousandsseparator";
}
Expand Down Expand Up @@ -3351,7 +3358,7 @@ function do_numerical($ia)
'maxlength'=>$maxlength,
'suffix'=>$suffix,
);
$answer .= Yii::app()->getController()->renderPartial('/survey/questions/numerical/item', $itemDatas, true);
$answer = Yii::app()->getController()->renderPartial('/survey/questions/numerical/item', $itemDatas, true);

$inputnames[]=$ia[1];
$mandatory=null;
Expand Down Expand Up @@ -3885,12 +3892,12 @@ function do_gender($ia)
'name'=>$ia[1],
'fChecked' => $fChecked,
'mChecked' => $mChecked,
'naChecked'=> $naChecke,
'naChecked'=> $naChecked,
'noAnswer' => $noAnswer,
'checkconditionFunction'=>$checkconditionFunction.'(this.value, this.name, this.type)',
'value' => $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]],
);
$answer .= Yii::app()->getController()->renderPartial('/survey/questions/gender/item', $itemDatas, true);
$answer = Yii::app()->getController()->renderPartial('/survey/questions/gender/item', $itemDatas, true);

$inputnames[]=$ia[1];
return array($answer, $inputnames);
Expand Down
Expand Up @@ -5,9 +5,10 @@
* @var $dateoutput htmlspecialchars($dateoutput,ENT_QUOTES,'utf-8')
* @var $checkconditionFunction $checkconditionFunction.'(this.value, this.name, this.type)
* @var $dateformatdetails $dateformatdetails['jsdate']
* @var $dateformat $dateformatdetails['dateformat']
*/
?>

<!-- Date footer-->
<input
class="text"
type="text"
Expand All @@ -17,9 +18,8 @@ class="text"
id="answer<?php echo $name; ?>"
value="<?php echo $dateoutput;?>"
maxlength="10"
alt="<?php eT('Answer'); ?>"
onchange="<?php echo $checkconditionFunction; ?>"
title="<?php sprintf(gT('Date in the format : %s'),$dateformatdetails['dateformat']);?>"
title="<?php echo sprintf(gT('Date in the format : %s'),$dateformat);?>"
/>
</p> <!-- Date item -->
<input type="hidden" id="dateformat<?php echo $name; ?>" value="<?php echo $dateformatdetails; ?>"/>
6 changes: 3 additions & 3 deletions application/views/survey/questions/date/dropdown/day.php
Expand Up @@ -11,12 +11,12 @@
</label>
<select id="day<?php echo $dayId;?>" name="day<?php echo $dayId;?>" class="form-control day">
<option value="">
<?php gT('Day'); ?>
<?php eT('Day'); ?>
</option>

<?php for ($i=1; $i<=31; $i++): ?>
<option value="<?php sprintf('%02d', $i); ?>" <?php if($i == $currentdate):?>SELECTED<?php endif; ?> >
<?php sprintf('%02d', $i); ?>
<option value="<?php echo sprintf('%02d', $i); ?>" <?php if($i == $currentdate):?>SELECTED<?php endif; ?> >
<?php echo sprintf('%02d', $i); ?>
</option>
<?php endfor; ?>
</select>
2 changes: 1 addition & 1 deletion application/views/survey/questions/date/dropdown/hour.php
Expand Up @@ -14,7 +14,7 @@
<?php for ($i=0; $i<24; $i++): ?>
<option value="<?php echo $i; ?>" <?php if ($i === (int)$currenthour && is_numeric($currenthour)):?>SELECTED<?php endif;?>>
<?php if ($datepart=='H'):?>
<?php sprintf('%02d', $i); ?>
<?php echo sprintf('%02d', $i); ?>
<?php else:?>
<?php echo $i;?>
<?php endif;?>
Expand Down
Expand Up @@ -19,7 +19,7 @@
<?php for($i=0; $i<60; $i+=$dropdown_dates_minute_step):?>
<option value="<?php echo $i; ?>" <?php if ($i === (int)$currentminute && is_numeric($currentminute)):?>SELECTED<?php endif;?> >
<?php if ($datepart=='i'):?>
<?php sprintf('%02d', $i);?>
<?php echo sprintf('%02d', $i);?>
<?php else:?>
<?php echo $i;?>
<?php endif;?>
Expand Down
2 changes: 1 addition & 1 deletion application/views/survey/questions/date/dropdown/month.php
Expand Up @@ -15,7 +15,7 @@
</option>

<?php for ($i=1; $i<=12; $i++):?>
<option value="<?php sprintf('%02d', $i); ?>" <?php if ($i == $currentmonth):?>SELECTED<?php endif; ?>>
<option value="<?php echo sprintf('%02d', $i); ?>" <?php if ($i == $currentmonth):?>SELECTED<?php endif; ?>>
<?php echo $montharray[$i-1]; ?>
</option>
<?php endfor;?>
Expand Down
11 changes: 4 additions & 7 deletions application/views/survey/questions/date/selector/selector.php
Expand Up @@ -2,6 +2,7 @@
/**
* Date Html, selector style :
* @var $name $ia[1]
* @var $qid $ia[0]
* @var $iLength
* @var $dateoutput
* @var $mindate
Expand All @@ -16,7 +17,7 @@
?>
<p class='question answer-item text-item date-item'>
<label for='answer<?php echo $name;?>' class='hide label'>
<?php sprintf(gT('Date in the format: %s'),$dateformatdetails); ?>
<?php echo sprintf(gT('Date in the format: %s'),$dateformatdetails); ?>
</label>

<input
Expand Down Expand Up @@ -57,12 +58,8 @@ class='popupdate'

<?php if($hidetip):?>
<p class="tip">
<?php sprintf(gT('Format: %s'),$dateformatdetails); ?>
<?php echo sprintf(gT('Format: %s'),$dateformatdetails); ?>
</p>
<?php endif;?>

<script type='text/javascript'>
/*<![CDATA[*/
doPopupDate(<?php echo $name; ?>);
/*]]>*/
</script>
<input type='hidden' class="namecontainer" data-name="<?php echo $qid; ?>" />
Expand Up @@ -32,4 +32,5 @@
</span>
</p>
<?php endif; ?>
</div>
</ul>
</div> <!-- Footer -->
10 changes: 5 additions & 5 deletions application/views/survey/questions/multiplenumeric/item.php
Expand Up @@ -20,16 +20,16 @@
<!-- question attribute "display_rows" is set -> we need a textarea to be able to show several rows -->
<li class="question-item answer-item text-item <?php echo $extraclass;?>" <?php echo $sDisplayStyle;?>>
<?php if($alert):?>
<div class="alert alert-danger errormandatory" role="alert">'.
<div class="alert alert-danger errormandatory" role="alert">
<?php echo $labelText;?>
</div>
</div> <!-- alert -->

<?php endif;?>
<div class="form-group-row row">
<label class='control-label col-xs-12' for="answer<?php echo $myfname; ?>">
<?php echo $labelText;?>
</label>
<div class="col-xs-12">
<div class="col-xs-12 input">
<?php echo $prefix;?>
<input
class="text form-control <?php echo $kpclass;?>"
Expand All @@ -42,6 +42,6 @@ class="text form-control <?php echo $kpclass;?>"
<?php echo $maxlength; ?>
/>
<?php echo $suffix;?>
</div>
</div>
</div> <!-- xs-12 -->
</div> <!-- form group -->
</li>
2 changes: 1 addition & 1 deletion application/views/survey/questions/numerical/item.php
Expand Up @@ -26,7 +26,7 @@ class='form-control text <?php echo $answertypeclass; ?>'
type="text"
size="<?php echo $tiwidth;?>"
name="<?php echo $id;?>"
title=<?php echo eT('Only numbers may be entered in this field.');?>"
title="<?php echo eT('Only numbers may be entered in this field.');?>"
id="answer<?php echo $id;?>"
value="<?php echo $fValue;?>"
onkeyup="<?php echo $checkconditionFunction; ?>(this.value, this.name, this.type,'onchange', <?php echo $integeronly; ?>);"
Expand Down
2 changes: 1 addition & 1 deletion application/views/survey/questions/ranking/item.php
Expand Up @@ -8,6 +8,6 @@
* @var $optiontext
*/
?>
<option value="<?php echo $value;?>" <?php echo $value;?> class='<?php echo $classes?>' id='<?php echo $id;?>'>
<option value="<?php echo $value;?>" class='<?php echo $classes?>' id='<?php echo $id;?>'>
<?php echo $optiontext;?>
</option>
2 changes: 1 addition & 1 deletion application/views/survey/questions/ranking/second_list.php
Expand Up @@ -24,7 +24,7 @@
<!-- The list with HTML answers -->
<div style="display:none">
<?php foreach ($answers as $ansrow):?>
<div id="htmlblock-<?php $rankId;?>-<?php echo $ansrow['code'];?>">
<div id="htmlblock-<?php echo $rankId;?>-<?php echo $ansrow['code'];?>">
<?php echo $ansrow['answer']; ?>
</div>
<?php endforeach;?>
Expand Down
12 changes: 12 additions & 0 deletions application/views/survey/system/questionhelp/tips.php
@@ -0,0 +1,12 @@
<?php
/**
* Question tips. For now, called from em_manager_helper::_ValidateQuestion
* @var $qid
* @var $vclass
* @var $vtip
*/
?>
<div id='vmsg_<?php echo $qid; ?>_<?php echo $vclass; ?>' class='em_<?php echo $vclass; ?> emtip text-info'>
<span class='glyphicon glyphicon-info-sign'></span>
&nbsp;<?php echo $vtip; ?>
</div>

0 comments on commit a6072a5

Please sign in to comment.