Skip to content

Commit 1c38250

Browse files
authored
Merge pull request #150 from ggoffy/master
next steps to replace hardcoded creation of tpl files
2 parents 834a165 + ccf8f32 commit 1c38250

4 files changed

Lines changed: 227 additions & 45 deletions

File tree

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<?php
2+
3+
namespace XoopsModules\Tdmcreate\Files\Templates\User;
4+
5+
use XoopsModules\Tdmcreate;
6+
use XoopsModules\Tdmcreate\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+
* tdmcreate 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 DisqusComments.
31+
*/
32+
class DisqusComments extends Files\CreateFile
33+
{
34+
/**
35+
* @public function constructor
36+
* @param null
37+
*/
38+
public function __construct()
39+
{
40+
parent::__construct();
41+
}
42+
43+
/**
44+
* @static function getInstance
45+
* @param null
46+
* @return DisqusComments
47+
*/
48+
public static function getInstance()
49+
{
50+
static $instance = false;
51+
if (!$instance) {
52+
$instance = new self();
53+
}
54+
55+
return $instance;
56+
}
57+
58+
/**
59+
* @public function write
60+
* @param string $module
61+
* @param string $filename
62+
*/
63+
public function write($module, $filename)
64+
{
65+
$this->setModule($module);
66+
$this->setFileName($filename);
67+
}
68+
69+
/**
70+
* @private function getTemplatesCommentCode
71+
* @param null
72+
*
73+
* @return string
74+
*/
75+
private function getTemplatesCommentCode()
76+
{
77+
$hc = Tdmcreate\Files\CreateHtmlCode::getInstance();
78+
79+
return $hc->getHtmlEmpty('Please! Enter here your comments code');
80+
}
81+
82+
/**
83+
* @public function render
84+
* @return bool|string
85+
*/
86+
public function render()
87+
{
88+
$module = $this->getModule();
89+
$filename = $this->getFileName();
90+
$moduleDirname = $module->getVar('mod_dirname');
91+
$content = $this->getTemplatesCommentCode();
92+
93+
$this->create($moduleDirname, 'templates', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
94+
95+
return $this->renderFile();
96+
}
97+
}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<?php
2+
3+
namespace XoopsModules\Tdmcreate\Files\Templates\User;
4+
5+
use XoopsModules\Tdmcreate;
6+
use XoopsModules\Tdmcreate\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+
* tdmcreate 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 FacebookComments.
31+
*/
32+
class FacebookComments extends Files\CreateFile
33+
{
34+
/**
35+
* @public function constructor
36+
* @param null
37+
*/
38+
public function __construct()
39+
{
40+
parent::__construct();
41+
}
42+
43+
/**
44+
* @static function getInstance
45+
* @param null
46+
* @return FacebookComments
47+
*/
48+
public static function getInstance()
49+
{
50+
static $instance = false;
51+
if (!$instance) {
52+
$instance = new self();
53+
}
54+
55+
return $instance;
56+
}
57+
58+
/**
59+
* @public function write
60+
* @param string $module
61+
* @param string $filename
62+
*/
63+
public function write($module, $filename)
64+
{
65+
$this->setModule($module);
66+
$this->setFileName($filename);
67+
}
68+
69+
/**
70+
* @private function getTemplatesCommentCode
71+
* @param null
72+
*
73+
* @return string
74+
*/
75+
private function getTemplatesCommentCode()
76+
{
77+
$hc = Tdmcreate\Files\CreateHtmlCode::getInstance();
78+
79+
return $hc->getHtmlEmpty('Please! Enter here your comments code');
80+
}
81+
82+
/**
83+
* @public function render
84+
* @return bool|string
85+
*/
86+
public function render()
87+
{
88+
$module = $this->getModule();
89+
$filename = $this->getFileName();
90+
$moduleDirname = $module->getVar('mod_dirname');
91+
$content = $this->getTemplatesCommentCode();
92+
93+
$this->create($moduleDirname, 'templates', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
94+
95+
return $this->renderFile();
96+
}
97+
}

class/Files/CreateHtmlCode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private function getAttributes($attributes)
103103
* @param string $n
104104
* @return string
105105
*/
106-
public function getHtmlEmpty($empty = '', $t = '', $n = "")
106+
public function getHtmlEmpty($empty = '', $t = '', $n = '')
107107
{
108108
return "{$t}{$empty}{$n}";
109109
}

class/Files/Templates/user/Footer.php

Lines changed: 32 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,36 @@ public function getTemplateUserFooterFacebookShareButton()
9595
return "<li class='fb-share-button' data-href='<{\$xoops_mpageurl}>' data-layout='button_count'></li>";
9696
}
9797

98+
/**
99+
* @public function render
100+
* @param null
101+
* @return bool|string
102+
*/
103+
private function getTemplateUserFooterContent($moduleDirname, $language)
104+
{
105+
$hc = Tdmcreate\Files\CreateHtmlCode::getInstance();
106+
$sc = Tdmcreate\Files\CreateSmartyCode::getInstance();
107+
$ret = $hc->getHtmlDiv('<{$copyright}>', 'pull-left', '', "\n", false);
108+
$ret .= $hc->getHtmlEmpty("\n");
109+
$contIf = $hc->getHtmlDiv('<{$pagenav}>', 'pull-right', "\t", "\n", false);
110+
$ret .= $sc->getSmartyConditions('pagenav', ' != ', "''", $contIf);
111+
$ret .= $hc->getHtmlEmpty("<br>\n");
112+
$contIf = $hc->getHtmlDiv("<a href='<{\$admin}>'><{\$smarty.const.{$language}ADMIN}></a>", 'text-center bold', "\t", "\n", false);
113+
$ret .= $sc->getSmartyConditions('xoops_isadmin', ' != ', "''", $contIf);
114+
$ret .= $hc->getHtmlEmpty("\n");
115+
$contIf = $sc->getSmartyIncludeFile('system_comments','flat',false, false,"\t\t\t");
116+
$contIf .= $this->getSimpleString('<{elseif $comment_mode == "thread"}>',"\t\t");
117+
$contIf .= $sc->getSmartyIncludeFile('system_comments','thread',false, false,"\t\t\t");
118+
$contIf .= $this->getSimpleString('<{elseif $comment_mode == "nest"}>',"\t\t");
119+
$contIf .= $sc->getSmartyIncludeFile('system_comments','nest',false, false,"\t\t\t");
120+
$contDiv = $sc->getSmartyConditions('comment_mode', ' == ', '"flat"', $contIf, false, '','',"\t\t");
121+
$contIf = $hc->getHtmlDiv($contDiv, 'pad2 marg2', "\t", "\n", true);
122+
$ret .= $sc->getSmartyConditions('comment_mode', '', '', $contIf);
123+
124+
return $ret;
125+
}
126+
127+
98128
/**
99129
* @public function render
100130
* @param null
@@ -103,53 +133,11 @@ public function getTemplateUserFooterFacebookShareButton()
103133
public function render()
104134
{
105135
$module = $this->getModule();
106-
$table = $this->getTable();
107136
$filename = $this->getFileName();
108137
$moduleDirname = $module->getVar('mod_dirname');
109138
$language = $this->getLanguage($moduleDirname, 'MA');
110-
$content = <<<EOT
111-
<{if \$bookmarks != 0}>
112-
<{include file="db:system_bookmarks.tpl"}>
113-
<{/if}>
114-
\n<{if \$fbcomments != 0}>
115-
<{include file="db:system_fbcomments.tpl"}>
116-
<{/if}>
117-
<div class="pull-left"><{\$copyright}></div>\n
118-
EOT;
119-
if (is_object($table) && null != $table->getVar('table_name')) {
120-
$content .= <<<EOT
121-
<{if \$pagenav != ''}>
122-
<div class="pull-right"><{\$pagenav}></div>
123-
<{/if}>
124-
<br>\n
125-
EOT;
126-
}
127-
$content .= <<<EOT
128-
<{if \$xoops_isadmin}>
129-
<div class="text-center bold"><a href="<{\$admin}>"><{\$smarty.const.{$language}ADMIN}></a></div><br>
130-
<{/if}>\n
131-
EOT;
132-
if (is_object($table)) {
133-
if (1 == $table->getVar('table_comments')) {
134-
$content .= <<<EOT
135-
<div class="pad2 marg2">
136-
<{if \$comment_mode == "flat"}>
137-
<{include file="db:system_comments_flat.tpl"}>
138-
<{elseif \$comment_mode == "thread"}>
139-
<{include file="db:system_comments_thread.tpl"}>
140-
<{elseif \$comment_mode == "nest"}>
141-
<{include file="db:system_comments_nest.tpl"}>
142-
<{/if}>
143-
</div>\n
144-
<br>\n
145-
EOT;
146-
}
147-
if (1 == $table->getVar('table_notifications')) {
148-
$content .= <<<'EOT'
149-
<{include file='db:system_notification_select.tpl'}>
150-
EOT;
151-
}
152-
}
139+
$content = $this->getTemplateUserFooterContent($moduleDirname, $language);
140+
153141
$this->create($moduleDirname, 'templates', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
154142

155143
return $this->renderFile();

0 commit comments

Comments
 (0)