Re: [fw-general] HowTo Zend_Test_PHPUnit_ControllerTestCase + Zend_Session

2008-09-12 Thread Giorgio Sironi
2008/9/11 Bruno Friedmann [EMAIL PROTECTED]:
 I've a application bootstrap which relies on Zend_Session. And I want to test 
 controllers with the new (not so)
 Zend_Test_PHPUnit_ControllerTestCase.

The problem is that Zend_Session is static: I also have opened a topic
in the fw-mvc list blaming the presence of so many static classes in
the framework components. Obviously you can reset some of them, like
Zend_Test_* does with the front controller and the helper broker, but
to me it feels like a workaround; also it means Zend_Session and other
classes has to be aware of testing, while a class should have only one
resposibility.


-- 
Giorgio Sironi
Piccolo Principe  Ossigeno Scripter
http://www.sourceforge.net/projects/ossigeno


[fw-general] Zend_Dojo_Form errors

2008-09-12 Thread valugi

1. Request object error
If you have errors in the request object when trying to make your forms to
use dojo, here is some clue. Dojo dijits uses some html templates and
.htaccess usually is not prepared for this.

.htaccess code:
RewriteEngine on
RewriteRule !\.(js|ico|gif|jpg|png|css|html)$ index.php


2. There is some error in the distribution that I have from zf. 1.6
I jave requests to this path:

http://zf.mysite.com/js/dojo/dijit/form/nls/en/validate.js

But then english version of this script is not there, is in the parent
folder.. just the english one.
http://zf.mysite.com/js/dojo/dijit/form/nls/validate.js

Can someone point how to make a good compilation of the dojo library so we
wont have this problems?

3. I want to validate a text field for emails. The below sintax is correct
as Zend_Dojo_Form_Element inherits from regular Zend_Form_Element to which I
can add validators for email. This means that dojo should make use of this
validator on user side or I have to add a special validator plugin of Dojo
itself in order to do the validation?

$email = new Zend_Dojo_Form_Element_TextBox( 'email' );
$email
-setLowercase( true )
-setMaxLength(40)
-setFilters(
array(
new Zend_Filter_StringToLower(),
new Zend_Filter_StringTrim()
)
)   
-setLabel('Email')
-addValidator( new Zend_Validate_EmailAddress())
-setRequired( true )
;

Thanks
-- 
View this message in context: 
http://www.nabble.com/Zend_Dojo_Form-errors-tp19453531p19453531.html
Sent from the Zend Framework mailing list archive at Nabble.com.



[fw-general] Problem with Zend_View initialisation...

2008-09-12 Thread Apsy

Hi List,

I have a problem with my custom class of Zend_View.

In my bootstrap, i have instanciate a plugin wich initialize the 
application like the Pastebin app of Matthew.

But i have a problem :
in my initView method of my plugin :

public function initView()
   {
   /*
* View
/
   $view = new App_View_Page();
   $view-setEncoding('UTF-8');
   $view-doctype('XHTML1_TRANSITIONAL');
   $view-strictVars(); // enables tracking/detection of typos and 
misspelled variables in views

   $view-headTitle('App');
   $view-headTitle()-setSeparator(' - ');
   $view-addHelperPath(BASE_PATH . 
'/application/library/ZymFramework/Zym/View/Helper', 'Zym_View_Helper');
   $view-addHelperPath(BASE_PATH . 
'/application/library/ZymFrameworkIncubator/Zym/View/Helper', 
'Zym_View_Helper');
   $view-addHelperPath(BASE_PATH . 
'/application/library/My/Lib/View/Helper', 'My_Lib_View_Helper');
   $view-addHelperPath(BASE_PATH . 
'/application/application/code/App/View/Helper', 'App_View_Helper');

   $view-locale = Zend_Registry::get('locale');
   Zend_Dojo::enableView($view);
   $view-dojo()-enable()
   -addStyleSheetModule('dijit.themes.tundra')
   -setCdnBase(Zend_Dojo::CDN_BASE_GOOGLE)
-setDjConfigOption('parseOnLoad', true)
-setDjConfigOption('usePlainJson', true)
-setDjConfigOption('locale', (string) ResaSystem::getLocale())
-setDjConfigOption('isDebug', ($this-env == 'production') 
? false : true);
  
   /*

* ViewRenderer
/
   $viewRenderer = new 
Zend_Controller_Action_Helper_ViewRenderer($view);

   $viewRenderer
-setViewBasePathSpec(BASE_PATH . '/application/design/views')
-setViewScriptPathSpec(':module/:controller/:action.:suffix')
-setViewSuffix('phtml');
   Zend_Debug::dump(get_class($viewRenderer-view));
   $viewRenderer-init();
   Zend_Debug::dump(get_class($viewRenderer-view));
   Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
   
   /*

* Layout
/
   $layout = Zend_Layout::startMvc($this-config-layout);
   $layout-setView($view);
  
   return $this;

   }

But i met an error like this :


 Error

exception 'Zend_View_Exception' with message 'script 'error/failure.phtml' not 
found in path (/var/htdocs/app/application/modules/default/views/scripts/)' in 
/var/htdocs/app/library/ZendFramework/Zend/View/Abstract.php:875
Stack trace:
#0 
/var/htdocs/resasystem.com/light/library/ZendFramework/Zend/View/Abstract.php(783):
 Zend_View_Abstract-_script('error/failure.p...')
#1 
/var/htdocs/resasystem.com/light/library/ZendFramework/Zend/Controller/Action/Helper/ViewRenderer.php(921):
 Zend_View_Abstract-render('error/failure.p...')
#2 
/var/htdocs/resasystem.com/light/library/ZendFramework/Zend/Controller/Action/Helper/ViewRenderer.php(942):
 Zend_Controller_Action_Helper_ViewRenderer-renderScript('error/failure.p...', 
NULL)
#3 
/var/htdocs/resasystem.com/light/library/ZendFramework/Zend/Controller/Action/Helper/ViewRenderer.php(981):
 Zend_Controller_Action_Helper_ViewRenderer-render()
#4 
/var/htdocs/resasystem.com/light/library/ZendFramework/Zend/Controller/Action/HelperBroker.php(171):
 Zend_Controller_Action_Helper_ViewRenderer-postDispatch()
#5 
/var/htdocs/resasystem.com/light/library/ZendFramework/Zend/Controller/Action.php(512):
 Zend_Controller_Action_HelperBroker-notifyPostDispatch()
#6 
/var/htdocs/resasystem.com/light/library/ZendFramework/Zend/Controller/Dispatcher/Standard.php(293):
 Zend_Controller_Action-dispatch('failureAction')
#7 
/var/htdocs/resasystem.com/light/library/ZendFramework/Zend/Controller/Front.php(946):
 
Zend_Controller_Dispatcher_Standard-dispatch(Object(Zend_Controller_Request_Http),
 Object(Zend_Controller_Response_Http))
#8 /var/htdocs/resasystem.com/light/application/ResaSystem.php(195): 
Zend_Controller_Front-dispatch()
#9 /var/htdocs/resasystem.com/light/public/index.php(9): 
Bootstrap::run('development')
#10 {main}


In my Bootstrap :
$initPlugin = new App_Controller_Plugin_Initialize(APPLICATION_ENV);
/***
* Le front controller
***/
   Zend_Controller_Front::getInstance()
   -registerPlugin($initPlugin, 1)
   -registerPlugin($localePlugin, 2)
   -registerPlugin($navigationPlugin, 3);


In few words, it seems that my view renderer is destruct and replace by 
a new one.


Can someone helps me ?

Thanks :)


[fw-general] [Paginator] several paginators per page + other issues

2008-09-12 Thread Olivier Ricordeau

Hi list,

First, I'm wondering if it's possible to have several paginators in the 
same page (I want to display them in the same page, but in different 
tabs). I'm asking this question because the example paginator control 
scripts use $this-previous (for instance), so I was thinking that 
several paginators per page could lead to conflicts. If the answer is 
no, is there a known workaround?


Second question: I have a strange behaviour with the view variables. In 
my controller's init() method I declare a few view variables (ex: 
$this-view-trans = new Translator()) and I can't manage to access them 
in the paginator control script. I've tried to make a var_dump($this) 
and $this has the type MyView (which is fine, MyView is a custom class 
that inherits from Zend_View). But I get an error if I write 
$this-trans-some_method(), telling me Call to a member function 
some_method() on a non-object

NB: Yes, I do a $paginator-setView($this-view) in my controller.

Cheers,
Olivier

--
- *Olivier RICORDEAU* -
 [EMAIL PROTECTED]



Re: [fw-general] Problem with Zend_View initialisation...

2008-09-12 Thread valugi

I think you should also check in the bootstrap for an existing dispatch check
plugin which checks the request object and if it founds it malformed
redirects this error controller/failure action.
-- 
View this message in context: 
http://www.nabble.com/Problem-with-Zend_View-initialisation...-tp19453716p19454175.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Class attribute of label and element

2008-09-12 Thread valugi

If you are constructing the element with Zend_Form_Element you can use

$element-setAttrib('class', false );

-- 
View this message in context: 
http://www.nabble.com/Class-attribute-of-label-and-element-tp19429978p19454369.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] [Paginator] several paginators per page + other issues

2008-09-12 Thread Bruno Friedmann
Hi Olivier,

Olivier Ricordeau wrote:
 Hi list,
 
 First, I'm wondering if it's possible to have several paginators in the
 same page (I want to display them in the same page, but in different
 tabs). I'm asking this question because the example paginator control
 scripts use $this-previous (for instance), so I was thinking that
 several paginators per page could lead to conflicts. If the answer is
 no, is there a known workaround?

I've recently implement paginator ( in simple use only 1 element by page ).
I have put it in top and bottom inside my view and I've not found any trouble 
with them.

in the view
?php echo $this-paginationControl($this-paginator, 'Jumping', 
'paginator.phtml'); ?

paginator.phtml is like the template found in docs.



 
 Second question: 
For this one I've no idea ... yet :-)

I have a strange behaviour with the view variables. In
 my controller's init() method I declare a few view variables (ex:
 $this-view-trans = new Translator()) and I can't manage to access them
 in the paginator control script. I've tried to make a var_dump($this)
 and $this has the type MyView (which is fine, MyView is a custom class
 that inherits from Zend_View). But I get an error if I write
 $this-trans-some_method(), telling me Call to a member function
 some_method() on a non-object
 NB: Yes, I do a $paginator-setView($this-view) in my controller.
 
 Cheers,
 Olivier
 


-- 

 Bruno Friedmann

Ioda-Net Sàrl
  2830 Vellerat - Switzerland

  Tél : ++41 32 435 7171
  Fax : ++41 32 435 7172
  gsm : ++41 78 802 6760
  www.ioda-net.ch

 Centre de Formation et de Coaching En Ligne
 www.cfcel.com



Re: [fw-general] HowTo Zend_Test_PHPUnit_ControllerTestCase + Zend_Session

2008-09-12 Thread Matthew Weier O'Phinney
Bruno --

I sent an email yesterday, but I don't see it in the archives, so I'll
ask again: Can you send both the bootstrap you use, the controller being
tested, and the test case? It's really hard to debug when I don't have
the information needed to reproduce the issue.

I know that Zend_Test works fine with sessions, as the example I
developed for the documentation -- the login form example -- utilizes
Zend_Session, and works. The issue here is likely something to do with
either (a) whitespace appearing before or after a class definition, or
(b) the environment you setup for your application. Both are
correctible.

-- Bruno Friedmann [EMAIL PROTECTED] wrote
(on Thursday, 11 September 2008, 06:53 PM +0200):
 Bruno Friedmann wrote:
  I'm facing a problem how to do this.
  
  I've a application bootstrap which relies on Zend_Session. And I want to 
  test controllers with the new (not so)
  Zend_Test_PHPUnit_ControllerTestCase.
  
  It's the first time I've to do this so excuse me for the newb questions.
  
  I've follow the documentation and also the Mathew post blog and wiki.
  
  On a simple Hello world example  tests are working nicely. (not too 
  difficult, but just here to prove the env is correctly setup)
  
  So when I launch my test on the complicate bootstrap I've received this 
  error :
  
  PHPUnit 3.2.21 by Sebastian Bergmann.
  
  IndexControllerTest
  E
  
  Time: 0 seconds
  
  There were 1 errors:
  
  1) testIndexAction(IndexControllerTest)
  Zend_Session_Exception: Session must be started before any output has been 
  sent to the browser; output started in
  /usr/share/php5/PEAR/PHPUnit/Util/Printer.php/139
  /ioda/data/web-include/ZF/library.160/Zend/Session/Namespace.php:116
  /home/bruno/workspace/socketfinder/sf/ZfApplication.php:155
  /home/bruno/workspace/socketfinder/sf/ZfApplication.php:118
  /home/bruno/workspace/socketfinder/sf/ZfApplication.php:98
  /home/bruno/workspace/socketfinder/sf/tests/Sf/controllers/IndexControllerTest.php:22
  
  I'm pretty sure I would have to do some sort of ouput_buffering but google 
  was not my friend today.
  It only give me what phpunit session conference I've missed.
  
  Any path to a solution or any advice are welcome.
  
 
 Ok a little step futher
 I've found that we can change this.
 Zend_Session::$_unitTestEnabled = true;
 
 but I've always a error ...
 
 testIndexAction(IndexControllerTest)
 Undefined variable: _SESSION
 /ioda/data/web-include/ZF/library.160/Zend/Session.php:522
 /ioda/data/web-include/ZF/library.160/Zend/Session.php:448
 /ioda/data/web-include/ZF/library.160/Zend/Session/Namespace.php:116
 /home/bruno/workspace/socketfinder/sf/ZfApplication.php:156
 
 
 
 -- 
 
  Bruno Friedmann
 
 

-- 
Matthew Weier O'Phinney
Software Architect   | [EMAIL PROTECTED]
Zend Framework   | http://framework.zend.com/


Re: [fw-general] HowTo Zend_Test_PHPUnit_ControllerTestCase + Zend_Session

2008-09-12 Thread Matthew Weier O'Phinney
-- Giorgio Sironi [EMAIL PROTECTED] wrote
(on Friday, 12 September 2008, 12:21 PM +0200):
 2008/9/11 Bruno Friedmann [EMAIL PROTECTED]:
  I've a application bootstrap which relies on Zend_Session. And I want to 
  test controllers with the new (not so)
  Zend_Test_PHPUnit_ControllerTestCase.
 
 The problem is that Zend_Session is static: 

We are well aware of Zend_Session's shortcomings, and have plans to
rewrite it for 2.0. It's basically impossible to test in its current
state, and over-engineered. (No, I did _not_ write it.) I had to place
some really ugly hacks in it to get it to work for testing with
Zend_Test.

 I also have opened a topic in the fw-mvc list blaming the presence of
 so many static classes in the framework components. Obviously you can
 reset some of them, like Zend_Test_* does with the front controller
 and the helper broker, but to me it feels like a workaround; 

This is something we also hope to address in 2.0. However, there are
definitely some good reasons to have the front controller a singleton,
and I haven't heard any truly compelling arguments for it not to be.
Same goes for the helper broker. If you or others can suggest a design
that meets the requirements of these components, I'm all ears, and
welcome your input -- but just saying it's hackish and/or stinks doesn't
really further the dialog.

 also it means Zend_Session and other classes has to be aware of
 testing, while a class should have only one resposibility.

See above.

-- 
Matthew Weier O'Phinney
Software Architect   | [EMAIL PROTECTED]
Zend Framework   | http://framework.zend.com/


Re: [fw-general] Zend_Dojo_Form errors

2008-09-12 Thread Matthew Weier O'Phinney
-- valugi [EMAIL PROTECTED] wrote
(on Friday, 12 September 2008, 03:50 AM -0700):
 1. Request object error
 If you have errors in the request object when trying to make your forms to
 use dojo, here is some clue. Dojo dijits uses some html templates and
 .htaccess usually is not prepared for this.
 
 .htaccess code:
 RewriteEngine on
 RewriteRule !\.(js|ico|gif|jpg|png|css|html)$ index.php

I posted a message to this list a couple days ago regarding this. Use
the following rewrite rule instead:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]

 2. There is some error in the distribution that I have from zf. 1.6
 I jave requests to this path:
 
 http://zf.mysite.com/js/dojo/dijit/form/nls/en/validate.js
 
 But then english version of this script is not there, is in the parent
 folder.. just the english one.
 http://zf.mysite.com/js/dojo/dijit/form/nls/validate.js
 
 Can someone point how to make a good compilation of the dojo library so we
 wont have this problems?

First off, can you send an HTML document that displayes this error for
me? I cannot reproduce it currently. Just save the HTML source of the
page that shows the issue.

Second, there are two ways you can get a Dojo release build:

  * go into the util/buildscripts/ subdirectory of the Dojo
installation, and run './build_release.sh'. This will create a Dojo
release build in the release/ subdirectory. Use that build for your
application

  * download a build from the Dojo website

 3. I want to validate a text field for emails. The below sintax is correct
 as Zend_Dojo_Form_Element inherits from regular Zend_Form_Element to which I
 can add validators for email. This means that dojo should make use of this
 validator on user side or I have to add a special validator plugin of Dojo
 itself in order to do the validation?

First off, ZF validators are server-side only; we have not implemented
any functionality to translate them to Dojo client-side validations.
This is for many reasons: no 1:1 correspondence between most ZF
validators and Dojo validation constraints; users can write custom ZF
validators, and we have no mechanisms for hinting to Dojo how to
interpret those.

So, this brings me to the second point: you'll have to use a dijit that
*can* perform validations. TextBox does not. I'd use ValidationTextBox,
and then provide it with a regExp property with a minimal regex for
vlaidating an email address:

 
   $email = new Zend_Dojo_Form_Element_TextBox( 'email' );

becomes:

$email = new Zend_Dojo_Form_Element_ValidationTextBox( 'email' 
);

   $email
   -setLowercase( true )
   -setMaxLength(40)

add this:

-setRegExp('[EMAIL PROTECTED],4}\b')

   -setFilters(
   array(
   new Zend_Filter_StringToLower(),
   new Zend_Filter_StringTrim()
   )
   )   
   -setLabel('Email')
   -addValidator( new Zend_Validate_EmailAddress())
   -setRequired( true )
   ;

and done.

-- 
Matthew Weier O'Phinney
Software Architect   | [EMAIL PROTECTED]
Zend Framework   | http://framework.zend.com/


Re: [fw-general] Problem with Zend_View initialisation...

2008-09-12 Thread Matthew Weier O'Phinney
-- Apsy [EMAIL PROTECTED] wrote
(on Friday, 12 September 2008, 01:04 PM +0200):
 I have a problem with my custom class of Zend_View.

 In my bootstrap, i have instanciate a plugin wich initialize the  
 application like the Pastebin app of Matthew.
 But i have a problem :
 in my initView method of my plugin :

 public function initView()
{
/*
 * View
 /
$view = new App_View_Page();

snip: view configuration

  /*
 * ViewRenderer
 /
$viewRenderer = new  
 Zend_Controller_Action_Helper_ViewRenderer($view);
$viewRenderer
 -setViewBasePathSpec(BASE_PATH . '/application/design/views')
 -setViewScriptPathSpec(':module/:controller/:action.:suffix')
 -setViewSuffix('phtml');
Zend_Debug::dump(get_class($viewRenderer-view));
$viewRenderer-init();

Here's the problem, right there. init() will initialize a DIFFERENT view
object. What you want to do is add your already initialized view object
to the view renderer:

$viewRenderer-setView($view);

and then things should work as expected

-- 
Matthew Weier O'Phinney
Software Architect   | [EMAIL PROTECTED]
Zend Framework   | http://framework.zend.com/


[fw-general] Singletons.

2008-09-12 Thread a_d_j_i

I want to make an application (like a library) embedded in another
application both using ZendFramework. My problem is that in the embedded
application I can't use the functionality of the singleton classes of
ZendFramework because I don't know how or who is using them.
There is a way to solve this ?


Thanks in advance [EMAIL PROTECTED]
-- 
View this message in context: 
http://www.nabble.com/Singletons.-tp19457005p19457005.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] [Paginator] several paginators per page + other issues

2008-09-12 Thread SiCo007

Hi, the paginators if set up as per the manual use partials, I may be wrong
as I've never used partials except for the paginator, the idea is that the
paginator lives within it's own space. Therefore it doesn't in heirt your
view variables just the variables you tell it to.

If you look at the paginator code it allows you to pass parameters to the
partial in the calling display method (I believe it's the last parameter).
These will then be accessible in your partial as their own variable.

Like I say though I may be wrong as I've never gone any more advanced than
just passing a string to the paginator.


Olivier Ricordeau wrote:
 
 
 I have a strange behaviour with the view variables. In
 my controller's init() method I declare a few view variables (ex:
 $this-view-trans = new Translator()) and I can't manage to access them
 in the paginator control script. I've tried to make a var_dump($this)
 and $this has the type MyView (which is fine, MyView is a custom class
 that inherits from Zend_View). But I get an error if I write
 $this-trans-some_method(), telling me Call to a member function
 some_method() on a non-object
 NB: Yes, I do a $paginator-setView($this-view) in my controller.
 
 Cheers,
 Olivier
 
 


-
Simon

http://www.ajb007.co.uk/
-- 
View this message in context: 
http://www.nabble.com/-Paginator--several-paginators-per-page-%2B-other-issues-tp19453883p19457129.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] HowTo Zend_Test_PHPUnit_ControllerTestCase + Zend_Session

2008-09-12 Thread Giorgio Sironi
2008/9/12 Matthew Weier O'Phinney [EMAIL PROTECTED]:
 -- Giorgio Sironi [EMAIL PROTECTED] wrote
 (on Friday, 12 September 2008, 12:21 PM +0200):

 I also have opened a topic in the fw-mvc list blaming the presence of
 so many static classes in the framework components. Obviously you can
 reset some of them, like Zend_Test_* does with the front controller
 and the helper broker, but to me it feels like a workaround;

 This is something we also hope to address in 2.0. However, there are
 definitely some good reasons to have the front controller a singleton,
 and I haven't heard any truly compelling arguments for it not to be.
 Same goes for the helper broker. If you or others can suggest a design
 that meets the requirements of these components, I'm all ears, and
 welcome your input -- but just saying it's hackish and/or stinks doesn't
 really further the dialog.

Singletons are enemy of unit testing because they carry state around
the application. This state is bad because every test should be
independent of the others. That's the reason why the front controller
is reset in every setUp().
I think Zend_Controller_Front is currently a singleton because it has
to be globally accessible.
A rapid `grep -r Zend_Controller_Front::getInstance library/Zend/`
gives interesting results, for instance some helpers:
library/Zend/Controller/Action/Helper/Redirector.php
library/Zend/View/Helper/Url.php
This is a circular reference: how the helpers are supposed to be Unit
tested if they depends on the entire object graph of the application?
I think the request, response, router etc. objects can be injected by
a factory owned by the front controller (or passed in the dispatcher).
The helper broker is registered as the $_helper property of every
controller dispatched, so putting a HelperList object as a public
property of the front controller can help the dispatcher to produce a
new broker to put in the controller choosed.
The main flow of the application will be something like:
class Application
{
$front = new Zend_Controller_Front();
$front-helpers-add(...) //$front-getHelperList() if you want
$front-getRequest()-add(array($_GET, $_POST, $_FILES, ...)); //
exagerating,
   // but superglobals are
also a global point of access
$front-dispatch();
}
..
class AUnitTestCase
{
$request = new Zend_Controller_Request(..);
$helper = new Zend_Controller_Action_Helper_ActionStack($request, ...);
}
..
class AIntegrationTestCase
{
$app = new Application();
$app-getFront()-getRequest()-add(// .. whatever you want
$app-dispatch('/');
$this-assertQuery($app-getResponse(), );
}
(These are only examples of what I think can improve the unit
testability of components and applications).
More discussion forthcoming..

-- 
Giorgio Sironi
Piccolo Principe  Ossigeno Scripter
http://www.sourceforge.net/projects/ossigeno


RE: [fw-general] Models and folder grouping

2008-09-12 Thread Scott Miller
I followed you up to a point.

1) I didn't have modules in my layout.  But given the size of this project
it makes sense so I reorganized my folder structure to use models (this
alone may make organization much easier the more I think about it)

2) I had to add a $paths[] = $moduleDir; so that I could access forms

3) $row =
Project::getModel('Acl/Users')-fetchRow($user-select()-where('user_name =
?', $form-getValue('username')));

Returns an error: Fatal error: Call to a member function fetchRow() on a
non-object in
C:\wamp\www\el-cel\application\modules\User\controllers\IndexController.php
on line 126

My layout was (in part)
- application
- - modules
- - - user
- - - - models
- - - - - acl
- - - - - - users.php
 



RE: [fw-general] Models and folder grouping

2008-09-12 Thread jkush1121

See, I think I was a bit unclear with my approach. It's a bit different.
Here's how I organized it:

The actual layout turns out as follows during the forloop:

/app
/app/modules
/app/modules/core
/app/modules/core/models -- Added to inclusion path during the forloop
/app/modules/core/models/Core 
/app/modules/core/models/Core/User.php
/app/modules/payment
/app/modules/payment/models -- Added to inclusion path during the forloop
/app/modules/payment/models/Payment
/app/modules/payment/models/Payment/Securepay.php

However, now I have the ability to create a new object of
Payment_Securepay(). 
   = Payment_Securepay  === Payment/Securepay.php

I did this for a couple reasons:

1.) Now I have the ability to reflect the table payment_securepay accurately
( without having to make modifications ). 
The php_inclusion path has already been set during the forloop of my
directory:

Project::register('original_include_path',  get_include_path());
\$paths[] = BP . DS . 'app' . DS . 'modules';
\$paths[] = BP . DS . 'lib';
\$dir = new DirectoryIterator(Project::getRoot().DS.'modules');
foreach(\$dir as \$file){
if (\$file-isDot() || !\$file-isDir()) {
continue;
}
--- ( HERE)\$paths[] = \$file-getPathname().DS.'models';
}
set_include_path( implode(PS, \$paths) . PS .
Project::registry('original_include_path'));

2. ) I also now can separate my models into various modules. ( obviously )

3.) My little trick was nothing more than a simple way to utilize the models
a different way 

For example,

Project::getModel('core/session', array('name'='something'))-start();

This will do...

1.) require_once 'Core/Session.php';
2.) pass array('name'='something')
3.) calls start method on the returning object.

For you:

The Acl/Users call should request:

/app
/app/modules
/app/modules/acl
/app/modules/acl/models -- Added to inclusion path during the forloop
/app/modules/acl/models/Acl
/app/modules/acl/models/Acl/Users.php

which will be...

class Acl_Users extends Zend_Db_Table_Abstract


which then ofcourse,

table acl_users...


Let me know if you still are having issues.


-jk


Ghrae wrote:
 
 I followed you up to a point.
 
 1) I didn't have modules in my layout.  But given the size of this project
 it makes sense so I reorganized my folder structure to use models (this
 alone may make organization much easier the more I think about it)
 
 2) I had to add a $paths[] = $moduleDir; so that I could access forms
 
 3) $row =
 Project::getModel('Acl/Users')-fetchRow($user-select()-where('user_name
 =
 ?', $form-getValue('username')));
 
 Returns an error: Fatal error: Call to a member function fetchRow() on a
 non-object in
 C:\wamp\www\el-cel\application\modules\User\controllers\IndexController.php
 on line 126
 
 My layout was (in part)
 - application
 - - modules
 - - - user
 - - - - models
 - - - - - acl
 - - - - - - users.php
  
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Models-and-folder-grouping-tp19412763p19458055.html
Sent from the Zend Framework mailing list archive at Nabble.com.


RE: [fw-general] Models and folder grouping

2008-09-12 Thread jkush1121

Also, i would do...
admin/models/admin/acl/user.php

which represents the table admin_acl_user. Making a module out of the ACL
Player should be grouped into an administration module. ( atleast thats how
i see it ).

-jk


jkush1121 wrote:
 
 See, I think I was a bit unclear with my approach. It's a bit different.
 Here's how I organized it:
 
 The actual layout turns out as follows during the forloop:
 
 /app
 /app/modules
 /app/modules/core
 /app/modules/core/models -- Added to inclusion path during the forloop
 /app/modules/core/models/Core 
 /app/modules/core/models/Core/User.php
 /app/modules/payment
 /app/modules/payment/models -- Added to inclusion path during the forloop
 /app/modules/payment/models/Payment
 /app/modules/payment/models/Payment/Securepay.php
 
 However, now I have the ability to create a new object of
 Payment_Securepay(). 
= Payment_Securepay  === Payment/Securepay.php
 
 I did this for a couple reasons:
 
 1.) Now I have the ability to reflect the table payment_securepay
 accurately ( without having to make modifications ). 
 The php_inclusion path has already been set during the forloop of my
 directory:
 
 Project::register('original_include_path',get_include_path());
   \$paths[] = BP . DS . 'app' . DS . 'modules';
   \$paths[] = BP . DS . 'lib';
   \$dir = new DirectoryIterator(Project::getRoot().DS.'modules');
   foreach(\$dir as \$file){
   if (\$file-isDot() || !\$file-isDir()) {
   continue;
   }
 --- ( HERE)  \$paths[] = \$file-getPathname().DS.'models';
   }
   set_include_path( implode(PS, \$paths) . PS .
 Project::registry('original_include_path'));
 
 2. ) I also now can separate my models into various modules. ( obviously )
 
 3.) My little trick was nothing more than a simple way to utilize the
 models a different way 
 
 For example,
 
 Project::getModel('core/session', array('name'='something'))-start();
 
 This will do...
 
 1.) require_once 'Core/Session.php';
 2.) pass array('name'='something')
 3.) calls start method on the returning object.
 
 For you:
 
 The Acl/Users call should request:
 
 /app
 /app/modules
 /app/modules/acl
 /app/modules/acl/models -- Added to inclusion path during the forloop
 /app/modules/acl/models/Acl
 /app/modules/acl/models/Acl/Users.php
 
 which will be...
 
 class Acl_Users extends Zend_Db_Table_Abstract
 
 
 which then ofcourse,
 
 table acl_users...
 
 
 Let me know if you still are having issues.
 
 
 -jk
 
 
 Ghrae wrote:
 
 I followed you up to a point.
 
 1) I didn't have modules in my layout.  But given the size of this
 project
 it makes sense so I reorganized my folder structure to use models (this
 alone may make organization much easier the more I think about it)
 
 2) I had to add a $paths[] = $moduleDir; so that I could access forms
 
 3) $row =
 Project::getModel('Acl/Users')-fetchRow($user-select()-where('user_name
 =
 ?', $form-getValue('username')));
 
 Returns an error: Fatal error: Call to a member function fetchRow() on a
 non-object in
 C:\wamp\www\el-cel\application\modules\User\controllers\IndexController.php
 on line 126
 
 My layout was (in part)
 - application
 - - modules
 - - - user
 - - - - models
 - - - - - acl
 - - - - - - users.php
  
 
 
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Models-and-folder-grouping-tp19412763p19458155.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Models and folder grouping

2008-09-12 Thread valugi

I think the most elegant way is to create your Loader

// in the bootstrap
require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload( 'My_Loader' );


//Your class in library
class My_Loader
{

public static function loadClass( $class)
{
 
// autodiscover the path from the class name
   
}

}

-- 
View this message in context: 
http://www.nabble.com/Models-and-folder-grouping-tp19412763p19458193.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] [Paginator] several paginators per page + other issues

2008-09-12 Thread Matthew Ratzloff
Hi Olivier,
I can confirm what Bruno and Simon have already said.  You may have multiple
pagination controls per page.  Note that the $this referenced in the view
partial is not the Zend_View instance, but a separate object containing
values for previous, next, etc.  Thus you would not be able to access any
variables from the view instance.

As noted by Simon, the final parameter of the PaginationControl helper is
reserved for user parameters.  A variety of documentation updates are
forthcoming.

-Matt

On Fri, Sep 12, 2008 at 4:19 AM, Olivier Ricordeau [EMAIL PROTECTED]wrote:

 Hi list,

 First, I'm wondering if it's possible to have several paginators in the
 same page (I want to display them in the same page, but in different tabs).
 I'm asking this question because the example paginator control scripts use
 $this-previous (for instance), so I was thinking that several paginators
 per page could lead to conflicts. If the answer is no, is there a known
 workaround?

 Second question: I have a strange behaviour with the view variables. In my
 controller's init() method I declare a few view variables (ex:
 $this-view-trans = new Translator()) and I can't manage to access them in
 the paginator control script. I've tried to make a var_dump($this) and $this
 has the type MyView (which is fine, MyView is a custom class that inherits
 from Zend_View). But I get an error if I write $this-trans-some_method(),
 telling me Call to a member function some_method() on a non-object
 NB: Yes, I do a $paginator-setView($this-view) in my controller.

 Cheers,
 Olivier

 --
 - *Olivier RICORDEAU* -
  [EMAIL PROTECTED]




Re: [fw-general] One simple problem tooks me 2 hour- hope it will help someone..

2008-09-12 Thread vladimirn

Now i have similar(or not) issue.
Fatal error: Uncaught exception 'Zend_Loader_PluginLoader_Exception' with
message 'Plugin by name LoggedInUser was not found in the registry.

I have in application/views/helpers/ file LoggedInUser.php

?php
class Zend_View_Helper_LoggedInUser
{
protected $_view;
function setView($view) 
{ 
$this-_view = $view; 
} 
function loggedInUser()
{
$auth = Zend_Auth::getInstance();
if($auth-hasIdentity()) 
{
$logoutUrl = $this-_view-linkTo('login/logout');
$user = $auth-getIdentity(); 

$username = $this-_view-escape(ucfirst($user));
$string = 'Welcome ' . $username . ' |  ' .
$logoutUrl . ' Log out ';
} else {
//$loginUrl = $this-_view-linkTo('auth/identify'); #4
//$string = ' '. $loginUrl . ' Log in '; #5
}if (isset($user)) {
return $string;}
}
}

In my layout i am trying to do next:
?php if (!$this-loggedInUser()):?
div id=header.

In bootstrap file i have:
$base  = realpath(dirname(__FILE__) . '/../');
$paths = array(
'.', 
$base . '/library',
$base . '/application',
$base . '/application/forms',
$base . '/application/models',
);
ini_set('include_path', implode(PATH_SEPARATOR, $paths));

I would like to say that i already read similar topic here, but didnt helped
me.

Thank you very much,
Vladimir

-- 
View this message in context: 
http://www.nabble.com/One-simple-problem-tooks-me-2-hour--hope-it-will-help-someone..-tp19445706p19460458.html
Sent from the Zend Framework mailing list archive at Nabble.com.



[fw-general] Status of Default Project Structure Component Proposal

2008-09-12 Thread Ralf Eggert
Hi,

I am highly interested in the current status of the Default Project
Structure Component Proposal. In June the proposal was approved for
incubator development.

http://framework.zend.com/wiki/x/6KM

Is there any news?

Thanks and best regards,

Ralf



RE: [fw-general] One simple problem tooks me 2 hour- hope it will help someone..

2008-09-12 Thread Terre Porter

I don't see a reference to a helper path for the view to use.

Something like : $this-_view-addHelperPath('path-to-helpers-dir'); 

Hope it helps

Terre


-Original Message-
From: vladimirn [mailto:[EMAIL PROTECTED] 
Sent: Friday, September 12, 2008 1:19 PM
To: fw-general@lists.zend.com
Subject: Re: [fw-general] One simple problem tooks me 2 hour- hope it will
help someone..


Now i have similar(or not) issue.
Fatal error: Uncaught exception 'Zend_Loader_PluginLoader_Exception' with
message 'Plugin by name LoggedInUser was not found in the registry.

I have in application/views/helpers/ file LoggedInUser.php

?php
class Zend_View_Helper_LoggedInUser
{
protected $_view;
function setView($view)
{
$this-_view = $view;
}
function loggedInUser()
{
$auth = Zend_Auth::getInstance();
if($auth-hasIdentity())
{
$logoutUrl = $this-_view-linkTo('login/logout');
$user = $auth-getIdentity(); 

$username = $this-_view-escape(ucfirst($user));
$string = 'Welcome ' . $username . ' |  ' .
$logoutUrl . ' Log out ';
} else {
//$loginUrl = $this-_view-linkTo('auth/identify'); #4 //$string = ' '.
$loginUrl . ' Log in '; #5 }if (isset($user)) { return $string;} } }

In my layout i am trying to do next:
?php if (!$this-loggedInUser()):?
div id=header.

In bootstrap file i have:
$base  = realpath(dirname(__FILE__) . '/../'); $paths = array(
'.', 
$base . '/library',
$base . '/application',
$base . '/application/forms',
$base . '/application/models',
);
ini_set('include_path', implode(PATH_SEPARATOR, $paths));

I would like to say that i already read similar topic here, but didnt helped
me.

Thank you very much,
Vladimir

--
View this message in context:
http://www.nabble.com/One-simple-problem-tooks-me-2-hour--hope-it-will-help-
someone..-tp19445706p19460458.html
Sent from the Zend Framework mailing list archive at Nabble.com.




Re: [fw-general] Status of Default Project Structure Component Proposal

2008-09-12 Thread Matthew Weier O'Phinney
-- Ralf Eggert [EMAIL PROTECTED] wrote
(on Friday, 12 September 2008, 07:25 PM +0200):
 I am highly interested in the current status of the Default Project
 Structure Component Proposal. In June the proposal was approved for
 incubator development.
 
 http://framework.zend.com/wiki/x/6KM
 
 Is there any news?

The version currently posted is the version we've accepted and which
Ralph is using as his target for Zend_Tool.

I saw your comment come through. We'd prefer not to have two separate
directory layouts. The reason is that a site may grow organically, and
at first need simply a single controller directory. As the sites needs
grow, the developer should not need to refactor; adding a modules
directory to application/ is a simple step and already supported by the
front controller and dispatcher.

-- 
Matthew Weier O'Phinney
Software Architect   | [EMAIL PROTECTED]
Zend Framework   | http://framework.zend.com/


[fw-general] Benchmarks

2008-09-12 Thread Matthew Ratzloff
In case anyone is curious, Rasmus Lerdorf posted some benchmarks of the
different frameworks.  Solar and Zend Framework come out ahead.
http://talks.php.net/show/drupal08/24

-Matt


RE: [fw-general] One simple problem tooks me 2 hour- hope it will help someone..

2008-09-12 Thread vladimirn



vRandom wrote:
 
 
 I don't see a reference to a helper path for the view to use.
 
 Something like : $this-_view-addHelperPath('path-to-helpers-dir'); 
 
 Hope it helps
 
 Terre
 
 
 


Thanks Terre :)
-- 
View this message in context: 
http://www.nabble.com/One-simple-problem-tooks-me-2-hour--hope-it-will-help-someone..-tp19445706p19462333.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Zend_Dojo Email validation, checkbox and Submit dojo form question- please?

2008-09-12 Thread vladimirn

Dear Matthew, 
thanks for your help.
I managed to prevent submiting form before all required fields are properly
filled.


Email:
-addElement ( 'validationTextBox', 'email', array ('required' = true,
'label' = 'Email address', 'regExp' =
'[EMAIL PROTECTED],4}\b', 'invalidMessage' =
'Please provide valid Email address.', 'filters' = array ('StringTrim',
'StringToLower' ), 'validators' = array ('NotEmpty', array ('StringLength',
true, array (6, 20 ) ), array ('Regex', true, array ('/\w+/i' ) ) ) ) )
(maybe someone will find this usefull)

BUT! :))

my checkboxes wont work :)

$agreements
-addElement ( 'checkbox', 'ages', array ('required' = true, 'label' =
'I\'m Over 18 years old', 'invalidMessage' = 'You must validate that you
are over 18' ) )
-addElement ( 'checkbox', 'promotions', array ('required' = true, 'label'
= 'I agree NOT to send any email promotions promoting this web site',
'invalidMessage' = 'You must validate that you are over 18' ) )
-addElement ( 'checkbox', 'terms', array ('required' = true, 'label' = 'I
agree to the Terms  Conditions', 'invalidMessage' = 'You must validate
that you are over 18' ) );

$form = new Zend_Dojo_Form ( );
$form-setMethod ( 'post' )-setAction ( /signup/process )-setName (
'signup' );

Alert you suggested me to make wont work as well :(
phtml:
? $this-dojo()-javascriptCaptureStart() ?
function validateForm() {
var form = dijit.byId(signup);
if (!form.validate()) {
alert(Invalid form);
return false;
}
return true;
}
? $this-dojo()-javascriptCaptureEnd() ?
? $this-dojo()-onLoadCaptureStart() ?
function () {
dojo.connect(dijit.byId(signup), onSubmit, validateForm);
}
? $this-dojo()-onLoadCaptureEnd() ?
div class=signupForm

?= $this-form ?
/div


Thanks,
Vladimir
-- 
View this message in context: 
http://www.nabble.com/Zend_Dojo-Email-validation%2C-checkbox-and-Submit-dojo-form-question--please--tp19441003p19462822.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Status of Default Project Structure Component Proposal

2008-09-12 Thread Ralf Eggert
Hi Matthew,

thanks for your reply

 I saw your comment come through. We'd prefer not to have two separate
 directory layouts. The reason is that a site may grow organically, and
 at first need simply a single controller directory. As the sites needs
 grow, the developer should not need to refactor; adding a modules
 directory to application/ is a simple step and already supported by the
 front controller and dispatcher.

Ok, thanks for the clarification. That makes sense to me!

Best regards,

Ralf


[fw-general] Loosing translations: ja_JP

2008-09-12 Thread mbneto
Hi,

I am facing a strange problem.  I have two servers (both same Linux
distro/version) and in one I can use the ja_JP translation with ZF and in
the other the loaded locale simply show empty strings for all japanese
characters.

I have a locale/ja_JP (CSV) with

something;字だけ入力してください
smeothing2:something2

in my code I use the $tr-_('something') and $tr-_('something2');

In one server both work and in the other only the something2 (added just to
test the application was loading the right locale file).

I've var_dump the $tr and it shows the  [_translate:protected] with all
the locales and the key = value correct for the something2 but in blank for
the something (ex.

[ja_JP]=
  array(29) {
[Name]=
string(0) 
...

Any ideas?


Re: [fw-general] Zend_Dojo_Form and Checkbox Element

2008-09-12 Thread Andrew Yager

I've just tried trunk, and have the same behaviour.

Having looked again at the HTML being generated, it seems quite odd:
dd input name=courseList[CEAudio] value=0 type=hidden  
input

options=enroll notenroll id=courseList[CEAudio]
name=courseList[CEAudio] value=notenroll type=checkbox /dd


You can't be using trunk. IDs on dijit CheckBoxes were fixed three  
days

ago. Please update your svn checkout and re-verify.


You were right; I wasn't using the latest trunk and have now fixed  
this. The HTML is much better:
input name=courseList[CBAudio] value=0 type=hiddeninput  
id=courseList-CBAudio name=courseList[CBAudio] value=notenroll  
type=checkbox
but the code still seems to be doing slightly the wrong thing; instead  
of putting the unchecked value into the hidden element, it puts it  
into the checkbox element, and the hidden element continues to show a  
value of 0.


For the elements that are checked by the $form-populate() method, the  
checkbox's value is enroll (the correct checked value).


I quickly verified this if I don't set the checked/unchecked values  
when I create the form elements - both the checkbox and hidden element  
show a value of '0', so I'm guessing at this point it is a bug?



Most Dojo widgits have their id's generated as (for example)
courseList-CEAudio ([] replaced by -), and I'm still confused as to  
how
the hidden/checkbox of the same name are supposed to function  
(although

they seem to, so I can't complain).


Basically, when a checkbox is unchecked, either no value is  
submitted or

an empty string is submitted for it (depending on the browser). This
causes issues on the server-side, particularly if the value is  
required.

The hidden element ensures a value is returned when the checkbox is
unchecked.

Within Zend_Form/Zend_Dojo, we allow you to set both the checked and
unchecked values; the unchecked value is placed in the hidden element,
the checked value in the checkbox itself. This way you get the
appropriate value back based on the status of the checkbox at
submission.


This makes great sense :-)

Thanks,
Andrew

--
Andrew Yager, Managing Director   (MACS BCompSc MCP)
Real World Technology Solutions Pty Ltd
ph: 1300 798 718 or (02) 9037 0500
fax: (02) 9037 0591 mob: 0405 152 568
http://www.rwts.com.au/ or http://www.stonebridgecomputing.com.au/



Re: [fw-general] Zend_Dojo_Form and Checkbox Element

2008-09-12 Thread Matthew Weier O'Phinney
-- Andrew Yager [EMAIL PROTECTED] wrote
(on Saturday, 13 September 2008, 10:17 AM +1000):
 I've just tried trunk, and have the same behaviour.

 Having looked again at the HTML being generated, it seems quite odd:
 dd input name=courseList[CEAudio] value=0 type=hidden  
 input
 options=enroll notenroll id=courseList[CEAudio]
 name=courseList[CEAudio] value=notenroll type=checkbox /dd

 You can't be using trunk. IDs on dijit CheckBoxes were fixed three  
 days
 ago. Please update your svn checkout and re-verify.

 You were right; I wasn't using the latest trunk and have now fixed this. 
 The HTML is much better:
 input name=courseList[CBAudio] value=0 type=hiddeninput  
 id=courseList-CBAudio name=courseList[CBAudio] value=notenroll  
 type=checkbox
 but the code still seems to be doing slightly the wrong thing; instead  
 of putting the unchecked value into the hidden element, it puts it into 
 the checkbox element, and the hidden element continues to show a value of 
 0.

 For the elements that are checked by the $form-populate() method, the  
 checkbox's value is enroll (the correct checked value).

 I quickly verified this if I don't set the checked/unchecked values when 
 I create the form elements - both the checkbox and hidden element show a 
 value of '0', so I'm guessing at this point it is a bug?

Yes. Please create an issue in the tracker. Be sure to include:
 
 * Minimum code necessary to reproduce
 * Expected result (in this case, the expected HTML)
 * Actual result (actual HTML generated)

Thanks!


 Most Dojo widgits have their id's generated as (for example)
 courseList-CEAudio ([] replaced by -), and I'm still confused as to  
 how
 the hidden/checkbox of the same name are supposed to function  
 (although
 they seem to, so I can't complain).

 Basically, when a checkbox is unchecked, either no value is submitted 
 or
 an empty string is submitted for it (depending on the browser). This
 causes issues on the server-side, particularly if the value is  
 required.
 The hidden element ensures a value is returned when the checkbox is
 unchecked.

 Within Zend_Form/Zend_Dojo, we allow you to set both the checked and
 unchecked values; the unchecked value is placed in the hidden element,
 the checked value in the checkbox itself. This way you get the
 appropriate value back based on the status of the checkbox at
 submission.

 This makes great sense :-)

 Thanks,
 Andrew

 --
 Andrew Yager, Managing Director   (MACS BCompSc MCP)
 Real World Technology Solutions Pty Ltd
 ph: 1300 798 718 or (02) 9037 0500
 fax: (02) 9037 0591 mob: 0405 152 568
 http://www.rwts.com.au/ or http://www.stonebridgecomputing.com.au/


-- 
Matthew Weier O'Phinney
Software Architect   | [EMAIL PROTECTED]
Zend Framework   | http://framework.zend.com/