36 $op =
$system->cleanVars($_REQUEST,
'op',
'default',
'string');
39 $xoops->header(
'admin:system/system_templates.tpl');
41 $xoops->theme()->addBaseScriptAssets(array(
'@jquery',
'@jqueryui'));
42 $xoops->theme()->addScript(
'media/jquery/plugins/jquery.easing.js');
43 $xoops->theme()->addScript(
'media/jquery/plugins/jqueryFileTree.js');
44 $xoops->theme()->addScript(
'modules/system/js/admin.js');
45 $xoops->theme()->addScript(
'modules/system/js/templates.js');
46 $xoops->theme()->addScript(
'modules/system/js/code_mirror/codemirror.js');
48 $xoops->theme()->addStylesheet(
'modules/system/css/admin.css');
49 $xoops->theme()->addStylesheet(
'modules/system/css/code_mirror/docs.css');
65 $xoops->tpl()->assign(
'index',
true);
70 $tplset_handler =
$xoops->getHandlerTplset();
71 $tplsetlist = $tplset_handler->getNameList();
73 foreach ($tplsetlist as $key =>
$name) {
74 $ele->addOption($key,
$name);
76 $form->addElement($ele);
86 $modules->addOptionArray($moduleslist);
89 $form->addElement(
new Xoops\Form\Hidden(
"active_templates",
"0"));
90 $form->addElement(
new Xoops\Form\Hidden(
"active_modules",
"0"));
91 $form->addElement(
new Xoops\Form\Hidden(
"op",
"tpls_overload"));
98 if (!
$xoops->security()->check()) {
99 $xoops->redirect(
'admin.php?fct=tplsets', 3, implode(
'<br />',
$xoops->security()->getErrors()));
106 if ($_REQUEST[
'select_modules'] ==
'0' || $_REQUEST[
'active_modules'] ==
'1') {
108 if (isset($_REQUEST[
'select_theme']) && isset($_REQUEST[
'force_generated'])) {
110 $template_overload =
\XoopsBaseConfig::get(
'themes-path') .
'/' . $_REQUEST[
'select_theme'] .
'/modules';
112 $verif_write =
false;
115 if (!is_dir($template_overload)) {
118 if (!is_dir($template_overload)) {
119 mkdir($template_overload, 0777);
121 chmod($template_overload, 0777);
122 copy($indexFile, $template_overload .
"/index.html");
125 $tplset =
$system->cleanVars($POST,
'tplset',
'default',
'string');
129 $tplset_handler =
$xoops->getHandlerTplset();
130 $tpltpl_handler =
$xoops->getHandlerTplfile();
134 $tplsets_arr = $tplset_handler->getObjects();
135 $tcount = $tplset_handler->getCount();
140 if ($_REQUEST[
'active_templates'] == 0) {
141 foreach (array_keys($tplsets_arr) as
$i) {
142 $tplsetname = $tplsets_arr[
$i]->getVar(
'tplset_name');
143 $tplstats = $tpltpl_handler->getModuleTplCount($tplsetname);
145 if (count($tplstats) > 0) {
146 foreach ($tplstats as $moddir => $filecount) {
150 if (!is_dir($template_overload .
'/' .
$module->getVar(
'dirname'))) {
151 mkdir($template_overload .
'/' .
$module->getVar(
'dirname'), 0777);
152 chmod($template_overload .
'/' .
$module->getVar(
'dirname'), 0777);
153 copy($indexFile, $template_overload .
'/' .
$module->getVar(
'dirname') .
'/index.html');
157 if (!is_dir($template_overload .
'/' .
$module->getVar(
'dirname') .
'/blocks')) {
158 if (!is_dir($template_overload .
'/' .
$module->getVar(
'dirname') .
'/blocks')) {
159 mkdir($template_overload .
'/' .
$module->getVar(
'dirname') .
'/blocks', 0777);
161 chmod($template_overload .
'/' .
$module->getVar(
'dirname') .
'/blocks', 0777);
162 copy($indexFile, $template_overload .
'/' .
$module->getVar(
'dirname') .
'/blocks' .
'/index.html');
169 $templates = $tpltpl_handler->find($tplsetname,
'module', null, $moddir);
170 for (
$j = 0;
$j < count($templates); ++
$j) {
171 $filename = $templates[
$j]->getVar(
'tpl_file');
172 if ($tplsetname == $tplset) {
173 $physical_file =
\XoopsBaseConfig::get(
'themes-path') .
'/' . $_REQUEST[
'select_theme'] .
'/modules/' . $moddir .
'/' . $filename;
175 $tplfile = $tpltpl_handler->get($templates[
$j]->getVar(
'tpl_id'),
true);
177 if (is_object($tplfile)) {
179 $open = fopen(
"" . $physical_file .
"",
"w+");
180 if (fwrite($open,
"" . html_entity_decode($tplfile->getVar(
'tpl_source',
'E'), ENT_QUOTES))) {
181 $text .=
'<tr class="' . $class .
'"><td align="center">' .
XoopsLocale::TEMPLATES .
'</td><td>' . $physical_file .
'</td><td align="center">';
190 $class = ($class ==
"even") ?
"odd" :
"even";
197 $btemplates = $tpltpl_handler->find($tplsetname,
'block', null, $moddir);
198 for ($k = 0; $k < count($btemplates); ++$k) {
199 $filename = $btemplates[$k]->getVar(
'tpl_file');
200 if ($tplsetname == $tplset) {
201 $physical_file =
\XoopsBaseConfig::get(
'themes-path') .
'/' . $_REQUEST[
'select_theme'] .
'/modules/' . $moddir .
'/blocks/' . $filename;
202 $btplfile = $tpltpl_handler->get($btemplates[$k]->getVar(
'tpl_id'),
true);
204 if (is_object($btplfile)) {
206 $open = fopen(
"" . $physical_file .
"",
"w+");
207 if (fwrite($open,
"" . utf8_encode(html_entity_decode($btplfile->getVar(
'tpl_source',
'E'))) .
"")) {
208 $text .=
'<tr class="' . $class .
'"><td align="center">' .
XoopsLocale::BLOCKS .
'</td><td>' . $physical_file .
'</td><td align="center">';
217 $class = ($class ==
"even") ?
"odd" :
"even";
229 foreach (array_keys($tplsets_arr) as
$i) {
230 $tplsetname = $tplsets_arr[
$i]->getVar(
'tplset_name');
231 $tplstats = $tpltpl_handler->getModuleTplCount($tplsetname);
233 if (count($tplstats) > 0) {
234 $moddir = $_REQUEST[
'select_modules'];
238 if (!is_dir($template_overload .
'/' .
$module->getVar(
'dirname'))) {
239 mkdir($template_overload .
'/' .
$module->getVar(
'dirname'), 0777);
240 chmod($template_overload .
'/' .
$module->getVar(
'dirname'), 0777);
241 copy($indexFile, $template_overload .
'/' .
$module->getVar(
'dirname') .
'/index.html');
245 if (!is_dir($template_overload .
'/' .
$module->getVar(
'dirname') .
'/blocks')) {
246 if (!is_dir($template_overload .
'/' .
$module->getVar(
'dirname') .
'/blocks')) {
247 mkdir($template_overload .
'/' .
$module->getVar(
'dirname') .
'/blocks', 0777);
249 chmod($template_overload .
'/' .
$module->getVar(
'dirname') .
'/blocks', 0777);
250 copy($indexFile, $template_overload .
'/' .
$module->getVar(
'dirname') .
'/blocks' .
'/index.html');
255 $select_templates_modules = $_REQUEST[
'select_templates_modules'];
256 for (
$l = 0;
$l < count($_REQUEST[
'select_templates_modules']); ++
$l) {
258 $templates = $tpltpl_handler->find($tplsetname,
'module', null, $moddir);
259 for (
$j = 0;
$j < count($templates); ++
$j) {
260 $filename = $templates[
$j]->getVar(
'tpl_file');
261 if ($tplsetname == $tplset) {
262 $physical_file =
\XoopsBaseConfig::get(
'themes-path') .
'/' . $_REQUEST[
'select_theme'] .
'/modules/' . $moddir .
'/' . $filename;
264 $tplfile = $tpltpl_handler->get($templates[
$j]->getVar(
'tpl_id'),
true);
266 if (is_object($tplfile)) {
268 if ($select_templates_modules[
$l] == $filename) {
269 $open = fopen(
"" . $physical_file .
"",
"w+");
270 if (fwrite($open,
"" . html_entity_decode($tplfile->getVar(
'tpl_source',
'E'), ENT_QUOTES))) {
271 $text .=
'<tr class="' . $class .
'"><td align="center">' .
XoopsLocale::TEMPLATES .
'</td><td>' . $physical_file .
'</td><td align="center">';
281 $class = ($class ==
"even") ?
"odd" :
"even";
288 $btemplates = $tpltpl_handler->find($tplsetname,
'block', null, $moddir);
289 for ($k = 0; $k < count($btemplates); ++$k) {
290 $filename = $btemplates[$k]->getVar(
'tpl_file');
291 if ($tplsetname == $tplset) {
292 $physical_file =
\XoopsBaseConfig::get(
'themes-path') .
'/' . $_REQUEST[
'select_theme'] .
'/modules/' . $moddir .
'/blocks/' . $filename;
293 $btplfile = $tpltpl_handler->get($btemplates[$k]->getVar(
'tpl_id'),
true);
295 if (is_object($btplfile)) {
297 if ($select_templates_modules[
$l] == $filename) {
298 $open = fopen(
"" . $physical_file .
"",
"w+");
299 if (fwrite($open,
"" . utf8_encode(html_entity_decode($btplfile->getVar(
'tpl_source',
'E'))) .
"")) {
300 $text .=
'<tr class="' . $class .
'"><td align="center">' .
XoopsLocale::BLOCKS .
'</td><td>' . $physical_file .
'</td><td align="center">';
310 $class = ($class ==
"even") ?
"odd" :
"even";
323 $xoops->tpl()->assign(
'verif', $verif_write);
329 $xoops->tpl()->assign(
'index',
true);
331 $tplset =
$system->cleanVars($POST,
'tplset',
'default',
'string');
335 $tpltpl_handler =
$xoops->getHandlerTplfile();
336 $templates_arr = $tpltpl_handler->find($tplset,
'', null, $_REQUEST[
'select_modules']);
339 foreach (array_keys($templates_arr) as
$i) {
340 $modules->addOption($templates_arr[$i]->getVar(
'tpl_file'));
344 $form->addElement(
new Xoops\Form\Hidden(
"active_templates",
"1"));
345 $form->addElement(
new Xoops\Form\Hidden(
"force_generated", $_REQUEST[
'force_generated']));
346 $form->addElement(
new Xoops\Form\Hidden(
"select_modules", $_REQUEST[
'select_modules']));
347 $form->addElement(
new Xoops\Form\Hidden(
"active_modules",
"1"));
348 $form->addElement(
new Xoops\Form\Hidden(
"select_theme", $_REQUEST[
'select_theme']));
349 $form->addElement(
new Xoops\Form\Hidden(
"op",
"tpls_overload"));
357 $path_file = $_REQUEST[
'path_file'];
358 if (isset($path_file)) {
360 $copy_file = $path_file;
361 copy($copy_file, $path_file .
'.back');
363 if (isset($_REQUEST[
'templates'])) {
364 $open = fopen(
"" . $path_file .
"",
"w+");
365 if (!fwrite($open, utf8_encode(stripslashes($_REQUEST[
'templates'])))) {
static getInstance($fct= '')
system_adminVersion($version, $value= '')
const FORCED_FILE_GENERATION
const TEMPLATE_OVERLOADED
const E_NO_ACCESS_PERMISSION