1: <?php
2:
3: 4: 5:
6: class Quform_Admin_Page_Tools_Migrate extends Quform_Admin_Page_Tools
7: {
8: 9: 10:
11: protected $migrator;
12:
13: 14: 15: 16: 17:
18: public function __construct(Quform_ViewFactory $viewFactory, Quform_Repository $repository, Quform_Migrator $migrator)
19: {
20: parent::__construct($viewFactory, $repository);
21:
22: $this->migrator = $migrator;
23: }
24:
25: 26: 27:
28: protected function enqueueScripts()
29: {
30: parent::enqueueScripts();
31:
32: wp_enqueue_script('quform-tools-migrate', Quform::adminUrl('js/tools.migrate.min.js'), array('jquery'), QUFORM_VERSION, true);
33: wp_localize_script('quform-tools-migrate', 'quformToolsMigrateL10n', $this->getScriptL10n());
34: }
35:
36: 37: 38: 39: 40:
41: protected function getScriptL10n()
42: {
43: return array(
44: 'migrateNonce' => wp_create_nonce('quform_migrate_form'),
45: 'pleaseWait' => __('Please wait', 'quform'),
46:
47: 'processingFormXOfY' => __('Processing form %1$d of %2$d', 'quform'),
48: 'migrateImportFormNonce' => wp_create_nonce('quform_migrate_import_form'),
49: 'migrateSettingsNonce' => wp_create_nonce('quform_migrate_settings'),
50: 'errorImportingForm' => __('An error occurred importing the form', 'quform'),
51: 'stopping' => __('Stopping...', 'quform'),
52: 'processing' => __('Processing...', 'quform'),
53: 'stopMigration' => __('Stop migration', 'quform'),
54:
55: 'errorMigratingKeys' => __('Error migrating keys: %s', 'quform'),
56:
57: 'errorMigratingForm' => __('Error migrating form ID %1$d: %2$s', 'quform'),
58: 'migrationCompleted' => __('Migration completed.', 'quform'),
59: 'migrationStopped' => __('Migration stopped.', 'quform'),
60: 'migrationError' => __('Migration error.', 'quform'),
61:
62: 'errorStartingMigration' => __('An error occurred starting the migration: %s', 'quform'),
63: );
64: }
65:
66: public function init()
67: {
68: $this->template = QUFORM_TEMPLATE_PATH . '/admin/tools/migrate.php';
69: }
70:
71: 72: 73: 74: 75:
76: protected function getAdminTitle()
77: {
78: return __('Migrate', 'quform');
79: }
80:
81: 82: 83: 84: 85: 86: 87:
88: public function getNavHtml(array $currentForm = null, array $extra = array())
89: {
90: $extra[40] = sprintf(
91: '<div class="qfb-nav-item qfb-nav-page-info"><i class="qfb-nav-page-icon qfb-icon-suitcase"></i><span class="qfb-nav-page-title">%s</span></div>',
92: esc_html__('Migrate', 'quform')
93: );
94:
95: return parent::getNavHtml($currentForm, $extra);
96: }
97:
98: 99: 100:
101: public function process()
102: {
103: if ( ! current_user_can('quform_full_access')) {
104: wp_die(__( 'You do not have sufficient permissions to access this page.', 'quform'), 403);
105: }
106:
107: $oldForms = $this->migrator->get1xForms();
108:
109: $this->view->with(array(
110: 'oldForms' => $oldForms
111: ));
112: }
113: }
114: