本文整理汇总了PHP中Filter类的典型用法代码示例。如果您正苦于以下问题:PHP Filter类的具体用法?PHP Filter怎么用?PHP Filter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Filter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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.');
}
}
示例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');
}
}
示例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;
}
示例4: combine
public function combine(Filter $filter)
{
$filters = $filter->getFilters();
foreach ($filters as $filter) {
$this->filters[] = $filter;
}
}
示例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);
}
示例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')));
}
示例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');
}
示例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());
}
示例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);
}
示例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));
}
示例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;
}
}
}
示例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;
}
示例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;
}
示例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");
}
示例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);
}
}
}