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'));
166 echo $this->quickNav();
169 <td> </td>
174 <table border="0" width="100%" cellspacing="0" cellpadding="0">
180 <?php echo $this->outerTabs($params); ?>
187 <td align="left" class="toptab" width="9"><img src="<?php echo $this->imgroot; ?>tabs/topleft.png" height="9" width="9" alt="" /></td>
188 <td class="toptab" width="30"><img src="<?php echo $this->imgroot; ?>clear.png" width="30" height="1" alt="" /></td>
189 <td class="toptab"><img src="<?php echo $this->imgroot; ?>clear.png" width="1" height="1" alt="" /></td>
190 <td class="toptab" width="30"><img src="<?php echo $this->imgroot; ?>clear.png" width="30" height="1" alt="" /></td>
191 <td align="right" class="toptab" width="9"><img src="<?php echo $this->imgroot; ?>tabs/topright.png" height="9" width="9" alt="" /></td>
196 <!-- Outer body row -->
198 <td class="toptab"><img src="<?php echo $this->imgroot; ?>clear.png" width="10" height="1" alt="" /></td>
199 <td valign="top" width="99%" class="toptab" colspan="3">
201 <!-- Inner Tabs / Shell -->
203 <table border="0" width="100%" cellspacing="0" cellpadding="0">
207 if (isset($params['group']) && $params['group']) {
215 echo $this->projectTabs($params['toptab'],$params['group']);
227 <td align="left" class="projecttab" width="9"><img src="<?php echo $this->imgroot; ?>tabs/topleft-inner.png" height="9" width="9" alt="" /></td>
228 <td class="projecttab" ><img src="<?php echo $this->imgroot; ?>clear.png" width="1" height="1" alt="" /></td>
229 <td align="right" class="projecttab" width="9"><img src="<?php echo $this->imgroot; ?>tabs/topright-inner.png" height="9" width="9" alt="" /></td>
233 <td class="projecttab" ><img src="<?php echo $this->imgroot; ?>clear.png" width="10" height="1" alt="" /></td>
234 <td valign="top" width="99%" class="projecttab">
240 function footer($params) {
244 <!-- end main body row -->
248 <td width="10" class="footer3" ><img src="<?php echo $this->imgroot; ?>clear.png" width="2" height="1" alt="" /></td>
251 <td align="left" class="footer1" width="9"><img src="<?php echo $this->imgroot; ?>tabs/bottomleft-inner.png" height="11" width="11" alt="" /></td>
252 <td class="footer3"><img src="<?php echo $this->imgroot; ?>clear.png" width="1" height="1" alt="" /></td>
253 <td align="right" class="footer1" width="9"><img src="<?php echo $this->imgroot; ?>tabs/bottomright-inner.png" height="11" width="11" alt="" /></td>
257 <!-- end inner body row -->
260 <td width="10" class="footer2"><img src="<?php echo $this->imgroot; ?>clear.png" width="2" height="1" alt="" /></td>
263 <td align="left" class="footer2" width="9"><img src="<?php echo $this->imgroot; ?>tabs/bottomleft.png" height="9" width="9" alt="" /></td>
264 <td class="footer2" colspan="3"><img src="<?php echo $this->imgroot; ?>clear.png" width="1" height="1" alt="" /></td>
265 <td align="right" class="footer2" width="9"><img src="<?php echo $this->imgroot; ?>tabs/bottomright.png" height="9" width="9" alt="" /></td>
269 $this->footerEnd($params);
272 function footerEnd($params) { ?>
274 <!-- PLEASE LEAVE "Powered By GForge" on your site -->
277 <a href="http://gforge.org/"><img src="/images/pow-gforge.png" alt="Powered By GForge Collaborative Development Environment" border="0" /></a>
281 global $sys_show_source;
282 if ($sys_show_source) {
283 echo util_make_link ('/source.php?file='.getStringFromServer('SCRIPT_NAME'),_('Show source'),array('class'=>'showsource'));
294 function getRootIndex() {
295 return $this->rootindex;
299 * boxTop() - Top HTML box
301 * @param string Box title
302 * @param bool Whether to echo or return the results
303 * @param string The box background color
305 function boxTop($title) {
307 <!-- Box Top Start -->
309 <table cellspacing="0" cellpadding="0" width="100%" border="0" style="background:url('.$this->imgroot.'vert-grad.png)">
311 <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>
312 <td width="100%" style="background:url('.$this->imgroot.'box-grad.png)"><span class="titlebar">'.$title.'</span></td>
313 <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>
317 <table cellspacing="2" cellpadding="2" width="100%" border="0">
321 <!-- Box Top End -->';
325 * boxMiddle() - Middle HTML box
327 * @param string Box title
328 * @param string The box background color
330 function boxMiddle($title) {
332 <!-- Box Middle Start -->
336 <td colspan="2" style="background:url('.$this->imgroot.'box-grad.png)"><span class="titlebar">'.$title.'</span></td>
340 <!-- Box Middle End -->';
344 * boxBottom() - Bottom HTML box
346 * @param bool Whether to echo or return the results
348 function boxBottom() {
350 <!-- Box Bottom Start -->
357 <!-- Box Bottom End -->';
361 * boxGetAltRowStyle() - Get an alternating row style for tables
363 * @param int Row number
365 function boxGetAltRowStyle($i) {
367 return ' class="altRowStyleEven"';
369 return ' class="altRowStyleOdd"';
374 * listTableTop() - Takes an array of titles and builds the first row of a new table.
376 * @param array The array of titles
377 * @param array The array of title links
379 function listTableTop ($title_arr,$links_arr=false) {
381 <table cellspacing="0" cellpadding="0" width="100%" border="0">
383 <!-- <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> -->
384 <td style="background:url('.$this->imgroot.'box-grad.png)">
385 <table width="100%" border="0" cellspacing="1" cellpadding="2" >
386 <tr class="tableheading">';
387 $count=count($title_arr);
389 for ($i=0; $i<$count; $i++) {
390 $return .= '<td>'.util_make_link ($links_arr[$i],$title_arr[$i],array('class'=>'sortbutton')).'</td>';
393 for ($i=0; $i<$count; $i++) {
395 <td>'.$title_arr[$i].'</td>';
398 return $return.'</tr>';
401 function listTableBottom() {
402 return '</table></td>
403 <!-- <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> -->
407 function outerTabs($params) {
408 global $sys_use_trove,$sys_use_snippet,$sys_use_people;
412 if ($sys_use_trove) {
413 $TABS_DIRS[]='/softwaremap/';
415 if ($sys_use_snippet) {
416 $TABS_DIRS[]='/snippet/';
418 if ($sys_use_people) {
419 $TABS_DIRS[]='/people/';
421 $TABS_TITLES[]=_('Home');
422 $TABS_TITLES[]=_('My Page');
423 if ($sys_use_trove) {
424 $TABS_TITLES[]=_('Project Tree');
426 if ($sys_use_snippet) {
427 $TABS_TITLES[]=_('Code Snippets');
429 if ($sys_use_people) {
430 $TABS_TITLES[]=_('Project Openings');
434 $PLUGIN_TABS_DIRS = Array();
435 $hookParams['DIRS'] = &$PLUGIN_TABS_DIRS;
436 $hookParams['TITLES'] = &$TABS_TITLES;
437 plugin_hook ("outermenu", $hookParams) ;
438 $TABS_DIRS = array_merge($TABS_DIRS, $PLUGIN_TABS_DIRS);
440 $user_is_super=false;
441 if (session_loggedin()) {
442 $projectmaster =& group_get_object(GROUP_IS_MASTER);
443 $projectstats =& group_get_object(GROUP_IS_STATS);
444 $permmaster =& $projectmaster->getPermission( session_get_user() );
445 $permstats =& $projectstats->getPermission( session_get_user() );
447 if ($permmaster->isAdmin()) {
449 $TABS_DIRS[]='/admin/';
450 $TABS_TITLES[]=_('Admin');
452 if ($permstats->isMember()) {
453 $TABS_DIRS[]='/reporting/';
454 $TABS_TITLES[]=_('Reporting');
457 if(isset($params['group']) && $params['group']) {
458 // get group info using the common result set
459 $project =& group_get_object($params['group']);
460 if ($project && is_object($project)) {
461 if ($project->isError()) {
463 } elseif (!$project->isProject()) {
466 $TABS_DIRS[]='/projects/'.$project->getUnixName().'/';
467 $TABS_TITLES[]=$project->getPublicName();
468 $selected=count($TABS_DIRS)-1;
471 } elseif (strstr($GLOBALS['REQUEST_URI'],'/my/') ||
472 strstr($GLOBALS['REQUEST_URI'],'/account/') ||
473 strstr($GLOBALS['REQUEST_URI'],'/register/') ||
474 strstr(getStringFromServer('REQUEST_URI'),'/themes/') ) {
475 $selected=array_search("/my/", $TABS_DIRS);
476 } elseif (strstr(getStringFromServer('REQUEST_URI'),'softwaremap')) {
477 $selected=array_search("/softwaremap/", $TABS_DIRS);
478 } elseif (strstr(getStringFromServer('REQUEST_URI'),'/snippet/')) {
479 $selected=array_search("/snippet/", $TABS_DIRS);
480 } elseif (strstr(getStringFromServer('REQUEST_URI'),'/people/')) {
481 $selected=array_search("/people/", $TABS_DIRS);
482 } elseif (strstr(getStringFromServer('REQUEST_URI'),'/reporting/')) {
483 $selected=array_search('/reporting/',$TABS_DIRS);
484 } elseif (strstr(getStringFromServer('REQUEST_URI'),'/admin/') && $user_is_super) {
485 $selected=array_search('/admin/',$TABS_DIRS);
486 } elseif (count($PLUGIN_TABS_DIRS)>0) {
487 foreach ($PLUGIN_TABS_DIRS as $PLUGIN_TABS_DIRS_VALUE) {
488 if (strstr(getStringFromServer('REQUEST_URI'),$PLUGIN_TABS_DIRS_VALUE)) {
489 $selected=array_search($PLUGIN_TABS_DIRS_VALUE,$TABS_DIRS);
496 echo $this->tabGenerator($TABS_DIRS,$TABS_TITLES,false,$selected,'','100%');
501 * projectTabs() - Prints out the project tabs, contained here in case
502 * we want to allow it to be overriden
504 * @param string Is the tab currently selected
505 * @param string Is the group we should look up get title info
507 function projectTabs($toptab,$group) {
508 // get group info using the common result set
509 $project =& group_get_object($group);
510 if (!$project || !is_object($project)) {
513 if ($project->isError()) {
514 //wasn't found or some other problem
517 if (!$project->isProject()) {
522 $TABS_DIRS[]='/projects/'. $project->getUnixName() .'/';
523 $TABS_TITLES[]=_('Summary');
524 (($toptab == 'home') ? $selected=(count($TABS_TITLES)-1) : '' );
527 $perm =& $project->getPermission( session_get_user() );
528 if ($perm->isAdmin()) {
529 $TABS_DIRS[]='/project/admin/?group_id='. $group;
530 $TABS_TITLES[]=_('Admin');
531 (($toptab == 'admin') ? $selected=(count($TABS_TITLES)-1) : '' );
534 $TABS_DIRS[]='http://'. $project->getHomePage();
535 $TABS_TITLES[]=_('Home Page');
538 // Project Activity tab
540 $TABS_DIRS[]='/activity/?group_id='. $group;
541 $TABS_TITLES[]=_('Activity');
542 (($toptab == 'activity') ? $selected=(count($TABS_TITLES)-1) : '' );
545 if ($project->usesForum()) {
546 $TABS_DIRS[]='/forum/?group_id='.$group;
547 $TABS_TITLES[]=_('Forums');
548 (($toptab == 'forums') ? $selected=(count($TABS_TITLES)-1) : '' );
552 if ($project->usesTracker()) {
553 $TABS_DIRS[]='/tracker/?group_id='.$group;
554 $TABS_TITLES[]=_('Tracker');
555 (($toptab == 'tracker' || $toptab == 'bugs' || $toptab == 'support' || $toptab == 'patch')
556 ? $selected=(count($TABS_TITLES)-1) : '' );
560 if ($project->usesMail()) {
561 $TABS_DIRS[]='/mail/?group_id='.$group;
562 $TABS_TITLES[]=_('Lists');
563 (($toptab == 'mail') ? $selected=(count($TABS_TITLES)-1) : '' );
567 if ($project->usesPm()) {
568 $TABS_DIRS[]='/pm/?group_id='.$group;
569 $TABS_TITLES[]=_('Tasks');
570 (($toptab == 'pm') ? $selected=(count($TABS_TITLES)-1) : '' );
574 if ($project->usesDocman()) {
575 $TABS_DIRS[]='/docman/?group_id='.$group;
576 $TABS_TITLES[]=_('Docs');
577 (($toptab == 'docman') ? $selected=(count($TABS_TITLES)-1) : '' );
581 if ($project->usesSurvey()) {
582 $TABS_DIRS[]='/survey/?group_id='.$group;
583 $TABS_TITLES[]=_('Surveys');
584 (($toptab == 'surveys') ? $selected=(count($TABS_TITLES)-1) : '' );
588 if ($project->usesNews()) {
589 $TABS_DIRS[]='/news/?group_id='.$group;
590 $TABS_TITLES[]=_('News');
591 (($toptab == 'news') ? $selected=(count($TABS_TITLES)-1) : '' );
595 if ($project->usesSCM()) {
596 $TABS_DIRS[]='/scm/?group_id='.$group;
597 $TABS_TITLES[]=_('SCM');
598 (($toptab == 'scm') ? $selected=(count($TABS_TITLES)-1) : '' );
601 // groupmenu_after_scm hook
602 $hookParams['DIRS'] = &$TABS_DIRS;
603 $hookParams['TITLES'] = &$TABS_TITLES;
604 $hookParams['toptab'] = &$toptab;
605 $hookParams['selected'] = &$selected;
606 $hookParams['group_id'] = $group ;
608 plugin_hook ("groupmenu_scm", $hookParams) ;
611 if ($project->usesFRS()) {
612 $TABS_DIRS[]='/frs/?group_id='.$group;
613 $TABS_TITLES[]=_('Files');
614 (($toptab == 'frs') ? $selected=(count($TABS_TITLES)-1) : '' );
618 $hookParams['DIRS'] = &$TABS_DIRS;
619 $hookParams['TITLES'] = &$TABS_TITLES;
620 $hookParams['toptab'] = &$toptab;
621 $hookParams['selected'] = &$selected;
622 $hookParams['group'] = $group;
624 plugin_hook ("groupmenu", $hookParams) ;
626 echo $this->tabGenerator($TABS_DIRS,$TABS_TITLES,true,$selected,'white','100%');
630 function tabGenerator($TABS_DIRS,$TABS_TITLES,$nested=false,$selected=false,$sel_tab_bgcolor='WHITE',$total_width='100%') {
632 $count=count($TABS_DIRS);
633 $width=intval((100/$count));
641 <table border="0" cellpadding="0" cellspacing="0" width="'.$total_width.'">
649 for ($i=0; $i<$count; $i++) {
652 // this is the first tab, choose an image with end-name
655 $issel=($selected==$i);
656 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
657 // $rowspan=(($issel)?'rowspan="2" ' : '');
660 <td '.$rowspan.'valign="top" width="10" style="background:url('.$this->imgroot . 'theme-'.$inner.'-end-'.(($issel) ? '' : 'not').'selected.png)">'.
661 '<img src="'.$this->imgroot . 'clear.png" height="25" width="10" alt="" /></td>'.
662 '<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>';
663 } elseif ($i==$count-1) {
665 // this is the last tab, choose an image with name-end
667 $wassel=($selected==$i-1);
668 $issel=($selected==$i);
669 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
670 // $rowspan=(($issel)?'rowspan="2" ' : '');
672 // Build image between current and prior tab
675 <td '.$rowspan.'colspan="2" valign="top" width="20" style="background:url('.$this->imgroot . 'theme-'.$inner.'-'.(($wassel) ? '' : 'not').'selected-'.(($issel) ? '' : 'not').'selected.png)">'.
676 '<img src="'.$this->imgroot . 'clear.png" height="2" width="20" alt="" /></td>'.
677 '<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>';
679 // Last graphic on right-side
682 <td '.$rowspan.'valign="top" width="10" style="background:url('.$this->imgroot . 'theme-'.$inner.'-'.(($issel) ? '' : 'not').'selected-end.png)">'.
683 '<img src="'.$this->imgroot . 'clear.png" height="2" width="10" alt="" /></td>';
689 $wassel=($selected==$i-1);
690 $issel=($selected==$i);
691 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
692 // $rowspan=(($issel)?'rowspan="2" ' : '');
694 // Build image between current and prior tab
697 <td '.$rowspan.'colspan="2" valign="top" width="20" style="background:url('.$this->imgroot . 'theme-'.$inner.'-'.(($wassel) ? '' : 'not').'selected-'.(($issel) ? '' : 'not').'selected.png)">'.
698 '<img src="'.$this->imgroot . 'clear.png" height="2" width="20" alt="" /></td>'.
699 '<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>';
706 // Building a bottom row in this table, which will be darker
708 if ($selected == 0) {
710 $end_cols=((count($TABS_DIRS)*3)-3);
711 } elseif ($selected == (count($TABS_DIRS)-1)) {
712 $beg_cols=((count($TABS_DIRS)*3)-3);
715 $beg_cols=($selected*3);
716 $end_cols=(((count($TABS_DIRS)*3)-3)-$beg_cols);
720 $return .= '<td colspan="'.$beg_cols.'" height="1" class="notSelTab"><img src="'.$this->imgroot.'clear.png" height="1" width="10" alt="" /></td>';
722 $return .= '<td colspan="3" height="1" class="selTab"><img src="'.$this->imgroot.'clear.png" height="1" width="10" alt="" /></td>';
724 $return .= '<td colspan="'.$end_cols.'" height="1" class="notSelTab"><img src="'.$this->imgroot.'clear.png" height="1" width="10" alt="" /></td>';
736 function searchBox() {
737 global $words,$forum_id,$group_id,$group_project_id,$atid,$exact,$type_of_search;
739 if(get_magic_quotes_gpc()) {
740 $defaultWords = stripslashes($words);
742 $defaultWords = $words;
746 $defaultWords = htmlspecialchars($defaultWords);
748 // if there is no search currently, set the default
749 if ( ! isset($type_of_search) ) {
754 <form action="/search/" method="get">
755 <table border="0" cellpadding="0" cellspacing="0">
757 <div align="center" class="searchbox">';
759 SEARCH__PARAMETER_GROUP_ID => $group_id,
760 SEARCH__PARAMETER_ARTIFACT_ID => $atid,
761 SEARCH__PARAMETER_FORUM_ID => $forum_id,
762 SEARCH__PARAMETER_GROUP_PROJECT_ID => $group_project_id
765 $searchManager =& getSearchManager();
766 $searchManager->setParametersValues($parameters);
767 $searchEngines =& $searchManager->getAvailableSearchEngines();
769 echo '<select name="type_of_search">';
770 for($i = 0, $max = count($searchEngines); $i < $max; $i++) {
771 $searchEngine =& $searchEngines[$i];
772 echo '<option value="'.$searchEngine->getType().'"'.( $type_of_search == $searchEngine->getType() ? ' selected="selected"' : '' ).'>'.$searchEngine->getLabel($parameters).'</option>'."\n";
774 echo '</select></div>';
778 // <input type="CHECKBOX" name="exact" value="1"'.( $exact ? ' CHECKED' : ' UNCHECKED' ).'> Require All Words';
780 print '</td><td> ';
781 $parameters = $searchManager->getParameters();
782 foreach($parameters AS $name => $value) {
783 print '<input type="hidden" value="'.$value.'" name="'.$name.'" />';
786 print '<input type="text" size="12" name="words" value="'.$defaultWords.'" />';
788 print '</td><td> </td><td>';
789 print '<input type="submit" name="Search" value="'._('Search').'" />';
792 if (isset($group_id) && $group_id) {
794 <td width="10"> </td>
795 <td>'.util_make_link ('/search/advanced_search.php?group_id='.$group_id,_('Advanced search'),array('class'=>'lnkutility')).'</td>';
797 print '</tr></table>';
802 function advancedSearchBox($sectionsArray, $group_id, $words, $isExact) {
803 // display the searchmask
805 <form name="advancedsearch" action="'.getStringFromServer('PHP_SELF').'" method="post">
806 <input type="hidden" name="search" value="1"/>
807 <input type="hidden" name="group_id" value="'.$group_id.'"/>
808 <div align="center"><br />
812 <input type="text" size="60" name="words" value="'.stripslashes(htmlspecialchars($words)).'" />
813 <input type="submit" name="submitbutton" value="'._('Search').'" />
818 <input type="radio" name="mode" value="'.SEARCH__MODE_AND.'" '.($isExact ? 'checked="checked"' : '').' />'._('with all words').'
821 <input type="radio" name="mode" value="'.SEARCH__MODE_OR.'" '.(!$isExact ? 'checked="checked"' : '').' />'._('with one word').'
824 </table><br /></div>'
825 .$this->createUnderSections($sectionsArray).'
829 //create javascript methods for select none/all
831 <script type="text/javascript">
832 <!-- method for disable/enable checkboxes
833 function setCheckBoxes(parent, checked) {
836 for (var i = 0; i < document.advancedsearch.elements.length; i++)
837 if (document.advancedsearch.elements[i].type == "checkbox")
838 if (document.advancedsearch.elements[i].name.substr(0, parent.length) == parent)
839 document.advancedsearch.elements[i].checked = checked;
847 function createUnderSections($sectionsArray) {
849 foreach ($sectionsArray as $section) {
850 if(is_array($section)) {
851 $countLines += (3 + count ($section));
853 //2 lines one for section name and one for checkbox
857 $breakLimit = round($countLines/3);
858 $break = $breakLimit;
861 <table width="100%" border="0" cellspacing="0" cellpadding="1">
862 <tr class="tableheader">
864 <table width="100%" cellspacing="0" border="0">
865 <tr class="tablecontent">
866 <!--<td colspan="2">'._('Search in').':</td-->
867 <td align="right">'._('Select').' <a href="javascript:setCheckBoxes(\'\', true)">'._('all').'</a> / <a href="javascript:setCheckBoxes(\'\', false)">'._('none').'</a></td>
869 <tr height="20" class="tablecontent">
870 <td colspan="3"> </td>
872 <tr align="center" valign="top" class="tablecontent">
874 foreach($sectionsArray as $key => $section) {
875 $oldcountlines = $countLines;
876 if (is_array($section)) {
877 $countLines += (3 + count ($section));
882 if ($countLines >= $break) {
883 //if the next block is so large that shifting it to the next column hits the breakpoint better
884 //the second part of statement (behind &&) proofs, that no 4th column is added
885 if ((($countLines - $break) >= ($break - $countLines)) && ((($break + $breakLimit)/$breakLimit) <= 3)) {
886 $return .= '</td><td>';
887 $break += $breakLimit;
891 $return .= '<table width="90%" border="0" cellpadding="1" cellspacing="0">
892 <tr><td><table width="100%" border="0" cellspacing="0" cellpadding="3">
895 <a href="#'.$key.'">'.$group_subsection_names[$key].'</a>'
898 ._('Select').' <a href="javascript:setCheckBoxes(\''.$key.'\', true)">'._('all').'</a> / <a href="javascript:setCheckBoxes(\''.$key.'\', false)">'._('none').'</a>
901 <tr class="tablecontent">
904 if (!is_array($section)) {
905 $return .= ' <input type="checkbox" name="'.urlencode($key).'"';
906 if (isset($GLOBALS[urlencode($key)]))
907 $return .= ' checked="checked" ';
908 $return .= ' /></input>'.$group_subsection_names[$key].'<br />';
911 foreach($section as $underkey => $undersection) {
912 $return .= ' <input type="checkbox" name="'.urlencode($key.$underkey).'"';
913 if (isset($GLOBALS[urlencode($key.$underkey)]))
914 $return .= ' checked ';
915 $return .= '></input>'.$undersection.'<br />';
921 </table></td></tr></table><br />';
923 if ($countLines >= $break) {
924 if (($countLines - $break) < ($break - $countLines)) {
925 $return .= '</td><td width="33%">';
926 $break += $breakLimit;
931 return $return.' </td>
933 </table></td></tr></table>';
937 * beginSubMenu() - Opening a submenu.
939 * @return string Html to start a submenu.
941 function beginSubMenu () {
948 * endSubMenu() - Closing a submenu.
950 * @return string Html to end a submenu.
952 function endSubMenu () {
953 $return = '</strong></p>';
958 * printSubMenu() - Takes two array of titles and links and builds the contents of a menu.
960 * @param array The array of titles.
961 * @param array The array of title links.
962 * @return string Html to build a submenu.
964 function printSubMenu ($title_arr,$links_arr) {
965 $count=count($title_arr);
969 for ($i=0; $i<$count; $i++) {
970 $return .= util_make_link ($links_arr[$i],$title_arr[$i]).' | ';
972 $return .= util_make_link ($links_arr[$i],$title_arr[$i]);
977 * subMenu() - Takes two array of titles and links and build a menu.
979 * @param array The array of titles.
980 * @param array The array of title links.
981 * @return string Html to build a submenu.
983 function subMenu ($title_arr,$links_arr) {
984 $return = $this->beginSubMenu () ;
985 $return .= $this->printSubMenu ($title_arr,$links_arr) ;
986 $return .= $this->endSubMenu () ;
991 * multiTableRow() - create a mutlilevel row in a table
993 * @param string the row attributes
994 * @param array the array of cell data, each element is an array,
995 * the first item being the text,
996 * the subsequent items are attributes (dont include
997 * the bgcolor for the title here, that will be
998 * handled by $istitle
999 * @param boolean is this row part of the title ?
1002 function multiTableRow($row_attr, $cell_data, $istitle) {
1006 $return .=' align="center" class="multiTableRowTitle"';
1009 for ( $c = 0; $c < count($cell_data); $c++ ) {
1011 for ( $a=1; $a < count($cell_data[$c]); $a++) {
1012 $return .= $cell_data[$c][$a].' ';
1016 $return .='<span class="multiTableRowTitle">';
1018 $return .= $cell_data[$c][0];
1020 $return .='</span>';
1032 * feedback() - returns the htmlized feedback string when an action is performed.
1034 * @param string feedback string
1035 * @return string htmlized feedback
1037 function feedback($feedback) {
1042 <span class="feedback">'.strip_tags($feedback, '<br>').'</span>';
1047 * getThemeIdFromName()
1049 * @param string the dirname of the theme
1050 * @return integer the theme id
1052 function getThemeIdFromName($dirname) {
1053 $res=db_query("SELECT theme_id FROM themes WHERE dirname='$dirname'");
1054 return db_result($res,0,'theme_id');
1057 function quickNav() {
1058 if (!session_loggedin()) {
1061 $res=db_query("SELECT * FROM groups NATURAL JOIN user_group WHERE user_id='".user_getid()."' ORDER BY group_name");
1063 if (!$res || db_numrows($res) < 1) {
1067 <form name="quicknavform">
1068 <select name="quicknav" onChange="location.href=document.quicknavform.quicknav.value">';
1070 <option value="">Quick Jump To...</option>';
1071 for ($i=0; $i<db_numrows($res); $i++) {
1073 <option value="/projects/'.db_result($res,$i,'unix_group_name').'/">'.db_result($res,$i,'group_name').'</option>';
1074 if (trim(db_result($res,$i,'admin_flags'))=='A') {
1076 <option value="/project/admin/?group_id='.db_result($res,$i,'group_id').'"> Admin</option>';
1079 if (db_result($res,$i,'use_tracker')) {
1081 <option value="/tracker/?group_id='.db_result($res,$i,'group_id').'"> Tracker</option>';
1082 if (db_result($res,$i,'admin_flags') || db_result($res,$i,'tracker_flags')) {
1084 <option value="/tracker/admin/?group_id='.db_result($res,$i,'group_id').'"> Admin</option>';
1088 if (db_result($res,$i,'use_pm')) {
1090 <option value="/pm/?group_id='.db_result($res,$i,'group_id').'"> Task Manager</option>';
1091 if (trim(db_result($res,$i,'admin_flags')) =='A' || db_result($res,$i,'project_flags')) {
1093 <option value="/pm/admin/?group_id='.db_result($res,$i,'group_id').'"> Admin</option>';
1097 if (db_result($res,$i,'use_frs')) {
1099 <option value="/frs/?group_id='.db_result($res,$i,'group_id').'"> Files</option>';
1100 if (trim(db_result($res,$i,'admin_flags'))=='A' || db_result($res,$i,'release_flags')) {
1102 <option value="/frs/admin/?group_id='.db_result($res,$i,'group_id').'"> Admin</option>';
1106 if (db_result($res,$i,'use_scm')) {
1108 <option value="/scm/?group_id='.db_result($res,$i,'group_id').'"> SCM</option>';
1109 /*if (db_result($res,$i,'admin_flags') || db_result($res,$i,'project_flags')) {
1111 <option value="/pm/admin/?group_id='.db_result($res,$i,'group_id').'"> Admin</option>';
1115 if (db_result($res,$i,'use_forum')) {
1117 <option value="/forum/?group_id='.db_result($res,$i,'group_id').'"> Forum</option>';
1118 if (trim(db_result($res,$i,'admin_flags'))=='A' || db_result($res,$i,'forum_flags')) {
1120 <option value="/forum/admin/?group_id='.db_result($res,$i,'group_id').'"> Admin</option>';
1124 if (db_result($res,$i,'use_mail')) {
1126 <option value="/mail/?group_id='.db_result($res,$i,'group_id').'"> Lists</option>';
1127 if (trim(db_result($res,$i,'admin_flags'))=='A') {
1129 <option value="/mail/admin/?group_id='.db_result($res,$i,'group_id').'"> Admin</option>';
1133 if (db_result($res,$i,'use_docman')) {
1135 <option value="/docman/?group_id='.db_result($res,$i,'group_id').'"> Docs</option>';
1136 if (trim(db_result($res,$i,'admin_flags'))=='A' || db_result($res,$i,'doc_flags')) {
1138 <option value="/docman/admin/?group_id='.db_result($res,$i,'group_id').'"> Admin</option>';
1142 if (db_result($res,$i,'use_news')) {
1144 <option value="/news/?group_id='.db_result($res,$i,'group_id').'"> News</option>';
1145 if (trim(db_result($res,$i,'admin_flags'))=='A') {
1147 <option value="/news/admin/?group_id='.db_result($res,$i,'group_id').'"> Admin</option>';
1151 if (db_result($res,$i,'use_survey')) {
1153 <option value="/survey/?group_id='.db_result($res,$i,'group_id').'"> Surveys</option>';
1154 if (trim(db_result($res,$i,'admin_flags'))=='A') {
1156 <option value="/survey/admin/?group_id='.db_result($res,$i,'group_id').'"> Admin</option>';
1172 // c-file-style: "bsd"