public function getDetailUrl($contextNavItemId = null) { if ($contextNavItemId) { return \cms\helpers\Url::toMenuItem($contextNavItemId, 'gallery/album/index', ['albumId' => $this->id, 'title' => \yii\helpers\Inflector::slug($this->title)]); } return \luya\helpers\Url::toManager('gallery/album/index', ['albumId' => $this->id, 'title' => \yii\helpers\Inflector::slug($this->title)]); }
/** * @param $_GET['redirect'] should be urlencoded * @param $_POST['LoginForm'] data to login */ public function actionIndex($ref = null) { if (!empty($ref)) { Yii::$app->session->set('accountRef', $ref); } if (!$this->module->getUserIdentity()->isGuest) { if (Yii::$app->session->get('accountRef')) { $url = Yii::$app->session->get('accountRef'); Yii::$app->session->remove('accountRef'); } else { $url = Url::toManager('account/settings/index'); } $this->redirect($url); } $model = new LoginForm(); // see if values are sent via post if (Yii::$app->request->post('LoginForm')) { $model->attributes = Yii::$app->request->post('LoginForm'); if (($userObject = $model->login()) !== false) { if ($this->module->getUserIdentity()->login($userObject)) { $url = Yii::$app->session->get('accountRef'); if (!$url) { $url = Url::toManager('account/settings/index'); } else { Yii::$app->session->remove('accountRef'); } $this->redirect($url); } } } return $this->renderLayout('index', ['model' => $model]); }
public function getDetailUrl($contextNavItemId = null) { if ($contextNavItemId) { return \cms\helpers\Url::toMenuItem($contextNavItemId, 'news/default/detail', ['id' => $this->id, 'title' => \yii\helpers\Inflector::slug($this->title)]); } return \luya\helpers\Url::toManager('news/default/detail', ['id' => $this->id, 'title' => \yii\helpers\Inflector::slug($this->title)]); }
public function eventBeforeRender($event) { if ($this->value === 1) { if (Yii::$app->getModule('account')->getUserIdentity()->isGuest) { $event->isValid = false; Yii::$app->response->redirect(Url::toManager('account/default/index')); } } }
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 testHelperEquals() { Yii::$app->composition->hidden = true; $this->assertEquals(Url::to(['/admin/login/index']), Url::toManager('admin/login/index')); Yii::$app->composition->hidden = false; $this->assertEquals(Url::to(['/admin/login/index']), Url::toManager('admin/login/index')); Yii::$app->composition->hidden = true; $this->assertEquals(Url::to(['/admin/login/index'], true), Url::toManager('admin/login/index', [], true)); Yii::$app->composition->hidden = false; $this->assertEquals(Url::to(['/admin/login/index'], true), Url::toManager('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'])); }
public function testModuleContextUrls() { Yii::$app->urlManager->contextNavItemId = 1; $url = Url::toManager('news/default/detail', ['id' => 1, 'title' => 'foo-bar']); $this->assertEquals('/1/foo-bar', $url); Yii::$app->urlManager->contextNavItemId = 2; $url = Url::toManager('news/default/detail', ['id' => 1, 'title' => 'foo-bar']); $this->assertEquals('/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']); $this->assertEquals('/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']); $this->assertEquals('/1/page-2-news-title?news=page', $url); }
/** * @param $_GET['redirect'] should be urlencoded * @param $_POST['LoginForm'] data to login */ public function actionIndex() { if (!$this->module->getUserIdentity()->isGuest) { return $this->redirect(Url::toManager('account/settings/index')); } $model = new LoginForm(); // see if values are sent via post if (Yii::$app->request->post('LoginForm')) { $model->attributes = Yii::$app->request->post('LoginForm'); if (($userObject = $model->login()) !== false) { if ($this->module->getUserIdentity()->login($userObject)) { $redirect = Yii::$app->request->get('redirect', false); if (!$redirect) { $redirect = Url::toManager('account/settings/index'); } return $this->redirect($redirect); } } } return $this->render('index', ['model' => $model]); }
<h1>Hallo <?php echo $model->firstname; ?> <?php echo $model->lastname; ?> </h1> <p>Einloggt als <?php echo $model->email; ?> .</p> <a href="<?php echo \luya\helpers\Url::toManager('account/default/logout'); ?> ">Ausloggen</a>
<?php if ($save) { ?> <p><strong>Vielen Dank</strong>, Sie haben sich erfolgreich registiert. <a href="<?php echo \luya\helpers\Url::toManager('account/default/index'); ?> ">Hier gehts zum Login</a></p> <?php } else { ?> <h1>Einen neuen Account anelgen</h1> <?php if (!empty($errors)) { ?> <ul> <?php foreach ($errors as $field => $msgs) { ?> <li><?php echo $field; ?> : <?php print_r($msgs); ?> </li> <?php } ?> </ul> <?php
/** * Delivers the url for nice urls /file/id/hash/hello-world.jpg * * @return string */ public function getSource() { return Url::toManager('admin/file/download', ['id' => $this->getId(), 'hash' => $this->getHashName(), 'fileName' => $this->getName()]); }
/** * Helper method for convenience. * * @param string $route * @param array $params * * @return string */ public function url($route, array $params = []) { return Url::toManager($route, $params); }
<?php if ($this->context->isGuest()) { ?> <li><a href="<?php echo Url::toManager('account/default/index'); ?> ">Login</a></li> <li><a href="<?php echo Url::toManager('account/register/index'); ?> ">Registration</a></li> <li><a href="<?php echo Url::toManager('account/default/lostpass'); ?> ">Passwort verloren</a></li> <?php } else { ?> <li><a href="<?php echo Url::toManager('account/default/logout'); ?> ">Logout</a></li> <li><a href="<?php echo Url::toManager('account/settings/index'); ?> ">Settings</a></li> <?php } ?> </ul> </div>
<h1>Einloggen</h1> <?php $form = \yii\widgets\ActiveForm::begin(['id' => 'login-form', 'options' => ['class' => 'form-horizontal']]); echo $form->field($model, 'email'); echo $form->field($model, 'password')->passwordInput(); ?> <button type="submit">Submit</button> <?php \yii\widgets\ActiveForm::end(); ?> <ul> <li><a href="<?php echo \luya\helpers\Url::toManager('account/default/lostpass'); ?> ">Passwort vergessen Formular</a></li> <li><a href="<?php echo \luya\helpers\Url::toManager('account/register/index'); ?> ">Noch keinen Account? Jetzt registrieren.</a></li> </ul>
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); }
<div class="row"> <div class="col-md-12"> <a href="<?php echo \luya\helpers\Url::toManager('gallery/cat/index'); ?> "><i class="fa fa-fw fa-chevron-left"></i> Kategorieübersicht</a> <br /> <br /> </div> </div> <?php if (count($albenData) == 0) { ?> <div class="alert alert-info">Es wurden noch keine Bilder zu dieser Kategorie hinterlegt.</div> <?php } else { ?> <div class="albums"> <div class="row"> <?php foreach ($albenData as $item) { ?> <div class="album col-xs-12 col-sm-6 col-md-4"> <a class="album__link" href="<?php echo $item->getDetailUrl(); ?> "> <img class="album__image" src="<?php echo Yii::$app->storage->getImage($item->cover_image_id)->source; ?> " />
<div class="row" style="margin-bottom:40px;"> <div class="col-md-4"> <a href="<?php echo \luya\helpers\Url::toManager('gallery/alben/index', ['catId' => $item->id, 'title' => \yii\helpers\Inflector::slug($item->title)]); ?> "> <img class="img-responsive img-rounded" src="<?php echo Yii::$app->storage->getImage($item->cover_image_id)->source; ?> " /> </a> </div> <div class="col-md-8"> <h1><?php echo $item->title; ?> </h1> <p><?php echo $item->description; ?> </p> <a class="btn btn-default" href="<?php echo \luya\helpers\Url::toManager('gallery/alben/index', ['catId' => $item->id, 'title' => \yii\helpers\Inflector::slug($item->title)]); ?> ">Alben anzeigen</a> </div> </div> <?php }