Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
Dwoo
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Common
Dwoo
Commits
eeef80e6
Commit
eeef80e6
authored
Sep 08, 2008
by
Seldaek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* fixes Agavi adapter's plugin_dir parameter handling
git-svn-id:
svn://dwoo.org/dwoo/trunk@173
0598d79b-80c4-4d41-97ba-ac86fbbd088b
parent
bd14bd1c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
131 additions
and
116 deletions
+131
-116
DwooRenderer.php
lib/Dwoo/Adapters/Agavi/DwooRenderer.php
+131
-116
No files found.
lib/Dwoo/Adapters/Agavi/DwooRenderer.php
View file @
eeef80e6
...
...
@@ -38,7 +38,6 @@
* {@link http://www.gnu.org/copyleft/lesser.html}
*
* @author Jordi Boggiano <j.boggiano@seld.be>
* @author David Zülke <dz@bitxtender.com>
* @copyright Copyright (c) 2008, Jordi Boggiano
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
* @link http://dwoo.org/
...
...
@@ -48,119 +47,134 @@
*/
class
DwooRenderer
extends
AgaviRenderer
implements
AgaviIReusableRenderer
{
/**
* @constant string The directory inside the cache dir where templates will
* be stored in compiled form.
*/
const
COMPILE_DIR
=
'templates'
;
/**
* @constant string The subdirectory inside the compile dir where templates
* will be stored in compiled form.
*/
const
COMPILE_SUBDIR
=
'dwoo'
;
/**
* @constant string The directory inside the cache dir where cached content
* will be stored.
*/
const
CACHE_DIR
=
'dwoo'
;
/**
* @var Dwoo Dwoo template engine.
*/
protected
$dwoo
=
null
;
/**
* @var string A string with the default template file extension,
* including the dot.
*/
protected
$defaultExtension
=
'.html'
;
/**
* Pre-serialization callback.
*
* Excludes the Dwoo instance to prevent excessive serialization load.
*/
public
function
__sleep
()
{
$keys
=
parent
::
__sleep
();
unset
(
$keys
[
array_search
(
'dwoo'
,
$keys
)]);
return
$keys
;
}
/**
* Grab a cleaned up dwoo instance.
*
* @return Dwoo A Dwoo instance.
*/
protected
function
getEngine
()
{
if
(
$this
->
dwoo
)
{
return
$this
->
dwoo
;
}
if
(
!
class_exists
(
'Dwoo'
))
{
if
(
file_exists
(
dirname
(
__FILE__
)
.
'/../../../dwooAutoload.php'
))
{
// file was dropped with the entire dwoo package
require
dirname
(
__FILE__
)
.
'/../../../dwooAutoload.php'
;
}
else
{
// assume the dwoo package is in the include path
require
'dwooAutoload.php'
;
}
}
$parentMode
=
fileperms
(
AgaviConfig
::
get
(
'core.cache_dir'
));
$compileDir
=
AgaviConfig
::
get
(
'core.cache_dir'
)
.
DIRECTORY_SEPARATOR
.
self
::
COMPILE_DIR
.
DIRECTORY_SEPARATOR
.
self
::
COMPILE_SUBDIR
;
AgaviToolkit
::
mkdir
(
$compileDir
,
$parentMode
,
true
);
$cacheDir
=
AgaviConfig
::
get
(
'core.cache_dir'
)
.
DIRECTORY_SEPARATOR
.
self
::
CACHE_DIR
;
AgaviToolkit
::
mkdir
(
$cacheDir
,
$parentMode
,
true
);
$this
->
dwoo
=
new
Dwoo
(
$compileDir
,
$cacheDir
);
if
(
!
empty
(
$this
->
plugin_dir
))
{
$this
->
dwoo
->
getLoader
()
->
addDirectory
(
$this
->
plugin_dir
);
}
return
$this
->
dwoo
;
}
/**
* Render the presentation and return the result.
*
* @param AgaviTemplateLayer The template layer to render.
* @param array The template variables.
* @param array The slots.
* @param array Associative array of additional assigns.
*
* @return string A rendered result.
*/
public
function
render
(
AgaviTemplateLayer
$layer
,
array
&
$attributes
=
array
(),
array
&
$slots
=
array
(),
array
&
$moreAssigns
=
array
())
{
$engine
=
$this
->
getEngine
();
$data
=
array
();
if
(
$this
->
extractVars
)
{
$data
=
$attributes
;
}
else
{
$data
[
$this
->
varName
]
=
&
$attributes
;
}
$data
[
$this
->
slotsVarName
]
=&
$slots
;
foreach
(
$this
->
assigns
as
$key
=>
$getter
)
{
$data
[
$key
]
=
$this
->
context
->
$getter
();
}
foreach
(
$moreAssigns
as
$key
=>
&
$value
)
{
if
(
isset
(
$this
->
moreAssignNames
[
$key
]))
{
$key
=
$this
->
moreAssignNames
[
$key
];
}
$data
[
$key
]
=&
$value
;
}
return
$engine
->
get
(
$layer
->
getResourceStreamIdentifier
(),
$data
);
}
/**
* @constant string The directory inside the cache dir where templates will
* be stored in compiled form.
*/
const
COMPILE_DIR
=
'templates'
;
/**
* @constant string The subdirectory inside the compile dir where templates
* will be stored in compiled form.
*/
const
COMPILE_SUBDIR
=
'dwoo'
;
/**
* @constant string The directory inside the cache dir where cached content
* will be stored.
*/
const
CACHE_DIR
=
'dwoo'
;
/**
* @var Dwoo Dwoo template engine.
*/
protected
$dwoo
=
null
;
/**
* @var string A string with the default template file extension,
* including the dot.
*/
protected
$defaultExtension
=
'.html'
;
protected
$plugin_dir
=
null
;
/**
* Pre-serialization callback.
*
* Excludes the Dwoo instance to prevent excessive serialization load.
*/
public
function
__sleep
()
{
$keys
=
parent
::
__sleep
();
unset
(
$keys
[
array_search
(
'dwoo'
,
$keys
)]);
return
$keys
;
}
/**
* Initialize this Renderer.
*
* @param AgaviContext The current application context.
* @param array An associative array of initialization parameters.
*/
public
function
initialize
(
AgaviContext
$context
,
array
$parameters
=
array
())
{
parent
::
initialize
(
$context
,
$parameters
);
$this
->
plugin_dir
=
$this
->
getParameter
(
'plugin_dir'
,
$this
->
plugin_dir
);
}
/**
* Grab a cleaned up dwoo instance.
*
* @return Dwoo A Dwoo instance.
*/
protected
function
getEngine
()
{
if
(
$this
->
dwoo
)
{
return
$this
->
dwoo
;
}
if
(
!
class_exists
(
'Dwoo'
))
{
if
(
file_exists
(
dirname
(
__FILE__
)
.
'/../../../dwooAutoload.php'
))
{
// file was dropped with the entire dwoo package
require
dirname
(
__FILE__
)
.
'/../../../dwooAutoload.php'
;
}
else
{
// assume the dwoo package is in the include path
require
'dwooAutoload.php'
;
}
}
$parentMode
=
fileperms
(
AgaviConfig
::
get
(
'core.cache_dir'
));
$compileDir
=
AgaviConfig
::
get
(
'core.cache_dir'
)
.
DIRECTORY_SEPARATOR
.
self
::
COMPILE_DIR
.
DIRECTORY_SEPARATOR
.
self
::
COMPILE_SUBDIR
;
AgaviToolkit
::
mkdir
(
$compileDir
,
$parentMode
,
true
);
$cacheDir
=
AgaviConfig
::
get
(
'core.cache_dir'
)
.
DIRECTORY_SEPARATOR
.
self
::
CACHE_DIR
;
AgaviToolkit
::
mkdir
(
$cacheDir
,
$parentMode
,
true
);
$this
->
dwoo
=
new
Dwoo
(
$compileDir
,
$cacheDir
);
if
(
!
empty
(
$this
->
plugin_dir
))
{
$this
->
dwoo
->
getLoader
()
->
addDirectory
(
$this
->
plugin_dir
);
}
return
$this
->
dwoo
;
}
/**
* Render the presentation and return the result.
*
* @param AgaviTemplateLayer The template layer to render.
* @param array The template variables.
* @param array The slots.
* @param array Associative array of additional assigns.
*
* @return string A rendered result.
*/
public
function
render
(
AgaviTemplateLayer
$layer
,
array
&
$attributes
=
array
(),
array
&
$slots
=
array
(),
array
&
$moreAssigns
=
array
())
{
$engine
=
$this
->
getEngine
();
$data
=
array
();
if
(
$this
->
extractVars
)
{
$data
=
$attributes
;
}
else
{
$data
[
$this
->
varName
]
=
&
$attributes
;
}
$data
[
$this
->
slotsVarName
]
=&
$slots
;
foreach
(
$this
->
assigns
as
$key
=>
$getter
)
{
$data
[
$key
]
=
$this
->
context
->
$getter
();
}
foreach
(
$moreAssigns
as
$key
=>
&
$value
)
{
if
(
isset
(
$this
->
moreAssignNames
[
$key
]))
{
$key
=
$this
->
moreAssignNames
[
$key
];
}
$data
[
$key
]
=&
$value
;
}
return
$engine
->
get
(
$layer
->
getResourceStreamIdentifier
(),
$data
);
}
}
\ No newline at end of file
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