本文整理汇总了PHP中Url::getBase方法的典型用法代码示例。如果您正苦于以下问题:PHP Url::getBase方法的具体用法?PHP Url::getBase怎么用?PHP Url::getBase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Url
的用法示例。
在下文中一共展示了Url::getBase方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: function
<?php
/**
* This file is part of the Morfy.
*
* (c) Romanenko Sergey / Awilum <awilum@msn.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
// Add {block name=block-name} shortcode
Shortcode::add('block', function ($attributes) {
if (isset($attributes['name'])) {
return Blocks::get($attributes['name']);
}
});
// Add {site_url} shortcode
Shortcode::add('site_url', function () {
return Url::getBase();
});
示例2: function
<?php
/**
* Breadcrumb Plugin
* Based on idea from https://github.com/tovic/breadcrumb-plugin-for-fansoro-cms
*
* @package Fansoro
* @subpackage Plugins
* @author Pavel Belousov / pafnuty
* @version 1.1.0
* @license https://github.com/pafnuty-fansoro-plugins/fansoro-plugin-breadcrumb/blob/master/LICENSE MIT
*/
Action::add('breadcrumb', function () {
// Configuration data
$config = Config::get('plugins.breadcrumb');
// Get current URI segments
$paths = Url::getUriSegments();
// Count total paths
$total_paths = count($paths);
// Path lifter
$lift = '';
// Breadcrumb's data
$data = [];
for ($i = 0; $i < $total_paths; $i++) {
$lift .= '/' . $paths[$i];
$page = Pages::getPage(file_exists(STORAGE_PATH . '/pages/' . $lift . '/index.md') || file_exists(STORAGE_PATH . '/pages/' . $lift . '.md') ? $lift : '404');
$data[Url::getBase() . $lift] = ['title' => $page['title'], 'current' => rtrim(Url::getCurrent(), '/') === rtrim(Url::getBase() . $lift, '/')];
}
$template = Template::factory(THEMES_PATH . '/' . Config::get('system.theme'));
$template->display('/plugins/breadcrumb/breadcrumb.tpl', ['home' => rtrim(Url::getCurrent(), '/') === rtrim(Url::getBase(), '/') ? true : Url::getBase(), 'config' => $config, 'branch' => $data]);
});
示例3: buttons
/**
* Morfy Social Sharing Buttons Plugin based on Likely
*
* (c) Evgeny Steblinsky / volter9 <volter9.github.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
class Likely
{
/**
* @param string $title
* @param string $url
* @param array|string $classes
*/
public static function buttons($title = '', $url = '', $classes = '')
{
$classes = is_array($classes) ? implode(' ', $classes) : $classes;
$template = Template::factory(PLUGINS_PATH . '/likely/templates/');
$template->display('likely.tpl', compact('title', 'url', 'classes'));
}
}
Action::add('theme_header', function () {
$base = Url::getBase();
printf('<link href="%s/plugins/likely/bower_components/ilyabirman-likely/release/likely.css" rel="stylesheet">', $base);
});
Action::add('theme_footer', function () {
$base = Url::getBase();
printf('<script src="%s/plugins/likely/bower_components/ilyabirman-likely/release/likely.js"></script>', $base);
});
示例4: die
File::delete(STORAGE_PATH . '/pages' . Request::get('del') . '.md');
Request::redirect(Url::getBase());
} else {
die('crsf detect !');
}
}
// remove Cache
if (Request::get('clearcache') == 'true') {
if (Request::get('token')) {
if (Dir::exists(CACHE_PATH . '/doctrine/')) {
Dir::delete(CACHE_PATH . '/doctrine/');
}
if (Dir::exists(CACHE_PATH . '/fenom/')) {
Dir::delete(CACHE_PATH . '/fenom/');
}
Request::redirect(Url::getBase());
} else {
die('crsf detect !');
}
}
// logout
if (Request::post('access_logout')) {
Session::delete(Config::get('plugins.edit.name') . '_user');
Request::redirect(Url::getCurrent());
}
// show template
$template->display('admin.tpl', ['title' => $name, 'content' => $page, 'current' => $url, 'directory' => Dir::scan(STORAGE_PATH . '/pages')]);
} else {
// login
if (Request::post('access_login')) {
if (Request::post('token')) {
示例5: function
/**
* Social Meta Plugin
*
* @package Fansoro
* @subpackage Plugins
* @author Pavel Belousov / pafnuty
* @version 1.2.0
* @license https://github.com/pafnuty-fansoro-plugins/fansoro-plugin-socialmeta/blob/master/LICENSE MIT
*/
Action::add('theme_meta', function () {
if (!class_exists('resize')) {
require_once PLUGINS_PATH . '/socialmeta/classes/resize.php';
}
require_once PLUGINS_PATH . '/socialmeta/classes/SocialMeta.php';
$config = Config::get('plugins.socialmeta');
$page = Pages::getCurrentPage();
$socialMeta = new SocialMeta();
$title = $page['title'];
$description = $page['description'] ? $page['description'] : $page['content'];
$description = $socialMeta->textLimit($description, 250);
$twitterImage = isset($page['twitter_image']) ? Url::getBase() . $page['twitter_image'] : $socialMeta->getImage($page['content'], $config['twitter']['noimage'], '600x330', '100');
$facebookImage = isset($page['og_image']) ? Url::getBase() . $page['og_image'] : $socialMeta->getImage($page['content'], $config['facebook']['noimage'], '600x315', '100');
$arTwitter = ['twitter:card' => 'summary_large_image', 'twitter:site' => '@' . $config['twitter']['author'], 'twitter:creator' => '@' . $config['twitter']['author'], 'twitter:domain' => Url::getBase(), 'twitter:title' => $title, 'twitter:description' => $description, 'twitter:image' => $twitterImage];
$arFacebook = ['og:type' => 'website', 'og:site_name' => Config::get('site.title'), 'og:url' => $page['url'], 'og:title' => $title, 'og:description' => $description, 'og:image' => $facebookImage];
foreach ($arTwitter as $name => $content) {
echo '<meta name="' . $name . '" content="' . $content . '">';
}
foreach ($arFacebook as $property => $content) {
echo '<meta property="' . $property . '" content="' . $content . '">';
}
}, '100');
示例6: function
<?php
/**
* Emoji plugin for Fansoro
*
* @package Fansoro
* @subpackage Plugins
* @author Pavel Belousov / pafnuty
* @version 1.1.0
* @license https://github.com/pafnuty-fansoro-plugins/fansoro-plugin-emoji/blob/master/LICENSE MIT
*
*/
Action::add('theme_header', function () {
echo '<link rel="stylesheet" href="' . Url::getBase() . '/plugins/emoji/assets/css/emoji.css">';
});
Action::add('theme_footer', function () {
echo '<script src="' . Url::getBase() . '/plugins/emoji/assets/js/emojify.min.js"></script>';
echo '<script src="' . Url::getBase() . '/plugins/emoji/assets/js/emoji.js"></script>';
});
示例7: init
public static function init()
{
// login vars
$user = trim(Config::get('plugins.gallery.email'));
$password = trim(Config::get('plugins.gallery.password'));
$token = trim(Config::get('plugins.gallery.token'));
$hash = md5($token . $password);
// get plugin info
//var_dump(json_encode(Config::get('plugins.gallery'),true));
$template = Template::factory(PLUGINS_PATH . '/gallery/templates/');
$template->setOptions(['strip' => false]);
$jsonFile = '';
$format = '';
$thumbnails_path = '';
$photos_path = '';
$json = '';
$info = '';
// check if dir exists if not create
if (!Dir::exists(ROOT_DIR . '/public/gallery')) {
Dir::create(ROOT_DIR . '/public/gallery');
}
if (!Dir::exists(ROOT_DIR . '/public/gallery/thumbnails')) {
Dir::create(ROOT_DIR . '/public/gallery/thumbnails');
}
if (!Dir::exists(ROOT_DIR . '/public/gallery/galleries')) {
Dir::create(ROOT_DIR . '/public/gallery/galleries');
}
if (!File::exists(ROOT_DIR . '/public/gallery/gallery.json')) {
File::setContent(ROOT_DIR . '/public/gallery/gallery.json', '[]');
} else {
$jsonFile = ROOT_DIR . '/public/gallery/gallery.json';
$format = array('jpg', 'jpeg', 'png', 'gif', 'bmp', 'JPG', 'JPEG');
$thumbnails_path = ROOT_DIR . '/public/gallery/thumbnails/';
$photos_path = ROOT_DIR . '/public/gallery/galleries/';
// decode json
$json = json_decode(File::getContent($jsonFile), true);
}
// show loginbtn
if (Session::exists(Config::get('plugins.gallery.name') . '_user')) {
// logout
if (Request::post('access_logout')) {
Session::delete(Config::get('plugins.gallery.name') . '_user');
Request::redirect(Url::getBase() . '/' . strtolower(Config::get('plugins.gallery.name')));
}
// create gallery
if (Request::post('createGallery')) {
if (Request::post('token')) {
// id
$id = time();
// json array remenber encode
$json[$id] = array('id' => $id, 'title' => Request::post('title') ? Request::post('title') : 'No title', 'desc' => Request::post('desc') ? Request::post('desc') : 'No desc', 'thumbnail' => '/public/gallery/thumbnails/' . $id . '.png', 'photos' => ROOT_DIR . '/public/gallery/galleries/' . $id . '/');
Dir::create($photos_path . $id);
// save content
if (File::setContent($jsonFile, json_encode($json))) {
self::upload('thumbnail', 'thumbnail', $format, $thumbnails_path, $id);
self::upload('photos', 'photos', $format, $photos_path, $id);
return self::set_msg('Success The gallery has been created');
}
} else {
die('Crsf detect!');
}
}
// update gallery
if (Request::post('updateGallery')) {
if (Request::post('token')) {
// json array remenber encode
$id = Request::post('update_id');
$json[$id] = array('id' => $id, 'title' => Request::post('update_title') ? Request::post('update_title') : 'No title', 'desc' => Request::post('update_desc') ? Request::post('update_desc') : 'No desc', 'thumbnail' => '/public/gallery/thumbnails/' . $id . '.png', 'photos' => ROOT_DIR . '/public/gallery/galleries/' . $id . '/');
// save content
if (File::setContent($jsonFile, json_encode($json))) {
//upload images
self::upload('thumbnail', 'update_thumbnail', $format, $thumbnails_path, $id);
self::upload('photos', 'update_photos', $format, $photos_path, $id);
return self::set_msg('Success The gallery has been updated');
}
} else {
die('Crsf detect!');
}
}
// resize gallery
if (Request::post('resizeGallery')) {
if (Request::post('token')) {
$uid = Request::post('gallery_id');
$w = Request::post('gallery_w');
$h = Request::post('gallery_h');
$files = File::scan($photos_path . $uid);
foreach ($files as $file) {
// Load the original image
$image = new SimpleImage($file);
$image->resize($w, $h, true);
$image->save($file);
}
return self::set_msg('Success The gallery Photos, has been resized');
}
}
// resize thumbnail
if (Request::post('resizeThumbnail')) {
if (Request::post('token')) {
$uid = Request::post('gallery_id');
$tw = Request::post('gallery_tw');
//.........这里部分代码省略.........
示例8: getPage
/**
* Get page
*
* <code>
* $page = Pages::getPage('downloads');
* </code>
*
* @access public
* @param string $url Url
* @return array
*/
public static function getPage($url)
{
// If url is empty that its a homepage
if ($url) {
$file = STORAGE_PATH . '/pages/' . $url;
} else {
$file = STORAGE_PATH . '/pages/' . 'index';
}
// Select the file
if (is_dir($file)) {
$file = STORAGE_PATH . '/pages/' . $url . '/index.md';
} else {
$file .= '.md';
}
// Get 404 page if file not exists
if (!file_exists($file)) {
$file = STORAGE_PATH . '/pages/' . '404.md';
Response::status(404);
}
// Create Unique Cache ID for requested page
$page_cache_id = md5('page' . ROOT_DIR . $file . filemtime($file));
if (Cache::driver()->contains($page_cache_id) && Config::get('system.pages.flush_cache') == false) {
return Cache::driver()->fetch($page_cache_id);
} else {
$content = file_get_contents($file);
$_page = explode('---', $content, 3);
$page = Yaml::parse($_page[1]);
$url = str_replace(STORAGE_PATH . '/pages', Url::getBase(), $file);
$url = str_replace('index.md', '', $url);
$url = str_replace('.md', '', $url);
$url = str_replace('\\', '/', $url);
$url = rtrim($url, '/');
$page['url'] = $url;
$_content = $_page[2];
// Parse page for summary <!--more-->
if (($pos = strpos($_content, "<!--more-->")) === false) {
$_content = Filter::apply('content', $_content);
} else {
$_content = explode("<!--more-->", $_content);
$_content['summary'] = Filter::apply('content', $_content[0]);
$_content['content'] = Filter::apply('content', $_content[0] . $_content[1]);
}
if (is_array($_content)) {
$page['summary'] = $_content['summary'];
$page['content'] = $_content['content'];
} else {
$page['content'] = $_content;
}
$page['slug'] = basename($file, '.md');
// Overload page title, keywords and description if needed
empty($page['title']) and $page['title'] = Config::get('site.title');
empty($page['keywords']) and $page['keywords'] = Config::get('site.keywords');
empty($page['description']) and $page['description'] = Config::get('site.description');
Cache::driver()->save($page_cache_id, $page);
return $page;
}
}
示例9:
</div><!--//content_inner-->
</div><!--//content-->
<div id="footer">
<p>
Missoula Adoptables was created for Software Engineering at the
University of Montana-Missoula by Jon-Michael Deldin and
Evan Cummings.
</p>
<p>
Contact us at
<a href="mailto:<?php
echo Site::getInstance()->getEmail();
?>
">
<?php
echo Site::getInstance()->getEmail();
?>
</a>
</p>
</div>
<script src="<?php
Url::getBase();
?>
/js/site.js"></script>
</body>
</html>
示例10: function
/**
* Poll for Fansoro CMS.
*
* @author Moncho Varela
*
* @version 1.0.0
*
* @license MIT
*/
Action::add('theme_footer', function () {
echo '<script>
var current = "' . Url::getCurrent() . '";
var pollDb = "' . Url::getBase() . '/plugins/poll/db/db.json";
</script>';
echo '<script src="' . Url::getBase() . '/plugins/poll/assets/poll.js"></script>';
});
/*
* Description: add function
* Example: {Poll(1,'Do you like Fansoro?','yes','no')}
*/
function Poll($id, $question, $answer1 = 'Yes', $answer2 = 'No')
{
// values
$id = isset($id) ? $id : '';
$question = isset($question) ? $question : '';
$answer1 = isset($answer1) ? $answer1 : '';
$answer2 = isset($answer2) ? $answer2 : '';
// json dir
$dir = PLUGINS_PATH . '/poll/db/db.json';
// clear vars init
示例11: logout
public function logout()
{
Session::instance()->vanish();
Url::redirectTo(Url::getBase());
}
示例12: logoutPage
public function logoutPage()
{
Session::destroy();
header('Location: ' . Url::getBase() . '/login');
exit;
}
示例13: function
<?php
/**
* Morfy Githubser Plugin.
*
* (c) Moncho Varela / Nakome <nakome@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
// add javascript file
Action::add('theme_footer', function () {
echo '<script type="text/javascript" src="' . Url::getBase() . '/plugins/githubser/githubser.js"></script>';
});
// add Shortcode {Githubser name="nakome"}
ShortCode::add('Githubser', function ($a) {
extract($a);
$name = $name ? $name : '';
return '<section>
<script type="text/javascript">var githubUsername = "' . $name . '";</script>
<div id="githubUser"></div>
</section>';
});
示例14: function
<?php
/**
* Youtube for Fansoro CMS
* Based on https://togetherjs.com/#tryitout-section.
*
* @author Moncho Varela
*
* @version 1.0.0
*
* @license MIT
*/
Action::add('theme_footer', function () {
echo '<script type="text/javascript" src="' . Url::getBase() . '/plugins/channel/assets/channel-dist.js"></script>';
});
ShortCode::add('Channel', function ($attr) {
extract($attr);
//{Channel name="nakome" limit="50"}
$name = isset($name) ? $name : Config::get('plugins.channel.username');
$limit = isset($limit) ? $limit : 1;
$quality = isset($quality) ? $quality : 'false';
$quantity = isset($quantity) ? $quantity : 8;
// template factory
$template = Template::factory(PLUGINS_PATH . '/' . Config::get('plugins.channel.name') . '/templates/');
$template->setOptions(['strip' => false]);
return $template->fetch('gallery.tpl', ['name' => $name, 'limit' => $limit, 'quality' => $quality, 'quantity' => $quantity, 'apikey' => Config::get('plugins.channel.apikey')]);
});
示例15: item_detail
/**
* Description: Producto Details Shortcode
* Shortcode to get details of product item.
*/
public static function item_detail($attributes, $content)
{
// Extract attributes
extract($attributes);
if (isset($id)) {
$id = $id;
} else {
$id = '';
}
if (isset($url)) {
$url = $url;
} else {
$url = '';
}
if (isset($title)) {
$title = $title;
} else {
$title = '';
}
if (isset($description)) {
$description = $description;
} else {
$description = '';
}
if (isset($image)) {
$image = $image;
} else {
$image = '';
}
if (isset($price)) {
$price = $price;
} else {
$price = '';
}
$template = Template::factory(PLUGINS_PATH . '/shipcart/templates/');
$template->setOptions(['strip' => false]);
// show template
return $template->fetch('item_detail.tpl', ['id' => $id, 'url' => Url::getBase() . $url, 'title' => $title, 'description' => $description, 'image' => Url::getBase() . $image, 'price' => $price, 'content' => Filter::apply('content', $content)]);
}