2009年9月30日星期三

Re: [fw-mvc] creating a cli interface to mvc web app

I posted a blog article about this just yesterday. The problem is that routing is a built in requirement of the FrontController dispatch cycle and there's no way to disable it, and yes, by default it insists on complaining about CLI requests.

You can wrok around it by supplying the FrontController with a custom Router which basically stubs all the right methods a Router needs, but which are all empty. So the FC can do routing, but the Router is just a dummy class that does nothing. Messy, but works ;). Here's the class I'm using:

<?php

class ZFExt_Controller_Router_Cli implements Zend_Controller_Router_Interface
{

    public function route(Zend_Controller_Request_Abstract $dispatcher){}
    public function assemble($userParams, $name = null, $reset = false, $encode = true){}
    public function getFrontController(){}
    public function setFrontController(Zend_Controller_Front $controller){}
    public function setParam($name, $value){}
    public function setParams(array $params){}
    public function getParam($name){}
    public function getParams(){}
    public function clearParams($name = null){}

}
 
Pádraic Brady

http://blog.astrumfutura.com
http://www.survivethedeepend.com
OpenID Europe Foundation Irish Representative



From: water <zflist@yahoo.com>
To: fw-mvc@lists.zend.com
Sent: Wed, September 30, 2009 9:35:55 PM
Subject: [fw-mvc] creating a cli interface to mvc web app

I wanted to create a scriptable cli to a web app that we have have. One of the things that it does is that it kicks off a set of writing thousands of static html files.

I have something like the following:
$fc=Zend_Controller_Front::getInstance();
$fc->setControllerDirectory(array(
                     'default'=>$app.'/controllers/'));

Zend_Layout::startMvc(array('layoutPath' => $app.'/layouts/'));

$request=new Zend_Controller_Request_Simple('jt','generator');
$response=new Zend_Controller_Response_Cli();

$fc->setRequest($request);
$fc->setResponse($response);
$fc->throwExceptions(true);
Zend_Debug::dump($request);
$fc->dispatch();

but it gives me the following error: 
PHP Fatal error:  Uncaught exception 'Zend_Controller_Router_Exception' with message 'Zend_Controller_Router_Rewrite requires a Zend_Controller_Request_Http-based request object' in /data/sites/site/www/zf_source/library/Zend/Controller/Router/Rewrite.php:359

Do I need to call this upon the index.php that I have in my doc_root? 

I'm sure somebody has crossed this bridge so I greatly appreciate the help.

-jonathan


[fw-mvc] creating a cli interface to mvc web app

I wanted to create a scriptable cli to a web app that we have have. One of the things that it does is that it kicks off a set of writing thousands of static html files.

I have something like the following:
$fc=Zend_Controller_Front::getInstance();
$fc->setControllerDirectory(array(
                     'default'=>$app.'/controllers/'));

Zend_Layout::startMvc(array('layoutPath' => $app.'/layouts/'));

$request=new Zend_Controller_Request_Simple('jt','generator');
$response=new Zend_Controller_Response_Cli();

$fc->setRequest($request);
$fc->setResponse($response);
$fc->throwExceptions(true);
Zend_Debug::dump($request);
$fc->dispatch();

but it gives me the following error: 
PHP Fatal error:  Uncaught exception 'Zend_Controller_Router_Exception' with message 'Zend_Controller_Router_Rewrite requires a Zend_Controller_Request_Http-based request object' in /data/sites/site/www/zf_source/library/Zend/Controller/Router/Rewrite.php:359

Do I need to call this upon the index.php that I have in my doc_root? 

I'm sure somebody has crossed this bridge so I greatly appreciate the help.

-jonathan


Re: [fw-auth] a couple questions about customizing Zend_Auth



On Tue, Sep 29, 2009 at 2:04 PM, Ralph Schindler <ralph.schindler@zend.com> wrote:


used getDbSelect() to get the select and join() a table, and could not

This is a bug in Zend_Db_Select. Currently, calling join before from
causes odd SQL to be produced.  It seems like fixing this issue:

http://framework.zend.com/issues/browse/ZF-6653

will probably solve yours.  I have this slated for an upcoming release.




Interesting, and not entirely surprising. Most people probably think of building their SQL from left to right, so the join() before from() would be an unusual case that you can easily forgive developers for not anticipating.


 

and kept getting Zend_Auth_Adapter_Exception, invalid SQL statement.

In any event, I gave up on this approach and am now extending Zend_Auth_Adapter_DbTable and overriding authenticate(). Is this a reasonable solution?

This is a very reasonable solution, in fact, it was designed for.  You
can see that since there are several small succinct methods that you can
override in Zend_Auth_Adapter_DbTable.


I extended Zend_Auth_Adapter_DbTable and implemented my own authenticate(), leveraging a couple of protected methods from the parent, stealing whoever's clever snippet that builds the boolean 'zend_auth_credential_match' expression, and adding the stuff I needed, e.g, a rather tortured SQL query because of my weird database structure, and a database update to set the users last_login timestamp. Works great.

 

Which brings me to the next question:  suppose you want to add an authentication failure code that means 'account disabled.'  Extend Zend_Auth_Result and have your authenticate return an instance of it?

It sounds like you want to build an Auth model, and inside that model,
extends Zend_Auth_Adapter_DbTable to detect this situation.  I would
return the standard failure constant, but also add the message that you
feel you might want to use as the failure message.


Well, yeah -- if I understand correctly, that's what I've done.

Model_AuthAdapter extends Zend_Auth_Adapter_DbTable
{

const FAILURE_ACCOUNT_DISABLED = 'Account disabled.';

function authenticate() {
      
        $this->_authenticateResultInfo['identity'] = $this->_identity;
         // stolen from parent
        if (empty($this->_credentialTreatment) || (strpos($this->_credentialTreatment, '?') === false)) {
            $this->_credentialTreatment = '?';
        }
        $credentialExpression = new Zend_Db_Expr(
            '(CASE WHEN ' .
            $this->_zendDb->quoteInto(
                $this->_zendDb->quoteIdentifier($this->_credentialColumn, true)
                . ' = ' . $this->_credentialTreatment, $this->_credential
                )
            . ' THEN 1 ELSE 0 END) AS '
            . $this->_zendDb->quoteIdentifier('zend_auth_credential_match')
            );
        // end stolen part
        if ($this->_identityColumn == 'username') {
            $identityColumn = 'users.username';
        } elseif ($this->_identityColumn == 'email') {
            $identityColumn = 'people.email';
        } else {
            throw new Exception('invalid identity column: '.$this->_identityColumn);
        }
        $select = $this->_zendDb->select();
        $select
            ->from($this->_tableName, array('username','group_id','active','last_login', $credentialExpression))
            ->join('groups','users.group_id = groups.id',array('group'=>'groups.name'))
            ->join('people','users.person_id = people.id',array('id','lastname','firstname','email'))
            ->join('person_types','people.person_type_id = person_types.id',array('person_type'=>'flavor'))
            ->where("$identityColumn = ? ",$this->_identity) ;
      
        $this->_zendDb->setFetchMode(Zend_Db::FETCH_OBJ);
        $results = $this->_zendDb->fetchAll($select);
        // borrowed from parent
        if ( ($authResult = $this->_authenticateValidateResultset($results)) instanceof Zend_Auth_Result) {
            return $authResult;
        }
        $user = array_shift($results);
        $authResult = $this->_authenticateValidateResult((array)$user);
        // if everything is good so far, make sure account is active
        if ($authResult->isValid()) {
            if (! $user->active) {
                return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_UNCATEGORIZED,
                    $this->_identity,array(self::FAILURE_ACCOUNT_DISABLED));
            }
        }
        $this->_zendDb->update('users',   array('last_login' => time()),           $this->_zendDb->quoteInto( 'person_id = ?', $user->id ) );
         return $authResult;
    }

}

Thank you Ralph.

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

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

Re: [fw-db] Zend_Db::fetchAll() unacceptably slow

Thanks, it was the DNS problem, now it's blazing fast.

Regards,
Saša Stamenković


On Wed, Sep 30, 2009 at 2:46 PM, till <klimpong@gmail.com> wrote:
On Wed, Sep 30, 2009 at 2:37 PM, Саша Стаменковић <umpirsky@gmail.com> wrote:
> Looks like slow db
> connection http://www.screencast.com/users/umpirsky/folders/Jing/media/953fb733-e2e8-4456-a9cd-0e4570722110
> What can I try? Maybe other server :P

Is the database server not on the same server? If it's external (on
another server), there are multiple things:

a) Replace DNS host with an IP address, saves the lookup (or fix the DNS)
b) If it's not DNS, let your ISP review the issue.
c) Better server and/or connection between those.

You could also apply the cache to Zend_Db_Table to save the meta data
between requests. And maybe cache the response from the database
entirely to avoid the SQL calls.

Till

Re: [fw-db] Zend_Db::fetchAll() unacceptably slow

On Wed, Sep 30, 2009 at 2:37 PM, Саша Стаменковић <umpirsky@gmail.com> wrote:
> Looks like slow db
> connection http://www.screencast.com/users/umpirsky/folders/Jing/media/953fb733-e2e8-4456-a9cd-0e4570722110
> What can I try? Maybe other server :P

Is the database server not on the same server? If it's external (on
another server), there are multiple things:

a) Replace DNS host with an IP address, saves the lookup (or fix the DNS)
b) If it's not DNS, let your ISP review the issue.
c) Better server and/or connection between those.

You could also apply the cache to Zend_Db_Table to save the meta data
between requests. And maybe cache the response from the database
entirely to avoid the SQL calls.

Till

Re: [fw-db] Zend_Db::fetchAll() unacceptably slow

Looks like slow db connection http://www.screencast.com/users/umpirsky/folders/Jing/media/953fb733-e2e8-4456-a9cd-0e4570722110

What can I try? Maybe other server :P

Regards,
Saša Stamenković


On Wed, Sep 30, 2009 at 2:12 PM, Benjamin Eberlei <kontakt@beberlei.de> wrote:

Hello,

can you make a tracedump or a kcachegrind output using xdebug
for just your use-case?

Otherwise its impossible to tell what causes this.

greetings,
Benjamin

On Wed, 30 Sep 2009 05:03:22 -0700 (PDT), umpirsky <umpirsky@gmail.com>
wrote:
> Hi.
>
> I have mysql table:
>
> CREATE TABLE `brand` (
>   `id` int(10) unsigned NOT NULL auto_increment COMMENT 'Car brand ID',
>   `title` varchar(32) default NULL COMMENT 'Car brand title',
>   PRIMARY KEY  (`id`)
> ) ENGINE=InnoDB AUTO_INCREMENT=95 DEFAULT CHARSET=utf8 CHECKSUM=1
> DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC
>
> with 93 records inserted.
>
> I'm using Zend_Db with MYSQLI adapter. When I execute fetchAll(null,
> 'title') it takes 15 seconds to complete fetch!!! This is terrible slow,
> isn't it?
>
> Profiler says:
>
>  0.00114       SELECT `brand`.* FROM `brand` ORDER BY `title` ASC
>
> which is ok and blazing fast.
>
> Looks like fetchAll is wasting time somewhere. This is not unacceptable.
>
> Any idea?

Re: [fw-db] Zend_Db::fetchAll() unacceptably slow

Hello,

can you make a tracedump or a kcachegrind output using xdebug
for just your use-case?

Otherwise its impossible to tell what causes this.

greetings,
Benjamin

On Wed, 30 Sep 2009 05:03:22 -0700 (PDT), umpirsky <umpirsky@gmail.com>
wrote:
> Hi.
>
> I have mysql table:
>
> CREATE TABLE `brand` (
> `id` int(10) unsigned NOT NULL auto_increment COMMENT 'Car brand ID',
> `title` varchar(32) default NULL COMMENT 'Car brand title',
> PRIMARY KEY (`id`)
> ) ENGINE=InnoDB AUTO_INCREMENT=95 DEFAULT CHARSET=utf8 CHECKSUM=1
> DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC
>
> with 93 records inserted.
>
> I'm using Zend_Db with MYSQLI adapter. When I execute fetchAll(null,
> 'title') it takes 15 seconds to complete fetch!!! This is terrible slow,
> isn't it?
>
> Profiler says:
>
> 0.00114 SELECT `brand`.* FROM `brand` ORDER BY `title` ASC
>
> which is ok and blazing fast.
>
> Looks like fetchAll is wasting time somewhere. This is not unacceptable.
>
> Any idea?

[fw-db] Zend_Db::fetchAll() unacceptably slow

Hi.

I have mysql table:

CREATE TABLE `brand` (
`id` int(10) unsigned NOT NULL auto_increment COMMENT 'Car brand ID',
`title` varchar(32) default NULL COMMENT 'Car brand title',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=95 DEFAULT CHARSET=utf8 CHECKSUM=1
DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC

with 93 records inserted.

I'm using Zend_Db with MYSQLI adapter. When I execute fetchAll(null,
'title') it takes 15 seconds to complete fetch!!! This is terrible slow,
isn't it?

Profiler says:

0.00114 SELECT `brand`.* FROM `brand` ORDER BY `title` ASC

which is ok and blazing fast.

Looks like fetchAll is wasting time somewhere. This is not unacceptable.

Any idea?
--
View this message in context: http://www.nabble.com/Zend_Db%3A%3AfetchAll%28%29-unacceptably-slow-tp25679668p25679668.html
Sent from the Zend DB mailing list archive at Nabble.com.

[fw-mvc] Zend_Form Validator doesn't work with a custom decorator

Hi.

May be I got up on the wrong side of the rock

this morning but if I uncomment the decorators

validation doesn't work !

 $this->addElement('select', 'regions', array(            'multiOptions' =>$this->data['regions'],            'required'    => true,            //'decorators' =>  array(array('ViewHelper',array('helper' => 'formSelect'))),            'validators'  => array(                 array('Digits',true),                     array('Db_RecordExists', false, array('table' => 'regions',                                                              'field' => 'id'))                 )         ));  Thanks in advance. Bye 

View this message in context: Zend_Form Validator doesn't work with a custom decorator
Sent from the Zend MVC mailing list archive at Nabble.com.

Re: [fw-mvc] Re: re[fw-mvc] direct after secconds?

Yups, and that was the solution I already posted, but with a Header instead of a HttpEquiv ;)
One of those are really the most simple one and work the best (others have more problems than these two).
Regards, Jurian
--
Jurian Sluiman
Soflomo.com


Op Wednesday 30 September 2009 03:50:32 schreef Kyle Spraggs:
> Peter Warnock-2 wrote:
> > Dolf:
> >
> > That was my original thought, but I think the use case calls for sending
> > output to the browser, in which the redirect would not work. - pw
> >
> > On Tue, Sep 29, 2009 at 2:31 PM, Dolf Schimmel
> >
> > <dolfschimmel@gmail.com>wrote:
> >> sleep(3);
> >> $this->view->_redirect()
> >>
> >> On Tue, Sep 29, 2009 at 7:13 AM, sina miandashti <miandashti@gmail.com>
> >>
> >> wrote:
> >> > thanks all...:X
> >> >
> >> >
> >> > --
> >> > ________________
> >> > Sincerely
> >> > Sina Miandashti
> >> > MuSicBasE.ir & InvisionPower.ir Admin
>
> Isn't that done easily enough using Meta tags?
>
> $this->headMeta()->appendHttpEquiv('Refresh',
> '3;URL=http://www.yourdomain.com');

Re: [fw-mvc] help using filters

For checking length, you should use validators, not filters http://framework.zend.com/manual/en/zend.validate.html, for length use http://framework.zend.com/manual/en/zend.validate.set.html#zend.validate.set.string_length

Regards,
Saša Stamenković


On Wed, Sep 30, 2009 at 9:04 AM, sina miandashti <miandashti@gmail.com> wrote:
hi

for example

i have form element textarea  called "user_sig"

and user add his/her signature into it ...

but i dont know what filters should i use for this element when updating the DB

also i want to check that the content is no long than for ex 300 character ...

plz help

--
________________
Sincerely
Sina Miandashti
MuSicBasE.ir & InvisionPower.ir Admin

[fw-mvc] help using filters

hi

for example

i have form element textarea called "user_sig"

and user add his/her signature into it ...

but i dont know what filters should i use for this element when updating the DB

also i want to check that the content is no long than for ex 300 character ...

plz help

--
________________
Sincerely
Sina Miandashti
MuSicBasE.ir & InvisionPower.ir Admin

2009年9月29日星期二

Re: [fw-mvc] how to use a 'recursive' route

I would use regex and explode the match. - pw

On Fri, Sep 25, 2009 at 5:21 AM, Dimitri van Hees <dimitri@freshheads.com> wrote:
Hi,

I've searched the whole internet about this issue, but without success, so I'm trying it here now ;-) Imagine I have a site where a user can recursively add subpages. Ofcourse the user isn't able to add routes, so I bet I should add a 'recursive' route. This should be something like: /page* where * = /userinput1/userinput2/userinput3 I assume. Then I think I have to handle this path myself. However, I am unable to get this whole path. Does anyone have a best practice for this? If I use page(/\w+)+ in a regex route I am only able to retrieve the last part (/userinput3) without the preceding path. Anyone?

Kind regards,

Dimitri

[fw-mvc] Re: re[fw-mvc] direct after secconds?

Peter Warnock-2 wrote:
>
> Dolf:
>
> That was my original thought, but I think the use case calls for sending
> output to the browser, in which the redirect would not work. - pw
>
> On Tue, Sep 29, 2009 at 2:31 PM, Dolf Schimmel
> <dolfschimmel@gmail.com>wrote:
>
>> sleep(3);
>> $this->view->_redirect()
>>
>> On Tue, Sep 29, 2009 at 7:13 AM, sina miandashti <miandashti@gmail.com>
>> wrote:
>> > thanks all...:X
>> >
>> >
>> > --
>> > ________________
>> > Sincerely
>> > Sina Miandashti
>> > MuSicBasE.ir & InvisionPower.ir Admin
>> >
>>
>>
>
>


Isn't that done easily enough using Meta tags?

$this->headMeta()->appendHttpEquiv('Refresh',
'3;URL=http://www.yourdomain.com');

--
View this message in context: http://www.nabble.com/redirect-after-secconds--tp25623693p25673758.html
Sent from the Zend MVC mailing list archive at Nabble.com.

Re: [fw-mvc] redirect after secconds?

Dolf:

That was my original thought, but I think the use case calls for sending output to the browser, in which the redirect would not work. - pw

On Tue, Sep 29, 2009 at 2:31 PM, Dolf Schimmel <dolfschimmel@gmail.com> wrote:
sleep(3);
$this->view->_redirect()

On Tue, Sep 29, 2009 at 7:13 AM, sina miandashti <miandashti@gmail.com> wrote:
> thanks all...:X
>
>
> --
> ________________
> Sincerely
> Sina Miandashti
> MuSicBasE.ir & InvisionPower.ir Admin
>


Re: [fw-mvc] redirect after secconds?

sleep(3);
$this->view->_redirect()

On Tue, Sep 29, 2009 at 7:13 AM, sina miandashti <miandashti@gmail.com> wrote:
> thanks all...:X
>
>
> --
> ________________
> Sincerely
> Sina Miandashti
> MuSicBasE.ir & InvisionPower.ir Admin
>

Re: [fw-mvc] What is the status of multi-page forms?

-- Marcus Stöhr <dafish@soundtrack-board.de> wrote
(on Tuesday, 29 September 2009, 06:06 PM +0200):
> I know there is a proposal [1] for multi-page forms and they were
> supposed to make it into the 1.9 release. However, they didn't made it
> and my question is what the status is and is there any chance to get
> this helper into 1.10?

Jurrien, the author of that proposal, hasn't had much time to dedicate
to it. However, we have quite some time until 1.10 (a couple months,
most likely), so if you want to help him out with the code, that could
be a huge boon.

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

Re: [fw-db] Support Zend_Db_Select sub selects ?

Cool, I didn't realize you could pass in a select object as the table. Nice! :)

--
Hector


On Tue, Sep 29, 2009 at 11:04 AM, sNop <snop3@seznam.cz> wrote:
Great, thank you, this is exactly what i need



Re: [fw-db] Support Zend_Db_Select sub selects ?

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrCTCsACgkQkCAxuhXMpxV3PwCfYrqUi4WUFl3h75nmcUWz6ENL
CoIAn0GizhOje8nPhF6CtLnSfkl+X9zL
=Jhgr
-----END PGP SIGNATURE-----
Great, thank you, this is exactly what i need

Re: [fw-auth] a couple questions about customizing Zend_Auth

> used getDbSelect() to get the select and join() a table, and could not

This is a bug in Zend_Db_Select. Currently, calling join before from
causes odd SQL to be produced. It seems like fixing this issue:

http://framework.zend.com/issues/browse/ZF-6653

will probably solve yours. I have this slated for an upcoming release.

>
> and kept getting Zend_Auth_Adapter_Exception, invalid SQL statement.
>
> In any event, I gave up on this approach and am now extending
> Zend_Auth_Adapter_DbTable and overriding authenticate(). Is this a
> reasonable solution?

This is a very reasonable solution, in fact, it was designed for. You
can see that since there are several small succinct methods that you can
override in Zend_Auth_Adapter_DbTable.

> Which brings me to the next question: suppose you want to add an
> authentication failure code that means 'account disabled.' Extend
> Zend_Auth_Result and have your authenticate return an instance of it?

It sounds like you want to build an Auth model, and inside that model,
extends Zend_Auth_Adapter_DbTable to detect this situation. I would
return the standard failure constant, but also add the message that you
feel you might want to use as the failure message.

-ralph

RE: [fw-db] Support Zend_Db_Select sub selects ?

I do it almost the same way. The only difference to Hector’s solution is that I use the actual select object in the new select statement instead of converting it to a string. This works very well for me.

 

$subSelect = $db->select()

->from('aktualne', array('n' => 'name'));

 

$select = $db->select()

->from(

    array('akt' => $subSelect),

    array('n')

)

->where('akt.n = ?', 2008);

 

Gina-Marie Rollock

 

From: Hector Virgen [mailto:djvirgen@gmail.com]
Sent: Tuesday, September 29, 2009 12:02 PM
To: sNop
Cc: fw-db@lists.zend.com
Subject: Re: [fw-db] Support Zend_Db_Select sub selects ?

 

You should be able to do that if you wrap your subselect in a Zend_Db_Expr object. Try this:

 

$subSelect = $db->select()

->from('aktualne', array('n' => 'name'));

 

$subSelectString = '(' . $subSelect->__toString() . ')';

 

$select = $db->select()

->from(

    array('akt' => new Zend_Db_Expr($subSelectString)),

    array('n')

)

->where('akt.n = ?', 2008);

 

$db->fetchAll($select);


--
Hector

2009/9/29 sNop <snop3@seznam.cz>

Hi,

something like this:
SELECT `akt`.`n`
FROM (
 SELECT `name` AS `n`
 FROM `aktualne`
) AS `akt`
WHERE `akt`.`n` = '2008'

Support this Zend_Db_Select ?

Thank for any suggestions.

 

[fw-mvc] What is the status of multi-page forms?

Hi there,

I know there is a proposal [1] for multi-page forms and they were
supposed to make it into the 1.9 release. However, they didn't made it
and my question is what the status is and is there any chance to get
this helper into 1.10?

Best regards,
Marcus

[1] - http://framework.zend.com/wiki/pages/viewpage.action?pageId=42130

Re: [fw-db] Support Zend_Db_Select sub selects ?

You should be able to do that if you wrap your subselect in a Zend_Db_Expr object. Try this:

$subSelect = $db->select()
->from('aktualne', array('n' => 'name'));

$subSelectString = '(' . $subSelect->__toString() . ')';

$select = $db->select()
->from(
    array('akt' => new Zend_Db_Expr($subSelectString)),
    array('n')
)
->where('akt.n = ?', 2008);

$db->fetchAll($select);

--
Hector


2009/9/29 sNop <snop3@seznam.cz>
Hi,

something like this:
SELECT `akt`.`n`
FROM (
 SELECT `name` AS `n`
 FROM `aktualne`
) AS `akt`
WHERE `akt`.`n` = '2008'

Support this Zend_Db_Select ?

Thank for any suggestions.


Re: [fw-mvc] how to use a 'recursive' route

What about using a regular route but giving it a large number of optional parts?

/page/:part1/:part2/:part3/:part4....

To make them optional, assign default values for each part.

Or you can probably make your own route class that can handle this, but I'm not too familiar with how to build custom routes.

--
Hector


On Tue, Sep 29, 2009 at 1:04 AM, Brenton Alker <brenton@tekerson.com> wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dimitri van Hees wrote:
> Hi,
>
> I've searched the whole internet about this issue, but without success,
> so I'm trying it here now ;-) Imagine I have a site where a user can
> recursively add subpages. Ofcourse the user isn't able to add routes, so
> I bet I should add a 'recursive' route. This should be something like:
> */page** where *** = */userinput1/userinput2/userinput3* I assume. Then
> I think I have to handle this path myself. However, I am unable to get
> this whole path. Does anyone have a best practice for this? If I use
> *page(/\w+)+* in a regex route I am only able to retrieve the last part
> (*/userinput3*) without the preceding path. Anyone?

If you're using a regex route (you appear to be) then you can do
"page(/.*)" to get the entire url after "/page". This doesn't break it
into parts, but that should be easy to do at the application level (if
it's actually required).

I have run into a similar problem in a different context, the routing
doesn't seem to deal very well with situations where there are an
unknown number of parts.

- --

Brenton Alker
PHP Developer - Brisbane, Australia

http://blog.tekerson.com/
http://twitter.com/tekerson

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkrBv5EACgkQ7bkAtAithuvppACg3cjvAQ+eYu6kO0jzTWWgMVWc
BGMAn0zQJPaPY7/NdKD9y7AIGC+mpXgQ
=3Et8
-----END PGP SIGNATURE-----


[fw-db] Support Zend_Db_Select sub selects ?

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrCHQUACgkQkCAxuhXMpxVpFQCeOf59Jbv9r76w4MQ3U/BoMG1o
bFIAn3Kl+K+DMaOD0+cdjkiT7qO64X/S
=ogh3
-----END PGP SIGNATURE-----
Hi,

something like this:
SELECT `akt`.`n`
FROM (
SELECT `name` AS `n`
FROM `aktualne`
) AS `akt`
WHERE `akt`.`n` = '2008'

Support this Zend_Db_Select ?

Thank for any suggestions.

Re: [fw-formats] Weird problem with Zend_Mail

Hi Ralf,

It's a long time ago, but did you guess what happened about this issue? I'm
having the same problem...

Thanks


Ralf Eggert wrote:
>
> Hi,
>
> I just updated to ZF 0.8.0 and have problems with some of my local unit
> tests which test. The messages I get look just weird to me:
>
> ------------------------------------------------------------------------
> Fatal error: Exception thrown without a stack frame in Unknown on line 0
>
> Call Stack:
> 0.0017 1. {main}() E:\_library\PHPUnit\TextUI\Command.php:0
> 0.2168 2. PHPUnit_TextUI_Command::main()
> E:\_library\PHPUnit\TextUI\Command.php:401
>
> Warning: Unknown: Failed to write session data (user). Please verify
> that the current setting of session.save_path is correct () in Unknown
> on line 0
>
> Call Stack:
> 0.0017 1. {main}() E:\_library\PHPUnit\TextUI\Command.php:0
> 0.2168 2. PHPUnit_TextUI_Command::main()
> E:\_library\PHPUnit\TextUI\Command.php:401
> ------------------------------------------------------------------------
>
> It took me some while to track down the code line which causes this
> problem. I finally found it in Zend_Mail_Protocol_Smtp::_startSession().
> When I comment out the single line, these message are not shown any more
> but an exception is thrown:
>
> ------------------------------------------------------------------------
> Zend_Mail_Protocol_Exception: A valid session has not been started
> E:\_library\Zend\Mail\Transport\Smtp.php:185
> E:\_library\Zend\Mail\Transport\Abstract.php:330
> E:\_library\Zend\Mail.php:563
> E:\www.travello-dev.com\tests\unit\framework\MailTest.php:68
> ------------------------------------------------------------------------
>
> This exception makes sense to me since there is a check for $this->_sess
> in Zend_Mail_Protocol_Smtp::mail() method.
>
> What I do not understand is, why the single line 399 in
> Zend_Mail_Protocol_Smtp::_startSession() is causing this problem by just
> setting the $this->_sess value to true.
>
> To give some further information. I am working on a Win XP machine and I
> am using Fakemail as a local mailer daemon to check in my unit tests if
> the mails are sent as expected. With the nightly 20070215-3419 I used
> before I upgraded to ZF 0.8.0 this problem did not occur.
>
> Is this worth to open a new issue for it?
>
> Best Regards,
>
> Ralf
>
>
>

--
View this message in context: http://www.nabble.com/Weird-problem-with-Zend_Mail-tp9132396p25662975.html
Sent from the Zend MFS mailing list archive at Nabble.com.

Re: [fw-mvc] how to use a 'recursive' route

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dimitri van Hees wrote:
> Hi,
>
> I've searched the whole internet about this issue, but without success,
> so I'm trying it here now ;-) Imagine I have a site where a user can
> recursively add subpages. Ofcourse the user isn't able to add routes, so
> I bet I should add a 'recursive' route. This should be something like:
> */page** where *** = */userinput1/userinput2/userinput3* I assume. Then
> I think I have to handle this path myself. However, I am unable to get
> this whole path. Does anyone have a best practice for this? If I use
> *page(/\w+)+* in a regex route I am only able to retrieve the last part
> (*/userinput3*) without the preceding path. Anyone?

If you're using a regex route (you appear to be) then you can do
"page(/.*)" to get the entire url after "/page". This doesn't break it
into parts, but that should be easy to do at the application level (if
it's actually required).

I have run into a similar problem in a different context, the routing
doesn't seem to deal very well with situations where there are an
unknown number of parts.

- --

Brenton Alker
PHP Developer - Brisbane, Australia

http://blog.tekerson.com/
http://twitter.com/tekerson

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkrBv5EACgkQ7bkAtAithuvppACg3cjvAQ+eYu6kO0jzTWWgMVWc
BGMAn0zQJPaPY7/NdKD9y7AIGC+mpXgQ
=3Et8
-----END PGP SIGNATURE-----

2009年9月28日星期一

Re: [fw-mvc] redirect after secconds?

thanks all...:X


--
________________
Sincerely
Sina Miandashti
MuSicBasE.ir & InvisionPower.ir Admin

Re: [fw-mvc] redirect after secconds?

IMO, html meta redirect is better than javascript redirect. Javascript redirection has accessibility issues. Browser with javascript disabled can not be redirected, etc.

But besides that all, redirection after seconds should not be used because of accessibility issue. You can redirect using HTTP header instead.

Here is the reference: http://www.w3.org/TR/WCAG10-CORE-TECHS/#auto-page-refresh

"Until user agents provide the ability to stop auto-redirect, do not use markup to redirect pages automatically. Instead, configure the server to perform redirects. This automatic refresh can be very disorienting to some users"

On Tue, Sep 29, 2009 at 7:55 AM, Ralph Schindler <ralph.schindler@zend.com> wrote:
Generally speaking, html meta tags and javascript are the better ways to implement this.  By the time the client has the web page, your application is already finished (the request has been delivered as a response).

If it were me, I'd do a javascript timed redirect inside the view script.

The first link has a "delayed" redirect, but the others are good too:
http://www.google.com/search?q=javascript+redirect

-ralph


sina miandashti wrote:
hi

its possible to use the $this->view->_redirect()  to an adress after 3
secconds ?





--
Best regards,

Andy L.

Re: [fw-mvc] redirect after secconds?

Generally speaking, html meta tags and javascript are the better ways to
implement this. By the time the client has the web page, your
application is already finished (the request has been delivered as a
response).

If it were me, I'd do a javascript timed redirect inside the view script.

The first link has a "delayed" redirect, but the others are good too:
http://www.google.com/search?q=javascript+redirect

-ralph

sina miandashti wrote:
> hi
>
> its possible to use the $this->view->_redirect() to an adress after 3
> secconds ?
>

Re: [fw-mvc] ZendX_JQuery_Form_Element_DatePicker problem under Ajax request

Are actually working the ZendX_JQuery_Form_Element 's without layout ?

I mean if i added layout to Ajax request does seems to work, otherwise not...
Hi,

I am doing some new forms for an application. Until now i used the ZendX_JQuery_Form_Element_DatePicker in non-ajax requests.

No i have one problem with rendering correctly ZendX_JQuery_Form_Element_DatePicker withind a subform from an ajax request.

The situation is:
1. JQuery and jQuery UI are initialized from controller (or from view)
$this->view->jQuery()->enable()->uiEnable();
and the js libraries are loaded, actually this code added to the view
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/jquery-ui.min.js"></script>   

2. The subform is rendered correctly

3. Problem is no code for initalizing the DatePicker is rendered, as:

<script type="text/javascript"> //<![CDATA[ $(document).ready(function() {     $("#test-1-start_date").datepicker({"showOn":"both","showStatus":"true","buttonImage":"\/admin\/library\/jqueryui\/media\/calendar.gif","buttonImageOnly":"true","dateFormat":"yy-mm-dd","changeMonth":"true","changeYear":"true"}); ); //]]>  </script>

Yes, i know adding the $(document).ready(function() { doesn't makes much sense from ajax, but anyway, i can't find any explanation why the DatePicker initialization code is not rendered also, just the libraries and form code...
--  Best regards, Cristian Bichis www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com


--  Best regards, Cristian Bichis www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com

Re: [fw-mvc] unit test and set layout

Perhaps it is because I do not use config.ini
All settings are set in the index.php (as in earlier versions of ZF)

2009/9/28 Алексей Шеин <confik@gmail.com>:
>
>
> 2009/9/28 Yuri Timofeev <tim4dev@gmail.com>
>>
>> I do not understand. All the tests I run and operate normally.
>> However, if the controller have "setLayout ( 'other (non default)
>> layout')" then you have the bug.
>>
>
> I also do have non-default layout and my tests work correctly.
> Maybe you should delete layout option when starting mvc:
>>
>> Zend_Layout::startMvc(array(
>>    'layoutPath' => $appRoot . '/application/layouts/' .
>> $config_layout->path,
>>    'layout' => 'main' // this one
>> ));
>
>

--
with best regards

Re: [fw-mvc] unit test and set layout



2009/9/28 Yuri Timofeev <tim4dev@gmail.com>
I do not understand. All the tests I run and operate normally.
However, if the controller have "setLayout ( 'other (non default)
layout')" then you have the bug.


I also do have non-default layout and my tests work correctly.
Maybe you should delete layout option when starting mvc:

Zend_Layout::startMvc(array(
   'layoutPath' => $appRoot . '/application/layouts/' . $config_layout->path,
   'layout' => 'main' // this one
));

 

Re: [fw-mvc] unit test and set layout

I do not understand. All the tests I run and operate normally.
However, if the controller have "setLayout ( 'other (non default)
layout')" then you have the bug.


2009/9/28 Алексей Шеин <confik@gmail.com>:
>
>
> 2009/9/27 Yuri Timofeev <tim4dev@gmail.com>
>>
>> Hi,
>>
>> Zend Framework 1.9.2
>>
>> I am writing a unit test for controller IndexController.php, which use
>> a different Layout:
>>
>> ---
>> application/controllers/IndexController.php
>> ---
>>  function indexAction()
>>  {
>>    $this->_helper->layout->setLayout('dashboard');
>>    $this->_helper->actionStack('problem-dashboard', 'job');
>>    $this->_helper->actionStack('problem-dashboard', 'volume');
>>    $this->_helper->actionStack('next-dashboard', 'job');
>>    $this->_helper->actionStack('running-dashboard', 'job');
>>    $this->_helper->actionStack('terminated-dashboard', 'job');
>>  }
>> ---
>>
>>
>> That part "bootstrap.php" for unit tests:
>>
>> ---
>> tests/application/bootstrap.php
>> ---
>> ...
>> Zend_Layout::startMvc(array(
>>    'layoutPath' => $appRoot . '/application/layouts/' .
>> $config_layout->path,
>>    'layout' => 'main'
>> ));
>> ...
>> ---
>
> You get this behavior because mvc instance resets on each test, i.e. on
> setUp() calling - you can see it in
> Zend_Test_PHPUnit_ControllerTestCase::reset() method.
> You can fully reboostrap your application, or just some parts (I went this
> way, it's a bit faster).
>
> My own ControllerTestCase class:
>
> <?php
>
> require_once('Zend/Test/PHPUnit/ControllerTestCase.php');
>
> abstract class ControllerTestCase extends
> Zend_Test_PHPUnit_ControllerTestCase
> {
>     /**
>      * @var Zend_Application
>      */
>     static protected $_application = null;
>
>     static $time = 0;
>
>     public function setUp()
>     {
>         $this->bootstrap = array($this, 'appBootstrap');
>         parent::setUp();
>     }
>
>     public function appBootstrap()
>     {
>         if (null === self::$_application) {
>             // init application
>             self::$_application = new Zend_Application(
>                 APPLICATION_ENV,
>                 APPLICATION_PATH . '/configs/application.ini'
>             );
>
>             $classFileIncCache = '/tmp/pluginLoaderCache.php';
>             if (file_exists($classFileIncCache)) {
>                 include_once $classFileIncCache;
>             }
>
> Zend_Loader_PluginLoader::setIncludeFileCache($classFileIncCache);
>
>             self::$_application->bootstrap();
>         }
>
>         $dirs = array(
>             'default' => APPLICATION_PATH . '/controllers',
> // add your modules here
>         );
>
> $this->getFrontController()->getDispatcher()->setControllerDirectory($dirs);
> // controller dirs are reseted too, restore them
>
>         Zend_Layout::startMvc(array('layoutPath' => APPLICATION_PATH .
> '/layouts/scripts')); // restart MVC
>
> //        self::$_application->setBootstrap(null)->bootstrap(); // or
> instead we can fully rebootstrap it again
>     }
> }
>
> ---
>
> tests/bootstrap.php (phpunit calls that one)
>
> <?php
> // Define path to application directory
> defined('APPLICATION_PATH')
>     || define('APPLICATION_PATH', realpath(dirname(__FILE__) .
> '/../application'));
>
> // Define application environment
> defined('APPLICATION_ENV')
>     || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ?
> getenv('APPLICATION_ENV') : 'testing'));
>
>
> // Ensure library/ is on include_path
> set_include_path(implode(PATH_SEPARATOR, array(
>     realpath(APPLICATION_PATH . '/../library'),
>     get_include_path()
> )));
>
>
> /** Zend_Application */
> require_once 'Zend/Application.php';
>
> /** Register autoloader */
> require_once 'Zend/Loader/Autoloader.php';
> $autoloader =
> Zend_Loader_Autoloader::getInstance()->setFallbackAutoloader(true);
>
> require_once 'ControllerTestCase.php';
>
> --
>
> Hope it helps.
>
> Regards,
> Shein Alexey
>
>
>
>

--
with best regards

2009年9月27日星期日

Re: [fw-mvc] How to start a test?

-- huajun qi <qihjun@gmail.com> wrote
(on Sunday, 27 September 2009, 10:28 AM +0800):
> I read the guide reference about testing, and I think it's different
> from usual unit test, it is integrated into the frame, isn't it?
>
> If I just want to test a class, but it refers to database, how can I
> do it?

For normal unit testing, you can use the unit testing framework of your
choice: PHPUnit, SimpleTest, phpt, etc.

What ZF provides are some PHPUnit extensions that allow you to test your
MVC applications and/or code that utilizes Zend_Db; these are found in
Zend_Test_PHPUnit_ControllerTestCase and Zend_Test_PHPUnit_Db,
respectively

> Does the test classes zf provides need to start the application?

For MVC application testing, yes -- you need to bootstrap your
application, and then use the methods in the ControllerTestCase to
dispatch actions and test against the response.

For testing code that utilizes Zend_Db -- for instance, your models
and/or service layer -- you can either use the DatabaseTestCase or the
DB mixin support to bootstrap the database connection.

> And I prefet to use simpletest framework, can it be deployed well?

It can -- but we have no official support for it within the framework.

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

[fw-mvc] unit test and set layout

Hi,

Zend Framework 1.9.2

I am writing a unit test for controller IndexController.php, which use
a different Layout:

---
application/controllers/IndexController.php
---
function indexAction()
{
$this->_helper->layout->setLayout('dashboard');
$this->_helper->actionStack('problem-dashboard', 'job');
$this->_helper->actionStack('problem-dashboard', 'volume');
$this->_helper->actionStack('next-dashboard', 'job');
$this->_helper->actionStack('running-dashboard', 'job');
$this->_helper->actionStack('terminated-dashboard', 'job');
}
---


That part "bootstrap.php" for unit tests:

---
tests/application/bootstrap.php
---
...
Zend_Layout::startMvc(array(
'layoutPath' => $appRoot . '/application/layouts/' . $config_layout->path,
'layout' => 'main'
));
...
---

Here's my test:

---
tests/application/controllers/IndexControllerTest.php
---
public function testIndex() {
$this->dispatch('index/index');
echo $this->response->outputBody(); // for debug !!!
$this->assertResponseCode(200);
$this->assertModule('default');
$this->assertController('index');
$this->assertAction('index');
// other asserts ...
}
---

This test fails. If I turn on the output "echo
$this->response->outputBody();", I see this:

---
---
Action Helper by name Layout not found

<h2>Trace:</h2>
<pre>
#0 /opt/prog/webacula/library/Zend/Controller/Action/HelperBroker.php(293):
Zend_Controller_Action_HelperBroker::_loadHelper('Layout')
#1 /opt/prog/webacula/library/Zend/Controller/Action/HelperBroker.php(339):
Zend_Controller_Action_HelperBroker->getHelper('layout')
#2 /opt/prog/webacula/application/controllers/IndexController.php(48):
Zend_Controller_Action_HelperBroker->__get('layout')
#3 /opt/prog/webacula/library/Zend/Controller/Action.php(513):
IndexController->indexAction()
#4 /opt/prog/webacula/library/Zend/Controller/Dispatcher/Standard.php(289):
Zend_Controller_Action->dispatch('indexAction')
#5 /opt/prog/webacula/library/Zend/Controller/Front.php(946):
Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_HttpTestCase),
Object(Zend_Controller_Response_HttpTestCase))
#6 /opt/prog/webacula/library/Zend/Test/PHPUnit/ControllerTestCase.php(190):
Zend_Controller_Front->dispatch()
#7 /opt/prog/webacula/tests/application/controllers/IndexControllerTest.php(29):
Zend_Test_PHPUnit_ControllerTestCase->dispatch('index/index/tes...')
#8 [internal function]: IndexControllerTest->testIndex()
#9 /usr/share/pear/PHPUnit/Framework/TestCase.php(489):
ReflectionMethod->invoke(Object(IndexControllerTest))
#10 /usr/share/pear/PHPUnit/Framework/TestCase.php(404):
PHPUnit_Framework_TestCase->runTest()
#11 /usr/share/pear/PHPUnit/Framework/TestResult.php(607):
PHPUnit_Framework_TestCase->runBare()
#12 /usr/share/pear/PHPUnit/Framework/TestCase.php(375):
PHPUnit_Framework_TestResult->run(Object(IndexControllerTest))
#13 /usr/share/pear/PHPUnit/Framework/TestSuite.php(677):
PHPUnit_Framework_TestCase->run(Object(PHPUnit_Framework_TestResult))
#14 /usr/share/pear/PHPUnit/Framework/TestSuite.php(658):
PHPUnit_Framework_TestSuite->runTest(Object(IndexControllerTest),
Object(PHPUnit_Framework_TestResult))
#15 /usr/share/pear/PHPUnit/Framework/TestSuite.php(621):
PHPUnit_Framework_TestSuite->run(Object(PHPUnit_Framework_TestResult),
false, Array, Array)
#16 /usr/share/pear/PHPUnit/Framework/TestSuite.php(621):
PHPUnit_Framework_TestSuite->run(Object(PHPUnit_Framework_TestResult),
false, Array, Array)
#17 /usr/share/pear/PHPUnit/TextUI/TestRunner.php(324):
PHPUnit_Framework_TestSuite->run(Object(PHPUnit_Framework_TestResult),
false, Array, Array)
#18 /usr/share/pear/PHPUnit/TextUI/Command.php(128):
PHPUnit_TextUI_TestRunner->doRun(Object(PHPUnit_Framework_TestSuite),
Array)
#19 /usr/bin/phpunit(52): PHPUnit_TextUI_Command::main()
#20 {main}
</pre>


If I modify a test, like this:

---NEW---
tests/application/controllers/IndexControllerTest.php
---
public function testIndex() {
$this->dispatch('index/index/test/1'); // workaround
...
}
---


And new IndexController.php :

---NEW---
application/controllers/IndexController.php
---
function indexAction()
{
// workaround
$unit_test = $this->_request->getParam('test', null);
if ( empty($unit_test)) {
// not test
$this->_helper->layout->setLayout('dashboard');
}
...
$this->_helper->actionStack('problem-dashboard', 'job');
$this->_helper->actionStack('problem-dashboard', 'volume');
$this->_helper->actionStack('next-dashboard', 'job');
$this->_helper->actionStack('running-dashboard', 'job');
$this->_helper->actionStack('terminated-dashboard', 'job');
}
---


That test works OK.

Question: why does not work if I use
"$this->_helper->layout->setLayout('dashboard')" ?

--
with best regards

Re: [fw-mvc] Some question about static route and view helper url

Thank's for the answer, I'll be careful with that next time.

Lucas

Hector Virgen a écrit :
> That's the correct behavior. If you don't specify a route name (or
> pass in NULL), the url will be based on the route that matched the
> current request. In other words, since the current request matched
> MyRoute and you want to build a url using the default route, you'll
> need to specify that to the helper.
>
> --
> Hector
>
>
> On Thu, Sep 24, 2009 at 2:30 AM, Lucas CORBEAUX
> <lucas.corbeaux@gmail.com <mailto:lucas.corbeaux@gmail.com>> wrote:
>
> Hi there,
>
> I'm working with Zend Framework since many months, but it's the
> first time I really need custom routes, so I used Zend_Application
> to config my router, and it works really well.
>
> My routes are statics, and looks like :
>
> resources.router.routes.myRoute.type =
> "Zend_Controller_Router_Route_Static"
> resources.router.routes.myRoute.route = "my/route"
> resources.router.routes.myRoute.defaults.action = "index"
> resources.router.routes.myRoute.defaults.controller = "myController"
> resources.router.routes.myRoute.defaults.module = "default"
> resources.router.routes.myRoute.defaults.param= "1"
>
> In my view I use a view helper :
>
> $this->url(array(), 'myRoute');
>
> The link appear as /my/route and forward to
> /default/index/myController, that's great. But when I'm using my
> custom route, all url view helper with a null $route value use the
> current route instead of the default... As all my navigation's
> link... And every link in my application forward to
> /default/index/myController.
>
> I just want to know if it's the standard behaviour, and if I need
> to change all my application's link to specificaly use the
> "default" route...
>
> Thanks for help,
> Lucas
>
>

2009年9月26日星期六

[fw-mvc] How to start a test?

I read the guide reference about testing,  and I think it's different from usual unit test, it is integrated into the frame, isn't it?

If I just want to test a class, but it refers to database, how can I do it?

Does the test classes zf provides need to start the application?

And I prefet to use simpletest framework, can it be deployed well?

--
Location:

Re: [fw-mvc] Zend_Auth_Adapter_Http with db ?

On Saturday 26 September 2009 17:08:01 sina miandashti wrote:
>is that possible to read username and password from db and
>authenticate with Zend_Auth_Adapter_Http ?

If you really must use that adapter, you can use the apache module, mod auth
mysql[1].

The alternative is to use Zend_Auth_Adapter_DbTable

[1] http://modauthmysql.sourceforge.net/
--
"Experience is the name everyone gives to their mistakes."
☘ Oscar Wilde

[fw-mvc] Zend_Auth_Adapter_Http with db ?

is that possible to read username and password from db and
authenticate with Zend_Auth_Adapter_Http ?

--
________________
Sincerely
Sina Miandashti
MuSicBasE.ir & InvisionPower.ir Admin

[fw-mvc] ZendX_JQuery_Form_Element_DatePicker problem under Ajax request

Hi,

I am doing some new forms for an application. Until now i used the ZendX_JQuery_Form_Element_DatePicker in non-ajax requests.

No i have one problem with rendering correctly ZendX_JQuery_Form_Element_DatePicker withind a subform from an ajax request.

The situation is:
1. JQuery and jQuery UI are initialized from controller (or from view)
$this->view->jQuery()->enable()->uiEnable();
and the js libraries are loaded, actually this code added to the view
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/jquery-ui.min.js"></script> 

2. The subform is rendered correctly

3. Problem is no code for initalizing the DatePicker is rendered, as:

<script type="text/javascript"> //<![CDATA[ $(document).ready(function() {     $("#test-1-start_date").datepicker({"showOn":"both","showStatus":"true","buttonImage":"\/admin\/library\/jqueryui\/media\/calendar.gif","buttonImageOnly":"true","dateFormat":"yy-mm-dd","changeMonth":"true","changeYear":"true"}); ); //]]>  </script>

Yes, i know adding the $(document).ready(function() { doesn't makes much sense from ajax, but anyway, i can't find any explanation why the DatePicker initialization code is not rendered also, just the libraries and form code...
--  Best regards, Cristian Bichis www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com

Re: [fw-mvc] redirect after secconds?

Hi,
As far as I know it's only possible with a Refresh header. A custom header is the only option:
$this->getResponse()->setHeader('Refresh', '3; URL=http://my.url.com');


Regards, Jurian
--
Jurian Sluiman
Soflomo.com


Op Saturday 26 September 2009 11:26:29 schreef sina miandashti:
> hi
>
> its possible to use the $this->view->_redirect() to an adress after 3
> secconds ?

[fw-mvc] redirect after secconds?

hi

its possible to use the $this->view->_redirect() to an adress after 3
secconds ?

--
________________
Sincerely
Sina Miandashti
MuSicBasE.ir & InvisionPower.ir Admin

Re: [fw-mvc] how to check if action or partial exists?

On Thursday 24 September 2009 23:34:01 Dimitri van Hees wrote:
>I don't want to render it yet, I just want to know whether I should add
>the partial or the action to my $return_value.
>

$front = Zend_Controller_Front::getInstance();
$dispatcher = $front->getDispatcher();

$test = new Zend_Controller_Request_Http()
$test->setParams(array(
'action' => 'foo',
'controller' => 'bar',
'module' => 'baz'
)
);

if($dispatcher->isDispatchable($test) {
// action method exists
} else {
// no action method, use partial
}

--
"Experience is the name everyone gives to their mistakes."
☘ Oscar Wilde

2009年9月25日星期五

Re: [fw-mvc] How To Extend Zend_Form_Element ?

You may be able to do that using the built-in HtmlTag decorator. It allows you to add any number of HTML tags to your element.


--
Hector


On Fri, Sep 25, 2009 at 12:47 PM, Rémi Goyard <rgoyard@gmail.com> wrote:
Hi, 
 Ok, thank you !
 I was creating a decorator for my forms elements to create tooltips for elements description to have something like that
<div class="description">
  <div class="title">tooltip Title</div>
  <div class="message">tooltip message (the description attribute ok the element)</div>
</div>
 But i want the developper to define his own title, so i would like to override the setDescription() method to accept Array or objects parameter.
 The setDescription method in ZF casts the parameter to string so if i pass an array the value of the description attribute is Array.
 Maybe if i use objects and use the __toString() magic method.
 If you have other ideas ... you're welcome !

Rémi

ps : Excuse me for my english !


On Fri, Sep 25, 2009 at 8:33 PM, Hector Virgen <djvirgen@gmail.com> wrote:
Not that I know of. All form elements extends Zend_Form_Element, so you'll either need to update Zend_Form_Element itself or change the class that all elements extend from.

What kind of functionality are you looking to add? Maybe there is another way around this limitation, or maybe it could be useful for other developers and added to the framework itself.

--
Hector



On Fri, Sep 25, 2009 at 10:46 AM, Rémi Goyard <rgoyard@gmail.com> wrote:
Hi,

  I need to add a method to all my form elements so i want to extend the Zend_Form_Element class.
  Is there a way to do that ?

thanks

Rémi



Re: [fw-mvc] How To Extend Zend_Form_Element ?

Hi, 
 Ok, thank you !
 I was creating a decorator for my forms elements to create tooltips for elements description to have something like that
<div class="description">
  <div class="title">tooltip Title</div>
  <div class="message">tooltip message (the description attribute ok the element)</div>
</div>
 But i want the developper to define his own title, so i would like to override the setDescription() method to accept Array or objects parameter.
 The setDescription method in ZF casts the parameter to string so if i pass an array the value of the description attribute is Array.
 Maybe if i use objects and use the __toString() magic method.
 If you have other ideas ... you're welcome !

Rémi

ps : Excuse me for my english !


On Fri, Sep 25, 2009 at 8:33 PM, Hector Virgen <djvirgen@gmail.com> wrote:
Not that I know of. All form elements extends Zend_Form_Element, so you'll either need to update Zend_Form_Element itself or change the class that all elements extend from.

What kind of functionality are you looking to add? Maybe there is another way around this limitation, or maybe it could be useful for other developers and added to the framework itself.

--
Hector



On Fri, Sep 25, 2009 at 10:46 AM, Rémi Goyard <rgoyard@gmail.com> wrote:
Hi,

  I need to add a method to all my form elements so i want to extend the Zend_Form_Element class.
  Is there a way to do that ?

thanks

Rémi


Re: [fw-mvc] How To Extend Zend_Form_Element ?

Not that I know of. All form elements extends Zend_Form_Element, so you'll either need to update Zend_Form_Element itself or change the class that all elements extend from.

What kind of functionality are you looking to add? Maybe there is another way around this limitation, or maybe it could be useful for other developers and added to the framework itself.

--
Hector


On Fri, Sep 25, 2009 at 10:46 AM, Rémi Goyard <rgoyard@gmail.com> wrote:
Hi,

  I need to add a method to all my form elements so i want to extend the Zend_Form_Element class.
  Is there a way to do that ?

thanks

Rémi

[fw-mvc] How To Extend Zend_Form_Element ?

Hi,

  I need to add a method to all my form elements so i want to extend the Zend_Form_Element class.
  Is there a way to do that ?

thanks

Rémi

[fw-mvc] how to use a 'recursive' route

Hi,

I've searched the whole internet about this issue, but without success, so I'm trying it here now ;-) Imagine I have a site where a user can recursively add subpages. Ofcourse the user isn't able to add routes, so I bet I should add a 'recursive' route. This should be something like: /page* where * = /userinput1/userinput2/userinput3 I assume. Then I think I have to handle this path myself. However, I am unable to get this whole path. Does anyone have a best practice for this? If I use page(/\w+)+ in a regex route I am only able to retrieve the last part (/userinput3) without the preceding path. Anyone?

Kind regards,

Dimitri

2009年9月24日星期四

Re: [fw-mvc] how to get configurations in bootstrap.php

Sorry to tell you that i use it in bootstrap.php under application.

And I prefer to use getOption() now, Thanks!

2009/9/24 Duo Zheng <duozheng@gmail.com>
huajun qi,
Could you be more specific on what you want? Where is $this->_options located at? Action Controller?



On Sep 24, 2009, at 4:40 AM, huajun qi wrote:

I have made it using '$this->_options', but i wonder whether this is a good way?



--
Location:




--
Location:

Re: [fw-mvc] how to check if action or partial exists?

I don't want to render it yet, I just want to know whether I should add the partial or the action to my $return_value. The point is that the website has two containers, and within these containers, per page, the customer needs to sort these containers via the CMS. We've created a symfony plugin for symfony projects and those all work great. However, as I am trying to implement this database/CMS structure to my ZF project, I need to know whether it's a action or a partial. True, I can also add a field to the databse in which I say whether it's a partial or an action, but this is not our default and a quick 'actionExists' or 'isAction' or 'partialExists' or 'isPartial' would do the trick anyway ;-)

Hector Virgen schreef:
I believe $view->render() will throw an exception if the view script could not be found. This may save you from having to run file_exists() and will automatically use the registered view script paths.

As far as the action is concerned, I think Mert is right, but there might be better ways.

Just curious -- why not store the actual information in the database? It would save you from writing tests if you knew how to call it.

--
Hector


On Thu, Sep 24, 2009 at 4:33 AM, Mert Oztekin <moztekin@anadolusigorta.com.tr> wrote:
May be it is the worst answer that can be given, but this should work : you can try method_exists() function to look if barAction exists in YourClass_Bar. And if false, you can check if 'bar.phtml' file exists with file_exists() function.

This should work. But there should be a much better answer.



-----Original Message-----
From: Dimitri van Hees [mailto:dimitri@freshheads.com]
Sent: Thursday, September 24, 2009 2:29 PM
To: fw-mvc@lists.zend.com
Subject: [fw-mvc] how to check if action or partial exists?

Hi,

I am working on a view helper that loops through a set of given
controller/action values. The rank of this set can be modified by the
user (it's stored in the database). However, not everything needs to be
a 'real' action. It could also be a partial, like a single banner. I
would still like to use the same pairs of data, stating that if the
action 'bar' exists in controller 'foo', I am going to output
$this->view->action('bar','foo'). If it doesn't exist, I'd like to check
if there is a partial called 'foor/bar.phtml' and eventually output
$this->view->partial('foor/bar.phtml'). If this also doesn't exist, I'd
like to throw an exception.

However, I can't find any possibility to check whether a partial or an
action in a given controller exists (from within my view helper or
anywhere else). Can anyone tell me if this is possible at all, and if it
is, how? Thanks in advance!

Kind regards,

Dimitri van Hees


Bu mesaj ve ekleri, mesajda g?nderildi?i belirtilen ki?i/ki?ilere ?zeldir ve gizlidir. Size yanl??l?kla ula?m??sa l?tfen g?nderen kisiyi bilgilendiriniz ve mesaj? sisteminizden siliniz. Mesaj ve eklerinin i?eri?i ile ilgili olarak ?irketimizin herhangi bir hukuki sorumlulu?u bulunmamaktad?r. ?irketimiz mesaj?n ve bilgilerinin size de?i?ikli?e u?rayarak veya ge? ula?mas?ndan, b?t?nl???n?n ve gizlili?inin korunamamas?ndan, vir?s i?ermesinden ve bilgisayar sisteminize verebilece?i herhangi bir zarardan sorumlu tutulamaz.

This message and attachments are confidential and intended for the individual(s) stated in this message. If you received this message in error, please immediately notify the sender and delete it from your system. Our company has no legal responsibility for the contents of the message and its attachments. Our company shall have no liability for any changes or late receiving, loss of integrity and confidentiality, viruses and any damages caused in anyway to your computer system.



Re: [fw-mvc] how to get configurations in bootstrap.php



On Thu, Sep 24, 2009 at 3:03 PM, Tomas Bartkus <to.bartkus@gmail.com> wrote:
Why not?

Answer: If you need to check if key exist, you should use method, because method already has that check.


Good point, thanks.

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

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

Re: [fw-mvc] Some question about static route and view helper url

That's the correct behavior. If you don't specify a route name (or pass in NULL), the url will be based on the route that matched the current request. In other words, since the current request matched MyRoute and you want to build a url using the default route, you'll need to specify that to the helper.

--
Hector


On Thu, Sep 24, 2009 at 2:30 AM, Lucas CORBEAUX <lucas.corbeaux@gmail.com> wrote:
Hi there,

I'm working with Zend Framework since many months, but it's the first time I really need custom routes, so I used Zend_Application to config my router, and it works really well.

My routes are statics, and looks like :

resources.router.routes.myRoute.type = "Zend_Controller_Router_Route_Static"
resources.router.routes.myRoute.route = "my/route"
resources.router.routes.myRoute.defaults.action = "index"
resources.router.routes.myRoute.defaults.controller = "myController"
resources.router.routes.myRoute.defaults.module = "default"
resources.router.routes.myRoute.defaults.param= "1"

In my view I use a view helper :

$this->url(array(), 'myRoute');

The link appear as /my/route and forward to /default/index/myController, that's great. But when I'm using my custom route, all url view helper with a null $route value use the current route instead of the default... As all my navigation's link... And every link in my application forward to /default/index/myController.

I just want to know if it's the standard behaviour, and if I need to change all my application's link to specificaly use the "default" route...

Thanks for help,
Lucas

Re: [fw-mvc] how to check if action or partial exists?

I believe $view->render() will throw an exception if the view script could not be found. This may save you from having to run file_exists() and will automatically use the registered view script paths.

As far as the action is concerned, I think Mert is right, but there might be better ways.

Just curious -- why not store the actual information in the database? It would save you from writing tests if you knew how to call it.

--
Hector


On Thu, Sep 24, 2009 at 4:33 AM, Mert Oztekin <moztekin@anadolusigorta.com.tr> wrote:
May be it is the worst answer that can be given, but this should work : you can try method_exists() function to look if barAction exists in YourClass_Bar. And if false, you can check if 'bar.phtml' file exists with file_exists() function.

This should work. But there should be a much better answer.



-----Original Message-----
From: Dimitri van Hees [mailto:dimitri@freshheads.com]
Sent: Thursday, September 24, 2009 2:29 PM
To: fw-mvc@lists.zend.com
Subject: [fw-mvc] how to check if action or partial exists?

Hi,

I am working on a view helper that loops through a set of given
controller/action values. The rank of this set can be modified by the
user (it's stored in the database). However, not everything needs to be
a 'real' action. It could also be a partial, like a single banner. I
would still like to use the same pairs of data, stating that if the
action 'bar' exists in controller 'foo', I am going to output
$this->view->action('bar','foo'). If it doesn't exist, I'd like to check
if there is a partial called 'foor/bar.phtml' and eventually output
$this->view->partial('foor/bar.phtml'). If this also doesn't exist, I'd
like to throw an exception.

However, I can't find any possibility to check whether a partial or an
action in a given controller exists (from within my view helper or
anywhere else). Can anyone tell me if this is possible at all, and if it
is, how? Thanks in advance!

Kind regards,

Dimitri van Hees


Bu mesaj ve ekleri, mesajda g?nderildi?i belirtilen ki?i/ki?ilere ?zeldir ve gizlidir. Size yanl??l?kla ula?m??sa l?tfen g?nderen kisiyi bilgilendiriniz ve mesaj? sisteminizden siliniz. Mesaj ve eklerinin i?eri?i ile ilgili olarak ?irketimizin herhangi bir hukuki sorumlulu?u bulunmamaktad?r. ?irketimiz mesaj?n ve bilgilerinin size de?i?ikli?e u?rayarak veya ge? ula?mas?ndan, b?t?nl???n?n ve gizlili?inin korunamamas?ndan, vir?s i?ermesinden ve bilgisayar sisteminize verebilece?i herhangi bir zarardan sorumlu tutulamaz.

This message and attachments are confidential and intended for the individual(s) stated in this message. If you received this message in error, please immediately notify the sender and delete it from your system. Our company has no legal responsibility for the contents of the message and its attachments. Our company shall have no liability for any changes or late receiving, loss of integrity and confidentiality, viruses and any damages caused in anyway to your computer system.


[fw-db] SpiffyDb Released

I've finally jumped the gun and got an initial release of SpiffyDb
ready. Here's an excerpt from my blog.

"I've just released SpiffyDb for the Zend Framework. SpiffyDb extends
the basic functionality of Zend_Db_Table and Zend_Db_Table_Select and
includes a Model/Mapper as shown in the Zend Framework Quick Start.
These new classes include a hoist of new features and automate much of
the model/mapper functionality that is common to them."

Documentation and download information can be found at
http://www.spiffyjr.me/sd-docs/.

--
Kyle Spraggs (SpiffyJr)
http://www.spiffyjr.me

Re: [fw-auth] How to set up OpenID authentication

I had problems with Google's OpenId. So far I understood, Zend_OpenId was not supporting final OpenId 2.0 protocol version (only draft 11 version of it). 

Maybe you have intentions to implement it? 

Or only me has problems with Google's openId? :-)

--
Regards,
Vladas Diržys


On Thu, Sep 24, 2009 at 18:47, Pádraic Brady <padraic.brady@yahoo.com> wrote:
Unfortunately, Zend_Openid has a few issues. I started doing some testing last week and will roll in some fixes in a while. In the meantime, I suggest reverting to something like the Janrain PHP library while this is being fixed.
 
Pádraic Brady

http://blog.astrumfutura.com
http://www.survivethedeepend.com
OpenID Europe Foundation Irish Representative



From: iceangel89 <comet2005@gmail.com>
To: fw-auth@lists.zend.com
Sent: Thursday, September 24, 2009 3:12:07 PM
Subject: [fw-auth] How to set up OpenID authentication

How to set up OpenID authentication, something of that like StackOverflow. i tried the code from http://framework.zend.com/manual/en/zend.auth.adapter.openid.html
$status = "";
$auth = Zend_Auth::getInstance();
if ((isset($_POST['openid_action']) &&
$_POST['openid_action'] == "login" &&
!empty($_POST['openid_identifier'])) ||
isset($_GET['openid_mode']) ||
isset($_POST['openid_mode'])) {
$result = $auth->authenticate(
new Zend_Auth_Adapter_OpenId(@$_POST['openid_identifier']));
...
this code does not seem to be working... i keep getting posted back to the same page

View this message in context: How to set up OpenID authentication
Sent from the Zend Auth mailing list archive at Nabble.com.