[fw-general] htaccess - how to allow a file to get pass zf?

2009-01-23 Thread johannesf

Hi

Many thanks for the superb zend framework!

Well, I need to allow a special file in my ZF htaccess. Som I can access
that file and not let the zf route the access.

Example 'httm://www.domain.com/special.php' will not get routed by the
framework.

Is that possible?


-- 
View this message in context: 
http://www.nabble.com/htaccess---how-to-allow-a-file-to-get-pass-zf--tp21620586p21620586.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] htaccess - how to allow a file to get pass zf?

2009-01-23 Thread Brenton Alker
johannesf wrote:
 Hi
 
 Many thanks for the superb zend framework!
 
 Well, I need to allow a special file in my ZF htaccess. Som I can access
 that file and not let the zf route the access.
 
 Example 'httm://www.domain.com/special.php' will not get routed by the
 framework.
 
 Is that possible?
 

Of course. If it's not working now, I imagine you are using a rewrite
rule something like:

RewriteRule !\.(js|ico|gif|jpg|png|css)$ /index.php

Which says take any file that doesn't have one of those extensions and
rewrite it to index.php

If you use a rule like

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /index.php

It will rewrite anything that isn't an actual file or directory to
index.php. So any file (including php scripts) that actually exist under
your document root will be directly accessible.

--

Brenton Alker

http://blog.tekerson.com/



signature.asc
Description: OpenPGP digital signature


Re: [fw-general] htaccess - how to allow a file to get pass zf?

2009-01-23 Thread johannesf

Thanks!

works pefect

all the best / johannes



Brenton Alker-3 wrote:
 
 johannesf wrote:
 Hi
 
 Many thanks for the superb zend framework!
 
 Well, I need to allow a special file in my ZF htaccess. Som I can access
 that file and not let the zf route the access.
 
 Example 'httm://www.domain.com/special.php' will not get routed by the
 framework.
 
 Is that possible?
 
 
 Of course. If it's not working now, I imagine you are using a rewrite
 rule something like:
 
 RewriteRule !\.(js|ico|gif|jpg|png|css)$ /index.php
 
 Which says take any file that doesn't have one of those extensions and
 rewrite it to index.php
 
 If you use a rule like
 
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule .* /index.php
 
 It will rewrite anything that isn't an actual file or directory to
 index.php. So any file (including php scripts) that actually exist under
 your document root will be directly accessible.
 
 --
 
 Brenton Alker
 
 http://blog.tekerson.com/
 
 
  
 

-- 
View this message in context: 
http://www.nabble.com/htaccess---how-to-allow-a-file-to-get-pass-zf--tp21620586p21621215.html
Sent from the Zend Framework mailing list archive at Nabble.com.



[fw-general] File_Transfer move_uploade_file permision denied

2009-01-23 Thread Bertil Wergelius
Why doesn't Upload catch the possibility that the destination catalog
has no write privileges?
I used to have a class for image uploads with this code sample:
if ($fel==UPLOAD_ERR_OK) {
 if (!($flytta_f...@move_uploaded_file($tempfil,$malet))) {
return(Flyttning av filen misslyckades);
 } else {
etc
and that works fine. But I can't figure out how that would be done in
or with Zend_File_Transfer.


Re: [fw-general] File_Transfer move_uploade_file permision denied

2009-01-23 Thread Thomas Weidner

Bertil,

Whatever you mean with upload but move_uploaded_file is part of PHP itself.
It does handle invalid write permission.

And also Zend_File_Transfer handles invalid write permissions and return an 
exception is this case with the proper message text.
Have you tried it out or are you just looking at the code unable to find out 
how it works ? :-)


Take a look at the manual or the examples which can be found around in the 
net.


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


- Original Message - 
From: Bertil Wergelius bertil.wergel...@gmail.com

To: fw-general@lists.zend.com
Sent: Friday, January 23, 2009 12:03 PM
Subject: [fw-general] File_Transfer move_uploade_file permision denied



Why doesn't Upload catch the possibility that the destination catalog
has no write privileges?
I used to have a class for image uploads with this code sample:
if ($fel==UPLOAD_ERR_OK) {
if (!($flytta_f...@move_uploaded_file($tempfil,$malet))) {
   return(Flyttning av filen misslyckades);
} else {
etc
and that works fine. But I can't figure out how that would be done in
or with Zend_File_Transfer. 




Re: [fw-general] File_Transfer move_uploade_file permision denied

2009-01-23 Thread Bertil Wergelius
Yes, Thomas, I did look at the manual but I have this test-code (that
by the way works excellently with the filter to change the name of the
file to underscores instead of spaces all thanks to your code, that is
really great and I thank you for that):

if ($form-isValid($_POST)) {
$filsokvag = $filuppladdning-getFilename();
$filnamnsfilter = new Zend_Filter_BaseName();
$sokvagsfilter = new Zend_Filter_Dir();
$mellanslag2understreck = new
Zend_Filter_Word_SeparatorToSeparator(' ','_');
$filnamnet = $filnamnsfilter-filter($filsokvag);
$sokvagen = $sokvagsfilter-filter($filsokvag);
$gammalsokvag = $sokvagen ./.$filnamnet;
$nya_filnamnet = $mellanslag2understreck-filter($filnamnet);

$nyafilsokvag = $sokvagen ./ .$nya_filnamnet;
$filadapter-addFilter('Rename',array(
'source' = $gammalsokvag,
'target' = $nyafilsokvag,
'overwrite' = true
 )
);
$filadapter-receive();
etc...

But if I change the directory rights to only read I get the message:
Warning: 
move_uploaded_file(/var/www/Testa_Div_Zend_framework/div_dokument/testa.odt)
[function.move-uploaded-file]: failed to open stream: Permission
denied in /var/www/ZendFramework/library/Zend/File/Transfer/Adapter/Http.php
on line 102

I've tried to do all sorts of things with if (!$filadapter-receive()
etc but nothing works. It seems like it accepts $filadapter-receive()
as true although it can't move the file from tmp to the destination.

Would be really grateful for help with sorting this out.


2009/1/23 Thomas Weidner thomas.weid...@gmx.at:
 Bertil,

 Whatever you mean with upload but move_uploaded_file is part of PHP itself.
 It does handle invalid write permission.

 And also Zend_File_Transfer handles invalid write permissions and return an
 exception is this case with the proper message text.
 Have you tried it out or are you just looking at the code unable to find out
 how it works ? :-)

 Take a look at the manual or the examples which can be found around in the
 net.

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


 - Original Message - From: Bertil Wergelius
 bertil.wergel...@gmail.com
 To: fw-general@lists.zend.com
 Sent: Friday, January 23, 2009 12:03 PM
 Subject: [fw-general] File_Transfer move_uploade_file permision denied


 Why doesn't Upload catch the possibility that the destination catalog
 has no write privileges?
 I used to have a class for image uploads with this code sample:
 if ($fel==UPLOAD_ERR_OK) {
if (!($flytta_f...@move_uploaded_file($tempfil,$malet))) {
   return(Flyttning av filen misslyckades);
} else {
 etc
 and that works fine. But I can't figure out how that would be done in
 or with Zend_File_Transfer.




[fw-general] Amf ZF-5094 and ZF-5388

2009-01-23 Thread Dirk Thomas

I have filled the two mentioned issues in Zend_Amf some time ago and provided
patches as well.

The patch for the first issue (ZF-5094) has been commited to svn trunk by
Wade Arnold in the middle of december. Why was it neither included in 1.7.2
nor 1.7.3?

For the second issue (ZF-5388) there was no response at all.

Currently i have to maintain a local repository for Zend_Amf which contains
these fixes since there is no ETA visible when these will be included in an
official release.

I would appreciate any kind of feedback - ranging from your patch is
wrong/not good enough because, ... to will only be part of 1.8.x.

Dirk Thomas
-- 
View this message in context: 
http://www.nabble.com/Amf-ZF-5094-and-ZF-5388-tp21624321p21624321.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Amf ZF-5094 and ZF-5388

2009-01-23 Thread Tobias Gies
Hi Dirk,

I can only comment on the first issue since I am no AMF expert, but
for ZF-5094, it seems like Wade has commited the patch to SVN trunk,
but never merged it to the release-1.7 branch.

Wade, did you have a reason to do so or should I merge the patch?

Best regards,
Tobias

2009/1/23 Dirk Thomas dirk.tho...@4wdmedia.de:

 I have filled the two mentioned issues in Zend_Amf some time ago and provided
 patches as well.

 The patch for the first issue (ZF-5094) has been commited to svn trunk by
 Wade Arnold in the middle of december. Why was it neither included in 1.7.2
 nor 1.7.3?

 For the second issue (ZF-5388) there was no response at all.

 Currently i have to maintain a local repository for Zend_Amf which contains
 these fixes since there is no ETA visible when these will be included in an
 official release.

 I would appreciate any kind of feedback - ranging from your patch is
 wrong/not good enough because, ... to will only be part of 1.8.x.

 Dirk Thomas
 --
 View this message in context: 
 http://www.nabble.com/Amf-ZF-5094-and-ZF-5388-tp21624321p21624321.html
 Sent from the Zend Framework mailing list archive at Nabble.com.




[fw-general] New Ubuntu packages

2009-01-23 Thread Mario Guenterberg
Hi all,

I have build the new ZF release as deb package for Ubuntu 8.04 and
8.10.
You can find them here: http://packages.havelsoft.org.

I'll do my best in the future to build and publish the packages
regulary as soon as a new ZF released.

Happy coding
Mario Guenterberg

-- 
-BEGIN GEEK CODE BLOCK-
Version: 3.12
GCS/CM d- s++: a+ C$ UBL*$ P++ L+++ E--- W+++ N+ o-- K- w O- M-
V-- PS++ PE++ Y PGP+++ t--- 5 X R++ tv- b+++ DI D  G++ e* h
r+++ y
--END GEEK CODE BLOCK--


signature.asc
Description: Digital signature


[fw-general] Zend_Test_PHPUnit_ControllerTestCase reset methods doesn't reset post array

2009-01-23 Thread fab2008

I'm playing a little bit with Zend_Test package and I've found a (IMHO) wrong
behaviour of resetRequest and resetResponse methods. In the example provided
on the documentation there is a testcase with the simulation of a request
from a logged user:

 public function testValidLoginShouldGoToProfilePage()
{
$this-request-setMethod('POST')
  -setPost(array(
  'username' = 'foobar',
  'password' = 'foobar'
  ));
$this-dispatch('/user/login');
$this-assertRedirectTo('/user/view');

$this-resetRequest()
 -resetResponse();

$this-request-setMethod('GET')
 -setPost(array());
$this-dispatch('/user/view');
$this-assertRoute('default');
$this-assertModule('default');
$this-assertController('user');
$this-assertAction('view');
$this-assertNotRedirect();
$this-assertQuery('dl');
$this-assertQueryContentContains('h2', 'User: foobar');
}

I've replicated this snippet adapting it to my app and I've seen two things:
- $this-resetRequest()-resetResponse(); call only sets request and
response to null and clears the Zend_Registry instance, so it's mandatory to
execute the following code:
$this-request-setMethod('GET')-setPost(array());

- the setPost function doesn't reset the $_POST global variable, instead if
it's called as in the exampe it has no effect. This is a snipplet of my test
case:

// login with valid admin
$this-getRequest()-setMethod('POST')-setPost(
array ('username' = 'fabio', 'password' = 
'fabio'));
$this-dispatch('/login');
$this-assertRedirectTo('/');

$this-resetRequest()-resetResponse();
$this-getRequest()-setPost(array());

//$_POST = array();

//**check for missing body
$this-getRequest()-setMethod('POST')-setPost(
array ('subject' = 'aa', 'language' = 
'test'));
$this-dispatch('/message/compose');
Zend_Debug::dump($_POST);


And this is the output of the dump:

array(4) {
  [username] = string(5) fabio
  [password] = string(5) fabio
  [language] = string(4) test
  [subject] = string(2) aa
}

Therefore the post array is not reset... If I decomment in my code the line
$_POST = array(); the test works as expected and everything goes fine:

array(2) {
  [language] = string(4) test
  [subject] = string(2) aa
}

I want to post an issue report on the tracker, but I don't have the create
issue privilege, I tried to wrote an email to ask for it but nobody has
answered me and I still haven't the privilege...



-- 
View this message in context: 
http://www.nabble.com/Zend_Test_PHPUnit_ControllerTestCase-reset-methods-doesn%27t-reset-post-array-tp21625452p21625452.html
Sent from the Zend Framework mailing list archive at Nabble.com.



[fw-general] Zend_JQuery and form select element.

2009-01-23 Thread Paweł Chuchmała
HI.

I use ZF 1.7.0.

If I try to create JQuery_Form, element select isn't properly
rendered. In JQUery_Form_Decorator_UiWidgetElement in method render
is:

$elementContent = $view-$helper($name, $value, $jQueryParams, $attribs);

where:
$attribs   = $this-getElementAttribs();

so, helper for render FormSelect is called with paramters:
array
  0 = string 'name' (length=20)
  1 = string 'value' (length=2)
  2 =
array
  empty /* our attribs*/
  3 =
array
  'options' =
array
  empty /* our empty values, or array if set */
  'listsep' = string 'br /' (length=6)
  'id' = string 'name' (length=20)

In html:

select name=name id=name
optgroup label=options
/optgroup
option value=listsep label=lt;br /gt;lt;br /gt;/option
option value=id label=namename/option
/select

It's a bug, or I doing something wrong?

regards,
pch

-- 
Paweł Chuchmała
pawel.chuchmala at gmail dot com


Re: [fw-general] Zend_JQuery and form select element.

2009-01-23 Thread Benjamin Eberlei
The UiWidgetElement decorator is only for jQuery UI elements, not for other 
elements such as Zend_Form_Element_Select. You need to use the default  
Zend_Form_Decorator_ViewHelper for such elements.

On Friday 23 January 2009 15:42:35 Paweł Chuchmała wrote:
 HI.

 I use ZF 1.7.0.

 If I try to create JQuery_Form, element select isn't properly
 rendered. In JQUery_Form_Decorator_UiWidgetElement in method render
 is:

 $elementContent = $view-$helper($name, $value, $jQueryParams, $attribs);

 where:
 $attribs   = $this-getElementAttribs();

 so, helper for render FormSelect is called with paramters:
 array
   0 = string 'name' (length=20)
   1 = string 'value' (length=2)
   2 =
 array
   empty /* our attribs*/
   3 =
 array
   'options' =
 array
   empty /* our empty values, or array if set */
   'listsep' = string 'br /' (length=6)
   'id' = string 'name' (length=20)

 In html:

 select name=name id=name
 optgroup label=options
 /optgroup
 option value=listsep label=lt;br /gt;lt;br /gt;/option
 option value=id label=namename/option
 /select

 It's a bug, or I doing something wrong?

 regards,
 pch

-- 
Benjamin Eberlei
http://www.beberlei.de


Re: [fw-general] Zend_JQuery and form select element.

2009-01-23 Thread Paweł Chuchmała
Ok. Thanks for answer.

regards,
pch

2009/1/23 Benjamin Eberlei kont...@beberlei.de:
 The UiWidgetElement decorator is only for jQuery UI elements, not for other
 elements such as Zend_Form_Element_Select. You need to use the default
 Zend_Form_Decorator_ViewHelper for such elements.

 On Friday 23 January 2009 15:42:35 Paweł Chuchmała wrote:
 HI.

 I use ZF 1.7.0.

 If I try to create JQuery_Form, element select isn't properly
 rendered. In JQUery_Form_Decorator_UiWidgetElement in method render
 is:

 $elementContent = $view-$helper($name, $value, $jQueryParams, $attribs);

 where:
 $attribs   = $this-getElementAttribs();

 so, helper for render FormSelect is called with paramters:
 array
   0 = string 'name' (length=20)
   1 = string 'value' (length=2)
   2 =
 array
   empty /* our attribs*/
   3 =
 array
   'options' =
 array
   empty /* our empty values, or array if set */
   'listsep' = string 'br /' (length=6)
   'id' = string 'name' (length=20)

 In html:

 select name=name id=name
 optgroup label=options
 /optgroup
 option value=listsep label=lt;br /gt;lt;br /gt;/option
 option value=id label=namename/option
 /select

 It's a bug, or I doing something wrong?

 regards,
 pch

 --
 Benjamin Eberlei
 http://www.beberlei.de




-- 
Paweł Chuchmała
pawel.chuchmala at gmail dot com


Re: [fw-general] File_Transfer move_uploade_file permision denied

2009-01-23 Thread Thomas Weidner
The code you gave is only partitial... it is not visible how the adapter is 
initiated and configured.

Also line 102 you gave is actually a comment.

So I expect that you are using an outdated release.
First update to the actual release.

Second as soon as you call any method which sets or gets the destination 
directory it is checked it there is write permission.

This is also done for the temporary directory when you don't set anyone.

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

- Original Message - 
From: Bertil Wergelius bertil.wergel...@gmail.com

To: Thomas Weidner thomas.weid...@gmx.at
Cc: fw-general@lists.zend.com
Sent: Friday, January 23, 2009 2:19 PM
Subject: Re: [fw-general] File_Transfer move_uploade_file permision denied



Yes, Thomas, I did look at the manual but I have this test-code (that
by the way works excellently with the filter to change the name of the
file to underscores instead of spaces all thanks to your code, that is
really great and I thank you for that):

if ($form-isValid($_POST)) {
   $filsokvag = $filuppladdning-getFilename();
   $filnamnsfilter = new Zend_Filter_BaseName();
   $sokvagsfilter = new Zend_Filter_Dir();
   $mellanslag2understreck = new
Zend_Filter_Word_SeparatorToSeparator(' ','_');
   $filnamnet = $filnamnsfilter-filter($filsokvag);
   $sokvagen = $sokvagsfilter-filter($filsokvag);
   $gammalsokvag = $sokvagen ./.$filnamnet;
   $nya_filnamnet = $mellanslag2understreck-filter($filnamnet);

   $nyafilsokvag = $sokvagen ./ .$nya_filnamnet;
   $filadapter-addFilter('Rename',array(
   'source' = $gammalsokvag,
   'target' = $nyafilsokvag,
   'overwrite' = true
)
   );
   $filadapter-receive();
etc...

But if I change the directory rights to only read I get the message:
Warning: 
move_uploaded_file(/var/www/Testa_Div_Zend_framework/div_dokument/testa.odt)

[function.move-uploaded-file]: failed to open stream: Permission
denied in 
/var/www/ZendFramework/library/Zend/File/Transfer/Adapter/Http.php

on line 102

I've tried to do all sorts of things with if (!$filadapter-receive()
etc but nothing works. It seems like it accepts $filadapter-receive()
as true although it can't move the file from tmp to the destination.

Would be really grateful for help with sorting this out.


2009/1/23 Thomas Weidner thomas.weid...@gmx.at:

Bertil,

Whatever you mean with upload but move_uploaded_file is part of PHP 
itself.

It does handle invalid write permission.

And also Zend_File_Transfer handles invalid write permissions and return 
an

exception is this case with the proper message text.
Have you tried it out or are you just looking at the code unable to find 
out

how it works ? :-)

Take a look at the manual or the examples which can be found around in 
the

net.

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


- Original Message - From: Bertil Wergelius
bertil.wergel...@gmail.com
To: fw-general@lists.zend.com
Sent: Friday, January 23, 2009 12:03 PM
Subject: [fw-general] File_Transfer move_uploade_file permision denied



Why doesn't Upload catch the possibility that the destination catalog
has no write privileges?
I used to have a class for image uploads with this code sample:
if ($fel==UPLOAD_ERR_OK) {
   if (!($flytta_f...@move_uploaded_file($tempfil,$malet))) {
  return(Flyttning av filen misslyckades);
   } else {
etc
and that works fine. But I can't figure out how that would be done in
or with Zend_File_Transfer.







Re: [fw-general] File_Transfer move_uploade_file permision denied

2009-01-23 Thread Bertil Wergelius
Well, there was a form with some other things there to but the
$filadapter-object was initialized with:
$filadapter = new Zend_File_Transfer_Adapter_Http();
and that it gave the line 102 may depend on that I tried to change
some of the code but I've changed that back again
and line 102 is

if (!move_uploaded_file($content['tmp_name'], ($directory .
$content['name']))) {

and I use  1.7.1

And I meant Zend_Validate_File_Upload when I spoke of Upload earlier

If there is a way to configure Zend_File_Transfer_Adapter_Http() that
would help me out with this would of course be great

All my best
/Bertil
2009/1/23 Thomas Weidner thomas.weid...@gmx.at:
 The code you gave is only partitial... it is not visible how the adapter is
 initiated and configured.
 Also line 102 you gave is actually a comment.

 So I expect that you are using an outdated release.
 First update to the actual release.

 Second as soon as you call any method which sets or gets the destination
 directory it is checked it there is write permission.
 This is also done for the temporary directory when you don't set anyone.

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

 - Original Message - From: Bertil Wergelius
 bertil.wergel...@gmail.com
 To: Thomas Weidner thomas.weid...@gmx.at
 Cc: fw-general@lists.zend.com
 Sent: Friday, January 23, 2009 2:19 PM
 Subject: Re: [fw-general] File_Transfer move_uploade_file permision denied


 Yes, Thomas, I did look at the manual but I have this test-code (that
 by the way works excellently with the filter to change the name of the
 file to underscores instead of spaces all thanks to your code, that is
 really great and I thank you for that):

 if ($form-isValid($_POST)) {
   $filsokvag = $filuppladdning-getFilename();
   $filnamnsfilter = new Zend_Filter_BaseName();
   $sokvagsfilter = new Zend_Filter_Dir();
   $mellanslag2understreck = new
 Zend_Filter_Word_SeparatorToSeparator(' ','_');
   $filnamnet = $filnamnsfilter-filter($filsokvag);
   $sokvagen = $sokvagsfilter-filter($filsokvag);
   $gammalsokvag = $sokvagen ./.$filnamnet;
   $nya_filnamnet = $mellanslag2understreck-filter($filnamnet);

   $nyafilsokvag = $sokvagen ./ .$nya_filnamnet;
   $filadapter-addFilter('Rename',array(
   'source' = $gammalsokvag,
   'target' = $nyafilsokvag,
   'overwrite' = true
)
   );
   $filadapter-receive();
 etc...

 But if I change the directory rights to only read I get the message:
 Warning:
 move_uploaded_file(/var/www/Testa_Div_Zend_framework/div_dokument/testa.odt)
 [function.move-uploaded-file]: failed to open stream: Permission
 denied in
 /var/www/ZendFramework/library/Zend/File/Transfer/Adapter/Http.php
 on line 102

 I've tried to do all sorts of things with if (!$filadapter-receive()
 etc but nothing works. It seems like it accepts $filadapter-receive()
 as true although it can't move the file from tmp to the destination.

 Would be really grateful for help with sorting this out.


 2009/1/23 Thomas Weidner thomas.weid...@gmx.at:

 Bertil,

 Whatever you mean with upload but move_uploaded_file is part of PHP
 itself.
 It does handle invalid write permission.

 And also Zend_File_Transfer handles invalid write permissions and return
 an
 exception is this case with the proper message text.
 Have you tried it out or are you just looking at the code unable to find
 out
 how it works ? :-)

 Take a look at the manual or the examples which can be found around in
 the
 net.

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


 - Original Message - From: Bertil Wergelius
 bertil.wergel...@gmail.com
 To: fw-general@lists.zend.com
 Sent: Friday, January 23, 2009 12:03 PM
 Subject: [fw-general] File_Transfer move_uploade_file permision denied


 Why doesn't Upload catch the possibility that the destination catalog
 has no write privileges?
 I used to have a class for image uploads with this code sample:
 if ($fel==UPLOAD_ERR_OK) {
   if (!($flytta_f...@move_uploaded_file($tempfil,$malet))) {
  return(Flyttning av filen misslyckades);
   } else {
 etc
 and that works fine. But I can't figure out how that would be done in
 or with Zend_File_Transfer.






Re: [fw-general] File_Transfer move_uploade_file permision denied

2009-01-23 Thread Thomas Weidner

The solution is:
Update to 1.7.3 as mentioned before

Btw: How should we find the problem in your code when you changed ZF's 
internal classes ? ;-)


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

- Original Message - 
From: Bertil Wergelius bertil.wergel...@gmail.com

To: Thomas Weidner thomas.weid...@gmx.at
Cc: fw-general@lists.zend.com
Sent: Friday, January 23, 2009 5:40 PM
Subject: Re: [fw-general] File_Transfer move_uploade_file permision denied



Well, there was a form with some other things there to but the
$filadapter-object was initialized with:
$filadapter = new Zend_File_Transfer_Adapter_Http();
and that it gave the line 102 may depend on that I tried to change
some of the code but I've changed that back again
and line 102 is

if (!move_uploaded_file($content['tmp_name'], ($directory .
$content['name']))) {

and I use  1.7.1

And I meant Zend_Validate_File_Upload when I spoke of Upload earlier

If there is a way to configure Zend_File_Transfer_Adapter_Http() that
would help me out with this would of course be great

All my best
/Bertil
2009/1/23 Thomas Weidner thomas.weid...@gmx.at:
The code you gave is only partitial... it is not visible how the adapter 
is

initiated and configured.
Also line 102 you gave is actually a comment.

So I expect that you are using an outdated release.
First update to the actual release.

Second as soon as you call any method which sets or gets the destination
directory it is checked it there is write permission.
This is also done for the temporary directory when you don't set anyone.

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

- Original Message - From: Bertil Wergelius
bertil.wergel...@gmail.com
To: Thomas Weidner thomas.weid...@gmx.at
Cc: fw-general@lists.zend.com
Sent: Friday, January 23, 2009 2:19 PM
Subject: Re: [fw-general] File_Transfer move_uploade_file permision 
denied




Yes, Thomas, I did look at the manual but I have this test-code (that
by the way works excellently with the filter to change the name of the
file to underscores instead of spaces all thanks to your code, that is
really great and I thank you for that):

if ($form-isValid($_POST)) {
  $filsokvag = $filuppladdning-getFilename();
  $filnamnsfilter = new Zend_Filter_BaseName();
  $sokvagsfilter = new Zend_Filter_Dir();
  $mellanslag2understreck = new
Zend_Filter_Word_SeparatorToSeparator(' ','_');
  $filnamnet = $filnamnsfilter-filter($filsokvag);
  $sokvagen = $sokvagsfilter-filter($filsokvag);
  $gammalsokvag = $sokvagen ./.$filnamnet;
  $nya_filnamnet = $mellanslag2understreck-filter($filnamnet);

  $nyafilsokvag = $sokvagen ./ .$nya_filnamnet;
  $filadapter-addFilter('Rename',array(
  'source' = $gammalsokvag,
  'target' = $nyafilsokvag,
  'overwrite' = true
   )
  );
  $filadapter-receive();
etc...

But if I change the directory rights to only read I get the message:
Warning:
move_uploaded_file(/var/www/Testa_Div_Zend_framework/div_dokument/testa.odt)
[function.move-uploaded-file]: failed to open stream: Permission
denied in
/var/www/ZendFramework/library/Zend/File/Transfer/Adapter/Http.php
on line 102

I've tried to do all sorts of things with if (!$filadapter-receive()
etc but nothing works. It seems like it accepts $filadapter-receive()
as true although it can't move the file from tmp to the destination.

Would be really grateful for help with sorting this out.


2009/1/23 Thomas Weidner thomas.weid...@gmx.at:


Bertil,

Whatever you mean with upload but move_uploaded_file is part of PHP
itself.
It does handle invalid write permission.

And also Zend_File_Transfer handles invalid write permissions and 
return

an
exception is this case with the proper message text.
Have you tried it out or are you just looking at the code unable to 
find

out
how it works ? :-)

Take a look at the manual or the examples which can be found around in
the
net.

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


- Original Message - From: Bertil Wergelius
bertil.wergel...@gmail.com
To: fw-general@lists.zend.com
Sent: Friday, January 23, 2009 12:03 PM
Subject: [fw-general] File_Transfer move_uploade_file permision denied



Why doesn't Upload catch the possibility that the destination catalog
has no write privileges?
I used to have a class for image uploads with this code sample:
if ($fel==UPLOAD_ERR_OK) {
  if (!($flytta_f...@move_uploaded_file($tempfil,$malet))) {
 return(Flyttning av filen misslyckades);
  } else {
etc
and that works fine. But I can't figure out how that would be done in
or with Zend_File_Transfer.










Re: [fw-general] Requested URL not found for all controllers except IndexController

2009-01-23 Thread Matthew Weier O'Phinney
-- Thomas VEQUAUD thomas.vequ...@gmail.com wrote
(on Friday, 23 January 2009, 06:06 PM +0100):
 
 Hi there,
 
 I'm developing my third project with Zend on a Linux server but this time it's
 with Zend Core for Oracle. So, the Apache server, PHP module are already
 configured for Zend (I mean that rewrite module is enabled).
 
 That works with IndexController but 404 error when I try to access to another
 controller...
 The requested URL /About/ was not found on this server
 I don't finish my controllers, view helpers nor the bootstrap by ?
 What the fuck!?!?
 
 Here is my .htaccess :
 RewriteEngine on
 RewriteCond %{SCRIPT_FILENAME} !-f
 RewriteCond %{SCRIPT_FILENAME} !-d
 RewriteRule ^(.*)$ index.php/$1

Change the above line to:

RewriteRule ^.*$ index.php [NC,L]

and see if it has any effect

 php_flag magic_quotes_gpc off
 php_flag register_globals off

-- 
Matthew Weier O'Phinney
Software Architect   | matt...@zend.com
Zend Framework   | http://framework.zend.com/


Re: [fw-general] Requested URL not found for all controllers except IndexController

2009-01-23 Thread Thomas VEQUAUD
On Fri, Jan 23, 2009 at 6:30 PM, Matthew Weier O'Phinney
matt...@zend.comwrote:


  Here is my .htaccess :
  RewriteEngine on
  RewriteCond %{SCRIPT_FILENAME} !-f
  RewriteCond %{SCRIPT_FILENAME} !-d
  RewriteRule ^(.*)$ index.php/$1

 Change the above line to:

RewriteRule ^.*$ index.php [NC,L]

 and see if it has any effect

  php_flag magic_quotes_gpc off
  php_flag register_globals off


Hey Vermonster! ;)

I'm no more at work, I'll try this on Monday... But I have the impression
the .htaccess file is not used! : /
Thank you

-- 
Thomas VEQUAUD  http://thomas.vequaud.free.fr/
Expert EPITECH en Ingénierie Informatique
Tél : +33(0)6.50.39.28.10  Fax: +33(0)9.58.46.10.07


[fw-general] zend_amf

2009-01-23 Thread Josh Team
Is there a services explorer out there for Zend_Amf, to test remote calls
via flash/flex like AMFPHP has/had?
If not, we'll prolly build one internally here.

Thanks,
Josh Team


Re: [fw-general] Best Practices: Eliminate redundancy within various controller init methods?

2009-01-23 Thread jasonzfw

Hi,

Many many thanks for the great set of responses. This helps to clarify
nicely. I've created a custom action helper, integrated it into the site,
and confirmed the framework is able to recognize and execute it. However
there remains one perplexing matter: how do I initialize this action helper
in a way that makes several of its variables automatically available to all
controllers? The idea is to completely remove all redundant code from the
various controllers' init() methods, thereby making the variables within the
controller available in each controller's $this context.

Based on your varied responses regarding the action helper, surely there's
some way to do this? The goal is to use this action helper to make the
following variables automatically available to all controllers:

$this-config = Zend_Registry::get('config');
$this-cache = Zend_Registry::get('cache');
$this-db = Zend_Registry::get('db');

Thanks for all of your help!
Jason




Ionut Gabriel Stan-2 wrote:
 
 On 1/8/2009 12:05, Rob Allen wrote:

 On 8 Jan 2009, at 09:26, Bart McLeod wrote:

 You can of course have a base custom controller, but you do not need to.

 Depending on what you need exactly you can use either an action helper
 in the init method or a plugin or both a plugin and an action helper.

 public function init(){
 $this-_helper-myInit(); //instead of your six lines of code
 }


 Actually, if you have a My_Controller_Action::init(), you don't need to
 define and init() at all in the child classes, whereas if you use a
 helper, you do need to define the init() in the controllers where you
 need the myInit().
 
 Depends on the place where you register the helper, because 
 HelperBroker::__construct() will call the init() method of all 
 registered helpers at the time Zend_Controller_Action is instantiated. 
 Then, the same HelperBroker will call the preDispatch() and 
 postDispatch() method of all helpers before and, respectively, after 
 Zend_Controller_Action::dispatch().
 
 There's a nice representation of this process here:
 
 http://surlandia.com/wp-content/uploads/2008/11/zf-dispatch-lifecycle-bw.jpg
 
 So, IMHO, a helper could be the solution, the only issue remaining might 
 be the place to register the helper and then what callback method to 
 use, init() or preDispatch().
 
 

 Regards,

 Rob...

 
 

-- 
View this message in context: 
http://www.nabble.com/Best-Practices%3A-Eliminate-redundancy-within-various-controller-init-methods--tp21341232p21631746.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Best Practices: Eliminate redundancy within various controller init methods?

2009-01-23 Thread Benjamin Eberlei
I would extend Zend_Controller_Action and make an application wide
action controller that has the init function which centralizes all the 
duplicated code.

btw, having the Database connection in the Controller is not best practice at 
all. You have to separate controllers and model, hence it being MVC not VC. I 
suggest a Service Layer between them or Model classes that have an public API 
that says nothing about Databases and stuff.

greetings,
Benjamin

On Friday 23 January 2009 21:08:14 jasonzfw wrote:
 Hi,

 Many many thanks for the great set of responses. This helps to clarify
 nicely. I've created a custom action helper, integrated it into the site,
 and confirmed the framework is able to recognize and execute it. However
 there remains one perplexing matter: how do I initialize this action helper
 in a way that makes several of its variables automatically available to all
 controllers? The idea is to completely remove all redundant code from the
 various controllers' init() methods, thereby making the variables within
 the controller available in each controller's $this context.

 Based on your varied responses regarding the action helper, surely there's
 some way to do this? The goal is to use this action helper to make the
 following variables automatically available to all controllers:

 $this-config = Zend_Registry::get('config');
 $this-cache = Zend_Registry::get('cache');
 $this-db = Zend_Registry::get('db');

 Thanks for all of your help!
 Jason

 Ionut Gabriel Stan-2 wrote:
  On 1/8/2009 12:05, Rob Allen wrote:
  On 8 Jan 2009, at 09:26, Bart McLeod wrote:
  You can of course have a base custom controller, but you do not need
  to.
 
  Depending on what you need exactly you can use either an action helper
  in the init method or a plugin or both a plugin and an action helper.
 
  public function init(){
  $this-_helper-myInit(); //instead of your six lines of code
  }
 
  Actually, if you have a My_Controller_Action::init(), you don't need to
  define and init() at all in the child classes, whereas if you use a
  helper, you do need to define the init() in the controllers where you
  need the myInit().
 
  Depends on the place where you register the helper, because
  HelperBroker::__construct() will call the init() method of all
  registered helpers at the time Zend_Controller_Action is instantiated.
  Then, the same HelperBroker will call the preDispatch() and
  postDispatch() method of all helpers before and, respectively, after
  Zend_Controller_Action::dispatch().
 
  There's a nice representation of this process here:
 
  http://surlandia.com/wp-content/uploads/2008/11/zf-dispatch-lifecycle-bw.
 jpg
 
  So, IMHO, a helper could be the solution, the only issue remaining might
  be the place to register the helper and then what callback method to
  use, init() or preDispatch().
 
  Regards,
 
  Rob...

-- 
Benjamin Eberlei
http://www.beberlei.de


Re: [fw-general] Best Practices: Eliminate redundancy within various controller init methods?

2009-01-23 Thread Matthew Weier O'Phinney
-- Benjamin Eberlei kont...@beberlei.de wrote
(on Friday, 23 January 2009, 09:35 PM +0100):
 I would extend Zend_Controller_Action and make an application wide
 action controller that has the init function which centralizes all the 
 duplicated code.

Umm... why not just create an action helper with an init() method, and
register it in the bootstrap... does the same thing, and ensures that
if you have multiple base action controllers floating around, they all
get the same behavior (and you really shouldn't be creating base
controllers now that we have action helpers...).

 btw, having the Database connection in the Controller is not best practice at 
 all. You have to separate controllers and model, hence it being MVC not VC. I 
 suggest a Service Layer between them or Model classes that have an public API 
 that says nothing about Databases and stuff.

Agreed on that one!


 On Friday 23 January 2009 21:08:14 jasonzfw wrote:
  Hi,
 
  Many many thanks for the great set of responses. This helps to clarify
  nicely. I've created a custom action helper, integrated it into the site,
  and confirmed the framework is able to recognize and execute it. However
  there remains one perplexing matter: how do I initialize this action helper
  in a way that makes several of its variables automatically available to all
  controllers? The idea is to completely remove all redundant code from the
  various controllers' init() methods, thereby making the variables within
  the controller available in each controller's $this context.
 
  Based on your varied responses regarding the action helper, surely there's
  some way to do this? The goal is to use this action helper to make the
  following variables automatically available to all controllers:
 
  $this-config = Zend_Registry::get('config');
  $this-cache = Zend_Registry::get('cache');
  $this-db = Zend_Registry::get('db');
 
  Thanks for all of your help!
  Jason
 
  Ionut Gabriel Stan-2 wrote:
   On 1/8/2009 12:05, Rob Allen wrote:
   On 8 Jan 2009, at 09:26, Bart McLeod wrote:
   You can of course have a base custom controller, but you do not need
   to.
  
   Depending on what you need exactly you can use either an action helper
   in the init method or a plugin or both a plugin and an action helper.
  
   public function init(){
   $this-_helper-myInit(); //instead of your six lines of code
   }
  
   Actually, if you have a My_Controller_Action::init(), you don't need to
   define and init() at all in the child classes, whereas if you use a
   helper, you do need to define the init() in the controllers where you
   need the myInit().
  
   Depends on the place where you register the helper, because
   HelperBroker::__construct() will call the init() method of all
   registered helpers at the time Zend_Controller_Action is instantiated.
   Then, the same HelperBroker will call the preDispatch() and
   postDispatch() method of all helpers before and, respectively, after
   Zend_Controller_Action::dispatch().
  
   There's a nice representation of this process here:
  
   http://surlandia.com/wp-content/uploads/2008/11/zf-dispatch-lifecycle-bw.
  jpg
  
   So, IMHO, a helper could be the solution, the only issue remaining might
   be the place to register the helper and then what callback method to
   use, init() or preDispatch().
  
   Regards,
  
   Rob...
 
 -- 
 Benjamin Eberlei
 http://www.beberlei.de
 

-- 
Matthew Weier O'Phinney
Software Architect   | matt...@zend.com
Zend Framework   | http://framework.zend.com/


RE: [fw-general] zend_amf

2009-01-23 Thread Wil Sinclair
Wade Arnold mentioned a services browser for AMFPHP in this post: 
http://wadearnold.com/blog/?p=112
That post is a must-read for all Zend_Amf and AMFPHP users, BTW. Executive 
summary: AMFPHP will be based on Zend_Amf going forward. :)

,Wil

From: Josh Team [mailto:josht...@gmail.com] 
Sent: Friday, January 23, 2009 11:06 AM
To: Zend Framework
Subject: [fw-general] zend_amf

Is there a services explorer out there for Zend_Amf, to test remote calls via 
flash/flex like AMFPHP has/had? 

If not, we'll prolly build one internally here.

Thanks,
Josh Team


[fw-general] making global view variables visible to view helpers

2009-01-23 Thread David Mintz
I have view variables that I want to be set in every view instance -- things
like paths to public resources. So I have been doing something stolen from
an example somewhere a long while ago:

$view = new Zend_View;
$view-web_root = Zend_Registry::get('siteConfig')-paths-web_root;
if (Zend_Auth::getInstance()-hasIdentity()) {
$view-user = Zend_Auth::getInstance()-getIdentity();
}
// etc
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
$viewRenderer-setView($view);
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);

These view vars are referenced in the layout and/or in the individual views,
and it's all good, except in the view helpers. Here,  $this-view can see
the variables that are set in the view instance by the controller action,
but not the ones that are set above in the bootstrap.

So -- what am I doing wrong, what's the best practice for setting app-wide
view variables?


Gratefully,

-- 
David Mintz
http://davidmintz.org/

The subtle source is clear and bright
The tributary streams flow through the darkness


Re: [fw-general] Best Practices: Eliminate redundancy within various controller init methods?

2009-01-23 Thread jasonzfw


beberlei wrote:
 
 I would extend Zend_Controller_Action and make an application wide
 action controller that has the init function which centralizes all the 
 duplicated code.
 

But I thought the purpose of using an action helper was to avoid exactly
this, as has been stated earlier in this thread? Extending the
Zend_Controller_Action is the easiest way to achieve this goal, but articles
such as 
http://devzone.zend.com/article/3350-Action-Helpers-in-Zend-Framework
http://devzone.zend.com/article/3350-Action-Helpers-in-Zend-Framework  state
this is not the appropriate approach.

Basically I'm under the impression I can call this action helper statically
within the bootstrap.php file, like so:

$initStuff =
Zend_Controller_Action_HelperBroker::getStaticHelper('InitializeStuff');

From there, it seems there should be some way to make certain variables
available in each controller's $this scope, perhaps using a callback within
the action helper. However this is the part of the puzzle that continues to
escape me.

Thank you!
Jason
-- 
View this message in context: 
http://www.nabble.com/Best-Practices%3A-Eliminate-redundancy-within-various-controller-init-methods--tp21341232p21632899.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] making global view variables visible to view helpers

2009-01-23 Thread Matthew Weier O'Phinney
-- David Mintz da...@davidmintz.org wrote
(on Friday, 23 January 2009, 04:14 PM -0500):
 I have view variables that I want to be set in every view instance -- things
 like paths to public resources. So I have been doing something stolen from an
 example somewhere a long while ago:
 
 $view = new Zend_View;
 $view-web_root = Zend_Registry::get('siteConfig')-paths-web_root;
 if (Zend_Auth::getInstance()-hasIdentity()) {
 $view-user = Zend_Auth::getInstance()-getIdentity();
 }
 // etc
 $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
 $viewRenderer-setView($view);
 Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);

Try changing the above three lines to this, and see if it makes any
difference:

$viewRenderer = 
Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')
$viewRenderer-setView($view);


 These view vars are referenced in the layout and/or in the individual views,
 and it's all good, except in the view helpers. Here,  $this-view can see the
 variables that are set in the view instance by the controller action, but not
 the ones that are set above in the bootstrap.
 
 So -- what am I doing wrong, what's the best practice for setting app-wide 
 view
 variables?

-- 
Matthew Weier O'Phinney
Software Architect   | matt...@zend.com
Zend Framework   | http://framework.zend.com/


Re: [fw-general] Best Practices: Eliminate redundancy within various controller init methods?

2009-01-23 Thread Matthew Weier O'Phinney
-- jasonzfw w...@wjgilmore.com wrote
(on Friday, 23 January 2009, 01:22 PM -0800):
 beberlei wrote:
  
  I would extend Zend_Controller_Action and make an application wide
  action controller that has the init function which centralizes all the 
  duplicated code.
  
 
 But I thought the purpose of using an action helper was to avoid exactly
 this, as has been stated earlier in this thread? Extending the
 Zend_Controller_Action is the easiest way to achieve this goal, but articles
 such as 
 http://devzone.zend.com/article/3350-Action-Helpers-in-Zend-Framework
 http://devzone.zend.com/article/3350-Action-Helpers-in-Zend-Framework  state
 this is not the appropriate approach.
 
 Basically I'm under the impression I can call this action helper statically
 within the bootstrap.php file, like so:
 
 $initStuff =
 Zend_Controller_Action_HelperBroker::getStaticHelper('InitializeStuff');
 
 From there, it seems there should be some way to make certain variables
 available in each controller's $this scope, perhaps using a callback within
 the action helper. However this is the part of the puzzle that continues to
 escape me.

Within your action helper's init() or preDispatch() method, do something
like this:

$controller = $this-getActionController();
$controller-foo = 'bar';

This will set the public 'foo' property of the current action controller
to the value 'bar'. We actually do this with the ViewRenderer to set the
'view' property.

-- 
Matthew Weier O'Phinney
Software Architect   | matt...@zend.com
Zend Framework   | http://framework.zend.com/


Re: [fw-general] Best Practices: Eliminate redundancy within various controller init methods?

2009-01-23 Thread jasonzfw


Matthew Weier O'Phinney-3 wrote:
 
 Within your action helper's init() or preDispatch() method, do something
 like this:
 
 $controller = $this-getActionController();
 $controller-foo = 'bar';
 

YES!! Works like a charm. :-) :-) :-)

Thanks so much, I really appreciate everybody's help!

Jason
-- 
View this message in context: 
http://www.nabble.com/Best-Practices%3A-Eliminate-redundancy-within-various-controller-init-methods--tp21341232p21633228.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Amf ZF-5094 and ZF-5388

2009-01-23 Thread Tobias Gies
Hi folks,

I merged the patch. Dirk, please run your testcase for ZF-5094 against
a current checkout of the release-1.7 branch.

Best regards,
Tobias

2009/1/23 Wade Arnold wade.arn...@t8design.com:
 Please merge the patch.
 Not sure what I did wrong that it did not get into 1.7.3. ?


Re: [fw-general] making global view variables visible to view helpers

2009-01-23 Thread David Mintz
On Fri, Jan 23, 2009 at 4:36 PM, Matthew Weier O'Phinney
matt...@zend.comwrote:

 -- David Mintz da...@davidmintz.org wrote
 (on Friday, 23 January 2009, 04:14 PM -0500):
  I have view variables that I want to be set in every view instance --
 things
  like paths to public resources. So I have been doing something stolen
 from an
  example somewhere a long while ago:
 
  $view = new Zend_View;
  $view-web_root = Zend_Registry::get('siteConfig')-paths-web_root;
  if (Zend_Auth::getInstance()-hasIdentity()) {
  $view-user = Zend_Auth::getInstance()-getIdentity();
  }
  // etc
  $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
  $viewRenderer-setView($view);
  Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);

 Try changing the above three lines to this, and see if it makes any
 difference:

$viewRenderer =
 Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')
$viewRenderer-setView($view);



Same story. e.g., I stick this stdClass $user object in the view in my
bootstrap, and can dump it in the view, but the helper doesn't see it. How
do people deal with this? It's got to be a common scenario. I suppose I
could pass whatever to the helper as args to the helper call.

Would it make a difference if I set these view vars in a plugin? Hmm I think
I'll try and see for myself...



-- 
David Mintz
http://davidmintz.org/

The subtle source is clear and bright
The tributary streams flow through the darkness


[fw-general] assigning variables inside the layout.phtml file

2009-01-23 Thread jamilhassanspain

I have some variables in my config.ini file that will be used to set content
in some places in the layout.phtml ( this is the main template file that the
website loads from ) .. 

These are places in the layout.phtml file like:

a) page title
b) and other contants in javascript inline scripts.. 

I'm asking what is the best way to do this.. 

I realize one way is to put code in the init() function of the controller
that will assign the Zend_Registry values to
$this-view-layout()-#variablename# = value;

Is there any other way to do this with helper and if so, how can I set that
up.. 

Let me know..

Thanks

Jamil
-- 
View this message in context: 
http://www.nabble.com/assigning-variables-inside-the-layout.phtml-file-tp21633607p21633607.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] making global view variables visible to view helpers

2009-01-23 Thread Matthew Weier O'Phinney
-- David Mintz vtbludg...@gmail.com wrote
(on Friday, 23 January 2009, 05:06 PM -0500):
 
 
 On Fri, Jan 23, 2009 at 4:36 PM, Matthew Weier O'Phinney matt...@zend.com
 wrote:
 
 -- David Mintz da...@davidmintz.org wrote
 (on Friday, 23 January 2009, 04:14 PM -0500):
  I have view variables that I want to be set in every view instance --
 things
  like paths to public resources. So I have been doing something stolen
 from an
  example somewhere a long while ago:
 
  $view = new Zend_View;
  $view-web_root = Zend_Registry::get('siteConfig')-paths-web_root;
  if (Zend_Auth::getInstance()-hasIdentity()) {
  $view-user = Zend_Auth::getInstance()-getIdentity();
  }
  // etc
  $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
  $viewRenderer-setView($view);
  Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
 
 Try changing the above three lines to this, and see if it makes any
 difference:
 
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper
 ('viewRenderer')
$viewRenderer-setView($view);
 
 
 
 Same story. e.g., I stick this stdClass $user object in the view in my
 bootstrap, and can dump it in the view, but the helper doesn't see it. How do
 people deal with this? It's got to be a common scenario. I suppose I could 
 pass
 whatever to the helper as args to the helper call.
 
 Would it make a difference if I set these view vars in a plugin? Hmm I think
 I'll try and see for myself...

Shouldn't make a difference. The other possibility is that it's an issue
in your helper. Are you extending Zend_View_Helper_Abstract? That class
provides a setView() implementation, which will ensure that $this-view
is available in your helper.

-- 
Matthew Weier O'Phinney
Software Architect   | matt...@zend.com
Zend Framework   | http://framework.zend.com/


RE: [fw-general] assigning variables inside the layout.phtml file

2009-01-23 Thread Terre Porter

 $this-view-layout()-#variablename# = value;

This didn't work for me from an action controller.

Here is what I ended up using a mixture of. I don't know if these are the
best ways but I found them useful.

You can use this in your view template:

$this-headTitle('New Zend Framework Project');
Or 
$this-headTitle($this-controllerSetVarHere);

Then in your layout template.

echo $this-headTitle();

The only downfall is that you have to have a view template. Or at least I
have not found a direct way to set them on the layout template.

You can also set template vars directly to the layout template from your
action controller, like this :

// assign var directly to layout template 
// ( - requires small adjustment to zend/layout.php -
http://framework.zend.com/issues/browse/ZF-4895)
Zend_Layout::getMvcInstance()-assign('varname', 'varvalue');

Then its simply a $this-varname in your layout template.

Some other useful layout functions :

-- disableLayout:

For when you don't want any layout template but would want the view rendered
only.

// disable layout
Zend_Layout::getMvcInstance()-disableLayout();

-- setLayout:

Change the layout template, I used this when I have special layouts that are
not the default layout.

// change layout file
Zend_Layout::getMvcInstance()-setLayout('404_base_page');

-- setLayoutPath:

Used this to make a subdirectory file system for the layout templates. But
now I use less templates so not using anymore but still useful.

// change layout path
Zend_Layout::getMvcInstance()-setLayoutPath('new/path/to/layout);

Hope those help.

I'm using all these, except the setLayoutPath, on
http://e-edition.tbnweekly.com

Hope that helps some.

Terre
 



Re: [fw-general] assigning variables inside the layout.phtml file

2009-01-23 Thread PHPScriptor

I don't know if this is 100% correct... I made this once so...

1. in your view setup you give the path to find the helpers:

class My_Controller_Plugin_ViewSetup extends Zend_Controller_Plugin_Abstract
{
$viewRenderer =
Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
$viewRenderer-init();
$view = $viewRenderer-view;

$dir = dirname(__FILE__) . '/../../../../app/views/helpers'; // path
to the main view helpers
$view-addHelperPath($dir);
}

2. builder your helpers eg:

class Zend_View_Helper_GiveMeThis
{
function GiveItToMe()
{
 return bla bla bla;
}
}

3. in your layout.phtml

?php echo $this-GiveItToMe(); ?



jamilhassanspain wrote:
 
 I have some variables in my config.ini file that will be used to set
 content in some places in the layout.phtml ( this is the main template
 file that the website loads from ) .. 
 
 These are places in the layout.phtml file like:
 
 a) page title
 b) and other contants in javascript inline scripts.. 
 
 I'm asking what is the best way to do this.. 
 
 I realize one way is to put code in the init() function of the controller
 that will assign the Zend_Registry values to
 $this-view-layout()-#variablename# = value;
 
 Is there any other way to do this with helper and if so, how can I set
 that up.. 
 
 Let me know..
 
 Thanks
 
 Jamil
 


-
visit my website at  http://www.phpscriptor.com/ http://www.phpscriptor.com/ 
-- 
View this message in context: 
http://www.nabble.com/assigning-variables-inside-the-layout.phtml-file-tp21633607p21634130.html
Sent from the Zend Framework mailing list archive at Nabble.com.