New filters introduced for page header, obsolete template removed:
authorRoland Häder <roland@mxchange.org>
Thu, 14 Jan 2010 20:09:03 +0000 (20:09 +0000)
committerRoland Häder <roland@mxchange.org>
Thu, 14 Jan 2010 20:09:03 +0000 (20:09 +0000)
- New filters 'pre_page_header' and 'post_page_header' introduced to let
  extensions add their own JavaScript inclusions.
- The HTML template 'header.tpl' is now no longer needed

.gitattributes
inc/filter-functions.php
inc/filters.php
inc/functions.php
templates/de/html/header.tpl [deleted file]

index 00ddc0e..8befaa2 100644 (file)
@@ -1421,7 +1421,6 @@ templates/de/html/guest/guest_top10_empty5.tpl -text
 templates/de/html/guest/guest_top10_row_earner.tpl -text
 templates/de/html/guest/guest_top10_row_login.tpl -text
 templates/de/html/guest/guest_top10_row_refs.tpl -text
-templates/de/html/header.tpl -text
 templates/de/html/impressum.tpl -text
 templates/de/html/index.tpl -text
 templates/de/html/index_forward.tpl -text
index 046ea8a..82747fe 100644 (file)
@@ -114,6 +114,14 @@ ORDER BY
        registerFilter('init', 'UPDATE_LOGIN_DATA');
        registerFilter('init', 'ACTIVATE_EXCHANGE');
 
+       // Page headers - pre-filter (normally, you want to register here)
+       registerFilter('pre_page_header', 'LOAD_PAGE_HEADER');
+
+       // Page headers - post-filter (normally, you don't want to register here)
+       // ------------------- LAST FILTER FOR THIS CHAIN! ------------------------
+       registerFilter('post_page_header', 'FINISH_PAGE_HEADER');
+       // ------------------- LAST FILTER FOR THIS CHAIN! ------------------------
+
        // Login failures handler
        registerFilter('post_youhere_line', 'CALL_HANDLER_LOGIN_FAILTURES');
 
index 5fc55a5..8636a38 100644 (file)
@@ -933,5 +933,36 @@ function FILTER_DO_LOGIN_ADMIN ($data) {
        return $data;
 }
 
+// Filter for loading page header, this should be ran first!
+function FILTER_LOAD_PAGE_HEADER () {
+       // Determine the page title
+       $content['header_title'] = determinePageTitle();
+
+       // Output page header code
+       $GLOBALS['page_header'] = loadTemplate('page_header', true, $content);
+
+       // Include meta data in 'guest' module
+       if (getModule() == 'index') {
+               // Load meta data template
+               $GLOBALS['page_header'] .= loadTemplate('metadata', true);
+
+               // Add meta description to header
+               if ((isInstalled()) && (isAdminRegistered()) && (SQL_IS_LINK_UP())) {
+                       // Add meta description not in admin and login module and when the script is installed
+                       generateMetaDescriptionCode();
+               } // END - if
+       } // END - if
+}
+
+// Filter for adding style sheet, closing page header
+function FILTER_FINISH_PAGE_HEADER () {
+       // Include stylesheet
+       loadIncludeOnce('inc/stylesheet.php');
+
+       // Closing HEAD tag
+       $GLOBALS['page_header'] .= '</head>';
+}
+
 // [EOF]
 ?>
+
index da1d250..c129368 100644 (file)
@@ -3792,32 +3792,18 @@ function isSpider () {
 
 // Prepares the header for HTML output
 function loadHtmlHeader () {
-       // Determine the page title
-       $content['header_title'] = determinePageTitle();
+       // Run two filters:
+       // 1.) pre_page_header (mainly loads the page_header template and includes
+       //     meta description)
+       runFilterChain('pre_page_header');
 
-       // Output page header code
-       $GLOBALS['page_header'] = loadTemplate('page_header', true, $content);
-
-       // Include meta data in 'guest' module
-       if (getModule() == 'index') {
-               // Load meta data template
-               $GLOBALS['page_header'] .= loadTemplate('metadata', true);
-
-               // Add meta description to header
-               if ((isInstalled()) && (isAdminRegistered()) && (SQL_IS_LINK_UP())) {
-                       // Add meta description not in admin and login module and when the script is installed
-                       generateMetaDescriptionCode();
-               } // END - if
-       } // END - if
+       // Here can be something be added, but normally one of the two filters
+       // around this line should do the job for you.
 
+       // 2.) post_page_header (mainly to load stylesheet, extra JavaScripts and
+       //     to close the head-tag)
        // Include more header data here
-       $GLOBALS['page_header'] .= loadTemplate('header', true);
-
-       // Include stylesheet
-       loadIncludeOnce('inc/stylesheet.php');
-
-       // Closing HEAD tag
-       $GLOBALS['page_header'] .= '</head>';
+       runFilterChain('post_page_header');
 }
 
 // Adds page header and footer to output array element
diff --git a/templates/de/html/header.tpl b/templates/de/html/header.tpl
deleted file mode 100644 (file)
index e69de29..0000000