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
639cd641
Commit
639cd641
authored
May 23, 2013
by
Alexander Kochetov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
yii\bootstrap\Carousel fixes
parent
b6283cc9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
24 deletions
+22
-24
Carousel.php
framework/yii/bootstrap/Carousel.php
+22
-24
No files found.
framework/yii/bootstrap/Carousel.php
View file @
639cd641
...
@@ -8,7 +8,6 @@
...
@@ -8,7 +8,6 @@
namespace
yii\bootstrap
;
namespace
yii\bootstrap
;
use
Yii
;
use
Yii
;
use
yii\base\InvalidConfigException
;
use
yii\base\Model
;
use
yii\base\Model
;
use
yii\helpers\base\ArrayHelper
;
use
yii\helpers\base\ArrayHelper
;
use
yii\helpers\Html
;
use
yii\helpers\Html
;
...
@@ -16,7 +15,7 @@ use yii\helpers\Html;
...
@@ -16,7 +15,7 @@ use yii\helpers\Html;
/**
/**
* Carousel renders a carousel bootstrap javascript component.
* Carousel renders a carousel bootstrap javascript component.
*
*
* For example
,
* For example
:
*
*
* ```php
* ```php
* echo Carousel::widget(array(
* echo Carousel::widget(array(
...
@@ -27,8 +26,8 @@ use yii\helpers\Html;
...
@@ -27,8 +26,8 @@ use yii\helpers\Html;
* ),
* ),
* array(
* array(
* 'content' => '<img src="http://twitter.github.io/bootstrap/assets/img/bootstrap-mdo-sfmoma-03.jpg"/>',
* 'content' => '<img src="http://twitter.github.io/bootstrap/assets/img/bootstrap-mdo-sfmoma-03.jpg"/>',
* '
options' => array(...)
* '
caption' => '<h4>This is title</h5><p>This is the caption text</p>',
* '
caption' => '<h4>This is title</h5><p>This is the caption text</p>'
* '
options' => array(...),
* ),
* ),
* )
* )
* ));
* ));
...
@@ -42,9 +41,9 @@ class Carousel extends Widget
...
@@ -42,9 +41,9 @@ class Carousel extends Widget
{
{
/**
/**
* @var array indicates what labels should be displayed on next and previous carousel controls. If [[controls]] is
* @var array indicates what labels should be displayed on next and previous carousel controls. If [[controls]] is
* set to `false`
or they do not hold `left` and `right` keys,
the controls will not be displayed.
* set to `false` the controls will not be displayed.
*/
*/
public
$controls
=
array
(
'
left'
=>
'‹'
,
'right'
=>
'›'
);
public
$controls
=
array
(
'
‹'
,
'›'
);
/**
/**
* @var array list of images to appear in the carousel. If this property is empty,
* @var array list of images to appear in the carousel. If this property is empty,
* the widget will not render anything. Each array element represents a single image in the carousel
* the widget will not render anything. Each array element represents a single image in the carousel
...
@@ -52,9 +51,9 @@ class Carousel extends Widget
...
@@ -52,9 +51,9 @@ class Carousel extends Widget
*
*
* ```php
* ```php
* array(
* array(
* 'content' => 'src of the image', // required
* 'content' => 'html, for example image', // required
* 'caption'=> ['html attributes of the image'], // optional
* 'options' => ['html attributes of the item'], // optional
* 'options' => ['html attributes of the item'], // optional
* 'caption'=> ['html attributes of the image'] // optional
* )
* )
* ```
* ```
*/
*/
...
@@ -95,7 +94,7 @@ class Carousel extends Widget
...
@@ -95,7 +94,7 @@ class Carousel extends Widget
{
{
ob_start
();
ob_start
();
echo
Html
::
beginTag
(
'ol'
,
array
(
'class'
=>
'carousel-indicators'
))
.
"
\n
"
;
echo
Html
::
beginTag
(
'ol'
,
array
(
'class'
=>
'carousel-indicators'
))
.
"
\n
"
;
for
(
$i
=
0
,
$
ln
=
count
(
$this
->
items
);
$i
<
$ln
;
$i
++
)
{
for
(
$i
=
0
,
$
count
=
count
(
$this
->
items
);
$i
<
$count
;
$i
++
)
{
$options
=
array
(
'data-target'
=>
'#'
.
$this
->
options
[
'id'
],
'data-slide-to'
=>
$i
);
$options
=
array
(
'data-target'
=>
'#'
.
$this
->
options
[
'id'
],
'data-slide-to'
=>
$i
);
if
(
$i
===
0
)
{
if
(
$i
===
0
)
{
$this
->
addCssClass
(
$options
,
'active'
);
$this
->
addCssClass
(
$options
,
'active'
);
...
@@ -113,7 +112,7 @@ class Carousel extends Widget
...
@@ -113,7 +112,7 @@ class Carousel extends Widget
{
{
ob_start
();
ob_start
();
echo
Html
::
beginTag
(
'div'
,
array
(
'class'
=>
'carousel-inner'
))
.
"
\n
"
;
echo
Html
::
beginTag
(
'div'
,
array
(
'class'
=>
'carousel-inner'
))
.
"
\n
"
;
for
(
$i
=
0
,
$
ln
=
count
(
$this
->
items
);
$i
<
$ln
;
$i
++
)
{
for
(
$i
=
0
,
$
count
=
count
(
$this
->
items
);
$i
<
$count
;
$i
++
)
{
$this
->
renderItem
(
$this
->
items
[
$i
],
$i
);
$this
->
renderItem
(
$this
->
items
[
$i
],
$i
);
}
}
echo
Html
::
endTag
(
'div'
)
.
"
\n
"
;
echo
Html
::
endTag
(
'div'
)
.
"
\n
"
;
...
@@ -128,25 +127,25 @@ class Carousel extends Widget
...
@@ -128,25 +127,25 @@ class Carousel extends Widget
public
function
renderItem
(
$item
,
$index
)
public
function
renderItem
(
$item
,
$index
)
{
{
if
(
is_string
(
$item
))
{
if
(
is_string
(
$item
))
{
$itemOptions
=
array
();
$itemContent
=
$item
;
$itemContent
=
$item
;
$itemCaption
=
''
;
$itemCaption
=
null
;
$itemOptions
=
array
();
}
else
{
}
else
{
$itemOptions
=
ArrayHelper
::
getValue
(
$item
,
'options'
,
array
());
$itemContent
=
$item
[
'content'
];
// if not string, must be array, force required key
$itemContent
=
$item
[
'content'
];
// if not string, must be array, force required key
$itemCaption
=
ArrayHelper
::
getValue
(
$item
,
'caption'
);
$itemCaption
=
ArrayHelper
::
getValue
(
$item
,
'caption'
);
if
(
$itemCaption
)
{
$itemOptions
=
ArrayHelper
::
getValue
(
$item
,
'options'
,
array
());
$itemCaption
=
Html
::
tag
(
'div'
,
$itemCaption
,
array
(
'class'
=>
'carousel-caption'
));
}
}
}
$this
->
addCssClass
(
$itemOptions
,
'item'
);
$this
->
addCssClass
(
$itemOptions
,
'item'
);
if
(
$index
===
0
)
{
if
(
$index
===
0
)
{
$this
->
addCssClass
(
$itemOptions
,
'active'
);
$this
->
addCssClass
(
$itemOptions
,
'active'
);
}
}
echo
Html
::
beginTag
(
'div'
,
$itemOptions
)
.
"
\n
"
;
echo
Html
::
beginTag
(
'div'
,
$itemOptions
)
.
"
\n
"
;
echo
$itemContent
.
"
\n
"
;
echo
$itemContent
.
"
\n
"
;
echo
$itemCaption
.
"
\n
"
;
if
(
$itemCaption
!==
null
)
{
echo
Html
::
tag
(
'div'
,
$itemCaption
,
array
(
'class'
=>
'carousel-caption'
))
.
"
\n
"
;
}
echo
Html
::
endTag
(
'div'
)
.
"
\n
"
;
echo
Html
::
endTag
(
'div'
)
.
"
\n
"
;
}
}
...
@@ -155,17 +154,16 @@ class Carousel extends Widget
...
@@ -155,17 +154,16 @@ class Carousel extends Widget
*/
*/
public
function
renderPreviousAndNext
()
public
function
renderPreviousAndNext
()
{
{
if
(
$this
->
controls
===
false
||
!
(
isset
(
$this
->
controls
[
'left'
])
&&
isset
(
$this
->
controls
[
'left'
])))
{
if
(
$this
->
controls
===
false
||
!
(
isset
(
$this
->
controls
[
0
],
$this
->
controls
[
1
])))
{
return
;
return
;
}
}
echo
Html
::
a
(
$this
->
controls
[
'left'
],
'#'
.
$this
->
options
[
'id'
],
array
(
echo
Html
::
a
(
$this
->
controls
[
0
],
'#'
.
$this
->
options
[
'id'
],
array
(
'class'
=>
'left carousel-control'
,
'class'
=>
'left carousel-control'
,
'data-slide'
=>
'prev'
'data-slide'
=>
'prev'
,
))
.
))
.
"
\n
"
"
\n
"
.
.
Html
::
a
(
$this
->
controls
[
1
],
'#'
.
$this
->
options
[
'id'
],
array
(
Html
::
a
(
$this
->
controls
[
'right'
],
'#'
.
$this
->
options
[
'id'
],
array
(
'class'
=>
'right carousel-control'
,
'class'
=>
'right carousel-control'
,
'data-slide'
=>
'next'
'data-slide'
=>
'next'
,
));
));
}
}
}
}
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