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'].'/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'].'/vendor/', $css);
201 if (file_exists($filename)) {
202 $css .= '?'.date ("U", filemtime($filename));
205 $this->stylesheets[] = array('css' => $css, 'media' => $media);
210 * getJavascripts - include javascript in html page. check to load only once the file
212 function getJavascripts() {
214 foreach ($this->javascripts as $js) {
216 $code .= '<script type="text/javascript" src="'.$js.'"></script>'."\n";
218 $this->javascripts = array();
223 * getStylesheets - include stylesheet in html page. check to load only once the file
225 function getStylesheets() {
227 foreach ($this->stylesheets as $c) {
230 $code .= '<link rel="stylesheet" type="text/css" href="'.$c['css'].'" media="'.$c['media'].'" />'."\n";
232 $code .= '<link rel="stylesheet" type="text/css" href="'.$c['css'].'"/>'."\n";
235 $this->stylesheets = array();
240 * header() - generates the complete header of page by calling
241 * headerStart() and bodyHeader().
243 function header($params) {
244 $this->headerStart($params); ?>
247 $this->bodyHeader($params);
251 * headerStart() - generates the header code for all themes up to the
253 * Override any of the methods headerHTMLDeclaration(), headerTitle(),
254 * headerFavIcon(), headerRSS(), headerSearch(), headerCSS(), or
255 * headerJS() to adapt your theme.
257 * @param array Header parameters array
259 function headerStart($params) {
260 $this->headerHTMLDeclaration();
263 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
264 <?php if (isset($params['meta-description'])) { ?>
265 <meta name="description" content="<?php echo $params['meta-description'] ?>" />
267 <?php if (isset($params['meta-keywords'])) { ?>
268 <meta name="keywords" content="<?php echo $params['meta-keywords'] ?>" />
271 plugin_hook('htmlhead', array());
272 $this->headerTitle($params);
273 $this->headerFavIcon();
275 $this->headerSearch();
278 $this->headerForgepluckerMeta();
279 $this->headerLinkedDataAutodiscovery();
286 * headerHTMLDeclaration() - generates the HTML declaration, i.e. the
287 * XML declaration, the doctype definition, and the opening <html>.
290 function headerHTMLDeclaration() {
291 global $sysDTDs, $sysXMLNSs;
293 print '<' . '?xml version="1.0" encoding="utf-8"?>'."\n";
294 if (!util_ifsetor($this->doctype) || !util_ifsetor($sysDTDs[$this->doctype])) {
295 $this->doctype = 'transitional';
297 echo $sysDTDs[$this->doctype]['doctype'] . "\n";
298 echo '<html xml:lang="' . _('en') . '" lang="' . _('en') .
299 '" ' . $sysXMLNSs . ">\n";
303 * headerTitle() - creates the <title> header
305 * @param array Header parameters array
307 function headerTitle($params) {
308 echo $this->navigation->getTitle($params);
313 * headerFavIcon() - creates the favicon <link> headers.
316 function headerFavIcon() {
317 echo $this->navigation->getFavIcon();
321 * headerRSS() - creates the RSS <link> headers.
324 function headerRSS() {
325 echo $this->navigation->getRSS();
329 * headerSearch() - creates the search <link> header.
332 function headerSearch() {
333 echo '<link rel="search" title="'
334 . forge_get_config ('forge_name').'" href="'
335 . util_make_url ('/export/search_plugin.php')
336 . '" type="application/opensearchdescription+xml"/>'."\n";
340 * Create the CSS headers for all cssfiles in $cssfiles and
341 * calls the plugin cssfile hook.
343 function headerCSS() {
344 plugin_hook ('cssfile',$this);
345 echo $this->getStylesheets();
349 * headerJS() - creates the JS headers and calls the plugin javascript hook
350 * @todo generalize this
352 function headerJS() {
354 <script type="text/javascript" src="/scripts/prototype/prototype.js"></script>
355 <script type="text/javascript" src="/scripts/scriptaculous/scriptaculous.js"></script>
356 <script type="text/javascript" src="/scripts/codendi/Tooltip.js"></script>
357 <script type="text/javascript" src="/scripts/codendi/LayoutManager.js"></script>
358 <script type="text/javascript" src="/scripts/codendi/ReorderColumns.js"></script>
359 <script type="text/javascript" src="/scripts/codendi/codendi-1236793993.js"></script>
360 <script type="text/javascript" src="/scripts/codendi/validate.js"></script>
361 <script type="text/javascript" src="'. util_make_uri('/js/common.js') .'"></script>
362 <script language="JavaScript" type="text/javascript">/* <![CDATA[ */';
363 plugin_hook ("javascript",false);
366 plugin_hook ("javascript_file",false);
367 echo $this->getJavascripts();
369 // invoke the 'javascript' hook for custom javascript addition
370 $params = array('return' => false);
371 plugin_hook("javascript",$params);
372 $javascript = $params['return'];
374 echo '<script type="text/javascript">';
382 * headerLinkedDataAutodiscovery() - creates the link+meta links to alternate
383 * representations for Linked Data autodiscovery
385 function headerLinkedDataAutodiscovery() {
386 // Only activated for /projects or /users for the moment
387 $script_name = getStringFromServer('SCRIPT_NAME');
389 if ($script_name == '/projects' || $script_name == '/users') {
391 $php_self = getStringFromServer('PHP_SELF');
393 // invoke the 'alt_representations' hook
394 $params = array('script_name' => $script_name,
395 'php_self' => $php_self,
396 'return' => array());
398 plugin_hook_by_reference('alt_representations', $params);
400 foreach($params['return'] as $link) {
406 function headerForgepluckerMeta() {
408 * Forge-Identification Meta Header, Version 1.0
409 * cf. http://home.gna.org/forgeplucker/forge-identification.html
412 $ff = new FusionForge();
413 printf('<meta name="Forge-Identification" content="%s:%s" />',
414 $ff->software_type, $ff->software_version);
418 function bodyHeader($params){
421 <table border="0" width="100%" cellspacing="0" cellpadding="0" id="headertable">
423 <td><a href="<?php echo util_make_url ('/'); ?>"><?php echo html_image('logo.png',198,52,array('border'=>'0')); ?></a></td>
424 <td><?php $this->searchBox(); ?></td>
425 <td align="right"><?php
426 $items = $this->navigation->getUserLinks();
427 for ($j = 0; $j < count($items['titles']); $j++) {
428 echo util_make_link($items['urls'][$j], $items['titles'][$j], array('class'=>'lnkutility'), true);
431 $params['template'] = ' {menu}';
432 plugin_hook('headermenu', $params);
437 <td> </td>
442 <table border="0" width="100%" cellspacing="0" cellpadding="0">
448 <?php echo $this->outerTabs($params); ?>
455 <td align="left" class="toptab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topleft.png" height="9" width="9" alt="" /></td>
456 <td class="toptab" width="30"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="30" height="1" alt="" /></td>
457 <td class="toptab"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
458 <td class="toptab" width="30"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="30" height="1" alt="" /></td>
459 <td align="right" class="toptab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topright.png" height="9" width="9" alt="" /></td>
464 <!-- Outer body row -->
466 <td class="toptab"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="10" height="1" alt="" /></td>
467 <td valign="top" width="99%" class="toptab" colspan="3">
469 <!-- Inner Tabs / Shell -->
471 <table border="0" width="100%" cellspacing="0" cellpadding="0">
475 if (isset($params['group']) && $params['group']) {
483 echo $this->projectTabs($params['toptab'],$params['group']);
493 <td align="left" class="projecttab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topleft-inner.png" height="9" width="9" alt="" /></td>
494 <td class="projecttab" ><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
495 <td align="right" class="projecttab" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/topright-inner.png" height="9" width="9" alt="" /></td>
499 <td class="projecttab" ><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="10" height="1" alt="" /></td>
500 <td valign="top" width="99%" class="projecttab">
506 function footer($params) {
510 <!-- end main body row -->
513 <td width="10" class="footer3" ><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="2" height="1" alt="" /></td>
516 <td align="left" class="footer1" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomleft-inner.png" height="11" width="11" alt="" /></td>
517 <td class="footer3"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
518 <td align="right" class="footer1" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomright-inner.png" height="11" width="11" alt="" /></td>
522 <!-- end inner body row -->
525 <td width="10" class="footer2"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="2" height="1" alt="" /></td>
528 <td align="left" class="footer2" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomleft.png" height="9" width="9" alt="" /></td>
529 <td class="footer2" colspan="3"><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="1" height="1" alt="" /></td>
530 <td align="right" class="footer2" width="9"><img src="<?php echo $this->imgbaseurl; ?>tabs/bottomright.png" height="9" width="9" alt="" /></td>
534 $this->footerEnd($params);
537 function footerEnd($params) { ?>
539 <!-- PLEASE LEAVE "Powered By FusionForge" on your site -->
541 <?php echo $this->navigation->getPoweredBy(); ?>
544 <?php echo $this->navigation->getShowSource();
546 plugin_hook('webanalytics_url', array());
556 function getRootIndex() {
557 return $this->rootindex;
561 * boxTop() - Top HTML box.
563 * @param string Box title
564 * @return string the html code
566 function boxTop($title) {
568 <!-- Box Top Start -->
570 <table class="fullwidth" style="background:url('.$this->imgroot.'vert-grad.png)">
571 <tr class="align-center">
572 <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>
573 <td width="100%" style="background:url('.$this->imgbaseurl.'box-grad.png)"><span class="titlebar">'.$title.'</span></td>
574 <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>
578 <table cellspacing="2" cellpadding="2" width="100%" border="0">
582 <!-- Box Top End -->';
586 * boxMiddle() - Middle HTML box.
588 * @param string Box title
589 * @return string The html code
591 function boxMiddle($title) {
593 <!-- Box Middle Start -->
596 <tr class="align-center">
597 <td colspan="2" style="background:url('.$this->imgbaseurl.'box-grad.png)"><span class="titlebar">'.$title.'</span></td>
599 <tr class="align-left">
601 <!-- Box Middle End -->';
605 * boxBottom() - Bottom HTML box.
607 * @return string the html code
609 function boxBottom() {
611 <!-- Box Bottom Start -->
618 <!-- Box Bottom End -->';
622 * boxGetAltRowStyle() - Get an alternating row style for tables.
624 * @param int Row number
625 * @return string the class code
627 function boxGetAltRowStyle($i) {
629 return ' class="altRowStyleEven"';
631 return ' class="altRowStyleOdd"';
636 * listTableTop() - Takes an array of titles and builds the first row of a new table.
638 * @param array The array of titles
639 * @param array The array of title links
640 * @param string The css classes to add (optional)
641 * @param string The id of the table (needed by sortable for example)
642 * @param array specific class for th column
643 * @return string the html code
645 function listTableTop($titleArray, $linksArray=false, $class='', $id='', $thClassArray=array()) {
648 $args .= ' class="listing '.$class.'"';
650 $args .= ' class="listing full"';
653 $args .= ' id="'.$id.'"';
658 if (count($titleArray)) {
659 $return .= '<thead><tr>';
661 $count=count($titleArray);
662 for ($i=0; $i<$count; $i++) {
664 if ($thClassArray && $thClassArray[$i]) {
665 $th .= ' class="'.$thClassArray[$i].'"';
667 $cell = $titleArray[$i];
669 $cell = util_make_link($linksArray[$i],$titleArray[$i]);
671 $return .= "\n".' <th'.$th.'>'.$cell.'</th>';
673 $return .= "\n".'</tr></thead>'."\n";
675 $return .= '<tbody>';
679 function listTableBottom() {
680 return '</tbody>'."\n".'</table>';
683 function outerTabs($params) {
684 $menu = $this->navigation->getSiteMenu();
685 echo $this->tabGenerator($menu['urls'], $menu['titles'], $menu['tooltips'], false, $menu['selected'], '');
689 * Prints out the quicknav menu, contained here in case we
690 * want to allow it to be overridden.
692 function quickNav() {
693 if (!session_loggedin()) {
696 // get all projects that the user belongs to
697 $groups = session_get_user()->getGroups();
699 if (count($groups) < 1) {
702 sortProjectList($groups);
705 <form id="quicknavform" name="quicknavform" action=""><div>
706 <select name="quicknav" id="quicknav" onchange="location.href=document.quicknavform.quicknav.value">
707 <option value="">'._('Quick Jump To...').'</option>';
709 foreach ($groups as $g) {
710 $group_id = $g->getID();
711 $menu = $this->navigation->getProjectMenu($group_id);
714 <option value="' . $menu['starturl'] . '">'
715 . $menu['name'] .'</option>';
717 for ($j = 0; $j < count($menu['urls']); $j++) {
719 <option value="' . $menu['urls'][$j] .'"> '
720 . $menu['titles'][$j] . '</option>';
721 if (@$menu['adminurls'][$j]) {
723 <option value="' . $menu['adminurls'][$j]
724 . '"> '
725 . _('Admin') . '</option>';
737 * projectTabs() - Prints out the project tabs, contained here in case
738 * we want to allow it to be overriden.
740 * @param string Is the tab currently selected
741 * @param string Is the group we should look up get title info
743 function projectTabs($toptab, $group_id) {
744 // get group info using the common result set
745 $menu = $this->navigation->getProjectMenu($group_id, $toptab);
746 echo $this->tabGenerator($menu['urls'], $menu['titles'], $menu['tooltips'], true, $menu['selected'], 'white');
749 function tabGenerator($TABS_DIRS, $TABS_TITLES, $TABS_TOOLTIPS, $nested=false, $selected=false, $sel_tab_bgcolor='white', $total_width='100%') {
751 $count=count($TABS_DIRS);
752 $width=intval((100/$count));
757 <table class="tabGenerator" ';
759 if ($total_width != '100%') {
760 $return .= 'style="width:' . $total_width . ';"';
770 for ($i=0; $i<$count; $i++) {
773 // this is the first tab, choose an image with end-name
776 $issel=($selected==$i);
777 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
778 // $rowspan=(($issel)?'rowspan="2" ' : '');
781 <td '.$rowspan.'class="top" width="10" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-end-'.(($issel) ? '' : 'not').'selected.png)">'.
782 '<img src="'.$this->imgbaseurl . 'clear.png" height="25" width="10" alt="" /></td>'.
783 '<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>';
784 } elseif ($i==$count-1) {
786 // this is the last tab, choose an image with name-end
788 $wassel=($selected==$i-1);
789 $issel=($selected==$i);
790 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
791 // $rowspan=(($issel)?'rowspan="2" ' : '');
793 // Build image between current and prior tab
796 <td '.$rowspan.'colspan="2" class="top" width="20" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-'.(($wassel) ? '' : 'not').'selected-'.(($issel) ? '' : 'not').'selected.png)">'.
797 '<img src="'.$this->imgbaseurl . 'clear.png" height="2" width="20" alt="" /></td>'.
798 '<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>';
800 // Last graphic on right-side
803 <td '.$rowspan.'class="top" width="10" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-'.(($issel) ? '' : 'not').'selected-end.png)">'.
804 '<img src="'.$this->imgbaseurl . 'clear.png" height="2" width="10" alt="" /></td>';
810 $wassel=($selected==$i-1);
811 $issel=($selected==$i);
812 $bgimg=(($issel)?'theme-'.$inner.'-selected-bg.png':'theme-'.$inner.'-notselected-bg.png');
813 // $rowspan=(($issel)?'rowspan="2" ' : '');
815 // Build image between current and prior tab
818 <td '.$rowspan.'colspan="2" class="top" width="20" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-'.(($wassel) ? '' : 'not').'selected-'.(($issel) ? '' : 'not').'selected.png)">'.
819 '<img src="'.$this->imgbaseurl . 'clear.png" height="2" width="20" alt="" /></td>'.
820 '<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>';
827 // Building a bottom row in this table, which will be darker
829 if ($selected == 0) {
831 $end_cols=((count($TABS_DIRS)*3)-3);
832 } elseif ($selected == (count($TABS_DIRS)-1)) {
833 $beg_cols=((count($TABS_DIRS)*3)-3);
836 $beg_cols=($selected*3);
837 $end_cols=(((count($TABS_DIRS)*3)-3)-$beg_cols);
841 $return .= '<td colspan="'.$beg_cols.'" height="1" class="notSelTab"><img src="'.$this->imgbaseurl.'clear.png" height="1" width="10" alt="" /></td>';
843 $return .= '<td colspan="3" height="1" class="selTab"><img src="'.$this->imgbaseurl.'clear.png" height="1" width="10" alt="" /></td>';
845 $return .= '<td colspan="'.$end_cols.'" height="1" class="notSelTab"><img src="'.$this->imgbaseurl.'clear.png" height="1" width="10" alt="" /></td>';
857 function searchBox() {
858 echo $this->navigation->getSearchBox();
862 * beginSubMenu() - Opening a submenu.
864 * @return string Html to start a submenu.
866 function beginSubMenu() {
873 * endSubMenu() - Closing a submenu.
875 * @return string Html to end a submenu.
877 function endSubMenu() {
878 $return = '</strong></p>';
883 * printSubMenu() - Takes two array of titles and links and builds the contents of a menu.
885 * @param array The array of titles.
886 * @param array The array of title links.
887 * @param array The array of string for title attributes.
888 * @return string Html to build a submenu.
890 function printSubMenu($title_arr, $links_arr, $attr_arr) {
891 $count=count($title_arr);
895 for ($i=0; $i<$count; $i++) {
896 $return .= util_make_link($links_arr[$i],$title_arr[$i],$attr_arr[$i]). $this->subMenuSeparator();
898 $return .= util_make_link($links_arr[$i],$title_arr[$i],$attr_arr[$i]);
903 * subMenuSeparator() - returns the separator used between submenus
905 * @return string Html to build a submenu separator.
907 function subMenuSeparator() {
912 * subMenu() - Takes two array of titles and links and build a menu.
914 * @param array The array of titles.
915 * @param array The array of title links.
916 * @param array The array of string for title attributes.
917 * @return string Html to build a submenu.
919 function subMenu($title_arr, $links_arr, $attr_arr = false) {
920 $return = $this->beginSubMenu();
921 $return .= $this->printSubMenu($title_arr, $links_arr, $attr_arr);
922 $return .= $this->endSubMenu();
927 * multiTableRow() - create a mutlilevel row in a table
929 * @param string the row attributes
930 * @param array the array of cell data, each element is an array,
931 * the first item being the text,
932 * the subsequent items are attributes (dont include
933 * the bgcolor for the title here, that will be
934 * handled by $istitle
935 * @param boolean is this row part of the title ?
936 * @return string the html code
938 function multiTableRow($row_attr, $cell_data, $istitle) {
942 $return .=' class="align-center multiTableRowTitle"';
945 for ( $c = 0; $c < count($cell_data); $c++ ) {
947 for ( $a=1; $a < count($cell_data[$c]); $a++) {
948 $return .= $cell_data[$c][$a].' ';
952 $return .='<span class="multiTableRowTitle">';
954 $return .= $cell_data[$c][0];
968 * feedback() - returns the htmlized feedback string when an action is performed.
970 * @param string feedback string
971 * @return string htmlized feedback
973 function feedback($feedback) {
978 <p class="feedback">'.strip_tags($feedback, '<br>').'</p>';
982 * warning_msg() - returns the htmlized warning string when an action is performed.
984 * @param string msg string
985 * @return string htmlized warning
987 function warning_msg($msg) {
992 <p class="warning_msg">'.strip_tags($msg, '<br>').'</p>';
997 * error_msg() - returns the htmlized error string when an action is performed.
999 * @param string msg string
1000 * @return string htmlized error
1002 function error_msg($msg) {
1007 <div class="error">' .
1008 util_pwrap(strip_tags($msg, '<br>')) .
1014 * information() - returns the htmlized information string.
1016 * @param string msg string
1017 * @return string htmlized information
1019 function information($msg) {
1024 <p class="information">'.strip_tags($msg, '<br>').'</p>';
1029 * getThemeIdFromName()
1031 * @param string the dirname of the theme
1032 * @return integer the theme id
1034 function getThemeIdFromName($dirname) {
1035 $res = db_query_params ('SELECT theme_id FROM themes WHERE dirname=$1',
1037 return db_result($res,0,'theme_id');
1040 function confirmBox($msg, $params, $buttons, $image='*none*') {
1041 if ($image == '*none*') {
1042 $image = html_image('stop.png','48','48',array());
1045 foreach ($params as $b => $v) {
1046 $prms[] = '<input type="hidden" name="'.$b.'" value="'.$v.'" />'."\n";
1048 $prm = join(' ', $prms);
1050 foreach ($buttons as $b => $v) {
1051 $btns[] = '<input type="submit" name="'.$b.'" value="'.$v.'" />'."\n";
1053 $btn = join(' '."\n ", $btns);
1056 <div id="infobox" style="margin-top: 15%; margin-left: 15%; margin-right: 15%; text-align: center;">
1057 <table align="center">
1060 <td>'.$msg.'<br/></td>
1063 <td colspan="2" align="center">
1065 <form action="' . getStringFromServer('PHP_SELF') . '" method="get" >
1076 function html_input($name, $id = '', $label = '', $type = 'text', $value = '', $extra_params = '') {
1080 $return = '<div class="field-holder">
1083 $return .= '<label for="' . $id . '">' . $label . '</label>
1086 $return .= '<input id="' . $id . '" type="' . $type . '"';
1087 //if input is a submit then name is not present
1089 $return .= ' name="' . $name . '"';
1092 $return .= ' value="' . $value . '"';
1094 if (is_array($extra_params)) {
1095 foreach ($extra_params as $key => $extra_params_value) {
1096 $return .= $key . '="' . $extra_params_value . '" ';
1104 function html_checkbox($name, $value, $id = '', $label = '', $checked = '', $extra_params = '') {
1108 $return = '<div class="field-holder">
1110 $return .= '<input name="' . $name . '" id="' . $id . '" type="checkbox" value="' . $value . '" ';
1112 $return .= 'checked="checked" ';
1114 if (is_array($extra_params)) {
1115 foreach ($extra_params as $key => $extra_params_value) {
1116 $return .= $key . '="' . $extra_params_value . '" ';
1121 $return .= '<label for="' . $id . '">' . $label . '</label>
1124 $return .= '</div>';
1128 function html_text_input_img_submit($name, $img_src, $id = '', $label = '', $value = '', $img_title = '', $img_alt = '', $extra_params = '', $img_extra_params = '') {
1136 $img_alt = $img_title;
1138 $return = '<div class="field-holder">
1141 $return .= '<label for="' . $id . '">' . $label . '</label>
1144 $return .= '<input id="' . $id . '" type="text" name="' . $name . '"';
1146 $return .= ' value="' . $value . '"';
1148 if (is_array($extra_params)) {
1149 foreach ($extra_params as $key => $extra_params_value) {
1150 $return .= $key . '="' . $extra_params_value . '" ';
1154 <input type="image" id="' . $id . '_submit" src="' . $this->imgbaseurl . $img_src . '" alt="' . util_html_secure($img_alt) . '" title="' . util_html_secure($img_title) . '"';
1155 if (is_array($img_extra_params)) {
1156 foreach ($img_extra_params as $key => $img_extra_params_value) {
1157 $return .= $key . '="' . $img_extra_params_value . '" ';
1165 function html_select($vals, $name, $label = '', $id = '', $checked_val = '', $text_is_value = false, $extra_params = '') {
1169 $return = '<div class="field-holder">
1172 $return .= '<label for="' . $id . '">' . $label . '</label>
1175 $return .= '<select name="' . $name . '" id="' . $id . '" ';
1176 if (is_array($extra_params)) {
1177 foreach ($extra_params as $key => $extra_params_value) {
1178 $return .= $key . '="' . $extra_params_value . '" ';
1182 $rows = count($vals);
1183 for ($i = 0; $i < $rows; $i++) {
1184 if ( $text_is_value ) {
1186 <option value="' . $vals[$i] . '"';
1187 if ($vals[$i] == $checked_val) {
1188 $return .= ' selected="selected"';
1192 <option value="' . $i . '"';
1193 if ($i == $checked_val) {
1194 $return .= ' selected="selected"';
1197 $return .= '>' . htmlspecialchars($vals[$i]) . '</option>';
1205 function html_textarea($name, $id = '', $label = '', $value = '', $extra_params = '') {
1209 $return = '<div class="field-holder">
1212 $return .= '<label for="' . $id . '">' . $label . '</label>
1215 $return .= '<textarea id="' . $id . '" name="' . $name . '" ';
1216 if (is_array($extra_params)) {
1217 foreach ($extra_params as $key => $extra_params_value) {
1218 $return .= $key . '="' . $extra_params_value . '" ';
1225 $return .= '</textarea>
1231 * @todo use listTableTop and make this function deprecated ?
1233 function html_table_top($cols, $summary = '', $class = '', $extra_params = '') {
1234 $return = '<table summary="' . $summary . '" ';
1236 $return .= 'class="' . $class . '" ';
1238 if (is_array($extra_params)) {
1239 foreach ($extra_params as $key => $extra_params_value) {
1240 $return .= $key . '="' . $extra_params_value . '" ';
1244 $return .= '<thead><tr>';
1245 $nbCols = count($cols);
1246 for ($i = 0; $i < $nbCols; $i++) {
1247 $return .= '<th scope="col">' . $cols[$i] . '</th>';
1249 $return .= '</tr></thead>';
1253 function getMonitorPic($title = '', $alt = '') {
1254 return $this->getPicto('ic/mail16w.png', $title, $alt);
1257 function getReleaseNotesPic($title = '', $alt = '') {
1258 return $this->getPicto('ic/manual16c.png', $title, $alt);
1261 /* no picto for download */
1262 function getDownloadPic($title = '', $alt = '') {
1263 return $this->getPicto('ic/save.png', $title, $alt);
1266 function getHomePic($title = '', $alt = '') {
1267 return $this->getPicto('ic/home16b.png', $title, $alt);
1270 function getFollowPic($title = '', $alt = '') {
1271 return $this->getPicto('ic/tracker20g.png', $title, $alt);
1274 function getForumPic($title = '', $alt = '') {
1275 return $this->getPicto('ic/forum20g.png', $title, $alt);;
1278 function getDocmanPic($title = '', $alt = '') {
1279 return $this->getPicto('ic/docman16b.png', $title, $alt);
1282 function getMailPic($title = '', $alt = '') {
1283 return $this->getPicto('ic/mail16b.png', $title, $alt);
1286 function getPmPic($title = '', $alt = '') {
1287 return $this->getPicto('ic/taskman20g.png', $title, $alt);
1290 function getSurveyPic($title = '', $alt = '') {
1291 return $this->getPicto('ic/survey16b.png', $title, $alt);
1294 function getScmPic($title = '', $alt = '') {
1295 return $this->getPicto('ic/cvs16b.png', $title, $alt);
1298 function getFtpPic($title = '', $alt = '') {
1299 return $this->getPicto('ic/ftp16b.png', $title, $alt);
1302 function getPicto($url, $title, $alt, $width = '20', $height = '20') {
1306 return html_image($url, $width, $height, array('title'=>$title, 'alt'=>$alt));
1310 * toSlug() - protect a string to be used as a link or an anchor
1312 * @param string $string the string used as a link or an anchor
1313 * @param string $space the caracter used as a replacement for a space
1314 * @return a protected string with only alphanumeric caracters
1316 function toSlug($string, $space = "-") {
1317 if (function_exists('iconv')) {
1318 $string = @iconv('UTF-8', 'ASCII//TRANSLIT', $string);
1320 $string = preg_replace("/[^a-zA-Z0-9_:. -]/", "-", $string);
1321 $string = strtolower($string);
1322 $string = str_replace(" ", $space, $string);
1323 if (!preg_match("/^[a-zA-Z:_]/", $string)) {
1324 /* some chars aren't allowed at the begin */
1325 $string = "_" . $string;
1330 function widget(&$widget, $layout_id, $readonly, $column_id, $is_minimized, $display_preferences, $owner_id, $owner_type) {
1331 $element_id = 'widget_'. $widget->id .'-'. $widget->getInstanceId();
1332 echo '<div class="widget" id="'. $element_id . "\">\n";
1333 echo '<div class="widget_titlebar '. ($readonly?'':'widget_titlebar_handle') . "\">\n";
1334 echo '<div class="widget_titlebar_title">'. $widget->getTitle() . "</div>\n";
1336 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";
1337 if ($is_minimized) {
1338 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";
1340 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";
1342 if (strlen($widget->hasPreferences())) {
1343 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";
1346 if ($widget->hasRss()) {
1347 echo '<div class="widget_titlebar_rss"><a href="'.$widget->getRssUrl($owner_id, $owner_type) . "\">rss</a></div>\n";
1351 if ($is_minimized) {
1352 $style = 'display:none;';
1354 echo '<div class="widget_content" style="'. $style . "\">\n";
1355 if (!$readonly && $display_preferences) {
1356 echo '<div class="widget_preferences">'. $widget->getPreferencesForm($layout_id, $owner_id, $owner_type) . "</div>\n";
1358 if ($widget->isAjax()) {
1359 echo '<div id="'. $element_id .'-ajax">';
1360 echo '<noscript><iframe width="99%" frameborder="0" src="'. $widget->getIframeUrl($owner_id, $owner_type) .'"></iframe></noscript>';
1363 echo $widget->getContent();
1366 if ($widget->isAjax()) {
1367 echo '<script type="text/javascript">/* <![CDATA[ */'."
1368 document.observe('dom:loaded', function () {
1369 $('$element_id-ajax').update('<div style=\"text-align:center\">". $this->getPicto('ic/spinner.gif','spinner','spinner', 10, 10) ."</div>');
1370 new Ajax.Updater('$element_id-ajax',
1371 '". $widget->getAjaxUrl($owner_id, $owner_type) ."'
1374 /* ]]> */</script>";
1379 function _getTogglePlusForWidgets() {
1380 return 'ic/toggle_plus.png';
1383 function _getToggleMinusForWidgets() {
1384 return 'ic/toggle_minus.png';
1387 /* Get the navigation links for the software map pages (trove,
1388 * tag cloud, full project list) according to what's enabled
1390 function printSoftwareMapLinks() {
1391 $subMenuTitle = array();
1392 $subMenuUrl = array();
1393 $subMenuAttr = array();
1395 if (forge_get_config('use_project_tags')) {
1396 $subMenuTitle[] = _('Tag cloud');
1397 $subMenuUrl[] = '/softwaremap/tag_cloud.php';
1398 $subMenuAttr[] = array('title' => _('Browse per tags defined by the projects.'), 'class' => 'tabtitle-nw');
1401 if (forge_get_config('use_trove')) {
1402 $subMenuTitle[] = _('Project Tree');
1403 $subMenuUrl[] = '/softwaremap/trove_list.php';
1404 $subMenuAttr[] = array('title' => _('Browse per category.'), 'class' => 'tabtitle');
1407 if (forge_get_config('use_project_full_list')) {
1408 $subMenuTitle[] = _('Project List');
1409 $subMenuUrl[] = '/softwaremap/full_list.php';
1410 $subMenuAttr[] = array('title' => _('Complete listing of available projects.'), 'class' => 'tabtitle');
1413 echo $this->subMenu($subMenuTitle, $subMenuUrl, $subMenuAttr);
1416 function displayStylesheetElements() {
1417 /* Codendi/Tuleap compatibility */
1423 // c-file-style: "bsd"