本文整理汇总了PHP中Weapon::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Weapon::add方法的具体用法?PHP Weapon::add怎么用?PHP Weapon::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Weapon
的用法示例。
在下文中一共展示了Weapon::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
} else {
Page::open($page->path)->header($header)->content($content)->save();
File::open($page->path)->renameTo(Date::format($date, 'Y-m-d-H-i-s') . '__' . $slug . $extension);
include DECK . DS . 'workers' . DS . 'task.custom.1.php';
if ($page->slug !== $slug && ($php_file = File::exist(File::D($page->path) . DS . $page->slug . '.php'))) {
File::open($php_file)->renameTo($slug . '.php');
}
Notify::success(Config::speak('notify_success_updated', $title) . ($extension === '.txt' ? ' <a class="pull-right" href="' . $config->url . '/' . $slug . '" target="_blank"><i class="fa fa-eye"></i> ' . $speak->view . '</a>' : ""));
Weapon::fire('on_page_update', array($G, $P));
Weapon::fire('on_page_repair', array($G, $P));
Guardian::kick($config->manager->slug . '/page/repair/id:' . Date::format($date, 'U'));
}
}
}
Weapon::add('SHIPMENT_REGION_BOTTOM', function () {
echo Asset::javascript('manager/assets/sword/editor.compose.js', "", 'sword/editor.compose.min.js');
}, 11);
Shield::lot(array('segment' => 'page', 'default' => $page))->attach('manager', false);
});
/**
* Page Killer
* -----------
*/
Route::accept($config->manager->slug . '/page/kill/id:(:num)', function ($id = "") use($config, $speak) {
if (!($page = Get::page($id, array('comments')))) {
Shield::abort();
}
if (Guardian::get('status') !== 'pilot' && Guardian::get('author') !== $page->author) {
Shield::abort();
}
Config::set(array('page_title' => $speak->deleting . ': ' . $page->title . $config->title_separator . $config->manager->title, 'page' => $page, 'cargo' => DECK . DS . 'workers' . DS . 'kill.page.php'));
示例2: function
<?php
Weapon::add('meta', function () {
$config = Config::get();
$indent = str_repeat(TAB, 2);
echo $indent . '<!-- Start Facebook Open Graph -->' . NL;
echo $indent . '<meta property="og:title" content="' . strip_tags($config->page_title) . '"' . ES . NL;
echo $indent . '<meta property="og:type" content="' . ($config->page_type == 'article' ? 'article' : 'website') . '"' . ES . NL;
echo $indent . '<meta property="og:url" content="' . $config->url_current . '"' . ES . NL;
if (isset($config->article->image)) {
echo $indent . '<meta property="og:image" content="' . $config->article->image . '"' . ES . NL;
} else {
if (isset($config->page->image)) {
echo $indent . '<meta property="og:image" content="' . $config->page->image . '"' . ES . NL;
}
}
echo $indent . '<meta property="og:site_name" content="' . $config->title . '"' . ES . NL;
if (isset($config->article->description)) {
echo $indent . '<meta property="og:description" content="' . strip_tags($config->article->description) . '"' . ES . NL;
} else {
if (isset($config->page->description)) {
echo $indent . '<meta property="og:description" content="' . strip_tags($config->page->description) . '"' . ES . NL;
} else {
echo $indent . '<meta property="og:description" content="' . strip_tags($config->description) . '"' . ES . NL;
}
}
echo $indent . '<!-- End Facebook Open Graph -->' . NL;
}, 11);
示例3: array
$text_kill = Config::speak('manager._this_', array($speak->delete, $text));
$bars[$text] = array('icon' => 'plus', 'url' => $config->manager->slug . '/' . $type . '/ignite', 'description' => Config::speak('manager.title_new_', $text), 'stack' => 9.029999999999999);
$bars[$speak->edit] = array('icon' => 'pencil', 'url' => $config->manager->slug . '/' . $type . '/repair/id:' . $id, 'description' => $text_repair, 'stack' => 9.039999999999999);
$bars[$speak->delete] = array('icon' => 'times', 'url' => $config->manager->slug . '/' . $type . '/kill/id:' . $id, 'description' => $text_kill, 'stack' => 9.050000000000001);
} else {
$link = Cell::a($config->manager->slug . '/article/ignite', Config::speak('manager.title_new_', $speak->article));
$link .= ' · ';
$link .= Cell::a($config->manager->slug . '/page/ignite', Config::speak('manager.title_new_', $speak->page));
$bars[$speak->add] = array('icon' => 'plus', 'url' => $config->manager->slug . '/article/ignite', 'description' => $link, 'stack' => 9.029999999999999);
}
Config::merge('manager_menu', $menus);
Config::merge('manager_bar', $bars);
});
}
// Loading frontend task(s) and route(s)
Weapon::add('routes_before', function () use($config, $speak) {
require __DIR__ . DS . 'workers' . DS . 'task.comment.ignite.php';
require __DIR__ . DS . 'workers' . DS . 'route.login.php';
});
// Add log in/out link in shield footer
function do_footer_manager_link($content, $path)
{
global $config, $speak;
if (File::N($path) === 'block.footer.bar') {
$s = Guardian::happy() ? '<a href="' . Filter::colon('manager:url', $config->url . '/' . $config->manager->slug . '/logout') . '" rel="nofollow">' . $speak->log_out . '</a>' : '<a href="' . Filter::colon('manager:url', $config->url . '/' . $config->manager->slug . '/login') . '" rel="nofollow">' . $speak->log_in . '</a>';
return str_replace('<div class="blog-footer-right">', '<div class="blog-footer-right">' . $s, $content);
}
return $content;
}
// Apply `do_footer_manager_link` filter
Filter::add('chunk:output', 'do_footer_manager_link');
示例4: time
$post = Date::slug($article->time);
$id = (int) time();
$parent = Request::post('parent');
$P = array('data' => $request);
$P['data']['id'] = $id;
$name = strip_tags($request['name']);
$email = Text::parse($request['email'], '->broken_entity');
$url = isset($request['url']) && trim($request['url']) !== "" ? $request['url'] : false;
$parser = strip_tags(Request::post('content_type', $config->html_parser->active));
$message = Text::parse($request['message'], '->text', WISE_CELL . '<img>', false);
$field = Request::post('fields', array());
include File::D(__DIR__, 2) . DS . 'task.fields.php';
// Temporarily disallow image(s) in comment to prevent XSS
$message = preg_replace('#<img(\\s[^<>]*?)>#i', '<img$1>', $message);
Page::header(array('Name' => $name, 'Email' => $email, 'URL' => $url, 'Status' => Guardian::happy() ? 1 : 2, 'Content Type' => $parser, 'Fields' => !empty($field) ? Text::parse($field, '->encoded_json') : false))->content($message)->saveTo(COMMENT . DS . $post . '_' . Date::slug($id) . '_' . ($parent ? Date::slug($parent) : '0000-00-00-00-00-00') . $extension);
Notify::success(Config::speak('notify_success_submitted', $speak->comment));
if ($extension === '.hold') {
Notify::info($speak->notify_info_comment_moderation);
}
Weapon::fire(array('on_comment_update', 'on_comment_construct'), array($G, $P));
Guardian::kick($config->url_current . $config->ur_query . (!Guardian::happy() && $config->comments->moderation ? '#' . $comment_form_id : '#' . sprintf($comment_id, Date::format($id, 'U'))));
} else {
Guardian::kick($config->url_current . $config->url_query . '#' . $comment_form_id);
}
}
}
}
}
}
Weapon::add('shield_before', 'do_comment_construct', 1);
示例5: function
<?php
Weapon::add('on_comment_construct', function ($G, $P) use($config, $speak) {
if ($config->is->post && ($post = $G['data'][$config->page_type])) {
$c = $config->states->{'plugin_' . md5(File::B(__DIR__))};
$title = $post['title'];
$url = $post['url'] . '#' . sprintf($G['data']['comment_id'], Date::format($P['data']['id'], 'U'));
$topic = sprintf($c->subject, $title, $url);
$parser = Request::post('content_type', $config->html_parser->active);
$message = '<blockquote><p>' . sprintf($c->message, $title, $url) . '</p></blockquote>';
$message .= '<h3>' . $P['data']['name'] . '</h3>';
$message .= $parser !== false && $parser !== 'HTML' ? Text::parse($P['data']['message'], '->html') : $P['data']['message'];
$message .= '<p>';
$message .= '<a href="' . $config->url . '/' . $config->manager->slug . '/comment/repair/id:' . $P['data']['id'] . '">' . $speak->edit . '</a>';
$message .= ' / ';
$message .= '<a href="' . $config->url . '/' . $config->manager->slug . '/comment/kill/id:' . $P['data']['id'] . '">' . $speak->delete . '</a>';
$message .= '</p>';
// Sending email notification ...
if (!Guardian::happy() && Notify::send($P['data']['email'], $config->author->email, $topic, $message, 'comment:')) {
Weapon::fire('on_comment_notify_construct', array($P, $config->author->email, $topic, $message));
}
}
});
示例6: function
<?php
$post = 'article';
$response = 'comment';
Weapon::add('tab_content_1_before', function ($page, $segment) use($config, $speak) {
include __DIR__ . DS . 'unit' . DS . 'form' . DS . 'response' . DS . 'post.php';
}, 0.9);
Weapon::add('tab_content_1_before', function ($page, $segment) use($config, $speak) {
include __DIR__ . DS . 'unit' . DS . 'form' . DS . 'response' . DS . 'status.php';
}, 3.1);
Weapon::add('tab_content_1_before', function ($page, $segment) use($config, $speak) {
include __DIR__ . DS . 'unit' . DS . 'form' . DS . 'response' . DS . 'parent.php';
}, 5.1);
require __DIR__ . DS . 'route.response.php';
示例7: function
<?php
Weapon::add('shield_before', function () {
$config = Config::get();
if ($config->comments->allow) {
$comment_service_config = File::open(__DIR__ . DS . 'states' . DS . 'config.txt')->unserialize();
Config::set('plugins.comment_service_config', $comment_service_config);
$active = $comment_service_config['service'];
if ($s = Config::get($config->page_type)) {
$active = isset($s->fields->comment_service) && trim($s->fields->comment_service) !== "" ? $s->fields->comment_service : $active;
}
if ($launch = File::exist(__DIR__ . DS . 'workers' . DS . $active . DS . 'launch.php')) {
require $launch;
}
Filter::add('chunk:path', function ($path) use($active) {
if ($active !== 0 && File::N($path) === 'comments') {
return __DIR__ . DS . 'workers' . DS . $active . DS . 'comments.php';
}
return $path;
});
}
});
示例8: function
* --------------
*/
// Add default article footer link(s)
Weapon::add('article_footer', function ($article) use($config, $speak) {
$e = File::E($article->path);
$comments = count(glob(COMMENT . DS . Date::slug($article->id) . '_*_*.{txt,hold}', GLOB_NOSORT | GLOB_BRACE));
$t = Jot::icon('comments') . ' ' . $comments;
$tt = array('title' => $comments . ' ' . ($comments === 1 ? $speak->comment : $speak->comments));
$comments = ($e === 'draft' || $comments === 0 ? Cell::span($t, $tt) : Cell::a($config->manager->slug . '/comment?filter=post%3A' . $article->id, $t, null, $tt)) . ' · ';
$status = Mecha::alter($e, array('draft' => Jot::span('info', Jot::icon('clock-o') . ' ' . $speak->draft) . ' · ', 'archive' => Jot::span('info', Jot::icon('history') . ' ' . $speak->archive) . ' · '), "");
echo $comments . $status . Cell::a($config->manager->slug . '/article/repair/id:' . $article->id, $speak->edit) . ' / ' . Cell::a($config->manager->slug . '/article/kill/id:' . $article->id, $speak->delete);
}, 20);
// Add default page footer link(s)
Weapon::add('page_footer', function ($page) use($config, $speak) {
$status = Mecha::alter(File::E($page->path), array('draft' => Jot::span('info', Jot::icon('clock-o') . ' ' . $speak->draft) . ' · ', 'archive' => Jot::span('info', Jot::icon('history') . ' ' . $speak->archive) . ' · '), "");
echo $status . Cell::a($config->manager->slug . '/page/repair/id:' . $page->id, $speak->edit) . ' / ' . Cell::a($config->manager->slug . '/page/kill/id:' . $page->id, $speak->delete);
}, 20);
/**
* Backend Route(s)
* ----------------
*
* Load the routes.
*
*/
Weapon::add('plugins_after', function () use($config, $speak, $segment) {
// loading cargo ...
require __DIR__ . DS . 'workers' . DS . 'cargo.php';
if ($detour = File::exist(__DIR__ . DS . 'workers' . DS . 'route.' . $segment . '.php')) {
require $detour;
}
}, 1);
示例9: array
$new_config['shield'] = $path === 'attach' ? $slug : 'normal';
File::serialize($new_config)->saveTo(STATE . DS . 'config.txt', 0600);
$G = array('data' => array('id' => $slug, 'action' => $path));
Notify::success(Config::speak('notify_success_updated', $speak->shield));
foreach (glob(LOG . DS . 'asset.*.log', GLOB_NOSORT) as $asset_cache) {
File::open($asset_cache)->delete();
}
Guardian::kick($config->manager->slug . '/shield/' . $slug);
});
/**
* Shield Updater (Base)
* ---------------------
*/
if ($route = Route::is($config->manager->slug . '/shield/(:any)/update')) {
Weapon::add('routes_before', function () use($config, $speak, $route) {
if (!Route::accepted($route['path'])) {
Route::accept($route['path'], function () use($config, $speak, $route) {
if ($request = Request::post()) {
$s = $route['lot'][0];
$request = Filter::apply('request:__shield', $request, $s);
Guardian::checkToken($request['token']);
unset($request['token']);
// remove token from request array
File::serialize($request)->saveTo(SHIELD . DS . $s . DS . 'states' . DS . 'config.txt', 0600);
Notify::success(Config::speak('notify_success_updated', $speak->shield));
Guardian::kick(File::D($config->url_current));
}
});
}
}, 1);
}
示例10: do_facebook_open_graph
<?php
function do_facebook_open_graph()
{
$config = Config::get();
$T2 = str_repeat(TAB, 2);
echo O_BEGIN . $T2 . '<!-- Start Facebook Open Graph -->' . NL;
echo $T2 . '<meta property="og:title" content="' . Text::parse($config->page_title, '->text') . '"' . ES . NL;
echo $T2 . '<meta property="og:url" content="' . Filter::colon('og:url', $config->url_current) . '"' . ES . NL;
if (isset($config->{$config->page_type}->description)) {
$config->description = $config->{$config->page_type}->description;
}
echo $T2 . '<meta property="og:description" content="' . Text::parse($config->description, '->text') . '"' . ES . NL;
if ($config->page_type !== '404' && isset($config->{$config->page_type}->image)) {
echo $T2 . '<meta property="og:image" content="' . $config->{$config->page_type}->image . '"' . ES . NL;
} else {
echo $T2 . '<meta property="og:image" content="' . Filter::colon('favicon:url', $config->url . '/favicon.ico') . '"' . ES . NL;
}
echo $T2 . '<meta property="og:site_name" content="' . $config->title . '"' . ES . NL;
echo $T2 . '<meta property="og:type" content="' . ($config->page_type === 'article' ? 'article' : 'website') . '"' . ES . NL;
echo $T2 . '<!-- End Facebook Open Graph -->' . O_END;
}
Weapon::add('meta', 'do_facebook_open_graph', 11);
示例11: unset
unset($request['content']);
// Remove content from request array
$request['path'] = $results;
File::serialize($request)->saveTo(__DIR__ . DS . 'states' . DS . 'config.txt', 0600);
Notify::success(Config::speak('notify_success_updated', $speak->plugin));
Guardian::kick(File::D($config->url_current));
}
});
/**
* Cache Killer
* ------------
*/
function do_remove_cache()
{
global $config, $c_cache;
foreach ($c_cache->path as $path => $expire) {
$path = str_replace(array('(:any)', '(:num)', '(:all)', '(', ')', '|', '/', ':'), array('*', '[0-9]*', '*', '{', '}', ',', '.', '.'), $path) . '.cache';
if ($cache = File::exist(CACHE . DS . $path)) {
File::open($cache)->delete();
} else {
foreach (glob(CACHE . DS . $path, GLOB_NOSORT | GLOB_BRACE) as $cache) {
File::open($cache)->delete();
}
}
}
}
$hooks = Mecha::walk(glob(POST . DS . '*', GLOB_NOSORT | GLOB_ONLYDIR), function ($v) {
return 'on_' . File::B($v) . '_update';
});
Weapon::add($hooks, 'do_remove_cache', 10);
示例12: function
<?php
Weapon::add('meta', function () {
$config = Config::get();
$T2 = str_repeat(TAB, 2);
echo O_BEGIN . $T2 . '<!-- Start Facebook Open Graph -->' . NL;
echo $T2 . '<meta property="og:title" content="' . Text::parse($config->page_title, '->text') . '"' . ES . NL;
echo $T2 . '<meta property="og:type" content="' . ($config->page_type === 'article' ? 'article' : 'website') . '"' . ES . NL;
echo $T2 . '<meta property="og:url" content="' . Filter::colon('og:url', $config->url_current) . '"' . ES . NL;
if ($config->page_type !== '404' && isset($config->{$config->page_type}->image)) {
echo $T2 . '<meta property="og:image" content="' . $config->{$config->page_type}->image . '"' . ES . NL;
}
echo $T2 . '<meta property="og:site_name" content="' . $config->title . '"' . ES . NL;
if (isset($config->{$config->page_type}->description)) {
$config->description = $config->{$config->page_type}->description;
}
echo $T2 . '<meta property="og:description" content="' . Text::parse($config->description, '->text') . '"' . ES . NL;
echo $T2 . '<!-- End Facebook Open Graph -->' . O_END;
}, 11);
示例13: function
<?php
// Refresh plugin(s) order cache on every update event
Weapon::add('on_plugin_update', function () {
Plugin::reload();
});
/**
* Plugin Manager
* --------------
*/
Route::accept(array($config->manager->slug . '/plugin', $config->manager->slug . '/plugin/(:num)'), function ($offset = 1) use($config, $speak) {
if (!Guardian::happy(1)) {
Shield::abort();
}
$offset = (int) $offset;
$destination = PLUGIN;
if (isset($_FILES) && !empty($_FILES)) {
Guardian::checkToken(Request::post('token'));
include __DIR__ . DS . 'task.ignite.package.php';
if (!Notify::errors()) {
File::upload($_FILES['file'], $destination, function () use($speak) {
Notify::clear();
Notify::success(Config::speak('notify_success_uploaded', $speak->plugin));
});
if ($package = File::exist($destination . DS . $name)) {
if (is_file($package)) {
Package::take($package)->extract();
// Extract the ZIP file
File::open($package)->delete();
// Delete the ZIP file
$P = array('data' => $_FILES);
示例14: array
$c->html_parser = (object) array('type' => array('HTML' => 'HTML'), 'active' => $c->html_parser);
}
$menus = Get::state_menu(null, false);
if (!isset($menus['navigation'])) {
$menus['navigation'] = $menus;
File::serialize($menus)->saveTo(STATE . DS . 'menu.txt', 0600);
}
if ($tag = Get::state_tag(null, false)) {
if (isset($tag[0]['id'])) {
$tags = array();
foreach ($tag as $t) {
$tags[$t['id']] = array('name' => $t['name'], 'slug' => $t['slug'], 'description' => $t['description'], 'scope' => 'article');
}
File::serialize($tags)->saveTo(STATE . DS . 'tag.txt', 0600);
}
}
if (is_string($c->author)) {
$c->author = (object) array('name' => $c->author, 'email' => $c->author_email, 'url' => $c->author_profile_url);
if ($c->page_type === 'manager') {
Notify::info('<strong>1.2.0</strong> — In your <a href="' . $c->url . '/' . $c->manager->slug . '/shield">shield</a> files, change all <code>$c->author</code> data to <code>$c->author->name</code>, <code>$c->author_email</code> data to <code>$c->author->email</code> and <code>$c->author_profile_url</code> data to <code>$c->author->url</code>. Then go to the <a href="' . $c->url . '/' . $c->manager->slug . '/config">configuration manager page</a> to kill this message by pressing the <strong>Update</strong> button.');
}
}
Config::set(Mecha::A($c));
$config = $c;
}, 1);
Weapon::add('on_config_update', function () {
// Self destruct ...
File::open(__FILE__)->delete();
Notify::clear();
Notify::success(Config::speak('notify_success_updated', Config::speak('config')));
});
示例15: function
<?php
// Forget all memor(y|ies) on page visit ...
// Clear all notif(y|ies) on page visit ...
Weapon::add('shield_after', function () {
Guardian::forget();
Notify::clear();
});