PluginProbe
E2Pdf – Export Pdf Tool for WordPress / 1.03.07
E2Pdf – Export Pdf Tool for WordPress v1.03.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.03.07, at classes/model/e2pdf-extension.php

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