2008年11月30日星期日

Re: [fw-mvc] Layout Requests

Sorry if anyone is offended about digging this up from the grave.

I have a concern about making actions for this type of functionality.
Correct me if I am wrong but to me the idea of an action is used for
generating the request response not returning some sort of response to other
controller action.

On top of the logical problems you end up with an action that is accessible
through your url parameters.

In the most generalized case such as a navigation would using a standalone
navigation helper be the best practice?


Thank you!

Matthew Weier O'Phinney-3 wrote:
>
> -- Anders Fredriksson <anders@tablefinder.com> wrote
> (on Saturday, 08 March 2008, 04:22 PM +0100):
>> On Mar 8, 2008, at 12:08 PM, Nick Lo wrote:
>>
>> >
>> > On 08/03/2008, at 9:08 PM, Anders Fredriksson wrote:
>> >
>> > > What I want to have done is the following:
>> > >
>> > > I have a default layout which has sections (placeholders) header,
>> > > content, and footer. Fairly common I would say. :)
>> > >
>> > > in my header templates I might want to do different stuff depending
>> on
>> > > what controller I'm in or what action is made.
>> > >
>> > > With the old Layout_Request it was very easy to make a call to a
>> specific
>> > > action in a controller and to render it to the appropriate
>> placeholder.
>> >
>> > ...
>> >
>> > > This solution works, but is in my opinion very ugly. So I'm all for
>> > > suggestions on how to do this in a nice way from controllers, ie not
>> from
>> > > the viewscripts.
>> >
>> > I'm not completely clear what you're looking for as I didn't use Layout
>> > Requests but from your comments above I wonder if you've tried direct
>> > action calls:
>> >
>> > <?php echo $this->action('right-navigation', 'layout', null,
>> > array('right-nav' => $this->rightNav)); ?>
>> >
>> > I was using this one to do pretty well what you describe above though
>> for
>> > a right hand navigation. That call is in the layout script but the
>> logic
>> > is in a LayoutController::rightNavigationAction()
>> >
>> > I cannot remember where this is documented otherwise I'd point to it
>> for
>> > more info.
>> >
>> > Nick
>> >
>> >
>>
>>
>> I'm not sure how I can make this more clear. The solution you suggest
>> would
>> not do it because that line would have to be in the default layout
>> template, which will always be the same for all actions,
>
> You *can* change the layout on the fly from within a view script or a
> controller action:
>
> // within controller action:
> $this->_helper->layout()->setLayout(...);
>
> // within a view script:
> $this->layout()->setLayout(...);
>
> If you have several distinct layouts for your site, this is a really
> good technique.
>
>> and I want to be able to make calls to render certain actions into
>> certain placeholders on the fly. And if I make such a call from a
>> controller it would automatically redirect to that controller.
>
> You don't understand how the action() helper works, methinks. It doesn't
> redirect to that controller, it simply takes the rendered content of
> that action and returns it:
>
> $content = $view->action('right-navigation', 'layout', null,
> array('right-nav' = $rightNav));
>
> This can be called from a view script, or within your controller, etc.
> Now, if you want to capture it into a placeholder, that's pretty simple
> as well:
>
> // in a controller action:
>
> $this->view->placeholder('right-navigation')->append($this->view->action(...));
>
> // within a view script:
> $this->placeholder('right-navigation')->append($this->action(...));
>
> You can use placeholders within your layout view scripts as well -- you
> don't have to rely on the layout segments. They act basically like view
> variables -- if they have nothing in them, nothing is echoed:
>
> // within layout script:
> echo $this->placeholder('right-navigation');
>
> Looking at what you've done below, I can't help but think you're
> over-complicating it, but I don't have the time to try and write up an
> alternative solution for you. Look at my above examples and see if you
> can find an alternative that may be simpler using them.
>
>> but to give a more concrete example (be prepared for the longest mail
>> I've
>> written below) :)
>>
>> my setup:
>>
>> applications/
>> default/
>> controllers/
>> IndexController.php
>> OtherController.php
>> models/
>> Example.php
>> views/
>> layouts/
>> default.tpl
>> scripts/
>> getheader.tpl
>> index/
>> index.tpl
>> sidebar.tpl
>> other/
>> index.tpl
>> foo.tpl
>> sidebar.tpl
>> lib/
>> EZ/
>> Controller/
>> Action.php
>> Layout/
>> Request.php
>> View/
>> Smarty.php
>> public_html/
>> index.php
>>
>>
>> Action.php
>>
>> class EZ_Controller_Action extends Zend_Controller_Action {
>> ...
>> public function init() {
>> ...
>> //Check if this is a layoutRequest. if it is change the response
>> segment
>> so that the result vill render
>> //into a variable named the value of the param EZ_Layout_Request
>> //This is a bit of an ugly solution but necessary since the
>> requestobject's type get lost
>> if ($this->getRequest()->has ( "EZ_Layout_Request" )) {
>> $this->isLayoutRequest = true;
>> $this->_helper->viewRenderer->setResponseSegment (
>> $this->requestObj->getParam ( "EZ_Layout_Request" ) );
>> }
>>
>> //Set default layout template
>> $this->_helper->layout ()->setLayout ('default');
>> }
>>
>> public function preDispatch() {
>> ...
>> if (! ($this->isLayoutRequest === true)) {
>> $layoutRequestHeader = new EZ_Layout_Request ( 'header', 'getheader'
>> );
>> $this->_helper->getHelper ( 'ActionStack' )->pushStack (
>> $layoutRequestHeader );
>> }
>> ...
>> }
>>
>> public function getheaderAction() {
>> if ($this->isLayoutRequest) {
>> $this->view->headline = $this->getHeadline ();
>> $this->view->HeadTitle ( "Example.com - " . $this->view->headline );
>> ...
>> $this->_helper->getStaticHelper ( 'viewRenderer' )->setNoController (
>> true );
>> $this->view->render ( 'getheader.tpl' );
>> } else {
>> $this->_redirect ( "/" );
>> }
>> }
>>
>> ... //other helperfunctions
>> }
>>
>> --------------------->IndexController.php
>>
>> class IndexController extends EZ_Controller_Action {
>> ...
>> public function indexAction() {
>> //do some specific stuff
>> $sidebarLayoutRequest = new EZ_Layout_Request('sidebar','sidebar');
>>
>> $this->_helper->getStaticHelper('ActionStack')->pushStack($sidebarLayoutRequest);
>> $this->view->foo = bar;
>> }
>>
>> public function sidebarAction() {
>> $this->view->someVar = new Example();
>> }
>> ...
>> }
>>
>> -------------------------->OtherController.php
>>
>> class OtherController extends EZ_Controller_Action {
>> public function indexAction() {
>> //do some other stuff
>> $sidebarLayoutRequest = new EZ_Layout_Request('sidebar','sidebar');
>>
>> $this->_helper->getStaticHelper('ActionStack')->pushStack($sidebarLayoutRequest);
>> $this->view->bar = 'foo';
>> }
>>
>> public function fooAction() {
>> //do some specific stuff
>> $sidebarLayoutRequest = new
>> EZ_Layout_Request('sidebar','sidebar','Index'); //have the index sidebar
>> instead
>>
>> $this->_helper->getStaticHelper('ActionStack')->pushStack($sidebarLayoutRequest);
>> }
>>
>> public function sidebarAction() {
>> $this->view->someOtherVar = new Example();
>> }
>>
>> }
>>
>> -------------------------------->default.tpl
>>
>> {$this->doctype()}
>> <html xmlns='http://www.w3.org/1999/xhtml' xml:lang="en" lang="en">
>> <head>
>> {$this->headTitle}
>> {$this->headScript()}
>> {$this->headLink()}
>> {$this->headStyle()}
>> {$this->headMeta()}
>> </head>
>> <body>
>> <div id="doc">
>> <div id="hd" class="header"> {layout section="header"}</div>
>> <div id="bd">
>> <div id="yui-main" class="png">
>> <div id="content" class="yui-g">
>> <!-- YOUR DATA GOES HERE -->
>> {layout section="content"}
>> </div>
>> <div class="yui-u">
>> {layout section="sidebar"}
>> </div>
>> </div>
>> </div>
>> <div id="ft"> {layout section="footer"}</div>
>> </div>
>> </body>
>> </html>
>>
>> ------------------------>index.tpl
>>
>> <p> I really would like some {$foo} now</p>
>>
>> ------------------------>index/sidebar.tpl
>> <h2> IndexSidebarTitle</h2>
>> <p> {$someVar}</p>
>>
>> ------------------------>other/sidebar.tpl
>> <h2> OtherSidebarTitle</h2>
>> <p> {$someOtherVar}</p>
>>
>> -------------------------->Request.php
>> class EZ_Layout_Request extends Zend_Controller_Request_Http {
>> /**
>> * $_nameKey
>> *
>> * @var string
>> */
>> protected $_nameKey = "EZ_Layout_Request";
>>
>> /**
>> * __construct()
>> *
>> * @param string $name
>> * @param string $action
>> * @param string $controller
>> * @param string $module
>> * @param array $params
>> */
>> public function __construct($name=null,$action=null,
>> $controller=null,
>> $module=null,$uri = null) {
>> if($name !== null) $this->setName($name);
>> if($action !== null) $this->setActionName($action);
>> if($controller !== null) $this->setControllerName($controller);
>> if($module !== null) $this->setModuleName($module);
>> parent::__construct($uri);
>> }
>>
>> /**
>> * setName() - This is the layout variable name that will be used
>> when
>> rendering
>> *
>> * @param string $name
>> * @return Zend_Layout_Request
>> */
>> public function setName($name)
>> {
>> $this->setParam($this->_nameKey,$name);
>> return $this;
>> }
>>
>> /**
>> * getName()
>> *
>> * @return string
>> */
>> public function getName()
>> {
>> return $this->getParam($this->_nameKey);
>> }
>>
>> /**
>> * setNameKey()
>> *
>> * @param String $key
>> */
>> public function setNameKey($key = "EZ_Layout_Request") {
>> $this->_nameKey = $key;
>> }
>> }
>> ------------------------------------------------------------------
>>
>> If I have any readers still with me down here, I want to say that this
>> setup is by far optimal, as I always have to check so that stuff that is
>> layoutrequests doesn't add scripts and other stuff more than once.
>>
>> What I want to achieve is to have the exact same functionality that Ralph
>> had in his Xend_Layout, which was the original for the Zend_Layout, but I
>> don't know how to do that just yet.
>>
>> I'm just really surprised that no one else is missing this functionality
>> as
>> it would be very good to have. it would basically mean that all of your
>> actions in all controllers could be treated as separately renderable
>> modules, that you could build up a page from very dynamically.
>>
>> Thanks to anyone who will answer this long post. :)
>>
>> Best,
>>
>> //Anders Fredriksson
>>
>>
>
> --
> Matthew Weier O'Phinney
> PHP Developer | matthew@zend.com
> Zend - The PHP Company | http://www.zend.com/
>
>

--
View this message in context: http://www.nabble.com/Layout-Requests-tp15913170p20766775.html
Sent from the Zend MVC mailing list archive at Nabble.com.

Re: [fw-mvc] zend_dojo DateTextBox (invalid message translation)

-- dnul <nxdiego@gmail.com> wrote
(on Saturday, 29 November 2008, 06:46 PM -0800):
>
> Hi , im using a Zend_Dojo_Form_Element_DateTextBox for choosing dates.
> I need to Localize the error message displayed when an invalid date is
> entered.
>
> I'm Using zend_translate (like this: $view->translate('tag') )
>
> setInvalidMessage sets a custom error message , but i dont know how to make
> zend_dojo translate this message as zend_validator does. Any thoughts?

I did not put translator support into the dijits for the reason that you
typically will do tooltip translations on the client-side, not server
side. Dojo has rich i18n capabilities, and dijit utilizes these. I'd
look into how to provide translations via Dojo for this.

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

Re: [fw-mvc] View helpers bug ?

-- Michael Depetrillo <klassicd@gmail.com> wrote
(on Sunday, 30 November 2008, 12:35 AM -0800):
> Zend_View_Helper_Partial uses a cloned version of the view object which is
> destroyed after the partial is rendered. This makes the layout helper useless
> in partials because the view has a private scope.

This is not entirely true. The layout helper always references the same
layout object (singleton). Additionally, the various placeholder helpers
utilize a registry in order to persist. The fact that the view object is
not the same should not be an issue.

We've been working on solving this issue, and I thought we had it solved
for 1.7.0. If this is not the case, I'd like the OP to file a bug report
with reproduce code so we can figure it out.


> On Fri, Nov 28, 2008 at 11:14 AM, Zladivliba Voskuy <nospampam@hotmail.fr>
> wrote:
>
> Thanks Matthew for your replies, but I really think this is a view helper
> bug.
>
>
> > > Here's what's not working :
> > > class Zend_View_Helper_Loginbox extends Zend_View_Helper_Partial{
> > > public function loginbox() {
> > > // this doesn't work, the file never gets included
> > > $this->view->headScript()->appendFile('/scripts/js/myfile.js');
> >
> > What version of ZF are you using? I *believe* the issue with
> > placeholders being populated from partials was fixed for either 1.6.0 or
> > 1.7.0.
>
> I used 1.6.0 I updated to 1.7.0 after your message, I have the exact same
> error.
>
>
> > You *do* know that you have to echo the headScript() view helper from
> > your layout file, right?
>
> "echo $this->headScript(); " is what I use on my layout file.
> Now as far as I remember I've been using this piece of code of my
> application, it works fine, except when I use it in a view helper ; this is
> the reason I'm re-posting this.
>
>
> > > // neigher the content of my javascript function after this !!!
> > > $this->view->dojo()->javascriptCaptureStart();
> > > ?>
> > >
> > > dojo.addOnLoad(function(){
> > > alert("it s not working");
> > > });
> > >
> > > <? $this->view->dojo()->javascriptCaptureEnd(); ?>
> >
> > Same goes for the dojo() view helper -- you have to echo it from your
> > layout file.
>
> echo $this->dojo(); is what I have on my layout file. Now everything piece
> of dojo code I have on my application works fine, except when I put it on a
> view helper.
>
> Is there anywhere else I can try to look to solve this thing ?
>
>
> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
> Appelez vos amis de PC à PC -- C'EST GRATUIT Téléchargez Messenger, c'est
> gratuit !
>
>

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

RE: [fw-mvc] zend_dojo DateTextBox (invalid message translation)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tmx SYSTEM "http://www.lisa.org/standards/tmx/tmx14.dtd">
<tmx version="1.4">
<header creationtoolversion="1.0.0" datatype="winres"
segtype="sentence" adminlang="en-us" srclang="cs-cz" o-tmf="abc"
creationtool="by Hand ;)">
</header>
<body>
<!-- Zend_Framework Messages -->
<!-- Validators -->

<!-- Ean13.php -->
<tu tuid='invalid'>
<tuv xml:lang="cs">
<seg>'%value%' není platný EAN13 čárový kód</seg>
</tuv>
</tu>
<tu tuid='invalidLength'>
<tuv xml:lang="cs">
<seg>'%value%' má být dlouhá 13 znaků</seg>
</tuv>
</tu>

<!-- AlNum.php -->
<tu tuid='notAlnum'>
<tuv xml:lang="cs">
<seg>'%value%' obsahuje jiné znaky než písmena a číslice</seg>
</tuv>
</tu>
<tu tuid='stringEmpty'>
<tuv xml:lang="cs">
<seg>'%value%' je prázdný řetězec</seg>
</tuv>
</tu>
<!-- Alpha.php -->
<tu tuid='notAlpha'>
<tuv xml:lang="cs">
<seg>'%value%' se skládá z jiných znaků než písmen</seg>
</tuv>
</tu>
<!-- stringEmpty s.o. -->

<!-- Between -->
<tu tuid='notBetween'>
<tuv xml:lang="cs">
<seg>'%value%' musí ležet mezi '%min%' a '%max%'</seg>
</tuv>
</tu>
<tu tuid='notBetweenStrict'>
<tuv xml:lang="cs">
<seg>'%value%' musí nutně ležet mezi '%min%' a '%max%'</seg>
</tuv>
</tu>
<!-- Ccnum.php -->
<tu tuid='ccnumLength'>
<tuv xml:lang="cs">
<seg>'%value%' musí být složena z 13 až 19 znaků</seg>
</tuv>
</tu>
<tu tuid='ccnumChecksum'>
<tuv xml:lang="cs">
<seg>Luhnův algoritmus (kontrolní součet mod-10) selhal na hodnotě '%value%'</seg>
</tuv>
</tu>
<!-- Date.php -->
<tu tuid='dateNotYYYY-MM-DD'>
<tuv xml:lang="cs">
<seg>'%value%' není datum ve formátu YYYY-MM-DD</seg>
</tuv>
</tu>
<tu tuid='dateInvalid'>
<tuv xml:lang="cs">
<seg>'%value%' není platné datum</seg>
</tuv>
</tu>
<tu tuid='dateFalseFormat'>
<tuv xml:lang="cs">
<seg>'%value%' neodpovídá danému formátu</seg>
</tuv>
</tu>
<!-- Digits.php -->
<tu tuid='notDigits'>
<tuv xml:lang="cs">
<seg>'%value%' obsahuje jiné znaky než číslice</seg>
</tuv>
</tu>
<!-- stringEmpty s.o. -->

<!-- EmailAddress.php -->
<tu tuid='emailAddressInvalid'>
<tuv xml:lang="cs">
<seg>'%value%' není platný e-mail ve formátu jmeno@domena"</seg>
</tuv>
</tu>
<tu tuid='emailAddressInvalidHostname'>
<tuv xml:lang="cs">
<seg>'%hostname%' není platné hostname pro e-mailovou adresu '%value%'</seg>
</tuv>
</tu>
<tu tuid='emailAddressInvalidMxRecord'>
<tuv xml:lang="cs">
<seg>'%hostname%' není platným MX záznamem pro e-mailovou adresu '%value%'</seg>
</tuv>
</tu>
<tu tuid='emailAddressDotAtom'>
<tuv xml:lang="cs">
<seg>'%localPart%' neodpovídá dot-Atom formátu</seg>
</tuv>
</tu>
<tu tuid='emailAddressQuotedString'>
<tuv xml:lang="cs">
<seg>'%localPart%' neodpovídá Quoted-String formátu</seg>
</tuv>
</tu>
<tu tuid='emailAddressInvalidLocalPart'>
<tuv xml:lang="cs">
<seg>'%localPart%' není platnou lokální částí e-mailové adresy '%value%'</seg>
</tuv>
</tu>
<!-- Float.php -->
<tu tuid='notFloat'>
<tuv xml:lang="cs">
<seg>'%value%' není racionální číslo (číslo s desetinnou čárkou)</seg>
</tuv>
</tu>
<!-- GreaterThan.php -->
<tu tuid='notGreaterThan'>
<tuv xml:lang="cs">
<seg>'%value%' není větší než '%min%'</seg>
</tuv>
</tu>

<!-- Hex.php -->
<tu tuid='notHex'>
<tuv xml:lang="cs">
<seg>'%value%' obsahuje jiné než hexadecimální číslice</seg>
</tuv>
</tu>

<!-- Hostname.php -->
<tu tuid='hostnameIpAddressNotAllowed'>
<tuv xml:lang="cs">
<seg>'%value%' není povolená IP adresa</seg>
</tuv>
</tu>
<tu tuid='hostnameUnknownTld'>
<tuv xml:lang="cs">
<seg>'%value%' není známá TLD</seg>
</tuv>
</tu>
<tu tuid='hostnameDashCharacter'>
<tuv xml:lang="cs">
<seg>'%value%' obsahuje pomlčku na zakázaném místě</seg>
</tuv>
</tu>
<tu tuid='hostnameInvalidHostnameSchema'>
<tuv xml:lang="cs">
<seg>'%value%' není platným DNS záznamem pro TLD '%tld%'</seg>
</tuv>
</tu>
<tu tuid='hostnameUndecipherableTld'>
<tuv xml:lang="cs">
<seg>'%value%' neobsahuje platnou TLD</seg>
</tuv>
</tu>
<tu tuid='hostnameInvalidHostname'>
<tuv xml:lang="cs">
<seg>'%value%' není platným hostname</seg>
</tuv>
</tu>
<tu tuid='hostnameInvalidLocalName'>
<tuv xml:lang="cs">
<seg>'%value%' není platným názvem umístění v lokální síti</seg>
</tuv>
</tu>
<tu tuid='hostnameLocalNameNotAllowed'>
<tuv xml:lang="cs">
<seg>'%value%' není povoleným umístěním v lokální síti</seg>
</tuv>
</tu>
<!-- Identical.php -->
<tu tuid='notSame'>
<tuv xml:lang="cs">
<seg>Řetězce si neodpovídají</seg>
</tuv>
</tu>
<tu tuid='missingToken'>
<tuv xml:lang="cs">
<seg>Chybějící znaky</seg>
</tuv>
</tu>
<!-- InArray.php -->
<tu tuid='notInArray'>
<tuv xml:lang="cs">
<seg>hodnota '%value%' nebyla v poli nalezena</seg>
</tuv>
</tu>
<!-- Int.php -->
<tu tuid='notInt'>
<tuv xml:lang="cs">
<seg>'%value%' není platné číslo</seg>
</tuv>
</tu>
<!-- Ip.php -->
<tu tuid='notIpAddress'>
<tuv xml:lang="cs">
<seg>'%value%' není platnou IP adresou</seg>
</tuv>
</tu>
<!-- LessThan.php -->
<tu tuid='notLessThan'>
<tuv xml:lang="cs">
<seg>'%value%' není menší než '%max%'</seg>
</tuv>
</tu>
<!-- NotEmpty.php -->
<tu tuid='isEmpty'>
<tuv xml:lang="cs">
<seg>Pole je prázdné. Musíte jej vyplnit</seg>
</tuv>
</tu>

<!-- StringLength.php -->
<tu tuid='stringLengthTooShort'>
<tuv xml:lang="cs">
<seg>'%value%' je kratší než %min% znaků</seg>
</tuv>
</tu>
<tu tuid='stringLengthTooLong'>
<tuv xml:lang="cs">
<seg>'%value%' je delší než %max% znaků</seg>
</tuv>
</tu>

<!-- RegEx -->
<tu tuid='regexNotMatch'>
<tuv xml:lang="cs">
<seg>'%value%' neodpovídá masce '%pattern%'</seg>
</tuv>
</tu>

</body>
</tmx>Hi,

try

$translator = new Zend_Translate(
'Zend_Translate_Adapter_Tmx',
/path/to/CzechValidatorsStrings.xml',
'cs'
);
$form->setTranslator($translator);

The example file is attached.


Jiri

-----Original Message-----
From: dnul [mailto:nxdiego@gmail.com]
Sent: Sunday, November 30, 2008 3:46 AM
To: fw-mvc@lists.zend.com
Subject: [fw-mvc] zend_dojo DateTextBox (invalid message translation)


Hi , im using a Zend_Dojo_Form_Element_DateTextBox for choosing dates.
I need to Localize the error message displayed when an invalid date is
entered.

I'm Using zend_translate (like this: $view->translate('tag') )

setInvalidMessage sets a custom error message , but i dont know how to make
zend_dojo translate this message as zend_validator does. Any thoughts?


thx

--
View this message in context:
http://www.nabble.com/zend_dojo-DateTextBox-%28invalid-message-translation%2
9-tp20754038p20754038.html

Sent from the Zend MVC mailing list archive at Nabble.com.

Re: [fw-mvc] View helpers bug ?

Zend_View_Helper_Partial uses a cloned version of the view object which is destroyed after the partial is rendered.  This makes the layout helper useless in partials because the view has a private scope.  

Michael DePetrillo
theman@michaeldepetrillo.com
Mobile: (858) 761-1605


On Fri, Nov 28, 2008 at 11:14 AM, Zladivliba Voskuy <nospampam@hotmail.fr> wrote:
Thanks Matthew for your replies, but I really think this is a view helper bug.


> > Here's what's not working :
> > class Zend_View_Helper_Loginbox extends Zend_View_Helper_Partial{
> > public function loginbox() {
> > // this doesn't work, the file never gets included
> > $this->view->headScript()->appendFile('/scripts/js/myfile.js');
>
> What version of ZF are you using? I *believe* the issue with
> placeholders being populated from partials was fixed for either 1.6.0 or
> 1.7.0.

I used 1.6.0 I updated to 1.7.0 after your message, I have the exact same error.


> You *do* know that you have to echo the headScript() view helper from
> your layout file, right?

"echo $this->headScript(); " is what I use on my layout file.
Now as far as I remember I've been using this piece of code of my application, it works fine, except when I use it in a view helper ; this is the reason I'm re-posting this.


> > // neigher the content of my javascript function after this !!!
> > $this->view->dojo()->javascriptCaptureStart();
> > ?>
> >
> > dojo.addOnLoad(function(){
> > alert("it s not working");
> > });
> >
> > <? $this->view->dojo()->javascriptCaptureEnd(); ?>
>
> Same goes for the dojo() view helper -- you have to echo it from your
> layout file.

echo $this->dojo(); is what I have on my layout file. Now everything piece of dojo code I have on my application works fine, except when I put it on a view helper.

Is there anywhere else I can try to look to solve this thing ?



Appelez vos amis de PC à PC -- C'EST GRATUIT Téléchargez Messenger, c'est gratuit !

2008年11月29日星期六

[fw-mvc] zend_dojo DateTextBox (invalid message translation)

Hi , im using a Zend_Dojo_Form_Element_DateTextBox for choosing dates.
I need to Localize the error message displayed when an invalid date is
entered.

I'm Using zend_translate (like this: $view->translate('tag') )

setInvalidMessage sets a custom error message , but i dont know how to make
zend_dojo translate this message as zend_validator does. Any thoughts?


thx

--
View this message in context: http://www.nabble.com/zend_dojo-DateTextBox-%28invalid-message-translation%29-tp20754038p20754038.html
Sent from the Zend MVC mailing list archive at Nabble.com.

Re: [fw-core] head style problem

Brandon Peacey wrote:
>
> Hello
> Hi, I think what you're looking for is headLink(),
> http://framework.zend.com/manual/en/zend.view.helpers.html#zend.view.helpers.initial.headlink
>
> In the reference guide:
>
> "Use HeadLink to link CSS files
>
> HeadLink should be used to create <link> elements for including external
> stylesheets. HeadScript is used when you wish to define your stylesheets
> inline. " -
> http://framework.zend.com/manual/en/zend.view.helpers.html#zend.view.helpers.initial.headstyle
>
>
> I'm having a problem with headStyle method; every time I try to prepend a
> style ( or append a style for that matter ) it will comment out my style
> sheet directory. Here is an example.
>
>
>
> $view->headStyle()->prependStyle('public/styles/main.css')
>
>
>
> Output:
>
>
>
> <style type="text/css" media="screen">
> <!--
> public/styles/main.css
> -->
> </style>
>
>
>
> Can anyone explain to me why this behavior is occurring?
>
> Thank you for your time.
>
>
>

--
View this message in context: http://www.nabble.com/head-style-problem-tp20748333p20749023.html
Sent from the Zend Core mailing list archive at Nabble.com.

Re: [fw-core] head style problem

you are using the wrong method use headLink instead, headStyle is used
for inline styles.

Heres what I use:

// set css links and a special import for the accessibility styles
$this->_view->headStyle()->setStyle('@import "/css/access.css";');
$this->_view->headLink()->appendStylesheet('/css/reset.css');

2008/11/29 Brandon Peacey <CodeSoftware@cox.net>:
> Hello
>
>
>
> I'm having a problem with headStyle method; every time I try to prepend a
> style ( or append a style for that matter ) it will comment out my style
> sheet directory. Here is an example.
>
>
>
> $view->headStyle()->prependStyle('public/styles/main.css')
>
>
>
> Output:
>
>
>
> <style type="text/css" media="screen">
>
> <!--
>
> public/styles/main.css
>
> -->
>
> </style>
>
>
>
> Can anyone explain to me why this behavior is occurring?
>
> Thank you for your time.

--
----------------------------------------------------------------------
[MuTe]
----------------------------------------------------------------------

[fw-core] head style problem

Hello

 

I’m having a problem with headStyle method; every time I try to prepend a style ( or append a style for that matter ) it will comment out my style sheet directory. Here is an example.

 

$view->headStyle()->prependStyle(‘public/styles/main.css’)

 

Output:

 

<style type="text/css" media="screen">
<!--
public/styles/main.css
-->
</style>

 

Can anyone explain to me why this behavior is occurring?

Thank you for your time.

Re: [fw-mvc] Project structure within modular application

*server layer = service layer....

2008/11/29 keith Pope <mute.pop3@googlemail.com>:
> When using addModuleDirectory you don't need to call setControllerDirectory.
>
> To get module specific config etc you are probably best to write a
> Front Controller Plugin and get the module name once routing has
> finished or during the dispatch loop startup. Personally I prefer to
> have a global config dir in the root so I dont have to do this.
>
> There are no guides currently that cover modular applications, I must
> say that the module/modular name does confuse a lot of people, it does
> not mean that ZF supports an easy way to implement a modular
> application, you still have to come up with solutions to handle
> inter-modular dependencies etc, though I use a server layer to help
> with this.
>
> You may also want to check out this proposal which outline the
> recommended project structure.
>
> http://framework.zend.com/wiki/display/ZFPROP/Zend+Framework+Default+Project+Structure+-+Wil+Sinclair
>
> Hope this helps
>
> 2008/11/29 Jiří Helmich <jiri@helmich.cz>:
>> Hi,
>>
>>
>>
>> I'm trying to run a modular application based on ZF MVC, so I've created the
>> project structure as it is described in Quick start guide (/application
>> copied under /application/modules/{somemodule}). Because of using modules, I
>> have several problems with the structure and bootstrapping the application,
>> because there is no modular application Quick start guide:
>>
>>
>>
>> $frontController->setControllerDirectory(APPLICATION_PATH .
>> '/controllers')->addModuleDirectory(APPLICATION_PATH.'/modules');
>>
>>
>>
>> Calling setControllerDirectory looses it sense, doesn't it?
>>
>>
>>
>> I'd like to set layout directory depending on the modules configugration
>> file, but – how can I parse
>> application/modules/{somemodule}/config/config.ini in the bootstrap?
>>
>>
>>
>> Has anybody any solution for this? Is there any guide for modular app?
>>
>>
>>
>> Thanks for any response
>>
>> Jiri
>>
>>
>
>
>
> --
> ----------------------------------------------------------------------
> [MuTe]
> ----------------------------------------------------------------------
>

--
----------------------------------------------------------------------
[MuTe]
----------------------------------------------------------------------

Re: [fw-mvc] Project structure within modular application

When using addModuleDirectory you don't need to call setControllerDirectory.

To get module specific config etc you are probably best to write a
Front Controller Plugin and get the module name once routing has
finished or during the dispatch loop startup. Personally I prefer to
have a global config dir in the root so I dont have to do this.

There are no guides currently that cover modular applications, I must
say that the module/modular name does confuse a lot of people, it does
not mean that ZF supports an easy way to implement a modular
application, you still have to come up with solutions to handle
inter-modular dependencies etc, though I use a server layer to help
with this.

You may also want to check out this proposal which outline the
recommended project structure.

http://framework.zend.com/wiki/display/ZFPROP/Zend+Framework+Default+Project+Structure+-+Wil+Sinclair

Hope this helps

2008/11/29 Jiří Helmich <jiri@helmich.cz>:
> Hi,
>
>
>
> I'm trying to run a modular application based on ZF MVC, so I've created the
> project structure as it is described in Quick start guide (/application
> copied under /application/modules/{somemodule}). Because of using modules, I
> have several problems with the structure and bootstrapping the application,
> because there is no modular application Quick start guide:
>
>
>
> $frontController->setControllerDirectory(APPLICATION_PATH .
> '/controllers')->addModuleDirectory(APPLICATION_PATH.'/modules');
>
>
>
> Calling setControllerDirectory looses it sense, doesn't it?
>
>
>
> I'd like to set layout directory depending on the modules configugration
> file, but – how can I parse
> application/modules/{somemodule}/config/config.ini in the bootstrap?
>
>
>
> Has anybody any solution for this? Is there any guide for modular app?
>
>
>
> Thanks for any response
>
> Jiri
>
>

--
----------------------------------------------------------------------
[MuTe]
----------------------------------------------------------------------

[fw-mvc] Project structure within modular application

Hi,

 

I’m trying to run a modular application based on ZF MVC, so I’ve created the project structure as it is described in Quick start guide (/application copied under /application/modules/{somemodule}). Because of using modules, I have several problems with the structure and bootstrapping the application, because there is no modular application Quick start guide:

 

$frontController->setControllerDirectory(APPLICATION_PATH . '/controllers')->addModuleDirectory(APPLICATION_PATH.'/modules');

 

Calling setControllerDirectory looses it sense, doesn’t it?

 

I’d like to set layout directory depending on the modules configugration file, but – how can I parse application/modules/{somemodule}/config/config.ini in the bootstrap?

 

Has anybody any solution for this? Is there any guide for modular app?

 

Thanks for any response

Jiri

 

Re: [fw-mvc] Zend_Form : How to set a class for the label wrapper?

Sorry for the delay.
It works gracefully!
Thanks!

--
Ramses Paiva
Software Architect
Sourcebits Technologies
www.sourcebits.com

On Thu, Nov 20, 2008 at 5:00 PM, Mon Zafra <monzee@gmail.com> wrote:
You can't pass options to the HtmlTag decorator used internally by the Label decorator, so you have to change the default decorators in order to accomplish this.
$decors = array(
'ViewHelper',
'Errors',
array('Description', array('tag' => 'p', 'class' => 'description')),
array('HtmlTag', array('tag' => 'dd')),
array(array('labelDtClose' => 'HtmlTag'),
array('tag' => 'dt', 'closeOnly' => true, 'placement' => 'prepend')),
'Label',
array(array('labelDtOpen' => 'HtmlTag'),
array('tag' => 'dt', 'openOnly' => true, 'placement' => 'prepend', 'class' => 'clear'))
);
$fieldEmail = $form->createElement(
    'text',
    'email',
    array('label' => 'Email:', 'decorators' => $decors)
)->setRequired(true);

   -- Mon



On Thu, Nov 20, 2008 at 3:58 PM, Ramses Paiva <ramses@sourcebits.com> wrote:
Hi list,


I'd like to set a class attribute for the label wrapper element and I'm not being able to do this.

My code:

$form =
new Zend_Form();

$fieldEmail = $form->createElement(
    'text',
    'email',
    array('label' => 'Email:')
)->setRequired(true);

$fieldEmail->getDecorator('Label')->setOption('class', 'clear');


What I'm getting is:

<dt>
    <label for="email" class="required clear">Email:</label>
</dt>

<dd>
    <input type="text" value="" id="email" name="email"/>
</dd>


And what I'd like to have is:

<dt class="clear">
    <label for="email" class="required">Email:</label>
</dt>

<dd>
    <input type="text" value="" id="email" name="email" />
</dd>


Any help? Ideas?


Best regards,

--
Ramses Paiva
Software Architect
Sourcebits Technologies
www.sourcebits.com

2008年11月28日星期五

RE: [fw-mvc] View helpers bug ?

Thanks Matthew for your replies, but I really think this is a view helper bug.

> > Here's what's not working :
> > class Zend_View_Helper_Loginbox extends Zend_View_Helper_Partial{
> > public function loginbox() {
> > // this doesn't work, the file never gets included
> > $this->view->headScript()->appendFile('/scripts/js/myfile.js');
>
> What version of ZF are you using? I *believe* the issue with
> placeholders being populated from partials was fixed for either 1.6.0 or
> 1.7.0.

I used 1.6.0 I updated to 1.7.0 after your message, I have the exact same error.

> You *do* know that you have to echo the headScript() view helper from
> your layout file, right?

"echo $this->headScript(); " is what I use on my layout file.
Now as far as I remember I've been using this piece of code of my application, it works fine, except when I use it in a view helper ; this is the reason I'm re-posting this.

> > // neigher the content of my javascript function after this !!!
> > $this->view->dojo()->javascriptCaptureStart();
> > ?>
> >
> > dojo.addOnLoad(function(){
> > alert("it s not working");
> > });
> >
> > <? $this->view->dojo()->javascriptCaptureEnd(); ?>
>
> Same goes for the dojo() view helper -- you have to echo it from your
> layout file.

echo $this->dojo(); is what I have on my layout file. Now everything piece of dojo code I have on my application works fine, except when I put it on a view helper.

Is there anywhere else I can try to look to solve this thing ?



Appelez vos amis de PC à PC -- C'EST GRATUIT Téléchargez Messenger, c'est gratuit !

Re: [fw-mvc] Zend_Form and Doctrine Integration

Also, although both you and I extended Zend_Form for our purposes, its probably better to not extend zend form and instead inject it...I realized this just now because i'm extending *my* version of Zend_From which introduces an dependency making it useless for others...


2008/11/28 Abraham Block <atblock@gmail.com>
I've done something similar in my projects using Zend_Db_Table though (and a lot of override options)

I really like django's model based forms and wish there was something internal in Zend framework like that.



On Fri, Nov 28, 2008 at 6:36 AM, Емил Иванов / Emil Ivanov <emil.vladev@gmail.com> wrote:
Hi all,

lately I've been working on integrating Zend_Form and Doctrine models.

What I tried to accomplish is something similar to django's
model-based forms. You have a model, that knows a hell lot of
information about itself, and you can create a form for it in one
line.
I uploaded what I have done here:
http://github.com/Vladev/zend-form-doctrine/tree/master

Check it out - there are tests that show the usage.

It's actually quite simple:

$form = new ZendX_Doctrine_Form(new Book()); // Book is an instance of
Doctrine_Record

And you are done.
It will create fields for all of the columns in the model (except for
pk and foreign keys). This can be overriden.

Right now it supports strings, integers and booleans columns, as well
as relations.
For relations it will generate the appropriate select (multi or not).
Again, can be overriden.

Validation is done by actually validating the model itself and
checking which columns did not validated.
Messages are attached to the form to indicate that.
No validators are added to the form itself.

Extending is done via subclassing the form and overriding some of the
methods. I've tried to keep them short and concise.

I'm considering including this is ZF, but don't know how exactly and
whether someone would like it.

So, have a look and share your thoughts. :)

P.S. Tests might not run out of the box as I extracted the code from
another app where we're using a custom runner. I've also renamed the
classes to ZendX_ instead of OutApp_.

Regards,
Emil Ivanov
--
My place to share my ideas:
http://vladev.blogspot.com
http://carutoo.com



Re: [fw-mvc] Zend_Form and Doctrine Integration

I've done something similar in my projects using Zend_Db_Table though (and a lot of override options)

I really like django's model based forms and wish there was something internal in Zend framework like that.


On Fri, Nov 28, 2008 at 6:36 AM, Емил Иванов / Emil Ivanov <emil.vladev@gmail.com> wrote:
Hi all,

lately I've been working on integrating Zend_Form and Doctrine models.

What I tried to accomplish is something similar to django's
model-based forms. You have a model, that knows a hell lot of
information about itself, and you can create a form for it in one
line.
I uploaded what I have done here:
http://github.com/Vladev/zend-form-doctrine/tree/master

Check it out - there are tests that show the usage.

It's actually quite simple:

$form = new ZendX_Doctrine_Form(new Book()); // Book is an instance of
Doctrine_Record

And you are done.
It will create fields for all of the columns in the model (except for
pk and foreign keys). This can be overriden.

Right now it supports strings, integers and booleans columns, as well
as relations.
For relations it will generate the appropriate select (multi or not).
Again, can be overriden.

Validation is done by actually validating the model itself and
checking which columns did not validated.
Messages are attached to the form to indicate that.
No validators are added to the form itself.

Extending is done via subclassing the form and overriding some of the
methods. I've tried to keep them short and concise.

I'm considering including this is ZF, but don't know how exactly and
whether someone would like it.

So, have a look and share your thoughts. :)

P.S. Tests might not run out of the box as I extracted the code from
another app where we're using a custom runner. I've also renamed the
classes to ZendX_ instead of OutApp_.

Regards,
Emil Ivanov
--
My place to share my ideas:
http://vladev.blogspot.com
http://carutoo.com


[fw-mvc] Zend_Form and Doctrine Integration

Hi all,

lately I've been working on integrating Zend_Form and Doctrine models.

What I tried to accomplish is something similar to django's
model-based forms. You have a model, that knows a hell lot of
information about itself, and you can create a form for it in one
line.
I uploaded what I have done here:
http://github.com/Vladev/zend-form-doctrine/tree/master

Check it out - there are tests that show the usage.

It's actually quite simple:

$form = new ZendX_Doctrine_Form(new Book()); // Book is an instance of
Doctrine_Record

And you are done.
It will create fields for all of the columns in the model (except for
pk and foreign keys). This can be overriden.

Right now it supports strings, integers and booleans columns, as well
as relations.
For relations it will generate the appropriate select (multi or not).
Again, can be overriden.

Validation is done by actually validating the model itself and
checking which columns did not validated.
Messages are attached to the form to indicate that.
No validators are added to the form itself.

Extending is done via subclassing the form and overriding some of the
methods. I've tried to keep them short and concise.

I'm considering including this is ZF, but don't know how exactly and
whether someone would like it.

So, have a look and share your thoughts. :)

P.S. Tests might not run out of the box as I extracted the code from
another app where we're using a custom runner. I've also renamed the
classes to ZendX_ instead of OutApp_.

Regards,
Emil Ivanov
--
My place to share my ideas:
http://vladev.blogspot.com
http://carutoo.com

2008年11月27日星期四

Re: [fw-db] Fetch parent row automatically

I like Zend Fremework so much, and more I use it more I like it BUT
actually I'm finding some problems when working with Zend_Db and related
classes.
For example I've noticed that when using the 'dependent row' magic method no
field of the parent class are returned and this is a strange way to work
because when I do a join I need both tables fields ... but maybe I've
misunderstood something.

However, I've also found a way to work and get all the field I need with a
join.

$id = (int)$params["id"];
$pages = new Pages();
$pagesInfo = $pages->info();
$pagesContent = new PagesContent();
$pagesContent = $pagesContent->info();

$select = $pages->select()->setIntegrityCheck(false)
->from(array("a" => $pagesInfo['name']),array('a.*'))
->joinLeft(array("b" => $pagesContent['name']),'b.page_id =
a.page_id')
->where('a.page_id = ?',$id)
->where('b.language_id = ?',1);

$result = $pages->fetchAll($select);
$this->view->result = $result->current();

I will get all the fields I need in both classes and also I can join other
table in a simply way.
The inconvenient is to create a 'info' var for each instanciated model. If
you have named table fields the 'right way' I think you could use the
joinUsing method when joining.


Actually I'm use the config.ini to save tables name so there is no need to
use them when coding. To specify table name when creating a model just add
these lines of code

protected function _setupTableName(){
$config = Zend_Registry::get('config');
$this->_name = $config->table->pages;
parent::_setupTableName();
}

I'm posting this because I've done HOURS of google searching finding few
discussion about this. Also the official documentation is still missing
something.
It will be useful also to know what you think about my solution and if
actually it exists a better one.

Cheers
--
View this message in context: http://www.nabble.com/Fetch-parent-row-automatically-tp18486102p20728826.html
Sent from the Zend DB mailing list archive at Nabble.com.

Re: [fw-db] Fetch parent row automatically

I like Zend Fremework so much, and more I use it more I like it BUT
actually I'm finding some problems when working with Zend_Db and related
classes.
For example I've noticed that when using the 'dependent row' magic method no
field of the parent class are returned and this is a strange way to work
because when I do a join I need both tables fields ... but maybe I've
misunderstood something.

However, I've also found a way to work and get all the field I need with a
join.

$id = (int)$params["id"];
$pages = new Pages();
$pagesInfo = $pages->info();
$pagesContent = new PagesContent();
$pagesContent = $pagesContent->info();

$select = $pages->select()->setIntegrityCheck(false)
->from(array("a" => $pagesInfo['name']),array('a.*'))
->joinLeft(array("b" => $pagesContent['name']),'b.page_id =
a.page_id')
->where('a.page_id = ?',$id)
->where('b.language_id = ?',1);

$result = $pages->fetchAll($select); // returns rowset of jobs
with category info
$this->view->result = $result->current();

I will get all the fields I need in both classes and also I can join other
table in a simply way.
The inconvenient is to create a 'info' var for each instanciated model. If
you have named table fields the 'right way' I think you could use the
joinUsing method when joining.


Actually I'm use the config.ini to save tables name so there is no need to
use them when coding. To specify table name when creating a model just add
these lines of code

protected function _setupTableName(){
$config = Zend_Registry::get('config');
$this->_name = $config->table->pages;
parent::_setupTableName();
}

I'm posting this because I've done HOURS of google searching finding few
discussion about this. Also the official documentation is still missing
something.
It will be useful also to know what you think about my solution and if
actually it exists a better one.

Cheers
--
View this message in context: http://www.nabble.com/Fetch-parent-row-automatically-tp18486102p20728826.html
Sent from the Zend DB mailing list archive at Nabble.com.

[fw-db] Subclassing Zend_Db_Select

Hi,

there are many Zend Framework components that can be subclassed and
customized, e.g. Zend_Form. It is possible to subclass a Zend_Form and to
change it, the way someone needs it. The most common way is through the use
of an init() method.

That brings me to my question. I would like to see such a possibility in
Zend_Db_Select as well. Is this already implemented? By using Zend_Db_Select
this way, it would be possible to create a class for every SELECT-statement.
This would create some kind of prepared statement in a PHP class. Another
pro would be the possibility to test single SELECT queries with UnitTests.

Is such a behaviour already implemented?

Other components where I am missing this behaviour are:

* Zend_Config
* Zend_Session_Namespace

Every comment is appreiciated..
Thanks

Richard

--
View this message in context: http://www.nabble.com/Subclassing-Zend_Db_Select-tp20725333p20725333.html
Sent from the Zend DB mailing list archive at Nabble.com.

Re: [fw-mvc] Project structure again

Cool. Thanks for the info.

--
View this message in context: http://www.nabble.com/Project-structure-again-tp20621021p20722907.html
Sent from the Zend MVC mailing list archive at Nabble.com.

Re: [fw-mvc] Zend_Form_SubForm and belongsTo ?? How to ?

-- S?ébastien Cramatte <scramatte@zensoluciones.com> wrote
(on Thursday, 27 November 2008, 04:00 PM +0100):
> I'm making an installer wizard.
>
> I've build a SubForm with atabase information (host,username, ...)
>
> I would like that all fields except "host" appear in a nested
> "params" array. The main idea is to reproduce "Zend_Config" structure
> and Zend_Config_Writer
>
> Currently I obtain this structure :
>
> array(3) {
> ["step_1"] => array(6) {
> ["adapter"] => string(9) "PDO_MYSQL"
> ["host"] => string(9) "127.0.0.1"
> ["dbname"] => string(2) "ZF"
> ["username"] => string(2) "ZF"
> ["password"] => string(4) "ZEND"
> ["dbprefix"] => string(3) "ZF_"
> }
> ...
> }
>
> And I would like to obtain
>
> array(3) {
> ["step_1"] => array(2) {
> ["adapter"] => string(9) "PDO_MYSQL"
> ["params"] => array(5) {
> ["host"] => string(9) "127.0.0.1"
> ["dbname"] => string(2) "ZF"
> ["username"] => string(2) "ZF"
> ["password"] => string(4) "ZEND"
> ["dbprefix"] => string(3) "ZF_"
> }
> }
> ...
> }

Use nested subforms.

The first would be named "step_1" and contain the element "adapter" and
the subform "params". The subform params would then contain the rest.

>
> I initialize my SubForm as this :
>
> $step1 = new Zend_Form_SubForm();
>
> $array = array(
> 'PDO_MYSQL' => 'Mysql',
> 'PDO_PGSQL' => 'PgSql',
> 'PDO_SQLITE' => 'Sqlite',
> 'PDO_ORACLE' => 'Oracle'
> );
>
> $field2 = new Zend_Form_Element_Select('adapter');
> $field2->setRequired(false)
> ->setLabel('adapter')
> ->addMultiOptions( $array )
> ->addValidator('InArray', false, array( array_keys($array)
> ));
>
> $field3 = new Zend_Form_Element_Text('host');
> $field3->setRequired(true)
> ->setBelongsTo('params')
> ->setLabel('host');
>
> $field4 = new Zend_Form_Element_Text('dbname');
> $field4->setRequired(true)
> ->setBelongsTo('params')
> ->setLabel('dbname');
>
> $field5 = new Zend_Form_Element_Text('username');
> $field5->setRequired(true)
> ->setBelongsTo('params')
> ->setLabel('username');
>
> $field6 = new Zend_Form_Element_Password('password');
> $field6->setRequired(true)
> ->setBelongsTo('params')
> ->setLabel('password');
>
> $field7 = new Zend_Form_Element_Text('dbprefix');
> $field7->setRequired(true)
> ->setBelongsTo('params')
> ->setLabel('dbprefix');
>
> $cancel = $this->addSubmitButton('cancel', 'cancel');
> $submit = $this->addSubmitButton('save', 'To step 2 >>');
>
> $step1->addElement($field2)
> ->addElement($field3)
> ->addElement($field4)
> ->addElement($field5)
> ->addElement($field6)
> ->addElement($field7)
> ->addElement($cancel)
> ->addElement($submit);
>
>
> Many thanks for your help
> Regards
>

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

Re: [fw-db] Parsing through large result sets

I'm not sure about this but maybe setting the fetch style to
*PDO::FETCH_LAZY or
**PDO::FETCH_PROPS_LATE (since PHP 5.2.0) *would make a difference.

Haven't tried it though...


On 11/27/2008 17:05, keith Pope wrote:
> I did a bit of testing and can reproduce your error using the while
> loop, though I chased it down to the actual PDO Mysql lib which gives
> the same problem. I tried using PDO::MYSQL_ATTR_USE_BUFFERED_QUERY but
> it seems to make no difference. I would suggest maybe using some
> pagination, or not using PDO...
>
> I cant find many docs about large resultsets in pdo, maybe its a bug
> not sure :) If I get it working I will post the method...
>
> Thx
>
> 2008/11/27 janpolsen<janpolsen@gmail.com>:
>
>> What monk.e.boy has written in the same thread is actually one of the things
>> I need to do.
>> I have a large table with securities and another even large table with
>> different types of prices related to securities.
>>
>> Making a join on those two tables results in one line with 15-20 columns:
>> first column is the secuirty id, second column is a date and the rest of the
>> columns are a value for each of the different price types. At the moments
>> this gives me about 20.000 rows.
>>
>> Trying to dump all that data to a i.e. csv file will trigger the
>> out-of-memory error.
>> I would've loved to be able to just do a:
>> file_put_contents($filename, $db->fetchAll($sql));
>> ... but the fetchAll() understandably triggers the out-of-memory.
>>
>> Hence the while ($row = $db->fetch())-loop as I have been used to, but which
>> sadly also triggers an out-of-memory (have in mind that I have memory_limit
>> set to 512MB) if I use ZF.
>>
>> I hope you can follow me :)
>>
>>
>> keith Pope-4 wrote:
>>
>>> Could you describe what you are trying to do, how many rows etc. I
>>> wouldn't mind to see if there is a workaround.
>>>
>> --
>> View this message in context: http://www.nabble.com/Parsing-through-large-result-sets-tp20264357p20718171.html
>> Sent from the Zend DB mailing list archive at Nabble.com.
>>
>>
>>
>
>
>
>

Re: [fw-db] Parsing through large result sets

That's awesome Keith...

Well, I don't like that it doesn't work, but it's much appreciated that you
are spending time on looking at it.

Personally I don't NEED to use PDO, but I am connecting to a MSSQL-database,
so I don't have any choice as far as I know.

Anyways... Thanks again for looking into it :)

Kind regards, Jan


keith Pope-4 wrote:
>
> I did a bit of testing and can reproduce your error using the while
> loop, though I chased it down to the actual PDO Mysql lib which gives
> the same problem. I tried using PDO::MYSQL_ATTR_USE_BUFFERED_QUERY but
> it seems to make no difference. I would suggest maybe using some
> pagination, or not using PDO...
>
> I cant find many docs about large resultsets in pdo, maybe its a bug
> not sure :) If I get it working I will post the method...

--
View this message in context: http://www.nabble.com/Parsing-through-large-result-sets-tp20264357p20721050.html
Sent from the Zend DB mailing list archive at Nabble.com.

Re: [fw-mvc] Project structure again

-- Michał Zieliński <zielun@gmail.com> wrote
(on Thursday, 27 November 2008, 05:13 AM -0800):
> Matthew, have you decided where forms should go in this proposed structure?
>
> Once there was a thread it:
> http://framework.zend.com/wiki/display/ZFPROP/Zend+Framework+Default+Project+Structure+-+Wil+Sinclair
>
> I wonder if anything changed and there is recommendation where to put the
> forms. I used to do that like: My/Form/FormName.php so far.
>
> Thanks for any clarification on that.

The recommendation is:

application/
forms/

However, an argument may also be made for putting in subdirectories
beneath application/models/ -- if your model uses a form as a validation
chain. As an example, in my pastebin I have this:

application/
models/
Paste.php (Paste)
DbTable/
Paste.php (DbTable_Paste)
Paste/
Form.php (Paste_Form)

// or
Form/
Paste.php (Form_Paste)

The "Paste" model then uses the form for validating incoming data.

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

Re: [fw-db] Parsing through large result sets

I did a bit of testing and can reproduce your error using the while
loop, though I chased it down to the actual PDO Mysql lib which gives
the same problem. I tried using PDO::MYSQL_ATTR_USE_BUFFERED_QUERY but
it seems to make no difference. I would suggest maybe using some
pagination, or not using PDO...

I cant find many docs about large resultsets in pdo, maybe its a bug
not sure :) If I get it working I will post the method...

Thx

2008/11/27 janpolsen <janpolsen@gmail.com>:
>
> What monk.e.boy has written in the same thread is actually one of the things
> I need to do.
> I have a large table with securities and another even large table with
> different types of prices related to securities.
>
> Making a join on those two tables results in one line with 15-20 columns:
> first column is the secuirty id, second column is a date and the rest of the
> columns are a value for each of the different price types. At the moments
> this gives me about 20.000 rows.
>
> Trying to dump all that data to a i.e. csv file will trigger the
> out-of-memory error.
> I would've loved to be able to just do a:
> file_put_contents($filename, $db->fetchAll($sql));
> ... but the fetchAll() understandably triggers the out-of-memory.
>
> Hence the while ($row = $db->fetch())-loop as I have been used to, but which
> sadly also triggers an out-of-memory (have in mind that I have memory_limit
> set to 512MB) if I use ZF.
>
> I hope you can follow me :)
>
>
> keith Pope-4 wrote:
>>
>> Could you describe what you are trying to do, how many rows etc. I
>> wouldn't mind to see if there is a workaround.
>
> --
> View this message in context: http://www.nabble.com/Parsing-through-large-result-sets-tp20264357p20718171.html
> Sent from the Zend DB mailing list archive at Nabble.com.
>
>

--
----------------------------------------------------------------------
[MuTe]
----------------------------------------------------------------------

[fw-mvc] Zend_Form_SubForm and belongsTo ?? How to ?

Hello

I'm making an installer wizard.

I've build a SubForm with atabase information (host,username, ...)

I would like that all fields except "host" appear in a nested
"params" array. The main idea is to reproduce "Zend_Config" structure
and Zend_Config_Writer

Currently I obtain this structure :

array(3) {
["step_1"] => array(6) {
["adapter"] => string(9) "PDO_MYSQL"
["host"] => string(9) "127.0.0.1"
["dbname"] => string(2) "ZF"
["username"] => string(2) "ZF"
["password"] => string(4) "ZEND"
["dbprefix"] => string(3) "ZF_"
}
...
}

And I would like to obtain

array(3) {
["step_1"] => array(2) {
["adapter"] => string(9) "PDO_MYSQL"
["params"] => array(5) {
["host"] => string(9) "127.0.0.1"
["dbname"] => string(2) "ZF"
["username"] => string(2) "ZF"
["password"] => string(4) "ZEND"
["dbprefix"] => string(3) "ZF_"
}
}
...
}

I initialize my SubForm as this :

$step1 = new Zend_Form_SubForm();

$array = array(
'PDO_MYSQL' => 'Mysql',
'PDO_PGSQL' => 'PgSql',
'PDO_SQLITE' => 'Sqlite',
'PDO_ORACLE' => 'Oracle'
);

$field2 = new Zend_Form_Element_Select('adapter');
$field2->setRequired(false)
->setLabel('adapter')
->addMultiOptions( $array )
->addValidator('InArray', false, array(
array_keys($array) ));

$field3 = new Zend_Form_Element_Text('host');
$field3->setRequired(true)
->setBelongsTo('params')
->setLabel('host');

$field4 = new Zend_Form_Element_Text('dbname');
$field4->setRequired(true)
->setBelongsTo('params')
->setLabel('dbname');

$field5 = new Zend_Form_Element_Text('username');
$field5->setRequired(true)
->setBelongsTo('params')
->setLabel('username');

$field6 = new Zend_Form_Element_Password('password');
$field6->setRequired(true)
->setBelongsTo('params')
->setLabel('password');

$field7 = new Zend_Form_Element_Text('dbprefix');
$field7->setRequired(true)
->setBelongsTo('params')
->setLabel('dbprefix');

$cancel = $this->addSubmitButton('cancel', 'cancel');
$submit = $this->addSubmitButton('save', 'To step 2 >>');

$step1->addElement($field2)
->addElement($field3)
->addElement($field4)
->addElement($field5)
->addElement($field6)
->addElement($field7)
->addElement($cancel)
->addElement($submit);


Many thanks for your help
Regards

Re: [fw-mvc] Project structure again

Matthew, have you decided where forms should go in this proposed structure?

Once there was a thread it:
http://framework.zend.com/wiki/display/ZFPROP/Zend+Framework+Default+Project+Structure+-+Wil+Sinclair

I wonder if anything changed and there is recommendation where to put the
forms. I used to do that like: My/Form/FormName.php so far.

Thanks for any clarification on that.

--
View this message in context: http://www.nabble.com/Project-structure-again-tp20621021p20719066.html
Sent from the Zend MVC mailing list archive at Nabble.com.

Re: [fw-db] Parsing through large result sets

What monk.e.boy has written in the same thread is actually one of the things
I need to do.
I have a large table with securities and another even large table with
different types of prices related to securities.

Making a join on those two tables results in one line with 15-20 columns:
first column is the secuirty id, second column is a date and the rest of the
columns are a value for each of the different price types. At the moments
this gives me about 20.000 rows.

Trying to dump all that data to a i.e. csv file will trigger the
out-of-memory error.
I would've loved to be able to just do a:
file_put_contents($filename, $db->fetchAll($sql));
... but the fetchAll() understandably triggers the out-of-memory.

Hence the while ($row = $db->fetch())-loop as I have been used to, but which
sadly also triggers an out-of-memory (have in mind that I have memory_limit
set to 512MB) if I use ZF.

I hope you can follow me :)


keith Pope-4 wrote:
>
> Could you describe what you are trying to do, how many rows etc. I
> wouldn't mind to see if there is a workaround.

--
View this message in context: http://www.nabble.com/Parsing-through-large-result-sets-tp20264357p20718171.html
Sent from the Zend DB mailing list archive at Nabble.com.

Re: [fw-db] Parsing through large result sets

>> I dont quite understand why you need to get all results from a large
>> table. Even in Mysql this is a bad idea and is why it has a safe mode
>> that stops this behaviour.

We do this quite a bit, say you have a ton of data that you can page though
using your pagination object, we have an export to csv button, this then
changes the view and stuff, but it also needs to read _all_ the data from
the DB.

I'm not saying what he is doing is correct, but some of us really do need to
stream a shit load of data. Reading this into an array sucks ;-)

John
--
View this message in context: http://www.nabble.com/Parsing-through-large-result-sets-tp20264357p20717998.html
Sent from the Zend DB mailing list archive at Nabble.com.

Re: [fw-db] Parsing through large result sets

Could you describe what you are trying to do, how many rows etc. I
wouldn't mind to see if there is a workaround.

2008/11/27 janpolsen <janpolsen@gmail.com>:
>
> The whole idea is to NOT get all the results at the same time.
>
> Instead the while($row = $res->fetch())-loop should give me only one row at
> a time.
> That is possible with the "internal" mysql* and mysqli* commands. Also the
> AdoDB-framwork works like this. So I don't understand why ZF shouldn't work
> like that as well.
>
> If I wanted to get all the results from a large table, then I would just use
> ->fetchAll() and I do indeed understand why that wouldn't work on large
> tables.
>
>
> keith Pope-4 wrote:
>>
>> I dont quite understand why you need to get all results from a large
>> table. Even in Mysql this is a bad idea and is why it has a safe mode
>> that stops this behaviour.
>
> --
> View this message in context: http://www.nabble.com/Parsing-through-large-result-sets-tp20264357p20717494.html
> Sent from the Zend DB mailing list archive at Nabble.com.
>
>

--
----------------------------------------------------------------------
[MuTe]
----------------------------------------------------------------------