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
16 require_once('common/include/constants.php');
17 require_once('www/search/include/SearchManager.class.php');
19 class Layout extends Error {
22 * The default main page content */
23 var $rootindex = 'index_std.php';
26 * The root location of the theme
27 * @var string $themeroot
32 * The root location for images
34 * @var string $imgroot
41 * Layout() - Constructor
45 $this->themeroot=$GLOBALS['sys_themeroot'].$GLOBALS['sys_theme'];
46 /* if images directory exists in theme, then use it as imgroot */
47 if (file_exists ($this->themeroot.'/images')){
48 $this->imgroot=util_make_url ('/themes/'.$GLOBALS['sys_theme'].'/images/');
50 // Constructor for parent class...
51 if ( file_exists($GLOBALS['sys_custom_path'] . '/index_std.php') )
52 $this->rootindex = $GLOBALS['sys_custom_path'] . '/index_std.php';
57 * createLinkToUserHome() - Creates a link to a user's home page
59 * @param string The user's user_name
60 * @param string The user's realname
62 function createLinkToUserHome($user_name, $realname) {
63 return util_make_link ('/users/'.$user_name.'/',$realname);
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="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 <link rel="alternate" title="<?php echo $GLOBALS['sys_name']; ?> - Project News Highlights RSS" href="<?php echo util_make_url ('/export/rss_sfnews.php'); ?>" type="application/rss+xml"/>
90 <link rel="alternate" title="<?php echo $GLOBALS['sys_name']; ?> - Project News Highlights RSS 2.0" href="<?php echo util_make_url ('/export/rss20_news.php'); ?>" type="application/rss+xml"/>
91 <link rel="alternate" title="<?php echo $GLOBALS['sys_name']; ?> - New Projects RSS" href="<?php echo util_make_url ('/export/rss_sfprojects.php'); ?>" type="application/rss+xml"/>
93 <?php if (isset($GLOBALS['group_id'])) {
94 $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"/>';
98 <?php $this->headerCSS(); ?>
100 <script language="JavaScript" type="text/javascript">
103 function admin_window(adminurl) {
104 AdminWin = window.open( adminurl, 'AdminWindow','scrollbars=yes,resizable=yes, toolbar=yes, height=400, width=400, top=2, left=2');
107 function help_window(helpurl) {
108 HelpWin = window.open( helpurl,'HelpWindow','scrollbars=yes,resizable=yes,toolbar=no,height=400,width=400');
111 <?php plugin_hook ("javascript",false) ; ?>
117 function headerCSS() {
118 /* check if a personalized css stylesheet exist, if yes include only
120 new stylesheets should use the <themename>.css file
122 $theme_cssfile=$GLOBALS['sys_themeroot'].$GLOBALS['sys_theme'].'/css/'.$GLOBALS['sys_theme'].'.css';
123 if (file_exists($theme_cssfile)){
125 <link rel="stylesheet" type="text/css" href="'.util_make_url ('/themes/'.$GLOBALS['sys_theme'].'/css/'.$GLOBALS['sys_theme'].'.css').'"/>';
127 /* if this is not our case, then include the compatibility stylesheet
128 that contains all removed styles from the code and check if a
129 custom stylesheet exists.
130 Used for compatibility with existing stylesheets
133 <link rel="stylesheet" type="text/css" href="'.util_make_url ('/themes/css/gforge-compat.css').'" />';
134 $theme_cssfile=$GLOBALS['sys_themeroot'].$GLOBALS['sys_theme'].'/css/theme.css';
135 if (file_exists($theme_cssfile)){
137 <link rel="stylesheet" type="text/css" href="'.util_make_url ('/themes/'.$GLOBALS['sys_theme'].'/css/theme.css').'" />';
140 plugin_hook ('cssfile',$this);
143 function header($params) {
144 $this->headerStart($params); ?>
147 $this->bodyHeader($params);
150 function bodyHeader($params){
153 <table border="0" width="100%" cellspacing="0" cellpadding="0" id="headertable">
156 <td><a href="<?php echo util_make_url (''); ?>/"><?php echo html_image('logo.png',198,52,array('border'=>'0')); ?></a></td>
157 <td><?php echo $this->searchBox(); ?></td>
158 <td align="right"><?php
159 if (session_loggedin()) {
160 echo util_make_link ('/account/logout.php',_('Log Out'),array('class'=>'lnkutility'));
161 echo util_make_link ('/account/',_('My Account'),array('class'=>'lnkutility'));
163 echo util_make_link ('/account/login.php',_('Log In'),array('class'=>'lnkutility'));
164 echo util_make_link ('/account/register.php',_('New Account'),array('class'=>'lnkutility'));
167 $params['template'] = ' {menu}';
168 plugin_hook ('headermenu', $params);
170 echo $this->quickNav();
173 <td> </td>
178 <table border="0" width="100%" cellspacing="0" cellpadding="0">
184 <?php echo $this->outerTabs($params); ?>
191 <td align="left" class="toptab" width="9"><img src="<?php echo $this->imgroot; ?>tabs/topleft.png" height="9" width="9" alt="" /></td>
192 <td class="toptab" width="30"><img src="<?php echo $this->imgroot; ?>clear.png" width="30" height="1" alt="" /></td>
193 <td class="toptab"><img src="<?php echo $this->imgroot; ?>clear.png" width="1" height="1" alt="" /></td>
194 <td class="toptab" width="30"><img src="<?php echo $this->imgroot; ?>clear.png" width="30" height="1" alt="" /></td>
195 <td align="right" class="toptab" width="9"><img src="<?php echo $this->imgroot; ?>tabs/topright.png" height="9" width="9" alt="" /></td>
200 <!-- Outer body row -->
202 <td class="toptab"><img src="<?php echo $this->imgroot; ?>clear.png" width="10" height="1" alt="" /></td>
203 <td valign="top" width="99%" class="toptab" colspan="3">
205 <!-- Inner Tabs / Shell -->
207 <table border="0" width="100%" cellspacing="0" cellpadding="0">
211 if (isset($params['group']) && $params['group']) {
219 echo $this->projectTabs($params['toptab'],$params['group']);
231 <td align="left" class="projecttab" width="9"><img src="<?php echo $this->imgroot; ?>tabs/topleft-inner.png" height="9" width="9" alt="" /></td>
232 <td class="projecttab" ><img src="<?php echo $this->imgroot; ?>clear.png" width="1" height="1" alt="" /></td>
233 <td align="right" class="projecttab" width="9"><img src="<?php echo $this->imgroot; ?>tabs/topright-inner.png" height="9" width="9" alt="" /></td>
237 <td class="projecttab" ><img src="<?php echo $this->imgroot; ?>clear.png" width="10" height="1" alt="" /></td>
238 <td valign="top" width="99%" class="projecttab">
244 function footer($params) {
248 <!-- end main body row -->
252 <td width="10" class="footer3" ><img src="<?php echo $this->imgroot; ?>clear.png" width="2" height="1" alt="" /></td>
255 <td align="left" class="footer1" width="9"><img src="<?php echo $this->imgroot; ?>tabs/bottomleft-inner.png" height="11" width="11" alt="" /></td>
256 <td class="footer3"><img src="<?php echo $this->imgroot; ?>clear.png" width="1" height="1" alt="" /></td>
257 <td align="right" class="footer1" width="9"><img src="<?php echo $this->imgroot; ?>tabs/bottomright-inner.png" height="11" width="11" alt="" /></td>
261 <!-- end inner body row -->
264 <td width="10" class="footer2"><img src="<?php echo $this->imgroot; ?>clear.png" width="2" height="1" alt="" /></td>
267 <td align="left" class="footer2" width="9"><img src="<?php echo $this->imgroot; ?>tabs/bottomleft.png" height="9" width="9" alt="" /></td>
268 <td class="footer2" colspan="3"><img src="<?php echo $this->imgroot; ?>clear.png" width="1" height="1" alt="" /></td>
269 <td align="right" class="footer2" width="9"><img src="<?php echo $this->imgroot; ?>tabs/bottomright.png" height="9" width="9" alt="" /></td>
273 $this->footerEnd($params);
276 function footerEnd($params) { ?>
278 <!-- PLEASE LEAVE "Powered By GForge" on your site -->
281 <a href="http://gforge.org/"><img src="/images/pow-gforge.png" alt="Powered By GForge Collaborative Development Environment" border="0" /></a>
285 global $sys_show_source;
286 if ($sys_show_source) {
287 echo util_make_link ('/source.php?file='.getStringFromServer('SCRIPT_NAME'),_('Show source'),array('class'=>'showsource'));
298 function getRootIndex() {
299 return $this->rootindex;
303 * boxTop() - Top HTML box
305 * @param string Box title
306 * @param bool Whether to echo or return the results
307 * @param string The box background color
309 function boxTop($title) {
311 <!-- Box Top Start -->
313 <table cellspacing="0" cellpadding="0" width="100%" border="0" style="background:url('.$this->imgroot.'vert-grad.png)">
315 <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>
316 <td width="100%" style="background:url('.$this->imgroot.'box-grad.png)"><span class="titlebar">'.$title.'</span></td>
317 <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>
321 <table cellspacing="2" cellpadding="2" width="100%" border="0">
325 <!-- Box Top End -->';
329 * boxMiddle() - Middle HTML box
331 * @param string Box title
332 * @param string The box background color
334 function boxMiddle($title) {
336 <!-- Box Middle Start -->
340 <td colspan="2" style="background:url('.$this->imgroot.'box-grad.png)"><span class="titlebar">'.$title.'</span></td>
344 <!-- Box Middle End -->';
348 * boxBottom() - Bottom HTML box
350 * @param bool Whether to echo or return the results
352 function boxBottom() {
354 <!-- Box Bottom Start -->
361 <!-- Box Bottom End -->';
365 * boxGetAltRowStyle() - Get an alternating row style for tables
367 * @param int Row number
369 function boxGetAltRowStyle($i) {
371 return ' class="altRowStyleEven"';
373 return ' class="altRowStyleOdd"';
378 * listTableTop() - Takes an array of titles and builds the first row of a new table.
380 * @param array The array of titles
381 * @param array The array of title links
383 function listTableTop ($title_arr,$links_arr=false) {
385 <table cellspacing="0" cellpadding="0" width="100%" border="0">
387 <!-- <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> -->
388 <td style="background:url('.$this->imgroot.'box-grad.png)">
389 <table width="100%" border="0" cellspacing="1" cellpadding="2" >
390 <tr class="tableheading">';
391 $count=count($title_arr);
393 for ($i=0; $i<$count; $i++) {
394 $return .= '<td>'.util_make_link ($links_arr[$i],$title_arr[$i],array('class'=>'sortbutton')).'</td>';
397 for ($i=0; $i<$count; $i++) {
399 <td>'.$title_arr[$i].'</td>';
402 return $return.'</tr>';
405 function listTableBottom() {
406 return '</table></td>
407 <!-- <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> -->
411 function outerTabs($params) {
412 global $sys_use_trove,$sys_use_snippet,$sys_use_people;
416 if ($sys_use_trove) {
417 $TABS_DIRS[]='/softwaremap/';
419 if ($sys_use_snippet) {
420 $TABS_DIRS[]='/snippet/';
422 if ($sys_use_people) {
423 $TABS_DIRS[]='/people/';
425 $TABS_TITLES[]=_('Home');
426 $TABS_TITLES[]=_('My Page');
427 if ($sys_use_trove) {
428 $TABS_TITLES[]=_('Project Tree');
430 if ($sys_use_snippet) {
431 $TABS_TITLES[]=_('Code Snippets');
433 if ($sys_use_people) {
434 $TABS_TITLES[]=_('Project Openings');
438 $PLUGIN_TABS_DIRS = Array();
439 $hookParams['DIRS'] = &$PLUGIN_TABS_DIRS;
440 $hookParams['TITLES'] = &$TABS_TITLES;
441 plugin_hook ("outermenu", $hookParams) ;
442 $TABS_DIRS = array_merge($TABS_DIRS, $PLUGIN_TABS_DIRS);
444 $user_is_super=false;
445 if (session_loggedin()) {
446 $projectmaster =& group_get_object(GROUP_IS_MASTER);
447 $projectstats =& group_get_object(GROUP_IS_STATS);
448 $permmaster =& $projectmaster->getPermission( session_get_user() );
449 $permstats =& $projectstats->getPermission( session_get_user() );
451 if ($permmaster->isAdmin()) {
453 $TABS_DIRS[]='/admin/';
454 $TABS_TITLES[]=_('Admin');
456 if ($permstats->isMember()) {
457 $TABS_DIRS[]='/reporting/';
458 $TABS_TITLES[]=_('Reporting');
461 if(isset($params['group']) && $params['group']) {
462 // get group info using the common result set
463 $project =& group_get_object($params['group']);
464 if ($project && is_object($project)) {
465 if ($project->isError()) {
467 } elseif (!$project->isProject()) {
470 $TABS_DIRS[]='/projects/'.$project->getUnixName().'/';
471 $TABS_TITLES[]=$project->getPublicName();
472 $selected=count($TABS_DIRS)-1;
475 } elseif (strstr($GLOBALS['REQUEST_URI'],'/my/') ||
476 strstr($GLOBALS['REQUEST_URI'],'/account/') ||
477 strstr($GLOBALS['REQUEST_URI'],'/register/') ||
478 strstr(getStringFromServer('REQUEST_URI'),'/themes/') ) {
479 $selected=array_search("/my/", $TABS_DIRS);
480 } elseif (strstr(getStringFromServer('REQUEST_URI'),'softwaremap')) {
481 $selected=array_search("/softwaremap/", $TABS_DIRS);
482 } elseif (strstr(getStringFromServer('REQUEST_URI'),'/snippet/')) {
483 $selected=array_search("/snippet/", $TABS_DIRS);
484 } elseif (strstr(getStringFromServer('REQUEST_URI'),'/people/')) {
485 $selected=array_search("/people/", $TABS_DIRS);
486 } elseif (strstr(getStringFromServer('REQUEST_URI'),'/reporting/')) {
487 $selected=array_search('/reporting/',$TABS_DIRS);
488 } elseif (strstr(getStringFromServer('REQUEST_URI'),'/admin/') && $user_is_super) {
489 $selected=array_search('/admin/',$TABS_DIRS);
490 } elseif (count($PLUGIN_TABS_DIRS)>0) {
491 foreach ($PLUGIN_TABS_DIRS as $PLUGIN_TABS_DIRS_VALUE) {
492 if (strstr(getStringFromServer('REQUEST_URI'),$PLUGIN_TABS_DIRS_VALUE)) {
493 $selected=array_search($PLUGIN_TABS_DIRS_VALUE,$TABS_DIRS);
500 echo $this->tabGenerator($TABS_DIRS,$TABS_TITLES,false,$selected,'','100%');
505 * projectTabs() - Prints out the project tabs, contained here in case
506 * we want to allow it to be overriden
508 * @param string Is the tab currently selected
509 * @param string Is the group we should look up get title info
511 function projectTabs($toptab,$group) {
512 // get group info using the common result set
513 $project =& group_get_object($group);
514 if (!$project || !is_object($project)) {
517 if ($project->isError()) {
518 //wasn't found or some other problem
521 if (!$project->isProject()) {
526 $TABS_DIRS[]='/projects/'. $project->getUnixName() .'/';
527 $TABS_TITLES[]=_('Summary');
528 (($toptab == 'home') ? $selected=(count($TABS_TITLES)-1) : '' );
531 $perm =& $project->getPermission( session_get_user() );
532 if ($perm->isAdmin()) {
533 $TABS_DIRS[]='/project/admin/?group_id='. $group;
534 $TABS_TITLES[]=_('Admin');
535 (($toptab == 'admin') ? $selected=(count($TABS_TITLES)-1) : '' );
538 $TABS_DIRS[]='http://'. $project->getHomePage();
539 $TABS_TITLES[]=_('Home Page');
542 // Project Activity tab
544 $TABS_DIRS[]='/activity/?group_id='. $group;
545 $TABS_TITLES[]=_('Activity');
546 (($toptab == 'activity') ? $selected=(count($TABS_TITLES)-1) : '' );
549 if ($project->usesForum()) {
550 $TABS_DIRS[]='/forum/?group_id='.$group;
551 $TABS_TITLES[]=_('Forums');
552 (($toptab == 'forums') ? $selected=(count($TABS_TITLES)-1) : '' );
556 if ($project->usesTracker()) {
557 $TABS_DIRS[]='/tracker/?group_id='.$group;
558 $TABS_TITLES[]=_('Tracker');
559 (($toptab == 'tracker' || $toptab == 'bugs' || $toptab == 'support' || $toptab == 'patch')
560 ? $selected=(count($TABS_TITLES)-1) : '' );
564 if ($project->usesMail()) {
565 $TABS_DIRS[]='/mail/?group_id='.$group;
566 $TABS_TITLES[]=_('Lists');
567 (($toptab == 'mail') ? $selected=(count($TABS_TITLES)-1) : '' );
571 if ($project->usesPm()) {
572 $TABS_DIRS[]='/pm/?group_id='.$group;
573 $TABS_TITLES[]=_('Tasks');
574 (($toptab == 'pm') ? $selected=(count($TABS_TITLES)-1) : '' );
578 if ($project->usesDocman()) {
579 $TABS_DIRS[]='/docman/?group_id='.$group;
580 $TABS_TITLES[]=_('Docs');
581 (($toptab == 'docman') ? $selected=(count($TABS_TITLES)-1) : '' );
585 if ($project->usesSurvey()) {
586 $TABS_DIRS[]='/survey/?group_id='.$group;
587 $TABS_TITLES[]=_('Surveys');
588 (($toptab == 'surveys') ? $selected=(count($TABS_TITLES)-1) : '' );
592 if ($project->usesNews()) {
593 $TABS_DIRS[]='/news/?group_id='.$group;
594 $TABS_TITLES[]=_('News');
595 (($toptab == 'news') ? $selected=(count($TABS_TITLES)-1) : '' );
599 if ($project->usesSCM()) {
600 $TABS_DIRS[]='/scm/?group_id='.$group;
601 $TABS_TITLES[]=_('SCM');
602 (($toptab == 'scm') ? $selected=(count($TABS_TITLES)-1) : '' );
605 // groupmenu_after_scm hook
606 $hookParams['DIRS'] = &$TABS_DIRS;
607 $hookParams['TITLES'] = &$TABS_TITLES;
608 $hookParams['toptab'] = &$toptab;
609 $hookParams['selected'] = &$selected;
610 $hookParams['group_id'] = $group ;
612 plugin_hook ("groupmenu_scm", $hookParams) ;
615 if ($project->usesFRS()) {
616 $TABS_DIRS[]='/frs/?group_id='.$group;
617 $TABS_TITLES[]=_('Files');
618 (($toptab == 'frs') ? $selected=(count($TABS_TITLES)-1) : '' );
622 $hookParams['DIRS'] = &$TABS_DIRS;
623 $hookParams['TITLES'] = &$TABS_TITLES;
624 $hookParams['toptab'] = &$toptab;
625 $hookParams['selected'] = &$selected;
626 $hookParams['group'] = $group;
628 plugin_hook ("groupmenu", $hookParams) ;
630 echo $this->tabGenerator($TABS_DIRS,$TABS_TITLES,true,$selected,'white','100%');
634 function tabGenerator($TABS_DIRS,$TABS_TITLES,$nested=false,$selected=false,$sel_tab_bgcolor='WHITE',$total_width='100%') {
636 $count=count($TABS_DIRS);
637 $width=intval((100/$count));
645 <table border="0" cellpadding="0" cellspacing="0" width="'.$total_width.'">
653 for ($i=0; $i<$count; $i++) {
656 // this is the first tab, choose an image with end-name
659 $issel=($selected==$i);
660 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
661 // $rowspan=(($issel)?'rowspan="2" ' : '');
664 <td '.$rowspan.'valign="top" width="10" style="background:url('.$this->imgroot . 'theme-'.$inner.'-end-'.(($issel) ? '' : 'not').'selected.png)">'.
665 '<img src="'.$this->imgroot . 'clear.png" height="25" width="10" alt="" /></td>'.
666 '<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'))).'</td>';
667 } elseif ($i==$count-1) {
669 // this is the last tab, choose an image with name-end
671 $wassel=($selected==$i-1);
672 $issel=($selected==$i);
673 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
674 // $rowspan=(($issel)?'rowspan="2" ' : '');
676 // Build image between current and prior tab
679 <td '.$rowspan.'colspan="2" valign="top" width="20" style="background:url('.$this->imgroot . 'theme-'.$inner.'-'.(($wassel) ? '' : 'not').'selected-'.(($issel) ? '' : 'not').'selected.png)">'.
680 '<img src="'.$this->imgroot . 'clear.png" height="2" width="20" alt="" /></td>'.
681 '<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'))).'</td>';
683 // Last graphic on right-side
686 <td '.$rowspan.'valign="top" width="10" style="background:url('.$this->imgroot . 'theme-'.$inner.'-'.(($issel) ? '' : 'not').'selected-end.png)">'.
687 '<img src="'.$this->imgroot . 'clear.png" height="2" width="10" alt="" /></td>';
693 $wassel=($selected==$i-1);
694 $issel=($selected==$i);
695 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
696 // $rowspan=(($issel)?'rowspan="2" ' : '');
698 // Build image between current and prior tab
701 <td '.$rowspan.'colspan="2" valign="top" width="20" style="background:url('.$this->imgroot . 'theme-'.$inner.'-'.(($wassel) ? '' : 'not').'selected-'.(($issel) ? '' : 'not').'selected.png)">'.
702 '<img src="'.$this->imgroot . 'clear.png" height="2" width="20" alt="" /></td>'.
703 '<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'))).'</td>';
710 // Building a bottom row in this table, which will be darker
712 if ($selected == 0) {
714 $end_cols=((count($TABS_DIRS)*3)-3);
715 } elseif ($selected == (count($TABS_DIRS)-1)) {
716 $beg_cols=((count($TABS_DIRS)*3)-3);
719 $beg_cols=($selected*3);
720 $end_cols=(((count($TABS_DIRS)*3)-3)-$beg_cols);
724 $return .= '<td colspan="'.$beg_cols.'" height="1" class="notSelTab"><img src="'.$this->imgroot.'clear.png" height="1" width="10" alt="" /></td>';
726 $return .= '<td colspan="3" height="1" class="selTab"><img src="'.$this->imgroot.'clear.png" height="1" width="10" alt="" /></td>';
728 $return .= '<td colspan="'.$end_cols.'" height="1" class="notSelTab"><img src="'.$this->imgroot.'clear.png" height="1" width="10" alt="" /></td>';
740 function searchBox() {
741 global $words,$forum_id,$group_id,$group_project_id,$atid,$exact,$type_of_search;
743 if(get_magic_quotes_gpc()) {
744 $defaultWords = stripslashes($words);
746 $defaultWords = $words;
750 $defaultWords = htmlspecialchars($defaultWords);
752 // if there is no search currently, set the default
753 if ( ! isset($type_of_search) ) {
758 <form action="/search/" method="get">
759 <table border="0" cellpadding="0" cellspacing="0">
761 <div align="center" class="searchbox">';
763 SEARCH__PARAMETER_GROUP_ID => $group_id,
764 SEARCH__PARAMETER_ARTIFACT_ID => $atid,
765 SEARCH__PARAMETER_FORUM_ID => $forum_id,
766 SEARCH__PARAMETER_GROUP_PROJECT_ID => $group_project_id
769 $searchManager =& getSearchManager();
770 $searchManager->setParametersValues($parameters);
771 $searchEngines =& $searchManager->getAvailableSearchEngines();
773 echo '<select name="type_of_search">';
774 for($i = 0, $max = count($searchEngines); $i < $max; $i++) {
775 $searchEngine =& $searchEngines[$i];
776 echo '<option value="'.$searchEngine->getType().'"'.( $type_of_search == $searchEngine->getType() ? ' selected="selected"' : '' ).'>'.$searchEngine->getLabel($parameters).'</option>'."\n";
778 echo '</select></div>';
782 // <input type="CHECKBOX" name="exact" value="1"'.( $exact ? ' CHECKED' : ' UNCHECKED' ).'> Require All Words';
784 print '</td><td> ';
785 $parameters = $searchManager->getParameters();
786 foreach($parameters AS $name => $value) {
787 print '<input type="hidden" value="'.$value.'" name="'.$name.'" />';
790 print '<input type="text" size="12" name="words" value="'.$defaultWords.'" />';
792 print '</td><td> </td><td>';
793 print '<input type="submit" name="Search" value="'._('Search').'" />';
796 if (isset($group_id) && $group_id) {
798 <td width="10"> </td>
799 <td>'.util_make_link ('/search/advanced_search.php?group_id='.$group_id,_('Advanced search'),array('class'=>'lnkutility')).'</td>';
801 print '</tr></table>';
806 function advancedSearchBox($sectionsArray, $group_id, $words, $isExact) {
807 // display the searchmask
809 <form name="advancedsearch" action="'.getStringFromServer('PHP_SELF').'" method="post">
810 <input type="hidden" name="search" value="1"/>
811 <input type="hidden" name="group_id" value="'.$group_id.'"/>
812 <div align="center"><br />
816 <input type="text" size="60" name="words" value="'.stripslashes(htmlspecialchars($words)).'" />
817 <input type="submit" name="submitbutton" value="'._('Search').'" />
822 <input type="radio" name="mode" value="'.SEARCH__MODE_AND.'" '.($isExact ? 'checked="checked"' : '').' />'._('with all words').'
825 <input type="radio" name="mode" value="'.SEARCH__MODE_OR.'" '.(!$isExact ? 'checked="checked"' : '').' />'._('with one word').'
828 </table><br /></div>'
829 .$this->createUnderSections($sectionsArray).'
833 //create javascript methods for select none/all
835 <script type="text/javascript">
836 <!-- method for disable/enable checkboxes
837 function setCheckBoxes(parent, checked) {
840 for (var i = 0; i < document.advancedsearch.elements.length; i++)
841 if (document.advancedsearch.elements[i].type == "checkbox")
842 if (document.advancedsearch.elements[i].name.substr(0, parent.length) == parent)
843 document.advancedsearch.elements[i].checked = checked;
851 function createUnderSections($sectionsArray) {
853 foreach ($sectionsArray as $section) {
854 if(is_array($section)) {
855 $countLines += (3 + count ($section));
857 //2 lines one for section name and one for checkbox
861 $breakLimit = round($countLines/3);
862 $break = $breakLimit;
865 <table width="100%" border="0" cellspacing="0" cellpadding="1">
866 <tr class="tableheader">
868 <table width="100%" cellspacing="0" border="0">
869 <tr class="tablecontent">
870 <!--<td colspan="2">'._('Search in').':</td-->
871 <td align="right">'._('Select').' <a href="javascript:setCheckBoxes(\'\', true)">'._('all').'</a> / <a href="javascript:setCheckBoxes(\'\', false)">'._('none').'</a></td>
873 <tr height="20" class="tablecontent">
874 <td colspan="3"> </td>
876 <tr align="center" valign="top" class="tablecontent">
878 foreach($sectionsArray as $key => $section) {
879 $oldcountlines = $countLines;
880 if (is_array($section)) {
881 $countLines += (3 + count ($section));
886 if ($countLines >= $break) {
887 //if the next block is so large that shifting it to the next column hits the breakpoint better
888 //the second part of statement (behind &&) proofs, that no 4th column is added
889 if ((($countLines - $break) >= ($break - $countLines)) && ((($break + $breakLimit)/$breakLimit) <= 3)) {
890 $return .= '</td><td>';
891 $break += $breakLimit;
895 $return .= '<table width="90%" border="0" cellpadding="1" cellspacing="0">
896 <tr><td><table width="100%" border="0" cellspacing="0" cellpadding="3">
899 <a href="#'.$key.'">'.$group_subsection_names[$key].'</a>'
902 ._('Select').' <a href="javascript:setCheckBoxes(\''.$key.'\', true)">'._('all').'</a> / <a href="javascript:setCheckBoxes(\''.$key.'\', false)">'._('none').'</a>
905 <tr class="tablecontent">
908 if (!is_array($section)) {
909 $return .= ' <input type="checkbox" name="'.urlencode($key).'"';
910 if (isset($GLOBALS[urlencode($key)]))
911 $return .= ' checked="checked" ';
912 $return .= ' /></input>'.$group_subsection_names[$key].'<br />';
915 foreach($section as $underkey => $undersection) {
916 $return .= ' <input type="checkbox" name="'.urlencode($key.$underkey).'"';
917 if (isset($GLOBALS[urlencode($key.$underkey)]))
918 $return .= ' checked ';
919 $return .= '></input>'.$undersection.'<br />';
925 </table></td></tr></table><br />';
927 if ($countLines >= $break) {
928 if (($countLines - $break) < ($break - $countLines)) {
929 $return .= '</td><td width="33%">';
930 $break += $breakLimit;
935 return $return.' </td>
937 </table></td></tr></table>';
941 * beginSubMenu() - Opening a submenu.
943 * @return string Html to start a submenu.
945 function beginSubMenu () {
952 * endSubMenu() - Closing a submenu.
954 * @return string Html to end a submenu.
956 function endSubMenu () {
957 $return = '</strong></p>';
962 * printSubMenu() - Takes two array of titles and links and builds the contents of a menu.
964 * @param array The array of titles.
965 * @param array The array of title links.
966 * @return string Html to build a submenu.
968 function printSubMenu ($title_arr,$links_arr) {
969 $count=count($title_arr);
973 for ($i=0; $i<$count; $i++) {
974 $return .= util_make_link ($links_arr[$i],$title_arr[$i]).' | ';
976 $return .= util_make_link ($links_arr[$i],$title_arr[$i]);
981 * subMenu() - Takes two array of titles and links and build a menu.
983 * @param array The array of titles.
984 * @param array The array of title links.
985 * @return string Html to build a submenu.
987 function subMenu ($title_arr,$links_arr) {
988 $return = $this->beginSubMenu () ;
989 $return .= $this->printSubMenu ($title_arr,$links_arr) ;
990 $return .= $this->endSubMenu () ;
995 * multiTableRow() - create a mutlilevel row in a table
997 * @param string the row attributes
998 * @param array the array of cell data, each element is an array,
999 * the first item being the text,
1000 * the subsequent items are attributes (dont include
1001 * the bgcolor for the title here, that will be
1002 * handled by $istitle
1003 * @param boolean is this row part of the title ?
1006 function multiTableRow($row_attr, $cell_data, $istitle) {
1010 $return .=' align="center" class="multiTableRowTitle"';
1013 for ( $c = 0; $c < count($cell_data); $c++ ) {
1015 for ( $a=1; $a < count($cell_data[$c]); $a++) {
1016 $return .= $cell_data[$c][$a].' ';
1020 $return .='<span class="multiTableRowTitle">';
1022 $return .= $cell_data[$c][0];
1024 $return .='</span>';
1036 * feedback() - returns the htmlized feedback string when an action is performed.
1038 * @param string feedback string
1039 * @return string htmlized feedback
1041 function feedback($feedback) {
1046 <span class="feedback">'.strip_tags($feedback, '<br>').'</span>';
1051 * getThemeIdFromName()
1053 * @param string the dirname of the theme
1054 * @return integer the theme id
1056 function getThemeIdFromName($dirname) {
1057 $res=db_query("SELECT theme_id FROM themes WHERE dirname='$dirname'");
1058 return db_result($res,0,'theme_id');
1061 function quickNav() {
1062 if (!session_loggedin()) {
1065 $res=db_query("SELECT * FROM groups NATURAL JOIN user_group WHERE user_id='".user_getid()."' ORDER BY group_name");
1067 if (!$res || db_numrows($res) < 1) {
1071 <form name="quicknavform">
1072 <select name="quicknav" onChange="location.href=document.quicknavform.quicknav.value">';
1074 <option value="">Quick Jump To...</option>';
1075 for ($i=0; $i<db_numrows($res); $i++) {
1077 <option value="/projects/'.db_result($res,$i,'unix_group_name').'/">'.db_result($res,$i,'group_name').'</option>';
1078 if (trim(db_result($res,$i,'admin_flags'))=='A') {
1080 <option value="/project/admin/?group_id='.db_result($res,$i,'group_id').'"> Admin</option>';
1083 if (db_result($res,$i,'use_tracker')) {
1085 <option value="/tracker/?group_id='.db_result($res,$i,'group_id').'"> Tracker</option>';
1086 if (db_result($res,$i,'admin_flags') || db_result($res,$i,'tracker_flags')) {
1088 <option value="/tracker/admin/?group_id='.db_result($res,$i,'group_id').'"> Admin</option>';
1092 if (db_result($res,$i,'use_pm')) {
1094 <option value="/pm/?group_id='.db_result($res,$i,'group_id').'"> Task Manager</option>';
1095 if (trim(db_result($res,$i,'admin_flags')) =='A' || db_result($res,$i,'project_flags')) {
1097 <option value="/pm/admin/?group_id='.db_result($res,$i,'group_id').'"> Admin</option>';
1101 if (db_result($res,$i,'use_frs')) {
1103 <option value="/frs/?group_id='.db_result($res,$i,'group_id').'"> Files</option>';
1104 if (trim(db_result($res,$i,'admin_flags'))=='A' || db_result($res,$i,'release_flags')) {
1106 <option value="/frs/admin/?group_id='.db_result($res,$i,'group_id').'"> Admin</option>';
1110 if (db_result($res,$i,'use_scm')) {
1112 <option value="/scm/?group_id='.db_result($res,$i,'group_id').'"> SCM</option>';
1113 /*if (db_result($res,$i,'admin_flags') || db_result($res,$i,'project_flags')) {
1115 <option value="/pm/admin/?group_id='.db_result($res,$i,'group_id').'"> Admin</option>';
1119 if (db_result($res,$i,'use_forum')) {
1121 <option value="/forum/?group_id='.db_result($res,$i,'group_id').'"> Forum</option>';
1122 if (trim(db_result($res,$i,'admin_flags'))=='A' || db_result($res,$i,'forum_flags')) {
1124 <option value="/forum/admin/?group_id='.db_result($res,$i,'group_id').'"> Admin</option>';
1128 if (db_result($res,$i,'use_mail')) {
1130 <option value="/mail/?group_id='.db_result($res,$i,'group_id').'"> Lists</option>';
1131 if (trim(db_result($res,$i,'admin_flags'))=='A') {
1133 <option value="/mail/admin/?group_id='.db_result($res,$i,'group_id').'"> Admin</option>';
1137 if (db_result($res,$i,'use_docman')) {
1139 <option value="/docman/?group_id='.db_result($res,$i,'group_id').'"> Docs</option>';
1140 if (trim(db_result($res,$i,'admin_flags'))=='A' || db_result($res,$i,'doc_flags')) {
1142 <option value="/docman/admin/?group_id='.db_result($res,$i,'group_id').'"> Admin</option>';
1146 if (db_result($res,$i,'use_news')) {
1148 <option value="/news/?group_id='.db_result($res,$i,'group_id').'"> News</option>';
1149 if (trim(db_result($res,$i,'admin_flags'))=='A') {
1151 <option value="/news/admin/?group_id='.db_result($res,$i,'group_id').'"> Admin</option>';
1155 if (db_result($res,$i,'use_survey')) {
1157 <option value="/survey/?group_id='.db_result($res,$i,'group_id').'"> Surveys</option>';
1158 if (trim(db_result($res,$i,'admin_flags'))=='A') {
1160 <option value="/survey/admin/?group_id='.db_result($res,$i,'group_id').'"> Admin</option>';
1176 // c-file-style: "bsd"