PluginProbe
E2Pdf – Export Pdf Tool for WordPress / 1.04.07
E2Pdf – Export Pdf Tool for WordPress v1.04.07
1.32.49 1.32.48 1.32.43 1.32.40 1.32.34 1.32.32 1.32.31 1.32.26 1.32.22 1.32.23 1.32.18 1.32.17 1.32.15 trunk 1.00.00 1.00.13 1.01.01 1.02.02 1.03.07 1.04.07 1.05.03 1.06.02 1.07.11 1.08.00 1.08.06 All 72 releases
e2pdf / classes / model / e2pdf-extension.php

e2pdf-extension.php in E2Pdf – Export Pdf Tool for WordPress 1.04.07, at classes/model/e2pdf-extension.php

284 lines 7.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * E2pdf Extension Model
5 *
6 * @copyright Copyright 2017 https://e2pdf.com
7 * @license GPL v2
8 * @version 1
9 * @link https://e2pdf.com
10 * @since 0.00.01
11 */
12 if (!defined('ABSPATH')) {
13 die('Access denied.');
14 }
15
16 class Model_E2pdf_Extension extends Model_E2pdf_Model {
17
18 private $extension;
19
20 function __construct() {
21 parent::__construct();
22 }
23
24 public function load($name) {
25 if (is_array(get_option('e2pdf_disabled_extensions')) &&
26 in_array($name, get_option('e2pdf_disabled_extensions'))) {
27 return false;
28 }
29 $class = 'Extension_E2pdf_' . ucfirst($name);
30 if (class_exists($class)) {
31 $extension = new $class();
32 if ($extension->active()) {
33 $this->extension = $extension;
34 return true;
35 }
36 }
37 return false;
38 }
39
40 public function loaded($extension) {
41 if ($this->extension() && method_exists($this->extension(), 'info')) {
42 $info = $this->extension()->info();
43 if (isset($info[$extension])) {
44 return true;
45 }
46 }
47 return false;
48 }
49
50 public function info($attr = false) {
51 if (method_exists($this->extension(), 'info')) {
52 return $this->extension()->info($attr);
53 }
54 return false;
55 }
56
57 public function extension() {
58 return $this->extension;
59 }
60
61 public function set($attr, $value) {
62 if (method_exists($this->extension(), 'set')) {
63 return $this->extension()->set($attr, $value);
64 }
65 return false;
66 }
67
68 public function get($attr) {
69 if (method_exists($this->extension(), 'get')) {
70 return $this->extension()->get($attr);
71 }
72 return false;
73 }
74
75 public function verify() {
76 if (method_exists($this->extension(), 'verify')) {
77 return $this->extension()->verify();
78 }
79 return false;
80 }
81
82 public function import() {
83 if (method_exists($this->extension(), 'import')) {
84 return $this->extension()->import();
85 }
86 return false;
87 }
88
89 public function backup($xml = false) {
90 if (method_exists($this->extension(), 'backup')) {
91 return $this->extension()->backup($xml);
92 }
93 return false;
94 }
95
96 public function item($item_id = false) {
97 if (method_exists($this->extension(), 'item')) {
98 return $this->extension()->item($item_id);
99 }
100 return false;
101 }
102
103 public function items() {
104 if (method_exists($this->extension(), 'items')) {
105 return $this->extension()->items();
106 }
107 return false;
108 }
109
110 /**
111 * Load styles from extension
112 */
113 public function styles() {
114 if (method_exists($this->extension(), 'styles')) {
115 return $this->extension()->styles();
116 }
117 return false;
118 }
119
120 /**
121 * Render Value via extension
122 */
123 public function render($value, $type = false, $field = array()) {
124 if (method_exists($this->extension(), 'render')) {
125 return $this->extension()->render($value, $type, $field);
126 }
127 return false;
128 }
129
130 /**
131 * Get available datasets
132 */
133 public function datasets($item = false, $name = false) {
134 if (method_exists($this->extension(), 'datasets')) {
135 return $this->extension()->datasets($item, $name);
136 }
137 return false;
138 }
139
140 /**
141 * Get current extension dataset
142 */
143 public function dataset($dataset_id = false) {
144 if (method_exists($this->extension(), 'dataset')) {
145 return $this->extension()->dataset($dataset_id);
146 }
147 return false;
148 }
149
150 /**
151 * List of available extensions
152 */
153 public function extensions($load = true) {
154 $list = array();
155 $extentions_path = $this->helper->get('plugin_dir') . 'classes/extension/*';
156 foreach (array_filter(glob($extentions_path), 'is_file') as $file) {
157 $info = pathinfo($file);
158 $file_name = basename($file, '.' . $info['extension']);
159 $file_name = substr($file_name, 6);
160
161 if ($load) {
162 if ($this->load($file_name)) {
163 $list = array_merge($list, $this->extension->info());
164 }
165 } else {
166 $list[] = $file_name;
167 }
168 }
169 return $list;
170 }
171
172 /**
173 * Delete item
174 */
175 public function delete_item($template_id = false, $dataset_id = false) {
176 if (method_exists($this->extension(), 'delete_item')) {
177 return $this->extension()->delete_item($template_id, $dataset_id);
178 }
179 return false;
180 }
181
182 /**
183 * Delete all items
184 */
185 public function delete_items($template_id = false) {
186 if (method_exists($this->extension(), 'delete_items')) {
187 return $this->extension()->delete_items($template_id);
188 }
189 return false;
190 }
191
192 /**
193 * Visual Mapper for Mapping field
194 *
195 * @return bool|string - Prepared form or false
196 */
197 public function visual_mapper() {
198
199 if (method_exists($this->extension(), 'visual_mapper')) {
200 if (!extension_loaded('libxml')) {
201 return __('libxml is required', 'e2pdf');
202 }
203 if (!extension_loaded('Dom')) {
204 return __('DOM is required', 'e2pdf');
205 }
206 return $this->extension()->visual_mapper();
207 }
208 return false;
209 }
210
211 public function add_form($template) {
212 if (method_exists($this->extension(), 'add_form')) {
213 return $this->extension()->add_form($template);
214 }
215 return $template;
216 }
217
218 /**
219 * Convert Field name to Value
220 * @since 0.01.34
221 *
222 * @param string $name - Field name
223 *
224 * @return bool|string - Converted value or false
225 */
226 public function auto_map($name = false) {
227 if (method_exists($this->extension(), 'auto_map') && $name) {
228 return $this->extension()->auto_map($name);
229 }
230 return false;
231 }
232
233 /**
234 * Auto PDF generation
235 */
236 public function auto() {
237 if (method_exists($this->extension(), 'auto')) {
238 return $this->extension()->auto();
239 }
240 return false;
241 }
242
243 /**
244 * Check if function exists inside extension
245 */
246 public function method($attr = false) {
247 if ($attr && method_exists($this->extension(), $attr)) {
248 return true;
249 }
250 return false;
251 }
252
253 /**
254 * Load actions from extension
255 */
256 public function load_actions() {
257 if (method_exists($this->extension(), 'load_actions')) {
258 return $this->extension()->load_actions();
259 }
260 return false;
261 }
262
263 /**
264 * Load filters from extension
265 */
266 public function load_filters() {
267 if (method_exists($this->extension(), 'load_filters')) {
268 return $this->extension()->load_filters();
269 }
270 return false;
271 }
272
273 /**
274 * Load shortcodes from extension
275 */
276 public function load_shortcodes() {
277 if (method_exists($this->extension(), 'load_shortcodes')) {
278 return $this->extension()->load_shortcodes();
279 }
280 return false;
281 }
282
283 }
284