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 * headerStart() - common code for all themes
59 * @param array Header parameters array
61 function headerStart($params) {
62 if (!$params['title']) {
63 $params['title'] = $GLOBALS['sys_name'];
65 $params['title'] = $GLOBALS['sys_name'] . ': ' . $params['title'];
67 print '<?xml version="1.0" encoding="utf-8"';
71 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
72 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
74 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="<?php echo _('en') ?>">
77 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
78 <title><?php echo $params['title']; ?></title>
79 <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"/>
80 <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"/>
81 <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"/>
83 <?php if (isset($GLOBALS['group_id'])) {
84 $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"/>';
88 <?php $this->headerCSS(); ?>
90 <script language="JavaScript" type="text/javascript">
93 function admin_window(adminurl) {
94 AdminWin = window.open( adminurl, 'AdminWindow','scrollbars=yes,resizable=yes, toolbar=yes, height=400, width=400, top=2, left=2');
97 function help_window(helpurl) {
98 HelpWin = window.open( helpurl,'HelpWindow','scrollbars=yes,resizable=yes,toolbar=no,height=400,width=400');
101 <?php plugin_hook ("javascript",false) ; ?>
107 function headerCSS() {
108 /* check if a personalized css stylesheet exist, if yes include only
110 new stylesheets should use the <themename>.css file
112 $theme_cssfile=$GLOBALS['sys_themeroot'].$GLOBALS['sys_theme'].'/css/'.$GLOBALS['sys_theme'].'.css';
113 if (file_exists($theme_cssfile)){
115 <link rel="stylesheet" type="text/css" href="'.util_make_url ('/themes/'.$GLOBALS['sys_theme'].'/css/'.$GLOBALS['sys_theme'].'.css').'"/>';
117 /* if this is not our case, then include the compatibility stylesheet
118 that contains all removed styles from the code and check if a
119 custom stylesheet exists.
120 Used for compatibility with existing stylesheets
123 <link rel="stylesheet" type="text/css" href="'.util_make_url ('/themes/css/gforge-compat.css').'" />';
124 $theme_cssfile=$GLOBALS['sys_themeroot'].$GLOBALS['sys_theme'].'/css/theme.css';
125 if (file_exists($theme_cssfile)){
127 <link rel="stylesheet" type="text/css" href="'.util_make_url ('/themes/'.$GLOBALS['sys_theme'].'/css/theme.css').'" />';
130 plugin_hook ('cssfile',$this);
133 function header($params) {
134 $this->headerStart($params); ?>
137 $this->bodyHeader($params);
140 function bodyHeader($params){
143 <table border="0" width="100%" cellspacing="0" cellpadding="0" id="headertable">
146 <td><a href="<?php echo util_make_url (''); ?>/"><?php echo html_image('logo.png',198,52,array('border'=>'0')); ?></a></td>
147 <td><?php echo $this->searchBox(); ?></td>
148 <td align="right"><?php
149 if (session_loggedin()) {
150 echo util_make_link ('/account/logout.php',_('Log Out'),array('class'=>'lnkutility'));
151 echo util_make_link ('/account/',_('My Account'),array('class'=>'lnkutility'));
153 echo util_make_link ('/account/login.php',_('Log In'),array('class'=>'lnkutility'));
154 echo util_make_link ('/account/register.php',_('New Account'),array('class'=>'lnkutility'));
157 $params['template'] = ' {menu}';
158 plugin_hook ('headermenu', $params);
160 echo $this->quickNav();
163 <td> </td>
168 <table border="0" width="100%" cellspacing="0" cellpadding="0">
174 <?php echo $this->outerTabs($params); ?>
181 <td align="left" class="toptab" width="9"><img src="<?php echo $this->imgroot; ?>tabs/topleft.png" height="9" width="9" alt="" /></td>
182 <td class="toptab" width="30"><img src="<?php echo $this->imgroot; ?>clear.png" width="30" height="1" alt="" /></td>
183 <td class="toptab"><img src="<?php echo $this->imgroot; ?>clear.png" width="1" height="1" alt="" /></td>
184 <td class="toptab" width="30"><img src="<?php echo $this->imgroot; ?>clear.png" width="30" height="1" alt="" /></td>
185 <td align="right" class="toptab" width="9"><img src="<?php echo $this->imgroot; ?>tabs/topright.png" height="9" width="9" alt="" /></td>
190 <!-- Outer body row -->
192 <td class="toptab"><img src="<?php echo $this->imgroot; ?>clear.png" width="10" height="1" alt="" /></td>
193 <td valign="top" width="99%" class="toptab" colspan="3">
195 <!-- Inner Tabs / Shell -->
197 <table border="0" width="100%" cellspacing="0" cellpadding="0">
201 if (isset($params['group']) && $params['group']) {
209 echo $this->projectTabs($params['toptab'],$params['group']);
221 <td align="left" class="projecttab" width="9"><img src="<?php echo $this->imgroot; ?>tabs/topleft-inner.png" height="9" width="9" alt="" /></td>
222 <td class="projecttab" ><img src="<?php echo $this->imgroot; ?>clear.png" width="1" height="1" alt="" /></td>
223 <td align="right" class="projecttab" width="9"><img src="<?php echo $this->imgroot; ?>tabs/topright-inner.png" height="9" width="9" alt="" /></td>
227 <td class="projecttab" ><img src="<?php echo $this->imgroot; ?>clear.png" width="10" height="1" alt="" /></td>
228 <td valign="top" width="99%" class="projecttab">
234 function footer($params) {
238 <!-- end main body row -->
242 <td width="10" class="footer3" ><img src="<?php echo $this->imgroot; ?>clear.png" width="2" height="1" alt="" /></td>
245 <td align="left" class="footer1" width="9"><img src="<?php echo $this->imgroot; ?>tabs/bottomleft-inner.png" height="11" width="11" alt="" /></td>
246 <td class="footer3"><img src="<?php echo $this->imgroot; ?>clear.png" width="1" height="1" alt="" /></td>
247 <td align="right" class="footer1" width="9"><img src="<?php echo $this->imgroot; ?>tabs/bottomright-inner.png" height="11" width="11" alt="" /></td>
251 <!-- end inner body row -->
254 <td width="10" class="footer2"><img src="<?php echo $this->imgroot; ?>clear.png" width="2" height="1" alt="" /></td>
257 <td align="left" class="footer2" width="9"><img src="<?php echo $this->imgroot; ?>tabs/bottomleft.png" height="9" width="9" alt="" /></td>
258 <td class="footer2" colspan="3"><img src="<?php echo $this->imgroot; ?>clear.png" width="1" height="1" alt="" /></td>
259 <td align="right" class="footer2" width="9"><img src="<?php echo $this->imgroot; ?>tabs/bottomright.png" height="9" width="9" alt="" /></td>
263 $this->footerEnd($params);
266 function footerEnd($params) { ?>
268 <!-- PLEASE LEAVE "Powered By GForge" on your site -->
271 <a href="http://gforge.org/"><img src="/images/pow-gforge.png" alt="Powered By GForge Collaborative Development Environment" border="0" /></a>
275 global $sys_show_source;
276 if ($sys_show_source) {
277 echo util_make_link ('/source.php?file='.getStringFromServer('SCRIPT_NAME'),_('Show source'),array('class'=>'showsource'));
288 function getRootIndex() {
289 return $this->rootindex;
293 * boxTop() - Top HTML box
295 * @param string Box title
296 * @param bool Whether to echo or return the results
297 * @param string The box background color
299 function boxTop($title) {
301 <!-- Box Top Start -->
303 <table cellspacing="0" cellpadding="0" width="100%" border="0" style="background:url('.$this->imgroot.'vert-grad.png)">
305 <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>
306 <td width="100%" style="background:url('.$this->imgroot.'box-grad.png)"><span class="titlebar">'.$title.'</span></td>
307 <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>
311 <table cellspacing="2" cellpadding="2" width="100%" border="0">
315 <!-- Box Top End -->';
319 * boxMiddle() - Middle HTML box
321 * @param string Box title
322 * @param string The box background color
324 function boxMiddle($title) {
326 <!-- Box Middle Start -->
330 <td colspan="2" style="background:url('.$this->imgroot.'box-grad.png)"><span class="titlebar">'.$title.'</span></td>
334 <!-- Box Middle End -->';
338 * boxBottom() - Bottom HTML box
340 * @param bool Whether to echo or return the results
342 function boxBottom() {
344 <!-- Box Bottom Start -->
351 <!-- Box Bottom End -->';
355 * boxGetAltRowStyle() - Get an alternating row style for tables
357 * @param int Row number
359 function boxGetAltRowStyle($i) {
361 return ' class="altRowStyleEven"';
363 return ' class="altRowStyleOdd"';
368 * listTableTop() - Takes an array of titles and builds the first row of a new table.
370 * @param array The array of titles
371 * @param array The array of title links
373 function listTableTop ($title_arr,$links_arr=false) {
375 <table cellspacing="0" cellpadding="0" width="100%" border="0">
377 <!-- <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> -->
378 <td style="background:url('.$this->imgroot.'box-grad.png)">
379 <table width="100%" border="0" cellspacing="1" cellpadding="2" >
380 <tr class="tableheading">';
381 $count=count($title_arr);
383 for ($i=0; $i<$count; $i++) {
384 $return .= '<td>'.util_make_link ($links_arr[$i],$title_arr[$i],array('class'=>'sortbutton')).'</td>';
387 for ($i=0; $i<$count; $i++) {
389 <td>'.$title_arr[$i].'</td>';
392 return $return.'</tr>';
395 function listTableBottom() {
396 return '</table></td>
397 <!-- <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> -->
401 function outerTabs($params) {
402 global $sys_use_trove,$sys_use_snippet,$sys_use_people;
406 if ($sys_use_trove) {
407 $TABS_DIRS[]='/softwaremap/';
409 if ($sys_use_snippet) {
410 $TABS_DIRS[]='/snippet/';
412 if ($sys_use_people) {
413 $TABS_DIRS[]='/people/';
415 $TABS_TITLES[]=_('Home');
416 $TABS_TITLES[]=_('My Page');
417 if ($sys_use_trove) {
418 $TABS_TITLES[]=_('Project Tree');
420 if ($sys_use_snippet) {
421 $TABS_TITLES[]=_('Code Snippets');
423 if ($sys_use_people) {
424 $TABS_TITLES[]=_('Project Openings');
428 $PLUGIN_TABS_DIRS = Array();
429 $hookParams['DIRS'] = &$PLUGIN_TABS_DIRS;
430 $hookParams['TITLES'] = &$TABS_TITLES;
431 plugin_hook ("outermenu", $hookParams) ;
432 $TABS_DIRS = array_merge($TABS_DIRS, $PLUGIN_TABS_DIRS);
434 $user_is_super=false;
435 if (session_loggedin()) {
436 $projectmaster =& group_get_object(GROUP_IS_MASTER);
437 $projectstats =& group_get_object(GROUP_IS_STATS);
438 $permmaster =& $projectmaster->getPermission( session_get_user() );
439 $permstats =& $projectstats->getPermission( session_get_user() );
441 if ($permmaster->isAdmin()) {
443 $TABS_DIRS[]='/admin/';
444 $TABS_TITLES[]=_('Admin');
446 if ($permstats->isMember()) {
447 $TABS_DIRS[]='/reporting/';
448 $TABS_TITLES[]=_('Reporting');
451 if(isset($params['group']) && $params['group']) {
452 // get group info using the common result set
453 $project =& group_get_object($params['group']);
454 if ($project && is_object($project)) {
455 if ($project->isError()) {
457 } elseif (!$project->isProject()) {
460 if (isset ($GLOBALS['sys_noforcetype']) && $GLOBALS['sys_noforcetype']) {
461 $TABS_DIRS[]='/project/?group_id'.$project->getId();
463 $TABS_DIRS[]='/projects/'.$project->getUnixName().'/';
465 $TABS_TITLES[]=$project->getPublicName();
466 $selected=count($TABS_DIRS)-1;
469 } elseif (strstr(getStringFromServer('REQUEST_URI'),'/my/') ||
470 strstr(getStringFromServer('REQUEST_URI'),'/account/') ||
471 strstr(getStringFromServer('REQUEST_URI'),'/register/') ||
472 strstr(getStringFromServer('REQUEST_URI'),'/themes/') ) {
473 $selected=array_search("/my/", $TABS_DIRS);
474 } elseif (strstr(getStringFromServer('REQUEST_URI'),'softwaremap')) {
475 $selected=array_search("/softwaremap/", $TABS_DIRS);
476 } elseif (strstr(getStringFromServer('REQUEST_URI'),'/snippet/')) {
477 $selected=array_search("/snippet/", $TABS_DIRS);
478 } elseif (strstr(getStringFromServer('REQUEST_URI'),'/people/')) {
479 $selected=array_search("/people/", $TABS_DIRS);
480 } elseif (strstr(getStringFromServer('REQUEST_URI'),'/reporting/')) {
481 $selected=array_search('/reporting/',$TABS_DIRS);
482 } elseif (strstr(getStringFromServer('REQUEST_URI'),'/admin/') && $user_is_super) {
483 $selected=array_search('/admin/',$TABS_DIRS);
484 } elseif (count($PLUGIN_TABS_DIRS)>0) {
485 foreach ($PLUGIN_TABS_DIRS as $PLUGIN_TABS_DIRS_VALUE) {
486 if (strstr(getStringFromServer('REQUEST_URI'),$PLUGIN_TABS_DIRS_VALUE)) {
487 $selected=array_search($PLUGIN_TABS_DIRS_VALUE,$TABS_DIRS);
494 echo $this->tabGenerator($TABS_DIRS,$TABS_TITLES,false,$selected,'','100%');
499 * projectTabs() - Prints out the project tabs, contained here in case
500 * we want to allow it to be overriden
502 * @param string Is the tab currently selected
503 * @param string Is the group we should look up get title info
505 function projectTabs($toptab,$group) {
506 // get group info using the common result set
507 $project =& group_get_object($group);
508 if (!$project || !is_object($project)) {
511 if ($project->isError()) {
512 //wasn't found or some other problem
515 if (!$project->isProject()) {
520 if (isset ($GLOBALS['sys_noforcetype']) && $GLOBALS['sys_noforcetype']) {
521 $TABS_DIRS[]='/project/?group_id='. $project->getId();
523 $TABS_DIRS[]='/projects/'. $project->getUnixName() .'/';
525 $TABS_TITLES[]=_('Summary');
526 (($toptab == 'home') ? $selected=(count($TABS_TITLES)-1) : '' );
529 $perm =& $project->getPermission( session_get_user() );
530 if ($perm->isAdmin()) {
531 $TABS_DIRS[]='/project/admin/?group_id='. $group;
532 $TABS_TITLES[]=_('Admin');
533 (($toptab == 'admin') ? $selected=(count($TABS_TITLES)-1) : '' );
536 $TABS_DIRS[]='http://'. $project->getHomePage();
537 $TABS_TITLES[]=_('Home Page');
540 // Project Activity tab
542 $TABS_DIRS[]='/activity/?group_id='. $group;
543 $TABS_TITLES[]=_('Activity');
544 (($toptab == 'activity') ? $selected=(count($TABS_TITLES)-1) : '' );
547 if ($project->usesForum()) {
548 $TABS_DIRS[]='/forum/?group_id='.$group;
549 $TABS_TITLES[]=_('Forums');
550 (($toptab == 'forums') ? $selected=(count($TABS_TITLES)-1) : '' );
554 if ($project->usesTracker()) {
555 $TABS_DIRS[]='/tracker/?group_id='.$group;
556 $TABS_TITLES[]=_('Tracker');
557 (($toptab == 'tracker' || $toptab == 'bugs' || $toptab == 'support' || $toptab == 'patch')
558 ? $selected=(count($TABS_TITLES)-1) : '' );
562 if ($project->usesMail()) {
563 $TABS_DIRS[]='/mail/?group_id='.$group;
564 $TABS_TITLES[]=_('Lists');
565 (($toptab == 'mail') ? $selected=(count($TABS_TITLES)-1) : '' );
569 if ($project->usesPm()) {
570 $TABS_DIRS[]='/pm/?group_id='.$group;
571 $TABS_TITLES[]=_('Tasks');
572 (($toptab == 'pm') ? $selected=(count($TABS_TITLES)-1) : '' );
576 if ($project->usesDocman()) {
577 $TABS_DIRS[]='/docman/?group_id='.$group;
578 $TABS_TITLES[]=_('Docs');
579 (($toptab == 'docman') ? $selected=(count($TABS_TITLES)-1) : '' );
583 if ($project->usesSurvey()) {
584 $TABS_DIRS[]='/survey/?group_id='.$group;
585 $TABS_TITLES[]=_('Surveys');
586 (($toptab == 'surveys') ? $selected=(count($TABS_TITLES)-1) : '' );
590 if ($project->usesNews()) {
591 $TABS_DIRS[]='/news/?group_id='.$group;
592 $TABS_TITLES[]=_('News');
593 (($toptab == 'news') ? $selected=(count($TABS_TITLES)-1) : '' );
597 if ($project->usesSCM()) {
598 $TABS_DIRS[]='/scm/?group_id='.$group;
599 $TABS_TITLES[]=_('SCM');
600 (($toptab == 'scm') ? $selected=(count($TABS_TITLES)-1) : '' );
603 // groupmenu_after_scm hook
604 $hookParams['DIRS'] = &$TABS_DIRS;
605 $hookParams['TITLES'] = &$TABS_TITLES;
606 $hookParams['toptab'] = &$toptab;
607 $hookParams['selected'] = &$selected;
608 $hookParams['group_id'] = $group ;
610 plugin_hook ("groupmenu_scm", $hookParams) ;
613 if ($project->usesFRS()) {
614 $TABS_DIRS[]='/frs/?group_id='.$group;
615 $TABS_TITLES[]=_('Files');
616 (($toptab == 'frs') ? $selected=(count($TABS_TITLES)-1) : '' );
620 $hookParams['DIRS'] = &$TABS_DIRS;
621 $hookParams['TITLES'] = &$TABS_TITLES;
622 $hookParams['toptab'] = &$toptab;
623 $hookParams['selected'] = &$selected;
624 $hookParams['group'] = $group;
626 plugin_hook ("groupmenu", $hookParams) ;
628 echo $this->tabGenerator($TABS_DIRS,$TABS_TITLES,true,$selected,'white','100%');
632 function tabGenerator($TABS_DIRS,$TABS_TITLES,$nested=false,$selected=false,$sel_tab_bgcolor='WHITE',$total_width='100%') {
634 $count=count($TABS_DIRS);
635 $width=intval((100/$count));
643 <table border="0" cellpadding="0" cellspacing="0" width="'.$total_width.'">
651 for ($i=0; $i<$count; $i++) {
654 // this is the first tab, choose an image with end-name
657 $issel=($selected==$i);
658 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
659 // $rowspan=(($issel)?'rowspan="2" ' : '');
662 <td '.$rowspan.'valign="top" width="10" style="background:url('.$this->imgroot . 'theme-'.$inner.'-end-'.(($issel) ? '' : 'not').'selected.png)">'.
663 '<img src="'.$this->imgroot . 'clear.png" height="25" width="10" alt="" /></td>'.
664 '<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>';
665 } elseif ($i==$count-1) {
667 // this is the last tab, choose an image with name-end
669 $wassel=($selected==$i-1);
670 $issel=($selected==$i);
671 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
672 // $rowspan=(($issel)?'rowspan="2" ' : '');
674 // Build image between current and prior tab
677 <td '.$rowspan.'colspan="2" valign="top" width="20" style="background:url('.$this->imgroot . 'theme-'.$inner.'-'.(($wassel) ? '' : 'not').'selected-'.(($issel) ? '' : 'not').'selected.png)">'.
678 '<img src="'.$this->imgroot . 'clear.png" height="2" width="20" alt="" /></td>'.
679 '<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>';
681 // Last graphic on right-side
684 <td '.$rowspan.'valign="top" width="10" style="background:url('.$this->imgroot . 'theme-'.$inner.'-'.(($issel) ? '' : 'not').'selected-end.png)">'.
685 '<img src="'.$this->imgroot . 'clear.png" height="2" width="10" alt="" /></td>';
691 $wassel=($selected==$i-1);
692 $issel=($selected==$i);
693 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
694 // $rowspan=(($issel)?'rowspan="2" ' : '');
696 // Build image between current and prior tab
699 <td '.$rowspan.'colspan="2" valign="top" width="20" style="background:url('.$this->imgroot . 'theme-'.$inner.'-'.(($wassel) ? '' : 'not').'selected-'.(($issel) ? '' : 'not').'selected.png)">'.
700 '<img src="'.$this->imgroot . 'clear.png" height="2" width="20" alt="" /></td>'.
701 '<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>';
708 // Building a bottom row in this table, which will be darker
710 if ($selected == 0) {
712 $end_cols=((count($TABS_DIRS)*3)-3);
713 } elseif ($selected == (count($TABS_DIRS)-1)) {
714 $beg_cols=((count($TABS_DIRS)*3)-3);
717 $beg_cols=($selected*3);
718 $end_cols=(((count($TABS_DIRS)*3)-3)-$beg_cols);
722 $return .= '<td colspan="'.$beg_cols.'" height="1" class="notSelTab"><img src="'.$this->imgroot.'clear.png" height="1" width="10" alt="" /></td>';
724 $return .= '<td colspan="3" height="1" class="selTab"><img src="'.$this->imgroot.'clear.png" height="1" width="10" alt="" /></td>';
726 $return .= '<td colspan="'.$end_cols.'" height="1" class="notSelTab"><img src="'.$this->imgroot.'clear.png" height="1" width="10" alt="" /></td>';
738 function searchBox() {
739 global $words,$forum_id,$group_id,$group_project_id,$atid,$exact,$type_of_search;
741 if(get_magic_quotes_gpc()) {
742 $defaultWords = stripslashes($words);
744 $defaultWords = $words;
748 $defaultWords = htmlspecialchars($defaultWords);
750 // if there is no search currently, set the default
751 if ( ! isset($type_of_search) ) {
756 <form action="/search/" method="get">
757 <table border="0" cellpadding="0" cellspacing="0">
759 <div align="center" class="searchbox">';
761 SEARCH__PARAMETER_GROUP_ID => $group_id,
762 SEARCH__PARAMETER_ARTIFACT_ID => $atid,
763 SEARCH__PARAMETER_FORUM_ID => $forum_id,
764 SEARCH__PARAMETER_GROUP_PROJECT_ID => $group_project_id
767 $searchManager =& getSearchManager();
768 $searchManager->setParametersValues($parameters);
769 $searchEngines =& $searchManager->getAvailableSearchEngines();
771 echo '<select name="type_of_search">';
772 for($i = 0, $max = count($searchEngines); $i < $max; $i++) {
773 $searchEngine =& $searchEngines[$i];
774 echo '<option value="'.$searchEngine->getType().'"'.( $type_of_search == $searchEngine->getType() ? ' selected="selected"' : '' ).'>'.$searchEngine->getLabel($parameters).'</option>'."\n";
776 echo '</select></div>';
780 // <input type="CHECKBOX" name="exact" value="1"'.( $exact ? ' CHECKED' : ' UNCHECKED' ).'> Require All Words';
782 print '</td><td> ';
783 $parameters = $searchManager->getParameters();
784 foreach($parameters AS $name => $value) {
785 print '<input type="hidden" value="'.$value.'" name="'.$name.'" />';
788 print '<input type="text" size="12" name="words" value="'.$defaultWords.'" />';
790 print '</td><td> </td><td>';
791 print '<input type="submit" name="Search" value="'._('Search').'" />';
794 if (isset($group_id) && $group_id) {
796 <td width="10"> </td>
797 <td>'.util_make_link ('/search/advanced_search.php?group_id='.$group_id,_('Advanced search'),array('class'=>'lnkutility')).'</td>';
799 print '</tr></table>';
804 function advancedSearchBox($sectionsArray, $group_id, $words, $isExact) {
805 // display the searchmask
807 <form name="advancedsearch" action="'.getStringFromServer('PHP_SELF').'" method="post">
808 <input type="hidden" name="search" value="1"/>
809 <input type="hidden" name="group_id" value="'.$group_id.'"/>
810 <div align="center"><br />
814 <input type="text" size="60" name="words" value="'.stripslashes(htmlspecialchars($words)).'" />
815 <input type="submit" name="submitbutton" value="'._('Search').'" />
820 <input type="radio" name="mode" value="'.SEARCH__MODE_AND.'" '.($isExact ? 'checked="checked"' : '').' />'._('with all words').'
823 <input type="radio" name="mode" value="'.SEARCH__MODE_OR.'" '.(!$isExact ? 'checked="checked"' : '').' />'._('with one word').'
826 </table><br /></div>'
827 .$this->createUnderSections($sectionsArray).'
831 //create javascript methods for select none/all
833 <script type="text/javascript">
834 <!-- method for disable/enable checkboxes
835 function setCheckBoxes(parent, checked) {
838 for (var i = 0; i < document.advancedsearch.elements.length; i++)
839 if (document.advancedsearch.elements[i].type == "checkbox")
840 if (document.advancedsearch.elements[i].name.substr(0, parent.length) == parent)
841 document.advancedsearch.elements[i].checked = checked;
849 function createUnderSections($sectionsArray) {
851 foreach ($sectionsArray as $section) {
852 if(is_array($section)) {
853 $countLines += (3 + count ($section));
855 //2 lines one for section name and one for checkbox
859 $breakLimit = round($countLines/3);
860 $break = $breakLimit;
863 <table width="100%" border="0" cellspacing="0" cellpadding="1">
864 <tr class="tableheader">
866 <table width="100%" cellspacing="0" border="0">
867 <tr class="tablecontent">
868 <!--<td colspan="2">'._('Search in').':</td-->
869 <td align="right">'._('Select').' <a href="javascript:setCheckBoxes(\'\', true)">'._('all').'</a> / <a href="javascript:setCheckBoxes(\'\', false)">'._('none').'</a></td>
871 <tr height="20" class="tablecontent">
872 <td colspan="3"> </td>
874 <tr align="center" valign="top" class="tablecontent">
876 foreach($sectionsArray as $key => $section) {
877 $oldcountlines = $countLines;
878 if (is_array($section)) {
879 $countLines += (3 + count ($section));
884 if ($countLines >= $break) {
885 //if the next block is so large that shifting it to the next column hits the breakpoint better
886 //the second part of statement (behind &&) proofs, that no 4th column is added
887 if ((($countLines - $break) >= ($break - $countLines)) && ((($break + $breakLimit)/$breakLimit) <= 3)) {
888 $return .= '</td><td>';
889 $break += $breakLimit;
893 $return .= '<table width="90%" border="0" cellpadding="1" cellspacing="0">
894 <tr><td><table width="100%" border="0" cellspacing="0" cellpadding="3">
897 <a href="#'.$key.'">'.$group_subsection_names[$key].'</a>'
900 ._('Select').' <a href="javascript:setCheckBoxes(\''.$key.'\', true)">'._('all').'</a> / <a href="javascript:setCheckBoxes(\''.$key.'\', false)">'._('none').'</a>
903 <tr class="tablecontent">
906 if (!is_array($section)) {
907 $return .= ' <input type="checkbox" name="'.urlencode($key).'"';
908 if (isset($GLOBALS[urlencode($key)]))
909 $return .= ' checked="checked" ';
910 $return .= ' /></input>'.$group_subsection_names[$key].'<br />';
913 foreach($section as $underkey => $undersection) {
914 $return .= ' <input type="checkbox" name="'.urlencode($key.$underkey).'"';
915 if (isset($GLOBALS[urlencode($key.$underkey)]))
916 $return .= ' checked ';
917 $return .= '></input>'.$undersection.'<br />';
923 </table></td></tr></table><br />';
925 if ($countLines >= $break) {
926 if (($countLines - $break) < ($break - $countLines)) {
927 $return .= '</td><td width="33%">';
928 $break += $breakLimit;
933 return $return.' </td>
935 </table></td></tr></table>';
939 * beginSubMenu() - Opening a submenu.
941 * @return string Html to start a submenu.
943 function beginSubMenu () {
950 * endSubMenu() - Closing a submenu.
952 * @return string Html to end a submenu.
954 function endSubMenu () {
955 $return = '</strong></p>';
960 * printSubMenu() - Takes two array of titles and links and builds the contents of a menu.
962 * @param array The array of titles.
963 * @param array The array of title links.
964 * @return string Html to build a submenu.
966 function printSubMenu ($title_arr,$links_arr) {
967 $count=count($title_arr);
971 for ($i=0; $i<$count; $i++) {
972 $return .= util_make_link ($links_arr[$i],$title_arr[$i]).' | ';
974 $return .= util_make_link ($links_arr[$i],$title_arr[$i]);
979 * subMenu() - Takes two array of titles and links and build a menu.
981 * @param array The array of titles.
982 * @param array The array of title links.
983 * @return string Html to build a submenu.
985 function subMenu ($title_arr,$links_arr) {
986 $return = $this->beginSubMenu () ;
987 $return .= $this->printSubMenu ($title_arr,$links_arr) ;
988 $return .= $this->endSubMenu () ;
993 * multiTableRow() - create a mutlilevel row in a table
995 * @param string the row attributes
996 * @param array the array of cell data, each element is an array,
997 * the first item being the text,
998 * the subsequent items are attributes (dont include
999 * the bgcolor for the title here, that will be
1000 * handled by $istitle
1001 * @param boolean is this row part of the title ?
1004 function multiTableRow($row_attr, $cell_data, $istitle) {
1008 $return .=' align="center" class="multiTableRowTitle"';
1011 for ( $c = 0; $c < count($cell_data); $c++ ) {
1013 for ( $a=1; $a < count($cell_data[$c]); $a++) {
1014 $return .= $cell_data[$c][$a].' ';
1018 $return .='<span class="multiTableRowTitle">';
1020 $return .= $cell_data[$c][0];
1022 $return .='</span>';
1034 * feedback() - returns the htmlized feedback string when an action is performed.
1036 * @param string feedback string
1037 * @return string htmlized feedback
1039 function feedback($feedback) {
1044 <span class="feedback">'.strip_tags($feedback, '<br>').'</span>';
1049 * getThemeIdFromName()
1051 * @param string the dirname of the theme
1052 * @return integer the theme id
1054 function getThemeIdFromName($dirname) {
1055 $res=db_query("SELECT theme_id FROM themes WHERE dirname='$dirname'");
1056 return db_result($res,0,'theme_id');
1059 function quickNav() {
1060 if (!session_loggedin()) {
1063 $res=db_query("SELECT * FROM groups NATURAL JOIN user_group WHERE user_id='".user_getid()."' ORDER BY group_name");
1065 if (!$res || db_numrows($res) < 1) {
1069 <form name="quicknavform">
1070 <select name="quicknav" onChange="location.href=document.quicknavform.quicknav.value">';
1072 <option value="">Quick Jump To...</option>';
1073 for ($i=0; $i<db_numrows($res); $i++) {
1075 <option value="/projects/'.db_result($res,$i,'unix_group_name').'/">'.db_result($res,$i,'group_name').'</option>';
1076 if (trim(db_result($res,$i,'admin_flags'))=='A') {
1078 <option value="/project/admin/?group_id='.db_result($res,$i,'group_id').'"> Admin</option>';
1081 if (db_result($res,$i,'use_tracker')) {
1083 <option value="/tracker/?group_id='.db_result($res,$i,'group_id').'"> Tracker</option>';
1084 if (db_result($res,$i,'admin_flags') || db_result($res,$i,'tracker_flags')) {
1086 <option value="/tracker/admin/?group_id='.db_result($res,$i,'group_id').'"> Admin</option>';
1090 if (db_result($res,$i,'use_pm')) {
1092 <option value="/pm/?group_id='.db_result($res,$i,'group_id').'"> Task Manager</option>';
1093 if (trim(db_result($res,$i,'admin_flags')) =='A' || db_result($res,$i,'project_flags')) {
1095 <option value="/pm/admin/?group_id='.db_result($res,$i,'group_id').'"> Admin</option>';
1099 if (db_result($res,$i,'use_frs')) {
1101 <option value="/frs/?group_id='.db_result($res,$i,'group_id').'"> Files</option>';
1102 if (trim(db_result($res,$i,'admin_flags'))=='A' || db_result($res,$i,'release_flags')) {
1104 <option value="/frs/admin/?group_id='.db_result($res,$i,'group_id').'"> Admin</option>';
1108 if (db_result($res,$i,'use_scm')) {
1110 <option value="/scm/?group_id='.db_result($res,$i,'group_id').'"> SCM</option>';
1111 /*if (db_result($res,$i,'admin_flags') || db_result($res,$i,'project_flags')) {
1113 <option value="/pm/admin/?group_id='.db_result($res,$i,'group_id').'"> Admin</option>';
1117 if (db_result($res,$i,'use_forum')) {
1119 <option value="/forum/?group_id='.db_result($res,$i,'group_id').'"> Forum</option>';
1120 if (trim(db_result($res,$i,'admin_flags'))=='A' || db_result($res,$i,'forum_flags')) {
1122 <option value="/forum/admin/?group_id='.db_result($res,$i,'group_id').'"> Admin</option>';
1126 if (db_result($res,$i,'use_mail')) {
1128 <option value="/mail/?group_id='.db_result($res,$i,'group_id').'"> Lists</option>';
1129 if (trim(db_result($res,$i,'admin_flags'))=='A') {
1131 <option value="/mail/admin/?group_id='.db_result($res,$i,'group_id').'"> Admin</option>';
1135 if (db_result($res,$i,'use_docman')) {
1137 <option value="/docman/?group_id='.db_result($res,$i,'group_id').'"> Docs</option>';
1138 if (trim(db_result($res,$i,'admin_flags'))=='A' || db_result($res,$i,'doc_flags')) {
1140 <option value="/docman/admin/?group_id='.db_result($res,$i,'group_id').'"> Admin</option>';
1144 if (db_result($res,$i,'use_news')) {
1146 <option value="/news/?group_id='.db_result($res,$i,'group_id').'"> News</option>';
1147 if (trim(db_result($res,$i,'admin_flags'))=='A') {
1149 <option value="/news/admin/?group_id='.db_result($res,$i,'group_id').'"> Admin</option>';
1153 if (db_result($res,$i,'use_survey')) {
1155 <option value="/survey/?group_id='.db_result($res,$i,'group_id').'"> Surveys</option>';
1156 if (trim(db_result($res,$i,'admin_flags'))=='A') {
1158 <option value="/survey/admin/?group_id='.db_result($res,$i,'group_id').'"> Admin</option>';
1174 // c-file-style: "bsd"