lecterror / cakephp-filter-plugin Goto Github PK
View Code? Open in Web Editor NEWA general filtering/search plugin for CakePHP apps
Home Page: http://lecterror.com/
License: GNU General Public License v3.0
A general filtering/search plugin for CakePHP apps
Home Page: http://lecterror.com/
License: GNU General Public License v3.0
After upgrading to PHP 5.4.17 (Mac OSX 10.9) received the following error
Strict (2048): Only variables should be assigned by reference [APP/Plugin/Filter/Controller/Component/FilterComponent.php, line 201]
$workingModel =& ClassRegistry::init($fieldModel);
changed to
$workingModel = ClassRegistry::init($fieldModel);
removed the error.
As of PHP 5, the new operator returns a reference automatically, so assigning the result of new by reference results in an E_DEPRECATED message in PHP 5.3 and later, and an E_STRICT message in earlier versions.
Hey. Thansk for the great plugin. It seems I am ot the only one who has this issue. (some others mentioned it on your blog). I'm using Cake 2.4.9
I have a field that doesn't have the issue (not required), and one that always is required. even when I add required => false.
I've tried using other settings on the field, but it remains required.
UPDATE: it seems the settings used in the model cannot be overriden.
I had:
class Post extends AppModel {
public $validate = array(
'title' => array(
'rule' => 'notEmpty'
),
'body' => array(
'rule' => 'notEmpty'
)
);
Guess that 'solves' that.
CakePHP v2.3, PHP v5.4
The FilteredBehavior returns an empty $query['conditions']-array.
A little research learned me this:
function beforeFind(Model $Model, $query)
{
...
$settings = $this->settings[$Model->alias];
$values = $this->_filterValues[$Model->alias];
foreach ($settings as $field => $options)
{
$this->addFieldToFilter($Model, $query, $settings, $values, $field, $options);
}
...
return $query;
}
Inhere, the methodcall
$this->addFieldToFilter($Model, $query, $settings, $values, $field, $options); returns an empty $query['conditions']-array.
Some new investigations:
protected function buildFilterConditions(array $query, $field, $options, $value)
{
...
}
The method creates the $query['conditions'] well, but after the transfer to beforeFind, it is empty. The only place where the $query['conditions']-array is properly set is after switch{ ... }.
any suggestions?
I'm trying to give your plugin a spin on CakePHP 2.13 but I'm hitting an error. Has it been tested on 2.1.x?
I've followed your article (http://lecterror.com/articles/view/cakephp-generic-filter-plugin) to get it setup:
git clone into Plugin/Filter
added: CakePlugin::load('Filter'); to Config/bootstrap.php
added: $components = array('Filter.Filter'); to AppController.php
added: var $filters = array
(
'index' => array(
'Item' => array(
'Item.code',
'Item.name',
'Mfg' => array(
'Mfg.code',
'Mfg.name'
),
)
)
);
to ItemsController.php
added: echo $filter->filterForm('Item', array('legend' => 'Search')); to the top of Items/index.ctp
I'm hitting the following error message:
Items
Notice (8): Undefined variable: filter [APP/View/Items/index.ctp, line 4]
Code Context
ob_start();
include $___viewFn;
$___viewFn = '/var/www/html/poms01/app/View/Items/index.ctp'
$___dataForView = array(
'viewFilterParams' => array(
),
'items' => array(
),
'acl' => object(AclComponent) {},
'user' => array(
),
'logged_in' => true
)
$viewFilterParams = array(
(int) 0 => array(
),
(int) 1 => array(
),
(int) 2 => array(
)
)
$items = array(
(int) 0 => array(
)
)
$acl = object(AclComponent) {}
$user = array(
'id' => '1',
'username' => 'admin',
'name' => 'Admin',
'email' => '[email protected]',
'group_id' => '1',
'created' => '06/19/2012 17:04:54',
'modified' => '06/19/2012 17:04:54'
)
$logged_in = true
include - APP/View/Items/index.ctp, line 4
View::_evaluate() - CORE/Cake/View/View.php, line 910
View::_render() - CORE/Cake/View/View.php, line 874
View::render() - CORE/Cake/View/View.php, line 465
Controller::render() - CORE/Cake/Controller/Controller.php, line 959
Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 110
Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 85
[main] - APP/webroot/index.php, line 92
Fatal error: Call to a member function filterForm() on a non-object in /var/www/html/poms01/app/View/Items/index.ctp on line 4 Call Stack: 0.0007 341276 1. {main}() /var/www/html/poms01/app/webroot/index.php:0 0.0443 1779296 2. Dispatcher->dispatch() /var/www/html/poms01/app/webroot/index.php:92 0.0645 2607592 3. Dispatcher->_invoke() /var/www/html/poms01/lib/Cake/Routing/Dispatcher.php:85 0.5128 7639632 4. Controller->render() /var/www/html/poms01/lib/Cake/Routing/Dispatcher.php:110 0.5221 7919400 5. View->render() /var/www/html/poms01/lib/Cake/Controller/Controller.php:959 0.5463 9392360 6. View->_render() /var/www/html/poms01/lib/Cake/View/View.php:465 0.5470 9392388 7. View->_evaluate() /var/www/html/poms01/lib/Cake/View/View.php:874 0.5477 9489236 8. include('/var/www/html/poms01/app/View/Items/index.ctp') /var/www/html/poms01/lib/Cake/View/View.php:910
Any suggestions?
Cheers,
Scott
Could you move the content of these pages to wiki here? https://github.com/lecterror/cakephp-filter-plugin/wiki
Hello,
while trying to fix the belongsTo bug I realized that the testcases are not working. Here my environment:
cake 2.0.4
phpunit 3.6.4
Some errors are due to some changes in the framework, especially the function expectError()
and trigger_error are apparently
not supported in this way anymore.
You can use $this->setExpectedException('PHPUnit_Framework_Error');
instead, but I'm not so sure whether this would fit all test-cases.
Hi,
I use cakePHP 2.4.4 and I get this error message.
Missing Helper
Error: FilterHelper could not be found.
Error: Create the class FilterHelper below in file: app\View\Helper\FilterHelper.php
<?php
class FilterHelper extends AppHelper {
}
Notice: If you want to customize this error message, create app\View\Errors\missing_helper.ctp
Deprecation Notice: Class Filter\Test\TestCase\Controller\Component\FilterTestCase located in plugins/Filter/tests\TestCase\Controller\Component\FilterComponentTest.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class Filter\Test\TestCase\DocumentCategoriesTable located in plugins/Filter/tests\TestCase\MockObjects.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:201
In FilterComponent::beforeRender, when there's a selector
specified, you check to see if a model has the specified method...
if (!method_exists($workingModel, $settings['selector']))
{
// trigger the error
... and if it doesn't, you trigger an error.
This doesn't take into account if the model has access to the selector
method through a behavior, either explicitly declared in the behavior or through a magic "mapMethod." Adding a check against the model's BehaviorCollection->hasMethod resolves this problem.
if (
! method_exists($workingModel, $settings['selector']) &&
! $workingModel->Behaviors->hasMethod($settings['selector'])
)
{
// now you can trigger that error
You have the following two links in your READ.MD that lead to a blank pade with an "Access denied" warning.
http://lecterror.com/articles/view/cakephp-generic-filter-plugin
http://lecterror.com/articles/view/cakephp-filter-plugin-advanced-usage
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.