Passed
Branch timgno (61fada)
by Gino
05:14
created

getTemplateUserHeaderFacebbokSDK()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 5

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 16
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 29 and the first side effect is on line 24.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
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: TemplatesUserHeader.php 12258 2014-01-02 09:33:29Z timgno $
23
 */
24
defined('XOOPS_ROOT_PATH') || die('Restricted access');
25
26
/**
27
 * Class TemplatesUserHeader.
28
 */
29
class TemplatesUserHeader extends TDMCreateHtmlSmartyCodes
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...
30
{
31
    /*
32
    *  @public function constructor
33
    *  @param null
34
    */
35
    /**
36
     *
37
     */
38
    public function __construct()
39
    {
40
        parent::__construct();
41
        $this->tdmcfile = TDMCreateFile::getInstance();
0 ignored issues
show
Bug introduced by
The property tdmcfile 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...
42
        $this->htmlcode = TDMCreateHtmlSmartyCodes::getInstance();
0 ignored issues
show
Documentation Bug introduced by
It seems like \TDMCreateHtmlSmartyCodes::getInstance() of type object<TDMCreateHtmlSmartyCodes> is incompatible with the declared type string of property $htmlcode.

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...
43
    }
44
45
    /*
46
    *  @static function &getInstance
47
    *  @param null
48
    */
49
    /**
50
     * @return TemplatesUserHeader
51
     */
52
    public static function &getInstance()
53
    {
54
        static $instance = false;
55
        if (!$instance) {
56
            $instance = new self();
57
        }
58
59
        return $instance;
60
    }
61
62
    /*
63
    *  @public function write
64
    *  @param string $module
65
    *  @param mixed $tables
66
    *  @param string $filename
67
    */
68
    /**
69
     * @param $module
70
     * @param $tables
71
     * @param $filename
72
     */
73
    public function write($module, $filename)
74
    {
75
        $this->setModule($module);
76
        $this->setFileName($filename);
77
    }
78
79
    /*
80
    *  @public function getTemplatesUserHeader
81
    *  @param null
82
    */
83
    /**
84
     * @return bool|string
85
     */
86
    public function getTemplatesUserHeader($moduleDirname)
87
    {
88
        $ret = $this->htmlcode->getSmartyIncludeFile($moduleDirname, 'breadcrumbs', false, true).PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getSmartyIncludeFile cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
89
        $var = $this->htmlcode->getSmartySingleVar('ads');
0 ignored issues
show
Bug introduced by
The method getSmartySingleVar cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
90
        $div = $this->htmlcode->getHtmlDiv($var, 'center').PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getHtmlDiv cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
91
        $ret .= $this->htmlcode->getSmartyConditions('ads', ' != ', '\'\'', $div).PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getSmartyConditions cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
92
93
        return $ret;
94
    }
95
96
    /*
97
     *  @public function getTemplateFooterFacebbokSDK
98
     *  @param null
99
     *
100
     * @return bool|string
101
     */
102
    public function getTemplateUserHeaderFacebbokSDK()
103
    {
104
        $ret = <<<EOT
105
	<!-- Load Facebook SDK for JavaScript -->
106
	<div id="fb-root"></div>
107
	<script>(function(d, s, id) {
108
	  var js, fjs = d.getElementsByTagName(s)[0];
109
	  if (d.getElementById(id)) return;
110
	  js = d.createElement(s); js.id = id;
111
	  js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1";
112
	  fjs.parentNode.insertBefore(js, fjs);
113
	}(document, 'script', 'facebook-jssdk'));</script>
114
EOT;
115
116
        return $ret;
117
    }
118
119
    /*
120
    *  @public function render
121
    *  @param null
122
    */
123
    /**
124
     * @return bool|string
125
     */
126
    public function render()
127
    {
128
        $module = $this->getModule();
129
        $filename = $this->getFileName();
130
        $moduleDirname = $module->getVar('mod_dirname');
131
        //$language = $this->getLanguage($moduleDirname, 'MA');
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
132
        $content = $this->getTemplatesUserHeader($moduleDirname);
133
134
        $this->tdmcfile->create($moduleDirname, 'templates', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
135
136
        return $this->tdmcfile->renderFile();
137
    }
138
}
139