UserVisit::getUserVisitCheckHost()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php namespace XoopsModules\Tdmcreate\Files\User;
2
3
use XoopsModules\Tdmcreate;
4
use XoopsModules\Tdmcreate\Files;
5
6
/*
7
 You may not change or alter any portion of this comment or credits
8
 of supporting developers from this source code or any supporting source code
9
 which is considered copyrighted (c) material of the original comment or credit authors.
10
11
 This program is distributed in the hope that it will be useful,
12
 but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
 */
15
/**
16
 * tdmcreate module.
17
 *
18
 * @copyright       XOOPS Project (https://xoops.org)
19
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
20
 *
21
 * @since           2.5.0
22
 *
23
 * @author          Txmod Xoops http://www.txmodxoops.org
24
 *
25
 * @version         $Id: UserVisit.php 12258 2014-01-02 09:33:29Z timgno \$
26
 */
27
28
/**
29
 * Class UserVisit.
30
 */
31
class UserVisit extends Files\CreateFile
32
{
33
    /**
34
    * @var mixed
35
    */
36
    private $uc = null;
37
38
    /**
39
    * @var string
40
    */
41
    private $xc = null;
42
43
    /**
44
    *  @public function constructor
45
    *  @param null
46
    */
47
48
    public function __construct()
49
    {
50
        parent::__construct();
51
        $this->xc = Tdmcreate\Files\CreateXoopsCode::getInstance();
0 ignored issues
show
Documentation Bug introduced by
It seems like XoopsModules\Tdmcreate\F...oopsCode::getInstance() of type XoopsModules\Tdmcreate\Files\CreateXoopsCode is incompatible with the declared type string of property $xc.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
52
        $this->phpcode = Tdmcreate\Files\CreatePhpCode::getInstance();
0 ignored issues
show
Documentation Bug introduced by
It seems like XoopsModules\Tdmcreate\F...ePhpCode::getInstance() of type XoopsModules\Tdmcreate\Files\CreatePhpCode is incompatible with the declared type string of property $phpcode.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
53
        $this->uc = UserXoopsCode::getInstance();
54
    }
55
56
    /**
57
    *  @static function getInstance
58
    *  @param null
59
     * @return UserVisit
60
     */
61
    public static function getInstance()
62
    {
63
        static $instance = false;
64
        if (!$instance) {
65
            $instance = new self();
66
        }
67
68
        return $instance;
69
    }
70
71
    /**
72
    *  @public function write
73
    *  @param string $module
74
    *  @param mixed $table
75
    *  @param string $filename
76
     */
77
    public function write($module, $table, $filename)
78
    {
79
        $this->setModule($module);
80
        $this->setTable($table);
81
        $this->setFileName($filename);
82
    }
83
84
    /**
85
     * @private function getUserVisitHeader
86
     *
87
     * @param $table
88
     *
89
     * @param $fields
90
     * @return string
91
     */
92
    private function getUserVisitHeader($table, $fields)
93
    {
94
        $ret = $this->getInclude();
95
        foreach (array_keys($fields) as $f) {
96
            $fieldName = $fields[$f]->getVar('field_name');
97
            if (0 == $f) {
98
                $fieldId = $fieldName;
99
            }
100
            if (1 == $fields[$f]->getVar('field_parent')) {
101
                $fieldPid = $fieldName;
102
            }
103
        }
104
        if (1 == $table->getVar('table_category')) {
105
            $ccFieldPid = $this->getCamelCase($fieldPid, false, true);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $fieldPid does not seem to be defined for all execution paths leading up to this point.
Loading history...
106
            $ret .= $this->xc->getXcXoopsRequest($ccFieldPid, (string)$fieldPid, '0', 'Int');
107
        }
108
        $ccFieldId = $this->getCamelCase($fieldId, false, true);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $fieldId does not seem to be defined for all execution paths leading up to this point.
Loading history...
109
        $ret .= $this->xc->getXcXoopsRequest($ccFieldId, (string)$fieldId, '0', 'Int');
110
111
        return $ret;
112
    }
113
114
    /**
115
     * @private function getUserVisitCheckPermissions
116
     *
117
     * @param null
118
     *
119
     * @return string
120
     */
121
    private function getUserVisitCheckPermissions()
122
    {
123
        $ret = '';
124
125
        return $ret;
126
    }
127
128
    /**
129
     * @private function getUserVisitCheckLimit
130
     *
131
     * @param null
132
     *
133
     * @return string
134
     */
135
    private function getUserVisitCheckLimit()
136
    {
137
        $ret = '';
138
139
        return $ret;
140
    }
141
142
    /**
143
     * @private function getUserVisitCheckHost
144
     *
145
     * @param null
146
     *
147
     * @return string
148
     */
149
    private function getUserVisitCheckHost()
150
    {
151
        $ret = '';
152
153
        return $ret;
154
    }
155
156
    /**
157
    *  @public function render
158
    *  @param null
159
     * @return bool|string
160
     */
161
    public function render()
162
    {
163
        $module = $this->getModule();
164
        $table = $this->getTable();
165
        $filename = $this->getFileName();
166
        $moduleDirname = $module->getVar('mod_dirname');
167
        $tableId = $table->getVar('table_id');
168
        $tableMid = $table->getVar('table_mid');
169
        $tableName = $table->getVar('table_name');
0 ignored issues
show
Unused Code introduced by
The assignment to $tableName is dead and can be removed.
Loading history...
170
        $tableSoleName = $table->getVar('table_solename');
0 ignored issues
show
Unused Code introduced by
The assignment to $tableSoleName is dead and can be removed.
Loading history...
171
        $fields = $this->getTableFields($tableMid, $tableId);
172
        $language = $this->getLanguage($moduleDirname, 'MA');
0 ignored issues
show
Unused Code introduced by
The assignment to $language is dead and can be removed.
Loading history...
173
        $content = $this->getHeaderFilesComments($module, $filename);
174
        $content .= $this->getUserVisitHeader($table, $fields);
175
        $content .= $this->getUserVisitCheckPermissions();
176
        $content .= $this->getUserVisitCheckLimit();
177
        $content .= $this->getUserVisitCheckHost();
178
179
        $this->create($moduleDirname, '/', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
180
181
        return $this->renderFile();
182
    }
183
}
184