本文整理汇总了PHP中Slug::getTimestamp方法的典型用法代码示例。如果您正苦于以下问题:PHP Slug::getTimestamp方法的具体用法?PHP Slug::getTimestamp怎么用?PHP Slug::getTimestamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Slug
的用法示例。
在下文中一共展示了Slug::getTimestamp方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_content_all
public static function get_content_all($folder = null, $future = false, $past = true, $conditions = null, $skip_status = false, $parse = true, $since = null, $until = null, $location = null, $distance_from = null)
{
$content_type = Config::getContentType();
$site_root = Config::getSiteRoot();
$absolute_folder = Path::resolve($folder);
$posts = self::get_file_list($absolute_folder);
$list = array();
// should we factor in location and distance?
$measure_distance = !is_null($location) && !is_null($distance_from) && preg_match(Pattern::COORDINATES, $distance_from, $matches);
if ($measure_distance) {
$center_point = array($matches[1], $matches[2]);
}
foreach ($posts as $key => $post) {
// starts with numeric value
unset($list[$key]);
if ((preg_match(Pattern::DATE, $key) || preg_match(Pattern::NUMERIC, $key)) && File::exists($post . ".{$content_type}")) {
$data = Statamic::get_content_meta($key, $absolute_folder, false, $parse);
$list[$key] = $data;
$list[$key]['url'] = $folder ? $site_root . $folder . "/" . $key : $site_root . $key;
$list[$key]['raw_url'] = $list[$key]['url'];
// Clean the folder numbers out
$list[$key]['url'] = Path::clean($list[$key]['url']);
# Set status and "raw" slug
if (substr($key, 0, 2) === "__") {
$list[$key]['status'] = 'draft';
$list[$key]['slug'] = substr($key, 2);
} elseif (substr($key, 0, 1) === "_") {
$list[$key]['status'] = 'hidden';
$list[$key]['slug'] = substr($key, 1);
} else {
$list[$key]['slug'] = $key;
}
$slug = $list[$key]['slug'];
$date_entry = false;
if (Config::getEntryTimestamps() && Slug::isDateTime($slug)) {
$datestamp = Slug::getTimestamp($key);
$date_entry = true;
# strip the date
$list[$key]['slug'] = preg_replace(Pattern::DATETIME, '', $slug);
$list[$key]['url'] = preg_replace(Pattern::DATETIME, '', $list[$key]['url']);
#override
$list[$key]['datestamp'] = $data['datestamp'];
$list[$key]['date'] = $data['date'];
} elseif (Slug::isDate($slug)) {
$datestamp = Slug::getTimestamp($slug);
$date_entry = true;
# strip the date
// $list[$key]['slug'] = substr($key, 11);
$list[$key]['slug'] = preg_replace(Pattern::DATE, '', $slug);
$list[$key]['url'] = preg_replace(Pattern::DATE, '', $list[$key]['url']);
#override
$list[$key]['datestamp'] = $data['datestamp'];
$list[$key]['date'] = $data['date'];
} else {
$list[$key]['slug'] = preg_replace(Pattern::NUMERIC, '', $slug);
$list[$key]['url'] = preg_replace(Pattern::NUMERIC, '', $list[$key]['url'], 1);
#override
}
$list[$key]['url'] = Path::tidy('/' . $list[$key]['url']);
# fully qualified url
$list[$key]['permalink'] = Path::tidy(Config::getSiteURL() . '/' . $list[$key]['url']);
/* $content = preg_replace('/<img(.*)src="(.*?)"(.*)\/?>/', '<img \/1 src="'.Statamic::get_asset_path(null).'/\2" /\3 />', $data['content']); */
//$list[$key]['content'] = Statamic::transform_content($data['content']);
// distance
if (isset($list[$key][$location]['latitude']) && $list[$key][$location]['latitude'] && isset($list[$key][$location]['longitude']) && $list[$key][$location]['longitude']) {
$list[$key]['coordinates'] = $list[$key][$location]['latitude'] . "," . $list[$key][$location]['longitude'];
}
if ($measure_distance && is_array($center_point)) {
if (!isset($list[$key][$location]) || !is_array($list[$key][$location])) {
unset($list[$key]);
}
if (isset($list[$key][$location]['latitude']) && $list[$key][$location]['latitude'] && isset($list[$key][$location]['longitude']) && $list[$key][$location]['longitude']) {
$list[$key]['distance_km'] = Statamic_Helper::get_distance_in_km($center_point, array($list[$key][$location]['latitude'], $list[$key][$location]['longitude']));
$list[$key]['distance_mi'] = Statamic_Helper::convert_km_to_miles($list[$key]['distance_km']);
} else {
unset($list[$key]);
}
}
if (!$skip_status) {
if (isset($data['status']) && $data['status'] != 'live') {
unset($list[$key]);
}
}
// Remove future entries
if ($date_entry && $future === false && $datestamp > time()) {
unset($list[$key]);
}
// Remove past entries
if ($date_entry && $past === false && $datestamp < time()) {
unset($list[$key]);
}
// Remove entries before $since
if ($date_entry && !is_null($since) && $datestamp < strtotime($since)) {
unset($list[$key]);
}
// Remove entries after $until
if ($date_entry && !is_null($until) && $datestamp > strtotime($until)) {
unset($list[$key]);
}
if ($conditions) {
//.........这里部分代码省略.........
示例2: get_datetimestamp
/**
* get_datetimestamp
* Gets a timestamp from a given $date_slug
*
* @deprecated Use Slug::getTimestamp() instead
*
* @param string $date_slug Date (or datetime) slug to inspect
* @return integer
*/
public static function get_datetimestamp($date_slug)
{
Log::warn("Use of Statamic_Helper::get_datetimestamp() is deprecated. Use Slug::getTimestamp() instead.", "core", "Statamic_Helper");
return Slug::getTimestamp($date_slug);
}