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
1c375b90
Commit
1c375b90
authored
Feb 06, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug fixes.
parent
a07a67ad
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
20 additions
and
79 deletions
+20
-79
YiiBase.php
framework/YiiBase.php
+1
-1
Module.php
framework/base/Module.php
+2
-1
I18N.php
framework/i18n/I18N.php
+13
-13
FileHelper.php
framework/util/FileHelper.php
+1
-1
error.php
framework/views/error.php
+1
-1
Application.php
framework/web/Application.php
+2
-7
Controller.php
framework/web/Controller.php
+0
-55
No files found.
framework/YiiBase.php
View file @
1c375b90
...
@@ -521,6 +521,6 @@ class YiiBase
...
@@ -521,6 +521,6 @@ class YiiBase
*/
*/
public
static
function
t
(
$message
,
$params
=
array
(),
$language
=
null
)
public
static
function
t
(
$message
,
$params
=
array
(),
$language
=
null
)
{
{
Yii
::
$app
->
getI18N
()
->
translate
(
$message
,
$params
,
$language
);
return
Yii
::
$app
->
getI18N
()
->
translate
(
$message
,
$params
,
$language
);
}
}
}
}
framework/base/Module.php
View file @
1c375b90
...
@@ -569,7 +569,7 @@ abstract class Module extends Component
...
@@ -569,7 +569,7 @@ abstract class Module extends Component
Yii
::
$app
->
controller
=
$oldController
;
Yii
::
$app
->
controller
=
$oldController
;
return
$status
;
return
$status
;
}
else
{
}
else
{
throw
new
InvalidRouteException
(
'Unable to resolve the request
: '
.
trim
(
$this
->
getUniqueId
()
.
'/'
.
$route
,
'/'
)
);
throw
new
InvalidRouteException
(
'Unable to resolve the request
"'
.
trim
(
$this
->
getUniqueId
()
.
'/'
.
$route
,
'/'
)
.
'".'
);
}
}
}
}
...
@@ -607,6 +607,7 @@ abstract class Module extends Component
...
@@ -607,6 +607,7 @@ abstract class Module extends Component
$controller
=
Yii
::
createObject
(
$this
->
controllerMap
[
$id
],
$id
,
$this
);
$controller
=
Yii
::
createObject
(
$this
->
controllerMap
[
$id
],
$id
,
$this
);
}
elseif
(
preg_match
(
'/^[a-z0-9\\-_]+$/'
,
$id
))
{
}
elseif
(
preg_match
(
'/^[a-z0-9\\-_]+$/'
,
$id
))
{
$className
=
StringHelper
::
id2camel
(
$id
)
.
'Controller'
;
$className
=
StringHelper
::
id2camel
(
$id
)
.
'Controller'
;
$classFile
=
$this
->
controllerPath
.
DIRECTORY_SEPARATOR
.
$className
.
'.php'
;
$classFile
=
$this
->
controllerPath
.
DIRECTORY_SEPARATOR
.
$className
.
'.php'
;
if
(
is_file
(
$classFile
))
{
if
(
is_file
(
$classFile
))
{
$className
=
$this
->
controllerNamespace
.
'\\'
.
$className
;
$className
=
$this
->
controllerNamespace
.
'\\'
.
$className
;
...
...
framework/i18n/I18N.php
View file @
1c375b90
...
@@ -20,19 +20,19 @@ class I18N extends Component
...
@@ -20,19 +20,19 @@ class I18N extends Component
$category
=
'app'
;
$category
=
'app'
;
}
}
$message
=
$this
->
getMessageSource
(
$category
)
->
translate
(
$category
,
$message
,
$language
);
//
$message = $this->getMessageSource($category)->translate($category, $message, $language);
//
if
(
!
is_array
(
$params
))
{
//
if (!is_array($params)) {
$params
=
array
(
$params
);
//
$params = array($params);
}
//
}
//
if
(
isset
(
$params
[
0
]))
{
//
if (isset($params[0])) {
$message
=
$this
->
getPluralFormat
(
$message
,
$params
[
0
],
$language
);
//
$message = $this->getPluralFormat($message, $params[0], $language);
if
(
!
isset
(
$params
[
'{n}'
]))
{
//
if (!isset($params['{n}'])) {
$params
[
'{n}'
]
=
$params
[
0
];
//
$params['{n}'] = $params[0];
}
//
}
unset
(
$params
[
0
]);
//
unset($params[0]);
}
//
}
return
$params
===
array
()
?
$message
:
strtr
(
$message
,
$params
);
return
$params
===
array
()
?
$message
:
strtr
(
$message
,
$params
);
}
}
...
...
framework/util/FileHelper.php
View file @
1c375b90
...
@@ -91,7 +91,7 @@ class FileHelper
...
@@ -91,7 +91,7 @@ class FileHelper
public
static
function
localize
(
$file
,
$language
=
null
,
$sourceLanguage
=
null
)
public
static
function
localize
(
$file
,
$language
=
null
,
$sourceLanguage
=
null
)
{
{
if
(
$language
===
null
)
{
if
(
$language
===
null
)
{
$language
=
\Yii
::
$app
->
getLanguage
()
;
$language
=
\Yii
::
$app
->
language
;
}
}
if
(
$sourceLanguage
===
null
)
{
if
(
$sourceLanguage
===
null
)
{
$sourceLanguage
=
\Yii
::
$app
->
sourceLanguage
;
$sourceLanguage
=
\Yii
::
$app
->
sourceLanguage
;
...
...
framework/views/error.php
View file @
1c375b90
...
@@ -50,7 +50,7 @@ $owner = $this->owner;
...
@@ -50,7 +50,7 @@ $owner = $this->owner;
</head>
</head>
<body>
<body>
<h1>
<?php
echo
get_class
(
$exception
)
?>
</h1>
<h1>
<?php
echo
$owner
->
htmlEncode
(
$exception
instanceof
\yii\base\Exception
?
$exception
->
getName
()
:
get_class
(
$exception
));
?>
</h1>
<h2>
<?php
echo
nl2br
(
$owner
->
htmlEncode
(
$exception
->
getMessage
()))
?>
</h2>
<h2>
<?php
echo
nl2br
(
$owner
->
htmlEncode
(
$exception
->
getMessage
()))
?>
</h2>
<p>
<p>
The above error occurred while the Web server was processing your request.
The above error occurred while the Web server was processing your request.
...
...
framework/web/Application.php
View file @
1c375b90
...
@@ -32,13 +32,8 @@ class Application extends \yii\base\Application
...
@@ -32,13 +32,8 @@ class Application extends \yii\base\Application
*/
*/
public
function
processRequest
()
public
function
processRequest
()
{
{
$route
=
$this
->
resolveRequest
();
$route
=
isset
(
$_GET
[
'r'
])
?
$_GET
[
'r'
]
:
''
;
return
$this
->
runController
(
$route
,
null
);
return
$this
->
runAction
(
$route
,
$_GET
);
}
protected
function
resolveRequest
()
{
return
array
();
}
}
/**
/**
...
...
framework/web/Controller.php
View file @
1c375b90
...
@@ -9,10 +9,6 @@
...
@@ -9,10 +9,6 @@
namespace
yii\web
;
namespace
yii\web
;
use
yii\base\Action
;
use
yii\base\Exception
;
use
yii\base\HttpException
;
/**
/**
* Controller is the base class of Web controllers.
* Controller is the base class of Web controllers.
*
*
...
@@ -22,54 +18,4 @@ use yii\base\HttpException;
...
@@ -22,54 +18,4 @@ use yii\base\HttpException;
*/
*/
class
Controller
extends
\yii\base\Controller
class
Controller
extends
\yii\base\Controller
{
{
private
$_pageTitle
;
/**
* Returns the request parameters that will be used for action parameter binding.
* Default implementation simply returns an empty array.
* Child classes may override this method to customize the parameters to be provided
* for action parameter binding (e.g. `$_GET`).
* @return array the request parameters (name-value pairs) to be used for action parameter binding
*/
public
function
getActionParams
()
{
return
$_GET
;
}
/**
* This method is invoked when the request parameters do not satisfy the requirement of the specified action.
* The default implementation will throw an exception.
* @param Action $action the action being executed
* @param Exception $exception the exception about the invalid parameters
* @throws HttpException $exception a 400 HTTP exception
*/
public
function
invalidActionParams
(
$action
,
$exception
)
{
throw
new
HttpException
(
400
,
\Yii
::
t
(
'yii|Your request is invalid.'
));
}
/**
* @return string the page title. Defaults to the controller name and the action name.
*/
public
function
getPageTitle
()
{
if
(
$this
->
_pageTitle
!==
null
)
{
return
$this
->
_pageTitle
;
}
else
{
$name
=
ucfirst
(
basename
(
$this
->
id
));
if
(
$this
->
action
!==
null
&&
strcasecmp
(
$this
->
action
->
id
,
$this
->
defaultAction
))
return
$this
->
_pageTitle
=
\Yii
::
$app
->
name
.
' - '
.
ucfirst
(
$this
->
action
->
id
)
.
' '
.
$name
;
else
return
$this
->
_pageTitle
=
\Yii
::
$app
->
name
.
' - '
.
$name
;
}
}
/**
* @param string $value the page title.
*/
public
function
setPageTitle
(
$value
)
{
$this
->
_pageTitle
=
$value
;
}
}
}
\ No newline at end of file
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