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
0e8e94bc
Commit
0e8e94bc
authored
Apr 02, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup.
parent
c629ad77
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
18 deletions
+42
-18
LocaleController.php
build/controllers/LocaleController.php
+1
-1
plurals.php
framework/i18n/data/plurals.php
+10
-10
ActiveForm.php
framework/widgets/ActiveForm.php
+31
-7
No files found.
build/controllers/LocaleController.php
View file @
0e8e94bc
...
...
@@ -62,7 +62,7 @@ class LocaleController extends Controller
}
$expr
=
preg_replace
(
'/\\bn\\b/'
,
'$n'
,
implode
(
'||'
,
$expr_or
));
$rules
[]
=
preg_replace_callback
(
'/range\((\d+),(\d+)\)/'
,
function
(
$matches
)
{
if
(
$matches
[
2
]
-
$matches
[
1
]
<=
2
)
{
if
(
$matches
[
2
]
-
$matches
[
1
]
<=
5
)
{
return
'array('
.
implode
(
','
,
range
(
$matches
[
1
],
$matches
[
2
]))
.
')'
;
}
else
{
return
$matches
[
0
];
...
...
framework/i18n/data/plurals.php
View file @
0e8e94bc
...
...
@@ -494,8 +494,8 @@ return array (
array
(
0
=>
'$n==1'
,
1
=>
'$n==2'
,
2
=>
'in_array($n,
range(3
,6))'
,
3
=>
'in_array($n,
range(7
,10))'
,
2
=>
'in_array($n,
array(3,4,5
,6))'
,
3
=>
'in_array($n,
array(7,8,9
,10))'
,
),
'ro'
=>
array
(
...
...
@@ -516,43 +516,43 @@ return array (
array
(
0
=>
'fmod($n,10)==1&&fmod($n,100)!=11'
,
1
=>
'in_array(fmod($n,10),array(2,3,4))&&!in_array(fmod($n,100),array(12,13,14))'
,
2
=>
'fmod($n,10)==0||in_array(fmod($n,10),
range(5,9))||in_array(fmod($n,100),range(11
,14))'
,
2
=>
'fmod($n,10)==0||in_array(fmod($n,10),
array(5,6,7,8,9))||in_array(fmod($n,100),array(11,12,13
,14))'
,
),
'bs'
=>
array
(
0
=>
'fmod($n,10)==1&&fmod($n,100)!=11'
,
1
=>
'in_array(fmod($n,10),array(2,3,4))&&!in_array(fmod($n,100),array(12,13,14))'
,
2
=>
'fmod($n,10)==0||in_array(fmod($n,10),
range(5,9))||in_array(fmod($n,100),range(11
,14))'
,
2
=>
'fmod($n,10)==0||in_array(fmod($n,10),
array(5,6,7,8,9))||in_array(fmod($n,100),array(11,12,13
,14))'
,
),
'hr'
=>
array
(
0
=>
'fmod($n,10)==1&&fmod($n,100)!=11'
,
1
=>
'in_array(fmod($n,10),array(2,3,4))&&!in_array(fmod($n,100),array(12,13,14))'
,
2
=>
'fmod($n,10)==0||in_array(fmod($n,10),
range(5,9))||in_array(fmod($n,100),range(11
,14))'
,
2
=>
'fmod($n,10)==0||in_array(fmod($n,10),
array(5,6,7,8,9))||in_array(fmod($n,100),array(11,12,13
,14))'
,
),
'ru'
=>
array
(
0
=>
'fmod($n,10)==1&&fmod($n,100)!=11'
,
1
=>
'in_array(fmod($n,10),array(2,3,4))&&!in_array(fmod($n,100),array(12,13,14))'
,
2
=>
'fmod($n,10)==0||in_array(fmod($n,10),
range(5,9))||in_array(fmod($n,100),range(11
,14))'
,
2
=>
'fmod($n,10)==0||in_array(fmod($n,10),
array(5,6,7,8,9))||in_array(fmod($n,100),array(11,12,13
,14))'
,
),
'sh'
=>
array
(
0
=>
'fmod($n,10)==1&&fmod($n,100)!=11'
,
1
=>
'in_array(fmod($n,10),array(2,3,4))&&!in_array(fmod($n,100),array(12,13,14))'
,
2
=>
'fmod($n,10)==0||in_array(fmod($n,10),
range(5,9))||in_array(fmod($n,100),range(11
,14))'
,
2
=>
'fmod($n,10)==0||in_array(fmod($n,10),
array(5,6,7,8,9))||in_array(fmod($n,100),array(11,12,13
,14))'
,
),
'sr'
=>
array
(
0
=>
'fmod($n,10)==1&&fmod($n,100)!=11'
,
1
=>
'in_array(fmod($n,10),array(2,3,4))&&!in_array(fmod($n,100),array(12,13,14))'
,
2
=>
'fmod($n,10)==0||in_array(fmod($n,10),
range(5,9))||in_array(fmod($n,100),range(11
,14))'
,
2
=>
'fmod($n,10)==0||in_array(fmod($n,10),
array(5,6,7,8,9))||in_array(fmod($n,100),array(11,12,13
,14))'
,
),
'uk'
=>
array
(
0
=>
'fmod($n,10)==1&&fmod($n,100)!=11'
,
1
=>
'in_array(fmod($n,10),array(2,3,4))&&!in_array(fmod($n,100),array(12,13,14))'
,
2
=>
'fmod($n,10)==0||in_array(fmod($n,10),
range(5,9))||in_array(fmod($n,100),range(11
,14))'
,
2
=>
'fmod($n,10)==0||in_array(fmod($n,10),
array(5,6,7,8,9))||in_array(fmod($n,100),array(11,12,13
,14))'
,
),
'cs'
=>
array
(
...
...
@@ -568,7 +568,7 @@ return array (
array
(
0
=>
'$n==1'
,
1
=>
'in_array(fmod($n,10),array(2,3,4))&&!in_array(fmod($n,100),array(12,13,14))'
,
2
=>
'$n!=1&&in_array(fmod($n,10),array(0,1))||in_array(fmod($n,10),
range(5
,9))||in_array(fmod($n,100),array(12,13,14))'
,
2
=>
'$n!=1&&in_array(fmod($n,10),array(0,1))||in_array(fmod($n,10),
array(5,6,7,8
,9))||in_array(fmod($n,100),array(12,13,14))'
,
),
'sl'
=>
array
(
...
...
framework/widgets/ActiveForm.php
View file @
0e8e94bc
...
...
@@ -110,8 +110,7 @@ class ActiveForm extends Widget
*/
public
function
error
(
$model
,
$attribute
,
$options
=
array
())
{
$attribute
=
$this
->
normalizeAttributeName
(
$attribute
);
$this
->
getInputName
(
$model
,
$attribute
);
$attribute
=
$this
->
getAttributeName
(
$attribute
);
$tag
=
isset
(
$options
[
'tag'
])
?
$options
[
'tag'
]
:
'div'
;
unset
(
$options
[
'tag'
]);
$error
=
$model
->
getFirstError
(
$attribute
);
...
...
@@ -126,15 +125,19 @@ class ActiveForm extends Widget
*/
public
function
label
(
$model
,
$attribute
,
$options
=
array
())
{
$attribute
=
$this
->
normalizeAttributeName
(
$attribute
);
$label
=
$model
->
getAttributeLabel
(
$attribute
);
return
Html
::
label
(
Html
::
encode
(
$label
),
isset
(
$options
[
'for'
])
?
$options
[
'for'
]
:
null
,
$options
);
$attribute
=
$this
->
getAttributeName
(
$attribute
);
$label
=
isset
(
$options
[
'label'
])
?
$options
[
'label'
]
:
Html
::
encode
(
$model
->
getAttributeLabel
(
$attribute
));
$for
=
array_key_exists
(
'for'
,
$options
)
?
$options
[
'for'
]
:
$this
->
getInputId
(
$model
,
$attribute
);
return
Html
::
label
(
$label
,
$for
,
$options
);
}
public
function
input
(
$type
,
$model
,
$attribute
,
$options
=
array
())
{
$value
=
$this
->
getAttributeValue
(
$model
,
$attribute
);
$name
=
$this
->
getInputName
(
$model
,
$attribute
);
if
(
!
array_key_exists
(
'id'
,
$options
))
{
$options
[
'id'
]
=
$this
->
getInputId
(
$model
,
$attribute
);
}
return
Html
::
input
(
$type
,
$name
,
$value
,
$options
);
}
...
...
@@ -162,6 +165,9 @@ class ActiveForm extends Widget
{
$value
=
$this
->
getAttributeValue
(
$model
,
$attribute
);
$name
=
$this
->
getInputName
(
$model
,
$attribute
);
if
(
!
array_key_exists
(
'id'
,
$options
))
{
$options
[
'id'
]
=
$this
->
getInputId
(
$model
,
$attribute
);
}
return
Html
::
textarea
(
$name
,
$value
,
$options
);
}
...
...
@@ -172,6 +178,9 @@ class ActiveForm extends Widget
if
(
!
array_key_exists
(
'uncheck'
,
$options
))
{
$options
[
'unchecked'
]
=
'0'
;
}
if
(
!
array_key_exists
(
'id'
,
$options
))
{
$options
[
'id'
]
=
$this
->
getInputId
(
$model
,
$attribute
);
}
return
Html
::
radio
(
$name
,
$checked
,
$value
,
$options
);
}
...
...
@@ -182,6 +191,9 @@ class ActiveForm extends Widget
if
(
!
array_key_exists
(
'uncheck'
,
$options
))
{
$options
[
'unchecked'
]
=
'0'
;
}
if
(
!
array_key_exists
(
'id'
,
$options
))
{
$options
[
'id'
]
=
$this
->
getInputId
(
$model
,
$attribute
);
}
return
Html
::
checkbox
(
$name
,
$checked
,
$value
,
$options
);
}
...
...
@@ -189,6 +201,9 @@ class ActiveForm extends Widget
{
$checked
=
$this
->
getAttributeValue
(
$model
,
$attribute
);
$name
=
$this
->
getInputName
(
$model
,
$attribute
);
if
(
!
array_key_exists
(
'id'
,
$options
))
{
$options
[
'id'
]
=
$this
->
getInputId
(
$model
,
$attribute
);
}
return
Html
::
dropDownList
(
$name
,
$checked
,
$items
,
$options
);
}
...
...
@@ -199,6 +214,9 @@ class ActiveForm extends Widget
if
(
!
array_key_exists
(
'unselect'
,
$options
))
{
$options
[
'unselect'
]
=
'0'
;
}
if
(
!
array_key_exists
(
'id'
,
$options
))
{
$options
[
'id'
]
=
$this
->
getInputId
(
$model
,
$attribute
);
}
return
Html
::
listBox
(
$name
,
$checked
,
$items
,
$options
);
}
...
...
@@ -228,7 +246,7 @@ class ActiveForm extends Widget
if
(
isset
(
$this
->
modelMap
[
$class
]))
{
$class
=
$this
->
modelMap
[
$class
];
}
elseif
((
$pos
=
strrpos
(
$class
,
'\\'
))
!==
false
)
{
$class
=
substr
(
$class
,
$pos
);
$class
=
substr
(
$class
,
$pos
+
1
);
}
if
(
!
preg_match
(
'/(^|.*\])(\w+)(\[.*|$)/'
,
$attribute
,
$matches
))
{
throw
new
InvalidParamException
(
'Attribute name must contain word characters only.'
);
...
...
@@ -245,6 +263,12 @@ class ActiveForm extends Widget
}
}
public
function
getInputId
(
$model
,
$attribute
)
{
$name
=
$this
->
getInputName
(
$model
,
$attribute
);
return
str_replace
(
array
(
'[]'
,
']['
,
'['
,
']'
,
' '
),
array
(
''
,
'-'
,
'-'
,
''
,
'-'
),
$name
);
}
public
function
getAttributeValue
(
$model
,
$attribute
)
{
if
(
!
preg_match
(
'/(^|.*\])(\w+)(\[.*|$)/'
,
$attribute
,
$matches
))
{
...
...
@@ -267,7 +291,7 @@ class ActiveForm extends Widget
}
}
public
function
normalize
AttributeName
(
$attribute
)
public
function
get
AttributeName
(
$attribute
)
{
if
(
preg_match
(
'/(^|.*\])(\w+)(\[.*|$)/'
,
$attribute
,
$matches
))
{
return
$matches
[
2
];
...
...
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