5 * Extends the basic Error class to add HTML functions
6 * for displaying all site dependent HTML, while allowing
7 * extendibility/overriding by themes via the Theme class.
9 * Make sure browser.php is included _before_ you create an instance of this object.
11 * Geoffrey Herteg, August 29, 2000
15 require_once $gfcommon.'include/constants.php';
16 require_once $gfwww.'search/include/SearchManager.class.php';
18 class Layout extends Error {
21 * The default main page content */
22 var $rootindex = 'index_std.php';
25 * The root location of the theme
26 * @var string $themeroot
31 * The root location for images
33 * @var string $imgroot
40 * Layout() - Constructor
44 $this->themeroot=$GLOBALS['sys_themeroot'].$GLOBALS['sys_theme'];
45 /* if images directory exists in theme, then use it as imgroot */
46 if (file_exists ($this->themeroot.'/images')){
47 $this->imgroot=util_make_url ('/themes/'.$GLOBALS['sys_theme'].'/images/');
49 // Constructor for parent class...
50 if ( file_exists($GLOBALS['sys_custom_path'] . '/index_std.php') )
51 $this->rootindex = $GLOBALS['sys_custom_path'] . '/index_std.php';
56 * headerLink() - common code for all themes
59 function headerLink() {
60 echo '<link rel="alternate" title="'.$GLOBALS['sys_name'].' - Project News Highlights RSS" href="'.util_make_url ('/export/rss_sfnews.php').'" type="application/rss+xml"/>';
61 echo '<link rel="alternate" title="'.$GLOBALS['sys_name'].' - Project News Highlights RSS 2.0" href="'.util_make_url ('/export/rss20_news.php').'" type="application/rss+xml"/>';
62 echo '<link rel="alternate" title="'.$GLOBALS['sys_name'].' - New Projects RSS" href="'.util_make_url ('/export/rss_sfprojects.php').'" type="application/rss+xml"/>';
63 echo '<link rel="search" title="'.$GLOBALS['sys_name'].'" href="'.util_make_url ('/export/search_plugin.php').'" type="application/opensearchdescription+xml"/>';
67 * headerStart() - common code for all themes
69 * @param array Header parameters array
71 function headerStart($params) {
72 if (!$params['title']) {
73 $params['title'] = $GLOBALS['sys_name'];
75 $params['title'] = $GLOBALS['sys_name'] . ': ' . $params['title'];
77 print '<?xml version="1.0" encoding="utf-8"';
81 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
82 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
84 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo _('en') ?>" lang="<?php echo _('en') ?>">
87 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
88 <title><?php echo $params['title']; ?></title>
89 <?php $this->headerLink(); ?>
91 <?php if (isset($GLOBALS['group_id'])) {
92 $activity = '<link rel="alternate" title="' . $GLOBALS['sys_name'] . ' - New Activity RSS" href="'. util_make_url ('/export/rss20_activity.php?group_id='.$GLOBALS['group_id']).'" type="application/rss+xml"/>';
96 <?php $this->headerCSS(); ?>
98 <script language="JavaScript" type="text/javascript">
101 function admin_window(adminurl) {
102 AdminWin = window.open( adminurl, 'AdminWindow','scrollbars=yes,resizable=yes, toolbar=yes, height=400, width=400, top=2, left=2');
105 function help_window(helpurl) {
106 HelpWin = window.open( helpurl,'HelpWindow','scrollbars=yes,resizable=yes,toolbar=no,height=400,width=400');
109 <?php plugin_hook ("javascript",false) ; ?>
115 function headerCSS() {
116 /* check if a personalized css stylesheet exist, if yes include only
118 new stylesheets should use the <themename>.css file
120 $theme_cssfile=$GLOBALS['sys_themeroot'].$GLOBALS['sys_theme'].'/css/'.$GLOBALS['sys_theme'].'.css';
121 if (file_exists($theme_cssfile)){
123 <link rel="stylesheet" type="text/css" href="'.util_make_url ('/themes/'.$GLOBALS['sys_theme'].'/css/'.$GLOBALS['sys_theme'].'.css').'"/>';
125 /* if this is not our case, then include the compatibility stylesheet
126 that contains all removed styles from the code and check if a
127 custom stylesheet exists.
128 Used for compatibility with existing stylesheets
131 <link rel="stylesheet" type="text/css" href="'.util_make_url ('/themes/css/gforge-compat.css').'" />';
132 $theme_cssfile=$GLOBALS['sys_themeroot'].$GLOBALS['sys_theme'].'/css/theme.css';
133 if (file_exists($theme_cssfile)){
135 <link rel="stylesheet" type="text/css" href="'.util_make_url ('/themes/'.$GLOBALS['sys_theme'].'/css/theme.css').'" />';
138 plugin_hook ('cssfile',$this);
141 function header($params) {
142 $this->headerStart($params); ?>
145 $this->bodyHeader($params);
148 function bodyHeader($params){
151 <table border="0" width="100%" cellspacing="0" cellpadding="0" id="headertable">
154 <td><a href="<?php echo util_make_url ('/'); ?>"><?php echo html_image('logo.png',198,52,array('border'=>'0')); ?></a></td>
155 <td><?php echo $this->searchBox(); ?></td>
156 <td align="right"><?php
157 if (session_loggedin()) {
158 $u =& user_get_object(user_getid());
159 echo util_make_link ('/account/logout.php', sprintf("%s (%s)", _('Log Out'), $u->getRealName()),array('class'=>'lnkutility'));
160 echo util_make_link ('/account/',_('My Account'),array('class'=>'lnkutility'));
162 echo util_make_link ('/account/login.php',_('Log In'),array('class'=>'lnkutility'));
163 if (!$GLOBALS['sys_user_reg_restricted']) {
164 echo util_make_link ('/account/register.php',_('New Account'),array('class'=>'lnkutility'));
168 $params['template'] = ' {menu}';
169 plugin_hook ('headermenu', $params);
171 echo $this->quickNav();
174 <td> </td>
179 <table border="0" width="100%" cellspacing="0" cellpadding="0">
185 <?php echo $this->outerTabs($params); ?>
192 <td align="left" class="toptab" width="9"><img src="<?php echo $this->imgroot; ?>tabs/topleft.png" height="9" width="9" alt="" /></td>
193 <td class="toptab" width="30"><img src="<?php echo $this->imgroot; ?>clear.png" width="30" height="1" alt="" /></td>
194 <td class="toptab"><img src="<?php echo $this->imgroot; ?>clear.png" width="1" height="1" alt="" /></td>
195 <td class="toptab" width="30"><img src="<?php echo $this->imgroot; ?>clear.png" width="30" height="1" alt="" /></td>
196 <td align="right" class="toptab" width="9"><img src="<?php echo $this->imgroot; ?>tabs/topright.png" height="9" width="9" alt="" /></td>
201 <!-- Outer body row -->
203 <td class="toptab"><img src="<?php echo $this->imgroot; ?>clear.png" width="10" height="1" alt="" /></td>
204 <td valign="top" width="99%" class="toptab" colspan="3">
206 <!-- Inner Tabs / Shell -->
208 <table border="0" width="100%" cellspacing="0" cellpadding="0">
212 if (isset($params['group']) && $params['group']) {
220 echo $this->projectTabs($params['toptab'],$params['group']);
232 <td align="left" class="projecttab" width="9"><img src="<?php echo $this->imgroot; ?>tabs/topleft-inner.png" height="9" width="9" alt="" /></td>
233 <td class="projecttab" ><img src="<?php echo $this->imgroot; ?>clear.png" width="1" height="1" alt="" /></td>
234 <td align="right" class="projecttab" width="9"><img src="<?php echo $this->imgroot; ?>tabs/topright-inner.png" height="9" width="9" alt="" /></td>
238 <td class="projecttab" ><img src="<?php echo $this->imgroot; ?>clear.png" width="10" height="1" alt="" /></td>
239 <td valign="top" width="99%" class="projecttab">
245 function footer($params) {
249 <!-- end main body row -->
253 <td width="10" class="footer3" ><img src="<?php echo $this->imgroot; ?>clear.png" width="2" height="1" alt="" /></td>
256 <td align="left" class="footer1" width="9"><img src="<?php echo $this->imgroot; ?>tabs/bottomleft-inner.png" height="11" width="11" alt="" /></td>
257 <td class="footer3"><img src="<?php echo $this->imgroot; ?>clear.png" width="1" height="1" alt="" /></td>
258 <td align="right" class="footer1" width="9"><img src="<?php echo $this->imgroot; ?>tabs/bottomright-inner.png" height="11" width="11" alt="" /></td>
262 <!-- end inner body row -->
265 <td width="10" class="footer2"><img src="<?php echo $this->imgroot; ?>clear.png" width="2" height="1" alt="" /></td>
268 <td align="left" class="footer2" width="9"><img src="<?php echo $this->imgroot; ?>tabs/bottomleft.png" height="9" width="9" alt="" /></td>
269 <td class="footer2" colspan="3"><img src="<?php echo $this->imgroot; ?>clear.png" width="1" height="1" alt="" /></td>
270 <td align="right" class="footer2" width="9"><img src="<?php echo $this->imgroot; ?>tabs/bottomright.png" height="9" width="9" alt="" /></td>
274 $this->footerEnd($params);
277 function footerEnd($params) { ?>
279 <!-- PLEASE LEAVE "Powered By FusionForge" on your site -->
282 <a href="http://fusionforge.org/"><img src="<?php echo util_make_url ('/images/pow-fusionforge.png'); ?>" alt="Powered By FusionForge" border="0" /></a>
286 global $sys_show_source;
287 if ($sys_show_source) {
288 echo util_make_link ('/source.php?file='.getStringFromServer('SCRIPT_NAME'),_('Show source'),array('class'=>'showsource'));
299 function getRootIndex() {
300 return $this->rootindex;
304 * boxTop() - Top HTML box
306 * @param string Box title
307 * @param bool Whether to echo or return the results
308 * @param string The box background color
310 function boxTop($title) {
312 <!-- Box Top Start -->
314 <table cellspacing="0" cellpadding="0" width="100%" border="0" style="background:url('.$this->imgroot.'vert-grad.png)">
316 <td valign="top" align="right" width="10" style="background:url('.$this->imgroot.'box-topleft.png)"><img src="'.$this->imgroot.'clear.png" width="10" height="20" alt="" /></td>
317 <td width="100%" style="background:url('.$this->imgroot.'box-grad.png)"><span class="titlebar">'.$title.'</span></td>
318 <td valign="top" width="10" style="background:url('.$this->imgroot.'box-topright.png)"><img src="'.$this->imgroot.'clear.png" width="10" height="20" alt="" /></td>
322 <table cellspacing="2" cellpadding="2" width="100%" border="0">
326 <!-- Box Top End -->';
330 * boxMiddle() - Middle HTML box
332 * @param string Box title
333 * @param string The box background color
335 function boxMiddle($title) {
337 <!-- Box Middle Start -->
341 <td colspan="2" style="background:url('.$this->imgroot.'box-grad.png)"><span class="titlebar">'.$title.'</span></td>
345 <!-- Box Middle End -->';
349 * boxBottom() - Bottom HTML box
351 * @param bool Whether to echo or return the results
353 function boxBottom() {
355 <!-- Box Bottom Start -->
362 <!-- Box Bottom End -->';
366 * boxGetAltRowStyle() - Get an alternating row style for tables
368 * @param int Row number
370 function boxGetAltRowStyle($i) {
372 return ' class="altRowStyleEven"';
374 return ' class="altRowStyleOdd"';
379 * listTableTop() - Takes an array of titles and builds the first row of a new table.
381 * @param array The array of titles
382 * @param array The array of title links
384 function listTableTop ($title_arr,$links_arr=false) {
386 <table cellspacing="0" cellpadding="0" width="100%" border="0">
388 <!-- <td valign="top" align="right" width="10" style="background:url('.$this->imgroot.'box-grad.png)"><img src="'.$this->imgroot.'box-topleft.png" width="10" height="75" alt="" /></td> -->
389 <td style="background:url('.$this->imgroot.'box-grad.png)">
390 <table width="100%" border="0" cellspacing="1" cellpadding="2" >
391 <tr class="tableheading">';
392 $count=count($title_arr);
394 for ($i=0; $i<$count; $i++) {
395 $return .= '<td>'.util_make_link ($links_arr[$i],$title_arr[$i],array('class'=>'sortbutton')).'</td>';
398 for ($i=0; $i<$count; $i++) {
400 <td>'.$title_arr[$i].'</td>';
403 return $return.'</tr>';
406 function listTableBottom() {
407 return '</table></td>
408 <!-- <td valign="top" align="right" width="10" style="background:url('.$this->imgroot.'box-grad.png)"><img src="'.$this->imgroot.'box-topright.png" width="10" height="75" alt="" /></td> -->
412 function outerTabs($params) {
413 global $sys_use_trove,$sys_use_snippet,$sys_use_people,$sys_use_project_tags, $sys_use_project_full_list;
415 $TABS_DIRS[]=util_make_url ('/');
416 $TABS_DIRS[]=util_make_url ('/my/');
417 if ($sys_use_trove || $sys_use_project_tags || $sys_use_project_full_list) {
418 $TABS_DIRS[]=util_make_url ('/softwaremap/') ;
420 if ($sys_use_snippet) {
421 $TABS_DIRS[]=util_make_url ('/snippet/') ;
423 if ($sys_use_people) {
424 $TABS_DIRS[]=util_make_url ('/people/') ;
426 $TABS_TITLES[]=_('Home');
427 $TABS_TITLES[]=_('My Page');
428 if ($sys_use_trove || $sys_use_project_tags || $sys_use_project_full_list) {
429 $TABS_TITLES[]=_('Projects');
431 if ($sys_use_snippet) {
432 $TABS_TITLES[]=_('Code Snippets');
434 if ($sys_use_people) {
435 $TABS_TITLES[]=_('Project Openings');
439 $PLUGIN_TABS_DIRS = Array();
440 $hookParams['DIRS'] = &$PLUGIN_TABS_DIRS;
441 $hookParams['TITLES'] = &$TABS_TITLES;
442 plugin_hook ("outermenu", $hookParams) ;
443 $TABS_DIRS = array_merge($TABS_DIRS, $PLUGIN_TABS_DIRS);
445 $user_is_super=false;
446 if (session_loggedin()) {
447 $projectmaster =& group_get_object(GROUP_IS_MASTER);
448 $projectstats =& group_get_object(GROUP_IS_STATS);
449 $permmaster =& $projectmaster->getPermission( session_get_user() );
450 $permstats =& $projectstats->getPermission( session_get_user() );
452 if ($permmaster->isAdmin()) {
454 $TABS_DIRS[]=util_make_url ('/admin/') ;
455 $TABS_TITLES[]=_('Admin');
457 if ($permstats->isMember()) {
458 $TABS_DIRS[]=util_make_url ('/reporting/') ;
459 $TABS_TITLES[]=_('Reporting');
462 if(isset($params['group']) && $params['group']) {
463 // get group info using the common result set
464 $project =& group_get_object($params['group']);
465 if ($project && is_object($project)) {
466 if ($project->isError()) {
468 } elseif (!$project->isProject()) {
471 if (isset ($GLOBALS['sys_noforcetype']) && $GLOBALS['sys_noforcetype']) {
472 $TABS_DIRS[]=util_make_url ('/project/?group_id') .$project->getId();
474 $TABS_DIRS[]=util_make_url ('/projects/') .$project->getUnixName().'/';
476 $TABS_TITLES[]=$project->getPublicName();
477 $selected=count($TABS_DIRS)-1;
480 } elseif (strstr(getStringFromServer('REQUEST_URI'),util_make_url ('/my/') ) ||
481 strstr(getStringFromServer('REQUEST_URI'),util_make_url ('/account/') ) ||
482 strstr(getStringFromServer('REQUEST_URI'),util_make_url ('/register/') ) ||
483 strstr(getStringFromServer('REQUEST_URI'),util_make_url ('/themes/') ) ) {
484 $selected=array_search(util_make_url ('/my/'), $TABS_DIRS);
485 } elseif (strstr(getStringFromServer('REQUEST_URI'),util_make_url ('softwaremap') )) {
486 $selected=array_search(util_make_url ('/softwaremap/'), $TABS_DIRS);
487 } elseif (strstr(getStringFromServer('REQUEST_URI'),util_make_url ('/snippet/') )) {
488 $selected=array_search(util_make_url ('/snippet/'), $TABS_DIRS);
489 } elseif (strstr(getStringFromServer('REQUEST_URI'),util_make_url ('/people/') )) {
490 $selected=array_search(util_make_url ('/people/'), $TABS_DIRS);
491 } elseif (strstr(getStringFromServer('REQUEST_URI'),util_make_url ('/reporting/') )) {
492 $selected=array_search(util_make_url ('/reporting/'),$TABS_DIRS);
493 } elseif (strstr(getStringFromServer('REQUEST_URI'),util_make_url ('/admin/') ) && $user_is_super) {
494 $selected=array_search(util_make_url ('/admin/'),$TABS_DIRS);
495 } elseif (count($PLUGIN_TABS_DIRS)>0) {
496 foreach ($PLUGIN_TABS_DIRS as $PLUGIN_TABS_DIRS_VALUE) {
497 if (strstr(getStringFromServer('REQUEST_URI'),$PLUGIN_TABS_DIRS_VALUE)) {
498 $selected=array_search($PLUGIN_TABS_DIRS_VALUE,$TABS_DIRS);
505 echo $this->tabGenerator($TABS_DIRS,$TABS_TITLES,false,$selected,'','100%');
510 * projectTabs() - Prints out the project tabs, contained here in case
511 * we want to allow it to be overriden
513 * @param string Is the tab currently selected
514 * @param string Is the group we should look up get title info
516 function projectTabs($toptab,$group) {
517 // get group info using the common result set
518 $project =& group_get_object($group);
519 if (!$project || !is_object($project)) {
522 if ($project->isError()) {
523 //wasn't found or some other problem
526 if (!$project->isProject()) {
531 if (isset ($GLOBALS['sys_noforcetype']) && $GLOBALS['sys_noforcetype']) {
532 $TABS_DIRS[]=util_make_url ('/project/?group_id=' . $project->getId());
534 $TABS_DIRS[]=util_make_url ('/projects/' . $project->getUnixName() .'/');
536 $TABS_TITLES[]=_('Summary');
537 (($toptab == 'home') ? $selected=(count($TABS_TITLES)-1) : '' );
540 $perm =& $project->getPermission( session_get_user() );
541 if ($perm->isAdmin()) {
542 $TABS_DIRS[]=util_make_url ('/project/admin/?group_id=' . $group);
543 $TABS_TITLES[]=_('Admin');
544 (($toptab == 'admin') ? $selected=(count($TABS_TITLES)-1) : '' );
547 $TABS_DIRS[]='http://'. $project->getHomePage();
548 $TABS_TITLES[]=_('Home Page');
551 // Project Activity tab
553 $TABS_DIRS[]=util_make_url ('/activity/?group_id=' . $group);
554 $TABS_TITLES[]=_('Activity');
555 (($toptab == 'activity') ? $selected=(count($TABS_TITLES)-1) : '' );
558 if ($project->usesForum()) {
559 $TABS_DIRS[]=util_make_url ('/forum/?group_id='.$group);
560 $TABS_TITLES[]=_('Forums');
561 (($toptab == 'forums') ? $selected=(count($TABS_TITLES)-1) : '' );
565 if ($project->usesTracker()) {
566 $TABS_DIRS[]=util_make_url ('/tracker/?group_id='.$group);
567 $TABS_TITLES[]=_('Tracker');
568 (($toptab == 'tracker' || $toptab == 'bugs' || $toptab == 'support' || $toptab == 'patch')
569 ? $selected=(count($TABS_TITLES)-1) : '' );
573 if ($project->usesMail()) {
574 $TABS_DIRS[]=util_make_url ('/mail/?group_id='.$group);
575 $TABS_TITLES[]=_('Lists');
576 (($toptab == 'mail') ? $selected=(count($TABS_TITLES)-1) : '' );
580 if ($project->usesPm()) {
581 $TABS_DIRS[]=util_make_url ('/pm/?group_id='.$group);
582 $TABS_TITLES[]=_('Tasks');
583 (($toptab == 'pm') ? $selected=(count($TABS_TITLES)-1) : '' );
587 if ($project->usesDocman()) {
588 $TABS_DIRS[]=util_make_url ('/docman/?group_id='.$group);
589 $TABS_TITLES[]=_('Docs');
590 (($toptab == 'docman') ? $selected=(count($TABS_TITLES)-1) : '' );
594 if ($project->usesSurvey()) {
595 $TABS_DIRS[]=util_make_url ('/survey/?group_id='.$group);
596 $TABS_TITLES[]=_('Surveys');
597 (($toptab == 'surveys') ? $selected=(count($TABS_TITLES)-1) : '' );
601 if ($project->usesNews()) {
602 $TABS_DIRS[]=util_make_url ('/news/?group_id='.$group);
603 $TABS_TITLES[]=_('News');
604 (($toptab == 'news') ? $selected=(count($TABS_TITLES)-1) : '' );
608 if ($project->usesSCM()) {
609 $TABS_DIRS[]=util_make_url ('/scm/?group_id='.$group);
610 $TABS_TITLES[]=_('SCM');
611 (($toptab == 'scm') ? $selected=(count($TABS_TITLES)-1) : '' );
614 // groupmenu_after_scm hook
615 $hookParams['DIRS'] = &$TABS_DIRS;
616 $hookParams['TITLES'] = &$TABS_TITLES;
617 $hookParams['toptab'] = &$toptab;
618 $hookParams['selected'] = &$selected;
619 $hookParams['group_id'] = $group ;
621 plugin_hook ("groupmenu_scm", $hookParams) ;
624 if ($project->usesFRS()) {
625 $TABS_DIRS[]=util_make_url ('/frs/?group_id='.$group);
626 $TABS_TITLES[]=_('Files');
627 (($toptab == 'frs') ? $selected=(count($TABS_TITLES)-1) : '' );
631 $hookParams['DIRS'] = &$TABS_DIRS;
632 $hookParams['TITLES'] = &$TABS_TITLES;
633 $hookParams['toptab'] = &$toptab;
634 $hookParams['selected'] = &$selected;
635 $hookParams['group'] = $group;
637 plugin_hook ("groupmenu", $hookParams) ;
639 echo $this->tabGenerator($TABS_DIRS,$TABS_TITLES,true,$selected,'white','100%');
643 function tabGenerator($TABS_DIRS,$TABS_TITLES,$nested=false,$selected=false,$sel_tab_bgcolor='white',$total_width='100%') {
645 $count=count($TABS_DIRS);
646 $width=intval((100/$count));
654 <table border="0" cellpadding="0" cellspacing="0" width="'.$total_width.'">
662 for ($i=0; $i<$count; $i++) {
665 // this is the first tab, choose an image with end-name
668 $issel=($selected==$i);
669 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
670 // $rowspan=(($issel)?'rowspan="2" ' : '');
673 <td '.$rowspan.'valign="top" width="10" style="background:url('.$this->imgroot . 'theme-'.$inner.'-end-'.(($issel) ? '' : 'not').'selected.png)">'.
674 '<img src="'.$this->imgroot . 'clear.png" height="25" width="10" alt="" /></td>'.
675 '<td '.$rowspan.'style="background:url('.$this->imgroot . $bgimg.')" width="'.$width.'%" align="center">'.util_make_link ($TABS_DIRS[$i],$TABS_TITLES[$i],array('class'=>(($issel)?'tabsellink':'tablink')),true).'</td>';
676 } elseif ($i==$count-1) {
678 // this is the last tab, choose an image with name-end
680 $wassel=($selected==$i-1);
681 $issel=($selected==$i);
682 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
683 // $rowspan=(($issel)?'rowspan="2" ' : '');
685 // Build image between current and prior tab
688 <td '.$rowspan.'colspan="2" valign="top" width="20" style="background:url('.$this->imgroot . 'theme-'.$inner.'-'.(($wassel) ? '' : 'not').'selected-'.(($issel) ? '' : 'not').'selected.png)">'.
689 '<img src="'.$this->imgroot . 'clear.png" height="2" width="20" alt="" /></td>'.
690 '<td '.$rowspan.'style="background:url('.$this->imgroot . $bgimg.')" width="'.$width.'%" align="center">'.util_make_link ($TABS_DIRS[$i],$TABS_TITLES[$i],array('class'=>(($issel)?'tabsellink':'tablink')),true).'</td>';
692 // Last graphic on right-side
695 <td '.$rowspan.'valign="top" width="10" style="background:url('.$this->imgroot . 'theme-'.$inner.'-'.(($issel) ? '' : 'not').'selected-end.png)">'.
696 '<img src="'.$this->imgroot . 'clear.png" height="2" width="10" alt="" /></td>';
702 $wassel=($selected==$i-1);
703 $issel=($selected==$i);
704 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
705 // $rowspan=(($issel)?'rowspan="2" ' : '');
707 // Build image between current and prior tab
710 <td '.$rowspan.'colspan="2" valign="top" width="20" style="background:url('.$this->imgroot . 'theme-'.$inner.'-'.(($wassel) ? '' : 'not').'selected-'.(($issel) ? '' : 'not').'selected.png)">'.
711 '<img src="'.$this->imgroot . 'clear.png" height="2" width="20" alt="" /></td>'.
712 '<td '.$rowspan.'style="background:url('.$this->imgroot . $bgimg.')" width="'.$width.'%" align="center">'.util_make_link ($TABS_DIRS[$i],$TABS_TITLES[$i],array('class'=>(($issel)?'tabsellink':'tablink')),true).'</td>';
719 // Building a bottom row in this table, which will be darker
721 if ($selected == 0) {
723 $end_cols=((count($TABS_DIRS)*3)-3);
724 } elseif ($selected == (count($TABS_DIRS)-1)) {
725 $beg_cols=((count($TABS_DIRS)*3)-3);
728 $beg_cols=($selected*3);
729 $end_cols=(((count($TABS_DIRS)*3)-3)-$beg_cols);
733 $return .= '<td colspan="'.$beg_cols.'" height="1" class="notSelTab"><img src="'.$this->imgroot.'clear.png" height="1" width="10" alt="" /></td>';
735 $return .= '<td colspan="3" height="1" class="selTab"><img src="'.$this->imgroot.'clear.png" height="1" width="10" alt="" /></td>';
737 $return .= '<td colspan="'.$end_cols.'" height="1" class="notSelTab"><img src="'.$this->imgroot.'clear.png" height="1" width="10" alt="" /></td>';
749 function searchBox() {
750 global $words,$forum_id,$group_id,$group_project_id,$atid,$exact,$type_of_search;
752 if(get_magic_quotes_gpc()) {
753 $defaultWords = stripslashes($words);
755 $defaultWords = $words;
759 $defaultWords = htmlspecialchars($defaultWords);
761 // if there is no search currently, set the default
762 if ( ! isset($type_of_search) ) {
767 <form action="/search/" method="get">
768 <table border="0" cellpadding="0" cellspacing="0">
770 <div align="center" class="searchbox">';
772 SEARCH__PARAMETER_GROUP_ID => $group_id,
773 SEARCH__PARAMETER_ARTIFACT_ID => $atid,
774 SEARCH__PARAMETER_FORUM_ID => $forum_id,
775 SEARCH__PARAMETER_GROUP_PROJECT_ID => $group_project_id
778 $searchManager =& getSearchManager();
779 $searchManager->setParametersValues($parameters);
780 $searchEngines =& $searchManager->getAvailableSearchEngines();
782 echo '<select name="type_of_search">';
783 for($i = 0, $max = count($searchEngines); $i < $max; $i++) {
784 $searchEngine =& $searchEngines[$i];
785 echo '<option value="'.$searchEngine->getType().'"'.( $type_of_search == $searchEngine->getType() ? ' selected="selected"' : '' ).'>'.$searchEngine->getLabel($parameters).'</option>'."\n";
787 echo '</select></div>';
791 // <input type="checkbox" name="exact" value="1"'.( $exact ? ' checked' : ' unchecked' ).'> Require All Words';
793 print '</td><td> ';
794 $parameters = $searchManager->getParameters();
795 foreach($parameters AS $name => $value) {
796 print '<input type="hidden" value="'.$value.'" name="'.$name.'" />';
799 print '<input type="text" size="12" name="words" value="'.$defaultWords.'" />';
801 print '</td><td> </td><td>';
802 print '<input type="submit" name="Search" value="'._('Search').'" />';
805 if (isset($group_id) && $group_id) {
807 <td width="10"> </td>
808 <td>'.util_make_link ('/search/advanced_search.php?group_id='.$group_id,_('Advanced search'),array('class'=>'lnkutility')).'</td>';
810 print '</tr></table>';
815 function advancedSearchBox($sectionsArray, $group_id, $words, $isExact) {
816 // display the searchmask
818 <form name="advancedsearch" action="'.getStringFromServer('PHP_SELF').'" method="post">
819 <input type="hidden" name="search" value="1"/>
820 <input type="hidden" name="group_id" value="'.$group_id.'"/>
821 <div align="center"><br />
825 <input type="text" size="60" name="words" value="'.stripslashes(htmlspecialchars($words)).'" />
826 <input type="submit" name="submitbutton" value="'._('Search').'" />
831 <input type="radio" name="mode" value="'.SEARCH__MODE_AND.'" '.($isExact ? 'checked="checked"' : '').' />'._('with all words').'
834 <input type="radio" name="mode" value="'.SEARCH__MODE_OR.'" '.(!$isExact ? 'checked="checked"' : '').' />'._('with one word').'
837 </table><br /></div>'
838 .$this->createUnderSections($sectionsArray).'
842 //create javascript methods for select none/all
844 <script type="text/javascript">
845 <!-- method for disable/enable checkboxes
846 function setCheckBoxes(parent, checked) {
849 for (var i = 0; i < document.advancedsearch.elements.length; i++)
850 if (document.advancedsearch.elements[i].type == "checkbox")
851 if (document.advancedsearch.elements[i].name.substr(0, parent.length) == parent)
852 document.advancedsearch.elements[i].checked = checked;
860 function createUnderSections($sectionsArray) {
861 global $group_subsection_names;
864 foreach ($sectionsArray as $section) {
865 if(is_array($section)) {
866 $countLines += (3 + count ($section));
868 //2 lines one for section name and one for checkbox
874 $breakLimit = ceil($countLines/$maxCol);
875 $break = $breakLimit;
880 <table width="100%" border="0" cellspacing="0" cellpadding="1">
881 <tr class="tableheader">
883 <table width="100%" cellspacing="0" border="0">
884 <tr class="tablecontent">
885 <!--<td colspan="2">'._('Search in').':</td-->
886 <td align="right">'._('Select').' <a href="javascript:setCheckBoxes(\'\', true)">'._('all').'</a> / <a href="javascript:setCheckBoxes(\'\', false)">'._('none').'</a></td>
888 <tr class="tablecontent">
889 <td colspan="3"> </td>
891 <tr align="center" valign="top" class="tablecontent">
893 foreach($sectionsArray as $key => $section) {
894 $oldcountlines = $countLines;
895 if (is_array($section)) {
896 $countLines += (3 + count ($section));
901 if ($countLines >= $break) {
902 // if we are closer to the limit with this one included, then
903 // it's better to include it.
904 if (($countCol < $maxCol) && ($countLines - $break) >= ($break - $oldcountlines)) {
905 $return .= '</td><td>';
907 $break += $breakLimit;
911 $return .= '<table width="90%" border="0" cellpadding="1" cellspacing="0">
912 <tr><td><table width="100%" border="0" cellspacing="0" cellpadding="3">
915 <a href="#'.$key.'">'.$group_subsection_names[$key].'</a>'
918 ._('Select').' <a href="javascript:setCheckBoxes(\''.$key.'\', true)">'._('all').'</a> / <a href="javascript:setCheckBoxes(\''.$key.'\', false)">'._('none').'</a>
921 <tr class="tablecontent">
924 if (!is_array($section)) {
925 $return .= ' <input type="checkbox" name="'.urlencode($key).'"';
926 if (isset($GLOBALS[urlencode($key)]))
927 $return .= ' checked="checked" ';
928 $return .= ' /></input>'.$group_subsection_names[$key].'<br />';
931 foreach($section as $underkey => $undersection) {
932 $return .= ' <input type="checkbox" name="'.urlencode($key.$underkey).'"';
933 if (isset($GLOBALS[urlencode($key.$underkey)]))
934 $return .= ' checked="checked" ';
935 $return .= ' />'.$undersection.'<br />';
941 </table></td></tr></table><br />';
943 if ($countLines >= $break) {
944 if (($countLines - $break) < ($break - $countLines)) {
945 $return .= '</td><td width="33%">';
946 $break += $breakLimit;
951 return $return.' </td>
953 </table></td></tr></table>';
957 * beginSubMenu() - Opening a submenu.
959 * @return string Html to start a submenu.
961 function beginSubMenu () {
968 * endSubMenu() - Closing a submenu.
970 * @return string Html to end a submenu.
972 function endSubMenu () {
973 $return = '</strong></p>';
978 * printSubMenu() - Takes two array of titles and links and builds the contents of a menu.
980 * @param array The array of titles.
981 * @param array The array of title links.
982 * @return string Html to build a submenu.
984 function printSubMenu ($title_arr,$links_arr) {
985 $count=count($title_arr);
989 for ($i=0; $i<$count; $i++) {
990 $return .= util_make_link ($links_arr[$i],$title_arr[$i]).' | ';
992 $return .= util_make_link ($links_arr[$i],$title_arr[$i]);
997 * subMenu() - Takes two array of titles and links and build a menu.
999 * @param array The array of titles.
1000 * @param array The array of title links.
1001 * @return string Html to build a submenu.
1003 function subMenu ($title_arr,$links_arr) {
1004 $return = $this->beginSubMenu () ;
1005 $return .= $this->printSubMenu ($title_arr,$links_arr) ;
1006 $return .= $this->endSubMenu () ;
1011 * multiTableRow() - create a mutlilevel row in a table
1013 * @param string the row attributes
1014 * @param array the array of cell data, each element is an array,
1015 * the first item being the text,
1016 * the subsequent items are attributes (dont include
1017 * the bgcolor for the title here, that will be
1018 * handled by $istitle
1019 * @param boolean is this row part of the title ?
1022 function multiTableRow($row_attr, $cell_data, $istitle) {
1026 $return .=' align="center" class="multiTableRowTitle"';
1029 for ( $c = 0; $c < count($cell_data); $c++ ) {
1031 for ( $a=1; $a < count($cell_data[$c]); $a++) {
1032 $return .= $cell_data[$c][$a].' ';
1036 $return .='<span class="multiTableRowTitle">';
1038 $return .= $cell_data[$c][0];
1040 $return .='</span>';
1052 * feedback() - returns the htmlized feedback string when an action is performed.
1054 * @param string feedback string
1055 * @return string htmlized feedback
1057 function feedback($feedback) {
1062 <div class="feedback">'.strip_tags($feedback, '<br>').'</div>';
1066 * warning_msg() - returns the htmlized warning string when an action is performed.
1068 * @param string msg string
1069 * @return string htmlized warning
1071 function warning_msg($msg) {
1076 <div class="warning_msg">'.strip_tags($msg, '<br>').'</div>';
1081 * error_msg() - returns the htmlized error string when an action is performed.
1083 * @param string msg string
1084 * @return string htmlized error
1086 function error_msg($msg) {
1091 <div class="error">'.strip_tags($msg, '<br>').'</div>';
1097 * getThemeIdFromName()
1099 * @param string the dirname of the theme
1100 * @return integer the theme id
1102 function getThemeIdFromName($dirname) {
1103 $res = db_query_params ('SELECT theme_id FROM themes WHERE dirname=$1',
1105 return db_result($res,0,'theme_id');
1108 function quickNav() {
1109 if (!session_loggedin()) {
1112 $res = db_query_params ('SELECT * FROM groups JOIN user_group USING (group_id) WHERE user_group.user_id=$1 AND groups.status=$2 ORDER BY group_name',
1113 array (user_getid(),
1116 if (!$res || db_numrows($res) < 1) {
1120 <form name="quicknavform">
1121 <select name="quicknav" onChange="location.href=document.quicknavform.quicknav.value">';
1123 <option value="">'._('Quick Jump To...').'</option>';
1124 for ($i=0; $i<db_numrows($res); $i++) {
1126 <option value="'.util_make_url_g (db_result($res,$i,'unix_group_name'),db_result($res,$i,'group_id')).'">'.db_result($res,$i,'group_name').'</option>';
1127 if (trim(db_result($res,$i,'admin_flags'))=='A') {
1129 <option value="'.util_make_url ('/project/admin/?group_id='.db_result($res,$i,'group_id')).'"> Admin</option>';
1132 if (db_result($res,$i,'use_tracker')) {
1134 <option value="'.util_make_url ('/tracker/?group_id='.db_result($res,$i,'group_id')).'"> Tracker</option>';
1135 if (db_result($res,$i,'admin_flags') || db_result($res,$i,'artifact_flags')) {
1137 <option value="'.util_make_url ('/tracker/admin/?group_id='.db_result($res,$i,'group_id')).'"> Admin</option>';
1141 if (db_result($res,$i,'use_pm')) {
1143 <option value="'.util_make_url ('/pm/?group_id='.db_result($res,$i,'group_id')).'"> Task Manager</option>';
1144 if (trim(db_result($res,$i,'admin_flags')) =='A' || db_result($res,$i,'project_flags')) {
1146 <option value="'.util_make_url ('/pm/admin/?group_id='.db_result($res,$i,'group_id')).'"> Admin</option>';
1150 if (db_result($res,$i,'use_frs')) {
1152 <option value="'.util_make_url('/frs/?group_id='.db_result($res,$i,'group_id')).'"> Files</option>';
1153 if (trim(db_result($res,$i,'admin_flags'))=='A' || db_result($res,$i,'release_flags')) {
1155 <option value="'.util_make_url('/frs/admin/?group_id='.db_result($res,$i,'group_id')).'"> Admin</option>';
1159 if (db_result($res,$i,'use_scm')) {
1161 <option value="'.util_make_url('/scm/?group_id='.db_result($res,$i,'group_id')).'"> SCM</option>';
1162 /*if (db_result($res,$i,'admin_flags') || db_result($res,$i,'project_flags')) {
1164 <option value="'.util_make_url('/pm/admin/?group_id='.db_result($res,$i,'group_id')).'"> Admin</option>';
1168 if (db_result($res,$i,'use_forum')) {
1170 <option value="'.util_make_url('/forum/?group_id='.db_result($res,$i,'group_id')).'"> Forum</option>';
1171 if (trim(db_result($res,$i,'admin_flags'))=='A' || db_result($res,$i,'forum_flags')) {
1173 <option value="'.util_make_url('/forum/admin/?group_id='.db_result($res,$i,'group_id')).'"> Admin</option>';
1177 if (db_result($res,$i,'use_mail')) {
1179 <option value="'.util_make_url('/mail/?group_id='.db_result($res,$i,'group_id')).'"> Lists</option>';
1180 if (trim(db_result($res,$i,'admin_flags'))=='A') {
1182 <option value="'.util_make_url('/mail/admin/?group_id='.db_result($res,$i,'group_id')).'"> Admin</option>';
1186 if (db_result($res,$i,'use_docman')) {
1188 <option value="'.util_make_url('/docman/?group_id='.db_result($res,$i,'group_id')).'"> Docs</option>';
1189 if (trim(db_result($res,$i,'admin_flags'))=='A' || db_result($res,$i,'doc_flags')) {
1191 <option value="'.util_make_url('/docman/admin/?group_id='.db_result($res,$i,'group_id')).'"> Admin</option>';
1195 if (db_result($res,$i,'use_news')) {
1197 <option value="'.util_make_url('/news/?group_id='.db_result($res,$i,'group_id')).'"> News</option>';
1198 if (trim(db_result($res,$i,'admin_flags'))=='A') {
1200 <option value="'.util_make_url('/news/admin/?group_id='.db_result($res,$i,'group_id')).'"> Admin</option>';
1204 if (db_result($res,$i,'use_survey')) {
1206 <option value="'.util_make_url('/survey/?group_id='.db_result($res,$i,'group_id')).'"> Surveys</option>';
1207 if (trim(db_result($res,$i,'admin_flags'))=='A') {
1209 <option value="'.util_make_url('/survey/admin/?group_id='.db_result($res,$i,'group_id')).'"> Admin</option>';
1225 // c-file-style: "bsd"