/
templates.php
1162 lines (1056 loc) · 48.4 KB
/
templates.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/*
* LimeSurvey
* Copyright (C) 2007 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: GNU/GPL License v2 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
* $Id$
*/
include_once("login_check.php");
// Standard templates
$standardtemplates=array('basic',
'bluengrey',
'business_grey',
'clear_logo',
'default',
'eirenicon',
'limespired',
'mint_idea',
'sherpa',
'vallendar');
//Standard Template Subfiles
//Only these files may be edited or saved
$files[]=array('name'=>'assessment.pstpl');
$files[]=array('name'=>'clearall.pstpl');
$files[]=array('name'=>'completed.pstpl');
$files[]=array('name'=>'endgroup.pstpl');
$files[]=array('name'=>'endpage.pstpl');
$files[]=array('name'=>'groupdescription.pstpl');
$files[]=array('name'=>'load.pstpl');
$files[]=array('name'=>'navigator.pstpl');
$files[]=array('name'=>'printanswers.pstpl');
$files[]=array('name'=>'privacy.pstpl');
$files[]=array('name'=>'question.pstpl');
$files[]=array('name'=>'question_start.pstpl');
$files[]=array('name'=>'register.pstpl');
$files[]=array('name'=>'save.pstpl');
$files[]=array('name'=>'surveylist.pstpl');
$files[]=array('name'=>'startgroup.pstpl');
$files[]=array('name'=>'startpage.pstpl');
$files[]=array('name'=>'survey.pstpl');
$files[]=array('name'=>'welcome.pstpl');
$files[]=array('name'=>'print_survey.pstpl');
$files[]=array('name'=>'print_group.pstpl');
$files[]=array('name'=>'print_question.pstpl');
//Standard CSS Files
//These files may be edited or saved
$cssfiles[]=array('name'=>'template.css');
$cssfiles[]=array('name'=>'ie_fix_6.css');
$cssfiles[]=array('name'=>'ie_fix_7.css');
$cssfiles[]=array('name'=>'ie_fix_8.css');
$cssfiles[]=array('name'=>'print_template.css');
$cssfiles[]=array('name'=>'template.js');
//Standard screens
//Only these may be viewed
$screens[]=array('name'=>$clang->gT('Survey List Page', 'unescaped'));
$screens[]=array('name'=>$clang->gT('Welcome Page', 'unescaped'));
$screens[]=array('name'=>$clang->gT('Question Page', 'unescaped'));
$screens[]=array('name'=>$clang->gT('Completed Page', 'unescaped'));
$screens[]=array('name'=>$clang->gT('Clear All Page', 'unescaped'));
$screens[]=array('name'=>$clang->gT('Register Page', 'unescaped'));
$screens[]=array('name'=>$clang->gT('Load Page', 'unescaped'));
$screens[]=array('name'=>$clang->gT('Save Page', 'unescaped'));
$screens[]=array('name'=>$clang->gT('Print answers page', 'unescaped'));
$screens[]=array('name'=>$clang->gT('Printable survey page', 'unescaped'));
//Page display blocks
$SurveyList=array('startpage.pstpl',
'surveylist.pstpl',
'endpage.pstpl'
);
$Welcome=array('startpage.pstpl',
'welcome.pstpl',
'privacy.pstpl',
'navigator.pstpl',
'endpage.pstpl'
);
$Question=array('startpage.pstpl',
'survey.pstpl',
'startgroup.pstpl',
'groupdescription.pstpl',
'question_start.pstpl',
'question.pstpl',
'endgroup.pstpl',
'navigator.pstpl',
'endpage.pstpl'
);
$CompletedTemplate=array(
'startpage.pstpl',
'assessment.pstpl',
'completed.pstpl',
'endpage.pstpl'
);
$Clearall=array('startpage.pstpl',
'clearall.pstpl',
'endpage.pstpl'
);
$Register=array('startpage.pstpl',
'survey.pstpl',
'register.pstpl',
'endpage.pstpl'
);
$Save=array('startpage.pstpl',
'save.pstpl',
'endpage.pstpl'
);
$Load=array('startpage.pstpl',
'load.pstpl',
'endpage.pstpl'
);
$printtemplate=array('startpage.pstpl',
'printanswers.pstpl',
'endpage.pstpl'
);
$printablesurveytemplate=array('print_survey.pstpl',
'print_group.pstpl',
'print_question.pstpl'
);
// Set this so common.php doesn't throw notices about undefined variables
$thissurvey['active']='N';
$file_version="LimeSurvey template editor ".$versionnumber;
$_SESSION['s_lang']=$_SESSION['adminlang'];
if (!isset($templatename)) {$templatename = sanitize_paranoid_string(returnglobal('templatename'));}
if (!isset($templatedir)) {$templatedir = sanitize_paranoid_string(returnglobal('templatedir'));}
if (!isset($editfile)) {$editfile = sanitize_paranoid_string(returnglobal('editfile'));}
if (!isset($screenname)) {$screenname=auto_unescape(returnglobal('screenname'));}
// Checks if screen name is in the list of allowed screen names
if ( isset($screenname) && (multiarray_search($screens,'name',$screenname)===false)) {die('Invalid screen name');} // Die you sneaky bastard!
if (!isset($action)) {$action=sanitize_paranoid_string(returnglobal('action'));}
if (!isset($subaction)) {$subaction=sanitize_paranoid_string(returnglobal('subaction'));}
if (!isset($otherfile)) {$otherfile = sanitize_paranoid_string(returnglobal('otherfile'));}
if (!isset($newname)) {$newname = sanitize_paranoid_string(returnglobal('newname'));}
if (!isset($copydir)) {$copydir = sanitize_paranoid_string(returnglobal('copydir'));}
$js_adminheader_includes[]= $homeurl."/scripts/edit_area/edit_area_loader.js";
$js_adminheader_includes[]= $homeurl."/scripts/templates.js";
// find out language for code editor
$availableeditorlanguages=array('bg','cs','de','dk','en','eo','es','fi','fr','hr','it','ja','mk','nl','pl','pt','ru','sk','zh');
$extension = substr(strrchr($editfile, "."), 1);
if ($extension=='css' || $extension=='js') {$highlighter=$extension;} else {$highlighter='html';};
if(in_array($_SESSION['adminlang'],$availableeditorlanguages)) {$codelanguage=$_SESSION['adminlang'];}
else {$codelanguage='en';}
if (isset ($_POST['changes'])) {
$changedtext=$_POST['changes'];
$changedtext=str_replace ('<?','',$changedtext);
if(get_magic_quotes_gpc())
{
$changedtext = stripslashes($changedtext);
}
}
if (isset ($_POST['changes_cp'])) {
$changedtext=$_POST['changes_cp'];
$changedtext=str_replace ('<?','',$changedtext);
if(get_magic_quotes_gpc())
{
$changedtext = stripslashes($changedtext);
}
}
$template_a=gettemplatelist();
foreach ($template_a as $tp) {
$templates[]=array("name"=>$tp, "dir"=>$templaterootdir."/".$tp);
}
unset($template_a);
// check if a template like this exists
if (recursive_in_array($templatename,$templates)===false)
{
$templatename = $defaulttemplate;
}
if ($subaction == "delete" && is_template_editable($templatename)==true)
{
rmdirr($templaterootdir."/".$templatename);
$templatequery = "UPDATE {$dbprefix}surveys set template='$defaulttemplate' where template='$templatename'\n";
$connect->Execute($templatequery) or safe_die ("Couldn't update surveys with default template!<br />\n$utquery<br />\n".$connect->ErrorMsg()); //Checked
$flashmessage=sprintf($clang->gT("Template '%s' was successfully deleted."),$templatename);
$templatename = $defaulttemplate;
}
if ($action == "templateupload")
{
include("import_resources_zip.php");
}
//Save Changes if necessary
if ($action=="templatesavechanges" && $changedtext) {
$changedtext=str_replace("\r\n", "\n", $changedtext);
if ($editfile) {
// Check if someone tries to submit a file other than one of the allowed filenames
if (multiarray_search($files,'name',$editfile)===false && multiarray_search($cssfiles,'name',$editfile)===false) {die('Invalid template filename');} // Die you sneaky bastard!
$savefilename=$templaterootdir."/".$templatename."/".$editfile;
if (is_writable($savefilename)) {
if (!$handle = fopen($savefilename, 'w')) {
echo "Could not open file ($savefilename)";
exit;
}
if (!fwrite($handle, $changedtext)) {
echo "Cannot write to file ($savefilename)";
exit;
}
fclose($handle);
} else {
echo "The file $savefilename is not writable";
}
}
}
if ($action == "templatecopy" && isset($newname) && isset($copydir)) {
//Copies all the files from one template directory to a new one
//This is a security issue because it is allowing copying from get variables...
$newdirname=$templaterootdir."/".$newname;
$copydirname=$templaterootdir."/".$copydir;
$mkdirresult=mkdir_p($newdirname);
if ($mkdirresult == 1) {
$copyfiles=getListOfFiles($copydirname);
foreach ($copyfiles as $file) {
$copyfile=$copydirname."/".$file;
$newfile=$newdirname."/".$file;
if (!copy($copyfile, $newfile)) {
echo "<script type=\"text/javascript\">\n<!--\nalert(\"".sprintf($clang->gT("Failed to copy %s to new template directory.","js"), $file)."\");\n//-->\n</script>";
}
}
$templates[]=array("name"=>$newname, "dir"=>$newdirname);
$templatename=$newname;
} elseif($mkdirresult == 2) {
echo "<script type=\"text/javascript\">\n<!--\nalert(\"".sprintf($clang->gT("Directory with the name `%s` already exists - choose another name","js"), $newname)."\");\n//-->\n</script>";
} else {
echo "<script type=\"text/javascript\">\n<!--\nalert(\"".sprintf($clang->gT("Unable to create directory `%s`.","js"), $newname)." ".$clang->gT("Please check the directory permissions.","js")."\");\n//-->\n</script>";
}
}
if ($action == "templaterename" && isset($newname) && isset($copydir)) {
$newdirname=$templaterootdir."/".$newname;
$olddirname=$templaterootdir."/".$copydir;
if (rename($olddirname, $newdirname)==false) {
echo "<script type=\"text/javascript\">\n<!--\nalert(\"".sprintf($clang->gT("Directory could not be renamed to `%s`.","js"), $newname)." ".$clang->gT("Maybe you don't have permission.","js")."\");\n//-->\n</script>";
} else {
$templates[]=array("name"=>$newname, "dir"=>$newdirname);
$templatename=$newname;
}
}
if ($action == "templateuploadfile")
{
if ($demoModeOnly == true)
{
$action = '';
} else
{
$the_full_file_path = $templaterootdir."/".$templatename . "/" . $_FILES['the_file']['name']; //This is where the temp file is
if ($extfile = strrchr($_FILES['the_file']['name'], '.'))
{
if (!(stripos(','.$allowedtemplateuploads.',',','. substr($extfile,1).',') === false))
{
//Uploads the file into the appropriate directory
if (!@move_uploaded_file($_FILES['the_file']['tmp_name'], $the_full_file_path)) {
echo "<strong><font color='red'>".$clang->gT("Error")."</font></strong><br />\n";
echo sprintf ($clang->gT("An error occurred uploading your file. This may be caused by incorrect permissions in your %s folder."),$tempdir)."<br /><br />\n";
echo "<input type='submit' value='".$clang->gT("Main Admin Screen")."' onclick=\"window.open('$scriptname', '_top')\" />\n";
echo "</td></tr></table>\n";
echo "</body>\n</html>\n";
exit;
}
}
else
{
// if we came here is because the file extention is not allowed
@unlink($_FILES['the_file']['tmp_name']);
echo "<strong><font color='red'>".$clang->gT("Error")."</font></strong><br />\n";
echo $clang->gT("This file type is not allowed to be uploaded.")."<br /><br />\n";
echo "<input type='submit' value='".$clang->gT("Main Admin Screen")."' onclick=\"window.open('$scriptname', '_top')\" />\n";
echo "</td></tr></table>\n";
echo "</body>\n</html>\n";
exit;
}
}
else
{
// if we came here is because the file extention is not allowed
@unlink($_FILES['the_file']['tmp_name']);
echo "<strong><font color='red'>".$clang->gT("Error")."</font></strong><br />\n";
echo $clang->gT("This file type is not allowed to be uploaded.")."<br /><br />\n";
echo "<input type='submit' value='".$clang->gT("Main Admin Screen")."' onclick=\"window.open('$scriptname', '_top')\" />\n";
echo "</td></tr></table>\n";
echo "</body>\n</html>\n";
exit;
}
}
}
if ($action == "templatefiledelete") {
$the_full_file_path = $templaterootdir."/".$templatename."/".$otherfile; //This is where the temp file is
unlink($the_full_file_path);
}
if ($action == "templatezip") {
require("classes/phpzip/phpzip.inc.php");
$z = new PHPZip();
$templatedir="$templaterootdir/$templatename/";
$zipfile="$tempdir/$templatename.zip";
$z -> Zip($templatedir, $zipfile);
if (is_file($zipfile)) {
//Send the file for download!
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header( "Content-Disposition: attachment; filename=$templatename.zip" );
header( "Content-Description: File Transfer");
@readfile($zipfile);
//Delete the temporary file
unlink($zipfile);
}
}
$normalfiles=array("DUMMYENTRY", ".", "..", "preview.png");
foreach ($files as $fl) {
$normalfiles[]=$fl["name"];
}
foreach ($cssfiles as $fl) {
$normalfiles[]=$fl["name"];
}
//CHECK ALL FILES EXIST, AND IF NOT - COPY IT FROM DEFAULT DIRECTORY
foreach ($files as $file) {
$thisfile="$templaterootdir/$templatename/".$file['name'];
if (!is_file($thisfile)) {
$copyfile="$templaterootdir/default/".$file['name'];
$newfile=$thisfile;
if (!@copy($copyfile, $newfile)) {
echo "<script type=\"text/javascript\">\n<!--\nalert(\"".sprintf($clang->gT("Failed to copy %s to new template directory.","js"), $file['name'])."\");\n//-->\n</script>";
}
}
}
//CHECK if ALL CSS & JS FILES EXIST, AND IF NOT - COPY IT FROM DEFAULT DIRECTORY
foreach ($cssfiles as $file) {
$thisfile="$templaterootdir/$templatename/".$file['name'];
if (!is_file($thisfile)) {
$copyfile="$templaterootdir/default/".$file['name'];
$newfile=$thisfile;
if (!@copy($copyfile, $newfile)) {
echo "<script type=\"text/javascript\">\n<!--\nalert(\"".sprintf($clang->gT("Failed to copy %s to new template directory.","js"), $file['name'])."\");\n//-->\n</script>";
}
}
}
if (!$screenname) {$screenname=$clang->gT("Welcome Page", "unescaped");}
if ($screenname != $clang->gT("Welcome Page")) {$_SESSION['step']=1;} else {unset($_SESSION['step']);} //This helps handle the load/save buttons
// =========================== FAKE DATA FOR TEMPLATES
$thissurvey['name']=$clang->gT("Template Sample");
$thissurvey['description']="This is a sample survey description. It could be quite long.<br /><br />But this one isn't.";
$thissurvey['welcome']=$clang->gT('Welcome to this sample survey').'<br />'.$clang->gT('You should have a great time doing this').'<br />';
$thissurvey['allowsave']="Y";
$thissurvey['active']="Y";
$thissurvey['templatedir']=$templatename;
$thissurvey['format']="G";
$thissurvey['surveyls_url']="http://www.limesurvey.org/";
$thissurvey['surveyls_urldescription']=$clang->gT("Some URL description");
$thissurvey['usecaptcha']="A";
$percentcomplete=makegraph(6, 10);
$groupname=$clang->gT("Group 1: The first lot of questions");
$groupdescription=$clang->gT("This group description is fairly vacuous, but quite important.");
$navigator="\t\t<input class=\"submit\" type=\"submit\" value=\" Next >> \" name=\"move\" />\n";
if ($screenname != $clang->gT("Welcome Page")) {$navigator = "\t\t<input class=\"submit\" type=\"submit\" value=\" << Previous\" name=\"move\" />\n".$navigator;}
$help="This is some help text";
$totalquestions="10";
$surveyformat="Format";
$completed = "<br /><span class='success'>".$clang->gT("Thank you!")."</span><br /><br />"
.$clang->gT("Your survey responses have been recorded.")."<br /><br />\n";
$notanswered="5";
$privacy="";
$surveyid="1295";
$token=1234567;
$assessments="<table align='center'><tr><th>".$clang->gT("Assessment heading")."</th></tr><tr><td align='center'>".$clang->gT("Assessment details")."<br />".$clang->gT("Note that this assessment section will only show if assessment rules have been set and assessment mode is activated.")."</td></tr></table>";
$printoutput="<span class='printouttitle'><strong>".$clang->gT("Survey name (ID)")."</strong> Test survey (46962)</span><br />
<table class='printouttable' >
<tr><th>".$clang->gT("Question")."</th><th>".$clang->gT("Your answer")."</th></tr>
<tr>
<td>id</td>
<td>12</td>
</tr>
<tr>
<td>Date Submitted</td>
<td>1980-01-01 00:00:00</td>
</tr>
<tr>
<td>This is a sample question text. The user was asked to enter a date.</td>
<td>2007-11-06</td>
</tr>
<tr>
<td>This is another sample question text - asking for number. </td>
<td>666</td>
</tr>
<tr>
<td>This is one last sample question text - asking for some free text. </td>
<td>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</td>
</tr>
</table>";
$addbr=false;
switch($screenname) {
case $clang->gT("Survey List Page", "unescaped"):
unset($files);
$list[]="<li class='surveytitle'><a href='#'>Survey Number 1</a></li>\n";
$list[]="<li class='surveytitle'><a href='#'>Survey Number 2</a></li>\n";
$surveylist=array(
"nosid"=>$clang->gT("You have not provided a survey identification number"),
"contact"=>sprintf($clang->gT("Please contact %s ( %s ) for further assistance."),$siteadminname,$siteadminemail),
"listheading"=>$clang->gT("The following surveys are available:"),
"list"=>implode("\n",$list),
);
$myoutput[]="";
foreach ($SurveyList as $qs) {
$files[]=array("name"=>$qs);
$myoutput = array_merge($myoutput, doreplacement("$templaterootdir/$templatename/$qs"));
}
break;
case $clang->gT("Question Page", "unescaped"):
unset($files);
foreach ($Question as $qs) {
$files[]=array("name"=>$qs);
}
$myoutput[]="<meta http-equiv=\"expires\" content=\"Wed, 26 Feb 1997 08:21:57 GMT\" />\n";
$myoutput[]="<meta http-equiv=\"Last-Modified\" content=\"".gmdate('D, d M Y H:i:s'). " GMT\" />\n";
$myoutput[]="<meta http-equiv=\"Cache-Control\" content=\"no-store, no-cache, must-revalidate\" />\n";
$myoutput[]="<meta http-equiv=\"Cache-Control\" content=\"post-check=0, pre-check=0, false\" />\n";
$myoutput[]="<meta http-equiv=\"Pragma\" content=\"no-cache\" />\n";
$myoutput = array_merge($myoutput, doreplacement("$templaterootdir/$templatename/startpage.pstpl"));
$myoutput = array_merge($myoutput, doreplacement("$templaterootdir/$templatename/survey.pstpl"));
$myoutput = array_merge($myoutput, doreplacement("$templaterootdir/$templatename/startgroup.pstpl"));
$myoutput = array_merge($myoutput, doreplacement("$templaterootdir/$templatename/groupdescription.pstpl"));
$question="How many roads must a man walk down?";
$questioncode="1a";
$answer="<ul><li><input type='radio' class='radiobtn' name='1' value='1' id='radio1' /><label class='answertext' for='radio1'>One</label></li><li><input type='radio' class='radiobtn' name='1' value='2' id='radio2' /><label class='answertext' for='radio2'>Two</label></li><li><input type='radio' class='radiobtn' name='1' value='3' id='radio3' /><label class='answertext' for='radio3'>Three</label></li></ul>\n";
$myoutput[]='<div id="question1" class="list-radio">';
$myoutput = array_merge($myoutput, doreplacement("$templaterootdir/$templatename/question.pstpl"));
$question='<span class="asterisk">*</span>'.$clang->gT("Please explain something in detail:");
$questioncode="2";
$answer="<textarea class='textarea' rows='5' cols='40'>Some text in this answer</textarea>";
$myoutput[]='<div id="question2" class="text-long mandatory">';
$myoutput = array_merge($myoutput, doreplacement("$templaterootdir/$templatename/question.pstpl"));
$myoutput = array_merge($myoutput, doreplacement("$templaterootdir/$templatename/endgroup.pstpl"));
$myoutput = array_merge($myoutput, doreplacement("$templaterootdir/$templatename/navigator.pstpl"));
$myoutput = array_merge($myoutput, doreplacement("$templaterootdir/$templatename/endpage.pstpl"));
break;
case $clang->gT("Welcome Page", "unescaped"):
unset($files);
$myoutput[]="";
foreach ($Welcome as $qs) {
$files[]=array("name"=>$qs);
$myoutput = array_merge($myoutput, doreplacement("$templaterootdir/$templatename/$qs"));
}
break;
case $clang->gT("Register Page", "unescaped"):
unset($files);
foreach($Register as $qs) {
$files[]=array("name"=>$qs);
}
foreach(file("$templaterootdir/$templatename/startpage.pstpl") as $op)
{
$myoutput[]=templatereplace($op);
}
foreach(file("$templaterootdir/$templatename/survey.pstpl") as $op)
{
$myoutput[]=templatereplace($op);
}
foreach(file("$templaterootdir/$templatename/register.pstpl") as $op)
{
$myoutput[]=templatereplace($op);
}
foreach(file("$templaterootdir/$templatename/endpage.pstpl") as $op)
{
$myoutput[]=templatereplace($op);
}
$myoutput[]= "\n";
break;
case $clang->gT("Save Page", "unescaped"):
unset($files);
foreach($Save as $qs) {
$files[]=array("name"=>$qs);
}
foreach(file("$templaterootdir/$templatename/startpage.pstpl") as $op)
{
$myoutput[]=templatereplace($op);
}
foreach(file("$templaterootdir/$templatename/save.pstpl") as $op)
{
$myoutput[]=templatereplace($op);
}
foreach(file("$templaterootdir/$templatename/endpage.pstpl") as $op)
{
$myoutput[]=templatereplace($op);
}
$myoutput[]= "\n";
break;
case $clang->gT("Load Page", "unescaped"):
unset($files);
foreach($Load as $qs) {
$files[]=array("name"=>$qs);
}
foreach(file("$templaterootdir/$templatename/startpage.pstpl") as $op)
{
$myoutput[]=templatereplace($op);
}
foreach(file("$templaterootdir/$templatename/load.pstpl") as $op)
{
$myoutput[]=templatereplace($op);
}
foreach(file("$templaterootdir/$templatename/endpage.pstpl") as $op)
{
$myoutput[]=templatereplace($op);
}
$myoutput[]= "\n";
break;
case $clang->gT("Clear All Page", "unescaped"):
unset($files);
foreach ($Clearall as $qs) {
$files[]=array("name"=>$qs);
}
foreach(file("$templaterootdir/$templatename/startpage.pstpl") as $op)
{
$myoutput[]=templatereplace($op);
}
foreach(file("$templaterootdir/$templatename/clearall.pstpl") as $op)
{
$myoutput[]=templatereplace($op);
}
foreach(file("$templaterootdir/$templatename/endpage.pstpl") as $op)
{
$myoutput[]=templatereplace($op);
}
$myoutput[]= "\n";
break;
case $clang->gT("Completed Page", "unescaped"):
unset($files);
$myoutput[]="";
foreach ($CompletedTemplate as $qs) {
$files[]=array("name"=>$qs);
$myoutput = array_merge($myoutput, doreplacement("$templaterootdir/$templatename/$qs"));
}
break;
case $clang->gT("Printable survey page", "unescaped"):
unset($files);
foreach ($printablesurveytemplate as $qs) {
$files[]=array("name"=>$qs);
}
$questionoutput=array();
foreach(file("$templaterootdir/$templatename/print_question.pstpl") as $op)
{
$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/$templatename/print_group.pstpl") as $op)
{
$groupoutput[]=templatereplace($op, array('QUESTIONS'=>implode(' ',$questionoutput)));
}
foreach(file("$templaterootdir/$templatename/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'=>'',
'HEADELEMENTS'=>getPrintableHeader(),
'SUBMIT_BY' => sprintf($clang->gT("Please submit by %s"), date('d.m.y')),
'THANKS'=>$clang->gT('Thank you for completing this survey.')
));
}
break;
case $clang->gT("Print answers page", "unescaped"):
unset($files);
foreach ($printtemplate as $qs) {
$files[]=array("name"=>$qs);
}
foreach(file("$templaterootdir/$templatename/startpage.pstpl") as $op)
{
$myoutput[]=templatereplace($op);
}
foreach(file("$templaterootdir/$templatename/printanswers.pstpl") as $op)
{
$myoutput[]=templatereplace($op);
}
foreach(file("$templaterootdir/$templatename/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=$templaterootdir."/".$templatename;
if ($handle = opendir($dirloc)) {
while(false !== ($file = readdir($handle))) {
if (!array_search($file, $normalfiles)) {
if (!is_dir("$dirloc/$file")) {
$otherfiles[]=array("name"=>$file);
}
}
} // while
closedir($handle);
}
//****************************************************************
//** OUTPUT STARTS HERE
//****************************************************************
$templatesoutput = "<script type=\"text/javascript\"> var adminlanguage='$codelanguage'; var highlighter='$highlighter'; </script>\n";
$templatesoutput.= "<script type='text/javascript'>\n"
."<!--\n"
."function copyprompt(text, defvalue, copydirectory, action)\n"
."\t{\n"
."\tif (newtemplatename=window.prompt(text, defvalue))\n"
."\t\t{\n"
//."\t\tvar url='admin.php?action=template'+action+'&newname='+newtemplatename+'©dir='+copydirectory;\n"
//."\t\twindow.open(url, '_top');\n"
. "\t\t\tsendPost('admin.php','".$_SESSION['checksessionpost']."',new Array('action','newname','copydir'),new Array('template'+action,newtemplatename,copydirectory));\n"
."\t\t}\n"
."\t}\n"
."function checkuploadfiletype(filename)\n"
."\t{\n"
."\tvar allowedtypes=',$allowedtemplateuploads,';\n"
."\tvar lastdotpos=-1;\n"
."\tvar ext='';\n"
."\tif ((lastdotpos=filename.lastIndexOf('.')) < 0)\n"
."\t\t{\n"
."\t\talert('".$clang->gT('This file type is not allowed to be uploaded.','js')."');\n"
."\t\treturn false;\n"
."\t\t}\n"
."\telse\n"
."\t\t{\n"
."\t\text = ',' + filename.substr(lastdotpos+1) + ',';\n"
."\t\text = ext.toLowerCase();\n"
."\t\tif (allowedtypes.indexOf(ext) < 0)\n"
."\t\t\t{\n"
."\t\t\talert('".$clang->gT('This file type is not allowed to be uploaded.','js')."');\n"
."\t\t\treturn false;\n"
."\t\t\t}\n"
."\t\telse\n"
."\t\t\t{\n"
."\t\t\treturn true;\n"
."\t\t\t}\n"
."\t\t}\n"
."\t}\n"
."//-->\n</script>\n";
$templatesoutput.= "<div class='menubar'>\n"
. "\t\t\t<div class='menubar-title'>\n"
. "\t\t\t\t\t<strong>".$clang->gT('Template Editor')."</strong>\n"
. "\t\t\t\t</div>\n"
. "\t\t\t<div class='menubar-main'>\n"
. "\t\t\t<div class='menubar-left'>\n"
. "\t\t\t\t\t<a href='$scriptname'"
. "onmouseout=\"hideTooltip()\" title=\"".$clang->gTview("Default Administration Page")."\" onmouseover=\"showTooltip(event,'".$clang->gT("Default Administration Page", "js")."')\">"
. "<img src='$imagefiles/home.png' name='HomeButton' alt='' title='' /></a>\n"
. "\t\t\t\t\t<img src='$imagefiles/blank.gif' alt='' width='60' height='10' />\n"
. "\t\t\t\t\t<img src='$imagefiles/seperator.gif' alt='' />";
if (isset($flashmessage))
{
$templatesoutput.='<span class="flashmessage">'.$flashmessage.'</span>';
}
elseif (is_template_editable($templatename)==false)
{
$templatesoutput.='<span class="flashmessage">'.sprintf($clang->gT('Note: This is a standard template. If you want to edit it %s please copy it first%s.'),"<a href='#' onmouseout=\"hideTooltip()\" onmouseover=\"showTooltip(event,'".$clang->gT("Copy Template", "js")."')\" title=\"".$clang->gTview("Copy Template")."\" "
."onclick=\"javascript: copyprompt('".$clang->gT("Please enter the name for the copied template:")."', '".$clang->gT("copy_of_")."$templatename', '$templatename', 'copy')\">",'</a>').'</span>';
}
$templatesoutput.= "</div>\n"
. "\t\t\t<div class='menubar-right'>\n"
//Logout Button
."<font style='boxcaption'><strong>".$clang->gT("Template:")."</strong> </font>"
."<select class=\"listboxtemplates\" name='templatedir' onchange='javascript: window.open(\"admin.php?action=templates&editfile=$editfile&screenname=".html_escape($screenname)."&templatename=\"+this.value, \"_top\")'>\n"
.makeoptions($templates, "name", "name", $templatename)
."</select>\n"
. "<a href='#' onclick=\"javascript: copyprompt('".$clang->gT("Create new template called:")."', '".$clang->gT("NewTemplate")."', 'default', 'copy')\""
. " onmouseout=\"hideTooltip()\" title=\"".$clang->gTview("Create new template")."\" onmouseover=\"showTooltip(event,'".$clang->gT("Create new template", "js")."')\">"
. "<img src='$imagefiles/add.png' alt='' title='' /></a>\n"
. "<img src='$imagefiles/seperator.gif' alt='' />"
. "\t\t<a href=\"#\" onclick=\"window.open('$scriptname?action=logout', '_top')\""
. "title=\"".$clang->gTview("Logout")."\" "
. "onmouseout=\"hideTooltip()\""
. "onmouseover=\"showTooltip(event,'".$clang->gT("Logout", "js")."');return false\">"
. "<img src='$imagefiles/logout.png' name='Logout'"
. "title='' alt='".$clang->gT("Logout")."' /></a>"
. "<img src='$imagefiles/blank.gif' alt='' width='20' />"
."</div></div></div>\n"
."<font style='size:12px;line-height:2px;'> </font>"; //CSS Firefox 2 transition fix
//TEMPLATE DETAILS
$templatesoutput.= "\t\t\t<div class='menubar'>\n"
. "<div class='menubar-title'>\n"
. "<strong>".$clang->gT("Template:")." <i>$templatename</i></strong>\n"
. "</div>\n"
. "<div class='menubar-main'>\n"
. "<div class='menubar-left'>\n";
$templatesoutput.= "<img src='$imagefiles/blank.gif' alt='' width='104' height='40'/>\n"
."\t\t\t\t\t<img src='$imagefiles/seperator.gif' alt='' />\n";
if (!is_template_editable($templatename))
{
$templatesoutput.="<img name='RenameTemplate' src='$imagefiles/edit_disabled.png' alt='' title=''"
." onmouseout=\"hideTooltip()\" onmouseover=\"showTooltip(event,'".$clang->gT("You can't rename a standard template.", "js")."')\" "
." />"
."<img name='EditName' src='$imagefiles/delete_disabled.png' alt='' title=''"
." onmouseout=\"hideTooltip()\" onmouseover=\"showTooltip(event,'".$clang->gT("You can't delete a standard template.", "js")."')\" "
." />";
}
else
{
$templatesoutput.= "<a href='#' onclick=\"javascript: copyprompt('".$clang->gT("Rename this template to:")."', '$templatename', '$templatename', 'rename')\">" .
"<img name='RenameTemplate' src='$imagefiles/edit.png' alt='' title=''" .
" onmouseout=\"hideTooltip()\" onmouseover=\"showTooltip(event,'".$clang->gT("Rename this template", "js")."')\" ".
" /></a>";
$templatesoutput.= "<a href='#' "
." onclick='if (confirm(\"".$clang->gT("Are you sure you want to delete this template?", "js")."\")) window.open(\"admin.php?action=templates&subaction=delete&templatename=$templatename\", \"_top\")' >" .
"<img name='DeleteTemplate' src='$imagefiles/delete.png' alt='' title=''" .
" onmouseout=\"hideTooltip()\" onmouseover=\"showTooltip(event,'".$clang->gT("Delete this template", "js")."')\" ".
" /></a>";
}
$templatesoutput.= "\t\t\t\t\t<img src='$imagefiles/blank.gif' alt='' width='20' height='10' />\n"
."\t\t\t\t\t<a href='#' onclick='javascript:window.open(\"admin.php?action=templatezip&editfile=$editfile&screenname=".html_escape($screenname)."&templatename=$templatename\", \"_top\")'"
."onmouseout=\"hideTooltip()\" title=\"".$clang->gTview("Export Template")."\" onmouseover=\"showTooltip(event,'".$clang->gT("Export Template", "js")."')\">"
."<img name='Export' src='$imagefiles/export.png' alt='' title='' /></a>\n"
."<a href='#' onclick='javascript:window.open(\"admin.php?action=templates&subaction=templateupload\", \"_top\")'"
."onmouseout=\"hideTooltip()\" title=\"".$clang->gTview("Import template")."\" onmouseover=\"showTooltip(event,'".$clang->gT("Import template", "js")."')\">"
."<img name='ImportTemplate' src='$imagefiles/import.png' alt='' title='' /></a>\n"
."\t\t\t\t\t<img src='$imagefiles/seperator.gif' alt='' border='0' />\n"
."<a href='#' onmouseout=\"hideTooltip()\" onmouseover=\"showTooltip(event,'".$clang->gT("Copy Template", "js")."')\" title=\"".$clang->gTview("Copy Template")."\" "
."onclick=\"javascript: copyprompt('".$clang->gT("Please enter the name for the copied template:")."', '".$clang->gT("copy_of_")."$templatename', '$templatename', 'copy')\">"
."<img name='MakeCopy' src='$imagefiles/copy.png' alt='' title='' /></a>"
."</div>\n"
."<div class='menubar-right'>\n"
."<font style='boxcaption'><strong>".$clang->gT("Screen:")."</strong> </font>"
. "<select class=\"listboxtemplates\" name='screenname' onchange='javascript: window.open(\"admin.php?action=templates&templatename=$templatename&editfile=$editfile&screenname=\"+this.value, \"_top\")'>\n"
. makeoptions($screens, "name", "name", html_escape($screenname) )
. "</select>\n"
."<img src='$imagefiles/blank.gif' width='45' height='10' alt='' />"
."<img src='$imagefiles/seperator.gif' alt='' />"
."<img src='$imagefiles/blank.gif' width='62' height='10' alt=''/>"
."</div></div></div>\n"
."<p style='margin:0;font-size:1px;line-height:1px;height:1px;'> </p>" //CSS Firefox 2 transition fix
."<table width='100%' border='0' bgcolor='#FFFFFF'>\n"
. "\t<tr>\n"
. "\t\t<td>\n";
if ($subaction=='templateupload')
{
$ZIPimportAction = " onclick='if (validatefilename(this.form,\"".$clang->gT('Please select a file to import!','js')."\")) {this.form.submit();}'";
if (!function_exists("zip_open"))
{
$ZIPimportAction = " onclick='alert(\"".$clang->gT("zip library not supported by PHP, Import ZIP Disabled","js")."\");'";
}
$templatesoutput.= "\t<form enctype='multipart/form-data' name='importtemplate' action='$scriptname' method='post' onsubmit='return validatefilename(this,\"".$clang->gT('Please select a file to import!','js')."\");'>\n"
. "\t<input type='hidden' name='lid' value='$lid' />\n"
. "\t<input type='hidden' name='action' value='templateupload' />\n"
. "\t<table width='60%' class='form2columns'>\n"
. "\t<tbody align='center'>"
. "\t\t<tr><th colspan='2' class='settingcaption'>".$clang->gT("Uploaded template file") ."</th>\n"
. "\t\t<tr><td> </td></tr>\n"
. "\t\t<tr><td>".$clang->gT("Select template ZIP file:")."</td>\n"
. "\t\t<td><input name=\"the_file\" type=\"file\" size=\"50\" /></td><td></td></tr>\n"
. "\t\t<tr><td></td><td><input type='button' value='".$clang->gT("Import template ZIP archive")."' $ZIPimportAction /></td><td></td>\n"
. "\t\t</tr>\n"
. "\t</tbody></table></form>\n";
}
elseif (isset($importtemplateoutput))
{
$templatesoutput.=$importtemplateoutput;
}
else
{
//FILE CONTROL DETAILS
if (is_template_editable($templatename)==true)
{
$templatesoutput.= "\t\t\t<table class='templatecontrol'>\n"
. "\t\t\t<tr>\n"
. "\t\t\t\t<th colspan='3'>\n"
. "\t\t\t\t\t<strong>".sprintf($clang->gT("Editing template '%s' - File '%s'"),$templatename,$editfile)."</strong>\n"
. "\t\t\t\t</th>\n"
. "\t\t\t</tr>\n"
. "\t\t\t<tr><th class='subheader' width='150'>"
.$clang->gT("Standard Files:")."</th>"
."<td align='center' valign='top' rowspan='3'>\n"
."<form name='editTemplate' method='post' action='admin.php'>\n"
."\t\t\t<input type='hidden' name='templatename' value='$templatename' />\n"
."\t\t\t<input type='hidden' name='screenname' value='".html_escape($screenname)."' />\n"
."\t\t\t<input type='hidden' name='editfile' value='$editfile' />\n"
."\t\t\t<input type='hidden' name='action' value='templatesavechanges' />\n"
."<textarea name='changes' id='changes' rows='15' class='codepress html'>";
if ($editfile) {
$templatesoutput.= textarea_encode(filetext($editfile));
}
$templatesoutput.= "</textarea><br />\n";
if (is_writable("$templaterootdir/$templatename")) {
$templatesoutput.= "<input align='right' type='submit' value='".$clang->gT("Save Changes")."'";
if (!is_template_editable($templatename)) {
$templatesoutput.= " disabled='disabled' alt='".$clang->gT("Changes cannot be saved to a standard template.")."'";
}
$templatesoutput.= " />";
}
else
{
$templatesoutput.='<span class="flashmessage">'.$clang->gT("You can't save changes because the template directory is not writable.").'</span>';
}
$templatesoutput.= "<br />\n"
."</form></td>";
$templatesoutput.= "<th class='subheader' colspan='2' align='right' width='200'>".$clang->gT("Other Files:")."</th></tr>\n";
$templatesoutput.="<tr><td valign='top' rowspan='2' class='subheader'><select size='6' name='editfile' onchange='javascript: window.open(\"admin.php?action=templates&templatename=$templatename&screenname=".html_escape($screenname)."&editfile=\"+this.value, \"_top\")'>\n"
.makeoptions($files, "name", "name", $editfile)
."</select><br /><br/>\n"
.$clang->gT("CSS & Javascript files:")
."<br/><select size='8' name='cssfiles' onchange='javascript: window.open(\"admin.php?action=templates&templatename=$templatename&screenname=".html_escape($screenname)."&editfile=\"+this.value, \"_top\")'>\n"
.makeoptions($cssfiles, "name", "name", $editfile)
. "</select>\n"
."</td>\n"
."<td valign='top' align='right' width='20%'><form action='admin.php' method='post'>"
."<table width='90' align='left' border='0' cellpadding='0' cellspacing='0'>\n<tr><td></td></tr>"
. "<tr><td><select size='11' style='min-width:130px;'name='otherfile' id='otherfile'>\n"
.makeoptions($otherfiles, "name", "name", "")
."</select>"
."</td></tr>"
."<tr><td>"
."<input type='submit' value='".$clang->gT("Delete")."' onclick=\"javascript:return confirm('".$clang->gT("Are you sure you want to delete this file?","js")."')\"";
if (!is_template_editable($templatename)) {
$templatesoutput.= " style='color: #BBBBBB;' disabled='disabled' alt='".$clang->gT("Files in a standard template cannot be deleted.")."'";
}
$templatesoutput.= " />\n"
."<input type='hidden' name='screenname' value='".html_escape($screenname)."' />\n"
."<input type='hidden' name='templatename' value='$templatename' />\n"
."<input type='hidden' name='action' value='templatefiledelete' />\n"
. "</td></tr></table></form></td>\n"
."</tr>\n"
."<tr>"
."<td valign='top'>"
."<form enctype='multipart/form-data' name='importtemplatefile' action='admin.php' method='post' onsubmit='return checkuploadfiletype(this.the_file.value);'>\n"
."<table><tr> <th class='subheader' valign='top' style='border: solid 1 #000080'>\n"
.$clang->gT("Upload a file:")."</th></tr><tr><td><input name=\"the_file\" type=\"file\" size=\"30\" /><br />"
."<input type='submit' value='".$clang->gT("Upload")."'";
if (!is_template_editable($templatename)) {
$templatesoutput.= " disabled='disabled'";
}
$templatesoutput.= " />\n"
."<input type='hidden' name='editfile' value='$editfile' />\n"
."<input type='hidden' name='screenname' value='".html_escape($screenname)."' />\n"
."<input type='hidden' name='templatename' value='$templatename' />\n"
."<input type='hidden' name='action' value='templateuploadfile' />\n"
."</td></tr></table></form>\n"
."\t\t\t\t\t\t</td>\n"
."\t\t\t\t\t</tr>\n"
."\t\t\t\t</table>\n"
."\t\t\t</td>\n"
."\t</tr>"
."</table>";
}
//SAMPLE ROW
$templatesoutput.= "\t\t\t<table class='menubar'>\n"
. "\t\t\t<tr>\n"
. "\t\t\t\t<td colspan='2' height='8'>\n"
. "\t\t\t\t\t<strong>".$clang->gT("Preview:")."</strong>\n"
. "\t\t\t\t\t<input type='button' value='iPhone' id='iphone'>\n"
. "\t\t\t\t\t<input type='button' value='640x480' id='640'>\n"
. "\t\t\t\t\t<input type='button' value='800x600' id='800'>\n"
. "\t\t\t\t\t<input type='button' value='1024x768' id='1024'>\n"
. "\t\t\t\t\t<input type='button' value='".$clang->gt("Full")."' id='full'>\n"
. "\t\t\t\t</td>\n"
. "\t\t\t</tr>\n"
."\t<tr>\n"
."\t\t<td width='90%' align='center' >\n";
// The following lines are forcing the browser to refresh the templates on each save
$time=date("ymdHis");
$fnew=fopen("$tempdir/template_temp_$time.html", "w+");
fwrite ($fnew, getHeader());
foreach ($cssfiles as $cssfile)
{
$myoutput=str_replace($cssfile['name'],$cssfile['name']."?t=$time",$myoutput);
}
foreach($myoutput as $line) {
fwrite($fnew, $line);
}
fclose($fnew);
$langdir_template="$publicurl/locale/".$_SESSION['adminlang']."/help";
$templatesoutput.= "<br />\n"
."<iframe id='previewiframe' src='$tempurl/template_temp_$time.html' width='95%' height='500' name='sample' style='background-color: white'>Embedded Frame</iframe>\n"
."<br /> <br />"
."</td></tr></table>\n";
}
function doreplacement($file) { //Produce sample page from template file