diff options
| author | Max Kremmel <xing@synapse.plus.com> | 2007-10-03 09:34:44 +0000 |
|---|---|---|
| committer | Max Kremmel <xing@synapse.plus.com> | 2007-10-03 09:34:44 +0000 |
| commit | 2bc28eeef66b29d62e8c7ce69e01c80052bd8c9c (patch) | |
| tree | a11a7a23a4c6c82ceb5c5053ed685b653974d45b | |
| parent | 5bbf536520ad5d7c9e58eb848adaeaafd534c6d3 (diff) | |
| download | liberty-2bc28eeef66b29d62e8c7ce69e01c80052bd8c9c.tar.gz liberty-2bc28eeef66b29d62e8c7ce69e01c80052bd8c9c.tar.bz2 liberty-2bc28eeef66b29d62e8c7ce69e01c80052bd8c9c.zip | |
load edit_storage_inc.php through the liberty edit service, update all instances of the attachment list when we delete an item, fix display on attachment deletion
| -rw-r--r-- | edit_storage_inc.php | 29 | ||||
| -rw-r--r-- | liberty_lib.php | 3 | ||||
| -rw-r--r-- | templates/edit_storage_list.tpl | 24 |
3 files changed, 42 insertions, 14 deletions
diff --git a/edit_storage_inc.php b/edit_storage_inc.php index 3528e42..648e80e 100644 --- a/edit_storage_inc.php +++ b/edit_storage_inc.php @@ -3,7 +3,7 @@ * edit_storage_inc * * @author spider <spider@steelsun.com> - * @version $Revision: 1.19 $ + * @version $Revision: 1.20 $ * @package liberty * @subpackage functions * @@ -12,11 +12,21 @@ * * Calculate a base URL for the attachment deletion/removal icons to use */ +include_once( '../bit_setup_inc.php' ); global $gBitSmarty, $gContent, $gBitUser, $gBitSystem, $gLibertySystem, $gBitThemes; -$attachmentActionBaseUrl = $gBitSmarty->get_template_vars( 'attachmentActionBaseURL' ); +// we need to load gContent if this is an ajax request +if( BitThemes::isAjaxRequest() ) { + include_once( LIBERTY_PKG_PATH.'lookup_content_inc.php' ); +} + +$attachmentActionBaseUrl = $gBitSmarty->get_template_vars( 'attachmentActionBaseUrl' ); if( empty( $attachmentActionBaseUrl )) { - $attachmentActionBaseURL = $_SERVER['PHP_SELF'].'?'; + if( $gBitSystem->getConfig( 'liberty_attachment_style' ) == 'ajax' ) { + $attachmentActionBaseUrl = LIBERTY_PKG_URL.'edit_storage_inc.php?'; + } else { + $attachmentActionBaseUrl = $_SERVER['PHP_SELF'].'?'; + } $GETArgs = split( '&',$_SERVER['QUERY_STRING'] ); $firstArg = TRUE; @@ -24,22 +34,21 @@ if( empty( $attachmentActionBaseUrl )) { $parts = split( '=', $arg ); if( $parts[0] != 'deleteAttachment' ) { if( !$firstArg ) { - $attachmentActionBaseURL .= "&"; + $attachmentActionBaseUrl .= "&"; } else { $firstArg = FALSE; } - $attachmentActionBaseURL .= $arg; + $attachmentActionBaseUrl .= $arg; } } - $gBitSmarty->assign( 'attachmentActionBaseURL', $attachmentActionBaseURL ); + $gBitSmarty->assign( 'attachmentActionBaseUrl', $attachmentActionBaseUrl ); } if( !empty( $_REQUEST['deleteAttachment'] )) { $attachmentId = $_REQUEST['deleteAttachment']; $attachmentInfo = $gContent->getAttachment( $attachmentId ); - // TODO: Should we have a permission for deleting attachments? if( $gBitUser->isAdmin() || ( $attachmentInfo['user_id'] == $gBitUser->mUserId && $gBitUser->hasPermission( 'p_liberty_delete_attachment' ))) { $gContent->expungeAttachment( $attachmentId ); } @@ -51,4 +60,10 @@ $gBitSmarty->assign_by_ref( 'gLibertySystem', $gLibertySystem ); $gBitSmarty->clear_assign( 'gContent' ); $gBitSmarty->assign( 'gContent', $gContent ); $gBitThemes->loadAjax( 'prototype' ); + +// output some stuff for ajax div +if( BitThemes::isAjaxRequest() ) { + echo $gBitSmarty->fetch( 'bitpackage:liberty/edit_storage_list.tpl' ); + die; +} ?> diff --git a/liberty_lib.php b/liberty_lib.php index df81b48..09fe3e3 100644 --- a/liberty_lib.php +++ b/liberty_lib.php @@ -1,6 +1,6 @@ <?php /** - * @version $Header: /cvsroot/bitweaver/_bit_liberty/liberty_lib.php,v 1.13 2007/09/26 16:22:52 nickpalmer Exp $ + * @version $Header: /cvsroot/bitweaver/_bit_liberty/liberty_lib.php,v 1.14 2007/10/03 09:34:44 squareing Exp $ * @package liberty * @subpackage functions */ @@ -399,6 +399,7 @@ function liberty_content_display( &$pObject, &$pParamHash ) { */ function liberty_content_edit( &$pObject ) { include_once( LIBERTY_PKG_PATH.'edit_help_inc.php' ); + include_once( LIBERTY_PKG_PATH."edit_storage_inc.php" ); } diff --git a/templates/edit_storage_list.tpl b/templates/edit_storage_list.tpl index 9ea5b5f..12b32d4 100644 --- a/templates/edit_storage_list.tpl +++ b/templates/edit_storage_list.tpl @@ -1,6 +1,8 @@ -{php} include (LIBERTY_PKG_PATH."edit_storage_inc.php"); {/php} {strip} -<div id="edit_storage_list{if !$uploadTab}_tab{/if}"> +{* don't replicate the surrounding div when inserting ajax content *} +{if !$gBitThemes->isAjaxRequest()} + <div id="edit_storage_list{if !$uploadTab}_tab{/if}"> +{/if} {if $gContent->mStorage} <div class="row"> <table class="data" summary="List of attached files"> @@ -38,11 +40,19 @@ {/if} {if $gBitUser->isAdmin() || ($storage.user_id == $gBitUser->mUserId && $gBitUser->hasPermission('p_liberty_delete_attachments') ) } {if $attachmentBrowser} - <a href="javascript:ajax_updater('attbrowser', '{$attachmentActionBaseURL}', 'deleteAttachment={$attachmentId}');">{biticon ipackage="icons" iname="edit-delete" iexplain="delete"}</a> + <a href="javascript: + ajax_updater('edit_storage_list', '{$attachmentActionBaseUrl}', 'deleteAttachment={$attachmentId}'); + ajax_updater('edit_storage_list_tab', '{$attachmentActionBaseUrl}', 'content_id={$gContent->mContentId}');"> + {biticon ipackage="icons" iname="edit-delete" iexplain="delete"} + </a> {elseif $libertyUploader || $gBitSystem->getConfig('liberty_attachment_style') == 'ajax'} - <a href="javascript:ajax_updater('edit_storage_list', '{$attachmentActionBaseURL}', 'deleteAttachment={$attachmentId}{if empty($gContent->mContentId)}{foreach from=$gContent->mStorage key=key item=val}&STORAGE[existing][{$val.attachment_id}]={$val.attachment_id}{/foreach}{/if}');">{biticon ipackage="icons" iname="edit-delete" iexplain="delete"}</a> + <a href="javascript: + ajax_updater('edit_storage_list', '{$attachmentActionBaseUrl}', 'content_id={$gContent->mContentId}&deleteAttachment={$attachmentId}{if empty($gContent->mContentId)}{foreach from=$gContent->mStorage key=key item=val}&STORAGE[existing][{$val.attachment_id}]={$val.attachment_id}{/foreach}{/if}'); + ajax_updater('edit_storage_list_tab', '{$attachmentActionBaseUrl}', 'content_id={$gContent->mContentId}');"> + {biticon ipackage="icons" iname="edit-delete" iexplain="delete"} + </a> {else} - <a href="{$attachmentActionBaseURL}&deleteAttachment={$attachmentId}">{biticon ipackage="icons" iname="edit-delete" iexplain="delete"}</a> + <a href="{$attachmentActionBaseUrl}&deleteAttachment={$attachmentId}">{biticon ipackage="icons" iname="edit-delete" iexplain="delete"}</a> {/if} {/if} </td> @@ -51,5 +61,7 @@ </table> </div> {/if} -</div> +{if !$gBitThemes->isAjaxRequest()} + </div> +{/if} {/strip} |
