Browse the code
| Revision log Information on the revision | |
|---|---|
| Revision: | 93 (differences) |
| Author: | xbright |
| Log message: |
* Some work on the Template class and the .tpl * Added an .htaccess option |
| Change revision: | |
0
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
<?php # ***** BEGIN LICENSE BLOCK ***** # # This file is a part of CodingTeam. See <http://www.codingteam.net>. # Copyright (C) 2007 CodingTeam Team (See AUTHORS and THANKS for details) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # # ***** END LICENSE BLOCK ***** class Template { private $tpl, $page, $ct_session, $ct_db, $basedir; function __construct ($tpl, $page, $ct_session, $ct_db, $basedir) { if ($ct_session->isLogged($ct_db)) // WARNING: add a '!' before test for the true return { $cachename = ereg_replace('/', '-', $page); $cachenamefile = $basedir.'/public/cache/'.md5($cachename).'.ctcache'; if (@filemtime($cachenamefile) < time() - ( 3600 * 24 * 360 )) { ob_start(); $this->parse($tpl, $page, $ct_session, $ct_bd, $basedir); $cachecontent = ob_get_contents(); ob_end_flush(); $filec = fopen($cachenamefile, 'w'); fwrite($filec, $cachecontent); fclose($filec); } else include ($cachenamefile); } else $this->parse($tpl, $page, $ct_session, $ct_bd, $basedir); } function parse ($tpl, $page, $ct_session, $ct_db, $basedir) { // Load user authentification module and requested module require($basedir.'/inc/modules/head_member/head_member.php'); $head_member = new head_member(); $head_member->treatForms($ct_db); $pagetag = explode('/', $page); foreach ($pagetag as $tag_ => $value) $req[$i++] = $value; $temp['tpl:lang'] = $req[1]; $temp['tpl:requesturi'] = substr($page, 4); require($basedir.'/inc/modules/'.$req[2].'/'.$req[2].'.php'); $view_loaded = new Module(); $view_loaded->treatForms($ct_db); // Import the .tpl file $this->tpl_file = file_get_contents($tpl); $temp['tpl:cssdir'] = '/inc/templates/'; $temp['tpl:images'] = '/public/images/'; // Set global values $temp['slogan'] = _('Create. Participate. Evolve. Free Software.'); $temp['button_search'] = _('Search'); $temp['link_freesoftwareprojects'] = _('Free software projects'); $temp['link_forum'] = _('Forum'); $temp['link_jabberserver'] = _('Jabber Server'); $temp['link_notepad'] = _('Notepad'); $temp['link_addproject'] = _('Add your project'); $poweredby = _('Powered by CodingTeam <strong>%s</strong>'); $temp['poweredby'] = str_replace('%s', file_get_contents($basedir.'/VERSION'), $poweredby); $temp['link_about'] = _('About CodingTeam'); $temp['link_donation'] = _('Make a donation'); // Set global views ob_start(); $head_member->getPageContent($ct_session, $ct_db); $temp['view:head_member'] = ob_get_clean(); // Set page data $view_loaded->getPageData(); $temp['title'] = $view_loaded->title; $temp['htmlmeta'] = $view_loaded->meta; // Set page menu ob_start(); $view_loaded->getPageMenu(); $temp['view:pagemenu'] = ob_get_clean(); // Set page content ob_start(); $view_loaded->getPageContent(); $temp['view:pagecontent'] = ob_get_clean(); // Edit the template foreach ($temp as $key => $value) { $search[] = '{'.$key.'}'; $replace[] = $value; } $this->tpl_show = str_replace($search, $replace, $this->tpl_file); // Show the result echo $this->tpl_show; } } ?>

CodingTeam