Skip to content

Commit

Permalink
Fixed bug #016503: TC-80: Sending information collection form is brok…
Browse files Browse the repository at this point in the history
…en in admin2

Add support for allowing extensions to easily defining custom action handlers based on post action name.
And fix feedback_form.tl issue with sender name missing on installs taht have sender name on feedback class.
  • Loading branch information
andrerom committed Aug 27, 2010
1 parent c9ac96e commit 25627c1
Show file tree
Hide file tree
Showing 12 changed files with 127 additions and 48 deletions.
Expand Up @@ -15,6 +15,14 @@
{attribute_view_gui attribute=$node.data_map.email}
</div>

{* Sender name (information collector). *}
{if is_set( $node.data_map.sender_name )}
<div class="attribute-email">
<label>{'Your name'|i18n( 'design/admin/preview/feedbackform' )}:</label>
{attribute_view_gui attribute=$node.data_map.sender_name}
</div>
{/if}

{* Subject (information collector). *}
<div class="attribute-subject">
<label>{'Subject'|i18n( 'design/admin/preview/feedbackform' )}:</label>
Expand Down
9 changes: 0 additions & 9 deletions design/admin2/templates/node/view/full.tpl
Expand Up @@ -114,15 +114,6 @@
</p>
</div>

<div class="button-right">
<div class="block">
{* Custom content action buttons. *}
{section var=ContentActions loop=$node.object.content_action_list}
<input class="button" type="submit" name="{$ContentActions.item.action}" value="{$ContentActions.item.name}" />
{/section}
</div>
</div>

<div class="float-break"></div>
</form>
{* DESIGN: Control bar END *}
Expand Down
22 changes: 21 additions & 1 deletion design/admin2/templates/preview.tpl
@@ -1,2 +1,22 @@
{* Content (pre)view in content window. *}
{node_view_gui content_node=$node view='admin_preview'}
{def $custom_actions = $node.object.content_action_list}
{if $custom_actions}
<form method="post" action={'content/action'|ezurl}>
<input type="hidden" name="TopLevelNode" value="{$node.object.main_node_id}" />
<input type="hidden" name="ContentNodeID" value="{$node.node_id}" />
<input type="hidden" name="ContentObjectID" value="{$node.contentobject_id}" />
{/if}

{node_view_gui content_node=$node view='admin_preview'}

{if $custom_actions}
<div class="button-right">
<div class="block">
{* Custom content action buttons. *}
{foreach $custom_actions as $custom_action}
<input class="button" type="submit" name="{$custom_action.action}" value="{$custom_action.name}" />
{/foreach}
</div>
</div>
</form>
{/if}
Expand Up @@ -24,6 +24,7 @@ Changes from 4.4.0beta1 to 4.4.0beta2
- Fixed bug #011317: appendDebugNodes breaks IE by triggering Quirks mode
- Fixed bug #013516: updateviewcount not getting correct paths
- Fixed bug #015406: eZ cannot convert images with ImageMagick on PHP 5.3
- Fixed bug #016503: TC-80: Sending information collection form is broken in admin2
- Fixed bug #016512: Activation email is sent even if user registration fails
- Fixed bug #016664: ezHTTPTool::sendHTTPRequest() fails on port not 80
(Add support for setting port in $uri when $port is false)
Expand Down
8 changes: 0 additions & 8 deletions kernel/classes/datatypes/ezkeyword/ezkeywordtype.php
Expand Up @@ -178,14 +178,6 @@ function metaData( $attribute )
return $return;
}

/*!
\return the collect information action if enabled
*/
function contentActionList( $classAttribute )
{
return array();
}

/*!
Delete stored object attribute
*/
Expand Down
22 changes: 16 additions & 6 deletions kernel/classes/datatypes/ezmultiprice/ezmultipricetype.php
Expand Up @@ -283,14 +283,24 @@ function customObjectAttributeHTTPAction( $http, $action, $contentObjectAttribut
}
}

/**
* Return content action(s) which can be performed on object containing
* the current datatype. Return format is array of arrays with key 'name'
* and 'action'. 'action' can be mapped to url in datatype.ini
*
* @param eZContentClassAttribute $classAttribute
* @return array
*/
function contentActionList( $classAttribute )
{
return array( array( 'name' => ezpI18n::tr( 'kernel/classes/datatypes', 'Add to basket' ),
'action' => 'ActionAddToBasket'
),
array( 'name' => ezpI18n::tr( 'kernel/classes/datatypes', 'Add to wish list' ),
'action' => 'ActionAddToWishList'
) );
$actionList = parent::contentActionList( $classAttribute );
$actionList[] = array( 'name' => ezpI18n::tr( 'kernel/classes/datatypes', 'Add to basket' ),
'action' => 'ActionAddToBasket'
);
$actionList[] = array( 'name' => ezpI18n::tr( 'kernel/classes/datatypes', 'Add to wish list' ),
'action' => 'ActionAddToWishList'
);
return $actionList;
}

/*!
Expand Down
22 changes: 16 additions & 6 deletions kernel/classes/datatypes/ezprice/ezpricetype.php
Expand Up @@ -197,14 +197,24 @@ function classAttributeContent( $classAttribute )
return $price;
}

/**
* Return content action(s) which can be performed on object containing
* the current datatype. Return format is array of arrays with key 'name'
* and 'action'. 'action' can be mapped to url in datatype.ini
*
* @param eZContentClassAttribute $classAttribute
* @return array
*/
function contentActionList( $classAttribute )
{
return array( array( 'name' => ezpI18n::tr( 'kernel/classes/datatypes', 'Add to basket' ),
'action' => 'ActionAddToBasket'
),
array( 'name' => ezpI18n::tr( 'kernel/classes/datatypes', 'Add to wish list' ),
'action' => 'ActionAddToWishList'
) );
$actionList = parent::contentActionList( $classAttribute );
$actionList[] = array( 'name' => ezpI18n::tr( 'kernel/classes/datatypes', 'Add to basket' ),
'action' => 'ActionAddToBasket'
);
$actionList[] = array( 'name' => ezpI18n::tr( 'kernel/classes/datatypes', 'Add to wish list' ),
'action' => 'ActionAddToWishList'
);
return $actionList;
}

function title( $contentObjectAttribute, $name = null )
Expand Down
17 changes: 5 additions & 12 deletions kernel/classes/ezcontentobject.php
Expand Up @@ -4775,23 +4775,16 @@ function contentActionList()
// Fetch content actions if not already fetched
if ( $this->ContentActionList === false )
{

$contentActionList = array();
foreach ( $attributeList as $attribute )
{
$contentActions = $attribute->contentActionList();
if ( count( $contentActions ) > 0 )
$contentActionList = $attribute->contentActionList();
if ( is_array( $contentActionList ) && !empty( $contentActionList ) )
{
$contentActionList = $attribute->contentActionList();

if ( is_array( $contentActionList ) )
foreach ( $contentActionList as $action )
{
foreach ( $contentActionList as $action )
if ( !$this->hasContentAction( $action['action'] ) )
{
if ( !$this->hasContentAction( $action['action'] ) )
{
$this->ContentActionList[] = $action;
}
$this->ContentActionList[] = $action;
}
}
}
Expand Down
12 changes: 8 additions & 4 deletions kernel/classes/ezdatatype.php
Expand Up @@ -942,14 +942,18 @@ function deleteStoredClassAttribute( $classAttribute, $version = null )
{
}

/*!
\return the content action(s) which can be performed on object containing
the current datatype.
/**
* Return content action(s) which can be performed on object containing
* the current datatype. Return format is array of arrays with key 'name'
* and 'action'. 'action' can be mapped to url in datatype.ini
*
* @param eZContentClassAttribute $classAttribute
* @return array
*/
function contentActionList( $classAttribute )
{
$actionList = array();
if ( is_object( $classAttribute ) )
if ( $classAttribute instanceof eZContentClassAttribute )
{
if ( $classAttribute->attribute( 'is_information_collector' ) == true )
{
Expand Down
37 changes: 35 additions & 2 deletions kernel/content/action.php
Expand Up @@ -1169,7 +1169,6 @@
$module->setExitStatus( $shopModule->exitStatus() );
$module->setRedirectURI( $shopModule->redirectURI() );
}

}
else if ( $http->hasPostVariable( "ActionAddToWishList" ) )
{
Expand Down Expand Up @@ -1304,6 +1303,41 @@
}
else
{
// Check if there are any custom actions to handle
$customActions = eZINI::instance( 'datatype.ini' )->variable( 'ViewSettings', 'CustomActionMap' );
foreach( $customActions as $customActionName => $customActionUrl )
{
if ( $http->hasPostVariable( $customActionName ) )
{
if ( strpos( $customActionUrl, '/' ) !== false )
{
list( $customActionModuleName, $customActionViewName ) = explode( '/', $customActionUrl );
$customActionModule = eZModule::exists( $customActionModuleName );
if ( !$customActionModule instanceof eZModule )
{
eZDebug::writeError( "Could not load custom action module for: $customActionUrl", "kernel/content/action.php" );
}

$result = $customActionModule->run( $customActionViewName, array() );
if ( isset( $result['content'] ) && $result['content'] )
{
return $result;
}
else
{
$module->setExitStatus( $customActionModule->exitStatus() );
$module->setRedirectURI( $customActionModule->redirectURI() );
return $result;
}
}
else
{
return $module->run( $customActionUrl );
}
}
}

// look for custom content action handlers
$baseDirectory = eZExtension::baseDirectory();
$contentINI = eZINI::instance( 'content.ini' );
$extensionDirectories = $contentINI->variable( 'ActionSettings', 'ExtensionDirectories' );
Expand Down Expand Up @@ -1526,7 +1560,6 @@
return $module->handleError( eZError::KERNEL_NOT_AVAILABLE, 'kernel' );
}


// return module contents
$Result = array();
$Result['content'] = isset( $result ) ? $result : null;
Expand Down
8 changes: 8 additions & 0 deletions kernel/content/collectinformation.php
Expand Up @@ -195,6 +195,14 @@
'name' => $validationName,
'description' => $description );
}
else
{
$validationName = $contentClassAttribute->attribute( 'name' );
$unvalidatedAttributes[] = array( 'id' => $contentObjectAttribute->attribute( 'id' ),
'identifier' => $contentClassAttribute->attribute( 'identifier' ),
'name' => $validationName,
'description' => 'Attribute did not validate as it seems to missing in form.' );
}
}
else if ( $status == eZInputValidator::STATE_ACCEPTED )
{
Expand Down
9 changes: 9 additions & 0 deletions settings/datatype.ini
Expand Up @@ -22,6 +22,15 @@ GroupedInput[]=ezrangeoption
GroupedInput[]=ezpackage
GroupedInput[]=ezuser

# List of custom datatype actions and corresponding <module>/<view> or
# just <view> in case of content module where they should be executed
# eg: CustomActionMap[ActionAddToBasket]=shop/basket
# eg: CustomActionMap[ActionCollectInformation]=collectinformation
# Note: Action definition should be defined in contentActionList function
# of the datatype, see ez[multi]pricetype.php for code example.
CustomActionMap[]


# Settings related to content editing and datatypes
[EditSettings]
# A list of datatypes that needs to group their input fields
Expand Down

0 comments on commit 25627c1

Please sign in to comment.