5 * Copyright 1999-2001 (c) VA Linux Systems
6 * Copyright 2010 - Alain Peyrat
7 * Copyright 2010-2011, Franck Villaume - Capgemini
8 * Copyright 2010-2012, Alain Peyrat - Alcatel-Lucent
9 * Copyright © 2011 Thorsten Glaser – tarent GmbH
10 * Copyright 2011 - Marc-Etienne Vargenau, Alcatel-Lucent
11 * Copyright 2012 - Franck Villaume - TrivialDev
12 * Copyright (C) 2012 Alain Peyrat - Alcatel-Lucent
13 * http://fusionforge.org
15 * This file is part of FusionForge. FusionForge is free software;
16 * you can redistribute it and/or modify it under the terms of the
17 * GNU General Public License as published by the Free Software
18 * Foundation; either version 2 of the Licence, or (at your option)
21 * FusionForge is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License along
27 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
28 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
33 * Extends the basic Error class to add HTML functions
34 * for displaying all site dependent HTML, while allowing
35 * extendibility/overriding by themes via the Theme class.
37 * Make sure browser.php is included _before_ you create an instance
42 require_once $gfcommon.'include/constants.php';
43 require_once $gfcommon.'include/FusionForge.class.php';
44 require_once $gfcommon.'include/Navigation.class.php';
46 class Layout extends Error {
49 * Which doctype to use. Can be configured in the
50 * constructor. If set to 'strict', headerHTMLDeclaration will
51 * create a doctype definition that uses the strict doctype,
52 * otherwise it will use the transitional doctype.
53 * @var string $doctype
55 var $doctype = 'transitional';
58 * The default main page content
59 * @var string $rootindex
61 var $rootindex = 'index_std.php';
64 * The base directory of the theme in the servers file system
65 * @var string $themedir
70 * The base url of the theme
71 * @var string $themeurl
76 * The base directory of the image files in the servers file system
82 * The base url of the image files
83 * @var string $imgbaseurl
88 * The base directory of the js files in the servers file system
94 * The base url of the js files
95 * @var string $jsbaseurl
100 * The navigation object that provides the basic links. Should
106 * The color bars in pm reporting
108 var $COLOR_LTBACK1 = '#C0C0C0';
111 var $js_min = array();
112 var $javascripts = array();
114 var $css_min = array();
115 var $stylesheets = array();
118 * Layout() - Constructor
121 // parent constructor
124 $this->navigation = new Navigation();
126 // determine rootindex
127 if ( file_exists(forge_get_config('custom_path') . '/index_std.php') ) {
128 $this->rootindex = forge_get_config('custom_path') . '/index_std.php';
130 $this->rootindex = $GLOBALS['gfwww'].'index_std.php';
133 // determine theme{dir,url}
134 $this->themedir = forge_get_config('themes_root') . '/' . forge_get_config('default_theme') . '/';
135 if (!file_exists ($this->themedir)) {
136 html_error_top(_("Can't find theme directory!"));
139 $this->themeurl = util_make_url('themes/' . forge_get_config('default_theme') . '/');
141 // determine {css,img,js}{url,dir}
142 if (file_exists ($this->themedir . 'images/')) {
143 $this->imgdir = $this->themedir . 'images/';
144 $this->imgbaseurl = $this->themeurl . 'images/';
146 $this->imgdir = $this->themedir;
147 $this->imgbaseurl = $this->themeurl;
150 if (file_exists ($this->themedir . 'js/')) {
151 $this->jsdir = $this->themedir . 'js/';
152 $this->jsbaseurl = $this->themeurl . 'js/';
154 $this->jsdir = $this->themedir;
155 $this->jsbaseurl = $this->themeurl;
158 $this->addStylesheet('/themes/css/fusionforge.css');
163 * Build the list of required Javascript files.
165 * If js file is found, then a timestamp is automatically added to ensure
166 * that file is cached only if not changed.
168 * @param string $js path to the JS file
170 function addJavascript($js) {
171 // If a minified version of the javascript is available, then use it.
172 if (isset($this->js_min[$js])) {
173 $js = $this->js_min[$js];
175 if ($js && !isset($this->js[$js])) {
176 $this->js[$js] = true;
177 $filename = $GLOBALS['fusionforge_basedir'].'/www'.$js;
178 if (file_exists($filename)) {
179 $js .= '?'.date ("U", filemtime($filename));
181 $filename = str_replace('/scripts/', $GLOBALS['fusionforge_basedir'].'/lib/vendor/', $js);
182 if (file_exists($filename)) {
183 $js .= '?'.date ("U", filemtime($filename));
186 $this->javascripts[] = $js;
190 function addStylesheet($css, $media='') {
191 if (isset($this->css_min[$css])) {
192 $css = $this->css_min[$css];
194 if (!isset($this->css[$css])) {
195 $this->css[$css] = true;
196 $filename = $GLOBALS['fusionforge_basedir'].'/www'.$css;
197 if (file_exists($filename)) {
198 $css .= '?'.date ("U", filemtime($filename));
200 $filename = str_replace('/scripts/', $GLOBALS['fusionforge_basedir'].'/lib/vendor/', $css);
201 if (file_exists($filename)) {
202 $css .= '?'.date ("U", filemtime($filename));
205 $this->stylesheets[] = array('css' => $css, 'media' => $media);
209 function getJavascripts() {
211 foreach ($this->javascripts as $js) {
213 $code .= '<script type="text/javascript" src="'.$js.'"></script>'."\n";
218 function getStylesheets() {
220 foreach ($this->stylesheets as $c) {
223 $code .= '<link rel="stylesheet" type="text/css" href="'.$c['css'].'" media="'.$c['media'].'" />'."\n";
225 $code .= '<link rel="stylesheet" type="text/css" href="'.$c['css'].'"/>'."\n";
232 * header() - generates the complete header of page by calling
233 * headerStart() and bodyHeader().
235 function header($params) {
236 $this->headerStart($params); ?>
239 $this->bodyHeader($params);
243 * headerStart() - generates the header code for all themes up to the
245 * Override any of the methods headerHTMLDeclaration(), headerTitle(),
246 * headerFavIcon(), headerRSS(), headerSearch(), headerCSS(), or
247 * headerJS() to adapt your theme.
249 * @param array Header parameters array
251 function headerStart($params) {
252 $this->headerHTMLDeclaration();
255 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
256 <?php if (isset($params['meta-description'])) { ?>
257 <meta name="description" content="<?php echo $params['meta-description'] ?>" />
259 <?php if (isset($params['meta-keywords'])) { ?>
260 <meta name="keywords" content="<?php echo $params['meta-keywords'] ?>" />
263 plugin_hook('htmlhead', array());
264 $this->headerTitle($params);
265 $this->headerFavIcon();
267 $this->headerSearch();
270 $this->headerForgepluckerMeta();
277 * headerHTMLDeclaration() - generates the HTML declaration, i.e. the
278 * XML declaration, the doctype definition, and the opening <html>.
281 function headerHTMLDeclaration() {
282 global $sysDTDs, $sysXMLNSs;
284 print '<?xml version="1.0" encoding="utf-8"?>'."\n";
285 if (!util_ifsetor($this->doctype) || !util_ifsetor($sysDTDs[$this->doctype])) {
286 $this->doctype = 'transitional';
288 echo $sysDTDs[$this->doctype]['doctype'] . "\n";
289 echo '<html xml:lang="' . _('en') . '" lang="' . _('en') .
290 '" ' . $sysXMLNSs . ">\n";
294 * headerTitle() - creates the <title> header
296 * @param array Header parameters array
298 function headerTitle($params) {
299 echo $this->navigation->getTitle($params);
304 * headerFavIcon() - creates the favicon <link> headers.
307 function headerFavIcon() {
308 echo $this->navigation->getFavIcon();
312 * headerRSS() - creates the RSS <link> headers.
315 function headerRSS() {
316 echo $this->navigation->getRSS();
320 * headerSearch() - creates the search <link> header.
323 function headerSearch() {
324 echo '<link rel="search" title="'
325 . forge_get_config ('forge_name').'" href="'
326 . util_make_url ('/export/search_plugin.php')
327 . '" type="application/opensearchdescription+xml"/>'."\n";
331 * Create the CSS headers for all cssfiles in $cssfiles and
332 * calls the plugin cssfile hook.
334 function headerCSS() {
335 plugin_hook ('cssfile',$this);
336 echo $this->getStylesheets();
340 * headerJS() - creates the JS headers and calls the plugin javascript hook
341 * @todo generalize this
343 function headerJS() {
345 <script type="text/javascript" src="/scripts/prototype/prototype.js"></script>
346 <script type="text/javascript" src="/scripts/scriptaculous/scriptaculous.js"></script>
347 <script type="text/javascript" src="/scripts/codendi/Tooltip.js"></script>
348 <script type="text/javascript" src="/scripts/codendi/LayoutManager.js"></script>
349 <script type="text/javascript" src="/scripts/codendi/ReorderColumns.js"></script>
350 <script type="text/javascript" src="/scripts/codendi/codendi-1236793993.js"></script>
351 <script type="text/javascript" src="/scripts/codendi/validate.js"></script>
352 <script type="text/javascript" src="'. util_make_uri('/js/common.js') .'"></script>
353 <script language="JavaScript" type="text/javascript">/* <![CDATA[ */';
354 plugin_hook ("javascript",false);
357 plugin_hook ("javascript_file",false);
358 echo $this->getJavascripts();
360 // invoke the 'javascript' hook for custom javascript addition
361 $params = array('return' => false);
362 plugin_hook("javascript",$params);
363 $javascript = $params['return'];
365 echo '<script type="text/javascript">';
372 function headerForgepluckerMeta() {
374 * Forge-Identification Meta Header, Version 1.0
375 * cf. http://home.gna.org/forgeplucker/forge-identification.html
378 $ff = new FusionForge();
379 printf('<meta name="Forge-Identification" content="%s:%s" />',
380 $ff->software_type, $ff->software_version);
384 function bodyHeader($params){
387 <table border="0" width="100%" cellspacing="0" cellpadding="0" id="headertable">
389 <td><a href="<?php echo util_make_url ('/'); ?>"><?php echo html_image('logo.png',198,52,array('border'=>'0')); ?></a></td>
390 <td><?php $this->searchBox(); ?></td>
391 <td align="right"><?php
392 $items = $this->navigation->getUserLinks();
393 for ($j = 0; $j < count($items['titles']); $j++) {
394 echo util_make_link($items['urls'][$j], $items['titles'][$j], array('class'=>'lnkutility'), true);
397 $params['template'] = ' {menu}';
398 plugin_hook('headermenu', $params);
403 <td> </td>
408 <table border="0" width="100%" cellspacing="0" cellpadding="0">
414 <?php echo $this->outerTabs($params); ?>
421 <td align="left" class="toptab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topleft.png" height="9" width="9" alt="" /></td>
422 <td class="toptab" width="30"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="30" height="1" alt="" /></td>
423 <td class="toptab"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
424 <td class="toptab" width="30"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="30" height="1" alt="" /></td>
425 <td align="right" class="toptab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topright.png" height="9" width="9" alt="" /></td>
430 <!-- Outer body row -->
432 <td class="toptab"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="10" height="1" alt="" /></td>
433 <td valign="top" width="99%" class="toptab" colspan="3">
435 <!-- Inner Tabs / Shell -->
437 <table border="0" width="100%" cellspacing="0" cellpadding="0">
441 if (isset($params['group']) && $params['group']) {
449 echo $this->projectTabs($params['toptab'],$params['group']);
459 <td align="left" class="projecttab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topleft-inner.png" height="9" width="9" alt="" /></td>
460 <td class="projecttab" ><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
461 <td align="right" class="projecttab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topright-inner.png" height="9" width="9" alt="" /></td>
465 <td class="projecttab" ><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="10" height="1" alt="" /></td>
466 <td valign="top" width="99%" class="projecttab">
472 function footer($params) {
476 <!-- end main body row -->
479 <td width="10" class="footer3" ><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="2" height="1" alt="" /></td>
482 <td align="left" class="footer1" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomleft-inner.png" height="11" width="11" alt="" /></td>
483 <td class="footer3"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
484 <td align="right" class="footer1" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomright-inner.png" height="11" width="11" alt="" /></td>
488 <!-- end inner body row -->
491 <td width="10" class="footer2"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="2" height="1" alt="" /></td>
494 <td align="left" class="footer2" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomleft.png" height="9" width="9" alt="" /></td>
495 <td class="footer2" colspan="3"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
496 <td align="right" class="footer2" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomright.png" height="9" width="9" alt="" /></td>
500 $this->footerEnd($params);
503 function footerEnd($params) { ?>
505 <!-- PLEASE LEAVE "Powered By FusionForge" on your site -->
507 <?php echo $this->navigation->getPoweredBy(); ?>
510 <?php echo $this->navigation->getShowSource();
512 plugin_hook('webanalytics_url', array());
522 function getRootIndex() {
523 return $this->rootindex;
527 * boxTop() - Top HTML box.
529 * @param string Box title
530 * @return string the html code
532 function boxTop($title) {
534 <!-- Box Top Start -->
536 <table class="fullwidth" style="background:url('.$this->imgroot.'vert-grad.png)">
537 <tr class="align-center">
538 <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>
539 <td width="100%" style="background:url('.$this->imgbaseurl.'box-grad.png)"><span class="titlebar">'.$title.'</span></td>
540 <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>
544 <table cellspacing="2" cellpadding="2" width="100%" border="0">
548 <!-- Box Top End -->';
552 * boxMiddle() - Middle HTML box.
554 * @param string Box title
555 * @return string The html code
557 function boxMiddle($title) {
559 <!-- Box Middle Start -->
562 <tr class="align-center">
563 <td colspan="2" style="background:url('.$this->imgbaseurl.'box-grad.png)"><span class="titlebar">'.$title.'</span></td>
565 <tr class="align-left">
567 <!-- Box Middle End -->';
571 * boxBottom() - Bottom HTML box.
573 * @return string the html code
575 function boxBottom() {
577 <!-- Box Bottom Start -->
584 <!-- Box Bottom End -->';
588 * boxGetAltRowStyle() - Get an alternating row style for tables.
590 * @param int Row number
591 * @return string the class code
593 function boxGetAltRowStyle($i) {
595 return ' class="altRowStyleEven"';
597 return ' class="altRowStyleOdd"';
602 * listTableTop() - Takes an array of titles and builds the first row of a new table.
604 * @param array The array of titles
605 * @param array The array of title links
606 * @param string The css classes to add (optional)
607 * @param string The id of the table (needed by sortable for example)
608 * @param array specific class for th column
609 * @return string the html code
611 function listTableTop($titleArray, $linksArray=false, $class='', $id='', $thClassArray=array()) {
614 $args .= ' class="listing '.$class.'"';
616 $args .= ' class="listing full"';
619 $args .= ' id="'.$id.'"';
624 if (count($titleArray)) {
625 $return .= '<thead><tr>';
627 $count=count($titleArray);
628 for ($i=0; $i<$count; $i++) {
630 if ($thClassArray && $thClassArray[$i]) {
631 $th .= ' class="'.$thClassArray[$i].'"';
633 $cell = $titleArray[$i];
635 $cell = util_make_link($linksArray[$i],$titleArray[$i]);
637 $return .= "\n".' <th'.$th.'>'.$cell.'</th>';
639 $return .= "\n".'</tr></thead>'."\n";
641 $return .= '<tbody>';
645 function listTableBottom() {
646 return '</tbody>'."\n".'</table>';
649 function outerTabs($params) {
650 $menu = $this->navigation->getSiteMenu();
651 echo $this->tabGenerator($menu['urls'], $menu['titles'], $menu['tooltips'], false, $menu['selected'], '');
655 * Prints out the quicknav menu, contained here in case we
656 * want to allow it to be overridden.
658 function quickNav() {
659 if (!session_loggedin()) {
662 // get all projects that the user belongs to
663 $groups = session_get_user()->getGroups();
665 if (count($groups) < 1) {
668 sortProjectList($groups);
671 <form id="quicknavform" name="quicknavform" action=""><div>
672 <select name="quicknav" id="quicknav" onchange="location.href=document.quicknavform.quicknav.value">
673 <option value="">'._('Quick Jump To...').'</option>';
675 foreach ($groups as $g) {
676 $group_id = $g->getID();
677 $menu = $this->navigation->getProjectMenu($group_id);
680 <option value="' . $menu['starturl'] . '">'
681 . $menu['name'] .'</option>';
683 for ($j = 0; $j < count($menu['urls']); $j++) {
685 <option value="' . $menu['urls'][$j] .'"> '
686 . $menu['titles'][$j] . '</option>';
687 if (@$menu['adminurls'][$j]) {
689 <option value="' . $menu['adminurls'][$j]
690 . '"> '
691 . _('Admin') . '</option>';
703 * projectTabs() - Prints out the project tabs, contained here in case
704 * we want to allow it to be overriden.
706 * @param string Is the tab currently selected
707 * @param string Is the group we should look up get title info
709 function projectTabs($toptab, $group_id) {
710 // get group info using the common result set
711 $menu = $this->navigation->getProjectMenu($group_id, $toptab);
712 echo $this->tabGenerator($menu['urls'], $menu['titles'], $menu['tooltips'], true, $menu['selected'], 'white');
715 function tabGenerator($TABS_DIRS, $TABS_TITLES, $TABS_TOOLTIPS, $nested=false, $selected=false, $sel_tab_bgcolor='white', $total_width='100%') {
717 $count=count($TABS_DIRS);
718 $width=intval((100/$count));
723 <table class="tabGenerator" ';
725 if ($total_width != '100%') {
726 $return .= 'style="width:' . $total_width . ';"';
736 for ($i=0; $i<$count; $i++) {
739 // this is the first tab, choose an image with end-name
742 $issel=($selected==$i);
743 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
744 // $rowspan=(($issel)?'rowspan="2" ' : '');
747 <td '.$rowspan.'class="top" width="10" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-end-'.(($issel) ? '' : 'not').'selected.png)">'.
748 '<img src="'.$this->imgbaseurl . 'clear.png" height="25" width="10" alt="" /></td>'.
749 '<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>';
750 } elseif ($i==$count-1) {
752 // this is the last tab, choose an image with name-end
754 $wassel=($selected==$i-1);
755 $issel=($selected==$i);
756 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
757 // $rowspan=(($issel)?'rowspan="2" ' : '');
759 // Build image between current and prior tab
762 <td '.$rowspan.'colspan="2" class="top" width="20" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-'.(($wassel) ? '' : 'not').'selected-'.(($issel) ? '' : 'not').'selected.png)">'.
763 '<img src="'.$this->imgbaseurl . 'clear.png" height="2" width="20" alt="" /></td>'.
764 '<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>';
766 // Last graphic on right-side
769 <td '.$rowspan.'class="top" width="10" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-'.(($issel) ? '' : 'not').'selected-end.png)">'.
770 '<img src="'.$this->imgbaseurl . 'clear.png" height="2" width="10" alt="" /></td>';
776 $wassel=($selected==$i-1);
777 $issel=($selected==$i);
778 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
779 // $rowspan=(($issel)?'rowspan="2" ' : '');
781 // Build image between current and prior tab
784 <td '.$rowspan.'colspan="2" class="top" width="20" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-'.(($wassel) ? '' : 'not').'selected-'.(($issel) ? '' : 'not').'selected.png)">'.
785 '<img src="'.$this->imgbaseurl . 'clear.png" height="2" width="20" alt="" /></td>'.
786 '<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>';
793 // Building a bottom row in this table, which will be darker
795 if ($selected == 0) {
797 $end_cols=((count($TABS_DIRS)*3)-3);
798 } elseif ($selected == (count($TABS_DIRS)-1)) {
799 $beg_cols=((count($TABS_DIRS)*3)-3);
802 $beg_cols=($selected*3);
803 $end_cols=(((count($TABS_DIRS)*3)-3)-$beg_cols);
807 $return .= '<td colspan="'.$beg_cols.'" height="1" class="notSelTab"><img src="'.$this->imgbaseurl.'clear.png" height="1" width="10" alt="" /></td>';
809 $return .= '<td colspan="3" height="1" class="selTab"><img src="'.$this->imgbaseurl.'clear.png" height="1" width="10" alt="" /></td>';
811 $return .= '<td colspan="'.$end_cols.'" height="1" class="notSelTab"><img src="'.$this->imgbaseurl.'clear.png" height="1" width="10" alt="" /></td>';
823 function searchBox() {
824 echo $this->navigation->getSearchBox();
828 * beginSubMenu() - Opening a submenu.
830 * @return string Html to start a submenu.
832 function beginSubMenu() {
839 * endSubMenu() - Closing a submenu.
841 * @return string Html to end a submenu.
843 function endSubMenu() {
844 $return = '</strong></p>';
849 * printSubMenu() - Takes two array of titles and links and builds the contents of a menu.
851 * @param array The array of titles.
852 * @param array The array of title links.
853 * @param array The array of string for title attributes.
854 * @return string Html to build a submenu.
856 function printSubMenu($title_arr, $links_arr, $attr_arr) {
857 $count=count($title_arr);
861 for ($i=0; $i<$count; $i++) {
862 $return .= util_make_link($links_arr[$i],$title_arr[$i],$attr_arr[$i]). $this->subMenuSeparator();
864 $return .= util_make_link($links_arr[$i],$title_arr[$i],$attr_arr[$i]);
869 * subMenuSeparator() - returns the separator used between submenus
871 * @return string Html to build a submenu separator.
873 function subMenuSeparator() {
878 * subMenu() - Takes two array of titles and links and build a menu.
880 * @param array The array of titles.
881 * @param array The array of title links.
882 * @param array The array of string for title attributes.
883 * @return string Html to build a submenu.
885 function subMenu($title_arr, $links_arr, $attr_arr = false) {
886 $return = $this->beginSubMenu();
887 $return .= $this->printSubMenu($title_arr, $links_arr, $attr_arr);
888 $return .= $this->endSubMenu();
893 * multiTableRow() - create a mutlilevel row in a table
895 * @param string the row attributes
896 * @param array the array of cell data, each element is an array,
897 * the first item being the text,
898 * the subsequent items are attributes (dont include
899 * the bgcolor for the title here, that will be
900 * handled by $istitle
901 * @param boolean is this row part of the title ?
902 * @return string the html code
904 function multiTableRow($row_attr, $cell_data, $istitle) {
908 $return .=' class="align-center multiTableRowTitle"';
911 for ( $c = 0; $c < count($cell_data); $c++ ) {
913 for ( $a=1; $a < count($cell_data[$c]); $a++) {
914 $return .= $cell_data[$c][$a].' ';
918 $return .='<span class="multiTableRowTitle">';
920 $return .= $cell_data[$c][0];
934 * feedback() - returns the htmlized feedback string when an action is performed.
936 * @param string feedback string
937 * @return string htmlized feedback
939 function feedback($feedback) {
944 <p class="feedback">'.strip_tags($feedback, '<br>').'</p>';
948 * warning_msg() - returns the htmlized warning string when an action is performed.
950 * @param string msg string
951 * @return string htmlized warning
953 function warning_msg($msg) {
958 <p class="warning_msg">'.strip_tags($msg, '<br>').'</p>';
963 * error_msg() - returns the htmlized error string when an action is performed.
965 * @param string msg string
966 * @return string htmlized error
968 function error_msg($msg) {
973 <div class="error">' .
974 util_pwrap(strip_tags($msg, '<br>')) .
980 * information() - returns the htmlized information string.
982 * @param string msg string
983 * @return string htmlized information
985 function information($msg) {
990 <p class="information">'.strip_tags($msg, '<br>').'</p>';
995 * getThemeIdFromName()
997 * @param string the dirname of the theme
998 * @return integer the theme id
1000 function getThemeIdFromName($dirname) {
1001 $res = db_query_params ('SELECT theme_id FROM themes WHERE dirname=$1',
1003 return db_result($res,0,'theme_id');
1006 function confirmBox($msg, $params, $buttons, $image='*none*') {
1007 if ($image == '*none*') {
1008 $image = html_image('stop.png','48','48',array());
1011 foreach ($params as $b => $v) {
1012 $prms[] = '<input type="hidden" name="'.$b.'" value="'.$v.'" />'."\n";
1014 $prm = join(' ', $prms);
1016 foreach ($buttons as $b => $v) {
1017 $btns[] = '<input type="submit" name="'.$b.'" value="'.$v.'" />'."\n";
1019 $btn = join(' '."\n ", $btns);
1022 <div id="infobox" style="margin-top: 15%; margin-left: 15%; margin-right: 15%; text-align: center;">
1023 <table align="center">
1026 <td>'.$msg.'<br/></td>
1029 <td colspan="2" align="center">
1031 <form action="' . getStringFromServer('PHP_SELF') . '" method="get" >
1042 function html_input($name, $id = '', $label = '', $type = 'text', $value = '', $extra_params = '') {
1046 $return = '<div class="field-holder">
1049 $return .= '<label for="' . $id . '">' . $label . '</label>
1052 $return .= '<input id="' . $id . '" type="' . $type . '"';
1053 //if input is a submit then name is not present
1055 $return .= ' name="' . $name . '"';
1058 $return .= ' value="' . $value . '"';
1060 if (is_array($extra_params)) {
1061 foreach ($extra_params as $key => $extra_params_value) {
1062 $return .= $key . '="' . $extra_params_value . '" ';
1070 function html_checkbox($name, $value, $id = '', $label = '', $checked = '', $extra_params = '') {
1074 $return = '<div class="field-holder">
1076 $return .= '<input name="' . $name . '" id="' . $id . '" type="checkbox" value="' . $value . '" ';
1078 $return .= 'checked="checked" ';
1080 if (is_array($extra_params)) {
1081 foreach ($extra_params as $key => $extra_params_value) {
1082 $return .= $key . '="' . $extra_params_value . '" ';
1087 $return .= '<label for="' . $id . '">' . $label . '</label>
1090 $return .= '</div>';
1094 function html_text_input_img_submit($name, $img_src, $id = '', $label = '', $value = '', $img_title = '', $img_alt = '', $extra_params = '', $img_extra_params = '') {
1102 $img_alt = $img_title;
1104 $return = '<div class="field-holder">
1107 $return .= '<label for="' . $id . '">' . $label . '</label>
1110 $return .= '<input id="' . $id . '" type="text" name="' . $name . '"';
1112 $return .= ' value="' . $value . '"';
1114 if (is_array($extra_params)) {
1115 foreach ($extra_params as $key => $extra_params_value) {
1116 $return .= $key . '="' . $extra_params_value . '" ';
1120 <input type="image" id="' . $id . '_submit" src="' . $this->imgbaseurl . $img_src . '" alt="' . util_html_secure($img_alt) . '" title="' . util_html_secure($img_title) . '"';
1121 if (is_array($img_extra_params)) {
1122 foreach ($img_extra_params as $key => $img_extra_params_value) {
1123 $return .= $key . '="' . $img_extra_params_value . '" ';
1131 function html_select($vals, $name, $label = '', $id = '', $checked_val = '', $text_is_value = false, $extra_params = '') {
1135 $return = '<div class="field-holder">
1138 $return .= '<label for="' . $id . '">' . $label . '</label>
1141 $return .= '<select name="' . $name . '" id="' . $id . '" ';
1142 if (is_array($extra_params)) {
1143 foreach ($extra_params as $key => $extra_params_value) {
1144 $return .= $key . '="' . $extra_params_value . '" ';
1148 $rows = count($vals);
1149 for ($i = 0; $i < $rows; $i++) {
1150 if ( $text_is_value ) {
1152 <option value="' . $vals[$i] . '"';
1153 if ($vals[$i] == $checked_val) {
1154 $return .= ' selected="selected"';
1158 <option value="' . $i . '"';
1159 if ($i == $checked_val) {
1160 $return .= ' selected="selected"';
1163 $return .= '>' . htmlspecialchars($vals[$i]) . '</option>';
1171 function html_textarea($name, $id = '', $label = '', $value = '', $extra_params = '') {
1175 $return = '<div class="field-holder">
1178 $return .= '<label for="' . $id . '">' . $label . '</label>
1181 $return .= '<textarea id="' . $id . '" name="' . $name . '" ';
1182 if (is_array($extra_params)) {
1183 foreach ($extra_params as $key => $extra_params_value) {
1184 $return .= $key . '="' . $extra_params_value . '" ';
1191 $return .= '</textarea>
1197 * @todo use listTableTop and make this function deprecated ?
1199 function html_table_top($cols, $summary = '', $class = '', $extra_params = '') {
1200 $return = '<table summary="' . $summary . '" ';
1202 $return .= 'class="' . $class . '" ';
1204 if (is_array($extra_params)) {
1205 foreach ($extra_params as $key => $extra_params_value) {
1206 $return .= $key . '="' . $extra_params_value . '" ';
1210 $return .= '<thead><tr>';
1211 $nbCols = count($cols);
1212 for ($i = 0; $i < $nbCols; $i++) {
1213 $return .= '<th scope="col">' . $cols[$i] . '</th>';
1215 $return .= '</tr></thead>';
1219 function getMonitorPic($title = '', $alt = '') {
1220 return $this->getPicto('ic/mail16w.png', $title, $alt);
1223 function getReleaseNotesPic($title = '', $alt = '') {
1224 return $this->getPicto('ic/manual16c.png', $title, $alt);
1227 /* no picto for download */
1228 function getDownloadPic($title = '', $alt = '') {
1229 return $this->getPicto('ic/save.png', $title, $alt);
1232 function getHomePic($title = '', $alt = '') {
1233 return $this->getPicto('ic/home16b.png', $title, $alt);
1236 function getFollowPic($title = '', $alt = '') {
1237 return $this->getPicto('ic/tracker20g.png', $title, $alt);
1240 function getForumPic($title = '', $alt = '') {
1241 return $this->getPicto('ic/forum20g.png', $title, $alt);;
1244 function getDocmanPic($title = '', $alt = '') {
1245 return $this->getPicto('ic/docman16b.png', $title, $alt);
1248 function getMailPic($title = '', $alt = '') {
1249 return $this->getPicto('ic/mail16b.png', $title, $alt);
1252 function getPmPic($title = '', $alt = '') {
1253 return $this->getPicto('ic/taskman20g.png', $title, $alt);
1256 function getSurveyPic($title = '', $alt = '') {
1257 return $this->getPicto('ic/survey16b.png', $title, $alt);
1260 function getScmPic($title = '', $alt = '') {
1261 return $this->getPicto('ic/cvs16b.png', $title, $alt);
1264 function getFtpPic($title = '', $alt = '') {
1265 return $this->getPicto('ic/ftp16b.png', $title, $alt);
1268 function getPicto($url, $title, $alt, $width = '20', $height = '20') {
1272 return html_image($url, $width, $height, array('title'=>$title, 'alt'=>$alt));
1276 * toSlug() - protect a string to be used as a link or an anchor
1278 * @param string $string the string used as a link or an anchor
1279 * @param string $space the caracter used as a replacement for a space
1280 * @return a protected string with only alphanumeric caracters
1282 function toSlug($string, $space = "-") {
1283 if (function_exists('iconv')) {
1284 $string = @iconv('UTF-8', 'ASCII//TRANSLIT', $string);
1286 $string = preg_replace("/[^a-zA-Z0-9_:. -]/", "-", $string);
1287 $string = strtolower($string);
1288 $string = str_replace(" ", $space, $string);
1289 if (!preg_match("/^[a-zA-Z:_]/", $string)) {
1290 /* some chars aren't allowed at the begin */
1291 $string = "_" . $string;
1296 function widget(&$widget, $layout_id, $readonly, $column_id, $is_minimized, $display_preferences, $owner_id, $owner_type) {
1297 $element_id = 'widget_'. $widget->id .'-'. $widget->getInstanceId();
1298 echo '<div class="widget" id="'. $element_id . "\">\n";
1299 echo '<div class="widget_titlebar '. ($readonly?'':'widget_titlebar_handle') . "\">\n";
1300 echo '<div class="widget_titlebar_title">'. $widget->getTitle() . "</div>\n";
1302 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>\n";
1303 if ($is_minimized) {
1304 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>\n";
1306 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>\n";
1308 if (strlen($widget->hasPreferences())) {
1309 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>\n";
1312 if ($widget->hasRss()) {
1313 echo '<div class="widget_titlebar_rss"><a href="'.$widget->getRssUrl($owner_id, $owner_type) . "\">rss</a></div>\n";
1317 if ($is_minimized) {
1318 $style = 'display:none;';
1320 echo '<div class="widget_content" style="'. $style . "\">\n";
1321 if (!$readonly && $display_preferences) {
1322 echo '<div class="widget_preferences">'. $widget->getPreferencesForm($layout_id, $owner_id, $owner_type) . "</div>\n";
1324 if ($widget->isAjax()) {
1325 echo '<div id="'. $element_id .'-ajax">';
1326 echo '<noscript><iframe width="99%" frameborder="0" src="'. $widget->getIframeUrl($owner_id, $owner_type) .'"></iframe></noscript>';
1329 echo $widget->getContent();
1332 if ($widget->isAjax()) {
1333 echo '<script type="text/javascript">/* <![CDATA[ */'."
1334 document.observe('dom:loaded', function () {
1335 $('$element_id-ajax').update('<div style=\"text-align:center\">". $this->getPicto('ic/spinner.gif','spinner','spinner', 10, 10) ."</div>');
1336 new Ajax.Updater('$element_id-ajax',
1337 '". $widget->getAjaxUrl($owner_id, $owner_type) ."'
1340 /* ]]> */</script>";
1345 function _getTogglePlusForWidgets() {
1346 return 'ic/toggle_plus.png';
1349 function _getToggleMinusForWidgets() {
1350 return 'ic/toggle_minus.png';
1353 /* Get the navigation links for the software map pages (trove,
1354 * tag cloud, full project list) according to what's enabled
1356 function printSoftwareMapLinks() {
1357 $subMenuTitle = array();
1358 $subMenuUrl = array();
1359 $subMenuAttr = array();
1361 if (forge_get_config('use_project_tags')) {
1362 $subMenuTitle[] = _('Tag cloud');
1363 $subMenuUrl[] = '/softwaremap/tag_cloud.php';
1364 $subMenuAttr[] = array('title' => _('Browse per tags defined by the projects.'), 'class' => 'tabtitle-nw');
1367 if (forge_get_config('use_trove')) {
1368 $subMenuTitle[] = _('Project Tree');
1369 $subMenuUrl[] = '/softwaremap/trove_list.php';
1370 $subMenuAttr[] = array('title' => _('Browse per category.'), 'class' => 'tabtitle');
1373 if (forge_get_config('use_project_full_list')) {
1374 $subMenuTitle[] = _('Project List');
1375 $subMenuUrl[] = '/softwaremap/full_list.php';
1376 $subMenuAttr[] = array('title' => _('Complete listing of available projects.'), 'class' => 'tabtitle');
1379 echo $this->subMenu($subMenuTitle, $subMenuUrl, $subMenuAttr);
1385 // c-file-style: "bsd"