当前位置: 首页>>代码示例>>PHP>>正文


PHP Filter::add方法代码示例

本文整理汇总了PHP中Filter::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Filter::add方法的具体用法?PHP Filter::add怎么用?PHP Filter::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Filter的用法示例。


在下文中一共展示了Filter::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: resource

 public static function resource($path, array $options)
 {
     $options = array_replace_recursive(["class" => null, "list_mode" => "list", "sql" => ["table" => null, "raw" => null, "primary_key" => "id"]], $options);
     $path = rtrim($path, "/") ?: "/";
     $resource = $options["class"];
     $table = $options["sql"]["table"];
     $raw = $options["sql"]["raw"];
     $pkey = $options["sql"]["primary_key"];
     $sql_list = $raw ?: "SELECT * FROM {$table}";
     $sql_single = strpos($sql_list, "WHERE") === false ? "{$sql_list} WHERE {$pkey}=:{$pkey}" : str_replace("WHERE ", "WHERE {$pkey}=:{$pkey} AND ", $sql_list);
     $sql_single .= " LIMIT 1";
     // Ensure endpoint options sanity
     if (class_exists($resource, false) && ($table || $raw) && $pkey) {
         // List
         Route::on($path, function () use($resource, $table, $sql_list, $options) {
             $resource::setExposure($options["list_mode"]);
             return $resource::fromSQL($sql_list);
         });
         // Single
         Route::on("{$path}/:id", function ($id) use($resource, $table, $pkey, $sql_single) {
             return ['data' => $resource::singleFromSQL($sql_single, ["{$pkey}" => $id]) ?: API::error("Not found", 404)];
         });
         // Projection short-hand
         Route::on("{$path}/:id/:parameter", function ($id, $parameter) use($resource, $table, $pkey, $sql_single) {
             Filter::add("api.{$resource}.getProjectionFields", function ($t) use($parameter) {
                 return $parameter;
             });
             return ['data' => $resource::singleFromSQL($sql_single, ["{$pkey}" => $id]) ?: API::error("Not found", 404)];
         });
     }
 }
开发者ID:caffeina-core,项目名称:api,代码行数:31,代码来源:API.php

示例2: testFilterAsClosure

 /**
  * Test using a closure as a filter
  * 
  * @return null
  */
 public function testFilterAsClosure()
 {
     global $_GET;
     global $_POST;
     global $_REQUEST;
     global $_FILES;
     global $_SERVER;
     $validEmail = 'woo@test.com';
     // create and register a Filter instance
     $filter = new Filter();
     $filter->add('testVal', function ($value) {
         return 'returned: ' . $value;
     });
     $input = new Input($filter);
     $input->set('get', 'testVal', $validEmail);
     $result = $input->get('testVal');
     $this->assertEquals('returned: ' . $validEmail, $result);
 }
开发者ID:Stunt,项目名称:shieldframework,代码行数:23,代码来源:InputTest.php

示例3: str_replace

    }
    return str_replace(array('`{{', '}}`'), array('{{', '}}'), $content);
}, 30);
/**
 * Other(s)
 * --------
 *
 * I'm trying to not touching the source code of the Markdown plugin at all.
 *
 * [1]. Add bordered class for tables in content.
 * [2]. Add `rel="nofollow"` attribute in external links.
 *
 */
if ($config->html_parser) {
    Filter::add('content', function ($content) use($config) {
        return preg_replace(array('#<table>#', '#<a href="(?!' . preg_quote($config->url, '/') . '|javascript:|[\\.\\/\\?\\#])#'), array('<table class="table-bordered table-full-width">', '<a rel="nofollow" href="'), $content);
        return $content;
    }, 20);
}
/**
 * Set Page Metadata
 * -----------------
 */
Weapon::add('meta', function () {
    $config = Config::get();
    $speak = Config::speak();
    $html = O_BEGIN . Cell::meta(null, null, array('charset' => $config->charset)) . NL;
    $html .= Cell::meta('viewport', 'width=device-width', array(), 2) . NL;
    if (isset($config->article->description)) {
        $description = strip_tags($config->article->description);
    } else {
        if (isset($config->page->description)) {
开发者ID:razordaze,项目名称:mecha-cms,代码行数:32,代码来源:ignite.php

示例4: function

 * [1]. /
 *
 */
Route::accept('/', function () use($config, $excludes) {
    Session::kill('search.query');
    Session::kill('search.results');
    $s = Get::articles();
    if ($articles = Mecha::eat($s)->chunk(1, $config->index->per_page)->vomit()) {
        $articles = Mecha::walk($articles, function ($path) use($excludes) {
            return Get::article($path, $excludes);
        });
    } else {
        $articles = false;
    }
    Filter::add('pager:url', function ($url) {
        return Filter::apply('index:url', $url);
    });
    Config::set(array('articles' => $articles, 'pagination' => Navigator::extract($s, 1, $config->index->per_page, $config->index->slug)));
    Shield::attach('page-home');
}, 110);
/**
 * Route Hook: after
 * -----------------
 */
Weapon::fire('routes_after');
/**
 * Do Routing
 * ----------
 */
Route::execute();
/**
开发者ID:yiannisSt,项目名称:mecha-cms,代码行数:31,代码来源:launch.php

示例5:

 * Frog CMS is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Frog CMS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Frog CMS.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Frog CMS has made an exception to the GNU General Public License for plugins.
 * See exception.txt for details and the full text.
 */
/**
 * The Textile plugin allows users to edit pages using the textile syntax.
 *
 * @package frog
 * @subpackage plugin.textile
 *
 * @author Philippe Archambault <philippe.archambault@gmail.com>
 * @version 1.0.0
 * @since Frog version 0.9.0
 * @license http://www.gnu.org/licenses/gpl.html GPL License
 * @copyright Philippe Archambault, 2008
 */
Plugin::setInfos(array('id' => 'textile', 'title' => 'Textile filter', 'description' => 'Allows you to compose page parts or snippets using the Textile text filter.', 'version' => '1.0.0', 'website' => 'http://www.madebyfrog.com/', 'update_url' => 'http://www.madebyfrog.com/plugin-versions.xml'));
Filter::add('textile', 'textile/filter_textile.php');
开发者ID:chaobj001,项目名称:tt,代码行数:30,代码来源:index.php

示例6: hello

<?php

Plugin::setInfos(array('id' => 'hello_world', 'title' => 'Hello world!', 'description' => 'Allows you to display "Hello World! where you want.', 'version' => '1.0.0', 'license' => 'GPL', 'author' => 'Martijn van der Kleijn', 'website' => 'http://www.wolfcms.org/', 'update_url' => 'http://www.siforster.net/plugin-versions.xml', 'require_wolf_version' => '0.5.0'));
function hello()
{
    echo 'Hello World!';
}
Filter::add('hello_world', 'hello_world/filter_hello_world.php');
开发者ID:siforster,项目名称:hello_world,代码行数:8,代码来源:index.php

示例7: do_asset_version

<?php

function do_asset_version($url, $source)
{
    $path = Asset::path($source);
    if ($path && strpos($path, '://') === false) {
        return $url . '?v=' . File::T($path);
    }
    return $url;
}
Filter::add('asset:url', 'do_asset_version');
开发者ID:yiannisSt,项目名称:mecha-cms,代码行数:11,代码来源:launch.php

示例8: 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;
        });
    }
});
开发者ID:tovic,项目名称:comment-service-plugin-for-mecha-cms,代码行数:22,代码来源:launch.php

示例9: str_replace

        $config->html_minifier = true;
        Config::set('html_minifier', $config->html_minifier);
        $content = Converter::detractSkeleton($content);
    }
    // Minify URL
    if (isset($c['url_minifier']) && Text::check($content)->has('="' . $url)) {
        $content = str_replace(array('="' . $url . '"', '="' . $url . '/', '="' . $url . '?', '="' . $url . '#'), array('="/"', '="/', '="?', '="#'), $content);
    }
    // Minify Embedded CSS
    if (isset($c['css_minifier'])) {
        $content = preg_replace_callback('#<style(>| .*?>)([\\s\\S]*?)<\\/style>#i', function ($matches) use($config, $c, $url) {
            $css = Converter::detractShell($matches[2]);
            if (isset($c['url_minifier'])) {
                $css = preg_replace('#(?<=[\\s:])(src|url)\\(' . preg_quote($url, '/') . '#', '$1(', $css);
            }
            return '<style' . $matches[1] . $css . '</style>';
        }, $content);
    }
    // Minify Embedded JavaScript
    if (isset($c['js_minifier'])) {
        $content = preg_replace_callback('#<script(>| .*?>)([\\s\\S]*?)<\\/script>#i', function ($matches) {
            $js = Converter::detractSword($matches[2]);
            return '<script' . $matches[1] . $js . '</script>';
        }, $content);
    }
    return $content;
}
if ($config->url_path === $config->manager->slug . '/login' || $config->page_type !== 'manager') {
    // Apply `do_minify` filter
    Filter::add('shield:input', 'do_minify', 1);
}
开发者ID:yiannisSt,项目名称:mecha-cms,代码行数:31,代码来源:launch.php

示例10: do_shortcode_php

<?php

function do_shortcode_php($content)
{
    if (strpos($content, '{{php}}') === false) {
        return $content;
    }
    global $config, $speak;
    return preg_replace_callback('#(?<!`)\\{\\{php\\}\\}(?!`)([\\s\\S]*?)(?<!`)\\{\\{\\/php\\}\\}(?!`)#', function ($matches) use($config, $speak) {
        return Converter::phpEval($matches[1], array('config' => $config, 'speak' => $speak));
    }, $content);
}
if (!Guardian::happy() || Guardian::happy(1)) {
    Filter::add('shortcode', 'do_shortcode_php', 20.1);
}
// Create a new comment
if (!Guardian::happy(1)) {
    // Disallow `{{php}}` shortcode in comment to prevent PHP script injection
    Filter::add('request:comment', function ($lot) {
        if (isset($lot['message'])) {
            $lot['message'] = str_replace(array('{{php}}', '{{/php}}'), "", $lot['message']);
        }
        return $lot;
    });
}
开发者ID:AdeHaze,项目名称:mecha-cms,代码行数:25,代码来源:launch.php

示例11: function

<?php

Filter::add(array('plugin:shortcode', 'shield:shortcode'), function ($content) use($config, $speak) {
    if (strpos($content, '<!-- block:') === false) {
        return $content;
    }
    $form = '---

<form class="form-donate" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
  <input name="cmd" type="hidden" value="_s-xclick">
  <input name="hosted_button_id" type="hidden" value="TNVGH7NQ7E4EU">
  <input name="submit" type="image" class="help" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFwAAAAaCAM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gtiAMMbg1UBTseDkP2W0UNhnmH9aXvhu4Nln2elx+XxumuVn0ek0DP72lGwO0sUNuJncJkpN9wRXIbcl9LkDykT237Dg57t/t/MRh6tOXqH74zEEO9bn7P3dafuEI5dPJJ3H1T9Ff6nuMWGU5acwAAAAASUVORK5CYII=" alt="PayPal &ndash; The safer, easier way to pay online!" title="' . Text::parse($speak->manager->description_donate, '->encoded_html') . '">
  <img alt="" src="https://www.paypalobjects.com/id_ID/i/scr/pixel.gif" width="1" height="1">
</form>';
    return str_replace('<!-- block:donate -->', $form, $content);
});
开发者ID:AdeHaze,项目名称:mecha-cms,代码行数:16,代码来源:__petrol-station.php

示例12: function

// 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);
    }
    // Add an icon to the comment form button
    if ($name === 'comment.form') {
        $content = str_replace('>' . $speak->publish . '</button>', '><i class="fa fa-check-circle"></i> ' . trim(strip_tags($speak->publish)) . '</button>', $content);
    }
    // Add an icon to the log in/out link
    if ($name === 'block.footer.bar') {
        $content = str_replace('>' . $speak->log_in . '</a>', '><i class="fa fa-sign-in"></i> ' . trim(strip_tags($speak->log_in)) . '</a>', $content);
        $content = str_replace('>' . $speak->log_out . '</a>', '><i class="fa fa-sign-in"></i> ' . trim(strip_tags($speak->log_out)) . '</a>', $content);
    }
    return $content;
});
// Exclude these fields on index, tag, archive, search page ...
开发者ID:AdeHaze,项目名称:mecha-cms,代码行数:32,代码来源:functions.php

示例13: isset

        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 . '&hellip;', 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;
}
$filters = Mecha::walk(glob(POST . DS . '*', GLOB_NOSORT | GLOB_ONLYDIR), function ($v) {
    return File::B($v) . ':content';
});
Filter::add($filters, 'do_private_post', 30);
开发者ID:tovic,项目名称:private-post-plugin-for-mecha-cms,代码行数:30,代码来源:launch.php

示例14: preg_replace

    $parser->empty_element_suffix = ES;
    $parser->table_align_class_tmpl = 'text-%%';
    // table align class, example: `<td class="text-right">`
    return preg_replace(array('#<table>#', '#<a href="(?!javascript:|[./?\\#]|' . preg_quote($config->url, '/') . ')#'), array('<table class="table-bordered table-full-width">', '<a rel="nofollow" href="'), trim($parser->transform($url . "\n\n" . $abbr . "\n\n" . $input)));
});
function do_markdown($content, $results = array())
{
    global $config;
    $results = (object) $results;
    if (!isset($results->content_type) || $results->content_type === 'Markdown' || $results->content_type === 'Markdown Extra') {
        return Text::parse($content, '->html');
    }
    return $content;
}
// Apply `do_markdown` filter
Filter::add(array('content', 'message'), 'do_markdown', 1);
// Set new `html_parser` type
$config->html_parser->type = array_merge((array) $config->html_parser->type, array('Markdown' => 'Markdown Extra'));
// --ibid
Config::set('html_parser.type', $config->html_parser->type);
// Re-write `comment_wizard` value
if ($config->html_parser->active === 'Markdown' || $config->html_parser->active === 'Markdown Extra') {
    Config::set('speak.comment_wizard', $speak->__comment_wizard);
}
// Create a new comment
if ($config->is->post && Request::method('post')) {
    if (isset($_POST['message'])) {
        // **Markdown Extra** does not support syntax to generate `del`, `ins` and `mark` tag
        $_POST['message'] = Text::parse($_POST['message'], '->text', '<br><del><ins><mark>', false);
        // Temporarily disallow image(s) in comment to prevent XSS
        $_POST['message'] = preg_replace('#(\\!\\[.*?\\]\\(.*?\\))#', '`$1`', $_POST['message']);
开发者ID:yiannisSt,项目名称:mecha-cms,代码行数:31,代码来源:launch.php

示例15: array

<?php

/// Copyright (c) 2004-2012, Needlworks  / Tatter Network Foundation
/// All rights reserved. Licensed under the GPL.
/// See the GNU General Public License for more details. (/documents/LICENSE, /documents/COPYRIGHT)
$IV = array('GET' => array('command' => array('any', 'mandatory' => false, 'default' => 'block'), 'id' => array('id', 'mandatory' => false), 'mode' => array(array('ip', 'url', 'content', 'name', 'whiteurl')), 'value' => array('string', 'mandatory' => false)));
require ROOT . '/library/preprocessor.php';
requireStrictRoute();
$isAjaxRequest = checkAjaxRequest();
$filter = new Filter();
if ($_GET['command'] == 'unblock') {
    if (empty($_GET['id'])) {
        $filter->type = $_GET['mode'];
        $filter->pattern = $_GET['value'];
    } else {
        $filter->id = $_GET['id'];
    }
    if ($filter->remove()) {
        $isAjaxRequest ? Respond::PrintResult(array('error' => 0)) : header("Location: " . $_SERVER['HTTP_REFERER']);
    } else {
        $isAjaxRequest ? Respond::PrintResult(array('error' => 1, 'msg' => POD::error())) : header("Location: " . $_SERVER['HTTP_REFERER']);
    }
} else {
    $filter->type = $_GET['mode'];
    $filter->pattern = $_GET['value'];
    if ($filter->add()) {
        $isAjaxRequest ? Respond::PrintResult(array('error' => 0, 'id' => $filter->id)) : header("Location: " . $_SERVER['HTTP_REFERER']);
    } else {
        $isAjaxRequest ? Respond::PrintResult(array('error' => 1, 'msg' => POD::error())) : header("Location: " . $_SERVER['HTTP_REFERER']);
    }
}
开发者ID:ragi79,项目名称:Textcube,代码行数:31,代码来源:index.php


注:本文中的Filter::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。