Passed
Pull Request — master (#14)
by Michael
04:13
created

admin/actions/texts.php (7 issues)

Severity
1
<?php
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
12
/**
13
 * oledrion
14
 *
15
 * @copyright   {@link https://xoops.org/ XOOPS Project}
16
 * @license     {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
17
 * @author      Hervé Thouzard (http://www.herve-thouzard.com/)
18
 */
19
20
use Xmf\Request;
21
use XoopsModules\Oledrion;
22
23
/**
24
 * Gestion des textes affichés sur certaines pages pour les utilisateurs
25
 */
26
if (!defined('OLEDRION_ADMIN')) {
27
    exit();
28
}
29
switch ($action) {
30
    // ****************************************************************************************************************
31
    case 'default': // Gestion des textes
32
33
        // ****************************************************************************************************************
34
        xoops_cp_header();
35
        // require_once OLEDRION_PATH . 'class/Registryfile.php';
36
        $registry = new Oledrion\Registryfile();
37
38
        $sform = new \XoopsThemeForm(_MI_OLEDRION_ADMENU8, 'frmatxt', $baseurl);
39
        $sform->addElement(new \XoopsFormHidden('op', 'texts'));
40
        $sform->addElement(new \XoopsFormHidden('action', 'savetexts'));
41
        $editor1 = Oledrion\Utility::getWysiwygForm(_AM_OLEDRION_INDEX_PAGE, 'welcome1', $registry->getfile(OLEDRION_TEXTFILE1), 5, 60, 'hometext1_hidden');
42
        if ($editor1) {
0 ignored issues
show
$editor1 is of type XoopsFormEditor, thus it always evaluated to true.
Loading history...
43
            $sform->addElement($editor1, false);
44
        }
45
46
        $editor2 = Oledrion\Utility::getWysiwygForm(_OLEDRION_CGV, 'welcome2', $registry->getfile(OLEDRION_TEXTFILE2), 5, 60, 'hometext2_hidden');
47
        if ($editor2) {
0 ignored issues
show
$editor2 is of type XoopsFormEditor, thus it always evaluated to true.
Loading history...
48
            $sform->addElement($editor2, false);
49
        }
50
51
        $editor3 = Oledrion\Utility::getWysiwygForm(_AM_OLEDRION_RECOMM_TEXT, 'welcome3', $registry->getfile(OLEDRION_TEXTFILE3), 5, 60, 'hometext3_hidden');
52
        if ($editor3) {
0 ignored issues
show
$editor3 is of type XoopsFormEditor, thus it always evaluated to true.
Loading history...
53
            $sform->addElement($editor3, false);
54
        }
55
56
        $editor4 = Oledrion\Utility::getWysiwygForm(_AM_OLEDRION_OFFLINEPAY_TEXT, 'welcome4', $registry->getfile(OLEDRION_TEXTFILE4), 5, 60, 'hometext4_hidden');
57
        if ($editor4) {
0 ignored issues
show
$editor4 is of type XoopsFormEditor, thus it always evaluated to true.
Loading history...
58
            $sform->addElement($editor4, false);
59
        }
60
61
        $editor5 = Oledrion\Utility::getWysiwygForm(_AM_OLEDRION_RESTRICT_TEXT, 'welcome5', $registry->getfile(OLEDRION_TEXTFILE5), 5, 60, 'hometext5_hidden');
62
        if ($editor5) {
0 ignored issues
show
$editor5 is of type XoopsFormEditor, thus it always evaluated to true.
Loading history...
63
            $sform->addElement($editor5, false);
64
        }
65
66
        $editor6 = Oledrion\Utility::getWysiwygForm(_AM_OLEDRION_CHECKOUT_TEXT1, 'welcome6', $registry->getfile(OLEDRION_TEXTFILE6), 5, 60, 'hometext6_hidden');
67
        if ($editor6) {
0 ignored issues
show
$editor6 is of type XoopsFormEditor, thus it always evaluated to true.
Loading history...
68
            $sform->addElement($editor6, false);
69
        }
70
71
        $editor7 = Oledrion\Utility::getWysiwygForm(_AM_OLEDRION_CHECKOUT_TEXT2, 'welcome7', $registry->getfile(OLEDRION_TEXTFILE7), 5, 60, 'hometext7_hidden');
72
        if ($editor7) {
0 ignored issues
show
$editor7 is of type XoopsFormEditor, thus it always evaluated to true.
Loading history...
73
            $sform->addElement($editor7, false);
74
        }
75
76
        $buttonTray = new \XoopsFormElementTray('', '');
77
        $submit_btn = new \XoopsFormButton('', 'post', _AM_OLEDRION_MODIFY, 'submit');
78
        $buttonTray->addElement($submit_btn);
79
        $sform->addElement($buttonTray);
80
        $sform = Oledrion\Utility::formMarkRequiredFields($sform);
81
        $sform->display();
82
83
        break;
84
    // ****************************************************************************************************************
85
    case 'savetexts': // Sauvegarde des textes d'accueil ********************************************************
86
87
        // ****************************************************************************************************************
88
        // require_once OLEDRION_PATH . 'class/Registryfile.php';
89
        $registry = new Oledrion\Registryfile();
90
        $registry->savefile(Request::getText('welcome1', '', 'POST'), OLEDRION_TEXTFILE1);
91
        $registry->savefile(Request::getText('welcome2', '', 'POST'), OLEDRION_TEXTFILE2);
92
        $registry->savefile(Request::getText('welcome3', '', 'POST'), OLEDRION_TEXTFILE3);
93
        $registry->savefile(Request::getText('welcome4', '', 'POST'), OLEDRION_TEXTFILE4);
94
        $registry->savefile(Request::getText('welcome5', '', 'POST'), OLEDRION_TEXTFILE5);
95
        $registry->savefile(Request::getText('welcome6', '', 'POST'), OLEDRION_TEXTFILE6);
96
        $registry->savefile(Request::getText('welcome7', '', 'POST'), OLEDRION_TEXTFILE7);
97
        Oledrion\Utility::updateCache();
98
        Oledrion\Utility::redirect(_AM_OLEDRION_SAVE_OK, $baseurl . '?op=texts', 2);
99
100
        break;
101
}
102