Completed
Pull Request — master (#126)
by Gino
03:40
created

TemplatesUserMoreFiles::renderFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 1
eloc 7
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: TemplatesUserMoreFiles.php 12258 2014-01-02 09:33:29Z timgno $
23
 */
24
25
/**
26
 * Class TemplatesUserMoreFiles.
27
 */
28
class TemplatesUserMoreFiles extends TDMCreateFile
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
    private $folder = null;
32
    //
33
    private $extension = null;
34
35
    /*
36
    *  @public function constructor
37
    *  @param null
38
    */
39
    /**
40
     *
41
     */
42
    public function __construct()
43
    {
44
        parent::__construct();
45
    }
46
47
    /*
48
    *  @static function getInstance
49
    *  @param null
50
    */
51
    /**
52
     * @return TemplatesUserMoreFiles
53
     */
54
    public static function getInstance()
55
    {
56
        static $instance = false;
57
        if (!$instance) {
58
            $instance = new self();
59
        }
60
61
        return $instance;
62
    }
63
64
    /*
65
    *  @public function write
66
    *  @param string $module
67
    *  @param string $filename
68
    */
69
    /**
70
     * @param $module
71
     * @param $filename
72
     *
73
     * @return string
74
     */
75
    public function write($module, $folder = '', $filename, $extension)
76
    {
77
        $this->setModule($module);
78
        $this->setFileName($filename);
79
        if ($folder != '') {
80
            $this->folder = 'templates/'.$folder;
81
        } else {
82
            $this->folder = 'templates';
83
        }
84
        $this->extension = $extension;
85
    }
86
87
    /*
88
    *  @private function getTemplatesUserMoreFile
89
    *  @param null
90
    */
91
    /**
92
     * @param null
93
     *
94
     * @return string
95
     */
96
    private function getTemplatesUserMoreFile()
97
    {
98
        $ret = <<<EOT
99
<div class="panel">
100
	Pleace! Enter here your template code here
101
</div>
102
EOT;
103
104
        return $ret;
105
    }
106
107
    /*
108
    *  @public function render
109
    *  @param string $filename
110
    */
111
    /**
112
     * @param $filename
113
     *
114
     * @return bool|string
115
     */
116
    public function render()
117
    {
118
        $module = $this->getModule();
119
        $filename = $this->getFileName();
120
        $moduleDirname = $module->getVar('mod_dirname');
121
        $content = $this->getTemplatesUserMoreFile();
122
        //
123
        $this->create($moduleDirname, $this->folder, $filename.'.'.$this->extension, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
124
125
        return $this->renderFile();
126
    }
127
}
128