Passed
Branch master (b7438d)
by Gino
03:05
created

UserXoopsCode::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
/*
4
 You may not change or alter any portion of this comment or credits
5
 of supporting developers from this source code or any supporting source code
6
 which is considered copyrighted (c) material of the original comment or credit authors.
7
8
 This program is distributed in the hope that it will be useful,
9
 but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 */
12
/**
13
 * tdmcreate module.
14
 *
15
 * @copyright       The XOOPS Project http://sourceforge.net/projects/xoops/
16
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
17
 *
18
 * @since           2.5.0
19
 *
20
 * @author          Txmod Xoops http://www.txmodxoops.org
21
 *
22
 * @version         $Id: UserXoopsCode.php 12258 2014-01-02 09:33:29Z timgno $
23
 */
24
25
/**
26
 * Class UserXoopsCode.
27
 */
28
class UserXoopsCode
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
29
{
30
    /*
31
    *  @static function &getInstance
32
    *  @param null
33
    */
34
    /**
35
     * @return UserXoopsCode
36
     */
37
    public static function &getInstance()
38
    {
39
        static $instance = false;
40
        if (!$instance) {
41
            $instance = new self();
42
        }
43
44
        return $instance;
45
    }
46
47
    /*
48
    *  @public function getUserTplMain
49
    *  @param string $moduleDirname
50
    *  @param string $tableName
51
    *  @return string
52
    */
53
    public function getUserTplMain($moduleDirname, $tableName = 'index')
54
    {
55
        return "\$GLOBALS['xoopsOption']['template_main'] = '{$moduleDirname}_{$tableName}.tpl';\n";
56
    }
57
58
    /*
59
     * @public function getUserAddMeta
60
     * @param $type
61
     * @param $language
62
     * @param $tableName
63
     *  
64
     * @return string
65
     */
66
    public function getUserAddMeta($type = '', $language, $tableName)
67
    {
68
        $pCodeAddMeta = TDMCreatePhpCode::getInstance();
69
        $stuTableName = strtoupper($tableName);
70
        $stripTags = $pCodeAddMeta->getPhpCodeStripTags('', $language.$stuTableName, true);
71
72
        return "\$GLOBALS['xoTheme']->addMeta( 'meta', '{$type}', {$stripTags});\n";
73
    }
74
75
    /*
76
    *  @public function getUserMetaKeywords
77
    *  @param string $moduleDirname
78
    *  
79
    *  @return string
80
    */
81
    public function getUserMetaKeywords($moduleDirname)
82
    {
83
        $pCodeMetaKeywords = TDMCreatePhpCode::getInstance();
84
        $implode = $pCodeMetaKeywords->getPhpCodeImplode(',', '$keywords');
85
86
        return "{$moduleDirname}MetaKeywords(\${$moduleDirname}->getConfig('keywords').', '. {$implode});\n";
87
    }
88
89
    /*
90
    *  @public function getUserMetaDesc
91
    *  @param string $moduleDirname    
92
    *  @param string $language
93
    *  @param string $file
94
    *  
95
    *  @return string
96
    */
97
    public function getUserMetaDesc($moduleDirname, $language, $file = 'INDEX')
98
    {
99
        return "{$moduleDirname}MetaDescription({$language}{$file}_DESC);\n";
100
    }
101
102
    /*
103
    *  @public function getUserBreadcrumbs
104
    *  @param string $language
105
    *  @param string $moduleDirname    
0 ignored issues
show
Bug introduced by
There is no parameter named $moduleDirname. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
106
    *  
107
    *  @return string
108
    */
109
    public function getUserBreadcrumbs($language, $tableName = 'index', $t = '')
110
    {
111
        $stuTableName = strtoupper($tableName);
112
        $title = array("'title'" => "{$language}{$stuTableName}");
113
        $pCodeBreadcrumbs = TDMCreatePhpCode::getInstance();
114
115
        return $pCodeBreadcrumbs->getPhpCodeArray('xoBreadcrumbs[]', $title, false, $t);
116
    }
117
118
    /*
119
    *  @public function getUserBreadcrumbs
120
    *  @param string $moduleDirname
121
    *  
122
    *  @return string
123
    */
124
    public function getUserBreadcrumbsHeaderFile($moduleDirname)
125
    {
126
        $pCodeHeaderFile = TDMCreatePhpCode::getInstance();
127
        $xCodeHeaderFile = TDMCreateXoopsCode::getInstance();
128
        $stuModuleDirname = strtoupper($moduleDirname);
129
        $ret = $pCodeHeaderFile->getPhpCodeCommentLine('Breadcrumbs');
130
        $ret .= $pCodeHeaderFile->getPhpCodeArray('xoBreadcrumbs', null, false, '');
131
        $getVar = $xCodeHeaderFile->getXcGetVar('', "GLOBALS['xoopsModule']", 'name', true);
132
        $titleLink = array("'title'" => $getVar, "'link'" => "{$stuModuleDirname}_URL . '/'");
133
        $ret .= $pCodeHeaderFile->getPhpCodeArray('xoBreadcrumbs[]', $titleLink, false, '');
134
135
        return $ret;
136
    }
137
138
    /*
139
    *  @public function getUserBreadcrumbs
140
    *  @param null
141
    *  
142
    *  @return string
143
    */
144
    public function getUserBreadcrumbsFooterFile()
145
    {
146
        $pCodeFooterFile = TDMCreatePhpCode::getInstance();
147
        $xCodeFooterFile = TDMCreateXoopsCode::getInstance();
148
        $cond = $xCodeFooterFile->getXcTplAssign('xoBreadcrumbs', '$xoBreadcrumbs');
149
        $ret = $pCodeFooterFile->getPhpCodeConditions('count($xoBreadcrumbs)', ' > ', '1', $cond, false, "\t\t");
150
151
        return $ret;
152
    }
153
154
    /*
155
    *  @public function getUserModVersion
156
    *  @param $eleArray
157
    *  @param $descriptions    
158
    *  @param $name
159
    *  @param $index	
160
    *  @param $num	
161
    *  
162
    *  @return string
163
    */
164
    public function getUserModVersion($eleArray = 1, $descriptions, $name = null, $index = null, $num = false, $t = '')
165
    {
166
        $ret = '';
167
        $mv = $t.'$modversion';
168
        if (!is_array($descriptions)) {
169
            $descs = array($descriptions);
170
        } else {
171
            $descs = $descriptions;
172
        }
173
        foreach ($descs as $key => $desc) {
174
            $one = ($name === null) ? $key : $name;
175
            $two = ($index === null) ? $key : $index;
176
            if ($eleArray === 1) {
177
                $ret .= $mv."['{$one}'] = {$desc};\n";
178
            } elseif ($eleArray === 2) {
179
                $ret .= $mv."['{$one}'][{$two}] = {$desc};\n";
180
            } elseif ($eleArray === 3) {
181
                $ret .= $mv."['{$one}'][{$two}]['{$key}'] = {$desc};\n";
182
            } elseif ($eleArray === 4) {
183
                $ret .= $mv."['{$one}'][{$two}][{$num}]['{$key}'] = {$desc};\n";
184
            }
185
        }
186
187
        return $ret;
188
    }
189
}
190