Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
Yii Dwoo renderer
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Common
Yii Dwoo renderer
Commits
57bef4f1
Commit
57bef4f1
authored
Nov 23, 2013
by
Hikonobu Kurihara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dwoo2に対応したクラスを追加
parent
72163bc0
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
112 additions
and
0 deletions
+112
-0
EDwoo2ViewRenderer.php
EDwoo2ViewRenderer.php
+103
-0
EDwooViewRenderer.php
EDwooViewRenderer.php
+9
-0
No files found.
EDwoo2ViewRenderer.php
0 → 100644
View file @
57bef4f1
<?php
/**
* Dwoo2 view renderer
*
* @author Alexander Makarov <sam@rmcreative.ru>
* @link http://code.google.com/p/yiiext/
* @link http://dwoo.org/
*
* @version 0.9.2
*
* @author KURIHARA Hikonobu <hiko@hymena.jp>
*/
class
EDwoo2ViewRenderer
extends
CApplicationComponent
implements
IViewRenderer
{
public
$fileExtension
=
'.tpl'
;
public
$filePermission
=
0755
;
public
$pluginsDir
=
null
;
public
$autoEscape
=
true
;
public
$delimiters
=
array
(
'{{'
,
'}}'
);
public
$dwooPath
=
'application.vendors.dwoo2.lib.Dwoo'
;
/**
* @var Dwoo
*/
private
$dwoo
;
/**
* Component initialization
*/
function
init
(){
// need this since Yii autoload handler raises an error if class is not found
spl_autoload_unregister
(
array
(
'YiiBase'
,
'autoload'
));
// registering Dwoo autoload handler
$dwooDir
=
Yii
::
getPathOfAlias
(
$this
->
dwooPath
);
Yii
::
import
(
$dwooDir
.
DIRECTORY_SEPARATOR
.
'Autoloader.php'
);
Dwoo\Autoloader
::
register
();
// 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\Core
(
$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
)));
$compiler
=
new
Dwoo\Compiler
();
$compiler
->
setAutoEscape
((
bool
)
$this
->
autoEscape
);
$compiler
->
setDelimiters
(
$this
->
delimiters
[
0
],
$this
->
delimiters
[
1
]);
//render or return
if
(
$return
)
return
$this
->
dwoo
->
get
(
$sourceFile
,
$data
);
else
$this
->
dwoo
->
get
(
$sourceFile
,
$data
,
null
,
true
);
}
}
EDwooViewRenderer.php
View file @
57bef4f1
...
@@ -7,12 +7,17 @@
...
@@ -7,12 +7,17 @@
* @link http://dwoo.org/
* @link http://dwoo.org/
*
*
* @version 0.9.2
* @version 0.9.2
*
* @author KURIHARA Hikonobu <hiko@hymena.jp>
*/
*/
class
EDwooViewRenderer
extends
CApplicationComponent
implements
IViewRenderer
{
class
EDwooViewRenderer
extends
CApplicationComponent
implements
IViewRenderer
{
public
$fileExtension
=
'.tpl'
;
public
$fileExtension
=
'.tpl'
;
public
$filePermission
=
0755
;
public
$filePermission
=
0755
;
public
$pluginsDir
=
null
;
public
$pluginsDir
=
null
;
public
$autoEscape
=
true
;
public
$delimiters
=
array
(
'{{'
,
'}}'
);
/**
/**
* @var Dwoo
* @var Dwoo
*/
*/
...
@@ -82,6 +87,10 @@ class EDwooViewRenderer extends CApplicationComponent implements IViewRenderer {
...
@@ -82,6 +87,10 @@ class EDwooViewRenderer extends CApplicationComponent implements IViewRenderer {
if
(
!
is_file
(
$sourceFile
)
||
(
$file
=
realpath
(
$sourceFile
))
===
false
)
if
(
!
is_file
(
$sourceFile
)
||
(
$file
=
realpath
(
$sourceFile
))
===
false
)
throw
new
CException
(
Yii
::
t
(
'yiiext'
,
'View file "{file}" does not exist.'
,
array
(
'{file}'
=>
$sourceFile
)));
throw
new
CException
(
Yii
::
t
(
'yiiext'
,
'View file "{file}" does not exist.'
,
array
(
'{file}'
=>
$sourceFile
)));
$compiler
=
new
Dwoo_Compiler
();
$compiler
->
setAutoEscape
((
bool
)
$this
->
autoEscape
);
$compiler
->
setDelimiters
(
$this
->
delimiters
[
0
],
$this
->
delimiters
[
1
]);
//render or return
//render or return
if
(
$return
)
if
(
$return
)
return
$this
->
dwoo
->
get
(
$sourceFile
,
$data
);
return
$this
->
dwoo
->
get
(
$sourceFile
,
$data
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment