Completed
Push — master ( 53ea58...16270d )
by Michael
04:51
created

latest_news.php ➔ publisher_latest_news_edit()   F

Complexity

Conditions 11
Paths 576

Size

Total Lines 144
Code Lines 114

Duplication

Lines 14
Ratio 9.72 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 11
eloc 114
c 1
b 0
f 0
nc 576
nop 1
dl 14
loc 144
rs 3.2929

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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 32 and the first side effect is on line 25.

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
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
 */
11
12
/**
13
 * @copyright       The XUUPS Project http://sourceforge.net/projects/xuups/
14
 * @license         http://www.fsf.org/copyleft/gpl.html GNU public license
15
 * @package         Publisher
16
 * @subpackage      Blocks
17
 * @since           1.0
18
 * @author          trabis <[email protected]>
19
 * @author          Bandit-x
20
 * @author          Mowaffak
21
 */
22
23
// defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');
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...
24
25
include_once dirname(__DIR__) . '/include/common.php';
26
27
/**
28
 * @param $options
29
 *
30
 * @return array
0 ignored issues
show
Documentation introduced by
Should the return type not be false|array<string,array>?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
31
 */
32
function publisher_latest_news_show($options)
0 ignored issues
show
Coding Style introduced by
publisher_latest_news_show uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
33
{
34
    $block = array();
35
36
    xoops_loadLanguage('main', 'publisher');
37
    $publisher = PublisherPublisher::getInstance();
38
39
    $start           = $options[0]; // You can show articles from specified range
40
    $limit           = $options[1];
41
    $columnCount     = $options[2];
42
    $letters         = $options[3];
43
    $selectedStories = $options[4];
44
    $sort            = $options[9];
45
    $order           = publisherGetOrderBy($sort);
46
    $imgWidth        = $options[11];
47
    $imgHeight       = $options[12];
48
    $border          = $options[13];
49
    $bordercolor     = $options[14];
50
51
    $block['spec']['columnwidth'] = (int)(1 / $columnCount * 100);
52
53
    $allcats = false;
54
    if (!isset($options[29])) {
55
        $allcats = true;
56
    } elseif (in_array(0, explode(',', $options[29]))) {
57
        $allcats = true;
58
    }
59
60
    // creating the ITEM objects that belong to the selected category
61 View Code Duplication
    if ($allcats) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
62
        $criteria = null;
63
    } else {
64
        $criteria = new CriteriaCompo();
65
        $criteria->add(new Criteria('categoryid', '(' . $options[29] . ')', 'IN'));
66
    }
67
68
    // Use specific ITEMS
69
    if ($selectedStories != 0) {
70
        unset($criteria); //removes category option
71
        $criteria = new CriteriaCompo();
72
        $criteria->add(new Criteria('itemid', '(' . $selectedStories . ')', 'IN'));
73
    }
74
75
    $itemsObj = $publisher->getHandler('item')->getItems($limit, $start, array(PublisherConstants::PUBLISHER_STATUS_PUBLISHED), -1, $sort, $order, '', true, $criteria, 'itemid');
76
77
    $scount = count($itemsObj);
78
79
    if ($scount == 0) {
80
        return false;
81
    }
82
    $k       = 0;
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $k. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
83
    $columns = array();
84
85
    foreach ($itemsObj as $itemid => $itemObj) {
86
        $item            = array();
87
        $item['itemurl'] = $itemObj->getItemUrl();
88
        $item['title']   = $itemObj->getItemLink();
89
        $item['alt']     = strip_tags($itemObj->getItemLink());
90
        $mainImage       = $itemObj->getMainImage();
91
        // check to see if GD function exist
92
        if (!function_exists('imagecreatetruecolor')) {
93
            $item['item_image'] = $mainImage['image_path'];
94
        } else {
95
            $item['item_image'] = PUBLISHER_URL . '/thumb.php?src=' . $mainImage['image_path'] . '&amp;w=' . $imgWidth; // No $imgHeight for autoheight option
96
        }
97
        $item['text'] = $itemObj->getBlockSummary($letters);
98
99
        $item = $itemObj->getMainImage($item); //returns an array
100
101
        $lsHeight = '';
102
        if ($options[12] != 0) {
103
            $lsHeight = 'height="' . $imgHeight . '" ';
104
        } // set height = 0 in block option for auto height
105
106
        if ($options[15] === 'LEFT') {
107
            $imgPosition = 'float: left';
108
            $lsMargin    = '-right';
109
        }
110
111
        if ($options[15] === 'CENTER') {
112
            $imgPosition = 'text-align:center';
113
            $lsMargin    = '';
114
        }
115
116
        if ($options[15] === 'RIGHT') {
117
            $imgPosition = 'float: right';
118
            $lsMargin    = '-left';
119
        }
120
121
        //Image
122
        if ($options[10] == 1 && $item['image_path'] != '') {
123
            $startdiv = '<div style="' . $imgPosition . '"><a href="' . $item['itemurl'] . '">';
0 ignored issues
show
Bug introduced by
The variable $imgPosition does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
124
            $style    = 'style="margin' . $lsMargin . ': 10px; padding: 2px; border: ' . $border . 'px solid #' . $bordercolor . '"';
0 ignored issues
show
Bug introduced by
The variable $lsMargin does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
125
            $enddiv   = 'width="' . $imgWidth . '" ' . $lsHeight . '/></a></div>';
126
            $image    = $startdiv . '<img ' . $style . ' src="' . $item['item_image'] . '" alt="' . $item['image_name'] . '" ' . $enddiv;
127
128
            $item['image'] = $image;
129
        }
130
131
        if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isAdmin(-1)) {
132
            $item['admin'] = "<a href='" . PUBLISHER_URL . '/submit.php?itemid=' . $itemObj->itemid() . "'><img src='" . PUBLISHER_URL . "/assets/images/links/edit.gif'" . " title='" . _CO_PUBLISHER_EDIT . "' alt='" . _CO_PUBLISHER_EDIT . "' /></a>&nbsp;";
133
            $item['admin'] .= "<a href='" . PUBLISHER_URL . '/admin/item.php?op=del&amp;itemid=' . $itemObj->itemid() . "'><img src='" . PUBLISHER_URL . "/assets/images/links/delete.png'" . " title='" . _CO_PUBLISHER_DELETE . "' alt='" . _CO_PUBLISHER_DELETE . "' /></a>";
134
        } else {
135
            $item['admin'] = '';
136
        }
137
138
        $block['topiclink'] = '';
139
        /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
52% 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...
140
        if ($options[16] == 1) {
141
         $block['topiclink'] = '| <a href="'.XOOPS_URL.'/modules/news/topics_directory.php">'._AM_NEWS_TOPICS_DIRECTORY.'</a> ';
142
         }
143
         */
144
        $block['archivelink'] = '';
145 View Code Duplication
        if ($options[17] == 1) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
146
            $block['archivelink'] = '| <a href="' . PUBLISHER_URL . '/archive.php">' . _MB_PUBLISHER_ARCHIVE . '</a> ';
147
        }
148
149
        //TODO: Should we not show link to Anonymous?
150
        $block['submitlink'] = '';
151
        if ($options[18] == 1 && $GLOBALS['xoopsUser']) {
152
            $block['submitlink'] = '| <a href="' . PUBLISHER_URL . '/submit.php">' . _MB_PUBLISHER_SUBMITNEWS . '</a> ';
153
        }
154
155
        $item['poster'] = '';
156
        if ($options[19] == 1) {
157
            $item['poster'] = _MB_PUBLISHER_POSTER . ' ' . $itemObj->posterName();
158
        }
159
160
        $item['posttime'] = '';
161
        if ($options[20] == 1) {
162
            $item['posttime'] = _ON . ' ' . $itemObj->getDatesub();
163
        }
164
165
        $item['topic_title'] = '';
166
        if ($options[21] == 1) {
167
            $item['topic_title'] = $itemObj->getCategoryLink() . _MB_PUBLISHER_SP;
168
        }
169
170
        $item['read'] = '';
171
        if ($options[22] == 1) {
172
            $item['read'] = '&nbsp;(' . $itemObj->counter() . ' ' . _READS . ')';
173
        }
174
175
        $item['more'] = '';
176
        if ($itemObj->body() != '' || $itemObj->comments() > 0) {
177
            $item['more'] = '<a class="publisher_spotlight_readmore" href="' . $itemObj->getItemUrl() . '">' . _MB_PUBLISHER_READMORE . '</a>';
178
        }
179
180
        $comments = $itemObj->comments();
181
        if ($options[23] == 1) {
182
            if ($comments > 0) {
183
                //shows 1 comment instead of 1 comm. if comments ==1
184
                //langugage file modified accordingly
185
                if ($comments == 1) {
186
                    $item['comment'] = '&nbsp;' . _MB_PUBLISHER_ONECOMMENT . '&nbsp;';
187
                } else {
188
                    $item['comment'] = '&nbsp;' . $comments . '&nbsp;' . _MB_PUBLISHER_COMMENTS . '&nbsp;';
189
                }
190
            } else {
191
                $item['comment'] = '&nbsp;' . _MB_PUBLISHER_NO_COMMENTS . '&nbsp;';
192
            }
193
        }
194
195
        $item['print'] = '';
196 View Code Duplication
        if ($options[24] == 1) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
197
            $item['print'] = '<a href="' . PublisherSeo::generateUrl('print', $itemObj->itemid(), $itemObj->short_url()) . '" rel="nofollow"><img src="' . PUBLISHER_URL . '/assets/images/links/print.gif" title="' . _CO_PUBLISHER_PRINT . '" alt="' . _CO_PUBLISHER_PRINT . '" /></a>&nbsp;';
198
        }
199
200
        $item['pdf'] = '';
201 View Code Duplication
        if ($publisher->getConfig('display_pdf')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
202
            if ($options[25] == 1) {
203
                $item['pdf'] = "<a href='" . PUBLISHER_URL . '/makepdf.php?itemid=' . $itemObj->itemid() . "' rel='nofollow'><img src='" . PUBLISHER_URL . "/assets/images/links/pdf.gif' title='" . _CO_PUBLISHER_PDF . "' alt='" . _CO_PUBLISHER_PDF . "' /></a>&nbsp;";
204
            }
205
        }
206
        $item['email'] = '';
207
        if ($options[26] == 1 && xoops_isActiveModule('tellafriend')) {
208
            $subject  = sprintf(_CO_PUBLISHER_INTITEMFOUND, $GLOBALS['xoopsConfig']['sitename']);
209
            $subject  = $itemObj->convertForJapanese($subject);
210
            $maillink = publisherTellAFriend($subject);
211
212
            $item['email'] = '<a href="' . $maillink . '"><img src="' . PUBLISHER_URL . '/assets/images/links/friend.gif" title="' . _CO_PUBLISHER_MAIL . '" alt="' . _CO_PUBLISHER_MAIL . '" /></a>&nbsp;';
213
        }
214
215
        $block['morelink'] = '';
216 View Code Duplication
        if ($options[27] == 1) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
217
            $block['morelink'] = '<a href="' . PUBLISHER_URL . '/index.php">' . _MB_PUBLISHER_MORE_ITEMS . '</a> ';
218
        }
219
220
        $block['latestnews_scroll'] = false;
221
        if ($options[5] == 1) {
222
            $block['latestnews_scroll'] = true;
223
        }
224
225
        $block['scrollheight'] = $options[6];
226
        $block['scrollspeed']  = $options[7];
227
        $block['scrolldir']    = $options[8];
228
229
        $block['template'] = $options[28];
230
231
        $block['imgwidth']  = $options[11];
232
        $block['imgheight'] = $options[12];
233
234
        $block['letters'] = $letters;
235
236
        $columns[$k][] = $item;
237
        ++$k;
238
239
        if ($k == $columnCount) {
240
            $k = 0;
241
        }
242
    }
243
244
    unset($item);
245
    $block['columns'] = $columns;
246
247
    return $block;
248
}
249
250
/**
251
 * @param $options
252
 *
253
 * @return string
254
 */
255
function publisher_latest_news_edit($options)
256
{
257
    $tabletag1 = '<tr><td style="padding:3px;" width="37%">';
258
    $tabletag2 = '</td><td style="padding:3px;">';
259
    $tabletag3 = '<tr><td style="padding-top:20px;border-bottom:1px solid #000;" colspan="2">';
260
    $tabletag4 = '</td></tr>';
261
262
    $form = "<table border='0' cellpadding='0' cellspacing='0'>";
263
    $form .= $tabletag3 . _MB_PUBLISHER_GENERALCONFIG . $tabletag4; // General Options
264
    $form .= $tabletag1 . _MB_PUBLISHER_FIRST . $tabletag2;
265
    $form .= "<input type='text' name='options[]' value='" . $options[0] . "' size='4'>&nbsp;" . _MB_PUBLISHER_ITEMS . '</td></tr>';
266
    $form .= $tabletag1 . _MB_PUBLISHER_DISP . $tabletag2;
267
    $form .= "<input type='text' name='options[]' value='" . $options[1] . "' size='4'>&nbsp;" . _MB_PUBLISHER_ITEMS . '</td></tr>';
268
    $form .= $tabletag1 . _MB_PUBLISHER_COLUMNS . $tabletag2;
269
    $form .= "<input type='text' name='options[]' value='" . $options[2] . "' size='4'>&nbsp;" . _MB_PUBLISHER_COLUMN . '</td></tr>';
270
    $form .= $tabletag1 . _MB_PUBLISHER_TEXTLENGTH . $tabletag2;
271
    $form .= "<input type='text' name='options[]' value='" . $options[3] . "' size='4'>&nbsp;" . _MB_PUBLISHER_LETTER . '</td></tr>';
272
    $form .= $tabletag1 . _MB_PUBLISHER_SELECTEDSTORIES . $tabletag2;
273
    $form .= "<input type='text' name='options[]' value='" . $options[4] . "' size='16'></td></tr>";
274
    $form .= $tabletag1 . _MB_PUBLISHER_SCROLL . $tabletag2;
275
    $form .= publisher_mk_chkbox($options, 5);
276
    $form .= $tabletag1 . _MB_PUBLISHER_SCROLLHEIGHT . $tabletag2;
277
    $form .= "<input type='text' name='options[]' value='" . $options[6] . "' size='4'></td></tr>";
278
    $form .= $tabletag1 . _MB_PUBLISHER_SCROLLSPEED . $tabletag2;
279
    $form .= "<input type='text' name='options[]' value='" . $options[7] . "' size='4'></td></tr>";
280
    $form .= $tabletag1 . _MB_PUBLISHER_SCROLLDIR . $tabletag2;
281
282
    $form .= "<select size='1' name='options[8]'>";
283
284
    $directions = array('right' => _MB_PUBLISHER_SCROLL_RIGHT, 'left' => _MB_PUBLISHER_SCROLL_LEFT, 'up' => _MB_PUBLISHER_SCROLL_UP, 'down' => _MB_PUBLISHER_SCROLL_DOWN);
285 View Code Duplication
    foreach ($directions as $key => $value) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
286
        $form .= "<option value='{$key}'";
287
        if ($options[8] == $key) {
288
            $form .= " selected='selected'";
289
        }
290
        $form .= ">{$value}</option>";
291
    }
292
    $form .= '</select></td></tr>';
293
294
    $form .= $tabletag1 . _MB_PUBLISHER_ORDER . $tabletag2;
295
296
    $form .= "<select name='options[9]'>";
297
    $form .= "<option value='datesub'";
298
    if ($options[9] === 'datesub') {
299
        $form .= " selected='selected'";
300
    }
301
    $form .= '>' . _MB_PUBLISHER_DATE . '</option>';
302
303
    $form .= "<option value='counter'";
304
    if ($options[9] === 'counter') {
305
        $form .= " selected='selected'";
306
    }
307
    $form .= '>' . _MB_PUBLISHER_HITS . '</option>';
308
309
    $form .= "<option value='weight'";
310
    if ($options[9] === 'weight') {
311
        $form .= " selected='selected'";
312
    }
313
    $form .= '>' . _MB_PUBLISHER_WEIGHT . '</option>';
314
315
    $form .= '</select></td></tr>';
316
317
    $form .= $tabletag3 . _MB_PUBLISHER_PHOTOSCONFIG . $tabletag4; // Photos Options
318
    $form .= $tabletag1 . _MB_PUBLISHER_IMGDISPLAY . $tabletag2;
319
    $form .= publisher_mk_chkbox($options, 10);
320
    $form .= $tabletag1 . _MB_PUBLISHER_IMGWIDTH . $tabletag2;
321
    $form .= "<input type='text' name='options[]' value='" . $options[11] . "' size='4'>&nbsp;" . _MB_PUBLISHER_PIXEL . '</td></tr>';
322
    $form .= $tabletag1 . _MB_PUBLISHER_IMGHEIGHT . $tabletag2;
323
    $form .= "<input type='text' name='options[]' value='" . $options[12] . "' size='4'>&nbsp;" . _MB_PUBLISHER_PIXEL . '</td></tr>';
324
    $form .= $tabletag1 . _MB_PUBLISHER_BORDER . $tabletag2;
325
    $form .= "<input type='text' name='options[]' value='" . $options[13] . "' size='4'>&nbsp;" . _MB_PUBLISHER_PIXEL . '</td></tr>';
326
    $form .= $tabletag1 . _MB_PUBLISHER_BORDERCOLOR . $tabletag2;
327
    $form .= "<input type='text' name='options[]' value='" . $options[14] . "' size='8'></td></tr>";
328
    $form .= $tabletag1 . _MB_PUBLISHER_IMGPOSITION . $tabletag2;
329
    $form .= "<select name='options[]'>";
330
    $form .= "<option value='LEFT'";
331
    if ($options[15] === 'LEFT') {
332
        $form .= " selected='selected'";
333
    }
334
    $form .= '>' . _LEFT . "</option>\n";
335
336
    $form .= "<option value='CENTER'";
337
    if ($options[15] === 'CENTER') {
338
        $form .= " selected='selected'";
339
    }
340
    $form .= '>' . _CENTER . "</option>\n";
341
342
    $form .= "<option value='RIGHT'";
343
    if ($options[15] === 'RIGHT') {
344
        $form .= " selected='selected'";
345
    }
346
    $form .= '>' . _RIGHT . '</option>';
347
    $form .= '</select></td></tr>';
348
349
    $form .= $tabletag3 . _MB_PUBLISHER_LINKSCONFIG . $tabletag4; // Links Options
350
    $form .= $tabletag1 . _MB_PUBLISHER_DISPLAY_TOPICLINK . $tabletag2;
351
    $form .= publisher_mk_chkbox($options, 16);
352
    $form .= $tabletag1 . _MB_PUBLISHER_DISPLAY_ARCHIVELINK . $tabletag2;
353
    $form .= publisher_mk_chkbox($options, 17);
354
    $form .= $tabletag1 . _MB_PUBLISHER_DISPLAY_SUBMITLINK . $tabletag2;
355
    $form .= publisher_mk_chkbox($options, 18);
356
    $form .= $tabletag1 . _MB_PUBLISHER_DISPLAY_POSTEDBY . $tabletag2;
357
    $form .= publisher_mk_chkbox($options, 19);
358
    $form .= $tabletag1 . _MB_PUBLISHER_DISPLAY_POSTTIME . $tabletag2;
359
    $form .= publisher_mk_chkbox($options, 20);
360
    $form .= $tabletag1 . _MB_PUBLISHER_DISPLAY_TOPICTITLE . $tabletag2;
361
    $form .= publisher_mk_chkbox($options, 21);
362
    $form .= $tabletag1 . _MB_PUBLISHER_DISPLAY_READ . $tabletag2;
363
    $form .= publisher_mk_chkbox($options, 22);
364
    $form .= $tabletag1 . _MB_PUBLISHER_DISPLAY_COMMENT . $tabletag2;
365
    $form .= publisher_mk_chkbox($options, 23);
366
    $form .= $tabletag1 . _MB_PUBLISHER_DISPLAY_PRINT . $tabletag2;
367
    $form .= publisher_mk_chkbox($options, 24);
368
    $form .= $tabletag1 . _MB_PUBLISHER_DISPLAY_PDF . $tabletag2;
369
    $form .= publisher_mk_chkbox($options, 25);
370
    $form .= $tabletag1 . _MB_PUBLISHER_DISPLAY_EMAIL . $tabletag2;
371
    $form .= publisher_mk_chkbox($options, 26);
372
    $form .= $tabletag1 . _MB_PUBLISHER_DISPLAY_MORELINK . $tabletag2;
373
    $form .= publisher_mk_chkbox($options, 27);
374
375
    $form .= $tabletag3 . _MB_PUBLISHER_TEMPLATESCONFIG . $tabletag4; // Templates Options
376
    $form .= $tabletag1 . _MB_PUBLISHER_TEMPLATE . $tabletag2;
377
    $form .= "<select size='1' name='options[28]'>";
378
379
    $templates = array('normal' => _MB_PUBLISHER_TEMPLATE_NORMAL, 'extended' => _MB_PUBLISHER_TEMPLATE_EXTENDED, 'ticker' => _MB_PUBLISHER_TEMPLATE_TICKER, 'slider1' => _MB_PUBLISHER_TEMPLATE_SLIDER1, 'slider2' => _MB_PUBLISHER_TEMPLATE_SLIDER2);
380 View Code Duplication
    foreach ($templates as $key => $value) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
381
        $form .= "<option value='{$key}'";
382
        if ($options[28] == $key) {
383
            $form .= " selected='selected'";
384
        }
385
        $form .= ">{$value}</option>";
386
    }
387
    $form .= '</select></td></tr>';
388
389
    //Select Which Categories To Show
390
    $form .= $tabletag3 . _MB_PUBLISHER_TOPICSCONFIG . $tabletag4; // Topics Options
391
    $form .= $tabletag1 . _MB_PUBLISHER_TOPICSDISPLAY . $tabletag2;
392
    $form .= publisherCreateCategorySelect($options[29], 0, true, 'options[29]');
393
    $form .= '</td></tr>';
394
395
    $form .= '</table>';
396
397
    return $form;
398
}
399
400
/**
401
 * @param $options
402
 * @param $number
403
 *
404
 * @return string
405
 */
406
function publisher_mk_chkbox($options, $number)
407
{
408
    $chk = '';
409
    if ($options[$number] == 1) {
410
        $chk = " checked='checked'";
411
    }
412
    $chkbox = "<input type='radio' name='options[{$number}]' value='1'" . $chk . ' />&nbsp;' . _YES . '&nbsp;&nbsp;';
413
    $chk    = '';
414
    if ($options[$number] == 0) {
415
        $chk = " checked='checked'";
416
    }
417
    $chkbox .= "<input type='radio' name='options[{$number}]' value='0'" . $chk . ' />&nbsp;' . _NO . '</td></tr>';
418
419
    return $chkbox;
420
}
421
422
/**
423
 * @param $options
424
 * @param $number
425
 *
426
 * @return string
427
 */
428
function publisher_mk_select($options, $number)
429
{
430
    $slc = '';
431
    if ($options[$number] == 2) {
432
        $slc = " checked='checked'";
433
    }
434
    $select = "<input type='radio' name='options[{$number}]' value='2'" . $slc . ' />&nbsp;' . _LEFT . '&nbsp;&nbsp;';
0 ignored issues
show
Unused Code introduced by
$select is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
435
    $slc    = '';
436
    if ($options[$number] == 1) {
437
        $slc = " checked='checked'";
438
    }
439
    $select = "<input type='radio' name='options[{$number}]' value='1'" . $slc . ' />&nbsp;' . _CENTER . '&nbsp;&nbsp;';
440
    $slc    = '';
441
    if ($options[$number] == 0) {
442
        $slc = " checked='checked'";
443
    }
444
    $select .= "<input type='radio' name='options[{$number}]' value='0'" . $slc . ' />&nbsp;' . _RIGHT . '</td></tr>';
445
446
    return $select;
447
}
448