当前位置: 首页>>代码示例>>PHP>>正文


PHP Application::url方法代码示例

本文整理汇总了PHP中Pagekit\Application::url方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::url方法的具体用法?PHP Application::url怎么用?PHP Application::url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pagekit\Application的用法示例。


在下文中一共展示了Application::url方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: authenticateAction

 /**
  * @Route(methods="POST", defaults={"_maintenance" = true})
  * @Request({"credentials": "array", "_remember_me": "boolean"})
  */
 public function authenticateAction($credentials, $remember = false)
 {
     $isXml = App::request()->isXmlHttpRequest();
     try {
         if (!App::csrf()->validate()) {
             throw new AuthException(__('Invalid token. Please try again.'));
         }
         App::auth()->authorize($user = App::auth()->authenticate($credentials, false));
         if (!$isXml) {
             return App::auth()->login($user, $remember);
         } else {
             App::auth()->setUser($user, $remember);
             return ['success' => true];
         }
     } catch (BadCredentialsException $e) {
         $error = __('Invalid username or password.');
     } catch (AuthException $e) {
         $error = $e->getMessage();
     }
     if (!$isXml) {
         App::message()->error($error);
         return App::redirect(App::url()->previous());
     } else {
         App::abort(400, $error);
     }
 }
开发者ID:aqnouch,项目名称:rimbo,代码行数:30,代码来源:AuthController.php

示例2: loginAction

 /**
  * @Route("/admin/login", defaults={"_maintenance"=true})
  */
 public function loginAction()
 {
     if (App::user()->isAuthenticated()) {
         return App::redirect('@system');
     }
     return ['$view' => ['title' => __('Login'), 'name' => 'system/theme:views/login.php', 'layout' => false], 'last_username' => App::session()->get(Auth::LAST_USERNAME), 'redirect' => App::request()->get('redirect') ?: App::url('@system', [], true), 'remember_me_param' => Auth::REMEMBER_ME_PARAM];
 }
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:10,代码来源:AdminController.php

示例3: requestAction

 /**
  * @Request({"email": "string"})
  */
 public function requestAction($email)
 {
     try {
         if (App::user()->isAuthenticated()) {
             return App::redirect();
         }
         if (!App::csrf()->validate()) {
             throw new Exception(__('Invalid token. Please try again.'));
         }
         if (empty($email)) {
             throw new Exception(__('Enter a valid email address.'));
         }
         if (!($user = User::findByEmail($email))) {
             throw new Exception(__('Unknown email address.'));
         }
         if ($user->isBlocked()) {
             throw new Exception(__('Your account has not been activated or is blocked.'));
         }
         $user->activation = App::get('auth.random')->generateString(32);
         $url = App::url('@user/resetpassword/confirm', ['user' => $user->username, 'key' => $user->activation], 0);
         try {
             $mail = App::mailer()->create();
             $mail->setTo($user->email)->setSubject(__('Reset password for %site%.', ['%site%' => App::module('system/site')->config('title')]))->setBody(App::view('system/user:mails/reset.php', compact('user', 'url', 'mail')), 'text/html')->send();
         } catch (\Exception $e) {
             throw new Exception(__('Unable to send confirmation link.'));
         }
         $user->save();
         return ['message' => __('Check your email for the confirmation link.')];
     } catch (Exception $e) {
         App::abort(400, $e->getMessage());
     }
 }
开发者ID:nstaeger,项目名称:pagekit,代码行数:35,代码来源:ResetPasswordController.php

示例4: uploadAction

 /**
  * @param FieldValueBase $fieldValue
  * @return array
  */
 public function uploadAction(FieldValueBase $fieldValue)
 {
     try {
         if (!($path = $this->getPath($fieldValue->field->get('path')))) {
             return $this->error(__('Invalid path.'));
         }
         if (!is_dir($path) || !App::user()->hasAccess('system: manage storage | bixframework: upload files')) {
             return $this->error(__('Permission denied.'));
         }
         $fileInfo = [];
         $files = App::request()->files->get('files');
         if (!$files) {
             return $this->error(__('No files uploaded.'));
         }
         /** @var UploadedFile $file */
         foreach ($files as $file) {
             if (!$file->isValid()) {
                 return $this->error(sprintf(__('Uploaded file invalid. (%s)'), $file->getErrorMessage()));
             }
             if (!($ext = $file->guessExtension()) or !in_array($ext, $fieldValue->field->get('allowed', []))) {
                 return $this->error(__('File extension not allowed.'));
             }
             if (!($size = $file->getClientSize()) or $size > $fieldValue->field->get('max_size', 0) * 1024 * 1024) {
                 return $this->error(__('File is too large.'));
             }
             //give file unique name
             $localFile = $file->move($path, sprintf('%d%d-%s', microtime(true) * 10000, rand(), preg_replace("/[^a-zA-Z0-9\\.]/", "-", $file->getClientOriginalName())));
             $fileInfo[] = ['name' => $file->getClientOriginalName(), 'size' => $localFile->getSize(), 'path' => str_replace(App::path(), '', $localFile->getPathname()), 'url' => ltrim(App::url()->getStatic($localFile->getPathname(), [], 'base'), '/')];
         }
         return ['message' => __('Upload complete.'), 'files' => $fileInfo];
     } catch (\Exception $e) {
         return $this->error(__('Unable to upload.'));
     }
 }
开发者ID:stroborobo,项目名称:pagekit-framework,代码行数:38,代码来源:UploadFieldType.php

示例5: indexAction

 /**
  * @Request({"path"})
  */
 public function indexAction($path)
 {
     if (!($dir = $this->getPath())) {
         return $this->error(__('Invalid path.'));
     }
     if (!is_dir($dir) || '-' === ($mode = $this->getMode($dir))) {
         throw new ForbiddenException(__('Permission denied.'));
     }
     $data = array_fill_keys(['items'], []);
     $data['mode'] = $mode;
     $finder = App::finder();
     $finder->sort(function ($a, $b) {
         return $b->getRealpath() > $a->getRealpath() ? -1 : 1;
     });
     foreach ($finder->depth(0)->in($dir) as $file) {
         if ('-' === ($mode = $this->getMode($file->getPathname()))) {
             continue;
         }
         $info = ['name' => $file->getFilename(), 'mime' => 'application/' . ($file->isDir() ? 'folder' : 'file'), 'path' => $this->normalizePath($path . '/' . $file->getFilename()), 'url' => ltrim(App::url()->getStatic($file->getPathname(), [], 'base'), '/'), 'writable' => $mode == 'w'];
         if (!$file->isDir()) {
             $info = array_merge($info, ['size' => $this->formatFileSize($file->getSize()), 'lastmodified' => date(\DateTime::ISO8601, $file->getMTime())]);
         }
         $data['items'][] = $info;
     }
     return $data;
 }
开发者ID:4nxiety,项目名称:pagekit,代码行数:29,代码来源:FinderController.php

示例6: getFormUrl

 public function getFormUrl()
 {
     if (!$this->id) {
         return '';
     }
     return App::url('@formmaker/form/front', ['id' => $this->id]);
 }
开发者ID:4nxiety,项目名称:pagekit-formmaker,代码行数:7,代码来源:Form.php

示例7: authenticateAction

 /**
  * @Route(methods="POST", defaults={"_maintenance" = true})
  * @Request({"credentials": "array", "remember_me": "boolean", "redirect": "string"})
  */
 public function authenticateAction($credentials, $remember = false, $redirect = '')
 {
     try {
         if (!App::csrf()->validate()) {
             throw new CsrfException(__('Invalid token. Please try again.'));
         }
         App::auth()->authorize($user = App::auth()->authenticate($credentials, false));
         if (($event = App::auth()->login($user, $remember)) && $event->hasResponse()) {
             return $event->getResponse();
         }
         if (App::request()->isXmlHttpRequest()) {
             return App::response()->json(['csrf' => App::csrf()->generate()]);
         } else {
             return App::redirect(preg_replace('#(https?:)?//[^/]+#', '', $redirect));
         }
     } catch (CsrfException $e) {
         if (App::request()->isXmlHttpRequest()) {
             return App::response()->json(['csrf' => App::csrf()->generate()], 401);
         }
         $error = $e->getMessage();
     } catch (BadCredentialsException $e) {
         $error = __('Invalid username or password.');
     } catch (AuthException $e) {
         $error = $e->getMessage();
     }
     if (App::request()->isXmlHttpRequest()) {
         App::abort(401, $error);
     } else {
         App::message()->error($error);
         return App::redirect(preg_replace('#(https?:)?//[^/]+#', '', App::url()->previous()));
     }
 }
开发者ID:nstaeger,项目名称:pagekit,代码行数:36,代码来源:AuthController.php

示例8: loginAction

 /**
  * @Route("/admin/login", defaults={"_maintenance"=true})
  * @Request({"redirect": "string", "message": "string"})
  */
 public function loginAction($redirect = '', $message = '')
 {
     if (App::user()->isAuthenticated()) {
         return App::redirect('@system');
     }
     return ['$view' => ['title' => __('Login'), 'name' => 'system/theme:views/login.php', 'layout' => false], 'last_username' => App::session()->get(Auth::LAST_USERNAME), 'redirect' => $redirect ?: App::url('@system'), 'message' => $message];
 }
开发者ID:pagekit,项目名称:pagekit,代码行数:11,代码来源:AdminController.php

示例9: indexAction

 public function indexAction()
 {
     $user = App::user();
     if (!$user->isAuthenticated()) {
         return App::redirect('@user/login', ['redirect' => App::url()->current()]);
     }
     return ['$view' => ['title' => __('Your Profile'), 'name' => 'system/user/profile.php'], '$data' => ['user' => ['name' => $user->name, 'email' => $user->email]]];
 }
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:8,代码来源:ProfileController.php

示例10: getUrl

 /**
  * @param int        $category_id
  * @param bool|false $base
  * @return string|bool
  */
 public function getUrl($category_id = 0, $base = false)
 {
     $category_id = $category_id ?: $this->get('primary_category', 0);
     if (!$category_id || App::config('bixie/download')->get('routing') == 'item') {
         return App::url('@download/id', ['id' => $this->id ?: 0], $base);
     } else {
         return App::url('@download/category/file/' . $category_id, ['id' => $this->id ?: 0], $base);
     }
 }
开发者ID:Bixie,项目名称:pagekit-download,代码行数:14,代码来源:File.php

示例11: onResponse

 /**
  * Filter the response content.
  */
 public function onResponse($event, $request, $response)
 {
     if (!is_string($content = $response->getContent())) {
         return;
     }
     $response->setContent(preg_replace_callback(self::REGEX_URL, function ($matches) {
         return sprintf(' %s="%s"', $matches['attr'], App::url($matches['url']));
     }, $content));
 }
开发者ID:rifal89,项目名称:pagekit,代码行数:12,代码来源:ResponseListener.php

示例12: indexAction

 public function indexAction()
 {
     $user = App::user();
     $userprofile = App::module('bixie/userprofile');
     if (!$user->isAuthenticated()) {
         return App::redirect('@user/login', ['redirect' => App::url()->current()]);
     }
     return ['$view' => ['title' => __('Your Profile'), 'name' => 'bixie/userprofile/profile.php'], '$data' => ['config' => $userprofile->config('default'), 'fields' => Field::getProfileFields(), 'profilevalues' => Profilevalue::getUserProfilevalues($user), 'user' => ['id' => $user->id, 'username' => $user->username, 'name' => $user->name, 'email' => $user->email]]];
 }
开发者ID:4nxiety,项目名称:pagekit-userprofile,代码行数:9,代码来源:ProfileController.php

示例13: indexAction

 /**
  * main profile edit page
  * @Route("/", methods="GET")
  */
 public function indexAction()
 {
     $user = App::user();
     $userprofile = App::module('bixie/userprofile');
     if (!$user->isAuthenticated()) {
         return App::redirect('@user/login', ['redirect' => App::url()->current()]);
     }
     $profileUser = ProfileUser::load($user);
     return ['$view' => ['title' => __('Your Profile'), 'name' => 'bixie/userprofile/profile-edit.php'], '$data' => ['config' => $userprofile->config(), 'user' => ['id' => $user->id, 'username' => $user->username, 'name' => $user->name, 'email' => $user->email]], 'profileUser' => $profileUser];
 }
开发者ID:Bixie,项目名称:pagekit-userprofile,代码行数:14,代码来源:ProfileController.php

示例14: viewAction

 /**
  * @Route("/{id}", name="view", requirements={"id"="\d+"})
  */
 public function viewAction($id)
 {
     $artist = Artist::query()->where('id = ?', [$id])->related('album')->first();
     $request = App::request();
     if (is_null($artist)) {
         $request->getSession()->getFlashBag()->add('error', __('Tried to view an non-existing Artist'));
         return App::response()->redirect('@shoutzor/artist/index');
     }
     $topTracks = $artist->getTopMedia();
     return ['$view' => ['title' => 'Artist: ' . $artist->name, 'name' => 'shoutzor:views/artist/view.php'], 'image' => is_null($artist->image) || empty($artist->image) ? App::url()->getStatic('shoutzor:assets/images/profile-placeholder.png') : App::url()->getStatic('shoutzor:' . App::module('shoutzor')->config('shoutzor')['imageDir'] . '/' . $artist->image), 'summary' => empty($artist->summary) ? __('No summary for this artist is available') : $artist->summary, 'artist' => $artist, 'topTracks' => $topTracks, 'albums' => $artist->getAlbums()];
 }
开发者ID:xorinzor,项目名称:Shoutzor,代码行数:14,代码来源:ArtistController.php

示例15: authenticateAction

 /**
  * @Route(methods="POST", defaults={"_maintenance" = true})
  * @Request({"credentials": "array"})
  */
 public function authenticateAction($credentials)
 {
     try {
         if (!App::csrf()->validate()) {
             throw new AuthException(__('Invalid token. Please try again.'));
         }
         App::auth()->authorize($user = App::auth()->authenticate($credentials, false));
         return App::auth()->login($user, App::request()->get(Auth::REMEMBER_ME_PARAM));
     } catch (BadCredentialsException $e) {
         App::message()->error(__('Invalid username or password.'));
     } catch (AuthException $e) {
         App::message()->error($e->getMessage());
     }
     return App::redirect(App::url()->previous());
 }
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:19,代码来源:AuthController.php


注:本文中的Pagekit\Application::url方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。