1 | <?php |
||
2 | |||
3 | namespace XoopsModules\Modulebuilder\Files\Templates\User\Defstyle; |
||
4 | |||
5 | use XoopsModules\Modulebuilder; |
||
6 | use XoopsModules\Modulebuilder\Files; |
||
7 | |||
8 | /* |
||
9 | You may not change or alter any portion of this comment or credits |
||
10 | of supporting developers from this source code or any supporting source code |
||
11 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
12 | |||
13 | This program is distributed in the hope that it will be useful, |
||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
16 | */ |
||
17 | /** |
||
18 | * modulebuilder module. |
||
19 | * |
||
20 | * @copyright XOOPS Project (https://xoops.org) |
||
21 | * @license GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
||
22 | * |
||
23 | * @since 2.5.0 |
||
24 | * |
||
25 | * @author Txmod Xoops https://xoops.org |
||
26 | * Goffy https://myxoops.org |
||
27 | * |
||
28 | */ |
||
29 | |||
30 | /** |
||
31 | * class Pdf. |
||
32 | */ |
||
33 | class Pdf extends Files\CreateFile |
||
34 | { |
||
35 | /** |
||
36 | * @var mixed |
||
37 | */ |
||
38 | private $hc = null; |
||
39 | |||
40 | /** |
||
41 | * @var mixed |
||
42 | */ |
||
43 | private $sc = null; |
||
44 | /** |
||
45 | * @public function constructor |
||
46 | * @param null |
||
47 | */ |
||
48 | public function __construct() |
||
49 | { |
||
50 | parent::__construct(); |
||
51 | $this->hc = Modulebuilder\Files\CreateHtmlCode::getInstance(); |
||
52 | $this->sc = Modulebuilder\Files\CreateSmartyCode::getInstance(); |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * @static function getInstance |
||
57 | * @param null |
||
58 | * @return Pdf |
||
59 | */ |
||
60 | public static function getInstance() |
||
61 | { |
||
62 | static $instance = false; |
||
63 | if (!$instance) { |
||
64 | $instance = new self(); |
||
65 | } |
||
66 | |||
67 | return $instance; |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * @public function write |
||
72 | * |
||
73 | * @param $module |
||
74 | * @param $table |
||
75 | * @param $filename |
||
76 | */ |
||
77 | public function write($module, $table, $filename) |
||
78 | { |
||
79 | $this->setModule($module); |
||
80 | $this->setFileName($filename); |
||
81 | $this->setTable($table); |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * @private function getTemplatesUserPagesItemPanel |
||
86 | * @param string $moduleDirname |
||
87 | * @param $tableId |
||
88 | * @param $tableMid |
||
89 | * @param $tableName |
||
90 | * @param $tableSoleName |
||
91 | * @param $language |
||
92 | * @return string |
||
93 | */ |
||
94 | private function getTemplatesUserPdfBody($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $language) |
||
95 | { |
||
96 | $fields = $this->getTableFields($tableMid, $tableId); |
||
97 | $ret = ''; |
||
98 | $content_header = $this->sc->getSmartySingleVar('content_header'); |
||
99 | $ret .= $this->hc->getHtmlDiv($content_header, 'panel-heading', '',"\n", false); |
||
100 | $retElem = ''; |
||
101 | foreach (\array_keys($fields) as $f) { |
||
102 | $fieldElement = $fields[$f]->getVar('field_element'); |
||
103 | if (1 == $fields[$f]->getVar('field_user')) { |
||
104 | if (1 == $fields[$f]->getVar('field_tbody')) { |
||
105 | $fieldName = $fields[$f]->getVar('field_name'); |
||
106 | $rpFieldName = $this->getRightString($fieldName); |
||
107 | $langConst = \mb_strtoupper($tableSoleName) . '_' . \mb_strtoupper($rpFieldName); |
||
108 | $lang = $this->sc->getSmartyConst($language, $langConst); |
||
109 | $retElem .= $this->hc->getHtmlDiv($lang . ': ' , 'col-sm-3',"\t", "\n", false); |
||
110 | switch ($fieldElement) { |
||
111 | default: |
||
112 | //case 3: |
||
113 | //case 4: |
||
114 | $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
115 | $retElem .= $this->hc->getHtmlDiv($doubleVar, 'col-sm-8', "\t", "\n", false); |
||
116 | break; |
||
117 | case 10: |
||
118 | $singleVar = $this->sc->getSmartySingleVar('xoops_icons32_url'); |
||
119 | $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
120 | $img = $this->hc->getHtmlImage($singleVar . '/' . $doubleVar, (string)$tableName); |
||
121 | $retElem .= $this->hc->getHtmlDiv($img, 'col-sm-8', "\t", "\n", false); |
||
122 | unset($img); |
||
123 | break; |
||
124 | case 13: |
||
125 | $singleVar = $this->sc->getSmartySingleVar($moduleDirname . '_upload_url'); |
||
126 | $doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
||
127 | $img = $this->hc->getHtmlImage($singleVar . "/images/{$tableName}/" . $doubleVar, (string)$tableName); |
||
128 | $retElem .= $this->hc->getHtmlDiv($img, 'col-sm-9',"\t", "\n", false); |
||
129 | unset($img); |
||
130 | break; |
||
131 | } |
||
132 | } |
||
133 | } |
||
134 | } |
||
135 | $ret .= $this->hc->getHtmlDiv($retElem, 'panel-body'); |
||
136 | |||
137 | return $ret; |
||
138 | } |
||
139 | |||
140 | /** |
||
141 | * @public function render |
||
142 | * @param null |
||
143 | * @return bool|string |
||
144 | */ |
||
145 | public function render() |
||
146 | { |
||
147 | $module = $this->getModule(); |
||
148 | $filename = $this->getFileName(); |
||
149 | $moduleDirname = $module->getVar('mod_dirname'); |
||
150 | $table = $this->getTable(); |
||
151 | $language = $this->getLanguage($moduleDirname, 'MA', '', false); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
152 | $tableId = $table->getVar('table_id'); |
||
153 | $tableMid = $table->getVar('table_mid'); |
||
154 | $tableName = $table->getVar('table_name'); |
||
155 | $tableSoleName = $table->getVar('table_solename'); |
||
156 | $content = $this->getTemplatesUserPdfBody($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $language); |
||
157 | |||
158 | $this->create($moduleDirname, 'templates', $filename, $content, \_AM_MODULEBUILDER_FILE_CREATED, \_AM_MODULEBUILDER_FILE_NOTCREATED); |
||
159 | |||
160 | return $this->renderFile(); |
||
161 | } |
||
162 | } |
||
163 |