Completed
Push — master ( 88111b...b3fce7 )
by Michael
05:58
created

About::__construct()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 21
nc 1
nop 1
dl 0
loc 27
rs 8.8571
c 0
b 0
f 0
1
<?php namespace XoopsModules\Smartobject;
2
//
3
4
// 2012-01-01 K.OHWADA
5
// PHP 5.3: Assigning the return value of new by reference is now deprecated.
6
7
/**
8
 * Id: smartobjectabout.php 159 2007-12-17 16:44:05Z malanciault
9
 * Module: SmartObject
10
 * Author: The SmartFactory <www.smartfactory.ca>
11
 * Licence: GNU
12
 */
13
14
use XoopsModuleHandler;
15
use XoopsModules\Smartobject;
16
17
// defined('XOOPS_ROOT_PATH') || die('Restricted access');
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
18
19
/**
20
 * Class About is a simple class that lets you build an about page
21
 * @author The SmartFactory <www.smartfactory.ca>
22
 */
23
class About
24
{
25
    public $_lang_aboutTitle;
26
    public $_lang_author_info;
27
    public $_lang_developer_lead;
28
    public $_lang_developer_contributor;
29
    public $_lang_developer_website;
30
    public $_lang_developer_email;
31
    public $_lang_developer_credits;
32
    public $_lang_module_info;
33
    public $_lang_module_status;
34
    public $_lang_module_release_date;
35
    public $_lang_module_demo;
36
    public $_lang_module_support;
37
    public $_lang_module_bug;
38
    public $_lang_module_submit_bug;
39
    public $_lang_module_feature;
40
    public $_lang_module_submit_feature;
41
    public $_lang_module_disclaimer;
42
    public $_lang_author_word;
43
    public $_lang_version_history;
44
    public $_lang_by;
45
    public $_tpl;
46
47
    /**
48
     * SmartobjectAbout constructor.
49
     * @param string $aboutTitle
50
     */
51
    public function __construct($aboutTitle = 'About')
52
    {
53
        global $xoopsModule, $xoopsConfig;
54
55
        /** @var Smartobject\Helper $helper */
56
        $helper = Smartobject\Helper::getInstance();
57
        $helper->loadLanguage('modinfo');
58
        
59
        $this->_aboutTitle = $aboutTitle;
0 ignored issues
show
Bug introduced by
The property _aboutTitle does not seem to exist. Did you mean _lang_aboutTitle?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
60
61
        $this->_lang_developer_contributor = _CO_SOBJECT_DEVELOPER_CONTRIBUTOR;
62
        $this->_lang_developer_website     = _CO_SOBJECT_DEVELOPER_WEBSITE;
63
        $this->_lang_developer_email       = _CO_SOBJECT_DEVELOPER_EMAIL;
64
        $this->_lang_developer_credits     = _CO_SOBJECT_DEVELOPER_CREDITS;
65
        $this->_lang_module_info           = _CO_SOBJECT_MODULE_INFO;
66
        $this->_lang_module_status         = _CO_SOBJECT_MODULE_STATUS;
67
        $this->_lang_module_release_date   = _CO_SOBJECT_MODULE_RELEASE_DATE;
68
        $this->_lang_module_demo           = _CO_SOBJECT_MODULE_DEMO;
69
        $this->_lang_module_support        = _CO_SOBJECT_MODULE_SUPPORT;
70
        $this->_lang_module_bug            = _CO_SOBJECT_MODULE_BUG;
71
        $this->_lang_module_submit_bug     = _CO_SOBJECT_MODULE_SUBMIT_BUG;
72
        $this->_lang_module_feature        = _CO_SOBJECT_MODULE_FEATURE;
73
        $this->_lang_module_submit_feature = _CO_SOBJECT_MODULE_SUBMIT_FEATURE;
74
        $this->_lang_module_disclaimer     = _CO_SOBJECT_MODULE_DISCLAIMER;
75
        $this->_lang_author_word           = _CO_SOBJECT_AUTHOR_WORD;
76
        $this->_lang_version_history       = _CO_SOBJECT_VERSION_HISTORY;
77
    }
78
79
    /**
80
     * @param $value
81
     * @return mixed
82
     */
83
    public function sanitize($value)
84
    {
85
        $myts = \MyTextSanitizer::getInstance();
86
87
        return $myts->displayTarea($value, 1);
88
    }
89
90
    public function render()
91
    {
92
        /**
93
         * @todo move the output to a template
94
         * @todo make the output XHTML compliant
95
         */
96
97
        $myts = \MyTextSanitizer::getInstance();
98
99
        global $xoopsModule;
100
101
        Smartobject\Utility::getXoopsCpHeader();
102
103
        /** @var XoopsModuleHandler $moduleHandler */
104
        $moduleHandler = xoops_getHandler('module');
105
        $versioninfo   = $moduleHandler->get($xoopsModule->getVar('mid'));
106
107
        //Smartobject\Utility::getAdminMenu(-1, $this->_aboutTitle . " " . $versioninfo->getInfo('name'));
0 ignored issues
show
Unused Code Comprehensibility introduced by
54% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
108
109
        require_once XOOPS_ROOT_PATH . '/class/template.php';
110
111
        // ---
112
        // 2012-01-01 PHP 5.3: Assigning the return value of new by reference is now deprecated.
113
        //      $this->_tpl = new \XoopsTpl();
0 ignored issues
show
Unused Code Comprehensibility introduced by
47% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
114
        $this->_tpl = new \XoopsTpl();
115
        // ---
116
117
        $this->_tpl->assign('module_url', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/');
118
        $this->_tpl->assign('module_image', $versioninfo->getInfo('image'));
119
        $this->_tpl->assign('module_name', $versioninfo->getInfo('name'));
120
        $this->_tpl->assign('module_version', $versioninfo->getInfo('version'));
121
        $this->_tpl->assign('module_status_version', $versioninfo->getInfo('status_version'));
122
123
        // Left headings...
124
        if ('' !== $versioninfo->getInfo('author_realname')) {
125
            $author_name = $versioninfo->getInfo('author') . ' (' . $versioninfo->getInfo('author_realname') . ')';
126
        } else {
127
            $author_name = $versioninfo->getInfo('author');
128
        }
129
        $this->_tpl->assign('module_author_name', $author_name);
130
131
        $this->_tpl->assign('module_license', $versioninfo->getInfo('license'));
132
133
        $this->_tpl->assign('module_credits', $versioninfo->getInfo('credits'));
134
135
        // Developers Information
136
        $this->_tpl->assign('module_developer_lead', $versioninfo->getInfo('developer_lead'));
137
        $this->_tpl->assign('module_developer_contributor', $versioninfo->getInfo('developer_contributor'));
138
        $this->_tpl->assign('module_developer_website_url', $versioninfo->getInfo('developer_website_url'));
139
        $this->_tpl->assign('module_developer_website_name', $versioninfo->getInfo('developer_website_name'));
140
        $this->_tpl->assign('module_developer_email', $versioninfo->getInfo('developer_email'));
141
142
        $people = $versioninfo->getInfo('people');
143
        if ($people) {
144
            $this->_tpl->assign('module_people_developers', isset($people['developers']) ? array_map([$this, 'sanitize'], $people['developers']) : false);
145
            $this->_tpl->assign('module_people_testers', isset($people['testers']) ? array_map([$this, 'sanitize'], $people['testers']) : false);
146
            $this->_tpl->assign('module_people_translators', isset($people['translators']) ? array_map([$this, 'sanitize'], $people['translators']) : false);
147
            $this->_tpl->assign('module_people_documenters', isset($people['documenters']) ? array_map([$this, 'sanitize'], $people['documenters']) : false);
148
            $this->_tpl->assign('module_people_other', isset($people['other']) ? array_map([$this, 'sanitize'], $people['other']) : false);
149
        }
150
        //$this->_tpl->assign('module_developers', $versioninfo->getInfo('developer_email'));
0 ignored issues
show
Unused Code Comprehensibility introduced by
77% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
151
152
        // Module Development information
153
        $this->_tpl->assign('module_date', $versioninfo->getInfo('date'));
154
        $this->_tpl->assign('module_status', $versioninfo->getInfo('status'));
155
        $this->_tpl->assign('module_demo_site_url', $versioninfo->getInfo('demo_site_url'));
156
        $this->_tpl->assign('module_demo_site_name', $versioninfo->getInfo('demo_site_name'));
157
        $this->_tpl->assign('module_support_site_url', $versioninfo->getInfo('support_site_url'));
158
        $this->_tpl->assign('module_support_site_name', $versioninfo->getInfo('support_site_name'));
159
        $this->_tpl->assign('module_submit_bug', $versioninfo->getInfo('submit_bug'));
160
        $this->_tpl->assign('module_submit_feature', $versioninfo->getInfo('submit_feature'));
161
162
        // Warning
163
        $this->_tpl->assign('module_warning', $this->sanitize($versioninfo->getInfo('warning')));
164
165
        // Author's note
166
        $this->_tpl->assign('module_author_word', $versioninfo->getInfo('author_word'));
167
168
        // For changelog thanks to 3Dev
169
        global $xoopsModule;
170
        $filename = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/changelog.txt';
171
        if (is_file($filename)) {
172
            $filesize = filesize($filename);
173
            $handle   = fopen($filename, 'r');
174
            $this->_tpl->assign('module_version_history', $myts->displayTarea(fread($handle, $filesize), true));
175
            fclose($handle);
176
        }
177
178
        $this->_tpl->display('db:smartobject_about.tpl');
179
180
        Smartobject\Utility::getModFooter();
181
182
        xoops_cp_footer();
183
    }
184
}
185