本文整理汇总了PHP中Filter类的典型用法代码示例。如果您正苦于以下问题:PHP Filter类的具体用法?PHP Filter怎么用?PHP Filter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Filter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: PerformTest
protected function PerformTest()
{
// Create the filter
$filter = new Filter();
// We want to include something that wouldn't be included by default
// for answers - link and exclude something that's included by default - score
$filter->SetIncludeItems('answer.link')->SetExcludeItems('answer.score');
// Get the filter's ID
$filter_id = $filter->GetID();
// Now make a request for an answer
$answer = API::Site('stackoverflow')->Answers()->Filter($filter_id)->Exec()->Fetch();
// Make sure the answer contains / excludes what we specified
if (!isset($answer['link'])) {
throw new Exception('"link" missing from response.');
}
if (isset($answer['score'])) {
throw new Exception('"score" included in response but should not be present.');
}
// Now lookup the filter by ID
$filter = new Filter($filter_id);
$included_items = $filter->GetIncludeItems();
// Make sure that the included items match what we describe
if (!in_array('answer.link', $included_items)) {
throw new Exception('"link" missing from filter description.');
}
if (in_array('answer.score', $included_items)) {
throw new Exception('"score" included in filter description but should not be present.');
}
}
开发者ID:ZackHodari,项目名称:QA_requester,代码行数:29,代码来源:filter_test.php
示例2: run
public function run()
{
include_once SANWEN_LIB . '/Common/functions.php';
include_used_file();
//include the file that used
Log::write('begin initApp');
$this->initApp();
//use the filter
$filter = new Filter();
//filter all url
Log::write('begin to filter url');
if ($filter->filter_all_url()) {
$include_file = get_include_file();
if (file_exists($include_file)) {
Log::write('get_include_file:' . $include_file);
include_once $include_file;
execute(null, null);
} else {
//对应地址的类不存在的时候,执行默认首页
if (file_exists(APP . '/Index/Action/Index.action.php')) {
include_once APP . '/Index/Action/Index.action.php';
execute("Index", "Index");
} else {
//默认首页不存在的时候,抛出错误信息
echo get_langage_message('system.lang.php', 'DEFAULT_INDEX_NOT_FOUND');
}
}
} else {
echo get_langage_message('system.lang.php', 'CAN_NOT_ACCESS');
}
}
开发者ID:pantingwen,项目名称:sanwenphp,代码行数:31,代码来源:Application.class.php
示例3: save
function save($package)
{
$Filter = new Filter();
$name = $this->getName($Filter->get($package, 'name', null));
if ($Filter->get($package, 'error', false)) {
// An HTTP error occurred
return false;
} else {
if (empty($name)) {
// An empty file name was posted
return false;
} else {
if ($this->exists($name)) {
return false;
}
}
}
$Uploader = new Uploader(array("application/zip"), array(SB_TMP_DIR));
list($result, $tmpfile) = $Uploader->upload($package, SB_TMP_DIR);
if (intval($result) != 1) {
// The file was not uploaded
return false;
}
if ($this->unzip($tmpfile, $this->directory)) {
return true;
}
unlink($tmpfile);
return false;
}
开发者ID:schulzp,项目名称:stamm_leo_website,代码行数:29,代码来源:module.php
示例4: combine
public function combine(Filter $filter)
{
$filters = $filter->getFilters();
foreach ($filters as $filter) {
$this->filters[] = $filter;
}
}
开发者ID:sorrina,项目名称:Validator,代码行数:7,代码来源:Filter.php
示例5: save
function save($package)
{
$Filter = new Filter();
$name = $this->getName($Filter->get($package, 'name', null));
if ($Filter->get($package, 'error', false)) {
// An HTTP error occurred
return false;
} else {
if (empty($name)) {
// An empty file name was posted
return false;
} else {
if ($this->exists($name)) {
return false;
}
}
}
$Uploader = new Uploader(array("application/zip"), array(SB_TMP_DIR));
list($result, $tmpfile) = $Uploader->upload($package, SB_TMP_DIR);
if (intval($result) != 1) {
// The file was not uploaded
return false;
}
// handle the file move to the managers dir
if (!FileSystem::make_dir($this->directory . $name)) {
// The target directory could not be created
return false;
}
return $this->unzip($tmpfile, $this->directory . $name);
}
开发者ID:schulzp,项目名称:stamm_leo_website,代码行数:30,代码来源:fragment.php
示例6: testShortcutFilter
public function testShortcutFilter()
{
$config = ['coverage' => ['include' => ['tests/*'], 'exclude' => ['tests/unit/CodeGuy.php']]];
$this->filter->whiteList($config);
$fileFilter = $this->filter->getFilter();
$this->assertFalse($fileFilter->isFiltered(codecept_root_dir('tests/unit/c3Test.php')));
$this->assertTrue($fileFilter->isFiltered(codecept_root_dir('tests/unit/CodeGuy.php')));
}
开发者ID:hitechdk,项目名称:Codeception,代码行数:8,代码来源:FilterTest.php
示例7: testLog_shouldWriteGoodLevels
/**
* Должен пропускать разрешенные уровни.
*/
public function testLog_shouldWriteGoodLevels()
{
$log = $this->getMock('Psr\\Log\\LoggerInterface');
$log->expects($this->once())->method('log');
$filter = new Filter($log);
$filter->closeAll();
$filter->open(['error']);
$filter->error('test');
}
开发者ID:Bashka,项目名称:bricks_log,代码行数:12,代码来源:FilterTest.php
示例8: testGetSetFilterImpact
/**
* Tests setting the filter impact via the collection helper method
*
* @covers \Expose\FilterCollection::setFilterImpact
*/
public function testGetSetFilterImpact()
{
$filter = new Filter();
$filter->setId(1234);
$filter->setImpact(3);
$this->collection->addFilter($filter);
$this->collection->setFilterImpact(1234, 27);
$this->assertEquals(27, $filter->getImpact());
}
开发者ID:thodison,项目名称:expose,代码行数:14,代码来源:FilterCollectionTest.php
示例9: doTest
private function doTest($initial, $filters, $expected)
{
$test = $initial;
foreach ($filters as $filter) {
$filter = new Filter($filter);
$filter->filter($test);
}
$this->assertEquals($expected, $test);
}
开发者ID:airbrake,项目名称:airbrake-php,代码行数:9,代码来源:FilterTest.php
示例10: postSaveFilter
public function postSaveFilter($p, $z)
{
$filterId = $_POST['id'] ? $_POST['id'] : null;
$filter = new Filter($filterId);
if (isset($_POST['name'])) {
$filter->name = $_POST['name'];
}
$filter->content = json_encode(json_decode($_POST['content'])->subs[0]);
$filter->save();
echo json_encode(array('id' => $filter->id));
}
开发者ID:laiello,项目名称:zoop,代码行数:11,代码来源:ZoneDefault.php
示例11: Populate
function Populate()
{
$filters = getDirectory(PATH_FILTER, false, true);
foreach ($filters as $file) {
if (stristr($file, FILE_EXTENSION_FILTER)) {
$filter = new Filter(str_replace(FILE_EXTENSION_FILTER, "", $file));
$filter->Load();
$this->Filters[$filter->FilterId] = $filter;
}
}
}
开发者ID:afzet,项目名称:cake-cart,代码行数:11,代码来源:objects.global.inc.php
示例12: createFromArray
/**
* @param $array
*
* @return Filter
*
* @deprecated won't be part of the CMDL 1.0 specification
*/
public static function createFromArray($array)
{
$filter = new Filter();
foreach ($array as $block) {
$filter->nextConditionsBlock();
foreach ($block as $condition) {
$filter->addCondition($condition[0], $condition[1], $condition[2]);
}
}
return $filter;
}
开发者ID:nhagemann,项目名称:anycontent-repository-mysql-php,代码行数:18,代码来源:FilterFactory.php
示例13: scopeFilter
/**
* Filter scope
*
* @param $query
* @param $request
* @return mixed
*/
public function scopeFilter($query, $request)
{
// Create ne filter object
$this->filter = new Filter($query, $request);
// Set the filters if any defined
$this->setFilters();
// Call order always after the all filters and if there are no custom filters applied
$this->filter->order();
// Object are always passed by reference
// http://php.net/manual/en/language.oop5.references.php
return $query;
}
开发者ID:aginev,项目名称:search-filters,代码行数:19,代码来源:Filterable.php
示例14: doSave
function doSave($Request)
{
$Filter = new Filter();
$package = @$_FILES['package'];
$item = $Filter->get($package, 'name', null);
if ($this->model->save($package)) {
$this->_setMessage('success', 'Success!', $item . " Skin was successfully installed.");
} else {
$this->_setMessage('error', 'Oops!', $item . " Skin could not be installed.");
}
Core::SBRedirect(INSTALLER_URL . "&com=skin");
}
开发者ID:schulzp,项目名称:stamm_leo_website,代码行数:12,代码来源:skin.php
示例15: addChunk
/**
* @param string|Filter $filter
* @param array $params
* @param string $relation
*/
public function addChunk($filter, $params = null, $relation = 'AND')
{
if ($filter instanceof Filter) {
$this->addChunk($filter->getFilterString(), $filter->getParams());
} elseif ($filter) {
if ($this->filterString) {
$this->filterString .= " {$relation} ";
}
$this->filterString .= $filter;
if (!is_null($params) && is_array($params)) {
$this->params = array_merge($this->params, $params);
}
}
}
开发者ID:ralfeus,项目名称:moomi-daeri.com,代码行数:19,代码来源:Filter.class.php
示例16: executeSave
public function executeSave()
{
$arr = array();
$fid = (int) mfwRequest::get('id');
if ($fid) {
$arr['id'] = $fid;
}
$arr['enable'] = (bool) mfwRequest::get('enable', true);
$arr['name'] = mfwRequest::get('name');
$arr['target'] = mfwRequest::get('target');
$arr['pattern'] = mfwRequest::get('pattern');
$filter = new Filter($arr);
$filter->save();
return $this->redirect('/filters/index');
}
开发者ID:ELN,项目名称:metahub,代码行数:15,代码来源:actions.php
示例17: cdbr_register_verify_field
/** save field in database, if field is valid */
function cdbr_register_verify_field()
{
$reponse = array();
$filter = new Filter();
$validator = new Validator();
foreach ($_POST as $stepfield => $value) {
$field = $stepfield;
$filter->apply('register', $field, $value);
$result = $validator->validate_field('register', $field, $value, $type_user);
$response[$field] = $result;
}
print json_encode($response);
die;
// or wordpress will print 0
}
开发者ID:CoordCulturaDigital-Minc,项目名称:pna,代码行数:16,代码来源:custom-profile.php
示例18: doDefault
function doDefault()
{
/* {{{ 导入过滤模块,并初始化 */
importModule("Filter.Filter");
$fl = new Filter();
/* }}} */
/* {{{ 过滤测试测试文本 */
$content = "大家好.有人认识李洪志吗? 学过法轮功的吗?";
echo "<b>原语句:</b> ", $content, "<br />";
/* }}} */
/* {{{ 检测是否含有非法关键字 */
$show = $fl->isForbidden($content);
if ($show) {
echo "<br />含有非法关键字!<br /><br />";
} else {
echo "<br />没有有非法关键字!<br /><br />";
}
/* }}} */
/* {{{ 过滤文本 */
$start = xdebug_time_index();
$show = $fl->clean($content);
echo "<b>过滤后的:</b>", $show, "<br />";
echo "用时: ", xdebug_time_index() - $start, "<br />";
/* }}} */
/* {{{ 过滤文本, 指定替换的格式 */
$start = xdebug_time_index();
$show = $fl->clean($content, "×");
echo "<br /><b>指定替换内容过滤:</b> ", $show, "<br />";
echo "用时: ", xdebug_time_index() - $start, "<br />";
/* }}} */
/* {{{ 并手工指定关键字再过滤文本 */
$start = xdebug_time_index();
$fl->setKey(array('大家好'));
$show = $fl->clean($content);
echo "<br /><b>手工指定关键字过滤:</b> ", $show, "<br />";
echo "用时: ", xdebug_time_index() - $start, "<br />";
/* }}} */
/* {{{ 模糊过滤文本 */
$start = xdebug_time_index();
$ff = new Filter();
$content = "start:李 洪 志-测-试- f-!u-c=k, fuck:end";
echo "<br /><b>原语句:</b> ", $content, "<br />";
$show = $ff->fuzzyClean($content, "*", 2);
//其中2为深度,默认值,值越大清理越干净,误杀越多,消耗资源越多.
echo "<b>模糊过滤后:</b> ", $show, "<br />";
echo "用时: ", xdebug_time_index() - $start, "<br />";
/* }}} */
}
开发者ID:sanplit,项目名称:huishou,代码行数:48,代码来源:index.php
示例19: filter
private function filter()
{
$input = Filter::run(strip_tags(parent::getVar('input')));
$find = array(' ', '#', '?', '&', '.', '!', '"', '§', '$', '%', '(', ')', '=', '*', '+', '~', '-', ':', ';', '>');
$input = str_replace($find, '', $input);
echo $input;
}
开发者ID:Tungse,项目名称:labs,代码行数:7,代码来源:index.php
示例20: getNeighborhood
public function getNeighborhood()
{
$images = FilterImage::all();
$filter = Filter::take(1)->get()[0];
$filters = Filter::all();
return View::make('site.neighborhood', array('images' => $images, 'text' => $filter->text, 'paragraph_title' => $filter->paragraph_title, 'filters' => $filters));
}
开发者ID:rilence,项目名称:pacificSite,代码行数:7,代码来源:HomeController.php
注:本文中的Filter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论