zend-framework

How can I customise Zend_Form regex error messages?

一个人想着一个人 提交于 2019-12-07 10:55:37
问题 I have the following code: $postcode = $form->createElement('text', 'postcode'); $postcode->setLabel('Post code:'); $postcode->addValidator('regex', false, array('/^[a-z]{1,3}[0-9]{1,3} ?[0-9]{1,3}[a-z]{1,3}$/i')); $postcode->addFilters(array('StringToUpper')); $postcode->setRequired(true); It creates an input field in a form and sets a regex validation rule and works just fine. The problem is that the error message it displays when a user enters an invalid postcode is this: 'POSTCODE' does

PHP: How to determine email attachment's MIME type?

拈花ヽ惹草 提交于 2019-12-07 10:53:26
I'm using Zend's Zend_Mail_Storage_Pop3 to connect to mail server, open an email, and iterate through its attachments. If the attachment is a PDF, I need to download it. At each iteration of each message part, I call the getHeaders and use Regex to determine the mime type of the attachment. In most cases, I get something like this: ["content-type"]=> string(64) "application/octet-stream; name=abc.pdf" ["content-transfer-encoding"]=> string(6) "base64" But in some cases, I get something like this: multipart/mixed; boundary=--boundary_2_1dca5b3b-499e-4109-b074-d8b5f914404a How do I determine the

Error inserting row in Google Spreadsheet using Zend Gdata

青春壹個敷衍的年華 提交于 2019-12-07 10:40:34
问题 I'm trying the simplest possible scenario to insert row in Google Spreadsheet using Zend Gdata 1.11 library. Spreadsheet has word 'Kolona' in cell A1. Here is entire php file: <?php require_once 'Zend/Loader.php'; Zend_Loader::loadClass('Zend_Gdata'); Zend_loader::loadClass('Zend_Gdata_Query'); Zend_Loader::loadClass('Zend_Gdata_Spreadsheets'); Zend_Loader::loadClass('Zend_Gdata_ClientLogin'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD

Zend capture layout and view content as variable

断了今生、忘了曾经 提交于 2019-12-07 10:31:26
问题 I have a controller Mycontroller with simple exemple action: public function exempleAction(){ // Using layout "mail" $this->_helper->layout()->setLayout("mail"); } I want to get HTML content of the view using: (to use it later as email content) $view_helper = new Zend_View_Helper_Action(); $html_content = $view_helper->action('exemple', 'Mycontroller','mymodule'); This successfully allow me to get the view content but WITHOUT the layout content . All the HTML code of the layout "mail" is not

How to download existing file in PHP

て烟熏妆下的殇ゞ 提交于 2019-12-07 10:13:33
问题 I have a pdf file on my server. I want to create such link that, user can click on it and download that pdf file. I am using Zend frame work with Php. 回答1: place this code inside a php file and call it f.e. "download.php": <?php $fullPath = "path/to/your/file.ext"; if ($fd = fopen ($fullPath, "r")) { $fsize = filesize($fullPath); $path_parts = pathinfo($fullPath); $ext = strtolower($path_parts["extension"]); header("Content-type: application/pdf"); header("Content-Disposition: attachment;

Zend GetText and .mo .po files

那年仲夏 提交于 2019-12-07 10:08:29
问题 I have inherited from an application made a developement company, and i need to get the .mo and .po files generated for my website. Here's what i have in the bootstrap : $translate = new Zend_Translate ('gettext', ROOT_PATH.'/languages/en/default.mo', 'en', array('disableNotices' => true)); $translate->setLocale($locale); I'm using the translate helper everywhere i have to set up text on my website but my .mo and .po files do not contain all the strings that are set up in my application. Is

Zend Framework: How to set default mail transport in configuration file?

独自空忆成欢 提交于 2019-12-07 10:06:57
问题 I know that default mail transport could be set in bootstrap file but how to do it in app.ini file? Basically I want to use smtp transport on local windows system and regular mail transport on production server. Edit: I'm already using these settings in app.ini . Thanks. 回答1: If your production server is *nix [production] resources.mail.transport.type = sendmail [development : production] resources.mail.transport.type = smtp resources.mail.transport.host = smtp.example.com 回答2: you may

How to prevent SQL Injection attack in applications programmed in Zend Framework?

為{幸葍}努か 提交于 2019-12-07 09:11:48
问题 I don't have any concept about ZF safety. Do I have to use Filter when operating on database? Maybe binding is enough ? How about this: $users->update($data, 'id=1'); Should $data array be filtered somehow ? Feel free to write anything you know about the issue. Could you give some links to good articles about safety in ZF (mainly about SQL Injection and XSS)? 回答1: Short answer While ZF takes and provides some measures to secure your app, you should still apply the same precautions that you'd

Subscript or Superscript text within a Zend Form label

喜夏-厌秋 提交于 2019-12-07 09:05:46
问题 I would like to include subscript text in a Zend_Form_Element's label, and it doesn't seem to be working: $zend_form_element->setLabel('Label <sub>x</sub>'); Is there anything I can do to get it to output properly without having to manually write the form on the view page? Thanks for the help, Dave 回答1: I would say that best way is to get actual decorator from element and then set escape option, not to add new decorator: $zend_form_element->getDecorator('Label')->setOption('escape',false);

Lucene foreign chars problem

孤人 提交于 2019-12-07 08:44:38
问题 I'm having some serious issues using Zend_Lucene and foreign characters like åäö. These issues appear both when the index is created and when it's queried. I've tried both iso-8859-1 and utf-8. ISO-8859-1 The query that doesn't work looks like " +_area:skåne ". With Zend_Lucene I'm getting no matches, but if I run this query in Luke I get many matching docuements. The index contains 20 fields. The "_area" field is added with the following syntax: $doc->addField(Zend_Search_Lucene_Field: