本文整理汇总了PHP中Slug::isDate方法的典型用法代码示例。如果您正苦于以下问题:PHP Slug::isDate方法的具体用法?PHP Slug::isDate怎么用?PHP Slug::isDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Slug
的用法示例。
在下文中一共展示了Slug::isDate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_content_tree
public static function get_content_tree($directory = '/', $depth = 1, $max_depth = 5, $folders_only = false, $include_entries = false, $hide_hidden = true, $include_content = false, $site_root = false)
{
// $folders_only = true only page.md
// folders_only = false includes any numbered or non-numbered page (excluding anything with a fields.yaml file)
// if include_entries is true then any numbered files are included
$content_root = Config::getContentRoot();
$content_type = Config::getContentType();
$site_root = $site_root ? $site_root : Config::getSiteRoot();
$current_url = Path::tidy($site_root . '/' . Request::getResourceURI());
$taxonomy_url = false;
if (Taxonomy::isTaxonomyURL($current_url)) {
list($taxonomy_type, $taxonomy_name) = Taxonomy::getCriteria($current_url);
$taxonomy_url = self::remove_taxonomy_from_path($current_url, $taxonomy_type, $taxonomy_name);
}
$directory = '/' . $directory . '/';
#ensure proper slashing
if ($directory != '/') {
$base = Path::tidy("{$content_root}/{$directory}");
} elseif ($directory == '/') {
$base = "{$content_root}";
} else {
$base = "{$content_root}";
}
$files = glob("{$base}/*");
$data = array();
if ($files) {
foreach ($files as $path) {
$current_name = basename($path);
if (!Pattern::endsWith($current_name, '.yaml')) {
// Hidden page that should be removed
if ($hide_hidden && Pattern::startsWith($current_name, '_')) {
continue;
}
$node = array();
$file = substr($path, strlen($base) + 1, strlen($path) - strlen($base) - strlen($content_type) - 2);
if (is_dir($path)) {
$folder = substr($path, strlen($base) + 1);
$node['type'] = 'folder';
$node['slug'] = basename($folder);
$node['title'] = ucwords(basename($folder));
$node['numeric'] = Slug::getOrderNumber($folder);
$node['file_path'] = Path::tidy($site_root . '/' . $directory . '/' . $folder . '/page');
if (Slug::isNumeric($folder)) {
$pos = strpos($folder, ".");
if ($pos !== false) {
$node['raw_url'] = Path::tidy(Path::clean($site_root . '/' . $directory . '/' . $folder));
$node['url'] = Path::clean($node['raw_url']);
$node['title'] = ucwords(basename(substr($folder, $pos + 1)));
} else {
$node['title'] = ucwords(basename($folder));
$node['raw_url'] = Path::tidy($site_root . '/' . $directory . '/' . $folder);
$node['url'] = Path::clean($node['raw_url']);
}
} else {
$node['title'] = ucwords(basename($folder));
$node['raw_url'] = Path::tidy($site_root . '/' . $directory . '/' . $folder);
$node['url'] = Path::clean($node['raw_url']);
}
$node['depth'] = $depth;
$node['children'] = $depth < $max_depth ? self::get_content_tree($directory . $folder . '/', $depth + 1, $max_depth, $folders_only, $include_entries, $hide_hidden, $include_content, $site_root) : null;
$node['is_current'] = $node['raw_url'] == $current_url || $node['url'] == $current_url ? true : false;
$node['is_parent'] = false;
if ($node['url'] == URL::popLastSegment($current_url) || $taxonomy_url && $node['url'] == $taxonomy_url) {
$node['is_parent'] = true;
}
$node['has_children'] = $node['children'] ? true : false;
// has entries?
if (File::exists(Path::tidy($path . "/fields.yaml"))) {
$node['has_entries'] = true;
} else {
$node['has_entries'] = false;
}
$meta = self::get_content_meta("page", Path::tidy($directory . "/" . $folder), false, true);
//$meta = self::get_content_meta("page", Statamic_Helper::reduce_double_slashes($directory."/".$folder));
if (isset($meta['title'])) {
$node['title'] = $meta['title'];
}
if (isset($meta['last_modified'])) {
$node['last_modified'] = $meta['last_modified'];
}
if ($hide_hidden === true && (isset($meta['status']) && ($meta['status'] == 'hidden' || $meta['status'] == 'draft'))) {
// placeholder condition
} else {
$data[] = $include_content ? array_merge($meta, $node) : $node;
// print_r($data);
}
} else {
if (Pattern::endsWith($path, $content_type)) {
if ($folders_only == false) {
if ($file == 'page' || $file == 'feed' || $file == '404') {
// $node['url'] = $directory;
// $node['title'] = basename($directory);
// $meta = self::get_content_meta('page', substr($directory, 1));
// $node['depth'] = $depth;
} else {
$include = true;
// date based is never included
if (Config::getEntryTimestamps() && Slug::isDateTime(basename($path))) {
$include = false;
} elseif (Slug::isDate(basename($path))) {
//.........这里部分代码省略.........
示例2: resolve
/**
* Finds a given path on the server, adding in any ordering elements missing
*
* @param string $path Path to resolve
* @return string
*/
public static function resolve($path)
{
$content_root = Config::getContentRoot();
$content_type = Config::getContentType();
if (strpos($path, "/") === 0) {
$parts = explode("/", substr($path, 1));
} else {
$parts = explode("/", $path);
}
$fixedpath = "/";
foreach ($parts as $part) {
if (!File::exists(Path::assemble($content_root, $path . '.' . $content_type)) && !is_dir(Path::assemble($content_root, $part))) {
// check folders
$list = Statamic::get_content_tree($fixedpath, 1, 1, FALSE, TRUE, FALSE);
foreach ($list as $item) {
$t = basename($item['slug']);
if (Slug::isNumeric($t)) {
$nl = strlen(Slug::getOrderNumber($t)) + 1;
if (strlen($part) >= strlen($item['slug']) - $nl && Pattern::endsWith($item['slug'], $part)) {
$part = $item['slug'];
break;
}
} else {
if (Pattern::endsWith($item['slug'], $part)) {
if (strlen($part) >= strlen($t)) {
$part = $item['slug'];
break;
}
}
}
}
// check files
$list = Statamic::get_file_list($fixedpath);
foreach ($list as $key => $item) {
if (Pattern::endsWith($key, $part)) {
$t = basename($item);
$offset = 0;
if (Pattern::startsWith($key, '__')) {
$offset = 2;
} elseif (Pattern::startsWith($key, '_')) {
$offset = 1;
}
if (Config::getEntryTimestamps() && Slug::isDateTime($t)) {
if (strlen($part) >= strlen($key) - 16 - $offset) {
$part = $key;
break;
}
} elseif (Slug::isDate($t)) {
if (strlen($part) >= strlen($key) - 12 - $offset) {
$part = $key;
break;
}
} elseif (Slug::isNumeric($t)) {
$nl = strlen(Slug::getOrderNumber($key)) + 1;
if (strlen($part) >= strlen($key) - $nl - $offset) {
$part = $key;
break;
}
} else {
$t = basename($item);
if (strlen($part) >= strlen($t) - $offset) {
$part = $key;
break;
}
}
}
}
}
if ($fixedpath != '/') {
$fixedpath .= '/';
}
$fixedpath .= $part;
}
return $fixedpath;
}
示例3: is_date_slug
/**
* is_date_slug
* Determines if a given $slug is date-based and is valid or not
*
* @deprecated Use Slug::isDate() instead
*
* @param string $slug Slug to inspect
* @return boolean
*/
public static function is_date_slug($slug)
{
Log::warn("Use of Statamic_Helper::is_date_slug() is deprecated. Use Slug::isDate() instead.", "core", "Statamic_Helper");
return Slug::isDate($slug);
}