* modified some forgotten tsPage::setUrl
[vsc.git] / _res / _libs / output.class.php
blob29005498d870b8328dbee7f6a12d481e0b52ba3f
1 <?php
2 abstract class Output {
3 public $theme,
4 $cookieSet,
5 $time = array('start' => 0,'end' => 0);
7 static private $instance = false;
9 static protected function memcacheEnabled () {
10 /// this sucks on so many ways
11 if (extension_loaded ('memcache') && C_USE_MEMCACHE == true) {
12 $memcache = new Memcache;
13 if (@$memcache->connect('localhost', 11211)) {
14 memcache_debug (true);
15 return $memcache;
18 return false;
21 public function store () {
25 /**
26 * static method to return the Output singleton instance
28 * @param string $to
29 * @return Output
31 static function getInstance ($to) {
32 // we have already initialized the page singleton
33 if (Output::$instance instanceof Output) {
34 return Output::$instance;
35 } else {
36 // the memcache object should also be a singleton
37 // with a static instance I can call wherever.
38 $memcache = Output::memcacheEnabled ();
39 if ( $memcache) {
40 Output::$instance = $memcache->get ( Output::getHash ());
43 if (!(Output::$instance instanceof Output)) {
44 Output::$instance = new $to ();
47 return Output::$instance;
50 static public function getHash () {
51 return md5($_SERVER['HTTP_HOST'].$_SERVER['QUERY_STRING']);
54 public function getTheme(){
55 // this should most probably be changed to tsPage::getRequest ('theme')
56 if (!empty($_GET['theme']) && isDebug()) {
57 $this->theme = $_GET['theme'];
58 } elseif (!empty($_POST['theme'])) {
59 $this->theme = $_POST['theme'];
60 } elseif (!empty($_COOKIE['theme'])) {
61 $this->theme = $_COOKIE['theme'];
63 if (empty($this->theme) ||
64 !is_dir(THEME_PATH.$this->theme) ||
65 !is_dir(THEME_PATH.$this->theme.DIRECTORY_SEPARATOR."_css") ||
66 !is_dir(THEME_PATH.$this->theme.DIRECTORY_SEPARATOR."_templates")
67 ) {
68 $this->theme = DEFAULT_THEME;
71 return $this->theme;
74 public function __construct(){}
76 public function __destruct (){}
78 abstract public function dispatch ();