Skip to content

Commit

Permalink
Fixed issue #4518: Template editor notices if you view Printable Surv…
Browse files Browse the repository at this point in the history
…ey Page

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey@9037 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
c-schmitz committed Aug 6, 2010
1 parent d415964 commit aa4d4e8
Showing 1 changed file with 100 additions and 104 deletions.
204 changes: 100 additions & 104 deletions admin/templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,8 @@
</tr>
</table>";
$addbr=false;
$templaterootdir=sGetTemplatePath($templatename);
$templaterooturl=sGetTemplateURL($templatename);
switch($screenname) {
case 'surveylist':
unset($files);
Expand Down Expand Up @@ -548,7 +550,6 @@
foreach($Register as $qs) {
$files[]=array("name"=>$qs);
}
$templaterootdir=sGetTemplatePath($templatename);
foreach(file("$templaterootdir/startpage.pstpl") as $op)
{
$myoutput[]=templatereplace($op);
Expand All @@ -573,7 +574,6 @@
foreach($Save as $qs) {
$files[]=array("name"=>$qs);
}
$templaterootdir=sGetTemplatePath($templatename);

foreach(file("$templaterootdir/startpage.pstpl") as $op)
{
Expand All @@ -595,7 +595,6 @@
foreach($Load as $qs) {
$files[]=array("name"=>$qs);
}
$templaterootdir=sGetTemplatePath($templatename);

foreach(file("$templaterootdir/startpage.pstpl") as $op)
{
Expand All @@ -617,7 +616,6 @@
foreach ($Clearall as $qs) {
$files[]=array("name"=>$qs);
}
$templaterootdir=sGetTemplatePath($templatename);

foreach(file("$templaterootdir/startpage.pstpl") as $op)
{
Expand All @@ -643,112 +641,110 @@
}
break;

case 'printablesurvey':
unset($files);
foreach ($printablesurveytemplate as $qs) {
$files[]=array("name"=>$qs);
}
$templaterootdir=sGetTemplatePath($templatename);
case 'printablesurvey':
unset($files);
foreach ($printablesurveytemplate as $qs) {
$files[]=array("name"=>$qs);
}

$questionoutput=array();
$questionoutput=array();
foreach(file("$templaterootdir/print_question.pstpl") as $op)
{ // echo '<pre>line '.__LINE__.'$op = '.htmlspecialchars(print_r($op)).'</pre>';
$questionoutput[]=templatereplace($op, array(
'QUESTION_NUMBER'=>'1',
'QUESTION_CODE'=>'Q1',
'QUESTION_MANDATORY' => $clang->gT('*'),
'QUESTION_SCENARIO' => 'Only answer this if certain conditions are met.', // if there are conditions on a question, list the conditions.
'QUESTION_CLASS' => ' mandatory list-radio',
'QUESTION_TYPE_HELP' => $clang->gT('Please choose *only one* of the following:'),
'QUESTION_MAN_MESSAGE' => '', // (not sure if this is used) mandatory error
'QUESTION_VALID_MESSAGE' => '', // (not sure if this is used) validation error
'QUESTION_TEXT'=>'This is a sample question text. The user was asked to pick an entry.',
'QUESTIONHELP'=>'This is some help text for this question.',
'ANSWER'=>'<ul>
<li>
<img src="'.$templaterooturl.'/'.$templatename.'/print_img_radio.png" alt="First choice" class="input-radio" height="14" width="14">
First choice
</li>
<li>
<img src="'.$templaterooturl.'/'.$templatename.'/print_img_radio.png" alt="Second choice" class="input-radio" height="14" width="14">
Second choice
</li>
<li>
<img src="'.$templaterooturl.'/'.$templatename.'/print_img_radio.png" alt="Third choice" class="input-radio" height="14" width="14">
Third choice
</li>
</ul>'
));
}
$groupoutput=array();
{ // echo '<pre>line '.__LINE__.'$op = '.htmlspecialchars(print_r($op)).'</pre>';
$questionoutput[]=templatereplace($op, array(
'QUESTION_NUMBER'=>'1',
'QUESTION_CODE'=>'Q1',
'QUESTION_MANDATORY' => $clang->gT('*'),
'QUESTION_SCENARIO' => 'Only answer this if certain conditions are met.', // if there are conditions on a question, list the conditions.
'QUESTION_CLASS' => ' mandatory list-radio',
'QUESTION_TYPE_HELP' => $clang->gT('Please choose *only one* of the following:'),
'QUESTION_MAN_MESSAGE' => '', // (not sure if this is used) mandatory error
'QUESTION_VALID_MESSAGE' => '', // (not sure if this is used) validation error
'QUESTION_TEXT'=>'This is a sample question text. The user was asked to pick an entry.',
'QUESTIONHELP'=>'This is some help text for this question.',
'ANSWER'=>'<ul>
<li>
<img src="'.$templaterooturl.'/'.$templatename.'/print_img_radio.png" alt="First choice" class="input-radio" height="14" width="14">
First choice
</li>
<li>
<img src="'.$templaterooturl.'/'.$templatename.'/print_img_radio.png" alt="Second choice" class="input-radio" height="14" width="14">
Second choice
</li>
<li>
<img src="'.$templaterooturl.'/'.$templatename.'/print_img_radio.png" alt="Third choice" class="input-radio" height="14" width="14">
Third choice
</li>
</ul>'
));
}
$groupoutput=array();
foreach(file("$templaterootdir/print_group.pstpl") as $op)
{
$groupoutput[]=templatereplace($op, array('QUESTIONS'=>implode(' ',$questionoutput)));
}
{
$groupoutput[]=templatereplace($op, array('QUESTIONS'=>implode(' ',$questionoutput)));
}
foreach(file("$templaterootdir/print_survey.pstpl") as $op)
{
$myoutput[]=templatereplace($op, array('GROUPS'=>implode(' ',$groupoutput),
'FAX_TO' => $clang->gT("Please fax your completed survey to:")." 000-000-000",
'SUBMIT_TEXT'=> $clang->gT("Submit your survey."),
'HEADELEMENTS'=>getPrintableHeader(),
'SUBMIT_BY' => sprintf($clang->gT("Please submit by %s"), date('d.m.y')),
'THANKS'=>$clang->gT('Thank you for completing this survey.'),
'END'=>$clang->gT('This is the survey end message.')
));
}
break;

case 'printanswers':
unset($files);
foreach ($printtemplate as $qs) {
$files[]=array("name"=>$qs);
}
$templaterootdir=sGetTemplatePath($templatename);
foreach(file("$templaterootdir/startpage.pstpl") as $op)
{
$myoutput[]=templatereplace($op);
}
foreach(file("$templaterootdir/printanswers.pstpl") as $op)
{
$myoutput[]=templatereplace($op);
}
foreach(file("$templaterootdir/endpage.pstpl") as $op)
{
$myoutput[]=templatereplace($op);
}
$myoutput[]= "\n";
break;
}
$myoutput[]="</html>";

if (is_array($files)) {
$match=0;
foreach ($files as $f) {
if ($editfile == $f["name"]) {
$match=1;
}
}
foreach ($cssfiles as $f) {
if ($editfile == $f["name"]) {
$match=1;
}
}
if ($match == 0) {
if (count($files) > 0) {
$editfile=$files[0]["name"];
} else {
$editfile="";
}
}
}
//Get list of 'otherfiles'
$otherfiles=array();
$dirloc=sGetTemplatePath($templatename);
if ($handle = opendir($dirloc)) {
{
$myoutput[]=templatereplace($op, array('GROUPS'=>implode(' ',$groupoutput),
'FAX_TO' => $clang->gT("Please fax your completed survey to:")." 000-000-000",
'SUBMIT_TEXT'=> $clang->gT("Submit your survey."),
'HEADELEMENTS'=>getPrintableHeader(),
'SUBMIT_BY' => sprintf($clang->gT("Please submit by %s"), date('d.m.y')),
'THANKS'=>$clang->gT('Thank you for completing this survey.'),
'END'=>$clang->gT('This is the survey end message.')
));
}
break;

case 'printanswers':
unset($files);
foreach ($printtemplate as $qs) {
$files[]=array("name"=>$qs);
}
foreach(file("$templaterootdir/startpage.pstpl") as $op)
{
$myoutput[]=templatereplace($op);
}
foreach(file("$templaterootdir/printanswers.pstpl") as $op)
{
$myoutput[]=templatereplace($op);
}
foreach(file("$templaterootdir/endpage.pstpl") as $op)
{
$myoutput[]=templatereplace($op);
}
$myoutput[]= "\n";
break;
}
$myoutput[]="</html>";

if (is_array($files)) {
$match=0;
foreach ($files as $f) {
if ($editfile == $f["name"]) {
$match=1;
}
}
foreach ($cssfiles as $f) {
if ($editfile == $f["name"]) {
$match=1;
}
}
if ($match == 0) {
if (count($files) > 0) {
$editfile=$files[0]["name"];
} else {
$editfile="";
}
}
}

//Get list of 'otherfiles'
$otherfiles=array();
if ($handle = opendir($templaterootdir)) {
while(false !== ($file = readdir($handle))) {
if (!array_search($file, $normalfiles)) {
if (!is_dir("$dirloc/$file")) {
if (!is_dir($templaterootdir.DIRECTORY_SEPARATOR.$file)) {
$otherfiles[]=array("name"=>$file);
}
}
Expand Down

0 comments on commit aa4d4e8

Please sign in to comment.