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
dc8b449c
Commit
dc8b449c
authored
May 23, 2013
by
Tobias Munk
Browse files
Options
Browse Files
Download
Plain Diff
Merge commit '
fbada2e8
' into extensions-composer
parents
e7c98a49
fbada2e8
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
409 additions
and
283 deletions
+409
-283
upgrade-from-v1.md
docs/guide/upgrade-from-v1.md
+5
-3
composer.json
framework/composer.json
+1
-1
YiiBase.php
framework/yii/YiiBase.php
+1
-0
Carousel.php
framework/yii/bootstrap/Carousel.php
+62
-61
Collapse.php
framework/yii/bootstrap/Collapse.php
+134
-0
Request.php
framework/yii/console/Request.php
+26
-5
Inflector.php
framework/yii/helpers/base/Inflector.php
+143
-205
assets.php
framework/yii/jui/assets.php
+3
-3
requirements.php
framework/yii/requirements/requirements.php
+2
-2
UrlManager.php
framework/yii/web/UrlManager.php
+10
-0
Menu.php
framework/yii/widgets/Menu.php
+0
-1
InflectorTest.php
tests/unit/framework/helpers/InflectorTest.php
+0
-2
UrlManagerTest.php
tests/unit/framework/web/UrlManagerTest.php
+22
-0
No files found.
docs/guide/upgrade-from-v1.md
View file @
dc8b449c
...
@@ -216,12 +216,14 @@ Using a widget is more straightforward in 2.0. You mainly use the `begin()`, `en
...
@@ -216,12 +216,14 @@ Using a widget is more straightforward in 2.0. You mainly use the `begin()`, `en
methods of the
`Widget`
class. For example,
methods of the
`Widget`
class. For example,
```
php
```
php
// $this refers to the View object
// Note that you have to "echo" the result to display it
// Note that you have to "echo" the result to display it
echo
\yii\widgets\Menu
::
widget
(
array
(
'items'
=>
$items
));
echo
\yii\widgets\Menu
::
widget
(
array
(
'items'
=>
$items
));
// $this refers to the View object
// Passing an array to initialize the object properties
$form
=
\yii\widgets\ActiveForm
::
begin
(
$this
);
$form
=
\yii\widgets\ActiveForm
::
begin
(
array
(
'options'
=>
array
(
'class'
=>
'form-horizontal'
),
'fieldConfig'
=>
array
(
'inputOptions'
=>
array
(
'class'
=>
'input-xlarge'
)),
));
...
form
inputs
here
...
...
form
inputs
here
...
\yii\widgets\ActiveForm
::
end
();
\yii\widgets\ActiveForm
::
end
();
```
```
...
...
framework/composer.json
View file @
dc8b449c
...
@@ -64,7 +64,7 @@
...
@@ -64,7 +64,7 @@
"source"
:
"https://github.com/yiisoft/yii2"
"source"
:
"https://github.com/yiisoft/yii2"
},
},
"require"
:
{
"require"
:
{
"php"
:
">=5.3.
11
"
,
"php"
:
">=5.3.
7
"
,
"ext-mbstring"
:
"*"
,
"ext-mbstring"
:
"*"
,
"lib-pcre"
:
"*"
"lib-pcre"
:
"*"
},
},
...
...
framework/yii/YiiBase.php
View file @
dc8b449c
...
@@ -616,6 +616,7 @@ class YiiBase
...
@@ -616,6 +616,7 @@ class YiiBase
YiiBase
::
$aliases
=
array
(
YiiBase
::
$aliases
=
array
(
'@yii'
=>
array
(
'@yii'
=>
array
(
'@yii/bootstrap'
=>
__DIR__
.
'/bootstrap'
,
'@yii/bootstrap'
=>
__DIR__
.
'/bootstrap'
,
'@yii/jui'
=>
__DIR__
.
'/jui'
,
'@yii'
=>
__DIR__
,
'@yii'
=>
__DIR__
,
),
),
);
);
framework/yii/bootstrap/Carousel.php
View file @
dc8b449c
...
@@ -7,28 +7,29 @@
...
@@ -7,28 +7,29 @@
namespace
yii\bootstrap
;
namespace
yii\bootstrap
;
use
Yii
;
use
yii\base\InvalidConfigException
;
use
yii\base\InvalidConfigException
;
use
yii\base\Model
;
use
yii\helpers\base\ArrayHelper
;
use
yii\helpers\base\ArrayHelper
;
use
yii\helpers\Html
;
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(
* 'items' => array(
* 'items' => array(
* // the item contains only the image
* '<img src="http://twitter.github.io/bootstrap/assets/img/bootstrap-mdo-sfmoma-01.jpg"/>',
* '<img src="http://twitter.github.io/bootstrap/assets/img/bootstrap-mdo-sfmoma-01.jpg"/>',
* // equivalent to the above
* array(
* array(
* 'content' => '<img src="http://twitter.github.io/bootstrap/assets/img/bootstrap-mdo-sfmoma-02.jpg"/>',
* 'content' => '<img src="http://twitter.github.io/bootstrap/assets/img/bootstrap-mdo-sfmoma-02.jpg"/>',
* ),
* ),
* // the item contains both the image and the caption
* 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</h4><p>This is the caption text</p>',
* '
caption' => '<h4>This is title</h5><p>This is the caption text</p>'
* '
options' => array(...),
* ),
* ),
* )
* )
* ));
* ));
...
@@ -41,20 +42,22 @@ use yii\helpers\Html;
...
@@ -41,20 +42,22 @@ use yii\helpers\Html;
class
Carousel
extends
Widget
class
Carousel
extends
Widget
{
{
/**
/**
* @var array
indicates what labels should be displayed on next and previous carousel controls. If [[controls]] is
* @var array
|boolean the labels for the previous and the next control buttons.
*
set to `false` or they do not hold `left` and `right` keys, the controls will
not be displayed.
*
If false, it means the previous and the next control buttons should
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 slides in the carousel. Each array element represents a single
* the widget will not render anything. Each array element represents a single image in the carousel
* slide with the following structure:
* with the following structure:
*
*
* ```php
* ```php
* array(
* array(
* 'content' => 'src of the image', // required
* // required, slide content (HTML), such as an image tag
* 'options' => ['html attributes of the item'], // optional
* 'content' => '<img src="http://twitter.github.io/bootstrap/assets/img/bootstrap-mdo-sfmoma-01.jpg"/>',
* 'caption'=> ['html attributes of the image'] // optional
* // optional, the caption (HTML) of the slide
* 'caption'=> '<h4>This is title</h4><p>This is the caption text</p>',
* // optional the HTML attributes of the slide container
* 'options' => array(),
* )
* )
* ```
* ```
*/
*/
...
@@ -75,97 +78,95 @@ class Carousel extends Widget
...
@@ -75,97 +78,95 @@ class Carousel extends Widget
*/
*/
public
function
run
()
public
function
run
()
{
{
if
(
empty
(
$this
->
items
))
{
return
;
}
echo
Html
::
beginTag
(
'div'
,
$this
->
options
)
.
"
\n
"
;
echo
Html
::
beginTag
(
'div'
,
$this
->
options
)
.
"
\n
"
;
echo
$this
->
renderIndicators
()
.
"
\n
"
;
echo
$this
->
renderIndicators
()
.
"
\n
"
;
echo
$this
->
renderItems
()
.
"
\n
"
;
echo
$this
->
renderItems
()
.
"
\n
"
;
echo
$this
->
render
PreviousAndNext
()
.
"
\n
"
;
echo
$this
->
render
Controls
()
.
"
\n
"
;
echo
Html
::
endTag
(
'div'
)
.
"
\n
"
;
echo
Html
::
endTag
(
'div'
)
.
"
\n
"
;
$this
->
registerPlugin
(
'carousel'
);
$this
->
registerPlugin
(
'carousel'
);
}
}
/**
/**
* Renders carousel indicators
* Renders carousel indicators.
* @return string the rendering result
*/
*/
public
function
renderIndicators
()
public
function
renderIndicators
()
{
{
ob_start
();
$indicators
=
array
();
echo
Html
::
beginTag
(
'ol'
,
array
(
'class'
=>
'carousel-indicators'
))
.
"
\n
"
;
for
(
$i
=
0
,
$count
=
count
(
$this
->
items
);
$i
<
$count
;
$i
++
)
{
for
(
$i
=
0
,
$ln
=
count
(
$this
->
items
);
$i
<
$ln
;
$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'
);
}
}
echo
Html
::
tag
(
'li'
,
''
,
$options
)
.
"
\n
"
;
$indicators
[]
=
Html
::
tag
(
'li'
,
''
,
$options
)
;
}
}
echo
Html
::
endTag
(
'ol'
)
.
"
\n
"
;
return
Html
::
tag
(
'ol'
,
implode
(
"
\n
"
,
$indicators
),
array
(
'class'
=>
'carousel-indicators'
));
return
ob_get_clean
();
}
}
/**
/**
* Renders carousel items as specified on [[items]]
* Renders carousel items as specified on [[items]].
* @return string the rendering result
*/
*/
public
function
renderItems
()
public
function
renderItems
()
{
{
ob_start
();
$items
=
array
();
echo
Html
::
beginTag
(
'div'
,
array
(
'class'
=>
'carousel-inner'
))
.
"
\n
"
;
for
(
$i
=
0
,
$count
=
count
(
$this
->
items
);
$i
<
$count
;
$i
++
)
{
for
(
$i
=
0
,
$ln
=
count
(
$this
->
items
);
$i
<
$ln
;
$i
++
)
{
$items
[]
=
$this
->
renderItem
(
$this
->
items
[
$i
],
$i
);
$this
->
renderItem
(
$this
->
items
[
$i
],
$i
);
}
}
echo
Html
::
endTag
(
'div'
)
.
"
\n
"
;
return
Html
::
tag
(
'div'
,
implode
(
"
\n
"
,
$items
),
array
(
'class'
=>
'carousel-inner'
));
return
ob_get_clean
();
}
}
/**
/**
* Renders a single carousel item
* Renders a single carousel item
* @param
mixed
$item a single item from [[items]]
* @param
string|array
$item a single item from [[items]]
* @param integer $index the item index as the first item should be set to `active`
* @param integer $index the item index as the first item should be set to `active`
* @return string the rendering result
* @throws InvalidConfigException if the item is invalid
*/
*/
public
function
renderItem
(
$item
,
$index
)
public
function
renderItem
(
$item
,
$index
)
{
{
if
(
is_string
(
$item
))
{
if
(
is_string
(
$item
))
{
$itemOptions
=
array
();
$content
=
$item
;
$itemContent
=
$item
;
$caption
=
null
;
$itemCaption
=
''
;
$options
=
array
();
}
else
{
}
elseif
(
isset
(
$item
[
'content'
]))
{
$itemOptions
=
ArrayHelper
::
getValue
(
$item
,
'options'
,
array
());
$content
=
$item
[
'content'
];
$itemContent
=
$item
[
'content'
];
// if not string, must be array, force required key
$caption
=
ArrayHelper
::
getValue
(
$item
,
'caption'
);
$itemCaption
=
ArrayHelper
::
getValue
(
$item
,
'caption'
);
if
(
$caption
!==
null
)
{
if
(
$itemCaption
)
{
$caption
=
Html
::
tag
(
'div'
,
$caption
,
array
(
'class'
=>
'carousel-caption'
));
$itemCaption
=
Html
::
tag
(
'div'
,
$itemCaption
,
array
(
'class'
=>
'carousel-caption'
));
}
}
$options
=
ArrayHelper
::
getValue
(
$item
,
'options'
,
array
());
}
else
{
throw
new
InvalidConfigException
(
'The "content" option is required.'
);
}
}
$this
->
addCssClass
(
$
itemO
ptions
,
'item'
);
$this
->
addCssClass
(
$
o
ptions
,
'item'
);
if
(
$index
===
0
)
{
if
(
$index
===
0
)
{
$this
->
addCssClass
(
$
itemO
ptions
,
'active'
);
$this
->
addCssClass
(
$
o
ptions
,
'active'
);
}
}
echo
Html
::
beginTag
(
'div'
,
$itemOptions
)
.
"
\n
"
;
echo
$itemContent
.
"
\n
"
;
return
Html
::
tag
(
'div'
,
$content
.
"
\n
"
.
$caption
,
$options
);
echo
$itemCaption
.
"
\n
"
;
echo
Html
::
endTag
(
'div'
)
.
"
\n
"
;
}
}
/**
/**
* Renders previous and next button if [[displayPreviousAndNext]] is set to `true`
* Renders previous and next control buttons.
* @throws InvalidConfigException if [[controls]] is invalid.
*/
*/
public
function
render
PreviousAndNext
()
public
function
render
Controls
()
{
{
if
(
$this
->
controls
===
false
||
!
(
isset
(
$this
->
controls
[
'left'
])
&&
isset
(
$this
->
controls
[
'left'
])))
{
if
(
isset
(
$this
->
controls
[
0
],
$this
->
controls
[
1
]))
{
return
;
return
Html
::
a
(
$this
->
controls
[
0
],
'#'
.
$this
->
options
[
'id'
],
array
(
}
echo
Html
::
a
(
$this
->
controls
[
'left'
],
'#'
.
$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'
,
));
));
}
elseif
(
$this
->
controls
===
false
)
{
return
''
;
}
else
{
throw
new
InvalidConfigException
(
'The "controls" property must be either false or an array of two elements.'
);
}
}
}
}
}
framework/yii/bootstrap/Collapse.php
0 → 100644
View file @
dc8b449c
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\bootstrap
;
use
yii\base\InvalidConfigException
;
use
yii\helpers\base\ArrayHelper
;
use
yii\helpers\Html
;
/**
* Collapse renders an accordion bootstrap javascript component.
*
* For example:
*
* ```php
* echo Collapse::widget(array(
* 'items' => array(
* // equivalent to the above
* 'Collapsible Group Item #1' => array(
* 'content' => 'Anim pariatur cliche...',
* // open its content by default
* 'contentOptions' => array('class'=>'in')
* ),
* // another group item
* 'Collapsible Group Item #2' => array(
* 'content' => 'Anim pariatur cliche...',
* 'contentOptions' => array(...),
* 'options' => array(...),
* ),
* )
* ));
* ```
*
* @see http://twitter.github.io/bootstrap/javascript.html#collapse
* @author Antonio Ramirez <amigo.cobos@gmail.com>
* @since 2.0
*/
class
Collapse
extends
Widget
{
/**
* @var array list of groups in the collapse widget. Each array element represents a single
* group with the following structure:
*
* ```php
* // item key is the actual group header
* 'Collapsible Group Item #1' => array(
* // required, the content (HTML) of the group
* 'content' => 'Anim pariatur cliche...',
* // optional the HTML attributes of the content group
* 'contentOptions'=> array(),
* // optional the HTML attributes of the group
* 'options'=> array(),
* )
* ```
*/
public
$items
=
array
();
/**
* Initializes the widget.
*/
public
function
init
()
{
parent
::
init
();
$this
->
addCssClass
(
$this
->
options
,
'accordion'
);
}
/**
* Renders the widget.
*/
public
function
run
()
{
echo
Html
::
beginTag
(
'div'
,
$this
->
options
)
.
"
\n
"
;
echo
$this
->
renderItems
()
.
"
\n
"
;
echo
Html
::
endTag
(
'div'
)
.
"
\n
"
;
$this
->
registerPlugin
(
'collapse'
);
}
/**
* Renders collapsible items as specified on [[items]].
* @return string the rendering result
*/
public
function
renderItems
()
{
$items
=
array
();
$index
=
0
;
foreach
(
$this
->
items
as
$header
=>
$item
)
{
$options
=
ArrayHelper
::
getValue
(
$item
,
'options'
,
array
());
$this
->
addCssClass
(
$options
,
'accordion-group'
);
$items
[]
=
Html
::
tag
(
'div'
,
$this
->
renderItem
(
$header
,
$item
,
++
$index
),
$options
);
}
return
implode
(
"
\n
"
,
$items
);
}
/**
* Renders a single collapsible item group
* @param string $header a label of the item group [[items]]
* @param array $item a single item from [[items]]
* @param integer $index the item index as each item group content must have an id
* @return string the rendering result
* @throws InvalidConfigException
*/
public
function
renderItem
(
$header
,
$item
,
$index
)
{
if
(
isset
(
$item
[
'content'
]))
{
$id
=
$this
->
options
[
'id'
]
.
'-collapse'
.
$index
;
$options
=
ArrayHelper
::
getValue
(
$item
,
'contentOptions'
,
array
());
$options
[
'id'
]
=
$id
;
$this
->
addCssClass
(
$options
,
'accordion-body collapse'
);
$header
=
Html
::
a
(
$header
,
'#'
.
$id
,
array
(
'class'
=>
'accordion-toggle'
,
'data-toggle'
=>
'collapse'
,
'data-parent'
=>
'#'
.
$this
->
options
[
'id'
]
))
.
"
\n
"
;
$content
=
Html
::
tag
(
'div'
,
$item
[
'content'
],
array
(
'class'
=>
'accordion-inner'
))
.
"
\n
"
;
}
else
{
throw
new
InvalidConfigException
(
'The "content" option is required.'
);
}
$group
=
array
();
$group
[]
=
Html
::
tag
(
'div'
,
$header
,
array
(
'class'
=>
'accordion-heading'
));
$group
[]
=
Html
::
tag
(
'div'
,
$content
,
$options
);
return
implode
(
"
\n
"
,
$group
);
}
}
\ No newline at end of file
framework/yii/console/Request.php
View file @
dc8b449c
...
@@ -15,9 +15,32 @@ class Request extends \yii\base\Request
...
@@ -15,9 +15,32 @@ class Request extends \yii\base\Request
{
{
const
ANONYMOUS_PARAMS
=
'-args'
;
const
ANONYMOUS_PARAMS
=
'-args'
;
public
function
getRawParams
()
private
$_params
;
/**
* Returns the command line arguments.
* @return array the command line arguments. It does not include the entry script name.
*/
public
function
getParams
()
{
if
(
!
isset
(
$this
->
_params
))
{
if
(
isset
(
$_SERVER
[
'argv'
]))
{
$this
->
_params
=
$_SERVER
[
'argv'
];
array_shift
(
$this
->
_params
);
}
else
{
$this
->
_params
=
array
();
}
}
return
$this
->
_params
;
}
/**
* Sets the command line arguments.
* @param array $params the command line arguments
*/
public
function
setParams
(
$params
)
{
{
return
isset
(
$_SERVER
[
'argv'
])
?
$_SERVER
[
'argv'
]
:
array
()
;
$this
->
_params
=
$params
;
}
}
/**
/**
...
@@ -26,9 +49,7 @@ class Request extends \yii\base\Request
...
@@ -26,9 +49,7 @@ class Request extends \yii\base\Request
*/
*/
public
function
resolve
()
public
function
resolve
()
{
{
$rawParams
=
$this
->
getRawParams
();
$rawParams
=
$this
->
getParams
();
array_shift
(
$rawParams
);
// the 1st argument is the yii script name
if
(
isset
(
$rawParams
[
0
]))
{
if
(
isset
(
$rawParams
[
0
]))
{
$route
=
$rawParams
[
0
];
$route
=
$rawParams
[
0
];
array_shift
(
$rawParams
);
array_shift
(
$rawParams
);
...
...
framework/yii/helpers/base/Inflector.php
View file @
dc8b449c
...
@@ -17,16 +17,17 @@ use Yii;
...
@@ -17,16 +17,17 @@ use Yii;
*/
*/
class
Inflector
class
Inflector
{
{
/**
/**
* @var array rules of plural words
* @var array the rules for converting a word into its plural form.
* The keys are the regular expressions and the values are the corresponding replacements.
*/
*/
protected
static
$plural
=
array
(
public
static
$plurals
=
array
(
'rules'
=>
array
(
'/([nrlm]ese|deer|fish|sheep|measles|ois|pox|media)$/i'
=>
'\1'
,
'/^(sea[- ]bass)$/i'
=>
'\1'
,
'/(m)ove$/i'
=>
'\1oves'
,
'/(m)ove$/i'
=>
'\1oves'
,
'/(f)oot$/i'
=>
'\1eet'
,
'/(f)oot$/i'
=>
'\1eet'
,
'/(h)uman$/i'
=>
'\1umans'
,
'/(h)uman$/i'
=>
'\1umans'
,
'/(s)tatus$/i'
=>
'\1\2
tatuses'
,
'/(s)tatus$/i'
=>
'\1
tatuses'
,
'/(s)taff$/i'
=>
'\1taff'
,
'/(s)taff$/i'
=>
'\1taff'
,
'/(t)ooth$/i'
=>
'\1eeth'
,
'/(t)ooth$/i'
=>
'\1eeth'
,
'/(quiz)$/i'
=>
'\1zes'
,
'/(quiz)$/i'
=>
'\1zes'
,
...
@@ -50,58 +51,15 @@ class Inflector
...
@@ -50,58 +51,15 @@ class Inflector
'/s$/'
=>
's'
,
'/s$/'
=>
's'
,
'/^$/'
=>
''
,
'/^$/'
=>
''
,
'/$/'
=>
's'
,
'/$/'
=>
's'
,
),
'uninflected'
=>
array
(
'.*[nrlm]ese'
,
'.*deer'
,
'.*fish'
,
'.*measles'
,
'.*ois'
,
'.*pox'
,
'.*sheep'
,
'people'
),
'irregular'
=>
array
(
'atlas'
=>
'atlases'
,
'beef'
=>
'beefs'
,
'brother'
=>
'brothers'
,
'cafe'
=>
'cafes'
,
'child'
=>
'children'
,
'cookie'
=>
'cookies'
,
'corpus'
=>
'corpuses'
,
'cow'
=>
'cows'
,
'ganglion'
=>
'ganglions'
,
'genie'
=>
'genies'
,
'genus'
=>
'genera'
,
'graffito'
=>
'graffiti'
,
'hoof'
=>
'hoofs'
,
'loaf'
=>
'loaves'
,
'man'
=>
'men'
,
'money'
=>
'monies'
,
'mongoose'
=>
'mongooses'
,
'move'
=>
'moves'
,
'mythos'
=>
'mythoi'
,
'niche'
=>
'niches'
,
'numen'
=>
'numina'
,
'occiput'
=>
'occiputs'
,
'octopus'
=>
'octopuses'
,
'opus'
=>
'opuses'
,
'ox'
=>
'oxen'
,
'penis'
=>
'penises'
,
'person'
=>
'people'
,
'sex'
=>
'sexes'
,
'soliloquy'
=>
'soliloquies'
,
'testis'
=>
'testes'
,
'trilby'
=>
'trilbys'
,
'turf'
=>
'turfs'
)
);
);
/**
/**
* @var array the rules to singular inflector
* @var array the rules for converting a word into its singular form.
* The keys are the regular expressions and the values are the corresponding replacements.
*/
*/
protected
static
$singular
=
array
(
public
static
$singulars
=
array
(
'rules'
=>
array
(
'/([nrlm]ese|deer|fish|sheep|measles|ois|pox|media|ss)$/i'
=>
'\1'
,
'/(s)tatuses$/i'
=>
'\1\2tatus'
,
'/^(sea[- ]bass)$/i'
=>
'\1'
,
'/(s)tatuses$/i'
=>
'\1tatus'
,
'/(f)eet$/i'
=>
'\1oot'
,
'/(f)eet$/i'
=>
'\1oot'
,
'/(t)eeth$/i'
=>
'\1ooth'
,
'/(t)eeth$/i'
=>
'\1ooth'
,
'/^(.*)(menu)s$/i'
=>
'\1\2'
,
'/^(.*)(menu)s$/i'
=>
'\1\2'
,
...
@@ -136,114 +94,129 @@ class Inflector
...
@@ -136,114 +94,129 @@ class Inflector
'/(n)ews$/i'
=>
'\1\2ews'
,
'/(n)ews$/i'
=>
'\1\2ews'
,
'/eaus$/'
=>
'eau'
,
'/eaus$/'
=>
'eau'
,
'/^(.*us)$/'
=>
'\\1'
,
'/^(.*us)$/'
=>
'\\1'
,
'/s$/i'
=>
''
'/s$/i'
=>
''
,
),
'uninflected'
=>
array
(
'.*[nrlm]ese'
,
'.*deer'
,
'.*fish'
,
'.*measles'
,
'.*ois'
,
'.*pox'
,
'.*sheep'
,
'.*ss'
),
'irregular'
=>
array
(
'foes'
=>
'foe'
,
'waves'
=>
'wave'
,
'curves'
=>
'curve'
)
);
);
/**
/**
* @var array list of words that should not be inflected
* @var array the special rules for converting a word between its plural form and singular form.
* The keys are the special words in singular form, and the values are the corresponding plural form.
*/
*/
protected
static
$uninflected
=
array
(
public
static
$specials
=
array
(
'Amoyese'
,
'atlas'
=>
'atlases'
,
'bison'
,
'beef'
=>
'beefs'
,
'Borghese'
,
'brother'
=>
'brothers'
,
'bream'
,
'cafe'
=>
'cafes'
,
'breeches'
,
'child'
=>
'children'
,
'britches'
,
'cookie'
=>
'cookies'
,
'buffalo'
,
'corpus'
=>
'corpuses'
,
'cantus'
,
'cow'
=>
'cows'
,
'carp'
,
'curve'
=>
'curves'
,
'chassis'
,
'foe'
=>
'foes'
,
'clippers'
,
'ganglion'
=>
'ganglions'
,
'cod'
,
'genie'
=>
'genies'
,
'coitus'
,
'genus'
=>
'genera'
,
'Congoese'
,
'graffito'
=>
'graffiti'
,
'contretemps'
,
'hoof'
=>
'hoofs'
,
'corps'
,
'loaf'
=>
'loaves'
,
'debris'
,
'man'
=>
'men'
,
'diabetes'
,
'money'
=>
'monies'
,
'djinn'
,
'mongoose'
=>
'mongooses'
,
'eland'
,
'move'
=>
'moves'
,
'elk'
,
'mythos'
=>
'mythoi'
,
'equipment'
,
'niche'
=>
'niches'
,
'Faroese'
,
'numen'
=>
'numina'
,
'flounder'
,
'occiput'
=>
'occiputs'
,
'Foochowese'
,
'octopus'
=>
'octopuses'
,
'gallows'
,
'opus'
=>
'opuses'
,
'Genevese'
,
'ox'
=>
'oxen'
,
'Genoese'
,
'penis'
=>
'penises'
,
'Gilbertese'
,
'sex'
=>
'sexes'
,
'graffiti'
,
'soliloquy'
=>
'soliloquies'
,
'headquarters'
,
'testis'
=>
'testes'
,
'herpes'
,
'trilby'
=>
'trilbys'
,
'hijinks'
,
'turf'
=>
'turfs'
,
'Hottentotese'
,
'wave'
=>
'waves'
,
'information'
,
'Amoyese'
=>
'Amoyese'
,
'innings'
,
'bison'
=>
'bison'
,
'jackanapes'
,
'Borghese'
=>
'Borghese'
,
'Kiplingese'
,
'bream'
=>
'bream'
,
'Kongoese'
,
'breeches'
=>
'breeches'
,
'Lucchese'
,
'britches'
=>
'britches'
,
'mackerel'
,
'buffalo'
=>
'buffalo'
,
'Maltese'
,
'cantus'
=>
'cantus'
,
'.*?media'
,
'carp'
=>
'carp'
,
'mews'
,
'chassis'
=>
'chassis'
,
'moose'
,
'clippers'
=>
'clippers'
,
'mumps'
,
'cod'
=>
'cod'
,
'Nankingese'
,
'coitus'
=>
'coitus'
,
'news'
,
'Congoese'
=>
'Congoese'
,
'nexus'
,
'contretemps'
=>
'contretemps'
,
'Niasese'
,
'corps'
=>
'corps'
,
'Pekingese'
,
'debris'
=>
'debris'
,
'Piedmontese'
,
'diabetes'
=>
'diabetes'
,
'pincers'
,
'djinn'
=>
'djinn'
,
'Pistoiese'
,
'eland'
=>
'eland'
,
'pliers'
,
'elk'
=>
'elk'
,
'Portuguese'
,
'equipment'
=>
'equipment'
,
'proceedings'
,
'Faroese'
=>
'Faroese'
,
'rabies'
,
'flounder'
=>
'flounder'
,
'rice'
,
'Foochowese'
=>
'Foochowese'
,
'rhinoceros'
,
'gallows'
=>
'gallows'
,
'salmon'
,
'Genevese'
=>
'Genevese'
,
'Sarawakese'
,
'Genoese'
=>
'Genoese'
,
'scissors'
,
'Gilbertese'
=>
'Gilbertese'
,
'sea[- ]bass'
,
'graffiti'
=>
'graffiti'
,
'series'
,
'headquarters'
=>
'headquarters'
,
'Shavese'
,
'herpes'
=>
'herpes'
,
'shears'
,
'hijinks'
=>
'hijinks'
,
'siemens'
,
'Hottentotese'
=>
'Hottentotese'
,
'species'
,
'information'
=>
'information'
,
'swine'
,
'innings'
=>
'innings'
,
'testes'
,
'jackanapes'
=>
'jackanapes'
,
'trousers'
,
'Kiplingese'
=>
'Kiplingese'
,
'trout'
,
'Kongoese'
=>
'Kongoese'
,
'tuna'
,
'Lucchese'
=>
'Lucchese'
,
'Vermontese'
,
'mackerel'
=>
'mackerel'
,
'Wenchowese'
,
'Maltese'
=>
'Maltese'
,
'whiting'
,
'mews'
=>
'mews'
,
'wildebeest'
,
'moose'
=>
'moose'
,
'Yengeese'
'mumps'
=>
'mumps'
,
'Nankingese'
=>
'Nankingese'
,
'news'
=>
'news'
,
'nexus'
=>
'nexus'
,
'Niasese'
=>
'Niasese'
,
'Pekingese'
=>
'Pekingese'
,
'Piedmontese'
=>
'Piedmontese'
,
'pincers'
=>
'pincers'
,
'Pistoiese'
=>
'Pistoiese'
,
'pliers'
=>
'pliers'
,
'Portuguese'
=>
'Portuguese'
,
'proceedings'
=>
'proceedings'
,
'rabies'
=>
'rabies'
,
'rice'
=>
'rice'
,
'rhinoceros'
=>
'rhinoceros'
,
'salmon'
=>
'salmon'
,
'Sarawakese'
=>
'Sarawakese'
,
'scissors'
=>
'scissors'
,
'series'
=>
'series'
,
'Shavese'
=>
'Shavese'
,
'shears'
=>
'shears'
,
'siemens'
=>
'siemens'
,
'species'
=>
'species'
,
'swine'
=>
'swine'
,
'testes'
=>
'testes'
,
'trousers'
=>
'trousers'
,
'trout'
=>
'trout'
,
'tuna'
=>
'tuna'
,
'Vermontese'
=>
'Vermontese'
,
'Wenchowese'
=>
'Wenchowese'
,
'whiting'
=>
'whiting'
,
'wildebeest'
=>
'wildebeest'
,
'Yengeese'
=>
'Yengeese'
,
);
);
/**
/**
* @var array map of special chars and its translation
* @var array map of special chars and its translation
. This is used by [[slug()]].
*/
*/
p
rotected
static
$transliteration
=
array
(
p
ublic
static
$transliteration
=
array
(
'/ä|æ|ǽ/'
=>
'ae'
,
'/ä|æ|ǽ/'
=>
'ae'
,
'/ö|œ/'
=>
'oe'
,
'/ö|œ/'
=>
'oe'
,
'/ü/'
=>
'ue'
,
'/ü/'
=>
'ue'
,
...
@@ -305,19 +278,10 @@ class Inflector
...
@@ -305,19 +278,10 @@ class Inflector
*/
*/
public
static
function
pluralize
(
$word
)
public
static
function
pluralize
(
$word
)
{
{
$unInflected
=
ArrayHelper
::
merge
(
static
::
$plural
[
'uninflected'
],
static
::
$uninflected
);
if
(
isset
(
self
::
$specials
[
$word
]))
{
$irregular
=
array_keys
(
static
::
$plural
[
'irregular'
]);
return
self
::
$specials
[
$word
];
}
$unInflectedRegex
=
'(?:'
.
implode
(
'|'
,
$unInflected
)
.
')'
;
foreach
(
static
::
$plurals
as
$rule
=>
$replacement
)
{
$irregularRegex
=
'(?:'
.
implode
(
'|'
,
$irregular
)
.
')'
;
if
(
preg_match
(
'/(.*)\\b('
.
$irregularRegex
.
')$/i'
,
$word
,
$regs
))
return
$regs
[
1
]
.
substr
(
$word
,
0
,
1
)
.
substr
(
static
::
$plural
[
'irregular'
][
strtolower
(
$regs
[
2
])],
1
);
if
(
preg_match
(
'/^('
.
$unInflectedRegex
.
')$/i'
,
$word
,
$regs
))
return
$word
;
foreach
(
static
::
$plural
[
'rules'
]
as
$rule
=>
$replacement
)
{
if
(
preg_match
(
$rule
,
$word
))
{
if
(
preg_match
(
$rule
,
$word
))
{
return
preg_replace
(
$rule
,
$replacement
,
$word
);
return
preg_replace
(
$rule
,
$replacement
,
$word
);
}
}
...
@@ -332,27 +296,11 @@ class Inflector
...
@@ -332,27 +296,11 @@ class Inflector
*/
*/
public
static
function
singularize
(
$word
)
public
static
function
singularize
(
$word
)
{
{
$result
=
array_search
(
$word
,
self
::
$specials
,
true
);
$unInflected
=
ArrayHelper
::
merge
(
static
::
$singular
[
'uninflected'
],
static
::
$uninflected
);
if
(
$result
!==
false
)
{
return
$result
;
$irregular
=
array_merge
(
}
static
::
$singular
[
'irregular'
],
foreach
(
static
::
$singulars
as
$rule
=>
$replacement
)
{
array_flip
(
static
::
$plural
[
'irregular'
])
);
$unInflectedRegex
=
'(?:'
.
implode
(
'|'
,
$unInflected
)
.
')'
;
$irregularRegex
=
'(?:'
.
implode
(
'|'
,
array_keys
(
$irregular
))
.
')'
;
if
(
preg_match
(
'/(.*)\\b('
.
$irregularRegex
.
')$/i'
,
$word
,
$regs
))
return
$regs
[
1
]
.
substr
(
$word
,
0
,
1
)
.
substr
(
$irregular
[
strtolower
(
$regs
[
2
])],
1
);
if
(
preg_match
(
'/^('
.
$unInflectedRegex
.
')$/i'
,
$word
,
$regs
))
return
$word
;
foreach
(
static
::
$singular
[
'rules'
]
as
$rule
=>
$replacement
)
{
if
(
preg_match
(
$rule
,
$word
))
{
if
(
preg_match
(
$rule
,
$word
))
{
return
preg_replace
(
$rule
,
$replacement
,
$word
);
return
preg_replace
(
$rule
,
$replacement
,
$word
);
}
}
...
@@ -369,7 +317,6 @@ class Inflector
...
@@ -369,7 +317,6 @@ class Inflector
*/
*/
public
static
function
titleize
(
$words
,
$ucAll
=
false
)
public
static
function
titleize
(
$words
,
$ucAll
=
false
)
{
{
$words
=
static
::
humanize
(
static
::
underscore
(
$words
),
$ucAll
);
$words
=
static
::
humanize
(
static
::
underscore
(
$words
),
$ucAll
);
return
$ucAll
?
ucwords
(
$words
)
:
ucfirst
(
$words
);
return
$ucAll
?
ucwords
(
$words
)
:
ucfirst
(
$words
);
}
}
...
@@ -492,7 +439,6 @@ class Inflector
...
@@ -492,7 +439,6 @@ class Inflector
*/
*/
public
static
function
slug
(
$string
,
$replacement
=
'-'
)
public
static
function
slug
(
$string
,
$replacement
=
'-'
)
{
{
$map
=
static
::
$transliteration
+
array
(
$map
=
static
::
$transliteration
+
array
(
'/[^\w\s]/'
=>
' '
,
'/[^\w\s]/'
=>
' '
,
'/\\s+/'
=>
$replacement
,
'/\\s+/'
=>
$replacement
,
...
@@ -521,20 +467,12 @@ class Inflector
...
@@ -521,20 +467,12 @@ class Inflector
{
{
if
(
in_array
((
$number
%
100
),
range
(
11
,
13
)))
{
if
(
in_array
((
$number
%
100
),
range
(
11
,
13
)))
{
return
$number
.
'th'
;
return
$number
.
'th'
;
}
else
{
switch
((
$number
%
10
))
{
case
1
:
return
$number
.
'st'
;
break
;
case
2
:
return
$number
.
'nd'
;
break
;
case
3
:
return
$number
.
'rd'
;
default
:
return
$number
.
'th'
;
break
;
}
}
switch
((
$number
%
10
))
{
case
1
:
return
$number
.
'st'
;
case
2
:
return
$number
.
'nd'
;
case
3
:
return
$number
.
'rd'
;
default
:
return
$number
.
'th'
;
}
}
}
}
}
}
framework/yii/jui/assets.php
View file @
dc8b449c
...
@@ -775,7 +775,7 @@ return array(
...
@@ -775,7 +775,7 @@ return array(
'css'
=>
array
(
'css'
=>
array
(
'themes/base/jquery.ui.autocomplete.css'
,
'themes/base/jquery.ui.autocomplete.css'
,
),
),
'depends'
=>
array
(
'yii/jui/theme/base/core'
),
'depends'
=>
array
(
'yii/jui/theme/base/core'
,
'yii/jui/theme/base/menu'
),
),
),
'yii/jui/theme/base/button'
=>
array
(
'yii/jui/theme/base/button'
=>
array
(
'sourcePath'
=>
__DIR__
.
'/assets'
,
'sourcePath'
=>
__DIR__
.
'/assets'
,
...
@@ -796,7 +796,7 @@ return array(
...
@@ -796,7 +796,7 @@ return array(
'css'
=>
array
(
'css'
=>
array
(
'themes/base/jquery.ui.dialog.css'
,
'themes/base/jquery.ui.dialog.css'
,
),
),
'depends'
=>
array
(
'yii/jui/theme/base/core'
),
'depends'
=>
array
(
'yii/jui/theme/base/core'
,
'yii/jui/theme/base/button'
,
'yii/jui/theme/base/resizeable'
),
),
),
'yii/jui/theme/base/menu'
=>
array
(
'yii/jui/theme/base/menu'
=>
array
(
'sourcePath'
=>
__DIR__
.
'/assets'
,
'sourcePath'
=>
__DIR__
.
'/assets'
,
...
@@ -838,7 +838,7 @@ return array(
...
@@ -838,7 +838,7 @@ return array(
'css'
=>
array
(
'css'
=>
array
(
'themes/base/jquery.ui.spinner.css'
,
'themes/base/jquery.ui.spinner.css'
,
),
),
'depends'
=>
array
(
'yii/jui/theme/base/core'
),
'depends'
=>
array
(
'yii/jui/theme/base/core'
,
'yii/jui/theme/base/button'
),
),
),
'yii/jui/theme/base/tabs'
=>
array
(
'yii/jui/theme/base/tabs'
=>
array
(
'sourcePath'
=>
__DIR__
.
'/assets'
,
'sourcePath'
=>
__DIR__
.
'/assets'
,
...
...
framework/yii/requirements/requirements.php
View file @
dc8b449c
...
@@ -9,9 +9,9 @@ return array(
...
@@ -9,9 +9,9 @@ return array(
array
(
array
(
'name'
=>
'PHP version'
,
'name'
=>
'PHP version'
,
'mandatory'
=>
true
,
'mandatory'
=>
true
,
'condition'
=>
version_compare
(
PHP_VERSION
,
'5.3.
11
'
,
'>='
),
'condition'
=>
version_compare
(
PHP_VERSION
,
'5.3.
7
'
,
'>='
),
'by'
=>
'<a href="http://www.yiiframework.com">Yii Framework</a>'
,
'by'
=>
'<a href="http://www.yiiframework.com">Yii Framework</a>'
,
'memo'
=>
'PHP 5.3.
11
or higher is required.'
,
'memo'
=>
'PHP 5.3.
7
or higher is required.'
,
),
),
array
(
array
(
'name'
=>
'Reflection extension'
,
'name'
=>
'Reflection extension'
,
...
...
framework/yii/web/UrlManager.php
View file @
dc8b449c
...
@@ -27,6 +27,12 @@ class UrlManager extends Component
...
@@ -27,6 +27,12 @@ class UrlManager extends Component
*/
*/
public
$enablePrettyUrl
=
false
;
public
$enablePrettyUrl
=
false
;
/**
/**
* @var boolean whether to enable strict parsing. If strict parsing is enabled, the incoming
* requested URL must match at least one of the [[rules]] in order to be treated as a valid request.
* This property is used only when [[enablePrettyUrl]] is true.
*/
public
$enableStrictParsing
=
false
;
/**
* @var array the rules for creating and parsing URLs when [[enablePrettyUrl]] is true.
* @var array the rules for creating and parsing URLs when [[enablePrettyUrl]] is true.
* This property is used only if [[enablePrettyUrl]] is true. Each element in the array
* This property is used only if [[enablePrettyUrl]] is true. Each element in the array
* is the configuration array for creating a single URL rule. The configuration will
* is the configuration array for creating a single URL rule. The configuration will
...
@@ -139,6 +145,10 @@ class UrlManager extends Component
...
@@ -139,6 +145,10 @@ class UrlManager extends Component
}
}
}
}
if
(
$this
->
enableStrictParsing
)
{
return
false
;
}
$suffix
=
(
string
)
$this
->
suffix
;
$suffix
=
(
string
)
$this
->
suffix
;
if
(
$suffix
!==
''
&&
$suffix
!==
'/'
&&
$pathInfo
!==
''
)
{
if
(
$suffix
!==
''
&&
$suffix
!==
'/'
&&
$pathInfo
!==
''
)
{
$n
=
strlen
(
$this
->
suffix
);
$n
=
strlen
(
$this
->
suffix
);
...
...
framework/yii/widgets/Menu.php
View file @
dc8b449c
...
@@ -26,7 +26,6 @@ use yii\helpers\Html;
...
@@ -26,7 +26,6 @@ use yii\helpers\Html;
* The following example shows how to use Menu:
* The following example shows how to use Menu:
*
*
* ~~~
* ~~~
* // $this is the view object currently being used
* echo Menu::widget(array(
* echo Menu::widget(array(
* 'items' => array(
* 'items' => array(
* // Important: you need to specify url as 'controller/action',
* // Important: you need to specify url as 'controller/action',
...
...
tests/unit/framework/helpers/InflectorTest.php
View file @
dc8b449c
...
@@ -8,8 +8,6 @@ use yiiunit\TestCase;
...
@@ -8,8 +8,6 @@ use yiiunit\TestCase;
class
InflectorTest
extends
TestCase
class
InflectorTest
extends
TestCase
{
{
public
function
testPluralize
()
public
function
testPluralize
()
{
{
$testData
=
array
(
$testData
=
array
(
...
...
tests/unit/framework/web/UrlManagerTest.php
View file @
dc8b449c
...
@@ -224,5 +224,27 @@ class UrlManagerTest extends \yiiunit\TestCase
...
@@ -224,5 +224,27 @@ class UrlManagerTest extends \yiiunit\TestCase
$request
->
pathInfo
=
'site/index'
;
$request
->
pathInfo
=
'site/index'
;
$result
=
$manager
->
parseRequest
(
$request
);
$result
=
$manager
->
parseRequest
(
$request
);
$this
->
assertFalse
(
$result
);
$this
->
assertFalse
(
$result
);
// strict parsing
$manager
=
new
UrlManager
(
array
(
'enablePrettyUrl'
=>
true
,
'enableStrictParsing'
=>
true
,
'suffix'
=>
'.html'
,
'cache'
=>
null
,
'rules'
=>
array
(
array
(
'pattern'
=>
'post/<id>/<title>'
,
'route'
=>
'post/view'
,
),
),
));
// matching pathinfo
$request
->
pathInfo
=
'post/123/this+is+sample.html'
;
$result
=
$manager
->
parseRequest
(
$request
);
$this
->
assertEquals
(
array
(
'post/view'
,
array
(
'id'
=>
'123'
,
'title'
=>
'this+is+sample'
)),
$result
);
// unmatching pathinfo
$request
->
pathInfo
=
'site/index.html'
;
$result
=
$manager
->
parseRequest
(
$request
);
$this
->
assertFalse
(
$result
);
}
}
}
}
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