public function getDetailUrl($contextNavItemId = null) { if ($contextNavItemId) { return \luya\helpers\Url::toModule($contextNavItemId, 'news/default/detail', ['id' => $this->id, 'title' => \yii\helpers\Inflector::slug($this->title)]); } return \luya\helpers\Url::to('news/default/detail', ['id' => $this->id, 'title' => \yii\helpers\Inflector::slug($this->title)]); }
public function getDetailUrl($contextNavItemId = null) { if ($contextNavItemId) { return \luya\helpers\Url::toModule($contextNavItemId, 'gallery/album/index', ['albumId' => $this->id, 'title' => \yii\helpers\Inflector::slug($this->title)]); } return \luya\helpers\Url::to('gallery/album/index', ['albumId' => $this->id, 'title' => \yii\helpers\Inflector::slug($this->title)]); }
public function testControllerMap() { Yii::$app->getModule('admin')->controllerMap = ['api-admin-user' => '\\admin\\apis\\UserController']; $rule = new \admin\components\UrlRule(); $this->assertEquals(true, is_array($rule->controller)); $this->assertArrayHasKey('admin/api-admin-user', $rule->controller); $this->assertEquals($rule->controller['admin/api-admin-user'], 'admin/api-admin-user'); $this->assertEquals(Url::to(['/admin/login/index']), Url::toManager('admin/login/index')); }
public function testHelperEqualsAbsoluteInternal() { Yii::$app->request->baseUrl = ''; Yii::$app->request->scriptUrl = ''; Yii::$app->composition->hidden = true; $this->assertEquals(Url::to(['/admin/login/index'], true), Url::toInternal(['admin/login/index'], true)); Yii::$app->composition->hidden = false; $this->assertEquals(Url::to(['/admin/login/index'], true), Url::toInternal(['admin/login/index'], true)); }
public function testBaseHelper() { $a = Url::toManager('urlmodule/bar/index'); $this->assertEquals($a, Url::to(['/urlmodule/bar/index'])); $this->assertEquals($a, Url::toRoute('/urlmodule/bar/index')); $b = Url::toManager('urlmodule/default/index'); $this->assertEquals($b, Url::to(['/urlmodule/default/index'])); $this->assertEquals($b, Url::toRoute('/urlmodule/default/index')); $c = Url::toManager('news/default/detail', ['id' => 1, 'title' => 'foo-bar']); $this->assertEquals($c, Url::to(['/news/default/detail', 'id' => 1, 'title' => 'foo-bar'])); $this->assertEquals($c, Url::toRoute(['/news/default/detail', 'id' => 1, 'title' => 'foo-bar'])); }
/** * @param $_GET['redirect'] should be urlencoded * @param $_POST['LoginForm'] data to login */ public function actionIndex() { if (!$this->module->getUserIdentity()->isGuest) { return $this->redirect(\luya\helpers\Url::to('account/settings/index')); } $model = new \account\models\LoginForm(); // see if values are sent via post if (isset($_POST['LoginForm'])) { $model->attributes = $_POST['LoginForm']; if (($userObject = $model->login()) !== false) { if ($this->module->getUserIdentity()->login($userObject)) { $redirect = \yii::$app->request->get('redirect', false); if (!$redirect) { $redirect = \luya\helpers\Url::to('account/settings/index'); } return $this->redirect($redirect); } } } return $this->render('index', ['model' => $model]); }
public function actionIndex() { $url = YiiUrl::to(Url::to('admin'), true); // redirect logged in users if (!Yii::$app->adminuser->isGuest) { return $this->redirect($url); } // get the login form model $model = new \admin\models\LoginForm(); // see if values are sent via post if (isset($_POST['login'])) { $model->attributes = $_POST['login']; if (($userObject = $model->login()) !== false) { if (Yii::$app->adminuser->login($userObject)) { return $this->redirect($url); } } } $this->view->registerJs("\$('#email').focus();"); return $this->render('index', ['model' => $model]); }
public function actionIndex() { $model = Yii::createObject(['class' => $this->module->registerFormClass]); if (!$model instanceof \account\RegisterInterface) { throw new Exception("Register form class must be instance of register interface."); } $state = false; if (Yii::$app->request->post()) { $model->load(Yii::$app->request->post()); if (($user = $model->register()) !== false) { $state = null; if ($this->module->registerConfirmEmail) { // send mail $hashKey = Yii::$app->security->generateRandomString(); $user->verification_hash = $hashKey; $user->update(false); $mail = $this->renderPartial('mail/_validationlink.php', ['hashKey' => $hashKey, 'user' => $user, 'link' => Url::to(['/account/register/activate', 'hash' => $hashKey], true)]); $state = 1; } if ($this->module->validateRegistration) { $mail = $this->renderPartial('mail/_waituntilvalidation.php', ['user' => $user]); // send mail to admin and user $user->update(false); $state = 2; } if ($state === null) { $mail = $this->renderPartial('mail/_login.php', ['user' => $user]); // the user is registered directly. $user->is_mail_verified = 1; $user->is_active = 1; $user->update(false); $state = 3; } Yii::$app->mail->compose('Registration', $mail)->address($user->email)->send(); } } return $this->renderLayout('index', ['model' => $model, 'state' => $state]); }
/** * Create an absolute link to a callback. * * This method is commonly used when returing data directly to the browser, there for the abolute url to a callback is required. Only logged in * users can view the callback url, but there is no other security about callbacks. * * @param string $callback The name of the callback without the callback prefix exmaple `createPdf` if the callback is `callbackCreatePdf()`. * @return string The absolute url to the callback. */ public function createCallbackUrl($callback) { return Url::to(['/admin/ngrest/callback', 'activeWindowCallback' => Inflector::camel2id($callback), 'ngrestConfigHash' => $this->getConfigHash(), 'activeWindowHash' => $this->getActiveWindowHash()], true); }
<ul> <li><a href="<?php echo \luya\helpers\Url::to('estore/default/basket'); ?> ">Basekt</a></li> </ul> estore header <ul> </ul> <hr /> <?php echo $content; ?> <hr /> estore footer <pre> <code> <?php print_r($this->context->getBasketTotal()); ?> </code> </pre>
<? foreach($catData as $item): ?> <div class="well"> <h1><?php echo $item->title; ?> </h1> <a href="<?php echo \luya\helpers\Url::to('gallery/alben/index', ['catId' => $item->id, 'title' => \yii\helpers\Inflector::slug($item->title)]); ?> ">Alben anzeigen</a> </div> <? endforeach; ?>
/** * Helper method for convenience. * * @param string $route * @param array $params * @return string */ public function url($route, array $params = []) { return Url::to($route, $params); }
public function testModuleContextOtherModuleAbsoluteUrls() { Yii::$app->request->baseUrl = ''; Yii::$app->request->scriptUrl = ''; Yii::$app->urlManager->contextNavItemId = 11; $this->assertEquals('http://localhost/en/admin/login', Url::toManager('admin/login/index', [], true)); $this->assertEquals('http://localhost/en/admin/login', Url::to(['/admin/login/index'], true)); $this->assertEquals('http://localhost/en/admin/login', Url::toRoute(['/admin/login/index'], true)); $this->assertEquals('http://localhost/en/admin/login', Url::toInternal(['/admin/login/index'], true)); Yii::$app->urlManager->contextNavItemId = 1; $url = Url::toManager('news/default/detail', ['id' => 1, 'title' => 'foo-bar'], true); $this->assertEquals('http://localhost/1/foo-bar', $url); Yii::$app->urlManager->contextNavItemId = 2; $url = Url::toManager('news/default/detail', ['id' => 1, 'title' => 'foo-bar'], true); $this->assertEquals('http://localhost/en/page-1/1/foo-bar', $url); Yii::$app->urlManager->contextNavItemId = 2; $url = Url::toManager('news/default/detail', ['id' => 1, 'title' => 'foo-bar', 'pa' => 'ram'], true); $this->assertEquals('http://localhost/en/page-1/1/foo-bar?pa=ram', $url); Yii::$app->urlManager->contextNavItemId = 1; $url = Url::toManager('news/default/detail', ['id' => 1, 'title' => 'page-2-news-title', 'news' => 'page'], true); $this->assertEquals('http://localhost/1/page-2-news-title?news=page', $url); }
public function testModuleUrls() { Yii::$app->urlManager->resetContext(); Yii::$app->composition->hidden = false; Yii::$app->getModule('news')->setContext('cms'); Yii::$app->getModule('news')->setContextOptions(['navItemId' => 1]); $url = Url::to('news/default/detail', ['id' => 1, 'title' => 'foo-bar']); $this->assertEquals("/de/page-1/1/foo-bar", $url); }
public function actionLogout() { Yii::$app->adminuser->logout(); $url = YiiUrl::to(Url::to('admin/login/index'), true); return $this->redirect($url); }