Skip to content

Commit

Permalink
Add Remove Source button so that relations can be removed from blocks
Browse files Browse the repository at this point in the history
(cherry picked from commit 83f3e3c)
  • Loading branch information
peterkeung authored and yannickroger committed Jun 8, 2015
1 parent f2435e9 commit 8331c58
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,20 @@ function customObjectAttributeHTTPAction( $http, $action, $contentObjectAttribut

eZContentBrowse::browse( $browseParameters, $module );
break;
case 'remove_source':
$page = $contentObjectAttribute->content();

$zone = $page->getZone( $params[1] );
$block = $zone->getBlock( $params[2] );

$fetchParams = unserialize( $block->attribute( 'fetch_params' ) );

unset( $fetchParams['Source'] );

$block->setAttribute( 'fetch_params', serialize( $fetchParams ) );
$contentObjectAttribute->setContent( $page );
$contentObjectAttribute->store();
break;
case 'custom_attribute':
$page = $contentObjectAttribute->content();
$zone = $page->getZone( $params[1] );
Expand Down Expand Up @@ -897,6 +911,19 @@ function customObjectAttributeHTTPAction( $http, $action, $contentObjectAttribut

eZContentBrowse::browse( $browseParameters, $module );
break;
case 'custom_attribute_remove_source':
$page = $contentObjectAttribute->content();
$zone = $page->getZone( $params[1] );
$block = $zone->getBlock( $params[2] );

$customAttributes = $block->attribute( 'custom_attributes' );

unset( $customAttributes[$params[3]] );

$block->setAttribute( 'custom_attributes', $customAttributes );
$contentObjectAttribute->setContent( $page );
$contentObjectAttribute->store();
break;
case 'remove_item':
$page = $contentObjectAttribute->content();
$zone = $page->getZone( $params[1] );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
{foreach ezini( $block.type, 'FetchParameters', 'block.ini' ) as $fetch_parameter => $value}
{if eq( $fetch_parameter, 'Source' )}
<input id="block-fetch-parameter-choose-source-{$block_id}" class="button block-control" name="CustomActionButton[{$attribute.id}_new_source_browse-{$zone_id}-{$block_id}]" type="submit" value="{'Choose source'|i18n( 'design/standard/block/edit' )}" />
{if is_set( $fetch_params['Source'] )}
<input id="block-fetch-parameter-remove-source-{$block_id}" class="button block-control" name="CustomActionButton[{$attribute.id}_remove_source-{$zone_id}-{$block_id}]" type="submit" value="{'Remove source'|i18n( 'design/standard/block/edit' )}" />
{/if}
<div class="source">
{'Current source:'|i18n( 'design/standard/block/edit' )}
{if is_set( $fetch_params['Source'] )}
Expand Down Expand Up @@ -104,6 +107,9 @@
{if eq( $use_browse_mode[$custom_attrib], 'true' )}
{if is_set($custom_attribute_names[$custom_attrib])}<label>{$custom_attribute_names[$custom_attrib]}:</label>{/if}
<input id="block-choose-source-{$block_id}" class="button block-control" name="CustomActionButton[{$attribute.id}_custom_attribute_browse-{$zone_id}-{$block_id}-{$custom_attrib}]" type="submit" value="{'Choose source'|i18n( 'design/standard/block/edit' )}" />
{if is_set( $block.custom_attributes[$custom_attrib] )}
<input class="button block-control" name="CustomActionButton[{$attribute.id}_custom_attribute_remove_source-{$zone_id}-{$block_id}-{$custom_attrib}]" type="submit" value="{'Remove source'|i18n( 'design/standard/block/edit' )}" />
{/if}
<div class="source">
{'Current source:'|i18n( 'design/standard/block/edit' )}
{if is_set( $block.custom_attributes[$custom_attrib] )}
Expand Down

0 comments on commit 8331c58

Please sign in to comment.