2009年3月31日星期二

Re: [fw-mvc] Paginator throws error "Reversed route is not specified" when using Zend_Controller_Router_Route_Regex

thanks. This solved half of the problem: The pagination is rendered properly
now, but the 'page' attribute does not get set in the paginator's
pagesInRange array. As a result, the url looks like this:

/context/whatever_the_context_is

instead of

/context/whatever_the_context_is/page/[page number]

What else do I have to be aware of?


j5 wrote:
>
> Add one more line to your route config
>
> routes.context.reverse = "context/%s"
>
>
> frank.quosdorf wrote:
>>
>> The following route is specified in config.ini:
>>
>> routes.context.type = "Zend_Controller_Router_Route_Regex"
>> routes.context.route = "context/(.+)"
>> routes.context.defaults.module = "context"
>> routes.context.defaults.controller = "index"
>> routes.context.defaults.action = "index"
>> routes.context.map.1 = "context"
>>
>> and made available in Bootstrap:
>>
>> $router->addConfig($config, "routes");
>>
>> When requesting the route including parameter, the correct controller
>> (context/index) is instantiated and the correct action is triggered.
>> After some pre-processing, the request is forwarded to the search
>> controller of another module:
>>
>> $context = $request->get("context");
>> $contextID = $this->findContextID($context); //... pre-processing
>> return $this->_forward("index", "search", "items");
>>
>> The search controller lists results and uses Zend_Paginator to render the
>> pagination. When calling the search controller directly, Zend_Paginator
>> properly renders the pagination. But, when forwarding the request as
>> described above, the Paginator throws the following error:
>>
>> < b r />< b >Warning< /b >: Cannot assemble. Reversed route is not
>> specified. in < b >[path to Zend ]\library\Zend\Paginator.php< /b > on
>> line < b >388< /b >< b r />
>>
>> Is there anything I need to be aware of when using
>> Zend_Controller_Router_Route_Regex, _forward(), and Zend_Paginator in
>> Zend 1.7.5 ?
>>
>
>

--
View this message in context: http://www.nabble.com/Paginator-throws-error-%22Reversed-route-is-not-specified%22-when-using-Zend_Controller_Router_Route_Regex-tp22738473p22820161.html
Sent from the Zend MVC mailing list archive at Nabble.com.

[fw-db] Table relationships on Rowset object

Hi,

Is there anyway to use the relationship automagic to work with Rowset
objects?

I'm looking at the docs and it doesn't seem so, but I just wanted to check.
For example, let's say I have a 'post' table and I query for 5 rows. For
each 'post' Row that exists in the returned Rowset, I also want to get the
associated 'tag' rows (Toxi like schema: post - tag - post_tag). Is there
anyway to use the findDependentRowset() method to operate on the 'post'
Rowset that is initially returned? I'm thinking possibly by taking the
primary keys of each Row object in the Rowset and forming an IN condition in
the second query. So something like the following would be created:

SELECT `tag`.*, `post_tag`.* FROM `tag` INNER JOIN `post_tag` ON `tag`.`id`
= `post_tag`.`tag_id` WHERE `post_tag.post_id IN (1,2,3,4,5);

Thanks.
--
View this message in context: http://www.nabble.com/Table-relationships-on-Rowset-object-tp22817263p22817263.html
Sent from the Zend DB mailing list archive at Nabble.com.

Re: [fw-mvc] headless controllers

Actually, since you don't need to render anything, it may be better to write an action helper. Then you would just call $this->_helper->myBackgroundTask(); from within any controller that needs to execute the background task.


-Hector


On Tue, Mar 31, 2009 at 4:26 PM, Hector Virgen <djvirgen@gmail.com> wrote:
The most direct way would probably be to use the action stack:

http://framework.zend.com/manual/en/zend.controller.actionhelpers.html#zend.controller.actionhelpers.actionstack

-Hector



On Tue, Mar 31, 2009 at 3:48 PM, Seth Atkins <satkins@nortel.com> wrote:
It would be within a browser. For example, suppose this was a storefront and everytime a product was purchased, units are subtracted from inventory. What if you wanted it to check each time against a predefined threshold of inventory and run a re-stock process which would automatically put in an order to a supplier. That re-stock process doesn't need to be visible to the user, nor does it need to run as a cron job or each time a single order is placed. Only when certain criteria are met.
 
Hence I could see the logic being something like "if foo->quantity < X, forward to bar(controller/action)" Then bar runs and then passes back to the view in foo.
 
So question is, would you use redirects, forwards, pre-dispach, or what to implement this type of application logic.
 
 
--Seth
 


From: Hector Virgen [mailto:djvirgen@gmail.com]
Sent: Tuesday, March 31, 2009 5:38 PM
To: Atkins, Seth (RICH1:5278)
Cc: fw-mvc@lists.zend.com
Subject: Re: [fw-mvc] headless controllers

Is your background task going to run in a browser or as a cronjob?

Also, note that you can instantiate your controllers manually. You just need to pass in valid request/response objects. This works out very well for cron jobs, which I have done in the past to generate/send daily newsletters.

-Hector


On Tue, Mar 31, 2009 at 1:27 PM, Seth Atkins <satkins@nortel.com> wrote:
I can't seem to find a lot of documentation on how one would typically implement a controller without a view. Yes, turning off the view is easy, but not my question.
 
Suppose I have a background task that I want to run under certain conditions. Call it controller1/action1. And after it is done, suppose I want it to go to controller2/index. Is the typical implementation to chain these together through redirects?
Like:
class controller1 extends ActionController
{
    function action1Action()
    {
    //do something
    $this->_redirect('/controller2/index');
    }
}
 
Or is it prefered to chain them together in the dispatch chain using custom pre/post dispatch methods?
 
I know ZF has the flexibility to do it many ways, just trying to get an idea of the pros/cons of the different ways.
 

Seth




Re: [fw-mvc] headless controllers

The most direct way would probably be to use the action stack:

http://framework.zend.com/manual/en/zend.controller.actionhelpers.html#zend.controller.actionhelpers.actionstack

-Hector


On Tue, Mar 31, 2009 at 3:48 PM, Seth Atkins <satkins@nortel.com> wrote:
It would be within a browser. For example, suppose this was a storefront and everytime a product was purchased, units are subtracted from inventory. What if you wanted it to check each time against a predefined threshold of inventory and run a re-stock process which would automatically put in an order to a supplier. That re-stock process doesn't need to be visible to the user, nor does it need to run as a cron job or each time a single order is placed. Only when certain criteria are met.
 
Hence I could see the logic being something like "if foo->quantity < X, forward to bar(controller/action)" Then bar runs and then passes back to the view in foo.
 
So question is, would you use redirects, forwards, pre-dispach, or what to implement this type of application logic.
 
 
--Seth
 


From: Hector Virgen [mailto:djvirgen@gmail.com]
Sent: Tuesday, March 31, 2009 5:38 PM
To: Atkins, Seth (RICH1:5278)
Cc: fw-mvc@lists.zend.com
Subject: Re: [fw-mvc] headless controllers

Is your background task going to run in a browser or as a cronjob?

Also, note that you can instantiate your controllers manually. You just need to pass in valid request/response objects. This works out very well for cron jobs, which I have done in the past to generate/send daily newsletters.

-Hector


On Tue, Mar 31, 2009 at 1:27 PM, Seth Atkins <satkins@nortel.com> wrote:
I can't seem to find a lot of documentation on how one would typically implement a controller without a view. Yes, turning off the view is easy, but not my question.
 
Suppose I have a background task that I want to run under certain conditions. Call it controller1/action1. And after it is done, suppose I want it to go to controller2/index. Is the typical implementation to chain these together through redirects?
Like:
class controller1 extends ActionController
{
    function action1Action()
    {
    //do something
    $this->_redirect('/controller2/index');
    }
}
 
Or is it prefered to chain them together in the dispatch chain using custom pre/post dispatch methods?
 
I know ZF has the flexibility to do it many ways, just trying to get an idea of the pros/cons of the different ways.
 

Seth



RE: [fw-mvc] headless controllers

It would be within a browser. For example, suppose this was a storefront and everytime a product was purchased, units are subtracted from inventory. What if you wanted it to check each time against a predefined threshold of inventory and run a re-stock process which would automatically put in an order to a supplier. That re-stock process doesn't need to be visible to the user, nor does it need to run as a cron job or each time a single order is placed. Only when certain criteria are met.
 
Hence I could see the logic being something like "if foo->quantity < X, forward to bar(controller/action)" Then bar runs and then passes back to the view in foo.
 
So question is, would you use redirects, forwards, pre-dispach, or what to implement this type of application logic.
 
 
--Seth
 


From: Hector Virgen [mailto:djvirgen@gmail.com]
Sent: Tuesday, March 31, 2009 5:38 PM
To: Atkins, Seth (RICH1:5278)
Cc: fw-mvc@lists.zend.com
Subject: Re: [fw-mvc] headless controllers

Is your background task going to run in a browser or as a cronjob?

Also, note that you can instantiate your controllers manually. You just need to pass in valid request/response objects. This works out very well for cron jobs, which I have done in the past to generate/send daily newsletters.

-Hector


On Tue, Mar 31, 2009 at 1:27 PM, Seth Atkins <satkins@nortel.com> wrote:
I can't seem to find a lot of documentation on how one would typically implement a controller without a view. Yes, turning off the view is easy, but not my question.
 
Suppose I have a background task that I want to run under certain conditions. Call it controller1/action1. And after it is done, suppose I want it to go to controller2/index. Is the typical implementation to chain these together through redirects?
Like:
class controller1 extends ActionController
{
    function action1Action()
    {
    //do something
    $this->_redirect('/controller2/index');
    }
}
 
Or is it prefered to chain them together in the dispatch chain using custom pre/post dispatch methods?
 
I know ZF has the flexibility to do it many ways, just trying to get an idea of the pros/cons of the different ways.
 

Seth


Re: [fw-mvc] headless controllers

Is your background task going to run in a browser or as a cronjob?

Also, note that you can instantiate your controllers manually. You just need to pass in valid request/response objects. This works out very well for cron jobs, which I have done in the past to generate/send daily newsletters.

-Hector


On Tue, Mar 31, 2009 at 1:27 PM, Seth Atkins <satkins@nortel.com> wrote:
I can't seem to find a lot of documentation on how one would typically implement a controller without a view. Yes, turning off the view is easy, but not my question.
 
Suppose I have a background task that I want to run under certain conditions. Call it controller1/action1. And after it is done, suppose I want it to go to controller2/index. Is the typical implementation to chain these together through redirects?
Like:
class controller1 extends ActionController
{
    function action1Action()
    {
    //do something
    $this->_redirect('/controller2/index');
    }
}
 
Or is it prefered to chain them together in the dispatch chain using custom pre/post dispatch methods?
 
I know ZF has the flexibility to do it many ways, just trying to get an idea of the pros/cons of the different ways.
 

Seth


Re: [fw-mvc] Getting dojo to work

No, it is possible. The key here is keeping the relative/absolute paths
lined up. the djConfig specified should work fine.

I've got /~dante/mixed/base-xd.html and /~dante/mixed/myns/module.js:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>

<title>Sample Dojo / Dijit Page</title>

<!-- load Tundra theme -->

<!-- load Dojo -->
<script>
var djConfig = {
modulePaths:[
"myns", "myns/"
],
baseUrl:"./mixed/"
}
</script>
<script src="http://o.aolcdn.com/dojo/1.3.0/dojo/dojo.xd.js"></script>
<script type="text/javascript">
dojo.require("myns.module");
dojo.addOnLoad(function(){
new myns.ModuleThing({}, "container");
})
</script>

</head>
<body class="tundra">
<div id="container"></div>
</body>
</html>

and module.js:

dojo.provide("myns.module");
dojo.require("dijit._Widget");

dojo.declare("myns.ModuleThing", dijit._Widget, {
postCreate:function(){
// this widget does nothing.
alert("This is nothing.");
}
});

It should entirely be possible. (though when you go to build, you'll
need to use loader=xd

Regards,
Peter

Matthew Weier O'Phinney wrote:
> -- Zladivliba Voskuy <nospampam@hotmail.fr> wrote
> (on Tuesday, 31 March 2009, 09:52 PM +0200):
>
>> I'm having a few problems to setup dojo with a module I'm using ; here's my
>> code :
>>
>>
>> $this->dojo()->setCdnBase( Zend_Dojo::CDN_BASE_GOOGLE )
>> ->setCdnDojoPath( Zend_Dojo::CDN_DOJO_PATH_GOOGLE )
>> ->addStyleSheetModule( 'dijit.themes.tundra' )
>> ->setDjConfigOption('parseOnLoad', true)
>> ->setDjConfigOption('debug', true)
>> ->setDjConfigOption('debugAtAllCosts', true)
>> ->registerModulePath('baseUrl', '/')
>> ->registerModulePath('dge', '/scripts/dge')
>> ->useCdn();
>>
>> Now the cdn is working ok, but I can't use the dge module. I don't know if the
>> baseUrl is supposed to work this way.
>> I'm trying to get the following result :
>>
>> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/dojo
>> /1.2.3/dojo/dojo.xd.js.uncompressed.js"
>> djConfig="parseOnLoad: true, baseUrl: './', modulePaths: {dge: '../scripts/
>> dge'}, debug:true, debugAtAllCosts:true"></script>
>>
>> Any idea how ?
>>
>
> IIRC, you cannot mix local modules with CDN -- you either have to use
> only the CDN OR use all local resources.
>
>


--
Peter E Higgins
Dojo Project Lead : http://dojotoolkit.org

[fw-mvc] headless controllers

I can't seem to find a lot of documentation on how one would typically implement a controller without a view. Yes, turning off the view is easy, but not my question.
 
Suppose I have a background task that I want to run under certain conditions. Call it controller1/action1. And after it is done, suppose I want it to go to controller2/index. Is the typical implementation to chain these together through redirects?
Like:
class controller1 extends ActionController
{
    function action1Action()
    {
    //do something
    $this->_redirect('/controller2/index');
    }
}
 
Or is it prefered to chain them together in the dispatch chain using custom pre/post dispatch methods?
 
I know ZF has the flexibility to do it many ways, just trying to get an idea of the pros/cons of the different ways.
 

Seth

[fw-auth] ZF and OpenSSO

Has anyone tried to implement OpenSSo instead of Zend_Auth and ACL?

We are trying to convert a current app from using Auth/Acl to OpenSSo and
figured I would see if anyone has experience of heard of this being done.

thanks.

--
View this message in context: http://www.nabble.com/ZF-and-OpenSSO-tp22811471p22811471.html
Sent from the Zend Auth mailing list archive at Nabble.com.

Re: [fw-mvc] Getting dojo to work

-- Zladivliba Voskuy <nospampam@hotmail.fr> wrote
(on Tuesday, 31 March 2009, 09:52 PM +0200):
> I'm having a few problems to setup dojo with a module I'm using ; here's my
> code :
>
>
> $this->dojo()->setCdnBase( Zend_Dojo::CDN_BASE_GOOGLE )
> ->setCdnDojoPath( Zend_Dojo::CDN_DOJO_PATH_GOOGLE )
> ->addStyleSheetModule( 'dijit.themes.tundra' )
> ->setDjConfigOption('parseOnLoad', true)
> ->setDjConfigOption('debug', true)
> ->setDjConfigOption('debugAtAllCosts', true)
> ->registerModulePath('baseUrl', '/')
> ->registerModulePath('dge', '/scripts/dge')
> ->useCdn();
>
> Now the cdn is working ok, but I can't use the dge module. I don't know if the
> baseUrl is supposed to work this way.
> I'm trying to get the following result :
>
> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/dojo
> /1.2.3/dojo/dojo.xd.js.uncompressed.js"
> djConfig="parseOnLoad: true, baseUrl: './', modulePaths: {dge: '../scripts/
> dge'}, debug:true, debugAtAllCosts:true"></script>
>
> Any idea how ?

IIRC, you cannot mix local modules with CDN -- you either have to use
only the CDN OR use all local resources.

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

Re: [fw-webservices] Zend_Server_Reflection_Exception be more specific with your feedback...

-- edub <ewahlstr@gmail.com> wrote
(on Tuesday, 31 March 2009, 12:05 PM -0700):
>
> I am working with creating a Zend_Json_Server and setting some classes like
> so:
>
> $server = new Zend_Json_Server();
>
> $server->setClass('MyClass', 'mynamespace');
>
> When I try to get the smd for this, Zend_Reflection throws the following
> error about my class:
>
> Zend_Server_Reflection_Exception Object
> "Variable number of arguments is not supported for services (except optional
> parameters). Number of function arguments must currespond to actual number
> of arguments described in a docblock."
>
> I understand exactly what this means and have gotten this code to work using
> some less complex classes - however, on the class I am attempting to expose
> right now, I just cannot find where I might have a discrepancy in my
> docblock.
>
> It would be extremely usefull if the Zend_Server_Reflection threw an
> exception that could help pinpoint which method it was having problems
> with... Has anyone had a similar experience?

Wow... I'm not sure how that exception message could be any more clear,
actually.

What it's saying is that there is a discrepancy with the number of
arguments defined in the function call and those in its corresponding
docblock. As an example:

/**
* Do something
*
* @param string $foo
* @return string
*/
public function doSomething($foo, $bar)
{
}

In this example, your function requires 2 parameters -- but your
docblock is only reporting one of them. This is an issue as we cannot
infer any type information on the second parameter -- and thus an
exception is raised.

The opposite is also true:

/**
* Do something
*
* @param string $foo
* @return string
*/
public function doSomething()
{
}

In this case, you may be using func_get_args() to process variable
numbers of arguments in your method. Being a good developer, you've
documented the fact that you might accept a parameter. However, because
there is no corresponding _real_ parameter in the method definition,
reflection is unaware of it, leading to a mismatch between the two.
Again, an exception is raised.

Both situtations are summed up nicely in the last sentence of that
exception message:

"Number of function arguments must correspond to actual number of
arguments described in a docblock."

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

[fw-mvc] Getting dojo to work

Hi everyone,

I'm having a few problems to setup dojo with a module I'm using ; here's my code :

       
       $this->dojo()->setCdnBase( Zend_Dojo::CDN_BASE_GOOGLE )
                     ->setCdnDojoPath( Zend_Dojo::CDN_DOJO_PATH_GOOGLE )
                     ->addStyleSheetModule( 'dijit.themes.tundra' )
                     ->setDjConfigOption('parseOnLoad', true)
                       ->setDjConfigOption('debug', true)
                       ->setDjConfigOption('debugAtAllCosts', true)
                       ->registerModulePath('baseUrl', '/')
                       ->registerModulePath('dge', '/scripts/dge')
                     ->useCdn();

Now the cdn is working ok, but I can't use the dge module. I don't know if the baseUrl is supposed to work this way.
I'm trying to get the following result :
 
  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/dojo/1.2.3/dojo/dojo.xd.js.uncompressed.js"  
  djConfig="parseOnLoad: true, baseUrl: './', modulePaths: {dge: '../scripts/dge'}, debug:true, debugAtAllCosts:true"></script>

Any idea how ?
Z.

--
My zend framework experience... the good, the bad
http://myzendframeworkexperience.blogspot.com/






Découvrez tout ce que Windows Live a à vous apporter !

[fw-webservices] Zend_Server_Reflection_Exception be more specific with your feedback...

I am working with creating a Zend_Json_Server and setting some classes like
so:

$server = new Zend_Json_Server();

$server->setClass('MyClass', 'mynamespace');

When I try to get the smd for this, Zend_Reflection throws the following
error about my class:

Zend_Server_Reflection_Exception Object
"Variable number of arguments is not supported for services (except optional
parameters). Number of function arguments must currespond to actual number
of arguments described in a docblock."

I understand exactly what this means and have gotten this code to work using
some less complex classes - however, on the class I am attempting to expose
right now, I just cannot find where I might have a discrepancy in my
docblock.

It would be extremely usefull if the Zend_Server_Reflection threw an
exception that could help pinpoint which method it was having problems
with... Has anyone had a similar experience?

Extra points to whomever gets the reference in the subject... :P
--
View this message in context: http://www.nabble.com/Zend_Server_Reflection_Exception-be-more-specific-with-your-feedback...-tp22807177p22807177.html
Sent from the Zend Web Services mailing list archive at Nabble.com.

[fw-mvc] Zend_Form setDisableLoadDefaultDecorators Performance

Hi all,

I have a complex form using the ViewScript decorator to render.

I notice that there is the setDisableLoadDefaultDecorators() method
available.

My question is should I call this? Does it make much/any difference to
performance?

My understanding was that Decorators were instantiated on request so I
would have thought it wouldn't do much -- but I still haven't got the
call order exactly clear in my head so I can't be sure.

("Xdebug", a faint voice kept calling...)

TIA
Carlton

Re: [fw-mvc] Accessing view placeholders in view helper called in layout

Since $this->myHelper() makes changes to $this->headLink(), you will need to call $this->myHelper() before calling $this->headLink().

Try capturing the output of $this->myHelper() and then echoing it later:

<?php $myHelper = $this->myHelper(); ?>
<?php echo $this->doctype('XHTML1_STRICT'); ?>
<htm>
<head>
<?php echo $this->headLink(); ?>
</head>
<body>

<?php echo $myHelper; ?>

</body>
</html>


-Hector


2009/3/31 Václav Vaník <vanik@walk.cz>

Well, i found the problem:

i will echo the headLink helper and after then I append to him another
stylesheets.

Well there are imho two possibilities:

a) change the helper to actions and use action stack plugin, which degrades
performance
b) split my view helpers to init() method called before echo of the headLink
and render() method which I insert to the place, where the html code should
be...

Another idea?

Best regards,

Václav Vaník


Václav Vaník wrote:
>
> Here is another problem... It is not necessary to add setView() method
> because my helper inherits Zend_View_Helper_Abstract
>
>
> Paweł Chuchmała wrote:
>>
>> Try add to your helper:
>>    public $view;
>> and
>>     public function setView(Zend_View_Interface $view)
>>     {
>>         $this->view = $view;
>>     }
>>
>>
>> 2009/3/30 Václav Vaník <vanik@walk.cz>:
>>>
>>> Hi guys,
>>>
>>> I have problem with appending e.g. CSS files in view helper called in
>>> layout.phtml
>>>
>>> My example:
>>>
>>> bootstrap:
>>>
>>>    $view = new Zend_View(array('encoding' => 'UTF-8'));
>>>    $view->addHelperPath(ROOT_DIR . '/app/www/views/helpers',
>>> 'Walk_View_Helper');
>>>    $view->addScriptPath(ROOT_DIR . '/app/www/views/scripts');
>>>    $view->doctype('XHTML1_STRICT');
>>>
>>>    $viewRenderer = new
>>> Zend_Controller_Action_Helper_ViewRenderer($view);
>>>    Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
>>>
>>>    $layout = Zend_Layout::startMvc(/path/to/layout.phtml);
>>>    $layout->setView($view);
>>>
>>> layout.phtml:
>>>
>>> <?php echo $this->doctype('XHTML1_STRICT'); ?>
>>> <htm>
>>> <head>
>>> <?php echo $this->headLink(); ?>
>>> </head>
>>> <body>
>>>
>>> <?php echo $this->myHelper(); ?>
>>>
>>> </body>
>>> </html>
>>>
>>> MyHelper:
>>>
>>> class Walk_MyHelper extends Zend_View_Helper_Abstract
>>> {
>>> public function myHelper()
>>> {
>>> $this->view->headLink()->appendStylesheet('/path/to/css');
>>> return 'foo';
>>> }
>>> }
>>>
>>> It seems helper "doesn't see" $this->view :(
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Accessing-view-placeholders-in-view-helper-called-in-layout-tp22782923p22782923.html
>>> Sent from the Zend MVC mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Paweł Chuchmała
>> pawel.chuchmala at gmail dot com
>>
>>
>
>

--
View this message in context: http://www.nabble.com/Accessing-view-placeholders-in-view-helper-called-in-layout-tp22782923p22802238.html
Sent from the Zend MVC mailing list archive at Nabble.com.


Re: [fw-mvc] MVC(/ZF?) complexity

-- Ondrej Ivanič <ondrej.ivanic@gmail.com> wrote
(on Tuesday, 31 March 2009, 04:15 PM +1100):
> On Thu, Mar 26, 2009 at 11:19 PM, Matthew Weier O'Phinney
> <matthew@zend.com> wrote:
> > -- Ondrej Ivanič <ondrej.ivanic@gmail.com> wrote
> > Could it be made simpler? Yes, very likely. Would it lose flexibility
> > in doing so? Yes, very likely.
>
> This wasn't a call to remove some functionality from ZF.
>
> > One of the guiding principles of ZF since the beginning is to provide
> > flexible and extensible solutions so that ZF users can adapt the
> > framework to their needs -- and not the other way around. Most other
> > frameworks take the "convention over configuration" approach which,
>
> Yes, you are right flexibility is good thing I don't like frameworks
> which forced me to use specific naming conventions and tweak millions
> configuration options.
>
> > I have ideas for simplifying the call graph. But all of the ideas above
> > are quite important to the goals of the project.
>
> Could you share your ideas?

Some of them are on th ewiki (search for "Zend_Controller 2.0"). Others
are in development, and I'll be posting about them when they're a bit
more solid and I've had a chance to do some benchmarking and call
graphs.

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

Re: [fw-mvc] Accessing view placeholders in view helper called in layout

Well, i found the problem:

i will echo the headLink helper and after then I append to him another
stylesheets.

Well there are imho two possibilities:

a) change the helper to actions and use action stack plugin, which degrades
performance
b) split my view helpers to init() method called before echo of the headLink
and render() method which I insert to the place, where the html code should
be...

Another idea?

Best regards,

Václav Vaník


Václav Vaník wrote:
>
> Here is another problem... It is not necessary to add setView() method
> because my helper inherits Zend_View_Helper_Abstract
>
>
> Paweł Chuchmała wrote:
>>
>> Try add to your helper:
>> public $view;
>> and
>> public function setView(Zend_View_Interface $view)
>> {
>> $this->view = $view;
>> }
>>
>>
>> 2009/3/30 Václav Vaník <vanik@walk.cz>:
>>>
>>> Hi guys,
>>>
>>> I have problem with appending e.g. CSS files in view helper called in
>>> layout.phtml
>>>
>>> My example:
>>>
>>> bootstrap:
>>>
>>>    $view = new Zend_View(array('encoding' => 'UTF-8'));
>>>    $view->addHelperPath(ROOT_DIR . '/app/www/views/helpers',
>>> 'Walk_View_Helper');
>>>    $view->addScriptPath(ROOT_DIR . '/app/www/views/scripts');
>>>    $view->doctype('XHTML1_STRICT');
>>>
>>>    $viewRenderer = new
>>> Zend_Controller_Action_Helper_ViewRenderer($view);
>>>    Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
>>>
>>>    $layout = Zend_Layout::startMvc(/path/to/layout.phtml);
>>>    $layout->setView($view);
>>>
>>> layout.phtml:
>>>
>>> <?php echo $this->doctype('XHTML1_STRICT'); ?>
>>> <htm>
>>> <head>
>>> <?php echo $this->headLink(); ?>
>>> </head>
>>> <body>
>>>
>>> <?php echo $this->myHelper(); ?>
>>>
>>> </body>
>>> </html>
>>>
>>> MyHelper:
>>>
>>> class Walk_MyHelper extends Zend_View_Helper_Abstract
>>> {
>>> public function myHelper()
>>> {
>>> $this->view->headLink()->appendStylesheet('/path/to/css');
>>> return 'foo';
>>> }
>>> }
>>>
>>> It seems helper "doesn't see" $this->view :(
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Accessing-view-placeholders-in-view-helper-called-in-layout-tp22782923p22782923.html
>>> Sent from the Zend MVC mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Paweł Chuchmała
>> pawel.chuchmala at gmail dot com
>>
>>
>
>

--
View this message in context: http://www.nabble.com/Accessing-view-placeholders-in-view-helper-called-in-layout-tp22782923p22802238.html
Sent from the Zend MVC mailing list archive at Nabble.com.

2009年3月30日星期一

Re: [fw-mvc] Accessing view placeholders in view helper called in layout

Here is another problem... It is not necessary to add setView() method
because my helper inherits Zend_View_Helper_Abstract


Paweł Chuchmała wrote:
>
> Try add to your helper:
> public $view;
> and
> public function setView(Zend_View_Interface $view)
> {
> $this->view = $view;
> }
>
>
> 2009/3/30 Václav Vaník <vanik@walk.cz>:
>>
>> Hi guys,
>>
>> I have problem with appending e.g. CSS files in view helper called in
>> layout.phtml
>>
>> My example:
>>
>> bootstrap:
>>
>>    $view = new Zend_View(array('encoding' => 'UTF-8'));
>>    $view->addHelperPath(ROOT_DIR . '/app/www/views/helpers',
>> 'Walk_View_Helper');
>>    $view->addScriptPath(ROOT_DIR . '/app/www/views/scripts');
>>    $view->doctype('XHTML1_STRICT');
>>
>>    $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view);
>>    Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
>>
>>    $layout = Zend_Layout::startMvc(/path/to/layout.phtml);
>>    $layout->setView($view);
>>
>> layout.phtml:
>>
>> <?php echo $this->doctype('XHTML1_STRICT'); ?>
>> <htm>
>> <head>
>> <?php echo $this->headLink(); ?>
>> </head>
>> <body>
>>
>> <?php echo $this->myHelper(); ?>
>>
>> </body>
>> </html>
>>
>> MyHelper:
>>
>> class Walk_MyHelper extends Zend_View_Helper_Abstract
>> {
>> public function myHelper()
>> {
>> $this->view->headLink()->appendStylesheet('/path/to/css');
>> return 'foo';
>> }
>> }
>>
>> It seems helper "doesn't see" $this->view :(
>> --
>> View this message in context:
>> http://www.nabble.com/Accessing-view-placeholders-in-view-helper-called-in-layout-tp22782923p22782923.html
>> Sent from the Zend MVC mailing list archive at Nabble.com.
>>
>>
>
>
>
> --
> Paweł Chuchmała
> pawel.chuchmala at gmail dot com
>
>

--
View this message in context: http://www.nabble.com/Accessing-view-placeholders-in-view-helper-called-in-layout-tp22782923p22799341.html
Sent from the Zend MVC mailing list archive at Nabble.com.

Re: [fw-mvc] MVC(/ZF?) complexity

Hi

On Thu, Mar 26, 2009 at 11:19 PM, Matthew Weier O'Phinney
<matthew@zend.com> wrote:
> -- Ondrej Ivanič <ondrej.ivanic@gmail.com> wrote
> Could it be made simpler? Yes, very likely. Would it lose flexibility
> in doing so? Yes, very likely.

This wasn't a call to remove some functionality from ZF.

> One of the guiding principles of ZF since the beginning is to provide
> flexible and extensible solutions so that ZF users can adapt the
> framework to their needs -- and not the other way around. Most other
> frameworks take the "convention over configuration" approach which,

Yes, you are right flexibility is good thing I don't like frameworks
which forced me to use specific naming conventions and tweak millions
configuration options.

> I have ideas for simplifying the call graph. But all of the ideas above
> are quite important to the goals of the project.

Could you share your ideas?

--
Ondrej Ivanic
(ondrej.ivanic@gmail.com)

[fw-db] bug(?!) empty configuration node strange affects

This is database section of my configuration file:
  <database>
    <connection>
      <adapter>pdo_mysql</adapter>
      <params>
        <host>192.168.1.177</host>
        <dbname>bbdo</dbname>
        <username>script</username>
        <password>script_stupid</password>
      </params>
    </connection>
  </database>

This is a MySql log file section as a result of connecting:

090331  0:29:17      92 Connect     script@192.168.1.177 on bbdo
                     92 Query       set names utf8
                     92 Query       DESCRIBE `courses`
                     92 Query       SELECT `courses`.* FROM `courses` WHERE (specialised = false)
........................

Everything good.
But.
This is slightly modified version. I simply add empty node <driver_options> (i have another problem related with and i leave it blank).
  <database>
    <connection>
      <adapter>pdo_mysql</adapter>
      <params>
        <host>192.168.1.177</host>
        <dbname>bbdo</dbname>
        <username>script</username>
        <password>script_stupid</password>
        <driver_options>
         
        </driver_options>
      </params>
    </connection>
  </database>


MySql log shows:
090331  0:33:08      93 Connect     script@192.168.1.177 on bbdo
                     93 Query       SET AUTOCOMMIT=0  /* <<<< WHAT IS THIS!? */
                     93 Query       set names utf8
                     93 Query       DESCRIBE `courses`
                     93 Query       SELECT `courses`.* FROM `courses` WHERE (specialised = false)
........................

As you see, a very strange line "SET AUTOCOMMIT=0" appears.

As result of this line, my inserts not works at all, but without any error messages, (and these inserts appears normally in mysql log).

I spend big time trying to understand why my inserts not working, and finally without any hope i try to delete unsuspicious _empy_ '<driver_options>' node from xml configuration, and it  works normally now.

But why _empty_(!) '<driver_options>' node make so effect?
It is a bug? Or what i doing wrong?

Thanks!

Re: [fw-mvc] Module specific Views

-- prodigitalson <ant.cunningham@gmail.com> wrote
(on Monday, 30 March 2009, 01:08 PM -0700):
> Sorry submitted by mistake and then couldnt edit.... Im having trouble figuring
> out certain behavior. I have a modular dir structure, with a module lookin like
> this:
>
> modules/
> --modulename/
> ----controllers/
> ----config/
> ----views/
> ------templates/

Rename the above to 'scripts', and it should work out-of-the-box.

> -------index/
> ----------index.phtml
> --------index.phtml
>
> Ive gotten it to work but its kind of wierd... It always throws an error saying
> it can find the view script if both modulename/views/templates/index.phtml and
> modulename/views/templates/index/index.phtml arent present. Why does it need
> modulename/views/templates/index.phtml? It doesnt seem to be using it for
> anything. When the view is successfully rendered it only consists of my layout
> (located in application/layouts/layout.phtml) wrapping the modulename/views/
> templates/index/index.phtml.

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

Re: [fw-mvc] Module specific Views

Sorry submitted by mistake and then couldnt edit.... Im having trouble figuring out certain behavior. I have a modular dir structure, with a module lookin like this:
 modules/ --modulename/ ----controllers/ ----config/ ----views/ ------templates/  -------index/ ----------index.phtml --------index.phtml 
Ive gotten it to work but its kind of wierd... It always throws an error saying it can find the view script if both modulename/views/templates/index.phtml and modulename/views/templates/index/index.phtml arent present. Why does it need modulename/views/templates/index.phtml? It doesnt seem to be using it for anything. When the view is successfully rendered it only consists of my layout (located in application/layouts/layout.phtml) wrapping the modulename/views/templates/index/index.phtml.

View this message in context: Re: Module specific Views
Sent from the Zend MVC mailing list archive at Nabble.com.

[fw-mvc] Module specific Views

Im having trouble figuring out certain behavior. I have a layout like this
--
View this message in context: http://www.nabble.com/Module-specific-Views-tp22791521p22791521.html
Sent from the Zend MVC mailing list archive at Nabble.com.

Re: [fw-mvc] Virtual Directorys

I think you could write a plugin and in the preDispatch function look
for the controller, if its not found do your database search and then
add the controller's folder to the front controller. It should find it
then. This will work with the action stack and _forward() if you use
them.

Sosy


On Mar 30, 2009, at 12:52 PM, Lionel Morrison wrote:

> Do you have an example of this or where to implement it. I'm
> thinking bootstrap but would this part of the try/catch routine?
>
> Thanks
> Lionel
>
>
> Petre Balau wrote:
>> Hi,
>>
>> You can use a regex route to redirect every requests for virtual
>> directories to a specific module/controller/action.
>>
>> Regards,
>> Peter
>>
>> ------------------------------------------------------------------------
>> *From:* Lionel Morrison <lionel@morrison101.com>
>> *To:* fw-mvc@lists.zend.com
>> *Sent:* Monday, March 30, 2009 7:24:40 PM
>> *Subject:* [fw-mvc] Virtual Directorys
>>
>> I have a website that has virtual directory support via a simple DB
>> lookup. The solution is simple. It looks up the folder name if the
>> physical folder does not exist. Much like what ZF does for it's
>> controllers. I'm converting a site to ZF and I'm clueless on how to
>> implement. If I try to access a folder that doesn't exist, ZF
>> throws an error telling me the controller do not exist. Which is
>> exactly what I expected.
>>
>> Example link: http://www.website.com/8796589
>>
>>
>> Can anyone point me in the right direction.
>>
>

Re: [fw-mvc] Virtual Directorys

Do you have an example of this or where to implement it. I'm thinking
bootstrap but would this part of the try/catch routine?

Thanks
Lionel


Petre Balau wrote:
> Hi,
>
> You can use a regex route to redirect every requests for virtual
> directories to a specific module/controller/action.
>
> Regards,
> Peter
>
> ------------------------------------------------------------------------
> *From:* Lionel Morrison <lionel@morrison101.com>
> *To:* fw-mvc@lists.zend.com
> *Sent:* Monday, March 30, 2009 7:24:40 PM
> *Subject:* [fw-mvc] Virtual Directorys
>
> I have a website that has virtual directory support via a simple DB
> lookup. The solution is simple. It looks up the folder name if the
> physical folder does not exist. Much like what ZF does for it's
> controllers. I'm converting a site to ZF and I'm clueless on how to
> implement. If I try to access a folder that doesn't exist, ZF throws
> an error telling me the controller do not exist. Which is exactly what
> I expected.
>
> Example link: http://www.website.com/8796589
>
>
> Can anyone point me in the right direction.
>

Re: [fw-mvc] Virtual Directorys

Hi,

Not sure if i understood you but what your asking is handled using the Apache rewrite rules. You said the current behavior is exactly what you have expected. So what's the problem then? Maybe i am misunderstanding.

Vince.

On Mon, Mar 30, 2009 at 7:24 PM, Lionel Morrison <lionel@morrison101.com> wrote:
I have a website that has virtual directory support via a simple DB lookup. The solution is simple. It looks up the folder name if the physical folder does not exist. Much like what ZF does for it's controllers. I'm converting a site to ZF and I'm clueless on how to implement. If I try to access a folder that doesn't exist, ZF throws an error telling me the controller do not exist. Which is exactly what I expected.

Example link: http://www.website.com/8796589


Can anyone point me in the right direction.




--
Vincent Gabriel.
Lead Developer, Senior Support.
Zend Certified Engineer.




[fw-mvc] Virtual Directorys

I have a website that has virtual directory support via a simple DB
lookup. The solution is simple. It looks up the folder name if the
physical folder does not exist. Much like what ZF does for it's
controllers. I'm converting a site to ZF and I'm clueless on how to
implement. If I try to access a folder that doesn't exist, ZF throws an
error telling me the controller do not exist. Which is exactly what I
expected.

Example link: http://www.website.com/8796589


Can anyone point me in the right direction.

[fw-db] Zend_Db_Select build by means of union() and Zend_Paginator...

Hi everyone,

I've been trying for so long to get this right but i can't seem to get it
right, i'm building a query by composing several queries with union() but
once i pass this Zend_Db_Select instance to the paginator i get an exception
"No table has been specified for the FROM clause" here's how i build the
query:

$select = $db->select();
$select->union($unionqueries);

$paginator = Zend_Paginator::factory($select);

If i look at the SQL query by calling $select->assemble() everything is ok,
just this problem with the paginator... Can someone please help me get this
right? Should i just retrieve all the results to an array and use that?

TIA,

Alexandre Paes
--
View this message in context: http://www.nabble.com/Zend_Db_Select-build-by-means-of-union%28%29-and-Zend_Paginator...-tp22786727p22786727.html
Sent from the Zend DB mailing list archive at Nabble.com.

Re: [fw-mvc] Module Bootstrap with Zend_Application - error

Matthew Weier O'Phinney wrote:
-- Cristian Bichis <contact@zftutorials.com> wrote (on Monday, 30 March 2009, 06:17 PM +0300):   
 Thanks for reply.  No method of that module bootstrap doesn't get called.  Maybe has something with my setting:  resources.modules = ""  on configs.ini....     
 What happens if you remove that setting?    
Something was wrong on my side (too many folders :) ) on test i made with keith Pope sample.

I re-worked the test and here are my conclusions:

1) With the resources.modules = "" setting in place nothing rendered to browser, no error with his sample, but the module bootstrap was called.

2) If i remove that setting (resources.modules = "") the module Bootstrap is not called but the application otherwise works fine.
--  Best regards, Cristian Bichis www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com

Re: [fw-mvc] Module Bootstrap with Zend_Application - error

-- Cristian Bichis <contact@zftutorials.com> wrote
(on Monday, 30 March 2009, 06:17 PM +0300):
> keith Pope wrote:
> 2009/3/30 Cristian Bichis <contact@zftutorials.com>:
>
>
> Yes, this looks correct.
>
> So in application/Bootstrap.php you have:
>
> run()
> {
> ...dispatch();
> }
>
> In application/modules/admin/Bootstrap.php
>
> run()
> {}
>
> so run() here should be empty
>
> heres one of my older bootstraps, this is totally untested:
>
> class Storefront_Bootstrap extends Zend_Application_Module_Bootstrap
> {
> public function _initModule()
> {
> $this->getResourceLoader()
> ->addResourceType(
> 'modelResource',
> 'models/resources',
> 'Resource'
> );
> $this->getResourceLoader()
> ->addResourceType(
> 'service',
> 'services',
> 'Service'
> );
> }
>
> public function run(){}
> }
>
>
>
> Thanks for reply.
>
> No method of that module bootstrap doesn't get called.
>
> Maybe has something with my setting:
>
> resources.modules = ""
>
> on configs.ini....

What happens if you remove that setting?

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

Re: [fw-mvc] Module Bootstrap with Zend_Application - error

keith Pope wrote:
2009/3/30 Cristian Bichis <contact@zftutorials.com>:   
Yes, this looks correct.  So in application/Bootstrap.php you have:  run() {   ...dispatch(); }  In application/modules/admin/Bootstrap.php  run() {}  so run() here should be empty  heres one of my older bootstraps, this is totally untested:  class Storefront_Bootstrap extends Zend_Application_Module_Bootstrap {     public function _initModule()     {         $this->getResourceLoader()                ->addResourceType(                     'modelResource',                     'models/resources',                     'Resource'                );          $this->getResourceLoader()                ->addResourceType(                     'service',                     'services',                     'Service'                );     }      public function run(){} }    
Thanks for reply.

No method of that module bootstrap doesn't get called.

Maybe has something with my setting:

resources.modules = ""

on configs.ini....

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

   
This worked fine for me now couple of days ago, after svn checkout application is loading many seconds then no error is displayed, logged or whatever...    Also i got a second question. How can be specified the paths to view helpers ?  resources.view.helperPrefix.my = "My_View_Helper_" resources.view.helperPath.my = "My/View/Helper"   Having a look at the view resource Zend_Application_Resource_View, new Zend_View($this->getOptions());, so it you can only set what Zend_View takes in its construct, not sure if this includes helper paths.   Ok, thanks.    -- Best regards, Cristian Bichis www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com        
     

Re: [fw-mvc] Module Bootstrap with Zend_Application - error

2009/3/30 Cristian Bichis <contact@zftutorials.com>:
> keith Pope wrote:
>
> http://code.google.com/p/zendframeworkstorefront/source/browse/#svn/branches/TRY-KP-Zapp
>
> It is only using a single default module at the moment though, your
> admin bootstrap I assume this is:
>
> modules/admin/Bootstrap.php ?
>
> If so I dont believe you need the run to dispatch here, you should
> only have one dispatch call in the main bootstrap class, the module
> specific bootstrap are for setting up module specific settings such as
> resource autoloading.
>
>
> I have module bootstrapping working for a single module here:
>
> I have two bootstraps:
> 1. application/Bootstrap.php
> 2. application/modules/admin/Bootstrap.php
> I have also other modules, and some of modules are gonna have their own
> bootstrap (for setting plugins, aso). I am trying to keep things modularized
> as much as possible so into main Bootstrap to keep just essential.

Yes, this looks correct.

So in application/Bootstrap.php you have:

run()
{
...dispatch();
}

In application/modules/admin/Bootstrap.php

run()
{}

so run() here should be empty

heres one of my older bootstraps, this is totally untested:

class Storefront_Bootstrap extends Zend_Application_Module_Bootstrap
{
public function _initModule()
{
$this->getResourceLoader()
->addResourceType(
'modelResource',
'models/resources',
'Resource'
);
$this->getResourceLoader()
->addResourceType(
'service',
'services',
'Service'
);
}

public function run(){}
}

>
> This worked fine for me now couple of days ago, after svn checkout
> application is loading many seconds then no error is displayed, logged or
> whatever...
>
>
>
> Also i got a second question. How can be specified the paths to view helpers
> ?
>
> resources.view.helperPrefix.my = "My_View_Helper_"
> resources.view.helperPath.my = "My/View/Helper"
>
>
> Having a look at the view resource Zend_Application_Resource_View, new
> Zend_View($this->getOptions());, so it you can only set what Zend_View
> takes in its construct, not sure if this includes helper paths.
>
>
> Ok, thanks.
>
>
>
> --
> Best regards,
> Cristian Bichis
> www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com
>
>
>

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

Re: [fw-mvc] Accessing view placeholders in view helper called in layout

Try add to your helper:
public $view;
and
public function setView(Zend_View_Interface $view)
{
$this->view = $view;
}


2009/3/30 Václav Vaník <vanik@walk.cz>:
>
> Hi guys,
>
> I have problem with appending e.g. CSS files in view helper called in
> layout.phtml
>
> My example:
>
> bootstrap:
>
>    $view = new Zend_View(array('encoding' => 'UTF-8'));
>    $view->addHelperPath(ROOT_DIR . '/app/www/views/helpers',
> 'Walk_View_Helper');
>    $view->addScriptPath(ROOT_DIR . '/app/www/views/scripts');
>    $view->doctype('XHTML1_STRICT');
>
>    $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view);
>    Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
>
>    $layout = Zend_Layout::startMvc(/path/to/layout.phtml);
>    $layout->setView($view);
>
> layout.phtml:
>
> <?php echo $this->doctype('XHTML1_STRICT'); ?>
> <htm>
> <head>
> <?php echo $this->headLink(); ?>
> </head>
> <body>
>
> <?php echo $this->myHelper(); ?>
>
> </body>
> </html>
>
> MyHelper:
>
> class Walk_MyHelper extends Zend_View_Helper_Abstract
> {
> public function myHelper()
> {
> $this->view->headLink()->appendStylesheet('/path/to/css');
> return 'foo';
> }
> }
>
> It seems helper "doesn't see" $this->view :(
> --
> View this message in context: http://www.nabble.com/Accessing-view-placeholders-in-view-helper-called-in-layout-tp22782923p22782923.html
> Sent from the Zend MVC mailing list archive at Nabble.com.
>
>

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

Re: [fw-mvc] Module Bootstrap with Zend_Application - error

keith Pope wrote:
 http://code.google.com/p/zendframeworkstorefront/source/browse/#svn/branches/TRY-KP-Zapp  It is only using a single default module at the moment though, your admin bootstrap I assume this is:  modules/admin/Bootstrap.php ?  If so I dont believe you need the run to dispatch here, you should only have one dispatch call in the main bootstrap class, the module specific bootstrap are for setting up module specific settings such as resource autoloading.   
I have module bootstrapping working for a single module here:
I have two bootstraps:
1. application/Bootstrap.php
2. application/modules/admin/Bootstrap.php
I have also other modules, and some of modules are gonna have their own bootstrap (for setting plugins, aso). I am trying to keep things modularized as much as possible so into main Bootstrap to keep just essential.

This worked fine for me now couple of days ago, after svn checkout application is loading many seconds then no error is displayed, logged or whatever...
   
  Also i got a second question. How can be specified the paths to view helpers ?  resources.view.helperPrefix.my = "My_View_Helper_" resources.view.helperPath.my = "My/View/Helper"     
 Having a look at the view resource Zend_Application_Resource_View, new Zend_View($this->getOptions());, so it you can only set what Zend_View takes in its construct, not sure if this includes helper paths.   
Ok, thanks.



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

Re: [fw-mvc] form->getValues and file upload

Thomas Weidner wrote:
>
> There are only 2 possible ways:
> You can eighter get the database id BEFORE you receive/store the
> file... between validation and retrievement.
No way to be sure of the next id
> Or you have to rename the file manually AFTER you received it and you
> have the database id.
>
>> How can I do this without extending and overloading the getValue()
>> method of the Zend_Form_Element_File ?
>
> As I said before... between validation and retrievement.
>
> In case that the file is very big, you will have severe performance
> problems with this solution.
>
> Think different:
> 1.) Post
> 2.) Validation
> 2.) Create empty database entry and get db-id
> 3.) Set id on form and filename
> 4.) getValues()
>
Is this a good solution in your opinion ?
> As I said before...
> When you want to name the filename after the database id you have only
> 2 ways:
> Eighter get the id BEFORE retrievement, as shown above.
> Or rename the file AFTER you inserted into your database (possible
> performance problems).
>
Create empty database entry and get db-id ?
Do you think I have to do:
$id = $model->insert(array()) ... // with an empty array()
and then $model->update($form->getValues(), $id) ?

and if I have NOT NULL fields ?
if I have FOREIGN KEYS to other tables ?
if I have UNIQUE KEYS ??
If I have many people doing the same concurrent operations with
transactions ?

mmm .. IMHO $form->getValues() simply do not have to move files
and not even filter them in terms of renaming/scaling/watermarking etc ...
just validate them only for MaxFileSize, Count, MimeType, Extension ..
that's all

.. it's only my point of view ;)

thanks anyway

simone

Re: [fw-mvc] Module Bootstrap with Zend_Application - error

2009/3/28 Cristian Bichis <contact@zftutorials.com>:
> Hi,
>
> I worked with Zend_Application last 3 weeks.
>
> I have now one problem with module bootstrap after switching to latest SVN
> version of ZF incubator.
>
> Even with a very very simple mopdule bootstrap as:
>
> <?php
> class Admin_Bootstrap extends Zend_Application_Module_Bootstrap
> {
>     public function run()
>     {
>         $front = Zend_Controller_Front::getInstance();
>         $this->front->dispatch();
>     }
> }
>
> the application takes lot of time to load them is freezing. I tested over
> both Windows and Linux based environments.
>
> Before of that the Zend_Application worked fine for me.
>
> Has anyone a sample of module bootstrapping working with latest version from
> incubator ?

I have module bootstrapping working for a single module here:

http://code.google.com/p/zendframeworkstorefront/source/browse/#svn/branches/TRY-KP-Zapp

It is only using a single default module at the moment though, your
admin bootstrap I assume this is:

modules/admin/Bootstrap.php ?

If so I dont believe you need the run to dispatch here, you should
only have one dispatch call in the main bootstrap class, the module
specific bootstrap are for setting up module specific settings such as
resource autoloading.

>
>
>
> Also i got a second question. How can be specified the paths to view helpers
> ?
>
> resources.view.helperPrefix.my = "My_View_Helper_"
> resources.view.helperPath.my = "My/View/Helper"

Having a look at the view resource Zend_Application_Resource_View, new
Zend_View($this->getOptions());, so it you can only set what Zend_View
takes in its construct, not sure if this includes helper paths.

>
> This doesn't seems to work. I tried couple of versions, no luck.
>
> --
> Best regards,
> Cristian Bichis
> www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com

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

[fw-mvc] Accessing view placeholders in view helper called in layout

Hi guys,

I have problem with appending e.g. CSS files in view helper called in
layout.phtml

My example:

bootstrap:

$view = new Zend_View(array('encoding' => 'UTF-8'));
$view->addHelperPath(ROOT_DIR . '/app/www/views/helpers',
'Walk_View_Helper');
$view->addScriptPath(ROOT_DIR . '/app/www/views/scripts');
$view->doctype('XHTML1_STRICT');

$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view);
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);

$layout = Zend_Layout::startMvc(/path/to/layout.phtml);
$layout->setView($view);

layout.phtml:

<?php echo $this->doctype('XHTML1_STRICT'); ?>
<htm>
<head>
<?php echo $this->headLink(); ?>
</head>
<body>

<?php echo $this->myHelper(); ?>

</body>
</html>

MyHelper:

class Walk_MyHelper extends Zend_View_Helper_Abstract
{
public function myHelper()
{
$this->view->headLink()->appendStylesheet('/path/to/css');
return 'foo';
}
}

It seems helper "doesn't see" $this->view :(
--
View this message in context: http://www.nabble.com/Accessing-view-placeholders-in-view-helper-called-in-layout-tp22782923p22782923.html
Sent from the Zend MVC mailing list archive at Nabble.com.

Re: [fw-mvc] form->getValues and file upload

> mmm .. IMHO $form->getValues() simply do not have to move files
> and not even filter them in terms of renaming/scaling/watermarking etc ...
> just validate them only for MaxFileSize, Count, MimeType, Extension ..
> that's all
>
> .. it's only my point of view ;)

You still miss one thing...
The value of the form file elment is the file itself.

So when you want to have the value of the file element you want to have the
file itself.
This means that when you call getValues(), the file will be received
otherwise you won't get the file.

When you don't want to get the file (as you said before) you must not call
getValues() on the file element.
Simple as is.

But what you are doing is, "get me the file" and then you you shout "I
didn't want to have the file"...
This does not work... eighter you want the file, or you don't want it.

You have do decide which way/solution you want.

When the two ways I showed you do not confirm your needs, then you will have
to do something your own.
Whatever solution you will create... at end you will still have one of the 2
solutions I wrote...
Eighter get the ID before renaming the file, or rename the file after you
received the ID.
( technical details in the solution not included :-) )

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

Re: [fw-mvc] form->getValues and file upload

> Sorry
> (I know you're starting to hate me but I have to understand),
> my last question about the file upload:
>
> Some hints:
> * File elements don't have a value
> OK
>
> * Receive a file multiple time does not make sense FALSE
> I have customers that send to my application files called: update.dat
> constantly (ever the same name and sometime simultaneously)

So your customer sends one file within a form "file.dat" and then you must
receive it multiple times ?

$form->file->receive();
$form->file->receive();
$form->file->receive();

Sorry, but after the first receive there is no file within the temporary
directory of PHP because it's already received.
PHP itself does not allow to receive a file multiple times.

What you are speaking of is to upload a same named file multiple times...
this has nothing to do with receiving the form data multiple times. I still
see no reason why someone should receive a file multiple times.

> * Use filters to change file content or file data while receiving
> (including file name for example)
> how can filter by Rename if I will know the name only AFTER the "insert
> into" Db operation ... (I mean the lastInsertId()) ?

You have a logical problem:
You want to store the file before you have the database id... how should
that work?

There are only 2 possible ways:
You can eighter get the database id BEFORE you receive/store the file...
between validation and retrievement.
Or you have to rename the file manually AFTER you received it and you have
the database id.

> if I do
> $id = $model->insert($form->getValues())
> the fields are filtered but the file is just uploaded (moved) and can't be
> renamed as I want because I will know the ID only when the insert()
> function returns
> if I do
> $id = $model->insert($request->getPost())
> The fields and the file are not filtered

Bad solution

> In my case the flow is:
> 1) Post the form
> 2) Filter the fields (including the files uploaded)
> 3) Insert into Db
> 4) Get the Last Insert Id
> 5) handle (move/rename as {$id}.jpg) the file uploaded

Also a bad solution.

> and NOT
> 1) Post the form
> 2) Filter the fields (including the files uploaded)
> 3) handle (move/rename as {$id}.jpg) the file uploaded
> 4) Insert into Db
> 5) Get the Last Insert Id

Another bad solution. :-)

> How can I do this without extending and overloading the getValue() method
> of the Zend_Form_Element_File ?

As I said before... between validation and retrievement.

> The only way I've found is:
> 1) rename first the file as the session_id() adding a filter Rename =>
> APPLICATION_PATH . '/tmp/' . session_id();
> 2) make the $id = $model->update($form->getValues()) ; // here rename the
> file and filter the fields
> 3) rename(APPLICATION_PATH . '/tmp/' . session_id(), $id.'jpg'); //
> re-rename as I wish

In case that the file is very big, you will have severe performance problems
with this solution.

Think different:
1.) Post
2.) Validation
2.) Create empty database entry and get db-id
3.) Set id on form and filename
4.) getValues()

As I said before...
When you want to name the filename after the database id you have only 2
ways:
Eighter get the id BEFORE retrievement, as shown above.
Or rename the file AFTER you inserted into your database (possible
performance problems).

> In this case I have to manage 2 tmp file ...
> 1 made by php file upload called /tmp/php123.tmp ...
> then renamed to tmp/SESSIONID by the filter ...
> and then manualy renamed to ID.jpg
>
> ... and hope that no1 else have the same session_id()
>
> :\ sad solution
>
> Thomas, congratulations for your job in Zend Framework ...
> I've read all your Blacksheeps paradise
> http://www.thomasweidner.com/flatpress/category/file-transfer/
> but I didn't find the 3-6 lines of code that resolv this problem
>
> bye
>
> Simone

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

Re: [fw-mvc] form->getValues and file upload

Sorry
(I know you're starting to hate me but I have to understand),
my last question about the file upload:

Some hints:
* File elements don't have a value
OK

* Receive a file multiple time does not make sense
FALSE
I have customers that send to my application files called: update.dat
constantly (ever the same name and sometime simultaneously)

* Use filters to change file content or file data while receiving
(including file name for example)
how can filter by Rename if I will know the name only AFTER the "insert
into" Db operation ... (I mean the lastInsertId()) ?

if I do
$id = $model->insert($form->getValues())
the fields are filtered but the file is just uploaded (moved) and can't
be renamed as I want because I will know the ID only when the insert()
function returns

if I do
$id = $model->insert($request->getPost())
The fields and the file are not filtered

In my case the flow is:
1) Post the form
2) Filter the fields (including the files uploaded)
3) Insert into Db
4) Get the Last Insert Id
5) handle (move/rename as {$id}.jpg) the file uploaded

and NOT
1) Post the form
2) Filter the fields (including the files uploaded)
3) handle (move/rename as {$id}.jpg) the file uploaded
4) Insert into Db
5) Get the Last Insert Id

How can I do this without extending and overloading the getValue()
method of the Zend_Form_Element_File ?

The only way I've found is:
1) rename first the file as the session_id() adding a filter Rename =>
APPLICATION_PATH . '/tmp/' . session_id();
2) make the $id = $model->update($form->getValues()) ; // here rename
the file and filter the fields
3) rename(APPLICATION_PATH . '/tmp/' . session_id(), $id.'jpg'); //
re-rename as I wish

In this case I have to manage 2 tmp file ...
1 made by php file upload called /tmp/php123.tmp ...
then renamed to tmp/SESSIONID by the filter ...
and then manualy renamed to ID.jpg

... and hope that no1 else have the same session_id()

:\ sad solution

Thomas, congratulations for your job in Zend Framework ...
I've read all your Blacksheeps paradise
http://www.thomasweidner.com/flatpress/category/file-transfer/
but I didn't find the 3-6 lines of code that resolv this problem

bye

Simone

2009年3月29日星期日

[fw-mvc] Method addMultiOptions does not exist ?

Hey all, I'm trying to populate my select box with data from my db, however, I'm having no success...
 
I get the error: Method addMultiOptions does not exist
 
... snip
 
    /**
     * Setup our vars
     */
    protected $_model;
 
    public function indexAction()
    {
     $model = $this->_getModel();
     $form = $this->_getServiceReportForm();
 
  foreach($model->fetchEntriesOrdered('company_name') as $c)
        {
         $form->getElement('company')->addMultiOptions(array(
   $c['id'] => $c['company_name']
   ));
        }
 
        if ($this->_request->isPost()) {
 
            if ($form->isValid($_POST)) {
             
                /*
                 * Process data
                 */
 
            } else {
             
                /*
                 * Data not valid
                 */             
               $form->populate($this->getRequest()->isPost());
            }
 
        } else {
 
           $this->view->form = $form;
        }
    }
... end snip
 
 
my form has this (extending Zend_Form)
 
        $this->addElement('select', 'company', array(
     'label'   => 'Company:',
     'required'  => true,
  ));
 
.......
 
My Model:
    public function fetchEntriesOrdered($order)
    {
     return $this->getTable()->fetchAll(null, $order)->toArray();
    }