mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-16 06:17:56 +08:00
bug fixes.
This commit is contained in:
@@ -521,6 +521,6 @@ class YiiBase
|
||||
*/
|
||||
public static function t($message, $params = array(), $language = null)
|
||||
{
|
||||
Yii::$app->getI18N()->translate($message, $params, $language);
|
||||
return Yii::$app->getI18N()->translate($message, $params, $language);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -569,7 +569,7 @@ abstract class Module extends Component
|
||||
Yii::$app->controller = $oldController;
|
||||
return $status;
|
||||
} 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
|
||||
$controller = Yii::createObject($this->controllerMap[$id], $id, $this);
|
||||
} elseif (preg_match('/^[a-z0-9\\-_]+$/', $id)) {
|
||||
$className = StringHelper::id2camel($id) . 'Controller';
|
||||
|
||||
$classFile = $this->controllerPath . DIRECTORY_SEPARATOR . $className . '.php';
|
||||
if (is_file($classFile)) {
|
||||
$className = $this->controllerNamespace . '\\' . $className;
|
||||
|
||||
@@ -20,19 +20,19 @@ class I18N extends Component
|
||||
$category = 'app';
|
||||
}
|
||||
|
||||
$message = $this->getMessageSource($category)->translate($category, $message, $language);
|
||||
|
||||
if (!is_array($params)) {
|
||||
$params = array($params);
|
||||
}
|
||||
|
||||
if (isset($params[0])) {
|
||||
$message = $this->getPluralFormat($message, $params[0], $language);
|
||||
if (!isset($params['{n}'])) {
|
||||
$params['{n}'] = $params[0];
|
||||
}
|
||||
unset($params[0]);
|
||||
}
|
||||
// $message = $this->getMessageSource($category)->translate($category, $message, $language);
|
||||
//
|
||||
// if (!is_array($params)) {
|
||||
// $params = array($params);
|
||||
// }
|
||||
//
|
||||
// if (isset($params[0])) {
|
||||
// $message = $this->getPluralFormat($message, $params[0], $language);
|
||||
// if (!isset($params['{n}'])) {
|
||||
// $params['{n}'] = $params[0];
|
||||
// }
|
||||
// unset($params[0]);
|
||||
// }
|
||||
|
||||
return $params === array() ? $message : strtr($message, $params);
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ class FileHelper
|
||||
public static function localize($file, $language = null, $sourceLanguage = null)
|
||||
{
|
||||
if ($language === null) {
|
||||
$language = \Yii::$app->getLanguage();
|
||||
$language = \Yii::$app->language;
|
||||
}
|
||||
if ($sourceLanguage === null) {
|
||||
$sourceLanguage = \Yii::$app->sourceLanguage;
|
||||
|
||||
@@ -50,7 +50,7 @@ $owner = $this->owner;
|
||||
</head>
|
||||
|
||||
<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>
|
||||
<p>
|
||||
The above error occurred while the Web server was processing your request.
|
||||
|
||||
@@ -32,13 +32,8 @@ class Application extends \yii\base\Application
|
||||
*/
|
||||
public function processRequest()
|
||||
{
|
||||
$route = $this->resolveRequest();
|
||||
return $this->runController($route, null);
|
||||
}
|
||||
|
||||
protected function resolveRequest()
|
||||
{
|
||||
return array();
|
||||
$route = isset($_GET['r']) ? $_GET['r'] : '';
|
||||
return $this->runAction($route, $_GET);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,10 +9,6 @@
|
||||
|
||||
namespace yii\web;
|
||||
|
||||
use yii\base\Action;
|
||||
use yii\base\Exception;
|
||||
use yii\base\HttpException;
|
||||
|
||||
/**
|
||||
* Controller is the base class of Web controllers.
|
||||
*
|
||||
@@ -22,54 +18,4 @@ use yii\base\HttpException;
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user