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


PHP blogPostModel::prepareView方法代码示例

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


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

示例1: execute

 public function execute()
 {
     $blog_id = wa()->getRequest()->param('blog_url_type');
     if ($blog_id <= 0) {
         $blog_id = waRequest::request('blog_id', 0, 'int');
     }
     $this->setLayout(new blogFrontendLayout());
     // Get contact id and name as post author
     if (wa()->getUser()->get('is_user')) {
         $post_contact_id = wa()->getUser()->getId();
         $post_contact_name = wa()->getUser()->getName();
     } else {
         foreach (blogHelper::getAuthors($blog_id) as $post_contact_id => $post_contact_name) {
             break;
         }
     }
     // Prepare empty fake post data
     $post_model = new blogPostModel();
     $post = $post_model->prepareView(array(array('id' => 0, 'blog_id' => $blog_id, 'contact_id' => $post_contact_id, 'contact_name' => $post_contact_name, 'datetime' => date('Y-m-d H:i:s'), 'title' => '%replace-with-real-post-title%', 'status' => 'published', 'text' => '<div class="replace-with-real-post-text"></div>' . $this->getScripts(), 'comments_allowed' => 0) + $post_model->getEmptyRow()));
     $post = array_merge($post[0], array('comments' => array(), 'comment_link' => '', 'link' => ''));
     $this->getResponse()->setTitle(_w('Preview'));
     $this->getResponse()->setMeta('keywords', '');
     $this->getResponse()->setMeta('description', '');
     $current_auth = wa()->getStorage()->read('auth_user_data');
     $current_auth_source = $current_auth ? $current_auth['source'] : null;
     $this->view->assign(array('realtime_preview' => true, 'frontend_post' => array(), 'errors' => array(), 'form' => array(), 'show_comments' => false, 'request_captcha' => false, 'require_authorization' => false, 'theme' => waRequest::param('theme', 'default'), 'current_auth_source' => $current_auth_source, 'current_auth' => $current_auth, true, 'auth_adapters' => wa()->getAuthAdapters(), 'post' => $post));
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:27,代码来源:blogFrontendPreviewTemplate.action.php

示例2: execute

 public function execute()
 {
     $this->post_id = max(0, $this->getRequest()->get('id', 0, waRequest::TYPE_INT));
     $this->parent_id = max(0, $this->getRequest()->post('parent', 0, waRequest::TYPE_INT));
     $comment_model = new blogCommentModel();
     $post_model = new blogPostModel();
     /**
      *
      * Parent comment data
      * @var array
      */
     $parent = null;
     $stream = false;
     //find comment parent
     if ($this->parent_id && ($parent = $comment_model->getById($this->parent_id))) {
         if ($this->post_id && $this->post_id != $parent['post_id']) {
             throw new waRightsException(_w('Access denied'));
         }
         if (!$this->post_id) {
             $stream = true;
         }
         $this->post_id = $parent['post_id'];
     } else {
         $this->parent_id = 0;
     }
     //find post
     if (!$this->post_id || !($post = $post_model->getBlogPost($this->post_id))) {
         throw new waException(_w('Post not found'), 404);
     }
     $contact_id = $this->getUser()->getId();
     #check rights
     $rights = blogHelper::checkRights($post['blog_id'], $contact_id, blogRightConfig::RIGHT_READ);
     //check comment mode
     if (!$post['comments_allowed']) {
         throw new waException(_w("Isn't allowed comment to this post"));
     }
     $comment = array('blog_id' => $post['blog_id'], 'post_id' => $this->post_id, 'contact_id' => $contact_id, 'text' => $this->getRequest()->post('text'), 'auth_provider' => blogCommentModel::AUTH_USER);
     $this->errors += $comment_model->validate($comment);
     if (count($this->errors) > 0) {
         return;
     }
     $id = $comment_model->add($comment, $this->parent_id);
     $this->logAction('comment_add', $id);
     $comment = $comment_model->getById($id);
     //$comment['new'] = false;
     $comment['parent'] = $this->parent_id;
     if ($stream) {
         $comment['parent_text'] = $parent ? $parent['text'] : null;
         $comment['parent_status'] = $parent ? $parent['status'] : null;
     } else {
         $count = $comment_model->getCount($post['blog_id'], $this->post_id);
         $this->response['count_str'] = $count . " " . _w('comment', 'comments', $count);
     }
     $comment['rights'] = $rights;
     $comment['post'] =& $post;
     $post['comments'] = $comment_model->prepareView(array($comment), array('photo_url_20'));
     blogHelper::extendRights($post['comments'], array(), $contact_id);
     if ($stream) {
         $posts = array($this->post_id => &$post);
         $blog_model = new blogBlogModel();
         $extend_data = array('blog' => $blog_model->search(array('id' => $this->post_id))->fetchSearchAll());
         $post_model->prepareView($posts, array('link' => true), $extend_data);
     } else {
         unset($comment['post']);
     }
     $view = wa()->getView();
     $view->assign('post', $post);
     $view->assign('contact_rights', $this->getUser()->getRights('contacts', 'backend'));
     $template = $view->fetch('templates/actions/post/include.comments.html');
     $this->getResponse()->addHeader('Content-type', 'application/json');
     $this->response['template'] = $template;
 }
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:72,代码来源:blogCommentsAdd.controller.php


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