本文整理汇总了PHP中Path::resolve方法的典型用法代码示例。如果您正苦于以下问题:PHP Path::resolve方法的具体用法?PHP Path::resolve怎么用?PHP Path::resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path
的用法示例。
在下文中一共展示了Path::resolve方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($path, $sanitized = false)
{
if ($sanitized) {
$this->path = $path;
} else {
$this->path = Path::resolve($path);
}
}
示例2: count
public function count()
{
$url = $this->fetchParam('from', URL::getCurrent());
$url = Path::resolve($url);
$max_depth = $this->fetchParam('max_depth', 1, 'is_numeric');
$tree = Statamic::get_content_tree($url, 1, $max_depth);
if ($this->content != '') {
return Parse::tagLoop($this->content, $tree);
} else {
return count($tree);
}
}
示例3: str_replace
if (substr($path, -5) == '.html') {
$path = str_replace('.html', '', $path);
}
$app->config['current_path'] = $path;
// init some variables for below
$content_root = Config::getContentRoot();
$content_type = Config::getContentType();
$response_code = 200;
$visible = true;
$add_prev_next = false;
$template_list = array('default');
// set up the app based on if a
if (File::exists("{$content_root}/{$path}.{$content_type}") || Folder::exists("{$content_root}/{$path}")) {
// endpoint or folder exists!
} else {
$path = Path::resolve($path);
$app->config['current_url'] = $app->config['current_path'];
$app->config['current_path'] = $path;
# override global current_path
}
// routes via routes.yaml
if (isset($app->config['_routes']['routes'][$current_url]) || isset($app->config['_routes'][$current_url])) {
# allows the route file to run without "route:" as the top level array key (backwards compatibility)
$current_route = isset($app->config['_routes']['routes'][$current_url]) ? $app->config['_routes']['routes'][$current_url] : $app->config['_routes'][$current_url];
$route = $current_route;
$template = $route;
$data = array();
if (is_array($route)) {
$template = isset($route['template']) ? $route['template'] : 'default';
if (isset($route['layout'])) {
$data['_layout'] = $route['layout'];
示例4: 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) {
//.........这里部分代码省略.........
示例5: function
})->name('files');
// Delete file
$admin_app->get('/file/delete', function () use($admin_app) {
authenticateForRole('admin');
doStatamicVersionCheck($admin_app);
$result = Addon::getAPI('file')->deleteFile();
$response = $admin_app->response();
$response['Content-Type'] = 'application/json';
$response->status(200);
$response->body(json_encode($result));
})->name('delete_file');
$admin_app->get('/url/unique', function () use($admin_app) {
$folder = Request::get('folder');
$url = Request::get('url');
$path = URL::assemble($folder, $url);
$data = array('exists' => Content::exists(Path::resolve($path)));
$response = $admin_app->response();
$response['Content-Type'] = 'application/json';
$response->body(json_encode($data));
});
/*
|--------------------------------------------------------------------------
| Hook: Add Routes
|--------------------------------------------------------------------------
|
| Allows add-ons to add their own hooks to the control panel.
|
*/
Hook::run('control_panel', 'add_routes');
// GET: 404
// --------------------------------------------------------
示例6: resolve_path
/**
* resolve_path
* Finds the actual path from a URL-friendly $path
*
* @deprecated As of v1.5
* @param string $path Path to resolve
* @return string
*/
public static function resolve_path($path)
{
Log::warn("Use of Statamic_Helper::resolve_path() is deprecated. Use Path::resolve() instead.", "core", "Statamic_Helper");
return Path::resolve($path);
}
示例7: cleanFoldersList
function cleanFoldersList($folder_params)
{
$folder_params_array = Helper::explodeOptions($folder_params, false);
foreach ($folder_params_array as $part) {
$folders[] = '/_content' . Path::resolve($part) . '/';
}
return $folders;
}