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


PHP post::get_schema_map方法代码示例

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


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

示例1: update

 /**
  * Updates an existing post in the posts table
  * @param bool $minor Indicates if this is a major or minor update
  * @return bool True on success
  */
 public function update($minor = true)
 {
     $this->modified = HabariDateTime::date_create();
     if (!$minor && $this->status != Post::status('draft')) {
         $this->updated = $this->modified;
     }
     if (isset($this->fields['guid'])) {
         unset($this->newfields['guid']);
     }
     if ($this->pubdate->int > HabariDateTime::date_create()->int && $this->status == Post::status('published')) {
         $this->status = Post::status('scheduled');
     }
     $allow = true;
     $allow = Plugins::filter('post_update_allow', $allow, $this);
     if (!$allow) {
         return false;
     }
     Plugins::act('post_update_before', $this);
     $this->newfields = Plugins::filter('post_update_change', $this->newfields, $this, $this->fields);
     // Call setslug() only when post slug is changed
     if (isset($this->newfields['slug'])) {
         if ($this->fields['slug'] != $this->newfields['slug']) {
             $this->setslug();
         }
     }
     // invoke plugins for all fields which have been changed
     // For example, a plugin action "post_update_status" would be
     // triggered if the post has a new status value
     foreach ($this->newfields as $fieldname => $value) {
         Plugins::act('post_update_' . $fieldname, $this, $this->fields[$fieldname], $value);
     }
     // invoke plugins for status changes
     if (isset($this->newfields['status']) && $this->fields['status'] != $this->newfields['status']) {
         Plugins::act('post_status_' . self::status_name($this->newfields['status']), $this, $this->fields['status']);
     }
     $result = parent::updateRecord('posts', array('id' => $this->id), post::get_schema_map());
     //scheduled post
     if ($this->fields['status'] == Post::status('scheduled') || $this->status == Post::status('scheduled')) {
         Posts::update_scheduled_posts_cronjob();
     }
     $this->fields = array_merge($this->fields, $this->newfields);
     $this->newfields = array();
     $this->save_tags();
     $this->info->commit();
     Plugins::act('post_update_after', $this);
     return $result;
 }
开发者ID:wwxgitcat,项目名称:habari,代码行数:52,代码来源:post.php

示例2: update

 /**
  * Updates an existing post in the posts table
  * @param bool $minor Indicates if this is a major or minor update
  * @return bool True on success
  */
 public function update($minor = true)
 {
     if ($this->id == 0) {
         return $this->insert() !== false;
     }
     $this->modified = DateTime::create();
     if (!$minor && $this->status != Post::status('draft')) {
         $this->updated = $this->modified;
     }
     if (isset($this->fields['guid'])) {
         unset($this->newfields['guid']);
     }
     // if the date is in the future and we are trying to publish the post, actually schedule it for posting later
     if ($this->pubdate > DateTime::create() && $this->status == Post::status('published')) {
         $this->status = Post::status('scheduled');
     } else {
         if ($this->pubdate <= DateTime::create() && $this->status == Post::status('scheduled')) {
             $this->status = Post::status('published');
         }
     }
     $allow = true;
     $allow = Plugins::filter('post_update_allow', $allow, $this);
     if (!$allow) {
         return false;
     }
     Plugins::act('post_update_before', $this);
     $this->newfields = Plugins::filter('post_update_change', $this->newfields, $this, $this->fields);
     // Call setslug() only when post slug is changed
     if (isset($this->newfields['slug'])) {
         if ($this->fields['slug'] != $this->newfields['slug']) {
             $this->setslug();
         }
     }
     // If content has changed, update cached_content with prerendered content
     if (isset($this->newfields['content']) && $this->fields['content'] != $this->newfields['content']) {
         $this->newfields['cached_content'] = Plugins::filter('post_prerender_content', $this->newfields['content'], $this);
     }
     // invoke plugins for all fields which have been changed
     // For example, a plugin action "post_update_status" would be
     // triggered if the post has a new status value
     $change_date = DateTime::create()->sql;
     foreach ($this->newfields as $fieldname => $value) {
         Plugins::act('post_update_' . $fieldname, $this, $this->fields[$fieldname], $value);
         if ($this->fields[$fieldname] != $value) {
             DB::insert('{revisions}', array('post_id' => $this->fields['id'], 'change_field' => $fieldname, 'old_value' => $this->fields[$fieldname], 'user_id' => User::identify()->id, 'change_date' => $change_date));
         }
     }
     // invoke plugins for status changes
     if (isset($this->newfields['status']) && $this->fields['status'] != $this->newfields['status']) {
         Plugins::act('post_status_' . self::status_name($this->newfields['status']), $this, $this->fields['status']);
     }
     $result = parent::updateRecord('posts', array('id' => $this->id), post::get_schema_map());
     //scheduled post
     if ($this->fields['status'] == Post::status('scheduled') || $this->status == Post::status('scheduled')) {
         Posts::update_scheduled_posts_cronjob();
     }
     $this->fields = array_merge($this->fields, $this->newfields);
     $this->newfields = array();
     $this->save_tags();
     $this->info->commit();
     Plugins::act('post_update_after', $this);
     return $result;
 }
开发者ID:habari,项目名称:system,代码行数:68,代码来源:post.php


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