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


PHP date::unix2sql方法代码示例

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


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

示例1: _entry_edit

 /**
  * Edit entry
  *
  * @param  integer|string  $entry_id
  */
 public function _entry_edit($entry_id = false)
 {
     $this->history = false;
     $entry = new Blog_Entry_Model((int) $entry_id);
     // For authenticated users only
     if (!$this->user || !$entry->is_author() && !$this->visitor->logged_in('admin')) {
         url::redirect(empty($_SESSION['history']) ? '/blogs' : $_SESSION['history']);
     }
     $errors = $form_errors = array();
     $form_messages = '';
     $form_values = $entry->as_array();
     /***** CHECK POST *****/
     if (request::method() == 'post') {
         $post = $this->input->post();
         // update
         $editing = (bool) $entry->id;
         if ($editing) {
             $extra['modified'] = date::unix2sql(time());
             $extra['modifies'] = (int) $entry->modifies + 1;
         } else {
             $extra['author_id'] = $this->user->id;
         }
         if ($entry->validate($post, true, $extra)) {
             // News feed event
             if (!$editing) {
                 newsfeeditem_blog::entry($this->user, $entry);
             }
             url::redirect(url::model($entry));
         } else {
             $form_errors = $post->errors();
             $form_messages = $post->message();
         }
         $form_values = arr::overwrite($form_values, $post->as_array());
     }
     /***** /CHECK POST *****/
     /***** SHOW FORM *****/
     if ($entry->id) {
         $this->page_actions[] = array('link' => url::model($entry) . '/delete?token=' . csrf::token($this->user->id), 'text' => __('Delete entry'), 'class' => 'entry-delete');
         $this->page_title = text::title($entry->name);
         $this->page_subtitle = __('Edit entry');
     } else {
         $this->page_title = __('New entry');
     }
     $form = $entry->get_form();
     if (empty($errors)) {
         widget::add('head', html::script(array('js/jquery.markitup.pack.js', 'js/markitup.bbcode.js')));
         widget::add('main', View::factory('blog/entry_edit', array('form' => $form, 'values' => $form_values, 'errors' => $form_errors, 'messages' => $form_messages)));
     } else {
         $this->_error(Kohana::lang('generic.error'), $errors);
     }
     /***** /SHOW FORM *****/
 }
开发者ID:anqqa,项目名称:Anqh,代码行数:57,代码来源:blogs.php

示例2: _topic_edit

 /**
  * Edit topic
  *
  * @param  mixed  $topic_id
  * @param  mixed  $area_id
  */
 public function _topic_edit($topic_id, $area_id = false)
 {
     $this->history = false;
     $errors = array();
     $forum_topic = new Forum_Topic_Model((int) $topic_id);
     $forum_area = $forum_topic->loaded() ? $forum_topic->forum_area : new Forum_Area_Model((int) $area_id);
     if ($forum_topic->loaded()) {
         // Editing topic
         $editing = true;
         if (!$forum_topic->has_access(Forum_Topic_Model::ACCESS_EDIT)) {
             url::back('forum');
         }
     } else {
         if ($forum_area->loaded()) {
             // New topic
             $editing = false;
             if (!$forum_area->has_access(Forum_Area_Model::ACCESS_WRITE)) {
                 url::back('forum');
             }
         } else {
             // New topic in unknown area
             $errors[] = __('Area :area or topic :topic not found', array(':area' => (int) $area_id, ':topic' => (int) $topic_id));
         }
     }
     if (empty($errors)) {
         $forum_post = new Forum_Post_Model((int) $forum_topic->first_post_id);
         $form_errors = array();
         $form_values_topic = $forum_topic->as_array();
         $form_values_post = $forum_post->as_array();
         $form_topics = false;
         // Bound area?
         if ($forum_area->is_type(Forum_Area_Model::TYPE_BIND)) {
             // Get bind config and load topics
             $bind = Forum_Area_Model::binds($forum_area->bind);
             if ($editing) {
                 // Can't edit bound topic
                 $form_topics = array($forum_topic->bind_id => $forum_topic->name);
             } else {
                 // Try to load options from configured model
                 try {
                     $bind_topics = ORM::factory($bind['model'])->find_bind_topics($forum_area->bind);
                     $form_topics = array(0 => __('Choose..')) + $bind_topics;
                 } catch (Kohana_Exception $e) {
                     $form_topics = array();
                 }
             }
         }
         // Admin actions
         if ($editing && $forum_topic->has_access(Forum_Topic_Model::ACCESS_DELETE)) {
             $this->page_actions[] = array('link' => url::model($forum_topic) . '/delete/?token=' . csrf::token(), 'text' => __('Delete topic'), 'class' => 'topic-delete');
         }
         // Check post
         if ($post = $this->input->post()) {
             $post['forum_area_id'] = $forum_area->id;
             $topic = $post;
             if (isset($bind_topics)) {
                 $topic['name'] = arr::get($bind_topics, (int) $topic['bind_id'], '');
             }
             $post_extra = $topic_extra = array('author_id' => $this->user->id, 'author_name' => $this->user->username);
             if ($editing) {
                 $post_extra['modifies'] = (int) $forum_post->modifies + 1;
                 $post_extra['modified'] = date::unix2sql(time());
             }
             $post_extra['author_ip'] = $this->input->ip_address();
             $post_extra['author_host'] = $this->input->host_name();
             // validate post first and save topic if ok
             if (csrf::valid() && $forum_post->validate($post, false, $post_extra) && $forum_topic->validate($topic, true, $topic_extra)) {
                 // post
                 $forum_post->forum_topic_id = $forum_topic->id;
                 $forum_post->save();
                 if (!$editing) {
                     // topic
                     $forum_topic->first_post_id = $forum_post->id;
                     $forum_topic->last_post_id = $forum_post->id;
                     $forum_topic->last_poster = $this->user->username;
                     $forum_topic->last_posted = date::unix2sql(time());
                     $forum_topic->posts = 1;
                     $forum_topic->save();
                     // area
                     $forum_area->last_topic_id = $forum_topic->id;
                     $forum_area->posts += 1;
                     $forum_area->topics += 1;
                     $forum_area->save();
                     // user
                     $this->user->posts += 1;
                     $this->user->save();
                     // News feed
                     newsfeeditem_forum::topic($this->user, $forum_topic);
                 }
                 // redirect back to topic
                 URL::redirect(url::model($forum_topic));
             } else {
                 $form_errors = array_merge($post->errors(), is_object($topic) ? $topic->errors() : array());
             }
//.........这里部分代码省略.........
开发者ID:anqqa,项目名称:Anqh,代码行数:101,代码来源:forum.php

示例3: _event_edit

 /**
  * Edit event
  *
  * @param  int|string  $event_id
  */
 public function _event_edit($event_id = false)
 {
     $this->history = false;
     $event = new Event_Model((int) $event_id);
     // For authenticated users only
     if (!$this->user || !$event->is_author() && !$this->visitor->logged_in(array('admin', 'event moderator'))) {
         url::back('/events');
     }
     $errors = $form_errors = array();
     $form_values = $event->as_array();
     $form_values['start_date'] = '';
     $form_values['start_hour'] = '';
     $form_values['end_hour'] = '';
     /***** CHECK POST *****/
     if (request::method() == 'post') {
         $post = array_merge($this->input->post(), $_FILES);
         $extra = array('start_time' => date::unix2sql(strtotime($post['start_date'] . ' ' . date::time_24h($post['start_hour']))));
         if (!empty($post['end_hour'])) {
             $end_time = strtotime($post['start_date']);
             // end hour is earlier than start hour = event ends the next day
             if ($post['end_hour'] < $post['start_hour']) {
                 $end_time = strtotime('+1 day', $end_time);
             }
             $extra['end_time'] = date('Y-m-d', $end_time) . ' ' . date::time_24h($post['end_hour']) . ':00';
         }
         // update
         $editing = (bool) $event->id;
         if ($editing) {
             $extra['modified'] = date::unix2sql(time());
             $extra['modifies'] = (int) $event->modifies + 1;
         } else {
             $extra['author_id'] = $this->user->id;
         }
         $city = ORM::factory('city', $post['city_id']);
         if ($city) {
             $extra['country_id'] = $city->country_id;
         }
         if (csrf::valid() && $event->validate($post, true, $extra)) {
             // Update tags
             $event->remove(ORM::factory('tag'));
             if (!empty($post['tags'])) {
                 foreach ($post['tags'] as $tag_id => $tag) {
                     $event->add(ORM::factory('tag', $tag_id));
                 }
                 $event->save();
             }
             // Handle flyer uploads
             foreach (array('flyer_front_image_id' => $post->flyer_front, 'flyer_back_image_id' => $post->flyer_back) as $image_id => $flyer) {
                 if (isset($flyer) && empty($flyer['error'])) {
                     $image = Image_Model::factory('events.flyer', $flyer, $this->user->id);
                     if ($image->id) {
                         $event->add($image);
                         $event->{$image_id} = $image->id;
                         $event->save();
                     }
                 }
             }
             if (!$editing) {
                 newsfeeditem_events::event($this->user, $event);
             }
             url::redirect(url::model($event));
         } else {
             $form_errors = $post->errors();
         }
         $form_values = arr::overwrite($form_values, $post->as_array());
     }
     /***** /CHECK POST *****/
     /***** SHOW FORM *****/
     if ($event->id) {
         $this->page_actions[] = array('link' => url::model($event) . '/delete/?token=' . csrf::token(), 'text' => __('Delete event'), 'class' => 'event-delete');
         $this->page_title = text::title($event->name);
         $this->page_subtitle = __('Edit event');
         list($form_values['start_date'], $form_values['start_hour']) = explode(' ', date('Y-m-d H', strtotime($event->start_time)));
         if (!empty($event->end_time)) {
             list($temp, $form_values['end_hour']) = explode(' ', date('Y-m-d H', strtotime($event->end_time)));
         }
     } else {
         $this->page_title = __('New event');
     }
     $form = $event->get_form();
     // Tags
     if ($tag_group = Kohana::config('events.tag_group')) {
         $form['tags'] = $form_values['tags'] = array();
         $tags = ORM::factory('tag_group', $tag_group);
         foreach ($tags->tags as $tag) {
             $form['tags'][$tag->id] = $tag->name;
             if ($event->has($tag)) {
                 $form_values['tags'][$tag->id] = $tag->name;
             }
         }
     }
     // City autocomplete
     $this->_autocomplete_city('city_name');
     // Venue autocomplete
     $venues = ORM::factory('venue')->where('event_host', '=', 1)->find_all();
//.........这里部分代码省略.........
开发者ID:anqqa,项目名称:Anqh,代码行数:101,代码来源:events.php


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