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
6316463a
Commit
6316463a
authored
May 24, 2013
by
Antonio Ramirez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add fixes
parent
edf983f4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
17 deletions
+14
-17
Tabs.php
framework/yii/bootstrap/Tabs.php
+14
-17
No files found.
framework/yii/bootstrap/Tabs.php
View file @
6316463a
...
@@ -70,10 +70,6 @@ class Tabs extends Widget
...
@@ -70,10 +70,6 @@ class Tabs extends Widget
* ```
* ```
*/
*/
public
$items
=
array
();
public
$items
=
array
();
/**
* @var int keeps track of the tabs count so to provide a correct id in case it has not been specified.
*/
protected
$counter
=
0
;
/**
/**
...
@@ -91,7 +87,6 @@ class Tabs extends Widget
...
@@ -91,7 +87,6 @@ class Tabs extends Widget
public
function
run
()
public
function
run
()
{
{
echo
$this
->
renderHeaders
(
$this
->
items
,
$this
->
options
)
.
"
\n
"
;
echo
$this
->
renderHeaders
(
$this
->
items
,
$this
->
options
)
.
"
\n
"
;
$this
->
counter
=
0
;
// reset tab counter
echo
Html
::
beginTag
(
'div'
,
array
(
'class'
=>
'tab-content'
))
.
"
\n
"
;
echo
Html
::
beginTag
(
'div'
,
array
(
'class'
=>
'tab-content'
))
.
"
\n
"
;
echo
$this
->
renderContents
(
$this
->
items
)
.
"
\n
"
;
echo
$this
->
renderContents
(
$this
->
items
)
.
"
\n
"
;
echo
Html
::
endTag
(
'div'
)
.
"
\n
"
;
echo
Html
::
endTag
(
'div'
)
.
"
\n
"
;
...
@@ -101,20 +96,20 @@ class Tabs extends Widget
...
@@ -101,20 +96,20 @@ class Tabs extends Widget
/**
/**
* @param array $items the items to render in the header.
* @param array $items the items to render in the header.
* @param array $options the HTML attributes of the menu container.
* @param array $options the HTML attributes of the menu container.
* @param integer $index the starting index of header item. Used to set ids.
* @return string the rendering result.
* @return string the rendering result.
* @throws InvalidConfigException
* @throws InvalidConfigException
*/
*/
protected
function
renderHeaders
(
$items
,
$options
=
array
())
protected
function
renderHeaders
(
$items
,
$options
=
array
()
,
$index
=
0
)
{
{
$headers
=
array
();
$headers
=
array
();
for
(
$i
=
0
,
$count
=
count
(
$items
);
$i
<
$count
;
$i
++
)
{
foreach
(
$items
as
$item
)
{
$item
=
$items
[
$i
];
if
(
!
isset
(
$item
[
'header'
]))
{
if
(
!
isset
(
$item
[
'header'
]))
{
throw
new
InvalidConfigException
(
"The 'header' option is required."
);
throw
new
InvalidConfigException
(
"The 'header' option is required."
);
}
}
$headerOptions
=
ArrayHelper
::
getValue
(
$item
,
'headerOptions'
,
array
());
$headerOptions
=
ArrayHelper
::
getValue
(
$item
,
'headerOptions'
,
array
());
if
(
$
this
->
counter
===
0
)
{
if
(
$
index
===
0
)
{
$this
->
addCssClass
(
$headerOptions
,
'active'
);
$this
->
addCssClass
(
$headerOptions
,
'active'
);
}
}
if
(
isset
(
$item
[
'items'
]))
{
if
(
isset
(
$item
[
'items'
]))
{
...
@@ -126,12 +121,13 @@ class Tabs extends Widget
...
@@ -126,12 +121,13 @@ class Tabs extends Widget
'class'
=>
'dropdown-toggle'
,
'class'
=>
'dropdown-toggle'
,
'data-toggle'
=>
'dropdown'
'data-toggle'
=>
'dropdown'
))
.
))
.
$this
->
renderHeaders
(
$item
[
'items'
],
array
(
'class'
=>
'dropdown-menu'
)),
$this
->
renderHeaders
(
$item
[
'items'
],
array
(
'class'
=>
'dropdown-menu'
)
,
$index
++
),
$headerOptions
$headerOptions
);
);
}
else
{
}
else
{
$contentOptions
=
ArrayHelper
::
getValue
(
$item
,
'options'
,
array
());
$contentOptions
=
ArrayHelper
::
getValue
(
$item
,
'options'
,
array
());
$id
=
ArrayHelper
::
getValue
(
$contentOptions
,
'id'
,
$this
->
options
[
'id'
]
.
'-tab'
.
$
this
->
counter
++
);
$id
=
ArrayHelper
::
getValue
(
$contentOptions
,
'id'
,
$this
->
options
[
'id'
]
.
'-tab'
.
$
index
++
);
$headers
[]
=
Html
::
tag
(
'li'
,
Html
::
a
(
$item
[
'header'
],
"#
$id
"
,
array
(
'data-toggle'
=>
'tab'
)),
$headerOptions
);
$headers
[]
=
Html
::
tag
(
'li'
,
Html
::
a
(
$item
[
'header'
],
"#
$id
"
,
array
(
'data-toggle'
=>
'tab'
)),
$headerOptions
);
}
}
}
}
...
@@ -142,10 +138,11 @@ class Tabs extends Widget
...
@@ -142,10 +138,11 @@ class Tabs extends Widget
/**
/**
* Renders tabs contents as specified on [[items]].
* Renders tabs contents as specified on [[items]].
* @param array $items the items to get the contents from.
* @param array $items the items to get the contents from.
* @param integer $index the starting index (for recursion)
* @return string the rendering result.
* @return string the rendering result.
* @throws InvalidConfigException
* @throws InvalidConfigException
*/
*/
protected
function
renderContents
(
$items
)
protected
function
renderContents
(
$items
,
$index
=
0
)
{
{
$contents
=
array
();
$contents
=
array
();
foreach
(
$items
as
$item
)
{
foreach
(
$items
as
$item
)
{
...
@@ -155,13 +152,13 @@ class Tabs extends Widget
...
@@ -155,13 +152,13 @@ class Tabs extends Widget
$options
=
ArrayHelper
::
getValue
(
$item
,
'options'
,
array
());
$options
=
ArrayHelper
::
getValue
(
$item
,
'options'
,
array
());
$this
->
addCssClass
(
$options
,
'tab-pane'
);
$this
->
addCssClass
(
$options
,
'tab-pane'
);
if
(
$this
->
counter
===
0
)
{
$this
->
addCssClass
(
$options
,
'active'
);
}
if
(
isset
(
$item
[
'items'
]))
{
if
(
isset
(
$item
[
'items'
]))
{
$contents
[]
=
$this
->
renderContents
(
$item
[
'items'
]);
$contents
[]
=
$this
->
renderContents
(
$item
[
'items'
]
,
$index
++
);
}
else
{
}
else
{
$options
[
'id'
]
=
ArrayHelper
::
getValue
(
$options
,
'id'
,
$this
->
options
[
'id'
]
.
'-tab'
.
$this
->
counter
++
);
if
(
$index
===
0
)
{
$this
->
addCssClass
(
$options
,
'active'
);
}
$options
[
'id'
]
=
ArrayHelper
::
getValue
(
$options
,
'id'
,
$this
->
options
[
'id'
]
.
'-tab'
.
$index
++
);
$contents
[]
=
Html
::
tag
(
'div'
,
$item
[
'content'
],
$options
);
$contents
[]
=
Html
::
tag
(
'div'
,
$item
[
'content'
],
$options
);
}
}
}
}
...
...
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