Code Duplication    Length = 140-140 lines in 2 locations

class/providers/shrinktheweb.php 1 location

@@ 40-179 (lines=140) @@
37
/**
38
 * Class MylinksShrinktheweb
39
 */
40
class MylinksShrinktheweb implements MylinksThumbPlugin
41
{
42
    private $image_width   = 0;
43
    private $site_url      = null;
44
    private $key           = null;
45
    private $attribution   = "<a href=\"http://www.shrinktheweb.com\" target=\"_blank\" title=\"Thumbnail Screenshots by ShrinkTheWeb\">Thumbnail Screenshots by ShrinkTheWeb</a>";
46
    private $provider_url  = 'http://images.shrinktheweb.com/xino.php';
47
    private $provider_name = 'ShrinkTheWeb';
48
49
    /**
50
     * MylinksShrinktheweb constructor.
51
     */
52
    public function __construct()
53
    {
54
    }
55
56
    /**
57
     * @return string
58
     */
59
    public function getProviderUrl()
60
    {
61
        $query_string = array(
62
            'stwembed'       => 1,
63
            'stwaccesskeyid' => $this->getProviderPrivateKey(),
64
            'stwxmax'        => $this->image_width,
65
            'stwurl'         => $this->site_url
66
        );
67
        $query        = http_build_query($query_string);
68
        $query        = empty($query) ? '' : '?' . $query;
69
        $providerUrl  = $this->provider_url . $query;
70
71
        return $providerUrl;
72
    }
73
74
    /**
75
     * @return string
76
     */
77
    public function getProviderName()
78
    {
79
        return $this->provider_name;
80
    }
81
82
    /**
83
     * @param $sz
84
     * @return mixed|void
85
     */
86
    public function setShotSize($sz)
87
    {
88
        if (isset($sz)) {
89
            if (is_array($sz) && array_key_exists('width', $sz)) {
90
                $this->image_width = (int)$sz['width'];
91
            } else {
92
                $this->image_width = (int)$sz;
93
            }
94
        }
95
    }
96
97
    /**
98
     * @return array
99
     */
100
    public function getShotSize()
101
    {
102
        return array('width' => $this->image_width, 'height' => 0);
103
    }
104
105
    /**
106
     * @param $url
107
     * @return mixed|void
108
     */
109
    public function setSiteUrl($url)
110
    {
111
        //@todo: sanitize url;
112
        $this->site_url = formatURL($url);
113
    }
114
115
    /**
116
     * @return string
117
     */
118
    public function getSiteUrl()
119
    {
120
        return urlencode($this->site_url);
121
    }
122
123
    /**
124
     * @param null $attr
125
     */
126
    public function setAttribution($attr = null)
127
    {
128
        $this->attribution = $attr;
129
    }
130
131
    /**
132
     * @param int $allowhtml
133
     * @return string
134
     */
135
    public function getAttribution($allowhtml = 0)
136
    {
137
        if ($allowhtml) {
138
            return $this->attribution;
139
        } else {
140
            $myts = MyTextSanitizer::getInstance();
141
142
            return $myts->htmlSpecialChars($this->attribution);
143
        }
144
    }
145
146
    /**
147
     * @param $key
148
     * @return mixed|void
149
     */
150
    public function setProviderPublicKey($key)
151
    {
152
        $this->key = $key;
153
    }
154
155
    /**
156
     * @return null
157
     */
158
    public function getProviderPublicKey()
159
    {
160
        return $this->key;
161
    }
162
163
    /**
164
     * @param $key
165
     * @return bool
166
     */
167
    public function setProviderPrivateKey($key)
168
    {
169
        return false;
170
    }
171
172
    /**
173
     * @return bool
174
     */
175
    public function getProviderPrivateKey()
176
    {
177
        return false;
178
    }
179
}
180

class/providers/thumbshots.php 1 location

@@ 40-179 (lines=140) @@
37
/**
38
 * Class MylinksThumbshots
39
 */
40
class MylinksThumbshots implements MylinksThumbPlugin
41
{
42
    private $image_width   = 0;
43
    private $site_url      = null;
44
    private $key           = null;
45
    private $attribution   = "<a href=\"http://www.thumbshots.com\" target=\"_blank\" title=\"Thumbnails Screenshots by Thumbshots\">Thumbnail Screenshots by Thumbshots</a>";
46
    private $provider_url  = 'http://images.thumbshots.com/image.aspx';
47
    private $provider_name = 'Thumbshots';
48
49
    /**
50
     * MylinksThumbshots constructor.
51
     */
52
    public function __construct()
53
    {
54
    }
55
56
    /**
57
     * @return string
58
     */
59
    public function getProviderUrl()
60
    {
61
        $query_string = array(
62
            'cid' => $this->getProviderPublicKey(),
63
            'v'   => 1,
64
            'w'   => $this->image_width,
65
            'url' => $this->site_url
66
        );
67
        $query        = http_build_query($query_string);
68
        $query        = empty($query) ? '' : '?' . $query;
69
        $providerUrl  = $this->provider_url . $query;
70
71
        return $providerUrl;
72
    }
73
74
    /**
75
     * @return string
76
     */
77
    public function getProviderName()
78
    {
79
        return $this->provider_name;
80
    }
81
82
    /**
83
     * @param $sz
84
     * @return mixed|void
85
     */
86
    public function setShotSize($sz)
87
    {
88
        if (isset($sz)) {
89
            if (is_array($sz) && array_key_exists('width', $sz)) {
90
                $this->image_width = (int)$sz['width'];
91
            } else {
92
                $this->image_width = (int)$sz;
93
            }
94
        }
95
    }
96
97
    /**
98
     * @return array
99
     */
100
    public function getShotSize()
101
    {
102
        return array('width' => $this->image_width, 'height' => 0);
103
    }
104
105
    /**
106
     * @param $url
107
     * @return mixed|void
108
     */
109
    public function setSiteUrl($url)
110
    {
111
        //@todo: sanitize url;
112
        $this->site_url = formatURL($url);
113
    }
114
115
    /**
116
     * @return string
117
     */
118
    public function getSiteUrl()
119
    {
120
        return urlencode($this->site_url);
121
    }
122
123
    /**
124
     * @param null $attr
125
     */
126
    public function setAttribution($attr = null)
127
    {
128
        $this->attribution = $attr;
129
    }
130
131
    /**
132
     * @param int $allowhtml
133
     * @return string
134
     */
135
    public function getAttribution($allowhtml = 0)
136
    {
137
        if ($allowhtml) {
138
            return $this->attribution;
139
        } else {
140
            $myts = MyTextSanitizer::getInstance();
141
142
            return $myts->htmlSpecialChars($this->attribution);
143
        }
144
    }
145
146
    /**
147
     * @param $key
148
     * @return mixed|void
149
     */
150
    public function setProviderPublicKey($key)
151
    {
152
        $this->key = $key;
153
    }
154
155
    /**
156
     * @return null
157
     */
158
    public function getProviderPublicKey()
159
    {
160
        return $this->key;
161
    }
162
163
    /**
164
     * @param $key
165
     * @return bool
166
     */
167
    public function setProviderPrivateKey($key)
168
    {
169
        return false;
170
    }
171
172
    /**
173
     * @return bool
174
     */
175
    public function getProviderPrivateKey()
176
    {
177
        return false;
178
    }
179
}
180