Error();
$this->navigation = new Navigation();
// determine rootindex
if ( file_exists(forge_get_config('custom_path') . '/index_std.php') ) {
$this->rootindex = forge_get_config('custom_path') . '/index_std.php';
} else {
$this->rootindex = $GLOBALS['gfwww'].'index_std.php';
}
// determine theme{dir,url}
$this->themedir = forge_get_config('themes_root') . '/' . forge_get_config('default_theme') . '/';
if (!file_exists ($this->themedir)) {
html_error_top(_("Cannot find theme directory!"));
return;
}
$this->themeurl = util_make_url('themes/' . forge_get_config('default_theme') . '/');
// determine {css,img,js}{url,dir}
if (file_exists ($this->themedir . 'images/')) {
$this->imgdir = $this->themedir . 'images/';
$this->imgbaseurl = $this->themeurl . 'images/';
} else {
$this->imgdir = $this->themedir;
$this->imgbaseurl = $this->themeurl;
}
if (file_exists ($this->themedir . 'js/')) {
$this->jsdir = $this->themedir . 'js/';
$this->jsbaseurl = $this->themeurl . 'js/';
} else {
$this->jsdir = $this->themedir;
$this->jsbaseurl = $this->themeurl;
}
$this->addStylesheet('/themes/css/fusionforge.css');
}
/**
* 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 ($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'].'/vendor/', $js);
if (file_exists($filename)) {
$js .= '?'.date ("U", filemtime($filename));
}
}
$this->javascripts[] = $js;
}
}
function addStylesheet($css, $media='') {
if (isset($this->css_min[$css])) {
$css = $this->css_min[$css];
}
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'].'/vendor/', $css);
if (file_exists($filename)) {
$css .= '?'.date ("U", filemtime($filename));
}
}
$this->stylesheets[] = array('css' => $css, 'media' => $media);
}
}
/**
* getJavascripts - include javascript in html page. check to load only once the file
*/
function getJavascripts() {
$code = '';
foreach ($this->javascripts as $js) {
$code .= "\t\t\t";
$code .= ''."\n";
}
$this->javascripts = array();
return $code;
}
/**
* getStylesheets - include stylesheet in html page. check to load only once the file
*/
function getStylesheets() {
$code = '';
foreach ($this->stylesheets as $c) {
$code .= "\t\t\t";
if ($c['media']) {
$code .= ''."\n";
} else {
$code .= ''."\n";
}
}
$this->stylesheets = array();
return $code;
}
/**
* header() - generates the complete header of page by calling
* headerStart() and bodyHeader().
*/
function header($params) {
$this->headerStart($params); ?>
bodyHeader($params);
}
/**
* headerStart() - generates the header code for all themes up to the
* closing .
* 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();
?>
headerTitle($params);
$this->headerFavIcon();
$this->headerRSS();
$this->headerSearch();
$this->headerCSS();
$this->headerJS();
$this->headerForgepluckerMeta();
$this->headerLinkedDataAutodiscovery();
?>
.
*
*/
function headerHTMLDeclaration() {
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 '\n";
}
/**
* headerTitle() - creates the header
*
* @param array Header parameters array
*/
function headerTitle($params) {
echo $this->navigation->getTitle($params);
}
/**
* headerFavIcon() - creates the favicon headers.
*
*/
function headerFavIcon() {
echo $this->navigation->getFavIcon();
}
/**
* headerRSS() - creates the RSS headers.
*
*/
function headerRSS() {
echo $this->navigation->getRSS();
}
/**
* headerSearch() - creates the search header.
*
*/
function headerSearch() {
echo ''."\n";
}
/**
* Create the CSS headers for all cssfiles in $cssfiles and
* calls the plugin cssfile hook.
*/
function headerCSS() {
plugin_hook ('cssfile',$this);
echo $this->getStylesheets();
}
/**
* headerJS() - creates the JS headers and calls the plugin javascript hook
* @todo generalize this
*/
function headerJS() {
echo '
';
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 '';
}
}
/**
* headerLinkedDataAutodiscovery() - creates the link+alternate links to alternate
* representations for Linked Data autodiscovery
*/
function headerLinkedDataAutodiscovery() {
// Only activated for /projects or /users for the moment
$script_name = getStringFromServer('SCRIPT_NAME');
$script_name = substr($script_name,0,strpos($script_name,'/',1));
if ($script_name == '/projects' || $script_name == '/users' || $script_name == '/softwaremap') {
$php_self = getStringFromServer('PHP_SELF');
// invoke the 'alt_representations' hook to add potential 'alternate' links (useful for Linked Data)
// cf. http://www.w3.org/TR/cooluris/#linking
$params = array('script_name' => $script_name,
'php_self' => $php_self,
'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('',
$ff->software_type, $ff->software_version);
echo "\n";
}
function bodyHeader($params){
?>