Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
name: ImportCheck
id: ImportCheck
version: 0.1
config_settings:
EntryPathCustomFieldBasename:
default: orig_entry_path
PagePathCustomFieldBasename:
default: orig_page_path
callbacks:
cms_post_import.entry: >
sub {
my ( $cb, $app, $entry, $path, $data ) = @_;
my $basename = 'field.' . MT->config( 'EntryPathCustomFieldBasename' );
if ( $entry->has_column( $basename ) ) {
$entry->$basename( $path );
}
return 1;
};
cms_post_import.page: >
sub {
my ( $cb, $app, $entry, $path, $data ) = @_;
my $basename = 'field.' . MT->config( 'PagePathCustomFieldBasename' );
if ( $entry->has_column( $basename ) ) {
$entry->$basename( $path );
}
return 1;
};
build_file: >
sub {
my ( $cb, %args ) = @_;
my $entry = $args{ Entry };
my $file = $args{ File };
return 1 if (! $entry );
my $basename = 'field.' . MT->config( 'EntryPathCustomFieldBasename' );
if (! $entry->has_column( $basename ) ) {
$basename = 'field.' . MT->config( 'PagePathCustomFieldBasename' );
}
if (! $entry->has_column( $basename ) ) {
return 1;
}
my $orig_path = $entry->$basename;
if ( $file ne $orig_path ) {
MT->log( 'Invalid publish path=>' . $file .':Original File=>' . $orig_path );
}
return 1;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.