Просмотр поста

.
~XeOn~

Помогите пожалуйста) Возникла проблемка. При использовании шаблонизатора выдает ошибки:

Notice: Use of undefined constant self - assumed 'self' in /var/www/s4_1570/data/www/amfeon.ru/includes/classes/template.php on line 19

Fatal error: Call to a member function assign() on a non-object in /var/www/s4_1570/data/www/amfeon.ru/modules/index/index.php on line 11

Класс шаблонизатора наследует класс Регистри. Вот шаблонизатор:
<?php

/**
 * @author Folour aka XeOn (SkyFire)
 * @project FoEngine
 * @contacts ICQ: 2666440, MAIL: Folour@i.ua
 * @copyright Folour Technologies, (c) 2012
 */
class Template extends Registry {
	
	protected static $tplExt = '.php';
	protected static $templates = array();
	
	public function __construct() {}
	public function __clone() {}
	
	public static function assign($name, $value) {
		parent::$storage[$name] = $value;
		return self;
	}
	
	public static function setTemplate ($tpl) {
		if(!isset($tpl))
			exit('Tpl name not set');
		self::$templates[] = ROOT . 'modules' . DSEP . MODULE . DSEP . 'templates' . DSEP . $tpl . self::$tplExt;
		return self;
	}
	
	public static function render ($exit = false) {
		//extract(parent::$storage, EXTR_PREFIX_ALL, '');
		if(!empty(self::$templates[0])) {
			foreach (self::$templates as $tpl) {
				if(file_exists($tpl)) {
					echo "\n\t\t<!-- " . basename($tpl) . " begin -->\n";
					require $tpl;
					echo "\n\t\t<!-- " . basename($tpl) . " end -->\n";
				}
				else {
					echo '<div><h1>Template ' . $tpl . ' is missing</h1></div>';
				}
			}
		}
		if($exit) {
			if(file_exists(ROOT . 'style' . DSEP . THEME . DSEP . 'templates' . DSEP . 'footer.php'))
				require ROOT . 'style' . DSEP . THEME . DSEP . 'templates' . DSEP . 'footer.php';
			exit;
		}
	}
}

Вот регистри
<?php

/**
 * @author Folour aka XeOn (SkyFire)
 * @project FoEngine
 * @contacts ICQ: 2666440, MAIL: Folour@i.ua
 * @copyright Folour Technologies, (c) 2012
 */
class Registry {
	protected static $instance = NULL;
	protected static $storage = array();
	
	public static function instance () {
		if(is_null(self::$instance))
			self::$instance = new self;
		//self::$storage['DB'] = new DB(parse_ini_file(INCDIR . 'dbcofig.fdb')));
		self::$instance -> __set('Functions', new Functions);
		self::$instance -> __set('Core', new Core);
		self::$instance -> __set('Tpl', new Template);
		return self::$instance;
	}
	
	public function __set($name, $value) {
		if(!isset(self::$storage[$name]))
			self::$storage[$name] = $value;
		return self::$instance;
	}
	
	public function __get($name) {
		if(isset(self::$storage[$name]))
			return self::$storage[$name];
		return self::$instance;
	}
	
	public function __isset($name) {
		return isset(self::$storage[$name]);
	}
	
	public function __unset($name) {
		unset(self::$storage[$name]);
	}
	
}


А вот как использую шаблонизатор:
<?php

/**
 * @author Folour aka XeOn (SkyFire)
 * @project FoEngine
 * @contacts ICQ: 2666440, MAIL: Folour@i.ua
 * @copyright Folour Technologies, (c) 2012
 */

$Tpl	-> assign('title', 'title')
		-> assign('content', 'content')
		-> setTemplate('content');

А затем в основном контроллере
$Tpl -> render();