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
5cd7961a
Commit
5cd7961a
authored
Apr 13, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
renamed clip to block.
parent
428d9128
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
103 deletions
+35
-103
View.php
framework/base/View.php
+13
-13
ViewContent.php
framework/base/ViewContent.php
+10
-77
Block.php
framework/widgets/Block.php
+12
-13
No files found.
framework/base/View.php
View file @
5cd7961a
...
@@ -53,11 +53,12 @@ class View extends Component
...
@@ -53,11 +53,12 @@ class View extends Component
*/
*/
public
$theme
;
public
$theme
;
/**
/**
* @var array a list of named output clips. You can call [[beginClip()]] and [[endClip()]]
* @var array a list of named output blocks. The keys are the block names and the values
* are the corresponding block content. You can call [[beginBlock()]] and [[endBlock()]]
* to capture small fragments of a view. They can be later accessed at somewhere else
* to capture small fragments of a view. They can be later accessed at somewhere else
* through this property.
* through this property.
*/
*/
public
$
clip
s
;
public
$
block
s
;
/**
/**
* @var Widget[] the widgets that are currently being rendered (not ended). This property
* @var Widget[] the widgets that are currently being rendered (not ended). This property
* is maintained by [[beginWidget()]] and [[endWidget()]] methods. Do not modify it.
* is maintained by [[beginWidget()]] and [[endWidget()]] methods. Do not modify it.
...
@@ -350,26 +351,25 @@ class View extends Component
...
@@ -350,26 +351,25 @@ class View extends Component
}
}
/**
/**
* Begins recording a clip.
* Begins recording a block.
* This method is a shortcut to beginning [[yii\widgets\Clip]]
* This method is a shortcut to beginning [[yii\widgets\Block]]
* @param string $id the clip ID.
* @param string $id the block ID.
* @param boolean $renderInPlace whether to render the clip content in place.
* @param boolean $renderInPlace whether to render the block content in place.
* Defaults to false, meaning the captured clip will not be displayed.
* Defaults to false, meaning the captured block will not be displayed.
* @return \yii\widgets\Clip the Clip widget instance
* @return \yii\widgets\Block the Block widget instance
* @see \yii\widgets\Clip
*/
*/
public
function
begin
Clip
(
$id
,
$renderInPlace
=
false
)
public
function
begin
Block
(
$id
,
$renderInPlace
=
false
)
{
{
return
$this
->
beginWidget
(
'yii\widgets\
Clip
'
,
array
(
return
$this
->
beginWidget
(
'yii\widgets\
Block
'
,
array
(
'id'
=>
$id
,
'id'
=>
$id
,
'renderInPlace'
=>
$renderInPlace
,
'renderInPlace'
=>
$renderInPlace
,
));
));
}
}
/**
/**
* Ends recording a
clip
.
* Ends recording a
block
.
*/
*/
public
function
end
Clip
()
public
function
end
Block
()
{
{
$this
->
endWidget
();
$this
->
endWidget
();
}
}
...
...
framework/base/ViewContent.php
View file @
5cd7961a
...
@@ -49,9 +49,13 @@ class ViewContent extends Component
...
@@ -49,9 +49,13 @@ class ViewContent extends Component
public
$metaTags
;
public
$metaTags
;
public
$linkTags
;
public
$linkTags
;
public
$css
;
public
$css
;
public
$js
;
public
$cssFiles
;
public
$cssFiles
;
public
$js
;
public
$jsFiles
;
public
$jsFiles
;
public
$jsInHead
;
public
$jsFilesInHead
;
public
$jsInBody
;
public
$jsFilesInBody
;
public
function
populate
(
$content
)
public
function
populate
(
$content
)
{
{
...
@@ -64,86 +68,16 @@ class ViewContent extends Component
...
@@ -64,86 +68,16 @@ class ViewContent extends Component
$this
->
metaTags
=
null
;
$this
->
metaTags
=
null
;
$this
->
linkTags
=
null
;
$this
->
linkTags
=
null
;
$this
->
css
=
null
;
$this
->
css
=
null
;
$this
->
js
=
null
;
$this
->
cssFiles
=
null
;
$this
->
cssFiles
=
null
;
$this
->
js
=
null
;
$this
->
jsFiles
=
null
;
$this
->
jsFiles
=
null
;
$this
->
jsInHead
=
null
;
$this
->
jsFilesInHead
=
null
;
$this
->
jsInBody
=
null
;
$this
->
jsFilesInBody
=
null
;
}
}
public
function
renderScripts
(
$pos
)
public
function
renderScripts
(
$pos
)
{
{
}
}
public
function
registerBundle
(
$name
)
{
if
(
!
isset
(
$this
->
bundles
[
$name
]))
{
$am
=
Yii
::
$app
->
assets
;
$bundle
=
$am
->
getBundle
(
$name
);
if
(
$bundle
!==
null
)
{
$this
->
bundles
[
$name
]
=
$bundle
;
}
else
{
throw
new
InvalidConfigException
(
"Asset bundle does not exist:
$name
"
);
}
}
}
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
framework/widgets/
Clip
.php
→
framework/widgets/
Block
.php
View file @
5cd7961a
...
@@ -7,28 +7,26 @@
...
@@ -7,28 +7,26 @@
namespace
yii\widgets
;
namespace
yii\widgets
;
use
Yii
;
use
yii\base\Widget
;
use
yii\base\Widget
;
use
yii\base\View
;
/**
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
* @since 2.0
*/
*/
class
Clip
extends
Widget
class
Block
extends
Widget
{
{
/**
/**
* @var string the ID of this
clip
.
* @var string the ID of this
block
.
*/
*/
public
$id
;
public
$id
;
/**
/**
* @var boolean whether to render the
clip
content in place. Defaults to false,
* @var boolean whether to render the
block
content in place. Defaults to false,
* meaning the captured
clip
will not be displayed.
* meaning the captured
block content
will not be displayed.
*/
*/
public
$renderInPlace
=
false
;
public
$renderInPlace
=
false
;
/**
/**
* Starts recording a
clip
.
* Starts recording a
block
.
*/
*/
public
function
init
()
public
function
init
()
{
{
...
@@ -37,15 +35,15 @@ class Clip extends Widget
...
@@ -37,15 +35,15 @@ class Clip extends Widget
}
}
/**
/**
* Ends recording a
clip
.
* Ends recording a
block
.
* This method stops output buffering and saves the rendering result as a named
clip
in the controller.
* This method stops output buffering and saves the rendering result as a named
block
in the controller.
*/
*/
public
function
run
()
public
function
run
()
{
{
$
clip
=
ob_get_clean
();
$
block
=
ob_get_clean
();
if
(
$this
->
render
Clip
)
{
if
(
$this
->
render
InPlace
)
{
echo
$
clip
;
echo
$
block
;
}
}
$this
->
view
->
clips
[
$this
->
id
]
=
$clip
;
$this
->
view
->
blocks
[
$this
->
id
]
=
$block
;
}
}
}
}
\ 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