1: <?php
2:
3: 4: 5:
6: class Quform_Admin_Page_Preview extends Quform_Admin_Page
7: {
8: 9: 10:
11: protected $options;
12:
13: 14: 15:
16: protected $scriptLoader;
17:
18: 19: 20:
21: protected $themes;
22:
23: 24: 25: 26: 27: 28: 29:
30: public function __construct(Quform_ViewFactory $viewFactory, Quform_Repository $repository, Quform_Options $options,
31: Quform_ScriptLoader $scriptLoader, Quform_Themes $themes)
32: {
33: parent::__construct($viewFactory, $repository);
34:
35: $this->options = $options;
36: $this->scriptLoader = $scriptLoader;
37: $this->viewFactory = $viewFactory;
38: $this->themes = $themes;
39: }
40:
41: public function init()
42: {
43: $this->template = QUFORM_TEMPLATE_PATH . '/admin/preview.php';
44: }
45:
46: public function process()
47: {
48: if ( ! current_user_can('quform_edit_forms')) {
49: wp_die(__( 'You do not have sufficient permissions to access this page.', 'quform'), 403);
50: }
51:
52: $l10n = array(
53: 'ajaxUrl' => admin_url('admin-ajax.php'),
54: 'notLoaded' => __('Sorry, the form preview could not be loaded.', 'quform')
55: );
56:
57: $styles = $this->scriptLoader->getStyles(true);
58:
59:
60: if (isset($styles['quform-custom'])) {
61: unset($styles['quform-custom']);
62: }
63:
64: foreach ($this->themes->getThemes() as $key => $theme) {
65: $styles["quform-theme-$key"] = array(
66: 'url' => $theme['cssUrl'],
67: 'version' => $theme['version']
68: );
69: }
70:
71: $styles['quform-preview'] = array(
72: 'url' => Quform::adminUrl('css/preview.min.css'),
73: 'version' => QUFORM_VERSION
74: );
75:
76: $scripts = $this->scriptLoader->getScripts(true);
77:
78: foreach ($this->themes->getThemes() as $key => $theme) {
79: if (isset($theme['jsUrl'])) {
80: $scripts["quform-theme-$key"] = array(
81: 'url' => $theme['jsUrl'],
82: 'version' => $theme['version']
83: );
84: }
85: }
86:
87: $scripts['quform-preview'] = array(
88: 'url' => Quform::adminUrl('js/preview.min.js'),
89: 'version' => QUFORM_VERSION
90: );
91:
92: $this->view->with(array(
93: 'l10n' => $l10n,
94: 'styles' => $styles,
95: 'scripts' => $scripts,
96: 'options' => $this->options,
97: 'scriptLoader' => $this->scriptLoader
98: ));
99:
100: echo $this->display();
101: exit;
102: }
103: }
104: