Re: [fw-general] Status of Lucene Search Particulars?

2007-07-09 Thread Alexander Veremyev

Hi Jeff,

Range queries are planned to be one of the first Zend_Search_Lucene 
module enhancements as well as wildcard queries.



There is no any special data type for dates in Zend_Search_Lucene. 
That's the same for Java Lucene.


Dates should be translated to strings to be indexed.
Best representation is 'MMDD'. It keeps dates order and gives a 
possibility to use range queries for searching dates range.



You can also combine user entered and programmatically generated queries 
through the API.
That's useful for translating user entered dates into internal 
representation.


With best regards,
   Alexander Veremyev.



Jeff Kolber wrote:

Hi there

new to the list so wanted to start our by saying thanks to the team and 
the community for providing a really great framework.


I am very keen on implementing Lucene in our php environment but am 
finding the (apparent) absence of date fields and range queries to be 
problematic.  Can anyone let me know if these things are 
planned,pending,shelved, did I miss them somewhere ? incubator etc?


thanks again.

Jeff Kolber
Lead Developer
Roubini Global Economics, LLC
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
http://www.rgemonitor.com/






[fw-general] Zend_Search Stop words

2007-07-09 Thread Andrew Craft

Hi,

We are implementing a stop word list and we have noticed an odd bit of
behaviour when doing searches and the order of stop words in the query.

Currenlty these are the stop words:

$stopWords = array('the', 'and', 'a', 'to', 'of', 'in', 
   'i', 'is', 'that', 'it', 'on', 'you', 
   'this', 'for', 'but', 'with', 'are', 
   'have', 'be', 'at', 'or', 'as', 'was', 
   'so', 'if', 'out', 'not');

If we do a query like: it is this it returns no results.

If we do a query like: this is it we get results.

I am just wondering if this is proper behaviour for the stop words and
searching?

TIA,

Andrew
-- 
View this message in context: 
http://www.nabble.com/Zend_Search-Stop-words-tf4049217s16154.html#a11501469
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Zend_Search Stop words

2007-07-09 Thread Alexander Veremyev

Hi Andrew,

Query parser has some inconsistencies in stop words processing 
(http://framework.zend.com/issues/browse/ZF-1624).


I am working on it right now and have just attached your comment to the 
issue.


Thank you very much for your comments!


With best regards,
   Alexander Veremyev.

Andrew Craft wrote:

Hi,

We are implementing a stop word list and we have noticed an odd bit of
behaviour when doing searches and the order of stop words in the query.

Currenlty these are the stop words:

$stopWords = array('the', 'and', 'a', 'to', 'of', 'in', 
   'i', 'is', 'that', 'it', 'on', 'you', 
   'this', 'for', 'but', 'with', 'are', 
   'have', 'be', 'at', 'or', 'as', 'was', 
   'so', 'if', 'out', 'not');


If we do a query like: it is this it returns no results.

If we do a query like: this is it we get results.

I am just wondering if this is proper behaviour for the stop words and
searching?

TIA,

Andrew




Re: [fw-general] Status of Lucene Search Particulars?

2007-07-09 Thread Jeff Kolber
Thanks for the reply ... is there some place where I can monitor the  
progress of this? maybe a dev list?



Jeff Kolber
Lead Developer
Roubini Global Economics, LLC
131 Varick Street, Suite 1005
New York, NY 10013
Tel: 212-645-0010
Fax:212-645-0023
[EMAIL PROTECTED]
http://www.rgemonitor.com/


On Jul 9, 2007, at 4:03 AM, Alexander Veremyev wrote:


Hi Jeff,

Range queries are planned to be one of the first Zend_Search_Lucene  
module enhancements as well as wildcard queries.



There is no any special data type for dates in Zend_Search_Lucene.  
That's the same for Java Lucene.


Dates should be translated to strings to be indexed.
Best representation is 'MMDD'. It keeps dates order and gives a  
possibility to use range queries for searching dates range.



You can also combine user entered and programmatically generated  
queries through the API.
That's useful for translating user entered dates into internal  
representation.


With best regards,
   Alexander Veremyev.



Jeff Kolber wrote:

Hi there
new to the list so wanted to start our by saying thanks to the  
team and the community for providing a really great framework.
I am very keen on implementing Lucene in our php environment but  
am finding the (apparent) absence of date fields and range queries  
to be problematic.  Can anyone let me know if these things are  
planned,pending,shelved, did I miss them somewhere ? incubator etc?

thanks again.
Jeff Kolber
Lead Developer
Roubini Global Economics, LLC
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
http://www.rgemonitor.com/






Re: [fw-general] Zend_Search Stop words

2007-07-09 Thread Andrew Craft

Thanks Alexender!

When this is ready to test let me know if you want and we can test it on our
search index.

Andrew



Alexander Veremyev wrote:
 
 Hi Andrew,
 
 Query parser has some inconsistencies in stop words processing 
 (http://framework.zend.com/issues/browse/ZF-1624).
 
 I am working on it right now and have just attached your comment to the 
 issue.
 
 Thank you very much for your comments!
 
 
 With best regards,
 Alexander Veremyev.
 
 Andrew Craft wrote:
 Hi,
 
 We are implementing a stop word list and we have noticed an odd bit of
 behaviour when doing searches and the order of stop words in the query.
 
 Currenlty these are the stop words:
 
 $stopWords = array('the', 'and', 'a', 'to', 'of', 'in', 
 'i', 'is', 'that', 'it', 'on', 'you', 
 'this', 'for', 'but', 'with', 'are', 
 'have', 'be', 'at', 'or', 'as', 'was', 
 'so', 'if', 'out', 'not');
 
 If we do a query like: it is this it returns no results.
 
 If we do a query like: this is it we get results.
 
 I am just wondering if this is proper behaviour for the stop words and
 searching?
 
 TIA,
 
 Andrew
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Zend_Search-Stop-words-tf4049217s16154.html#a11501884
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Status of Lucene Search Particulars?

2007-07-09 Thread Alexander Veremyev

Not all fixes/improvements are announced in mailing lists.
But all of them are definitely listed in changelog.


You can also subscribe to issue tracking.

You have to register within JIRA to get this possibility 
(http://framework.zend.com/issues/secure/Signup!default.jspa).
After logging in you will get Watch it option at the left side of page 
representing the issue.


Range searching issue is ZF-400 
(http://framework.zend.com/issues/browse/ZF-400).



With best regards,
   Alexander Veremyev.


Jeff Kolber wrote:
Thanks for the reply ... is there some place where I can monitor the 
progress of this? maybe a dev list? 



Jeff Kolber
Lead Developer
Roubini Global Economics, LLC
131 Varick Street, Suite 1005
New York, NY 10013
Tel: 212-645-0010
Fax:212-645-0023
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
http://www.rgemonitor.com/


On Jul 9, 2007, at 4:03 AM, Alexander Veremyev wrote:


Hi Jeff,

Range queries are planned to be one of the first Zend_Search_Lucene 
module enhancements as well as wildcard queries.



There is no any special data type for dates in Zend_Search_Lucene. 
That's the same for Java Lucene.


Dates should be translated to strings to be indexed.
Best representation is 'MMDD'. It keeps dates order and gives a 
possibility to use range queries for searching dates range.



You can also combine user entered and programmatically generated 
queries through the API.
That's useful for translating user entered dates into internal 
representation.


With best regards,
   Alexander Veremyev.



Jeff Kolber wrote:

Hi there
new to the list so wanted to start our by saying thanks to the team 
and the community for providing a really great framework.
I am very keen on implementing Lucene in our php environment but am 
finding the (apparent) absence of date fields and range queries to be 
problematic.  Can anyone let me know if these things are 
planned,pending,shelved, did I miss them somewhere ? incubator etc?

thanks again.
Jeff Kolber
Lead Developer
Roubini Global Economics, LLC
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
http://www.rgemonitor.com/








RE: [fw-general] Allowing global variables with Zend Framework

2007-07-09 Thread Bill Karwin
I'm not aware of anything in Zend Framework that would require enabling,
to permit usage of global variables or superglobals like $_GET and
$_POST.

But it's not clear what usage of globals you mean.  Certainly the Zend
Framework components themselves should not make use of global variables.
So if there are any global that you need to use to specify ZF behavior,
you need to pass these variables as arguments to class methods.

Regards
Bill Karwin

 -Original Message-
 From: kevin7654 [mailto:[EMAIL PROTECTED] 
 Sent: Saturday, July 07, 2007 5:34 PM
 To: fw-general@lists.zend.com
 Subject: [fw-general] Allowing global variables with Zend Framework
 
 
 Hello,
 
 I'm trying to slowly migrate an app I've written over to the 
 zend framework. 
 The app currently relies on global variables, ie global 
 $my_name, and it also relies on get and post values.  Can I 
 enable this with the zend framework?
 
 
 Thanks,
 
 Kevin
 --
 View this message in context: 
 http://www.nabble.com/Allowing-global-variables-with-Zend-Fram
 ework-tf4042358s16154.html#a11483587
 Sent from the Zend Framework mailing list archive at Nabble.com.
 
 


Re: [fw-general] Allowing global variables with Zend Framework

2007-07-09 Thread Matthew Weier O'Phinney
-- kevin7654 [EMAIL PROTECTED] wrote
(on Saturday, 07 July 2007, 05:34 PM -0700):
 I'm trying to slowly migrate an app I've written over to the zend framework. 
 The app currently relies on global variables, ie global $my_name, and it
 also relies on get and post values.  Can I enable this with the zend
 framework?

There's nothing that prevents you from using globals or superglobals in
ZF. However, that said, you can sometimes run into issues using globals
that weren't first defined in the global namespace. Adding a declaration
for them in your bootstrap will typically correct the issue.

-- 
Matthew Weier O'Phinney
PHP Developer| [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/


[fw-general] Extended $this-_helper-FlashMessenger;

2007-07-09 Thread Yann Nave

Hello everybody,

Before FlashMessenger helper, I made a little FlashMessenger code with
Zend_Session like this  :

   public function init()
   {

   $this-session = Zend_Registry::get('session');
   $this-view-flash_message = $this-session-flash_message;
   $this-session-flash_message = null;
   }

  public function saveAction()
  {
  //some code here
  //if success
  $flash_message['state'] = 'true';
  $flash_message['message'] = Ok;

  //else
   $flash_message['state'] = 'false';
   $flash_message['message'] = Erreur;
  }


So I'm using 'true' or 'false' as CSS class to have different display
for my message.

Is there a way to do this with flashMessenger helper ?

Thanks

--
Yannux
http://blog.onbebop.net


[fw-general] Release Schedule

2007-07-09 Thread Aaron D. Campbell
I see the roadmap, with some of the future things to be implemented in 
ZF, but is there a release schedule?  Specifically I'd like to see when 
Zend_Layout is coming out.  I was told it would be included in 1.1, but 
when is that due out?


[fw-general] Problem with Zend_Mail and Japanese

2007-07-09 Thread abzic

Hello
I have a zend framework based website with options for English and Japanese
languages. Both languages work as expected in the website. There is a
feature to send emails that also works well except for the Japanese chars
appear garbled in the email client program. Below is a 'simplified copy' of
the code I am using to send the emails. 
Any help or suggestion is much appreciated. 
Andres

$gt   = new Zend_Translate(gettext, languages/jp.mo)
$mail = new Zend_Mail(UTF-8);

$mail-setFrom([EMAIL PROTECTED], Website name);
$mail-addTo([EMAIL PROTECTED], Name);
$mail-setSubject($gt-_(Email subject));

$body = sprintf(h1%s/h1p%s/p,
  $gt-_(Hello),
  $gt-_(More text here... Japanese translation));

$mail-setBodyHtml($body,UTF-8);
$mail-send();

Notes: 
1) I do not think there is a problem with the jp.mo file as everything in
the website (Japanese version included) is working ok. 
2) When used in English, the emails look perfect.


-- 
View this message in context: 
http://www.nabble.com/Problem-with-Zend_Mail-and-Japanese-tf4052746s16154.html#a11511581
Sent from the Zend Framework mailing list archive at Nabble.com.



[fw-general] Lucene Partial matching

2007-07-09 Thread Greg Freeman

In Zend Search Lucene is it possible for query terms to partially match?

Like Happy* matching Happyness
-- 
View this message in context: 
http://www.nabble.com/Lucene-Partial-matching-tf4052773s16154.html#a11511660
Sent from the Zend Framework mailing list archive at Nabble.com.



[fw-general] Models, Objects and RDBMS - Best Practise

2007-07-09 Thread Sam Davey

Hi,

First off thank you to everyone who contributed to getting the first release
out.  The emphasis the framework puts on best practices has massively
improved my analysis and development techniques (or should I say its
improved my awareness... the rest will hopefully follow with practice).

After finally grabbing the v 1.0 release I have started developing a system
from scratch.  I've been following Pádraic Bradys excellent tutorials on
complex views and I've sorted out a layout and the basic CRUD operations of
my systems elements.

However this is where I get stuck, I'm not sure how BEST to initialize data
in models for related record sets from an RDB.  Let me explain. Lets take a
simple example:

'A product is made by a manufacturer and can be in one or more categories.'

I've created 3 models, product, manufacturer and category.  Each extends
Zend_Db_Table but offers a custom findByFilter() method which returns a
result set based on data from a filter form.  So far so good, it all works,
I get data from the particular table the model relates to.

My question in this...  I don't just want data from the table the model
relates to.  A product has a manufacturer (therefore assume a foreign key
'manufacturer_id') so I want the manufacturer name as well. Or perhaps I
want the categories the product is in. Or perhaps I want any other related
data which might exist. This is fine when were talking about one record (an
instance of a product HAS-A instance of a manufacturer... easy)

Now don't get me wrong... I've been programming PHP for ages.  I could do
these things easily.  I could throw method after method at my models until I
have the functionality I need and I'll end up with something that works. 
But eventually my models will become bloated and I will end up with the
maintenance nightmare I have with my current system.  I'm after the best
practice, not just an answer to what appears to be a simple query.

* Can someone point me towards a description of a design pattern or a simple
tutorial which clearly describes the BEST way to achieve this? Performance
is key... I don't want to start creating manufacturer objects for every
product in a result set just to get the name of the manufacturer of a
product (or do I?).

* Am I barking up the wrong tree... if I want a result set of all products
and related manufacturer names do I simply write a method to get me this
data? And if so then what if I want a slightly different result set? Do I
just write another method and continue in this fashion as and when new needs
arise?

Cheers,

Sam
-- 
View this message in context: 
http://www.nabble.com/Models%2C-Objects-and-RDBMS---Best-Practise-tf4052812s16154.html#a11511779
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Lucene Partial matching

2007-07-09 Thread Greg Freeman

The reason I ask if that the stuff I'm indexing can have 'tags' associated
with it. I'm wondering the best way to store tags in a lucene index. Could
it be put in a space separated unstored field?
-- 
View this message in context: 
http://www.nabble.com/Lucene-Partial-matching-tf4052773s16154.html#a11511785
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Models, Objects and RDBMS - Best Practise

2007-07-09 Thread Bryce Lohr
I've been having similar challenges in the application I'm working on. So far, I 
personally haven't ran across any sort of design pattern or best practice that 
really addresses this issue.


I don't know how much this helps, but here's an idea I've been kicking around in 
my head. Set up your directory structure like so:


app/
  models/
Products/
  Queries.php
  Defaults.php
  Validation.php
  Service.php
Manufacturers/
  Queries.php
  Defaults.php
  Validation.php
  Service.php
Categories/
  ...

The basic idea is that you have one directory for each model, such as 
Products, and inside that directory are various classes centered on managing the 
business/domain logic related to the model. I was thinking about breaking the 
models down like so:


 * Queries.php: Thinest possible wrapper methods around SQL queries. So you'd 
have various methods for selecting Product result sets in the Product model. 
These queries shouldn't be restricted to one table; they should do whatever is 
required to get the correct results. It seems appropriate to put 
inserts/updates/deletes here, too. I'd make the actual SQL queries properties of 
the class, instead of burying them inside the methods; it would make easier to 
just override just a particular query.
 * Defaults.php: The methods here are used basically to provide a data model of 
sorts for blank CRUD forms, for entering new data. I was thinking there was a 
Zend_Db_Table method that returned new rows for inserting, based on the table, 
but I can't remember what it is. This would be sort of like that, but keep all 
your defaults for all the forms primarily related to the model in this one, 
separate class. Feel free to omit this if not applicable.
 * Service.php: The main API for getting things related to this model done. 
This is where the meat of the domain logic would lie. This class would use the 
other classes in the same model directory. It could actually use any class from 
any other model; whatever it takes to get the job done. The way I see it, the 
Views and Controllers would just exist to provide a UI to the API exposed here. 
This way, your application logic is separated from the front end, and you could 
access the same application functionality through a CLI script, a cron job, a 
web services interfaces, etc.
 * Validation.php: It just seems like a good idea to me to separate out the 
data validation code for the model into its own class. The Service class would 
just use this class to do data validation. Of course, if you don't want/need to 
separate it out, you don't have to.


The thing I like about this approach is that, given a well-normalized relational 
database, it gets you out of the mindset of tying classes 1-to-1 with tables. So 
you're free to think in terms of joined result sets and the core business 
objects your application deals with. And the directory structure gives you the 
freedom to break down any given model's problem into as many or few classes as 
necessary to get the job done and keep the code maintainable.


All that said, although I've been thinking about it for a while, I haven't 
actually implemented any of this yet. It sounds like a great idea to me, but 
then I could be totally off my rocker. :) So if this is crazy, or doesn't work 
for you, ignore it.


Hope this helps,
Bryce Lohr


Sam Davey wrote:

Hi,

First off thank you to everyone who contributed to getting the first release
out.  The emphasis the framework puts on best practices has massively
improved my analysis and development techniques (or should I say its
improved my awareness... the rest will hopefully follow with practice).

After finally grabbing the v 1.0 release I have started developing a system
from scratch.  I've been following Pádraic Bradys excellent tutorials on
complex views and I've sorted out a layout and the basic CRUD operations of
my systems elements.

However this is where I get stuck, I'm not sure how BEST to initialize data
in models for related record sets from an RDB.  Let me explain. Lets take a
simple example:

'A product is made by a manufacturer and can be in one or more categories.'

I've created 3 models, product, manufacturer and category.  Each extends
Zend_Db_Table but offers a custom findByFilter() method which returns a
result set based on data from a filter form.  So far so good, it all works,
I get data from the particular table the model relates to.

My question in this...  I don't just want data from the table the model
relates to.  A product has a manufacturer (therefore assume a foreign key
'manufacturer_id') so I want the manufacturer name as well. Or perhaps I
want the categories the product is in. Or perhaps I want any other related
data which might exist. This is fine when were talking about one record (an
instance of a product HAS-A instance of a manufacturer... easy)

Now don't get me wrong... I've been programming PHP for ages.  I could do
these things easily.  

Re: [fw-general] ZF Application Variables?

2007-07-09 Thread pat

To Jack,

The most common and basic use of Application Variables are page 
counters.  Decide how you would implement a page counter in Zend and you 
will have the mechanism for your application variables.


A database seems like a bit much for a page counter.  Although it would 
take care of race conditions.


cheers,

pat





Jack Sleight wrote:
Hi, 
Are there any plans to introduce an application variable type system in ZF?

Something like this:

http://www.leosingleton.com/projects/code/phpapp/

As far as I'm aware this is something PHP cant do. If this is something you
would be interested in adding I would be happy to help with a
proposal/coding/development.

Thanks, 
Jack
  




RE: [fw-general] Release Schedule

2007-07-09 Thread Andi Gutmans
Hi Aaron,

We are spending this week on planning. This includes both defining the
product lifecycle (major/minor/mini releases, how we branch, what goes
into mini vs. minor, etc...) and also try and pin down owners +
priorities for the various features. 
It will probably not be 100% final by the end of this week but it'll
give everyone a clearer idea of how we think we should manage the
various version releases, what the rought schedules should look like,
etc.. In any case, Zend_View_Layout is high on our priority list and not
a very big piece of work (a lot of headway has already been made by the
various community members). So I believe this should move forward
quickly soon and even if it's not in an official release you'll be able
to pull it out of the incubator.

Andi


 -Original Message-
 From: Aaron D. Campbell [mailto:[EMAIL PROTECTED] 
 Sent: Monday, July 09, 2007 3:06 PM
 To: fw-general@lists.zend.com
 Subject: [fw-general] Release Schedule
 
 I see the roadmap, with some of the future things to be 
 implemented in ZF, but is there a release schedule?  
 Specifically I'd like to see when Zend_Layout is coming out.  
 I was told it would be included in 1.1, but when is that due out?
 


Re: [fw-general] Release Schedule

2007-07-09 Thread Kevin McArthur

Thanks Andi for making Layout a priority (we were getting nervous =P).

The next big thing is probably to open up discussion on Zend_Form. There's 
been some community discussion on the path forward but no real plan as of 
yet.


Is there any specific plans for Zend_Form going forward? The proposal that 
is in the tracker is somewhat dated.


For my vote I'm looking for something that can:

- Create forms from an instance of a class or config file (not an 
abstract-class approach)

- Validate/Filter Data
- Integrates with the flash messenger and repopulates forms on failed 
validations (sessions)
- Has appropriate view helpers to handle common form scenarios (array 
binding option lists for example)
- Is sufficiently lightweight as to not intrude onto business logic/model 
logic. (there's been considerable debate on where the validation process 
stops [the checking for a free username scenario])


I'm sure theres a lot more, so anyone else who has an opinion, speak up.

Kevin

- Original Message - 
From: Andi Gutmans [EMAIL PROTECTED]

To: Aaron D. Campbell [EMAIL PROTECTED]; fw-general@lists.zend.com
Sent: Monday, July 09, 2007 7:58 PM
Subject: RE: [fw-general] Release Schedule


Hi Aaron,

We are spending this week on planning. This includes both defining the
product lifecycle (major/minor/mini releases, how we branch, what goes
into mini vs. minor, etc...) and also try and pin down owners +
priorities for the various features.
It will probably not be 100% final by the end of this week but it'll
give everyone a clearer idea of how we think we should manage the
various version releases, what the rought schedules should look like,
etc.. In any case, Zend_View_Layout is high on our priority list and not
a very big piece of work (a lot of headway has already been made by the
various community members). So I believe this should move forward
quickly soon and even if it's not in an official release you'll be able
to pull it out of the incubator.

Andi



-Original Message-
From: Aaron D. Campbell [mailto:[EMAIL PROTECTED]
Sent: Monday, July 09, 2007 3:06 PM
To: fw-general@lists.zend.com
Subject: [fw-general] Release Schedule

I see the roadmap, with some of the future things to be
implemented in ZF, but is there a release schedule?
Specifically I'd like to see when Zend_Layout is coming out.
I was told it would be included in 1.1, but when is that due out?





RE: [fw-general] Release Schedule

2007-07-09 Thread Andi Gutmans
Cool. Don't forget to give us a case-study once you're done :)

Andi 

 -Original Message-
 From: Aaron D. Campbell [mailto:[EMAIL PROTECTED] 
 Sent: Monday, July 09, 2007 7:49 PM
 To: fw-general@lists.zend.com
 Subject: Re: [fw-general] Release Schedule
 
 Awesome.  I have a current application that's been expanded 
 over and over.  We're hoping to start rewriting it in a 
 couple months, and are trying to plan everything out.  
 Hopefully we'll see a good release of Layout before then (or 
 at least see it completed enough to use).
 
 Andi Gutmans wrote:
  Hi Aaron,
 
  We are spending this week on planning. This includes both 
 defining the 
  product lifecycle (major/minor/mini releases, how we 
 branch, what goes 
  into mini vs. minor, etc...) and also try and pin down owners + 
  priorities for the various features.
  It will probably not be 100% final by the end of this week 
 but it'll 
  give everyone a clearer idea of how we think we should manage the 
  various version releases, what the rought schedules should 
 look like, 
  etc.. In any case, Zend_View_Layout is high on our priority 
 list and 
  not a very big piece of work (a lot of headway has already 
 been made 
  by the various community members). So I believe this should move 
  forward quickly soon and even if it's not in an official release 
  you'll be able to pull it out of the incubator.
 
  Andi
 


[fw-general] Zend_Filter_Input fields meta command with arrays problem

2007-07-09 Thread Joshua Ross
I am having a problem with Zend_Filter_Input when attempting to validate an 
array of values using the fields meta command.  What happens is that ZFI 
passes the array of values to my filter which correctly returns true and 
then ZFI passes each value separately which fails.  Here is my 
code(simplified) pretty much straight from the doc:


$validators = array('password_check' = array('StringEquals',
   'presence' = 'required',
   'fields' = array('password0', 'password1'));

$input = new Zend_Filter_Input(array(), $validators, 
$this-getRequest()-getPost());

$input-addNamespace('Local_Validate');

if (!$input-isValid()) {

}

What happens is StringEquals is called three times, once with an array, and 
once with each string.  Some debug output dumping the value passed to my 
StringEquals validator produces the following:


array(2) {
 [password0] = string(9) Testing1!
 [password1] = string(9) Testing1!
}

string(9) Testing1!

string(9) Testing1!


So I looked into ZFI and it appears it handles arrays of fields (line 720 in 
ZF 1.0.0 v5344) but then it continues to evaluate all fields in the data 
array *seperately* validating it against the current validator chain which 
happens to be the validator StringEquals which only validates arrays... 
which of course returns false.


Basically, it appears either I am missing something or having the fields 
meta command set to an array will not work if the validator validates that 
the value is in fact an array.  Anyone else come across this?  Should my 
validator simply return true if the value is not an array?  I'm not sure I 
care too much for that work around.  To me, if you pass the fields meta 
command with an array value it should only validate the array, not each 
seperately.  Any help is appreciated,

Thanks
Josh 





[fw-general] Re: Zend_Filter_Input fields meta command with arrays problem

2007-07-09 Thread Joshua Ross


Joshua Ross [EMAIL PROTECTED] wrote in 
message news:[EMAIL PROTECTED]
I am having a problem with Zend_Filter_Input when attempting to validate an 
array of values using the fields meta command.  What happens is that ZFI 
passes the array of values to my filter which correctly returns true and 
then ZFI passes each value separately which fails.  Here is my 
code(simplified) pretty much straight from the doc:


$validators = array('password_check' = array('StringEquals',
   'presence' = 'required',
   'fields' = array('password0', 'password1'));

$input = new Zend_Filter_Input(array(), $validators, 
$this-getRequest()-getPost());

$input-addNamespace('Local_Validate');

if (!$input-isValid()) {

}

What happens is StringEquals is called three times, once with an array, 
and once with each string.  Some debug output dumping the value passed to 
my StringEquals validator produces the following:


array(2) {
 [password0] = string(9) Testing1!
 [password1] = string(9) Testing1!
}

string(9) Testing1!

string(9) Testing1!


So I looked into ZFI and it appears it handles arrays of fields (line 720 
in ZF 1.0.0 v5344) but then it continues to evaluate all fields in the 
data array *seperately* validating it against the current validator chain 
which happens to be the validator StringEquals which only validates 
arrays... which of course returns false.


Basically, it appears either I am missing something or having the fields 
meta command set to an array will not work if the validator validates that 
the value is in fact an array.  Anyone else come across this?  Should my 
validator simply return true if the value is not an array?  I'm not sure I 
care too much for that work around.  To me, if you pass the fields meta 
command with an array value it should only validate the array, not each 
seperately.  Any help is appreciated,

Thanks
Josh





The following if stmt fixes the issue:
// Added the below if check
if (1 == count($validatorRule[self::FIELDS])) {
   if (!$validatorRule[self::VALIDATOR_CHAIN]-isValid($value)) {
   $this-_invalidMessages[$validatorRule[self::RULE]] = 
$validatorRule[self::VALIDATOR_CHAIN]-getMessages();
   $this-_invalidErrors[$validatorRule[self::RULE]] = 
$validatorRule[self::VALIDATOR_CHAIN]-getErrors();

   unset($this-_validFields[$fieldKey]);
   $failed = true;
   if ($validatorRule[self::BREAK_CHAIN]) {
   return;
   }
}