Re: [fw-general] Zend_Form and validation language
-- Dividy [EMAIL PROTECTED] wrote (on Saturday, 02 February 2008, 03:19 PM -0800): For my first post on this nice forum, could someone explain me in details how to translate the error messages of a zend_form validation ? I tried much thing but none work. You'll need to do several things. First, for each validator you use, determine what the various error codes are -- you can do this by looking at the values of the validator's class constants. For instance, 'Zend_Validate_NotEmpty' defines the constant Zend_Validate_NotEmpty::STRING_EMPTY to 'stringEmpty'. Armed with that list, create translations for one of the translation adapters supported by Zend_Translate. If you were using, for instance, the 'array' adapter, you could do this: ?php // translations.php return array( 'stringEmpty' = 'Please fill in this value', ... ); Then, create your translate object: $translations = include 'path/to/translations.php'; $translate = new Zend_Translate('array', $translations, 'en'); And pass the translation adapter to your form: $form-setTranslator($translate-getAdapter()); And that's all there is to it. The above defines english translations, but you can do whatever language you want; refer to the Zend_Translate manual for more information on creating these. -- Matthew Weier O'Phinney PHP Developer| [EMAIL PROTECTED] Zend - The PHP Company | http://www.zend.com/
Re: [fw-general] How can i inherit Zend_Form_Element?
-- Hinikato [EMAIL PROTECTED] wrote (on Saturday, 02 February 2008, 11:57 PM -0800): I can't understand how can i inherit Zend_Form_Element. I tried redefine them but so many decorators and elements. Extend Zend_Form_Element. If you don't like the decorators present, override the _loadDefaultDecorators() method and setup your own defaults. -- Matthew Weier O'Phinney PHP Developer| [EMAIL PROTECTED] Zend - The PHP Company | http://www.zend.com/
[fw-general] Re: [fw-mvc] Proposal for a user agent component
I agree with all your thoughts on the component. The part with returning device capabilities was more like an eventual goal as you say though. A good start would be to simply classify devices into some predefined categories. The name Zend_Device is also more fitting I guess. Thanks for the comment. I'll update the proposal with these ideas. Matthew Ratzloff wrote: Christer, I'm actually in the process of finishing up just such a component for my job. (Can't share it, unfortunately--it contains some proprietary knowledge.) Some thoughts: - Call it Zend_Device. - Identifying specific mobile devices is more important than identifying specific standard browsers. - Rely on multiple data sources, not just one. - Return device capabilities in addition to identifying the device (maybe you'd want this to be an eventual goal, but plan for it). - If you're returning device capabilities, you'll want some form of local caching/storage. Figure that into the proposal. - Integrate it into the ContextSwitch view helper. Good luck! -Matt On Wed, January 30, 2008 11:26 am, Christer Edvartsen wrote: I have created a page in the wiki that will hold the proposal for a Zend_UserAgent component. The proposal does not hold that much information yet, but I will add some more as soon as I get some feedback from you guys. It's located at http://framework.zend.com/wiki/display/ZFPROP/Zend_UserAgent+-+Christer+Edvartsen The component is supposed to be used to classify user agents into some predefined categories. I suggest the following categories: * Browser * RSS Reader * Mobile Device * Robot A Zend_Controller_Action helper could also be made by using this component but I guess something like this could live outside of a typical MVC application so I suggest it as a separate component. There are several user agent databases out there, and the one I was thinking about using is http://www.user-agents.org/ which has an extensive list of user agent strings. One problem is that the database does not have the Mobile device category. The list is huge though (2500+ user agents) and I don't think it would be necessary to use _every_ user agent string in that database. Does anyone have any ideas of how to decide of what list we could use for something like this? The component will be made in such a manner that developers can add their own list/database if they think the one we provide is not sufficient. The component could also be extended to fetch some more detalied information about mobile devices using WURFL (http://wurfl.sourceforge.net/). Any comments? -- Christer Edvartsen [EMAIL PROTECTED] http://cogo.wordpress.com/ -- Christer Edvartsen [EMAIL PROTECTED] http://cogo.wordpress.com/
Re: [fw-general] Zend_Form and validation language
Hi, Translations doesn't work with AJAX. Example: This code produces standard validators messages $response = $form-processAjax($form-getValues()); $this-getResponse()-setHeader('Content-Type', 'application/json') -setBody($response); This code populates messages from translator file $form-isValid($this-_request-getPost()); I think you should extend method: Zend_Form::public function processAjax(array $data) { require_once 'Zend/Json.php'; if ($this-isValidPartial($data)) { return Zend_Json::encode(true); } $messages = $this-getMessages(); // put translation here ;) return Zend_Json::encode($messages); } regards, Łukasz On 03/02/2008, Matthew Weier O'Phinney [EMAIL PROTECTED] wrote: -- Dividy [EMAIL PROTECTED] wrote (on Saturday, 02 February 2008, 03:19 PM -0800): For my first post on this nice forum, could someone explain me in details how to translate the error messages of a zend_form validation ? I tried much thing but none work. You'll need to do several things. First, for each validator you use, determine what the various error codes are -- you can do this by looking at the values of the validator's class constants. For instance, 'Zend_Validate_NotEmpty' defines the constant Zend_Validate_NotEmpty::STRING_EMPTY to 'stringEmpty'. Armed with that list, create translations for one of the translation adapters supported by Zend_Translate. If you were using, for instance, the 'array' adapter, you could do this: ?php // translations.php return array( 'stringEmpty' = 'Please fill in this value', ... ); Then, create your translate object: $translations = include 'path/to/translations.php'; $translate = new Zend_Translate('array', $translations, 'en'); And pass the translation adapter to your form: $form-setTranslator($translate-getAdapter()); And that's all there is to it. The above defines english translations, but you can do whatever language you want; refer to the Zend_Translate manual for more information on creating these.
Re: [fw-general] JIRA Client license for any Zend Framework developer
This is great news! Thanks! Andries Seutens http://andries.systray.be Simone Carletti schreef: Hi all, Igor Sereda, the chief developer of JIRA Client and owner of ALM Works, has provided a JIRA Client license for free for any Zend Framework developer. If you don't know JIRA Client, this software is a cross platform desktop client for JIRA issue tracker. http://www.almworks.com/jiraclient/overview.html With JIRA Client you have access to all the most important features of JIRA with some nice plus such as offline management, custom advanced filters and reports. JIRA Client is not a free software but since Zend Framework is an open source project, Igor provided the license for free according to current JIRA Client license agreement. I attach the license here to this post if someone else wants to use it. http://www.nabble.com/file/p15268436/jiraclient_zend.license jiraclient_zend.license -- Simone Gecontroleerd op virussen door de JOJO Secure Gateway.
Re: [fw-general] Zend_Form and validation language
-- Dividy [EMAIL PROTECTED] wrote (on Monday, 04 February 2008, 06:22 AM -0800): Dividy wrote: For my first post on this nice forum, could someone explain me in details how to translate the error messages of a zend_form validation ? I tried much thing but none work. Thanks. First, thanks for answering so fast because using Zend every day, is just a pure pleasure. Here's what i had came to while waiting for your answer : Please note my previous response -- this is no longer necessary using the current svn trunk, as getMessages() now translates error messages by default if a translate adapter is present and the error code is present in the translations. ?php $t=$form-getElements(); foreach ($t as $element) { $validateurs=$element-getValidators(); $validateurs_noms=array_keys($validateurs); for ($k=0;$kcount($validateurs_noms);$k++){ if ($validateurs_noms[$k]=='Zend_Validate_StringLength'){ $valobj=$element-getValidator($validateurs_noms[$k]); $valobj-setMessages( array( Zend_Validate_StringLength::TOO_SHORT = 'Les données saisies sont trop courtes', Zend_Validate_StringLength::TOO_LONG = 'Les données saisies sont trop trop longues' )); } if ($validateurs_noms[$k]=='Zend_Validate_Alnum'){ $valobj=$element-getValidator($validateurs_noms[$k]); $valobj-setMessages( array( Zend_Validate_Alnum::STRING_EMPTY = 'Ce champ est requis', Zend_Validate_Alnum::NOT_ALNUM = 'Uniquement des chiffres et des lettres' )); } if ($validateurs_noms[$k]=='Zend_Validate_Regex'){ $valobj=$element-getValidator($validateurs_noms[$k]); $valobj-setMessages( array( Zend_Validate_Regex::NOT_MATCH = 'Les données ne correspondent pas au format demandé' )); } if ($validateurs_noms[$k]=='Zend_Validate_InArray'){ $valobj=$element-getValidator($validateurs_noms[$k]); $valobj-setMessages( array( Zend_Validate_InArray::NOT_IN_ARRAY = 'Mauvais choix, veuillez recommencer' )); } if ($validateurs_noms[$k]=='Zend_Validate_NotEmpty'){ $valobj=$element-getValidator($validateurs_noms[$k]); $valobj-setMessages( array( Zend_Validate_NotEmpty::IS_EMPTY = 'Le champ est vide, veuillez le remplir' )); } if ($validateurs_noms[$k]=='Zend_Validate_EmailAddress'){ $valobj=$element-getValidator($validateurs_noms[$k]); $valobj-setMessages( array( Zend_Validate_EmailAddress::INVALID = 'Adresse e-mail invalide, veuillez la vérifier', Zend_Validate_EmailAddress::INVALID_HOSTNAME = 'Adresse e-mail invalide, veuillez la vérifier', Zend_Validate_EmailAddress::INVALID_LOCAL_PART= 'Adresse e-mail invalide, veuillez la vérifier', Zend_Validate_EmailAddress::INVALID_MX_RECORD = 'Adresse e-mail invalide, veuillez la vérifier' )); } } } ? -- Matthew Weier O'Phinney PHP Developer| [EMAIL PROTECTED] Zend - The PHP Company | http://www.zend.com/
Re: [fw-general] Zend_Form and validation language
Dividy wrote: Hello all :) For my first post on this nice forum, could someone explain me in details how to translate the error messages of a zend_form validation ? I tried much thing but none work. Thanks. First, thanks for answering so fast because using Zend every day, is just a pure pleasure. Here's what i had came to while waiting for your answer : ?php $t=$form-getElements(); foreach ($t as $element) { $validateurs=$element-getValidators(); $validateurs_noms=array_keys($validateurs); for ($k=0;$kcount($validateurs_noms);$k++){ if ($validateurs_noms[$k]=='Zend_Validate_StringLength'){ $valobj=$element-getValidator($validateurs_noms[$k]); $valobj-setMessages( array( Zend_Validate_StringLength::TOO_SHORT = 'Les données saisies sont trop courtes', Zend_Validate_StringLength::TOO_LONG = 'Les données saisies sont trop trop longues' )); } if ($validateurs_noms[$k]=='Zend_Validate_Alnum'){ $valobj=$element-getValidator($validateurs_noms[$k]); $valobj-setMessages( array( Zend_Validate_Alnum::STRING_EMPTY = 'Ce champ est requis', Zend_Validate_Alnum::NOT_ALNUM = 'Uniquement des chiffres et des lettres' )); } if ($validateurs_noms[$k]=='Zend_Validate_Regex'){ $valobj=$element-getValidator($validateurs_noms[$k]); $valobj-setMessages( array( Zend_Validate_Regex::NOT_MATCH = 'Les données ne correspondent pas au format demandé' )); } if ($validateurs_noms[$k]=='Zend_Validate_InArray'){ $valobj=$element-getValidator($validateurs_noms[$k]); $valobj-setMessages( array( Zend_Validate_InArray::NOT_IN_ARRAY = 'Mauvais choix, veuillez recommencer' )); } if ($validateurs_noms[$k]=='Zend_Validate_NotEmpty'){ $valobj=$element-getValidator($validateurs_noms[$k]); $valobj-setMessages( array( Zend_Validate_NotEmpty::IS_EMPTY = 'Le champ est vide, veuillez le remplir' )); } if ($validateurs_noms[$k]=='Zend_Validate_EmailAddress'){ $valobj=$element-getValidator($validateurs_noms[$k]); $valobj-setMessages( array( Zend_Validate_EmailAddress::INVALID = 'Adresse e-mail invalide, veuillez la vérifier', Zend_Validate_EmailAddress::INVALID_HOSTNAME = 'Adresse e-mail invalide, veuillez la vérifier', Zend_Validate_EmailAddress::INVALID_LOCAL_PART= 'Adresse e-mail invalide, veuillez la vérifier', Zend_Validate_EmailAddress::INVALID_MX_RECORD = 'Adresse e-mail invalide, veuillez la vérifier' )); } } } ? -- View this message in context: http://www.nabble.com/Zend_Form-and-validation-language-tp15248574s16154p15268761.html Sent from the Zend Framework mailing list archive at Nabble.com.
[fw-general] redirect and 500 Internal Error
Hi. It wont be a pure Zend Framewerok issue. I have problem with apache's 500 Internal Error on several production servers. For example. This code works on my localhost machine but on production server it rises 500 Internal Error: // SomeController.php function doSomethingAction() { $this-_redirector-gotoRouteAndExit(array('id' = $quiz_id), 'quiz_info'); } // SomeRouters.php $route = new Zend_Controller_Router_Route( 'quiz/info/:id', array( 'module'= 'index', 'controller'= 'quiz', 'action'= 'show' ) ); $router-addRoute('quiz_info', $route); During several experiments I've figured out that it produces some infinite loop (something like redirections chain). On both machines I have standard .htaccess file: RewriteEngine on RewriteRule !\.(js|ico|gif|jpg|png|swf|css|html)$ index.php Where is the bug? Thanks for help, Łukasz
Re: [fw-general] Get output from other controller/action
-- daniel.stancu [EMAIL PROTECTED] wrote (on Monday, 04 February 2008, 07:12 AM -0800): Could someone explain to me how to get the output of other controller/action from the current controller? Use the action view helper: public function someAction { // Grab content from FooController::otherAction(): $otherAction = $this-view-action('other', 'foo'); // ... } This assumes you're using either current svn trunk or the 1.5.0 Preview Release. -- Matthew Weier O'Phinney PHP Developer| [EMAIL PROTECTED] Zend - The PHP Company | http://www.zend.com/
Re: [fw-general] Get output from other controller/action
Hi Daniel, Depends on why you need it - if you want to attach the output to a View, there's the Action View Helper which can be called from your view template. Otherwise, you could dig into it's code and replicate it into a Controller Action Helper accessible from with any Controller. Both options are entirely possible, but the I don't think the controller based one is implemented in the framework by default. Best regards, Paddy daniel.stancu wrote: Hi, Could someone explain to me how to get the output of other controller/action from the current controller? Thanks, Daniel Stancu - Pádraic Brady http://blog.astrumfutura.com http://www.patternsforphp.com OpenID Europe Foundation - Irish Representative -- View this message in context: http://www.nabble.com/Get-output-from-other-controller-action-tp15268947s16154p15269460.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] Zend_Form and validation language
Thanks for all your good advices. I tried everything you proposed some days ago and it didn't give any good results. That's why i have come with this solution. But please, if you could give me an example of line you'd put in a csv file, that would be great :) e.g. I tried using isEmpty;The string is empty in my en.csv file and then put the translation in my fr.csv file, but it didn't work :) Thanks in advance for your precious time. Matthew Weier O'Phinney-3 wrote: -- Dividy [EMAIL PROTECTED] wrote (on Monday, 04 February 2008, 06:22 AM -0800): Dividy wrote: For my first post on this nice forum, could someone explain me in details how to translate the error messages of a zend_form validation ? I tried much thing but none work. Thanks. First, thanks for answering so fast because using Zend every day, is just a pure pleasure. Here's what i had came to while waiting for your answer : Please note my previous response -- this is no longer necessary using the current svn trunk, as getMessages() now translates error messages by default if a translate adapter is present and the error code is present in the translations. ?php $t=$form-getElements(); foreach ($t as $element) { $validateurs=$element-getValidators(); $validateurs_noms=array_keys($validateurs); for ($k=0;$kcount($validateurs_noms);$k++){ if ($validateurs_noms[$k]=='Zend_Validate_StringLength'){ $valobj=$element-getValidator($validateurs_noms[$k]); $valobj-setMessages( array( Zend_Validate_StringLength::TOO_SHORT = 'Les données saisies sont trop courtes', Zend_Validate_StringLength::TOO_LONG = 'Les données saisies sont trop trop longues' )); } if ($validateurs_noms[$k]=='Zend_Validate_Alnum'){ $valobj=$element-getValidator($validateurs_noms[$k]); $valobj-setMessages( array( Zend_Validate_Alnum::STRING_EMPTY = 'Ce champ est requis', Zend_Validate_Alnum::NOT_ALNUM = 'Uniquement des chiffres et des lettres' )); } if ($validateurs_noms[$k]=='Zend_Validate_Regex'){ $valobj=$element-getValidator($validateurs_noms[$k]); $valobj-setMessages( array( Zend_Validate_Regex::NOT_MATCH = 'Les données ne correspondent pas au format demandé' )); } if ($validateurs_noms[$k]=='Zend_Validate_InArray'){ $valobj=$element-getValidator($validateurs_noms[$k]); $valobj-setMessages( array( Zend_Validate_InArray::NOT_IN_ARRAY = 'Mauvais choix, veuillez recommencer' )); } if ($validateurs_noms[$k]=='Zend_Validate_NotEmpty'){ $valobj=$element-getValidator($validateurs_noms[$k]); $valobj-setMessages( array( Zend_Validate_NotEmpty::IS_EMPTY = 'Le champ est vide, veuillez le remplir' )); } if ($validateurs_noms[$k]=='Zend_Validate_EmailAddress'){ $valobj=$element-getValidator($validateurs_noms[$k]); $valobj-setMessages( array( Zend_Validate_EmailAddress::INVALID = 'Adresse e-mail invalide, veuillez la vérifier', Zend_Validate_EmailAddress::INVALID_HOSTNAME = 'Adresse e-mail invalide, veuillez la vérifier', Zend_Validate_EmailAddress::INVALID_LOCAL_PART= 'Adresse e-mail invalide, veuillez la vérifier', Zend_Validate_EmailAddress::INVALID_MX_RECORD = 'Adresse e-mail invalide, veuillez la vérifier' )); } } } ? -- Matthew Weier O'Phinney PHP Developer| [EMAIL
Re: [fw-general] redirect and 500 Internal Error
most likely the problem is that mod_rewrite is not enabled on the production server. enable it (or make your admin do it) and you should be good to go. Best regards, Tobias 2008/2/4, Łukasz Kazimierz Bandzarewicz [EMAIL PROTECTED]: Hi. It wont be a pure Zend Framewerok issue. I have problem with apache's 500 Internal Error on several production servers. For example. This code works on my localhost machine but on production server it rises 500 Internal Error: // SomeController.php function doSomethingAction() { $this-_redirector-gotoRouteAndExit(array('id' = $quiz_id), 'quiz_info'); } // SomeRouters.php $route = new Zend_Controller_Router_Route( 'quiz/info/:id', array( 'module'= 'index', 'controller'= 'quiz', 'action'= 'show' ) ); $router-addRoute('quiz_info', $route); During several experiments I've figured out that it produces some infinite loop (something like redirections chain). On both machines I have standard .htaccess file: RewriteEngine on RewriteRule !\.(js|ico|gif|jpg|png|swf|css|html)$ index.php Where is the bug? Thanks for help, Łukasz
[fw-general] Zend_Http_Client_Adapter_Curl
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, I needed curl for authentication to the proxy with NTLM. Therefore I changed the Zend_Http_Client_Adapter_Curl (in the incubator) according to the Zend_Http_Client_Adapter_Interface. Now the curl adapter passes successful the same phpunit tests the socket adapter is going through. 0 errors with PHP Code Sniffer (Zend Coding Standard) What else has to be done to move out the adapter from the incubator? Best Regards Christian Fraunholz - -- Mayflower GmbH / ThinkPHP Developer -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.7 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHpu6JrZ77+sisSpIRAo7/AJ4wdILSbz5mJQCY6lLwLhGIlCmjEACgmDqc 60tZQX6SRDhcgMxF+r33OgQ= =qxx2 -END PGP SIGNATURE-
Re: [fw-general] Zend_Form and validation language
-- Dividy [EMAIL PROTECTED] wrote (on Monday, 04 February 2008, 09:42 AM -0800): Thanks for all your good advices. I tried everything you proposed some days ago and it didn't give any good results. That's why i have come with this solution. But please, if you could give me an example of line you'd put in a csv file, that would be great :) e.g. I tried using isEmpty;The string is empty in my en.csv file and then put the translation in my fr.csv file, but it didn't work :) You had it right... but there was a problem in trunk... while validation in the *elements* was getting properly translated, the form object was not injecting the translator into the elements... oops! Corrected now in svn trunk. Thanks in advance for your precious time. And thank you for the issue reporting! Matthew Weier O'Phinney-3 wrote: -- Dividy [EMAIL PROTECTED] wrote (on Monday, 04 February 2008, 06:22 AM -0800): Dividy wrote: For my first post on this nice forum, could someone explain me in details how to translate the error messages of a zend_form validation ? I tried much thing but none work. Thanks. First, thanks for answering so fast because using Zend every day, is just a pure pleasure. Here's what i had came to while waiting for your answer : Please note my previous response -- this is no longer necessary using the current svn trunk, as getMessages() now translates error messages by default if a translate adapter is present and the error code is present in the translations. ?php $t=$form-getElements(); foreach ($t as $element) { $validateurs=$element-getValidators(); $validateurs_noms=array_keys($validateurs); for ($k=0;$kcount($validateurs_noms);$k++){ if ($validateurs_noms[$k]=='Zend_Validate_StringLength'){ $valobj=$element-getValidator($validateurs_noms[$k]); $valobj-setMessages( array( Zend_Validate_StringLength::TOO_SHORT = 'Les données saisies sont trop courtes', Zend_Validate_StringLength::TOO_LONG = 'Les données saisies sont trop trop longues' )); } if ($validateurs_noms[$k]=='Zend_Validate_Alnum'){ $valobj=$element-getValidator($validateurs_noms[$k]); $valobj-setMessages( array( Zend_Validate_Alnum::STRING_EMPTY = 'Ce champ est requis', Zend_Validate_Alnum::NOT_ALNUM = 'Uniquement des chiffres et des lettres' )); } if ($validateurs_noms[$k]=='Zend_Validate_Regex'){ $valobj=$element-getValidator($validateurs_noms[$k]); $valobj-setMessages( array( Zend_Validate_Regex::NOT_MATCH = 'Les données ne correspondent pas au format demandé' )); } if ($validateurs_noms[$k]=='Zend_Validate_InArray'){ $valobj=$element-getValidator($validateurs_noms[$k]); $valobj-setMessages( array( Zend_Validate_InArray::NOT_IN_ARRAY = 'Mauvais choix, veuillez recommencer' )); } if ($validateurs_noms[$k]=='Zend_Validate_NotEmpty'){ $valobj=$element-getValidator($validateurs_noms[$k]); $valobj-setMessages( array( Zend_Validate_NotEmpty::IS_EMPTY = 'Le champ est vide, veuillez le remplir' )); } if ($validateurs_noms[$k]=='Zend_Validate_EmailAddress'){ $valobj=$element-getValidator($validateurs_noms[$k]); $valobj-setMessages( array( Zend_Validate_EmailAddress::INVALID = 'Adresse e-mail invalide, veuillez la vérifier', Zend_Validate_EmailAddress::INVALID_HOSTNAME = 'Adresse e-mail invalide, veuillez la vérifier',
Re: [fw-general] Zend_Form and validation language
-- Łukasz Kazimierz Bandzarewicz [EMAIL PROTECTED] wrote (on Monday, 04 February 2008, 11:02 AM +0100): Translations doesn't work with AJAX. Example: This code produces standard validators messages $response = $form-processAjax($form-getValues()); $this-getResponse()-setHeader('Content-Type', 'application/json') -setBody($response); This code populates messages from translator file $form-isValid($this-_request-getPost()); I think you should extend method: Zend_Form::public function processAjax(array $data) { require_once 'Zend/Json.php'; if ($this-isValidPartial($data)) { return Zend_Json::encode(true); } $messages = $this-getMessages(); // put translation here ;) return Zend_Json::encode($messages); } You must not be using subversion. :-) I modified getMessages() in trunk late last week to perform translations; getMessages() now always returns i18n-ized messages if a translate adapter is present. On 03/02/2008, Matthew Weier O'Phinney [EMAIL PROTECTED] wrote: -- Dividy [EMAIL PROTECTED] wrote (on Saturday, 02 February 2008, 03:19 PM -0800): For my first post on this nice forum, could someone explain me in details how to translate the error messages of a zend_form validation ? I tried much thing but none work. You'll need to do several things. First, for each validator you use, determine what the various error codes are -- you can do this by looking at the values of the validator's class constants. For instance, 'Zend_Validate_NotEmpty' defines the constant Zend_Validate_NotEmpty::STRING_EMPTY to 'stringEmpty'. Armed with that list, create translations for one of the translation adapters supported by Zend_Translate. If you were using, for instance, the 'array' adapter, you could do this: ?php // translations.php return array( 'stringEmpty' = 'Please fill in this value', ... ); Then, create your translate object: $translations = include 'path/to/translations.php'; $translate = new Zend_Translate('array', $translations, 'en'); And pass the translation adapter to your form: $form-setTranslator($translate-getAdapter()); And that's all there is to it. The above defines english translations, but you can do whatever language you want; refer to the Zend_Translate manual for more information on creating these. -- Matthew Weier O'Phinney PHP Developer| [EMAIL PROTECTED] Zend - The PHP Company | http://www.zend.com/
Re: [fw-general] redirect and 500 Internal Error
what is the entry in the apache error.log? 2008/2/4, Łukasz Kazimierz Bandzarewicz [EMAIL PROTECTED]: Without mod_rewrite you can't execute ZF application. I forgot mention that, if I change redirect code to: if (isset($_SERVER['HTTP_REFERER'])) { $previousUrl = $_SERVER['HTTP_REFERER']; } else { $previousUrl = BASE_URL; } $this-_redirect($previousUrl); script works on both servers. Any ideas? On 04/02/2008, Tobias Gies [EMAIL PROTECTED] wrote: most likely the problem is that mod_rewrite is not enabled on the production server. enable it (or make your admin do it) and you should be good to go. Best regards, Tobias 2008/2/4, Łukasz Kazimierz Bandzarewicz [EMAIL PROTECTED]: Hi. It wont be a pure Zend Framewerok issue. I have problem with apache's 500 Internal Error on several production servers. For example. This code works on my localhost machine but on production server it rises 500 Internal Error: // SomeController.php function doSomethingAction() { $this-_redirector-gotoRouteAndExit(array('id' = $quiz_id), 'quiz_info'); } // SomeRouters.php $route = new Zend_Controller_Router_Route( 'quiz/info/:id', array( 'module'= 'index', 'controller'= 'quiz', 'action'= 'show' ) ); $router-addRoute('quiz_info', $route); During several experiments I've figured out that it produces some infinite loop (something like redirections chain). On both machines I have standard .htaccess file: RewriteEngine on RewriteRule !\.(js|ico|gif|jpg|png|swf|css|html)$ index.php Where is the bug? Thanks for help, Łukasz
Re: [fw-general] Zend_Loader and Zend_Filter_Input issues
OK, thanks for clearing that up Matthew. Matthew Weier O'Phinney-3 wrote: -- Codiac [EMAIL PROTECTED] wrote (on Monday, 04 February 2008, 10:48 AM -0800): I noticed the E_WARNING in my apps too and also noticed you're assigned to solve it ;-). For me it's unclear which fix version release is the mini-release that's mentioned in the jira issue, is that the 1.5.0PR2 release or will it be solved in the Release Candidates? It will need to be for the next release candidate; the plugin loader, which Simon used to correct the problem, is not going into a core release until then. Simon Mundy wrote: Hi Darby The revisions you've made to Zend_Loader have thrown up some other side-effects - and looking closely into the Zend_Filter_Input module perhaps that's been a good thing! When I updated my ZF library to trunk, I started getting lots of E_WARNINGs refering to missing Zend_Filter_NotEmpty and Zend_Filter_Between. Strange, I thought, they're only validators, not filters. Try as I could I couldn't shake these warnings (I leave my dev box as 'chatty' as possible to even throw notices to see if everything is OK). When I looked closer into the Zend_Filter_Input class, I found that there's a method called '_getFilterOrValidator($interface, $classBaseName)'. It iterates through all the namespaces to find a matching class - which probably worked noiselessly before, but now, of course, Zend_Loader throws all these warnings for non-existent classes. Is there a reason for this performance hog - Zend_Filter_Input I mean? Is there any likelihood that a filter and a validator will share the same namespace? Are there any developers out there that would be adversely affected by a slight refactoring for this - adding namespaces for either a Validator or Filter so that the loader can be slightly more efficient? I'll pop an issue in on JIRA but wanted to raise it here first to gauge a reaction and see who's the caretaker of this component at present? Cheers -- Simon Mundy | Director | PEPTOLAB 202/258 Flinders Lane | Melbourne | Victoria | Australia | 3000 Voice +61 (0) 3 9654 4324 | Mobile 0438 046 061 | Fax +61 (0) 3 9654 4124 http://www.peptolab.com -- View this message in context: http://www.nabble.com/Zend_Loader-and-Zend_Filter_Input-issues-tp15241946s16154p15273466.html Sent from the Zend Framework mailing list archive at Nabble.com. -- Matthew Weier O'Phinney PHP Developer| [EMAIL PROTECTED] Zend - The PHP Company | http://www.zend.com/ -- View this message in context: http://www.nabble.com/Zend_Loader-and-Zend_Filter_Input-issues-tp15241946s16154p15275792.html Sent from the Zend Framework mailing list archive at Nabble.com.
[fw-general] Get output from other controller/action
Hi, Could someone explain to me how to get the output of other controller/action from the current controller? Thanks, Daniel Stancu -- View this message in context: http://www.nabble.com/Get-output-from-other-controller-action-tp15268947s16154p15268947.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] Zend_Form and validation language
-- Jim Scherer [EMAIL PROTECTED] wrote (on Monday, 04 February 2008, 09:24 AM -0800): How does this work for 'INVALID' that appears in EmailAddress and Date? Or 'STRING_EMPTY' that appears in Alnum, Alpha, and Digits? Use the values of the constants as the keys. So, with EmailAddress: emailAddressInvalid emailAddressInvalidHostname emailAddressInvalidMxRecord emailAddressInvalidDotAtom emailAddressInvalidQuotedString emailAddressInvalidLocalPart or with Digits: notDigits stringEmpty etc. Most of the Zend_Validate constants are simply camelCased versions of the constants. Matthew Weier O'Phinney-3 wrote: -- Dividy [EMAIL PROTECTED] wrote (on Saturday, 02 February 2008, 03:19 PM -0800): For my first post on this nice forum, could someone explain me in details how to translate the error messages of a zend_form validation ? I tried much thing but none work. You'll need to do several things. First, for each validator you use, determine what the various error codes are -- you can do this by looking at the values of the validator's class constants. For instance, 'Zend_Validate_NotEmpty' defines the constant Zend_Validate_NotEmpty::STRING_EMPTY to 'stringEmpty'. Armed with that list, create translations for one of the translation adapters supported by Zend_Translate. If you were using, for instance, the 'array' adapter, you could do this: ?php // translations.php return array( 'stringEmpty' = 'Please fill in this value', ... ); Then, create your translate object: $translations = include 'path/to/translations.php'; $translate = new Zend_Translate('array', $translations, 'en'); And pass the translation adapter to your form: $form-setTranslator($translate-getAdapter()); And that's all there is to it. The above defines english translations, but you can do whatever language you want; refer to the Zend_Translate manual for more information on creating these. -- Matthew Weier O'Phinney PHP Developer| [EMAIL PROTECTED] Zend - The PHP Company | http://www.zend.com/ -- View this message in context: http://www.nabble.com/Zend_Form-and-validation-language-tp15248574s16154p15269233.html Sent from the Zend Framework mailing list archive at Nabble.com. -- Matthew Weier O'Phinney PHP Developer| [EMAIL PROTECTED] Zend - The PHP Company | http://www.zend.com/
[fw-general] Zend_Filter_Input refactoring
Hi everyone A heads-up to anyone using Zend_Filter_Input - there's a refactored version of Zend_Filter_Input added to the incubator that's ready for testing and comment by the community. It was refactored after noticing the E_WARNING's being thrown up after the improvements made to Zend_Loader - the warnings were being thrown because Zend_Filter_Input cycled through a number of namespaces to try and match class names. E.g. if I wanted to access the validator 'Between' then firstly Zend_Filter_Input would try and match 'Zend_Filter_Between' (and fail) before finding Zend_Validate_Between. Previously no such warnings were emitted because Zend_Loader suppressed error messages. The new component leverages the flexibility of the plugin loader and performs equally as well if not slightly more efficiently. A couple of notes:- * The protected properties '_namespaces' and '_userNamespaces' are removed (made redundant) * The 'addNamespace()' method has been marked as deprecated but maintained for BC. It proxies to addFilterPrefixPath and addValidatePrefixPath to provide essentially the same functionality Could anyone who uses (and perhaps subclasses) Zend_Filter_Input please give this a test run and make comment on it as soon as possible? I'd like to gauge if there's likely to be any conflicts before this can be added to trunk. Cheers -- Simon Mundy | Director | PEPTOLAB 202/258 Flinders Lane | Melbourne | Victoria | Australia | 3000 Voice +61 (0) 3 9654 4324 | Mobile 0438 046 061 | Fax +61 (0) 3 9654 4124 http://www.peptolab.com
Re: [fw-general] Zend_Loader and Zend_Filter_Input issues
-- Codiac [EMAIL PROTECTED] wrote (on Monday, 04 February 2008, 10:48 AM -0800): I noticed the E_WARNING in my apps too and also noticed you're assigned to solve it ;-). For me it's unclear which fix version release is the mini-release that's mentioned in the jira issue, is that the 1.5.0PR2 release or will it be solved in the Release Candidates? It will need to be for the next release candidate; the plugin loader, which Simon used to correct the problem, is not going into a core release until then. Simon Mundy wrote: Hi Darby The revisions you've made to Zend_Loader have thrown up some other side-effects - and looking closely into the Zend_Filter_Input module perhaps that's been a good thing! When I updated my ZF library to trunk, I started getting lots of E_WARNINGs refering to missing Zend_Filter_NotEmpty and Zend_Filter_Between. Strange, I thought, they're only validators, not filters. Try as I could I couldn't shake these warnings (I leave my dev box as 'chatty' as possible to even throw notices to see if everything is OK). When I looked closer into the Zend_Filter_Input class, I found that there's a method called '_getFilterOrValidator($interface, $classBaseName)'. It iterates through all the namespaces to find a matching class - which probably worked noiselessly before, but now, of course, Zend_Loader throws all these warnings for non-existent classes. Is there a reason for this performance hog - Zend_Filter_Input I mean? Is there any likelihood that a filter and a validator will share the same namespace? Are there any developers out there that would be adversely affected by a slight refactoring for this - adding namespaces for either a Validator or Filter so that the loader can be slightly more efficient? I'll pop an issue in on JIRA but wanted to raise it here first to gauge a reaction and see who's the caretaker of this component at present? Cheers -- Simon Mundy | Director | PEPTOLAB 202/258 Flinders Lane | Melbourne | Victoria | Australia | 3000 Voice +61 (0) 3 9654 4324 | Mobile 0438 046 061 | Fax +61 (0) 3 9654 4124 http://www.peptolab.com -- View this message in context: http://www.nabble.com/Zend_Loader-and-Zend_Filter_Input-issues-tp15241946s16154p15273466.html Sent from the Zend Framework mailing list archive at Nabble.com. -- Matthew Weier O'Phinney PHP Developer| [EMAIL PROTECTED] Zend - The PHP Company | http://www.zend.com/
Re: [fw-general] Zend_TextParser proposal, ideas, suggestions?
Hi, I did finish the Zend_TextParser proposal, it is ready for review and I would appreciate any feedback. The link to the proposal: http://framework.zend.com/wiki/x/3KQ Regards, Pieter Kokx
Re: [fw-general] redirect and 500 Internal Error
It should. However, you should also look into your .htaccess file again. did you set a proper RewriteBase (i.e., RewriteBase /subdir)? Best regards Tobias 2008/2/4, Łukasz Kazimierz Bandzarewicz [EMAIL PROTECTED]: I read ZF manual very carefully and I've found: 7.4.2.2. Base Url and Subdirectories Zend_Controller_Request_Http allows Zend_Controller_Router_Rewrite to be used in subdirectories. Zend_Controller_Request_Http will attempt to automatically detect your base URL and set it accordingly. For example, if you keep your index.php in a webserver subdirectory named /projects/myapp/index.php, base URL (rewrite base) should be set to /projects/myapp. This string will then be stripped from the beginning of the path before calculating any route matches. This frees one from the necessity of prepending it to any of your routes. A route of 'user/:username' will match URIs like http://localhost/projects/myapp/user/martel and http://example.com/user/martel. On my localhost machine baseUrl is: localhost/my_site/www On the server: production_site.com/subdir Now I don't have time for test it, but I think $controller-setBaseUrl('...') will solve this problem, wouldn't it? regards, Łukasz On 04/02/2008, Tobias Gies [EMAIL PROTECTED] wrote: you will then have to ask the server admin. my crystal ball is broken :-( 2008/2/4, Łukasz Kazimierz Bandzarewicz [EMAIL PROTECTED]: Unfortunately I don't have access to error.log On 04/02/2008, Tobias Gies [EMAIL PROTECTED] wrote: what is the entry in the apache error.log? 2008/2/4, Łukasz Kazimierz Bandzarewicz [EMAIL PROTECTED]: Without mod_rewrite you can't execute ZF application. I forgot mention that, if I change redirect code to: if (isset($_SERVER['HTTP_REFERER'])) { $previousUrl = $_SERVER['HTTP_REFERER']; } else { $previousUrl = BASE_URL; } $this-_redirect($previousUrl); script works on both servers. Any ideas? On 04/02/2008, Tobias Gies [EMAIL PROTECTED] wrote: most likely the problem is that mod_rewrite is not enabled on the production server. enable it (or make your admin do it) and you should be good to go. Best regards, Tobias 2008/2/4, Łukasz Kazimierz Bandzarewicz [EMAIL PROTECTED]: Hi. It wont be a pure Zend Framewerok issue. I have problem with apache's 500 Internal Error on several production servers. For example. This code works on my localhost machine but on production server it rises 500 Internal Error: // SomeController.php function doSomethingAction() { $this-_redirector-gotoRouteAndExit(array('id' = $quiz_id), 'quiz_info'); } // SomeRouters.php $route = new Zend_Controller_Router_Route( 'quiz/info/:id', array( 'module'= 'index', 'controller'= 'quiz', 'action'= 'show' ) ); $router-addRoute('quiz_info', $route); During several experiments I've figured out that it produces some infinite loop (something like redirections chain). On both machines I have standard .htaccess file: RewriteEngine on RewriteRule !\.(js|ico|gif|jpg|png|swf|css|html)$ index.php Where is the bug? Thanks for help, Łukasz
[fw-general] Nested Calls to Zend_View View Action Helper
Suppose I have a phtml file that features something like: ?= $this-action('index', 'nav') ? Say NavController implements three actions: indexAction, widgetOneAction, and widgetTwoAction; indexAction does nothing but render the following view script: pstart/p ?= $this-action('widgetOne', 'nav') ? ?= $this-action('widgetTwo', 'nav') ? pend/p When I try this, the eventual output ends up looking something like this: [output of widgetTwo] pstart/p [output of widgetOne] [output of widgetTwo] pend/p If the order of widgetOne and widgetTwo are switched, then widgetOne's output gets duplicated instead. If either call is eliminated, the remaining widget gets its output duplicated. The action functions aren't getting called twice, the output of the last function is simply being prepended to the desired output for some reason. Can anybody help me understand why this is? Is nesting calls to the view action helper even a good idea? What is the preferred way of implementing behavior like this? -- View this message in context: http://www.nabble.com/Nested-Calls-to-Zend_View-View-Action-Helper-tp15281249s16154p15281249.html Sent from the Zend Framework mailing list archive at Nabble.com.