Skip to content

Commit 07d1390

Browse files
authored
Merge pull request #4 from ggoffy/master
adapted hardcoded creation of templates into new way (next steps)
2 parents 5671c67 + ca1fb00 commit 07d1390

File tree

9 files changed

+97
-279
lines changed

9 files changed

+97
-279
lines changed

_TODO.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ TODOs:
1212
implement constants interface
1313

1414

15-
15+
Broken files:
16+
Notification for broken files in xoops_version adapt?
17+
add initiate event when click on broken file
1618

1719

1820
Notifications:

class/Files/CreateHtmlCode.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ public function getHtmlEmpty($empty = '', $t = '', $n = '')
114114
* @param string $n
115115
* @return string
116116
*/
117-
public function getHtmlComment($htmlComment = '', $n = '')
117+
public function getHtmlComment($htmlComment = '', $t = '', $n = '')
118118
{
119-
return "<!-- {$htmlComment} -->{$n}";
119+
return "{$t}<!-- {$htmlComment} -->{$n}";
120120
}
121121

122122
/**

class/Files/CreateSmartyCode.php

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,9 @@ public function getSmartyIncludeFile($moduleDirname, $fileName = 'header', $admi
201201
* @param string $n
202202
* @return string
203203
*/
204-
public function getSmartyIncludeFileListSection($moduleDirname, $fileName, $tableFieldName, $t = '', $n = '')
204+
public function getSmartyIncludeFileListSection($moduleDirname, $fileName, $itemName, $arrayName, $t = '', $n = '')
205205
{
206-
return "{$t}<{include file='db:{$moduleDirname}_{$fileName}_list.tpl' {$tableFieldName}=\${$tableFieldName}[i]}>{$n}";
206+
return "{$t}<{include file='db:{$moduleDirname}_{$fileName}_list.tpl' {$itemName}=\${$arrayName}[i]}>{$n}";
207207
}
208208

209209
/**
@@ -233,31 +233,28 @@ public function getSmartyIncludeFileListForeach($moduleDirname, $fileName, $tabl
233233
* @param string $n
234234
* @return string
235235
*/
236-
public function getSmartyConditions($condition = '', $operator = '', $type = '', $contentIf = '', $contentElse = false, $count = false, $noSimbol = false, $t = '', $n = "\n")
236+
public function getSmartyConditions($condition = '', $operator = '', $type = '', $contentIf = '', $contentElse = false, $count = false, $noSimbol = false, $t = '', $n = "\n", $split = true)
237237
{
238-
if (!$contentElse) {
239-
if (!$count) {
240-
$ret = "{$t}<{if \${$condition}{$operator}{$type}}>{$n}";
241-
} elseif (!$noSimbol) {
242-
$ret = "{$t}<{if {$condition}{$operator}{$type}}>{$n}";
243-
} else {
244-
$ret = "{$t}<{if count(\${$condition}){$operator}{$type}}>{$n}";
245-
}
246-
$ret .= "{$contentIf}";
247-
$ret .= "{$t}<{/if}>{$n}";
238+
$ns = '';
239+
$ts = '';
240+
if ($split) {
241+
$ns = $n;
242+
$ts = $t;
243+
}
244+
if (!$count) {
245+
$ret = "{$t}<{if \${$condition}{$operator}{$type}}>{$ns}";
246+
} elseif (!$noSimbol) {
247+
$ret = "{$t}<{if {$condition}{$operator}{$type}}>{$ns}";
248248
} else {
249-
if (!$count) {
250-
$ret = "{$t}<{if \${$condition}{$operator}{$type}}>{$n}";
251-
} elseif (!$noSimbol) {
252-
$ret = "{$t}<{if {$condition}{$operator}{$type}}>{$n}";
253-
} else {
254-
$ret = "{$t}<{if count(\${$condition}){$operator}{$type}}>{$n}";
255-
}
256-
$ret .= "{$contentIf}";
257-
$ret .= "{$t}<{else}>{$n}";
249+
$ret = "{$t}<{if count(\${$condition}){$operator}{$type}}>{$ns}";
250+
}
251+
$ret .= "{$contentIf}";
252+
if ($contentElse) {
253+
$ret .= "{$ts}<{else}>{$ns}";
258254
$ret .= "{$contentElse}";
259-
$ret .= "{$t}<{/if}>{$n}";
260255
}
256+
$ret .= "{$ts}<{/if}>{$n}";
257+
261258

262259
return $ret;
263260
}

class/Files/Templates/Admin/TemplatesAdminAbout.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ public function render()
7777
$module = $this->getModule();
7878
$filename = $this->getFileName();
7979
$moduleDirname = $module->getVar('mod_dirname');
80-
$content = $hc->getHtmlComment('Header') . PHP_EOL;
80+
$content = $hc->getHtmlComment('Header', '', "\n");
8181
$content .= $sc->getSmartyIncludeFile($moduleDirname, 'header', true, true) . PHP_EOL;
82-
$content .= $hc->getHtmlComment('About Page') . PHP_EOL;
82+
$content .= $hc->getHtmlComment('About Page', '', "\n");
8383
$single = $sc->getSmartySingleVar('about');
8484
$content .= $hc->getHtmlTag('div', ['class' => 'top'], $single) . PHP_EOL;
85-
$content .= $hc->getHtmlComment('Footer') . PHP_EOL;
85+
$content .= $hc->getHtmlComment('Footer', '', "\n");
8686
$content .= $sc->getSmartyIncludeFile($moduleDirname, 'footer', true, true);
8787

8888
$this->create($moduleDirname, 'templates/admin', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);

class/Files/Templates/Admin/TemplatesAdminBroken.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private function getTemplatesAdminBrokenHeader($moduleDirname)
7777
{
7878
$hc = Tdmcreate\Files\CreateHtmlCode::getInstance();
7979
$sc = Tdmcreate\Files\CreateSmartyCode::getInstance();
80-
$ret = $hc->getHtmlComment('Header', "\n");
80+
$ret = $hc->getHtmlComment('Header', '',"\n");
8181
$ret .= $sc->getSmartyIncludeFile($moduleDirname, 'header', true, '', '', "\n\n");
8282

8383
return $ret;
@@ -221,7 +221,7 @@ private function getTemplatesAdminBrokenFooter($moduleDirname)
221221
$div = $hc->getHtmlDiv($strong, 'errorMsg', "\t", "\n");
222222
$ret = $sc->getSmartyConditions('error', '', '', $div);
223223
$ret .= $hc->getHtmlEmpty('', '', "\n");
224-
$ret .= $hc->getHtmlComment('Footer', "\n");
224+
$ret .= $hc->getHtmlComment('Footer', '', "\n");
225225
$ret .= $sc->getSmartyIncludeFile($moduleDirname, 'footer', true);
226226

227227
return $ret;

class/Files/Templates/Admin/TemplatesAdminIndex.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ public function render()
7878
$filename = $this->getFileName();
7979
$moduleDirname = $module->getVar('mod_dirname');
8080

81-
$content = $hc->getHtmlComment('Header') . PHP_EOL;
81+
$content = $hc->getHtmlComment('Header', '', "\n") ;
8282
$content .= $sc->getSmartyIncludeFile($moduleDirname, 'header', true, true) . PHP_EOL;
83-
$content .= $hc->getHtmlComment('Index Page') . PHP_EOL;
83+
$content .= $hc->getHtmlComment('Index Page', '', "\n") ;
8484
$single = $sc->getSmartySingleVar('index');
8585
$content .= $hc->getHtmlTag('div', ['class' => 'top'], $single) . PHP_EOL;
86-
$content .= $hc->getHtmlComment('Footer') . PHP_EOL;
86+
$content .= $hc->getHtmlComment('Footer', '', "\n");
8787
$content .= $sc->getSmartyIncludeFile($moduleDirname, 'footer', true, true);
8888

8989
$this->create($moduleDirname, 'templates/admin', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);

class/Files/Templates/Admin/TemplatesAdminPages.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private function getTemplatesAdminPagesHeader($moduleDirname)
7777
{
7878
$hc = Tdmcreate\Files\CreateHtmlCode::getInstance();
7979
$sc = Tdmcreate\Files\CreateSmartyCode::getInstance();
80-
$ret = $hc->getHtmlComment('Header', "\n");
80+
$ret = $hc->getHtmlComment('Header', '',"\n");
8181
$ret .= $sc->getSmartyIncludeFile($moduleDirname, 'header', true, '', '', "\n\n");
8282

8383
return $ret;
@@ -273,7 +273,7 @@ private function getTemplatesAdminPagesFooter($moduleDirname)
273273
{
274274
$hc = Tdmcreate\Files\CreateHtmlCode::getInstance();
275275
$sc = Tdmcreate\Files\CreateSmartyCode::getInstance();
276-
$ret = $hc->getHtmlComment('Footer', "\n");
276+
$ret = $hc->getHtmlComment('Footer', '', "\n");
277277
$ret .= $sc->getSmartyIncludeFile($moduleDirname, 'footer', true);
278278

279279
return $ret;

0 commit comments

Comments
 (0)