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
12 * Geoffrey Herteg, August 29, 2000
16 require_once $gfcommon.'include/constants.php';
17 require_once $gfwww.'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
44 // determine rootindex
45 if ( file_exists($GLOBALS['sys_custom_path'] . '/index_std.php') )
46 $this->rootindex = $GLOBALS['sys_custom_path'] . '/index_std.php';
48 $this->rootindex = $GLOBALS['gfwww'].'index_std.php';
50 // determine themeroot
51 $this->themeroot = $GLOBALS['sys_themeroot'].$GLOBALS['sys_theme'];
52 /* if images directory exists in theme, then use it as imgroot */
53 if (file_exists ($this->themeroot.'/images')){
54 $this->imgroot = util_make_url ('/themes/'.$GLOBALS['sys_theme'].'/images/');
61 * headerLink() - common code for all themes
64 function headerLink() {
65 echo '<link rel="alternate" title="'.$GLOBALS['sys_name'].' - Project News Highlights RSS" href="'.util_make_url ('/export/rss_sfnews.php').'" type="application/rss+xml"/>';
66 echo '<link rel="alternate" title="'.$GLOBALS['sys_name'].' - Project News Highlights RSS 2.0" href="'.util_make_url ('/export/rss20_news.php').'" type="application/rss+xml"/>';
67 echo '<link rel="alternate" title="'.$GLOBALS['sys_name'].' - New Projects RSS" href="'.util_make_url ('/export/rss_sfprojects.php').'" type="application/rss+xml"/>';
68 echo '<link rel="search" title="'.$GLOBALS['sys_name'].'" href="'.util_make_url ('/export/search_plugin.php').'" type="application/opensearchdescription+xml"/>';
72 * headerStart() - common code for all themes
74 * @param array Header parameters array
76 function headerStart($params) {
77 if (!$params['title']) {
78 $params['title'] = $GLOBALS['sys_name'];
80 $params['title'] = $GLOBALS['sys_name'] . ': ' . $params['title'];
82 print '<?xml version="1.0" encoding="utf-8"';
86 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
87 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
89 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo _('en') ?>" lang="<?php echo _('en') ?>">
92 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
93 <title><?php echo $params['title']; ?></title>
94 <?php $this->headerLink(); ?>
96 <?php if (isset($GLOBALS['group_id'])) {
97 $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"/>';
101 <?php $this->headerCSS(); ?>
103 <script language="JavaScript" type="text/javascript">
106 function admin_window(adminurl) {
107 AdminWin = window.open( adminurl, 'AdminWindow','scrollbars=yes,resizable=yes, toolbar=yes, height=400, width=400, top=2, left=2');
110 function help_window(helpurl) {
111 HelpWin = window.open( helpurl,'HelpWindow','scrollbars=yes,resizable=yes,toolbar=no,height=400,width=400');
114 <?php plugin_hook ("javascript",false) ; ?>
120 function headerCSS() {
121 /* check if a personalized css stylesheet exist, if yes include only
123 new stylesheets should use the <themename>.css file
125 $theme_cssfile = $this->themeroot . '/css/'.$GLOBALS['sys_theme'].'.css';
126 if (file_exists($theme_cssfile)){
128 <link rel="stylesheet" type="text/css" href="'.util_make_url ('/themes/'.$GLOBALS['sys_theme'].'/css/'.$GLOBALS['sys_theme'].'.css').'"/>';
130 /* if this is not our case, then include the compatibility stylesheet
131 that contains all removed styles from the code and check if a
132 custom stylesheet exists.
133 Used for compatibility with existing stylesheets
136 <link rel="stylesheet" type="text/css" href="'.util_make_url ('/themes/css/gforge-compat.css').'" />';
137 $theme_cssfile = $this->themeroot . '/css/theme.css';
138 if (file_exists($theme_cssfile)){
140 <link rel="stylesheet" type="text/css" href="'.util_make_url ('/themes/'.$GLOBALS['sys_theme'].'/css/theme.css').'" />';
143 plugin_hook ('cssfile',$this);
146 function header($params) {
147 $this->headerStart($params); ?>
150 $this->bodyHeader($params);
153 function bodyHeader($params){
156 <table border="0" width="100%" cellspacing="0" cellpadding="0" id="headertable">
159 <td><a href="<?php echo util_make_url ('/'); ?>"><?php echo html_image('logo.png',198,52,array('border'=>'0')); ?></a></td>
160 <td><?php echo $this->searchBox(); ?></td>
161 <td align="right"><?php
162 if (session_loggedin()) {
163 $u =& user_get_object(user_getid());
164 echo util_make_link ('/account/logout.php', sprintf("%s (%s)", _('Log Out'), $u->getRealName()),array('class'=>'lnkutility'));
165 echo util_make_link ('/account/',_('My Account'),array('class'=>'lnkutility'));
167 echo util_make_link ('/account/login.php',_('Log In'),array('class'=>'lnkutility'));
168 if (!$GLOBALS['sys_user_reg_restricted']) {
169 echo util_make_link ('/account/register.php',_('New Account'),array('class'=>'lnkutility'));
173 $params['template'] = ' {menu}';
174 plugin_hook ('headermenu', $params);
176 echo $this->quickNav();
179 <td> </td>
184 <table border="0" width="100%" cellspacing="0" cellpadding="0">
190 <?php echo $this->outerTabs($params); ?>
197 <td align="left" class="toptab" width="9"><img src="<?php echo $this->imgroot; ?>tabs/topleft.png" height="9" width="9" alt="" /></td>
198 <td class="toptab" width="30"><img src="<?php echo $this->imgroot; ?>clear.png" width="30" height="1" alt="" /></td>
199 <td class="toptab"><img src="<?php echo $this->imgroot; ?>clear.png" width="1" height="1" alt="" /></td>
200 <td class="toptab" width="30"><img src="<?php echo $this->imgroot; ?>clear.png" width="30" height="1" alt="" /></td>
201 <td align="right" class="toptab" width="9"><img src="<?php echo $this->imgroot; ?>tabs/topright.png" height="9" width="9" alt="" /></td>
206 <!-- Outer body row -->
208 <td class="toptab"><img src="<?php echo $this->imgroot; ?>clear.png" width="10" height="1" alt="" /></td>
209 <td valign="top" width="99%" class="toptab" colspan="3">
211 <!-- Inner Tabs / Shell -->
213 <table border="0" width="100%" cellspacing="0" cellpadding="0">
217 if (isset($params['group']) && $params['group']) {
225 echo $this->projectTabs($params['toptab'],$params['group']);
235 <td align="left" class="projecttab" width="9"><img src="<?php echo $this->imgroot; ?>tabs/topleft-inner.png" height="9" width="9" alt="" /></td>
236 <td class="projecttab" ><img src="<?php echo $this->imgroot; ?>clear.png" width="1" height="1" alt="" /></td>
237 <td align="right" class="projecttab" width="9"><img src="<?php echo $this->imgroot; ?>tabs/topright-inner.png" height="9" width="9" alt="" /></td>
241 <td class="projecttab" ><img src="<?php echo $this->imgroot; ?>clear.png" width="10" height="1" alt="" /></td>
242 <td valign="top" width="99%" class="projecttab">
248 function footer($params) {
252 <!-- end main body row -->
256 <td width="10" class="footer3" ><img src="<?php echo $this->imgroot; ?>clear.png" width="2" height="1" alt="" /></td>
259 <td align="left" class="footer1" width="9"><img src="<?php echo $this->imgroot; ?>tabs/bottomleft-inner.png" height="11" width="11" alt="" /></td>
260 <td class="footer3"><img src="<?php echo $this->imgroot; ?>clear.png" width="1" height="1" alt="" /></td>
261 <td align="right" class="footer1" width="9"><img src="<?php echo $this->imgroot; ?>tabs/bottomright-inner.png" height="11" width="11" alt="" /></td>
265 <!-- end inner body row -->
268 <td width="10" class="footer2"><img src="<?php echo $this->imgroot; ?>clear.png" width="2" height="1" alt="" /></td>
271 <td align="left" class="footer2" width="9"><img src="<?php echo $this->imgroot; ?>tabs/bottomleft.png" height="9" width="9" alt="" /></td>
272 <td class="footer2" colspan="3"><img src="<?php echo $this->imgroot; ?>clear.png" width="1" height="1" alt="" /></td>
273 <td align="right" class="footer2" width="9"><img src="<?php echo $this->imgroot; ?>tabs/bottomright.png" height="9" width="9" alt="" /></td>
277 $this->footerEnd($params);
280 function footerEnd($params) { ?>
282 <!-- PLEASE LEAVE "Powered By FusionForge" on your site -->
284 <a href="http://fusionforge.org/"><img src="<?php echo util_make_url ('/images/pow-fusionforge.png'); ?>" alt="Powered By FusionForge" border="0" /></a>
288 global $sys_show_source;
289 if ($sys_show_source) {
290 echo util_make_link ('/source.php?file='.getStringFromServer('SCRIPT_NAME'),_('Show source'),array('class'=>'showsource'));
301 function getRootIndex() {
302 return $this->rootindex;
306 * boxTop() - Top HTML box
308 * @param string Box title
309 * @param bool Whether to echo or return the results
310 * @param string The box background color
312 function boxTop($title) {
314 <!-- Box Top Start -->
316 <table cellspacing="0" cellpadding="0" width="100%" border="0" style="background:url('.$this->imgroot.'vert-grad.png)">
317 <tr class="align-center">
318 <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>
319 <td width="100%" style="background:url('.$this->imgroot.'box-grad.png)"><span class="titlebar">'.$title.'</span></td>
320 <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>
324 <table cellspacing="2" cellpadding="2" width="100%" border="0">
328 <!-- Box Top End -->';
332 * boxMiddle() - Middle HTML box
334 * @param string Box title
335 * @param string The box background color
337 function boxMiddle($title) {
339 <!-- Box Middle Start -->
342 <tr class="align-center">
343 <td colspan="2" style="background:url('.$this->imgroot.'box-grad.png)"><span class="titlebar">'.$title.'</span></td>
347 <!-- Box Middle End -->';
351 * boxBottom() - Bottom HTML box
353 * @param bool Whether to echo or return the results
355 function boxBottom() {
357 <!-- Box Bottom Start -->
364 <!-- Box Bottom End -->';
368 * boxGetAltRowStyle() - Get an alternating row style for tables
370 * @param int Row number
372 function boxGetAltRowStyle($i) {
374 return ' class="altRowStyleEven"';
376 return ' class="altRowStyleOdd"';
381 * listTableTop() - Takes an array of titles and builds the first row of a new table.
383 * @param array The array of titles
384 * @param array The array of title links
386 function listTableTop ($title_arr,$links_arr=false,$selected=false) {
388 <table cellspacing="0" cellpadding="0" width="100%" border="0">
389 <tr class="align-center">
390 <!-- <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> -->
391 <td style="background:url('.$this->imgroot.'box-grad.png)">
392 <table width="100%" border="0" cellspacing="1" cellpadding="2" >
393 <tr class="tableheading">';
394 $count=count($title_arr);
396 for ($i=0; $i<$count; $i++) {
397 $return .= '<td>'.util_make_link ($links_arr[$i],$title_arr[$i],array('class'=>'sortbutton')).'</td>';
400 for ($i=0; $i<$count; $i++) {
402 <td>'.$title_arr[$i].'</td>';
405 return $return.'</tr>';
408 function listTableBottom() {
409 return '</table></td>
410 <!-- <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> -->
414 function outerTabs($params) {
415 global $sys_use_trove,$sys_use_snippet,$sys_use_people,$sys_use_project_tags, $sys_use_project_full_list;
417 $TABS_DIRS[]=util_make_url ('/');
418 $TABS_DIRS[]=util_make_url ('/my/');
419 if ($sys_use_trove || $sys_use_project_tags || $sys_use_project_full_list) {
420 $TABS_DIRS[]=util_make_url ('/softwaremap/') ;
422 if ($sys_use_snippet) {
423 $TABS_DIRS[]=util_make_url ('/snippet/') ;
425 if ($sys_use_people) {
426 $TABS_DIRS[]=util_make_url ('/people/') ;
428 $TABS_TITLES[]=_('Home');
429 $TABS_TITLES[]=_('My Page');
430 if ($sys_use_trove || $sys_use_project_tags || $sys_use_project_full_list) {
431 $TABS_TITLES[]=_('Projects');
433 if ($sys_use_snippet) {
434 $TABS_TITLES[]=_('Code Snippets');
436 if ($sys_use_people) {
437 $TABS_TITLES[]=_('Project Openings');
441 $PLUGIN_TABS_DIRS = Array();
442 $hookParams['DIRS'] = &$PLUGIN_TABS_DIRS;
443 $hookParams['TITLES'] = &$TABS_TITLES;
444 plugin_hook ("outermenu", $hookParams) ;
445 $TABS_DIRS = array_merge($TABS_DIRS, $PLUGIN_TABS_DIRS);
447 $user_is_super=false;
448 if (session_loggedin()) {
449 $projectmaster =& group_get_object(GROUP_IS_MASTER);
450 $projectstats =& group_get_object(GROUP_IS_STATS);
451 $permmaster =& $projectmaster->getPermission( session_get_user() );
452 $permstats =& $projectstats->getPermission( session_get_user() );
454 if ($permmaster->isAdmin()) {
456 $TABS_DIRS[]=util_make_url ('/admin/') ;
457 $TABS_TITLES[]=_('Admin');
459 if ($permstats->isMember()) {
460 $TABS_DIRS[]=util_make_url ('/reporting/') ;
461 $TABS_TITLES[]=_('Reporting');
464 if(isset($params['group']) && $params['group']) {
465 // get group info using the common result set
466 $project =& group_get_object($params['group']);
467 if ($project && is_object($project)) {
468 if ($project->isError()) {
470 } elseif (!$project->isProject()) {
473 if (isset ($GLOBALS['sys_noforcetype']) && $GLOBALS['sys_noforcetype']) {
474 $TABS_DIRS[]=util_make_url ('/project/?group_id') .$project->getId();
476 $TABS_DIRS[]=util_make_url ('/projects/') .$project->getUnixName().'/';
478 $TABS_TITLES[]=$project->getPublicName();
479 $selected=count($TABS_DIRS)-1;
482 } elseif (strstr(getStringFromServer('REQUEST_URI'),util_make_uri ('/my/') ) ||
483 strstr(getStringFromServer('REQUEST_URI'),util_make_uri ('/account/') ) ||
484 strstr(getStringFromServer('REQUEST_URI'),util_make_uri ('/register/') ) ||
485 strstr(getStringFromServer('REQUEST_URI'),util_make_uri ('/themes/') ) ) {
486 $selected=array_search(util_make_url ('/my/'), $TABS_DIRS);
487 } elseif (strstr(getStringFromServer('REQUEST_URI'),util_make_uri ('softwaremap') )) {
488 $selected=array_search(util_make_url ('/softwaremap/'), $TABS_DIRS);
489 } elseif (strstr(getStringFromServer('REQUEST_URI'),util_make_uri ('/snippet/') )) {
490 $selected=array_search(util_make_url ('/snippet/'), $TABS_DIRS);
491 } elseif (strstr(getStringFromServer('REQUEST_URI'),util_make_uri ('/people/') )) {
492 $selected=array_search(util_make_url ('/people/'), $TABS_DIRS);
493 } elseif (strstr(getStringFromServer('REQUEST_URI'),util_make_uri ('/reporting/') )) {
494 $selected=array_search(util_make_url ('/reporting/'),$TABS_DIRS);
495 } elseif (strstr(getStringFromServer('REQUEST_URI'),util_make_uri ('/admin/') ) && $user_is_super) {
496 $selected=array_search(util_make_url ('/admin/'),$TABS_DIRS);
497 } elseif (count($PLUGIN_TABS_DIRS)>0) {
498 foreach ($PLUGIN_TABS_DIRS as $PLUGIN_TABS_DIRS_VALUE) {
499 if (strstr(getStringFromServer('REQUEST_URI'), parse_url ($PLUGIN_TABS_DIRS_VALUE, PHP_URL_PATH))) {
500 $selected=array_search($PLUGIN_TABS_DIRS_VALUE, $TABS_DIRS);
507 echo $this->tabGenerator($TABS_DIRS, $TABS_TITLES, false, $selected, '');
512 * quicknav() - Prints out the quicknav menu, contained
513 * here in case we want to allow it to be
517 function quickNav() {
518 if (!session_loggedin()) {
521 // get all projects that the user belongs to
522 $res = db_query_params ('SELECT group_id FROM groups JOIN user_group USING (group_id) WHERE user_group.user_id=$1 AND groups.status=$2 ORDER BY group_name',
526 if (!$res || db_numrows($res) < 1) {
530 <form id="quicknavform" name="quicknavform" action=""><div>
531 <select name="quicknav" id="quicknav" onChange="location.href=document.quicknavform.quicknav.value">
532 <option value="">'._('Quick Jump To...').'</option>';
534 for ($i = 0; $i < db_numrows($res); $i++) {
535 $group_id = db_result($res, $i, 'group_id');
536 $project =& group_get_object($group_id);
537 if (!$project || !is_object($project)) {
540 if ($project->isError()) {
541 //wasn't found or some other problem
544 if (!$project->isProject()) {
548 $menu = $project->getMenu();
550 <option value="' . $menu['start'] . '">'
551 . $project->getPublicName() .'</option>';
553 for ($j = 0; $j < count($menu['dirs']); $j++) {
555 <option value="' . $menu['dirs'][$j] .'"> '
556 . $menu['titles'][$j] . '</option>';
557 if ($menu['admindirs'][$j]) {
559 <option value="' . $menu['admindirs'][$j]
560 . '"> '
561 . _('Admin') . '</option>';
574 * projectTabs() - Prints out the project tabs, contained here in case
575 * we want to allow it to be overriden
577 * @param string Is the tab currently selected
578 * @param string Is the group we should look up get title info
580 function projectTabs($toptab, $group) {
581 // get group info using the common result set
582 $project =& group_get_object($group);
583 if (!$project || !is_object($project)) {
586 if ($project->isError()) {
587 //wasn't found or some other problem
590 if (!$project->isProject()) {
594 $menu = $project->getMenu($toptab);
596 echo $this->tabGenerator($menu['dirs'], $menu['titles'], true, $menu['selected'], 'white');
599 function tabGenerator($TABS_DIRS,$TABS_TITLES,$nested=false,$selected=false,$sel_tab_bgcolor='white',$total_width='100%') {
601 $count=count($TABS_DIRS);
602 $width=intval((100/$count));
607 <table class="tabGenerator" ';
609 if ($total_width != '100%') {
610 $return .= 'style="width:' . $total_width . ';"';
620 for ($i=0; $i<$count; $i++) {
623 // this is the first tab, choose an image with end-name
626 $issel=($selected==$i);
627 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
628 // $rowspan=(($issel)?'rowspan="2" ' : '');
631 <td '.$rowspan.'valign="top" width="10" style="background:url('.$this->imgroot . 'theme-'.$inner.'-end-'.(($issel) ? '' : 'not').'selected.png)">'.
632 '<img src="'.$this->imgroot . 'clear.png" height="25" width="10" alt="" /></td>'.
633 '<td '.$rowspan.'style="background:url('.$this->imgroot . $bgimg.')" width="'.$width.'%" align="center">'.util_make_link ($TABS_DIRS[$i],$TABS_TITLES[$i],array('class'=>(($issel)?'tabsellink':'tablink')),true).'</td>';
634 } elseif ($i==$count-1) {
636 // this is the last tab, choose an image with name-end
638 $wassel=($selected==$i-1);
639 $issel=($selected==$i);
640 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
641 // $rowspan=(($issel)?'rowspan="2" ' : '');
643 // Build image between current and prior tab
646 <td '.$rowspan.'colspan="2" valign="top" width="20" style="background:url('.$this->imgroot . 'theme-'.$inner.'-'.(($wassel) ? '' : 'not').'selected-'.(($issel) ? '' : 'not').'selected.png)">'.
647 '<img src="'.$this->imgroot . 'clear.png" height="2" width="20" alt="" /></td>'.
648 '<td '.$rowspan.'style="background:url('.$this->imgroot . $bgimg.')" width="'.$width.'%" align="center">'.util_make_link ($TABS_DIRS[$i],$TABS_TITLES[$i],array('class'=>(($issel)?'tabsellink':'tablink')),true).'</td>';
650 // Last graphic on right-side
653 <td '.$rowspan.'valign="top" width="10" style="background:url('.$this->imgroot . 'theme-'.$inner.'-'.(($issel) ? '' : 'not').'selected-end.png)">'.
654 '<img src="'.$this->imgroot . 'clear.png" height="2" width="10" alt="" /></td>';
660 $wassel=($selected==$i-1);
661 $issel=($selected==$i);
662 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
663 // $rowspan=(($issel)?'rowspan="2" ' : '');
665 // Build image between current and prior tab
668 <td '.$rowspan.'colspan="2" valign="top" width="20" style="background:url('.$this->imgroot . 'theme-'.$inner.'-'.(($wassel) ? '' : 'not').'selected-'.(($issel) ? '' : 'not').'selected.png)">'.
669 '<img src="'.$this->imgroot . 'clear.png" height="2" width="20" alt="" /></td>'.
670 '<td '.$rowspan.'style="background:url('.$this->imgroot . $bgimg.')" width="'.$width.'%" align="center">'.util_make_link ($TABS_DIRS[$i],$TABS_TITLES[$i],array('class'=>(($issel)?'tabsellink':'tablink')),true).'</td>';
677 // Building a bottom row in this table, which will be darker
679 if ($selected == 0) {
681 $end_cols=((count($TABS_DIRS)*3)-3);
682 } elseif ($selected == (count($TABS_DIRS)-1)) {
683 $beg_cols=((count($TABS_DIRS)*3)-3);
686 $beg_cols=($selected*3);
687 $end_cols=(((count($TABS_DIRS)*3)-3)-$beg_cols);
691 $return .= '<td colspan="'.$beg_cols.'" height="1" class="notSelTab"><img src="'.$this->imgroot.'clear.png" height="1" width="10" alt="" /></td>';
693 $return .= '<td colspan="3" height="1" class="selTab"><img src="'.$this->imgroot.'clear.png" height="1" width="10" alt="" /></td>';
695 $return .= '<td colspan="'.$end_cols.'" height="1" class="notSelTab"><img src="'.$this->imgroot.'clear.png" height="1" width="10" alt="" /></td>';
707 function searchBox() {
708 global $words,$forum_id,$group_id,$group_project_id,$atid,$exact,$type_of_search;
710 if(get_magic_quotes_gpc()) {
711 $defaultWords = stripslashes($words);
713 $defaultWords = $words;
717 $defaultWords = htmlspecialchars($defaultWords);
719 // if there is no search currently, set the default
720 if ( ! isset($type_of_search) ) {
724 print '<form action="/search/" method="get" id="search-box-form">';
725 print '<div class="searchbox">';
727 SEARCH__PARAMETER_GROUP_ID => $group_id,
728 SEARCH__PARAMETER_ARTIFACT_ID => $atid,
729 SEARCH__PARAMETER_FORUM_ID => $forum_id,
730 SEARCH__PARAMETER_GROUP_PROJECT_ID => $group_project_id
733 $searchManager =& getSearchManager();
734 $searchManager->setParametersValues($parameters);
735 $searchEngines =& $searchManager->getAvailableSearchEngines();
737 echo '<select name="type_of_search">';
738 for($i = 0, $max = count($searchEngines); $i < $max; $i++) {
739 $searchEngine =& $searchEngines[$i];
740 echo '<option value="'.$searchEngine->getType().'"'.( $type_of_search == $searchEngine->getType() ? ' selected="selected"' : '' ).'>'.$searchEngine->getLabel($parameters).'</option>'."\n";
744 $parameters = $searchManager->getParameters();
745 foreach($parameters AS $name => $value) {
746 print '<input type="hidden" value="'.$value.'" name="'.$name.'" id="'.$name.'"/>';
748 print '<label for="search-words" class="skip">' . html_image('pixel-transparent.gif', 1, 1, array('alt' => "")) . '</label>';
749 print '<input type="text" name="words" size="12" id="search-words" value="'.$defaultWords.'" />';
751 print '<label for="search-submit" class="skip">' . html_image('pixel-transparent.gif', 1, 1, array('alt' => "")) . '</label>';
752 print '<input type="image" name="Search" id="search-submit" src="/themes/adullact-v3/image/picto_bleu_loupe.png" alt="'._('Search').'" title="'._('Search').'" />';
754 if (isset($group_id) && $group_id) {
755 $link_content = html_image('picto_remarques.png','21','21',array('alt'=>_('Advanced search'), 'title'=>_('Advanced search')));
756 print ' '.util_make_link ('/search/advanced_search.php?group_id='.$group_id, $link_content, array('class'=>'lnkutility', 'id'=>'advanced-search'));
762 function advancedSearchBox($sectionsArray, $group_id, $words, $isExact) {
763 // display the searchmask
765 <form name="advancedsearch" action="'.getStringFromServer('PHP_SELF').'" method="post">
766 <input type="hidden" name="search" value="1"/>
767 <input type="hidden" name="group_id" value="'.$group_id.'"/>
768 <div class="align-center"><br />
772 <input type="text" size="60" name="words" value="'.stripslashes(htmlspecialchars($words)).'" />
773 <input type="submit" name="submitbutton" value="'._('Search').'" />
778 <input type="radio" name="mode" value="'.SEARCH__MODE_AND.'" '.($isExact ? 'checked="checked"' : '').' />'._('with all words').'
781 <input type="radio" name="mode" value="'.SEARCH__MODE_OR.'" '.(!$isExact ? 'checked="checked"' : '').' />'._('with one word').'
784 </table><br /></div>'
785 .$this->createUnderSections($sectionsArray).'
789 //create javascript methods for select none/all
791 <script type="text/javascript">
792 <!-- method for disable/enable checkboxes
793 function setCheckBoxes(parent, checked) {
796 for (var i = 0; i < document.advancedsearch.elements.length; i++)
797 if (document.advancedsearch.elements[i].type == "checkbox")
798 if (document.advancedsearch.elements[i].name.substr(0, parent.length) == parent)
799 document.advancedsearch.elements[i].checked = checked;
807 function createUnderSections($sectionsArray) {
808 global $group_subsection_names;
811 foreach ($sectionsArray as $section) {
812 if(is_array($section)) {
813 $countLines += (3 + count ($section));
815 //2 lines one for section name and one for checkbox
821 $breakLimit = ceil($countLines/$maxCol);
822 $break = $breakLimit;
827 <table width="100%" border="0" cellspacing="0" cellpadding="1">
828 <tr class="tableheader">
830 <table width="100%" cellspacing="0" border="0">
831 <tr class="tablecontent">
832 <!--<td colspan="2">'._('Search in').':</td-->
833 <td align="right">'._('Select').' <a href="javascript:setCheckBoxes(\'\', true)">'._('all').'</a> / <a href="javascript:setCheckBoxes(\'\', false)">'._('none').'</a></td>
835 <tr class="tablecontent">
836 <td colspan="3"> </td>
838 <tr valign="top" class="tablecontent align-center">
840 foreach($sectionsArray as $key => $section) {
841 $oldcountlines = $countLines;
842 if (is_array($section)) {
843 $countLines += (3 + count ($section));
848 if ($countLines >= $break) {
849 // if we are closer to the limit with this one included, then
850 // it's better to include it.
851 if (($countCol < $maxCol) && ($countLines - $break) >= ($break - $oldcountlines)) {
852 $return .= '</td><td>';
854 $break += $breakLimit;
858 $return .= '<table width="90%" border="0" cellpadding="1" cellspacing="0">
859 <tr><td><table width="100%" border="0" cellspacing="0" cellpadding="3">
862 <a href="#'.$key.'">'.$group_subsection_names[$key].'</a>'
865 ._('Select').' <a href="javascript:setCheckBoxes(\''.$key.'\', true)">'._('all').'</a> / <a href="javascript:setCheckBoxes(\''.$key.'\', false)">'._('none').'</a>
868 <tr class="tablecontent">
871 if (!is_array($section)) {
872 $return .= ' <input type="checkbox" name="'.urlencode($key).'"';
873 if (isset($GLOBALS[urlencode($key)]))
874 $return .= ' checked="checked" ';
875 $return .= ' /></input>'.$group_subsection_names[$key].'<br />';
878 foreach($section as $underkey => $undersection) {
879 $return .= ' <input type="checkbox" name="'.urlencode($key.$underkey).'"';
880 if (isset($GLOBALS[urlencode($key.$underkey)]))
881 $return .= ' checked="checked" ';
882 $return .= ' />'.$undersection.'<br />';
888 </table></td></tr></table><br />';
890 if ($countLines >= $break) {
891 if (($countLines - $break) < ($break - $countLines)) {
892 $return .= '</td><td width="33%">';
893 $break += $breakLimit;
898 return $return.' </td>
900 </table></td></tr></table>';
904 * beginSubMenu() - Opening a submenu.
906 * @return string Html to start a submenu.
908 function beginSubMenu () {
915 * endSubMenu() - Closing a submenu.
917 * @return string Html to end a submenu.
919 function endSubMenu () {
920 $return = '</strong></p>';
925 * printSubMenu() - Takes two array of titles and links and builds the contents of a menu.
927 * @param array The array of titles.
928 * @param array The array of title links.
929 * @return string Html to build a submenu.
931 function printSubMenu ($title_arr,$links_arr) {
932 $count=count($title_arr);
936 for ($i=0; $i<$count; $i++) {
937 $return .= util_make_link ($links_arr[$i],$title_arr[$i]).' | ';
939 $return .= util_make_link ($links_arr[$i],$title_arr[$i]);
944 * subMenu() - Takes two array of titles and links and build a menu.
946 * @param array The array of titles.
947 * @param array The array of title links.
948 * @return string Html to build a submenu.
950 function subMenu ($title_arr,$links_arr) {
951 $return = $this->beginSubMenu () ;
952 $return .= $this->printSubMenu ($title_arr,$links_arr) ;
953 $return .= $this->endSubMenu () ;
958 * multiTableRow() - create a mutlilevel row in a table
960 * @param string the row attributes
961 * @param array the array of cell data, each element is an array,
962 * the first item being the text,
963 * the subsequent items are attributes (dont include
964 * the bgcolor for the title here, that will be
965 * handled by $istitle
966 * @param boolean is this row part of the title ?
969 function multiTableRow($row_attr, $cell_data, $istitle) {
973 $return .=' class="align-center multiTableRowTitle"';
976 for ( $c = 0; $c < count($cell_data); $c++ ) {
978 for ( $a=1; $a < count($cell_data[$c]); $a++) {
979 $return .= $cell_data[$c][$a].' ';
983 $return .='<span class="multiTableRowTitle">';
985 $return .= $cell_data[$c][0];
999 * feedback() - returns the htmlized feedback string when an action is performed.
1001 * @param string feedback string
1002 * @return string htmlized feedback
1004 function feedback($feedback) {
1009 <div class="feedback">'.strip_tags($feedback, '<br>').'</div>';
1013 * warning_msg() - returns the htmlized warning string when an action is performed.
1015 * @param string msg string
1016 * @return string htmlized warning
1018 function warning_msg($msg) {
1023 <div class="warning_msg">'.strip_tags($msg, '<br>').'</div>';
1028 * error_msg() - returns the htmlized error string when an action is performed.
1030 * @param string msg string
1031 * @return string htmlized error
1033 function error_msg($msg) {
1038 <div class="error">'.strip_tags($msg, '<br>').'</div>';
1044 * getThemeIdFromName()
1046 * @param string the dirname of the theme
1047 * @return integer the theme id
1049 function getThemeIdFromName($dirname) {
1050 $res = db_query_params ('SELECT theme_id FROM themes WHERE dirname=$1',
1052 return db_result($res,0,'theme_id');
1055 function confirmBox($msg, $params, $buttons, $image='*none*') {
1056 if ($image == '*none*') {
1057 $image = html_image('stop.png','48','48',array());
1060 foreach ($params as $b => $v) {
1061 $prms[] = '<input type="hidden" name="'.$b.'" value="'.$v.'" />'."\n";
1063 $prm = join(' ', $prms);
1065 foreach ($buttons as $b => $v) {
1066 $btns[] = '<input type="submit" name="'.$b.'" value="'.$v.'" />'."\n";
1068 $btn = join(' '."\n ", $btns);
1071 <div id="infobox" style="margin-top: 15%; margin-left: 15%; margin-right: 15%; text-align: center;">
1072 <table align="center">
1075 <td>'.$msg.'<br/></td>
1078 <td colspan="2" align="center">
1080 <form action="' . getStringFromServer('PHP_SELF') . '" method="get" >
1091 function html_input($name, $id = '', $label = '', $type = 'text', $value = '', $extra_params = '') {
1095 $return = '<div class="field-holder">
1098 $return .= '<label for="' . $id . '">' . $label . '</label>
1101 $return .= '<input id="' . $id . '" type="' . $type . '"';
1102 //if input is a submit then name is not present
1104 $return .= ' name="' . $name . '"';
1107 $return .= ' value="' . $value . '"';
1109 if (is_array($extra_params)) {
1110 foreach ($extra_params as $key => $extra_params_value) {
1111 $return .= $key . '="' . $extra_params_value . '" ';
1119 function html_checkbox($name, $value, $id = '', $label = '', $checked = '', $extra_params = '') {
1123 $return = '<div class="field-holder">
1125 $return .= '<input name="' . $name . '" id="' . $id . '" type="checkbox" value="' . $value . '" ';
1127 $return .= 'checked="checked" ';
1129 if (is_array($extra_params)) {
1130 foreach ($extra_params as $key => $extra_params_value) {
1131 $return .= $key . '="' . $extra_params_value . '" ';
1136 $return .= '<label for="' . $id . '">' . $label . '</label>
1139 $return .= '</div>';
1143 function html_text_input_img_submit($name, $img_src, $id = '', $label = '', $value = '', $img_title = '', $img_alt = '', $extra_params = '', $img_extra_params = '') {
1151 $img_alt = $img_title;
1153 $return = '<div class="field-holder">
1156 $return .= '<label for="' . $id . '">' . $label . '</label>
1159 $return .= '<input id="' . $id . '" type="text" name="' . $name . '"';
1161 $return .= ' value="' . $value . '"';
1163 if (is_array($extra_params)) {
1164 foreach ($extra_params as $key => $extra_params_value) {
1165 $return .= $key . '="' . $extra_params_value . '" ';
1169 <input type="image" id="' . $id . '_submit" src="' . $this->imgroot . $img_src . '" alt="' . $img_alt . '" title="' . $img_title . '"';
1170 if (is_array($img_extra_params)) {
1171 foreach ($img_extra_params as $key => $img_extra_params_value) {
1172 $return .= $key . '="' . $img_extra_params_value . '" ';
1180 function html_select($vals, $name, $label = '', $id = '', $checked_val = '', $text_is_value = false, $extra_params = '') {
1184 $return = '<div class="field-holder">
1187 $return .= '<label for="' . $id . '">' . $label . '</label>
1190 $return .= '<select name="' . $name . '" id="' . $id . '" ';
1191 if (is_array($extra_params)) {
1192 foreach ($extra_params as $key => $extra_params_value) {
1193 $return .= $key . '="' . $extra_params_value . '" ';
1197 $rows = count($vals);
1198 for ($i = 0; $i < $rows; $i++) {
1199 if ( $text_is_value ) {
1201 <option value="' . $vals[$i] . '"';
1202 if ($vals[$i] == $checked_val) {
1203 $return .= ' selected="selected"';
1207 <option value="' . $i . '"';
1208 if ($i == $checked_val) {
1209 $return .= ' selected="selected"';
1212 $return .= '>' . htmlspecialchars($vals[$i]) . '</option>';
1220 function html_textarea($name, $id = '', $label = '', $value = '', $extra_params = '') {
1224 $return = '<div class="field-holder">
1227 $return .= '<label for="' . $id . '">' . $label . '</label>
1230 $return .= '<textarea id="' . $id . '" name="' . $name . '" ';
1231 if (is_array($extra_params)) {
1232 foreach ($extra_params as $key => $extra_params_value) {
1233 $return .= $key . '="' . $extra_params_value . '" ';
1240 $return .= '</textarea>
1245 function html_table_top($cols, $summary = '', $class = '', $extra_params = '') {
1246 $return = '<table summary="' . $summary . '" ';
1248 $return .= 'class="' . $class . '" ';
1250 if (is_array($extra_params)) {
1251 foreach ($extra_params as $key => $extra_params_value) {
1252 $return .= $key . '="' . $extra_params_value . '" ';
1256 $return .= '<thead><tr>';
1257 $nbCols = count($cols);
1258 for ($i = 0; $i < $nbCols; $i++) {
1259 $return .= '<th scope="col">' . $cols[$i] . '</th>';
1261 $return .= '</tr></thead>';
1265 function getMonitorPic($title = '', $alt = '') {
1266 return $this->getPicto('ic/mail16w.png', $title, $alt, '15', '15');
1269 function getReleaseNotesPic($title = '', $alt = '') {
1270 return $this->getPicto('ic/manual16c.png', $title, $alt, '15', '15');
1273 /* no picto for download */
1274 function getDownloadPic($title = '', $alt = '') {
1275 return $this->getPicto('ic/save.png', $title, $alt, '15', '15');
1278 function getHomePic($title = '', $alt = '') {
1279 return $this->getPicto('ic/home16b.png', $title, $alt);
1282 function getFollowPic($title = '', $alt = '') {
1283 return $this->getPicto('ic/tracker20g.png', $title, $alt);
1286 function getForumPic($title = '', $alt = '') {
1287 return $this->getPicto('ic/forum20g.png', $title, $alt);;
1290 function getDocmanPic($title = '', $alt = '') {
1291 return $this->getPicto('ic/docman16b.png', $title, $alt);
1294 function getMailPic($title = '', $alt = '') {
1295 return $this->getPicto('ic/mail16b.png', $title, $alt);
1298 function getPmPic($title = '', $alt = '') {
1299 return $this->getPicto('ic/taskman20g.png', $title, $alt);
1302 function getScmPic($title = '', $alt = '') {
1303 return $this->getPicto('ic/cvs16b.png', $title, $alt);
1306 function getFtpPic($title = '', $alt = '') {
1307 return $this->getPicto('ic/ftp16b.png', $title, $alt);
1310 function getPicto($url, $title, $alt, $width = '20', $height = '20') {
1314 return html_image($url, $width, $height, array('title'=>$title, 'alt'=>$alt));
1318 * toSlug() - protect a string to be used as a link or an anchor
1320 * @param string $string the string used as a link or an anchor
1321 * @param string $space the caracter used as a replacement for a space
1322 * @return a protected string with only alphanumeric caracters
1324 function toSlug($string, $space = "-") {
1325 if (function_exists('iconv')) {
1326 $string = @iconv('UTF-8', 'ASCII//TRANSLIT', $string);
1328 $string = preg_replace("/[^a-zA-Z0-9- ]/", "-", $string);
1329 $string = strtolower($string);
1330 $string = str_replace(" ", $space, $string);
1338 // c-file-style: "bsd"