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
4bf0518d
Commit
4bf0518d
authored
Feb 07, 2009
by
darh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added ability to set template class with ZF view params (refs #19)
git-svn-id:
svn://dwoo.org/dwoo/trunk@247
0598d79b-80c4-4d41-97ba-ac86fbbd088b
parent
a2783db6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
14 deletions
+68
-14
View.php
lib/Dwoo/Adapters/ZendFramework/View.php
+68
-14
No files found.
lib/Dwoo/Adapters/ZendFramework/View.php
View file @
4bf0518d
...
@@ -35,6 +35,16 @@ class Dwoo_Adapters_ZendFramework_View extends Zend_View_Abstract
...
@@ -35,6 +35,16 @@ class Dwoo_Adapters_ZendFramework_View extends Zend_View_Abstract
protected
$_compiler
=
null
;
protected
$_compiler
=
null
;
/**
/**
* @var string
*/
protected
$_templateFileClass
=
'Dwoo_Template_File'
;
/**
* @var array
*/
protected
$_templateFileSettings
=
array
();
/**
* @var Dwoo_IPluginProxy
* @var Dwoo_IPluginProxy
*/
*/
protected
$_pluginProxy
=
null
;
protected
$_pluginProxy
=
null
;
...
@@ -48,6 +58,7 @@ class Dwoo_Adapters_ZendFramework_View extends Zend_View_Abstract
...
@@ -48,6 +58,7 @@ class Dwoo_Adapters_ZendFramework_View extends Zend_View_Abstract
*/
*/
public
function
__construct
(
$opt
=
array
())
public
function
__construct
(
$opt
=
array
())
{
{
if
(
is_array
(
$opt
))
{
if
(
is_array
(
$opt
))
{
$this
->
setOptions
(
$opt
);
$this
->
setOptions
(
$opt
);
}
elseif
(
$opt
instanceof
Zend_Config
)
{
}
elseif
(
$opt
instanceof
Zend_Config
)
{
...
@@ -62,6 +73,7 @@ class Dwoo_Adapters_ZendFramework_View extends Zend_View_Abstract
...
@@ -62,6 +73,7 @@ class Dwoo_Adapters_ZendFramework_View extends Zend_View_Abstract
* - engine = engine class name|engine object|array of options for engine
* - engine = engine class name|engine object|array of options for engine
* - dataProvider = data provider class name|data provider object|array of options for data provider
* - dataProvider = data provider class name|data provider object|array of options for data provider
* - compiler = compiler class name|compiler object|array of options for compiler
* - compiler = compiler class name|compiler object|array of options for compiler
* - templateFile =
*
*
* Array of options:
* Array of options:
* - type class name or object for engine, dataProvider or compiler
* - type class name or object for engine, dataProvider or compiler
...
@@ -84,14 +96,16 @@ class Dwoo_Adapters_ZendFramework_View extends Zend_View_Abstract
...
@@ -84,14 +96,16 @@ class Dwoo_Adapters_ZendFramework_View extends Zend_View_Abstract
// end BC
// end BC
// Making sure that everything is loaded.
// Making sure that everything is loaded.
$
opt
=
array_merge
(
array
(
$
defaults
=
array
(
'engine'
=>
'Dwoo'
,
'engine'
=>
'Dwoo'
,
'dataProvider'
=>
'Dwoo_Data'
,
'dataProvider'
=>
'Dwoo_Data'
,
'compiler'
=>
'Dwoo_Compiler'
,
'compiler'
=>
'Dwoo_Compiler'
,
),
$opt
);
);
$opt
=
array_merge
(
$defaults
,
$opt
);
// Setting options to Dwoo objects...
// Setting options to Dwoo objects...
foreach
(
$opt
as
$type
=>
$settings
)
{
foreach
(
$opt
as
$type
=>
$settings
)
{
if
(
!
method_exists
(
$this
,
'set'
.
$type
))
{
if
(
!
method_exists
(
$this
,
'set'
.
$type
))
{
throw
new
Dwoo_Exception
(
"Unknown type
$type
"
);
throw
new
Dwoo_Exception
(
"Unknown type
$type
"
);
}
}
...
@@ -99,17 +113,24 @@ class Dwoo_Adapters_ZendFramework_View extends Zend_View_Abstract
...
@@ -99,17 +113,24 @@ class Dwoo_Adapters_ZendFramework_View extends Zend_View_Abstract
if
(
is_string
(
$settings
)
||
is_object
(
$settings
))
{
if
(
is_string
(
$settings
)
||
is_object
(
$settings
))
{
call_user_func
(
array
(
$this
,
'set'
.
$type
),
$settings
);
call_user_func
(
array
(
$this
,
'set'
.
$type
),
$settings
);
}
elseif
(
is_array
(
$settings
))
{
}
elseif
(
is_array
(
$settings
))
{
// Set requested class
if
(
array_key_exists
(
'type'
,
$settings
))
{
if
(
array_key_exists
(
'type'
,
$settings
))
{
call_user_func
(
array
(
$this
,
'set'
.
$type
),
$settings
[
'type'
]);
call_user_func
(
array
(
$this
,
'set'
.
$type
),
$settings
[
'type'
]);
}
}
$rel
=
call_user_func
(
array
(
$this
,
'get'
.
$type
));
if
(
array_key_exists
(
$type
,
$defaults
))
{
// Call get so that the class is initialized
foreach
(
$settings
as
$method
=>
$value
)
{
$rel
=
call_user_func
(
array
(
$this
,
'get'
.
$type
));
if
(
method_exists
(
$rel
,
'set'
.
$method
))
{
call_user_func
(
array
(
$rel
,
'set'
.
$method
),
$value
);
// Call set*() methods so that all the settings are set.
foreach
(
$settings
as
$method
=>
$value
)
{
if
(
method_exists
(
$rel
,
'set'
.
$method
))
{
call_user_func
(
array
(
$rel
,
'set'
.
$method
),
$value
);
}
}
}
}
elseif
(
'templateFile'
==
$type
)
{
// Remember the settings for the templateFile
$this
->
_templateFileSettings
=
$settings
;
}
}
}
}
}
}
...
@@ -316,6 +337,41 @@ class Dwoo_Adapters_ZendFramework_View extends Zend_View_Abstract
...
@@ -316,6 +337,41 @@ class Dwoo_Adapters_ZendFramework_View extends Zend_View_Abstract
return
$this
->
_compiler
;
return
$this
->
_compiler
;
}
}
/**
* Initializes Dwoo_ITemplate type of class and sets properties from _templateFileSettings
*
* @param string Template location
* @return Dwoo_ITemplate
*/
public
function
getTemplateFile
(
$template
)
{
$templateFileClass
=
$this
->
_templateFileClass
;
$dwooTemplateFile
=
new
$templateFileClass
(
$template
);
if
(
!
(
$dwooTemplateFile
instanceof
Dwoo_ITemplate
))
{
throw
new
Dwoo_Exception
(
"Custom templateFile class must be a subclass of Dwoo_ITemplate"
);
}
foreach
(
$this
->
_templateFileSettings
as
$method
=>
$value
)
{
if
(
method_exists
(
$dwooTemplateFile
,
'set'
.
$method
))
{
call_user_func
(
array
(
$dwooTemplateFile
,
'set'
.
$method
),
$value
);
}
}
return
$dwooTemplateFile
;
}
/**
* Dwoo_ITemplate type of class
*
* @param string Name of the class
* @return void
*/
public
function
setTemplateFile
(
$tempateFileClass
)
{
dbg
(
$tempateFileClass
);
$this
->
_templateFileClass
=
$tempateFileClass
;
}
/**
/**
* Passes data to Dwoo_Data object
* Passes data to Dwoo_Data object
...
@@ -369,10 +425,8 @@ class Dwoo_Adapters_ZendFramework_View extends Zend_View_Abstract
...
@@ -369,10 +425,8 @@ class Dwoo_Adapters_ZendFramework_View extends Zend_View_Abstract
*/
*/
public
function
_run
()
public
function
_run
()
{
{
$template
=
new
Dwoo_Template_File
(
func_get_arg
(
0
));
echo
$this
->
_engine
->
get
(
echo
$this
->
_engine
->
get
(
$t
emplate
,
$t
his
->
getTemplateFile
(
func_get_arg
(
0
))
,
$this
->
getDataProvider
(),
$this
->
getDataProvider
(),
$this
->
getCompiler
()
$this
->
getCompiler
()
);
);
...
...
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