[257902] Make the babel server consumable by other organisations.
Fourth patch. Hooks for head and footer.
diff --git a/addons/babel.eclipse.org/html/foot.php b/addons/babel.eclipse.org/html/foot.php
new file mode 100644
index 0000000..395c2e4
--- /dev/null
+++ b/addons/babel.eclipse.org/html/foot.php
@@ -0,0 +1,24 @@
+<?php
+/*******************************************************************************
+ * Copyright (c) 2008 Eclipse Foundation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Paul Colton (Aptana)- initial API and implementation
+ *    Eclipse Foundation
+*******************************************************************************/
+
+?>
+<br /><center><a target="_blank" href="https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Babel&component=Server&bug_file_loc=<?= $_SERVER['SCRIPT_NAME'] ?>">Report errors or enhancements</a> | <a href="https://dev.eclipse.org/mailman/listinfo/babel-translators">Discuss translations on the translators mailing list</a></center><br />
+</div></div>
+</div><div id="footer">
+<ul id="footernav">
+<li class="first"><a href="/">Home</a></li>
+<li><a href="http://www.eclipse.org/legal/privacy.php">Privacy Policy</a></li>
+<li><a href="http://www.eclipse.org/legal/termsofuse.php">Terms of Use</a></li>
+</ul>
+<p>Copyright &copy; <?=date("Y");?> The Eclipse Foundation. All Rights Reserved</p>
+</div></body></html>
\ No newline at end of file
diff --git a/addons/babel.eclipse.org/html/head.php b/addons/babel.eclipse.org/html/head.php
new file mode 100755
index 0000000..ea622c8
--- /dev/null
+++ b/addons/babel.eclipse.org/html/head.php
@@ -0,0 +1,183 @@
+<?php
+/*******************************************************************************
+ * Copyright (c) 2007 Eclipse Foundation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *    Paul Colton (Aptana)- initial API and implementation
+ *    Eclipse Foundation
+*******************************************************************************/
+
+// this is actually a paste from the phoenix header.php:
+/* 
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head><title><?= $pageTitle ?></title><meta name="author" content="<?= $pageAuthor ?>" />
+<meta name="keywords" content="<?= $pageKeywords ?>" /><link rel="stylesheet" type="text/css" href="/eclipse.org-common/themes/Phoenix/css/small.css" title="small" /><link rel="alternate stylesheet" type="text/css" href="/eclipse.org-common/themes/Phoenix/css/large.css" title="large" /><link rel="stylesheet" type="text/css" href="/eclipse.org-common/themes/Phoenix/css/visual.css" media="screen" /><link rel="stylesheet" type="text/css" href="/eclipse.org-common/themes/Phoenix/css/layout.css" media="screen" />
+<!--[if IE]>    <link rel="stylesheet" type="text/css" href="/eclipse.org-common/themes/Phoenix/css/ie_style.css" media="screen"/> <![endif]-->
+<link rel="stylesheet" type="text/css" href="/eclipse.org-common/themes/Phoenix/css/print.css" media="print" />
+<link rel="stylesheet" type="text/css" href="/eclipse.org-common/themes/Phoenix/css/header.css" media="screen" />
+<script type="text/javascript" src="/eclipse.org-common/themes/Phoenix/styleswitcher.js"></script>
+<?php if( isset($extraHtmlHeaders) ) echo $extraHtmlHeaders; ?></head>
+<body>
+<div id="header">
+    <div id="header-graphic" class="eclipse-main">
+        <a href="/"><img src="/eclipse.org-common/themes/Phoenix/images/eclipse_home_header.jpg" alt="" /></a><h1>Eclipse</h1>  
+    </div>
+    <div id="header-global-holder" class="eclipse-main-global">
+        <div id="header-global-links"><ul>
+<li><a href="/org/foundation/contact.php" class="first_one">Contact</a></li><li><a href="/legal/">Legal</a></li>
+            </ul>
+        </div>
+        <div id="header-icons">
+<a href="http://live.eclipse.org"><img src="/eclipse.org-common/themes/Phoenix/images/Icon_Live.png" width="28" height="28" alt="Eclipse Live" title="Eclipse Live" /></a>
+<a href="http://www.eclipseplugincentral.com"><img src="/eclipse.org-common/themes/Phoenix/images/Icon_plugin.png" width="28" height="28" alt="Eclipse Plugin Central" title="Eclipse Plugin Central" /></a>
+<a href="http://www.planeteclipse.org"><img src="/eclipse.org-common/themes/Phoenix/images/Icon_planet.png" width="28" height="28" alt="Planet Eclipse" title="Planet Eclipse" /></a>
+        </div>
+    </div></div>
+    
+<?php // Now pasting menu.php, copied from phoenix as well. ?>
+            <div id="header-menu"><div id="header-nav">
+        <ul>
+<?php
+    global $App;
+    $www_prefix = "";
+    $pageRSS = "";
+    
+    if(isset($App)) {
+        $www_prefix = $App->getWWWPrefix();
+        
+        if($App->PageRSS != "") {
+            $pageRSS = $App->PageRSS;
+        }
+    }
+
+    $firstClass = "class=\"first_one\""; 
+    $nextclass = "";
+    
+    /*for($i = 0; $i < $Menu->getMenuItemCount(); $i++) {
+        $MenuItem = $Menu->getMenuItemAt($i);
+            
+        
+        ?>
+        <li><a <?=$firstClass;?> href="<?= $MenuItem->getURL(); ?>" target="<?= $MenuItem->getTarget(); ?>"><?= $MenuItem->getText(); ?></a></li> 
+        <?php
+        $firstClass="";
+            }*\/
+        ?>
+        </ul>
+    </div>
+    <div id="header-utils">
+<?php // we inline this function, originally used with $App
+function getGoogleSearchHTML() {
+        $strn = <<<EOHTML
+        <form action="http://www.google.com/cse" id="searchbox_017941334893793413703:sqfrdtd112s">
+        <input type="hidden" name="cx" value="017941334893793413703:sqfrdtd112s" />
+        <input type="text" name="q" size="25" />
+        <input type="submit" name="sa" value="Search" />
+        </form>
+        <script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=searchbox_017941334893793413703%3Asqfrdtd112s&lang=en"></script>
+EOHTML;
+        return $strn;
+}
+
+?>
+<?= 
+
+getGoogleSearchHTML() ?>
+        <ul>
+            <?php
+                if($pageRSS != "") {
+            ?><li class="rss_feed"><a href="<?= $pageRSS ?>" target="_blank"><img src="/eclipse.org-common/themes/Phoenix/images/rss_btn.gif" alt="RSS" height="16" width="16" border="0" class="rss_icon" /></a></li>
+            <?php
+                } 
+            ?>
+            <li class="text_size"><a class="smallText" title="Small Text" href="#" onclick="setActiveStyleSheet('small');return false;">A</a> <a class="largeText" title="Large Text" href="#" onclick="setActiveStyleSheet('large');return false;">A</a></li>
+        </ul>
+    </div></div>
+        
+
+<?php // done copying stuff
+*/
+// now our own header: ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head><title><?= $pageTitle ?></title><meta name="author" content="<?= $pageAuthor ?>" />
+<meta name="keywords" content="<?= $pageKeywords ?>" />
+<link rel="stylesheet" type="text/css" href="babel.css" media="screen" />
+<link rel="stylesheet" type="text/css" href="babel_print.css" media="print" />
+<?php if( isset($extraHtmlHeaders) ) echo $extraHtmlHeaders; ?></head>
+<body>
+<div id="header">
+    <div id="header-graphic" class="babel">
+        <a href="/"><img src="images/babel_header.jpg" alt="" /></a><h1>Babel</h1>  
+    </div>
+    <div id="header-global-holder" class="babel-global">
+        <div id="header-global-links">
+            <ul>
+                <li><a href="http://www.eclipse.org/org/foundation/contact.php" class="first_one">Contact</a></li>
+                <li><a href="http://www.eclipse.org/legal/">Legal</a></li>
+            </ul>
+        </div>
+        <div id="header-icons">
+            <a href="http://www.eclipse.org"><img src="images/Icon_Org.png" width="28" height="28" alt="eclipse.org" title="Eclipse.org" /></a>
+            <a href="http://live.eclipse.org"><img src="images/Icon_Live.png" width="28" height="28" alt="Eclipse Live" title="Eclipse Live" /></a>
+            <a href="http://www.eclipseplugincentral.com"><img src="images/Icon_plugin.png" width="28" height="28" alt="Eclipse Plugin Central" title="Eclipse Plugin Central" /></a>
+            <a href="http://www.planeteclipse.org"><img src="images/Icon_planet.png" width="28" height="28" alt="Planet Eclipse" title="Planet Eclipse" /></a>
+        </div>
+    </div>
+</div>
+
+<div id="header-menu">
+    <div id="header-nav">
+    <ul>
+        <li><a class="first_one" href="./" target="_self">Home</a></li> 
+        <li><a  href="map_files.php" target="_self">For committers</a></li> 
+        <li><a  href="recent.php" target="_self">Recent Translations</a></li> 
+        <li><a  href="http://www.eclipse.org/babel" target="_self">About Babel</a></li> 
+    </ul>
+    </div>
+    <div id="header-utils"></div>
+</div>
+<?php
+
+global $User;
+
+$LoginString = "LOGOUT";
+$LoginAction = "?submit=Logout";
+if(!$User) {
+	$LoginString = "LOGIN";
+	$LoginAction = "";
+}
+
+?>
+
+
+<script src='js/yui2.3.1/yahoo/yahoo.js' type='text/javascript'></script>
+<script src='js/yui2.3.1/dom/dom.js' type='text/javascript'></script>
+<script src='js/yui2.3.1/event/event.js' type='text/javascript'></script>
+<script src='js/yui2.3.1/connection/connection.js' type='text/javascript'></script>
+<script src='js/yui2.3.1/logger/logger.js' type='text/javascript'></script>
+
+<!--  
+<script src='js/yui2.3.1/element/element-beta.js' type='text/javascript'></script>
+<script src='js/yui2.3.1/tabview/tabview.js' type='text/javascript'></script>
+-->
+
+<script src='js/global.js' type='text/javascript'></script>
+<script src='js/projectString.js' type='text/javascript'></script>
+<script src='js/language.js' type='text/javascript'></script>
+<script src='js/project.js' type='text/javascript'></script>
+<script src='js/version.js' type='text/javascript'></script>
+<script src='js/files.js' type='text/javascript'></script>
+<script src='js/translation.js' type='text/javascript'></script>
+<script src='js/translationHint.js' type='text/javascript'></script>
+
+<script language="javascript">
+	document.getElementById("header-utils").innerHTML = "<ul><li><a href='login.php<?= $LoginAction ?>'><?= $LoginString ?></a></li></ul>";
+</script>
+<div id="container">
\ No newline at end of file
diff --git a/addons/babel.eclipse.org/html_functions.php b/addons/babel.eclipse.org/html_functions.php
index b095bf9..8f09e53 100644
--- a/addons/babel.eclipse.org/html_functions.php
+++ b/addons/babel.eclipse.org/html_functions.php
@@ -37,12 +37,28 @@
         }
 JS;
     }
+    
+    /**
+     * Outputs the head of the html page.
+     */
+    function head() {
+        include(dirname(__FILE__) . "/html/head.php");
+    }
+    
+    /**
+     * Outputs the footer of the html page.
+     */
+    function footer() {
+        include(dirname(__FILE__) . "/html/foot.php");
+    }
 
 }
 
 function __register_html($addon) {
     $addon->register('image_root', array('BabelEclipseOrg', '_imageRoot'));
     $addon->register('validate_map_file_url', array('BabelEclipseOrg', 'validateMapFileUrl'));
+    $addon->register('head', array('BabelEclipseOrg', 'head'));
+    $addon->register('footer', array('BabelEclipseOrg', 'footer'));
 }
 
 global $register_function_html;
diff --git a/addons/babel.eclipse.org/staging/html_functions.php b/addons/babel.eclipse.org/staging/html_functions.php
index d6ac047..0c67113 100644
--- a/addons/babel.eclipse.org/staging/html_functions.php
+++ b/addons/babel.eclipse.org/staging/html_functions.php
@@ -15,11 +15,17 @@
 // Use a class to define the hooks to avoid bugs with already defined functions.
 class BabelEclipseOrgStaging extends BabelEclipseOrg {
 
+    function head() {
+        BabelEclipseOrg::head();
+        echo "<h1 style='color: red'>This is the staging area. Don't do any serious translation work here!</h1><br/>";
+    }
 }
 
 function __register_html_staging($addon) {
     $addon->register('image_root', array('BabelEclipseOrgStaging', '_imageRoot'));
     $addon->register('validate_map_file_url', array('BabelEclipseOrgStaging', 'validateMapFileUrl'));
+    $addon->register('head', array('BabelEclipseOrgStaging', 'head'));
+    $addon->register('footer', array('BabelEclipseOrgStaging', 'footer'));
 }
 
 global $register_function_html;
diff --git a/addons/reference/html_functions.php b/addons/reference/html_functions.php
index 0f85d28..729ca2b 100644
--- a/addons/reference/html_functions.php
+++ b/addons/reference/html_functions.php
@@ -28,11 +28,24 @@
         return "function fnCheckUrl() {}";
     }
 
+    /**
+     * Outputs the head of the html page.
+     */
+    function head() {
+    }
+    
+    /**
+     * Outputs the footer of the html page.
+     */
+    function footer() {
+    }
 }
 
 function __register_html_ref($addon) {
     $addon->register('image_root', array('Reference', '_imageRoot'));
     $addon->register('validate_map_file_url', array('Reference', 'validateMapFileUrl'));
+    $addon->register('head', array('Reference', 'head'));
+    $addon->register('footer', array('Reference', 'footer'));
 }
 
 global $register_function_html;
diff --git a/html/global.php b/html/global.php
index 3efabd5..b17d4d6 100644
--- a/html/global.php
+++ b/html/global.php
@@ -15,7 +15,7 @@
 define("COOKIE_REMEMBER",	"cBABEL");
 define("COOKIE_SESSION" ,	"sBABEL");
 
-require('html_functions.php');
+require(dirname(__FILE__) . '/html_functions.php');
 
 $GLOBALS['g_LOADTIME'] = microtime();
 require(dirname(__FILE__) . "/../classes/system/dbconnection.class.php");
diff --git a/html/help_babel.php b/html/help_babel.php
index 4a88444..7bd27cd 100644
--- a/html/help_babel.php
+++ b/html/help_babel.php
@@ -14,7 +14,8 @@
 $pageTitle 		= "Babel Project - Eclipse translation";
 $pageKeywords 	= "translation,language,nlpack,pack,eclipse,babel,english,french,german,chinese,japanese,spanish,arabic,hebrew,hungarian,polish,italian,russian,dutch,finnish,greek,norwegian,sweedish,turkish";
 
-include("head.php");
+global $addon;
+$addon->callHook("head");
 
 ?>
 
@@ -47,5 +48,6 @@
 </div>
 
 <?php
-	include("foot.php");
+	global $addon;
+    $addon->callHook("footer");
 ?>
\ No newline at end of file
diff --git a/html/import.php b/html/import.php
index 15301fa..aff3e04 100644
--- a/html/import.php
+++ b/html/import.php
@@ -76,10 +76,12 @@
 		}
 }
 
-include("head.php");
+global $addon;
+$addon->callHook("head");
 
 include("content/en_import.php");
 
-include("foot.php");  
+global $addon;
+$addon->callHook("footer"); 
 
 ?>
\ No newline at end of file
diff --git a/html/importing.php b/html/importing.php
index f7d8a41..2bfd759 100644
--- a/html/importing.php
+++ b/html/importing.php
@@ -16,7 +16,8 @@
 $pageTitle 		= "Babel Project";
 $pageKeywords 	= "translation,language,nlpack,pack,eclipse,babel";
 
-include("head.php");
+global $addon;
+$addon->callHook("head");
 
 
 
@@ -58,5 +59,6 @@
 <script>YAHOO.languageManager.getAjaxLanguages();</script>
 
 <?php
-	include("foot.php");
+	global $addon;
+    $addon->callHook("footer");
 ?>
\ No newline at end of file
diff --git a/html/index.php b/html/index.php
index b065361..7380be9 100644
--- a/html/index.php
+++ b/html/index.php
@@ -16,7 +16,8 @@
 $pageTitle 		= "Babel Project - Eclipse translation";
 $pageKeywords 	= "translation,language,nlpack,pack,eclipse,babel,english,french,german,chinese,japanese,spanish,arabic,hebrew,hungarian,polish,italian,russian,dutch,finnish,greek,norwegian,sweedish,turkish";
 
-include("head.php");
+global $addon;
+$addon->callHook("head");
 
 ?>
 <h1 id="page-message">Welcome to the Babel Project</h1>
@@ -50,5 +51,6 @@
 <script>YAHOO.languageManager.getAjaxLanguages();</script>
 
 <?php
-	include("foot.php");
+	global $addon;
+    $addon->callHook("footer");
 ?>
\ No newline at end of file
diff --git a/html/languages.php b/html/languages.php
index 667c6af..91cad23 100644
--- a/html/languages.php
+++ b/html/languages.php
@@ -17,7 +17,8 @@
 $pageTitle 		= "Babel Project - Eclipse translation";
 $pageKeywords 	= "translation,language,nlpack,pack,eclipse,babel,english,french,german,chinese,japanese,spanish,arabic,hebrew,hungarian,polish,italian,russian,dutch,finnish,greek,norwegian,sweedish,turkish";
 
-include("head.php");
+global $addon;
+$addon->callHook("head");
 
 ?>
 <h1 id="page-message">Supported languages</h1>
@@ -47,5 +48,6 @@
 contact us</a> if the language you need is missing.</p>
 
 <?php
-	include("foot.php");
+	global $addon;
+    $addon->callHook("footer");
 ?>
\ No newline at end of file
diff --git a/html/login.php b/html/login.php
index 2c2bf0d..6253dea 100755
--- a/html/login.php
+++ b/html/login.php
@@ -80,9 +80,11 @@
 # TODO: finish the intro text
 
 
-include("head.php");
+global $addon;
+$addon->callHook("head");
 
 include("content/en_login.php");
 
-include("foot.php");  
+global $addon;
+$addon->callHook("footer");
 ?>
\ No newline at end of file
diff --git a/html/map_files.php b/html/map_files.php
index f7aa4c4..5f82946 100644
--- a/html/map_files.php
+++ b/html/map_files.php
@@ -95,9 +95,10 @@
 	$sql = "SELECT train_id, project_id, version FROM release_train_projects ORDER BY project_id, version ASC";
 	$rs_train_project_list = mysql_query($sql, $dbh);
 	
-	include("head.php");
+	global $addon;
+    $addon->callHook("head");
 	include($incfile);
-	include("foot.php");  
+    $addon->callHook("footer");
 }
 
 
diff --git a/html/recent.php b/html/recent.php
index 2a98702..d8daf67 100644
--- a/html/recent.php
+++ b/html/recent.php
@@ -111,8 +111,9 @@
 ORDER BY t.created_on desc 
 LIMIT $LIMIT";
 $rs_p_stat = mysql_query($sql, $dbh);
-include("head.php");
+global $addon;
+$addon->callHook("head");
 include($incfile);
-include("foot.php");  
+$addon->callHook("footer");
 
 ?>
\ No newline at end of file
diff --git a/html/stats.php b/html/stats.php
index c90cf60..7dbe41a 100644
--- a/html/stats.php
+++ b/html/stats.php
@@ -63,8 +63,9 @@
 $sql = "SELECT p.project_id, p.version, l.name, l.locale, p.pct_complete FROM project_progress AS p INNER JOIN languages AS l ON l.language_id = p.language_id $where ORDER BY p.pct_complete DESC, p.project_id, p.version, l.name";
 $rs_p_stat = mysql_query($sql, $dbh);
 
-include("head.php");
+global $addon;
+$addon->callHook("head");
 include($incfile);
-include("foot.php");  
+$addon->callHook("footer");
 
 ?>
\ No newline at end of file
diff --git a/html/translate.php b/html/translate.php
index adbb6dc..b6f07f1 100644
--- a/html/translate.php
+++ b/html/translate.php
@@ -16,7 +16,8 @@
 $pageTitle 		= "Babel Project";
 $pageKeywords 	= "translation,language,nlpack,pack,eclipse,babel";
 
-include("head.php");
+global $addon;
+$addon->callHook("head");
 
 
 //$_SESSION['language'] = "";
@@ -130,5 +131,6 @@
 
 
 <?php
-	include("foot.php");
+	global $addon;
+    $addon->callHook("footer");
 ?>
\ No newline at end of file
diff --git a/html/user.php b/html/user.php
index 8d239c9..e700421 100644
--- a/html/user.php
+++ b/html/user.php
@@ -16,7 +16,8 @@
 $pageTitle 		= "Babel Project";
 $pageKeywords 	= "translation,language,nlpack,pack,eclipse,babel";
 
-include("head.php");
+global $addon;
+$addon->callHook("head");
 
 ?>
 
@@ -40,5 +41,6 @@
 
 </div>
 <?php
-	include("foot.php");
+	global $addon;
+    $addon->callHook("footer");
 ?>
\ No newline at end of file