本文整理匯總了PHP中Mecha::O方法的典型用法代碼示例。如果您正苦於以下問題:PHP Mecha::O方法的具體用法?PHP Mecha::O怎麽用?PHP Mecha::O使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Mecha
的用法示例。
在下文中一共展示了Mecha::O方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: do_private_post
function do_private_post($content, $results)
{
global $config, $speak;
$results = Mecha::O($results);
$results = $config->is->post ? Get::postHeader($results->path, POST . DS . $config->page_type, '/', $config->page_type . ':') : false;
if ($results === false) {
return $speak->plugin_private_post->description;
}
$s = isset($results->fields->pass) ? $results->fields->pass : "";
if (strpos($s, ':') !== false) {
$s = explode(':', $s, 2);
if (isset($s[1])) {
$speak->plugin_private_post->hint = ltrim($s[1]);
}
// override password hint
$s = $s[0];
}
$hash = md5($s . PRIVATE_POST_SALT);
$html = Notify::read(false) . '<div class="overlay--' . File::B(__DIR__) . '"></div><form class="form--' . File::B(__DIR__) . '" action="' . $config->url . '/' . File::B(__DIR__) . '/do:access" method="post">' . NL;
$html .= TAB . Form::hidden('token', Guardian::token()) . NL;
$html .= TAB . Form::hidden('_', $hash) . NL;
$html .= TAB . Form::hidden('kick', $config->url_current) . NL;
$html .= TAB . '<p>' . $speak->plugin_private_post->hint . '</p>' . NL;
$html .= TAB . '<p>' . Form::text('access', "", $speak->password . '…', array('autocomplete' => 'off')) . ' ' . Form::button($speak->submit, null, 'submit') . '</p>' . NL;
$html .= '</form>' . O_END;
if ($results && isset($results->fields->pass) && trim($results->fields->pass) !== "") {
if (!Guardian::happy() && Session::get('is_allow_post_access') !== $hash) {
return $html;
}
}
return $content;
}
示例2: info
public static function info($folder = null, $array = false)
{
$config = Config::get();
$speak = Config::speak();
// Check whether the localized "about" file is available
if (!($info = File::exist(PLUGIN . DS . $folder . DS . 'about.' . $config->language . '.txt'))) {
$info = PLUGIN . DS . $folder . DS . 'about.txt';
}
$default = 'Title' . S . ' ' . ucwords(Text::parse($folder, '->text')) . "\n" . 'Author' . S . ' ' . $speak->anon . "\n" . 'URL' . S . ' #' . "\n" . 'Version' . S . ' 0.0.0' . "\n" . "\n" . SEPARATOR . "\n" . "\n" . Config::speak('notify_not_available', $speak->description);
$info = Text::toPage(File::open($info)->read($default), 'content', 'plugin:');
return $array ? $info : Mecha::O($info);
}
示例3: function
if ($request = Request::post()) {
Guardian::checkToken($request['token']);
$info_path = Mecha::walk($deletes, function ($v) {
$_path = ASSET . DS . $v;
File::open($_path)->delete();
return $_path;
});
$is_folder_or_file = count($deletes) === 1 && is_dir(ASSET . DS . $deletes[0]) ? 'folder' : 'file';
$P = array('data' => array('files' => $info_path));
Notify::success(Config::speak('notify_' . $is_folder_or_file . '_deleted', '<code>' . implode('</code>, <code>', $deletes) . '</code>'));
Weapon::fire(array('on_asset_update', 'on_asset_destruct'), array($P, $P));
Guardian::kick($config->manager->slug . '/asset/1' . str_replace('&', '&', HTTP::query('path', $p)));
} else {
Notify::warning(count($deletes) === 1 ? Config::speak('notify_confirm_delete_', '<code>' . File::path($name) . '</code>') : $speak->notify_confirm_delete);
}
Shield::lot(array('segment' => 'asset', 'files' => Mecha::O($deletes)))->attach('manager');
});
/**
* Multiple Asset Action
* ---------------------
*/
Route::accept($config->manager->slug . '/asset/do', function ($path = "") use($config, $speak) {
if ($request = Request::post()) {
Guardian::checkToken($request['token']);
if (!isset($request['selected'])) {
Notify::error($speak->notify_error_no_files_selected);
Guardian::kick($config->manager->slug . '/asset/1');
}
$files = Mecha::walk($request['selected'], function ($v) {
return str_replace('%2F', '/', Text::parse($v, '->encoded_url'));
});
示例4: pageAnchor
/**
* ==========================================================================
* GET MINIMUM DATA OF A PAGE
* ==========================================================================
*
* -- CODE: -----------------------------------------------------------------
*
* var_dump(Get::pageAnchor('about'));
*
* --------------------------------------------------------------------------
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Parameter | Type | Description
* ---------- | ------ | ---------------------------------------------------
* $path | string | The URL path of the page file, or a page slug
* $folder | string | Folder of the page(s)
* $connector | string | See `Get::page()`
* $FP | string | See `Get::page()`
* ---------- | ------ | ---------------------------------------------------
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
*/
public static function pageAnchor($path, $folder = PAGE, $connector = '/', $FP = 'page:')
{
$config = Config::get();
if (strpos($path, ROOT) === false) {
$path = self::pagePath($path, $folder);
// By page slug, ID or time
}
if ($path && ($buffer = File::open($path)->get(1)) !== false) {
$results = self::pageExtract($path);
$parts = explode(S, $buffer, 2);
$results['url'] = self::AMF($config->url . $connector . $results['slug'], $FP, 'url');
$results['title'] = self::AMF(isset($parts[1]) ? Text::DS(trim($parts[1])) : "", $FP, 'title');
return Mecha::O($results);
}
return false;
}
示例5: array
if ($id && ($post = call_user_func('Get::' . $segment, $id, array('content', 'excerpt', 'tags')))) {
$extension_o = '.' . File::E($post->path);
if (!Guardian::happy(1) && Guardian::get('author') !== $post->author) {
Shield::abort();
}
if (!File::exist(CUSTOM . DS . Date::slug($post->date->unix) . $extension_o)) {
$post->css_raw = $config->defaults->{$segment . '_css'};
$post->js_raw = $config->defaults->{$segment . '_js'};
}
$title = $speak->editing . ': ' . ($post->state !== 'drafted' ? Cell::a($post->url, $post->title, true) : $post->title) . $config->title_separator . $config->manager->title;
} else {
if ($id !== false) {
Shield::abort();
// File not found!
}
$post = Mecha::O(array('id' => "", 'path' => "", 'state' => 'drafted', 'date' => array('W3C' => ""), 'kind' => array(), 'slug' => "", 'title_raw' => $config->defaults->{$segment . '_title'}, 'link_raw' => "", 'description_raw' => "", 'author_raw' => Guardian::get('author'), 'content_type_raw' => $config->html_parser->active, 'fields_raw' => array(), 'content_raw' => $config->defaults->{$segment . '_content'}, 'css_raw' => $config->defaults->{$segment . '_css'}, 'js_raw' => $config->defaults->{$segment . '_js'}));
$title = Config::speak('manager.title_new_', $speak->{$segment}) . $config->title_separator . $config->manager->title;
}
$G = array('data' => Mecha::A($post));
Config::set(array('page_title' => $title, 'page' => $post, 'html_parser' => array('active' => $post->content_type_raw), 'cargo' => 'repair.post.php'));
if ($request = Request::post()) {
Guardian::checkToken($request['token']);
// Check for invalid time pattern
if (isset($request['date']) && trim($request['date']) !== "" && !preg_match('#^\\d{4,}\\-\\d{2}\\-\\d{2}T\\d{2}\\:\\d{2}\\:\\d{2}\\+\\d{2}\\:\\d{2}$#', $request['date'])) {
Notify::error($speak->notify_invalid_time_pattern);
Guardian::memorize($request);
}
$rid = (int) date('U', isset($request['date']) && trim($request['date']) !== "" ? strtotime($request['date']) : time());
$request['path'] = $post->path;
// Set post date by submitted time, or by input value if available
$date = date('c', $rid);
示例6: function
* ----------
*/
Route::accept($config->manager->slug . '/tag/kill/id:(:any)', function ($id = false) use($config, $speak, $tags) {
if (!Guardian::happy(1)) {
Shield::abort();
}
if (!isset($tags[$id])) {
Shield::abort();
// Tag not found!
}
$title = $tags[$id]['name'];
Config::set(array('page_title' => $speak->deleting . ': ' . $title . $config->title_separator . $config->manager->title, 'cargo' => 'kill.tag.php'));
$G = array('data' => $tags);
$G['data']['id'] = $id;
if ($request = Request::post()) {
$request = Filter::apply('request:__tag', $request, $id);
Guardian::checkToken($request['token']);
unset($tags[$id]);
// delete ...
ksort($tags);
$P = array('data' => $tags);
$P['data']['id'] = $id;
File::serialize($tags)->saveTo(STATE . DS . 'tag.txt', 0600);
Notify::success(Config::speak('notify_success_deleted', $title));
Weapon::fire(array('on_tag_update', 'on_tag_destruct'), array($G, $P));
Guardian::kick($config->manager->slug . '/tag');
} else {
Notify::warning(Config::speak('notify_confirm_delete_', '<strong>' . $title . '</strong>'));
}
Shield::lot(array('segment' => 'tag', 'id' => $id, 'file' => Mecha::O($tags[$id])))->attach('manager');
});
示例7: function
* -----------
*/
Route::accept($config->manager->slug . '/menu/kill/key:(:any)', function ($key = false) use($config, $speak) {
if (!Guardian::happy(1)) {
Shield::abort();
}
$menus = Get::state_menu(null, array(), false);
if (!isset($menus[$key])) {
Shield::abort();
// Menu not found!
}
Config::set(array('page_title' => $speak->deleting . ': ' . $speak->menu . $config->title_separator . $config->manager->title, 'cargo' => 'kill.menu.php'));
$G = array('data' => $menus);
$G['data']['key'] = $key;
if ($request = Request::post()) {
$request = Filter::apply('request:__menu', $request, $key);
Guardian::checkToken($request['token']);
unset($menus[$key]);
// delete ...
ksort($menus);
$P = array('data' => $menus);
$P['data']['key'] = $key;
File::serialize($menus)->saveTo(STATE . DS . 'menu.txt', 0600);
Notify::success(Config::speak('notify_success_deleted', $speak->menu));
Weapon::fire(array('on_menu_update', 'on_menu_destruct'), array($G, $P));
Guardian::kick($config->manager->slug . '/menu');
} else {
Notify::warning(Config::speak('notify_confirm_delete_', '<code>Menu::' . $key . '()</code>'));
}
Shield::lot(array('segment' => 'menu', 'id' => $key, 'file' => Mecha::O($menus[$key])))->attach('manager');
});
示例8: get
/**
* =============================================================
* GET CONFIGURATION DATA BY ITS KEY
* =============================================================
*
* -- CODE: ----------------------------------------------------
*
* echo Config::get('url');
*
* -------------------------------------------------------------
*
* echo Config::get('index')->slug;
*
* -------------------------------------------------------------
*
* echo Config::get('index.slug');
*
* -------------------------------------------------------------
*
* $config = Config::get();
*
* echo $config->url;
* echo $config->index->slug;
*
* -------------------------------------------------------------
*
* $bucket = Config::get(array('foo', 'bar', 'baz'));
*
* -------------------------------------------------------------
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Parameter | Type | Description
* --------- | ------ | ---------------------------------------
* $key | string | Key of data to be called
* $fallback | mixed | Fallback value if data does not exist
* --------- | ------ | ---------------------------------------
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
*/
public static function get($key = null, $fallback = false)
{
if (is_null($key)) {
return Mecha::O(self::$bucket);
}
if (is_array($key)) {
$results = array();
foreach ($key as $k => $v) {
$f = is_array($fallback) && array_key_exists($k, $fallback) ? $fallback[$k] : $fallback;
$results[$v] = self::get($v, $f);
}
return (object) $results;
}
if (is_string($key) && strpos($key, '.') !== false) {
$output = Mecha::GVR(self::$bucket, $key, $fallback);
return is_array($output) ? Mecha::O($output) : $output;
}
return array_key_exists($key, self::$bucket) ? Mecha::O(self::$bucket[$key]) : $fallback;
}
示例9: function
<?php
/**
* Shortcode Manager
* -----------------
*/
Route::accept($config->manager->slug . '/shortcode', function () use($config, $speak) {
if (!Guardian::happy(1)) {
Shield::abort();
}
$shortcodes = Get::state_shortcode(null, array(), false);
$G = array('data' => $shortcodes);
Config::set(array('page_title' => $speak->shortcodes . $config->title_separator . $config->manager->title, 'cargo' => 'cargo.shortcode.php'));
if ($request = Request::post()) {
$request = Filter::apply('request:__shortcode', $request);
Guardian::checkToken($request['token']);
$data = array();
for ($i = 0, $keys = $request['key'], $count = count($keys); $i < $count; ++$i) {
if (trim($keys[$i]) !== "") {
$data[$keys[$i]] = $request['value'][$i];
}
}
$P = array('data' => $data);
File::serialize($data)->saveTo(STATE . DS . 'shortcode.txt', 0600);
Notify::success(Config::speak('notify_success_updated', $speak->shortcode));
Weapon::fire('on_shortcode_update', array($G, $P));
Guardian::kick($config->url_current);
}
Shield::lot(array('segment' => 'shortcode', 'files' => Mecha::O($shortcodes)))->attach('manager');
});
示例10: function
Weapon::add('tab_content_2_before', function ($page, $segment) use($config, $speak) {
$segment = $segment[0];
include __DIR__ . DS . 'unit' . DS . 'form' . DS . 'fields[].php';
}, 1);
File::write($config->{'__total_' . $segment . 's'})->saveTo(LOG . DS . $segment . 's.total.log', 0600);
if ($id && ($response = call_user_func('Get::' . $segment, $id, array('message')))) {
if (!Guardian::happy(1)) {
Shield::abort();
}
$title = $speak->editing . ': ' . ($response->permalink !== '#' ? Cell::a($response->permalink, $speak->{$segment}, true) : $speak->{$segment}) . $config->title_separator . $config->manager->title;
} else {
if ($id !== false) {
Shield::abort();
// File not found!
}
$response = Mecha::O(array('id' => "", 'path' => "", 'post' => "", 'parent' => "", 'state' => 'pending', 'date' => array('W3C' => ""), 'name_raw' => Guardian::get('author'), 'email' => Guardian::get('email'), 'url_raw' => "", 'status_raw' => Guardian::get('status_raw'), 'content_type_raw' => $config->html_parser->active, 'fields_raw' => array(), 'message_raw' => ""));
$title = Config::speak('manager.title_new_', $speak->{$segment}) . $config->title_separator . $config->manager->title;
}
$G = array('data' => Mecha::A($response));
Config::set(array('page_title' => $title, 'page' => $response, 'html_parser' => array('active' => $response->content_type_raw), 'cargo' => 'repair.response.php'));
if ($request = Request::post()) {
$request = Filter::apply('request:__' . $segment, $request, $id);
Guardian::checkToken($request['token']);
$rid = $id ? $id : time();
$request['post'] = Request::post('post');
$request['parent'] = Request::post('parent');
$extension = $request['extension'];
$name = $request['name'];
$email = $request['email'];
$url = isset($request['url']) && trim($request['url']) !== "" ? $request['url'] : false;
$message = $request['message'];
示例11: function
}
}
}
} else {
$tab_id = 'tab-content-2';
include __DIR__ . DS . 'task.js.tab.php';
}
}
$filter = Request::get('q', "");
$filter = $filter ? Text::parse($filter, '->safe_file_name') : "";
$s = Get::closestFolders($destination, 'ASC', 'path', $filter);
if (!($folders = Mecha::eat($s)->chunk($offset, $config->manager->per_page)->vomit())) {
Shield::abort();
}
Config::set(array('page_title' => $speak->plugins . $config->title_separator . $config->manager->title, 'offset' => $offset, 'pagination' => Navigator::extract($s, $offset, $config->manager->per_page, $config->manager->slug . '/plugin'), 'cargo' => 'cargo.plugin.php'));
Shield::lot(array('segment' => 'plugin', 'folders' => Mecha::O($folders)))->attach('manager');
});
/**
* Plugin Configurator
* -------------------
*/
Route::accept($config->manager->slug . '/plugin/(:any)', function ($slug = 1) use($config, $speak) {
if (is_numeric($slug)) {
// It's an index page
Route::execute($config->manager->slug . '/plugin/(:num)', array($slug));
}
if (!Guardian::happy(1)) {
Shield::abort();
}
if (!File::exist(PLUGIN . DS . $slug . DS . 'launch.php') && !File::exist(PLUGIN . DS . $slug . DS . '__launch.php')) {
Shield::abort();
示例12: explode
$page->css_raw = $config->defaults->page_custom_css;
$page->js_raw = $config->defaults->page_custom_js;
}
// Remove automatic page description data from page composer
$test = explode(SEPARATOR, str_replace("\r", "", file_get_contents($page->path)), 2);
if (strpos($test[0], "\n" . 'Description' . S . ' ') === false) {
$page->description = "";
}
unset($test);
Config::set(array('page_title' => $speak->editing . ': ' . $page->title . $config->title_separator . $config->manager->title, 'page' => Mecha::A($page)));
} else {
if ($id !== false) {
Shield::abort();
// File not found!
}
$page = Mecha::O(array('id' => "", 'path' => "", 'state' => 'draft', 'date' => array('W3C' => ""), 'title' => $config->defaults->page_title, 'slug' => "", 'content_raw' => $config->defaults->page_content, 'content_type' => $config->html_parser, 'description' => "", 'author' => Guardian::get('author'), 'css_raw' => $config->defaults->page_custom_css, 'js_raw' => $config->defaults->page_custom_js, 'fields' => array()));
Config::set(array('page_title' => Config::speak('manager.title_new_', $speak->page) . $config->title_separator . $config->manager->title, 'page' => Mecha::A($page)));
}
$G = array('data' => Mecha::A($page));
Config::set('html_parser', $page->content_type);
if ($request = Request::post()) {
Guardian::checkToken($request['token']);
$task_connect = $page;
include DECK . DS . 'workers' . DS . 'task.field.5.php';
include DECK . DS . 'workers' . DS . 'task.field.6.php';
$extension = $request['action'] === 'publish' ? '.txt' : '.draft';
// Check for duplicate slug, except for the current old slug.
// Allow user(s) to change their post slug, but make sure they
// do not type the slug of another post.
if (trim($slug) !== "" && $slug !== $page->slug && ($files = Get::pages('DESC', "", 'txt,draft,archive'))) {
foreach ($files as $file) {
示例13: foreach
echo $speak->name;
?>
</th>
<th><?php
echo $speak->slug;
?>
</th>
<th class="text-center" colspan="2"><?php
echo $speak->action;
?>
</th>
</tr>
</thead>
<tbody>
<?php
foreach (Mecha::O($files_all) as $key => $value) {
?>
<tr<?php
echo Session::get('recent_item_update') === $key ? ' class="active"' : "";
?>
>
<td class="text-right"><?php
echo $key;
?>
</td>
<td><?php
echo $value->name;
?>
</td>
<td><code><?php
echo $value->slug;
示例14: glob
if ($_file !== false) {
// Remove empty folder(s)
$f = glob(File::D($_file) . DS . '*', GLOB_NOSORT);
if (empty($f)) {
File::open(File::D($_file))->delete();
}
Notify::success(Config::speak('notify_file_deleted', '<code>' . File::B($_file) . '</code>'));
} else {
Notify::success(Config::speak('notify_success_deleted', $speak->shield));
}
Weapon::fire(array('on_shield_update', 'on_shield_destruct'), array($P, $P));
Guardian::kick($config->manager->slug . '/shield' . ($_file !== false ? '/' . $folder : ""));
} else {
Notify::warning(Config::speak('notify_confirm_delete_', $file !== false ? '<code>' . $path . '</code>' : '<strong>' . $info->title . '</strong>'));
}
Shield::lot(array('segment' => 'shield', 'folder' => $folder, 'files' => Mecha::O(Get::files(SHIELD . DS . $folder, '*')), 'path' => $path))->attach('manager');
});
/**
* Shield Attacher
* ---------------
*/
Route::accept($config->manager->slug . '/shield/(attach|eject)/id:(:any)', function ($path = "", $slug = "") use($config, $speak) {
if (!Guardian::happy(1) || !file_exists(SHIELD . DS . $slug)) {
Shield::abort();
}
$new_config = Get::state_config();
$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));
$mode = $path === 'eject' ? 'eject' : 'mount';
Notify::success(Config::speak('notify_success_updated', $speak->shield));
示例15: get
/**
* =============================================================
* GET CONFIGURATION VALUE BY ITS KEY
* =============================================================
*
* -- CODE: ----------------------------------------------------
*
* echo Config::get('url');
*
* -------------------------------------------------------------
*
* echo Config::get('index')->slug;
*
* -------------------------------------------------------------
*
* echo Config::get('index.slug');
*
* -------------------------------------------------------------
*
* $config = Config::get();
*
* echo $config->url;
* echo $config->index->slug;
*
* -------------------------------------------------------------
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Parameter | Type | Description
* --------- | ------ | ---------------------------------------
* $key | string | Key of data to be called
* $fallback | mixed | Fallback value if data does not exist
* --------- | ------ | ---------------------------------------
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
*/
public static function get($key = null, $fallback = false)
{
if (is_null($key)) {
return Mecha::O(self::$bucket);
}
if (is_string($key) && strpos($key, '.') !== false) {
$output = Mecha::GVR(self::$bucket, $key, $fallback);
return is_array($output) ? Mecha::O($output) : $output;
}
return array_key_exists($key, self::$bucket) ? Mecha::O(self::$bucket[$key]) : $fallback;
}