<?php
/**
* Base layout class.
+ *
+ * Copyright 1999-2001 (c) VA Linux Systems
+ * Copyright 2010 - Alain Peyrat
+ * Copyright 2010-2011, Franck Villaume - Capgemini
+ * Copyright 2010-2012, Alain Peyrat - Alcatel-Lucent
+ * Copyright © 2011 Thorsten Glaser – tarent GmbH
+ * Copyright 2011 - Marc-Etienne Vargenau, Alcatel-Lucent
+ * Copyright 2012 - Franck Villaume - TrivialDev
+ * Copyright (C) 2012 Alain Peyrat - Alcatel-Lucent
+ * http://fusionforge.org
+ *
+ * This file is part of FusionForge. FusionForge is free software;
+ * you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the Licence, or (at your option)
+ * any later version.
+ *
+ * FusionForge is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with FusionForge; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+/**
*
* Extends the basic Error class to add HTML functions
* for displaying all site dependent HTML, while allowing
* Make sure browser.php is included _before_ you create an instance
* of this object.
*
- * Geoffrey Herteg, August 29, 2000
- *
*/
require_once $gfcommon.'include/constants.php';
+require_once $gfcommon.'include/FusionForge.class.php';
require_once $gfcommon.'include/Navigation.class.php';
class Layout extends Error {
* Which doctype to use. Can be configured in the
* constructor. If set to 'strict', headerHTMLDeclaration will
* create a doctype definition that uses the strict doctype,
- * otherwise it will use the transitional doctype.
+ * otherwise it will use the transitional doctype.
* @var string $doctype
*/
var $doctype = 'transitional';
/**
- * Which cssfiles to use. Can be configured in the
- * constructor.
- *
- * @var array $cssurls is a list of urls that should point to
- * the used stylesheets.
- */
- var $cssurls;
-
- /**
- * The default main page content
- * @var string $rootindex
+ * The default main page content
+ * @var string $rootindex
*/
var $rootindex = 'index_std.php';
/**
* The base directory of the theme in the servers file system
- * @var string $themedir
- */
+ * @var string $themedir
+ */
var $themedir;
/**
* The base url of the theme
- * @var string $themeurl
- */
+ * @var string $themeurl
+ */
var $themeurl;
- /**
- * The base directory of the css files in the servers file system
- * @var string $cssdir
- */
- var $cssdir;
-
- /**
- * The base url of the css files
- * @var string $cssbaseurl
- */
- var $cssbaseurl;
-
/**
* The base directory of the image files in the servers file system
- * @var string $imgdir
- */
+ * @var string $imgdir
+ */
var $imgdir;
/**
* The base url of the image files
- * @var string $imgbaseurl
- */
+ * @var string $imgbaseurl
+ */
var $imgbaseurl;
/**
* The base directory of the js files in the servers file system
- * @var string $jsdir
- */
+ * @var string $jsdir
+ */
var $jsdir;
/**
* The base url of the js files
- * @var string $jsbaseurl
- */
- var $jsbaseurl;
-
- /*
- * kept for backwards compatibility
- */
- /**
- * The base directory of the theme
- * @var string $themeroot
- * @todo: remove in 5.0
- * @deprecated deprecated since 4.9
- */
- var $themeroot;
-
- /**
- * The base directory of the theme
- * @var string $themeroot
- * @todo: remove in 5.0
- * @deprecated deprecated since 4.9
+ * @var string $jsbaseurl
*/
- var $imgroot;
+ var $jsbaseurl;
/**
* The navigation object that provides the basic links. Should
*/
var $navigation;
+ /**
+ * The color bars in pm reporting
+ */
+ var $COLOR_LTBACK1 = '#C0C0C0';
+
+ var $js = array();
+ var $js_min = array();
+ var $javascripts = array();
+ var $css = array();
+ var $css_min = array();
+ var $stylesheets = array();
/**
* Layout() - Constructor
$this->themeurl = util_make_url('themes/' . forge_get_config('default_theme') . '/');
// determine {css,img,js}{url,dir}
- if (file_exists ($this->themedir . 'css/')) {
- $this->cssdir = $this->themedir . 'css/';
- $this->cssbaseurl = $this->themeurl . 'css/';
- } else {
- $this->cssdir = $this->themedir;
- $this->cssbaseurl = $this->themeurl;
- }
-
if (file_exists ($this->themedir . 'images/')) {
$this->imgdir = $this->themedir . 'images/';
$this->imgbaseurl = $this->themeurl . 'images/';
$this->jsbaseurl = $this->themeurl;
}
- // determine CSS stylesheets
- $this->cssurls[] = util_make_url ('/themes/css/fusionforge.css');
-
- /* check if a personalized css stylesheet exist, if yes include only
- this stylesheet. New stylesheets should use the <themename>.css file.
- */
- $theme_cssfile = forge_get_config('default_theme') . '.css';
- if (file_exists($this->cssdir . $theme_cssfile)) {
- $this->cssurls[] = $this->cssbaseurl . $theme_cssfile;
- } else {
- /* if this is not the case, then include the compatibility stylesheet
- that contains all removed styles from the code and check if a
- custom stylesheet exists.
- Used for compatibility with existing stylesheets
- */
- $this->cssurls[] = util_make_url('/themes/css/gforge-compat.css');
- if (file_exists($this->cssdir . 'theme.css')) {
- $this->cssurls[] = $this->cssbaseurl . 'theme.css';
- }
- }
+ $this->addStylesheet('/themes/css/fusionforge.css');
- // for backward compatibility
- $this->themeroot = $this->themedir;
- $this->imgroot = $this->imgbaseurl;
}
+ /**
+ * Build the list of required Javascript files.
+ *
+ * If js file is found, then a timestamp is automatically added to ensure
+ * that file is cached only if not changed.
+ *
+ * @param string $js path to the JS file
+ */
function addJavascript($js) {
+ // If a minified version of the javascript is available, then use it.
if (isset($this->js_min[$js])) {
$js = $this->js_min[$js];
}
- if (!isset($this->js[$js])) {
+ if ($js && !isset($this->js[$js])) {
$this->js[$js] = true;
$filename = $GLOBALS['fusionforge_basedir'].'/www'.$js;
if (file_exists($filename)) {
$js .= '?'.date ("U", filemtime($filename));
+ } else {
+ $filename = str_replace('/scripts/', $GLOBALS['fusionforge_basedir'].'/lib/vendor/', $js);
+ if (file_exists($filename)) {
+ $js .= '?'.date ("U", filemtime($filename));
+ }
}
- echo '<script type="text/javascript" src="'.$js.'"></script>'."\n";
+ $this->javascripts[] = $js;
}
}
- function addStylesheet($css, $media) {
+ function addStylesheet($css, $media='') {
if (isset($this->css_min[$css])) {
$css = $this->css_min[$css];
}
- if (!isset($this->js[$css])) {
- $this->js[$css] = true;
+ if (!isset($this->css[$css])) {
+ $this->css[$css] = true;
$filename = $GLOBALS['fusionforge_basedir'].'/www'.$css;
if (file_exists($filename)) {
$css .= '?'.date ("U", filemtime($filename));
+ } else {
+ $filename = str_replace('/scripts/', $GLOBALS['fusionforge_basedir'].'/lib/vendor/', $css);
+ if (file_exists($filename)) {
+ $css .= '?'.date ("U", filemtime($filename));
+ }
}
- if ($media) {
- $media = ' media="'.$media.'"';
+ $this->stylesheets[] = array('css' => $css, 'media' => $media);
+ }
+ }
+
+ function getJavascripts() {
+ $code = '';
+ foreach ($this->javascripts as $js) {
+ $code .= "\t\t\t";
+ $code .= '<script type="text/javascript" src="'.$js.'"></script>'."\n";
+ }
+ return $code;
+ }
+
+ function getStylesheets() {
+ $code = '';
+ foreach ($this->stylesheets as $c) {
+ $code .= "\t\t\t";
+ if ($c['media']) {
+ $code .= '<link rel="stylesheet" type="text/css" href="'.$c['css'].'" media="'.$c['media'].'" />'."\n";
+ } else {
+ $code .= '<link rel="stylesheet" type="text/css" href="'.$c['css'].'"/>'."\n";
}
- echo ' <link rel="stylesheet" type="text/css" href="'.$css.'"'.$media.' />'."\n";
}
+ return $code;
}
- /**
- * header() - generates the complete header of page by calling
+ /**
+ * header() - generates the complete header of page by calling
* headerStart() and bodyHeader().
*/
function header($params) {
$this->bodyHeader($params);
}
-
/**
- * headerStart() - generates the header code for all themes up to the
+ * headerStart() - generates the header code for all themes up to the
* closing </head>.
- * Override any of the methods headerHTMLDeclaration(), headerTitle(),
- * headerFavIcon(), headerRSS(), headerSearch(), headerCSS(), or
- * headerJS() to adapt your theme.
+ * Override any of the methods headerHTMLDeclaration(), headerTitle(),
+ * headerFavIcon(), headerRSS(), headerSearch(), headerCSS(), or
+ * headerJS() to adapt your theme.
*
* @param array Header parameters array
*/
function headerStart($params) {
$this->headerHTMLDeclaration();
- ?>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <?php
- $this->headerTitle($params);
+ ?>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<?php if (isset($params['meta-description'])) { ?>
+ <meta name="description" content="<?php echo $params['meta-description'] ?>" />
+<?php } ?>
+<?php if (isset($params['meta-keywords'])) { ?>
+ <meta name="keywords" content="<?php echo $params['meta-keywords'] ?>" />
+<?php } ?>
+ <?php
+ plugin_hook('htmlhead', array());
+ $this->headerTitle($params);
$this->headerFavIcon();
$this->headerRSS();
$this->headerSearch();
$this->headerCSS();
- $this->headerJS();
+ $this->headerJS();
+ $this->headerForgepluckerMeta();
+ $this->headerLinkedDataAutodiscovery();
?>
- </head>
- <?php
- }
-
- /**
- * headerLink() - creates the link headers of the page (FavIcon, RSS and Search)
- * @deprecated deprecated since 4.9, use the individual header-functions
- * @todo remove in 5.0
- */
- function headerLink() {
- $this->headerFavIcon();
- $this->headerRSS();
- $this->headerSearch();
+ </head>
+ <?php
}
/**
* headerHTMLDeclaration() - generates the HTML declaration, i.e. the
- * XML declaration, the doctype definition, and the opening <html>.
+ * XML declaration, the doctype definition, and the opening <html>.
*
*/
function headerHTMLDeclaration() {
- print '<?xml version="1.0" encoding="utf-8"?>';
- if ($this->doctype=='strict') {
- echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
- } else {
- echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
- }
- echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="'
- . _('en') . '" lang="' . _('en') . '">';
+ global $sysDTDs, $sysXMLNSs;
+
+ print '<?xml version="1.0" encoding="utf-8"?>'."\n";
+ if (!util_ifsetor($this->doctype) || !util_ifsetor($sysDTDs[$this->doctype])) {
+ $this->doctype = 'transitional';
+ }
+ echo $sysDTDs[$this->doctype]['doctype'] . "\n";
+ echo '<html xml:lang="' . _('en') . '" lang="' . _('en') .
+ '" ' . $sysXMLNSs . ">\n";
}
/**
- * headerTitle() - creates the <title> header
+ * headerTitle() - creates the <title> header
*
* @param array Header parameters array
*/
/**
- * headerFavIcon() - creates the favicon <link> headers
+ * headerFavIcon() - creates the favicon <link> headers.
*
*/
function headerFavIcon() {
}
/**
- * headerRSS() - creates the RSS <link> headers
+ * headerRSS() - creates the RSS <link> headers.
*
*/
function headerRSS() {
}
/**
- * headerSearch() - creates the search <link> header
+ * headerSearch() - creates the search <link> header.
*
*/
function headerSearch() {
- echo '<link rel="search" title="'
- . forge_get_config ('forge_name').'" href="'
- . util_make_url ('/export/search_plugin.php')
- . '" type="application/opensearchdescription+xml"/>';
+ echo '<link rel="search" title="'
+ . forge_get_config ('forge_name').'" href="'
+ . util_make_url ('/export/search_plugin.php')
+ . '" type="application/opensearchdescription+xml"/>'."\n";
}
- /**
+ /**
* Create the CSS headers for all cssfiles in $cssfiles and
* calls the plugin cssfile hook.
*/
function headerCSS() {
- // include the common css
- foreach ($this->cssurls as $cssurl) {
- echo '<link rel="stylesheet" type="text/css" href="' . $cssurl . '" />';
- }
-
plugin_hook ('cssfile',$this);
+ echo $this->getStylesheets();
}
/**
*/
function headerJS() {
echo '
-<script type="text/javascript" src="/scripts/prototype/prototype.js"></script>
- <script type="text/javascript" src="/scripts/scriptaculous/scriptaculous.js"></script>
- <script type="text/javascript" src="/scripts/codendi/Tooltip.js"></script>
- <script type="text/javascript" src="/scripts/codendi/LayoutManager.js"></script>
- <script type="text/javascript" src="/scripts/codendi/ReorderColumns.js"></script>
- <script type="text/javascript" src="/scripts/codendi/codendi-1236793993.js"></script>
- <script type="text/javascript" src="/scripts/codendi/validate.js"></script>
+ <script type="text/javascript" src="/scripts/prototype/prototype.js"></script>
+ <script type="text/javascript" src="/scripts/scriptaculous/scriptaculous.js"></script>
+ <script type="text/javascript" src="/scripts/codendi/Tooltip.js"></script>
+ <script type="text/javascript" src="/scripts/codendi/LayoutManager.js"></script>
+ <script type="text/javascript" src="/scripts/codendi/ReorderColumns.js"></script>
+ <script type="text/javascript" src="/scripts/codendi/codendi-1236793993.js"></script>
+ <script type="text/javascript" src="/scripts/codendi/validate.js"></script>
<script type="text/javascript" src="'. util_make_uri('/js/common.js') .'"></script>
- <script type="text/javascript">';
+ <script language="JavaScript" type="text/javascript">/* <![CDATA[ */';
plugin_hook ("javascript",false);
echo '
- </script>';
+ /* ]]> */</script>';
plugin_hook ("javascript_file",false);
+ echo $this->getJavascripts();
+
+ // invoke the 'javascript' hook for custom javascript addition
+ $params = array('return' => false);
+ plugin_hook("javascript",$params);
+ $javascript = $params['return'];
+ if($javascript) {
+ echo '<script type="text/javascript">';
+ echo $javascript;
+ echo '
+ </script>';
+ }
+ }
+
+ /**
+ * headerLinkedDataAutodiscovery() - creates the link+meta links to alternate
+ * representations for Linked Data autodiscovery
+ */
+ function headerLinkedDataAutodiscovery() {
+ // Only activated for /projects or /users for the moment
+ $script_name = getStringFromServer('SCRIPT_NAME');
+
+ if ($script_name == '/projects' || $script_name == '/users') {
+
+ // invoke the 'alt_representations' hook
+ $params = array('script_name' => $script_name,
+ 'return' => array());
+
+ plugin_hook_by_reference('alt_representations', $params);
+
+ foreach($params['return'] as $link) {
+ echo " $link"."\n";
+ }
+ }
+ }
+
+ function headerForgepluckerMeta() {
+ /*-
+ * Forge-Identification Meta Header, Version 1.0
+ * cf. http://home.gna.org/forgeplucker/forge-identification.html
+ */
+ echo "\t\t\t";
+ $ff = new FusionForge();
+ printf('<meta name="Forge-Identification" content="%s:%s" />',
+ $ff->software_type, $ff->software_version);
+ echo "\n";
}
function bodyHeader($params){
}
$params['template'] = ' {menu}';
- plugin_hook ('headermenu', $params);
+ plugin_hook('headermenu', $params);
$this->quickNav();
<td class="projecttab" ><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="10" height="1" alt="" /></td>
<td valign="top" width="99%" class="projecttab">
- <?php
+ <?php
}
<!-- end main body row -->
-
</td>
<td width="10" class="footer3" ><img src="<?php echo $this->imgbaseurl; ?>clear.png" width="2" height="1" alt="" /></td>
</tr>
<?php echo $this->navigation->getPoweredBy(); ?>
</div>
- <?php echo $this->navigation->getShowSource(); ?>
+ <?php echo $this->navigation->getShowSource();
+
+ plugin_hook('webanalytics_url', array());
+
+ ?>
</body>
- </div>
</html>
<?php
}
/**
- * boxTop() - Top HTML box
+ * boxTop() - Top HTML box.
*
- * @param string Box title
- * @param bool Whether to echo or return the results
- * @param string The box background color
+ * @param string Box title
+ * @return string the html code
*/
function boxTop($title) {
return '
<!-- Box Top Start -->
- <table cellspacing="0" cellpadding="0" width="100%" border="0" style="background:url('.$this->imgbaseurl.'vert-grad.png)">
+ <table class="fullwidth" style="background:url('.$this->imgroot.'vert-grad.png)">
<tr class="align-center">
<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>
<td width="100%" style="background:url('.$this->imgbaseurl.'box-grad.png)"><span class="titlebar">'.$title.'</span></td>
}
/**
- * boxMiddle() - Middle HTML box
+ * boxMiddle() - Middle HTML box.
*
- * @param string Box title
- * @param string The box background color
+ * @param string Box title
+ * @return string The html code
*/
function boxMiddle($title) {
return '
<tr class="align-center">
<td colspan="2" style="background:url('.$this->imgbaseurl.'box-grad.png)"><span class="titlebar">'.$title.'</span></td>
</tr>
- <tr align="left">
+ <tr class="align-left">
<td colspan="2">
<!-- Box Middle End -->';
}
/**
- * boxBottom() - Bottom HTML box
+ * boxBottom() - Bottom HTML box.
*
- * @param bool Whether to echo or return the results
+ * @return string the html code
*/
function boxBottom() {
return '
}
/**
- * boxGetAltRowStyle() - Get an alternating row style for tables
+ * boxGetAltRowStyle() - Get an alternating row style for tables.
*
- * @param int Row number
+ * @param int Row number
+ * @return string the class code
*/
function boxGetAltRowStyle($i) {
if ($i % 2 == 0) {
/**
* listTableTop() - Takes an array of titles and builds the first row of a new table.
*
- * @param array The array of titles
- * @param array The array of title links
+ * @param array The array of titles
+ * @param array The array of title links
+ * @param string The css classes to add (optional)
+ * @param string The id of the table (needed by sortable for example)
+ * @param array specific class for th column
+ * @return string the html code
*/
- function listTableTop ($title_arr,$links_arr=false,$selected=false) {
- $return = '
- <table cellspacing="0" cellpadding="0" width="100%" border="0">
- <tr class="align-center">
- <!-- <td valign="top" align="right" width="10" style="background:url('.$this->imgbaseurl.'box-grad.png)"><img src="'.$this->imgbaseurl.'box-topleft.png" width="10" height="75" alt="" /></td> -->
- <td style="background:url('.$this->imgbaseurl.'box-grad.png)">
- <table width="100%" border="0" cellspacing="1" cellpadding="2" >
- <tr class="tableheading">';
- $count=count($title_arr);
- if ($links_arr) {
- for ($i=0; $i<$count; $i++) {
- $return .= '<td>'.util_make_link ($links_arr[$i],$title_arr[$i],array('class'=>'sortbutton')).'</td>';
- }
+ function listTableTop($titleArray, $linksArray=false, $class='', $id='', $thClassArray=array()) {
+ $args = '';
+ if ($class) {
+ $args .= ' class="listing '.$class.'"';
} else {
+ $args .= ' class="listing full"';
+ }
+ if ($id) {
+ $args .= ' id="'.$id.'"';
+ }
+ $return = "\n".
+ '<table'.$args.'>';
+
+ if (count($titleArray)) {
+ $return .= '<thead><tr>';
+
+ $count=count($titleArray);
for ($i=0; $i<$count; $i++) {
- $return .= '
- <td>'.$title_arr[$i].'</td>';
+ $th = '';
+ if ($thClassArray && $thClassArray[$i]) {
+ $th .= ' class="'.$thClassArray[$i].'"';
+ }
+ $cell = $titleArray[$i];
+ if ($linksArray) {
+ $cell = util_make_link($linksArray[$i],$titleArray[$i]);
+ }
+ $return .= "\n".' <th'.$th.'>'.$cell.'</th>';
}
+ $return .= "\n".'</tr></thead>'."\n";
}
- return $return.'</tr>';
+ $return .= '<tbody>';
+ return $return;
}
function listTableBottom() {
- return '</table></td>
- <!-- <td valign="top" align="right" width="10" style="background:url('.$this->imgbaseurl.'box-grad.png)"><img src="'.$this->imgbaseurl.'box-topright.png" width="10" height="75" alt="" /></td> -->
- </tr></table>';
+ return '</tbody>'."\n".'</table>';
}
function outerTabs($params) {
- $menu =& $this->navigation->getSiteMenu();
-
- echo $this->tabGenerator($menu['urls'], $menu['titles'], false, $menu['selected'], '');
-
+ $menu = $this->navigation->getSiteMenu();
+ echo $this->tabGenerator($menu['urls'], $menu['titles'], $menu['tooltips'], false, $menu['selected'], '');
}
/**
return;
} else {
// get all projects that the user belongs to
- $res = db_query_params ('SELECT group_id FROM groups JOIN user_group USING (group_id) WHERE user_group.user_id=$1 AND groups.status=$2 ORDER BY group_name',
- array (user_getid(),
- 'A'));
- echo db_error();
- if (!$res || db_numrows($res) < 1) {
+ $groups = session_get_user()->getGroups();
+
+ if (count($groups) < 1) {
return;
} else {
+ sortProjectList($groups);
+
echo '
<form id="quicknavform" name="quicknavform" action=""><div>
- <select name="quicknav" id="quicknav" onChange="location.href=document.quicknavform.quicknav.value">
+ <select name="quicknav" id="quicknav" onchange="location.href=document.quicknavform.quicknav.value">
<option value="">'._('Quick Jump To...').'</option>';
- for ($i = 0; $i < db_numrows($res); $i++) {
- $group_id = db_result($res, $i, 'group_id');
- $menu =& $this->navigation->getProjectMenu($group_id);
+ foreach ($groups as $g) {
+ $group_id = $g->getID();
+ $menu = $this->navigation->getProjectMenu($group_id);
echo '
- <option value="' . $menu['starturl'] . '">'
+ <option value="' . $menu['starturl'] . '">'
. $menu['name'] .'</option>';
for ($j = 0; $j < count($menu['urls']); $j++) {
echo '
- <option value="' . $menu['urls'][$j] .'"> '
+ <option value="' . $menu['urls'][$j] .'"> '
. $menu['titles'][$j] . '</option>';
- if ($menu['adminurls'][$j]) {
+ if (@$menu['adminurls'][$j]) {
echo '
- <option value="' . $menu['adminurls'][$j]
- . '"> '
+ <option value="' . $menu['adminurls'][$j]
+ . '"> '
. _('Admin') . '</option>';
}
}
}
/**
- * projectTabs() - Prints out the project tabs, contained here in case
- * we want to allow it to be overriden
+ * projectTabs() - Prints out the project tabs, contained here in case
+ * we want to allow it to be overriden.
*
- * @param string Is the tab currently selected
- * @param string Is the group we should look up get title info
+ * @param string Is the tab currently selected
+ * @param string Is the group we should look up get title info
*/
function projectTabs($toptab, $group_id) {
// get group info using the common result set
- $menu =& $this->navigation->getProjectMenu($group_id, $toptab);
-
- echo $this->tabGenerator($menu['urls'], $menu['titles'], true, $menu['selected'], 'white');
+ $menu = $this->navigation->getProjectMenu($group_id, $toptab);
+ echo $this->tabGenerator($menu['urls'], $menu['titles'], $menu['tooltips'], true, $menu['selected'], 'white');
}
- function tabGenerator($TABS_DIRS,$TABS_TITLES,$nested=false,$selected=false,$sel_tab_bgcolor='white',$total_width='100%') {
+ function tabGenerator($TABS_DIRS, $TABS_TITLES, $TABS_TOOLTIPS, $nested=false, $selected=false, $sel_tab_bgcolor='white', $total_width='100%') {
$count=count($TABS_DIRS);
$width=intval((100/$count));
// $rowspan=(($issel)?'rowspan="2" ' : '');
$return .= '
- <td '.$rowspan.'valign="top" width="10" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-end-'.(($issel) ? '' : 'not').'selected.png)">'.
+ <td '.$rowspan.'class="top" width="10" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-end-'.(($issel) ? '' : 'not').'selected.png)">'.
'<img src="'.$this->imgbaseurl . 'clear.png" height="25" width="10" alt="" /></td>'.
'<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>';
} elseif ($i==$count-1) {
// Build image between current and prior tab
//
$return .= '
- <td '.$rowspan.'colspan="2" valign="top" width="20" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-'.(($wassel) ? '' : 'not').'selected-'.(($issel) ? '' : 'not').'selected.png)">'.
+ <td '.$rowspan.'colspan="2" class="top" width="20" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-'.(($wassel) ? '' : 'not').'selected-'.(($issel) ? '' : 'not').'selected.png)">'.
'<img src="'.$this->imgbaseurl . 'clear.png" height="2" width="20" alt="" /></td>'.
- '<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>';
+ '<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>';
//
// Last graphic on right-side
//
$return .= '
- <td '.$rowspan.'valign="top" width="10" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-'.(($issel) ? '' : 'not').'selected-end.png)">'.
+ <td '.$rowspan.'class="top" width="10" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-'.(($issel) ? '' : 'not').'selected-end.png)">'.
'<img src="'.$this->imgbaseurl . 'clear.png" height="2" width="10" alt="" /></td>';
} else {
// Build image between current and prior tab
//
$return .= '
- <td '.$rowspan.'colspan="2" valign="top" width="20" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-'.(($wassel) ? '' : 'not').'selected-'.(($issel) ? '' : 'not').'selected.png)">'.
+ <td '.$rowspan.'colspan="2" class="top" width="20" style="background:url('.$this->imgbaseurl . 'theme-'.$inner.'-'.(($wassel) ? '' : 'not').'selected-'.(($issel) ? '' : 'not').'selected.png)">'.
'<img src="'.$this->imgbaseurl . 'clear.png" height="2" width="20" alt="" /></td>'.
- '<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>';
+ '<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>';
}
}
return $return.'
- </table>
+ </table>
<!-- end tabs -->
';
*
* @return string Html to start a submenu.
*/
- function beginSubMenu () {
+ function beginSubMenu() {
$return = '
<p><strong>';
return $return;
*
* @return string Html to end a submenu.
*/
- function endSubMenu () {
+ function endSubMenu() {
$return = '</strong></p>';
return $return;
}
/**
* printSubMenu() - Takes two array of titles and links and builds the contents of a menu.
*
- * @param array The array of titles.
- * @param array The array of title links.
+ * @param array The array of titles.
+ * @param array The array of title links.
+ * @param array The array of string for title attributes.
* @return string Html to build a submenu.
*/
- function printSubMenu ($title_arr,$links_arr) {
+ function printSubMenu($title_arr, $links_arr, $attr_arr) {
$count=count($title_arr);
$count--;
$return = '';
for ($i=0; $i<$count; $i++) {
- $return .= util_make_link ($links_arr[$i],$title_arr[$i]).' | ';
+ $return .= util_make_link($links_arr[$i],$title_arr[$i],$attr_arr[$i]). $this->subMenuSeparator();
}
- $return .= util_make_link ($links_arr[$i],$title_arr[$i]);
+ $return .= util_make_link($links_arr[$i],$title_arr[$i],$attr_arr[$i]);
return $return;
}
+ /**
+ * subMenuSeparator() - returns the separator used between submenus
+ *
+ * @return string Html to build a submenu separator.
+ */
+ function subMenuSeparator() {
+ return '';
+ }
+
/**
* subMenu() - Takes two array of titles and links and build a menu.
*
- * @param array The array of titles.
- * @param array The array of title links.
+ * @param array The array of titles.
+ * @param array The array of title links.
+ * @param array The array of string for title attributes.
* @return string Html to build a submenu.
*/
- function subMenu ($title_arr,$links_arr) {
- $return = $this->beginSubMenu () ;
- $return .= $this->printSubMenu ($title_arr,$links_arr) ;
- $return .= $this->endSubMenu () ;
+ function subMenu($title_arr, $links_arr, $attr_arr = false) {
+ $return = $this->beginSubMenu();
+ $return .= $this->printSubMenu($title_arr, $links_arr, $attr_arr);
+ $return .= $this->endSubMenu();
return $return;
}
*
* @param string the row attributes
* @param array the array of cell data, each element is an array,
- * the first item being the text,
- * the subsequent items are attributes (dont include
- * the bgcolor for the title here, that will be
- * handled by $istitle
- * @param boolean is this row part of the title ?
- *
+ * the first item being the text,
+ * the subsequent items are attributes (dont include
+ * the bgcolor for the title here, that will be
+ * handled by $istitle
+ * @param boolean is this row part of the title ?
+ * @return string the html code
*/
function multiTableRow($row_attr, $cell_data, $istitle) {
$return= '
return '';
} else {
return '
- <div class="feedback">'.strip_tags($feedback, '<br>').'</div>';
+ <p class="feedback">'.strip_tags($feedback, '<br>').'</p>';
}
}
/**
return '';
} else {
return '
- <div class="warning_msg">'.strip_tags($msg, '<br>').'</div>';
+ <p class="warning_msg">'.strip_tags($msg, '<br>').'</p>';
}
}
return '';
} else {
return '
- <div class="error">'.strip_tags($msg, '<br>').'</div>';
+ <div class="error">' .
+ util_pwrap(strip_tags($msg, '<br>')) .
+ "</div>\n";
}
}
+ /**
+ * information() - returns the htmlized information string.
+ *
+ * @param string msg string
+ * @return string htmlized information
+ */
+ function information($msg) {
+ if (!$msg) {
+ return '';
+ } else {
+ return '
+ <p class="information">'.strip_tags($msg, '<br>').'</p>';
+ }
+ }
/**
* getThemeIdFromName()
*
* @param string the dirname of the theme
- * @return integer the theme id
+ * @return integer the theme id
*/
function getThemeIdFromName($dirname) {
$res = db_query_params ('SELECT theme_id FROM themes WHERE dirname=$1',
foreach ($params as $b => $v) {
$prms[] = '<input type="hidden" name="'.$b.'" value="'.$v.'" />'."\n";
}
- $prm = join(' ', $prms);
+ $prm = join(' ', $prms);
foreach ($buttons as $b => $v) {
$btns[] = '<input type="submit" name="'.$b.'" value="'.$v.'" />'."\n";
}
- $btn = join(' '."\n ", $btns);
+ $btn = join(' '."\n ", $btns);
return '
<div id="infobox" style="margin-top: 15%; margin-left: 15%; margin-right: 15%; text-align: center;">
}
}
$return .= '/>
- <input type="image" id="' . $id . '_submit" src="' . $this->imgbaseurl . $img_src . '" alt="' . $img_alt . '" title="' . $img_title . '"';
+ <input type="image" id="' . $id . '_submit" src="' . $this->imgbaseurl . $img_src . '" alt="' . util_html_secure($img_alt) . '" title="' . util_html_secure($img_title) . '"';
if (is_array($img_extra_params)) {
foreach ($img_extra_params as $key => $img_extra_params_value) {
$return .= $key . '="' . $img_extra_params_value . '" ';
return $return;
}
+ /**
+ * @todo use listTableTop and make this function deprecated ?
+ */
function html_table_top($cols, $summary = '', $class = '', $extra_params = '') {
$return = '<table summary="' . $summary . '" ';
if ($class) {
}
function getMonitorPic($title = '', $alt = '') {
- return $this->getPicto('ic/mail16w.png', $title, $alt, '15', '15');
+ return $this->getPicto('ic/mail16w.png', $title, $alt);
}
function getReleaseNotesPic($title = '', $alt = '') {
- return $this->getPicto('ic/manual16c.png', $title, $alt, '15', '15');
+ return $this->getPicto('ic/manual16c.png', $title, $alt);
}
/* no picto for download */
function getDownloadPic($title = '', $alt = '') {
- return $this->getPicto('ic/save.png', $title, $alt, '15', '15');
+ return $this->getPicto('ic/save.png', $title, $alt);
}
function getHomePic($title = '', $alt = '') {
function getPicto($url, $title, $alt, $width = '20', $height = '20') {
if (!$alt) {
- $alt = $title;
+ $alt = $title;
}
return html_image($url, $width, $height, array('title'=>$title, 'alt'=>$alt));
}
if (function_exists('iconv')) {
$string = @iconv('UTF-8', 'ASCII//TRANSLIT', $string);
}
- $string = preg_replace("/[^a-zA-Z0-9- ]/", "-", $string);
+ $string = preg_replace("/[^a-zA-Z0-9_:. -]/", "-", $string);
$string = strtolower($string);
$string = str_replace(" ", $space, $string);
+ if (!preg_match("/^[a-zA-Z:_]/", $string)) {
+ /* some chars aren't allowed at the begin */
+ $string = "_" . $string;
+ }
return $string;
}
+
function widget(&$widget, $layout_id, $readonly, $column_id, $is_minimized, $display_preferences, $owner_id, $owner_type) {
$element_id = 'widget_'. $widget->id .'-'. $widget->getInstanceId();
- echo '<div class="widget" id="'. $element_id .'">';
- echo '<div class="widget_titlebar '. ($readonly?'':'widget_titlebar_handle') .'">';
- echo '<div class="widget_titlebar_title">'. $widget->getTitle() .'</div>';
+ echo '<div class="widget" id="'. $element_id . "\">\n";
+ echo '<div class="widget_titlebar '. ($readonly?'':'widget_titlebar_handle') . "\">\n";
+ echo '<div class="widget_titlebar_title">'. $widget->getTitle() . "</div>\n";
if (!$readonly) {
- 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>';
+ 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";
if ($is_minimized) {
- 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>';
+ 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";
} else {
- 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>';
+ 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";
}
if (strlen($widget->hasPreferences())) {
- 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>';
+ 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";
}
}
if ($widget->hasRss()) {
- echo '<div class="widget_titlebar_rss"><a href="'.$widget->getRssUrl($owner_id, $owner_type).'">rss</a></div>';
+ echo '<div class="widget_titlebar_rss"><a href="'.$widget->getRssUrl($owner_id, $owner_type) . "\">rss</a></div>\n";
}
- echo '</div>';
+ echo "</div>\n";
$style = '';
if ($is_minimized) {
$style = 'display:none;';
}
- echo '<div class="widget_content" style="'. $style .'">';
+ echo '<div class="widget_content" style="'. $style . "\">\n";
if (!$readonly && $display_preferences) {
- echo '<div class="widget_preferences">'. $widget->getPreferencesForm($layout_id, $owner_id, $owner_type) .'</div>';
+ echo '<div class="widget_preferences">'. $widget->getPreferencesForm($layout_id, $owner_id, $owner_type) . "</div>\n";
}
if ($widget->isAjax()) {
echo '<div id="'. $element_id .'-ajax">';
echo '<noscript><iframe width="99%" frameborder="0" src="'. $widget->getIframeUrl($owner_id, $owner_type) .'"></iframe></noscript>';
- echo '</div>';
+ echo "</div>\n";
} else {
echo $widget->getContent();
}
- echo '</div>';
+ echo "</div>\n";
if ($widget->isAjax()) {
- echo '<script type="text/javascript">'."
+ echo '<script type="text/javascript">/* <![CDATA[ */'."
document.observe('dom:loaded', function () {
- $('$element_id-ajax').update('<div style=\"text-align:center\">". $this->getPicto('ic/spinner.gif','spinner','spinner') ."</div>');
- new Ajax.Updater('$element_id-ajax',
+ $('$element_id-ajax').update('<div style=\"text-align:center\">". $this->getPicto('ic/spinner.gif','spinner','spinner', 10, 10) ."</div>');
+ new Ajax.Updater('$element_id-ajax',
'". $widget->getAjaxUrl($owner_id, $owner_type) ."'
);
});
- </script>";
+ /* ]]> */</script>";
}
- echo '</div>';
+ echo "</div>\n";
}
+
function _getTogglePlusForWidgets() {
return 'ic/toggle_plus.png';
}
+
function _getToggleMinusForWidgets() {
return 'ic/toggle_minus.png';
}
-}
+ /* Get the navigation links for the software map pages (trove,
+ * tag cloud, full project list) according to what's enabled
+ */
+ function printSoftwareMapLinks() {
+ $subMenuTitle = array();
+ $subMenuUrl = array();
+ $subMenuAttr = array();
+
+ if (forge_get_config('use_project_tags')) {
+ $subMenuTitle[] = _('Tag cloud');
+ $subMenuUrl[] = '/softwaremap/tag_cloud.php';
+ $subMenuAttr[] = array('title' => _('Browse per tags defined by the projects.'), 'class' => 'tabtitle-nw');
+ }
+
+ if (forge_get_config('use_trove')) {
+ $subMenuTitle[] = _('Project Tree');
+ $subMenuUrl[] = '/softwaremap/trove_list.php';
+ $subMenuAttr[] = array('title' => _('Browse per category.'), 'class' => 'tabtitle');
+ }
+
+ if (forge_get_config('use_project_full_list')) {
+ $subMenuTitle[] = _('Project List');
+ $subMenuUrl[] = '/softwaremap/full_list.php';
+ $subMenuAttr[] = array('title' => _('Complete listing of available projects.'), 'class' => 'tabtitle');
+ }
+
+ echo $this->subMenu($subMenuTitle, $subMenuUrl, $subMenuAttr);
+ }
+}
// Local Variables:
// mode: php