<?php
class uberTpl
{
private $outputData;
private $params = Array();
private $includeFiles = Array();
public function Init()
{
global $core, $users;
$this->SetParam('', 'Holo');
$this->SetParam('body_id', '');
$this->SetParam('page_title', ' ');
$this->SetParam('flash_build', 'flash_50_9');
$this->SetParam('web_build', '63_1dc60c6d6ea6e089c6893ab4e0541ee0/711');
$this->SetParam('web_build_str', '50-BUILD66 - 06.05.2010 22:28');
$this->SetParam('req_path', WWW);
$this->SetParam('www', WWW);
$this->SetParam('badges', '' . WWW . '/c_images/album1584/');
$this->SetParam('hotel_status_fig', uberCore::GetSystemStatusString(true));
$this->SetParam('hotel_status', uberCore::GetSystemStatusString(false));
if (LOGGED_IN)
{
$this->SetParam('habboLoggedIn', 'true');
$this->SetParam('habboName', USER_NAME);
}
else
{
$this->SetParam('habboLoggedIn', 'false');
$this->SetParam('habboName', '');
}
}
public function AddIncludeSet($set)
{
switch (strtolower($set))
{
case "frontpage":
$this->AddIncludeFile(new IncludeFile('text/javascript', 'http://cobe.me/resources/habbo/webbuild/?file=libs2.js&type=js'));
$this->AddIncludeFile(new IncludeFile('text/javascript', 'http://cobe.me/resources/habbo/webbuild/?file=landing.js&type=js'));
$this->AddIncludeFile(new IncludeFile('text/css', 'http://cobe.me/resources/habbo/webbuild/?file=frontpage.css&type=css', 'stylesheet'));
break;
case "register":
$this->AddIncludeFile(new IncludeFile('text/javascript', 'http://cobe.me/resources/habbo/webbuild/?file=visual.js&type=js'));
$this->AddIncludeFile(new IncludeFile('text/javascript', 'http://cobe.me/resources/habbo/webbuild/?file=common.js&type=js'));
$this->AddIncludeFile(new IncludeFile('text/css', 'http://cobe.me/resources/habbo/webbuild/?file=style.css&type=css', 'stylesheet'));
$this->AddIncludeFile(new IncludeFile('text/css', 'http://cobe.me/resources/habbo/webbuild/?file=buttons.css&type=css', 'stylesheet'));
$this->AddIncludeFile(new IncludeFile('text/css', 'http://cobe.me/resources/habbo/webbuild/?file=boxes.css&type=css', 'stylesheet'));
$this->AddIncludeFile(new IncludeFile('text/css', 'http://cobe.me/resources/habbo/webbuild/?file=tooltips.css&type=css', 'stylesheet'));
$this->AddIncludeFile(new IncludeFile('text/css', 'http://cobe.me/resources/habbo/webbuild/?file=embeddedregistration.css&type=css', 'stylesheet'));
$this->AddIncludeFile(new IncludeFile('text/javascript', 'http://cobe.me/resources/habbo/webbuild/?file=simpleregistration.js&type=js'));
break;
case "process-template":
$this->AddIncludeFile(new IncludeFile('text/javascript', 'http://cobe.me/resources/habbo/webbuild/?file=libs2.js&type=js'));
$this->AddIncludeFile(new IncludeFile('text/javascript', 'http://cobe.me/resources/habbo/webbuild/?file=visual.js&type=js'));
$this->AddIncludeFile(new IncludeFile('text/javascript', 'http://cobe.me/resources/habbo/webbuild/?file=libs.js&type=js'));
$this->AddIncludeFile(new IncludeFile('text/javascript', 'http://cobe.me/resources/habbo/webbuild/?file=common.js&type=js'));
$this->AddIncludeFile(new IncludeFile('text/javascript', 'http://cobe.me/resources/habbo/webbuild/?file=fullcontent.js&type=js'));
$this->AddIncludeFile(new IncludeFile('text/css', 'http://cobe.me/resources/habbo/webbuild/?file=style.css&type=css', 'stylesheet'));
$this->AddIncludeFile(new IncludeFile('text/css', 'http://cobe.me/resources/habbo/webbuild/?file=buttons.css&type=css', 'stylesheet'));
$this->AddIncludeFile(new IncludeFile('text/css', 'http://cobe.me/resources/habbo/webbuild/?file=boxes.css&type=css', 'stylesheet'));
$this->AddIncludeFile(new IncludeFile('text/css', 'http://cobe.me/resources/habbo/webbuild/?file=tooltips.css&type=css', 'stylesheet'));
$this->AddIncludeFile(new IncludeFile('text/css', 'http://cobe.me/resources/habbo/webbuild/?file=process.css&type=css', 'stylesheet'));
break;
case 'myhabbo':
$this->AddIncludeFile(new IncludeFile('text/javascript', 'http://cobe.me/resources/habbo/webbuild/?file=libs2.js&type=js'));
$this->AddIncludeFile(new IncludeFile('text/javascript', 'http://cobe.me/resources/habbo/webbuild/?file=visual.js&type=js'));
$this->AddIncludeFile(new IncludeFile('text/javascript', 'http://cobe.me/resources/habbo/webbuild/?file=libs.js&type=js'));
$this->AddIncludeFile(new IncludeFile('text/javascript', 'http://cobe.me/resources/habbo/webbuild/?file=common.js&type=js'));
$this->AddIncludeFile(new IncludeFile('text/javascript', 'http://cobe.me/resources/habbo/webbuild/?file=fullcontent.js&type=js'));
$this->AddIncludeFile(new IncludeFile('text/css', 'http://cobe.me/resources/habbo/webbuild/?file=style.css&type=css', 'stylesheet'));
$this->AddIncludeFile(new IncludeFile('text/css', 'http://cobe.me/resources/habbo/webbuild/?file=buttons.css&type=css', 'stylesheet'));
$this->AddIncludeFile(new IncludeFile('text/css', 'http://cobe.me/resources/habbo/webbuild/?file=boxes.css&type=css', 'stylesheet'));
$this->AddIncludeFile(new IncludeFile('text/css', 'http://cobe.me/resources/habbo/webbuild/?file=tooltips.css&type=css', 'stylesheet'));
$this->AddIncludeFile(new IncludeFile('text/css', 'http://cobe.me/resources/habbo/webbuild/?file=myhabbo/myhabbo.css&type=css', 'stylesheet'));
$this->AddIncludeFile(new IncludeFile('text/css', 'http://cobe.me/resources/habbo/webbuild/?file=myhabbo/skins.css&type=css', 'stylesheet'));
$this->AddIncludeFile(new IncludeFile('text/css', 'http://cobe.me/resources/habbo/webbuild/?file=myhabbo/dialogs.css&type=css', 'stylesheet'));
$this->AddIncludeFile(new IncludeFile('text/css', 'http://cobe.me/resources/habbo/webbuild/?file=myhabbo/buttons.css&type=css', 'stylesheet'));
$this->AddIncludeFile(new IncludeFile('text/css', 'http://cobe.me/resources/habbo/webbuild/?file=myhabbo/control.textarea.css&type=css', 'stylesheet'));
$this->AddIncludeFile(new IncludeFile('text/css', 'http://cobe.me/resources/habbo/webbuild/?file=myhabbo/boxes.css&type=css', 'stylesheet'));
$this->AddIncludeFile(new IncludeFile('text/css', 'http://cobe.me/resources/habbo/webbuild/?file=myhabbo.css&type=css', 'stylesheet'));
$this->AddIncludeFile(new IncludeFile('text/javascript', 'http://cobe.me/resources/habbo/webbuild/?file=homeview.js&type=js'));
$this->AddIncludeFile(new IncludeFile('text/css', 'http://cobe.me/resources/habbo/webbuild/?file=lightwindow.css&type=css', 'stylesheet'));
break;
case 'default':
default:
$this->AddIncludeFile(new IncludeFile('text/javascript', 'http://cobe.me/resources/habbo/webbuild/?file=libs2.js&type=js'));
$this->AddIncludeFile(new IncludeFile('text/javascript', 'http://cobe.me/resources/habbo/webbuild/?file=visual.js&type=js'));
$this->AddIncludeFile(new IncludeFile('text/javascript', 'http://cobe.me/resources/habbo/webbuild/?file=libs.js&type=js'));
$this->AddIncludeFile(new IncludeFile('text/javascript', 'http://cobe.me/resources/habbo/webbuild/?file=common.js&type=js'));
$this->AddIncludeFile(new IncludeFile('text/javascript', 'http://cobe.me/resources/habbo/webbuild/?file=fullcontent.js&type=js'));
$this->AddIncludeFile(new IncludeFile('text/css', 'http://cobe.me/resources/habbo/webbuild/?file=style.css&type=css', 'stylesheet'));
$this->AddIncludeFile(new IncludeFile('text/css', 'http://cobe.me/resources/habbo/webbuild/?file=buttons.css&type=css', 'stylesheet'));
$this->AddIncludeFile(new IncludeFile('text/css', 'http://cobe.me/resources/habbo/webbuild/?file=boxes.css&type=css', 'stylesheet'));
$this->AddIncludeFile(new IncludeFile('text/css', 'http://cobe.me/resources/habbo/webbuild/?file=tooltips.css&type=css', 'stylesheet'));
break;
}
}
public function AddGeneric($tplName)
{
$tpl = new Template($tplName);
$this->outputData .= $tpl->GetHtml();
}
public function AddTemplate($tpl)
{
$this->outputData .= $tpl->GetHtml();
}
public function SetParam($param, $value)
{
$this->params[$param] = is_object($value) ? $value->fetch() : $value;
}
public function UnsetParam($param)
{
unset($this->params[$param]);
}
public function AddIncludeFile($incFile)
{
$this->includeFiles[] = $incFile;
}
public function WriteIncludeFiles()
{
foreach ($this->includeFiles as $f)
{
$this->Write($f->GetHtml() . LB);
}
}
public function Write($str)
{
$this->outputData .= $str;
}
public function FilterParams($str)
{
foreach ($this->params as $param => $value)
{
$str = str_ireplace('%' . $param . '%', $value, $str);
}
return $str;
}
public function Output()
{
global $core;
//$this->Write(LB . LB . '<!-- Took ' . ( round((microtime(true) - $core->execStart), 4) ) . ' to output this page -->' . LB . LB);
echo $this->FilterParams($this->outputData);
}
}
class Template
{
private $params = Array();
private $tplName = '';
public function Template($tplName)
{
$this->tplName = $tplName;
}
public function GetHtml()
{
global $users;
extract($this->params);
$file = CWD . 'inc/tpl/' . $this->tplName . '.tpl';
if (!file_exists($file))
{
uberCore::SystemError('Template system error', 'Could not load template: ' . $this->tplName);
}
ob_start();
include($file);
$data = ob_get_contents();
ob_end_clean();
return $this->FilterParams($data);
}
public function FilterParams($str)
{
foreach ($this->params as $param => $value)
{
if (is_object($value))
{
continue;
}
$str = str_ireplace('%' . $param . '%', $value, $str);
}
return $str;
}
public function SetParam($param, $value)
{
$this->params[$param] = $value;
}
public function UnsetParam($param)
{
unset($this->params[$param]);
}
}
class IncludeFile
{
private $type;
private $src;
private $rel;
private $name;
public function IncludeFile($type, $src, $rel = '', $name = '')
{
global $tpl;
$this->type = $type;
$this->src = $src;
$this->rel = $rel;
$this->name = $name;
}
public function GetHtml()
{
switch ($this->type)
{
case 'application/rss+xml':
return '<link rel="' . $this->rel . '" type="' . $this->type . '" title="' . $this->name . '" href="' . $this->src . '" />';
case 'text/javascript':
return '<script src="' . $this->src . '" type="text/javascript"></script>';
case 'text/rocketscript':
return '<script data-cfasync="true" src="' . $this->src . '"></script>';
case 'text/css':
default:
return '<link rel="' . $this->rel . '" href="' . $this->src . '" type="' . $this->type . '" />';
}
}
}
?>