5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright 2010 - Alain Peyrat
7 * Copyright 2010-2011, Franck Villaume - Capgemini
8 * Copyright 2010-2011, Alain Peyrat - Alcatel-Lucent
9 * http://fusionforge.org
11 * This file is part of FusionForge.
13 * FusionForge is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * FusionForge is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with FusionForge; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 * Extends the basic Error class to add HTML functions
31 * for displaying all site dependent HTML, while allowing
32 * extendibility/overriding by themes via the Theme class.
34 * Make sure browser.php is included _before_ you create an instance
39 require_once $gfcommon.'include/constants.php';
40 require_once $gfcommon.'include/FusionForge.class.php';
41 require_once $gfcommon.'include/Navigation.class.php';
43 class Layout extends Error {
46 * Which doctype to use. Can be configured in the
47 * constructor. If set to 'strict', headerHTMLDeclaration will
48 * create a doctype definition that uses the strict doctype,
49 * otherwise it will use the transitional doctype.
50 * @var string $doctype
52 var $doctype = 'transitional';
55 * The default main page content
56 * @var string $rootindex
58 var $rootindex = 'index_std.php';
61 * The base directory of the theme in the servers file system
62 * @var string $themedir
67 * The base url of the theme
68 * @var string $themeurl
73 * The base directory of the image files in the servers file system
79 * The base url of the image files
80 * @var string $imgbaseurl
85 * The base directory of the js files in the servers file system
91 * The base url of the js files
92 * @var string $jsbaseurl
97 * The navigation object that provides the basic links. Should
103 * The color bars in pm reporting
105 var $COLOR_LTBACK1 = '#C0C0C0';
108 var $js_min = array();
109 var $javascripts = array();
111 var $css_min = array();
112 var $stylesheets = array();
115 * Layout() - Constructor
118 // parent constructor
121 $this->navigation = new Navigation();
123 // determine rootindex
124 if ( file_exists(forge_get_config('custom_path') . '/index_std.php') ) {
125 $this->rootindex = forge_get_config('custom_path') . '/index_std.php';
127 $this->rootindex = $GLOBALS['gfwww'].'index_std.php';
130 // determine theme{dir,url}
131 $this->themedir = forge_get_config('themes_root') . '/' . forge_get_config('default_theme') . '/';
132 if (!file_exists ($this->themedir)) {
133 html_error_top(_("Can't find theme directory!"));
136 $this->themeurl = util_make_url('themes/' . forge_get_config('default_theme') . '/');
138 // determine {css,img,js}{url,dir}
139 if (file_exists ($this->themedir . 'images/')) {
140 $this->imgdir = $this->themedir . 'images/';
141 $this->imgbaseurl = $this->themeurl . 'images/';
143 $this->imgdir = $this->themedir;
144 $this->imgbaseurl = $this->themeurl;
147 if (file_exists ($this->themedir . 'js/')) {
148 $this->jsdir = $this->themedir . 'js/';
149 $this->jsbaseurl = $this->themeurl . 'js/';
151 $this->jsdir = $this->themedir;
152 $this->jsbaseurl = $this->themeurl;
155 $this->addStylesheet('/themes/css/fusionforge.css');
160 * Constructs a list of Javascript files followed by some timestamp
162 * TODO document the purpose of this : probably to avoid caching versions updated on the server
163 * @param string $js path to the JS file
165 function addJavascript($js) {
166 // TODO : what's the point of this ? ... unused ?
167 if (isset($this->js_min[$js])) {
168 $js = $this->js_min[$js];
170 if ($js && !isset($this->js[$js])) {
171 $this->js[$js] = true;
172 $filename = $GLOBALS['fusionforge_basedir'].'/www'.$js;
173 if (file_exists($filename)) {
174 $js .= '?'.date ("U", filemtime($filename));
176 $filename = str_replace('/scripts/', $GLOBALS['fusionforge_basedir'].'/lib/vendor/', $js);
177 if (file_exists($filename)) {
178 $js .= '?'.date ("U", filemtime($filename));
181 $this->javascripts[] = $js;
185 function addStylesheet($css, $media='') {
186 if (isset($this->css_min[$css])) {
187 $css = $this->css_min[$css];
189 if (!isset($this->css[$css])) {
190 $this->css[$css] = true;
191 $filename = $GLOBALS['fusionforge_basedir'].'/www'.$css;
192 if (file_exists($filename)) {
193 $css .= '?'.date ("U", filemtime($filename));
195 $filename = str_replace('/scripts/', $GLOBALS['fusionforge_basedir'].'/lib/vendor/', $css);
196 if (file_exists($filename)) {
197 $css .= '?'.date ("U", filemtime($filename));
200 $this->stylesheets[] = array('css' => $css, 'media' => $media);
204 function getJavascripts() {
206 foreach ($this->javascripts as $js) {
207 $code .= ' <script type="text/javascript" src="'.$js.'"></script>'."\n";
212 function getStylesheets() {
214 foreach ($this->stylesheets as $c) {
216 $code .= ' <link rel="stylesheet" type="text/css" href="'.$c['css'].'" media="'.$c['media'].'" />'."\n";
218 $code .= ' <link rel="stylesheet" type="text/css" href="'.$c['css'].'"/>'."\n";
225 * header() - generates the complete header of page by calling
226 * headerStart() and bodyHeader().
228 function header($params) {
229 $this->headerStart($params); ?>
232 $this->bodyHeader($params);
236 * headerStart() - generates the header code for all themes up to the
238 * Override any of the methods headerHTMLDeclaration(), headerTitle(),
239 * headerFavIcon(), headerRSS(), headerSearch(), headerCSS(), or
240 * headerJS() to adapt your theme.
242 * @param array Header parameters array
244 function headerStart($params) {
245 $this->headerHTMLDeclaration();
248 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
250 plugin_hook('htmlhead', array());
251 $this->headerTitle($params);
252 $this->headerFavIcon();
254 $this->headerSearch();
257 $this->headerForgepluckerMeta();
264 * headerHTMLDeclaration() - generates the HTML declaration, i.e. the
265 * XML declaration, the doctype definition, and the opening <html>.
268 function headerHTMLDeclaration() {
269 print '<?xml version="1.0" encoding="utf-8"?>'."\n";
270 if (isset($this->doctype) && $this->doctype=='strict') {
271 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'."\n";
273 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'."\n";
275 echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="'
276 . _('en') . '" lang="' . _('en') . '">'."\n";
280 * headerTitle() - creates the <title> header
282 * @param array Header parameters array
284 function headerTitle($params) {
285 echo $this->navigation->getTitle($params);
290 * headerFavIcon() - creates the favicon <link> headers.
293 function headerFavIcon() {
294 echo $this->navigation->getFavIcon();
298 * headerRSS() - creates the RSS <link> headers.
301 function headerRSS() {
302 echo $this->navigation->getRSS();
306 * headerSearch() - creates the search <link> header.
309 function headerSearch() {
310 echo '<link rel="search" title="'
311 . forge_get_config ('forge_name').'" href="'
312 . util_make_url ('/export/search_plugin.php')
313 . '" type="application/opensearchdescription+xml"/>'."\n";
317 * Create the CSS headers for all cssfiles in $cssfiles and
318 * calls the plugin cssfile hook.
320 function headerCSS() {
321 plugin_hook ('cssfile',$this);
322 echo $this->getStylesheets();
326 * headerJS() - creates the JS headers and calls the plugin javascript hook
327 * @todo generalize this
329 function headerJS() {
331 <script type="text/javascript" src="/scripts/prototype/prototype.js"></script>
332 <script type="text/javascript" src="/scripts/scriptaculous/scriptaculous.js"></script>
333 <script type="text/javascript" src="/scripts/codendi/Tooltip.js"></script>
334 <script type="text/javascript" src="/scripts/codendi/LayoutManager.js"></script>
335 <script type="text/javascript" src="/scripts/codendi/ReorderColumns.js"></script>
336 <script type="text/javascript" src="/scripts/codendi/codendi-1236793993.js"></script>
337 <script type="text/javascript" src="/scripts/codendi/validate.js"></script>
338 <script type="text/javascript" src="'. util_make_uri('/js/common.js') .'"></script>';
339 plugin_hook ("javascript_file",false);
340 echo $this->getJavascripts();
341 echo '<script type="text/javascript">';
342 plugin_hook ("javascript",false);
347 function headerForgepluckerMeta() {
349 * Forge-Identification Meta Header, Version 1.0
350 * cf. http://home.gna.org/forgeplucker/forge-identification.html
352 $ff = new FusionForge();
353 return sprintf('<meta name="Forge-Identification" content="%s:%s" />',
355 $ff->software_version) . "\n";
358 function bodyHeader($params){
361 <table border="0" width="100%" cellspacing="0" cellpadding="0" id="headertable">
363 <td><a href="<?php echo util_make_url ('/'); ?>"><?php echo html_image('logo.png',198,52,array('border'=>'0')); ?></a></td>
364 <td><?php $this->searchBox(); ?></td>
365 <td align="right"><?php
366 $items = $this->navigation->getUserLinks();
367 for ($j = 0; $j < count($items['titles']); $j++) {
368 echo util_make_link($items['urls'][$j], $items['titles'][$j], array('class'=>'lnkutility'), true);
371 $params['template'] = ' {menu}';
372 plugin_hook('headermenu', $params);
377 <td> </td>
382 <table border="0" width="100%" cellspacing="0" cellpadding="0">
388 <?php echo $this->outerTabs($params); ?>
395 <td align="left" class="toptab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topleft.png" height="9" width="9" alt="" /></td>
396 <td class="toptab" width="30"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="30" height="1" alt="" /></td>
397 <td class="toptab"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
398 <td class="toptab" width="30"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="30" height="1" alt="" /></td>
399 <td align="right" class="toptab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topright.png" height="9" width="9" alt="" /></td>
404 <!-- Outer body row -->
406 <td class="toptab"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="10" height="1" alt="" /></td>
407 <td valign="top" width="99%" class="toptab" colspan="3">
409 <!-- Inner Tabs / Shell -->
411 <table border="0" width="100%" cellspacing="0" cellpadding="0">
415 if (isset($params['group']) && $params['group']) {
423 echo $this->projectTabs($params['toptab'],$params['group']);
433 <td align="left" class="projecttab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topleft-inner.png" height="9" width="9" alt="" /></td>
434 <td class="projecttab" ><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
435 <td align="right" class="projecttab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topright-inner.png" height="9" width="9" alt="" /></td>
439 <td class="projecttab" ><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="10" height="1" alt="" /></td>
440 <td valign="top" width="99%" class="projecttab">
446 function footer($params) {
450 <!-- end main body row -->
453 <td width="10" class="footer3" ><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="2" height="1" alt="" /></td>
456 <td align="left" class="footer1" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomleft-inner.png" height="11" width="11" alt="" /></td>
457 <td class="footer3"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
458 <td align="right" class="footer1" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomright-inner.png" height="11" width="11" alt="" /></td>
462 <!-- end inner body row -->
465 <td width="10" class="footer2"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="2" height="1" alt="" /></td>
468 <td align="left" class="footer2" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomleft.png" height="9" width="9" alt="" /></td>
469 <td class="footer2" colspan="3"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
470 <td align="right" class="footer2" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomright.png" height="9" width="9" alt="" /></td>
474 $this->footerEnd($params);
477 function footerEnd($params) { ?>
479 <!-- PLEASE LEAVE "Powered By FusionForge" on your site -->
481 <?php echo $this->navigation->getPoweredBy(); ?>
484 <?php echo $this->navigation->getShowSource(); ?>
492 function getRootIndex() {
493 return $this->rootindex;
497 * boxTop() - Top HTML box.
499 * @param string Box title
500 * @return string the html code
502 function boxTop($title) {
504 <!-- Box Top Start -->
506 <table cellspacing="0" cellpadding="0" width="100%" border="0" style="background:url('.$this->imgbaseurl.'vert-grad.png)">
507 <tr class="align-center">
508 <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>
509 <td width="100%" style="background:url('.$this->imgbaseurl.'box-grad.png)"><span class="titlebar">'.$title.'</span></td>
510 <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>
514 <table cellspacing="2" cellpadding="2" width="100%" border="0">
518 <!-- Box Top End -->';
522 * boxMiddle() - Middle HTML box.
524 * @param string Box title
525 * @return string The html code
527 function boxMiddle($title) {
529 <!-- Box Middle Start -->
532 <tr class="align-center">
533 <td colspan="2" style="background:url('.$this->imgbaseurl.'box-grad.png)"><span class="titlebar">'.$title.'</span></td>
537 <!-- Box Middle End -->';
541 * boxBottom() - Bottom HTML box.
543 * @return string the html code
545 function boxBottom() {
547 <!-- Box Bottom Start -->
554 <!-- Box Bottom End -->';
558 * boxGetAltRowStyle() - Get an alternating row style for tables.
560 * @param int Row number
561 * @return string the class code
563 function boxGetAltRowStyle($i) {
565 return ' class="altRowStyleEven"';
567 return ' class="altRowStyleOdd"';
572 * listTableTop() - Takes an array of titles and builds the first row of a new table.
574 * @param array The array of titles
575 * @param array The array of title links
576 * @param string The css classes to add (optional)
577 * @param string The id of the table (needed by sortable for example)
578 * @param array specific class for th column
579 * @return string the html code
581 function listTableTop($titleArray, $linksArray=false, $class='', $id='', $thClassArray=array()) {
584 $args .= ' class="listing '.$class.'"';
586 $args .= ' class="listing full"';
589 $args .= ' id="'.$id.'"';
594 if (count($titleArray)) {
595 $return .= '<thead><tr>';
597 $count=count($titleArray);
598 for ($i=0; $i<$count; $i++) {
600 if ($thClassArray && $thClassArray[$i]) {
601 $th .= ' class="'.$thClassArray[$i].'"';
603 $cell = $titleArray[$i];
605 $cell = util_make_link($linksArray[$i],$titleArray[$i]);
607 $return .= "\n".' <th'.$th.'>'.$cell.'</th>';
609 $return .= "\n".'</tr></thead>'."\n";
611 $return .= '<tbody>';
615 function listTableBottom() {
616 return '</tbody>'."\n".'</table>';
619 function outerTabs($params) {
620 $menu = $this->navigation->getSiteMenu();
621 echo $this->tabGenerator($menu['urls'], $menu['titles'], false, $menu['selected'], '');
625 * Prints out the quicknav menu, contained here in case we
626 * want to allow it to be overridden.
628 function quickNav() {
629 if (!session_loggedin()) {
632 // get all projects that the user belongs to
633 $groups = session_get_user()->getGroups();
635 if (count($groups) < 1) {
638 sortProjectList($groups);
641 <form id="quicknavform" name="quicknavform" action=""><div>
642 <select name="quicknav" id="quicknav" onChange="location.href=document.quicknavform.quicknav.value">
643 <option value="">'._('Quick Jump To...').'</option>';
645 foreach ($groups as $g) {
646 $group_id = $g->getID();
647 $menu = $this->navigation->getProjectMenu($group_id);
650 <option value="' . $menu['starturl'] . '">'
651 . $menu['name'] .'</option>';
653 for ($j = 0; $j < count($menu['urls']); $j++) {
655 <option value="' . $menu['urls'][$j] .'"> '
656 . $menu['titles'][$j] . '</option>';
657 if (@$menu['adminurls'][$j]) {
659 <option value="' . $menu['adminurls'][$j]
660 . '"> '
661 . _('Admin') . '</option>';
673 * projectTabs() - Prints out the project tabs, contained here in case
674 * we want to allow it to be overriden.
676 * @param string Is the tab currently selected
677 * @param string Is the group we should look up get title info
679 function projectTabs($toptab, $group_id) {
680 // get group info using the common result set
681 $menu = $this->navigation->getProjectMenu($group_id, $toptab);
682 echo $this->tabGenerator($menu['urls'], $menu['titles'], true, $menu['selected'], 'white');
685 function tabGenerator($TABS_DIRS,$TABS_TITLES,$nested=false,$selected=false,$sel_tab_bgcolor='white',$total_width='100%') {
687 $count=count($TABS_DIRS);
688 $width=intval((100/$count));
693 <table class="tabGenerator" ';
695 if ($total_width != '100%') {
696 $return .= 'style="width:' . $total_width . ';"';
706 for ($i=0; $i<$count; $i++) {
709 // this is the first tab, choose an image with end-name
712 $issel=($selected==$i);
713 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
714 // $rowspan=(($issel)?'rowspan="2" ' : '');
717 <td '.$rowspan.'valign="top" width="10" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-end-'.(($issel) ? '' : 'not').'selected.png)">'.
718 '<img src="'.$this->imgbaseurl . 'clear.png" height="25" width="10" alt="" /></td>'.
719 '<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>';
720 } elseif ($i==$count-1) {
722 // this is the last tab, choose an image with name-end
724 $wassel=($selected==$i-1);
725 $issel=($selected==$i);
726 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
727 // $rowspan=(($issel)?'rowspan="2" ' : '');
729 // Build image between current and prior tab
732 <td '.$rowspan.'colspan="2" valign="top" width="20" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-'.(($wassel) ? '' : 'not').'selected-'.(($issel) ? '' : 'not').'selected.png)">'.
733 '<img src="'.$this->imgbaseurl . 'clear.png" height="2" width="20" alt="" /></td>'.
734 '<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>';
736 // Last graphic on right-side
739 <td '.$rowspan.'valign="top" width="10" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-'.(($issel) ? '' : 'not').'selected-end.png)">'.
740 '<img src="'.$this->imgbaseurl . 'clear.png" height="2" width="10" alt="" /></td>';
746 $wassel=($selected==$i-1);
747 $issel=($selected==$i);
748 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
749 // $rowspan=(($issel)?'rowspan="2" ' : '');
751 // Build image between current and prior tab
754 <td '.$rowspan.'colspan="2" valign="top" width="20" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-'.(($wassel) ? '' : 'not').'selected-'.(($issel) ? '' : 'not').'selected.png)">'.
755 '<img src="'.$this->imgbaseurl . 'clear.png" height="2" width="20" alt="" /></td>'.
756 '<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>';
763 // Building a bottom row in this table, which will be darker
765 if ($selected == 0) {
767 $end_cols=((count($TABS_DIRS)*3)-3);
768 } elseif ($selected == (count($TABS_DIRS)-1)) {
769 $beg_cols=((count($TABS_DIRS)*3)-3);
772 $beg_cols=($selected*3);
773 $end_cols=(((count($TABS_DIRS)*3)-3)-$beg_cols);
777 $return .= '<td colspan="'.$beg_cols.'" height="1" class="notSelTab"><img src="'.$this->imgbaseurl.'clear.png" height="1" width="10" alt="" /></td>';
779 $return .= '<td colspan="3" height="1" class="selTab"><img src="'.$this->imgbaseurl.'clear.png" height="1" width="10" alt="" /></td>';
781 $return .= '<td colspan="'.$end_cols.'" height="1" class="notSelTab"><img src="'.$this->imgbaseurl.'clear.png" height="1" width="10" alt="" /></td>';
793 function searchBox() {
794 echo $this->navigation->getSearchBox();
798 * beginSubMenu() - Opening a submenu.
800 * @return string Html to start a submenu.
802 function beginSubMenu() {
809 * endSubMenu() - Closing a submenu.
811 * @return string Html to end a submenu.
813 function endSubMenu() {
814 $return = '</strong></p>';
819 * printSubMenu() - Takes two array of titles and links and builds the contents of a menu.
821 * @param array The array of titles.
822 * @param array The array of title links.
823 * @param array The array of string for title attributes.
824 * @return string Html to build a submenu.
826 function printSubMenu($title_arr, $links_arr, $attr_arr) {
827 $count=count($title_arr);
831 for ($i=0; $i<$count; $i++) {
832 $return .= util_make_link($links_arr[$i],$title_arr[$i],$attr_arr[$i]).' | ';
834 $return .= util_make_link($links_arr[$i],$title_arr[$i],$attr_arr[$i]);
839 * subMenu() - Takes two array of titles and links and build a menu.
841 * @param array The array of titles.
842 * @param array The array of title links.
843 * @param array The array of string for title attributes.
844 * @return string Html to build a submenu.
846 function subMenu($title_arr, $links_arr, $attr_arr = false) {
847 $return = $this->beginSubMenu();
848 $return .= $this->printSubMenu($title_arr, $links_arr, $attr_arr);
849 $return .= $this->endSubMenu();
854 * multiTableRow() - create a mutlilevel row in a table
856 * @param string the row attributes
857 * @param array the array of cell data, each element is an array,
858 * the first item being the text,
859 * the subsequent items are attributes (dont include
860 * the bgcolor for the title here, that will be
861 * handled by $istitle
862 * @param boolean is this row part of the title ?
863 * @return string the html code
865 function multiTableRow($row_attr, $cell_data, $istitle) {
869 $return .=' class="align-center multiTableRowTitle"';
872 for ( $c = 0; $c < count($cell_data); $c++ ) {
874 for ( $a=1; $a < count($cell_data[$c]); $a++) {
875 $return .= $cell_data[$c][$a].' ';
879 $return .='<span class="multiTableRowTitle">';
881 $return .= $cell_data[$c][0];
895 * feedback() - returns the htmlized feedback string when an action is performed.
897 * @param string feedback string
898 * @return string htmlized feedback
900 function feedback($feedback) {
905 <div class="feedback">'.strip_tags($feedback, '<br>').'</div>';
909 * warning_msg() - returns the htmlized warning string when an action is performed.
911 * @param string msg string
912 * @return string htmlized warning
914 function warning_msg($msg) {
919 <div class="warning_msg">'.strip_tags($msg, '<br>').'</div>';
924 * error_msg() - returns the htmlized error string when an action is performed.
926 * @param string msg string
927 * @return string htmlized error
929 function error_msg($msg) {
934 <div class="error">'.strip_tags($msg, '<br>').'</div>';
940 * getThemeIdFromName()
942 * @param string the dirname of the theme
943 * @return integer the theme id
945 function getThemeIdFromName($dirname) {
946 $res = db_query_params ('SELECT theme_id FROM themes WHERE dirname=$1',
948 return db_result($res,0,'theme_id');
951 function confirmBox($msg, $params, $buttons, $image='*none*') {
952 if ($image == '*none*') {
953 $image = html_image('stop.png','48','48',array());
956 foreach ($params as $b => $v) {
957 $prms[] = '<input type="hidden" name="'.$b.'" value="'.$v.'" />'."\n";
959 $prm = join(' ', $prms);
961 foreach ($buttons as $b => $v) {
962 $btns[] = '<input type="submit" name="'.$b.'" value="'.$v.'" />'."\n";
964 $btn = join(' '."\n ", $btns);
967 <div id="infobox" style="margin-top: 15%; margin-left: 15%; margin-right: 15%; text-align: center;">
968 <table align="center">
971 <td>'.$msg.'<br/></td>
974 <td colspan="2" align="center">
976 <form action="' . getStringFromServer('PHP_SELF') . '" method="get" >
987 function html_input($name, $id = '', $label = '', $type = 'text', $value = '', $extra_params = '') {
991 $return = '<div class="field-holder">
994 $return .= '<label for="' . $id . '">' . $label . '</label>
997 $return .= '<input id="' . $id . '" type="' . $type . '"';
998 //if input is a submit then name is not present
1000 $return .= ' name="' . $name . '"';
1003 $return .= ' value="' . $value . '"';
1005 if (is_array($extra_params)) {
1006 foreach ($extra_params as $key => $extra_params_value) {
1007 $return .= $key . '="' . $extra_params_value . '" ';
1015 function html_checkbox($name, $value, $id = '', $label = '', $checked = '', $extra_params = '') {
1019 $return = '<div class="field-holder">
1021 $return .= '<input name="' . $name . '" id="' . $id . '" type="checkbox" value="' . $value . '" ';
1023 $return .= 'checked="checked" ';
1025 if (is_array($extra_params)) {
1026 foreach ($extra_params as $key => $extra_params_value) {
1027 $return .= $key . '="' . $extra_params_value . '" ';
1032 $return .= '<label for="' . $id . '">' . $label . '</label>
1035 $return .= '</div>';
1039 function html_text_input_img_submit($name, $img_src, $id = '', $label = '', $value = '', $img_title = '', $img_alt = '', $extra_params = '', $img_extra_params = '') {
1047 $img_alt = $img_title;
1049 $return = '<div class="field-holder">
1052 $return .= '<label for="' . $id . '">' . $label . '</label>
1055 $return .= '<input id="' . $id . '" type="text" name="' . $name . '"';
1057 $return .= ' value="' . $value . '"';
1059 if (is_array($extra_params)) {
1060 foreach ($extra_params as $key => $extra_params_value) {
1061 $return .= $key . '="' . $extra_params_value . '" ';
1065 <input type="image" id="' . $id . '_submit" src="' . $this->imgbaseurl . $img_src . '" alt="' . $img_alt . '" title="' . $img_title . '"';
1066 if (is_array($img_extra_params)) {
1067 foreach ($img_extra_params as $key => $img_extra_params_value) {
1068 $return .= $key . '="' . $img_extra_params_value . '" ';
1076 function html_select($vals, $name, $label = '', $id = '', $checked_val = '', $text_is_value = false, $extra_params = '') {
1080 $return = '<div class="field-holder">
1083 $return .= '<label for="' . $id . '">' . $label . '</label>
1086 $return .= '<select name="' . $name . '" id="' . $id . '" ';
1087 if (is_array($extra_params)) {
1088 foreach ($extra_params as $key => $extra_params_value) {
1089 $return .= $key . '="' . $extra_params_value . '" ';
1093 $rows = count($vals);
1094 for ($i = 0; $i < $rows; $i++) {
1095 if ( $text_is_value ) {
1097 <option value="' . $vals[$i] . '"';
1098 if ($vals[$i] == $checked_val) {
1099 $return .= ' selected="selected"';
1103 <option value="' . $i . '"';
1104 if ($i == $checked_val) {
1105 $return .= ' selected="selected"';
1108 $return .= '>' . htmlspecialchars($vals[$i]) . '</option>';
1116 function html_textarea($name, $id = '', $label = '', $value = '', $extra_params = '') {
1120 $return = '<div class="field-holder">
1123 $return .= '<label for="' . $id . '">' . $label . '</label>
1126 $return .= '<textarea id="' . $id . '" name="' . $name . '" ';
1127 if (is_array($extra_params)) {
1128 foreach ($extra_params as $key => $extra_params_value) {
1129 $return .= $key . '="' . $extra_params_value . '" ';
1136 $return .= '</textarea>
1142 * @todo use listTableTop and make this function deprecated ?
1144 function html_table_top($cols, $summary = '', $class = '', $extra_params = '') {
1145 $return = '<table summary="' . $summary . '" ';
1147 $return .= 'class="' . $class . '" ';
1149 if (is_array($extra_params)) {
1150 foreach ($extra_params as $key => $extra_params_value) {
1151 $return .= $key . '="' . $extra_params_value . '" ';
1155 $return .= '<thead><tr>';
1156 $nbCols = count($cols);
1157 for ($i = 0; $i < $nbCols; $i++) {
1158 $return .= '<th scope="col">' . $cols[$i] . '</th>';
1160 $return .= '</tr></thead>';
1164 function getMonitorPic($title = '', $alt = '') {
1165 return $this->getPicto('ic/mail16w.png', $title, $alt, '15', '15');
1168 function getReleaseNotesPic($title = '', $alt = '') {
1169 return $this->getPicto('ic/manual16c.png', $title, $alt, '15', '15');
1172 /* no picto for download */
1173 function getDownloadPic($title = '', $alt = '') {
1174 return $this->getPicto('ic/save.png', $title, $alt, '15', '15');
1177 function getHomePic($title = '', $alt = '') {
1178 return $this->getPicto('ic/home16b.png', $title, $alt);
1181 function getFollowPic($title = '', $alt = '') {
1182 return $this->getPicto('ic/tracker20g.png', $title, $alt);
1185 function getForumPic($title = '', $alt = '') {
1186 return $this->getPicto('ic/forum20g.png', $title, $alt);;
1189 function getDocmanPic($title = '', $alt = '') {
1190 return $this->getPicto('ic/docman16b.png', $title, $alt);
1193 function getMailPic($title = '', $alt = '') {
1194 return $this->getPicto('ic/mail16b.png', $title, $alt);
1197 function getPmPic($title = '', $alt = '') {
1198 return $this->getPicto('ic/taskman20g.png', $title, $alt);
1201 function getSurveyPic($title = '', $alt = '') {
1202 return $this->getPicto('ic/survey16b.png', $title, $alt);
1205 function getScmPic($title = '', $alt = '') {
1206 return $this->getPicto('ic/cvs16b.png', $title, $alt);
1209 function getFtpPic($title = '', $alt = '') {
1210 return $this->getPicto('ic/ftp16b.png', $title, $alt);
1213 function getPicto($url, $title, $alt, $width = '20', $height = '20') {
1217 return html_image($url, $width, $height, array('title'=>$title, 'alt'=>$alt));
1221 * toSlug() - protect a string to be used as a link or an anchor
1223 * @param string $string the string used as a link or an anchor
1224 * @param string $space the caracter used as a replacement for a space
1225 * @return a protected string with only alphanumeric caracters
1227 function toSlug($string, $space = "-") {
1228 if (function_exists('iconv')) {
1229 $string = @iconv('UTF-8', 'ASCII//TRANSLIT', $string);
1231 $string = preg_replace("/[^a-zA-Z0-9- ]/", "-", $string);
1232 $string = strtolower($string);
1233 $string = str_replace(" ", $space, $string);
1237 function widget(&$widget, $layout_id, $readonly, $column_id, $is_minimized, $display_preferences, $owner_id, $owner_type) {
1238 $element_id = 'widget_'. $widget->id .'-'. $widget->getInstanceId();
1239 echo '<div class="widget" id="'. $element_id .'">';
1240 echo '<div class="widget_titlebar '. ($readonly?'':'widget_titlebar_handle') .'">';
1241 echo '<div class="widget_titlebar_title">'. $widget->getTitle() .'</div>';
1243 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>';
1244 if ($is_minimized) {
1245 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>';
1247 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>';
1249 if (strlen($widget->hasPreferences())) {
1250 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>';
1253 if ($widget->hasRss()) {
1254 echo '<div class="widget_titlebar_rss"><a href="'.$widget->getRssUrl($owner_id, $owner_type).'">rss</a></div>';
1258 if ($is_minimized) {
1259 $style = 'display:none;';
1261 echo '<div class="widget_content" style="'. $style .'">';
1262 if (!$readonly && $display_preferences) {
1263 echo '<div class="widget_preferences">'. $widget->getPreferencesForm($layout_id, $owner_id, $owner_type) .'</div>';
1265 if ($widget->isAjax()) {
1266 echo '<div id="'. $element_id .'-ajax">';
1267 echo '<noscript><iframe width="99%" frameborder="0" src="'. $widget->getIframeUrl($owner_id, $owner_type) .'"></iframe></noscript>';
1270 echo $widget->getContent();
1273 if ($widget->isAjax()) {
1274 echo '<script type="text/javascript">'."
1275 document.observe('dom:loaded', function () {
1276 $('$element_id-ajax').update('<div style=\"text-align:center\">". $this->getPicto('ic/spinner.gif','spinner','spinner') ."</div>');
1277 new Ajax.Updater('$element_id-ajax',
1278 '". $widget->getAjaxUrl($owner_id, $owner_type) ."'
1286 function _getTogglePlusForWidgets() {
1287 return 'ic/toggle_plus.png';
1290 function _getToggleMinusForWidgets() {
1291 return 'ic/toggle_minus.png';
1294 /* Get the navigation links for the software map pages (trove,
1295 * tag cloud, full project list) according to what's enabled
1297 function printSoftwareMapLinks() {
1298 $subMenuTitle = array();
1299 $subMenuUrl = array();
1301 if (forge_get_config('use_project_tags')) {
1302 $subMenuTitle[] = _('Tag cloud');
1303 $subMenuUrl[] = '/softwaremap/tag_cloud.php';
1306 if (forge_get_config('use_trove')) {
1307 $subMenuTitle[] = _('Project Tree');
1308 $subMenuUrl[] = '/softwaremap/trove_list.php';
1311 if (forge_get_config('use_project_full_list')) {
1312 $subMenuTitle[] = _('Project List');
1313 $subMenuUrl[] = '/softwaremap/full_list.php';
1316 echo $this->subMenu($subMenuTitle, $subMenuUrl);
1322 // c-file-style: "bsd"