| @@ -1,14 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | - * E2Pdf Convert 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 | |
| 4 | + * File: /model/e2pdf-convert.php | |
| 5 | + * | |
| 6 | + * @package E2Pdf | |
| 7 | + * @license GPLv3 | |
| 8 | + * @link https://e2pdf.com | |
| 11 | 9 | */ |
| 12 | 10 | if (!defined('ABSPATH')) { |
| 13 | 11 | die('Access denied.'); |
| 14 | 12 | } |
| @@ -14,26 +12,11 @@ | ||
| 14 | 12 | } |
| 15 | 13 | |
| 16 | 14 | class Model_E2pdf_Convert extends Model_E2pdf_Model { |
| 17 | 15 | |
| 18 | - protected $convert = NULL; | |
| 19 | - | |
| 20 | - /** | |
| 21 | - * Initialize functions | |
| 22 | - */ | |
| 23 | - function __construct() { | |
| 24 | - parent::__construct(); | |
| 25 | - } | |
| 26 | - | |
| 27 | - /** | |
| 28 | - * Convert Template to PHP Output | |
| 29 | - * | |
| 30 | - * @param array $data - Template | |
| 31 | - * | |
| 32 | - * @return string - Converted template | |
| 33 | - */ | |
| 16 | + // to PHP | |
| 34 | 17 | public function toPHP($data = array()) { |
| 35 | - $content = ""; | |
| 18 | + $content = ''; | |
| 36 | 19 | foreach ($data as $key => $value) { |
| 37 | 20 | if (is_array($value)) { |
| 38 | 21 | $content .= "'" . $key . "' => ["; |
| 39 | 22 | $content .= $this->toPHP($value); |
| @@ -43,48 +26,5 @@ | ||
| 43 | 26 | } |
| 44 | 27 | } |
| 45 | 28 | return $content; |
| 46 | 29 | } |
| 47 | - | |
| 48 | - /** | |
| 49 | - * Set options for API Request | |
| 50 | - * | |
| 51 | - * @param string $key - Key | |
| 52 | - * @param mixed $value - Value | |
| 53 | - */ | |
| 54 | - public function set($key, $value = false) { | |
| 55 | - if (!$this->convert) { | |
| 56 | - $this->convert = new stdClass(); | |
| 57 | - } | |
| 58 | - if (is_array($key)) { | |
| 59 | - foreach ($key as $attr => $value) { | |
| 60 | - $this->convert->$attr = $value; | |
| 61 | - } | |
| 62 | - } else { | |
| 63 | - $this->convert->$key = $value; | |
| 64 | - } | |
| 65 | - } | |
| 66 | - | |
| 67 | - /** | |
| 68 | - * Convert Template | |
| 69 | - */ | |
| 70 | - public function convert() { | |
| 71 | - | |
| 72 | - $data = !empty($this->convert->data) ? $this->convert->data : array(); | |
| 73 | - | |
| 74 | - $file = '<?php' . PHP_EOL; | |
| 75 | - $file .= 'function e2pdf_template() {' . PHP_EOL; | |
| 76 | - $file .= '$template = [' . PHP_EOL; | |
| 77 | - $file .= $this->toPHP($data); | |
| 78 | - $file .= '];' . PHP_EOL; | |
| 79 | - $file .= 'return $template;' . PHP_EOL; | |
| 80 | - $file .= '}'; | |
| 81 | - | |
| 82 | - if ($file) { | |
| 83 | - $response['file'] = base64_encode($file); | |
| 84 | - } else { | |
| 85 | - $response['error'] = __("Something went wrong!", "e2pdf"); | |
| 86 | - } | |
| 87 | - return $response; | |
| 88 | - } | |
| 89 | - | |
| 90 | 30 | } |