Re: [fw-general] Best way to setup a Default controller that will be called if controller not found

2012-01-25 Thread Hector Virgen
On Wed, Jan 25, 2012 at 7:20 AM, Adam Dear addrum...@gmail.com wrote:

 Is the proper way to create a custom route that routes every request
 to my default controller, and then define routes that send requests to
 few actual controllers that will exist or is there a mechanism that I
 could use in a front controller plugin that would be more appropriate?


I prefer the idea of creating a custom route and mapping it to a common
controller/action that can load any arbitrary page that exists in the
database. For example, you can add this route to your config:

resources.router.routes.page.type = Zend_Controller_Router_Route_Regex
resources.router.routes.page.route = (.*)
resources.router.routes.page.defaults.controller = page
resources.router.routes.page.defaults.action = view
resources.router.routes.page.map.1 = slug
resources.router.routes.page.reverse = %s

This would catch *all* requests and route them to the page controller's
view action. Within that action, you can look in to the database for the
page that matches the slug parameter:

$slug = $this-_request-getParam('slug');

If you visit /about, then $slug will be about. If you visit
/foo/bar/derp.html, then $slug will be foo/bar/derp.html.

This means you'd have one controller, one action, and not need to
copy/paste the same code in multiple controllers. You can also create new
pages by just adding a new row to the database.

In the case where a page cannot be loaded from the database, throwing an
exception from within the action would trigger your error page (error
controller, error action).

The drawback to this approach is that you'll lose the built-in default
routing that maps the URL to module, controller, and action. You may want
to set up new routes to handle specific controllers. For example, if you
wanted to expose the other action methods in your page controller, you
could add a route like this:

resources.router.routes.page.type = Zend_Controller_Router_Route
resources.router.routes.page.route = page/:action/*
resources.router.routes.page.defaults.controller = page

You would have to repeat this for each controller you want to expose.

I hope this helps!

--
*Hector Virgen*
http://www.virgentech.com
Circle me on Google+ https://plus.google.com/101544567700763078999/


Re: [fw-general] Re: Zend_Auth::getInstance()-clearIdentity() doesn't seem to log me out?

2011-12-05 Thread Hector Virgen
Don't forget your logout action will need to set up the Zend_Auth singleton
with the same storage adapter that is used in your login action. If you're
using the default storage adapter, then this likely won't apply to you, but
if you are using a different one (or especially if you're using a custom
one) you'll need to configure Zend_Auth so it will clear the identity
correctly.

If that fixes the problem, I suggest bootstrapping Zend_Auth so that it's
ready to go in all of your actions.

--
*Hector Virgen*
http://www.virgentech.com
Circle me on Google+ https://plus.google.com/101544567700763078999/


Re: [fw-general] Naming controllers

2011-08-15 Thread Hector Virgen
The Controller part of the class name is a convention used by Zend
Framework that must be followed in order for it to be loaded. It also helps
reduce the chances of class name collisions.

You can still think of the controller class as a noun, but you'll need to
follow this convention in order to use it with the Zend_Controller
component.

--
*Hector Virgen*
http://www.virgentech.com
Follow me on Twitter: @djvirgen http://twitter.com/djvirgen






Re: [fw-general] Re: Views error 404 in XP using Zend Server + apache

2011-08-15 Thread Hector Virgen
Is there a .htaccess file in the public folder? Zend Tool should have
created this for you. It should also contain some rewrite rules if you look
in the file. No need to modify anything there unless you need some unique
customization.

Also check Apache's httpd.conf file and ensure that AllowOverride is
enabled. you should have something similar to this:

DocumentRoot /path/to/project/public/
Directory /path/to/project/public/
Order allow,deny
Allow from all
AllowOverride all
/Directory

Note that the document root points to your project's public folder. This
means your URLs will end up looking more like this:

http://localhost/controller/action

I hope this helps!

--
*Hector Virgen*
http://www.virgentech.com
Follow me on Twitter: @djvirgen http://twitter.com/djvirgen


Re: [fw-general] Best practice with routes management using separate .ini

2011-08-15 Thread Hector Virgen
I suggest creating a new bootstrap resource plugin by the same name
router, extend the ZF one, and add your own logic to pull the config from
a separate file.

Something like this should do the trick:

http://pastie.org/2377345

Then update your application.ini with this line:

resources.router.configPath = APPLICATION_PATH /configs/routes.ini

The benefit is that you can still leverage the logic in the original ZF
router bootstrap resource plugin and pretty much copy/paste the routes from
application.ini to routes.ini. Just remove resources. from the beginning
of each line.

I hope this helps!

--
*Hector Virgen*
http://www.virgentech.com
Follow me on Twitter: @djvirgen http://twitter.com/djvirgen



On Mon, Aug 15, 2011 at 1:47 PM, Sergio Rinaudo kaiohken1...@hotmail.comwrote:


 Hi all,
 in my ZF project I have lots of different routes that now are defined
 within the application.ini using the resources.router,
 resources.router.routes.login.* for example .

 Searching on the web I found that some people are using a separate ini file
 only for routes, called route.ini or routes.ini, omitting the
 resources.router part when adding a route.

 So my questions are:

 - is it a good practice to store route configuration in a separate file?
 - is there a standard name for this file?
 - how and where load it?
 - I've already an idea about the above questions answers,  so I give it a
 try, and loading the routes with  resources.router throws a
 Zend_Controller_Router_Exception 'No route configuration in section
 'routes'', why?

 Thanks to everyone will help me to make it clear.

 Regards

 Sergio Rinaudo



Re: [fw-general] Zend_Console_Getopt manage if there no options

2011-07-07 Thread Hector Virgen
That's not exactly how the options work. How it works is if the id
parameter is passed in then an integer value is required. It won't fail if
no id parameter is passed in.

You may want to add this code after the catch block to make the id
argument required:

if (null === $opts-id) {
echo $opts-getUsageMessage();
exit;
}

--
*Hector Virgen*
http://www.virgentech.com
Follow me on Twitter: @djvirgen http://twitter.com/djvirgen



On Thu, Jul 7, 2011 at 7:13 AM, whisher whis...@maktoob.com wrote:

 Hi,
 try {
$opts = new Zend_Console_Getopt(array(
'id=i' = 'id option,required an integer parameter'
));
$opts-parse();
echo $opts-id;
 } catch (Zend_Console_Getopt_Exception $e) {
echo $e-getMessage();
echo $e-getUsageMessage();
exit();
 }
 If I run this snippet above without parameter
 like ./myscript.php I'm waiting an exception instead the script fails
 without error.
 Is it the a feature or I miss something ?
 Thanks in advance
 Bye


 --
 View this message in context:
 http://zend-framework-community.634137.n4.nabble.com/Zend-Console-Getopt-manage-if-there-no-options-tp3651587p3651587.html
 Sent from the Zend Framework mailing list archive at Nabble.com.

 --
 List: fw-general@lists.zend.com
 Info: http://framework.zend.com/archives
 Unsubscribe: fw-general-unsubscr...@lists.zend.com





Re: [fw-general] Re: How can I insert class name for Zend Navigation generated menu?

2011-06-10 Thread Hector Virgen
Can you use :last-child pseudo-selector? It's not available in older
browsers but works great with new browsers and jQuery.

ul.navigation li:last-child{
color: red;
}

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com


Re: [fw-general] Setting list seperator in Zend_View_Helper_FormRadio

2011-05-10 Thread Hector Virgen
On Tue, May 10, 2011 at 11:27 AM, Marcus Stöhr
daf...@soundtrack-board.dewrote:

 How can I pass a custom list seperator to the view helper without extended
 the view helper and duplicate nearly all the code there?


You can call setSeparator() on your form element:

$element-setSeparator('');

Or when you add your element:

$form-addElement('radio', 'my_radio', array(
'separator' = ''
));

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com


Re: [fw-general] Navigation visibility of subpages

2011-05-10 Thread Hector Virgen
Have you tried using setOnlyActiveBranch()?

echo $this-navigation()-menu()-setOnlyActiveBranch(true)-menu();

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com


Re: [fw-general] Module Bootstrap

2011-05-05 Thread Hector Virgen
The pluginPaths option allows you specify *prefixes* to your bootstrap
resource plugins. So you'll want something like this:

pluginPaths.My_Resource =  My/Resource

And you would create your resource plugin here:

My/Resource/Frontcontroller.php

And the class would look something like this:

class My_Resource_Frontcontroller extends
Zend_Application_Bootstrap_Resource_Frontcontroller
{
public function init()
{
parent::init();
}
}

You'll also need to ensure that the class can be autoloaded. In this case,
you'll need to add this line to your application.ini:

autoloadernamespaces[] = My_

And lastly the directory that contains the My directory should be in your
include path. One such place might be the library folder in your
application.

I hope this helps!

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com



On Thu, May 5, 2011 at 4:35 AM, Simon Walter si...@gikaku.com wrote:

 On 05/05/2011 02:35 PM, Greg wrote:

 Instead of overriding the FrontController itself, you could override
 the Front Controller bootstrap resource
 (Zend_Application_Resource_Frontcontroller) - it should be possible to
 specify the dir location for your overriding resources. Then in that
 custom front controller resource class, it could be possible to
 override the init() method to manipulate the controllerdirectory array
 prior to calling the parent init() method, eg:

 My_Resource_Frontcontroller
   extends Zend_Application_Resource_Frontcontroller
 {

 public function init()
 {

//bootstrap dependencies used to figure out which modules to load
   //e.g
   $db = $this-getBootstrap()-bootstrap('db');

   //controller dirs
  $controllerdirectory = array(
'default' =  '/modules/default/controllers'
  );

   $this-setOption('controllerdirectory', $controllerdirectory);

   parent::init(); //sets desired controller dirs in the front controller

 }

 }



 Thanks Greg, that looks like it could work. Where would I specify to use my
 class (My_Resource_Frontcontroller) instead of the default
 (Zend_Application_Resource_Frontcontroller)?

 I read here:
 http://blog.philipbrown.id.au/2009/06/extending-zend-framework-application-resource-plugins/
 and here:
 http://blog.madarco.net/327/how-to-make-your-own-zend-framework-resource-plugin/
 that I should add something like this to my application.ini file:

 pluginPaths.My_Resource_Frontcontroller=  My/Resource/Frontcontroller

 I also read elsewhere that the name of the resource plugin class must just
 end in Frontcontroller in order it to be used for that resource.

 Is that correct?


 --
 List: fw-general@lists.zend.com
 Info: http://framework.zend.com/archives
 Unsubscribe: fw-general-unsubscr...@lists.zend.com





Re: [fw-general] Module Bootstrap

2011-05-04 Thread Hector Virgen
You might want to use a front controller plugin to handle this. The plugin
could inspect the route prior to dispatching (using the routeShutdown()
hook) and if the detected module is disabled it could forward the request to
the error controller.

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com


Re: [fw-general] Re: Change layout in bootstrap

2011-04-27 Thread Hector Virgen
Rename your class to Default_Plugin_Layout (keeping the same file name)
and place this line in your application.ini:

resources.frontController.plugins.layout = Default_Plugin_Layout

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com



On Wed, Apr 27, 2011 at 10:15 AM, ratclot rat_c...@hotmail.com wrote:

 Thanks for your answer. But now i have an error calling de plugin:

 Fatal error: Class 'Plugin_Layout' not found in
 /home/zerego/application/Bootstrap.php on line 8

 application/plugins/Layout.php:

class Layout extends Zend_Controller_Plugin_Abstract
{
public function preDispatch()
{
$user = Zend_Auth::getInstance();
$role = $user-getIdentity()-role;
$layout = Zend_Layout::getMvcInstance();

switch ($role) {
case 'admin':
$layout-setLayout('layout2');
break;

case 'normal':
$layout-setLayout('layout');
break;

default:
$layout-setLayout('layout');
break;
}
}
}

 application/Bootstrap.php:


class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initPlugins()
{
$front = Zend_Controller_Front::getInstance();
$front-registerPlugin(new Plugin_Layout());
}
}


 Sorry but i´m learning zend and OOP by my self. If you can help me again...
 :D


 --
 View this message in context:
 http://zend-framework-community.634137.n4.nabble.com/Change-layout-in-bootstrap-tp3475680p3478808.html
 Sent from the Zend Framework mailing list archive at Nabble.com.

 --
 List: fw-general@lists.zend.com
 Info: http://framework.zend.com/archives
 Unsubscribe: fw-general-unsubscr...@lists.zend.com





Re: [fw-general] Re: Change layout in bootstrap

2011-04-27 Thread Hector Virgen
Also remove any code you added to your bootstrap.php file that attempts to
load this plugin.

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com



On Wed, Apr 27, 2011 at 10:40 AM, ratclot rat_c...@hotmail.com wrote:

 the same error:

 Fatal error: Class 'Plugin_Layout' not found in
 /home/zerego/application/Bootstrap.php on line 8

 i change de layout.php to:

 class Default_Plugin_Layout extends Zend_Controller_Plugin_Abstract

 and put the resources.frontController.plugins.layout =
 Default_Plugin_Layout  in the ini

 :S


 --
 View this message in context:
 http://zend-framework-community.634137.n4.nabble.com/Change-layout-in-bootstrap-tp3475680p3478908.html
 Sent from the Zend Framework mailing list archive at Nabble.com.

 --
 List: fw-general@lists.zend.com
 Info: http://framework.zend.com/archives
 Unsubscribe: fw-general-unsubscr...@lists.zend.com





Re: [fw-general] Re: Reference guide suggestion

2011-04-25 Thread Hector Virgen
That's a pretty nice user script! I like how he used nested lists and placed
the navigation in the sidebar.

I borrowed from his idea and updated my user script to use nested lists and
to pull the title from the h1.

http://www.virgentech.com/userscripts/zfdocs.user.js

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com



On Thu, Apr 21, 2011 at 7:12 PM, David Muir davidkmuir+z...@gmail.comwrote:

 Chris Morrell also put together a greasemonkey script that I've been using:
 http://cmorrell.com/webdev/zf/zend-framework-documentation-777

 Cheers,
 David

 --
 View this message in context:
 http://zend-framework-community.634137.n4.nabble.com/Reference-guide-suggestion-tp3466461p3467235.html
 Sent from the Zend Framework mailing list archive at Nabble.com.

 --
 List: fw-general@lists.zend.com
 Info: http://framework.zend.com/archives
 Unsubscribe: fw-general-unsubscr...@lists.zend.com





Re: [fw-general] Reference guide suggestion

2011-04-21 Thread Hector Virgen
I agree. A couple weeks ago I put together a rudimentary GreaseMonkey script
that automatically places a simple table of contents at the top of the
manual pages. Feel free to use this until the ZF docs are updated:

http://www.virgentech.com/userscripts/zfdocs.user.js

BTW I wrote it in jQuery so it includes the jQuery source at the top. I
didn't have time to learn Dojo but I'm sure it could be ported quite easily.

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com



On Thu, Apr 21, 2011 at 10:22 AM, ctoomey ctoo...@gmail.com wrote:

 Hi, my team and I are new to ZF and have been poring over the Reference
 Guide, which is quite nice.  One suggestion though that would make it
 easier
 to use is to have a table of page contents at the top of each page for the
 sections in the page.  This would list and hyperlink to the page
 sections/sub-sections, which would make it much easier to navigate the
 pages
 when using them for reference lookups.

 For especially the longer pages, e.g.

 http://zendframework.com/manual/en/zend.controller.action.html
 http://zendframework.com/manual/en/zend.controller.actionhelpers.html
 http://zendframework.com/manual/en/zend.cache.frontends.html

 it'd be really handy.

 There are many examples of such table-of-page-contents around the web,
 here's one from the HTML5 spec.

 http://www.w3.org/TR/html5/offline.html

 thx,
 Chris


 --
 View this message in context:
 http://zend-framework-community.634137.n4.nabble.com/Reference-guide-suggestion-tp3466461p3466461.html
 Sent from the Zend Framework mailing list archive at Nabble.com.

 --
 List: fw-general@lists.zend.com
 Info: http://framework.zend.com/archives
 Unsubscribe: fw-general-unsubscr...@lists.zend.com





Re: [fw-general] Zend_Json_Encoder strange behaviour with array of Object

2011-04-21 Thread Hector Virgen
Perhaps you could create a new object that contains your objects and
implements its own toJson method, and then pass that to Zend_Json::encode():

http://pastie.org/1820421

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com


Re: [fw-general] Displaying data in table with select element in each row - how?

2011-04-18 Thread Hector Virgen
You probably don't need Zend_Form for this since you most likely won't be
using element-level validators/filters. So I'd stick to a regular view
script and use the formCheckbox/formSubmit view helpers.

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com


Re: [fw-general] Zend_Cache Two_Levels - APC and Sqlite

2011-04-13 Thread Hector Virgen
Are you using Zend_Cache or APC directly?

BTW I'm surprised about the behavior of APC. According to the docs:

keys are cache-unique, so storing a second value with the same key will
 overwrite the original value.


http://www.php.net/manual/en/function.apc-store.php

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com


Re: [fw-general] after submit form event

2011-03-28 Thread Hector Virgen
You'll need to use AJAX to show the result of the form submission in the
dialog box.

I'm not familiar with Dojo but generally the implementation goes something
like this:

   1. Attach an event handler to the form's submit event to trigger a
   callback function when the submit event is fired.
   2. Within that callback, gather the form's value and submit it via AJAX
   to your webserver.
   3. While still in your callback, return false or use whatever Dojo
   provides to prevent the form from actually submitting.
   4. Set up a callback for AJAX success that updates the dialog with what
   the server responded with.
   5. Don't forget to set up callbacks for error responses.

I hope this helps.

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com


Re: [fw-general] Custom Decorators (buildErrors empty)

2011-03-24 Thread Hector Virgen
On Thu, Mar 24, 2011 at 11:33 AM, My Lists l...@eduardocury.net wrote:

 $element-getMessages(), returns empty.


$element-getMessages() will be empty unless the element's value is invalid.
Are you validating the form (or element) and passing in a known invalid
value?

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com


[fw-general] Zend_Rest_Client and non-XML REST services

2011-03-22 Thread Hector Virgen
Hello,

I'm attempting to use Zend_Rest_Client to talk to our own in-house REST
service which responds with a content-type of application/json, but it seems
that Zend_Rest_Client is only compatible with XML responses. Is there a way
to support non-XML responses such as JSON? Thanks!

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com


Re: [fw-general] Zend_Rest_Client and non-XML REST services

2011-03-22 Thread Hector Virgen
Thanks, Matthew. That's what I've been doing for the time being.

I'm considering putting together a proposal to improve Zend_Rest (for
ZF2.0). Improvements would include:

   - Client support for various response content types (xml, json, etc.)
   - Full level 3 maturity (server and client) according to the Richardson
   Maturity Model
   http://martinfowler.com/articles/richardsonMaturityModel.html

Any thoughts on this?

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com


Re: [fw-general] Re: Detect Mobile use Different View

2011-03-18 Thread Hector Virgen
If you bootstrapped the view, you can access it like this:

$front = Zend_Controller_Front::getInstance();
$bootstrap = $front-getParam('bootstrap');
$view = $bootstrap-getResource('view');

If that returns null, then you can ask the ViewRenderer to initialize the
view for you:

$viewRenderer =
Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
if (null === ($view = $viewRenderer-getView())) {
$viewRenderer-initView();
$view = $viewRenderer-getView();
}

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com


Re: [fw-general] Re: Detect Mobile use Different View

2011-03-18 Thread Hector Virgen
Detecting a mobile device in the bootstrap seems way too early for me. I
haven't used Zend_Useragent yet, but what I know about the bootstrap is that
it's there to *prepare* your application for running. So it wouldn't make
sense to me to detect mobile browsers during bootstrapping. A
front-controller plugin seems the best approach.

Have you tried my suggestions? It seems you should be able to write some
quick logic in your plugin. In pseudo code:

if [Zend_Useragent detects a mobile browser] AND [mobile view script exists]
then update view renderer's view script suffix

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com


Re: [fw-general] Re: How can I extend Zend_View_Helper_Navigation_Menu?

2011-03-17 Thread Hector Virgen
On Thu, Mar 17, 2011 at 3:16 AM, Peter Sharp str...@hotmail.com wrote:

 protected function _initSettings()
{
// Retrieve the view
$this-bootstrap('layout');
$layout = $this-getResource('layout');
$view = $layout-getView();


If you look at the source of Zend_Layout#getView(), it attempts to load the
view instance from the viewRenderer action helper. At this point, the
viewRenderer doesn't have a view instance yet, so Zend_Layout calls
$viewRenderer-initView() which ends up creating a new view instance --
which doesn't have your prefix paths.

The proper way to access the view instance is to pull it from the bootstrap.
Change those 3 lines to this and you should be set:

$this-bootstrap('view');
$view = $this-getResource('view');


 // Register Custom URL Handler
$urlHelper = new Custom_Controller_Action_Helper_Url();
Zend_Controller_Action_HelperBroker::addHelper($urlHelper);

   // Create ACL and add the ACL action helper
$acl = new Custom_Acl();
$aclHelper = new Custom_Controller_Action_Helper_Acl(null,
 array('acl' = $acl));
Zend_Controller_Action_HelperBroker::addHelper($aclHelper);

// Create the site navigation object
$nav_config = new Zend_Config_Xml(APPLICATION_PATH .
 '/configs/navigation.xml', 'nav');
$nav_config = $this-_extrapolateAcl($nav_config-toArray());
$navigation = new Zend_Navigation($nav_config);

$role = Zend_Auth::getInstance()-getIdentity();
if(null == $role)
$role = 'guest';
else
$role = $role-role;

// Attach navigation to the view
$view-navigation($navigation)-setAcl($acl)-setRole($role);


At this point, the navigation helper will add the
Zend_View_Helper_Navigation prefix/path if it is not already registered. If
you bootstrap the view prior to calling this, your prefix paths should
already be set up correctly. You can verify by doing a var_dump() of
$view-getPrefiPaths().


// Other view configuration
$view-addHelperPath('Zend/View/Helper/Navigation',
 'Zend_View_Helper_Navigation');
$view-addHelperPath('Custom/View/Helper', 'Custom_View_Helper');


You don't need to add helper paths here since they were already added in
application.ini and you should now be using a single Zend_View instance
throughout your application. If you decide to keep this code in
_initSettings instead of using application.ini, move these lines towards the
top of this method (before calling $view-navigation()).


$view-doctype('HTML5');


   }


--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com


Re: [fw-general] Error message on a create form

2011-03-16 Thread Hector Virgen
$newsletter-setLabel('Subscribe to Newsletter')*; // -- remove this
semi-colon*
   -setCheckedValue=('1')

Those are easy to miss :)

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com


Re: [fw-general] Error message on a create form

2011-03-16 Thread Hector Virgen
Please see correction below:

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com



On Wed, Mar 16, 2011 at 9:40 AM, Hector Virgen djvir...@gmail.com wrote:

 $newsletter-setLabel('Subscribe to Newsletter')*; // -- remove this
 semi-colon*
-setCheckedValue('1') *-- remove = from method call*



Re: [fw-general] How can I extend Zend_View_Helper_Navigation_Menu?

2011-03-16 Thread Hector Virgen
Zend's Navigation_* view helpers are not located in the same place as all of
the other Zend view helpers. This means the parent Navigation view helper
has to register a new prefix/path pair on its own.

Normally this prefix/path pair gets registered *after* your application is
bootstrapped. This means your prefix paths end up looking like this:

Zend_View_Helper = Zend/View/Helper
Custom_View_Helper = Custom/View/Helper
Zend_View_Helper_Navigation = Zend/View/Helper/Navigation

Since Zend_View uses a LIFO stack for resolving view helper paths, it ends
up finding the menu helper in the path Zend/View/Helper/Navigation and
uses that one -- which is not what you want.

To get around this, you can manually register the prefix/path for Zend's
navigation helpers and then register your custom path. I normally use
application.ini for this:

   resources.view.helperPath.Zend_View_Helper_Navigation =
Zend/View/Helper/Navigation
resources.view.helperPath.Custom_View_Helper = Custom/View/Helper

This results in a prefix/path stack that looks like this:

Zend_View_Helper = Zend/View/Helper
Zend_View_Helper_Navigation = Zend/View/Helper/Navigation
Custom_View_Helper = Custom/View/Helper

At this point Zend_View should now be able to find your custom menu view
helper.

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com


Re: [fw-general] Hiding the default controller in modular layout

2011-03-15 Thread Hector Virgen
Take a look at Zend_Controller_Dispatcher_Standard#isDispatchable()

http://framework.zend.com/apidoc/core/Zend_Controller/Dispatcher/Zend_Controller_Dispatcher_Standard.html#isDispatchable

This may help you accomplish what you want without using a custom route. If
this works, you'll probably want to put it in a controller
plugin's routeShutdown() hook.

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com


Re: [fw-general] Re: Testing ZF models with PHPUnit

2011-03-12 Thread Hector Virgen
I've had good results with always using the unit test bootstrap even when
running individual tests. To ensure the bootstrap is used, I always execute
phpunit from the same directory as my phpunit.xml file (or pass in the
--configuration argument). Something like this:

phpunit --configuration src/tests/phpunit.xml --group models

--
Hector Virgen
Sent from my Droid X
On Mar 12, 2011 11:11 AM, tonystamp tonyst...@hotmail.co.uk wrote:
 Thanks for the pointers. I prefer the second one too, but was wondering if
 that would be best placed in the test bootstrap, or should it placed in
 every individual tests set-up, in case they are run manually (bypassing
the
 unit test bootstrap)?

 --
 View this message in context:
http://zend-framework-community.634137.n4.nabble.com/Testing-ZF-models-with-PHPUnit-tp3348158p3349377.html
 Sent from the Zend Framework mailing list archive at Nabble.com.


Re: [fw-general] Testing ZF models with PHPUnit

2011-03-11 Thread Hector Virgen
Zend_* classes are autoloaded using Zend_Loader_Autoloader, which by default
doesn't know about your module classes.

To fix this, add a setUp() method in your unit test that sets up the module
autoloader. The most straight-forward way to do this that should get it
working right away is to instantiate Zend_Application_Module_Autoloader:

http://pastie.org/1660038

Another approach would be to set up Zend_Application with your config and
bootstrap it:

http://pastie.org/1660060

This method helps ensure that your PHP environment is as close as possible
to your application's environment and benefits from also bootstrapping any
resources that your model may need.

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com



On Fri, Mar 11, 2011 at 5:45 AM, tonystamp tonyst...@hotmail.co.uk wrote:

 Hi, finally managed to get phpunit configured all nice and happy with that,
 but i'm having some trouble autoloading my models into my test scripts. I
 think the issue is that i am calling my models with their namespace prefix
 (new Domain_Model_Something) whereas the test scripts have no idea of the
 namespace as it is throwing a file not found on an include statement.

 My directory structure is:
 project/
 project/application
 project/application/models
 project/application/controllers (etc)
 project/application/tests
 project/library
 project/httpdocs

 Here is my phpunit.xml
 ?xml version=1.0 encoding=UTF-8?



./controllers


./models


./




 ...and the phpunit bootstrap, TestHelper.php;
 ?php
 error_reporting(E_ALL | E_STRICT);
 ini_set('display_errors', 1);

 date_default_timezone_set('Europe/London');

 define('APPLICATION_ENV', 'testing');
 define('APPLICATION_PATH', realpath(dirname(__FILE__) .
 '/../../application'));

 // Directories for include path
 $root = realpath(dirname(__FILE__) . '/../../');
 $library = $root . DIRECTORY_SEPARATOR . 'library';
 $models = $root . DIRECTORY_SEPARATOR . 'application' . DIRECTORY_SEPARATOR
 .'models';

 $path = array(
$library,
$models,
get_include_path()
 );

 set_include_path(implode(PATH_SEPARATOR, $path));

 require_once 'Zend/Loader/Autoloader.php';
 $loader = Zend_Loader_Autoloader::getInstance();

 // Unset global variables
 unset($root, $library, $models, $path);

 And my simple test:
 require_once 'PHPUnit/Framework.php';
class News_ArticleTest extends PHPUnit_Framework_TestCase
{
public function testInstance(){
$news = new Domain_Model_News_Article();
$this-assertInstanceOf('Domain_Model_News_Article',
 $news);
}
}

 Do i need to add the 'Domain' namespace to the autoloader? Testing with
 loading Zend_ classes seems to be ok so i can only assume it has no idea
 what or where a 'Domain_Model_' is?

 --
 View this message in context:
 http://zend-framework-community.634137.n4.nabble.com/Testing-ZF-models-with-PHPUnit-tp3348158p3348158.html
 Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Zend_Db_Select with multiple from's

2011-03-09 Thread Hector Virgen
On Wed, Mar 9, 2011 at 3:14 PM, gelform co...@gelform.com wrote:

 I can't figure out how to set multiple from's.


You can only have one FROM in a SQL query. To join another table, use
$select-join($tableName, $arrayOfFields) or $select-join(array($alias =
$tableName), $arrayOfFields).

The join() method will use an INNER JOIN, but if you need a LEFT JOIN use
the joinLeft() method.

For more info you might want to read up on the documentation:

http://framework.zend.com/manual/en/zend.db.select.html

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com


Re: [fw-general] Re: Zend_Db_Select with multiple from's

2011-03-09 Thread Hector Virgen
On Wed, Mar 9, 2011 at 4:30 PM, gelform co...@gelform.com wrote:

 i guess I have to use raw sql.


What is the resulting SQL you are trying to achieve? Most likely
Zend_Db_Select can be used to generate it.

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com


Re: [fw-general] Zend guru advise on how to build a secure function - could we make a proposal out of this ?

2011-03-08 Thread Hector Virgen
On Tue, Mar 8, 2011 at 8:31 AM, Zladivliba Voskuy nospam...@hotmail.frwrote:

 Less code means less vulnerabiliites.


Hmm.. I would argue that less code means more vulnerabilities. In order to
protect a simple application from potential threats code must be added (e.g.
filters, validators, escaping mechanisms, etc). As for HtmlPurifier, it is
bundled with more code that is there specifically for security reasons.

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com


Re: [fw-general] mv controller modules/default -- not recognised

2011-03-08 Thread Hector Virgen
In Windows the command is move. For more information type move /? in the
command prompt.

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com


Re: [fw-general] Re: Newbie : Message: Invalid controller specified

2011-03-07 Thread Hector Virgen
On Mon, Mar 7, 2011 at 11:06 AM, tkuben tku...@hotmail.com wrote:

 what if you want a URL like this:

 http://localhost/press_release

 Would you create a new controller called press_release and the actions
 associated with it. If the end user requires this to be an underscore. What
 do we do?


The ZF convention is to convert dashes to camel case when it comes to
controllers, e.g.:

/foo-bar = FooBarController
/derp-doo-dun = DerpDooDunController

If you want to use underscores, you'll need to create a route that routes
press_release to whichever controller/action you end up creating to handle
this request. For more information on routes check out the documentation
here:

http://framework.zend.com/manual/en/zend.controller.router.html

If you are using Zend_Application and want to configure your routes with
application.ini, refer to this documentation here:

http://framework.zend.com/manual/en/zend.application.available-resources.html#zend.application.available-resources.router

I hope this helps!

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com


Re: [fw-general] how to use json action context?

2011-03-06 Thread Hector Virgen
The ContextSwitch helper requires the format parameter to be set (see
Zend_Controller_Action_Helper_ContextSwitch#initContext()).

However, you could cheat and add the format parameter to the request at the
top of your init() hook:

public function init()
{
$this-getRequest()-setParam('format', 'json');
/* ... the rest of your code ... */
}

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com


Re: [fw-general] Re: Setting a custom route seems to break zend_navigation URLs

2011-03-03 Thread Hector Virgen
In your navigation configuration you need to specify which route to use for
each page -- it won't default to the default route. Without specifying a
route it's like calling the Url view helper and passing in NULL as the route
(which ends up using the currently matched route).

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com



On Thu, Mar 3, 2011 at 6:01 AM, Stryks str...@hotmail.com wrote:


 Peter Sharp wrote:
 
  I have defined a custom route in order to capture a parameter in the
  middle
  of a URL.
 
  ...
 
  Which seemed to give the desired result.  However, once I have arrived at
  the URL, all my zend_navigation URL's insert the literal part of the
  custom
  route.  i.e. the home link now ends with \vendor.  So once at that URL,
 no
  links work to allow navigation back to the default controller.
 
  ...
 
  I have figured out a workaround, by specifying the default route for each
  element added to zend_navigation, but it seems that this should not be
  required.  Surely the default route should be the ... well ... default
  unless I specify otherwise?
 

 Ok ... so after a long and relatively fruitless search, I decided to have a
 look in the Zend Framework Issue Tracker ... and there we go.

 My workaround seems to be the desired way to use zend_navigation and the
 url
 view helper is to specify  that the default router is to be used on each
 url() call and zend_navigation element in order for the current route not
 to
 be.

 I have commented on the issue I found, but this seems odd to me.  Surely
 'default' should be used by default unless another named route is supplied?

 There is also another issue that I've had and like this one, I somehow
 managed to figure out the way to make it work.  If you have a named route
 and you are using zend_navigation, you must specify a default or required
 value for the variable part(s) of your route or it will throw an exception.

 This may be related to using zend_acl with zend_navigation and custom
 routes, but surely I'm not the only one doing so.

 I am right on both these things, yes?  They are expected?

 Thanks

 --
 View this message in context:
 http://zend-framework-community.634137.n4.nabble.com/Setting-a-custom-route-seems-to-break-zend-navigation-URLs-tp3331646p385.html
 Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Re: Catching ALL Exceptions

2011-03-03 Thread Hector Virgen

 $front-registerPlugin(new MB_Plugins_Exceptions());


You shouldn't have to manually register the error handler plugin -- the
front controller will do this automatically unless you called
$front-throwExceptions(true). That call will internally disable the error
handler plugin.

I think what i need to do is extend Zend_Controller_Plugin_ErrorHandler
 an add a preDispatch() but i'm very much stuck as to how i can do this to
 do what i want.


The dispatcher's try/catch block is designed to catch all exceptions that
extend from the base Exception class, so I'm surprised that an exception
thrown within your action controller is not being caught. Are you sure
that's where it's being thrown from? Take a look at the stack trace to be
sure. And are you sure that the front controller's throwExceptions flag is
false (it is false by default)?

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com


Re: [fw-general] Re: Setting a custom route seems to break zend_navigation URLs

2011-03-03 Thread Hector Virgen
On Thu, Mar 3, 2011 at 1:57 PM, Peter Sharp str...@hotmail.com wrote:

  I guess what I find confusing in this is that the route 'default' is not
 used as the default.  You see the word default and you expect that if
 nothing is specified, then the default value should be used.


I totally agree with your statement. This question and others like it come
up over and over again -- Why is the default route not used when I don't
specify one?

If it were named base or standard like you said it might help, but I
think similar questions will come up -- Why is the base/basic/standard
route not used when I don't specify one?

I posted a comment about this in the Zend_Navigation documentation, but
perhaps it could be made more obvious by specifying this gotcha directly
in the docs.

http://framework.zend.com/manual/en/zend.navigation.pages.html

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com


Re: [fw-general] About a way of refreshing MetaDataCache of Zend_Db_Table.

2011-03-01 Thread Hector Virgen
On Tue, Mar 1, 2011 at 12:00 AM, koji ueda golgok...@gmail.com wrote:

 Is there a way of refresh or clear cache?


If your cache only contains db meta data you can call
$cache-clean(Zend_Cache::CLEANING_MODE_ALL);

If it has other cache data then I suggest using a cache id prefix. Check out
the docs for how to set up the cache id prefix:

http://framework.zend.com/manual/en/zend.cache.frontends.html

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com


Re: [fw-general] Problem accessing view helpers in the default (layout) within modules other than default.

2011-03-01 Thread Hector Virgen
For each module (including the default module) be sure to add the view
script helper path to application.ini. This will prepare your view instance
for loading view helpers from any module, regardless of which module ends up
being routed to.

; Add view helper paths for for default module:
resources.view.helperPath.Default_View_Helper = APPLICATION_PATH
/views/helpers

; Add view helper paths for each module:
knowledgebase.resources.view.helperPath.Knowledgebase_View_Helper =
APPLICATION_PATH /modules/knowledgebase/views/helpers
othermodule.resources.view.helperPath.Othermodule_View_Helper =
APPLICATION_PATH /modules/othermodule/views/helpers

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com



On Mon, Feb 28, 2011 at 4:45 PM, Markizano Draconus asthral...@gmail.comwrote:

 Hey Aaron,


 I am having a bit of trouble with a view helper.  I call a view
 helper in my layout, and it works fine when I am accessing the default
 module, however when I view a module page (with the same layout), I get an
 exception.

 [Exception information]

 Message: Plugin by name 'LoggedInAs' was not found in the registry; used
 paths: Knowledgebase_View_Helper_:

 /home/amurray/projects/bizweb/application/modules/Knowledgebase/views/helper
 s/ Zend_View_Helper_: Zend/View/Helper/

 [In APPLICATION_PATH/application/views/helpers/LoggedInAs.php]

 class Zend_View_Helper_LoggedInAs extends Zend_View_Helper_Abstract {
public function loggedInAs() {
// [script inside function working fine]
}
 }



 Consider:

 class Knowledgebase_View_Helper_LoggedInAs extends
 Zend_View_Helper_Abstract {

public function loggedInAs() {
// [script inside function working fine]
}
 }

 Instead of the class that you are using right now.

 By using the class name

 Zend_View_Helper_LoggedInAs

 It's implied that the file:

 Zend/View/Helper/LoggedInAs.php

 needs to be loaded. Unless this view helper actually was in the ZF library,
 then that might be okay. However, it seems you are attempting to load
 something in your default application/views/helpers path, which means, you
 can use the default class names.

 Hope this helps,
 -Kizano
 //-
 Information Security
 eMail: asthral...@gmail.com
 http://www.markizano.net/



Re: [fw-general] Detecting a routing error in a controller plugin

2011-02-18 Thread Hector Virgen
In your error controller, at the end of the errorAction() method, make a
call to $this-renderScript() and pass in a relative path to your error
script template -- relative as in relative to one of your view script
paths. I hope this helps!

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com



On Fri, Feb 18, 2011 at 12:14 PM, Ryan Lange cl1mh422...@gmail.com wrote:

 In an application that I'm creating, I have the need to have all view
 scripts (including those for modules) in a non-standard directory, as well
 as change the default extension. The relevant directory structure would
 look
 like this:

 base path/
application/
modules/
ModuleName/
public/
Templates/
zf-views/
module-name/
index/
index.tpl.php
error/
error.tpl.php

  I've decided to use a controller plugin to do this globally:

 ?php

 class Emg_Plugin_View extends Zend_Controller_Plugin_Abstract
 {
/**
 * @var Zend_Controller_Action_Helper_ViewRenderer
 */
protected $_view_renderer;

/**
 * Sets the view script extension and the base script path before
 routing
 * occurs.
 *
 * This is done so that, if there's a routing error (e.g. invalid
 module,
 * controller, or action), the view script for the error controller can
 be
 * found.
 *
 * We can't check for the requested module and adjust the path
 accordingly
 * because that information hasn't been extracted from the requested URI
 at
 * this point.
 *
 * @param Zend_Controller_Request_Abstract $request
 * @return void
 */
public function routeStartup( Zend_Controller_Request_Abstract $request
 )
{
$this-_getViewRenderer()-setViewSuffix( 'tpl.php' );
$this-_getView()-setScriptPath( PUBLIC_PATH .
 '/Templates/zf-views' );
}

/**
 * Adjusts the script path for modules.
 *
 * @param Zend_Controller_Request_Abstract $request
 * @return void
 */
public function dispatchLoopStartup( Zend_Controller_Request_Abstract
 $request )
{
if( 'default' != $request-getModuleName() ) {
$this-_getView()-setScriptPath( PUBLIC_PATH .
 '/Templates/zf-views/' . $request-getModuleName() );
}
}

/**
 * @return Zend_Controller_Action_Helper_ViewRenderer
 */
protected function _getViewRenderer()
{
if( null === $this-_view_renderer ) {
$this-_view_renderer =
 Zend_Controller_Action_HelperBroker::getStaticHelper( 'ViewRenderer' );
}

return $this-_view_renderer;
}

/**
 * @return Zend_View_Interface
 */
protected function _getView()
{
return $this-_getViewRenderer()-view;
}
 }

 The problem I'm running into is that if a non-existent controller or action
 is requested in the ModuleName module (let's say /module-name/foo), I get
 the following exception:

 Fatal error: Uncaught exception 'Zend_View_Exception' with message 'script
 'error/error.tpl.php' not found in path (base
 path/application/views/scripts/:base
 path/htdocs/Templates/zf-views/module-name/)' in base
 path/library/Zend/View/Abstract.php:980
 Stack trace:
 #0 base path/library/Zend/View/Abstract.php(876):
 Zend_View_Abstract-_script('error/error.tpl...')
 #1 base path/library/Zend/Controller/Action/Helper/ViewRenderer.php(898):
 Zend_View_Abstract-render('error/error.tpl...')
 #2 base path/library/Zend/Controller/Action/Helper/ViewRenderer.php(919):

 Zend_Controller_Action_Helper_ViewRenderer-renderScript('error/error.tpl...',
 NULL)
 #3 base path/library/Zend/Controller/Action/Helper/ViewRenderer.php(958):
 Zend_Controller_Action_Helper_ViewRenderer-render()
 #4 base path/library/ in base path/library/Zend/View/Abstract.php on
 line 980

 Not surprisingly, given the code above, it's trying to look for the error
 view script in ModuleName's view script path. What I need to do is, in
 dispatchLoopStartup(), forgo updating the script path with the module name
 if there's been a routing error. I'm just not sure how to go about that.
 I've tried both of the following if conditions...

 if( 'default' != $request-getModuleName()  'error' !=
 $request-getControllerName() ) {

 ...and...

 if( 'default' != $request-getModuleName()  null === $request-getParam(
 'error_handler' ) ) {

 ...but neither have solved my problem.

 Any help would be appreciated. Any suggestions on how to handle the
 situation in general more elegantly would also be appreciated. ;o)


 Thanks,
 Ryan Lange



Re: [fw-general] How can I inlude flashMessenger messages in JSON context

2011-02-11 Thread Hector Virgen
When using the JSON context with the ContextSwitch helper, all view
variables are returned in the JSON response. So the easiest thing to do is
to provide the FlashMessenger messages to the view.

Add one of these lines in your controller's action method:

// Get messages stored during previous request:
$this-view-flashMessages = $this-getMessages();

// Get messages stored during current request:
$this-view-flashMessages = $this-getCurrentMessages();

Or you can use array_merge() to merge both of them together.

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com


Re: [fw-general] Re: How can I inlude flashMessenger messages in JSON context

2011-02-11 Thread Hector Virgen
On Fri, Feb 11, 2011 at 9:52 AM, gelform co...@gelform.com wrote:


 I was able to create a plugin and get the messages, but I'm not sure how to
 send them to the view?


I suggest bootstrapping the view (if you're not already) and pulling it
statically from the bootstrap in your controller plugin:

$front = Zend_Controller_Front::getInstance();
$bootstrap = $front-getParam('bootstrap');
$view = $bootstrap-getResource('view');

If you're not bootstrapping the view, then $bootstrap-getResource('view') may
return null.. to fix that, add this line to your application.ini:

resources.view[] =

I hope this helps!

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com


Re: [fw-general] Re: How can I inlude flashMessenger messages in JSON context

2011-02-11 Thread Hector Virgen
I believe the correct approach is to assign those to $this-layout(), for
example:

## views/scripts/index/index.phtml
?php $this-layout()-foo = Foo! ?

## layouts/scripts/layout.phtml
?php echo $this-layout()-foo ?

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com


Re: [fw-general] Re: [zf-contributors] Re: [fw-general] Re: [zf-contributors] Discontinuing Maintenance of ZendX JQuery - Suggest drop for 2.0

2011-01-31 Thread Hector Virgen
 Damn. As a high-level userland freeloader I have been loving the
convenience
 of doing what seems kind of like time travel --
 $this-JQuery()-onLoadCaptureStart() -- in my views. I wonder how you
might
 hack up something equivalent in ZF 2.0.

I use this:

jQuery(function($){
// js code goes here
});

It's regular jquery so you can place it in an external file or use
$this-headScript()-appendScript($jscode);


Re: [fw-general] Re: why Zend_Db_Adapter happened to be much slower than mysql_query

2011-01-27 Thread Hector Virgen
Since you're using transactions I don't see why there would be such a big
difference between Zend_Db and mysql_query(). Have you tried running this
several times and averaging the results?

If these results are consistent, you might want to try modifying your timer
so you can see how long it takes to build the query and execute the query
separately. And also time the commit() call mysql_query() equivalent.

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com



On Thu, Jan 27, 2011 at 2:25 AM, Oleg_201080 opp20071...@gmail.com wrote:


 I don't beleive that using Zend_Db is several times slower, maybe I'm doing
 something wrong with it.
 These results seems very suprising to me.
 --
 View this message in context:
 http://zend-framework-community.634137.n4.nabble.com/why-Zend-Db-Adapter-happened-to-be-much-slower-than-mysql-query-tp3241873p3241882.html
 Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Re: Search for existing value in headMeta

2011-01-27 Thread Hector Virgen
Jurien, back to your original post, generally what I do is I set the
default meta tags early in the application (usually during bootstrap) and
actions/views can replace them if necessary by providing new values using
the normal view helper methods. This means my layout just has a simple echo
and no logic:

?php echo $this-headMeta(); ?

As for handling this in the bootstrap, I've written a nifty meta bootstrap
resource plugin that allows me to configure each environment with different
defaults. Feel free to check it out here: http://pastie.org/1504249

My configuration for this resource looks like this:

; Meta data
resources.meta.names.title = Virgen Technologies
resources.meta.names.description = Web technologies and stuff!
resources.meta.names.keywords = php mysql apache zend framework
resources.meta.httpEquivs.expires = Wed, 26 Feb 1997 08:21:57 GMT
resources.meta.httpEquivs.pragma = no-cache
resources.meta.httpEquivs.Cache-Control = no-cache
resources.meta.httpEquivs.Content-Type = text/html;charset=utf-8
resources.meta.httpEquivs.Content-Language = en-US

I hope this helps!

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com



On Thu, Jan 27, 2011 at 3:12 PM, Wil Moore III wil.mo...@wilmoore.comwrote:



 weierophinney wrote:
 
  the storage into Zend_Registry. I'm not sure how much any of this is
  really relevant to the need you explained in a previous post, however...
 
 From what I know of these helpers, it is due to the initial design that is
 limiting his use case.

 The registry (it doesn't have to be a global static, it could have been an
 object instance) would have been better since it is an ArrayObject
 (implements offsetExists); however, at a minimum, the the helpers could
 have
 extended ArrayObject and it would have been all good.


 -
 --
 Wil Moore III

 Why is Bottom-posting better than Top-posting:
 http://www.caliburn.nl/topposting.html

 DO NOT TOP-POST and DO trim your replies:
 http://linux.sgms-centre.com/misc/netiquette.php#toppost
 --
 View this message in context:
 http://zend-framework-community.634137.n4.nabble.com/Search-for-existing-value-in-headMeta-tp3237161p3243407.html
 Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Zend_Mail enable/disable

2011-01-04 Thread Hector Virgen
You can try using the File transport:

http://framework.zend.com/manual/en/zend.mail.different-transports.html

It writes outbound mail to a file instead of sending over the internet. You
can configure it with application.ini:

resources.mail.transport.type = file

Or you can try creating your own blackhole transport if you just want them
to disappear forever.

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com



On Tue, Jan 4, 2011 at 8:37 AM, Antonio Caccese i...@antoniocaccese.itwrote:

 Hi, exist a way to enable/disable email sending, for example in
 application.ini?

 Thank you




Re: [fw-general] Get full html response in a plugin

2010-12-22 Thread Hector Virgen
You'll need to register your plugin after the layout plugin, which I believe
is registered in position 100. Try this:

$front-registerPlugin($myplugin, 150);

Also don't forget to return early in your post-dispatch hook if the request
is not marked as dispatched (meaning a forward was detected):

if (!$request-isDispatched()) {
return;
}

--
Hector Virgen
Sent from my Droid X
On Dec 22, 2010 4:53 PM, Sergio Rinaudo kaiohken1...@hotmail.com wrote:

 Hi all,
 how to get and set the full html response in a plugin?

 I'm trying to minify the html response but apparently I cannot get and set
the the full html response using response object's
 getBody/setBody methods.

 I am currently working inside the postDispatch hook in my test plugin.


 Thanks for any help.


 Sergio





Re: RE: [fw-general] Get full html response in a plugin

2010-12-22 Thread Hector Virgen
You should benchmark your app with and without the plugin. Try benchmarking
common pages like the homepage, login, etc. and see for yourself if the
performance gains outweigh the minification-on-the-fly cost.

--
Hector Virgen
Sent from my Droid X
On Dec 22, 2010 7:56 PM, Sergio Rinaudo kaiohken1...@hotmail.com wrote:

 Hi Hector,
 it perfectly worked!

 Do you think is a good idea minify the html response in this way to
increase performances?

 Thank you very much for your help

 Sergio




 Date: Wed, 22 Dec 2010 19:35:23 -0800
 Subject: Re: [fw-general] Get full html response in a plugin
 From: djvir...@gmail.com
 To: kaiohken1...@hotmail.com
 CC: fw-general@lists.zend.com

 You'll need to register your plugin after the layout plugin, which I
believe is registered in position 100. Try this:
 $front-registerPlugin($myplugin, 150);
 Also don't forget to return early in your post-dispatch hook if the
request is not marked as dispatched (meaning a forward was detected):
 if (!$request-isDispatched()) {

 return;

 }
 --

 Hector Virgen

 Sent from my Droid X
 On Dec 22, 2010 4:53 PM, Sergio Rinaudo kaiohken1...@hotmail.com
wrote:

 Hi all,
 how to get and set the full html response in a plugin?


 I'm trying to minify the html response but apparently I cannot get and
set the the full html response using response object's
 getBody/setBody methods.

 I am currently working inside the postDispatch hook in my test plugin.



 Thanks for any help.


 Sergio






Re: [fw-general] How to not enter in the frontController's dispatch loop properly ?

2010-12-20 Thread Hector Virgen
Have you tried calling $request-setDispatched(true) within your plugin?
That should prevent the dispatcher from dispatching your action controller.
You may also want to disable your layout to prevent it from double
rendering.

--
Hector Virgen
Sent from my Droid X
On Dec 20, 2010 7:54 AM, benoit benoit.delpo...@gmail.com wrote:


Re: [fw-general] delete, update params quoting

2010-12-07 Thread Hector Virgen
Hi Fred,

From the documentation:

If you provide an array of arrays as the third argument, the values will be
 automatically quoted into the keys. These will then be joined together as
 terms, separated by AND operators.


http://framework.zend.com/manual/en/zend.db.adapter.html#zend.db.adapter.write.update

Although I think the wording is a bit off. You don't need to pass in an
array of arrays, but instead just an associative array. So your call would
look like this:

$this-update($data, array('id = ?' = $obj-id));

I hope this helps!
http://framework.zend.com/manual/en/zend.db.adapter.html
--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com



On Mon, Dec 6, 2010 at 11:59 AM, Fred Garlov fredgarlo...@googlemail.comwrote:

 Hello,

 is there any reason for not having auto quoting of query parameters
 for delete() and update() methods?

 $this-update($data, $this-getAdapter()-quoteInto('id = ?', $obj-id));

 I mean, we have it for where() method: $query =
 $this-select()-where('id = ?', $value);

 IMHO, it would be uniformly and easily like this:

 $this-update($data, 'id = ?', $obj-id);

 Regards, Fred



Re: [fw-general] headlink append seems to prepend

2010-12-06 Thread Hector Virgen
The code snippet provided by the OP has worked for me.

Since Zend_Layout follows the two-step view pattern, the inner view is
rendered first (which has the call to appendStylesheet()) and then the
layout is rendered (which has a call to prependStylesheet()). So the order
of things should look like this:

Controller (or view) calls appendStylesheet('/c/css/homepage.css')
Stylesheet stack looks like ['/c/css/homepage.css']

Layout calls prependStylesheet('/c/css/loader.css')
Stylesheet stack looks like ['/c/css/loader.css', '/c/css/homepage.css']

End result should be loader.css followed by homepage.css. I'm not sure why
the OP is getting different results. More detail on the code snippet might
be useful.

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com


Re: [fw-general] Problems with Zend Test and redirects in controller plugins

2010-12-06 Thread Hector Virgen
You need to return the redirector for unit tests:

return $redirector-gotoSimple(/*...*/);

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com



On Mon, Dec 6, 2010 at 3:00 PM, Fernando Morgenstern 
cont...@fernandomarcelo.com wrote:

 Hi,

 I'm having some issues with Zend Test and controller plugins.

 The issue is specifically with an Auth plugin that i have. If i have this
 code:

 $redirector =
 Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
 $redirector-gotoSimple('index', 'login', 'public');
 return;

 It's ignored by Zend Test and it executes the code in controllers without
 applying the redirect.

 If i use the same redirect code in controllers, it works ok.

 Is this a bug in Zend Test? Any way to fix this issue?

 Regards,

 Fernando Morgenstern
 cont...@fernandomarcelo.com






Re: [fw-general] Problems with Zend Test and redirects in controller plugins

2010-12-06 Thread Hector Virgen
I didn't realize this was from within a plugin. Which hook are you in? Did
you try calling $request-isDispatched(true)?

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com



On Mon, Dec 6, 2010 at 4:18 PM, Fernando Marcelo 
cont...@fernandomarcelo.com wrote:

 Thanks for the reply but i also tried this in the past and i get the same
 result: controller code is still executed and redirect is ignored.

 Any other ideas?

 Regards,

 Fernando Morgenstern
 cont...@fernandomarcelo.com




 Em 06/12/2010, às 22:14, Hector Virgen escreveu:

  You need to return the redirector for unit tests:
 
  return $redirector-gotoSimple(/*...*/);
 
  --
  Hector Virgen
  Sr. Web Developer
  http://www.virgentech.com
 
 
 
  On Mon, Dec 6, 2010 at 3:00 PM, Fernando Morgenstern 
 cont...@fernandomarcelo.com wrote:
  Hi,
 
  I'm having some issues with Zend Test and controller plugins.
 
  The issue is specifically with an Auth plugin that i have. If i have this
 code:
 
  $redirector =
 Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
  $redirector-gotoSimple('index', 'login', 'public');
  return;
 
  It's ignored by Zend Test and it executes the code in controllers without
 applying the redirect.
 
  If i use the same redirect code in controllers, it works ok.
 
  Is this a bug in Zend Test? Any way to fix this issue?
 
  Regards,
 
  Fernando Morgenstern
  cont...@fernandomarcelo.com
 
 
 
 




Re: [fw-general] Problems with Zend Test and redirects in controller plugins

2010-12-06 Thread Hector Virgen
If you tell the request that it has already been dispatched, it will skip
dispatching the action controller. There are certain times (like when
redirecting) that you'll want to skip dispatching.

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com



On Mon, Dec 6, 2010 at 4:32 PM, Fernando Marcelo 
cont...@fernandomarcelo.com wrote:

 Hi,

 I'm using it in preDispatch hook.

  Did you try calling $request-isDispatched(true)?

 Sorry, but i don't see a relation between this code and my problem. Could
 you please explain?

 Regards,

 Fernando Morgenstern
 cont...@fernandomarcelo.com




 Em 06/12/2010, às 22:27, Hector Virgen escreveu:

  I didn't realize this was from within a plugin. Which hook are you in?
 Did you try calling $request-isDispatched(true)?
 
  --
  Hector Virgen
  Sr. Web Developer
  http://www.virgentech.com
 
 
 
  On Mon, Dec 6, 2010 at 4:18 PM, Fernando Marcelo 
 cont...@fernandomarcelo.com wrote:
  Thanks for the reply but i also tried this in the past and i get the same
 result: controller code is still executed and redirect is ignored.
 
  Any other ideas?
 
  Regards,
 
  Fernando Morgenstern
  cont...@fernandomarcelo.com
 
 
 
 
  Em 06/12/2010, às 22:14, Hector Virgen escreveu:
 
   You need to return the redirector for unit tests:
  
   return $redirector-gotoSimple(/*...*/);
  
   --
   Hector Virgen
   Sr. Web Developer
   http://www.virgentech.com
  
  
  
   On Mon, Dec 6, 2010 at 3:00 PM, Fernando Morgenstern 
 cont...@fernandomarcelo.com wrote:
   Hi,
  
   I'm having some issues with Zend Test and controller plugins.
  
   The issue is specifically with an Auth plugin that i have. If i have
 this code:
  
   $redirector =
 Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
   $redirector-gotoSimple('index', 'login', 'public');
   return;
  
   It's ignored by Zend Test and it executes the code in controllers
 without applying the redirect.
  
   If i use the same redirect code in controllers, it works ok.
  
   Is this a bug in Zend Test? Any way to fix this issue?
  
   Regards,
  
   Fernando Morgenstern
   cont...@fernandomarcelo.com
  
  
  
  
 
 




Re: [fw-general] Re: problem with autoloading class definition for serialization and deserialization

2010-11-29 Thread Hector Virgen
David, do you think implementing the SPL's Serializable interface can help
with concern #3?

--
Hector Virgen
Sent from my Droid X
On Nov 29, 2010 5:10 AM, David Muir
davidkmuir+z...@gmail.comdavidkmuir%2bz...@gmail.com
wrote:

 Throwing it on a slight tangent, but maybe storing the objects in the
session
 isn't the best solution. I've done it in the past, but have found that
it's
 often more trouble than it's worth.

 I would do instead is either inject a Zend_Session_Namespace to store
object
 data, or create a mapper that maps it to the session.

 The advantages of this is:

 1. You don't need to load class definitions for each requests (even if you
 don't need them)
 2. You can set up a sub-system that uses the same session that is
otherwise
 comepletely independent.
 3. You can change the class definition without killing your session. You
 might still get errors, but if you're smart with the mapper, you can
 automatically migrate the session data from the old class definition to
the
 new one. basically means you can update the live site without having to
wipe
 all your user's sessions.

 no.3 is probably the biggest reason for not storing standard objects in
the
 session. If you do end up storing them in the session, make sure you clear
 all sessions after doing an update. Otherwise the user will be unable to
 access the site until the session expires, they clear their cookies, or
use
 a different browser.

 Cheers,
 David
 --
 View this message in context:
http://zend-framework-community.634137.n4.nabble.com/problem-with-autoloading-class-definition-for-serialization-and-deserialization-tp3062477p3062973.html
 Sent from the Zend Framework mailing list archive at Nabble.com.


Re: [fw-general] singleton models

2010-11-29 Thread Hector Virgen
The Singleton pattern might be a good idea at first, but be cautious about
maintainability in the future. Accessing a Singleton is much like accessing
a global variable and introduces many of the same  problems.

For example, it can be difficult or tricky to unit test a class that loads a
Singleton dependency on it's own. Instead, you'll want to inject that
dependency using the constructor or a setter method.

Singletons, like global variables, also introduce hidden dependencies. In
other words, it's not obvious the class Foo depends on Singleton class Bar
without looking through the source of Foo. This can make maintenance and
reuse difficult.

Generally I try to avoid singletons like the plague for the reasons above.
To avoid creating duplicate instances, create it once (usually in a
controller or, better yet, using an action helper) and inject it into
whatever objects will need it.

I hope this helps :)

--
Hector Virgen
Sent from my Droid X
On Nov 29, 2010 6:28 AM, Serkan Temizel serkantemi...@gmail.com wrote:
 Do you think is it a good idea making models singleton?

 On my project I need *users *model object many times. I call it in the
 controller, in some plugins and in some view helpers.

 Making it singletone, I think will improve performance but can't figure
out
 drawbacks.

 Thanks


Re: [fw-general] Meta tags rendering and indentation issues

2010-11-28 Thread Hector Virgen
Are you using the doctype view helper? That's what all the other view
helpers will reference when generating their html.

--
Hector Virgen
Sent from my Droid X
On Nov 28, 2010 4:54 AM, navanitachora navanitach...@gmail.com wrote:

 Dear Folks,

 I have a problem with meta tags being rendered by headMeta() in the
format:

 meta name=author content=some author  (a space before the closing )

 I wish to use HTML 4.01 Strict doctype and do not want to have a space as
 above
 to keep the coding consistent. Is there a neat way by which I could get
rid
 of t
 he space rendered by the headMeta() helper method.

 My second problem is with indentation please see the HTML segment page
 below:

 !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN
 http://www.w3.org/TR/html4/strict.dtd;
 html lang=en
 head
 titleSome title/title
 meta name=author content=Catherine Jennings
 meta name=date content=2010
 meta name=copyright content=© Catherine Jennings 2010
 meta name=keywords content=Poetic Tributes
 meta name=description content=
 /head

 As you can see the first meta tag line is indented correctly but the other
 meta tag lines do not respect the indentation. I have tried using
 setIndent(' ') however this makes the first meta tag line be indented by
 another extra four spaces which I do not want.

 I know these are fairly minor issues but I would like to keep Zend's way
of
 coding and mine the same as far as HTML is concerned.

 I hope you could shed some light as I am new to Zend.

 I am currently using Zend 1.11 on Ubuntu Linux.

 Thanks in advance.
 --
 View this message in context:
http://zend-framework-community.634137.n4.nabble.com/Meta-tags-rendering-and-indentation-issues-tp3062357p3062357.html
 Sent from the Zend Framework mailing list archive at Nabble.com.


Re: [fw-general] problem with autoloading class definition for serialization and deserialization

2010-11-28 Thread Hector Virgen
Is the module autoloader set up before the session is started? If you are
using protected _init* methods in your bootstrap, make sure the autoloader
method is above the session one, or call $this-bootstrap('autoloader')
within your _initSession method.

--
Hector Virgen
Sent from my Droid X
On Nov 28, 2010 7:43 AM, Bram Gadeyne gadeyneb...@gmail.com wrote:
 Dear all,

 I'm trying to persist some objects to the session. But everything I try
 end up with the following error message:

 Fatal error: Shop_CardController::addAction(): The script tried to
 execute a method or access a property of an incomplete object. Please
 ensure that the class definition Default_Model_Card of the object you
 are trying to operate on was loaded _before_ unserialize() gets called
 or provide a __autoload() function to load the class definition in

/var/www/uitleendienst/application/modules/shop/controllers/CardController.php

 on line 43

 These are my settings in the bootstrap.php for autoloading modules:

 $modelLoader=new Zend_Application_Module_Autoloader(array(
 'namespace' = '',
 'basePath' = APPLICATION_PATH.'/modules/default'));

 In the bootstrap I've also entered:
 class_exists('Shop_Model_Card', true); //returns false
 Zend_Session::start();

 This is the code that results in an error:

 37 $ns = new Zend_Session_Namespace('mysession');
 38 if(!isset($ns-card)){
 39 $card=new Shop_Model_Card();
 40 }else{
 41 $card=$ns-card;
 42 }
 43 $card-addUitleningToList(value);
 44 $ns-card = $card;

 The code returns this error when the else part is executed and $ns-card
 should get deserialized. How do I get Zend framework to autoload the
 Shop_Model_Card class?

 This is my class definition for Shop_Model_Card.

 class Shop_Model_Card{

 private $uitleningen;

 public function getUitleningen(){
 return $this-uitleningen;
 }

 public function __construct() {
 //$this-uitleningen=array();
 }

 public function clear(){
 $this-uitleningen=array();
 }

 public function addUitleningToList($uitlening){
 if($this-uitleningen==null){
 $this-uitleningen=array();
 }
 array_push($this-uitleningen, $uitlening);
 }

 public function removeFromList($uitleningid){
 $temparr=array();
 $i=$uitleningid;
 while($isizeof($this-uitleningen-1)){
 $this-uitleningen[$i]=$this-uitleningen[$i+1];
 $i++;
 }
 $this-uitleningen[$i+1]=null;
 }
 }

 Can someone help me please?

 With kind regards,
 Bram Gadeyne


Re: [fw-general] problem with autoloading class definition for serialization and deserialization

2010-11-28 Thread Hector Virgen
Can you use pastebin.com or pastie.org instead? Thanks!

--
Hector Virgen
Sent from my Droid X
On Nov 28, 2010 10:01 AM, Bram Gadeyne gadeyneb...@gmail.com wrote:
 Thank you for your answer!

 However, I think I already do what you propose here. Here's the first
 method from my bootstrap file.:

 protected function _initAutoload(){
 $modelLoader=new Zend_Application_Module_Autoloader(array(
 'namespace' = '',
 'basePath' = APPLICATION_PATH.'/modules/default'));

 if(Zend_Auth::getInstance()-hasIdentity()){


Zend_Registry::set('role',Zend_Auth::getInstance()-getStorage()-read()-role);
 }else{
 Zend_Registry::set('role','guests');
 }

 class_exists('Shop_Model_Card', true); //this returns false
 Zend_Session::start();

 $this-_acl=new Model_UitleendienstACL();

 $fc=Zend_Controller_Front::getInstance();


$fc-addModuleDirectory(dirname(dirname(__FILE__)).'/application/modules');
 $fc-registerPlugin(new Plugin_AccessCheck($this-_acl));

 return $modelLoader;
 }

 I've added my complete bootstrap file as an attachment.

 With kind regards
 Bram Gadeyne

 On 28-11-10 18:46, Hector Virgen wrote:

 Is the module autoloader set up before the session is started? If you
 are using protected _init* methods in your bootstrap, make sure the
 autoloader method is above the session one, or call
 $this-bootstrap('autoloader') within your _initSession method.

 --
 Hector Virgen
 Sent from my Droid X

 On Nov 28, 2010 7:43 AM, Bram Gadeyne gadeyneb...@gmail.com
 mailto:gadeyneb...@gmail.com wrote:
  Dear all,
 
  I'm trying to persist some objects to the session. But everything I try
  end up with the following error message:
 
  Fatal error: Shop_CardController::addAction(): The script tried to
  execute a method or access a property of an incomplete object. Please
  ensure that the class definition Default_Model_Card of the object you
  are trying to operate on was loaded _before_ unserialize() gets called
  or provide a __autoload() function to load the class definition in
 

/var/www/uitleendienst/application/modules/shop/controllers/CardController.php


  on line 43
 
  These are my settings in the bootstrap.php for autoloading modules:
 
  $modelLoader=new Zend_Application_Module_Autoloader(array(
  'namespace' = '',
  'basePath' = APPLICATION_PATH.'/modules/default'));
 
  In the bootstrap I've also entered:
  class_exists('Shop_Model_Card', true); //returns false
  Zend_Session::start();
 
  This is the code that results in an error:
 
  37 $ns = new Zend_Session_Namespace('mysession');
  38 if(!isset($ns-card)){
  39 $card=new Shop_Model_Card();
  40 }else{
  41 $card=$ns-card;
  42 }
  43 $card-addUitleningToList(value);
  44 $ns-card = $card;
 
  The code returns this error when the else part is executed and
 $ns-card
  should get deserialized. How do I get Zend framework to autoload the
  Shop_Model_Card class?
 
  This is my class definition for Shop_Model_Card.
 
  class Shop_Model_Card{
 
  private $uitleningen;
 
  public function getUitleningen(){
  return $this-uitleningen;
  }
 
  public function __construct() {
  //$this-uitleningen=array();
  }
 
  public function clear(){
  $this-uitleningen=array();
  }
 
  public function addUitleningToList($uitlening){
  if($this-uitleningen==null){
  $this-uitleningen=array();
  }
  array_push($this-uitleningen, $uitlening);
  }
 
  public function removeFromList($uitleningid){
  $temparr=array();
  $i=$uitleningid;
  while($isizeof($this-uitleningen-1)){
  $this-uitleningen[$i]=$this-uitleningen[$i+1];
  $i++;
  }
  $this-uitleningen[$i+1]=null;
  }
  }
 
  Can someone help me please?
 
  With kind regards,
  Bram Gadeyne


Re: [fw-general] problem with autoloading class definition for serialization and deserialization

2010-11-28 Thread Hector Virgen
Thanks! I think Nabble discards the attachments plus I can't view php files
on my phone :(

Anyways, I noticed your module autoloader is loading the namespace '' but
your session wants to unserialize a Shop_* class. You'll need to set up
another module autoloader for the Shop namespace or manually require_once()
the file.

You can also try bootstrapping the modules resource if that is what sets
up your module autoloader for the shop module.

I how this helps!

--
Hector Virgen
Sent from my Droid X
On Nov 28, 2010 10:32 AM, Bram Gadeyne gadeyneb...@gmail.com wrote:
 Offcourse!

 Here's the URL: http://pastie.org/1330361

 kind regards
 Bram Gadeyne

 On 28-11-10 19:30, Hector Virgen wrote:

 Can you use pastebin.com http://pastebin.com or pastie.org
 http://pastie.org instead? Thanks!

 --
 Hector Virgen
 Sent from my Droid X

 On Nov 28, 2010 10:01 AM, Bram Gadeyne gadeyneb...@gmail.com
 mailto:gadeyneb...@gmail.com wrote:
  Thank you for your answer!
 
  However, I think I already do what you propose here. Here's the first
  method from my bootstrap file.:
 
  protected function _initAutoload(){
  $modelLoader=new Zend_Application_Module_Autoloader(array(
  'namespace' = '',
  'basePath' = APPLICATION_PATH.'/modules/default'));
 
  if(Zend_Auth::getInstance()-hasIdentity()){
 
 

Zend_Registry::set('role',Zend_Auth::getInstance()-getStorage()-read()-role);
  }else{
  Zend_Registry::set('role','guests');
  }
 
  class_exists('Shop_Model_Card', true); //this returns false
  Zend_Session::start();
 
  $this-_acl=new Model_UitleendienstACL();
 
  $fc=Zend_Controller_Front::getInstance();
 
 

$fc-addModuleDirectory(dirname(dirname(__FILE__)).'/application/modules');
  $fc-registerPlugin(new Plugin_AccessCheck($this-_acl));
 
  return $modelLoader;
  }
 
  I've added my complete bootstrap file as an attachment.
 
  With kind regards
  Bram Gadeyne
 
  On 28-11-10 18:46, Hector Virgen wrote:
 
  Is the module autoloader set up before the session is started? If you
  are using protected _init* methods in your bootstrap, make sure the
  autoloader method is above the session one, or call
  $this-bootstrap('autoloader') within your _initSession method.
 
  --
  Hector Virgen
  Sent from my Droid X
 
  On Nov 28, 2010 7:43 AM, Bram Gadeyne gadeyneb...@gmail.com
 mailto:gadeyneb...@gmail.com
  mailto:gadeyneb...@gmail.com mailto:gadeyneb...@gmail.com wrote:
   Dear all,
  
   I'm trying to persist some objects to the session. But everything
 I try
   end up with the following error message:
  
   Fatal error: Shop_CardController::addAction(): The script tried to
   execute a method or access a property of an incomplete object.
Please
   ensure that the class definition Default_Model_Card of the
 object you
   are trying to operate on was loaded _before_ unserialize() gets
 called
   or provide a __autoload() function to load the class definition in
  
 

/var/www/uitleendienst/application/modules/shop/controllers/CardController.php


 
   on line 43
  
   These are my settings in the bootstrap.php for autoloading modules:
  
   $modelLoader=new Zend_Application_Module_Autoloader(array(
   'namespace' = '',
   'basePath' = APPLICATION_PATH.'/modules/default'));
  
   In the bootstrap I've also entered:
   class_exists('Shop_Model_Card', true); //returns false
   Zend_Session::start();
  
   This is the code that results in an error:
  
   37 $ns = new Zend_Session_Namespace('mysession');
   38 if(!isset($ns-card)){
   39 $card=new Shop_Model_Card();
   40 }else{
   41 $card=$ns-card;
   42 }
   43 $card-addUitleningToList(value);
   44 $ns-card = $card;
  
   The code returns this error when the else part is executed and
  $ns-card
   should get deserialized. How do I get Zend framework to autoload the
   Shop_Model_Card class?
  
   This is my class definition for Shop_Model_Card.
  
   class Shop_Model_Card{
  
   private $uitleningen;
  
   public function getUitleningen(){
   return $this-uitleningen;
   }
  
   public function __construct() {
   //$this-uitleningen=array();
   }
  
   public function clear(){
   $this-uitleningen=array();
   }
  
   public function addUitleningToList($uitlening){
   if($this-uitleningen==null){
   $this-uitleningen=array();
   }
   array_push($this-uitleningen, $uitlening);
   }
  
   public function removeFromList($uitleningid){
   $temparr=array();
   $i=$uitleningid;
   while($isizeof($this-uitleningen-1)){
   $this-uitleningen[$i]=$this-uitleningen[$i+1];
   $i++;
   }
   $this-uitleningen[$i+1]=null;
   }
   }
  
   Can someone help me please?
  
   With kind regards,
   Bram Gadeyne


Re: [fw-general] Error controller query

2010-11-25 Thread Hector Virgen
The code in the first var_dump is the exception code, which defaults to
zero. I don't think ZF uses exception codes but I could be wrong.

On the second var_dump(), that's a response object which was updated to
respond with a 404.

I hope this helps!

--
Hector Virgen
Sent from my Droid X
On Nov 25, 2010 7:56 AM, Mike A mik...@hotmail.co.uk wrote:
 With a bad controller http://domain/default/sfsdf:

 I var_dump($errors) after the first line of class ErrorController
 $errors = $this-_getParam('error_handler'), and get (edited)...

 *object*(/ArrayObject/)[/32/]
 /public/ 'exception'=
 *object*(/Zend_Controller_Dispatcher_Exception/)[/31/]
 /protected/ 'message'= string 'Invalid controller specified (sfsdf)'
/(length=36)/
 /protected/ 'code'= int 0

 I var_dump($this-getFrontController()) and get (edited)...

 *object*(/Zend_Controller_Front/)[/7/]
 /protected/ '_dispatcher'=
 *object*(/Zend_Controller_Dispatcher_Standard/)[/4/]
 /protected/ '_response'=
 *object*(/Zend_Controller_Response_Http/)[/28/]
 /protected/ '_httpResponseCode'= int 404
 /protected/ '_plugins'=
 *object*(/Zend_Controller_Plugin_Broker/)[/8/]
 /protected/ '_response'=
 *object*(/Zend_Controller_Response_Http/)[/28/]
 /protected/ '_httpResponseCode'= int 404
 /protected/ '_request'=
 *object*(/Zend_Controller_Request_Http/)[/27/]
 /protected/ '_response'=
 *object*(/Zend_Controller_Response_Http/)[/28/]
 /protected/ '_httpResponseCode'= int 404

 Why does code in the first dump not match the (correct)
 httpResponseCode in the second? It does if I have a good controller and
 a bad action.

 TIA...




Re: [fw-general] Re: Zend_Loader::isReadable: need to get the path tested

2010-11-24 Thread Hector Virgen
The source for Zend_Loader#isReadable() is fairly straight-forward. It
wouldn't be too difficult to extend the class and add your own method which
returns the absolute path of the provided relative path:

http://pastie.org/1323290

Note: the code above was not tested, but is meant as an example.

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com



On Wed, Nov 24, 2010 at 7:50 AM, benoit benoit.delpo...@gmail.com wrote:


 Ok, i choose the solution with de file_get_contents, didn't know that it
 use
 include_path with its second parameter to true.

 But I think it could be usefull to get the path tested by the
 Zend_Loader::isReadable ;)

 Thanks a lot.
 --
 View this message in context:
 http://zend-framework-community.634137.n4.nabble.com/Zend-Loader-isReadable-need-to-get-the-path-tested-tp3054202p3057544.html
 Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Basic unit testing of error controller

2010-11-24 Thread Hector Virgen
If you're using the default route, error/error/jg will route successfully to
the error controller's error action. This is why you don't see the
EXCEPTION_NO_CONTROLLER nor EXCEPTION_NO_ACTION errors.

If you look at the default errorAction() method provided by Zend_Tool,
you'll see that it defaults to a 500 error code even if no exception was
thrown.

There is nothing in the error controller that causes an exception to be
thrown if a bad parameter is passed -- you'll need to implement this logic
yourself.

I hope this helps!

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com



On Wed, Nov 24, 2010 at 9:48 AM, Mike A mik...@hotmail.co.uk wrote:

 Moved on a bit with this. A bit confused, though, about the
 $this-response-isException() flag and output under some conditions of
 $this-getRequest()-getParam('error_handler')-type.

 Example unit test for ErrorController...

 public function testX() {
$this-dispatch('/error/error/jg');

echo Response exception (boolean):
 .$this-response-isException().\n;
echo Response code: . $this-response-getHttpResponseCode().\n;
echo Exception
 dump:.var_dump($this-getRequest()-getParam('error_handler')-type).\n;
 }

 If I set dispatch to provide a bad controller or action I get isException
 flagged as boolean 1 and corresponding getHttpResponseCode() and error
 handler type. For a bad controller the values are 404 and
 EXCEPTION_NO_CONTROLLER, and for a bad action the same HttpResponseCode
 and EXCEPTION_NO_ACTION.

 If in dispatch I set correct controller and action but a bad parameter, as
 in the above example unit test, I receive the expected HttpResponseCode
 (500) but null values for isException and the error_handler type. Why is
 this?



 On 23/11/2010 20:26, Mike A wrote:

 After 8pm here, suspect my two brain cells  have given up, but have to set
 up a walking skeleton...

 I want to write a unit test to check two items.

 1)  The different error handler messages (like
 Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER); and 2) the
 HTTP error codes.

 For an ErrorController action exception...
 public function testX() {
$this-dispatch('/error/xxx');

...
 }

 How to get the error_handler result?  In ErrorController it starts with
 $errors = $this-_getParam('error_handler');

 A practical example or pointer to one would be appreciated.

 TIA...

 Mike A.






Re: [fw-general] Re: ZF models and Zend_Db classes

2010-11-18 Thread Hector Virgen
If you're using the module resource
autoloaderhttp://framework.zend.com/manual/en/zend.loader.autoloader-resource.html#zend.loader.autoloader-resource.module,
the default location for classes that extend Zend_Db_Table_Abstract can be
autoloaded from:

application/models/DbTable/

Your classes would then be prefixed with {namespace}_Model_DbTable_

So if you're using the autoloader namespace Default and want to autoload a
db table named Foo, your class name would be:

Default_Model_DbTable_Foo

And it would be placed in:

application/models/DbTable/Foo.php

You don't have to follow this convention but this is how it would work out
of the box.

I hope this helps!

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com



On Thu, Nov 18, 2010 at 1:31 PM, Fozzyuw jmbertu...@gmail.com wrote:


 Hi Bill,

 First, thank you very much for your response as well as your contributions
 to the Zend Framework.  I know I use the reference guide daily, that you
 wrote, in my pursuit of getting better at ZF.

 I believe you answered one of my long standing confusions of MVC structure
 in understanding what a Model really is.  Are they all things other than
 Controller/Views Models?  Clearly because there are situations were you
 simply have a Table/Data access class, not really a Model of an object,
 like
 a product (which could have multiple data access classes depending on how
 the database and object was designed).

 Your explanation made sense to me.

 Regarding class loading.  I suppose that was just a different confusion
 I've
 had and I tend to think of things as a whole.  But I appreciate your
 response to that question.  In many ways, as I work more with MVC I start
 to
 question myself if I shouldt be using something like a require_once
 because I start to feel that there should be Zend FrameworK way of doing
 it, like auto-loading.

 Cheers!
 --
 View this message in context:
 http://zend-framework-community.634137.n4.nabble.com/ZF-models-and-Zend-Db-classes-tp3049177p3049627.html
 Sent from the Zend Framework mailing list archive at Nabble.com.



[fw-general] Zend_Form and Custom Error Messages

2010-11-10 Thread Hector Virgen
Hello,

What is the most straight-forward way to mark an element as invalid and
display a custom error message *without using validators*?

For example, we are using a web service to process data submitted via a web
form. I have set up validators in my form for the basic things like required
fields and string length, but sometimes there is additional validation that
occurs on the web-service side that could prevent the process from
continuing. In that event I'd like to take the error message from the web
service and inject it into the offending form element to be displayed to the
user.

I've looked over the API and
documentationhttp://framework.zend.com/manual/en/zend.form.elements.html#zend.form.elements.validators.errorsand
there are two methods that seem likely candidates for doing my
bidding:

*Zend_Form_Element#setErrors(array $errors)*
*Overwrite any previously set error messages and flag as failed validation*

*Zend_Form_Element#setErrorMessages(array $errorMessages)*
*Same as addErrorMessages(), but clears custom error message stack first*

If I use setErrors() and pass in an array with a single error message, the
message is duplicated when rendering.

If I use setErrorMessages() and pass in an array with a single error
message, the message is not displayed at all when rendering.

I found that if I call both methods and pass in the same single-value array
to both of them, it works as expected -- I get my nice error message on the
rendered form.

Is this typically how it should be done? Or am I missing something? Thanks!

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com


[fw-general] Re: Zend_Form and Custom Error Messages

2010-11-10 Thread Hector Virgen
After looking into this a bit further, I found that the errors decorator
calls Zend_Form_Element#getMessages(), which simply returns the
$_messagesarray. Unfortunately, there's no way to clear that array
without calling
Zend_Form_Element#isValid(). When calling Zend_Form_Element#setErrors(), the
provided errors are appended to the $_messages array. In other words, once
an error message has been added to the stack during validation, it's
practically impossible to remove.

The following unit tests demonstrate the problem:

http://pastie.org/1288565

However, it could just be that I am not using Zend_Form correctly. Has
anyone run into this problem before?

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com



On Wed, Nov 10, 2010 at 1:53 PM, Hector Virgen djvir...@gmail.com wrote:

 Hello,

 What is the most straight-forward way to mark an element as invalid and
 display a custom error message *without using validators*?

 For example, we are using a web service to process data submitted via a web
 form. I have set up validators in my form for the basic things like required
 fields and string length, but sometimes there is additional validation that
 occurs on the web-service side that could prevent the process from
 continuing. In that event I'd like to take the error message from the web
 service and inject it into the offending form element to be displayed to the
 user.

 I've looked over the API and 
 documentationhttp://framework.zend.com/manual/en/zend.form.elements.html#zend.form.elements.validators.errorsand
  there are two methods that seem likely candidates for doing my bidding:

 *Zend_Form_Element#setErrors(array $errors)*
 *Overwrite any previously set error messages and flag as failed validation
 *

 *Zend_Form_Element#setErrorMessages(array $errorMessages)*
 *Same as addErrorMessages(), but clears custom error message stack first*

 If I use setErrors() and pass in an array with a single error message, the
 message is duplicated when rendering.

 If I use setErrorMessages() and pass in an array with a single error
 message, the message is not displayed at all when rendering.

 I found that if I call both methods and pass in the same single-value array
 to both of them, it works as expected -- I get my nice error message on the
 rendered form.

 Is this typically how it should be done? Or am I missing something? Thanks!

 --
 *Hector Virgen*
 Sr. Web Developer
 http://www.virgentech.com




Re: [fw-general] Accessing config from CLI crons

2010-11-05 Thread Hector Virgen
I believe that param is added when the application is run(). Since you're
not calling run(), you'll need to add that param manually:

$bootstrap = $application-getBootstrap();
Zend_Controller_Front::getInstance()-setParam('bootstrap', $bootstrap);

--
Hector Virgen
Sent from my Droid X
On Nov 4, 2010 11:57 PM, umpirsky umpir...@gmail.com wrote:


Re: [fw-general] Accessing config from CLI crons

2010-11-05 Thread Hector Virgen
Either way works, but I like your version because I personally believe
singletons are evil :)

Just don't forget to bootstrap the front controller before accessing the
resource, otherwise it will return null.

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com



On Fri, Nov 5, 2010 at 8:05 AM, Jurian Sluiman
subscr...@juriansluiman.nlwrote:

 Hi all,

 On Friday 05 Nov 2010 14:41:59 Hector Virgen wrote:
  $bootstrap = $application-getBootstrap();
  Zend_Controller_Front::getInstance()-setParam('bootstrap', $bootstrap);

 While most tutorials use the Singleton pattern of the frontController, I
 see
 myself using the bootstrap more often:

 $fc = $bootstrap-getResource('frontController')-setParam('bootstrap',
 $bootstrap);

 I'm not sure why I'm used to this method, but is there a preferable method?
 The same counts for Zend_Registry: I prefer to get the
 cache/log/navigation/etc from bootstrap than set them into the registry.

 Regards, Jurian
 --
 Jurian Sluiman
 Soflomo - http://soflomo.com



Re: [fw-general] Dinamicly created Menu question

2010-10-29 Thread Hector Virgen
You might want to take a look at existing open-source CMSs built on ZF.
Recite CMS looks promising: http://www.recitecms.com/

http://www.recitecms.com/There are more here:
http://framework.zend.com/wiki/pages/viewpage.action?pageId=14134

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com



On Thu, Oct 28, 2010 at 11:42 PM, vladimirn nezabor...@gmail.com wrote:


 First of all i would like to say hello to all of you guys.
 There is a question bothering me for some time now.
 While ago i have created a CMS where i allowed admin users to create a
 pages, menus, categories etc.. dinamicly.
 I would love to port all that ideas to Zend Framework env.
 Talking about ZF, as far as i know, to show a page to user, at list i need
 to have a controller and a view file.
 If i want to create a new menu/page using zend framework, how i can do
 that?
 I mean, i can make some nice form and i can create data and record it to
 some table, but what i am wondering about is how user can access to newly
 created menus an pages?
 FOr egzample, if i create a menu Test, and record all Test attributes
 (name, description, metatags etc..) in database, it is not a problem to
 fetch it from DB and to add it to existing menu tree.
 But what about content of this menu?
 I can create a field in table, name it content and assign it to this new
 Test.
 How to access this content on website? Do i have to create view file and
 controler TestController.php and proper action to show the dinamicly
 created
 content?
 The goal is to have a CMS where admin can create menus and content on the
 fly.
 I hope i was clear enough :)
 I would appreciate any advise here
 Vladd
 --
 View this message in context:
 http://zend-framework-community.634137.n4.nabble.com/Dinamicly-created-Menu-question-tp3018527p3018527.html
 Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] MVC design question

2010-10-29 Thread Hector Virgen
You can probably place that common code in your preDispatch() hook:

if ($article = $this-_request-getParam('article')) {
// Load article and assign to view
}

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com



On Fri, Oct 29, 2010 at 3:32 PM, debussy007 debussy...@gmail.com wrote:


 Hi,

 That's a recurring problem I have had for a long time :

 Let's say I have an action allowing to view an article, and an action
 allowing to edit an article.

 To setup the views, the code is the same for both actions (get the article
 id from GET parameter, fetch article, execute some checks, and other
 things). Only the view files are different, in the edit version, there is a
 form with input elements.

 I have here duplicated code. How would you handle this ?

 Thank you for any advice
 --
 View this message in context:
 http://zend-framework-community.634137.n4.nabble.com/MVC-design-question-tp3019840p3019840.html
 Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Securing database username/password

2010-10-26 Thread Hector Virgen
I would extend the built-in resource plugin so that it accepts a
configPath option that points to an external config file. Once the
external config is loaded, you can call parent::init() and continue on like
normal.

--
*Hector Virgen*
Sr. Web Developer
Walt Disney Parks and Resorts Online
http://www.virgentech.com



On Tue, Oct 26, 2010 at 9:01 AM, Frank DiRocco ofang...@gmail.com wrote:

 Henry,

 Have you tried loading the config? I do something like this in my 1.10.x
 bootstrap _inits, the ini file is compiled just like application.ini

 $config = new Zend_Config_Ini('path/to/yourDbSchemaCredentials.ini',
 'dbsecrets');

 Just keep in mind, your credentials will be available/accessible in this
 $config variable

 On Oct 26, 2010, at 9:10 AM, Henry Umansky wrote:

  Hello all,
  I'm trying to upgrade my pre-1.8 ZF application to the latest version and
 utilize Zend_Application. However, I'm running into a subversion security
 issue. Within my old application, I was able to store my database connection
 information into a separate config.ini file and then simply add that file to
 the svn:ignore list. That way my sensitive database information is not
 stored in my public subversion repository. However, now that I'm using
 Zend_Application, I can't really add application.ini to the svn:ignore list
 (nor do I want to, since I use Capistrano for deployment). Is there a best
 practice for scenarios similar to this? Can I add another config file in
 something like a _initDB() in the Bootstrap.php file or is there another
 recommended method?
 
  Thank you,
  Henry




Re: [fw-general] Preventing XSS : Zend_Filter_Tags is enough?

2010-10-25 Thread Hector Virgen
If HTML is not allowed, it's better to escape the value instead of strip out
content that resembles HTML.

--
*Hector Virgen*
Sr. Web Developer
Walt Disney Parks and Resorts Online
http://www.virgentech.com



On Mon, Oct 25, 2010 at 9:29 AM, robert mena robert.m...@gmail.com wrote:

 Hi,

 I'd like to know if is it safe to filter XSS use Zend_Filter_Tags if none
 of
 my fields is supposed to receive any HTML.

 I read somewhere (at padraic's blog?) that for more sophisticated filtering
 (like allowing certain tags/attributes) Zend_Filter_Tags is not the option.

 Regards.



Re: [fw-general] Zend_Form - Unable to translate error messages post-validation

2010-10-25 Thread Hector Virgen
Thanks for the clarification, Thomas. I'll be sure to add translations prior
to validating.

--
*Hector Virgen*
Sr. Web Developer
Walt Disney Parks and Resorts Online
http://www.virgentech.com


Re: [fw-general] Preventing XSS : Zend_Filter_Tags is enough?

2010-10-25 Thread Hector Virgen
Then I guess it depends -- do you want to filter out all html, or allow
html-like content to be displayed back to your users (escaped, of course)?

Personally I prefer the latter because it allows users to write something
like Strong tags look like this: strongcontent/strong

The users will see the actual HTML instead of it being stripped or rendered.

If you're only concerned about XSS then escaping should be fine -- as long
as you remember to escape it whenever it can be evaluated by a parser.

--
*Hector Virgen*
Sr. Web Developer
Walt Disney Parks and Resorts Online
http://www.virgentech.com



On Mon, Oct 25, 2010 at 11:04 AM, robert mena robert.m...@gmail.com wrote:

 Hi Hector,

 Thanks for your reply.

 If I recall the 'general' advice should be filter input and escape output.
  I am looking for the filter part right now.


 On Mon, Oct 25, 2010 at 12:39 PM, Hector Virgen djvir...@gmail.comwrote:

 If HTML is not allowed, it's better to escape the value instead of strip
 out content that resembles HTML.

 --
 *Hector Virgen*
 Sr. Web Developer
 Walt Disney Parks and Resorts Online
 http://www.virgentech.com



 On Mon, Oct 25, 2010 at 9:29 AM, robert mena robert.m...@gmail.comwrote:

 Hi,

 I'd like to know if is it safe to filter XSS use Zend_Filter_Tags if none
 of
 my fields is supposed to receive any HTML.

 I read somewhere (at padraic's blog?) that for more sophisticated
 filtering
 (like allowing certain tags/attributes) Zend_Filter_Tags is not the
 option.

 Regards.






[fw-general] Zend_Form - Unable to translate error messages post-validation

2010-10-22 Thread Hector Virgen
Hello,

I've been following Matthew Weier O'Phinney's blog post Using Zend_Form In
Your 
Modelshttp://weierophinney.net/matthew/archives/200-Using-Zend_Form-in-Your-Models.htmland
so far it has been working great -- except for translation.

We are currently not using Zend_Translate -- our solution is to use a view
helper to apply the translated labels, descriptions etc to the form just
prior to rendering. But the problem I am experiencing also occurs when
Zend_Translate is used.

If I pass in a translation adapter to the form after calling
Zend_Form#isValid(), everything gets translated except for the error
messages. However, if I pass in the translation adapter *before* validating,
everything works as expected.

I've put together the following unit tests to confirm it:

Unit tests: http://pastie.org/1241063
Result: http://pastie.org/1241069

It seems that the solution would be to update my form to apply the
translation adapter in its init() method, but I've delegated that
responsibility to the view script (similar to other view-related tasks in
Matthew's blog). The main reason for that is due to our translations being
stored in a CMS, which our model does not have access to (the model only
contains business rules). Additionally, I'm not always rendering the form,
so supplying a translation adapter when I only need to validate is a waste
of resources.

After some poking around through the source of Zend_Form_Element, there
doesn't appear to be a way to directly modify the error messages. I ended up
using ReflectionObject to manually modify Zend_Form_Element's protected
$_messages array -- but this seems very hackish to me. Is there a better
way?

--
*Hector Virgen*
Sr. Web Developer
Walt Disney Parks and Resorts Online
http://www.virgentech.com


Re: [fw-general] Re: Generating URL's - View Helper? Action Helper?

2010-10-20 Thread Hector Virgen
There's an easier way to extend the existing Url view helper. Since view
helpers are loaded using a LIFO stack, you can create your own view helper
named url and Zend_View will use that one instead of the built-in version.
I suggest extending the existing helper instead of copying it. That way you
can ksort the $urlOptions array before passing it to the parent method.

Here's a quick example (not tested):

http://pastie.org/1235792

The added benefit is that you don't have to decide which helper to use in
your view scripts -- just use the same call $this-url() and pass in true
as the fifth parameter.

I hope this helps!

--
*Hector Virgen*
Sr. Web Developer
Walt Disney Parks and Resorts Online
http://www.virgentech.com



On Wed, Oct 20, 2010 at 9:11 AM, Fozzyuw jmbertu...@gmail.com wrote:


 As a follow up to myself,

 I've found that the View Helper Url() works pretty well, with one
 exception, I so far haven't found if it is capable of sorting parameters
 alphabetically by the name column.

 ie: /[module]/controller/action/name1/value1/name2/value2

 Where name1 is always alphabetically sorted compared to name2.

 I'll have to dig through the router code to see if there's an option that
 can be set to do this, but I might simply create a custom view helper
 called
 UrlAdvanced that does this instead (due to time considerations).

 This View Helper can be easy to make.  Simply take the current View Helper
 URL, copy it and rename appropriately to UrlAdvanced and change the
 Zend_ part of the Zend_View_Helper to whatever namespace you use on
 your
 site.

 Then, in the main method, I will simply add an option to allow the
 parameters to be sorted.

 This will require taking all the page parameters, sorting them, and then
 re-submitting them with the reset parameter set.  Or something like that.

 I'll try this out and post my solution/code once I've completed it.

 Fozzy
 --
 View this message in context:
 http://zend-framework-community.634137.n4.nabble.com/Generating-URL-s-View-Helper-Action-Helper-tp3002936p3004178.html
 Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Re: Generating URL's - View Helper? Action Helper?

2010-10-20 Thread Hector Virgen
Named parameters (such as module, controller and action in the
default route) should not be affected by the ksort, but anything that is
handled by * should (in your case, the name1 and name2 keys). Again, I
didn't test the code, but if it doesn't work that way I'd be surprised.

--
*Hector Virgen*
Sr. Web Developer
Walt Disney Parks and Resorts Online
http://www.virgentech.com



On Wed, Oct 20, 2010 at 11:48 AM, Fozzyuw jmbertu...@gmail.com wrote:


 Hi Hector,

 Thanks for the tip about helpers.

 One item of note, ksorting doesn't actually do anything when passing it to:
 $router-assemble($urlOptions, $name, $reset, $encode);

 If that doesn't make sense, here's the thing, the URL helper code is simply
 this:

 
 $router = Zend_Controller_Front::getInstance()-getRouter();
 return $router-assemble($urlOptions, $name, $reset, $encode);
 

 tossing a ksort between them doesn't effect the order in which the
 $router-assemble() generates the URL.  I've just cracked open
 /Zend/Controller/Router/Route.php to see how the assemble() function
 works, but there's a bit more going on in there in terms of having logic
 for
 handling translations and partials, which I'm not familiar with.

 So, I'm trying to digest what's going on there to figure out if there's a
 Zend way of doing it or if I simply have to create my own URL helper that
 generates the URL, and skip trying to use Router-Route.



 --
 View this message in context:
 http://zend-framework-community.634137.n4.nabble.com/Generating-URL-s-View-Helper-Action-Helper-tp3002936p3004397.html
 Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Re: Generating URL's - View Helper? Action Helper?

2010-10-20 Thread Hector Virgen
I just ran a quick test using a simple route, and my assumption was correct
-- the wildcard params keep the order that was supplied:

echo $view-url(array('foo' = 'bar', 'derp' = 'doo'));
// /index/index/foo/bar/derp/doo

echo $view-url(array('derp' = 'doo', 'foo' = 'bar'));
// /index/index/derp/doo/foo/bar

So in theory a ksort should work.

--
*Hector Virgen*
Sr. Web Developer
Walt Disney Parks and Resorts Online
http://www.virgentech.com



On Wed, Oct 20, 2010 at 11:54 AM, Hector Virgen djvir...@gmail.com wrote:

 Named parameters (such as module, controller and action in the
 default route) should not be affected by the ksort, but anything that is
 handled by * should (in your case, the name1 and name2 keys). Again, I
 didn't test the code, but if it doesn't work that way I'd be surprised.

 --
 *Hector Virgen*
 Sr. Web Developer
 Walt Disney Parks and Resorts Online
 http://www.virgentech.com



 On Wed, Oct 20, 2010 at 11:48 AM, Fozzyuw jmbertu...@gmail.com wrote:


 Hi Hector,

 Thanks for the tip about helpers.

 One item of note, ksorting doesn't actually do anything when passing it
 to:
 $router-assemble($urlOptions, $name, $reset, $encode);

 If that doesn't make sense, here's the thing, the URL helper code is
 simply
 this:

 
 $router = Zend_Controller_Front::getInstance()-getRouter();
 return $router-assemble($urlOptions, $name, $reset, $encode);
 

 tossing a ksort between them doesn't effect the order in which the
 $router-assemble() generates the URL.  I've just cracked open
 /Zend/Controller/Router/Route.php to see how the assemble() function
 works, but there's a bit more going on in there in terms of having logic
 for
 handling translations and partials, which I'm not familiar with.

 So, I'm trying to digest what's going on there to figure out if there's a
 Zend way of doing it or if I simply have to create my own URL helper
 that
 generates the URL, and skip trying to use Router-Route.



 --
 View this message in context:
 http://zend-framework-community.634137.n4.nabble.com/Generating-URL-s-View-Helper-Action-Helper-tp3002936p3004397.html
 Sent from the Zend Framework mailing list archive at Nabble.com.





Re: [fw-general] Re: Generating URL's - View Helper? Action Helper?

2010-10-20 Thread Hector Virgen
Good catch, but if you reset the parameters, you'll lose the ones that
weren't explicitly passed in. Maybe the answer is to extend the router so
you can customize its assemble method?

--
*Hector Virgen*
Sr. Web Developer
Walt Disney Parks and Resorts Online
http://www.virgentech.com



On Wed, Oct 20, 2010 at 1:16 PM, Fozzyuw jmbertu...@gmail.com wrote:


 Yes you are right.

 I got it to work but there was one gotcha.  I needed to set the reset
 parameter to true, to let the parameters to sort properly.

 This is the view helper I created (basically a copy/paste of the actual
 view
 helper URL class, you can, of course, just extend as Hector did)
 http://pastie.org/1236307

 Notice, that I set $reset = true, if $sort=true.  This is just an extra
 check to make sure it works, in case one forgets.

 Then, basically I create a link HTML in the view script as such:
 http://pastie.org/1236403

 And if anyone's not familiar with custom view scripts, you have to register
 them in your bootstrap file like this:
 http://pastie.org/1236410

 That seemed to do the trick.
 --
 View this message in context:
 http://zend-framework-community.634137.n4.nabble.com/Generating-URL-s-View-Helper-Action-Helper-tp3002936p3004521.html
 Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Image CAPTCHA creates huge files

2010-10-18 Thread Hector Virgen
It seems the default image format is PNG and I couldn't find a way to change
it (perhaps JPG might have better compression). Have you tried decreasing
the height/width? 900KB seems rather large even for a PNG.

--
*Hector Virgen*
Sr. Web Developer
Walt Disney Parks and Resorts Online
http://www.virgentech.com



On Mon, Oct 18, 2010 at 6:40 AM, Cem Derin c...@wysiwyg.de wrote:

 Hello,

 I've used Zend_Captcha_Image to create Captchas for a stand alone form
 (code below). Unfortunately I discovered, that the class creates huge image
 files (with this code the images are about 900KB), way too heavy for web
 applications. Did you experienced this problem too? Do you have any
 suggestions? I already tweaked the class to use the third (compression-)
 argument in imagepng – unfortunately without any effect.

 $captcha = new Zend_Captcha_Image(array(
'name'  =  'foo',
'wordLength'=  '4',
'timeout'   =  300,
'font'  =  $path,
'imgDir'=  $savePath,
'imgUrl'=  '/captcha',
'width' =  304,
 ));

 php version: php version 5.2.12.14-dev

 gd info

 gd

 GD Support  enabled
 GD Version  bundled (2.0.34 compatible)
 FreeType Supportenabled
 FreeType Linkagewith freetype
 FreeType Version2.2.1
 T1Lib Support   enabled
 GIF Read Supportenabled
 GIF Create Support  enabled
 JPG Support enabled
 PNG Support enabled
 WBMP Supportenabled
 XPM Support enabled
 XBM Support enabled


 Thanks

 Cem
 *
 Cem Derin  :  Software Development  :  T +49.211.8670 175

 wysiwyg* software design gmbh  :  Stresemannstr. 26, 40210 Düsseldorf
 Hrb 31084, Ust. Id.Nr: DE 811799982  :  GF: Florian Breiter
 T +49.211 8670 10  :  F +49.211 134679  :  aktuell: http://www.wysiwyg.de




Re: [fw-general] Re: Date Subtractions Differences

2010-10-18 Thread Hector Virgen
I've seen this question come up from time to time even though there's a
note about this in the documentation.

http://framework.zend.com/manual/en/zend.date.constants.html#zend.date.constants.selfdefinedformats

Maybe the documentation should make that note a bit more pronounced, maybe
with a bright background color or larger font. Or maybe it could be marked
important instead of note.

--
*Hector Virgen*
Sr. Web Developer
Walt Disney Parks and Resorts Online
http://www.virgentech.com



On Sun, Oct 17, 2010 at 8:16 PM, David Muir
davidkmuir+z...@gmail.comdavidkmuir%2bz...@gmail.com
 wrote:


  is the ISO year, which is different from  which is the normal
 calendar year.
 http://en.wikipedia.org/wiki/ISO_year#Relation_with_the_Gregorian_calendar

 You should use either of the following:
 $date = new Zend_Date($datecolumn, Zend_Date::ISO_8601);
 $date = new Zend_Date($datecolumn, '-MM-dd');

 Cheers,
 David
 --
 View this message in context:
 http://zend-framework-community.634137.n4.nabble.com/Date-Subtractions-Differences-tp2996040p2999618.html
 Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Letter case problem in Zend_Http_Response

2010-10-14 Thread Hector Virgen
As brought up by Artem, it's case-insensitive so it shouldn't matter as long
as browsers are following the spec.

--
*Hector Virgen*
Sr. Web Developer
Walt Disney Parks and Resorts Online
http://www.virgentech.com



On Thu, Oct 14, 2010 at 9:47 AM, Ryan Chan ryanchan...@gmail.com wrote:

 Hi,

 On Fri, Oct 15, 2010 at 12:32 AM, Artem Stepin aste...@24h.de wrote:
   this should help:
  http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2
 
  Each header field consists of a name followed by a colon (:) and the
  field value. Field names are case-insensitive. 

 So I just wonder why only 1st letter is uppercase.



Re: [fw-general] Re: Firefox - double request

2010-10-12 Thread Hector Virgen
Have you checked your HTML for broken links? Although the HTML may validate,
a link or img tag with an empty source (href, src, etc.) will resolve to
the current page and can cause a double request. Also check your CSS -- a
background image URL or @import directive may be broken.

--
*Hector Virgen*
Sr. Web Developer
Walt Disney Parks and Resorts Online
http://www.virgentech.com



On Tue, Oct 12, 2010 at 1:47 PM, debussy007 debussy...@gmail.com wrote:


 In my htaccess file, I have the following rule :

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

 In the access logs of Apache, there are no 404 for that request, only the
 below (you may see the double request) :

 127.0.0.1 - - [12/Oct/2010:22:40:42 +0200] GET
 /xyz/agenda/index/index/dateStart/31-01-2011 HTTP/1.1 200 6682
 127.0.0.1 - - [12/Oct/2010:22:40:43 +0200] GET
 /xyz/agenda/index/index/dateStart/31-01-2011 HTTP/1.1 200 6682

 The page has been validated strictly HTML 4.01
 I disabled all my Firefox extensions.

 I still got the error. Anyway, I'll just keep looking for the problem ...
 if
 you have any other idea, please share.
 Thanks
 --
 View this message in context:
 http://zend-framework-community.634137.n4.nabble.com/Firefox-double-request-tp2992431p2992708.html
 Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Re: Zend_Validate_Date returns false for dates between: 28/10/2038 and 19/03/2042

2010-10-08 Thread Hector Virgen
That's only 28 years into the future. I think it's perfectly valid to worry
about those dates not working -- consider, for example, a mortgage company
that signs 30-year loans. I'm sure they'd want to show the expected maturity
date for a mortgage signed today.

--
*Hector Virgen*
Sr. Web Developer
Walt Disney Parks and Resorts Online
http://www.virgentech.com



On Fri, Oct 8, 2010 at 2:01 PM, Daniel Latter dan.lat...@gmail.com wrote:

 related to below but does anyone think its silly to be messing with dates
 in
 an app so far in future? Our use case is that we are storing driving
 licences and their expiry date - to be checked in future - and we are using
 Zend_Validate_Date to validate input...?

 Obviously we can just extend Zend_Validate_Date and override isValid method
 but just wondering if anyone has any good arguments against above scenario
 or to why we shouldn't worry about dates so far in future??

 Daniel.

 On 8 October 2010 21:52, Daniel Latter dan.lat...@gmail.com wrote:

  Hi all,
 
  I posted an issue (as in the title of this post) on the tracker:
 
  http://framework.zend.com/issues/browse/ZF-10525
 
  I have later realised it may have something to do with the 32-bit integer
  limit but I dont understand why Zend_validate_Date starts to return true
  after the date mentioned (19/03/2042) ?
 
  Is it because overflow occurs in the bit pattern for the number so the
  number falls back into the 32-bit integer range again?
 
  Thanks
  Daniel
 



Re: [fw-general] Re: Zend_Validate_Date returns false for dates between: 28/10/2038 and 19/03/2042

2010-10-08 Thread Hector Virgen
I just tried to reproduce this in both 64-bit and 32-bit, and both times it
worked as expected. It looks like there's something else going on.

Here's my test code:

$v = new Zend_Validate_Date();
echo $v-isValid('2038-10-28') ? 'valid' : 'no';
echo PHP_EOL;
echo $v-isValid('2038-10-29') ? 'valid' : 'no';
echo PHP_EOL;

And output:

valid
valid

If you can isolate the issue into a small reproducible script it should be
easier to find the problem.

--
*Hector Virgen*
Sr. Web Developer
Walt Disney Parks and Resorts Online
http://www.virgentech.com



On Fri, Oct 8, 2010 at 3:01 PM, Daniel Latter dan.lat...@gmail.com wrote:

 Thanks for the response Hector,

 I guess I was coming from the point of view that - can we assume an app
 will
 be doing the same thing it is now with regard to functionality in, say, 28
 years time? but then I think that question is dependant on the nature of
 the
 app and how critical its operation is?

 Also do you think the issue with Zend_validate_Date is because of the
 32-bit
 integer limit like I assumed?

 Thanks
 Daniel

 On 8 October 2010 22:52, Hector Virgen djvir...@gmail.com wrote:

  That's only 28 years into the future. I think it's perfectly valid to
 worry
  about those dates not working -- consider, for example, a mortgage
 company
  that signs 30-year loans. I'm sure they'd want to show the expected
 maturity
  date for a mortgage signed today.
 
  --
  *Hector Virgen*
  Sr. Web Developer
  Walt Disney Parks and Resorts Online
  http://www.virgentech.com
 
 
 
  On Fri, Oct 8, 2010 at 2:01 PM, Daniel Latter dan.lat...@gmail.com
 wrote:
 
  related to below but does anyone think its silly to be messing with
 dates
  in
  an app so far in future? Our use case is that we are storing driving
  licences and their expiry date - to be checked in future - and we are
  using
  Zend_Validate_Date to validate input...?
 
  Obviously we can just extend Zend_Validate_Date and override isValid
  method
  but just wondering if anyone has any good arguments against above
 scenario
  or to why we shouldn't worry about dates so far in future??
 
  Daniel.
 
  On 8 October 2010 21:52, Daniel Latter dan.lat...@gmail.com wrote:
 
   Hi all,
  
   I posted an issue (as in the title of this post) on the tracker:
  
   http://framework.zend.com/issues/browse/ZF-10525
  
   I have later realised it may have something to do with the 32-bit
  integer
   limit but I dont understand why Zend_validate_Date starts to return
 true
   after the date mentioned (19/03/2042) ?
  
   Is it because overflow occurs in the bit pattern for the number so the
   number falls back into the 32-bit integer range again?
  
   Thanks
   Daniel
  
 
 
 



Re: [fw-general] Re: Select object behaviour

2010-10-05 Thread Hector Virgen
So zero equals infinity? Interesting... But with ZF being object-oriented, I
think we can expect more intuitive behavior.

--
Hector Virgen
Sent from my Droid X
On Oct 5, 2010 4:56 AM, David Muir
davidkmuir+z...@gmail.comdavidkmuir%2bz...@gmail.com
wrote:


Re: [fw-general] Re: Select object behaviour

2010-10-05 Thread Hector Virgen
FETCH FIRST 0...
SELECT TOP 0...
SELECT... LIMIT 0

I'm having trouble believing that anyone would expect more than zero rows to
be returned.

I agree with you about throwing an exception for limit zero, but since we
can't have a BC break, the next best thing IMO would be to honor the
developer's intentions as much as possible.

--
Hector Virgen
Sent from my Droid X


Re: [fw-general] Select object behaviour

2010-10-04 Thread Hector Virgen
I agree; iterating over a limit 0 result set should result in no more than
0 iterations. Have you filed a bug report?

--
Hector Virgen
Sent from my Droid X
On Oct 4, 2010 2:17 AM, Daniel Latter dan.lat...@gmail.com wrote:
 what i meant was if you do happen to pass a zero to the limit method, then
 say loop over the (possibly millions of rows it will return) returned
rows,
 couldn't this potentially bring down a server?

 Daniel.

 2010/10/3 Valeriy Yatsko d...@design.ru

 Good day

  Yes, but it doesnt seem right to assume someones app will have the same
  amount or rows that is equesl to the max integer the os can hold?

 You really have table larger than 2 000 000 000 entries on 32-bit
servers?
 :)

 Let's see... int = 4 bytes on 32 bit systems:
 2 000 000 000 x 4 = 8 000 000 000 = ~ 8 gb minimum per table :)

 Let's add here at least varchar(255):
 2 000 000 000 x (4 + 255) = 518 000 000 000 = ~ 518 gb per table :)

 Try to search some data through this table. :)

 There are some architecture solutions for this, like splitting tables
into
 smaller (or shards).

 --
 Валерий Яцко
 __
 d...@design.ru | http://www.artlebedev.ru



Re: [fw-general] Select object behaviour

2010-10-02 Thread Hector Virgen
Limit 0 us definitely an incorrect usage, so maybe an exception should be
thrown?

--
Hector Virgen
Sent from my Droid X
On Oct 2, 2010 5:15 PM, Daniel Latter dan.lat...@gmail.com wrote:
 Hi,

 I know what your saying but my point is that, is this intended behaviour
to
 return a number so large if a zero happend to be passed.?

 Thanks
 Daniel.

 2010/10/3 Valeriy Yatsko d...@design.ru

 Good day

  dont know if this is a bug or not but if you pass the following
 parameters
  to the limit method on select object like so:
 
  -limit(0, 10);
 
  It produces the following SQL:
 
  LIMIT 2147483647 OFFSET 10
 
  now i know you should vaidate the limit val beforehand but this could
  potentially kill someones app?


 In Zend_Db_Select, you can use the limit() method to specify the count of
 rows and the number of rows to skip. The first argument to this method is
 the desired count of rows. The second argument is the number of rows to
 skip.

 So you should use
 -limit(10,0)
 instead.

 --
 Валерий Яцко
 __
 d...@design.ru | http://www.artlebedev.ru




Re: [fw-general] Select object behaviour

2010-10-02 Thread Hector Virgen
So limit 0 (or limit null, or limit false) would remove the limit portion if
the query?

--
Hector Virgen
Sent from my Droid X
On Oct 2, 2010 5:21 PM, Daniel Latter dan.lat...@gmail.com wrote:
 or just throw away the limit part altogether?

 Daniel

 On 3 October 2010 01:17, Hector Virgen djvir...@gmail.com wrote:

 Limit 0 us definitely an incorrect usage, so maybe an exception should be
 thrown?

 --
 Hector Virgen
 Sent from my Droid X
 On Oct 2, 2010 5:15 PM, Daniel Latter dan.lat...@gmail.com wrote:
  Hi,
 
  I know what your saying but my point is that, is this intended
behaviour
 to
  return a number so large if a zero happend to be passed.?
 
  Thanks
  Daniel.
 
  2010/10/3 Valeriy Yatsko d...@design.ru
 
  Good day
 
   dont know if this is a bug or not but if you pass the following
  parameters
   to the limit method on select object like so:
  
   -limit(0, 10);
  
   It produces the following SQL:
  
   LIMIT 2147483647 OFFSET 10
  
   now i know you should vaidate the limit val beforehand but this
could
   potentially kill someones app?
 
 
  In Zend_Db_Select, you can use the limit() method to specify the count
 of
  rows and the number of rows to skip. The first argument to this method
 is
  the desired count of rows. The second argument is the number of rows
to
  skip.
 
  So you should use
  -limit(10,0)
  instead.
 
  --
  Валерий Яцко
  __
  d...@design.ru | http://www.artlebedev.ru
 
 



Re: [fw-general] Select object behaviour

2010-10-02 Thread Hector Virgen
Regardless of how it actually works, I would expect limit null or limit
false to remove the limit portion if the query, while limit 0 would do an
actual limit 0. Having it do a limit 2.1 bajillion is just strange and
unexpected behavior.

Just my 2c.

--
Hector Virgen
Sent from my Droid X
On Oct 2, 2010 5:28 PM, Daniel Latter dan.lat...@gmail.com wrote:
 OK, so it doesnt seem to be a bug judging by what Valeriy said and the
link
 posted but i think this maybe a bit drastic, as Hector said I think limit
0,
 null or false should just remove or even dont add the limit part?

 Daniel.

 On 3 October 2010 01:24, Hector Virgen djvir...@gmail.com wrote:

 So limit 0 (or limit null, or limit false) would remove the limit portion
 if the query?

 --
 Hector Virgen
 Sent from my Droid X
 On Oct 2, 2010 5:21 PM, Daniel Latter dan.lat...@gmail.com wrote:
  or just throw away the limit part altogether?
 
  Daniel
 
  On 3 October 2010 01:17, Hector Virgen djvir...@gmail.com wrote:
 
  Limit 0 us definitely an incorrect usage, so maybe an exception should
 be
  thrown?
 
  --
  Hector Virgen
  Sent from my Droid X
  On Oct 2, 2010 5:15 PM, Daniel Latter dan.lat...@gmail.com wrote:
   Hi,
  
   I know what your saying but my point is that, is this intended
 behaviour
  to
   return a number so large if a zero happend to be passed.?
  
   Thanks
   Daniel.
  
   2010/10/3 Valeriy Yatsko d...@design.ru
  
   Good day
  
dont know if this is a bug or not but if you pass the following
   parameters
to the limit method on select object like so:
   
-limit(0, 10);
   
It produces the following SQL:
   
LIMIT 2147483647 OFFSET 10
   
now i know you should vaidate the limit val beforehand but this
 could
potentially kill someones app?
  
  
   In Zend_Db_Select, you can use the limit() method to specify the
 count
  of
   rows and the number of rows to skip. The first argument to this
 method
  is
   the desired count of rows. The second argument is the number of
rows
 to
   skip.
  
   So you should use
   -limit(10,0)
   instead.
  
   --
   Валерий Яцко
  
 __
   d...@design.ru | http://www.artlebedev.ru
  
  
 



Re: [fw-general] Specifying a Database Adapter and Zend_Application_Resource_Multidb

2010-10-02 Thread Hector Virgen
The simplest way to do this is to not extend Zend_Db_Table_Abstract. In ZF,
tables are not models. I've gone down this route personally and it's very
difficult to do anything slightly complex loo ike dealing with multiple
tables.

Instead, I suggest creating a model that doesn't extend a base class, and
have that model instantiate the table(s) it needs. The model can then inject
the correct db instance if necessary.

--
Hector Virgen
Sent from my Droid X
On Oct 2, 2010 10:12 AM, EvilThug evilt...@tr-kdl.com wrote:


Re: [fw-general] How to run an application installer?

2010-09-30 Thread Hector Virgen
The separate installer script is a good idea, but I'd stick with a single
ini configuration file. The installer script doesn't need to bootstrap
everything like your application does. You can pick and choose what to
bootstrap:

$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH .
'/configs/application.ini');
$bootstrap = $application-getBootstrap();
$bootstrap-bootstrap('frontcontroller');
$bootstrap-bootstrap('view');
$bootstrap-bootstrap('router');
$application-run();

--
*Hector Virgen*
Sr. Web Developer
Walt Disney Parks and Resorts Online
http://www.virgentech.com



On Thu, Sep 30, 2010 at 7:46 AM, Daniel Stefaniuk 
daniel.stefan...@gmail.com wrote:

 I have build an installer for my web application and I have a problem when
 the bootstrap process initializes all the resources defined in the
 application.ini file. Because a database haven't been created yet some of
 the resources that need to use it fail to initialize.

 I created two application's entries, main one (index.php) and one for the
 installer (install.php) along with their own bootstraps and configuration
 files. But now, this forces me to maintain duplicated properties (in
 application.ini and install.ini files) defined for both bootstrap
 processes.
 The list is pretty big as I declare a lot of custom properties I need to
 have access to during normal application usage and installation.
 Personally,
 I don't like this solution.

 What is the best approach to solve this problem?

 Thanks

 Daniel



Re: [fw-general] includes are slow - wrong set_include_path ?

2010-09-30 Thread Hector Virgen
View scripts are not handled by the autoloader. Take a look at your view's
script paths, which is a LIFO stack:

var_dump($view-getScriptPaths());

Since there is no prefixing for view scripts, the view object has to search
each of the directories (starting with the last one) for the matching view
script. Therefore it's a good idea to keep the number of paths down to a
minimum if possible.

--
*Hector Virgen*
Sr. Web Developer
Walt Disney Parks and Resorts Online
http://www.virgentech.com



On Thu, Sep 30, 2010 at 11:06 AM, debussy007 debussy...@gmail.com wrote:


 Hi,

 I profiled my application, and noticed with the help of xdebug and webgrind
 that my includes are very slow.
 Like for example ~450 ms was needed for an include of a .phtml file !

 I wonder if I am doing something wrong with include paths, if I'm not
 wrong,
 ZF uses it to find the files.

 This is my confiuration :

 [...]
 set_include_path(realpath(dirname(__FILE__) . '/../library'));
 require_once 'Zend/Loader/Autoloader.php';
 $autoloader = Zend_Loader_Autoloader::getInstance();
 $autoloader-registerNamespace(array('My_', 'MyZend_'));
 $resourceLoader  = new Zend_Application_Module_Autoloader(array(
'namespace' = 'My',
'basePath'  = './application/'
 ));
 $resourceLoader
-addResourceType('constants', 'constants/', 'Constant')
-addResourceType('exceptions', 'exceptions/', 'Exception')
-addResourceType('plugins', 'helpers/Plugin/', 'Plugin')
-addResourceType('helpers', 'helpers/Common/', 'Helper')
-addResourceType('viewHelpers', 'helpers/ViewHelper/',
 'View_Helper')
-addResourceType('actionHelpers', 'helpers/ActionHelper/',
 'Action_Helper');
 [...]


 Can anyone help me out with this ?

 Thank you very much !!
 --
 View this message in context:
 http://zend-framework-community.634137.n4.nabble.com/includes-are-slow-wrong-set-include-path-tp2736921p2736921.html
 Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Zend_Cache and dynamic backend location ?

2010-09-23 Thread Hector Virgen
How will you read from the cache if you don't know where the the cache file
is?

I would suggest using separate cache instances for different locations. For
example, a database cache could store cache file in /tmp/db while a page
cache could store them in /tmp/pages. You can then pick the right cache for
the task at hand and not deal with specifying directories all the time.

--
*Hector Virgen*
Sr. Web Developer
Walt Disney Parks and Resorts Online
http://www.virgentech.com



On Thu, Sep 23, 2010 at 1:17 PM, debussy007 debussy...@gmail.com wrote:


 Hi,

 I want to store the cache files at a dynamic location.

 e.g.
 ./tmp/123/
 ./tmp/3467/
 ./tmp/18/
 etcetera

 But when calling save(), seems that I cannot specify a subdirectory
 unfortunately.

 So is there any way to achieve that ?

 This is how I use Zend_Cache, but now all files are in ./tmp/ :
 $frontendOptions = array('lifetime' = NULL, 'automatic_serialization' =
 true);
 $backendOptions = array('cache_dir' = './tmp/');
 $cache = Zend_Cache::factory('Core', 'File', $frontendOptions,
 $backendOptions);


 Thank you for any help!
 --
 View this message in context:
 http://zend-framework-community.634137.n4.nabble.com/Zend-Cache-and-dynamic-backend-location-tp2552648p2552648.html
 Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Zend_Auth storing special characters

2010-09-16 Thread Hector Virgen
Which auth storage adapter are you using? If you're storing in the session,
are you using a custom session storage adapter or file-based?

--
*Hector Virgen*
Sr. Web Developer
Walt Disney Parks and Resorts Online
http://www.virgentech.com



On Thu, Sep 16, 2010 at 7:30 AM, Bradley Holt bradley.h...@foundline.comwrote:

 Keith,

 On Wed, Sep 15, 2010 at 10:47 AM, keith Pope mute.p...@googlemail.comwrote:

 Hi,

 Has anyone ever had any problems with Zend_Auth failing to
 store/serialize data that has ü etc in.

 I seem to be losing the auth session for all users with names
 containing utf-8 chars


 Are you using a PDO database adapter?  Do you have the charset parameter
 for your database connection set to UTF8?


 Thx

 Keith






  1   2   3   4   5   >