5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright 2010 - Alain Peyrat
7 * Copyright 2010 - Franck Villaume - Capgemini
8 * http://fusionforge.org
10 * This file is part of FusionForge.
12 * FusionForge is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * FusionForge is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with FusionForge; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 * Extends the basic Error class to add HTML functions
30 * for displaying all site dependent HTML, while allowing
31 * extendibility/overriding by themes via the Theme class.
33 * Make sure browser.php is included _before_ you create an instance
38 require_once $gfcommon.'include/constants.php';
39 require_once $gfcommon.'include/FusionForge.class.php';
40 require_once $gfcommon.'include/Navigation.class.php';
42 class Layout extends Error {
45 * Which doctype to use. Can be configured in the
46 * constructor. If set to 'strict', headerHTMLDeclaration will
47 * create a doctype definition that uses the strict doctype,
48 * otherwise it will use the transitional doctype.
49 * @var string $doctype
51 var $doctype = 'transitional';
54 * The default main page content
55 * @var string $rootindex
57 var $rootindex = 'index_std.php';
60 * The base directory of the theme in the servers file system
61 * @var string $themedir
66 * The base url of the theme
67 * @var string $themeurl
72 * The base directory of the image files in the servers file system
78 * The base url of the image files
79 * @var string $imgbaseurl
84 * The base directory of the js files in the servers file system
90 * The base url of the js files
91 * @var string $jsbaseurl
96 * The navigation object that provides the basic links. Should
102 * The color bars in pm reporting
104 var $COLOR_LTBACK1 = '#C0C0C0';
107 var $js_min = array();
108 var $javascripts = array();
110 var $css_min = array();
111 var $stylesheets = array();
114 * Layout() - Constructor
117 // parent constructor
120 $this->navigation = new Navigation();
122 // determine rootindex
123 if ( file_exists(forge_get_config('custom_path') . '/index_std.php') ) {
124 $this->rootindex = forge_get_config('custom_path') . '/index_std.php';
126 $this->rootindex = $GLOBALS['gfwww'].'index_std.php';
129 // determine theme{dir,url}
130 $this->themedir = forge_get_config('themes_root') . '/' . forge_get_config('default_theme') . '/';
131 if (!file_exists ($this->themedir)) {
132 html_error_top(_("Can't find theme directory!"));
135 $this->themeurl = util_make_url('themes/' . forge_get_config('default_theme') . '/');
137 // determine {css,img,js}{url,dir}
138 if (file_exists ($this->themedir . 'images/')) {
139 $this->imgdir = $this->themedir . 'images/';
140 $this->imgbaseurl = $this->themeurl . 'images/';
142 $this->imgdir = $this->themedir;
143 $this->imgbaseurl = $this->themeurl;
146 if (file_exists ($this->themedir . 'js/')) {
147 $this->jsdir = $this->themedir . 'js/';
148 $this->jsbaseurl = $this->themeurl . 'js/';
150 $this->jsdir = $this->themedir;
151 $this->jsbaseurl = $this->themeurl;
154 $this->addStylesheet('/themes/css/fusionforge.css');
158 function addJavascript($js) {
159 if (isset($this->js_min[$js])) {
160 $js = $this->js_min[$js];
162 if (!isset($this->js[$js])) {
163 $this->js[$js] = true;
164 $filename = $GLOBALS['fusionforge_basedir'].'/www'.$js;
165 if (file_exists($filename)) {
166 $js .= '?'.date ("U", filemtime($filename));
168 $filename = str_replace('/scripts/', $GLOBALS['fusionforge_basedir'].'/lib/vendor/', $js);
169 if (file_exists($filename)) {
170 $js .= '?'.date ("U", filemtime($filename));
173 $this->javascripts[] = $js;
177 function addStylesheet($css, $media='') {
178 if (isset($this->css_min[$css])) {
179 $css = $this->css_min[$css];
181 if (!isset($this->css[$css])) {
182 $this->css[$css] = true;
183 $filename = $GLOBALS['fusionforge_basedir'].'/www'.$css;
184 if (file_exists($filename)) {
185 $css .= '?'.date ("U", filemtime($filename));
187 $filename = str_replace('/scripts/', $GLOBALS['fusionforge_basedir'].'/lib/vendor/', $css);
188 if (file_exists($filename)) {
189 $css .= '?'.date ("U", filemtime($filename));
192 $this->stylesheets[] = array('css' => $css, 'media' => $media);
196 function getJavascripts() {
198 foreach ($this->javascripts as $js) {
199 $code .= ' <script type="text/javascript" src="'.$js.'"></script>'."\n";
204 function getStylesheets() {
206 foreach ($this->stylesheets as $c) {
208 $code .= ' <link rel="stylesheet" type="text/css" href="'.$c['css'].'" media="'.$c['media'].'" />'."\n";
210 $code .= ' <link rel="stylesheet" type="text/css" href="'.$c['css'].'"/>'."\n";
217 * header() - generates the complete header of page by calling
218 * headerStart() and bodyHeader().
220 function header($params) {
221 $this->headerStart($params); ?>
224 $this->bodyHeader($params);
228 * headerStart() - generates the header code for all themes up to the
230 * Override any of the methods headerHTMLDeclaration(), headerTitle(),
231 * headerFavIcon(), headerRSS(), headerSearch(), headerCSS(), or
232 * headerJS() to adapt your theme.
234 * @param array Header parameters array
236 function headerStart($params) {
237 $this->headerHTMLDeclaration();
240 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
242 $this->headerTitle($params);
243 $this->headerFavIcon();
245 $this->headerSearch();
248 $this->headerForgepluckerMeta();
255 * headerHTMLDeclaration() - generates the HTML declaration, i.e. the
256 * XML declaration, the doctype definition, and the opening <html>.
259 function headerHTMLDeclaration() {
260 print '<?xml version="1.0" encoding="utf-8"?>'."\n";
261 if (isset($this->doctype) && $this->doctype=='strict') {
262 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'."\n";
264 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'."\n";
266 echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="'
267 . _('en') . '" lang="' . _('en') . '">'."\n";
271 * headerTitle() - creates the <title> header
273 * @param array Header parameters array
275 function headerTitle($params) {
276 echo $this->navigation->getTitle($params);
281 * headerFavIcon() - creates the favicon <link> headers.
284 function headerFavIcon() {
285 echo $this->navigation->getFavIcon();
289 * headerRSS() - creates the RSS <link> headers.
292 function headerRSS() {
293 echo $this->navigation->getRSS();
297 * headerSearch() - creates the search <link> header.
300 function headerSearch() {
301 echo '<link rel="search" title="'
302 . forge_get_config ('forge_name').'" href="'
303 . util_make_url ('/export/search_plugin.php')
304 . '" type="application/opensearchdescription+xml"/>'."\n";
308 * Create the CSS headers for all cssfiles in $cssfiles and
309 * calls the plugin cssfile hook.
311 function headerCSS() {
312 plugin_hook ('cssfile',$this);
313 echo $this->getStylesheets();
317 * headerJS() - creates the JS headers and calls the plugin javascript hook
318 * @todo generalize this
320 function headerJS() {
322 <script type="text/javascript" src="/scripts/prototype/prototype.js"></script>
323 <script type="text/javascript" src="/scripts/scriptaculous/scriptaculous.js"></script>
324 <script type="text/javascript" src="/scripts/codendi/Tooltip.js"></script>
325 <script type="text/javascript" src="/scripts/codendi/LayoutManager.js"></script>
326 <script type="text/javascript" src="/scripts/codendi/ReorderColumns.js"></script>
327 <script type="text/javascript" src="/scripts/codendi/codendi-1236793993.js"></script>
328 <script type="text/javascript" src="/scripts/codendi/validate.js"></script>
329 <script type="text/javascript" src="'. util_make_uri('/js/common.js') .'"></script>
330 <script type="text/javascript">';
331 plugin_hook ("javascript",false);
334 plugin_hook ("javascript_file",false);
335 echo $this->getJavascripts();
338 function headerForgepluckerMeta() {
340 * Forge-Identification Meta Header, Version 1.0
341 * cf. http://home.gna.org/forgeplucker/forge-identification.html
343 $ff = new FusionForge();
344 return sprintf('<meta name="Forge-Identification" content="%s:%s" />',
346 $ff->software_version) . "\n";
349 function bodyHeader($params){
352 <table border="0" width="100%" cellspacing="0" cellpadding="0" id="headertable">
354 <td><a href="<?php echo util_make_url ('/'); ?>"><?php echo html_image('logo.png',198,52,array('border'=>'0')); ?></a></td>
355 <td><?php $this->searchBox(); ?></td>
356 <td align="right"><?php
357 $items = $this->navigation->getUserLinks();
358 for ($j = 0; $j < count($items['titles']); $j++) {
359 echo util_make_link($items['urls'][$j], $items['titles'][$j], array('class'=>'lnkutility'), true);
362 $params['template'] = ' {menu}';
363 plugin_hook ('headermenu', $params);
368 <td> </td>
373 <table border="0" width="100%" cellspacing="0" cellpadding="0">
379 <?php echo $this->outerTabs($params); ?>
386 <td align="left" class="toptab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topleft.png" height="9" width="9" alt="" /></td>
387 <td class="toptab" width="30"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="30" height="1" alt="" /></td>
388 <td class="toptab"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
389 <td class="toptab" width="30"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="30" height="1" alt="" /></td>
390 <td align="right" class="toptab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topright.png" height="9" width="9" alt="" /></td>
395 <!-- Outer body row -->
397 <td class="toptab"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="10" height="1" alt="" /></td>
398 <td valign="top" width="99%" class="toptab" colspan="3">
400 <!-- Inner Tabs / Shell -->
402 <table border="0" width="100%" cellspacing="0" cellpadding="0">
406 if (isset($params['group']) && $params['group']) {
414 echo $this->projectTabs($params['toptab'],$params['group']);
424 <td align="left" class="projecttab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topleft-inner.png" height="9" width="9" alt="" /></td>
425 <td class="projecttab" ><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
426 <td align="right" class="projecttab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topright-inner.png" height="9" width="9" alt="" /></td>
430 <td class="projecttab" ><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="10" height="1" alt="" /></td>
431 <td valign="top" width="99%" class="projecttab">
437 function footer($params) {
441 <!-- end main body row -->
444 <td width="10" class="footer3" ><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="2" height="1" alt="" /></td>
447 <td align="left" class="footer1" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomleft-inner.png" height="11" width="11" alt="" /></td>
448 <td class="footer3"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
449 <td align="right" class="footer1" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomright-inner.png" height="11" width="11" alt="" /></td>
453 <!-- end inner body row -->
456 <td width="10" class="footer2"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="2" height="1" alt="" /></td>
459 <td align="left" class="footer2" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomleft.png" height="9" width="9" alt="" /></td>
460 <td class="footer2" colspan="3"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
461 <td align="right" class="footer2" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomright.png" height="9" width="9" alt="" /></td>
465 $this->footerEnd($params);
468 function footerEnd($params) { ?>
470 <!-- PLEASE LEAVE "Powered By FusionForge" on your site -->
472 <?php echo $this->navigation->getPoweredBy(); ?>
475 <?php echo $this->navigation->getShowSource(); ?>
483 function getRootIndex() {
484 return $this->rootindex;
488 * boxTop() - Top HTML box.
490 * @param string Box title
491 * @return string the html code
493 function boxTop($title) {
495 <!-- Box Top Start -->
497 <table cellspacing="0" cellpadding="0" width="100%" border="0" style="background:url('.$this->imgbaseurl.'vert-grad.png)">
498 <tr class="align-center">
499 <td valign="top" align="right" width="10" style="background:url('.$this->imgbaseurl.'box-topleft.png)"><img src="'.$this->imgbaseurl.'clear.png" width="10" height="20" alt="" /></td>
500 <td width="100%" style="background:url('.$this->imgbaseurl.'box-grad.png)"><span class="titlebar">'.$title.'</span></td>
501 <td valign="top" width="10" style="background:url('.$this->imgbaseurl.'box-topright.png)"><img src="'.$this->imgbaseurl.'clear.png" width="10" height="20" alt="" /></td>
505 <table cellspacing="2" cellpadding="2" width="100%" border="0">
509 <!-- Box Top End -->';
513 * boxMiddle() - Middle HTML box.
515 * @param string Box title
516 * @return string The html code
518 function boxMiddle($title) {
520 <!-- Box Middle Start -->
523 <tr class="align-center">
524 <td colspan="2" style="background:url('.$this->imgbaseurl.'box-grad.png)"><span class="titlebar">'.$title.'</span></td>
528 <!-- Box Middle End -->';
532 * boxBottom() - Bottom HTML box.
534 * @return string the html code
536 function boxBottom() {
538 <!-- Box Bottom Start -->
545 <!-- Box Bottom End -->';
549 * boxGetAltRowStyle() - Get an alternating row style for tables.
551 * @param int Row number
552 * @return string the class code
554 function boxGetAltRowStyle($i) {
556 return ' class="altRowStyleEven"';
558 return ' class="altRowStyleOdd"';
563 * listTableTop() - Takes an array of titles and builds the first row of a new table.
565 * @param array The array of titles
566 * @param array The array of title links
567 * @param string The css classes to add (optional)
568 * @param string The id of the table (needed by sortable for example)
569 * @param array specific class for th column
570 * @return string the html code
572 function listTableTop($titleArray, $linksArray=false, $class='', $id='', $thClassArray=array()) {
575 $args .= ' class="listing '.$class.'"';
577 $args .= ' class="listing full"';
580 $args .= ' id="'.$id.'"';
585 if (count($titleArray)) {
586 $return .= '<thead><tr>';
588 $count=count($titleArray);
589 for ($i=0; $i<$count; $i++) {
591 if ($thClassArray && $thClassArray[$i]) {
592 $th .= ' class="'.$thClassArray[$i].'"';
594 $cell = $titleArray[$i];
596 $cell = util_make_link($linksArray[$i],$titleArray[$i]);
598 $return .= "\n".' <th'.$th.'>'.$cell.'</th>';
600 $return .= "\n".'</tr></thead>'."\n";
602 $return .= '<tbody>';
606 function listTableBottom() {
607 return '</tbody>'."\n".'</table>';
610 function outerTabs($params) {
611 $menu = $this->navigation->getSiteMenu();
612 echo $this->tabGenerator($menu['urls'], $menu['titles'], false, $menu['selected'], '');
616 * Prints out the quicknav menu, contained here in case we
617 * want to allow it to be overridden.
619 function quickNav() {
620 if (!session_loggedin()) {
623 // get all projects that the user belongs to
624 $groups = session_get_user()->getGroups();
626 if (count($groups) < 1) {
629 sortProjectList($groups);
632 <form id="quicknavform" name="quicknavform" action=""><div>
633 <select name="quicknav" id="quicknav" onChange="location.href=document.quicknavform.quicknav.value">
634 <option value="">'._('Quick Jump To...').'</option>';
636 foreach ($groups as $g) {
637 $group_id = $g->getID();
638 $menu =& $this->navigation->getProjectMenu($group_id);
641 <option value="' . $menu['starturl'] . '">'
642 . $menu['name'] .'</option>';
644 for ($j = 0; $j < count($menu['urls']); $j++) {
646 <option value="' . $menu['urls'][$j] .'"> '
647 . $menu['titles'][$j] . '</option>';
648 if (@$menu['adminurls'][$j]) {
650 <option value="' . $menu['adminurls'][$j]
651 . '"> '
652 . _('Admin') . '</option>';
664 * projectTabs() - Prints out the project tabs, contained here in case
665 * we want to allow it to be overriden.
667 * @param string Is the tab currently selected
668 * @param string Is the group we should look up get title info
670 function projectTabs($toptab, $group_id) {
671 // get group info using the common result set
672 $menu =& $this->navigation->getProjectMenu($group_id, $toptab);
673 echo $this->tabGenerator($menu['urls'], $menu['titles'], true, $menu['selected'], 'white');
676 function tabGenerator($TABS_DIRS,$TABS_TITLES,$nested=false,$selected=false,$sel_tab_bgcolor='white',$total_width='100%') {
678 $count=count($TABS_DIRS);
679 $width=intval((100/$count));
684 <table class="tabGenerator" ';
686 if ($total_width != '100%') {
687 $return .= 'style="width:' . $total_width . ';"';
697 for ($i=0; $i<$count; $i++) {
700 // this is the first tab, choose an image with end-name
703 $issel=($selected==$i);
704 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
705 // $rowspan=(($issel)?'rowspan="2" ' : '');
708 <td '.$rowspan.'valign="top" width="10" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-end-'.(($issel) ? '' : 'not').'selected.png)">'.
709 '<img src="'.$this->imgbaseurl . 'clear.png" height="25" width="10" alt="" /></td>'.
710 '<td '.$rowspan.'style="background:url('.$this->imgbaseurl . $bgimg.')" width="'.$width.'%" align="center">'.util_make_link ($TABS_DIRS[$i],$TABS_TITLES[$i],array('class'=>(($issel)?'tabsellink':'tablink')),true).'</td>';
711 } elseif ($i==$count-1) {
713 // this is the last tab, choose an image with name-end
715 $wassel=($selected==$i-1);
716 $issel=($selected==$i);
717 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
718 // $rowspan=(($issel)?'rowspan="2" ' : '');
720 // Build image between current and prior tab
723 <td '.$rowspan.'colspan="2" valign="top" width="20" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-'.(($wassel) ? '' : 'not').'selected-'.(($issel) ? '' : 'not').'selected.png)">'.
724 '<img src="'.$this->imgbaseurl . 'clear.png" height="2" width="20" alt="" /></td>'.
725 '<td '.$rowspan.'style="background:url('.$this->imgbaseurl . $bgimg.')" width="'.$width.'%" align="center">'.util_make_link ($TABS_DIRS[$i],$TABS_TITLES[$i],array('class'=>(($issel)?'tabsellink':'tablink')),true).'</td>';
727 // Last graphic on right-side
730 <td '.$rowspan.'valign="top" width="10" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-'.(($issel) ? '' : 'not').'selected-end.png)">'.
731 '<img src="'.$this->imgbaseurl . 'clear.png" height="2" width="10" alt="" /></td>';
737 $wassel=($selected==$i-1);
738 $issel=($selected==$i);
739 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
740 // $rowspan=(($issel)?'rowspan="2" ' : '');
742 // Build image between current and prior tab
745 <td '.$rowspan.'colspan="2" valign="top" width="20" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-'.(($wassel) ? '' : 'not').'selected-'.(($issel) ? '' : 'not').'selected.png)">'.
746 '<img src="'.$this->imgbaseurl . 'clear.png" height="2" width="20" alt="" /></td>'.
747 '<td '.$rowspan.'style="background:url('.$this->imgbaseurl . $bgimg.')" width="'.$width.'%" align="center">'.util_make_link ($TABS_DIRS[$i],$TABS_TITLES[$i],array('class'=>(($issel)?'tabsellink':'tablink')),true).'</td>';
754 // Building a bottom row in this table, which will be darker
756 if ($selected == 0) {
758 $end_cols=((count($TABS_DIRS)*3)-3);
759 } elseif ($selected == (count($TABS_DIRS)-1)) {
760 $beg_cols=((count($TABS_DIRS)*3)-3);
763 $beg_cols=($selected*3);
764 $end_cols=(((count($TABS_DIRS)*3)-3)-$beg_cols);
768 $return .= '<td colspan="'.$beg_cols.'" height="1" class="notSelTab"><img src="'.$this->imgbaseurl.'clear.png" height="1" width="10" alt="" /></td>';
770 $return .= '<td colspan="3" height="1" class="selTab"><img src="'.$this->imgbaseurl.'clear.png" height="1" width="10" alt="" /></td>';
772 $return .= '<td colspan="'.$end_cols.'" height="1" class="notSelTab"><img src="'.$this->imgbaseurl.'clear.png" height="1" width="10" alt="" /></td>';
784 function searchBox() {
785 echo $this->navigation->getSearchBox();
789 * beginSubMenu() - Opening a submenu.
791 * @return string Html to start a submenu.
793 function beginSubMenu () {
800 * endSubMenu() - Closing a submenu.
802 * @return string Html to end a submenu.
804 function endSubMenu () {
805 $return = '</strong></p>';
810 * printSubMenu() - Takes two array of titles and links and builds the contents of a menu.
812 * @param array The array of titles.
813 * @param array The array of title links.
814 * @return string Html to build a submenu.
816 function printSubMenu ($title_arr,$links_arr) {
817 $count=count($title_arr);
821 for ($i=0; $i<$count; $i++) {
822 $return .= util_make_link($links_arr[$i],$title_arr[$i]).' | ';
824 $return .= util_make_link($links_arr[$i],$title_arr[$i]);
829 * subMenu() - Takes two array of titles and links and build a menu.
831 * @param array The array of titles.
832 * @param array The array of title links.
833 * @return string Html to build a submenu.
835 function subMenu ($title_arr,$links_arr) {
836 $return = $this->beginSubMenu() ;
837 $return .= $this->printSubMenu($title_arr,$links_arr) ;
838 $return .= $this->endSubMenu() ;
843 * multiTableRow() - create a mutlilevel row in a table
845 * @param string the row attributes
846 * @param array the array of cell data, each element is an array,
847 * the first item being the text,
848 * the subsequent items are attributes (dont include
849 * the bgcolor for the title here, that will be
850 * handled by $istitle
851 * @param boolean is this row part of the title ?
852 * @return string the html code
854 function multiTableRow($row_attr, $cell_data, $istitle) {
858 $return .=' class="align-center multiTableRowTitle"';
861 for ( $c = 0; $c < count($cell_data); $c++ ) {
863 for ( $a=1; $a < count($cell_data[$c]); $a++) {
864 $return .= $cell_data[$c][$a].' ';
868 $return .='<span class="multiTableRowTitle">';
870 $return .= $cell_data[$c][0];
884 * feedback() - returns the htmlized feedback string when an action is performed.
886 * @param string feedback string
887 * @return string htmlized feedback
889 function feedback($feedback) {
894 <div class="feedback">'.strip_tags($feedback, '<br>').'</div>';
898 * warning_msg() - returns the htmlized warning string when an action is performed.
900 * @param string msg string
901 * @return string htmlized warning
903 function warning_msg($msg) {
908 <div class="warning_msg">'.strip_tags($msg, '<br>').'</div>';
913 * error_msg() - returns the htmlized error string when an action is performed.
915 * @param string msg string
916 * @return string htmlized error
918 function error_msg($msg) {
923 <div class="error">'.strip_tags($msg, '<br>').'</div>';
929 * getThemeIdFromName()
931 * @param string the dirname of the theme
932 * @return integer the theme id
934 function getThemeIdFromName($dirname) {
935 $res = db_query_params ('SELECT theme_id FROM themes WHERE dirname=$1',
937 return db_result($res,0,'theme_id');
940 function confirmBox($msg, $params, $buttons, $image='*none*') {
941 if ($image == '*none*') {
942 $image = html_image('stop.png','48','48',array());
945 foreach ($params as $b => $v) {
946 $prms[] = '<input type="hidden" name="'.$b.'" value="'.$v.'" />'."\n";
948 $prm = join(' ', $prms);
950 foreach ($buttons as $b => $v) {
951 $btns[] = '<input type="submit" name="'.$b.'" value="'.$v.'" />'."\n";
953 $btn = join(' '."\n ", $btns);
956 <div id="infobox" style="margin-top: 15%; margin-left: 15%; margin-right: 15%; text-align: center;">
957 <table align="center">
960 <td>'.$msg.'<br/></td>
963 <td colspan="2" align="center">
965 <form action="' . getStringFromServer('PHP_SELF') . '" method="get" >
976 function html_input($name, $id = '', $label = '', $type = 'text', $value = '', $extra_params = '') {
980 $return = '<div class="field-holder">
983 $return .= '<label for="' . $id . '">' . $label . '</label>
986 $return .= '<input id="' . $id . '" type="' . $type . '"';
987 //if input is a submit then name is not present
989 $return .= ' name="' . $name . '"';
992 $return .= ' value="' . $value . '"';
994 if (is_array($extra_params)) {
995 foreach ($extra_params as $key => $extra_params_value) {
996 $return .= $key . '="' . $extra_params_value . '" ';
1004 function html_checkbox($name, $value, $id = '', $label = '', $checked = '', $extra_params = '') {
1008 $return = '<div class="field-holder">
1010 $return .= '<input name="' . $name . '" id="' . $id . '" type="checkbox" value="' . $value . '" ';
1012 $return .= 'checked="checked" ';
1014 if (is_array($extra_params)) {
1015 foreach ($extra_params as $key => $extra_params_value) {
1016 $return .= $key . '="' . $extra_params_value . '" ';
1021 $return .= '<label for="' . $id . '">' . $label . '</label>
1024 $return .= '</div>';
1028 function html_text_input_img_submit($name, $img_src, $id = '', $label = '', $value = '', $img_title = '', $img_alt = '', $extra_params = '', $img_extra_params = '') {
1036 $img_alt = $img_title;
1038 $return = '<div class="field-holder">
1041 $return .= '<label for="' . $id . '">' . $label . '</label>
1044 $return .= '<input id="' . $id . '" type="text" name="' . $name . '"';
1046 $return .= ' value="' . $value . '"';
1048 if (is_array($extra_params)) {
1049 foreach ($extra_params as $key => $extra_params_value) {
1050 $return .= $key . '="' . $extra_params_value . '" ';
1054 <input type="image" id="' . $id . '_submit" src="' . $this->imgbaseurl . $img_src . '" alt="' . $img_alt . '" title="' . $img_title . '"';
1055 if (is_array($img_extra_params)) {
1056 foreach ($img_extra_params as $key => $img_extra_params_value) {
1057 $return .= $key . '="' . $img_extra_params_value . '" ';
1065 function html_select($vals, $name, $label = '', $id = '', $checked_val = '', $text_is_value = false, $extra_params = '') {
1069 $return = '<div class="field-holder">
1072 $return .= '<label for="' . $id . '">' . $label . '</label>
1075 $return .= '<select name="' . $name . '" id="' . $id . '" ';
1076 if (is_array($extra_params)) {
1077 foreach ($extra_params as $key => $extra_params_value) {
1078 $return .= $key . '="' . $extra_params_value . '" ';
1082 $rows = count($vals);
1083 for ($i = 0; $i < $rows; $i++) {
1084 if ( $text_is_value ) {
1086 <option value="' . $vals[$i] . '"';
1087 if ($vals[$i] == $checked_val) {
1088 $return .= ' selected="selected"';
1092 <option value="' . $i . '"';
1093 if ($i == $checked_val) {
1094 $return .= ' selected="selected"';
1097 $return .= '>' . htmlspecialchars($vals[$i]) . '</option>';
1105 function html_textarea($name, $id = '', $label = '', $value = '', $extra_params = '') {
1109 $return = '<div class="field-holder">
1112 $return .= '<label for="' . $id . '">' . $label . '</label>
1115 $return .= '<textarea id="' . $id . '" name="' . $name . '" ';
1116 if (is_array($extra_params)) {
1117 foreach ($extra_params as $key => $extra_params_value) {
1118 $return .= $key . '="' . $extra_params_value . '" ';
1125 $return .= '</textarea>
1131 * @todo use listTableTop and make this function deprecated ?
1133 function html_table_top($cols, $summary = '', $class = '', $extra_params = '') {
1134 $return = '<table summary="' . $summary . '" ';
1136 $return .= 'class="' . $class . '" ';
1138 if (is_array($extra_params)) {
1139 foreach ($extra_params as $key => $extra_params_value) {
1140 $return .= $key . '="' . $extra_params_value . '" ';
1144 $return .= '<thead><tr>';
1145 $nbCols = count($cols);
1146 for ($i = 0; $i < $nbCols; $i++) {
1147 $return .= '<th scope="col">' . $cols[$i] . '</th>';
1149 $return .= '</tr></thead>';
1153 function getMonitorPic($title = '', $alt = '') {
1154 return $this->getPicto('ic/mail16w.png', $title, $alt, '15', '15');
1157 function getReleaseNotesPic($title = '', $alt = '') {
1158 return $this->getPicto('ic/manual16c.png', $title, $alt, '15', '15');
1161 /* no picto for download */
1162 function getDownloadPic($title = '', $alt = '') {
1163 return $this->getPicto('ic/save.png', $title, $alt, '15', '15');
1166 function getHomePic($title = '', $alt = '') {
1167 return $this->getPicto('ic/home16b.png', $title, $alt);
1170 function getFollowPic($title = '', $alt = '') {
1171 return $this->getPicto('ic/tracker20g.png', $title, $alt);
1174 function getForumPic($title = '', $alt = '') {
1175 return $this->getPicto('ic/forum20g.png', $title, $alt);;
1178 function getDocmanPic($title = '', $alt = '') {
1179 return $this->getPicto('ic/docman16b.png', $title, $alt);
1182 function getMailPic($title = '', $alt = '') {
1183 return $this->getPicto('ic/mail16b.png', $title, $alt);
1186 function getPmPic($title = '', $alt = '') {
1187 return $this->getPicto('ic/taskman20g.png', $title, $alt);
1190 function getSurveyPic($title = '', $alt = '') {
1191 return $this->getPicto('ic/survey16b.png', $title, $alt);
1194 function getScmPic($title = '', $alt = '') {
1195 return $this->getPicto('ic/cvs16b.png', $title, $alt);
1198 function getFtpPic($title = '', $alt = '') {
1199 return $this->getPicto('ic/ftp16b.png', $title, $alt);
1202 function getPicto($url, $title, $alt, $width = '20', $height = '20') {
1206 return html_image($url, $width, $height, array('title'=>$title, 'alt'=>$alt));
1210 * toSlug() - protect a string to be used as a link or an anchor
1212 * @param string $string the string used as a link or an anchor
1213 * @param string $space the caracter used as a replacement for a space
1214 * @return a protected string with only alphanumeric caracters
1216 function toSlug($string, $space = "-") {
1217 if (function_exists('iconv')) {
1218 $string = @iconv('UTF-8', 'ASCII//TRANSLIT', $string);
1220 $string = preg_replace("/[^a-zA-Z0-9- ]/", "-", $string);
1221 $string = strtolower($string);
1222 $string = str_replace(" ", $space, $string);
1226 function widget(&$widget, $layout_id, $readonly, $column_id, $is_minimized, $display_preferences, $owner_id, $owner_type) {
1227 $element_id = 'widget_'. $widget->id .'-'. $widget->getInstanceId();
1228 echo '<div class="widget" id="'. $element_id .'">';
1229 echo '<div class="widget_titlebar '. ($readonly?'':'widget_titlebar_handle') .'">';
1230 echo '<div class="widget_titlebar_title">'. $widget->getTitle() .'</div>';
1232 echo '<div class="widget_titlebar_close"><a href="/widgets/updatelayout.php?owner='. $owner_type.$owner_id .'&action=widget&name['. $widget->id .'][remove]='. $widget->getInstanceId() .'&column_id='. $column_id .'&layout_id='. $layout_id .'">'. $this->getPicto('ic/close.png', 'Close','Close') .'</a></div>';
1233 if ($is_minimized) {
1234 echo '<div class="widget_titlebar_maximize"><a href="/widgets/updatelayout.php?owner='. $owner_type.$owner_id .'&action=maximize&name['. $widget->id .']='. $widget->getInstanceId() .'&column_id='. $column_id .'&layout_id='. $layout_id .'">'. $this->getPicto($this->_getTogglePlusForWidgets(), 'Maximize', 'Maximize') .'</a></div>';
1236 echo '<div class="widget_titlebar_minimize"><a href="/widgets/updatelayout.php?owner='. $owner_type.$owner_id .'&action=minimize&name['. $widget->id .']='. $widget->getInstanceId() .'&column_id='. $column_id .'&layout_id='. $layout_id .'">'. $this->getPicto($this->_getToggleMinusForWidgets(), 'Minimize', 'Minimize') .'</a></div>';
1238 if (strlen($widget->hasPreferences())) {
1239 echo '<div class="widget_titlebar_prefs"><a href="/widgets/updatelayout.php?owner='. $owner_type.$owner_id .'&action=preferences&name['. $widget->id .']='. $widget->getInstanceId() .'&layout_id='. $layout_id .'">'. _('Preferences') .'</a></div>';
1242 if ($widget->hasRss()) {
1243 echo '<div class="widget_titlebar_rss"><a href="'.$widget->getRssUrl($owner_id, $owner_type).'">rss</a></div>';
1247 if ($is_minimized) {
1248 $style = 'display:none;';
1250 echo '<div class="widget_content" style="'. $style .'">';
1251 if (!$readonly && $display_preferences) {
1252 echo '<div class="widget_preferences">'. $widget->getPreferencesForm($layout_id, $owner_id, $owner_type) .'</div>';
1254 if ($widget->isAjax()) {
1255 echo '<div id="'. $element_id .'-ajax">';
1256 echo '<noscript><iframe width="99%" frameborder="0" src="'. $widget->getIframeUrl($owner_id, $owner_type) .'"></iframe></noscript>';
1259 echo $widget->getContent();
1262 if ($widget->isAjax()) {
1263 echo '<script type="text/javascript">'."
1264 document.observe('dom:loaded', function () {
1265 $('$element_id-ajax').update('<div style=\"text-align:center\">". $this->getPicto('ic/spinner.gif','spinner','spinner') ."</div>');
1266 new Ajax.Updater('$element_id-ajax',
1267 '". $widget->getAjaxUrl($owner_id, $owner_type) ."'
1275 function _getTogglePlusForWidgets() {
1276 return 'ic/toggle_plus.png';
1279 function _getToggleMinusForWidgets() {
1280 return 'ic/toggle_minus.png';
1283 /* Get the navigation links for the software map pages (trove,
1284 * tag cloud, full project list) according to what's enabled
1286 function printSoftwareMapLinks() {
1287 $subMenuTitle = array();
1288 $subMenuUrl = array();
1290 if (forge_get_config('use_project_tags')) {
1291 $subMenuTitle[] = _('Tag cloud');
1292 $subMenuUrl[] = '/softwaremap/tag_cloud.php';
1295 if (forge_get_config('use_trove')) {
1296 $subMenuTitle[] = _('Project Tree');
1297 $subMenuUrl[] = '/softwaremap/trove_list.php';
1300 if (forge_get_config('use_project_full_list')) {
1301 $subMenuTitle[] = _('Project List');
1302 $subMenuUrl[] = '/softwaremap/full_list.php';
1305 echo $this->subMenu($subMenuTitle, $subMenuUrl);
1312 // c-file-style: "bsd"