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
5038c35f
Commit
5038c35f
authored
May 27, 2013
by
Alexander Kochetov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring
parent
e84f5649
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
22 deletions
+14
-22
Tabs.php
framework/yii/jui/Tabs.php
+14
-22
No files found.
framework/yii/jui/Tabs.php
View file @
5038c35f
...
@@ -42,7 +42,7 @@ use yii\helpers\Html;
...
@@ -42,7 +42,7 @@ use yii\helpers\Html;
* ),
* ),
* array(
* array(
* 'label' => 'Ajax tab',
* 'label' => 'Ajax tab',
* '
ajax
' => array('ajax/content'),
* '
url
' => array('ajax/content'),
* ),
* ),
* ),
* ),
* 'options' => array(
* 'options' => array(
...
@@ -75,19 +75,13 @@ class Tabs extends Widget
...
@@ -75,19 +75,13 @@ class Tabs extends Widget
/**
/**
* @var array list of tab items. Each item can be an array of the following structure:
* @var array list of tab items. Each item can be an array of the following structure:
*
*
* ~~~
* - label: string, required, specifies the header link label. When [[encodeLabels]] is true, the label
* array(
* will be HTML-encoded.
* 'label' => 'Tab header label',
* - content: string, @todo comment
* 'content' => 'Tab item content',
* - url: mixed, @todo comment
* 'ajax' => 'http://www.yiiframework.com', //or array('ajax/action'),
* - template: string, optional, @todo comment
* // the HTML attributes of the item container tag. This will overwrite "itemOptions".
* - options: array, optional, @todo comment
* 'options' => array(),
* - headerOptions: array, optional, @todo comment
* // the HTML attributes of the header container tag. This will overwrite "headerOptions".
* 'headerOptions' = array(),
* // @todo comment.
* 'template'
* )
* ~~~
*/
*/
public
$items
=
array
();
public
$items
=
array
();
/**
/**
...
@@ -103,13 +97,11 @@ class Tabs extends Widget
...
@@ -103,13 +97,11 @@ class Tabs extends Widget
*/
*/
public
$headerOptions
=
array
();
public
$headerOptions
=
array
();
/**
/**
* @var string
* @var string @todo comment
* @todo comment.
*/
*/
public
$linkTemplate
=
'<a href="{url}">{label}</a>'
;
public
$linkTemplate
=
'<a href="{url}">{label}</a>'
;
/**
/**
* @var boolean
* @var boolean whether the labels for header items should be HTML-encoded.
* @todo comment.
*/
*/
public
$encodeLabels
=
true
;
public
$encodeLabels
=
true
;
...
@@ -140,11 +132,11 @@ class Tabs extends Widget
...
@@ -140,11 +132,11 @@ class Tabs extends Widget
if
(
!
isset
(
$item
[
'label'
]))
{
if
(
!
isset
(
$item
[
'label'
]))
{
throw
new
InvalidConfigException
(
"The 'label' option is required."
);
throw
new
InvalidConfigException
(
"The 'label' option is required."
);
}
}
if
(
isset
(
$item
[
'
ajax
'
]))
{
if
(
isset
(
$item
[
'
url
'
]))
{
$url
=
$item
[
'ajax'
]
;
$url
=
Html
::
url
(
$item
[
'url'
])
;
}
else
{
}
else
{
if
(
!
isset
(
$item
[
'content'
]))
{
if
(
!
isset
(
$item
[
'content'
]))
{
throw
new
InvalidConfigException
(
"The 'content' or '
ajax
' option is required."
);
throw
new
InvalidConfigException
(
"The 'content' or '
url
' option is required."
);
}
}
$options
=
array_merge
(
$this
->
itemOptions
,
ArrayHelper
::
getValue
(
$item
,
'options'
,
array
()));
$options
=
array_merge
(
$this
->
itemOptions
,
ArrayHelper
::
getValue
(
$item
,
'options'
,
array
()));
$tag
=
ArrayHelper
::
remove
(
$options
,
'tag'
,
'div'
);
$tag
=
ArrayHelper
::
remove
(
$options
,
'tag'
,
'div'
);
...
@@ -158,7 +150,7 @@ class Tabs extends Widget
...
@@ -158,7 +150,7 @@ class Tabs extends Widget
$template
=
ArrayHelper
::
getValue
(
$item
,
'template'
,
$this
->
linkTemplate
);
$template
=
ArrayHelper
::
getValue
(
$item
,
'template'
,
$this
->
linkTemplate
);
$headers
[]
=
Html
::
tag
(
'li'
,
strtr
(
$template
,
array
(
$headers
[]
=
Html
::
tag
(
'li'
,
strtr
(
$template
,
array
(
'{label}'
=>
$this
->
encodeLabels
?
Html
::
encode
(
$item
[
'label'
])
:
$item
[
'label'
],
'{label}'
=>
$this
->
encodeLabels
?
Html
::
encode
(
$item
[
'label'
])
:
$item
[
'label'
],
'{url}'
=>
Html
::
url
(
$url
)
,
'{url}'
=>
$url
,
)),
$headerOptions
);
)),
$headerOptions
);
}
}
return
Html
::
tag
(
'ul'
,
implode
(
"
\n
"
,
$headers
))
.
"
\n
"
.
implode
(
"
\n
"
,
$items
);
return
Html
::
tag
(
'ul'
,
implode
(
"
\n
"
,
$headers
))
.
"
\n
"
.
implode
(
"
\n
"
,
$items
);
...
...
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