當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。