Removal of old text
[elgg.git] / lib / templates.php
blob1cce3ed0669715932c7da6e72a32b6b0845384af
1 <?php
3 /*** NZVLE TODO
4 ***
5 *** + Break the html/css bits of the default template into separate files
6 *** they mess up the code layout and indentation, and generally don't
7 *** belong here.
8 *** + Clean up and document the calling conventions -- get rid of $parameter
9 *** + the callbacks to template_variables_substitute are *evil* -- rework
10 ***
11 ***/
13 function default_template () {
15 global $CFG;
16 global $template;
17 global $template_definition;
18 $sitename = $CFG->sitename;
20 $run_result = '';
22 $template_definition[] = array(
23 'id' => 'pageshell',
24 'name' => gettext("Page Shell"),
25 'description' => gettext("The main page shell, including headers and footers."),
26 'glossary' => array(
27 '{{metatags}}' => gettext("Page metatags (mandatory) - must be in the 'head' portion of the page"),
28 '{{title}}' => gettext("Page title"),
29 '{{menu}}' => gettext("Menu"),
30 '{{topmenu}}' => gettext("Status menu"),
31 '{{mainbody}}' => gettext("Main body"),
32 '{{sidebar}}' => gettext("Sidebar")
36 $welcome = gettext("Welcome"); // gettext variable
38 $template['pageshell'] = <<< END
40 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
41 <html xmlns="http://www.w3.org/1999/xhtml">
42 <head>
43 <title>{{title}}</title>
44 {{metatags}}
45 </head>
46 <body>
47 <!-- elgg banner and logo -->
48 <div id="container"><!-- start container -->
49 <div id="statusbar"><!-- start statusbar -->
50 <div id="welcome"><!-- start welcome -->
51 <p>$welcome {{userfullname}}</p>
52 </div><!-- end welcome -->
53 {{topmenu}}
54 </div><!-- end statusbar -->
55 <div id="header"><!-- start header -->
56 <h1>$sitename</h1>
57 <h2>Community learning space</h2>
58 <ul id="navigation">
59 {{menu}}
60 </ul>
61 </div><!-- end header -->
62 <div id="content_holder"><!-- start contentholder -->
63 <div id="maincontent_container"><!-- start main content -->
64 {{messageshell}}
65 {{mainbody}}
66 </div><!-- end main content -->
67 <div id="sidebar_container">
68 <div id="sidebar"><!-- start sidebar -->
69 <ul><!-- open sidebar lists -->
70 {{sidebar}}
71 </ul>
72 </div><!-- end sidebar -->
73 </div><!-- end sidebar_container -->
74 </div><!-- end contentholder -->
75 <div class="clearall" />
76 <div id="footer"><!-- start footer -->
77 <a href="http://elgg.net"><img src="{$url}_templates/elgg_powered.png" alt="Powered by Elgg" title="Powered by Elgg" border="0" /></a>
78 </div><!-- end footer -->
79 </div><!-- end container -->
80 </body>
81 </html>
83 END;
85 $template_definition[] = array(
86 'id' => 'css',
87 'name' => gettext("Stylesheet"),
88 'description' => gettext("The Cascading Style Sheet for the template."),
89 'glossary' => array()
92 $template['css'] = <<< END
94 CSS for Elgg default
97 body{
98 margin: 0;
99 padding: 0;
100 font-family: "Lucida Grande", verdana, arial, helvetica, sans-serif;
101 color: #333;
102 background: #eee;
103 width: 97%;
104 margin: auto;
108 text-decoration: none;
109 font-family: verdana, arial, helvetica;
110 color: #7289AF;
111 font-size:13px;
115 font-family: arial, helvetica, Tahoma;
116 color: #000000;
117 font-size: 75%;
121 h2 {
122 font-family: arial, helvetica, Tahoma;
126 h3 {
127 font-family: arial, helvetica, Tahoma;
130 h4 {
131 font-family: arial, helvetica, Tahoma;
134 h5 {
135 color: #1181AA;
138 /*-------------------------------------------------
139 STATUS BAR
140 -------------------------------------------------*/
142 #Statusbar {
143 color: #1181AA;
144 padding: 3px 10px 2px 0;
145 margin: 0px;
146 text-align: bottom;
147 font-size: 9px;
148 height: 19px;
149 background: #eee;
153 #Statusbar a {
154 font-size: 11px;
155 color: #666;
158 #StatusRight {
159 text-align: right;
160 padding: 0px;
161 padding-top: 0px;
162 padding-bottom: 0px;
165 #StatusRight a:hover {
166 text-decoration: underline;
169 #StatusLeft {
170 float: left;
171 color: #333;
174 #StatusLeft p {
175 font-weight: normal;
176 font-size: 12px;
177 font-weight: bold;
178 padding: 0px;
179 padding-left: 3px;
180 margin: 0px;
181 color:#ggg;
184 /*-------------------------------------------------
185 HEADER
186 -------------------------------------------------*/
188 #Header {
189 width: 100%;
190 background: #1181AA;
191 border: 1px solid #ccc;
192 border-bottom: none;
193 padding: 0px;
194 margin: 0px;
195 text-align: left;
198 #Header h1 {
199 padding: 0;
200 padding-bottom: 4px;
201 margin: 7px 0 0 20px;
202 font-size: 24px;
203 font-weight: normal;
204 color: #FAC83D;
205 text-align: left;
208 #Header h2 {
209 padding: 0 0 7px 0;
210 margin: 0 0 0 20px;
211 font-size: 16px;
212 font-weight: normal;
213 color: #fff;
214 border: none;
215 font-family: "Lucida Grande", arial, sans-serif;
218 #Header h3 {
219 padding: 0 20px 0 0;
220 margin: 7px 0px 0 0;
221 width: 200px;
222 text-align: right;
223 float: right;
224 font-size: 10px;
225 font-weight: normal;
226 font-family: verdana;
229 #Header h3 a {
230 font-weight: bold;
231 text-decoration: none;
234 /*-------------------------------------------------
235 contents
236 -------------------------------------------------*/
238 .Container {
239 margin: 0 auto;
240 text-align: center;
241 width: 100%;
242 min-width: 750px;
245 .ClearAll {
246 padding: 0px;
247 clear: both;
248 font-size: 0px;
251 .userlist {
252 clear: both;
253 margin:0px;
254 margin-bottom:5px;
257 #ContentFrame, .ContentFrame {
258 margin: 0;
259 padding: 20px 0;
260 width: 100%;
261 text-align: left;
262 float: left;
263 border: 1px solid #ccc;
264 border-top: none;
265 background-color: #fff;
268 .Left {
269 margin: 0;
270 padding: 0;
271 text-align: left;
272 width: 68%;
273 float: left;
276 .Left h2 {
277 padding-bottom: 5px;
278 padding-top: 5px;
279 border: 0px;
280 margin: 0;
281 font-size: 14px;
282 color: #666;
285 .Left h1 {
286 padding-bottom: 5px;
287 padding-top: 5px;
288 border: 0px;
289 margin: 0;
290 font-size: 15px;
291 color: #666;
296 .Right {
297 margin: 0px;
298 padding: 0;
299 text-align: left;
300 float: right;
301 width: 30%;
302 overflow: hidden;
305 #Footer {
306 font-size: 10px;
307 color: #fff;
308 margin: 10px 0 20px 20px;
309 text-align: center;
310 padding:5px;
313 #Footer .performanceinfo {
314 color: #000;
317 #Footer a:link, #Footer a:visited {
318 color: #666;
319 text-align:right;
322 #Footer a:hover {
323 color: #fff;
324 background: #666;
327 /*-------------------------------------------------
328 TABS
329 -------------------------------------------------*/
331 #Tabs {
332 height: 21px;
333 margin: 0;
334 padding-left: 20px;
335 text-align:left;
338 #Tabs li {
339 margin: 0;
340 padding: 0;
341 display: inline;
342 list-style-type: none;
343 border: none;
346 #Tabs a:link, #Tabs a:visited {
348 background: #eaeac7;
349 font-size: 11px;
350 font-weight: normal;
351 padding: 4px 6px;
352 margin: 0 2px 0 0;
353 border: 0px solid #036;
354 border-bottom: #eaeac7;
355 text-decoration: none;
356 color: #333;
359 #Tabs a:link.current, #Tabs a:visited.current {
360 border-bottom: 1px solid #fff;
361 background: #fff;
362 color: #393;
363 font-weight: bold;
366 #Tabs a:hover {
367 color: #000;
368 background: #ffc;
371 #Tabs li a:hover {
372 background: #FCD63F;
375 /*-------------------------------------------------
376 Profile table
377 -------------------------------------------------*/
379 .profiletable {
380 border: 1px;
381 border-style: solid;
382 border-color: #ddd;
383 text-align: top;
386 .profiletable p {
387 padding: 0px;
388 margin: 0px;
391 .profiletable img {
392 border: 0;
395 .profiletable .fieldname {
396 background-color: #F9F9F9;
397 border-right: 2px solid #eaeac7; /*#8B8C8C;*/
398 color: #1181AA;
399 padding-left: 10px;
400 text-align: bottom;
403 .profiletable .fieldname p {
404 color: #666;
407 .fileTable {
408 background-color: #F9F9F9;
409 border: 1px solid #DDD;
412 .fileTable p {
413 padding: 0px;
414 margin: 0px;
415 color: #1181AA;
418 /*-------------------------------------------------
419 SELECTED HEADER
420 -------------------------------------------------*/
422 .SectionContent {
423 margin: 0 0 20px 0;
426 .SectionContent h1 {
427 padding-bottom: 2px;
428 border-bottom: 1px solid #666;
429 margin: 0;
430 font-size: 16px;
431 color: #666;
434 .SectionContent h3 {
435 font-family: verdana;
436 padding: 2px 0 0 0;
437 margin: 0;
438 font-size: 10px;
439 font-weight: normal;
440 color: #000;
443 .SectionContent h3 a {
444 font-weight: bold;
447 .SectionContent h3 a:hover {
448 text-decoration: underline;
451 /*-------------------------------------------------
452 INDIVIDUAL POSTS
453 -------------------------------------------------*/
455 .Post {
456 margin: 0 0 10px 0;
457 padding: 0 0 20px 110px;
458 font-size: 75%;
459 font-family: arial;
462 .Post p {
463 padding: 0;
464 margin: 3px 0 10px 0;
465 font-size: 12px;
466 line-height: 16px;
469 .Post h1 {
470 /* padding-top: 5px;*/
471 color: #000;
474 .Post h1 a {
475 color: #000;
476 text-decoration: none;
479 .Post h1 a:hover {
480 background: #fff;
481 color: #000;
482 text-decoration: underline;
485 h2.date, h2.weblogdateheader {
486 padding: 0 0 0 0;
487 margin: 0 0 2px 0;
488 color: #333;
489 font-size: 10px;
490 font-weight: normal;
491 font-style: italic;
492 line-height: 12px;
493 border-bottom: 1px solid #ccc;
496 .Post h2.subhead {
497 padding: 0;
498 margin: 15px 0 0 0;
499 color: #000;
500 font-size: 12px;
501 font-weight: bold;
502 font-style: normal;
503 line-height: 12px;
506 .Post h5 {
507 margin-top: 0px;
508 padding-top: 0px;
509 font-size: 100%;
512 .Post h3 {
513 padding: 0 0 0 0;
514 margin: 0 0 5px 0;
515 color: #666;
516 font-family: verdana;
517 font-size: 10px;
518 font-weight: normal;
519 line-height: 14px;
520 text-align: left;
523 .Post h3 a {
524 color: #666;
525 text-decoration: none;
526 border-bottom: 1px dotted #666;
527 padding-bottom: 0;
530 .Post h3 a:hover {
531 color: #fff;
532 background-color: #666;
535 .Post h3 a.commentlink:link {
536 font-weight: bold;
537 color: #000;
540 .Post h3 a.commentlink:hover {
541 color: #fff;
542 background: #333;
545 .Post ol, .Post ul {
546 margin: 3px 0 10px 0;
547 padding: 0;
550 .Post li {
551 margin-left: 30px;
552 font-size: 12px;
553 line-height: 16px;
556 .Post ul li {
557 list-style-type: square;
560 .Post table {
561 background: #dcdcdc;
564 .Post td {
565 background: #fff;
566 padding: 5px;
567 font-size: 12px;
571 /*-------------------------------------------------
572 SIDEBAR
573 -------------------------------------------------*/
575 .Sidebar h1 {
576 padding: 4px 0 2px 0;
577 border-bottom: 1px solid #666;
578 margin: 0 0 5px 0;
579 font-size: 12px;
580 color: #000;
583 .Sidebar p.incategory {
584 margin-top: 0;
585 background: #ececec;
586 padding: 4px;
589 .Sidebar h2, .Sidebar h2.border {
590 font-family: "Lucida Grande", arial, sans-serif;
591 font-size: 12px;
592 font-weight: bold;
593 color: #333;
594 margin: 20px 0 3px 0;
595 padding: 0;
596 border: none;
599 .Sidebar h2.border {
600 border-bottom: 1px solid #d5d5d5;
604 .box_user {
605 /*background-color: #FAC83D;*/ /*#FAC83D;*/
606 margin: 0px;
607 margin-bottom: 5px;
610 .box_user .me {
611 padding: 3px;
612 background-color:#FAC83D;
613 padding-top: 3px;
614 min-height: 71px;
617 .box_user p {
618 color: #000; /*#1181AA;*/
619 padding: 0px;
620 margin-top: 0px;
623 .box_user .usermenu a {
624 color: #000; /*#1181AA;*/
625 padding: 0px;
626 margin-top: 0px;
627 font-size: 75%;
628 text-decoration: underline;
631 .profile_item {
632 border: 1px;
633 border-style: none;
634 border-color: #ebebeb;
635 background-color: #ebebeb;
636 margin: 0px;
637 margin-bottom: 3px;
640 .profile_item2 {
641 border: 1px;
642 border-style: none;
643 border-color: #fff;
644 background-color: #fff;
645 margin: 0px;
646 margin-bottom: 3px;
649 #js {
650 border: 1px solid #D3322A;
651 background: #F7DAD8;
652 padding: 3px 50px;
653 margin: 0;
656 #js p {
657 padding: 0px;
658 margin: 2px;
662 /*-------------------------------------------------
663 COMMENTS
664 -------------------------------------------------*/
666 .Comments h4 {
667 margin: 0 0 10px 0;
668 font-size: 10px;
669 color: #666;
670 padding: 3px 0;
671 font-weight: normal;
672 border-bottom: 1px solid #d5d5d5;
675 .Comments h2 {
676 padding: 2px 4px;
677 color: #fff;
678 background: #666;
679 font-size: 11px;
680 border-bottom: 1px solid #333;
681 margin: 0;
685 .Comments div.Post {
686 background: #f9f9f9;
687 border-bottom: 1px solid #efefef;
688 margin: 0 0 5px 0;
689 clear: left;
690 color: #333;
691 padding: 5px;
694 .Comments div.Post:after {
695 content: ".";
696 display: block;
697 height: 0;
698 clear: both;
699 visibility: hidden;
702 /* Hides form IE-mac \*/
703 * html .Comments div.Post {height: 1%;}
704 /* End hide from IE-mac */
706 .Comments #OriginalPost {
707 padding: 0 0 30px 0;
708 background: #fff;
709 border-bottom: none;
712 .Post#Preview {
713 border: 2px solid #ef9c00;
714 padding: 0;
717 .Post#Preview h2 {
718 margin: 0;
719 padding: 5px 10px;
720 background: #ff6;
721 border: none;
722 color: #000;
725 .Post#Preview #PreviewBody {
726 padding: 10px;
729 .Post#Preview #PreviewButtons {
730 text-align: left;
731 background: #ffc;
732 padding: 5px 10px;
735 div.Comments img.avatar {
736 margin: 0 10px 10px 0;
737 width: 48px;
738 float: left;
739 padding-left: 5px;
742 div.Comments div.Post ul,
743 div.Comments div.Post ol {
744 clear: left;
747 div.Comments div.Post ol li,
748 div.Comments div.Post ul li {
751 /*-------------------------------------------------
752 alignment
753 -------------------------------------------------*/
755 .col {
756 padding: 0 5px;
757 text-align: left;
760 .Left .col {
761 padding: 0 30px 0 20px;
762 min-width: 100px;
765 .Right .col {
766 min-width: 100px;
767 border-left: 1px dotted #dcdcdc;
768 padding: 0 10px;
771 .infobox {
772 padding: 0px;
773 margin: 0px;
774 margin-bottom: 0px;
777 /* ------------- help files -------------*/
779 .helpFiles ul {
780 font-family: arial, helvetica, Tahoma;
781 color: #000000;
782 font-size: 75%;
786 /*-------------- extra blog classes -----*/
787 .user {
788 float: left;
789 margin: 0px;
790 padding: 0px;
791 padding-bottom: 5px;
792 /* padding: 0.3em 2em 2em 0; */
793 width: 105px;
794 text-align: left;
797 .weblog_post .post_content {
798 padding-left: 2em;
801 .clearing{clear:both;}
803 /* site news for home.php */
805 .siteNews {
806 background:#ebebeb;
809 .siteNews h2 {
810 background: #1181AA;
811 font-size: 90%;
812 color: #FAC83D;
813 padding: 0px;
814 padding-left: 5px;
817 /* ---- feeds --------- */
819 .feeds {
820 font-size: 12px;
821 border-bottom: 1px dotted #aaaaaa;
822 background: transparent url("{$CFG->wwwroot}_templates/sunflower.jpg") bottom right no-repeat;
825 .feed_content p {
826 font-size: 12px;
829 .feed_content a {
830 color: black;
831 border: 0px;
832 border-bottom: 1px;
833 border-style: dotted;
834 border-color: grey;
837 .feed_content a:hover {
838 background: #fff;
841 .feed_content img {
842 border: 1px solid #666666;
843 padding: 5px;
846 .feed_date h4 {
847 font-size:13px;
848 line-height: 21px;
849 font-weight: bold;
850 padding: 5px 10px 5px 5px;
851 background: #D0DEDF;
852 text-decoration:none;
855 .feed_content h5 a {
856 color: black;
857 border: 0px;
858 border-bottom: 1px;
859 border-style: dotted;
860 border-color: grey;
863 .feed_content h5 a:hover {
864 background: #FCD63F;
867 .feed_content h5 {
868 padding: 0px;
869 padding-bottom: 4px;
870 margin: 0px;
873 .via a {
874 font-size:11px;
875 color:#1181AA;
876 border:0px;
877 border-bottom:1px;
878 border-style:dashed;
879 border-color:ebebeb;
882 .via a:hover {
883 background: #ffc;
887 END;
889 $template_definition[] = array(
890 'id' => 'contentholder',
891 'name' => gettext("Content holder"),
892 'description' => gettext("Contains the main content for a page (as opposed to the sidebar or the title)."),
893 'glossary' => array(
894 '{{title}}' => gettext("The title"),
895 '{{submenu}}' => gettext("The page submenu"),
896 '{{body}}' => gettext("The body of the page")
900 $template['contentholder'] = <<< END
902 <div class="SectionContent">
904 <h1>{{title}}</h1>
905 {{submenu}}
906 </div>
907 {{body}}
909 END;
911 $template_definition[] = array(
912 'id' => 'ownerbox',
913 'name' => gettext("Owner box"),
914 'description' => gettext("A box containing a description of the owner of the current profile."),
915 'glossary' => array(
916 '{{name}}' => gettext("The user's name"),
917 '{{profileurl}}' => gettext("The URL of the user's profile page, including terminating slash"),
918 '{{usericon}}' => gettext("The user's icon, if it exists"),
919 '{{tagline}}' => gettext("A short blurb about the user"),
920 '{{usermenu}}' => gettext("Links to friend / unfriend a user"),
921 '{{lmshosts}}' => gettext("Links to any lms hosts the user is attached to"),
925 $tags = gettext("Tags");
926 $resources = gettext("Resources");
927 $template['ownerbox'] = <<< END
929 <div class="me">
930 <div style="float: left; width: 70px"><a href="{{profileurl}}">{{usericon}}</a></div>
931 <div style="margin-left: 75px; margin-top: 0px; padding-top: 0px; text-align: left" ><p>
932 <span class="userdetails">{{name}}<br /><a href="{{profileurl}}rss/">RSS</a> | <a href="{{profileurl}}tags/">$tags</a> | <a href="{{profileurl}}newsclient/">$resources</a></span></p>
933 <p>{{tagline}}</p>
934 <p>{{lmshosts}}</p>
935 <p style="margin-bottom: 3px" class="usermenu">{{usermenu}}</p>
936 </div>
937 </div>
939 END;
941 $template_definition[] = array(
942 'id' => 'infobox',
943 'name' => gettext("Information Box"),
944 'description' => gettext("A box containing a caption and some text, used extensively throughout the site. For example, the 'friends' box and most page bodies are info boxes. Of course, you can alter this template however you wish - it doesn't need to be an actual box."),
945 'glossary' => array(
946 '{{name}}' => gettext("The title"),
947 '{{contents}}' => gettext("The contents of the box")
950 $template['infobox'] = <<< END
952 <table class="infobox" width="100%">
953 <caption align="top">
954 {{name}}
955 </caption>
956 <tr>
957 <td>
958 {{contents}}
959 </td>
960 </tr>
961 </table><br />
962 END;
964 $template_definition[] = array(
965 'id' => 'messageshell',
966 'name' => gettext("System message shell"),
967 'description' => gettext("A list of system messages will be placed within the message shell."),
968 'glossary' => array(
969 '{{messages}}' => gettext("The messages")
973 $template['messageshell'] = <<< END
975 <div id="js">{{messages}}</div><br />
977 END;
979 $template_definition[] = array(
980 'id' => 'messages',
981 'name' => gettext("Individual system messages"),
982 'description' => gettext("Each individual system message."),
983 'glossary' => array(
984 '{{message}}' => gettext("The system message")
988 $template['messages'] = <<< END
991 {{message}}
992 </p>
994 END;
997 $template_definition[] = array(
998 'id' => 'menu',
999 'name' => gettext("Main menu shell"),
1000 'description' => gettext("A list of main menu items will be placed within the menubar shell."),
1001 'glossary' => array(
1002 '{{menuitems}}' => gettext("The menu items")
1006 $template['menu'] = <<< END
1008 {{menuitems}}
1009 END;
1011 $template_definition[] = array(
1012 'id' => 'menuitem',
1013 'name' => gettext("Individual main menu item"),
1014 'description' => gettext("This is the template for each individual main menu item. A series of these is placed within the menubar shell template."),
1015 'glossary' => array(
1016 '{{location}}' => gettext("The URL of the menu item"),
1017 '{{name}}' => gettext("The menu item's name")
1021 $template['menuitem'] = <<< END
1023 <li><a href="{{location}}">{{name}}</a></li>
1025 END;
1027 $template_definition[] = array(
1028 'id' => 'selectedmenuitem',
1029 'name' => gettext("Selected individual main menu item"),
1030 'description' => gettext("This is the template for an individual main menu item if it is selected."),
1031 'glossary' => array(
1032 '{{location}}' => gettext("The URL of the menu item"),
1033 '{{name}}' => gettext("The menu item's name")
1037 $template['selectedmenuitem'] = <<< END
1039 <li><a class="current" href="{{location}}">{{name}}</a></li>
1041 END;
1043 $template_definition[] = array(
1044 'id' => 'submenu',
1045 'name' => gettext("Sub-menubar shell"),
1046 'description' => gettext("A list of sub-menu items will be placed within the menubar shell."),
1047 'glossary' => array(
1048 '{{submenuitems}}' => gettext("The menu items")
1052 $template['submenu'] = <<< END
1054 <h3>
1055 {{submenuitems}}
1056 </h3>
1057 END;
1059 $template_definition[] = array(
1060 'id' => 'submenuitem',
1061 'name' => gettext("Individual sub-menu item"),
1062 'description' => gettext("This is the template for each individual sub-menu item. A series of these is placed within the sub-menubar shell template."),
1063 'glossary' => array(
1064 '{{location}}' => gettext("The URL of the menu item"),
1065 '{{menu}}' => gettext("The menu item's name")
1069 $template['submenuitem'] = <<< END
1071 <a href="{{location}}">{{name}}</a>&nbsp;|
1073 END;
1075 $template_definition[] = array(
1076 'id' => 'topmenu',
1077 'name' => gettext("Status menubar shell"),
1078 'description' => gettext("A list of statusbar menu items will be placed within the status menubar shell."),
1079 'glossary' => array(
1080 '{{topmenuitems}}' => gettext("The menu items")
1084 $template['topmenu'] = <<< END
1086 <div id="StatusRight">
1087 {{topmenuitems}}
1088 </div>
1090 END;
1092 $template_definition[] = array(
1093 'id' => 'topmenuitem',
1094 'name' => gettext("Individual statusbar menu item"),
1095 'description' => gettext("This is the template for each individual statusbar menu item. A series of these is placed within the status menubar shell template."),
1096 'glossary' => array(
1097 '{{location}}' => gettext("The URL of the menu item"),
1098 '{{menu}}' => gettext("The menu item's name")
1102 $template['topmenuitem'] = <<< END
1104 [<a href="{{location}}">{{name}}</a>]&nbsp;
1106 END;
1108 $template_definition[] = array(
1109 'id' => 'databox',
1110 'name' => gettext("Data input box (two columns)"),
1111 'description' => gettext("This is mostly used whenever some input is taken from the user. For example, each of the fields in the profile edit screen is a data input box."),
1112 'glossary' => array(
1113 '{{name}}' => gettext("The name for the data we're inputting"),
1114 '{{column1}}' => gettext("The first item of data"),
1115 '{{column2}}' => gettext("The second item of data")
1119 $template['databox'] = <<< END
1121 <div class="infobox">
1122 <table width="95%" class="profiletable" align="center" style="margin-bottom: 3px">
1123 <tr>
1125 <td width="20%" class="fieldname" valign="top">
1126 <p><b>{{name}}</b></p>
1127 </td>
1128 <td width="50%" valign="top">
1129 <p>{{column1}}</p>
1130 </td>
1131 <td width="30%" valign="top">
1132 <p>{{column2}}</p>
1133 </td>
1134 </tr>
1135 </table>
1136 </div>
1138 END;
1140 $template_definition[] = array(
1141 'id' => 'databox1',
1142 'name' => gettext("Data input box (one column)"),
1143 'description' => gettext("A single-column version of the data box."),
1144 'glossary' => array(
1145 '{{name}}' => gettext("The name of the data we're inputting"),
1146 '{{column1}}' => gettext("The data itself")
1150 $template['databox1'] = <<< END
1152 <div class="infobox">
1153 <table width="95%" class="profiletable" align="center" style="margin-bottom: 3px">
1154 <tr>
1156 <td width="20%" class="fieldname" valign="top">
1157 <p><b>{{name}}</b></p>
1158 </td>
1159 <td width="80%" valign="top">
1160 <p>{{column1}}</p>
1161 </td>
1162 </tr>
1163 </table>
1164 </div>
1166 END;
1168 $template_definition[] = array(
1169 'id' => 'databoxvertical',
1170 'name' => gettext("Data input box (vertical)"),
1171 'description' => gettext("A slightly different version of the data box, used on this edit page amongst other places."),
1172 'glossary' => array(
1173 '{{name}}' => gettext("Name of the data we\'re inputting"),
1174 '{{contents}}' => gettext("The data itself")
1178 $template['databoxvertical'] = <<< END
1179 <div class="infobox">
1180 <table width="95%" class="fileTable" align="center" style="margin-bottom: 3px">
1181 <tr>
1182 <td class="fieldname">
1183 <p><b>{{name}}</b></p>
1184 </td>
1185 </tr>
1186 <tr>
1187 <td>
1188 <p>{{contents}}</p>
1189 </td>
1190 </tr>
1191 </table>
1192 </div>
1194 END;
1195 return $run_result;
1198 function templates_main () {
1200 global $PAGE;
1202 $run_result = '';
1205 * Templates unit
1208 // Load default values
1209 $function['init'][] = path . "units/templates/default_template.php";
1211 // Actions
1212 $function['templates:init'][] = path . "units/templates/template_actions.php";
1214 // Draw template (returns HTML as opposed to echoing it straight to the screen)
1215 $function['templates:draw'][] = path . "units/templates/template_draw.php";
1217 // Function to substitute variables within a template, used in templates:draw
1218 $function['templates:variables:substitute'][] = path . "units/templates/variables_substitute.php";
1220 // Function to draw the page, once supplied with a main body and title
1221 $function['templates:draw:page'][] = path . "units/templates/page_draw.php";
1223 // Function to display a list of templates
1224 $function['templates:view'][] = path . "units/templates/templates_view.php";
1225 $function['templates:preview'][] = path . "units/templates/templates_preview.php";
1227 // Function to display input fields for template editing
1228 $function['templates:edit'][] = path . "units/templates/templates_edit.php";
1230 // Function to allow the user to create a new template
1231 $function['templates:add'][] = path . "units/templates/templates_add.php";
1233 if ($context == "account") {
1234 $PAGE->menu_sub[] = array( 'name' => 'template:edit',
1235 'html' => templates_draw(array( 'context' => 'submenuitem',
1236 'name' => gettext("Change theme"),
1237 'location' => url . '_templates/')));
1240 return $run_result;
1243 function templates_page_setup (){
1245 global $PAGE;
1246 global $CFG;
1248 if (!empty($PAGE->setupdone)) {
1249 return false; // don't run twice
1252 $PAGE->setupdone = true; // leave your mark
1255 // Populate $PAGE with links for non-module core code
1258 if (isadmin()) {
1259 $PAGE->menu_top [] = array( 'name' => 'admin',
1260 'html' => a_hrefg("{$CFG->wwwroot}_admin/",
1261 "Administration"));
1264 $PAGE->menu_top[] = array(
1265 'name' => 'userdetails',
1266 'html' => a_hrefg("{$CFG->wwwroot}_userdetails/",
1267 "Account settings"));
1269 $PAGE->menu_top[] = array(
1270 'name' => 'logoff',
1271 'html' => a_hrefg("{$CFG->wwwroot}login/logout.php",
1272 "Log off"));
1274 if (context == "account") {
1275 $PAGE->menu_sub[] = array(
1276 'name' => 'user:edit',
1277 'html' => a_hrefg("{$CFG->wwwroot}_userdetails/",
1278 "Edit user details"));
1279 $PAGE->menu_sub[] = array(
1280 'name' => 'user:icon',
1281 'html' => a_hrefg("{$CFG->wwwroot}_icons/",
1282 "Your site picture"));
1285 if (context == "admin" && logged_on && run("users:flags:get",array("admin", $_SESSION['userid']))) {
1286 $PAGE->menu_sub[] = array(
1287 'name' => 'admin',
1288 'html' => a_hrefg("{$CFG->wwwroot}_admin/",
1289 "Main"));
1291 $PAGE->menu_sub[] = array(
1292 'name' => 'admin:useradd',
1293 'html' => a_hrefg("{$CFG->wwwroot}_admin/users_add.php",
1294 "Add users"));
1296 $PAGE->menu_sub[] = array(
1297 'name' => 'admin:users',
1298 'html' => a_hrefg("{$CFG->wwwroot}_admin/users.php",
1299 "Manage users"));
1301 $PAGE->menu_sub[] = array(
1302 'name' => 'admin:flaggedcontent',
1303 'html' => a_hrefg("{$CFG->wwwroot}_admin/flags.php",
1304 "Manage flagged content"));
1306 $PAGE->menu_sub[] = array(
1307 'name' => 'admin:spam',
1308 'html' => a_hrefg("{$CFG->wwwroot}_admin/antispam.php",
1309 "Spam control"));
1315 // Give a chance to all registered modules
1317 if ($allmods = get_list_of_plugins('mod') ) {
1318 foreach ($allmods as $mod) {
1319 $mod_pagesetup = $mod . '_pagesetup';
1320 if (function_exists($mod_pagesetup)) {
1321 $mod_pagesetup();
1322 } else {
1323 notify("Function $mod_pagesetup doesn't exist!");
1329 function templates_page_draw ($param) {
1330 // Draws the page, given a title and a main body (parameters[0] and [1]).
1331 $title = $param[0];
1332 $mainbody = $param[1];
1334 $run_result = '';
1336 global $messages;
1338 ////
1339 //// Prepare things for the module run
1340 //// populating $PAGE as required
1341 ////
1342 if (empty($PAGE->setupdone)) {
1343 templates_page_setup();
1346 $messageshell = "";
1347 if (isset($messages) && sizeof($messages) > 0) {
1348 foreach($messages as $message) {
1349 $messageshell .=templates_draw(array(
1350 'context' => 'messages',
1351 'message' => $message
1355 $messageshell =templates_draw(array(
1356 'context' => 'messageshell',
1357 'messages' => $messageshell
1362 // If $parameter[2] is set, we'll substitute it for the
1363 // sidebar
1364 if (isset($param[2])) {
1365 $sidebarhtml = $param[2];
1366 } else {
1367 $sidebarhtml = run("display:sidebar");
1370 $run_result .= templates_draw(array(
1371 'context' => 'pageshell',
1372 'title' => $title,
1373 'menu' => displaymenu(),
1374 'submenu' => displaymenu_sub(),
1375 'top' => displaymenu_top(),
1376 'sidebar' => $sidebarhtml,
1377 'mainbody' => $mainbody,
1378 'messageshell' => $messageshell
1381 return $run_result;
1384 function templates_actions () {
1386 global $CFG,$USER,$db;
1388 // Actions
1390 global $template;
1391 global $messages;
1393 $action = optional_param('action');
1394 if (!logged_on) {
1395 return false;
1398 $run_result = '';
1400 switch ($action) {
1401 case "templates:select":
1402 $id = optional_param('selected_template',0,PARAM_INT);
1403 if ($id == -1) {
1404 $exists = 1;
1405 } else {
1406 $exists = record_exists_sql('SELECT ident FROM '.$CFG->prefix.'templates WHERE ident = '.$id.' AND (owner = '.$USER->ident ." OR public='yes')");
1408 if ($exists) {
1409 $t = new StdClass;
1410 $t->template_id = $id;
1411 $t->ident = $USER->ident;
1412 update_record('users',$t);
1414 $messages[] = gettext("Your current template has been changed.");
1416 break;
1418 case "templates:save":
1419 $template = optional_param('template');
1420 $id = optional_param('save_template_id',0,PARAM_INT);
1421 $templatetitle = optional_param('templatetitle');
1422 if (!empty($template) && !empty($id) && !empty($templatetitle)) {
1423 unset($_SESSION['template_element_cache'][$id]);
1424 $exists = record_exists('templates','ident',$id,'owner',$USER->ident);
1425 if ($exists) {
1426 $t = new StdClass;
1427 $t->name = $templatetitle;
1428 $t->ident = $id;
1429 update_record('templates',$t);
1430 delete_records('template_elements','template_id',$id);
1431 $contents = optional_param('template');
1432 foreach ($contents as $name => $content) {
1433 //TODO Fix this with PARAM_CLEANHTML or similar
1434 $slashname = addslashes($name);
1435 $slashcontent = addslashes($content);
1436 if ($content != "" && $content != $template[$name]) {
1437 $te = new StdClass;
1438 $te->name = $slashname;
1439 $te->content = $slashcontent;
1440 $te->template_id = $id;
1441 insert_record('template_elements',$te);
1444 $messages[] = gettext("Your template has been updated.");
1447 break;
1448 case "deletetemplate":
1449 $id = optional_param('delete_template_id',0,PARAM_INT);
1450 unset($_SESSION['template_element_cache'][$id]);
1451 $exists = record_exists('templates','ident',$id,'owner',$USER->ident);
1452 if ($exists) {
1453 $db->execute('UPDATE '.$CFG->prefix.'users SET template_id = -1 WHERE template_id = '.$id);
1454 delete_records('template_elements','template_id',$id);
1455 delete_records('template','ident',$id);
1456 $messages[] = gettext("Your template was deleted.");
1458 break;
1459 case "templates:create":
1460 $based_on = optional_param('template_based_on',0,PARAM_INT);
1461 $name = optional_param('new_template_name');
1462 if (!empty($name)) { // $based_on can be empty, surely? -Penny
1463 $t = new StdClass;
1464 $t->name = $name;
1465 $t->public = 'no';
1466 $t->owner = $USER->ident;
1467 $new_template_id = insert_record('templates',$t);
1468 if ($based_on != -1) {
1469 $exists = record_exists_sql('SELECT ident FROM '.$CFG->prefix.'templates WHERE ident = ? AND (owner = ? OR public = ?)',array($based_on,$USER->ident,'yes'));
1470 if ($exists) {
1471 if ($elements = get_records('template_elements','template_id',$based_on)) {
1472 foreach($elements as $element) {
1473 $element->template_id = $new_template_id;
1474 insert_record('template_elements',$element);
1480 break;
1482 return $run_result;
1485 /// NOTE: this function takes a named array as single parameter
1486 function templates_draw ($parameter) {
1488 // Draw a page element using a specified template (or, if the template is -1, the default)
1489 // $parameter['template'] = the template ID, $parameter['element'] = the template element,
1490 // all other $parameter[n] = template elements
1492 // Initialise global template variable, which contains the default template
1493 global $template;
1495 // Initialise global template ID variable, which contains the template ID we're using
1496 global $template_id;
1497 global $page_owner;
1499 global $page_template_cache;
1501 $run_result = '';
1503 if ($parameter['context'] === 'topmenuitem') {
1504 // error_log("templates_draw pcontext " . print_r($parameter,1));
1506 // Get template details
1507 if (!isset($template_id)) {
1508 if (!isset($page_owner) || $page_owner == -1) {
1509 $template_id = -1;
1510 } else {
1511 // if (!isset($_SESSION['template_id_cache'][$page_owner])) {
1512 if (!$template_id = get_field('users','template_id','ident',$page_owner)) {
1513 $template_id = -1;
1515 // }
1516 // $template_id = $_SESSION['template_id_cache'][$page_owner];
1520 // Template ID override
1521 $t = optional_param('template_preview',0,PARAM_INT);
1522 if (!empty($t)) {
1523 $template_id = $t;
1526 // Grab the template content
1527 if ($template_id == -1 || ($parameter['context'] != "css" && $parameter['context'] != "pageshell")) {
1528 $template_element = $template[$parameter['context']];
1529 } else {
1530 $template_context = addslashes($parameter['context']);
1531 if (!isset($page_template_cache[$parameter['context']])) {
1532 $result = get_template_element($template_id, $template_context);
1533 $page_template_cache[$parameter['context']] = $result;
1534 } else {
1535 $result = $page_template_cache[$parameter['context']];
1537 if (!empty($result)) {
1538 $template_element = stripslashes($result->content);
1539 } else {
1540 $template_element = $template[$parameter['context']];
1544 if ($parameter['context'] === 'topmenuitem') {
1545 // error_log("templates_draw pcontext " . print_r($template_element));
1548 // Substitute elements
1550 $functionbody = "
1551 \$passed = array(".var_export($parameter,true).",\$matches[1], " . $template_id . ");
1552 return templates_variables_substitute(\$passed);
1555 // $template_element = templates_variables_substitute(array($parameter,$template_element));
1556 $body = preg_replace_callback("/\{\{([A-Za-z_0-9]*)\}\}/i",create_function('$matches',$functionbody),$template_element);
1558 $run_result = $body;
1559 return $run_result;
1562 function templates_add () {
1563 global $USER;
1565 // Create a new template
1566 $header = gettext("Create theme"); // gettext variable
1567 $desc = gettext("Here you can create your own themes based on one of the existing public themes. Just select which public theme you would like to alter and then create your own. You will now have edit privilages."); // gettext variable
1569 $panel = <<< END
1571 <h2>$header</h2>
1572 <p>$desc</p>
1573 <form action="index.php" method="post">
1575 END;
1577 $panel .= <<< END
1579 END;
1581 $panel .=templates_draw(array(
1582 'context' => 'databox1',
1583 'name' => gettext("Theme name"),
1584 'column1' => display_input_field(array("new_template_name","","text"))
1588 $default = gettext("Default Theme"); // gettext variable
1589 $column1 = <<< END
1591 <select name="template_based_on">
1592 <option value="-1">$default</option>
1593 END;
1595 if ($templates = get_records_select('templates','owner = '.$USER->ident." OR public = 'yes'",'public')) {
1596 foreach($templates as $template) {
1597 $column1 .= "<option value=\"".$template->ident."\">".stripslashes($template->name) . "</option>";
1601 $column1 .= <<< END
1602 </select>
1603 END;
1605 $panel .=templates_draw(array(
1606 'context' => 'databox1',
1607 'name' => gettext("Based on"),
1608 'column1' => $column1
1612 $buttonValue = gettext("Create Theme"); // gettext variable
1613 $panel .= <<< END
1616 <input type="hidden" name="action" value="templates:create" />
1617 <input type="submit" value="$buttonValue" />
1618 </p>
1620 </form>
1622 END;
1624 $run_result .= $panel;
1625 return $run_result;
1628 function templates_edit () {
1631 global $template;
1632 global $template_definition;
1633 global $USER;
1635 if (!isset($parameter)) {
1636 // Get template details
1637 if (!$template_id = get_field('users','template_id','ident',$USER->ident)) {
1638 $template_id = -1;
1640 } else {
1641 if (!is_array($parameter)) {
1642 $template_id = (int) $parameter;
1643 } else {
1644 $template_id = -1;
1648 // Grab title, see if we can edit the template
1649 $editable = 0;
1650 if ($template_id == -1) {
1651 $templatetitle = gettext("Default Theme");
1652 } else {
1653 $templatestuff = get_record('templates','ident',$template_id);
1654 $templatetitle = stripslashes($templatestuff->name);
1655 if ($templatestuff->owner == $USER->ident) {
1656 $editable = 1;
1658 if (($templatestuff->owner != $USER->ident) && ($templatestuff->public != 'yes')) {
1659 $template_id = -1;
1663 // Grab the template content
1664 if ($template_id == -1) {
1665 $current_template = $template;
1666 } else {
1667 if ($elements = get_records('template_elements','template_id',$template_id)) {
1668 foreach($result as $element) {
1669 $current_template[stripslashes($element->name)] = stripslashes($element->content);
1671 } else {
1672 $current_template = $template;
1676 $run_result .= <<< END
1678 <form action="" method="post">
1680 END;
1682 $run_result .= templates_draw(array(
1683 'context' => 'databoxvertical',
1684 'name' => gettext("Theme Name"),
1685 'contents' => display_input_field(array("templatetitle",$templatetitle,"text"))
1689 foreach($template_definition as $element) {
1691 $name = "<b>" . $element['name'] . "</b><br /><i>" . $element['description'] . "</i>";
1692 $glossary = gettext("Glossary"); // gettext variable
1694 if (is_array($element['glossary']) && sizeof($element['glossary']) > 0) {
1695 $column1 = "<b>$glossary</b><br />";
1696 foreach($element['glossary'] as $gloss_id => $gloss_descr) {
1697 $column1 .= $gloss_id . " -- " . $gloss_descr . "<br />";
1699 } else {
1700 $column1 = "";
1703 if ($current_template[$element['id']] == "" || !isset($current_template[$element['id']])) {
1704 $current_template[$element['id']] = $template[$element['id']];
1707 $column2 = display_input_field(array("template[" . $element['id'] . "]",$current_template[$element['id']],"longtext"));
1709 $run_result .=templates_draw(array(
1710 'context' => 'databox',
1711 'name' => $name,
1712 'column2' => $column1,
1713 'column1' => $column2
1717 $run_result .=templates_draw(array(
1718 'context' => 'databoxvertical',
1719 'name' => $name,
1720 'contents' => $column1 . "<br />" . $column2
1727 if ($editable) {
1728 $save = gettext("Save"); // gettext variable
1729 $run_result .= <<< END
1731 <p align="center">
1732 <input type="hidden" name="action" value="templates:save" />
1733 <input type="hidden" name="save_template_id" value="$template_id" />
1734 <input type="submit" value="$save" />
1735 </p>
1737 END;
1738 } else {
1739 $noEdit = gettext("You may not edit this theme. To create a new, editable theme based on the default, go to <a href=\"index.php\">the main themes page</a>."); // gettext variable
1740 $run_result .= <<< END
1743 $noEdit
1744 </p>
1746 END;
1748 $run_result .= <<< END
1750 </form>
1752 END;
1753 return $run_result;
1756 function templates_preview () {
1758 global $CFG;
1760 // Preview template
1762 // Basic page elements
1764 $name = "Basic page elements";
1765 $heading1 = gettext("Heading one"); // gettext variable
1766 $heading2 = gettext("Heading two"); // gettext variable
1767 $bulletList = gettext("A bullet list"); // gettext variable
1768 $heading3 = gettext("Heading three"); // gettext variable
1769 $numberedList = gettext("A numbered list"); // gettext variable
1770 $body = <<< END
1772 <img src="{$CFG->wwwroot}_templates/leaves.jpg" width="300" height="225" alt="A test image" align="right" />
1773 <h1>$heading1</h1>
1774 <p>Paragraph text</p>
1775 <h2>$heading2</h2>
1776 <ul>
1777 <li>$bulletList</li>
1778 </ul>
1779 <h3>$heading3</h3>
1780 <ol>
1781 <li>$numberedList</li>
1782 </ol>
1784 END;
1786 $run_result .=templates_draw(array(
1787 'context' => 'contentholder',
1788 'title' => $name,
1789 'body' => $body
1793 // Form elements
1795 $name = "Data input";
1797 $body =templates_draw(array(
1798 'context' => 'databox',
1799 'name' => gettext("Some text input"),
1800 'column1' => display_input_field(array("blank","","text")),
1801 'column2' => run("display:access_level_select",array("blank","PUBLIC"))
1804 $body .=templates_draw(array(
1805 'context' => 'databox1',
1806 'name' => gettext("Some longer text input"),
1807 'column1' => display_input_field(array("blank","","longtext"))
1810 $body .=templates_draw(array(
1811 'context' => 'databoxvertical',
1812 'name' => gettext("Further text input"),
1813 'contents' => display_input_field(array("blank","","longtext")) . "<br />" . display_input_field(array("blank","","text")) . "<br /><input type='button' value='Button' />"
1817 $run_result .=templates_draw(array(
1818 'context' => 'contentholder',
1819 'title' => $name,
1820 'body' => $body,
1821 'submenu' => ''
1824 return $run_result;
1827 function templates_view () {
1828 global $USER;
1830 $user_template = get_field('users','template_id','ident',$USER->ident);
1831 $sitename = sitename;
1832 $title = gettext("Select / Create / Edit Themes"); // gettext variable
1833 $header = gettext("Public Themes"); // gettext variable
1834 $desc = sprintf(gettext("The following are public themes that you can use to change the way your %s looks - these do not change the content only the appearance. Check the preview and then select the one you want. If you wish you can adapt one of these using the 'create theme' option below."), $sitename); // gettext variable
1835 $panel = <<< END
1837 <h2>$title</h2>
1838 <form action="" method="post">
1839 <h3>
1840 $header
1841 </h3>
1843 $desc
1844 </p>
1846 END;
1848 $template_list[] = array(
1849 'name' => gettext("Default Theme"),
1850 'id' => -1
1852 if ($templates = get_records('templates','public','yes')) {
1853 foreach($templates as $template) {
1854 $template_list[] = array(
1855 'name' => stripslashes($template->name),
1856 'id' => stripslashes($template->ident)
1860 foreach($template_list as $template) {
1861 $name = "<input type='radio' name='selected_template' value='".$template['id']."' ";
1862 if ($template['id'] == $user_template) {
1863 $name .= "checked=\"checked\"";
1865 $name .=" /> ";
1866 $column1 = "<b>" . $template['name'] . "</b>";
1867 $column2 = "<a href=\"".url."_templates/preview.php?template_preview=".$template['id']."\" target=\"preview\">" . gettext("preview") . "</a>";
1868 $panel .=templates_draw(array(
1869 'context' => 'databox',
1870 'name' => $name,
1871 'column1' => $column1,
1872 'column2' => $column2
1877 $templates = get_records('templates','owner',$USER->ident);
1878 $header2 = gettext("Personal themes"); // gettext variable
1879 $desc2 = gettext("These are themes that you have created. You can edit and delete these. These theme(s) only control actual look and feel - you cannot change any content here. To change any of your content you need to use the other menu options such as: edit profile, update weblog etc."); // gettext variable
1881 if (is_array($templates) && sizeof($templates) > 0) {
1882 $panel .= <<< END
1883 <h3>
1884 $header2
1885 </h3>
1887 $desc2
1888 </p>
1890 END;
1892 foreach($templates as $template) {
1893 $name = "<input type='radio' name='selected_template' value='".$template->ident."'";
1894 if ($template->ident == $user_template) {
1895 $name .= "checked=\"checked\"";
1897 $name .=" /> ";
1898 $column1 = "<b>" . stripslashes($template->name) . "</b>";
1899 $column2 = "<a href=\"".url."_templates/preview.php?template_preview=".$template->ident."\" target=\"preview\">" . gettext("preview") . "</a>";
1901 $column2 .= " | <a href=\"".url."_templates/edit.php?id=".$template->ident."\" >". gettext("Edit") ."</a>";
1902 $column2 .= " | <a href=\"".url."_templates/?action=deletetemplate&amp;delete_template_id=".$template->ident."\" onclick=\"return confirm('" . gettext("Are you sure you want to permanently remove this template?") . "')\">" . gettext("Delete") . "</a>";
1903 $panel .=templates_draw(array(
1904 'context' => 'databox',
1905 'name' => $name,
1906 'column1' => $column1,
1907 'column2' => $column2
1913 $submitValue = gettext("Select new theme"); // gettext variable
1914 $panel .= <<< END
1917 <input type="submit" value=$submitValue />
1918 <input type="hidden" name="action" value="templates:select" />
1919 </p>
1921 </form>
1923 END;
1925 $run_result .= $panel;
1926 return $run_result;
1929 function templates_variables_substitute ($param) {
1931 global $CFG;
1933 $variables = $param[0];
1934 $template_variable = $param[1];
1936 $run_result = '';
1938 // Substitute variables in templates:
1939 // where {{variablename}} is found in the template, this function is passed
1940 // "variablename" and returns the proper variable
1942 global $menubar;
1943 global $submenubar;
1944 global $metatags;
1945 global $PAGE;
1946 global $template_id;
1948 //error_log("tvs " . print_r($template_variable,1));
1950 if (isset($variables[$template_variable])) {
1951 return $variables[$template_variable];
1952 } else {
1953 switch($template_variable) {
1955 case "username":
1956 if (logged_on) {
1957 return $_SESSION['username'];
1958 } else {
1959 return gettext("Guest");
1961 break;
1963 case "userfullname":
1964 if (logged_on) {
1965 return $_SESSION['name'];
1966 } else {
1967 return gettext("Guest")
1968 . " [<a href=\"".url."login/index.php\">" . gettext("Log in") . "</a>]";
1970 break;
1971 case "menu":
1972 if (logged_on) {
1973 return templates_draw(array(
1974 'menuitems' => menu_join('', $PAGE->menu),
1975 'context' => 'menu'
1978 break;
1980 case "submenu":
1981 return templates_draw(array(
1982 'submenuitems' => menu_join('&nbsp;|&nbsp;', $PAGE->menu_sub),
1983 'context' => 'submenu'
1985 break;
1987 case "topmenu":
1988 if (logged_on) {
1989 return templates_draw(array(
1990 'topmenuitems' => menu_join('&nbsp;|&nbsp;', $PAGE->menu_top),
1991 'context' => 'topmenu'
1994 break;
1996 case "url":
1997 return url;
1998 break;
2000 case "userfullname":
2001 global $page_owner;
2002 if (!isset($page_owner) || $page_owner == -1) {
2003 return "";
2004 } else {
2005 return run("users:id_to_name", $page_owner);
2007 break;
2009 case "metatags":
2010 // $run_result = "<link href=\"/".$template_variable.".css\" rel=\"stylesheet\" type=\"text/css\" />";
2011 return "<style type=\"text/css\"><!--\n"
2012 . templates_draw(array(
2013 'template' => $template_id,
2014 'context' => 'css'
2017 . "// -->\n</style>\n"
2018 . $metatags;
2019 break;
2021 case 'perf':
2022 $perf = get_performance_info();
2023 if (defined('ELGG_PERFTOLOG')) {
2024 error_log("PERF: " . $perf['txt']);
2026 if (defined('ELGG_PERFTOFOOT') || $CFG->debug > 7 || $CFG->perfdebug > 7) {
2027 return $perf['html'];
2030 break;
2033 return $run_result;
2036 /***
2037 *** Fetches the template elements from disk or db.
2038 ***/
2039 function get_template_element ($template_id, $element_name) {
2040 global $CFG;
2042 if ($CFG->templatestore === 'db') {
2043 $result = get_record('template_elements','template_id',$template_id,'name',$element_name);
2044 } else {
2045 $template_name = get_field('templates', 'name', 'ident', $template_id);
2046 $template_name = strtolower(clean_param($template_name, PARAM_ALPHANUM));
2047 $template_file = $CFG->templatesroot . $template_name . '/' . $element_name;
2049 if (! $element_content = file_get_contents($template_file)) {
2050 trigger_error("Problems retrieving template element from $template_file");
2051 } else {
2052 $result = new StdClass;
2053 $result->content = $element_content;
2054 $result->ident = $template_id;
2055 $result->name = $element_name;
2058 return $result;
2061 /*** menu_join()
2062 *** performs a join on one of
2063 *** the $PAGE->menu* variables
2064 *** returns HTML
2065 ***/
2066 function menu_join ($separator, $menuarray) {
2067 $html = array();
2068 foreach ($menuarray as $entry) {
2069 array_push($html, $entry['html']);
2071 return join($separator, $html);