| Server IP : 23.94.149.180 / Your IP : 216.73.216.147 Web Server : nginx/1.20.1 System : Linux deadrock 5.14.0-741.22.1.el9_9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Nov 12 15:18:14 UTC 2026 x86_64 User : apache ( 48) PHP Version : 8.6.0 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /files/www/lawyerbabe/mblog/extras/examples/plugins/BackupRestoreSample/ |
Upload File : |
# Movable Type (r) Open Source (C) 2005-2008 Six Apart, Ltd.
# This program is distributed under the terms of the
# GNU General Public License, version 2.
#
# $Id: BackupRestoreSample.pl 1174 2008-01-08 21:02:50Z bchoate $
package MT::Plugin::BackupRestoreSample;
use strict;
use base 'MT::Plugin';
use vars qw($VERSION);
$VERSION = '0.1';
use BackupRestoreSample::Object;
my $plugin;
my $ns = 'urn:sixapart.com:ns:pluginsample';
$plugin = MT::Plugin::BackupRestoreSample->new({
name => "BackupRestoreSample",
version => $VERSION,
description => "<MT_TRANS phrase=\"This plugin is to test out the backup restore callback.\">",
author_name => "Fumiaki Yoshimatsu",
author_link => "http://www.sixapart.com/",
#l10n_class => 'BackupRestore::L10N',
object_classes => [
'BackupRestoreSample::Object'
],
schema_version => '0.1',
});
MT->add_plugin($plugin);
MT->add_callback('Backup', 9, $plugin, \&backup);
MT->add_callback("Restore.backup_restore_sample_object:$ns", 9, $plugin, \&restore);
sub backup {
my ($cb, $blog_ids, $progress) = @_;
my $xml;
my $terms = {};
$terms->{blog_id} = $blog_ids if defined($blog_ids) && (0 < scalar(@$blog_ids));
my @objects = BackupRestoreSample::Object->load($terms);
for my $object (@objects) {
$xml .= $object->to_xml($ns);
}
$progress->('BackupRestoreSampleObject is backed up.', 'BackupRestoreSample::Object');
return $xml;
}
sub restore {
my ($cb, $data, $objects, $deferred, $progress) = @_;
return 0 if $ns ne $data->{NamespaceURI};
my $attrs = $data->{Attributes};
my %column_data = map { $attrs->{$_}->{LocalName} => $attrs->{$_}->{Value} }
grep { $attrs->{$_}->{Value} ne $ns } keys(%$attrs);
my $obj = BackupRestoreSample::Object->new;
$obj->set_values(\%column_data);
$progress->('BackupRestoreSampleObject is restored.', 'BackupRestoreSample::Object');
return $obj;
}
1;