1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace XoopsModules\Modulebuilder\Files\Language; |
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 LanguageBlocks. |
32
|
|
|
*/ |
33
|
|
|
class LanguageBlocks extends Files\CreateFile |
34
|
|
|
{ |
35
|
|
|
/** |
36
|
|
|
* @var mixed |
37
|
|
|
*/ |
38
|
|
|
private $ld = null; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @public function constructor |
42
|
|
|
* @param null |
43
|
|
|
*/ |
44
|
|
|
public function __construct() |
45
|
|
|
{ |
46
|
|
|
parent::__construct(); |
47
|
|
|
$this->ld = LanguageDefines::getInstance(); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @static function getInstance |
52
|
|
|
* @param null |
53
|
|
|
* @return LanguageBlocks |
54
|
|
|
*/ |
55
|
|
|
public static function getInstance() |
56
|
|
|
{ |
57
|
|
|
static $instance = false; |
58
|
|
|
if (!$instance) { |
59
|
|
|
$instance = new self(); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
return $instance; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @public function write |
67
|
|
|
* @param string $module |
68
|
|
|
* @param mixed $tables |
69
|
|
|
* @param string $filename |
70
|
|
|
*/ |
71
|
|
|
public function write($module, $tables, $filename) |
72
|
|
|
{ |
73
|
|
|
$this->setModule($module); |
74
|
|
|
$this->setFileName($filename); |
75
|
|
|
$this->setTables($tables); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @private function getLanguageBlock |
80
|
|
|
* @param string $language |
81
|
|
|
* |
82
|
|
|
* @return string |
83
|
|
|
*/ |
84
|
|
|
private function getLanguageBlock($language) |
85
|
|
|
{ |
86
|
|
|
$tables = $this->getTables(); |
87
|
|
|
$ret = $this->ld->getAboveDefines('Admin Edit'); |
88
|
|
|
$ret .= $this->ld->getDefine($language, 'DISPLAY', 'How Many Items to Display'); |
89
|
|
|
$ret .= $this->ld->getDefine($language, 'DISPLAY_SPOTLIGHT', "How Many Items to Display (only valid if you select 'all')", true); |
90
|
|
|
$ret .= $this->ld->getDefine($language, 'TITLE_LENGTH', 'Title Length'); |
91
|
|
|
$ret .= $this->ld->getDefine($language, 'CATTODISPLAY', 'Categories to Display'); |
92
|
|
|
$ret .= $this->ld->getDefine($language, 'ALLCAT', 'All Categories'); |
93
|
|
|
foreach (\array_keys($tables) as $t) { |
94
|
|
|
if (1 === (int)$tables[$t]->getVar('table_blocks')) { |
95
|
|
|
$tableName = $tables[$t]->getVar('table_name'); |
96
|
|
|
$tableSoleName = $tables[$t]->getVar('table_solename'); |
97
|
|
|
$ucfTableName = \ucfirst($tableName); |
98
|
|
|
$ucfTableSoleName = \ucfirst($tableSoleName); |
99
|
|
|
$stuTableName = \mb_strtoupper($tableName); |
100
|
|
|
$stuTableSoleName = \mb_strtoupper($tableSoleName); |
101
|
|
|
$ret .= $this->ld->getAboveDefines($ucfTableName); |
102
|
|
|
$fields = $this->getTableFields($tables[$t]->getVar('table_mid'), $tables[$t]->getVar('table_id')); |
103
|
|
|
$ret .= $this->ld->getDefine($language, $stuTableName . '_TO_DISPLAY', $ucfTableName . ' to Display'); |
104
|
|
|
$ret .= $this->ld->getDefine($language, 'ALL_' . $stuTableName, 'All ' . $ucfTableName); |
105
|
|
|
foreach (\array_keys($fields) as $f) { |
106
|
|
|
if (1 === (int)$fields[$f]->getVar('field_block')) { |
107
|
|
|
$fieldName = $fields[$f]->getVar('field_name'); |
108
|
|
|
$stuFieldName = \mb_strtoupper($fieldName); |
109
|
|
|
$rpFieldName = $this->getRightString($fieldName); |
110
|
|
|
$fieldNameDesc = \ucfirst($rpFieldName); |
111
|
|
|
$ret .= $this->ld->getDefine($language, $stuFieldName, $fieldNameDesc); |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
$ret .= $this->ld->getDefine($language, $stuTableSoleName . '_GOTO', 'Goto ' . $ucfTableSoleName); |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
return $ret; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @private function getFooter |
123
|
|
|
* @param null |
124
|
|
|
* @return string |
125
|
|
|
*/ |
126
|
|
|
private function getLanguageFooter() |
127
|
|
|
{ |
128
|
|
|
$ret = $this->ld->getBelowDefines('End'); |
129
|
|
|
$ret .= $this->ld->getBlankLine(); |
130
|
|
|
|
131
|
|
|
return $ret; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* @public function render |
136
|
|
|
* @param null |
137
|
|
|
* @return bool|string |
138
|
|
|
*/ |
139
|
|
|
public function render() |
140
|
|
|
{ |
141
|
|
|
$module = $this->getModule(); |
142
|
|
|
$filename = $this->getFileName(); |
143
|
|
|
$moduleDirname = $module->getVar('mod_dirname'); |
144
|
|
|
$language = $this->getLanguage($moduleDirname, 'MB', '', false); |
|
|
|
|
145
|
|
|
$content = $this->getHeaderFilesComments($module); |
146
|
|
|
$content .= $this->getLanguageBlock($language); |
147
|
|
|
$content .= $this->getLanguageFooter(); |
148
|
|
|
|
149
|
|
|
$this->create($moduleDirname, 'language/' . $GLOBALS['xoopsConfig']['language'], $filename, $content, \_AM_MODULEBUILDER_FILE_CREATED, \_AM_MODULEBUILDER_FILE_NOTCREATED); |
150
|
|
|
|
151
|
|
|
return $this->renderFile(); |
152
|
|
|
} |
153
|
|
|
} |
154
|
|
|
|