2015-03-08 18:02:59 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class Theme {
|
|
|
|
|
2017-05-21 22:01:44 +02:00
|
|
|
// Return the metatag <title> with a predefine structure
|
|
|
|
public static function headTitle()
|
2015-09-22 01:37:04 +02:00
|
|
|
{
|
2017-05-21 22:01:44 +02:00
|
|
|
global $Url;
|
|
|
|
global $Site;
|
|
|
|
global $dbTags;
|
|
|
|
global $dbCategories;
|
|
|
|
global $WHERE_AM_I;
|
|
|
|
global $page;
|
|
|
|
|
|
|
|
$title = $Site->title();
|
|
|
|
|
|
|
|
if( $WHERE_AM_I=='page' ) {
|
|
|
|
$title = $page->title().' - '.$Site->title();
|
|
|
|
}
|
|
|
|
elseif( $WHERE_AM_I=='tag' ) {
|
|
|
|
$tagKey = $Url->slug();
|
|
|
|
$tagName = $dbTags->getName($tagKey);
|
|
|
|
$title = $tagName.' - '.$Site->title();
|
|
|
|
}
|
|
|
|
elseif( $WHERE_AM_I=='category' ) {
|
|
|
|
$categoryKey = $Url->slug();
|
|
|
|
$categoryName = $dbCategories->getName($categoryKey);
|
|
|
|
$title = $categoryName.' - '.$Site->title();
|
2016-02-14 17:34:25 +01:00
|
|
|
}
|
|
|
|
|
2017-05-21 22:01:44 +02:00
|
|
|
return '<title>'.$title.'</title>'.PHP_EOL;
|
|
|
|
}
|
2015-09-22 01:37:04 +02:00
|
|
|
|
2017-05-21 22:01:44 +02:00
|
|
|
// Return the metatag <decription> with a predefine structure
|
|
|
|
public static function headDescription()
|
|
|
|
{
|
|
|
|
global $Site;
|
|
|
|
global $WHERE_AM_I;
|
|
|
|
global $page;
|
|
|
|
|
|
|
|
$description = $Site->description();
|
|
|
|
|
|
|
|
if( $WHERE_AM_I=='page' ) {
|
|
|
|
$description = $page->description();
|
2015-09-22 01:37:04 +02:00
|
|
|
}
|
|
|
|
|
2017-05-21 22:01:44 +02:00
|
|
|
return '<meta name="description" content="'.$description.'">'.PHP_EOL;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function charset($charset)
|
|
|
|
{
|
|
|
|
return '<meta charset="'.$charset.'">'.PHP_EOL;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function viewport($content)
|
|
|
|
{
|
|
|
|
return '<meta name="viewport" content="'.$content.'">'.PHP_EOL;
|
2015-09-22 01:37:04 +02:00
|
|
|
}
|
|
|
|
|
2017-05-21 22:01:44 +02:00
|
|
|
public static function css($files, $path=HTML_PATH_THEME)
|
2015-05-15 00:07:45 +02:00
|
|
|
{
|
2017-05-21 22:01:44 +02:00
|
|
|
if( !is_array($files) ) {
|
2015-05-15 00:07:45 +02:00
|
|
|
$files = array($files);
|
|
|
|
}
|
|
|
|
|
2017-05-21 22:01:44 +02:00
|
|
|
$links = '';
|
2015-05-15 00:07:45 +02:00
|
|
|
foreach($files as $file) {
|
2017-05-21 22:01:44 +02:00
|
|
|
$links .= '<link rel="stylesheet" type="text/css" href="'.$path.$file.'">'.PHP_EOL;
|
2015-05-15 00:07:45 +02:00
|
|
|
}
|
|
|
|
|
2017-05-21 22:01:44 +02:00
|
|
|
return $links;
|
2015-05-15 00:07:45 +02:00
|
|
|
}
|
|
|
|
|
2017-05-21 22:01:44 +02:00
|
|
|
public static function javascript($files, $path=HTML_PATH_THEME)
|
2015-05-15 00:07:45 +02:00
|
|
|
{
|
2017-05-21 22:01:44 +02:00
|
|
|
if( !is_array($files) ) {
|
2015-05-15 00:07:45 +02:00
|
|
|
$files = array($files);
|
|
|
|
}
|
|
|
|
|
2017-05-21 22:01:44 +02:00
|
|
|
$scripts = '';
|
2015-05-15 00:07:45 +02:00
|
|
|
foreach($files as $file) {
|
2017-05-21 22:01:44 +02:00
|
|
|
$scripts .= '<script src="'.$path.$file.'"></script>'.PHP_EOL;
|
2015-05-15 00:07:45 +02:00
|
|
|
}
|
|
|
|
|
2017-05-21 22:01:44 +02:00
|
|
|
return $scripts;
|
|
|
|
}
|
2015-05-15 00:07:45 +02:00
|
|
|
|
2017-05-21 22:01:44 +02:00
|
|
|
public static function js($files, $path=HTML_PATH_THEME)
|
|
|
|
{
|
|
|
|
self::javascript($files, $path);
|
2015-05-15 00:07:45 +02:00
|
|
|
}
|
|
|
|
|
2017-05-21 22:01:44 +02:00
|
|
|
public static function plugins($type)
|
2015-05-15 00:07:45 +02:00
|
|
|
{
|
2017-05-21 22:01:44 +02:00
|
|
|
global $plugins;
|
|
|
|
foreach($plugins[$type] as $plugin) {
|
|
|
|
echo call_user_func(array($plugin, $type));
|
|
|
|
}
|
|
|
|
}
|
2016-02-14 17:34:25 +01:00
|
|
|
|
2017-05-21 22:01:44 +02:00
|
|
|
// ---- OLD
|
|
|
|
|
|
|
|
public static function favicon($file='favicon.png', $path=HTML_PATH_THEME_IMG, $typeIcon=true, $echo=true)
|
|
|
|
{
|
|
|
|
$type = 'image/png';
|
|
|
|
if($typeIcon) {
|
|
|
|
$type = 'image/x-icon';
|
2016-02-14 17:34:25 +01:00
|
|
|
}
|
|
|
|
|
2017-05-21 22:01:44 +02:00
|
|
|
$tmp = '<link rel="shortcut icon" href="'.$path.$file.'" type="'.$type.'">'.PHP_EOL;
|
2015-05-15 00:07:45 +02:00
|
|
|
|
|
|
|
if($echo) {
|
|
|
|
echo $tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $tmp;
|
|
|
|
}
|
|
|
|
|
2016-02-14 17:34:25 +01:00
|
|
|
|
|
|
|
|
2015-05-15 00:07:45 +02:00
|
|
|
|
|
|
|
|
2017-05-21 22:01:44 +02:00
|
|
|
|
|
|
|
|
2015-05-15 00:07:45 +02:00
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-03-08 18:02:59 +01:00
|
|
|
|
|
|
|
|
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
|
|
|
?>
|