00001 <?php
00002 # This file is part of the Savane project
00003 # <http://gna.org/projects/savane/>
00004 #
00005 # $Id: title.php 4975 2005-11-15 17:25:35Z yeupou $
00006 #
00007 # Copyright 2005 (c) Mathieu Roy <yeupou--gnu.org>
00008 #
00009 # The Savane project is free software; you can redistribute it and/or
00010 # modify it under the terms of the GNU General Public License
00011 # as published by the Free Software Foundation; either version 2
00012 # of the License, or (at your option) any later version.
00013 #
00014 # The Savane project is distributed in the hope that it will be useful,
00015 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00017 # GNU General Public License for more details.
00018 #
00019 # You should have received a copy of the GNU General Public License
00020 # along with the Savane project; if not, write to the Free Software
00021 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00022
00023
00024 # Get the context given the url. Fpr best efficiency, this function will
00025 # return guessed values as soon as possible.
00026 # As contest should be always available in pages, it will be set as constants
00027 function context_guess ()
00028 {
00029 # By default, we consider that the action, called subcontext, is browsing.
00030 # Only trackers allows actions that are not browsing or configuration.
00031 $subcontext = "browsing";
00032
00033 # Obtain the name of the current page
00034 $page = $_SERVER[SCRIPT_NAME];
00035 $page_basename = basename($page);
00036
00037 # Try a first guess of the context
00038 $context = basename(dirname($page));
00039
00040 # If context is projects, it is actually a the project/ index page
00041 # that is available at the url localhost/projects/thisgroup
00042 if ($context == "projects")
00043 {
00044 $context = "project";
00045 return context_set($context, $subcontext);
00046 }
00047
00048 # If we are in project, we need to look at the actuel script pagename
00049 # as it may gives subcontext details
00050 # This is because we want to print very short title for this specific
00051 # part of the interface, breaking the principle of having generic context
00052 # and page subtitles added after semicolon.
00053
00054 if ($context == "project")
00055 {
00056 if ($page_basename == "search.php")
00057 {
00058 $subcontext = "search";
00059 return context_set($context, $subcontext);
00060 }
00061 if ($page_basename == "memberlist.php")
00062 {
00063 $subcontext = "members";
00064 return context_set($context, $subcontext);
00065 }
00066 if ($page_basename == "memberlist-gpgkeys.php")
00067 {
00068 $subcontext = "members-gpgkeys";
00069 return context_set($context, $subcontext);
00070 }
00071 }
00072
00073 # If we are in my, we need to look at the actuel script pagename
00074 # To find out the subcontext.
00075 # This is because we want to print very short title for this specific
00076 # part of the interface, breaking the principle of having generic context
00077 # and page subtitles added after semicolon.
00078 if ($context == "my")
00079 {
00080 if ($page_basename == "bookmarks.php")
00081 {
00082 $subcontext = "bookmarks";
00083 return context_set($context, $subcontext);
00084 }
00085 if ($page_basename == "items.php")
00086 {
00087 $subcontext = "items";
00088 return context_set($context, $subcontext);
00089 }
00090 if ($page_basename == "groups.php")
00091 {
00092 $subcontext = "groups";
00093 return context_set($context, $subcontext);
00094 }
00095 if ($page_basename == "votes.php")
00096 {
00097 $subcontext = "votes";
00098 return context_set($context, $subcontext);
00099 }
00100 }
00101
00102 # Same with site administration part
00103 if ($context == "siteadmin")
00104 {
00105 if ($page_basename == "group_type.php")
00106 {
00107 $subcontext = "grouptype";
00108 return context_set($context, $subcontext);
00109 }
00110 if ($page_basename == "grouplist.php")
00111 {
00112 $subcontext = "groupedit";
00113 return context_set($context, $subcontext);
00114 }
00115 if ($page_basename == "groupedit.php")
00116 {
00117 $subcontext = "groupedit";
00118 return context_set($context, $subcontext);
00119 }
00120 if ($page_basename == "userlist.php")
00121 {
00122 $subcontext = "useredit";
00123 return context_set($context, $subcontext);
00124 }
00125 return context_set($context, $subcontext);
00126 }
00127
00128
00129 # If we are in usual trackers pages, try to guess the action (subcontext)
00130 # from the arguments passed in the request.
00131 # We want to know if the guy is:
00132 # - posting new items
00133 # - editing items / posting comments
00134 # - doing searches
00135 # - doing configuration
00136 # This is relevant if ARTIFACT has been already defined, which means
00137 # we are for sure in trackers pages.
00138 if (defined('ARTIFACT') && $context != "admin")
00139 {
00140 if ($_GET[func] == "additem" || $_POST[func] == "additem" )
00141 {
00142 $subcontext = "postitem";
00143 return context_set($context, $subcontext);
00144 }
00145 if ($_GET[func] == "detailitem" || $_POST[func] == "detailitem" )
00146 {
00147 $subcontext = "edititem";
00148 return context_set($context, $subcontext);
00149 }
00150 if ($_GET[func] == "search" || $_POST[func] == "search" )
00151 {
00152 $subcontext = "search";
00153 return context_set($context, $subcontext);
00154 }
00155 }
00156
00157 # If we are in admin pages, we need to go deeped to find the appropriate
00158 # main context
00159 if ($context == "admin")
00160 {
00161 $subcontext = "configure";
00162
00163 # If ARTIFACT has been defined, we are in a tracker configuration for
00164 # sure.
00165 # Otherwise, we have to go deeper
00166 if (defined('ARTIFACT'))
00167 {
00168 $context = ARTIFACT;
00169 return context_set($context, $subcontext);
00170
00171 }
00172 else
00173 {
00174 $context = basename(dirname(dirname($page)));
00175 return context_set($context, $subcontext);
00176 }
00177 }
00178
00179 # Normally, context should have been guessed already
00180 return context_set($context, $subcontext);
00181 }
00182
00183 # Defines context
00184 function context_set ($context, $subcontext)
00185 {
00186 # Defines main context, kind of pages (cvs, bug tracker...)
00187 define(CONTEXT, $context);
00188 # Defines subcontext, kind of action done (postitem...)
00189 define(SUBCONTEXT, $subcontext);
00190
00191 return true;
00192 }
00193
00194 # Get title depending on the context
00195 function context_title ()
00196 {
00197 global $group_id;
00198
00199 switch (CONTEXT)
00200 {
00201 case 'siteadmin': $title = _("Site Administration"); break;
00202
00203 case 'project':
00204 switch (SUBCONTEXT)
00205 {
00206 case 'configure': $title = _("Administration Summary"); break;
00207 case 'search': $title = _("Search in this Group"); break;
00208 default: $title = _("Summary"); break;
00209 }
00210 break;
00211
00212 case 'download':
00213 switch (SUBCONTEXT)
00214 {
00215 case 'configure': $title = _("Filelist Administration"); break;
00216 default: $title = _("Filelist"); break;
00217 }
00218 break;
00219
00220 case 'cvs': $title = _("SCM: CVS Repositories"); break;
00221
00222 case 'arch': $title = _("SCM: GNU Arch Repositories"); break;
00223
00224 case 'svn': $title = _("SCM: Subversion Repositories"); break;
00225
00226 case 'userguide':
00227 $title = _("In Depth Guide");
00228 $group_id = $GLOBALS['sys_group_id'];
00229 break;
00230
00231 case 'cookbook':
00232 switch (SUBCONTEXT)
00233 {
00234 case 'configure': $title = _("Cookbook Administration"); break;
00235 default: $title = _("Cookbook"); break;
00236 }
00237 break;
00238
00239 case 'support':
00240 switch (SUBCONTEXT)
00241 {
00242 case 'configure': $title = _("Support Tracker Administration"); break;
00243 default: $title = _("Support"); break;
00244 }
00245 break;
00246
00247 case 'bugs':
00248 switch (SUBCONTEXT)
00249 {
00250 case 'configure': $title = _("Bugs Tracker Administration"); break;
00251 default: $title = _("Bugs"); break;
00252 }
00253 break;
00254
00255 case 'bugs':
00256 switch (SUBCONTEXT)
00257 {
00258 case 'configure': $title = _("Bugs Tracker Administration"); break;
00259 default: $title = _("Bugs"); break;
00260 }
00261 break;
00262
00263 case 'task':
00264 switch (SUBCONTEXT)
00265 {
00266 case 'configure': $title = _("Tasks Manager Administration"); break;
00267 default: $title = _("Tasks"); break;
00268 }
00269 break;
00270
00271 case 'patch':
00272 switch (SUBCONTEXT)
00273 {
00274 case 'configure': $title = _("Patch Manager Administration"); break;
00275 default: $title = _("Patches"); break;
00276 }
00277 break;
00278
00279 case 'news':
00280 switch (SUBCONTEXT)
00281 {
00282 case 'configure': $title = _("News Manager Administration"); break;
00283 default: $title = _("News"); break;
00284 }
00285 break;
00286
00287 case 'mail':
00288 switch (SUBCONTEXT)
00289 {
00290 case 'configure': $title = _("Mailing Lists Administration"); break;
00291 default: $title = _("Mailing Lists"); break;
00292 }
00293 break;
00294
00295 case 'searchingroup': $title = _("Search"); break;
00296
00297 case 'people': $title = sprintf(_("People at %s"), $GLOBALS['sys_name']); break;
00298
00299 case 'my':
00300 switch (SUBCONTEXT)
00301 {
00302 case 'configure': $title = _("My Account Configuration"); break;
00303 case 'items': $title = _("My Items"); break;
00304 case 'votes': $title = _("My Votes"); break;
00305 case 'groups': $title = _("My Group Membership"); break;
00306 case 'bookmarks': $title = _("My Bookmarks"); break;
00307 default: $title = _("My Incoming Items"); break;
00308 }
00309 break;
00310
00311 default: $title = $GLOBALS['sys_name'];
00312 }
00313
00314
00315 # case 'admin': $title = _("Site Administration"); break;
00316
00317 if ($group_id)
00318 {
00319 $project = project_get_object($group_id);
00320 # I18N
00321 # This is "<projectname> - <title>"
00322 $title = sprintf("%s - %s", $project->getPublicName(), $title);
00323 }
00324
00325 return $title;
00326
00327 }
00328
00329 function context_icon ()
00330 {
00331 switch (CONTEXT)
00332 {
00333 case 'siteadmin': return 'admin'; break;
00334 case 'my':
00335 switch (SUBCONTEXT)
00336 {
00337 case 'groups': return 'people'; break;
00338 case 'configure': return 'preferences'; break;
00339 default: return 'desktop'; break;
00340 }
00341 break;
00342 case 'project':
00343 switch (SUBCONTEXT)
00344 {
00345 case 'search': return 'directory'; break;
00346 case 'members': return 'people'; break;
00347 case 'members-gpgkeys': return 'keys'; break;
00348 case 'configure': return 'preferences'; break;
00349 default: return 'main'; break;
00350 }
00351 break;
00352 case 'forum': return 'news'; break;
00353 case 'bugs': return 'bug'; break;
00354 case 'doc': return 'man'; break;
00355 case 'userguide': return 'man'; break;
00356 case 'cookbook': return 'man'; break;
00357 case 'support': return 'help'; break;
00358 case 'mail': return 'mail'; break;
00359 case 'task': return 'task'; break;
00360 case 'cvs': return 'cvs'; break;
00361 case 'svn': return 'cvs'; break;
00362 case 'arch': return 'cvs'; break;
00363 case 'news': return 'news'; break;
00364 case 'special': return 'news'; break;
00365 case 'patch': return 'patch'; break;
00366 case 'download': return 'download'; break;
00367 case 'people': return 'people'; break;
00368 case 'search': return 'directory'; break;
00369 default: return 'main'; break;
00370 }
00371 }
00372
00373 ?>