[fw-general] Zend_Form upload file

2010-03-16 Thread Jacky Chen
Hi,

i have found that Zend_Form_Element_File ignore no file option would not
work if the form that submited is missing that file element.

let's say,there is a form that upload a file to the server,

form enctype=multipart/form-data action=/demo/upload method=post

any text:input type=text name=any / br /

upload file:input type=file name=uploadFile /br /

input type=submit value=upload /

/form



and the Zend_Form as this,

?php

class DemoController extends Zend_Controller_Action

{

public function uploadAction() {

$form = new Zend_Form();
$any = new Zend_Form_Element_Text('any');
$form-addElement($any);

$uploadFile = new Zend_Form_Element_File('uploadFile');
$uploadFile-setAllowEmpty(true);
$form-addElement($uploadFile);

if ($this-_request-isPost()  $form-isValid($_POST)) {
 echo 'valid';
}

}

}


then submit the form,that is ok.But if submit the form as this,it is not valid,

form enctype=multipart/form-data action=/demo/upload method=post

any text:input type=text name=any / br /

input type=submit value=upload /

/form

this form just missing the file element,input type=file
name=uploadFile /,but i had set the Zend_Form to allow empty
file,ignore no file option.


I think this should be a bug. Right?


Best Regards


[fw-general] create form element problems

2009-08-05 Thread Jacky Chen
Hi there,
when i create a form element with pluginLoader in the options,
like this,

$text = new Zend_Form_Element_Text('name',array(

'pluginLoader' = new Zend_Loader_PluginLoader(array(
'My_Path_Prefix'='My/Path/Prefix'))

));

it throw the exception like following:

An error occurred

Application error

Exception information:

Message: Invalid type  provided to setPluginLoader()

Stack trace:

#0 /Code/php/ZendFramework/library/Zend/Form/Element.php(329):
Zend_Form_Element-setPluginLoader(Object(Zend_Loader_PluginLoader))
#1 /Code/php/ZendFramework/library/Zend/Form/Element.php(223):
Zend_Form_Element-setOptions(Array)
#2 /projects/SiteBuilder/application/controllers/IndexController.php(15):
Zend_Form_Element-__construct('name', Array)
#3 /Code/php/ZendFramework/library/Zend/Controller/Action.php(513):
IndexController-indexAction()
#4
/Code/php/ZendFramework/library/Zend/Controller/Dispatcher/Standard.php(289):
Zend_Controller_Action-dispatch('indexAction')
#5 /Code/php/ZendFramework/library/Zend/Controller/Front.php(946):
Zend_Controller_Dispatcher_Standard-dispatch(Object(Zend_Controller_Request_Http),
Object(Zend_Controller_Response_Http))
#6
/Code/php/ZendFramework/library/Zend/Application/Bootstrap/Bootstrap.php(77):
Zend_Controller_Front-dispatch()
#7 /Code/php/ZendFramework/library/Zend/Application.php(335):
Zend_Application_Bootstrap_Bootstrap-run()
#8 /projects/SiteBuilder/public/index.php(26): Zend_Application-run()
#9 {main}

Request Parameters:

array (
'controller' = 'index',
'action' = 'index',
'module' = 'default',
)
how can i provide the type of the pluginLoader in the element construct
options?

Best Regards
Jacky


[fw-general] zend_db_table::fetchRow() always fetch the first row

2009-08-05 Thread Jacky Chen
Hi there,
if the Zend_Db_Table::fetchRow() always return the first row from the result
is correct?

because i want to fetch one row from the result set also by offset,such as
this,

// $table is an object of a class that extends Zend_Db_Table

$select = $table-select()-limit(1, rand(0,100));
$row = $table-fetchRow($select);

but it always return the first row of the result set.

how to solved that?

Best Regards
Jacky


Re: [fw-general] Bug with zend_file addValidator method

2009-08-03 Thread Jacky Chen
 be unlogically and lead to a difference between the elements. I
 see no reason why we should not allow to overwrite messages from a validator
 for the file element, but for all others.

 Greetings
 Thomas Weidner, I18N Team Leader, Zend Framework
 http://www.thomasweidner.com

 - Original Message - From: Jacky Chen jacky...@gmail.com
 To: Thomas Weidner thomas.weid...@gmx.at
 Sent: Tuesday, March 31, 2009 4:24 AM
 Subject: Re: [fw-general] Bug with zend_file addValidator method


 Thomas,
 may be you don't understand me, sorry for my poor english.

 for example,i add the file IsImage validator to the file element as
 following:

 $file = new Zend_Form_Element_File('file');
 $file-addValidator('isImage',true,array('messages'=array(Z
 end_Validate_File_IsImage::NOT_DETECTED='the file is not an image')));

 then,in the addValidator() method of file transfer adapter would pass the
 $options that contains the
 array('messages'=array(Zend_Validate_File_IsImage::NOT_DETECTED='the file
 is not an image')) to the IsImage validator constructor.Actually, the
 'messages' option should not pass to the IsImage validator constructor.

 compare the _loadValidator() method in the Zend_Form_Element and the
 addValidator() method in the Zend_File_Transfer_Adapter_Abstract as
 following highlight code:

 Zend_Form_Element::_loadValidator():
 -
 protected function _loadValidator(array $validator)
   {
   $origName = $validator['validator'];
   $name =
 $this-getPluginLoader(self::VALIDATE)-load($validator['validator']);

   if (array_key_exists($name, $this-_validators)) {
   require_once 'Zend/Form/Exception.php';
   throw new Zend_Form_Exception(sprintf('Validator instance
 already exists for validator %s', $origName));
   }

   if (empty($validator['options'])) {
   $instance = new $name;
   } else {
   $messages = false;
   if (isset($validator['options']['messages'])) {
   $messages = $validator['options']['messages'];
   unset($validator['options']['messages']);
   }

   $r = new ReflectionClass($name);
   if ($r-hasMethod('__construct')) {
   $instance = $r-newInstanceArgs((array)
 $validator['options']);
   } else {
   $instance = $r-newInstance();
   }

   if ($messages) {
   if (is_array($messages)) {
   $instance-setMessages($messages);
   } elseif (is_string($messages)) {
   $instance-setMessage($messages);
   }
   }
   }

   $instance-zfBreakChainOnFailure =
 $validator['breakChainOnFailure'];

   if ($origName != $name) {
   $validatorNames = array_keys($this-_validators);
   $order  = array_flip($validatorNames);
   $order[$name]   = $order[$origName];
   $validatorsExchange = array();
   unset($order[$origName]);
   asort($order);
   foreach ($order as $key = $index) {
   if ($key == $name) {
   $validatorsExchange[$key] = $instance;
   continue;
   }
   $validatorsExchange[$key] = $this-_validators[$key];
   }
   $this-_validators = $validatorsExchange;
   } else {
   $this-_validators[$name] = $instance;
   }

   return $instance;
   }

 Zend_File_Transfer_Adapter_Abstract::addValidator()

 ---
 public function addValidator($validator, $breakChainOnFailure = false,
 $options = null, $files = null)
   {
   if ($validator instanceof Zend_Validate_Interface) {
   $name = get_class($validator);
   } elseif (is_string($validator)) {
   $name  =
 $this-getPluginLoader(self::VALIDATE)-load($validator);
   $validator = new $name($options);
   if (is_array($options)  isset($options['messages'])) {
   if (is_array($options['messages'])) {
   $validator-setMessages($options['messages']);
   } elseif (is_string($options['messages'])) {
   $validator-setMessage($options['messages']);
   }

   unset($options['messages']);
   }
   } else {
   require_once 'Zend/File/Transfer/Exception.php';
   throw new Zend_File_Transfer_Exception('Invalid validator
 provided to addValidator; must be string or Zend_Validate_Interface');
   }

   $this-_validators[$name] = $validator;
   $this-_break[$name]  = $breakChainOnFailure;
   $files= $this-_getFiles($files, true, true);
   foreach ($files as $file) {
   $this-_files[$file]['validators'][] = $name;
   $this-_files[$file]['validated']= false;
   }

   return $this;
   }


 sorry for my poor english again,i can't describe my

[fw-general] problem with form file element

2009-04-24 Thread Jacky Chen
Hi there,
when i update the latest zend framework from svn, then the form with file
element was failed when submit the form with a file to upload. It would get
the error message like The file 'x' was not found  . what's wrong with
it? How should i fixed it?Thanks.

Best Regards
Jacky


Re: [fw-general] problem with form file element

2009-04-24 Thread Jacky Chen
Thank you very much,Thomas.

2009/4/25 Thomas Weidner thomas.weid...@gmx.at

 Is there a reason why you are trying to receive the same file 2 times ?
 Is there a reason why you check for a uploaded file after you received the
 uploaded file ? Quite useless to check if the user uploaded it after working
 with it.

 You should read here for details:

 http://www.thomasweidner.com/flatpress/2009/04/17/recieving-files-with-zend_form_element_file/

 Greetings
 Thomas Weidner, I18N Team Leader, Zend Framework
 http://www.thomasweidner.com


 - Original Message - From: Jacky Chen jacky...@gmail.com
 To: Thomas Weidner thomas.weid...@gmx.at
 Cc: fw-general@lists.zend.com
 Sent: Friday, April 24, 2009 5:55 PM
 Subject: Re: [fw-general] problem with form file element



  sorry,Thomas,here is the code,
 ?php
 class IndexController extends Zend_Controller_Action
 {
   /**
* upload action
*/
 public function uploadAction()
 {
 $form = new Zend_Form();
 $form-setEnctype('multipart/form-data');
 $form-addElement('file','upload',array('label'='choose
 file','destination'=realpath('.')));

 $form-upload-setDecorators(array('Label','File','Description','Errors'));
 $form-addElement('submit','submit');
 if ($this-_request-isPost() 
 $form-isValid($this-_request-getPost()))
 {
 $values = $form-getValues();
 $form-upload-receive();
 if ($form-upload-isUploaded()) {
 echo 'upload succ';
 } else {
 echo 'upload fail';
 }
 }
 $this-view-form = $form;
 }
 }

 upload.phtml:

 ?php echo $this-form; ?

 upload was succ,but get The file 'upload' was not found error message.
 Best Regards
 Jacky

 2009/4/24 Thomas Weidner thomas.weid...@gmx.at

  Hi there,

 when i update the latest zend framework from svn, then the form with
 file
 element was failed when submit the form with a file to upload. It would
 get
 the error message like The file 'x' was not found  . what's wrong
 with
 it? How should i fixed it?


 By providing your code to the list so people can see what you've done.
 ;-)
 Imagination is not always a good way to get proper help.

 Greetings
 Thomas Weidner, I18N Team Leader, Zend Framework
 http://www.thomasweidner.com






Re: [fw-general] about zend_form_element_file error messages

2009-03-31 Thread Jacky Chen
Sorry,Thomas,but it exactly not worked for me.I just copy and run the
example that you provided to me. But it just print the empty array when
uploaded an file that is not gif extension. Maybe the Zend Framework version
you used not the same with i used. But i use the newest ZF that update from
the svn.
just try the example that you provided,upload an file that not gif
extension,and see that if any error messages were displayed?

Forgive me the poor english. Thank you very much.

Best Regards,
Jacky

2009/3/31 Thomas Weidner thomas.weid...@gmx.at

 Jacky,

 2 things before:

 Stop writing me privatly when we have a conversation over the mailing list.
 It's really annoying always to go into the spam filter to get your mail.
 Future mails not coming through the mailing list will be ignored by me.

 Second note... please stop just to say doesn't work without giving the
 example code you've tried.
 This is wether usefull nor shows it that you really want to be helped.

 Now the answer:
 What I've said before is true. It works like I've said. See the code with
 which I've tested it:
 -
 ?php
 error_reporting(E_ALL|E_STRICT);

 ini_set('include_path',ini_get('include_path').PATH_SEPARATOR.'../library');
 require_once('Zend/Loader.php');
 Zend_Loader::registerAutoload();

 $request = new Zend_Controller_Request_Http();

 // setup the form
 $form = new Zend_Form();
 $form-setMethod(Zend_Form::METHOD_POST)
-setAttrib('enctype', Zend_Form::ENCTYPE_MULTIPART);

   $form = new Zend_Form();
 $element  = new Zend_Form_Element_File('file');
 $element-setRequired(true);
 $element-addValidator('upload', false, array('messages' =
 array(Zend_Validate_File_Upload::FILE_NOT_FOUND = 'no file given')));
 $element-addValidator('extension', true, array('gif', 'messages' =
 array(Zend_Validate_File_Extension::FALSE_EXTENSION = 'not a gif image')));

 $form-addElement($element);
 $form-setAttrib('enctype', 'multipart/form-data');
 $form-addElement('submit', 'Submit');


 // check the form
 if($request-isPost()) {
   $formData = $request-getPost();
   if($form-isValid($formData)) {
   $form-file-receive();
   } else {
 print \nVALIDATION FAILURES:;
   print_r($form-file-getMessages());
   }
 }
 print /pre;

 ?

 html
 head
 titleTest/title
 /head
 body
 ?php echo $form-render(new Zend_View());?
 /body
 /html
 -
 and the output I am getting is
 Array ( [fileUploadErrorFileNotFound] = no file given )

 which clearly shows that the set message is really thrown out as expected.
 Once again... when you set the false constants nothing will be outputted as
 the validator accesses a different error message than you gave.

 Greetings
 Thomas Weidner, I18N Team Leader, Zend Framework
 http://www.thomasweidner.com

 - Original Message - From: Jacky Chen jacky...@gmail.com
 To: Thomas Weidner thomas.weid...@gmx.at
 Sent: Tuesday, March 31, 2009 9:10 AM

 Subject: Re: [fw-general] about zend_form_element_file error messages


  No,it not worked as you said, i got an empty array() from
 $form-getMessages() when no file was uploaded. And the Zend Framework is
 the newest from the svn.
 Best Regards,
 Jacky

 2009/3/31 Thomas Weidner thomas.weid...@gmx.at

  Well, when you want to display a own error message, then you have to set
 the correct message constant.

 NOT_FOUND is, as it's text says, for file not found...
 FALSE_EXTENSION is as it's text says for file has the false extension...

 So why should your text be displayed when you set the false constant ?
 Giving NOT_FOUND will not be displayed when the extension is false.

 I would simply set the correct message constant to get the wished output.
 Running your code I get eighter
 [fileUploadErrorNoFile] = The file 'file' was not uploaded  when no
 file
 was uploaded, or
 [fileUploadErrorNoFile] = The file 'file' was not uploaded  when a
 false
 extension was used.

 And when I change your code from NOT_FOUND to FALSE_EXTENSION then I get
 [fileExtensionFalse] = not a gif image  displayed when I do print_r on
 getMessages() from the form.

 Greetings
 Thomas Weidner, I18N Team Leader, Zend Framework
 http://www.thomasweidner.com

 - Original Message - From: Jacky Chen jacky...@gmail.com
 To: Thomas Weidner thomas.weid...@gmx.at
 Sent: Tuesday, March 31, 2009 4:42 AM

 Subject: Re: [fw-general] about zend_form_element_file error messages


  OK,i want to validate a form file element if an image with gif

 extension,but
 no error messages be displayed after the form validate failed.
 just try this:

 ?php
 required_once 'Zend/Controller/Action.php';

 class IndexController extends Zend_Controller_Action
 {
  public function indexAction()
  {
  $form = new Zend_Form();
  $form-setEnctype(Zend_Form::ENCTYPE_MULTIPART);

  $image = new Zend_Form_Element_File('image');
  $image-setLabel('upload a gif image');
  $image-setRequired(true);



 $image-addValidator('extension',true,array

Re: [fw-general] about zend_form_element_file error messages

2009-03-31 Thread Jacky Chen
I use the SVN trunk r14554, too. Can you capture the screen of the output
messages when uploaded a file that not gif extension ? Thanks.
Best Regards,
Jacky

2009/3/31 Thomas Weidner thomas.weid...@gmx.at

 Are you using a release version or the svn trunk or a svn branch ?
 I've tested on SVN trunk r14554 and the related lines of code look similar
 to the actual branch 1.7.

 Greetings
 Thomas Weidner, I18N Team Leader, Zend Framework
 http://www.thomasweidner.com

 - Original Message - From: Jacky Chen jacky...@gmail.com
 To: fw-general@lists.zend.com
 Sent: Tuesday, March 31, 2009 4:44 PM

 Subject: Re: [fw-general] about zend_form_element_file error messages


  Sorry,Thomas,but it exactly not worked for me.I just copy and run the
 example that you provided to me. But it just print the empty array when
 uploaded an file that is not gif extension. Maybe the Zend Framework
 version
 you used not the same with i used. But i use the newest ZF that update
 from
 the svn.
 just try the example that you provided,upload an file that not gif
 extension,and see that if any error messages were displayed?

 Forgive me the poor english. Thank you very much.

 Best Regards,
 Jacky

 2009/3/31 Thomas Weidner thomas.weid...@gmx.at

  Jacky,

 2 things before:

 Stop writing me privatly when we have a conversation over the mailing
 list.
 It's really annoying always to go into the spam filter to get your mail.
 Future mails not coming through the mailing list will be ignored by me.

 Second note... please stop just to say doesn't work without giving the
 example code you've tried.
 This is wether usefull nor shows it that you really want to be helped.

 Now the answer:
 What I've said before is true. It works like I've said. See the code with
 which I've tested it:
 -
 ?php
 error_reporting(E_ALL|E_STRICT);


 ini_set('include_path',ini_get('include_path').PATH_SEPARATOR.'../library');
 require_once('Zend/Loader.php');
 Zend_Loader::registerAutoload();

 $request = new Zend_Controller_Request_Http();

 // setup the form
 $form = new Zend_Form();
 $form-setMethod(Zend_Form::METHOD_POST)
   -setAttrib('enctype', Zend_Form::ENCTYPE_MULTIPART);

  $form = new Zend_Form();
 $element  = new Zend_Form_Element_File('file');
 $element-setRequired(true);
 $element-addValidator('upload', false, array('messages' =
 array(Zend_Validate_File_Upload::FILE_NOT_FOUND = 'no file given')));
 $element-addValidator('extension', true, array('gif', 'messages' =
 array(Zend_Validate_File_Extension::FALSE_EXTENSION = 'not a gif
 image')));

 $form-addElement($element);
 $form-setAttrib('enctype', 'multipart/form-data');
 $form-addElement('submit', 'Submit');


 // check the form
 if($request-isPost()) {
  $formData = $request-getPost();
  if($form-isValid($formData)) {
  $form-file-receive();
  } else {
 print \nVALIDATION FAILURES:;
  print_r($form-file-getMessages());
  }
 }
 print /pre;

 ?

 html
 head
 titleTest/title
 /head
 body
 ?php echo $form-render(new Zend_View());?
 /body
 /html
 -
 and the output I am getting is
 Array ( [fileUploadErrorFileNotFound] = no file given )

 which clearly shows that the set message is really thrown out as
 expected.
 Once again... when you set the false constants nothing will be outputted
 as
 the validator accesses a different error message than you gave.

 Greetings
 Thomas Weidner, I18N Team Leader, Zend Framework
 http://www.thomasweidner.com

 - Original Message - From: Jacky Chen jacky...@gmail.com
 To: Thomas Weidner thomas.weid...@gmx.at
 Sent: Tuesday, March 31, 2009 9:10 AM

 Subject: Re: [fw-general] about zend_form_element_file error messages


  No,it not worked as you said, i got an empty array() from

 $form-getMessages() when no file was uploaded. And the Zend Framework
 is
 the newest from the svn.
 Best Regards,
 Jacky

 2009/3/31 Thomas Weidner thomas.weid...@gmx.at

  Well, when you want to display a own error message, then you have to
 set

 the correct message constant.

 NOT_FOUND is, as it's text says, for file not found...
 FALSE_EXTENSION is as it's text says for file has the false
 extension...

 So why should your text be displayed when you set the false constant ?
 Giving NOT_FOUND will not be displayed when the extension is false.

 I would simply set the correct message constant to get the wished
 output.
 Running your code I get eighter
 [fileUploadErrorNoFile] = The file 'file' was not uploaded  when no
 file
 was uploaded, or
 [fileUploadErrorNoFile] = The file 'file' was not uploaded  when a
 false
 extension was used.

 And when I change your code from NOT_FOUND to FALSE_EXTENSION then I
 get
 [fileExtensionFalse] = not a gif image  displayed when I do print_r
 on
 getMessages() from the form.

 Greetings
 Thomas Weidner, I18N Team Leader, Zend Framework
 http://www.thomasweidner.com

 - Original Message - From: Jacky Chen jacky...@gmail.com
 To: Thomas Weidner

[fw-general] Bug with zend_file addValidator method

2009-03-30 Thread Jacky Chen
Hi there,
there is a bug for the method addValidator in Zend_File Adapter,it should
construct the validator instance after unset the options with messages.

Best Regards,
Jacky


[fw-general] about zend_form_element_file error messages

2009-03-30 Thread Jacky Chen
Hi,
is it not implement the error messages process for the form file element
just now,or missing that? no error messages are assign to the form file
element after the file adapter validated the file element.

Best Regards,
Jacky


[fw-general] headScript helper problem

2009-03-12 Thread Jacky Chen
Hi guys,
i enable zend_layout in my application, there are four template files,
layout.phtml, header.phtml, index.phtml, footer.phtml ,to render.
layout.phtml is the layout template,and header.phtml and footer.phtml
rendered in layout.phtml,the code as following:

layout.phtml
--
html
head
titlelayout template/title
?php echo $this-headScript(); ?
/head
body

?php echo $this-render('header.phtml'); ?

?php echo $this-layout()-content; ?

?php echo $this-render('footer.phtml'); ?

/body
/html

header.phtml
---
html
head
?php $this-headScript()-captureStart(); ?
// script in header
?php $this-headScript()-captureEnd(); ?
/head
body
..
/body
/html

index.phtml
-
html
head
?php $this-headScript()-captureStart(); ?
// script in the index
?php $this-headScript()-captureEnd(); ?
/head
body
.
/body
/html

i capture scripts in both header.phtml and index.phtml templates,but only
scripts that captured in index.phtml be output. why,and how to solve that?

Greetings,
Jacky


[fw-general] how to write such route

2009-03-06 Thread Jacky Chen
hi guys,
i want to add a router that match any characters but not match the word
manage,for example,it would match /home , /news , /blog , but /manage
should not be matched. how to write such a route? thanks.

Greetings,
Jacky


[fw-general] rename filter not work correctly

2009-03-03 Thread Jacky Chen
Hi zfer,
it seem that the file rename filter not work correctly,it not rename the
file when i upload the file first,but it worked when i upload the same file
after the first.
for example,i add a rename filter that set target to c.jpg,and then upload a
file named a.jpg,but the uploaded file would remain the name of a.jpg,then i
upload file a.jpg again,rename worked,in the destination directory,there
would be two files(a.jpg,c.jpg).

sorry for my poor english.

Best Regards
Jacky


[fw-general] about invokeArgs in the front controller and dispatcher

2008-09-24 Thread Jacky Chen
Hi,

i set noViewRenderer to true by default in the bootstrap file before
dispatch start, and check the module name in a controller plugin that hook
the preDispatch event to switch on/off to the viewRenderer,if there is admin
module,following code would be called in the plugin preDispatch() method:

public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$module = $request-getModuleName();

if ('admin' == $module) {
Zend_Controller_Front::getInstance()-setParam('noViewRenderer',
false);
if (!Zend_Controller_Action_HelperBroker::hasHelper('viewRenderer'))
{
Zend_Controller_Action_HelperBroker::getStack()-offsetSet(-80,
new Zend_Controller_Action_Helper_ViewRenderer());
}
}
}

but i found that the value of noViewRenderer passed to the dispacher remains
true. Because call the method setParams() of the Front controller not affect
the params that had been passed to the dispatcher.

So if call $this-getInvokeArg('noViewRenderer') in the controllers of admin
module ,it will return true not false, but call
$this-getFrontController()-getParam('noViewRenderer') will return false as
expected.

I want to know if that is the expected behaviour?Thx.


[fw-general] about params in Front and Dispatcher

2008-09-24 Thread Jacky Chen
Hi,

I want to render views by viewRenderer automatic for a module, and another
one by manual.For example,i want that admin module to render view by
viewRenderer,and default module to render view by explicit.

so i setParam('noViewRenderer', true) in the bootstrap file,and register a
plugin to hook the preDispatch() event,then check if the module is admin or
not,
if yes,then call

Zend_Controller_Front::getInstance()-setParam('noViewRenderer', false);

And i found that,$front-setParam('noViewRenderer',false) not affect the
result,because setParam in Front controller not affect the params in the
dispather.
So i change:
Zend_Controller_Front::getInstance()-setParam('noViewRenderer',
false);
To

Zend_Controller_Front::getInstance()-getDispatcher()-setParam('noViewRenderer',
false);
And it is OK.

But another problem is arise.


[fw-general] about the code in the Zend_Controller_Action::__call()

2008-09-24 Thread Jacky Chen
Hi,

let's look at the code of the method __call() of the Zend_Controller_Action:

public function __call($methodName, $args)
{
if ('Action' == substr($methodName, -6)) {
require_once 'Zend/Controller/Action/Exception.php';
$action = substr($methodName, 0, strlen($methodName) - 6);
require_once 'Zend/Controller/Action/Exception.php';
throw new Zend_Controller_Action_Exception(sprintf('Action %s
does not exist and was not trapped in __call()', $action), 404);
}

require_once 'Zend/Controller/Action/Exception.php';
throw new Zend_Controller_Action_Exception(sprintf('Method %s does
not exist and was not trapped in __call()', $methodName), 500);
}

the require_once 'Zend/Controller/Action/Exception.php' statement appear
here three times,it is better like following:

public function __call($methodName, $args)
{
require_once 'Zend/Controller/Action/Exception.php';

if ('Action' == substr($methodName, -6)) {
$action = substr($methodName, 0, strlen($methodName) - 6);
throw new Zend_Controller_Action_Exception(sprintf('Action %s
does not exist and was not trapped in __call()', $action), 404);
}

throw new Zend_Controller_Action_Exception(sprintf('Method %s does
not exist and was not trapped in __call()', $methodName), 500);
}


[fw-general] Bug with Zend_File_Transfer

2008-09-19 Thread Jacky Chen
it seem that each validation for the file elements in the zend_form would
validate all of the file elements in the form.it means that if there have
two file elements in the form,says A and B. So isValid() for the element A
is called,it would validate A and B,not just A.

So if i want to upload two files, one is option, and another is
required,then would result in error if i left the option one empty.

do you understand me? if you don't , try the following:

?php

$form = new Zend_Form();
$form-setEnctype(Zend_Form::ENCTYPE_MULTIPART);

// file a,optional
$a = new Zend_Form_Element_File('A');
$a-setLabel('file a');
$form-addElement($a);

// file b,required
$b = new Zend_Form_Element_File('B');
$b-setLabel('file b');
$b-setRequired(true);
$form-addElement($b);

if ($this-_request-isPost()) {
if ($form-isValid($_POST)) {
echo 'valid';
} else {
echo 'invalid';
}
}
echo $form;


Re: [fw-general] Bug with Zend_File_Transfer

2008-09-19 Thread Jacky Chen
thanks your rapid reply.

2008/9/19 Thomas Weidner [EMAIL PROTECTED]

 Jacky,

 this is not supported for now and has been reported several times in the
 last few days.
 A issue is already filled and in work.

 Greetings
 Thomas Weidner, I18N Team Leader, Zend Framework
 http://www.thomasweidner.com

 - Original Message - From: Jacky Chen [EMAIL PROTECTED]
 To: fw-general@lists.zend.com
 Sent: Friday, September 19, 2008 8:47 AM
 Subject: [fw-general] Bug with Zend_File_Transfer



  it seem that each validation for the file elements in the zend_form would
 validate all of the file elements in the form.it means that if there have
 two file elements in the form,says A and B. So isValid() for the element A
 is called,it would validate A and B,not just A.

 So if i want to upload two files, one is option, and another is
 required,then would result in error if i left the option one empty.

 do you understand me? if you don't , try the following:

 ?php

 $form = new Zend_Form();
 $form-setEnctype(Zend_Form::ENCTYPE_MULTIPART);

 // file a,optional
 $a = new Zend_Form_Element_File('A');
 $a-setLabel('file a');
 $form-addElement($a);

 // file b,required
 $b = new Zend_Form_Element_File('B');
 $b-setLabel('file b');
 $b-setRequired(true);
 $form-addElement($b);

 if ($this-_request-isPost()) {
   if ($form-isValid($_POST)) {
   echo 'valid';
   } else {
   echo 'invalid';
   }
 }
 echo $form;





[fw-general] Bug with Zend_File_Transfer

2008-09-11 Thread Jacky Chen
Hi there,

there is a bug in the Zend_File_Transfer_Abstract::setOptions() , the code
in the setOptions() as bellow:

if (is_array($options)) {
 $this-_options += $options;
}


Maybe the following code should it be:

if (is_array($options)) {
$this-_options = $options + $this-_options;
}


[fw-general] about file rename filter

2008-09-10 Thread Jacky Chen
Hi guy,

Let's say that i want to rename the upload file abc.jpg to cba.jpg just
after the file is complete upload in the form,how can i add the rename
filter to the form?
of course,i can add the filter like this $upload-addFilter('cba.jpg', true)
if i know that the file that would be upload is a jpg file,but problem is,i
don't know what type file would be upload,may be jpg,gif,pdf,or zip,etc.
And i found that the file rename filter doesn't deal with the file
extension.

Sorry for my poor english.Thanks.

Best Regards.


[fw-general] Re: about file rename filter

2008-09-10 Thread Jacky Chen
Sorry,

the code $upload-addFilter('cba.js',true) incorrect.
it should be $upload-addFilter('rename',array('cba.jpg', true));

2008/9/11 Jacky Chen [EMAIL PROTECTED]

 Hi guy,

 Let's say that i want to rename the upload file abc.jpg to cba.jpg just
 after the file is complete upload in the form,how can i add the rename
 filter to the form?
 of course,i can add the filter like this $upload-addFilter('cba.jpg',
 true) if i know that the file that would be upload is a jpg file,but problem
 is,i don't know what type file would be upload,may be jpg,gif,pdf,or
 zip,etc.
 And i found that the file rename filter doesn't deal with the file
 extension.

 Sorry for my poor english.Thanks.

 Best Regards.



[fw-general] custom error message doesn't display with Zend_Form_Element_File

2008-09-07 Thread Jacky Chen
Hi,

I add a NotExists validator to a file element with custom error message,but
the validator just display the default DOES_EXISTS error message.


[fw-general] is there a proposal about jquery?

2008-07-10 Thread Jacky Chen
Hi all,

is there a proposal about jquery? have some one plan to integrate it into
zend framework? jquery is a wonderful javascript library, in my opinion,
powerful and easy use, i look forward some one to integrate it into zend
framework.


[fw-general] how to get format action name without Action suffix?

2008-07-09 Thread Jacky Chen
Hi,

I want to get the format action name,but there just a method in
Zend_Controller_Dispatcher_Abstract::formatActionName($unformatted), but it
return the action name with the Action suffix.

because action name or controller name can be, get.data,or get-data, for
example.If i call the method getActionName() with Request,it just return the
unformatted action name,and i want to test that if there is a getData
action.

I think it is convenient if there have a method return the format module(or
controller,or action)name. There have one,but is protected.


[fw-general] about filters and validators order in Zend_Form

2008-07-09 Thread Jacky Chen
Hi,

in the Zend_Form of current implement,filters is apply before validators,but
i want to filter data after form is validate.
For example,in the regiser form,i have to validate the field password not
empty,and than filter it with the MD5 filter.
I think it is best  that developer can set the filters order,filtering
before or after validators.


Re: [fw-general] about filters and validators order in Zend_Form

2008-07-09 Thread Jacky Chen
thanks.


 We plan on having both the current prefilter, as well as a postfilter;
 I'm not sure that this will make 1.6, however.

that sounds great! Thanks your great job!


2008/7/10 Matthew Weier O'Phinney [EMAIL PROTECTED]:

 -- Jacky Chen [EMAIL PROTECTED] wrote
 (on Thursday, 10 July 2008, 12:30 AM +0800):
   in the Zend_Form of current implement,filters is apply before
 validators,but i
  want to filter data after form is validate.
  For example,in the regiser form,i have to validate the field password not
  empty,and than filter it with the MD5 filter.
  I think it is best  that developer can set the filters order,filtering
 before
  or after validators.

 We plan on having both the current prefilter, as well as a postfilter;
 I'm not sure that this will make 1.6, however.

 For now, if you wish to filter after validation, simply run the values
 through a Zend_Filter filter chain or concrete filter.

 --
 Matthew Weier O'Phinney
 Software Architect   | [EMAIL PROTECTED]
 Zend Framework   | http://framework.zend.com/



[fw-general] about setLayout() method in layout view helper

2008-07-05 Thread Jacky Chen
Hi,

there is a method of *setLayout(Zend_Layout $layout)* in the view helper of
*Zend_View_Helper_Layout*, how to call this method? the code, *
$this-layout(),* in the view just return the instance of the *Zend_Layout*,
not the *Zend_View_Helper_Layout* instance.

in the view file:
?php
// call Zend_Layout::setLayout($name), not
Zend_View_Helper_Layout::setLayout(Zend_Layout $layout)
$this-layout()-setLayout('layout');
?

maybe it is a bug?

Best Regards,
Jacky


[fw-general] is it a bug or not?

2008-05-03 Thread Jacky Chen
Hi,
I add an select element to the Zend_Form,like this,

$course = new Zend_Form_Element_Select('course[]');
$form-addElement($course);

And,the name of the course element would be course,not
course[],except that i set the multiple attribute of the element to true.
But i won't this style of multiple select, i would like to multiple select
elements.

Example:
 i want the style of multiple select like this:
select name=course[]
  option value=valuecourse option/option
  ..
/select
select name=course[]
  option value=valuecourse option/option
  ..
/select

 not the style of this:
select name=course[] multiple=multiple
  option value=valuecourse option/option
  ..
/select

Then i look for the code,and i found that in the setName() method of
Zend_Form_Element class, it call the filterName() method with default value
of false to $allowBrackets parameter,then it always filter out the brackets.

Best Regards.
Jacky


Re: [fw-general] is it a bug or not?

2008-05-03 Thread Jacky Chen
thanks your reply,Matthew.

2008/5/3 Matthew Weier O'Phinney [EMAIL PROTECTED]:

 -- Jacky Chen [EMAIL PROTECTED] wrote
 (on Saturday, 03 May 2008, 03:54 PM +0800):
   I add an select element to the Zend_Form,like this,
 
  $course = new Zend_Form_Element_Select('course[]');
  $form-addElement($course);
 
  And,the name of the course element would be course,not course[],except
 that i
  set the multiple attribute of the element to true. But i won't this
 style of
  multiple select, i would like to multiple select elements.
 
  Example:
   i want the style of multiple select like this:
  select name=course[]
option value=valuecourse option/option
..
  /select
  select name=course[]
option value=valuecourse option/option
..
  /select
 
   not the style of this:
  select name=course[] multiple=multiple
option value=valuecourse option/option
..
  /select
 
  Then i look for the code,and i found that in the setName() method of
  Zend_Form_Element class, it call the filterName() method with default
 value of
  false to $allowBrackets parameter,then it always filter out the
 brackets.

 This functionality is setup so that iteration and overloading work.

 For what you want, you should use a sub form, and attach your various
 select elements to that subform; that way they will be namespaced and
 you can fetch all values as an array.

 Another option is to create a custom element that creates all of the
 selects; in the subclass set the '_isArray' property true, which will
 ensure that the name has the '[]' appended when you pass the values to
 the form helpers.

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



[fw-general] bug with Zend_Form_Decorator_ViewHelper

2008-04-16 Thread Jacky Chen
Hi there,
In the render method of Zend_Form_Decorator_ViewHelper,there is missing
the fifth argument that Zend_View_Helper_FormMultiCheckbox and other helpers
that need the listsep argument.

Best Regards.


[fw-general] how to add file field to zend_form

2008-04-11 Thread Jacky Chen
Hi All,
How can i add file field to Zend_Form?

Best Regards.


[fw-general] how to set dependent element in Zend_Form

2008-04-09 Thread Jacky Chen
Hi All,
I want to validate an element that it depend on another element is
set.Can i do that in Zend_Form, if yes, and how?

Best Regards


[fw-general] is it a bug with Zend_View_Helper_FormCheckbox?

2008-03-24 Thread Jacky Chen
Hi there,
i found that view helper of formCheckbox not display options elements,is it
a bug or not?


Re: [fw-general] is it a bug with Zend_View_Helper_FormCheckbox?

2008-03-24 Thread Jacky Chen
and how can i use checkbox in the Zend_Form?

2008/3/24, Matthew Weier O'Phinney [EMAIL PROTECTED]:

 -- Jacky Chen [EMAIL PROTECTED] wrote
 (on Monday, 24 March 2008, 05:06 PM +0800):

  i found that view helper of formCheckbox not display options
  elements,is it a bug or not?


 I need to update the documentation for that helper. Basically, the
 fourth $options parameter is no longer used. If you want to mark
 the element as checked, you need to pass a 'checked' option in the
 $attribs array.

 The reason the $options array was removed is because the prior
 implementation was extremely buggy and did not follow w3c
 specifications.


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



[fw-general] bug with Zend_Controller_Request_Http::setParam

2008-01-02 Thread Jacky Chen
Hi,

in the method setParam of Zend_Controller_Request_Http,the code like this:


public function setParam($key, $value)
{
$keyName = (null !== ($alias = $this-getAlias($key))) ? $alias :
$key;

parent::setParam($key, $value);
return $this;
}

is it sould parent::setParam($keyName, $value) rather than
parent::setParam($key, $value) ?


Re: [fw-general] Zend_Mail Bug?

2007-12-28 Thread Jacky Chen
Hi Simone,

the code for sending emails are following:


$tr = new Zend_Mail_Transport_Smtp($mailConfig-host,
$mailConfig-options-toArray());
Zend_Mail::setDefaultTransport($tr);
$mail = new Zend_Mail('utf8');

$mail-setBodyHtml($body);
$mail-setBodyText($body);
$mail-setFrom($mailConfig-from, $mailConfig-sender);
$mail-addTo($email);
$mail-setSubject($subject);
try {
$mail-send();
return true;
} catch (Exception $e) {
return false;
}
and the subject and body contains Chinese characters.


2007/12/29, Simone Carletti [EMAIL PROTECTED]:


 It would be helpful if you post here a sample code you use for sending
 emails.
 A real example would be wonderful. :)

 -- Simone


 Jacky Chen-2 wrote:
 
  Hi all,
 
  I send mail with Zend_Mail,and i received the mail body as
 following.What
  is
  the problem?
 
  =E5=96=84=E8=B5=84=E6=96=99?=
  Content-Type: multipart/alternative; charset=utf8;
   boundary==_a63f032d182e04daf6311fe5329bef65
  MIME-Version: 1.0
 
  --=_a63f032d182e04daf6311fe5329bef65
  Content-Type: text/plain; charset=utf8
  Content-Transfer-Encoding: quoted-printable
 
 
 =E4=BA=B2=E7=88=B1=E7=9A=84=E7=94=A8=E6=88=B7=E6=82=A8=E5=A5=BD=EF=BC=81p=
 =E6=AC=A2=E8=BF=8E=E5=8A=A0=E5=85=A5HeySpace=E5=A4=A7=E5=AE=B6=E5=BA=AD=
 
 =EF=BC=8C=E8=AF=B7=E7=82=B9=E5=87=BB=E4=BB=A5=E4=B8=8B=E9=93=BE=E6=8E=A5=
  =E5=AE=8C=E5=96=84=E6=82=A8=E7=9A=84=E8=B5=84=E6=96=99=EF=BC=9Abr /
  /passport/register/email/jacky.hf%40gmail.com/active/ec=
  61998014a83f48a84e0b3dbafeb01f /p
 
  --=_a63f032d182e04daf6311fe5329bef65
  Content-Type: text/html; charset=utf8
  Content-Transfer-Encoding: quoted-printable
 
 
 =E4=BA=B2=E7=88=B1=E7=9A=84=E7=94=A8=E6=88=B7=E6=82=A8=E5=A5=BD=EF=BC=81p=
 =E6=AC=A2=E8=BF=8E=E5=8A=A0=E5=85=A5HeySpace=E5=A4=A7=E5=AE=B6=E5=BA=AD=
 
 =EF=BC=8C=E8=AF=B7=E7=82=B9=E5=87=BB=E4=BB=A5=E4=B8=8B=E9=93=BE=E6=8E=A5=
  =E5=AE=8C=E5=96=84=E6=82=A8=E7=9A=84=E8=B5=84=E6=96=99=EF=BC=9Abr /
  /passport/register/email/jacky.hf%40gmail.com/active/ec=
  61998014a83f48a84e0b3dbafeb01f /p
 
  --=_a63f032d182e04daf6311fe5329bef65--
 
 

 --
 View this message in context:
 http://www.nabble.com/Zend_Mail-Bug--tp14521843s16154p14532427.html
 Sent from the Zend Framework mailing list archive at Nabble.com.




Re: [fw-general] Zend_Mail Bug?

2007-12-28 Thread Jacky Chen
Hi Simone,

the code for sending emails are following:


$tr = new Zend_Mail_Transport_Smtp($mailConfig-host,
$mailConfig-options-toArray());
Zend_Mail::setDefaultTransport($tr);
$mail = new Zend_Mail('utf8');

$mail-setBodyHtml($body);
$mail-setBodyText($body);
$mail-setFrom($mailConfig-from, $mailConfig-sender);
$mail-addTo($email);
$mail-setSubject($subject);
try {
$mail-send();
return true;
} catch (Exception $e) {
return false;
}
and the subject and body contains Chinese characters.

I search the solution for solve this problem,and i found that the problem
would be in the Zend_Mail::_encodeHeader() methods.

the code of the _encodeHeader() methods are following:

protected function _encodeHeader($value)
{
  if (Zend_Mime::isPrintable($value)) {
  return $value;
  } else {
  $quotedValue = Zend_Mime::encodeQuotedPrintable($value);
  $quotedValue = str_replace(array('?', ' '), array('=3F', '=20'),
$quotedValue);
  return '=?' . $this-_charset . '?Q?' . $quotedValue . '?=';
  }
}

if change it like this:

protected function _encodeHeader($value)
{
  if (Zend_Mime::isPrintable($value)) {
  return $value;
  } else {
  return '=?'.$this-_charset.'?B?'.base64_encode($value).'?=';
  }
}

the problem is soloved.

2007/12/29, Jacky Chen [EMAIL PROTECTED]:

 Hi Simone,

 the code for sending emails are following:


 $tr = new Zend_Mail_Transport_Smtp($mailConfig-host,
 $mailConfig-options-toArray());
 Zend_Mail::setDefaultTransport($tr);
 $mail = new Zend_Mail('utf8');

 $mail-setBodyHtml($body);
 $mail-setBodyText($body);
 $mail-setFrom($mailConfig-from, $mailConfig-sender);
 $mail-addTo($email);
 $mail-setSubject($subject);
 try {
 $mail-send();
 return true;
 } catch (Exception $e) {
 return false;
 }
 and the subject and body contains Chinese characters.


 2007/12/29, Simone Carletti [EMAIL PROTECTED]:
 
 
  It would be helpful if you post here a sample code you use for sending
  emails.
  A real example would be wonderful. :)
 
  -- Simone
 
 
  Jacky Chen-2 wrote:
  
   Hi all,
  
   I send mail with Zend_Mail,and i received the mail body as
  following.What
   is
   the problem?
  
   =E5=96=84=E8=B5=84=E6=96=99?=
   Content-Type: multipart/alternative; charset=utf8;
boundary==_a63f032d182e04daf6311fe5329bef65
   MIME-Version: 1.0
  
   --=_a63f032d182e04daf6311fe5329bef65
   Content-Type: text/plain; charset=utf8
   Content-Transfer-Encoding: quoted-printable
  
  
  =E4=BA=B2=E7=88=B1=E7=9A=84=E7=94=A8=E6=88=B7=E6=82=A8=E5=A5=BD=EF=BC=81p=
  =E6=AC=A2=E8=BF=8E=E5=8A=A0=E5=85=A5HeySpace=E5=A4=A7=E5=AE=B6=E5=BA=AD=
 
  
  =EF=BC=8C=E8=AF=B7=E7=82=B9=E5=87=BB=E4=BB=A5=E4=B8=8B=E9=93=BE=E6=8E=A5=
   =E5=AE=8C=E5=96=84=E6=82=A8=E7=9A=84=E8=B5=84=E6=96=99=EF=BC=9Abr /
   /passport/register/email/jacky.hf%40gmail.com/active/ec=
   61998014a83f48a84e0b3dbafeb01f /p
  
   --=_a63f032d182e04daf6311fe5329bef65
   Content-Type: text/html; charset=utf8
   Content-Transfer-Encoding: quoted-printable
  
  
  =E4=BA=B2=E7=88=B1=E7=9A=84=E7=94=A8=E6=88=B7=E6=82=A8=E5=A5=BD=EF=BC=81p=
 
  =E6=AC=A2=E8=BF=8E=E5=8A=A0=E5=85=A5HeySpace=E5=A4=A7=E5=AE=B6=E5=BA=AD=
  
  =EF=BC=8C=E8=AF=B7=E7=82=B9=E5=87=BB=E4=BB=A5=E4=B8=8B=E9=93=BE=E6=8E=A5=
   =E5=AE=8C=E5=96=84=E6=82=A8=E7=9A=84=E8=B5=84=E6=96=99=EF=BC=9Abr /
   /passport/register/email/jacky.hf%40gmail.com/active/ec=
   61998014a83f48a84e0b3dbafeb01f /p
  
   --=_a63f032d182e04daf6311fe5329bef65--
  
  
 
  --
  View this message in context:
  http://www.nabble.com/Zend_Mail-Bug--tp14521843s16154p14532427.html
  Sent from the Zend Framework mailing list archive at 
  Nabble.comhttp://nabble.com/
  .
 
 



[fw-general] Zend_Mail Bug?

2007-12-27 Thread Jacky Chen
Hi all,

I send mail with Zend_Mail,and i received the mail body as following.What is
the problem?

=E5=96=84=E8=B5=84=E6=96=99?=
Content-Type: multipart/alternative; charset=utf8;
 boundary==_a63f032d182e04daf6311fe5329bef65
MIME-Version: 1.0

--=_a63f032d182e04daf6311fe5329bef65
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: quoted-printable

=E4=BA=B2=E7=88=B1=E7=9A=84=E7=94=A8=E6=88=B7=E6=82=A8=E5=A5=BD=EF=BC=81p=
=E6=AC=A2=E8=BF=8E=E5=8A=A0=E5=85=A5HeySpace=E5=A4=A7=E5=AE=B6=E5=BA=AD=
=EF=BC=8C=E8=AF=B7=E7=82=B9=E5=87=BB=E4=BB=A5=E4=B8=8B=E9=93=BE=E6=8E=A5=
=E5=AE=8C=E5=96=84=E6=82=A8=E7=9A=84=E8=B5=84=E6=96=99=EF=BC=9Abr /a hr=
ef=3D/passport/register/email/jacky.hf%40gmail.com/active/ec61998014a83f4=
8a84e0b3dbafeb01f/passport/register/email/jacky.hf%40gmail.com/active/ec=
61998014a83f48a84e0b3dbafeb01f/a/p

--=_a63f032d182e04daf6311fe5329bef65
Content-Type: text/html; charset=utf8
Content-Transfer-Encoding: quoted-printable

=E4=BA=B2=E7=88=B1=E7=9A=84=E7=94=A8=E6=88=B7=E6=82=A8=E5=A5=BD=EF=BC=81p=
=E6=AC=A2=E8=BF=8E=E5=8A=A0=E5=85=A5HeySpace=E5=A4=A7=E5=AE=B6=E5=BA=AD=
=EF=BC=8C=E8=AF=B7=E7=82=B9=E5=87=BB=E4=BB=A5=E4=B8=8B=E9=93=BE=E6=8E=A5=
=E5=AE=8C=E5=96=84=E6=82=A8=E7=9A=84=E8=B5=84=E6=96=99=EF=BC=9Abr /a hr=
ef=3D/passport/register/email/jacky.hf%40gmail.com/active/ec61998014a83f4=
8a84e0b3dbafeb01f/passport/register/email/jacky.hf%40gmail.com/active/ec=
61998014a83f48a84e0b3dbafeb01f/a/p

--=_a63f032d182e04daf6311fe5329bef65--


[fw-general] how to set timezone depend on locale

2007-09-04 Thread Jacky Chen
Hi there,
I want to set timezone depend on the user locale,how to do it?


Best Regards,
Jacky


Re: [fw-general] how to set timezone depend on locale

2007-09-04 Thread Jacky Chen
Thanks.

2007/9/4, Yann Nave [EMAIL PROTECTED]:

 And Timezone depends more on Country / Region  than on locales

 On 9/4/07, Thomas Weidner [EMAIL PROTECTED] wrote:
  This is not possible, because timezones are not related to locales.
 
  Expect you have the locale 'en_US'...
  so which of the 5 possible timezones will you use ???
 
  or when you use the locale 'en'...
  which of the 15 possible timezones then to use ???
 
  The only possibility for you is that you create a relation (array,
 db,...)
  between timezone and locale yourself.
  I dont know any project in the wild wild world which adds this natively.
 
  Greetings
  Thomas
  I18N Team Leader
 
 
  - Original Message -
  From: Jacky Chen [EMAIL PROTECTED]
  To: fw-general@lists.zend.com
  Sent: Tuesday, September 04, 2007 10:40 AM
  Subject: [fw-general] how to set timezone depend on locale
 
 
   Hi there,
  I want to set timezone depend on the user locale,how to do it?
  
  
   Best Regards,
   Jacky
  
 
 


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



[fw-general] about the url view helper

2007-08-01 Thread Jacky Chen
Hi list,
when i use the view helper of Url,i met a problem.what i want is to use
the url helper to construct the right url for the right router.
for example,when i use the default router,it construct the url as *
/news/read/id/1* for me as i call *
$this-url(array('controller'='news','action'='read','id'=1)).*
but now,i want to use the url like *?controller=newsaction=readid=1*,so
i remove the default routes.and error occurs when i call *$this-url(array
('controller'='news','action'='read','id'=1)).*

sorry for my english.

/**
 * case one,use default route
 */
$router = new Zend_Controller_Router_Rewrite();
//$router-removeDefaultRoutes();
$front = Zend_Controller_Front::getInstance();
$front-setRouter($router);
$front-setControllerDirectory('./application/default/controllers');
$front-dispatch();

at this case,i use
$this-url(array('controller'='news','action'='read','id'=1)) would
return  */news/read/id/1*

/**
 * case two,remove default routes
 */
$router = new Zend_Controller_Router_Rewrite();
$router-removeDefaultRoutes();
$front = Zend_Controller_Front::getInstance();
$front-setRouter($router);
$front-setControllerDirectory('./application/default/controllers');
$front-dispatch();

at this case,call $this-url() would produce error.and what i want is it to
return *index.php?controller=newsaction=readid=1*


Re: [fw-general] is it a bug?

2007-05-16 Thread Jacky Chen

sorry,i make a mistake,it isn't any errors on the table relationships.i am
so sorry.

Regards,
Jacky

2007/5/16, Jacky Chen [EMAIL PROTECTED]:


As the example in the manual of Zend_DB_Table_Relationships

?php

class Accounts extends Zend_Db_Table_Abstract
{
protected $_name= 'accounts' ;
protected $_primary = array('account_id');
protected  $_dependentTables = array('Bugs');
}

class  Products extends Zend_Db_Table_Abstract
{
protected $_name = 'products';
protected $_primary  = array('product_id');
protected $_dependentTables = array( 'Bugs');
}

class Bugs extends  Zend_Db_Table_Abstract
{
protected $_name= 'bugs' ;
protected $_referenceMap= array(
'Reporter'  = array(
'columns'   = 'reported_by' ,
'refTableClass' = 'Accounts' ,
'refColumns'= 'account_id'
 ),
'Engineer' = array(
'columns'= 'assigned_to',
'refTableClass' =  'Accounts',
'refColumns'=  'account_id'
),
'Verifier' = array(
 'columns'   = array('verified_by'),
 'refTableClass' = 'Accounts',
'refColumns' = array('account_id')
),
'Product'  = array(
'columns'   = array('product_id' ),
'refTableClass' = 'Products' ,
'refColumns'= array('product_id' )
)
);
}

?

If the primary key of accounts table is id,and the table products or/and
bugs have the same primary key as the table accounts,id.

Now,the code above should change as following

?php

class Accounts extends Zend_Db_Table_Abstract
{
protected $_name= 'accounts' ;
protected $_primary = array('id');
protected  $_dependentTables = array('Bugs');
}

class  Products extends Zend_Db_Table_Abstract
{
protected $_name = 'products';
protected $_primary  = array('id');
protected $_dependentTables = array( 'Bugs');
}

class Bugs extends Zend_Db_Table_Abstract
{
protected $_name= 'bugs' ;
protected $_referenceMap= array(
'Reporter' = array(
'columns'   = 'reported_by',
 'refTableClass' = 'Accounts',
 'refColumns'= 'id'
),
'Engineer'  = array(
'columns'   = 'assigned_to' ,
'refTableClass' = 'Accounts' ,
'refColumns'= 'id'
),
'Verifier' = array(
'columns'= array('verified_by'),
'refTableClass'  = 'Accounts',
'refColumns'= array( 'id')
),
'Product' = array(
 'columns'   = array('product_id'),
 'refTableClass' = 'Products',
 'refColumns'= array('id')
)
);
}

?

And then invoke the findManyToManyRowset method introduce errors.
sorry for my bad english.

Regards,
Jacky


2007/5/16, Bill Karwin [EMAIL PROTECTED]:

  Can you show the complete declaration of your $_referenceMap array?
 I'm having difficulty following your description.

 Regards,
 Bill Karwin

  --
 *From:* Jacky Chen [mailto:[EMAIL PROTECTED]
 *Sent:* Tuesday, May 15, 2007 1:22 AM
 *To:* fw-general@lists.zend.com
 *Subject:* [fw-general] is it a bug?


  Hi list,
 In Zend_Db_Table Relationships,if there are two or more tables with the
 same primary key in the table _referenceMap,exception would be throw.Idon't 
know if it is a bug.

 Regards
 Jacky





Re: [fw-general] is it a bug?

2007-05-15 Thread Jacky Chen

As the example in the manual of Zend_DB_Table_Relationships

?php

class Accounts extends Zend_Db_Table_Abstract
{
   protected $_name= 'accounts';
   protected $_primary = array('account_id');
   protected $_dependentTables = array('Bugs');
}

class Products extends Zend_Db_Table_Abstract
{
   protected $_name= 'products';
   protected $_primary = array('product_id');
   protected $_dependentTables = array('Bugs');
}

class Bugs extends Zend_Db_Table_Abstract
{
   protected $_name= 'bugs';
   protected $_referenceMap= array(
   'Reporter' = array(
   'columns'   = 'reported_by',
   'refTableClass' = 'Accounts',
   'refColumns'= 'account_id'
   ),
   'Engineer' = array(
   'columns'   = 'assigned_to',
   'refTableClass' = 'Accounts',
   'refColumns'= 'account_id'
   ),
   'Verifier' = array(
   'columns'   = array('verified_by'),
   'refTableClass' = 'Accounts',
   'refColumns'= array('account_id')
   ),
   'Product' = array(
   'columns'   = array('product_id'),
   'refTableClass' = 'Products',
   'refColumns'= array('product_id')
   )
   );
}

?

If the primary key of accounts table is id,and the table products or/and
bugs have the same primary key as the table accounts,id.

Now,the code above should change as following

?php

class Accounts extends Zend_Db_Table_Abstract
{
   protected $_name= 'accounts';
   protected $_primary = array('id');
   protected $_dependentTables = array('Bugs');
}

class Products extends Zend_Db_Table_Abstract
{
   protected $_name= 'products';
   protected $_primary = array('id');
   protected $_dependentTables = array('Bugs');
}

class Bugs extends Zend_Db_Table_Abstract
{
   protected $_name= 'bugs';
   protected $_referenceMap= array(
   'Reporter' = array(
   'columns'   = 'reported_by',
   'refTableClass' = 'Accounts',
   'refColumns'= 'id'
   ),
   'Engineer' = array(
   'columns'   = 'assigned_to',
   'refTableClass' = 'Accounts',
   'refColumns'= 'id'
   ),
   'Verifier' = array(
   'columns'   = array('verified_by'),
   'refTableClass' = 'Accounts',
   'refColumns'= array('id')
   ),
   'Product' = array(
   'columns'   = array('product_id'),
   'refTableClass' = 'Products',
   'refColumns'= array('id')
   )
   );
}

?

And then invoke the findManyToManyRowset method introduce errors.
sorry for my bad english.

Regards,
Jacky


2007/5/16, Bill Karwin [EMAIL PROTECTED]:


 Can you show the complete declaration of your $_referenceMap array?  I'm
having difficulty following your description.

Regards,
Bill Karwin

 --
*From:* Jacky Chen [mailto:[EMAIL PROTECTED]
*Sent:* Tuesday, May 15, 2007 1:22 AM
*To:* fw-general@lists.zend.com
*Subject:* [fw-general] is it a bug?


 Hi list,
In Zend_Db_Table Relationships,if there are two or more tables with the
same primary key in the table _referenceMap,exception would be throw.Idon't 
know if it is a bug.

Regards
Jacky




Re: [fw-general] route problem

2007-04-18 Thread Jacky Chen

Thank you,Martel.

2007/4/19, Martel Valgoerad [EMAIL PROTECTED]:


Jacky Chen wrote:

 Hi all,
 I want to specify a url such as
 http://localhost/index.php?controller=indexaction=view
 http://localhost/index.php?controller=indexaction=view and have it
 dispatch properly,how?

It should work out of the box. You just have to tell the request of your
request base url if you use any routes:

require_once 'Zend/Controller/Request/Http.php';
$request = new Zend_Controller_Request_Http();
$request-setBaseUrl('index.php');
$controller-setRequest($request);

AND/OR make sure you don't have any routes (in order not to waste
resources):

require_once 'Zend/Controller/Router/Rewrite.php';
$router = new Zend_Controller_Router_Rewrite();
$router-removeDefaultRoutes();
$controller-setRouter($router);

I suppose there should be some method for disabling the router altogether,
like:

$controller-disableRouter();

For now disabling the router is very hard. Even if you are determined
enough to
extend the dispatcher. And the router is designed as a filter to request
so it
is optional.

--
Michael Minicki aka Martel Valgoerad | [EMAIL PROTECTED] |
http://aie.pl/martel.asc

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Make sure you have finished speaking before your audience has finished
listening. -- Dorothy Sarnoff



[fw-general] question about zend_db_table

2007-04-09 Thread Jacky Chen

Hi there,
how can i query limit rows from zend_db_table,if the query result is
large.And also the Zend_Db_Table Relationships.

Best Regards,
Jacky


[fw-general] problem for zend_feed

2007-03-22 Thread Jacky Chen

Hi,there
i met a problem when i produce a rss feed.How can i encode the entry
title?If the entry title contain the  char,a warning would occure.
*Warning*: DOMDocument::createElement()
[function.DOMDocument-createElementhttp://www.fzfz.com/rss/function.DOMDocument-createElement]:
unterminated entity reference

Regards,
Jacky


[fw-general] can one module adds more than one controller directory?

2007-03-08 Thread Jacky Chen

i just want to add more than one controller directory to one module.
for example:
...
$front-addControllerDirectory(./controllers/n1,news);
$front-addControllerDirectory(./controllers/n2,news);

As that the controller directory would be ./controllers/n2,not the two.


[fw-general] bug in route

2007-01-18 Thread Jacky Chen

Hi there,
Sorry for my english,i just point out the bug with codes.

bootstrap file code:
// index.php
$router = new Zend_Controller_RewriteRouter();
$router-addRoute('passport',new
Zend_Controller_Router_Route(':action',array('controller'='passport','action'='login')));
$front = Zend_Controller_Front::getInstance();
$front-setRouter($router);
$front-setControllerDirectory(CONTROLLER_DIR);
$front-throwException(true);
try {
   $front-dispatch();
} catch(Zend_Exception $e) {
   Zend::dump($e);
}

passport controller code:
// PassportController.php
class PassportController extends Zend_Controller_Action
{
   public function loginAction()
   {
   echo 'login actionbr/';
   echo $this-getRequest()-getParam('forward');
   }

   public function registerAction()
   {
   echo 'register actionbr/';
   echo $this-getRequest()-getParam('forward');
   }

   public function logoutAction()
   {
   echo 'logout actionbr/';
   echo $this-getRequest()-getParam('forward');
   }
}

type following url to test the route result:
test group one:
http://myhost/login // output  'login actionbr/' ,call login
succ
http://myhost/register // output 'register actionbr/',call
register succ
http://myhost/logout   // output 'logout actionbr/' , call logout
succ

test group two:
http://myhost/login?forward=index.php // output 'login
actionbr/index.php',actually
call login failed
http://myhost/register?forward=index.php // output 'login actionbr/
index.php',call register failed
http://myhost/logout?forward=index.php  // output 'login actionbr/
index.php',call logout failed

test group three:
http://myhost/login?forward=test.php // output  'login actionbr/test.php'
,call login succ
http://myhost/register?forward=test.php // output  'register actionbr/
test.php' ,call login succ
http://myhost/logout?forward=test.php // output  'logout actionbr/test.php'
,call login succ



you can pass other string to the forward query string to test it,if the
query string is end up with index.php,it may be call non-default action
failed.

Regards
Jacky


[fw-general] match path problem

2007-01-18 Thread Jacky Chen

Hi there,
I want to add two routers,one to match the path such as http://myhost/actionor
http://myhost/action?querystring and another match the path such as
http://myhost/controller/action .How?

Best Regards,
Jacky


[fw-general] bug in route

2007-01-14 Thread Jacky Chen

Hi there,
i has wrtie a passport controller PassportController,there are three
actions,loginAction,logoutAction,registerAction.
When i invoke these action with a query string end up with index.php,and
then the action was be redirect to the default action,loginAction.

defaut route is:
$router = new Zend_Controller_RewriteRouter();
$router-addRoute('passport',new
Zend_Controller_Router_Route(':action',array('controller'='passport','action'='login')));

for example:
when i link to  http://www.mysite.com/register  there is ok,but when i added
a query string end up with index.php to the request uri,
say
http://www.mysite.com/register?forward=http%3A%2F%2Fbbs.mysite.com%2Findex.php
,and
then  it would invoke the login action,when i change the forward parameter
to a string that not end up with index.php,it is ok to invoke the
registerAction.

And you can test this problem just to set a query string with the string
index.php to the end of the request uri.

my englist is poor,do you understand my mind?

Best Regards


Re: [fw-general] bug in Zend_Controller_Front

2006-12-07 Thread Jacky Chen

2006/12/7, Matthew Weier O'Phinney [EMAIL PROTECTED]:


-- Jacky Chen [EMAIL PROTECTED] wrote
(on Thursday, 07 December 2006, 03:55 PM +0800):
 In new Zend_Controller_Front (svn 2172) implement,the
setControllerDirectory()
 and dispatch() methods have been modified.In the code line 630,there is
set the
 dispather controller directory in the dispatch() method.So in my
bootstrap file
 index.php , my code like this:
 ...
 $rout = new Zend_Controller_RewriteRouter();
 $front = Zend_Controller_Front::getInstance();
 $front-setRouter($router);
 $front-setControllerDirectory(CONTROLLER_DIR);
 //   ??
 if (!empty($controllers_dir)) {
  foreach ($controllers_dir as $dir) {
   $front-addControllerDirectory(rtrim(CONTROLLER_DIR,'/\\').'/'.$dir);
  }
 }
 $response = $front-dispatch();
 ...
 I set the controller directory with this statement $front-
 setControllerDirectory(CONTROLLER_DIR); And then add other controller
 directories in the $controllers_dir array to the front
controller.Becasue in
 the dispatch() method of the Front Controller,there is a code in line
630 (the
 code
is:$dispatcher-setControllerDirectory($this-getControllerDirectory());)
 to set the controller directory of the dispatcher,so all the directories
i had
 added have be reset to Front::_controllerDir which was set by call the
method
 setControllerDirectory() of the Front Controller.

Fixed in current HEAD.

--



not work yet.


Re: [fw-general] bug in Zend_Controller_Front

2006-12-07 Thread Jacky Chen

I had updated the svn,when i running my app,i get this exception message:

Array ( [0] = Zend_Exception Object ( [message:protected] = File
\IndexController.php was not found. [string:private] = [code:protected]
= 0 [file:protected] = H:\fzwc\zend\Zend.php [line:protected] = 200
[trace:private] = Array ( [0] = Array ( [file] = H:\fzwc\zend\Zend.php
[line] = 97 [function] = loadFile [class] = Zend [type] = :: [args] =
Array ( [0] = IndexController.php [1] = \ [2] = 1 ) ) [1] = Array (
[file] = H:\fzwc\web\index.php [line] = 15 [function] = loadClass [class]
= Zend [type] = :: [args] = Array ( [0] = _IndexController ) ) [2] =
Array ( [function] = __autoload [args] = Array ( [0] = _IndexController )
) [3] = Array ( [file] = H:\fzwc\zend\Zend\Controller\Dispatcher.php
[line] = 542 [function] = class_exists [args] = Array ( [0] =
_IndexController ) ) [4] = Array ( [file] =
H:\fzwc\zend\Zend\Controller\Dispatcher.php [line] = 389 [function] =
loadClass [class] = Zend_Controller_Dispatcher [type] = - [args] = Array
( [0] = _IndexController [1] = H:/fzwc/web/controllers ) ) [5] = Array (
[file] = H:\fzwc\zend\Zend\Controller\Front.php [line] = 666 [function] =
dispatch [class] = Zend_Controller_Dispatcher [type] = - [args] = Array
( [0] = Zend_Controller_Request_Http Object ( [_requestUri:protected] = /
[_baseUrl:protected] = [_basePath:protected] = [_pathInfo:protected] = /
[_params:protected] = Array ( [controller] = index ) [_aliases:protected]
= Array ( ) [_dispatched:protected] = 1 [_controllerKey:protected] =
controller [_actionKey:protected] = action ) [1] =
Zend_Controller_Response_Http Object ( [_body:protected] =
[_exceptions:protected] = Array *RECURSION* [_headers:protected] = Array (
) [_renderExceptions:protected] = ) ) ) [6] = Array ( [file] =
H:\fzwc\web\index.php [line] = 57 [function] = dispatch [class] =
Zend_Controller_Front [type] = - [args] = Array ( ) ) ) ) )

regards


Re: [fw-general] bug in Zend_Controller_Front

2006-12-07 Thread Jacky Chen

Anything is ok when i use the old files of Zend/Controller,but it failed if
use the new Zend/Controller files.

my app directory layout is:

app
|--- controllers
||- IndexController.php
||- news
|| |- NewsController.php
|| |- CommentController.php
||- other directories and controllers
| index.php
| other directories and files

my app is running under MS Windows,files are readable and writable.

my bootstrape file is simple,following is the main code of the bootstrap
file:

// route request to spec controller
$router = new Zend_Controller_RewriteRouter();
$controller = Zend_Controller_Front::getInstance();
$controller-setRouter($router);
$controller-setControllerDirectory(CONTROLLER_DIR);

// add other controller directories
if (!empty($controllers_dir)) {
foreach ($controllers_dir as $dir) {
 $controller-addControllerDirectory(rtrim(CONTROLLER_DIR,'/\\').'/'.$dir);
}
}

$response = $controller-dispatch();


[fw-general] Route problem

2006-11-28 Thread Jacky Chen

Hi,
when there are no actions match in the controller,the noRouteAction should
be call,but it isn't. ( incubator/library )


[fw-general] bug in Zend/Controller/Dispatcher.php

2006-11-24 Thread Jacky Chen

Hi
when i run my app under linux,i got the error:
*Fatal error*: Uncaught exception 'Zend_Controller_Dispatcher_Exception'
with message 'Directory mnt/hdb/web project/fz/web/controllers/news not
found or not readable' in /mnt/hdb/web
project/fz/zend/Zend/Controller/Dispatcher.php:146 Stack trace: #0
/mnt/hdb/web project/fz/zend/Zend/Controller/Front.php(184):
Zend_Controller_Dispatcher-addControllerDirectory('mnt/hdb/web pro...') #1
/mnt/hdb/web project/fz/web/index.php(52):
Zend_Controller_Front-addControllerDirectory('mnt/hdb/web pro...') #2
{main} thrown in */mnt/hdb/web
project/fz/zend/Zend/Controller/Dispatcher.php* on line *146**

*There should be a NewsController.php,but Dispatcher load it as news ,
'Directory
mnt/hdb/web project/fz/web/controllers/news not found

And this app run well under windows.
My linux system is Fedora 6,and php 5.1.6, apache 2.2.3,mysql 5.0.22

Best Regards.


Re: [fw-general] bug with Zend_Http_Request

2006-11-18 Thread Jacky Chen

Hi,Matthew
you just corrected the *$count($segs)* bug.And the bug with the methods
of Zend_Http_Request hasn't corrected yet.


*/**
* Base URL of request
* @var string
*/
   protected $_baseUrl = ''; *

*/**
* Base path of request
* @var string
*/
   protected $_basePath = ''; *

*/**
* PATH_INFO
* @var string
*/
   protected $_pathInfo = '';*
these attributes initial value is an empty string.And the methods following
to compare these attributes with *null . *the condition statement *if
($this-_baseUrl === null)* equal to *if ('' === null)* always get
false.Soshould corrected the condition statement with
*if ($this-_baseUrl === '')* statement or corrected the attribute *
$_baseUrl* initial value '' with *null. (protected $_baseUrl;)*

   */**
* Everything in REQUEST_URI before PATH_INFO
* form action=?=$baseUrl?/news/submit method=POST/
*
* @return string
*/
   public function getBaseUrl()
   {
   if ($this-_baseUrl === null) {
   $this-setBaseUrl();
   }

   return $this-_baseUrl;
   } *
**
*/**
* Everything in REQUEST_URI before PATH_INFO not including the filename
* img src=?=$basePath?/images/zend.png/
*
* @return string
*/
   public function getBasePath()
   {
   if ($this-_basePath === null) {
   $this-setBasePath();
   }

   return $this-_basePath;
   } *
**
*/**
* Returns everything between the BaseUrl and QueryString.
* This value is calculated instead of reading PATH_INFO
* directly from $_SERVER due to cross-platform differences.
*
* @return string
*/
   public function getPathInfo()
   {
   if ($this-_pathInfo === null) {
   $this-setPathInfo();
   }

   return $this-_pathInfo;
   }
*
sorry for my englist again.

2006/11/19, Matthew Weier O'Phinney [EMAIL PROTECTED]:


-- ?? [EMAIL PROTECTED] wrote
(on Saturday, 18 November 2006, 10:10 AM +0800):
 In Zend_Http_Request code line 337 , $count($segs)  should be
count($segs).
 And the attributes $_baseUrl,$_basePath and $_pathInfo initial value is
''. But
 the method getBaseUrl(),getBasePath() and getPathInfo() detect the
attributes
 link this :if ($this-_baseUrl === null)  , if ($this-_basePath ===
null)  and
 if ($this-_pathInfo === null) .
 So when invoke method of these,just return ''.

Corrected in subversion; please test!

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