tpl->addValue('Freshy2StyleSheet',array('tplFreshy2Theme','FreshyStyleSheet'));
$core->tpl->addValue('Freshy2LayoutClass',array('tplFreshy2Theme','FreshyLayoutClass'));
$core->tpl->addBlock('Freshy2IfHasSidebar',array('tplFreshy2Theme','FreshyIfHasSidebar'));
$core->tpl->addBlock('Freshy2IfHasSidebarContent',array('tplFreshy2Theme','FreshyIfHasSidebarContent'));
$core->tpl->addBlock('Freshy2MenuIf',array('tplFreshy2Theme','FreshyMenuIf'));
$core->addBehavior('publicHeadContent',array('tplFreshy2Theme','publicHeadContent'));
l10n::set(dirname(__FILE__).'/locales/'.$_lang.'/public');
require dirname(__FILE__).'/lib/class.freshy2.config.php';
class tplFreshy2Theme
{
public static $config;
public static $syssettings;
public static function initSettings() {
global $core;
self::$config = new freshy2Config($core);
self::$syssettings =& $core->blog->settings->system;
}
public static function FreshyStyleSheet($attr) {
return "style.css";
}
public static function FreshyMenuIf($attr,$content) {
if (isset($attr['name']) && $attr['name']=="freshymenu") {
$menu = "freshymenu";
} else {
$menu = "simplemenu";
}
return 'menu == "'.$menu.'"): ?>'."\n".
$content."\n".
''."\n";
}
public static function FreshyLayoutClass($attr) {
$p = 'right_sidebar != "none")'."\n";
$p .= ' echo "sidebar_right ";'."\n";
$p .= 'if (tplFreshy2Theme::$config->left_sidebar != "none")'."\n";
$p .= ' echo "sidebar_left";'."\n";
$p .= '?>'."\n";
return $p;
}
public static function FreshyIfHasSidebar($attr,$content) {
if (isset($attr['pos']))
$pos=trim(strtolower($attr['pos']));
else
$pos="right";
if ($pos == 'both') {
return 'left_sidebar != "none") '.
'&& (tplFreshy2Theme::$config->right_sidebar != "none")): ?>'."\n".
$content."\n".
''."\n";
} else {
$setting = $pos."_sidebar";
return ''.$setting.' != "none"): ?>'."\n".
$content."\n".
''."\n";
}
}
public static function FreshyIfHasSidebarContent($attr,$content) {
if (isset($attr['pos']))
$pos=trim(strtolower($attr['pos']));
else
$pos="right";
$setting = $pos."_sidebar";
if (isset($attr['value']))
$value=trim(strtolower($attr['value']));
else
$value="nav";
return ''.$setting.' == "'.$value.'"): ?>'."\n".
$content."\n".
''."\n";
}
public static function publicHeadContent($core)
{
$cust = self::$config->custom_theme;
$topimg = self::$config->top_image;
$theme_url= self::$syssettings->themes_url."/".self::$syssettings->theme;
$css_content='';
if (empty($cust) === false && $cust !== 'default') {
$css_content .= '@import url('.
$theme_url.'/'.$cust.");\n";
}
if ($topimg !== null && $topimg !== 'default') {
$css_content .= "#header_image {\n".
"background-image:url(".$theme_url.'/images/headers/'.$topimg.");\n".
"}\n";
}
if ($css_content != "") {
echo '\n";
}
}
}
$core->tpl->addValue('gravatar', array('gravatar', 'tplGravatar'));
class gravatar {
const
URLBASE = 'http://www.gravatar.com/avatar.php?gravatar_id=%s&default=%s&size=%d',
HTMLTAG = '
',
DEFAULT_SIZE = '40',
DEFAULT_CLASS = 'gravatar_img',
DEFAULT_ALT = 'Gravatar de %s';
public static function tplGravatar($attr)
{
$md5mail = '\'.md5(strtolower($_ctx->comments->getEmail(false))).\'';
$size = array_key_exists('size', $attr) ? $attr['size'] : self::DEFAULT_SIZE;
$class = array_key_exists('class', $attr) ? $attr['class'] : self::DEFAULT_CLASS;
$alttxt = array_key_exists('alt', $attr) ? $attr['alt'] : self::DEFAULT_ALT;
$altimg = array_key_exists('altimg', $attr) ? $attr['altimg'] : '';
$gurl = sprintf(self::URLBASE,
$md5mail, urlencode($altimg), $size);
$gtag = sprintf(self::HTMLTAG,
$gurl, $class, preg_match("/%s/i", $alttxt) ?
sprintf($alttxt, '\'.$_ctx->comments->comment_author.\'') : $alttxt);
return '';
}
}
tplFreshy2Theme::initSettings();