Skip to content

Commit b298d9a

Browse files
committed
updates for pdf creation
1 parent a9ebae0 commit b298d9a

7 files changed

Lines changed: 185 additions & 69 deletions

File tree

class/Devtools.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public static function function_qualifier($src_path, $dst_path, $moduleName) {
103103
'in_array',
104104
'ini_get',
105105
'intval',
106+
'include',
106107
'is_array',
107108
'is_bool',
108109
'is_callable',
@@ -132,6 +133,7 @@ public static function function_qualifier($src_path, $dst_path, $moduleName) {
132133
'readlink',
133134
'redirect_header',
134135
'rename',
136+
'require',
135137
'rmdir',
136138
'round',
137139
'scandir',

class/Files/CreateArchitecture.php

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -645,31 +645,41 @@ public function setFilesToBuilding($module)
645645
}
646646
// User Pdf File
647647
if (\in_array(1, $tablePdf)) {
648-
$userPdf = Modulebuilder\Files\User\UserPdf::getInstance();
649-
$userPdf->write($module, $table, 'pdf.php');
650-
$ret[] = $userPdf->render();
651-
// User Templates Pdf File
652-
if ($templateType == 'bootstrap') {
653-
$userTemplatesPdf = Modulebuilder\Files\Templates\User\Bootstrap\Pdf::getInstance();
654-
} else {
655-
$userTemplatesPdf = Modulebuilder\Files\Templates\User\Defstyle\Pdf::getInstance();
648+
foreach ($tables as $table) {
649+
if ($table->getVar('table_pdf')) {
650+
$tableName = $table->getVar('table_name');
651+
$userPdf = Modulebuilder\Files\User\UserPdf::getInstance();
652+
$userPdf->write($module, $table, $tableName . '_pdf.php');
653+
$ret[] = $userPdf->render();
654+
// User Templates Pdf File
655+
if ($templateType == 'bootstrap') {
656+
$userTemplatesPdf = Modulebuilder\Files\Templates\User\Bootstrap\Pdf::getInstance();
657+
} else {
658+
$userTemplatesPdf = Modulebuilder\Files\Templates\User\Defstyle\Pdf::getInstance();
659+
}
660+
$userTemplatesPdf->write($module, $table, $moduleDirname . '_' . $tableName . '_pdf.tpl');
661+
$ret[] = $userTemplatesPdf->render();
662+
}
656663
}
657-
$userTemplatesPdf->write($module, $moduleDirname . '_pdf.tpl');
658-
$ret[] = $userTemplatesPdf->render();
659664
}
660665
// User Print File
661666
if (\in_array(1, $tablePrint)) {
662-
$userPrint = Modulebuilder\Files\User\UserPrint::getInstance();
663-
$userPrint->write($module, $table, 'print.php');
664-
$ret[] = $userPrint->render();
665-
// User Templates Print File
666-
if ($templateType == 'bootstrap') {
667-
$userTemplatesPrint = Modulebuilder\Files\Templates\User\Bootstrap\UserPrint::getInstance();
668-
} else {
669-
$userTemplatesPrint = Modulebuilder\Files\Templates\User\Defstyle\UserPrint::getInstance();
667+
foreach ($tables as $table) {
668+
if ($table->getVar('table_print')) {
669+
$tableName = $table->getVar('table_name');
670+
$userPrint = Modulebuilder\Files\User\UserPrint::getInstance();
671+
$userPrint->write($module, $table, $tableName . '_print.php');
672+
$ret[] = $userPrint->render();
673+
// User Templates Print File
674+
if ($templateType == 'bootstrap') {
675+
$userTemplatesPrint = Modulebuilder\Files\Templates\User\Bootstrap\UserPrint::getInstance();
676+
} else {
677+
$userTemplatesPrint = Modulebuilder\Files\Templates\User\Defstyle\UserPrint::getInstance();
678+
}
679+
$userTemplatesPrint->write($module, $table, $moduleDirname . '_' . $tableName . '_print.tpl');
680+
$ret[] = $userTemplatesPrint->render();
681+
}
670682
}
671-
$userTemplatesPrint->write($module, $table, $moduleDirname . '_print.tpl');
672-
$ret[] = $userTemplatesPrint->render();
673683
}
674684

675685
//TODO: UserSearch has to be adapted

class/Files/CreateXoopsCode.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -885,16 +885,17 @@ public function getXcHandlerDelete($left, $var, $obj = '', $handler = 'Handler')
885885
* @param string $index
886886
* @param bool $noArray
887887
* @param string $t
888+
* @param string $obj
888889
* @return string
889890
*/
890-
public function getXcGetValues($tableName, $tableSoleName, $index = 'i', $noArray = false, $t = '')
891+
public function getXcGetValues($tableName, $tableSoleName, $index = 'i', $noArray = false, $t = '', $obj = '')
891892
{
892893
$index = '' !== $index ? $index : 'i';
893894
$ucfTableName = \ucfirst($tableName);
894895
if (!$noArray) {
895896
$ret = "{$t}\${$tableSoleName} = \${$tableName}All[\${$index}]->getValues{$ucfTableName}();\n";
896897
} else {
897-
$ret = "{$t}\${$tableSoleName} = \${$tableName}->getValues{$ucfTableName}();\n";
898+
$ret = "{$t}\${$tableSoleName} = \${$tableName}{$obj}->getValues{$ucfTableName}();\n";
898899
}
899900

900901
return $ret;
@@ -1576,13 +1577,17 @@ public function getXcXoopsUserUnameFromId($left, $value, $t = '')
15761577
* @param $tplString
15771578
* @param $phpRender
15781579
* @param bool $leftIsString
1579-
*
15801580
* @param string $t
1581+
* @param string $tpl
15811582
* @return string
15821583
*/
1583-
public function getXcXoopsTplAssign($tplString, $phpRender, $leftIsString = true, $t = '')
1584+
public function getXcXoopsTplAssign($tplString, $phpRender, $leftIsString = true, $t = '', $tpl = '')
15841585
{
15851586
$assign = "{$t}\$GLOBALS['xoopsTpl']->assign(";
1587+
if ('' !== $tpl) {
1588+
$assign = "{$t}\${$tpl}->assign(";
1589+
}
1590+
15861591
if (false === $leftIsString) {
15871592
$ret = $assign . "{$tplString}, {$phpRender});\n";
15881593
} else {

class/Files/Templates/User/Defstyle/Pdf.php

Lines changed: 71 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,24 @@
3131
*/
3232
class Pdf extends Files\CreateFile
3333
{
34+
/**
35+
* @var mixed
36+
*/
37+
private $hc = null;
38+
39+
/**
40+
* @var mixed
41+
*/
42+
private $sc = null;
3443
/**
3544
* @public function constructor
3645
* @param null
3746
*/
3847
public function __construct()
3948
{
4049
parent::__construct();
50+
$this->hc = Modulebuilder\Files\CreateHtmlCode::getInstance();
51+
$this->sc = Modulebuilder\Files\CreateSmartyCode::getInstance();
4152
}
4253

4354
/**
@@ -59,26 +70,70 @@ public static function getInstance()
5970
* @public function write
6071
*
6172
* @param $module
73+
* @param $table
6274
* @param $filename
6375
*/
64-
public function write($module, $filename)
76+
public function write($module, $table, $filename)
6577
{
6678
$this->setModule($module);
6779
$this->setFileName($filename);
80+
$this->setTable($table);
6881
}
6982

7083
/**
71-
* @private function getTemplatesUserPdfBody
72-
*
73-
* @param null
74-
*
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
7593
* @return string
7694
*/
77-
private function getTemplatesUserPdfBody()
95+
private function getTemplatesUserPdfBody($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $tableRate, $tableBroken, $language)
7896
{
79-
$ret = <<<'EOT'
80-
<div><{$pdfoutput}></div>
81-
EOT;
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');
82137

83138
return $ret;
84139
}
@@ -93,7 +148,13 @@ public function render()
93148
$module = $this->getModule();
94149
$filename = $this->getFileName();
95150
$moduleDirname = $module->getVar('mod_dirname');
96-
$content = $this->getTemplatesUserPdfBody();
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);
97158

98159
$this->create($moduleDirname, 'templates', $filename, $content, _AM_MODULEBUILDER_FILE_CREATED, _AM_MODULEBUILDER_FILE_NOTCREATED);
99160

0 commit comments

Comments
 (0)