Commit bffa9863 by Hikonobu Kurihara

Merge branch 'master' of git://github.com/yiiext/dwoo-renderer

parents 2ec4f10a 72163bc0
<?php
/**
* Dwoo view renderer
*
* @author Alexander Makarov <sam@rmcreative.ru>
* @link http://code.google.com/p/yiiext/
* @link http://dwoo.org/
*
* @version 0.9.2
*/
class EDwooViewRenderer extends CApplicationComponent implements IViewRenderer {
public $fileExtension='.tpl';
public $filePermission=0755;
public $pluginsDir = null;
/**
* @var Dwoo
*/
private $dwoo;
/**
* Component initialization
*/
function init(){
Yii::import('application.vendors.*');
// need this since Yii autoload handler raises an error if class is not found
spl_autoload_unregister(array('YiiBase','autoload'));
// registering Dwoo autoload handler
require_once 'Dwoo/dwooAutoload.php';
// adding back Yii autoload handler
spl_autoload_register(array('YiiBase','autoload'));
// compiled templates directory
$compileDir = Yii::app()->getRuntimePath().'/dwoo/compiled/';
// create compiled directory if not exists
if(!file_exists($compileDir)){
mkdir($compileDir, $this->filePermission, true);
}
// cached templates directory
$cacheDir = Yii::app()->getRuntimePath().'/dwoo/cache/';
// create compiled directory if not exists
if(!file_exists($cacheDir)){
mkdir($cacheDir, $this->filePermission, true);
}
$this->dwoo = new Dwoo($compileDir, $cacheDir);
$loader = $this->dwoo->getLoader();
// adding extension plugin directory
$loader->addDirectory(Yii::getPathOfAlias('application.extensions.Dwoo.plugins'));
// adding config plugin directory if specified
if(!empty($this->pluginsDir)){
$loader->addDirectory(Yii::getPathOfAlias($this->pluginsDir));
}
}
/**
* Renders a view file.
* This method is required by {@link IViewRenderer}.
* @param CBaseController the controller or widget who is rendering the view file.
* @param string the view file path
* @param mixed the data to be passed to the view
* @param boolean whether the rendering result should be returned
* @return mixed the rendering result, or null if the rendering result is not needed.
*/
public function renderFile($context,$sourceFile,$data,$return) {
// current controller properties will be accessible as {this.property}
$data['this'] = $context;
$data['Yii'] = Yii::app();
$data["TIME"] = sprintf('%0.5f',Yii::getLogger()->getExecutionTime());
$data["MEMORY"] = round(Yii::getLogger()->getMemoryUsage()/(1024*1024),2)." MB";
// check if view file exists
if(!is_file($sourceFile) || ($file=realpath($sourceFile))===false)
throw new CException(Yii::t('yiiext','View file "{file}" does not exist.', array('{file}'=>$sourceFile)));
//render or return
if($return)
return $this->dwoo->get($sourceFile, $data);
else
$this->dwoo->get($sourceFile, $data, null, true);
}
}
readme_en.txt
\ No newline at end of file
0.9.2
-----
- Fixed renderFile method (Sam Dark)
0.9.1
-----
- Changed translation category to 'yiiext'.
- New naming conventions.
- readme_ru.
- Added Yii varialbe.
- Added TIME and MEMORY variables.
0.9
---
- Initial public release (Sam Dark)
\ No newline at end of file
Dwoo view renderer
==================
This extension allows you to use [Dwoo](http://dwoo.org/) templates in Yii.
###Resources
* [SVN](http://code.google.com/p/yiiext/source/browse/trunk/app/extensions#extensions/yiiext/renderers/dwoo)
* [Dwoo](http://dwoo.org/)
* [Discuss](http://www.yiiframework.com/forum/index.php?/topic/4965-dwoo-view-renderer/)
* [Report a bug](http://code.google.com/p/yiiext/issues/list)
###Requirements
* Yii 1.0 or above
###Installation
* Extract the release file under `protected/extensions`.
* [Download](http://dwoo.org/download) and extract Dwoo (dwoo-x.x.x.tar\dwoo\) under `protected/vendors/Dwoo`.
* Add the following to your config file 'components' section:
~~~
[php]
'viewRenderer'=>array(
'class'=>'ext.yiiext.renderers.dwoo.EDwooViewRenderer',
'fileExtension' => '.tpl',
//'pluginsDir' => 'application.dwooPlugins',
),
~~~
###Usage
* [Dwoo syntax](http://wiki.dwoo.org/index.php/Syntax).
* Current controller properties are accessible via {$this->pageTitle}.
* Yii properties are available as follows: {$Yii->theme->baseUrl}.
* Used memory is stored in {$MEMORY}, used time is in {$TIME}.
\ No newline at end of file
Шаблонизатор Dwoo для Yii
=========================
Данное расширение позволяет использовать [Dwoo](http://dwoo.org/) в шаблонах Yii.
###Полезные ссылки
* [SVN](http://code.google.com/p/yiiext/source/browse/trunk/app/extensions#extensions/yiiext/renderers/dwoo)
* [Dwoo](http://dwoo.org/)
* [Обсуждение](http://yiiframework.ru/forum/viewtopic.php?f=9&t=245)
* [Соощить об ошибке](http://code.google.com/p/yiiext/issues/list)
###Требования
* Yii 1.0 и выше
###Установка
* Распаковать в `protected/extensions`.
* [Скачать](http://dwoo.org/download) и распаковать `dwoo-x.x.x.tar\dwoo\` в `protected/vendors/Dwoo`.
* Добавить в конфигурацю в секцию 'components':
~~~
[php]
'viewRenderer'=>array(
'class'=>'ext.yiiext.renderers.dwoo.EDwooViewRenderer',
'fileExtension' => '.tpl',
//'pluginsDir' => 'application.dwooPlugins',
),
~~~
###Использование
* [Синтаксис Dwoo](http://wiki.dwoo.org/index.php/Syntax).
* Свойства текущего контроллера доступны как {$this->pageTitle}.
* Свойства Yii доступны как {$Yii->theme->baseUrl}.
* Использованную память можно вывести как {$MEMORY}, затраченное время как {$TIME}.
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment