allow plugins/apps to add custom headers to all pages
This commit is contained in:
parent
2098cbd822
commit
155f62bcf6
11
lib/base.php
11
lib/base.php
|
@ -120,6 +120,7 @@ if(!$error and !$RUNTIME_NOAPPS ){
|
||||||
class OC_UTIL {
|
class OC_UTIL {
|
||||||
public static $scripts=array();
|
public static $scripts=array();
|
||||||
public static $styles=array();
|
public static $styles=array();
|
||||||
|
public static $headers=array();
|
||||||
private static $fsSetup=false;
|
private static $fsSetup=false;
|
||||||
|
|
||||||
// Can be set up
|
// Can be set up
|
||||||
|
@ -231,6 +232,16 @@ class OC_UTIL {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Add a custom element to the header
|
||||||
|
* @param string tag tag name of the element
|
||||||
|
* @param array $attributes array of attrobutes for the element
|
||||||
|
* @param string $text the text content for the element
|
||||||
|
*/
|
||||||
|
public static function addHeader( $tag, $attributes, $text=''){
|
||||||
|
self::$headers[]=array('tag'=>$tag,'attributes'=>$attributes,'text'=>$text);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* formats a timestamp in the "right" way
|
* formats a timestamp in the "right" way
|
||||||
*
|
*
|
||||||
|
|
|
@ -206,9 +206,6 @@ class OC_TEMPLATE{
|
||||||
$search=new OC_TEMPLATE( 'core', 'part.searchbox');
|
$search=new OC_TEMPLATE( 'core', 'part.searchbox');
|
||||||
$search->assign('searchurl',OC_HELPER::linkTo( 'search', 'index.php' ));
|
$search->assign('searchurl',OC_HELPER::linkTo( 'search', 'index.php' ));
|
||||||
$page->assign('searchbox', $search->fetchPage());
|
$page->assign('searchbox', $search->fetchPage());
|
||||||
|
|
||||||
// Add custom headers
|
|
||||||
$page->assign('headers',$this->headers);
|
|
||||||
|
|
||||||
// Add navigation entry
|
// Add navigation entry
|
||||||
$page->assign( "navigation", OC_APP::getNavigation());
|
$page->assign( "navigation", OC_APP::getNavigation());
|
||||||
|
@ -220,9 +217,6 @@ class OC_TEMPLATE{
|
||||||
$search->assign('searchurl',OC_HELPER::linkTo( 'search', 'index.php' ));
|
$search->assign('searchurl',OC_HELPER::linkTo( 'search', 'index.php' ));
|
||||||
$page->assign('searchbox', $search->fetchPage());
|
$page->assign('searchbox', $search->fetchPage());
|
||||||
|
|
||||||
// Add custom headers
|
|
||||||
$page->assign('headers',$this->headers);
|
|
||||||
|
|
||||||
// Add menu data
|
// Add menu data
|
||||||
if( OC_GROUP::inGroup( $_SESSION["user_id"], "admin" )){
|
if( OC_GROUP::inGroup( $_SESSION["user_id"], "admin" )){
|
||||||
$page->assign( "adminnavigation", OC_APP::getAdminNavigation());
|
$page->assign( "adminnavigation", OC_APP::getAdminNavigation());
|
||||||
|
@ -232,8 +226,6 @@ class OC_TEMPLATE{
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$page = new OC_TEMPLATE( "core", "layout.guest" );
|
$page = new OC_TEMPLATE( "core", "layout.guest" );
|
||||||
// Add custom headers
|
|
||||||
$page->assign('headers',$this->headers);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the css and js files
|
// Add the css and js files
|
||||||
|
@ -259,7 +251,13 @@ class OC_TEMPLATE{
|
||||||
$page->append( "cssfiles", "$WEBROOT/core/$style.css" );
|
$page->append( "cssfiles", "$WEBROOT/core/$style.css" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add custom headers
|
||||||
|
$page->assign('headers',$this->headers);
|
||||||
|
foreach(OC_UTIL::$headers as $header){
|
||||||
|
$page->append('headers',$header);
|
||||||
|
}
|
||||||
|
|
||||||
// Add css files and js files
|
// Add css files and js files
|
||||||
$page->assign( "content", $data );
|
$page->assign( "content", $data );
|
||||||
return $page->fetchPage();
|
return $page->fetchPage();
|
||||||
|
|
Loading…
Reference in New Issue