provide an option to add custom elements to the header of templates
This commit is contained in:
parent
1aa8399915
commit
4d11e920be
4 changed files with 57 additions and 2 deletions
|
@ -13,6 +13,18 @@
|
||||||
<?php foreach($_['jsfiles'] as $jsfile): ?>
|
<?php foreach($_['jsfiles'] as $jsfile): ?>
|
||||||
<script type="text/javascript" src="<?php echo $jsfile; ?>"></script>
|
<script type="text/javascript" src="<?php echo $jsfile; ?>"></script>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
<?php foreach($_['headers'] as $header): ?>
|
||||||
|
<?php
|
||||||
|
echo '<'.$header['tag'].' ';
|
||||||
|
foreach($header['attributes'] as $name=>$value){
|
||||||
|
echo "$name='$value' ";
|
||||||
|
};
|
||||||
|
echo '>';
|
||||||
|
echo $header['text'];
|
||||||
|
echo '</'.$header['tag'].'>';
|
||||||
|
?>
|
||||||
|
<script type="text/javascript" src="<?php echo $jsfile; ?>"></script>
|
||||||
|
<?php endforeach; ?>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body id="body-settings">
|
<body id="body-settings">
|
||||||
|
|
|
@ -13,6 +13,19 @@
|
||||||
<?php foreach($_['jsfiles'] as $jsfile): ?>
|
<?php foreach($_['jsfiles'] as $jsfile): ?>
|
||||||
<script type="text/javascript" src="<?php echo $jsfile; ?>"></script>
|
<script type="text/javascript" src="<?php echo $jsfile; ?>"></script>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
|
||||||
|
<?php foreach($_['headers'] as $header): ?>
|
||||||
|
<?php
|
||||||
|
echo '<'.$header['tag'].' ';
|
||||||
|
foreach($header['attributes'] as $name=>$value){
|
||||||
|
echo "$name='$value' ";
|
||||||
|
};
|
||||||
|
echo '>';
|
||||||
|
echo $header['text'];
|
||||||
|
echo '</'.$header['tag'].'>';
|
||||||
|
?>
|
||||||
|
<script type="text/javascript" src="<?php echo $jsfile; ?>"></script>
|
||||||
|
<?php endforeach; ?>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body id="body-login">
|
<body id="body-login">
|
||||||
|
|
|
@ -13,6 +13,18 @@
|
||||||
<?php foreach($_['jsfiles'] as $jsfile): ?>
|
<?php foreach($_['jsfiles'] as $jsfile): ?>
|
||||||
<script type="text/javascript" src="<?php echo $jsfile; ?>"></script>
|
<script type="text/javascript" src="<?php echo $jsfile; ?>"></script>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
<?php foreach($_['headers'] as $header): ?>
|
||||||
|
<?php
|
||||||
|
echo '<'.$header['tag'].' ';
|
||||||
|
foreach($header['attributes'] as $name=>$value){
|
||||||
|
echo "$name='$value' ";
|
||||||
|
};
|
||||||
|
echo '>';
|
||||||
|
echo $header['text'];
|
||||||
|
echo '</'.$header['tag'].'>';
|
||||||
|
?>
|
||||||
|
<script type="text/javascript" src="<?php echo $jsfile; ?>"></script>
|
||||||
|
<?php endforeach; ?>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body id="body-user">
|
<body id="body-user">
|
||||||
|
|
|
@ -76,6 +76,7 @@ class OC_TEMPLATE{
|
||||||
private $vars; // Vars
|
private $vars; // Vars
|
||||||
private $template; // The path to the template
|
private $template; // The path to the template
|
||||||
private $l10n; // The l10n-Object
|
private $l10n; // The l10n-Object
|
||||||
|
private $headers=array(); //custom headers
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
|
@ -152,6 +153,16 @@ class OC_TEMPLATE{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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 function addHeader( $tag, $attributes, $text=''){
|
||||||
|
$this->headers[]=array('tag'=>$tag,'attributes'=>$attributes,'text'=>$text);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Prints the proceeded template
|
* @brief Prints the proceeded template
|
||||||
* @returns true/false
|
* @returns true/false
|
||||||
|
@ -195,7 +206,9 @@ 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 menu data
|
|
||||||
|
// 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());
|
||||||
|
@ -206,6 +219,10 @@ 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 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());
|
||||||
|
@ -215,7 +232,8 @@ class OC_TEMPLATE{
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$page = new OC_TEMPLATE( "core", "layout.guest" );
|
$page = new OC_TEMPLATE( "core", "layout.guest" );
|
||||||
// Add data if required
|
// Add custom headers
|
||||||
|
$page->assign('headers',$this->headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the css and js files
|
// Add the css and js files
|
||||||
|
|
Loading…
Reference in a new issue