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


PHP Updater::posts_in_year_month方法代码示例

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


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

示例1: __construct

 public function __construct($source_filename, $is_draft = -1)
 {
     $this->source_filename = $source_filename;
     $this->is_draft = $is_draft === -1 ? false !== strpos($source_filename, 'drafts/') || false !== strpos($source_filename, 'pages/') : $is_draft;
     $this->timestamp = filemtime($source_filename);
     $segments = explode("\n\n", trim(file_get_contents($source_filename)), 2);
     if (!isset($segments[1])) {
         $segments[1] = '';
     }
     if (count($segments) > 1) {
         // Read headers for Tag, Type values
         $headers = explode("\n", $segments[0]);
         $has_title_yet = false;
         foreach ($headers as $header) {
             if (isset($header[0]) && $header[0] == '=') {
                 $has_title_yet = true;
                 continue;
             }
             if (!$has_title_yet) {
                 $has_title_yet = true;
                 $this->title = $header;
                 continue;
             }
             if ($this->is_draft && strtolower($header) == 'publish-now') {
                 $this->publish_now = true;
                 continue;
             }
             $fields = explode(':', $header, 2);
             if (count($fields) < 2) {
                 continue;
             }
             $fname = strtolower($fields[0]);
             $fields[1] = trim($fields[1]);
             if ($fname == 'tags') {
                 $this->tags = self::parse_tag_str($fields[1]);
             } else {
                 if ($fname == 'type') {
                     $this->type = str_replace('|', ' ', $fields[1]);
                 } else {
                     if ($fname == 'published') {
                         $this->timestamp = strtotime($fields[1]);
                     } else {
                         $this->headers[$fname] = $fields[1];
                     }
                 }
             }
             if (isset($this->headers['link'])) {
                 $this->type = 'link';
             }
         }
         array_shift($segments);
     }
     $this->body = isset($segments[0]) ? $segments[0] : '';
     $filename = basename($source_filename);
     $filename_datestr = substr($filename, 0, 8);
     if (is_numeric($filename_datestr)) {
         $this->year = intval(substr($filename_datestr, 0, 4));
         $this->month = intval(substr($filename_datestr, 4, 2));
         $this->day = intval(substr($filename_datestr, 6, 2));
         $this->offset_in_day = intval(substr($filename, 9, 2));
         $this->slug = ltrim(substr($filename, 11, -strlen(Updater::$post_extension)), '-');
     } else {
         $this->year = intval(idate('Y', $this->timestamp));
         $this->month = intval(idate('m', $this->timestamp));
         $this->day = intval(idate('d', $this->timestamp));
         $posts_in_ym = Updater::posts_in_year_month($this->year, $this->month);
         $this->offset_in_day = isset($posts_in_ym[$this->day]) ? count($posts_in_ym[$this->day]) + 1 : 1;
         $this->slug = substring_before($filename, '.');
     }
     if (!$this->is_draft && $source_filename != $this->expected_source_filename()) {
         error_log("Expected filename mismatch:\nfilename: {$source_filename}\nexpected: " . $this->expected_source_filename());
     }
 }
开发者ID:natealmeida,项目名称:secondcrack,代码行数:73,代码来源:Post.php


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