本文整理汇总了PHP中File::N方法的典型用法代码示例。如果您正苦于以下问题:PHP File::N方法的具体用法?PHP File::N怎么用?PHP File::N使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类File
的用法示例。
在下文中一共展示了File::N方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pagePath
/**
* ==========================================================================
* GET PAGE PATH
* ==========================================================================
*
* -- CODE: -----------------------------------------------------------------
*
* var_dump(Get::pagePath('lorem-ipsum'));
*
* --------------------------------------------------------------------------
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Parameter | Type | Description
* --------- | ----- | -----------------------------------------------------
* $detector | mixed | Slug, ID or time of the page
* --------- | ----- | -----------------------------------------------------
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
*/
public static function pagePath($detector, $folder = PAGE)
{
foreach (glob($folder . DS . '*.{txt,draft,archive}', GLOB_NOSORT | GLOB_BRACE) as $path) {
list($time, $kind, $slug) = explode('_', File::N($path), 3);
if ($slug === $detector || (string) $time === Date::format($detector, 'Y-m-d-H-i-s')) {
return $path;
}
}
return false;
}
示例2: call_user_func
<?php
if ($responses = call_user_func('Get::' . $segment[0] . 's', 'DESC', 'post:' . Date::slug(Request::get('post', $page->post)))) {
?>
<div class="grid-group">
<span class="grid span-1 form-label"><?php
echo $speak->parent;
?>
</span>
<span class="grid span-5">
<?php
if (count($responses) > 600) {
// 600+ response(s), fallback to text input for performance reason
$_parent = call_user_func('Get::' . $segment[0], $page->parent, array('message', 'message_raw'));
echo Form::text('parent', Request::get('parent', Guardian::wayback('parent', $page->parent)), time());
echo $_parent ? ' ' . Jot::btn('action:external-link', "", $_parent->permalink, array('title' => $_parent->name, 'target' => '_blank')) : "";
} else {
$results = array();
$s = Date::slug($page->id);
foreach ($responses as $v) {
list($_post, $_time, $_parent) = explode('_', File::N($v), 3);
$results[($s === $_time ? '.' : "") . Date::format($_time, 'U')] = Date::extract($_time, 'FORMAT_3');
}
krsort($results);
echo Form::select('parent', array("" => '— ' . $speak->none . ' —') + $results, Request::get('parent', Guardian::wayback('parent', $page->parent)));
}
?>
</span>
</div>
<?php
}
示例3: do_response_reply_x
function do_response_reply_x($post)
{
global $config, $speak, $parent;
$s = Asset::loaded($config->protocol . ICON_LIBRARY_PATH) ? '<i class="fa fa-times-circle"></i> ' : "";
echo ' <a href="' . $post->url . '" class="btn btn-reject btn-reject-reply"' . ($parent === false ? ' style="display:none;"' : "") . '>' . $s . $speak->cancel . '</a>';
}
Weapon::add('comment_footer', 'do_response_reply', 20.1);
Weapon::add('comment_form_button_after', 'do_response_reply_x');
Weapon::add('shell_before', 'do_response_reply_css');
Weapon::add('SHIPMENT_REGION_BOTTOM', 'do_response_reply_js');
// No JavaScript
if ($parent !== false) {
Guardian::memorize('parent', $parent);
if ($response = Get::commentAnchor($parent)) {
Weapon::add('chunk_before', function ($G) use($speak, $parent, $response) {
if (File::N($G['data']['path']) === 'comment.form') {
$prefix = File::B(File::D($response->path));
$to = Config::speak($prefix . '_reply_to_', Cell::a('#' . $prefix . '-' . $parent, $response->name));
echo Cell::h4($to);
}
});
}
}
// Error
if ($s = Request::post('parent', false)) {
Filter::add('guardian:kick', function ($url) use($config, $s) {
if (!Notify::errors()) {
return $url;
}
$ss = explode('#', $url, 2);
return $config->url_current . HTTP::query('reply', $s) . '#' . $ss[1];
示例4: array
<?php
$bucket = array();
if ($config->total_pages > 0) {
foreach (Get::pages() as $page) {
list($time, $kind, $slug) = explode('_', File::N($page), 3);
$bucket[] = (object) array('url' => $config->url . '/' . $slug, 'date' => Date::format($time, 'c'), 'changefreq' => 'weekly', 'priority' => (string) '0.5');
}
}
if ($config->total_articles > 0) {
foreach (Get::articles() as $article) {
list($time, $kind, $slug) = explode('_', File::N($article), 3);
$bucket[] = (object) array('url' => $config->url . '/' . $config->index->slug . '/' . $slug, 'date' => Date::format($time, 'c'), 'changefreq' => 'weekly', 'priority' => (string) '1.0');
}
}
echo '<?xml version="1.0" encoding="UTF-8" ?>';
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
if (!empty($bucket)) {
foreach ($bucket as $i => $item) {
echo '<url>';
echo '<loc>' . $item->url . '</loc>';
echo '<lastmod>' . $item->date . '</lastmod>';
echo '<changefreq>' . $item->changefreq . '</changefreq>';
echo '<priority>' . $item->priority . '</priority>';
Weapon::fire('sitemap_item', array($item, $i));
echo '</url>';
}
}
echo '</urlset>';
示例5: function
*
*/
Route::accept($config->index->slug . '/(:any)', function ($slug = "") use($config, $speak) {
if (!($article = Get::article($slug))) {
Shield::abort('404-article');
}
if ($article->state === 'drafted') {
Shield::abort('404-article');
}
if (isset($_GET['repair']) && Guardian::happy()) {
Guardian::kick($config->manager->slug . '/article/repair/id:' . $article->id);
}
// Collecting article slug ...
if ($articles = Get::articles('DESC', "", File::E($article->path))) {
$articles = Mecha::walk($articles, function ($path) {
$parts = explode('_', File::N($path), 3);
return $parts[2];
});
}
Filter::add('pager:url', function ($url) {
return Filter::apply('article:url', $url);
});
Config::set(array('page_title' => $article->title . $config->title_separator . $config->title, 'article' => $article, 'pagination' => Navigator::extract($articles, $slug, 1, $config->index->slug)));
Weapon::add('shell_after', function () use($article) {
if (isset($article->css) && trim($article->css) !== "") {
echo O_BEGIN . $article->css . O_END;
}
});
Weapon::add('sword_after', function () use($article) {
if (isset($article->js) && trim($article->js) !== "") {
echo O_BEGIN . $article->js . O_END;
示例6: function
*
*/
Route::accept($config->index->slug . '/(:any)', function ($slug = "") use($config, $speak) {
if (!($article = Get::article($slug))) {
Shield::abort('404-article');
}
if (isset($_GET['repair']) && Guardian::happy()) {
Guardian::kick($config->manager->slug . '/article/repair/id:' . $article->id);
}
if ($article->state === 'draft') {
Shield::abort('404-article');
}
// Collecting article slug ...
if ($articles = Get::articles('DESC', "", File::E($article->path))) {
foreach ($articles as &$v) {
$parts = explode('_', File::N($v), 3);
$v = $parts[2];
}
unset($parts, $v);
}
Config::set(array('page_title' => $article->title . $config->title_separator . $config->title, 'article' => $article, 'pagination' => Navigator::extract($articles, $slug, 1, $config->index->slug)));
Weapon::add('shell_after', function () use($article) {
if (isset($article->css) && trim($article->css) !== "") {
echo O_BEGIN . $article->css . O_END;
}
});
Weapon::add('sword_after', function () use($article) {
if (isset($article->js) && trim($article->js) !== "") {
echo O_BEGIN . $article->js . O_END;
}
});
示例7: extractTo
/**
* ====================================================================
* EXTRACTING
* ====================================================================
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Parameter | Type | Description
* ------------ | ------ | -------------------------------------------
* $destination | string | Path to a package file
* $bucket | string | Load the extracted file(s) into this folder
* ------------ | ------ | -------------------------------------------
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
*/
public static function extractTo($destination, $bucket = false)
{
if (is_null($destination)) {
$destination = File::D(self::$open);
} else {
$destination = rtrim(File::path($destination), DS);
}
// Handling for `Package::take('file.zip')->extractTo('foo/bar', true)`
if ($bucket === true) {
$bucket = File::N(self::$open);
}
if ($bucket !== false && !File::exist($destination . DS . $bucket)) {
$bucket = File::path($bucket);
mkdir($destination . DS . $bucket, 0777, true);
}
if (self::$zip->open(self::$open) === true) {
if ($bucket !== false) {
self::$zip->extractTo($destination . DS . $bucket);
} else {
self::$zip->extractTo($destination);
}
self::$zip->close();
}
return new static();
}
示例8: attach
/**
* ==========================================================
* RENDER A PAGE
* ==========================================================
*
* -- CODE: -------------------------------------------------
*
* Shield::attach('article');
*
* ----------------------------------------------------------
*
*/
public static function attach($name, $fallback = false, $buffer = true)
{
$path__ = File::path($name);
$s = explode('-', File::N($name), 2);
$G = array('data' => array('name' => $name, 'name_base' => $s[0]));
if (strpos($path__, ROOT) === 0 && file_exists($path__) && is_file($path__)) {
// do nothing ...
} else {
if ($_path = File::exist(self::path($path__, $fallback))) {
$path__ = $_path;
} else {
if ($_path = File::exist(self::path($s[0], $fallback))) {
$path__ = $_path;
} else {
Guardian::abort(Config::speak('notify_file_not_exist', '<code>' . $path__ . '</code>'));
}
}
}
$lot__ = self::cargo();
$path__ = Filter::apply('shield:path', $path__);
$G['data']['lot'] = $lot__;
$G['data']['path'] = $path__;
$G['data']['path_base'] = $s[0];
$out = "";
// Begin shield
Weapon::fire('shield_lot_before', array($G, $G));
extract(Filter::apply('shield:lot', $lot__));
Weapon::fire('shield_lot_after', array($G, $G));
Weapon::fire('shield_before', array($G, $G));
if ($buffer) {
ob_start(function ($content) use($path__, &$out) {
$content = Filter::apply('shield:input', $content, $path__);
$out = Filter::apply('shield:output', $content, $path__);
return $out;
});
require $path__;
ob_end_flush();
} else {
require $path__;
}
$G['data']['content'] = $out;
// Reset shield lot
self::$lot = array();
// End shield
Weapon::fire('shield_after', array($G, $G));
exit;
}
示例9: array
<?php
$name = $_FILES['file']['name'];
$mime = $_FILES['file']['type'];
$extension = File::E($name);
$mime_accept = array('application/download', 'application/octet-stream', 'application/x-compressed', 'application/x-zip-compressed', 'application/zip', 'multipart/x-zip');
$extension_accept = array('zip');
$path = File::N($name);
if (!empty($name)) {
if (File::exist($destination . DS . $path)) {
Notify::error(Config::speak('notify_folder_exist', '<code>' . $path . '</code>'));
} else {
if (!Mecha::walk($mime_accept)->has($mime) || !Mecha::walk($extension_accept)->has($extension)) {
Notify::error(Config::speak('notify_invalid_file_extension', 'ZIP'));
}
}
} else {
Notify::error($speak->notify_error_no_file_selected);
}
示例10: function
<?php
/**
* Custom Function(s)
* ------------------
*
* Add your own custom function(s) here. You can do something like
* making custom widget(s), custom route(s), custom filter(s),
* custom weapon(s), loading custom asset(s), etc. So that you can
* manipulate the site output without having to touch the CMS core.
*
*/
// HTML output manipulation
Filter::add('chunk:output', function ($content, $path) use($config, $speak) {
$name = File::N($path);
// Add an icon to the log in form button
if ($name === 'page.body' && Route::is($config->manager->slug . '/login')) {
return str_replace('>' . $speak->login . '</button>', '><i class="fa fa-key"></i> ' . trim(strip_tags($speak->login)) . '</button>', $content);
}
// Add an icon to the older and newer link text
if ($name === 'pager') {
$content = str_replace('>' . $speak->newer . '</a>', '><i class="fa fa-angle-left"></i> ' . trim(strip_tags($speak->newer)) . '</a>', $content);
$content = str_replace('>' . $speak->older . '</a>', '>' . trim(strip_tags($speak->older)) . ' <i class="fa fa-angle-right"></i></a>', $content);
}
// Add an icon to the article date
if ($name === 'article.time') {
$content = str_replace('<time ', '<i class="fa fa-calendar"></i> <time ', $content);
}
// Add an icon to the comments title
if ($name === 'comments.header') {
$content = str_replace('<h3>', '<h3><i class="fa fa-comments"></i> ', $content);
示例11: archive
/**
* Widget Archive
* --------------
*
* [1]. Widget::archive('HIERARCHY');
* [2]. Widget::archive('HIERARCHY', 'ASC');
*
*/
public static function archive($type = 'HIERARCHY', $sort = 'DESC', $folder = ARTICLE)
{
$T1 = TAB;
$T2 = str_repeat($T1, 2);
$T3 = str_repeat($T1, 3);
$T4 = str_repeat($T1, 4);
$kin = strtolower($type);
$p = $folder !== POST ? File::B($folder) : 'post';
$id = Config::get('widget_archive_' . $kin . '_id', 0) + 1;
$config = Config::get();
$speak = Config::speak();
$query = $config->archive_query;
$month_names = (array) $speak->month_names;
$archives = array();
$html = O_BEGIN . '<div class="widget widget-archive widget-archive-' . $kin . '" id="widget-archive-' . $kin . '-' . $id . '">' . NL;
if ($files = call_user_func('Get::' . $p . 's', $sort)) {
if ($type === 'HIERARCHY') {
$i = 0;
foreach ($files as $file) {
list($year, $month) = explode('-', File::N($file));
$archives[$year][$month][] = $file;
}
$html .= $T1 . '<ul>' . NL;
foreach ($archives as $year => $months) {
if (is_array($months)) {
$posts_count_per_year = 0;
$s = explode('-', $query);
$expand = $query ? (int) $s[0] === (int) $year : $i === 0;
foreach ($months as $month) {
$posts_count_per_year += count($month);
}
$html .= $T2 . '<li class="' . ($expand ? 'open' : 'close') . ((int) $query === (int) $year ? ' ' . self::$config['classes']['current'] : "") . '">' . NL . $T3 . '<a href="javascript:;" class="toggle ' . ($expand ? 'open' : 'close') . '">' . ($expand ? '▼' : '►') . '</a> <a href="' . Filter::colon('archive:url', $config->url . '/' . $config->archive->slug . '/' . $year) . '">' . $year . '</a> <span class="counter">' . $posts_count_per_year . '</span>' . NL;
$html .= $T3 . '<ul>' . NL;
foreach ($months as $month => $days) {
if (is_array($days)) {
$html .= $T4 . '<li' . ((string) $query === $year . '-' . $month ? ' class="' . self::$config['classes']['current'] . '"' : "") . '><a href="' . Filter::colon('archive:url', $config->url . '/' . $config->archive->slug . '/' . $year . '-' . $month) . '">' . $year . ' ' . $month_names[(int) $month - 1] . '</a> <span class="counter">' . count($days) . '</span></li>' . NL;
}
}
$html .= $T3 . '</ul>' . NL;
$html .= $T2 . '</li>' . NL;
}
$i++;
}
$html .= $T1 . '</ul>' . NL;
}
if ($type === 'LIST' || $type === 'DROPDOWN') {
foreach ($files as $name) {
$s = explode('-', File::N($name));
$archives[] = $s[0] . '-' . $s[1];
}
$counter = array_count_values($archives);
$archives = array_unique($archives);
$i = 0;
if ($type === 'LIST') {
$html .= $T1 . '<ul>' . NL;
foreach ($archives as $archive) {
list($year, $month) = explode('-', $archive);
$html .= $T2 . '<li' . ((string) $query === $year . '-' . $month ? ' class="' . self::$config['classes']['current'] . '"' : "") . '><a href="' . Filter::colon('archive:url', $config->url . '/' . $config->archive->slug . '/' . $archive) . '">' . $year . ' ' . $month_names[(int) $month - 1] . '</a> <span class="counter">' . $counter[$archive] . '</span></li>' . NL;
$i++;
}
$html .= $T1 . '</ul>' . NL;
} else {
$html .= $T1 . '<select>' . NL . ($query === "" ? $T2 . '<option disabled selected>' . $speak->select . '…</option>' . NL : "");
foreach ($archives as $archive) {
list($year, $month) = explode('-', $archive);
$html .= $T2 . '<option value="' . Filter::colon('archive:url', $config->url . '/' . $config->archive->slug . '/' . $archive) . '"' . ((string) $query === $year . '-' . $month ? ' selected' : "") . '>' . $year . ' ' . $month_names[(int) $month - 1] . ' (' . $counter[$archive] . ')</option>' . NL;
}
$html .= $T1 . '</select>' . NL;
}
}
} else {
$html .= $T1 . Config::speak('notify_empty', strtolower($speak->{$p . 's'})) . NL;
}
$html .= '</div>' . O_END;
Config::set('widget_archive_' . $kin . '_id', $id);
return Filter::apply(array('widget:archive.' . $kin, 'widget:archive', 'widget'), $html, $id);
}
示例12: array
?>
/update" method="post">
<?php
echo Form::hidden('token', $token);
?>
<?php
$twitter_cards_config = File::open(__DIR__ . DS . 'states' . DS . 'config.txt')->unserialize();
?>
<label class="grid-group">
<span class="grid span-2 form-label"><?php
echo $speak->plugin_twitter_cards->twitter_site . ' ' . Jot::info($speak->plugin_twitter_cards->description);
?>
</span>
<span class="grid span-4">
<?php
echo Form::text('twitter_site', $twitter_cards_config['twitter_site'], Text::parse(File::N($config->host), '->array_key', true), array('class' => 'input-block'));
?>
</span>
</label>
<label class="grid-group">
<span class="grid span-2 form-label"><?php
echo $speak->plugin_twitter_cards->twitter_creator . ' ' . Jot::info($speak->plugin_twitter_cards->description);
?>
</span>
<span class="grid span-4">
<?php
echo Form::text('twitter_creator', $twitter_cards_config['twitter_creator'], Text::parse($config->author->name, '->array_key', true), array('class' => 'input-block'));
?>
</span>
</label>
<div class="grid-group">
示例13: md5
<?php
$c_dashboard = $config->states->{'plugin_' . md5(File::B(__DIR__))};
$options = array();
foreach (glob(__DIR__ . DS . 'assets' . DS . 'shell' . DS . 'pigment' . DS . '*.css', GLOB_NOSORT) as $skin) {
$s = File::N($skin);
if ($ss = File::open($skin)->get(1)) {
// Get title from CSS comment ...
$ss = preg_replace('#\\/\\*!?\\s*(.*?)\\s*\\*\\/#', '$1', $ss);
} else {
$ss = Text::parse($s, '->title');
}
$options[$s] = $ss;
}
asort($options);
?>
<p><?php
echo Form::select('skin', $options, $c_dashboard->skin) . ' ' . Jot::button('action', $speak->update);
?>
</p>
示例14:
<fieldset>
<legend>Disqus</legend>
<label class="grid-group">
<span class="grid span-1 form-label"><?php
echo $speak->id . ' ' . Jot::info($speak->plugin_comment_service->description->disqus_id);
?>
</span>
<span class="grid span-5"><?php
echo Form::text('services[disqus][id]', $comment_service_config['services']['disqus']['id'], File::N($config->host));
?>
</span>
</label>
</fieldset>
示例15: array
if (trim($request['email']) !== "" && !Guardian::check($request['email'], '->email')) {
Notify::error($speak->notify_invalid_email);
Guardian::memorize($request);
}
$P = array('data' => $request, 'action' => $request['action']);
if (!Notify::errors()) {
$name = $request['name'];
$email = Text::parse($request['email'], '->broken_entity');
$url = isset($request['url']) ? $request['url'] : false;
$message = $request['message'];
$field = Request::post('fields', array());
include DECK . DS . 'workers' . DS . 'task.field.2.php';
include DECK . DS . 'workers' . DS . 'task.field.1.php';
// Update data
Page::open($comment->path)->header(array('Name' => $name, 'Email' => $email, 'URL' => $url, 'Status' => $request['status'], 'Content Type' => Request::post('content_type', 'HTML'), 'UA' => $request['ua'] !== 'N/A' ? $request['ua'] : false, 'IP' => $request['ip'] !== 'N/A' ? $request['ip'] : false, 'Fields' => !empty($field) ? Text::parse($field, '->encoded_json') : false))->content($message)->save();
File::open($comment->path)->renameTo(File::N($comment->path) . $extension);
Notify::success(Config::speak('notify_success_updated', $speak->comment));
Weapon::fire('on_comment_update', array($G, $P));
Weapon::fire('on_comment_repair', array($G, $P));
Guardian::kick($config->manager->slug . '/comment/repair/id:' . $id);
}
}
Shield::lot(array('segment' => 'comment', 'default' => $comment))->attach('manager', false);
});
/**
* Comment Killer
* --------------
*/
Route::accept($config->manager->slug . '/comment/kill/id:(:num)', function ($id = "") use($config, $speak) {
if (Guardian::get('status') !== 'pilot') {
Shield::abort();