本文整理汇总了PHP中Pagekit\Application::view方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::view方法的具体用法?PHP Application::view怎么用?PHP Application::view使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pagekit\Application
的用法示例。
在下文中一共展示了Application::view方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendMail
/**
* @return MailHelper
*/
public function sendMail()
{
if (!($adminMail = $this->submission->form->get('submitEmail'))) {
return $this;
}
$user_email = $this->submission->email ?: false;
$mailSubject = $this->replaceString($this->submission->form->get('email_subject'));
$mailBody = $this->replaceString($this->submission->form->get('email_body'));
$mailBody = App::content()->applyPlugins($mailBody, ['submission' => $this->submission, 'markdown' => $this->submission->form->get('email_body_markdown')]);
try {
/** @var Message $mail */
$mail = App::mailer()->create();
if ($user_email && $this->submission->form->get('use_replyto', 0)) {
$mail->setReplyTo($user_email);
}
$mail->setTo($adminMail)->setSubject($mailSubject)->setBody(App::view('bixie/formmaker/mails/template.php', compact('mailBody')), 'text/html')->send();
if ($user_email) {
$mail = App::mailer()->create();
$mail->setTo($user_email)->setSubject($mailSubject)->setBody(App::view('bixie/formmaker/mails/template.php', compact('mailBody')), 'text/html')->send();
}
} catch (\Exception $e) {
throw new Exception(__('Unable to send confirmation mail.'));
}
return $this;
}
示例2: 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());
}
}
示例3: onOrderitem
/**
* cartItem displayed to user/admin
* @param Event $event
* @param Order $order
* @param CartItem $cartItem
*/
public function onOrderitem(Event $event, Order $order, CartItem $cartItem)
{
if ($cartItem->item_model == 'Bixie\\Download\\Model\\File') {
/** @var File $file */
$file = $cartItem->loadItemModel();
$orderValid = $this->validateOrder($order, $cartItem, $file);
$event->addParameters(['bixie.cart.admin.order' => App::view('bixie/download/templates/file_admin.php', compact('order', 'cartItem', 'file', 'orderValid')), 'bixie.cart.order_item' => App::view('bixie/download/templates/file_cart_order_item.php', compact('order', 'cartItem', 'file', 'orderValid'))]);
}
}
示例4: showAction
/**
* Converts an Exception to a Response.
*
* @param Request $request
* @param FlattenException $exception
* @return Response
*/
public function showAction(Request $request, FlattenException $exception)
{
if (is_subclass_of($exception->getClass(), 'Pagekit\\Kernel\\Exception\\HttpException')) {
$title = $exception->getMessage();
} else {
$title = __('Whoops, looks like something went wrong.');
}
$content = $this->getAndCleanOutputBuffering($request->headers->get('X-Php-Ob-Level', -1));
$response = App::view('system/error.php', compact('title', 'exception', 'content'));
return App::response($response, $exception->getCode(), $exception->getHeaders());
}
示例5: onRequest
/**
* Puts the page in maintenance mode.
*/
public function onRequest($event, $request)
{
if (!$event->isMasterRequest()) {
return;
}
$site = App::module('system/site');
if ($site->config('maintenance.enabled') && !(App::isAdmin() || $request->attributes->get('_maintenance') || App::user()->hasAccess('site: maintenance access'))) {
$message = $site->config('maintenance.msg') ?: __("We'll be back soon.");
$response = App::view('system/theme:views/maintenance.php', compact('message'));
$request->attributes->set('_disable_debugbar', true);
$types = $request->getAcceptableContentTypes();
if ('json' == $request->getFormat(array_shift($types))) {
$response = App::response()->json($message, 503);
} else {
$response = App::response($response, 503);
}
$event->setResponse($response);
}
}
示例6: formAction
/**
* @Route("/{id}", name="form/front")
*/
public function formAction($id = 0)
{
$user = App::user();
if (!($form = Form::where(['id = ?'], [$id])->where(function ($query) use($user) {
if (!$user->isAdministrator()) {
$query->where('status = 1');
}
})->related('fields')->first())) {
App::abort(404, __('Form not found!'));
}
if (!App::node()->hasAccess(App::user())) {
App::abort(403, __('Insufficient User Rights.'));
}
if ($form->get('recaptcha')) {
App::view()->on('footer', function ($event) {
$event->addResult('<script src="https://www.google.com/recaptcha/api.js?onload=grecacapthaCallback&render=explicit" async defer></script>');
});
}
return ['$view' => ['title' => __($form->title), 'name' => 'formmaker:views/form.php'], '$data' => ['config' => App::module('formmaker')->publicConfig(), 'formitem' => $form, 'fields' => array_values($form->fields)]];
}
示例7: sendMail
/**
* @return string
*/
public function sendMail()
{
if (!($adminMail = $this->submission->form->get('submitEmail'))) {
return '';
}
$userMail = '';
$mailSubject = $this->replaceString($this->submission->form->get('email_subject'));
$mailBody = $this->replaceString($this->submission->form->get('email_body'));
$mailBody = App::content()->applyPlugins($mailBody, ['submission' => $this->submission, 'markdown' => $this->submission->form->get('email_body_markdown')]);
try {
$mail = App::mailer()->create();
$mail->setTo($adminMail)->setSubject($mailSubject)->setBody(App::view('formmaker:views/mails/template.php', compact('mailBody')), 'text/html')->send();
if ($this->submission->email) {
$mail = App::mailer()->create();
$mail->setTo($this->submission->email)->setSubject($mailSubject)->setBody(App::view('formmaker:views/mails/template.php', compact('mailBody')), 'text/html')->send();
}
} catch (\Exception $e) {
throw new Exception(__('Unable to send confirmation mail.'));
}
return $userMail;
}
示例8: onRequest
/**
* Puts the page in maintenance mode.
*/
public function onRequest($event, $request)
{
if (!$event->isMasterRequest()) {
return;
}
$site = App::module('system/site');
if ($site->config('maintenance.enabled') && !(App::isAdmin() || $request->attributes->get('_maintenance') || App::user()->hasAccess('site: maintenance access') || App::user()->hasAccess('system: access admin area'))) {
$message = $site->config('maintenance.msg') ?: __("We'll be back soon.");
$logo = $site->config('maintenance.logo') ?: 'app/system/assets/images/pagekit-logo-large-black.svg';
$response = App::view('system/theme:views/maintenance.php', compact('message', 'logo'));
$request->attributes->set('_disable_debugbar', true);
$types = $request->getAcceptableContentTypes();
if (!App::user()->isAuthenticated() && $request->isXMLHttpRequest()) {
App::abort('401', 'Unauthorized');
} elseif ('json' == $request->getFormat(array_shift($types))) {
$response = App::response()->json($message, 503);
} else {
$response = App::response($response, 503);
}
$event->setResponse($response);
}
}
示例9: sendApproveMail
protected function sendApproveMail($user)
{
try {
$mail = App::mailer()->create();
$mail->setTo(App::module('mail')->config('from_address'))->setSubject(__('Approve an account at %site%.', ['%site%' => App::module('system/site')->config('title')]))->setBody(App::view('system/user:mails/approve.php', compact('user', 'mail')), 'text/html')->send();
} catch (\Exception $e) {
}
}
示例10: fileAction
/**
* @Route("/{id}", name="id")
* @Request({"id":"int", "category_id":"int"})
*/
public function fileAction($id = 0, $category_id = 0)
{
/** @var File $file */
if (!($file = File::where(['id = ?', 'status = ?'], [$id, '1'])->where(function ($query) {
return $query->where('roles IS NULL')->whereInSet('roles', App::user()->roles, false, 'OR');
})->first())) {
App::abort(404, __('File not found.'));
}
$file->setActiveCategory($category_id);
App::trigger('bixie.prepare.file', [$file, App::view()]);
$file->content = App::content()->applyPlugins($file->content, ['file' => $file, 'markdown' => $file->get('markdown')]);
$previous = File::getPrevious($file);
$next = File::getNext($file);
/** @var Category $category */
if ($category_id && !($category = Category::where(['id = ?', 'status = ?'], [$category_id, '1'])->where(function ($query) {
return $query->where('roles IS NULL')->whereInSet('roles', App::user()->roles, false, 'OR');
})->related('files')->first())) {
App::abort(404, __('Category not found.'));
}
if ($breadcrumbs = App::module('bixie/breadcrumbs')) {
if ($category_id) {
$cat = $category;
$crumbs = [['title' => $category->title, 'url' => $category->getUrl()]];
while ($parent_id = $cat->parent_id) {
if ($cat = $cat->find($parent_id, true)) {
$crumbs[] = ['title' => $cat->title, 'url' => $cat->getUrl()];
}
}
foreach (array_reverse($crumbs) as $data) {
$breadcrumbs->addUrl($data);
}
}
//add file
$breadcrumbs->addUrl(['title' => $file->title, 'url' => $file->getUrl()]);
}
return ['$view' => ['title' => __($file->title), 'name' => 'bixie/download/file.php'], 'download' => $this->download, 'config' => $this->download->config(), 'previous' => $previous, 'next' => $next, 'file' => $file, 'node' => App::node()];
}