[fw-general] CrudController vs. Action helpers

2009-03-11 Thread Marko Korhonen

Hello,

Earlier I converted all my "Base" controllers to action helpers (thanks,
Matthew), except for one.
I still have CrudController which basicly has create/read/update/delete
actions and lot's of event methods.

I also found the old CrudController slides from Matthew (any updates coming
to this Matthew?):
http://weierophinney.net/matthew/uploads/2007-02-28-FrameworkPresentation.pdf

This makes the same thing, it's just a bit old.

I'll include some of my CrufController methods below.

Any comments/feedback or suggestions would be great!

br, Marko

protected function _setForm()
{

// load the form and creates it
}

protected function _processForm($data = array())
{
$this->_alterForm(); // Event

//processing + event calls here and there
}

// Gets the name of the Model we are creating/reading/updating/deleting
protected function _getModel()
{
return $this->_request->getModuleName();
}

// Do something when empty row is created in createAction()
protected function _onRowCreation()
{

}

// Alter the form somehow (my forms are loaded from ini files and then
altered if needed)
protected function _alterForm()
{

}

// After form is altered you can still do something like set some element
values
protected function _alterFormPostProcess()
{

}

// Do something before form validation starts 
protected function _onBeforeValidation(array $post)
{
return $post;
}

// Do something after form validation succeeded
protected function _onValidationSucceed(array $post)
{
return $post;
}

// Do something if form was not valid
protected function _onValidationFailed(array $post)
{
return $post;
}

// Do something just before when saving the row
protected function _onBeforeSave()
{
return true;
}

// Do something just before deleting the row
protected function _onBeforeDelete()
{
return true;
}

// Do something just after row has been saved
protected function _onSave()
{

}

// Do something after all saving and other stuff have been made
protected function _onSaveComplete()
{
if ($this->_request->isXmlHttpRequest())
{
$this->_helper->json(array("redirect" => 
$this->_getRedirectOnSave()));
}
else
{
// Redirect to the next page
$this->_redirect($this->_getRedirectOnSave(), 
array("prependBase" =>
false));
}
}

// Get the redirect url after save > normally goes to readAction
protected function _getRedirectOnSave()
{
if ($this->_hasParam("redirect_url"))
{
return $this->_getParam("redirect_url",
$this->getFrontController()->getBaseUrl());
}
else
{
return $this->getFrontController()->getBaseUrl();
}
}

// Get the redirect url after delete
protected function _getRedirectOnDelete(array $data)
{
return $this->getFrontController()->getBaseUrl();
}

// Gets the form section name for the ini file [user_form]
protected function _getFormName()
{
return "{$this->_request->getModuleName()}_form";
}
-- 
View this message in context: 
http://www.nabble.com/CrudController-vs.-Action-helpers-tp22470068p22470068.html
Sent from the Zend Framework mailing list archive at Nabble.com.



[fw-general] Re: Plugin Loader problem with File Upload elements

2009-03-11 Thread Tim Nagel
Sorry to reply to my own email - I've narrowed down the problem (as far as I
can see) to Zend/Form/Element/File.php.

I cant really see the exact cause though :|

Tim


[fw-general] Plugin Loader problem with File Upload elements

2009-03-11 Thread Tim Nagel
All,

I am currently using a few Zend_Form_Element_File elements in a few
different forms. Some of these forms work fine.

All of the file elements we've used so far follow the same 'code', which
I'll paste below.

The problem is occuring on one and only one of our form implementations
where I get the exception from Zend_Loader_PluginLoader:

'Plugin by name 'Upload' was not found in the registry; used paths:
Infinite_Validate_: Infinite/Validate/
Zend_Validate_: Zend/Validate/'

The exception is thrown from within isValid() call pathness/stack.

The issue disappears when reverting back to 1.7.0. I have been unable to
determin where the issue is, except that I think it has something to do with
the class being Zend_Validate_File_Upload whereas the pluginloader might be
looking for Zend_Validate_Upload ?



// $addEditForm created above (Zend_Form obj)
$addEditForm->setAttrib('enctype', 'multipart/form-data');
$aes = $addEditForm->getSubForm('addEdit');

$aes->addDisplayGroup(array('coverLetterTA', 'coverLetterFile',
'coverLetterFile_Save', 'coverLetterSaved'), 'coverletter');
$aes->addDisplayGroup(array('resumeFile', 'resumeFile_Save', 'resumeSaved'),
'resume');

//  (irrelevant stuff)

$resumePath = APPLICATION_PATH . Zend_Registry::get('config')->resourcepath
. "/resumes";
$clfile = $aes->getElement('coverLetterFile');
$rfile = $aes->getElement('resumeFile');

$clfile->setDestination($resumePath);
$clfile->addFilter(new Infinite_Filter_File_UniqueUploads('cl' .
($this->_user ? $this->_user->userID : '')));
$rfile->setDestination($resumePath);
$rfile->addFilter(new Infinite_Filter_File_UniqueUploads('r' . ($this->_user
? $this->_user->userID : '')));

if ($this->getRequest()->isPost() AND
$addEditForm->isValid($this->getRequest()->getPost())) *// FAILS HERE.*
{
 $insertData = $addEditForm->getValues();
 $this->fillRowWithData($application, $insertData['addEdit']);

 if ($insertData['addEdit']['coverLetterOpts'] == 'upload' AND
$clfile->receive())
 {
  $path = $clfile->getFileName();
  $application->coverLetterPath = $path;
 }

 if ($insertData['addEdit']['resumeOpts'] == 'upload' AND $rfile->receive())
 {
  $path = $rfile->getFileName();
  $application->resumePath = $path;
 }

 $applicationID = $application->save();
}


Re: [fw-general] SVN tags for ZendX

2009-03-11 Thread Carlton Gibson


Thanks for both your answers Matthew.

On 11 Mar 2009, at 15:09, Matthew Weier O'Phinney wrote:


-- Carlton Gibson  wrote
(on Wednesday, 11 March 2009, 01:29 PM +):


On 11 Mar 2009, at 13:11, Jan Wagner-Rosenkranz wrote:

Carlton Gibson schrieb:

I'm looking to checkout the ZendX library as a svn:external. I was
hoping to just target a release tag but there aren't any defined in
/extras/tags.



I use:
http://framework.zend.com/svn/framework/extras/branches/release-1.7/library/ZendX


Jan,
Thanks for your suggestion. My only concern is that this is still
subject to changes. That's why I'm after a tag.


Two things with regard to this. First, changes merged to a release
branch are primarily bugfixes, and should always be backwards
compatible.


Okay, since this is the case I'll probably go with Jan's approach.


Second, if you want to ensure that the revision does not change... pin
to a specific revision. svn:externals supports that natively. As an
example, you can use something like the following:

   externals/extras r14722  
http://framework.zend.com/svn/framework/extras/branches/release-1.7/library/ZendX

I gave a made-up revision number there, but that's the basic idea --  
you

can specify a revision between the local path and the externals path.



This was what I had in mind (but the syntax is helpful).

Thanks again.


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




[fw-general] Handling timezones?

2009-03-11 Thread Alex
Hello,

What's the recommended strategy for handling timezones with Zend_Date? I use
the datetime in mysql to store dates.

What's the right combination of date_default_timezone_set and Zend_date so
that everything is always stored in UTC and the user always sees dates in
his local time?

- Alex


Re: [fw-general] SVN tags for ZendX

2009-03-11 Thread Matthew Weier O'Phinney
-- Carlton Gibson  wrote
(on Wednesday, 11 March 2009, 01:29 PM +):
>
> On 11 Mar 2009, at 13:11, Jan Wagner-Rosenkranz wrote:
>> Carlton Gibson schrieb:
>>> I'm looking to checkout the ZendX library as a svn:external. I was  
>>> hoping to just target a release tag but there aren't any defined in 
>>> /extras/tags.
>
>> I use:
>> http://framework.zend.com/svn/framework/extras/branches/release-1.7/library/ZendX
>
> Jan,
> Thanks for your suggestion. My only concern is that this is still  
> subject to changes. That's why I'm after a tag.

Two things with regard to this. First, changes merged to a release
branch are primarily bugfixes, and should always be backwards
compatible.

Second, if you want to ensure that the revision does not change... pin
to a specific revision. svn:externals supports that natively. As an
example, you can use something like the following:

externals/extras r14722  
http://framework.zend.com/svn/framework/extras/branches/release-1.7/library/ZendX

I gave a made-up revision number there, but that's the basic idea -- you
can specify a revision between the local path and the externals path.

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


Re: [fw-general] SVN tags for ZendX

2009-03-11 Thread Matthew Weier O'Phinney
-- Carlton Gibson  wrote
(on Wednesday, 11 March 2009, 12:29 PM +):
> I'm looking to checkout the ZendX library as a svn:external. I was  
> hoping to just target a release tag but there aren't any defined in / 
> extras/tags.

Use the release branch instead -- that way you also get bug/security
fixes.

> In the meantime I'll target the revision shipped with the latest  
> distribution but would it be possible to get tags set up for each  
> release as they happen going forward?

We're still working out the release process in regards to ZendX --
manual compilation is also tricky. :)

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


Re: [fw-general] SVN tags for ZendX

2009-03-11 Thread Carlton Gibson


On 11 Mar 2009, at 13:11, Jan Wagner-Rosenkranz wrote:

Carlton Gibson schrieb:
I'm looking to checkout the ZendX library as a svn:external. I was  
hoping to just target a release tag but there aren't any defined  
in /extras/tags.



I use:
http://framework.zend.com/svn/framework/extras/branches/release-1.7/library/ZendX


Jan,
Thanks for your suggestion. My only concern is that this is still  
subject to changes. That's why I'm after a tag.


Regards,
Carlton


Re: [fw-general] SVN tags for ZendX

2009-03-11 Thread Jan Wagner-Rosenkranz

Carlton Gibson schrieb:
I'm looking to checkout the ZendX library as a svn:external. I was 
hoping to just target a release tag but there aren't any defined in 
/extras/tags.


In the meantime I'll target the revision shipped with the latest 
distribution but would it be possible to get tags set up for each 
release as they happen going forward?


I use:
http://framework.zend.com/svn/framework/extras/branches/release-1.7/library/ZendX

Jan


[fw-general] SVN tags for ZendX

2009-03-11 Thread Carlton Gibson

Hi all,

I'm looking to checkout the ZendX library as a svn:external. I was  
hoping to just target a release tag but there aren't any defined in / 
extras/tags.


In the meantime I'll target the revision shipped with the latest  
distribution but would it be possible to get tags set up for each  
release as they happen going forward?


Regards,
Carlton