本文整理汇总了PHP中Converter::ES方法的典型用法代码示例。如果您正苦于以下问题:PHP Converter::ES方法的具体用法?PHP Converter::ES怎么用?PHP Converter::ES使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Converter
的用法示例。
在下文中一共展示了Converter::ES方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: content
public static function content($data = "")
{
if ($data === false) {
$data = "";
}
// Restrict user(s) from inputting the `SEPARATOR` constant
// to prevent mistake(s) in parsing the file content
$data = Converter::ES($data);
self::$bucket_alt = trim(self::$bucket_alt) !== "" && is_null(self::$open) ? trim(self::$bucket_alt) . (trim($data) !== "" ? "\n\n" . SEPARATOR . "\n\n" . $data : "") : $data;
return new static();
}
示例2: array
File::open($post->path)->renameTo(File::B($_));
$custom_ = CUSTOM . DS . Date::slug($post->date->W3C);
if (file_exists($custom_ . $extension_o)) {
Weapon::fire('on_custom_update', array($G, $P));
if (trim(File::open($custom_ . $extension_o)->read()) === "" || trim(File::open($custom_ . $extension_o)->read()) === SEPARATOR || empty($css) && empty($js) || $css === $config->defaults->{$segment . '_css'} && $js === $config->defaults->{$segment . '_js'}) {
// Always delete empty custom CSS and JavaScript file(s) ...
File::open($custom_ . $extension_o)->delete();
Weapon::fire('on_custom_destruct', array($G, $P));
} else {
File::write(Converter::ES($css) . "\n\n" . SEPARATOR . "\n\n" . Converter::ES($js))->saveTo($custom_ . $extension_o);
File::open($custom_ . $extension_o)->renameTo(Date::slug($date) . $extension);
Weapon::fire('on_custom_repair', array($G, $P));
}
} else {
if (!empty($css) && $css !== $config->defaults->{$segment . '_css'} || !empty($js) && $js !== $config->defaults->{$segment . '_js'}) {
File::write(Converter::ES($css) . "\n\n" . SEPARATOR . "\n\n" . Converter::ES($js))->saveTo(CUSTOM . DS . Date::slug($date) . $extension_o);
Weapon::fire(array('on_custom_update', 'on_custom_construct'), array($G, $P));
}
}
if ($post->slug !== $slug && ($php_file = File::exist(File::D($post->path) . DS . $post->slug . '.php'))) {
File::open($php_file)->renameTo($slug . '.php');
}
// Rename all response file(s) related to post if post date has been changed
if ((string) $date !== (string) $post->date->W3C && ($responses = call_user_func('Get::' . $response . 's', 'DESC', 'post:' . $id, 'txt,hold'))) {
foreach ($responses as $v) {
$parts = explode('_', File::B($v));
$parts[0] = Date::slug($date);
File::open($v)->renameTo(implode('_', $parts));
}
}
}
示例3: post
/**
* ==========================================================================
* EXTRACT POST FILE INTO LIST OF POST DATA FROM ITS PATH/SLUG/ID
* ==========================================================================
*
* -- CODE: -----------------------------------------------------------------
*
* var_dump(Get::post('about'));
*
* --------------------------------------------------------------------------
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Parameter | Type | Description
* ---------- | ------ | ---------------------------------------------------
* $reference | mixed | Slug, ID, path or array of `Get::postExtract()`
* $excludes | array | Exclude some field(s) from result(s)
* $folder | string | Folder of the post(s)
* $connector | string | Path connector for post URL
* $FP | string | Filter prefix for `Text::toPage()`
* ---------- | ------ | ---------------------------------------------------
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
*/
public static function post($reference, $excludes = array(), $folder = POST, $connector = '/', $FP = 'post:')
{
$config = Config::get();
$speak = Config::speak();
$excludes = array_flip($excludes);
$results = false;
if (!is_array($reference)) {
// By slug => `post-slug` or by ID => `1403355917`
if (strpos($reference, $folder) !== 0) {
$reference = self::postPath($reference, $folder);
}
// By path => `lot\posts\$folder\2014-06-21-20-05-17_1,2,3_page-slug.txt`
$results = self::postExtract($reference, $FP);
} else {
// From `Get::postExtract()`
$results = $reference;
}
if (!$results || !file_exists($results['path'])) {
return false;
}
// RULES: Do not do any tags looping, content parsing
// and external file requesting if it has been marked as
// the excluded field(s). For better performance.
$results = $results + Text::toPage(file_get_contents($results['path']), isset($excludes['content']) ? false : 'content', $FP, array('link' => "", 'author' => $config->author->name, 'description' => "", 'content_type' => $config->html_parser->active, 'fields' => array(), 'content' => "", 'css' => "", 'js' => ""), $results);
$content = $results['content_raw'];
$time = str_replace(array(' ', ':'), '-', $results['time']);
$e = File::E($results['path']);
// Custom post content with PHP file, named as the post slug
if ($php = File::exist(File::D($results['path']) . DS . $results['slug'] . '.php')) {
ob_start();
include $php;
$results['content'] = ob_get_clean();
}
$results['date'] = Filter::colon($FP . 'date', Date::extract($results['time']), $results);
$results['url'] = Filter::colon($FP . 'url', $config->url . $connector . $results['slug'], $results);
$results['excerpt'] = $more = "";
if ($content !== "") {
$exc = isset($excludes['content']) && strpos($content, '<!--') !== false ? Text::toPage(Converter::ES($content), 'content', $FP, array(), $results) : $results;
$exc = $exc['content'];
$exc = is_array($exc) ? implode("", $exc) : $exc;
// Generate fake description data
if ($results['description'] === "") {
$results['description'] = Converter::curt($exc, $config->excerpt->length, $config->excerpt->suffix);
}
// Manual post excerpt with `<!-- cut+ "Read More" -->`
if (strpos($exc, '<!-- cut+ ') !== false) {
preg_match('#<!-- cut\\+( +([\'"]?)(.*?)\\2)? -->#', $exc, $matches);
$more = !empty($matches[3]) ? $matches[3] : $speak->read_more;
$more = '<p><a class="fi-link" href="' . $results['url'] . '#' . sprintf($config->excerpt->id, $results['id']) . '">' . $more . '</a></p>';
$exc = preg_replace('#<!-- cut\\+( +(.*?))? -->#', '<!-- cut -->', $exc);
}
// ... or `<!-- cut -->`
if (strpos($exc, '<!-- cut -->') !== false) {
$parts = explode('<!-- cut -->', $exc, 2);
$results['excerpt'] = Filter::colon($FP . 'excerpt', trim($parts[0]) . $more, $results);
$results['content'] = trim($parts[0]) . NL . NL . '<span class="fi" id="' . sprintf($config->excerpt->id, $results['id']) . '" aria-hidden="true"></span>' . NL . NL . trim($parts[1]);
}
}
// Post Tags
if (!isset($excludes['tags'])) {
$tags = array();
foreach ($results['kind'] as $id) {
$tags[] = call_user_func('self::' . rtrim($FP, ':') . 'Tag', 'id:' . $id);
}
$results['tags'] = Filter::colon($FP . 'tags', Mecha::eat($tags)->order('ASC', 'name')->vomit(), $results);
}
// Post Images
$results['images'] = Filter::colon($FP . 'images', self::imagesURL($results['content']), $results);
$results['image'] = Filter::colon($FP . 'image', isset($results['images'][0]) ? $results['images'][0] : Image::placeholder(), $results);
// Post CSS and JS
if ($file = File::exist(CUSTOM . DS . Date::slug($results['time']) . '.' . File::E($results['path']))) {
$custom = explode(SEPARATOR, File::open($file)->read());
$css = isset($custom[0]) ? Converter::DS(trim($custom[0])) : "";
$js = isset($custom[1]) ? Converter::DS(trim($custom[1])) : "";
// css_raw
// post:css_raw
// custom:css_raw
//.........这里部分代码省略.........