Yii Framework Forum: [extension] datafilter - Yii Framework Forum

Jump to content

  • (3 Pages)
  • +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

[extension] datafilter Rate Topic: -----

#1 User is offline   seb 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 240
  • Joined: 29-June 09

Posted 20 July 2009 - 01:13 AM

Datafilter extension can be used to add search and filtration capabilities to data grids.

Extension: http://www.yiiframew...ion/datafilter/
0

#2 User is offline   menatep 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 32
  • Joined: 25-May 09

Posted 14 August 2009 - 03:32 AM

Is there a demo of this extension running?
0

#3 User is offline   seb 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 240
  • Joined: 29-June 09

Posted 18 August 2009 - 11:25 AM

View Postmenatep, on 14 August 2009 - 03:32 AM, said:

Is there a demo of this extension running?

No, but I working now on simple sample project and will upload it soon.
0

#4 User is offline   seb 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 240
  • Joined: 29-June 09

Posted 19 August 2009 - 12:08 PM

I attached demo application preview (it contains also upcoming datafilter version).
Bugreports and feature requests are welcome :)
Attached File  datafilterdemo.zip (250.86K)
Number of downloads: 48
-1

#5 User is offline   menatep 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 32
  • Joined: 25-May 09

Posted 21 August 2009 - 03:18 AM

I got this error....
first i searched for user with name containing "user"
then i tried to filter out the result by selecting country as "Russia"

CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'name' in where clause is ambiguous

Source File
C:\wamp\www\framework\db\CDbCommand.php(322)

00310: }
00311:
00312: if($this->_connection->enableProfiling)
00313: Yii::endProfile('system.db.CDbCommand.query('.$this->getText().')','system.db.CDbCommand.query');
00314:
00315: return $result;
00316: }
00317: catch(Exception $e)
00318: {
00319: if($this->_connection->enableProfiling)
00320: Yii::endProfile('system.db.CDbCommand.query('.$this->getText().')','system.db.CDbCommand.query');
00321: Yii::log('Error in querying SQL: '.$this->getText().$params,CLogger::LEVEL_ERROR,'system.db.CDbCommand');
00322: throw new CDbException(Yii::t('yii','CDbCommand failed to execute the SQL statement: {error}',
00323: array('{error}'=>$e->getMessage())));
00324: }
00325: }
00326: }
0

#6 User is offline   Eric 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 20-August 09

Posted 21 August 2009 - 05:02 AM

i extracted \datafilter into \protected\extensions
did everything on the documentation,
then got this error:
YiiBase::include(CDataFilter.php) [<a href='yiibase.include'>yiibase.include</a>]: failed to open stream: No such file or directory

please help me on this, thanks.
0

#7 User is offline   menatep 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 32
  • Joined: 25-May 09

Posted 21 August 2009 - 12:19 PM

Eric.... index.php needs to be modified to refer to your correct framework path.
0

#8 User is offline   seb 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 240
  • Joined: 29-June 09

Posted 23 August 2009 - 10:12 AM

View Postmenatep, on 21 August 2009 - 03:18 AM, said:

I got this error....
first i searched for user with name containing "user"
then i tried to filter out the result by selecting country as "Russia"

This can be fixed changing User::getDataFilterSearchFields() to
    public function getDataFilterSearchFields($filterName)
    {
        switch ($filterName) {
            case 'userFieldsSearch':
                return array(
                    'df_users.id'=>'User ID',
                    'df_users.name'=>'Name',
                    'df_users.username'=>'Username',
                );
        }
    }

I can not attach fixed demo because of 500KB global upload quota :( .


View PostEric, on 21 August 2009 - 05:02 AM, said:

i extracted \datafilter into \protected\extensions
did everything on the documentation,
then got this error:
YiiBase::include(CDataFilter.php) [<a href='yiibase.include'>yiibase.include</a>]: failed to open stream: No such file or directory

please help me on this, thanks.

Eric, you probably need to add datafilters classes to Yii's import in config/main.php:
    // autoloading model and component classes
    'import'=>array(
	'application.models.*',
	'application.components.*',
        ...
        'application.extensions.datafilter.*',
        'application.extensions.datafilter.filters.*',
    ),

0

#9 User is offline   martial123 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 25-June 09

Posted 24 August 2009 - 04:34 AM

Dear All

I meet the problem at multiple data filtering at multiple pages

let say my default controller is

http://localhost/des...p?r=users/admin, it is the first page and i add the data filtering on it

and there is another pages http://localhost/des...les_setup/admin and i also include another


after i run IE by addresss http://localhost/des...ccess/index.php, system show me the default page of http://localhost/des...p?r=users/admin

and at the menu bar, i click the "Modules Setup", so that it will go to
http://localhost/des...les_setup/admin

and i do some filtering by module_id = PP and click the search button, system will jump to the

http://localhost/des...ext=&yt0=Search

rather than remain

http://localhost/des...les_setup/admin

Is it is the data filtering LIMITATION?

Please Help~~~~
0

#10 User is offline   Anticon 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 25-February 09
  • Location:Germany

Posted 24 August 2009 - 05:53 AM

$criteria->condition = ' countries_id = '.$_GET['countryFilter'];


is very vulnerable against SQL-Injections...
0

#11 User is offline   seb 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 240
  • Joined: 29-June 09

Posted 25 August 2009 - 02:09 AM

View Postmartial123, on 24 August 2009 - 04:34 AM, said:

Dear All

I meet the problem at multiple data filtering at multiple pages

let say my default controller is

http://localhost/des...p?r=users/admin, it is the first page and i add the data filtering on it

and there is another pages http://localhost/des...les_setup/admin and i also include another


after i run IE by addresss http://localhost/des...ccess/index.php, system show me the default page of http://localhost/des...p?r=users/admin

and at the menu bar, i click the "Modules Setup", so that it will go to
http://localhost/des...les_setup/admin

and i do some filtering by module_id = PP and click the search button, system will jump to the

http://localhost/des...ext=&yt0=Search

rather than remain

http://localhost/des...les_setup/admin

Is it is the data filtering LIMITATION?

Please Help~~~~

I am not very experienced web-developer and the problem here is that after form is submited previous parameters are striped, for example having
www.sitename/index.php?r=modules_setup/admin

as form action we will get url like
www.sitename/index.php?param1=value1&param2=value2&... 

after form is submited.
I can use hidden field to preserve existing parameters, but I expect some problems with that.

Martial123, maybe you can use "path" urls for your application (setting 'urlFormat'=>'path' for urlManager component in config\main.php)? This also solves a problem.


View PostAnticon, on 24 August 2009 - 05:53 AM, said:

$criteria->condition = ' countries_id = '.$_GET['countryFilter'];


is very vulnerable against SQL-Injections...

Can you suggest more secure way to build sql? It is a demo application, but I think some people can reproduce this vulnerable code in their applications.
0

#12 User is offline   pestaa 

  • past Yii dev member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 705
  • Joined: 07-May 09
  • Location:Hungary

Posted 25 August 2009 - 02:47 AM

View Postseb, on 25 August 2009 - 02:09 AM, said:

Can you suggest more secure way to build sql?


$criteria->condition = ' countries_id = :filter';
$criteria->params = array(':filter'=>$_GET['countryFilter']);

0

#13 User is offline   seb 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 240
  • Joined: 29-June 09

Posted 26 August 2009 - 11:35 AM

View Postpestaa, on 25 August 2009 - 02:47 AM, said:

$criteria->condition = ' countries_id = :filter';
$criteria->params = array(':filter'=>$_GET['countryFilter']);


Thanks, I will use this for the demo application.
0

#14 User is offline   seb 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 240
  • Joined: 29-June 09

Posted 02 September 2009 - 05:42 AM

View Postpestaa, on 25 August 2009 - 02:47 AM, said:

$criteria->condition = ' countries_id = :filter';
$criteria->params = array(':filter'=>$_GET['countryFilter']);



I am trying now to build all conditions such way, but have a problem with LIKE condition.
I have code:
$localCriteria = new CDbCriteria;
$localCriteria->condition = ' '.$searchField.' LIKE "%'.$searchValue.'%" ';

It works, but $searchValue taken from $_GET and placed to condition directly.

I changed this code to:
$localCriteria = new CDbCriteria;
$localCriteria->condition = ' '.$searchField.' LIKE "%:searchValue%" ';
$localCriteria->params = array(':searchValue'=>$searchValue); 

This code does not work - returned empty set, but I know it should be some results.
May be someone have any suggestions how to make it work?
0

#15 User is offline   pestaa 

  • past Yii dev member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 705
  • Joined: 07-May 09
  • Location:Hungary

Posted 03 September 2009 - 08:04 AM

It should be:
$localCriteria = new CDbCriteria;
$localCriteria->condition = $searchField.' LIKE :searchValue';
$localCriteria->params = array(':searchValue'=>'%'.$searchValue.'%'); 

0

#16 User is offline   seb 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 240
  • Joined: 29-June 09

Posted 04 September 2009 - 04:35 AM

View Postpestaa, on 03 September 2009 - 08:04 AM, said:

It should be:
$localCriteria = new CDbCriteria;
$localCriteria->condition = $searchField.' LIKE :searchValue';
$localCriteria->params = array(':searchValue'=>'%'.$searchValue.'%'); 


Thanks! I tried many combinations, but not the right one :(.
Pestaa, congratulations for joining Yii team.

I uploaded new datafilter version and demo application: datafilter downloads
0

#17 User is offline   icevan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 51
  • Joined: 18-June 09
  • Location:Russia

Posted 10 September 2009 - 04:33 AM

CDataFilterWidget.php:

155: echo CHtml::form($this->formAction,$this->formMethod,$this->formOptions);


Did not work on servers where appplication work not in root folder. http://myserv.net/fold/fold/myYiiApp
Should be
155: echo CHtml::form( CHtml::normalizeUrl($this->formAction) ,$this->formMethod,$this->formOptions);

PHP Ice Monster
0

#18 User is offline   seb 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 240
  • Joined: 29-June 09

Posted 18 September 2009 - 02:46 AM

View Posticevan, on 10 September 2009 - 04:33 AM, said:

CDataFilterWidget.php:

155: echo CHtml::form($this->formAction,$this->formMethod,$this->formOptions);


Did not work on servers where appplication work not in root folder. http://myserv.net/fold/fold/myYiiApp
Should be
155: echo CHtml::form( CHtml::normalizeUrl($this->formAction) ,$this->formMethod,$this->formOptions);


Thanks, will do like you suggested.
0

#19 User is offline   seb 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 240
  • Joined: 29-June 09

Posted 18 September 2009 - 08:05 AM

I uploaded new datafilter version 0.3 and demo application: datafilter downloads.
Most important new features are: CDataFilterWidget - options to generate submit and reset buttons, CDataFilter - option to store filter state to the session.
0

#20 User is offline   fibler 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 35
  • Joined: 06-October 09

Posted 12 October 2009 - 06:43 AM

@seb - Hi there, not sure why I am getting the following error when installing your version 0.3 extension...

I have tried both yii-1.0.8 and yii-1.0.9, as well as the demo app and adding it to testdrive app with user table.

Still I get the same error. If you know why I get this error would be very helpful.

PHP Error
Description

Declaration of CFilterSearch::applyCriteria() should be compatible with that of CFilterBase::applyCriteria()
Source File

/Library/WebServer/Documents/yii-datafilter/protected/extensions/datafilter/filters/CFilterSearch.php(12)

00001: <?php
00002: /**
00003:  * CFilterSearch class file.
00004:  *
00005:  * @author Seb <serebrov@algo-rithm.com>, Algo-rithm
00006:  *
00007:  * @version 0.3
00008:  *
00009:  * @desc CFilterSearch is a link to filter data.
00010:  */
00011: class CFilterSearch extends CFilterBase
00012: {
00013:     /**
00014:      * Apply filter's value to criteria. Method call redirected to model's
00015:      * method applyDataSearchCriteria()
00016:      * @param <CActiveRecord> $model
00017:      * @param <CDbCriteria> $criteria
00018:      */
00019:     public function applyCriteria($model, &$criteria)
00020:     {              
00021:         $searchFields = $model->getDataFilterSearchFields($this->name);
00022:         $fieldName = $this->getValue();
00023: 
00024:         if ( isset($searchFields[$fieldName])) {


0

Share this topic:


  • (3 Pages)
  • +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users