Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
486ab3ff
Commit
486ab3ff
authored
Apr 08, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
script WIP
parent
ad4cf9e8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
117 additions
and
0 deletions
+117
-0
View.php
framework/base/View.php
+10
-0
ViewContent.php
framework/base/ViewContent.php
+107
-0
No files found.
framework/base/View.php
View file @
486ab3ff
...
...
@@ -35,6 +35,10 @@ class View extends Component
*/
public
$context
;
/**
* @var ViewContent
*/
public
$content
;
/**
* @var mixed custom parameters that are shared among view templates.
*/
public
$params
;
...
...
@@ -83,6 +87,11 @@ class View extends Component
if
(
is_array
(
$this
->
theme
))
{
$this
->
theme
=
Yii
::
createObject
(
$this
->
theme
);
}
if
(
is_array
(
$this
->
content
))
{
$this
->
content
=
Yii
::
createObject
(
$this
->
content
);
}
else
{
$this
->
content
=
new
ViewContent
;
}
}
/**
...
...
@@ -156,6 +165,7 @@ class View extends Component
}
else
{
$output
=
$this
->
renderPhpFile
(
$viewFile
,
$params
);
}
$output
=
$this
->
content
->
populate
(
$output
);
$this
->
afterRender
(
$viewFile
,
$output
);
}
...
...
framework/base/ViewContent.php
0 → 100644
View file @
486ab3ff
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\base
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
ViewContent
extends
Component
{
const
POS_HEAD
=
1
;
const
POS_BEGIN
=
2
;
const
POS_END
=
3
;
public
$packages
;
public
$title
;
public
$metaTags
;
public
$linkTags
;
public
$css
;
public
$js
;
public
$cssFiles
;
public
$jsFiles
;
public
function
populate
(
$content
)
{
return
$content
;
}
public
function
reset
()
{
$this
->
title
=
null
;
$this
->
metaTags
=
null
;
$this
->
linkTags
=
null
;
$this
->
css
=
null
;
$this
->
js
=
null
;
$this
->
cssFiles
=
null
;
$this
->
jsFiles
=
null
;
}
public
function
getMetaTag
(
$key
)
{
return
isset
(
$this
->
metaTags
[
$key
])
?
$this
->
metaTags
[
$key
]
:
null
;
}
public
function
setMetaTag
(
$key
,
$tag
)
{
$this
->
metaTags
[
$key
]
=
$tag
;
}
public
function
getLinkTag
(
$key
)
{
return
isset
(
$this
->
linkTags
[
$key
])
?
$this
->
linkTags
[
$key
]
:
null
;
}
public
function
setLinkTag
(
$key
,
$tag
)
{
$this
->
linkTags
[
$key
]
=
$tag
;
}
public
function
getCss
(
$key
)
{
return
isset
(
$this
->
css
[
$key
])
?
$this
->
css
[
$key
]
:
null
;
}
public
function
setCss
(
$key
,
$css
)
{
$this
->
css
[
$key
]
=
$css
;
}
public
function
getCssFile
(
$key
)
{
return
isset
(
$this
->
cssFiles
[
$key
])
?
$this
->
cssFiles
[
$key
]
:
null
;
}
public
function
setCssFile
(
$key
,
$file
)
{
$this
->
cssFiles
[
$key
]
=
$file
;
}
public
function
getJs
(
$key
,
$position
=
self
::
POS_END
)
{
return
isset
(
$this
->
js
[
$position
][
$key
])
?
$this
->
js
[
$position
][
$key
]
:
null
;
}
public
function
setJs
(
$key
,
$js
,
$position
=
self
::
POS_END
)
{
$this
->
js
[
$position
][
$key
]
=
$js
;
}
public
function
getJsFile
(
$key
,
$position
=
self
::
POS_END
)
{
return
isset
(
$this
->
jsFiles
[
$position
][
$key
])
?
$this
->
jsFiles
[
$position
][
$key
]
:
null
;
}
public
function
setJsFile
(
$key
,
$file
,
$position
=
self
::
POS_END
)
{
$this
->
jsFiles
[
$position
][
$key
]
=
$file
;
}
}
\ 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