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


PHP blogPostModel类代码示例

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


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

示例1: execute

 public function execute()
 {
     if ($target_blog = max(0, $this->getRequest()->post('blog', 0, waRequest::TYPE_INT))) {
         $blog_model = new blogBlogModel();
         if ($blog = $blog_model->getById($target_blog)) {
             if ($ids = $this->getRequest()->post('id', null, waRequest::TYPE_ARRAY_INT)) {
                 $post_model = new blogPostModel();
                 $comment_model = new blogCommentModel();
                 $this->response['moved'] = array();
                 foreach ($ids as $id) {
                     try {
                         //rights will checked for each record separately
                         $post_model->updateItem($id, array('blog_id' => $target_blog));
                         $comment_model->updateByField('post_id', $id, array('blog_id' => $target_blog));
                         $this->response['moved'][$id] = $id;
                     } catch (Exception $ex) {
                         if (!isset($this->response['error'])) {
                             $this->response['error'] = array();
                         }
                         $this->response['error'][$id] = $ex->getMessage();
                     }
                 }
                 $this->response['style'] = $blog['color'];
                 $blog_model->recalculate();
             }
         } else {
         }
     }
 }
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:29,代码来源:blogPostMove.controller.php

示例2: defaultAction

 public function defaultAction()
 {
     // When viewed from a public dashboard, pretend we're logged in
     $old_user = $user = $this->getUser();
     if (wa()->getUser()->getId() != $user->getId()) {
         $old_user = wa()->getUser();
         wa()->setUser($user);
     }
     $blog_model = new blogBlogModel();
     $blogs = $blog_model->getAvailable(wa()->getUser());
     $blog_id = $this->getSettings('blog_id');
     if ($blog_id && !empty($blogs[$blog_id])) {
         $blog_ids = array($blog_id);
     } else {
         $blog_ids = array_keys($blogs);
     }
     $post_model = new blogPostModel();
     $posts = $post_model->search(array('blog_id' => $blog_ids), array('status' => 'view', 'author_link' => false, 'rights' => true, 'text' => 'cut'), array('blog' => $blogs))->fetchSearchPage(1, 1);
     wa()->setUser($old_user);
     $post = reset($posts);
     $blog = false;
     if ($post && !empty($blogs[$post['blog_id']])) {
         $blog = $blogs[$post['blog_id']];
     }
     $this->display(array('blog' => $blog, 'post' => $post));
 }
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:26,代码来源:blogPosts.widget.php

示例3: execute

 public function execute()
 {
     ob_start();
     $app = $this->getApp();
     $app_settings_model = new waAppSettingsModel();
     $app_settings_model->set($app, 'cron_schedule', time());
     waFiles::create($this->getConfig()->getPath('log') . '/' . $app . '/');
     $log_file = "{$app}/cron.txt";
     $post_model = new blogPostModel();
     $params = array('datetime' => date("Y-m-d H:i:s"), 'status' => blogPostModel::STATUS_SCHEDULED);
     $posts_schedule = $post_model->select("id,blog_id,contact_id,status,datetime")->where('datetime <= s:datetime AND status=s:status', $params)->fetchAll();
     if ($posts_schedule) {
         foreach ($posts_schedule as $post) {
             try {
                 waLog::log("Attempt publishing post with id [{$post['id']}]", $log_file);
                 $data = array("status" => blogPostModel::STATUS_PUBLISHED);
                 waLog::log($post_model->updateItem($post['id'], $data, $post) ? "success" : "fail", $log_file);
             } catch (Exception $ex) {
                 waLog::log($ex->getMessage(), $log_file);
                 waLog::log($ex->getTraceAsString(), $log_file);
             }
         }
     }
     $action = __FUNCTION__;
     /**
      * @event cron_action
      * @param string $action
      * @return void
      */
     wa()->event('cron_action', $action);
     if ($log = ob_get_clean()) {
         waLog::log($log, $log_file);
     }
 }
开发者ID:navi8602,项目名称:wa-shop-ppg,代码行数:34,代码来源:blogCronSchedule.cli.php

示例4: execute

 public function execute()
 {
     $data = waRequest::post();
     // check required params
     $this->post('blog_id', true);
     $this->post('title', true);
     $blog_model = new blogBlogModel();
     $blogs = $blog_model->getAvailable();
     if (!isset($blogs[$data['blog_id']])) {
         throw new waAPIException('invalid_param', 'Blog not found', 404);
     }
     $blog = $blogs[$data['blog_id']];
     if ($blog['rights'] < blogRightConfig::RIGHT_READ_WRITE) {
         throw new waAPIException('access_denied', 403);
     }
     $data = array_merge($data, array('blog_status' => $blog['status'], 'url' => '', 'text' => '', 'status' => blogPostModel::STATUS_PUBLISHED));
     $post_model = new blogPostModel();
     $options = array();
     if (waRequest::post('transliterate', null)) {
         $options['transliterate'] = true;
     }
     $messages = $post_model->validate($data, array('transliterate' => true));
     if ($messages) {
         throw new waAPIException('invalid_param', 'Validate messages: ' . implode("\n", $messages), 404);
     }
     $id = $post_model->updateItem(null, $data);
     $_GET['id'] = $id;
     $method = new blogPostGetInfoMethod();
     $this->response = $method->getResponse(true);
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:30,代码来源:blog.post.add.method.php

示例5: execute

 public function execute()
 {
     $this->getResponse()->addHeader('Content-type', 'application/json');
     if ($comment_id = $this->getRequest()->post('id', 0, waRequest::TYPE_INT)) {
         $comment_model = new blogCommentModel();
         $comment = $comment_model->getById($comment_id);
         if (!$comment) {
             throw new waException(_w('Comment not found'), 404);
         }
         $post_model = new blogPostModel();
         if (!($post = $post_model->getBlogPost(array('id' => $comment['post_id'], 'blog_id' => $comment['blog_id'])))) {
             throw new waException(_w('Post not found'), 404);
         }
         $user_id = $this->getUser()->getId();
         $rights = blogHelper::checkRights($comment['blog_id'], $user_id, blogRightConfig::RIGHT_READ_WRITE);
         if ($rights == blogRightConfig::RIGHT_READ_WRITE && $user_id != $post['contact_id']) {
             throw new waRightsException(_w('Access denied'), 403);
         }
         $status = $this->getRequest()->post('status', blogCommentModel::STATUS_DELETED);
         if ($status != blogCommentModel::STATUS_DELETED) {
             $status = blogCommentModel::STATUS_PUBLISHED;
         }
         $changed = $comment_model->updateById($comment_id, array('status' => $status));
         $count = $comment_model->getCount($comment['blog_id'], $comment['post_id']);
         if ($changed) {
             if ($status == blogCommentModel::STATUS_DELETED) {
                 $this->log('comment_delete', 1);
             } else {
                 $this->log('comment_restore', 1);
             }
         }
         $this->response = array('count_str' => $count . " " . _w('comment', 'comments', $count), 'status' => $status, 'changed' => $changed);
     }
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:34,代码来源:blogCommentsEdit.controller.php

示例6: execute

 public function execute()
 {
     $routes = $this->getRoutes();
     $app_id = wa()->getApp();
     $blog_model = new blogBlogModel();
     $post_model = new blogPostModel();
     $blogs = $blog_model->getAvailable(false, array('id', 'name', 'url'));
     foreach ($routes as $route) {
         $lastmod = null;
         $this->routing->setRoute($route);
         $default_blog_id = isset($route['blog_url_type']) ? (int) $route['blog_url_type'] : 0;
         $default_blog_id = max(0, $default_blog_id);
         $extend_options = array('datetime' => true);
         $extend_data = array('blog' => $blogs);
         foreach ($blogs as $blog_id => $blog) {
             if (!$default_blog_id || $blog_id == $default_blog_id) {
                 $search_options = array('blog_id' => $blog_id);
                 $posts = $post_model->search($search_options, $extend_options, $extend_data)->fetchSearchAll('id,title,url,datetime,blog_id');
                 foreach ($posts as $post) {
                     $post['blog_url'] = $blog['url'];
                     $post_lastmod = strtotime($post['datetime']);
                     $lastmod = max($lastmod, $post_lastmod);
                     if (!empty($post['comment_datetime'])) {
                         $post_lastmod = max($post_lastmod, strtotime($post['comment_datetime']));
                     }
                     $this->addUrl($post['link'], $post_lastmod);
                 }
             }
         }
         $this->addUrl(wa()->getRouteUrl($app_id . "/frontend", array(), true), $lastmod);
     }
 }
开发者ID:navi8602,项目名称:wa-shop-ppg,代码行数:32,代码来源:blogSitemapConfig.class.php

示例7: 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

示例8: execute

 public function execute()
 {
     $id = $this->get('id', true);
     $post_model = new blogPostModel();
     $post = $post_model->getById($id);
     if (!$post) {
         throw new waAPIException('invalid_param', 'Post not found', 404);
     }
     //check rights
     if (blogHelper::checkRights($post['blog_id']) < blogRightConfig::RIGHT_FULL && $post['contact_id'] != wa()->getUser()->getId()) {
         throw new waAPIException('access_denied', 403);
     }
     $data = array_merge($post, waRequest::post());
     $blog_model = new blogBlogModel();
     $blogs = $blog_model->getAvailable();
     if (!isset($blogs[$data['blog_id']])) {
         throw new waAPIException('invalid_param', 'Blog not found', 404);
     }
     $blog = $blogs[$data['blog_id']];
     $data['blog_status'] = $blog['status'];
     $data['datetime'] = $this->formateDatetime($data['datetime']);
     $messages = $post_model->validate($data, array('transliterate' => true));
     if ($messages) {
         throw new waAPIException('invalid_param', 'Validate messages: ' . implode("\n", $messages), 404);
     }
     $post_model->updateItem($data['id'], $data);
     $_GET['id'] = $id;
     $method = new blogPostGetInfoMethod();
     $this->response = $method->getResponse(true);
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:30,代码来源:blog.post.update.method.php

示例9: isInUse

 public function isInUse($value)
 {
     if ($this->subject == self::SUBJECT_BLOG) {
         $model = new blogBlogModel();
     } else {
         $model = new blogPostModel();
     }
     $cond = $this->options['id'] ? 'url = :url AND id != i:id' : 'url = :url';
     return $model->select('id')->where($cond, array('url' => $value, 'id' => $this->options['id']))->limit(1)->fetch();
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:10,代码来源:blogSlugValidator.class.php

示例10: updateMarkdownText

 public function updateMarkdownText($post)
 {
     $post_id = $post['id'];
     $text = null;
     if (isset($post['plugin']) && isset($post['plugin'][$this->id]) && $post['plugin'][$this->id]) {
         $text = trim($post['plugin'][$this->id]);
     }
     $post_model = new blogPostModel();
     $post_model->updateById($post_id, array('text_markdown' => $text));
 }
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:10,代码来源:blogMarkdown.plugin.php

示例11: move

 static function move($blog_id, $move_blog_id)
 {
     if ($blog_id != $move_blog_id) {
         $post_model = new blogPostModel();
         $post_model->updateByField('blog_id', $blog_id, array('blog_id' => $move_blog_id));
         $comment_model = new blogCommentModel();
         $comment_model->updateByField('blog_id', $blog_id, array('blog_id' => $move_blog_id));
         $blog_model = new blogBlogModel();
         $blog_model->recalculate(array($blog_id, $move_blog_id));
     }
 }
开发者ID:navi8602,项目名称:wa-shop-ppg,代码行数:11,代码来源:blogPost.class.php

示例12: execute

 public function execute()
 {
     $post_title = waRequest::post('post_title', '', waRequest::TYPE_STRING_TRIM);
     $blog_id = waRequest::post('blog_id', 0, waRequest::TYPE_INT);
     $slug = waRequest::post('slug', '', waRequest::TYPE_STRING_TRIM);
     $blog_model = new blogBlogModel();
     $blog = $blog_model->getById($blog_id);
     if (!$blog) {
         throw new waException(_w("Can't find corresponding blog"));
     }
     $this->response['is_private_blog'] = $blog['status'] == blogBlogModel::STATUS_PRIVATE;
     $post_id = waRequest::post('post_id', 0, waRequest::TYPE_INT);
     $post_model = new blogPostModel();
     if ($post_id) {
         $post = $post_model->getById($post_id, array('text', 'text_before_cut'));
         if (!$post) {
             throw new waException(_w("Can't find corresponding post"));
         }
         if ($post['status'] != blogPostModel::STATUS_PUBLISHED) {
             $options = array('contact_id' => $post['contact_id'], 'blog_id' => $blog_id, 'post_id' => $post['id'], 'user_id' => wa()->getUser()->getId());
             $this->response['preview_hash'] = blogPostModel::getPreviewHash($options);
             $this->response['preview_hash'] = base64_encode($this->response['preview_hash'] . $options['user_id']);
         }
         $this->response['slug'] = $post['url'];
         $this->response['is_published'] = $post['status'] == blogPostModel::STATUS_PUBLISHED;
         $this->response['is_adding'] = false;
     } else {
         $post = array();
         $this->response['slug'] = $slug ? $slug : blogHelper::transliterate($post_title);
         $this->response['is_published'] = false;
         $this->response['is_adding'] = true;
     }
     $post['blog_id'] = $blog_id;
     $post['album_link_type'] = 'blog';
     $other_links = blogPostModel::getPureUrls($post);
     $this->response['link'] = array_shift($other_links);
     if (!$this->response['link']) {
         $this->response['is_private_blog'] = true;
     }
     $this->response['other_links'] = $other_links;
     foreach ($this->response as $k => &$item) {
         if (!$item || !is_string($item) && !is_array($item)) {
             continue;
         }
         if (is_array($item)) {
             $item = array_map('htmlspecialchars', $item, array_fill(0, count($item), ENT_QUOTES));
             continue;
         }
         $item = htmlspecialchars($item, ENT_QUOTES);
     }
     unset($item);
     $this->getResponse()->addHeader('Content-type', 'application/json');
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:53,代码来源:blogPostGetPostUrl.controller.php

示例13: execute

 public function execute()
 {
     $post_id = max(0, waRequest::get('id', 0, waRequest::TYPE_INT));
     if (!$post_id) {
         throw new waException(_w('Post not found'), 404);
     }
     $post_model = new blogPostModel();
     $search_options = array('id' => $post_id);
     $extend_options = array('comments' => array(20), 'user' => array('photo_url_50'), 'status' => 'view');
     $post = $post_model->search($search_options, $extend_options)->fetchSearchItem();
     if (!$post) {
         throw new waException(_w('Post not found'), 404);
     }
     $post['rights'] = $this->getRights("blog.{$post['blog_id']}");
     $posts = array(&$post);
     blogHelper::extendRights($posts, array(), $this->getUser()->getId());
     blogPhotosBridge::loadAlbums($posts);
     if (isset($post['comments']) && $post['comments']) {
         $post['comments'] = blogCommentModel::extendRights($post['comments'], array($post_id => $post));
     }
     $blog_model = new blogBlogModel();
     $blog = $blog_model->getById($post['blog_id']);
     if ($blog['status'] != blogBlogModel::STATUS_PUBLIC || $post['status'] != blogPostModel::STATUS_PUBLISHED) {
         blogHelper::checkRights($post['blog_id'], true, blogRightConfig::RIGHT_READ);
     }
     $items = $blog_model->prepareView(array($blog));
     $blog = array_shift($items);
     $this->setLayout(new blogDefaultLayout());
     $this->getResponse()->setTitle($post['title']);
     /**
      * Backend post view page
      * UI hook allow extends post view page
      * @event backend_post
      * @param array[string]mixed $post Current page post item data
      * @param array[string]int $post['id'] Post ID
      * @param array[string]int $post['blog_id'] Post blog ID
      * @return array[string][string]string $backend_post['%plugin_id%']['footer'] Plugin %plugin_id% footer html
      */
     $this->view->assign('backend_post', wa()->event('backend_post', $post, array('footer')));
     $user = $this->getUser();
     $this->view->assign('current_contact', array('id' => $user->getId(), 'name' => $user->getName(), 'photo20' => $user->getPhoto(20)));
     $this->view->assign('blog_id', $blog['id']);
     $this->view->assign('blog', $blog);
     $this->view->assign('contact_rights', $this->getUser()->getRights('contacts', 'backend'));
     if ($this->getConfig()->getOption('can_use_smarty')) {
         try {
             $post['text'] = $this->view->fetch("string:{$post['text']}", $this->cache_id);
         } catch (SmartyException $ex) {
             $post['text'] = blogPost::handleTemplateException($ex, $post);
         }
     }
     $this->view->assign('post', $post);
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:53,代码来源:blogPost.action.php

示例14: verify

 private function verify()
 {
     $post_slug = waRequest::param('post_url', false, waRequest::TYPE_STRING);
     $post_model = new blogPostModel();
     $this->post = $post_model->getBySlug($post_slug);
     if (!$this->post || $this->post['status'] != blogPostModel::STATUS_PUBLISHED || !$this->post['comments_allowed']) {
         throw new waException(_w('Post not found'), 404);
     }
     if ($this->blog_id && !in_array($this->post['blog_id'], (array) $this->blog_id)) {
         throw new waException(_w('Post not found'), 404);
     }
 }
开发者ID:Favorskij,项目名称:webasyst-framework,代码行数:12,代码来源:blogFrontendComment.controller.php

示例15: execute

 public function execute()
 {
     if ($ids = $this->getRequest()->post('id', null, waRequest::TYPE_ARRAY_INT)) {
         $post_model = new blogPostModel();
         $blog_model = new blogBlogModel();
         $blogs = $blog_model->getAvailable($this->getUser(), 'id');
         $options = array('id' => $ids, 'blog_id' => array_keys($blogs));
         $this->response['deleted'] = $post_model->deleteByField($options);
         $this->logAction('post_delete', implode(',', $ids));
     } else {
         $this->errors[] = 'empty request';
     }
 }
开发者ID:cjmaximal,项目名称:webasyst-framework,代码行数:13,代码来源:blogPostDelete.controller.php


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