uk/prop/{id}-{address} * * redirect to page with correct alias: * en/prop/{id}-xxx => en/prop/{id}-{address} * * redirect to server url: * ?_escaped_fragment_=/en/prop/{id}-{address} => en/prop/{id}-{address} * * @param $language * @param $id * @param null $alias * @param string $mode * * @throws \yii\web\HttpException * @throws \yii\base\InvalidConfigException * @return string */ public function actionView($language, $id, $alias, $mode) { if ($language && isset(LanguageHelper::$db2jsMap[$language])) { Yii::$app->language = $language; } /** @var Ticket $model*/ $model = Ticket::find(['id' => (int) $id, 'public' => 'y']); if (null == $model) { throw new HttpException(404, 'Page not found.'); } // redirect to correct escaped fragment url if (empty($language) || $alias !== $model->alias || $mode !== PropUrlRule::MODE_ESCAPED_FRAGMENT) { $serverAlias = Yii::$app->urlManager->createUrl([ 'prop/view', 'language' => Yii::$app->language, 'alias' => $model->alias, 'mode' => PropUrlRule::MODE_ESCAPED_FRAGMENT, ]); $this->redirect($serverAlias)->send(); return null; } // $serverAlias = Yii::$app->urlManager->createUrl([ // 'prop/view', // 'language' => Yii::$app->language, // 'alias' => $model->alias, // 'mode' => PropUrlRule::MODE_SERVER, // ]); // // // redirect to correct server url // if (empty($language) || $alias !== $model->alias || $mode === PropUrlRule::MODE_ESCAPED_FRAGMENT) { // $this->redirect($serverAlias)->send(); // return null; // } $clientUrl = Yii::$app->urlManager->createAbsoluteUrl([ 'prop/view', 'language' => Yii::$app->language, 'alias' => $model->alias, 'mode' => PropUrlRule::MODE_CLIENT, ]); // todo: redirect user from server (prop/) and escaped fragment (?_escaped_fragment_) urls to client "#!/prop" urls $result = []; $result['url'] = $clientUrl; $result['ticket'] = $model->getAttributes(); $tags = Ticket::getTicketTags($model->id); $result['tags'] = $tags ? HelperData::group(Ticket::getTicketTags($model->id), ['typeCode', 'typeName', 'internalTypeId']) : []; if (($result['images'] = Ticket::getTicketImages($model->id))) { foreach ($result['images'] as &$img) { $img['thumbnailUrl'] = ThumbGenerator::getThumbnailUrl($img['filenameFs'], 96, 72, ThumbGenerator::METHOD_INNER); $img['imageUrl'] = ThumbGenerator::getThumbnailUrl($img['filenameFs'], 800, 600, ThumbGenerator::METHOD_INNER); } } $this->layout = false; return $this->render('view.php', $result); } }