Skip to content
Permalink
Browse files

New feature #5807: ability to replace survey_runtime.js function in t…

…emplate

Fixed issue : time_limit attribute javascript error
Dev : add only one css/js file if needed for question
Dev : use css_header_includes and js_header_includes array from qanda
Dev : TODO remove double call to jquery-ui.css, problem with slider
  • Loading branch information
Shnoulle committed May 14, 2012
1 parent b830ac0 commit b216f3ef4276dfe518be1704416a0802851044ec
@@ -240,15 +240,14 @@ function run()
}
return;
}
$meta = '<script type="text/javascript">
$meta ='<script type="text/javascript" src="'.Yii::app()->getConfig("generalscripts").'jquery/jquery.js"></script>';
$meta .= '<script type="text/javascript">
var uploadurl = "'.$this->createUrl('/uploader/index/mode/upload/').'";
var imageurl = "'.Yii::app()->getConfig('imageurl').'/";
var surveyid = "'.$surveyid.'";
var fieldname = "'.$param['fieldname'].'";
var questgrppreview = '.$param['preview'].';
</script>';
$meta .='<script type="text/javascript" src="'.Yii::app()->getConfig("generalscripts").'/ajaxupload.js"></script>
<script type="text/javascript" src="'.Yii::app()->getConfig("generalscripts").'/uploader.js"></script>
<link type="text/css" href="'.Yii::app()->getConfig("generalscripts").'/uploader.css" rel="stylesheet" />';
@@ -7076,25 +7076,6 @@ function getHeader($meta = false)
$languagecode = Yii::app()->getConfig('defaultlang');
}
$js_header = ''; $css_header='';
if(Yii::app()->getConfig("js_admin_includes"))
{
foreach (Yii::app()->getConfig("js_admin_includes") as $jsinclude)
{
if (substr($jsinclude,0,4) == 'http')
$js_header .= "<script type=\"text/javascript\" src=\"{$jsinclude}\"></script>\n";
else
$js_header .= "<script type=\"text/javascript\" src=\"".Yii::app()->baseUrl."{$jsinclude}\"></script>\n";
}
}
if(Yii::app()->getConfig("css_admin_includes"))
{
foreach (Yii::app()->getConfig("css_admin_includes") as $cssinclude)
{
$css_header .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"".Yii::app()->baseUrl.$cssinclude."\" />\n";
}
}
if ( !$embedded )
{
$header= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"
@@ -7103,13 +7084,7 @@ function getHeader($meta = false)
{
$header.=" dir=\"rtl\" ";
}
$header.= ">\n\t<head>\n"
. $css_header
. "<script type=\"text/javascript\" src=\"".Yii::app()->getConfig('generalscripts')."jquery/jquery.js\"></script>\n"
. "<script type=\"text/javascript\" src=\"".Yii::app()->getConfig('generalscripts')."jquery/jquery-ui.js\"></script>\n"
. "<link href=\"".Yii::app()->getConfig('generalscripts')."jquery/css/start/jquery-ui.css\" media=\"all\" type=\"text/css\" rel=\"stylesheet\" />"
. "<link href=\"".Yii::app()->getConfig('generalscripts')."jquery/css/start/lime-progress.css\" media=\"all\" type=\"text/css\" rel=\"stylesheet\" />"
. $js_header;
$header.= ">\n\t<head>\n";
if ($meta)
$header .= $meta;
@@ -2857,7 +2857,7 @@ function UpdateSessionGroupList($surveyid, $language)
function SetSurveyLanguage($surveyid, $language)
{
$surveyid=sanitize_int($surveyid);
$defaultlang = Yii::app()->getConfig('defaultlang');
$default_language = Yii::app()->getConfig('defaultlang');
if (isset($surveyid) && $surveyid>0)
{
@@ -2891,7 +2891,7 @@ function SetSurveyLanguage($surveyid, $language)
{
$_SESSION['survey_'.$surveyid]['s_lang'] = $language;
Yii::import('application.libraries.Limesurvey_lang', true);
$clang = new Limesurvey_lang($defaultlang);
$clang = new Limesurvey_lang($language);
}
$oApplication=Yii::app();
@@ -1228,7 +1228,7 @@ function do_date($ia)
{
$js_header_includes[] = '/scripts/jquery/locale/jquery.ui.datepicker-'.$clang->langcode.'.js';
}
$css_header_includes[]= '/scripts/jquery/css/start/jquery-ui.css';
//$css_header_includes[]= '/scripts/jquery/css/start/jquery-ui.css'; already included by default
// Format the date for output
if (trim($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]])!='')
@@ -3022,11 +3022,8 @@ function do_file_upload($ia)
headFileName: '" . $clang->gT('File name','js') . "'
};
</script>\n";
/*if ($pos)
$answer .= "<script type='text/javascript' src='{$rooturl}/scripts/modaldialog.js'></script>";
else */
$answer .= "<script type='text/javascript' src='".Yii::app()->getBaseUrl(true)."/scripts/modaldialog.js'></script>";
//$js_header_includes[]= '/scripts/modaldialog.js'; //not working!
$js_header_includes[]= "<script type='text/javascript' src='".Yii::app()->getBaseUrl(true)."/scripts/modaldialog.js'></script>";
// Modal dialog
$answer .= $uploadbutton;
@@ -3423,7 +3420,7 @@ function do_multiplenumeric($ia)
{
$slider_layout=true;
$extraclass .=" withslider";
$css_header_includes[]= '/scripts/jquery/css/start/jquery-ui.css';
//$css_header_includes[]= '/scripts/jquery/css/start/jquery-ui.css'; already included by default
if (trim($aQuestionAttributes['slider_accuracy'])!='')
{
//$slider_divisor = 1 / $slider_accuracy['value'];
@@ -3592,7 +3589,7 @@ function do_multiplenumeric($ia)
$slider_showmax='';
}
$js_header_includes[] = '/scripts/jquery/jquery-ui.js';
//$js_header_includes[] = '/scripts/jquery/jquery-ui.js'; already included by default
$js_header_includes[] = '/scripts/jquery/lime-slider.js';
if (isset($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname]) && $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname] != '')
@@ -3680,7 +3677,7 @@ function do_multiplenumeric($ia)
// $answer_main .= $answer_computed;
// }
if($slider_layout){
$answer .= "<script type='text/javascript' src='".Yii::app()->baseUrl."/scripts/jquery/lime-slider.js'></script>";
$js_header_includes[]= "/scripts/jquery/lime-slider.js";
}
if (trim($aQuestionAttributes['equals_num_value']) != ''
|| trim($aQuestionAttributes['min_num_value']) != ''
@@ -122,12 +122,74 @@ function templatereplace($line, $replacements = array(), &$redata = array(), $de
if(!isset($templatedir)) $templatedir = getTemplatePath($templatename);
if(!isset($templateurl)) $templateurl = getTemplateURL($templatename)."/";
if (stripos ($line,"</head>"))
// TEMPLATECSS and TEMPLATEJS
$_templatecss="";$_templatejs="";
if(stripos ($line,"{TEMPLATECSS}"))
{
$line=str_ireplace("</head>",
"<script type=\"text/javascript\" src=\"".Yii::app()->getConfig('generalscripts')."survey_runtime.js\"></script>\n"
.useFirebug()
."\t</head>", $line);
global $css_header_includes;
if (file_exists($templatedir . '/jquery-ui-custom.css'))
{
$_jqueryuicssurl = "{$templateurl}jquery-ui-custom.css";
}
elseif(file_exists($templatedir . '/jquery-ui.css'))
{
$_jqueryuicssurl = "{$templateurl}jquery-ui.css";
}
# else
# { // Review for slider
# $_jqueryuicssurl =Yii::app()->getConfig('generalscripts')."jquery/css/start/jquery-ui.css";
# }
$_templatecss .="<link rel='stylesheet' type='text/css' media='all' href='".Yii::app()->getConfig('generalscripts')."jquery/css/start/jquery-ui.css' />\n"; // Remove it after corrected slider
$_templatecss.= "<link rel='stylesheet' type='text/css' media='all' href='{$_jqueryuicssurl}' />\n";
if(Yii::app()->getConfig("css_admin_includes"))
{
if(!$js_header_includes){$js_header_includes=array();}
foreach (Yii::app()->getConfig("css_admin_includes") as $cssinclude)
{
$css_header_includes[] = $cssinclude;
}
}
$_templatecss .= "<link href='".Yii::app()->getConfig('generalscripts')."jquery/css/start/lime-progress.css' media='all' type='text/css' rel='stylesheet' />\n";
if($css_header_includes){
$css_header_includes = array_unique($css_header_includes);
foreach ($css_header_includes as $cssinclude)
{
$_templatecss .= "<link rel='stylesheet' type='text/css' media='all' href='".Yii::app()->baseUrl.$cssinclude."' />\n";
}
}
$_templatecss.= "<link rel='stylesheet' type='text/css' media='all' href='{$templateurl}template.css' />\n";
if (getLanguageRTL($clang->langcode))
{
$_templatecss.="<link rel='stylesheet' type='text/css' media='all' href='{$templateurl}template-rtl.css' />\n";
}
}
if(stripos ($line,"{TEMPLATEJS}"))
{
global $js_header_includes;
$_jqueryuijsurl=Yii::app()->getConfig('generalscripts')."jquery/jquery-ui.js";
$_templatejs.= "<script type='text/javascript' src='".Yii::app()->getConfig('generalscripts')."jquery/jquery.js'></script>\n";
$_templatejs.= "<script type='text/javascript' src='{$_jqueryuijsurl}'></script>\n";
if(Yii::app()->getConfig("js_admin_includes"))
{
if(!$js_header_includes){$js_header_includes=array();}
foreach (Yii::app()->getConfig("js_admin_includes") as $jsinclude)
{
$js_header_includes[]=$jsinclude;
}
}
if($js_header_includes){
$js_header_includes = array_unique($js_header_includes);
foreach ($js_header_includes as $jsinclude)
{
if (substr($jsinclude,0,4) == 'http')
$_templatejs .= "<script type='text/javascript' src='{$jsinclude}'></script>\n";
else
$_templatejs .= "<script type='text/javascript' src='".Yii::app()->baseUrl.$jsinclude."'></script>\n";
}
}
$_templatejs.= "<script type='text/javascript' src='".Yii::app()->getConfig('generalscripts')."survey_runtime.js'></script>\n";
$_templatejs.= "<script type='text/javascript' src='{$templateurl}template.js'></script>\n";
$_templatejs.= useFirebug();
}
// surveyformat
@@ -402,12 +464,6 @@ function templatereplace($line, $replacements = array(), &$redata = array(), $de
$_saveall = "";
}
$_templatecss = "<link rel='stylesheet' type='text/css' href='{$templateurl}template.css' />\n";
if (getLanguageRTL($clang->langcode))
{
$_templatecss.="<link rel='stylesheet' type='text/css' href='{$templateurl}template-rtl.css' />\n";
}
if(!isset($help)) $help = "";
if (flattenText($help, true,true) != '')
{
@@ -776,6 +832,7 @@ function templatereplace($line, $replacements = array(), &$redata = array(), $de
$coreReplacements['SURVEYLISTHEADING'] = (isset($surveylist))?$surveylist['listheading']:'';
$coreReplacements['SURVEYNAME'] = (isset($thissurvey['name']) ? $thissurvey['name'] : '');
$coreReplacements['TEMPLATECSS'] = $_templatecss;
$coreReplacements['TEMPLATEJS'] = $_templatejs;
$coreReplacements['TEMPLATEURL'] = $templateurl;
$coreReplacements['THEREAREXQUESTIONS'] = $_therearexquestions;
if (!$anonymized) $coreReplacements['TOKEN'] = $_token;
@@ -3,7 +3,8 @@
<title>{SURVEYNAME} :: {GROUPNAME}</title>
<meta name="generator" content="LimeSurvey http://www.limesurvey.org" />

<link rel="stylesheet" type="text/css" href="{TEMPLATEURL}jquery-ui-custom.css" />

<!-- The following line includes jquery-ui.css or jquery-ui-custom.css from template dir, template.css and needed specific css file for survey -->
{TEMPLATECSS}

<!--[if lte IE 6]>
@@ -20,8 +21,8 @@
<style type="text/css" media="aural tty">
progress-graph .zero, progress-graph .graph, progress-graph .cent { display: none; }
</style>
<script type="text/javascript" src="{TEMPLATEURL}template.js"></script>
<!-- The following line includes jquery.js, jquery-ui.js, survey_runtime.js , template.js and needed specific js file for survey -->
{TEMPLATEJS}
<link rel="shortcut icon" href="{TEMPLATEURL}favicon.ico" />
{GOOGLE_ANALYTICS_JAVASCRIPT}
</head>
@@ -1,13 +1,9 @@

<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>
{SURVEYNAME}
</title>
<meta name="generator" content="LimeSurvey http://www.limesurvey.org" />

<link rel="stylesheet" type="text/css" href="{TEMPLATEURL}jquery-ui-custom.css" />

<!-- The following line includes template.css and if an RTL-language is used template-rtl.css -->
<!-- The following line includes jquery-ui.css or jquery-ui-custom.css from template dir, template.css and needed specific css file for survey -->
{TEMPLATECSS}

<!--[if lte IE 6]>
@@ -24,8 +20,8 @@
<style type="text/css" media="aural tty">
progress-graph .zero, progress-graph .graph, progress-graph .cent { display: none; }
</style>
<script type="text/javascript" src="{TEMPLATEURL}template.js"></script>
<!-- The following line includes jquery.js, jquery-ui.js, survey_runtime.js , template.js and needed specific js file for survey -->
{TEMPLATEJS}
<link rel="shortcut icon" href="{TEMPLATEURL}favicon.ico" />
{GOOGLE_ANALYTICS_JAVASCRIPT}
</head>
@@ -1,25 +1,21 @@
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>{SURVEYNAME} {GROUPNAME} {SITENAME}</title>
<meta name="generator" content="LimeSurvey http://www.limesurvey.org" />

<meta name="viewport" content="width=device-width" />
<!-- The following CSS hides visual elements of the progress bar from screen readers. -->
<style type="text/css" media="aural tty">
progress-graph .zero, progress-graph .graph, progress-graph .cent { display: none; }
</style>
<!-- The following line includes template.css and if an RTL-language is used template-rtl.css -->
<title>{SURVEYNAME} {GROUPNAME} {SITENAME}</title>
<meta name="generator" content="LimeSurvey http://www.limesurvey.org" />
<meta name="viewport" content="width=device-width" />
<!-- The following line includes jquery-ui.css or jquery-ui-custom.css from template dir, template.css and needed specific css file for survey -->
{TEMPLATECSS}
<link rel="stylesheet" type="text/css" media="print" href="{TEMPLATEURL}print.css" />
<link rel="shortcut icon" href="{TEMPLATEURL}favicon.ico" />
{GOOGLE_ANALYTICS_JAVASCRIPT}
<link rel="stylesheet" type="text/css" media="print" href="{TEMPLATEURL}print.css" />
<link rel="shortcut icon" href="{TEMPLATEURL}favicon.ico" />
<!-- The following line includes jquery.js, jquery-ui.js, survey_runtime.js , template.js and needed specific js file for survey -->
{TEMPLATEJS}
{GOOGLE_ANALYTICS_JAVASCRIPT}
</head>
<!--[if lt IE 7 ]> <body class="lang-{SURVEYLANGUAGE} {SURVEYFORMAT} ie ie6 no-js"> <![endif]-->
<!--[if IE 7 ]> <body class="lang-{SURVEYLANGUAGE} {SURVEYFORMAT} ie ie7 no-js"> <![endif]-->
<!--[if IE 8 ]> <body class="lang-{SURVEYLANGUAGE} {SURVEYFORMAT} ie ie8 no-js"> <![endif]-->
<!--[if IE 9 ]> <body class="lang-{SURVEYLANGUAGE} {SURVEYFORMAT} ie ie9 no-js"> <![endif]-->
<!--[if gt IE 9]><!--><body id="body" class="lang-{SURVEYLANGUAGE} {SURVEYFORMAT} no-js"><!--<![endif]-->
<script type='text/javascript'>/*<![CDATA[*/(function(H){ H.className=H.className.replace(/\bno-js\b/,'js') })(document.getElementsByTagName('body')[0]);/*]]>*/</script>
<script type="text/javascript" src="{TEMPLATEURL}template.js"></script>
<div id="container">
<div id="head">
<div class="wrapper">
@@ -51,6 +51,11 @@ ul#surveylist{list-style:none}
#progress-wrapper .ui-widget-content{float:left;width:150px;height:1em;text-align:left;border-color:#666;border-style:solid;border-width:1px}
#progress-wrapper .ui-widget-header{background-color:#AAA;background-image:none;border:1px solid #666}
#progress-wrapper #progress-post{float:left;width:45px;text-align:left;margin:0 0 0 5px}
@media reader {
#progressbar,#progress-pre,#progress-post{display:none}
}


.ui-slider{width:15em;display:inline-block;border:1px solid #666;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;margin:.4em 0 .2em}
.slider_showmin{float:left;width:3em;font-size:.7em;font-weight:400;text-align:left;color:#666;margin:1.4em 0 0}
.slider_showmax{float:right;width:3em;font-size:.7em;font-weight:400;text-align:right;color:#666;margin:1.4em 0 0}
@@ -3,9 +3,7 @@

<title>{SURVEYNAME} :: {GROUPNAME}</title>

<link rel="stylesheet" type="text/css" href="{TEMPLATEURL}jquery-ui-custom.css" />

<!-- The following line includes template.css and if an RTL-language is used template-rtl.css -->
<!-- The following line includes jquery-ui.css or jquery-ui-custom.css from template dir, template.css and needed specific css file for survey -->
{TEMPLATECSS}

<!--[if lte IE 6]>
@@ -22,8 +20,8 @@
<style type="text/css" media="aural tty">
progress-graph .zero, progress-graph .graph, progress-graph .cent { display: none; }
</style>
<script type="text/javascript" src="{TEMPLATEURL}template.js"></script>
<!-- The following line includes jquery.js, jquery-ui.js, survey_runtime.js , template.js and needed specific js file for survey -->
{TEMPLATEJS}
<link rel="shortcut icon" href="{TEMPLATEURL}favicon.ico" />
{GOOGLE_ANALYTICS_JAVASCRIPT}
</head>
@@ -2,10 +2,8 @@
<title>{SURVEYNAME}</title>
<meta name="generator" content="LimeSurvey http://www.limesurvey.org" />

<link rel="stylesheet" type="text/css" href="{TEMPLATEURL}jquery-ui-custom.css" />

<!-- The following line includes template.css and if an RTL-language is used template-rtl.css -->
{TEMPLATECSS}
<!-- The following line includes jquery-ui.css or jquery-ui-custom.css from template dir, template.css and needed specific css file for survey -->
{TEMPLATECSS}

<!--[if lte IE 6]>
<link rel="stylesheet" type="text/css" href="{TEMPLATEURL}ie_fix_6.css" />
@@ -21,8 +19,8 @@
<style type="text/css" media="aural tty">
progress-graph .zero, progress-graph .graph, progress-graph .cent { display: none; }
</style>
<script type="text/javascript" src="{TEMPLATEURL}template.js"></script>
<!-- The following line includes jquery.js, jquery-ui.js, survey_runtime.js , template.js and needed specific js file for survey -->
{TEMPLATEJS}
<link rel="shortcut icon" href="{TEMPLATEURL}favicon.ico" />
{GOOGLE_ANALYTICS_JAVASCRIPT}
</head>
@@ -1,11 +1,8 @@

<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title> {SURVEYNAME} </title>
<meta name="generator" content="LimeSurvey http://www.limesurvey.org" />

<link rel="stylesheet" type="text/css" href="{TEMPLATEURL}jquery-ui-custom.css" />

<!-- The following line includes template.css and if an RTL-language is used template-rtl.css -->
<!-- The following line includes jquery-ui.css or jquery-ui-custom.css from template dir, template.css and needed specific css file for survey -->
{TEMPLATECSS}

<!--[if lte IE 6]>
@@ -22,8 +19,8 @@
<style type="text/css" media="aural tty">
progress-graph .zero, progress-graph .graph, progress-graph .cent { display: none; }
</style>
<script type="text/javascript" src="{TEMPLATEURL}template.js"></script>
<!-- The following line includes jquery.js, jquery-ui.js, survey_runtime.js , template.js and needed specific js file for survey -->
{TEMPLATEJS}
<link rel="shortcut icon" href="{TEMPLATEURL}favicon.ico" />
{GOOGLE_ANALYTICS_JAVASCRIPT}
</head>

0 comments on commit b216f3e

Please sign in to comment.
You can’t perform that action at this time.