JsJquery::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php namespace XoopsModules\Tdmcreate\Files\Assets\Js;
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: JsJquery.php 12258 2014-01-02 09:33:29Z timgno $
26
 */
27
defined('XOOPS_ROOT_PATH') || exit('Restricted access');
28
29
/**
30
 * Class JsJquery.
31
 */
32
class JsJquery extends Files\CreateFile
33
{
34
    /**
35
    *  @public function constructor
36
    *  @param null
37
    */
38
39
    public function __construct()
40
    {
41
        parent::__construct();
42
        $this->tdmcfile = Files\CreateFile::getInstance();
0 ignored issues
show
Bug Best Practice introduced by
The property tdmcfile does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
43
    }
44
45
    /**
46
    *  @static function getInstance
47
    *  @param null
48
     * @return JsJquery
49
     */
50
    public static function getInstance()
51
    {
52
        static $instance = false;
53
        if (!$instance) {
54
            $instance = new self();
55
        }
56
57
        return $instance;
58
    }
59
60
    /**
61
    *  @public function write
62
    *  @param string $module
63
    *  @param string $filename
64
     */
65
    public function write($module, $filename)
66
    {
67
        $this->setModule($module);
68
        $this->setFileName($filename);
69
    }
70
71
    /**
72
    *  @public function render
73
    *  @param null
74
     * @return bool|string
75
     */
76
    public function render()
77
    {
78
        $module = $this->getModule();
79
        $filename = $this->getFileName();
80
        $moduleDirname = $module->getVar('mod_dirname');
81
        $content = $this->getHeaderFilesComments($module, $filename, 0);
82
        $content .= <<<'EOT'
83
$(document).ready(function(){
84
    $( "button, input:button, input:submit, input:file, input:reset" ).css("color","inherit").button();
85
    $( ".check" ).css("color","#fff").button();
86
    $( ".radio" ).css("color","#fff").buttonset();
87
    $( ".toolbar" ).css("color","#000").buttonset();
88
});
89
EOT;
90
91
        $this->tdmcfile->create($moduleDirname, 'assets/js', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
92
93
        return $this->tdmcfile->renderFile();
94
    }
95
}
96