本文整理汇总了PHP中URL::assemble方法的典型用法代码示例。如果您正苦于以下问题:PHP URL::assemble方法的具体用法?PHP URL::assemble怎么用?PHP URL::assemble使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类URL
的用法示例。
在下文中一共展示了URL::assemble方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getContent
public function getContent()
{
$url = URL::assemble(Config::getSiteRoot(), $this->fetchConfig('globals_url', null, null, false, false));
$content = ContentService::getContentByUrl($url);
$content = current($content->extract());
return $content;
}
示例2: getParent
/**
* Retrieve the parent page
* @return Array Array containing the content of the parent page
*/
private function getParent()
{
$parent = URL::assemble(URL::popLastSegment(URL::getCurrent()));
if (Taxonomy::isTaxonomyURL($parent)) {
$parent = URL::popLastSegment($parent);
}
return Content::get($parent);
}
示例3: index
public function index()
{
// we need the local path
if (!isset($this->context['_local_path'])) {
return '';
}
// local path exists, return the correct format
$path = Config::get('_admin_path') . '.php/publish?path=' . substr($this->context['_local_path'], 1, strrpos($this->context['_local_path'], '.') - 1);
return URL::assemble(Config::getSiteRoot(), $path);
}
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:10,代码来源:pi.control_panel_edit_url.php
示例4: render
public function render()
{
// Let's make sure they set an upload destination
if (array_get($this->field_config, 'destination', false) === false) {
throw new Exception("You need to set a destination for your File field.");
}
// Normalize the destination
$this->destination = trim(array_get($this->field_config, 'destination'), '/') . '/';
// Allow a string or an array, but we want an array
$has_data = ($this->field_data != '');
$this->field_data = Helper::ensureArray($this->field_data);
// Clean up {{ _site_root }} and lack of leading slash existence
foreach ($this->field_data as $i => $file) {
$this->field_data[$i] = URL::tidy('/' . str_replace('{{ _site_root }}', '', $file));
}
// Whether or not to allow the browse existing files functionality
$allow_browse = array_get($this->field_config, 'browse', true);
// Resizing config
if ($resize = array_get($this->field_config, 'resize')) {
$resize['resize'] = true;
$resize = http_build_query($resize);
}
// If we're in a subdirectory, prepend it to all the filenames
if (($site_root = Config::getSiteRoot()) != '/') {
foreach ($this->field_data as $i => $file) {
$this->field_data[$i] = URL::assemble($site_root, $file);
}
}
// Send data to the view
$vars = array(
'field_id' => $this->field_id,
'field_name' => $this->fieldname,
'tabindex' => $this->tabindex,
'has_data' => $has_data,
'field_data' => $this->field_data,
'field_config' => $this->field_config,
'destination' => $this->destination,
'allow_browse' => $allow_browse,
'server_files' => ($allow_browse) ? json_encode($this->tasks->generateModal($this->field_config, $this->destination)) : null,
'file_thumb' => URL::assemble(Config::getSiteRoot(), Config::get('admin_path'), 'themes', Config::get('admin_theme'), '/img/file.png'),
'resize' => $resize
);
$template = File::get($this->getAddonLocation() . 'views/fieldtype.html');
return Parse::template($template, $vars);
}
示例5: render
public function render()
{
// Generate a hash unique to this field's config and data
$hash = Helper::makeHash($this->field_config, $this->field_data);
// If we've already saved the output, grab it from blink's cache
// and avoid further processing.
if ($this->blink->exists($hash)) {
$html = $this->blink->get($hash);
return $this->renderFieldReplacements($html);
}
// Let's make sure they set an upload destination
if (array_get($this->field_config, 'destination', false) === false) {
throw new Exception("You need to set a destination for your File field.");
}
// Normalize the destination
$this->destination = trim(array_get($this->field_config, 'destination'), '/') . '/';
// Allow a string or an array, but we want an array
$has_data = $this->field_data != '';
$this->field_data = Helper::ensureArray($this->field_data);
// Clean up {{ _site_root }} and lack of leading slash existence
foreach ($this->field_data as $i => $file) {
$this->field_data[$i] = URL::tidy('/' . str_replace('{{ _site_root }}', '', $file));
}
// Whether or not to allow the browse existing files functionality
$allow_browse = array_get($this->field_config, 'browse', true);
// Resizing config
if ($resize = array_get($this->field_config, 'resize')) {
$resize['resize'] = true;
$resize = http_build_query($resize);
}
// If we're in a subdirectory, prepend it to all the filenames
if (($site_root = Config::getSiteRoot()) != '/') {
foreach ($this->field_data as $i => $file) {
$this->field_data[$i] = URL::assemble($site_root, $file);
}
}
// Send data to the view
$vars = array('field_id' => $this->field_id, 'field_name' => $this->fieldname, 'tabindex' => $this->tabindex, 'has_data' => $has_data, 'field_data' => $this->field_data, 'field_config' => $this->field_config, 'destination' => $this->destination, 'allow_browse' => $allow_browse, 'browse_url' => URL::assemble(Config::getSiteRoot(), Config::get('admin_path') . '.php/files?config=' . rawurlencode(Helper::encrypt(serialize($this->field_config)))), 'file_thumb' => $this->tasks->defaultFileThumbnail(), 'resize' => $resize);
// Get the view template from the file
$template = File::get($this->getAddonLocation() . 'views/fieldtype.html');
// Parse it
$html = Parse::template($template, $vars);
// Save it to cache for other similar fields
$this->blink->set($hash, $html);
// Output!
return $this->renderFieldReplacements($html);
}
示例6: getShareableImage
/**
* Will return the sharable image for the page.
*/
private function getShareableImage()
{
try {
// if an image variable was passed directly
if ($this->fetch('image')) {
return $this->fetch('image');
}
// if there was an og image specified on the page, use it (or get first image from array)
if (isset($this->page['og_image'])) {
$image = "";
if (is_array($this->page['og_image'])) {
$image = $this->page['og_image'][0];
} else {
$image = $this->page['og_image'];
}
return URL::assemble($this->site_url, $image);
}
// if another image is specified as the source
if ($this->shareable_image_source && isset($this->page[$this->sharable_image_source])) {
if (is_array($this->page[$this->sharable_image_source])) {
$image = $this->page[$this->sharable_image_source][0];
} else {
$image = $this->page[$this->sharable_image_source];
}
return URL::assemble($this->site_url, $image);
}
// if there's a default image
if ($this->sharable_image_default) {
return $this->sharable_image_default;
}
// and if all else fails return an empty string
return "";
} catch (Exception $e) {
return "<!-- Exception occured: " . $e->getMessage() . " -->";
}
}
示例7: member__logout
/**
* Logs a user out
*
* @return void
*/
public function member__logout()
{
$return = Request::get('return', Config::getSiteRoot());
Auth::logout();
URL::redirect(URL::assemble(Config::getSiteRoot(), $return));
}
示例8: img
public function img()
{
$src = $this->fetchParam('src', null, null, false, false);
$file = $this->theme_path . $this->theme_assets_path . 'img/' . $src;
$alt = $this->fetchParam('alt', null, null, false, false);
$tag = $this->fetchParam('tag', false, null, true, false);
$cache_bust = $this->fetchParam('cache_bust', Config::get('theme_cache_bust', false), false, true, true);
if ($alt) {
$alt = ' alt="' . $alt . '"';
}
if ($cache_bust && File::exists($file)) {
$file .= '?v=' . ($last_modified = filemtime($file));
}
$filename = URL::assemble($this->site_root, $file);
return $tag ? '<img src="' . $filename . '" ' . $alt . '>' : $filename;
}
示例9: defaultFileThumbnail
public function defaultFileThumbnail()
{
return URL::assemble(Config::getSiteRoot(), Config::get('admin_path'), 'themes', Config::get('admin_theme'), '/img/file.png');
}
示例10: dirname
$file = $content_root . "/" . $path . "." . $content_type;
File::delete($file);
}
if ($count > 1) {
$admin_app->flash('success', 'Entries successfully deleted!');
} else {
$admin_app->flash('success', 'Entry successfully deleted!');
}
$url = $admin_app->urlFor('entries') . "?path=" . dirname($path);
$admin_app->redirect($url);
})->name('delete_entry')->via('GET', 'POST');
// GET: DELETE PAGE
$admin_app->get('/delete/page', function () use($admin_app) {
authenticateForRole('admin');
doStatamicVersionCheck($admin_app);
$path = URL::assemble(BASE_PATH, Config::getContentRoot(), $admin_app->request()->get('path'));
$type = $admin_app->request()->get('type');
if ($type == "folder" && Folder::exists($path)) {
Folder::delete($path);
$admin_app->flash('success', 'Page successfully deleted!');
} else {
if (!Pattern::endsWith($path, Config::getContentType())) {
$path .= Config::getContentType();
}
if (File::exists($path)) {
File::delete($path);
$admin_app->flash('success', 'Page successfully deleted!');
} else {
$admin_app->flash('failure', 'Unable to delete page.');
}
}
示例11: loadAllConfigs
/**
* Load the config (yaml) files in a specified order:
*
* 1. Loose per-site configs
* 2. Routes
* 3. Settings
* 4. Theme overrides
*/
public static function loadAllConfigs($admin = FALSE)
{
/*
|--------------------------------------------------------------------------
| YAML Mode
|--------------------------------------------------------------------------
|
| We need to know the YAML mode first (loose, strict, transitional),
| so we parse the settings file once to check before doing anything else.
|
*/
$preload_config = YAML::parse(Config::getConfigPath() . '/settings.yaml');
$yaml_mode = array_get($preload_config, '_yaml_mode', 'loose');
/*
|--------------------------------------------------------------------------
| Default Settings
|--------------------------------------------------------------------------
|
| We keep a set of default options that the user config overrides, allowing
| us to always have clean defaults.
|
*/
$default_config = YAML::parse(Config::getAppConfigPath() . '/default.settings.yaml');
/*
|--------------------------------------------------------------------------
| User Site Settings
|--------------------------------------------------------------------------
|
| Next we parse and override the user's settings.
|
*/
$user_config = YAML::parse(Config::getConfigPath() . '/settings.yaml', $yaml_mode);
$config = array_merge($default_config, $user_config);
/*
|--------------------------------------------------------------------------
| Routes and vanity URLs
|--------------------------------------------------------------------------
|
| Any URL can be manipulated by routes or vanity urls. We need this info
| early on, before content parsing begins.
|
*/
$routes = array();
if (File::exists(Config::getConfigPath() . '/routes.yaml')) {
$routes['_routes'] = YAML::parse('_config/routes.yaml', $yaml_mode);
}
// check for vanity URLs first, we may need to redirect
$vanity = array();
if (File::exists(Config::getConfigPath() . '/vanity.yaml')) {
$vanity['_vanity_urls'] = YAML::parse(Config::getConfigPath() . '/vanity.yaml', $yaml_mode);
}
$config = array_merge($config, $routes, $vanity);
/*
|--------------------------------------------------------------------------
| Global Variables
|--------------------------------------------------------------------------
|
| We parse all the yaml files in the root (except settings and routes) of
| the config folder and make them available as global template variables.
|
*/
if (Folder::exists($config_files_location = Config::getConfigPath())) {
$finder = new Finder();
$files = $finder->files()->in($config_files_location)->name('*.yaml')->notName('routes.yaml')->notName('vanity.yaml')->notName('settings.yaml')->depth(0);
if (iterator_count($files) > 0) {
foreach ($files as $file) {
$config = array_merge($config, YAML::parse($file->getRealPath(), $yaml_mode));
}
}
}
/*
|--------------------------------------------------------------------------
| Theme Variables
|--------------------------------------------------------------------------
|
| Theme variables need to specifically parsed later so they can override
| any site/global defaults.
|
*/
$themes_path = array_get($config, '_themes_path', '_themes');
$theme_name = array_get($config, '_theme', 'denali');
if (Folder::exists($theme_files_location = URL::assemble(BASE_PATH, $themes_path, $theme_name))) {
$finder = new Finder();
// clear previous Finder interator results
$theme_files = $finder->files()->in($theme_files_location)->name('*.yaml')->depth(0);
if (iterator_count($theme_files) > 0) {
foreach ($theme_files as $file) {
$config = array_merge($config, YAML::parse($file->getRealPath(), $yaml_mode));
}
}
}
/*
//.........这里部分代码省略.........
示例12: get
/**
* Returns the full path of a given script
*
* @param string $file Script file to find
* @return string
*/
public function get($file)
{
$file_location = Config::getAddOnPath($this->context->addon_name) . '/';
if (File::exists(BASE_PATH . $file_location . $file)) {
return URL::assemble(Config::getSiteRoot(), $file_location, $file);
} elseif (File::exists(BASE_PATH . $file_location . 'assets/' . $file)) {
return URL::assemble(Config::getSiteRoot(), $file_location, 'assets', $file);
}
$this->context->log->error("Asset file `" . $file . "` doesn't exist.");
return "";
}
示例13: function
echo $modal;
})->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
示例14: getAddOnPath
/**
* Returns the path for a given $addon relative to the BASE_PATH
*
* @param string $addon Add-on to use
* @return string
*/
public static function getAddOnPath($addon)
{
return URL::assemble(self::getAddOnsPath(), $addon);
}
示例15: 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(URL::assemble($content_root, $path . '.' . $content_type)) && !is_dir(URL::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;
}
// /2-blog/hidden
return $fixedpath;
}