NewsFeaturesDownloadsDevelopmentSupportAbout Us

Action Class Reference
[Action]

Inherits Object.

Inherited by AdminAction, AdminDefaultAction, AdminLoginAction, BlogAction, ResourceServerAction, SummaryAction, UpdateStepFour, UpdateStepOne, UpdateStepThree, UpdateStepTwo, WizardIntro, WizardStepFive, WizardStepFour, WizardStepOne, WizardStepThree, and WizardStepTwo.

List of all members.


Public Member Functions

 Action ($actionInfo, $httpRequest)
 perform ()
 validate ()
 validationErrorProcessing ()
 setValidationErrorView ($view)
 registerFieldValidator ($fieldName, $validator, $onlyIfAvailable=false)
 registerField ($fieldName)
 getView ()
 setCommonData ($copyFormValues=false)
 setForwardAction ($nextActionKey)
 setSuccess ($success)

Public Attributes

 $_view
 $_request
 $_actionInfo
 $_fieldValidators
 $_validationErrorView
 $_previousAction
 $_isSuccess

Private Member Functions

 setPreviousAction ($previousAction)
 getPreviousAction ()
 setForwardActionParameter ($param, $value)

Detailed Description

The base most basic action class is Action, which provides some common code and the Action.perform() method which should be implemented by child classes wishing to provide some business logic. At the end of the method, an Action class is expected to generate a valid View object (or a child class of View) that will be used by the Controller to render some contents to be sent to the client.

Action classes are expected to at least provide their own logic in the Action.perform() method. In previous versions of pLog it was also necessary to provide data validation logic in the Action.validate() method, but that is not necessary anymore (albeit possible if needed) since the introduction of the new data validation framework (See the FormValidator class and the Validator and Validator_Rules modules) The Action.validate() method now provides some code of its own that triggers the data validation process if there is any data to be validated.

There is a lot more information about the data validation framework here: http://wiki.plogworld.net/index.php/PLog_1.0/Forms_and_data_validation

The View object that Action classes must create can be set via the private attribute Action._view or te method Action.setView(), though the first one is the most widely used throughout the core code.

Please keep in mind that it is advisable to call the Action.setCommonData() method at the very end of the Action.perform() method in our custom classes because it needs to perform some extra operations right before the view is sent back to the controller.

Definition at line 56 of file action.class.php.


Member Function Documentation

Action.Action ( actionInfo,
httpRequest 
)

Action.setPreviousAction ( previousAction  )  [private]

Parameters:
previousAction a valid Action object
Returns:
Always true

Definition at line 104 of file action.class.php.

Action.getPreviousAction (  )  [private]

returns the reference to the previous action in the process flow

Returns:
A valid Action object, or null if there is no previous action

Definition at line 115 of file action.class.php.

Action.perform (  ) 

Receives the HTTP request from the client as parameter, so that we can extract the parameters and perform our business logic.

The result of this will be a view, which will normally be the output of the processing we just did or for example an error view showing an error message. Once we have completed processing, the controller will call the getView() method to get the resulting view and send it back to the customer.

Returns:
Returns nothing

Reimplemented in AddCommentAction, AdminAddArticleCategoryAction, AdminAddBlogAction, AdminAddBlogTemplateAction, AdminAddBlogUserAction, AdminAddCustomFieldAction, AdminAddLinkAction, AdminAddLinkCategoryAction, AdminAddLocaleAction, AdminAddPostAction, AdminAddResourceAction, AdminAddResourceAlbumAction, AdminAddTemplateAction, AdminAddUserAction, AdminBlogCustomFieldsAction, AdminBlogSecurityAction, AdminBlogSettingsAction, AdminBlogTemplateChooserAction, AdminCleanupAction, AdminControlCenterAction, AdminCreateBlogAction, AdminCreateUserAction, AdminDefaultAction, AdminDeleteArticleCategoryAction, AdminDeleteBlogAction, AdminDeleteBlogTemplateAction, AdminDeleteBlogUserPermissionsAction, AdminDeleteCommentAction, AdminDeleteCustomFieldsAction, AdminDeleteGalleryItemsAction, AdminDeleteLinkAction, AdminDeleteLinkCategoryAction, AdminDeleteLocalesAction, AdminDeletePostAction, AdminDeleteReferrerAction, AdminDeleteResourceAction, AdminDeleteResourceAlbumAction, AdminDeleteTemplatesAction, AdminDeleteTrackbackAction, AdminDeleteUsersAction, AdminEditArticleCategoriesAction, AdminEditArticleCategoryAction, AdminEditBlogAction, AdminEditBlogTemplatesAction, AdminEditCommentsAction, AdminEditCustomFieldAction, AdminEditLinkAction, AdminEditLinkCategoriesAction, AdminEditLinkCategoryAction, AdminEditLinksAction, AdminEditPostAction, AdminEditPostsAction, AdminEditResourceAlbumAction, AdminEditTemplatesAction, AdminEditTrackbacksAction, AdminEmptyAction, AdminGlobalSettingsAction, AdminLoginAction, AdminLogoutAction, AdminMainAction, AdminManageAction, AdminMarkCommentAction, AdminNewArticleCategoryAction, AdminNewBlogTemplateAction, AdminNewBlogUserAction, AdminNewCustomFieldAction, AdminNewLinkAction, AdminNewLinkCategoryAction, AdminNewLocaleAction, AdminNewPostAction, AdminNewResourceAction, AdminNewResourceAlbumAction, AdminNewTemplateAction, AdminPluginCenterAction, AdminPostStatsAction, AdminPreviewPostAction, AdminRegeneratePreviewAction, AdminResourceAlbumsAction, AdminResourceInfoAction, AdminResourceListAction, AdminResourcesAction, AdminResourcesGroupAction, AdminSendTrackbacksAction, AdminShowBlogUsersAction, AdminSiteBlogsAction, AdminSiteLocalesAction, AdminSiteSettingsAction, AdminSiteUsersAction, AdminStatisticsAction, AdminUpdateArticleCategoryAction, AdminUpdateBlogSettingsAction, AdminUpdateCustomFieldAction, AdminUpdateEditBlogAction, AdminUpdateGlobalSettingsAction, AdminUpdateLinkAction, AdminUpdateLinkCategoryAction, AdminUpdatePostAction, AdminUpdateResourceAction, AdminUpdateResourceAlbumAction, AdminUpdateUserProfileAction, AdminUpdateUserSettingsAction, AdminUserPictureSelectAction, AdminUserProfileAction, AdminUserSettingsAction, AdminXmlPingAction, AdminXmlSaveDraftAction, CommentAction, DefaultAction, ResourceServerAction, RssAction, SearchAction, TemplateAction, ViewAlbumAction, ViewArticleAction, ViewArticleTrackbacksAction, ViewResourceAction, ActiveAccountAction, BlogListAction, BlogProfileAction, ChooseBlogTemplateAction, doBlogRegistration, doFinishRegister, doReadAgreement, doUserCreation, doUserRegister, SummaryCustomPageAction, SummaryDefaultAction, SummaryRegistrationDisabledAction, SummaryRssAction, SummarySearchAction, SummarySendResetEmail, SummarySetNewPassword, SummaryShowResetPasswordForm, SummaryUpdatePassword, UserListAction, UserProfileAction, WizardIntro, WizardStepOne, WizardStepTwo, WizardStepThree, WizardStepFour, WizardStepFive, UpdateStepOne, UpdateStepTwo, UpdateStepThree, and UpdateStepFour.

Definition at line 131 of file action.class.php.

Action.validate (  ) 

This method can be used for data validation and is always executed before perform(). If it returns 'true', execution will continue as normal. If it returns 'false', the process will be stopped and the current contents of the view will be returned. If the view is empty, an exception will be thrown.

As of pLog 1.0, it is not necessary to implement data validation code here and it is recommended to use the data validation framework (see methods Action.registerFieldValidator() and related) There is more information about the data validation framework in the wiki: http://wiki.plogworld.net/index.php/PLog_1.0/Forms_and_data_validation.

With the default code provided in the Action.validate() method, the callback method Action.validationErrorProcessing() will be called and after that, the view set via the Action.setValidationErrorView() will be used to generate the contents of the error message.

Returns:
Returns true if data is correct or false otherwise. See above for more details.

Reimplemented in AddCommentAction, AdminAddBlogTemplateAction, AdminAddLocaleAction, AdminMainAction, AdminNewResourceAction, AdminPostStatsAction, AdminSendTrackbacksAction, AdminUpdateGlobalSettingsAction, AdminUpdateResourceAction, AdminUpdateUserSettingsAction, AdminUserPictureSelectAction, AdminXmlSaveDraftAction, DefaultAction, ResourceServerAction, ViewAlbumAction, ViewArticleAction, ViewArticleTrackbacksAction, ViewResourceAction, SummaryRssAction, SummarySearchAction, SummarySetNewPassword, UpdateStepTwo, and UpdateStepFour.

Definition at line 152 of file action.class.php.

References validationErrorProcessing().

Referenced by BlogAction.checkDateParameter(), SummaryCustomPageAction.perform(), and doUserCreation.perform().

Action.validationErrorProcessing (  ) 

This method will be called when a validation error happens. Child classes are free to extend or reimplement this one and can be used as some sort of a trigger in order to do some cleanup if needed.

Ê

Returns:
nothing

Reimplemented in AddCommentAction, and RegisterAction.

Definition at line 172 of file action.class.php.

References setCommonData().

Referenced by validate().

Action.setValidationErrorView ( view  ) 

sets the view that will be shown in case there is an error during the validation process... It makes things a bit easier for us when it comes to validate data. This view will only be used if validate() generates a validation error or if we force the action to generate an error via Action.setSuccess()

Parameters:
view A valid View object
Returns:
Always true
See also:
View

Definition at line 199 of file action.class.php.

Referenced by AddCommentAction.AddCommentAction(), AdminAddArticleCategoryAction.AdminAddArticleCategoryAction(), AdminAddBlogAction.AdminAddBlogAction(), AdminAddBlogUserAction.AdminAddBlogUserAction(), AdminAddCustomFieldAction.AdminAddCustomFieldAction(), AdminAddLinkAction.AdminAddLinkAction(), AdminAddLinkCategoryAction.AdminAddLinkCategoryAction(), AdminAddPostAction.AdminAddPostAction(), AdminAddResourceAction.AdminAddResourceAction(), AdminAddResourceAlbumAction.AdminAddResourceAlbumAction(), AdminAddUserAction.AdminAddUserAction(), AdminDeleteArticleCategoryAction.AdminDeleteArticleCategoryAction(), AdminDeleteBlogAction.AdminDeleteBlogAction(), AdminDeleteBlogTemplateAction.AdminDeleteBlogTemplateAction(), AdminDeleteBlogUserPermissionsAction.AdminDeleteBlogUserPermissionsAction(), AdminDeleteCommentAction.AdminDeleteCommentAction(), AdminDeleteCustomFieldsAction.AdminDeleteCustomFieldsAction(), AdminDeleteGalleryItemsAction.AdminDeleteGalleryItemsAction(), AdminDeleteLinkAction.AdminDeleteLinkAction(), AdminDeleteLinkCategoryAction.AdminDeleteLinkCategoryAction(), AdminDeleteLocalesAction.AdminDeleteLocalesAction(), AdminDeletePostAction.AdminDeletePostAction(), AdminDeleteReferrerAction.AdminDeleteReferrerAction(), AdminDeleteResourceAction.AdminDeleteResourceAction(), AdminDeleteResourceAlbumAction.AdminDeleteResourceAlbumAction(), AdminDeleteTemplatesAction.AdminDeleteTemplatesAction(), AdminDeleteTrackbackAction.AdminDeleteTrackbackAction(), AdminDeleteUsersAction.AdminDeleteUsersAction(), AdminEditArticleCategoryAction.AdminEditArticleCategoryAction(), AdminEditBlogAction.AdminEditBlogAction(), AdminEditCommentsAction.AdminEditCommentsAction(), AdminEditCustomFieldAction.AdminEditCustomFieldAction(), AdminEditLinkAction.AdminEditLinkAction(), AdminEditLinkCategoryAction.AdminEditLinkCategoryAction(), AdminEditLinksAction.AdminEditLinksAction(), AdminEditPostAction.AdminEditPostAction(), AdminEditResourceAlbumAction.AdminEditResourceAlbumAction(), AdminEditTrackbacksAction.AdminEditTrackbacksAction(), AdminLoginAction.AdminLoginAction(), AdminMarkCommentAction.AdminMarkCommentAction(), AdminResourceInfoAction.AdminNewResourceAlbumAction(), AdminPostStatsAction.AdminPostStatsAction(), AdminRegeneratePreviewAction.AdminRegeneratePreviewAction(), AdminResourcesAction.AdminResourcesAction(), AdminUpdateArticleCategoryAction.AdminUpdateArticleCategoryAction(), AdminUpdateBlogSettingsAction.AdminUpdateBlogSettingsAction(), AdminUpdateCustomFieldAction.AdminUpdateCustomFieldAction(), AdminUpdateEditBlogAction.AdminUpdateEditBlogAction(), AdminUpdateLinkAction.AdminUpdateLinkAction(), AdminUpdateLinkCategoryAction.AdminUpdateLinkCategoryAction(), AdminUpdatePostAction.AdminUpdatePostAction(), AdminUpdateResourceAction.AdminUpdateResourceAction(), AdminUpdateResourceAlbumAction.AdminUpdateResourceAlbumAction(), AdminUpdateUserProfileAction.AdminUpdateUserProfileAction(), AdminUpdateUserSettingsAction.AdminUpdateUserSettingsAction(), AdminUserProfileAction.AdminUserProfileAction(), BlogProfileAction.BlogProfileAction(), ChooseBlogTemplateAction.ChooseBlogTemplateAction(), DefaultAction.DefaultAction(), doBlogRegistration.doBlogRegistration(), doUserCreation.doUserCreation(), ResourceServerAction.ResourceServerAction(), RssAction.RssAction(), SearchAction.SearchAction(), SummarySendResetEmail.SummarySendResetEmail(), SummaryUpdatePassword.SummaryUpdatePassword(), TemplateAction.TemplateAction(), UserProfileAction.UserProfileAction(), AdminUpdateResourceAction.validate(), ViewAlbumAction.ViewAlbumAction(), ViewArticleAction.ViewArticleAction(), CommentAction.ViewArticleAction(), ViewArticleTrackbacksAction.ViewArticleTrackbacksAction(), ViewResourceAction.ViewResourceAction(), WizardStepFive.WizardStepFive(), WizardStepFour.WizardStepFour(), and WizardStepOne.WizardStepOne().

Action.registerFieldValidator ( fieldName,
validator,
onlyIfAvailable = false 
)

registers a new validator, for validating data coming from fields

Parameters:
fieldName The name of the field from the form that we're going to validate
validator A valid class inheriting from the Validator base class and that implements the validate() method, that will be used for validating fields.
onlyIfAvailable validate this field only if its value is not emtpy
Returns:
Always true
See also:
FormValidator

Validator

Definition at line 217 of file action.class.php.

Referenced by ActiveAccountAction.ActiveAccountAction(), AddCommentAction.AddCommentAction(), AdminAddArticleCategoryAction.AdminAddArticleCategoryAction(), AdminAddBlogAction.AdminAddBlogAction(), AdminAddBlogUserAction.AdminAddBlogUserAction(), AdminAddCustomFieldAction.AdminAddCustomFieldAction(), AdminAddLinkAction.AdminAddLinkAction(), AdminAddLinkCategoryAction.AdminAddLinkCategoryAction(), AdminAddPostAction.AdminAddPostAction(), AdminAddResourceAction.AdminAddResourceAction(), AdminAddResourceAlbumAction.AdminAddResourceAlbumAction(), AdminAddUserAction.AdminAddUserAction(), AdminDeleteArticleCategoryAction.AdminDeleteArticleCategoryAction(), AdminDeleteBlogAction.AdminDeleteBlogAction(), AdminDeleteBlogTemplateAction.AdminDeleteBlogTemplateAction(), AdminDeleteBlogUserPermissionsAction.AdminDeleteBlogUserPermissionsAction(), AdminDeleteCommentAction.AdminDeleteCommentAction(), AdminDeleteCustomFieldsAction.AdminDeleteCustomFieldsAction(), AdminDeleteGalleryItemsAction.AdminDeleteGalleryItemsAction(), AdminDeleteLinkAction.AdminDeleteLinkAction(), AdminDeleteLinkCategoryAction.AdminDeleteLinkCategoryAction(), AdminDeleteLocalesAction.AdminDeleteLocalesAction(), AdminDeletePostAction.AdminDeletePostAction(), AdminDeleteReferrerAction.AdminDeleteReferrerAction(), AdminDeleteResourceAction.AdminDeleteResourceAction(), AdminDeleteResourceAlbumAction.AdminDeleteResourceAlbumAction(), AdminDeleteTemplatesAction.AdminDeleteTemplatesAction(), AdminDeleteTrackbackAction.AdminDeleteTrackbackAction(), AdminDeleteUsersAction.AdminDeleteUsersAction(), AdminEditArticleCategoryAction.AdminEditArticleCategoryAction(), AdminEditBlogAction.AdminEditBlogAction(), AdminEditCommentsAction.AdminEditCommentsAction(), AdminEditCustomFieldAction.AdminEditCustomFieldAction(), AdminEditLinkAction.AdminEditLinkAction(), AdminEditLinkCategoryAction.AdminEditLinkCategoryAction(), AdminEditLinksAction.AdminEditLinksAction(), AdminEditPostAction.AdminEditPostAction(), AdminEditResourceAlbumAction.AdminEditResourceAlbumAction(), AdminEditTrackbacksAction.AdminEditTrackbacksAction(), AdminLoginAction.AdminLoginAction(), AdminMarkCommentAction.AdminMarkCommentAction(), AdminResourceInfoAction.AdminNewResourceAlbumAction(), AdminPostStatsAction.AdminPostStatsAction(), AdminRegeneratePreviewAction.AdminRegeneratePreviewAction(), AdminResourcesAction.AdminResourcesAction(), AdminUpdateArticleCategoryAction.AdminUpdateArticleCategoryAction(), AdminUpdateBlogSettingsAction.AdminUpdateBlogSettingsAction(), AdminUpdateCustomFieldAction.AdminUpdateCustomFieldAction(), AdminUpdateEditBlogAction.AdminUpdateEditBlogAction(), AdminUpdateLinkAction.AdminUpdateLinkAction(), AdminUpdateLinkCategoryAction.AdminUpdateLinkCategoryAction(), AdminUpdatePostAction.AdminUpdatePostAction(), AdminUpdateResourceAction.AdminUpdateResourceAction(), AdminUpdateResourceAlbumAction.AdminUpdateResourceAlbumAction(), AdminUpdateUserProfileAction.AdminUpdateUserProfileAction(), AdminUpdateUserSettingsAction.AdminUpdateUserSettingsAction(), AdminUserProfileAction.AdminUserProfileAction(), BlogProfileAction.BlogProfileAction(), ChooseBlogTemplateAction.ChooseBlogTemplateAction(), DefaultAction.DefaultAction(), doBlogRegistration.doBlogRegistration(), doUserCreation.doUserCreation(), ResourceServerAction.ResourceServerAction(), RssAction.RssAction(), SearchAction.SearchAction(), SummarySendResetEmail.SummarySendResetEmail(), SummaryUpdatePassword.SummaryUpdatePassword(), TemplateAction.TemplateAction(), UserProfileAction.UserProfileAction(), ViewAlbumAction.ViewAlbumAction(), ViewArticleAction.ViewArticleAction(), CommentAction.ViewArticleAction(), ViewArticleTrackbacksAction.ViewArticleTrackbacksAction(), ViewResourceAction.ViewResourceAction(), WizardStepFive.WizardStepFive(), WizardStepFour.WizardStepFour(), and WizardStepOne.WizardStepOne().

Action.registerField ( fieldName  ) 

Action.getView (  ) 

This function does not need to be reimplemented by the childs of this class. It just returns the resulting view of the operation.

Returns:
A valid View object

Definition at line 246 of file action.class.php.

Action.setCommonData ( copyFormValues = false  ) 

we can do things here that are common to all the views. This method must be called just before the Action.perform() method has finished its processing since most of the child Action classes use it to do some kind of post-processing.

Parameters:
copyFormValues Whether the values from fields that were registered via Action.registerFieldValidator() and Action.registerField() should be passed back to the view as variables or not. It defaults to 'false' but this parameter is useful in those cases when we would like to force an error to happen (not a validation error) and still keep the form values.
Returns:
Always true

Reimplemented in AdminAction, BlogAction, and SummaryAction.

Definition at line 263 of file action.class.php.

Referenced by UpdateStepThree.perform(), UpdateStepOne.perform(), WizardStepFive.perform(), WizardStepFour.perform(), WizardStepThree.perform(), WizardStepTwo.perform(), WizardStepOne.perform(), WizardIntro.perform(), AdminLoginAction.perform(), and validationErrorProcessing().

Action.setForwardAction ( nextActionKey  ) 

after executing the current action we will not show the results but transfer the execution flow to another action. In other words, the Controller will detect that the processing is being passed to another Action class and instead of calling Action.getView() right after Action.perform() it will call the perform() method of the next action in the flow. It is only possible to specify one action to forward to at a time, but this feature can be used as many times as needed.

Parameters:
actionKey The key of the action to which we're forwarding the process flow. This is not the class name of the action but the key name to which the action class has been assigned.
Returns:
Always true

Definition at line 292 of file action.class.php.

References Controller.setForwardAction().

Action.setForwardActionParameter ( param,
value 
) [private]

sets a parameter in the session... or in other words, make it available for the next coming action.

Parameters:
param 
value 
Returns:
Always true

Definition at line 308 of file action.class.php.

Action.setSuccess ( success  ) 

This method can be used to trigger validation errors even if they did not really happen, or to disable errors if they happened.

Parameters:
success Whether to force or unforce an error

Definition at line 319 of file action.class.php.


Member Data Documentation

Action.$_view

Definition at line 60 of file action.class.php.

Action.$_request

Definition at line 61 of file action.class.php.

Action.$_actionInfo

Definition at line 62 of file action.class.php.

Action.$_fieldValidators

Definition at line 63 of file action.class.php.

Action.$_validationErrorView

Definition at line 64 of file action.class.php.

Action.$_previousAction

Definition at line 65 of file action.class.php.

Action.$_isSuccess

Definition at line 66 of file action.class.php.