本文整理汇总了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());
}
}