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


PHP blogPostModel::validate方法代码示例

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


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

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

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

示例3: save

 private function save($post)
 {
     $options = array();
     if (waRequest::post('transliterate', null)) {
         $options['transliterate'] = true;
     }
     $this->validate_messages = $this->post_model->validate($post, $options);
     if ($this->validate_messages) {
         $this->errors = $this->validate_messages;
     } else {
         $post['text_before_cut'] = null;
         $post['cut_link_label'] = null;
         $template = '<!--[\\s]*?more[\\s]*?(text[\\s]*?=[\\s]*?[\'"]([\\s\\S]*?)[\'"])*[\\s]*?-->';
         $descriptor = preg_split("/{$template}/", $post['text'], 2, PREG_SPLIT_DELIM_CAPTURE);
         if ($descriptor) {
             if (count($descriptor) == 2) {
                 $post['text_before_cut'] = blogPost::closeTags($descriptor[0]);
             } elseif (count($descriptor) > 2) {
                 $post['text_before_cut'] = blogPost::closeTags($descriptor[0]);
                 if (isset($descriptor[2])) {
                     $post['cut_link_label'] = $descriptor[2];
                 }
             }
         }
         if ($post['id']) {
             $prev_post = $this->post_model->getFieldsById($post['id'], 'status');
             if ($prev_post['status'] != blogPostModel::STATUS_PUBLISHED && $post['status'] == blogPostModel::STATUS_PUBLISHED) {
                 $this->inline = false;
             }
             $this->post_model->updateItem($post['id'], $post);
             if ($prev_post['status'] != blogPostModel::STATUS_PUBLISHED && $post['status'] == blogPostModel::STATUS_PUBLISHED) {
                 $this->log('post_publish', 1);
             } else {
                 $this->log('post_edit', 1);
             }
         } else {
             $post['id'] = $this->post_model->updateItem(null, $post);
             $this->log('post_publish', 1);
         }
         $this->saveParams($post['id']);
         $this->clearViewCache($post['id'], $post['url']);
         if (!$this->inline) {
             if ($post['status'] != blogPostModel::STATUS_PUBLISHED) {
                 $params = array('module' => 'post', 'action' => 'edit', 'id' => $post['id']);
             } elseif ($post['blog_status'] == blogBlogModel::STATUS_PUBLIC) {
                 $params = array('blog' => $post['blog_id']);
             } else {
                 $params = array('module' => 'post', 'id' => $post['id']);
             }
             $this->response['redirect'] = $this->getRedirectUrl($params);
         } else {
             $this->response['formatted_datetime'] = waDateTime::format('humandatetime', $post['datetime']);
             $this->response['id'] = $post['id'];
             $this->response['url'] = $post['url'];
             if ($post['status'] != blogPostModel::STATUS_PUBLISHED) {
                 $options = array('contact_id' => $post['contact_id'], 'blog_id' => $post['blog_id'], 'post_id' => $post['id'], 'user_id' => wa()->getUser()->getId());
                 $preview_hash = blogPostModel::getPreviewHash($options);
                 $this->response['preview_hash'] = base64_encode($preview_hash . $options['user_id']);
                 $this->response['debug'] = $options;
             }
         }
     }
 }
开发者ID:navi8602,项目名称:wa-shop-ppg,代码行数:63,代码来源:blogPostSave.controller.php


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