bludit/bl-kernel/helpers/theme.class.php

193 lines
3.2 KiB
PHP
Raw Normal View History

2015-03-08 18:02:59 +01:00
<?php
class Theme {
2016-02-14 17:34:25 +01:00
public static function favicon($file='favicon.png', $path=HTML_PATH_THEME_IMG, $typeIcon=true, $echo=true)
2015-09-22 01:37:04 +02:00
{
2016-02-14 17:34:25 +01:00
$type = 'image/png';
if($typeIcon) {
$type = 'image/x-icon';
}
$tmp = '<link rel="shortcut icon" href="'.$path.$file.'" type="'.$type.'">'.PHP_EOL;
2015-09-22 01:37:04 +02:00
if($echo) {
echo $tmp;
}
return $tmp;
}
2015-05-15 00:07:45 +02:00
public static function css($files, $path=HTML_PATH_THEME_CSS, $echo=true)
{
if(!is_array($files)) {
$files = array($files);
}
$tmp = '';
foreach($files as $file) {
$tmp .= '<link rel="stylesheet" type="text/css" href="'.$path.$file.'">'.PHP_EOL;
}
if($echo) {
echo $tmp;
}
return $tmp;
}
public static function javascript($files, $path=HTML_PATH_THEME_JS, $echo=true)
{
if(!is_array($files)) {
$files = array($files);
}
$tmp = '';
foreach($files as $file) {
$tmp .= '<script src="'.$path.$file.'"></script>'.PHP_EOL;
}
if($echo) {
echo $tmp;
}
return $tmp;
}
2016-02-14 17:34:25 +01:00
public static function title($title=false, $echo=true)
2015-05-15 00:07:45 +02:00
{
2016-02-14 17:34:25 +01:00
global $Url;
global $Post, $Page;
global $Site;
2016-09-26 05:25:40 +02:00
global $dbTags;
2016-02-14 17:34:25 +01:00
$tmp = $title;
if(empty($title))
{
if( $Url->whereAmI()=='post' ) {
$tmp = $Post->title().' - '.$Site->title();
}
elseif( $Url->whereAmI()=='page' ) {
$tmp = $Page->title().' - '.$Site->title();
}
2016-09-26 05:25:40 +02:00
elseif( $Url->whereAmI()=='tag' ) {
$tag = $dbTags->getTag($Url->slug());
$tmp = $tag.' - '.$Site->title();
}
2016-02-14 17:34:25 +01:00
else {
$tmp = $Site->title();
}
}
$tmp = '<title>'.$tmp.'</title>'.PHP_EOL;
2015-05-15 00:07:45 +02:00
if($echo) {
echo $tmp;
}
return $tmp;
}
2016-02-14 17:34:25 +01:00
public static function description($description=false, $echo=true)
2015-05-15 00:07:45 +02:00
{
2016-02-14 17:34:25 +01:00
global $Url;
global $Post, $Page;
global $Site;
$tmp = $description;
if(empty($description))
{
if( $Url->whereAmI()=='post' ) {
$tmp = $Post->description();
}
elseif( $Url->whereAmI()=='page' ) {
$tmp = $Page->description();
}
else {
$tmp = $Site->description();
}
}
$tmp = '<meta name="description" content="'.$tmp.'">'.PHP_EOL;
2015-05-15 00:07:45 +02:00
if($echo) {
echo $tmp;
}
return $tmp;
}
2015-07-07 00:22:03 +02:00
public static function keywords($keywords, $echo=true)
{
if(is_array($keywords)) {
$keywords = implode(',', $keywords);
}
$tmp = '<meta name="keywords" content="'.$keywords.'">'.PHP_EOL;
if($echo) {
echo $tmp;
}
return $tmp;
}
2015-05-15 00:07:45 +02:00
public static function viewport($content='width=device-width, initial-scale=1.0', $echo=true)
{
$tmp = '<meta name="viewport" content="'.$content.'">'.PHP_EOL;
if($echo) {
echo $tmp;
}
return $tmp;
}
public static function charset($charset, $echo=true)
{
$tmp = '<meta charset="'.$charset.'">'.PHP_EOL;
if($echo) {
echo $tmp;
}
return $tmp;
}
2015-03-08 18:02:59 +01:00
public static function plugins($type)
{
global $plugins;
foreach($plugins[$type] as $plugin)
{
echo call_user_func(array($plugin, $type));
}
}
2015-09-22 01:37:04 +02:00
public static function jquery($echo=true)
{
2016-01-17 01:45:16 +01:00
$tmp = '<script src="'.HTML_PATH_ADMIN_THEME_JS.'jquery.min.js'.'"></script>'.PHP_EOL;
if($echo) {
echo $tmp;
}
return $tmp;
}
public static function fontAwesome($echo=true, $online=false)
{
$tmp = '<link rel="stylesheet" href="'.HTML_PATH_ADMIN_THEME_CSS.'font-awesome.min.css'.'">'.PHP_EOL;
2015-09-22 01:37:04 +02:00
if($echo) {
echo $tmp;
}
return $tmp;
}
2015-05-15 00:07:45 +02:00
2015-03-08 18:02:59 +01:00
}
2016-01-08 00:43:09 +01:00
?>