diff --git a/framework/YiiBase.php b/framework/YiiBase.php index 464bcea..d57c92d 100644 --- a/framework/YiiBase.php +++ b/framework/YiiBase.php @@ -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); } } diff --git a/framework/base/Module.php b/framework/base/Module.php index 3217471..3ac53ff 100644 --- a/framework/base/Module.php +++ b/framework/base/Module.php @@ -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; diff --git a/framework/i18n/I18N.php b/framework/i18n/I18N.php index 42b7e07..ab87dfc 100644 --- a/framework/i18n/I18N.php +++ b/framework/i18n/I18N.php @@ -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); } diff --git a/framework/util/FileHelper.php b/framework/util/FileHelper.php index 6565c77..996fba0 100644 --- a/framework/util/FileHelper.php +++ b/framework/util/FileHelper.php @@ -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; diff --git a/framework/views/error.php b/framework/views/error.php index dbbc848..c1700f2 100644 --- a/framework/views/error.php +++ b/framework/views/error.php @@ -50,7 +50,7 @@ $owner = $this->owner;
- +The above error occurred while the Web server was processing your request. diff --git a/framework/web/Application.php b/framework/web/Application.php index a25df7a..fcc8910 100644 --- a/framework/web/Application.php +++ b/framework/web/Application.php @@ -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); } /** diff --git a/framework/web/Controller.php b/framework/web/Controller.php index 22cb8e7..c694f9a 100644 --- a/framework/web/Controller.php +++ b/framework/web/Controller.php @@ -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; - } } \ No newline at end of file