Completed
Pull Request — master (#69)
by Gino
03:22
created

LanguageMailTpl::renderFile()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 32
Code Lines 8

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 32
rs 8.8571
cc 1
eloc 8
nc 1
nop 1
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: 1.91 LanguageMailTpl.php 12258 2014-01-02 09:33:29Z timgno $
23
 */
24
25
/**
26
 * Class LanguageMailTpl.
27
 */
28
class LanguageMailTpl 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
    *  @public function constructor
32
    *  @param null
33
    */
34
    /**
35
     *
36
     */
37
    public function __construct()
38
    {
39
        parent::__construct();
40
        $this->defines = LanguageDefines::getInstance();
0 ignored issues
show
Bug introduced by
The property defines does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
41
    }
42
43
    /*
44
    *  @static function &getInstance
45
    *  @param null
46
    */
47
    /**
48
     * @return LanguageMailTpl
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 $module
63
	 * @param $filename
64
	 *
65
     * @param $module
66
     */
67
    public function write($module, $filename)
68
    {
69
        $this->setModule($module);
70
		$this->setFileName($filename);
71
    }
72
73
    /*
74
    *  @public function renderFile
75
    *  @param string $filename
76
    */
77
    /**
78
     * @param $filename
79
     *
80
     * @return bool|string
81
     */
82
    public function render()
83
    {
84
        $module = $this->getModule();
85
		$filename = $this->getFileName();
86
        $moduleDirname = $module->getVar('mod_dirname');
87
        $content = <<<EOT
88
// ---------- Templates Mail Content Dummy ---------- //
89
Hello {X_UNAME},
90
91
A new story "{STORY_NAME}" has been added at {X_SITENAME}.
92
93
You can view this story here:
94
{STORY_URL}
95
96
-----------
97
98
You are receiving this message because you selected to be notified when new stories are added to our site.
99
100
If this is an error or you wish not to receive further such notifications, please update your subscriptions by visiting the link below:
101
{X_UNSUBSCRIBE_URL}
102
103
Please do not reply to this message.
104
105
-----------
106
107
{X_SITENAME} ({X_SITEURL})
108
webmaster
109
{X_ADMINMAIL}
110
EOT;
111
        $this->create($moduleDirname, 'language/english/mail_template', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
112
113
        return $this->renderFile();
114
    }
115
}
116