Example #1
0
 /**
  * @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;
 }
 /**
  * @Route("/", methods="GET")
  * @Request({"filter": "array", "post":"int", "page":"int", "limit":"int"})
  */
 public function indexAction($filter = [], $post = 0, $page = 0, $limit = 0)
 {
     $query = Comment::query();
     $filter = array_merge(array_fill_keys(['status', 'search', 'order'], ''), $filter);
     extract($filter, EXTR_SKIP);
     if ($post) {
         $query->where(['post_id = ?'], [$post]);
     } elseif (!$this->user->hasAccess('blog: manage comments')) {
         App::abort(403, __('Insufficient user rights.'));
     }
     if (!$this->user->hasAccess('blog: manage comments')) {
         $query->where(['status = ?'], [Comment::STATUS_APPROVED]);
         if ($this->user->isAuthenticated()) {
             $query->orWhere(function ($query) {
                 $query->where(['status = ?', 'user_id = ?'], [Comment::STATUS_PENDING, App::user()->id]);
             });
         }
     } elseif (is_numeric($status)) {
         $query->where(['status = ?'], [(int) $status]);
     } else {
         $query->where(function ($query) {
             $query->orWhere(['status = ?', 'status = ?'], [Comment::STATUS_APPROVED, Comment::STATUS_PENDING]);
         });
     }
     if ($search) {
         $query->where(function ($query) use($search) {
             $query->orWhere(['author LIKE ?', 'email LIKE ?', 'url LIKE ?', 'ip LIKE ?', 'content LIKE ?'], array_fill(0, 5, "%{$search}%"));
         });
     }
     $count = $query->count();
     $pages = ceil($count / ($limit ?: PHP_INT_MAX));
     $page = max(0, min($pages - 1, $page));
     if ($limit) {
         $query->offset($page * $limit)->limit($limit);
     }
     if (preg_match('/^(created)\\s(asc|desc)$/i', $order, $match)) {
         $order = $match;
     } else {
         $order = [1 => 'created', 2 => App::module('blog')->config('comments.order')];
     }
     $comments = $query->related(['post' => function ($query) {
         return $query->related('comments');
     }])->related('user')->orderBy($order[1], $order[2])->get();
     $posts = [];
     foreach ($comments as $i => $comment) {
         $p = $comment->post;
         if ($post && (!$p || !$p->hasAccess($this->user) || !($p->isPublished() || $this->user->hasAccess('blog: manage comments')))) {
             App::abort(403, __('Post not found.'));
         }
         $comment->content = App::content()->applyPlugins($comment->content, ['comment' => true]);
         $posts[$p->id] = $p;
         $comment->special = count(array_diff($comment->user ? $comment->user->roles : [], [0, 1, 2]));
         $comment->post = null;
         $comment->user = null;
     }
     $comments = array_values($comments);
     $posts = array_values($posts);
     return compact('comments', 'posts', 'pages', 'count');
 }
Example #3
0
 public function getThankyou()
 {
     if ($this->form->get('afterSubmit') == 'thankyou') {
         $thankyou = (new MailHelper($this))->replaceString($this->form->get('thankyou'));
         return App::content()->applyPlugins($thankyou, ['submission' => $this, 'markdown' => $this->form->get('thankyou_markdown')]);
     }
     return '';
 }
Example #4
0
 public function indexAction($id = 0)
 {
     if (!($page = Page::find($id))) {
         App::abort(404, __('Page not found.'));
     }
     $page->content = App::content()->applyPlugins($page->content, ['page' => $page, 'markdown' => $page->get('markdown')]);
     return ['$view' => ['title' => $page->title, 'name' => 'system/site/page.php'], 'page' => $page, 'node' => App::node()];
 }
 /**
  * @Route("/{id}", name="id")
  */
 public function projectAction($id = 0)
 {
     if (!($project = Project::where(['id = ?', 'date < ?'], [$id, new \DateTime()])->first())) {
         App::abort(404, __('Project not found.'));
     }
     $project->intro = App::content()->applyPlugins($project->intro, ['project' => $project, 'markdown' => $project->get('markdown')]);
     $project->content = App::content()->applyPlugins($project->content, ['project' => $project, 'markdown' => $project->get('markdown')]);
     $previous = Project::getPrevious($project);
     $next = Project::getNext($project);
     return ['$view' => ['title' => __($project->title), 'name' => 'bixie/portfolio/project.php'], 'portfolio' => $this->portfolio, 'config' => $this->portfolio->config(), 'previous' => $previous, 'next' => $next, 'project' => $project];
 }
 /**
  * @Route("/{id}", name="id")
  */
 public function postAction($id = 0)
 {
     if (!($post = Post::where(['id = ?', 'status = ?', 'date < ?'], [$id, Post::STATUS_PUBLISHED, new \DateTime()])->related('user')->first())) {
         App::abort(404, __('Post not found!'));
     }
     if (!$post->hasAccess(App::user())) {
         App::abort(403, __('Insufficient User Rights.'));
     }
     $post->excerpt = App::content()->applyPlugins($post->excerpt, ['post' => $post, 'markdown' => $post->get('markdown')]);
     $post->content = App::content()->applyPlugins($post->content, ['post' => $post, 'markdown' => $post->get('markdown')]);
     $user = App::user();
     return ['$view' => ['title' => __($post->title), 'name' => 'blog/post.php'], '$comments' => ['config' => ['post' => $post->id, 'enabled' => $post->isCommentable(), 'requireinfo' => $this->blog->config('comments.require_email'), 'max_depth' => $this->blog->config('comments.max_depth')], 'user' => ['name' => $user->name, 'isAuthenticated' => $user->isAuthenticated(), 'canComment' => $user->hasAccess('blog: post comments'), 'skipApproval' => $user->hasAccess('blog: skip comment approval')]], 'blog' => $this->blog, 'post' => $post];
 }
 /**
  * @Route("/{id}", name="id")
  */
 public function postAction($id = 0)
 {
     if (!($post = Post::where(['id = ?', 'status = ?', 'date < ?'], [$id, Post::STATUS_PUBLISHED, new \DateTime()])->related('user')->first())) {
         App::abort(404, __('Post not found!'));
     }
     if (!$post->hasAccess(App::user())) {
         App::abort(403, __('Insufficient User Rights.'));
     }
     $post->excerpt = App::content()->applyPlugins($post->excerpt, ['post' => $post, 'markdown' => $post->get('markdown')]);
     $post->content = App::content()->applyPlugins($post->content, ['post' => $post, 'markdown' => $post->get('markdown')]);
     $user = App::user();
     $description = $post->get('meta.og:description');
     if (!$description) {
         $description = strip_tags($post->excerpt ?: $post->content);
         $description = rtrim(mb_substr($description, 0, 150), " \t\n\r\v.,") . '...';
     }
     return ['$view' => ['title' => __($post->title), 'name' => 'blog/post.php', 'og:type' => 'article', 'article:published_time' => $post->date->format(\DateTime::ATOM), 'article:modified_time' => $post->modified->format(\DateTime::ATOM), 'article:author' => $post->user->name, 'og:title' => $post->get('meta.og:title') ?: $post->title, 'og:description' => $description, 'og:image' => $post->get('image.src') ? App::url()->getStatic($post->get('image.src'), [], 0) : false], '$comments' => ['config' => ['post' => $post->id, 'enabled' => $post->isCommentable(), 'requireinfo' => $this->blog->config('comments.require_email'), 'max_depth' => $this->blog->config('comments.max_depth'), 'user' => ['name' => $user->name, 'isAuthenticated' => $user->isAuthenticated(), 'canComment' => $user->hasAccess('blog: post comments'), 'skipApproval' => $user->hasAccess('blog: skip comment approval')]]], 'blog' => $this->blog, 'post' => $post];
 }
 /**
  * @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;
 }
 /**
  * @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()];
 }
Example #10
0
<?php

use Pagekit\Application as App;
return ['id' => 'htmlcode', 'label' => __('Html code'), 'hasOptions' => 0, 'required' => 0, 'multiple' => 0, 'dependancies' => ['editor'], 'prepareValue' => function ($field, $value) {
    return App::content()->applyPlugins($value, ['field' => $field, 'markdown' => $field->get('markdown')]);
}];