Completed
Push — master ( 88111b...b3fce7 )
by Michael
05:58
created

AddTo   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 65
rs 10
c 0
b 0
f 0
wmc 8
lcom 1
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 14 5
A render() 0 17 2
A renderForBlock() 0 13 1
1
<?php namespace XoopsModules\Smartobject;
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
/**
14
 * @copyright    XOOPS Project https://xoops.org/
15
 * @license      GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
16
 * @package
17
 * @since
18
 * @author     XOOPS Development Team
19
 */
20
21
use XoopsModules\Smartobject;
22
23
24
/**
25
 * SmartAddTo class to easily add content to social networking/bookmarking site
26
 *
27
 * @credit http://addtobookmarks.com/, James Morris and the XoopsInfo team
28
 */
29
30
// defined('XOOPS_ROOT_PATH') || die('Restricted access');
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% 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...
31
32
class AddTo
33
{
34
    public $_layout;
35
    public $_method;
36
37
    /**
38
     * Constructor of SmartAddTo
39
     *
40
     * @param int $layout 0=Horizontal 1 row, 1=Horizontal 2 rows, 2=Vertical with icons, 3=Vertical no icons
41
     * @param int $method 0=directpage, 1=popup
42
     */
43
    public function __construct($layout = 0, $method = 1)
44
    {
45
        $layout = (int)$layout;
46
        if ($layout < 0 || $layout > 3) {
47
            $layout = 0;
48
        }
49
        $this->_layout = $layout;
50
51
        $method = (int)$method;
52
        if ($method < 0 || $method > 1) {
53
            $method = 1;
54
        }
55
        $this->_method = $method;
56
    }
57
58
    /**
59
     * @param  bool $fetchOnly
60
     * @return mixed|string|void
61
     */
62
    public function render($fetchOnly = false)
63
    {
64
        global $xoTheme, $xoopsTpl;
65
66
        $xoTheme->addStylesheet(SMARTOBJECT_URL . 'include/addto/addto.css');
67
68
        $xoopsTpl->assign('smartobject_addto_method', $this->_method);
69
        $xoopsTpl->assign('smartobject_addto_layout', $this->_layout);
70
71
        $xoopsTpl->assign('smartobject_addto_url', SMARTOBJECT_URL . 'include/addto/');
72
73
        if ($fetchOnly) {
74
            return $xoopsTpl->fetch('db:smartobject_addto.tpl');
75
        } else {
76
            $xoopsTpl->display('db:smartobject_addto.tpl');
77
        }
78
    }
79
80
    /**
81
     * @return array
82
     */
83
    public function renderForBlock()
84
    {
85
        global $xoTheme;
86
87
        $xoTheme->addStylesheet(SMARTOBJECT_URL . 'include/addto/addto.css');
88
89
        $block                             = [];
90
        $block['smartobject_addto_method'] = $this->_method;
91
        $block['smartobject_addto_layout'] = $this->_layout;
92
        $block['smartobject_addto_url']    = SMARTOBJECT_URL . 'include/addto/';
93
94
        return $block;
95
    }
96
}
97