]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - themes/fusionforge/themeinfo.php
Reformat code
[SourceForge/phpwiki.git] / themes / fusionforge / themeinfo.php
1 <?php
2 // Avoid direct call to this file.
3 // PHPWIKI_VERSION is defined in lib/prepend.php
4 if (!defined('PHPWIKI_VERSION')) {
5     header("Location: /");
6     exit;
7 }
8
9 require_once 'lib/WikiTheme.php';
10 require_once 'themes/wikilens/themeinfo.php';
11
12 class WikiTheme_fusionforge extends WikiTheme_Wikilens
13 {
14
15     function getCSS()
16     {
17         $css = array();
18         $css[] = $this->_CSSlink("", "fusionforge.css", "");
19         $css[] = $this->_CSSlink("", "fusionforge-print.css", "print");
20         $css[] = $this->_CSSlink("Fullscreen", "fusionforge-fullscreen.css", "screen", true);
21         $css[] = $this->_CSSlink("Autonumbering", "fusionforge-autonumbering.css", "", true);
22         $css[] = $this->_CSSlink("Rereading Mode", "fusionforge-rereading.css", "", true);
23         return HTML($css);
24     }
25
26     function header()
27     {
28         global $HTML, $group_id, $group_public_name, $request, $project;
29
30         $pagename = $request->getArg('pagename');
31
32         $submenu = Template('navbar')->asXML();
33
34         if (defined('FUSIONFORGE') and FUSIONFORGE) {
35
36             $domain = textdomain(NULL);
37             textdomain('fusionforge');
38
39             //group is private
40             if (!$project->isPublic()) {
41                 //if it's a private group, you must be a member of that group
42                 session_require_perm('project_read', $group_id);
43             }
44
45             //for dead projects must be member of admin project
46             if (!$project->isActive()) {
47                 //only SF group can view non-active, non-holding groups
48                 session_require_global_perm('forge_admin');
49             }
50
51             $HTML->header(array('h1' => '',
52                     'title' => $group_public_name . _(": ") . htmlspecialchars($pagename),
53                     'group' => $group_id,
54                     'toptab' => 'wiki',
55                     'submenu' => $submenu
56                 )
57             );
58
59             // Display a warning banner for internal users when the wiki is opened
60             // to external users.
61             if (method_exists($project, 'getIsExternal') && $project->getIsExternal()) {
62                 $external_user = false;
63                 if (session_loggedin()) {
64                     $user = session_get_user();
65                     $external_user = $user->getIsExternal();
66                 }
67                 if (!$external_user) {
68                     $page = $request->getPage();
69                     if ($page->get('external')) {
70                         $external_msg = _("This page is external.");
71                     }
72                     echo $HTML->information(_("This project is shared with third-party users") .
73                         sprintf(_(" (non %s users)."), forge_get_config('company')) .
74                         (isset($external_msg) ? ' ' . $external_msg : ''));
75                 }
76             }
77             textdomain($domain);
78         }
79     }
80
81     function footer()
82     {
83
84         if (defined('FUSIONFORGE') and FUSIONFORGE) {
85             global $HTML;
86
87             $domain = textdomain(NULL);
88             textdomain('fusionforge');
89
90             $HTML->footer(array());
91
92             textdomain($domain);
93         }
94     }
95
96     function initGlobals()
97     {
98         global $request;
99         static $already = 0;
100         if (!$already) {
101             $script_url = deduce_script_name();
102             $script_url .= '/' . $GLOBALS['group_name'];
103             if ((DEBUG & _DEBUG_REMOTE) and isset($_GET['start_debug']))
104                 $script_url .= ("?start_debug=" . $_GET['start_debug']);
105             $folderArrowPath = dirname($this->_findData('images/folderArrowLoading.gif'));
106             $pagename = $request->getArg('pagename');
107             $this->addMoreHeaders(JavaScript('', array('src' => $this->_findData("wikilens.js"))));
108             $js = "var data_path = '" . javascript_quote_string(DATA_PATH) . "';\n"
109                 // Temp remove pagename because of XSS warning
110                 //  ."var pagename  = '". javascript_quote_string($pagename) ."';\n"
111                 . "var script_url= '" . javascript_quote_string($script_url) . "';\n"
112                 . "var stylepath = data_path+'/" . javascript_quote_string($this->_theme) . "/';\n"
113                 . "var folderArrowPath = '" . javascript_quote_string($folderArrowPath) . "';\n"
114                 . "var use_path_info = " . (USE_PATH_INFO ? "true" : "false") . ";\n";
115             $this->addMoreHeaders(JavaScript($js));
116             $already = 1;
117         }
118     }
119
120     function load()
121     {
122
123         $this->initGlobals();
124
125         /**
126          * The Signature image is shown after saving an edited page. If this
127          * is set to false then the "Thank you for editing..." screen will
128          * be omitted.
129          */
130
131         $this->addImageAlias('signature', WIKI_NAME . "Signature.png");
132         // Uncomment this next line to disable the signature.
133         $this->addImageAlias('signature', false);
134
135         /*
136          * Link icons.
137          */
138         $this->setLinkIcon('http');
139         $this->setLinkIcon('https');
140         $this->setLinkIcon('ftp');
141         $this->setLinkIcon('mailto');
142
143         $this->setButtonSeparator("");
144
145         /**
146          * WikiWords can automatically be split by inserting spaces between
147          * the words. The default is to leave WordsSmashedTogetherLikeSo.
148          */
149         $this->setAutosplitWikiWords(false);
150
151         /**
152          * Layout improvement with dangling links for mostly closed wiki's:
153          * If false, only users with edit permissions will be presented the
154          * special wikiunknown class with "?" and Tooltip.
155          * If true (default), any user will see the ?, but will be presented
156          * the PrintLoginForm on a click.
157          */
158         $this->setAnonEditUnknownLinks(false);
159
160         /*
161          * You may adjust the formats used for formatting dates and times
162          * below.  (These examples give the default formats.)
163          * Formats are given as format strings to PHP strftime() function See
164          * http://www.php.net/manual/en/function.strftime.php for details.
165          * Do not include the server's zone (%Z), times are converted to the
166          * user's time zone.
167          */
168         $this->setDateFormat("%d %B %Y");
169         $this->setTimeFormat("%H:%M");
170     }
171
172     /* Callback when a new user creates or edits a page */
173     function CbNewUserEdit(&$request, $userid)
174     {
175         $content = "{{Template/UserPage}}\n\n----\n[[CategoryWiki user]]";
176         $dbi =& $request->_dbi;
177         $page = $dbi->getPage($userid);
178         $page->save($content, WIKIDB_FORCE_CREATE, array('author' => $userid));
179         $dbi->touch();
180     }
181 }
182
183 $WikiTheme = new WikiTheme_fusionforge('fusionforge');
184
185 // Local Variables:
186 // mode: php
187 // tab-width: 8
188 // c-basic-offset: 4
189 // c-hanging-comment-ender-p: nil
190 // indent-tabs-mode: nil
191 // End: