|
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 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
|
22
|
|
|
* |
|
23
|
|
|
* @since 2.5.0 |
|
24
|
|
|
* |
|
25
|
|
|
* @author Txmod Xoops http://www.txmodxoops.org |
|
26
|
|
|
* |
|
27
|
|
|
*/ |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* class Pdf. |
|
31
|
|
|
*/ |
|
32
|
|
|
class Pdf extends Files\CreateFile |
|
33
|
|
|
{ |
|
34
|
|
|
/** |
|
35
|
|
|
* @var mixed |
|
36
|
|
|
*/ |
|
37
|
|
|
private $hc = null; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var mixed |
|
41
|
|
|
*/ |
|
42
|
|
|
private $sc = null; |
|
43
|
|
|
/** |
|
44
|
|
|
* @public function constructor |
|
45
|
|
|
* @param null |
|
46
|
|
|
*/ |
|
47
|
|
|
public function __construct() |
|
48
|
|
|
{ |
|
49
|
|
|
parent::__construct(); |
|
50
|
|
|
$this->hc = Modulebuilder\Files\CreateHtmlCode::getInstance(); |
|
51
|
|
|
$this->sc = Modulebuilder\Files\CreateSmartyCode::getInstance(); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @static function getInstance |
|
56
|
|
|
* @param null |
|
57
|
|
|
* @return Pdf |
|
58
|
|
|
*/ |
|
59
|
|
|
public static function getInstance() |
|
60
|
|
|
{ |
|
61
|
|
|
static $instance = false; |
|
62
|
|
|
if (!$instance) { |
|
63
|
|
|
$instance = new self(); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
return $instance; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @public function write |
|
71
|
|
|
* |
|
72
|
|
|
* @param $module |
|
73
|
|
|
* @param $table |
|
74
|
|
|
* @param $filename |
|
75
|
|
|
*/ |
|
76
|
|
|
public function write($module, $table, $filename) |
|
77
|
|
|
{ |
|
78
|
|
|
$this->setModule($module); |
|
79
|
|
|
$this->setFileName($filename); |
|
80
|
|
|
$this->setTable($table); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @private function getTemplatesUserPagesItemPanel |
|
85
|
|
|
* @param string $moduleDirname |
|
86
|
|
|
* @param $tableId |
|
87
|
|
|
* @param $tableMid |
|
88
|
|
|
* @param $tableName |
|
89
|
|
|
* @param $tableSoleName |
|
90
|
|
|
* @param $tableRate |
|
91
|
|
|
* @param $tableBroken |
|
92
|
|
|
* @param $language |
|
93
|
|
|
* @return string |
|
94
|
|
|
*/ |
|
95
|
|
|
private function getTemplatesUserPdfBody($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $tableRate, $tableBroken, $language) |
|
|
|
|
|
|
96
|
|
|
{ |
|
97
|
|
|
$fields = $this->getTableFields($tableMid, $tableId); |
|
98
|
|
|
$ret = ''; |
|
99
|
|
|
$content_header = $this->sc->getSmartySingleVar('content_header'); |
|
100
|
|
|
$ret .= $this->hc->getHtmlDiv($content_header, 'panel-heading', '',"\n", false); |
|
101
|
|
|
$retElem = ''; |
|
102
|
|
|
foreach (\array_keys($fields) as $f) { |
|
103
|
|
|
$fieldElement = $fields[$f]->getVar('field_element'); |
|
104
|
|
|
if (1 == $fields[$f]->getVar('field_user')) { |
|
105
|
|
|
if (1 == $fields[$f]->getVar('field_tbody')) { |
|
106
|
|
|
$fieldName = $fields[$f]->getVar('field_name'); |
|
107
|
|
|
$rpFieldName = $this->getRightString($fieldName); |
|
108
|
|
|
$langConst = \mb_strtoupper($tableSoleName) . '_' . \mb_strtoupper($rpFieldName); |
|
109
|
|
|
$lang = $this->sc->getSmartyConst($language, $langConst); |
|
110
|
|
|
$retElem .= $this->hc->getHtmlDiv($lang . ': ' , 'col-sm-3',"\t", "\n", false); |
|
111
|
|
|
switch ($fieldElement) { |
|
112
|
|
|
default: |
|
113
|
|
|
//case 3: |
|
114
|
|
|
//case 4: |
|
115
|
|
|
$doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
|
116
|
|
|
$retElem .= $this->hc->getHtmlDiv($doubleVar, 'col-sm-8', "\t", "\n", false); |
|
117
|
|
|
break; |
|
118
|
|
|
case 10: |
|
119
|
|
|
$singleVar = $this->sc->getSmartySingleVar('xoops_icons32_url'); |
|
120
|
|
|
$doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
|
121
|
|
|
$img = $this->hc->getHtmlImage($singleVar . '/' . $doubleVar, (string)$tableName); |
|
122
|
|
|
$retElem .= $this->hc->getHtmlDiv($img, 'col-sm-8', "\t", "\n", false); |
|
123
|
|
|
unset($img); |
|
124
|
|
|
break; |
|
125
|
|
|
case 13: |
|
126
|
|
|
$singleVar = $this->sc->getSmartySingleVar($moduleDirname . '_upload_url'); |
|
127
|
|
|
$doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
|
128
|
|
|
$img = $this->hc->getHtmlImage($singleVar . "/images/{$tableName}/" . $doubleVar, (string)$tableName); |
|
129
|
|
|
$retElem .= $this->hc->getHtmlDiv($img, 'col-sm-9',"\t", "\n", false); |
|
130
|
|
|
unset($img); |
|
131
|
|
|
break; |
|
132
|
|
|
} |
|
133
|
|
|
} |
|
134
|
|
|
} |
|
135
|
|
|
} |
|
136
|
|
|
$ret .= $this->hc->getHtmlDiv($retElem, 'panel-body'); |
|
137
|
|
|
|
|
138
|
|
|
return $ret; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* @public function render |
|
143
|
|
|
* @param null |
|
144
|
|
|
* @return bool|string |
|
145
|
|
|
*/ |
|
146
|
|
|
public function render() |
|
147
|
|
|
{ |
|
148
|
|
|
$module = $this->getModule(); |
|
149
|
|
|
$filename = $this->getFileName(); |
|
150
|
|
|
$moduleDirname = $module->getVar('mod_dirname'); |
|
151
|
|
|
$table = $this->getTable(); |
|
152
|
|
|
$language = $this->getLanguage($moduleDirname, 'MA'); |
|
153
|
|
|
$tableId = $table->getVar('table_id'); |
|
154
|
|
|
$tableMid = $table->getVar('table_mid'); |
|
155
|
|
|
$tableName = $table->getVar('table_name'); |
|
156
|
|
|
$tableSoleName = $table->getVar('table_solename'); |
|
157
|
|
|
$content = $this->getTemplatesUserPdfBody($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $tableRate, $tableBroken, $language); |
|
|
|
|
|
|
158
|
|
|
|
|
159
|
|
|
$this->create($moduleDirname, 'templates', $filename, $content, _AM_MODULEBUILDER_FILE_CREATED, _AM_MODULEBUILDER_FILE_NOTCREATED); |
|
160
|
|
|
|
|
161
|
|
|
return $this->renderFile(); |
|
162
|
|
|
} |
|
163
|
|
|
} |
|
164
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.