Skip to content

Commit 517fde3

Browse files
authored
Merge pull request #60 from ggoffy/master
various fixes;moved to final
2 parents e093d80 + f12c363 commit 517fde3

15 files changed

Lines changed: 377 additions & 215 deletions

README.md

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,12 @@ If you liked the modulebuilder module and thanks to the long process for giving
55

66
# ModuleBuilder version 3.x
77

8-
[![Build Status](https://scrutinizer-ci.com/g/txmodxoops/modulebuilder/badges/build.png?b=master)](https://travis-ci.org/txmodxoops/modulebuilder)
9-
[![Jenkins coverage](https://img.shields.io/jenkins/c/https/jenkins.qa.ubuntu.com/address-book-service-utopic-i386-ci.svg)](https://github.com/txmodxoops/modulebuilder)
8+
[![Build Status](https://scrutinizer-ci.com/g/ggoffy/modulebuilder/badges/build.png?b=master)](https://travis-ci.org/ggoffy/modulebuilder)
9+
[![Jenkins coverage](https://img.shields.io/jenkins/c/https/jenkins.qa.ubuntu.com/address-book-service-utopic-i386-ci.svg)](https://github.com/XoopsModules25x/modulebuilder)
1010
[![Software License](https://img.shields.io/badge/license-GPL-brightgreen.svg?style=flat)](docs/license.txt)
11-
[![Quality Score](https://img.shields.io/scrutinizer/g/txmodxoops/modulebuilder.svg?style=flat)](https://scrutinizer-ci.com/g/txmodxoops/modulebuilder)
12-
[![Gem](https://img.shields.io/gem/dt/rails.svg)](txmodxoops/modulebuilder)
13-
[![Latest Version](https://img.shields.io/github/release/txmodxoops/modulebuilder.svg?style=flat)](https://github.com/txmodxoops/ModuleBuilder-1.91/releases/latest)
14-
15-
<p>
16-
<a href="http://issuestats.com/github/txmodxoops/modulebuilder"><img alt="Issue Stats" src="http://issuestats.com/github/txmodxoops/modulebuilder/badge/pr?style=flat"></a>
17-
<a href="http://issuestats.com/github/txmodxoops/modulebuilder"><img alt="Issue Stats" src="http://issuestats.com/github/txmodxoops/modulebuilder/badge/issue?style=flat"></a>
18-
<!--[![Github Releases (by Release)](https://img.shields.io/badge/modulebuilder-alpha%203.2-green.svg)](https://github.com/txmodxoops/modulebuilder/tree/alpha-3-4)-->
19-
</p>
11+
[![Quality Score](https://img.shields.io/scrutinizer/g/ggoffy/modulebuilder.svg?style=flat)](https://scrutinizer-ci.com/g/ggoffy/modulebuilder)
12+
[![Gem](https://img.shields.io/gem/dt/rails.svg)](XoopsModules25x/modulebuilder)
13+
[![Latest Version](https://img.shields.io/github/release/XoopsModules25x/modulebuilder.svg?style=flat)](https://github.com/XoopsModules25x/modulebuilder/releases/latest)
2014

2115
> **Note:** This repository contains the code of the modulebuilder module
2216
It's under development currently. If you want to build with developers this version of module or create a base modules, you can use the last version of this module at [Txmod XOOPS Web Site](http://www.txmodxoops.org), and visit the main discussion forum at [XOOPS Web Site](https://xoops.org/modules/newbb/viewtopic.php?topic_id=76746) for more information.
@@ -61,11 +55,16 @@ Apache = 2.4.10, 2.4.18
6155
XOOPS = 2.5.11
6256

6357
Codeception = 2.0.13
58+
6459
Selenium IDE = 2.9.0
6560

66-
[![Stories in Ready](https://badge.waffle.io/txmodxoops/modulebuilder.svg?label=ready&title=Ready)](http://waffle.io/txmodxoops/modulebuilder)
67-
[![Stories in Work in Progress](https://badge.waffle.io/txmodxoops/modulebuilder.svg?label=Work in Progress&title=Work in Progress)](http://waffle.io/txmodxoops/modulebuilder)
68-
[![Stories in Done](https://badge.waffle.io/txmodxoops/modulebuilder.svg?label=done&title=Done)](http://waffle.io/txmodxoops/modulebuilder)
69-
[![Stories in Roadmap](https://badge.waffle.io/txmodxoops/modulebuilder.svg?label=roadmap&title=Roadmap)](http://waffle.io/txmodxoops/modulebuilder)
61+
#### Tutorial:
62+
[![Tutorial Available](https://xoops.org/images/tutorial-available-blue.svg)](https://xoops.gitbook.io/modulebuilder-tutorial/) Tutorial: coming soon on [GitBook](https://xoops.gitbook.io/modulebuilder-tutorial/).
63+
To contribute to the Tutorial, [fork it on GitHub](https://github.com/XoopsDocs/modulebuilder-tutorial)
64+
65+
#### Translation:
66+
[![Translations on Transifex](https://xoops.org/images/translations-transifex-blue.svg)](https://www.transifex.com/xoops)
67+
68+
Please visit us on https://xoops.org
7069

71-
[![Throughput Graph](https://graphs.waffle.io/txmodxoops/modulebuilder/throughput.svg)](https://waffle.io/txmodxoops/modulebuilder/metrics)
70+
Current and upcoming "next generation" versions of XOOPS CMS are being crafted on GitHub at: https://github.com/XOOPS

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/Language/LanguageAdmin.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,27 @@ public function write($module, $table, $tables, $filename)
9393
*/
9494
public function getLanguageAdminIndex($language, $tables)
9595
{
96+
$thereare = '';
97+
$tableUser = 0;
98+
foreach (\array_keys($tables) as $t) {
99+
if (1 == (int)$tables[$t]->getVar('table_user')) {
100+
$tableUser = 1;
101+
}
102+
$tableName = $tables[$t]->getVar('table_name');
103+
$stuTableName = \mb_strtoupper($tableName);
104+
$stlTableName = \mb_strtolower($tableName);
105+
$thereare .= $this->ld->getDefine($language, "THEREARE_{$stuTableName}", "There are <span class='bold'>%s</span> {$stlTableName} in the database", true);
106+
}
96107
$ret = $this->ld->getBlankLine();
97108
$ret .= $this->pc->getPhpCodeIncludeDir('__DIR__','common', true);
98-
$ret .= $this->pc->getPhpCodeIncludeDir('__DIR__','main', true);
109+
if ($tableUser) {
110+
$ret .= $this->pc->getPhpCodeIncludeDir('__DIR__', 'main', true);
111+
}
99112
$ret .= $this->ld->getBlankLine();
100113
$ret .= $this->ld->getAboveHeadDefines('Admin Index');
101114
$ret .= $this->ld->getDefine($language, 'STATISTICS', 'Statistics');
102115
$ret .= $this->ld->getAboveDefines('There are');
103-
foreach (\array_keys($tables) as $t) {
104-
$tableName = $tables[$t]->getVar('table_name');
105-
$stuTableName = \mb_strtoupper($tableName);
106-
$stlTableName = \mb_strtolower($tableName);
107-
$ret .= $this->ld->getDefine($language, "THEREARE_{$stuTableName}", "There are <span class='bold'>%s</span> {$stlTableName} in the database", true);
108-
}
116+
$ret .= $thereare;
109117

110118
return $ret;
111119
}

class/Files/Language/LanguageMain.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ private function getLanguageMain($module, $language)
120120
$tableSubmit = 0;
121121
$tableBroken = 0;
122122
$tableRate = 0;
123+
$tablePrint = 0;
123124
foreach (\array_keys($tables) as $i) {
124125
if (1 == $tables[$i]->getVar('table_user')) {
125126
$tableName = $tables[$i]->getVar('table_name');
@@ -133,6 +134,9 @@ private function getLanguageMain($module, $language)
133134
if (1 === (int)$tables[$i]->getVar('table_rate')) {
134135
$tableRate = 1;
135136
}
137+
if (1 === (int)$tables[$i]->getVar('table_print')) {
138+
$tablePrint = 1;
139+
}
136140
$stuTableName = \mb_strtoupper($tableName);
137141
$stuTableSoleName = \mb_strtoupper($tableSoleName);
138142
$ucfTableName = $utility::UcFirstAndToLower($tableName);
@@ -197,6 +201,10 @@ private function getLanguageMain($module, $language)
197201
$ret .= $this->ld->getDefine($language, 'RATING_DISLIKE', 'Dislike');
198202
$ret .= $this->ld->getDefine($language, 'RATING_ERROR1', 'Error: update base table failed!');
199203
}
204+
if (1 === $tablePrint) {
205+
$ret .= $this->ld->getAboveHeadDefines('Print');
206+
$ret .= $this->ld->getDefine($language, 'PRINT', 'Print');
207+
}
200208
return $ret;
201209
}
202210

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

Lines changed: 69 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,68 @@ 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 $language
7591
* @return string
7692
*/
77-
private function getTemplatesUserPdfBody()
93+
private function getTemplatesUserPdfBody($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $language)
7894
{
79-
$ret = <<<'EOT'
80-
<div><{$pdfoutput}></div>
81-
EOT;
95+
$fields = $this->getTableFields($tableMid, $tableId);
96+
$ret = '';
97+
$content_header = $this->sc->getSmartySingleVar('content_header');
98+
$ret .= $this->hc->getHtmlDiv($content_header, 'panel-heading', '',"\n", false);
99+
$retElem = '';
100+
foreach (\array_keys($fields) as $f) {
101+
$fieldElement = $fields[$f]->getVar('field_element');
102+
if (1 == $fields[$f]->getVar('field_user')) {
103+
if (1 == $fields[$f]->getVar('field_tbody')) {
104+
$fieldName = $fields[$f]->getVar('field_name');
105+
$rpFieldName = $this->getRightString($fieldName);
106+
$langConst = \mb_strtoupper($tableSoleName) . '_' . \mb_strtoupper($rpFieldName);
107+
$lang = $this->sc->getSmartyConst($language, $langConst);
108+
$retElem .= $this->hc->getHtmlDiv($lang . ': ' , 'col-sm-3',"\t", "\n", false);
109+
switch ($fieldElement) {
110+
default:
111+
//case 3:
112+
//case 4:
113+
$doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName);
114+
$retElem .= $this->hc->getHtmlDiv($doubleVar, 'col-sm-8', "\t", "\n", false);
115+
break;
116+
case 10:
117+
$singleVar = $this->sc->getSmartySingleVar('xoops_icons32_url');
118+
$doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName);
119+
$img = $this->hc->getHtmlImage($singleVar . '/' . $doubleVar, (string)$tableName);
120+
$retElem .= $this->hc->getHtmlDiv($img, 'col-sm-8', "\t", "\n", false);
121+
unset($img);
122+
break;
123+
case 13:
124+
$singleVar = $this->sc->getSmartySingleVar($moduleDirname . '_upload_url');
125+
$doubleVar = $this->sc->getSmartyDoubleVar($tableSoleName, $rpFieldName);
126+
$img = $this->hc->getHtmlImage($singleVar . "/images/{$tableName}/" . $doubleVar, (string)$tableName);
127+
$retElem .= $this->hc->getHtmlDiv($img, 'col-sm-9',"\t", "\n", false);
128+
unset($img);
129+
break;
130+
}
131+
}
132+
}
133+
}
134+
$ret .= $this->hc->getHtmlDiv($retElem, 'panel-body');
82135

83136
return $ret;
84137
}
@@ -93,7 +146,13 @@ public function render()
93146
$module = $this->getModule();
94147
$filename = $this->getFileName();
95148
$moduleDirname = $module->getVar('mod_dirname');
96-
$content = $this->getTemplatesUserPdfBody();
149+
$table = $this->getTable();
150+
$language = $this->getLanguage($moduleDirname, 'MA');
151+
$tableId = $table->getVar('table_id');
152+
$tableMid = $table->getVar('table_mid');
153+
$tableName = $table->getVar('table_name');
154+
$tableSoleName = $table->getVar('table_solename');
155+
$content = $this->getTemplatesUserPdfBody($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $language);
97156

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

0 commit comments

Comments
 (0)