Code Duplication    Length = 33-36 lines in 2 locations

action.blog.php 1 location

@@ 121-156 (lines=36) @@
118
    /* edit a single blog */
119
    // no break
120
    case 'edit':
121
    default:
122
        if (!empty(Request::getString('fetch', '', 'POST'))) {
123
            $blog_obj = $blogHandler->fetch(Request::getText('blog_feed', '', 'POST'));
124
            $blog_obj->setVar('blog_id', $blog_id);
125
        } else {
126
            $blog_obj = $blogHandler->get($blog_id);
127
        }
128
        $categories = Request::getArray('categories', [], 'POST');//isset($_POST['categories']) ? $_POST['categories'] : array();
129
        if (in_array('-1', $categories)) {
130
            $categories = [];
131
        }
132
        if (empty($categories) && $blog_id > 0) {
133
            $crit       = new Criteria('bc.blog_id', $blog_id);
134
            $categories = array_keys($categoryHandler->getByBlog($crit));
135
        }
136
        if (empty($categories)) {
137
            $categories = [0 => _NONE];
138
        }
139
140
        echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _EDIT . '</legend>';
141
        echo '<br>';
142
        if (empty($blog_id) && $blog_obj->getVar('blog_feed')) {
143
            $criteria  = new Criteria('blog_feed', $blog_obj->getVar('blog_feed'));
144
            $blogs_obj = $blogHandler->getList($criteria);
145
            if (count($blogs_obj) > 0) {
146
                echo "<div class=\"errorMsg\">" . planet_constant('MD_BLOGEXISTS');
147
                foreach (array_keys($blogs_obj) as $bid) {
148
                    echo "<br><a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'b' . $bid . "\" target=\"_blank\">" . $blogs_obj[$bid] . '</a>';
149
                }
150
                echo '</div>';
151
                unset($blogs_obj, $criteria);
152
            }
153
        }
154
        include XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/include/form.blog.php';
155
        echo '</fieldset>';
156
        break;
157
}
158
159
include XOOPS_ROOT_PATH . '/footer.php';

admin/admin.blog.php 1 location

@@ 210-242 (lines=33) @@
207
208
    /* edit a single blog */
209
    // no break
210
    case 'edit':
211
        if (!empty(Request::getString('fetch', '', 'POST'))) {
212
            $blog_obj = $blogHandler->fetch(Request::getString('blog_feed', '', 'POST'));
213
            $blog_obj->setVar('blog_id', $blog_id);
214
        } else {
215
            $blog_obj = $blogHandler->get($blog_id);
216
        }
217
        $categories = Request::getArray('categories', [], 'POST');
218
        if (empty($categories) && $blog_id > 0) {
219
            $crit       = new Criteria('bc.blog_id', $blog_id);
220
            $categories = array_keys($categoryHandler->getByBlog($crit));
221
        }
222
        if (empty($categories)) {
223
            $categories = [0 => _NONE];
224
        }
225
226
        echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _EDIT . '</legend>';
227
        echo '<br>';
228
        if (empty($blog_id) && $blog_obj->getVar('blog_feed')) {
229
            $criteria  = new Criteria('blog_feed', $blog_obj->getVar('blog_feed'));
230
            $blogs_obj = $blogHandler->getList($criteria);
231
            if (count($blogs_obj) > 0) {
232
                echo "<div class=\"errorMsg\">" . planet_constant('AM_BLOGEXISTS');
233
                foreach (array_keys($blogs_obj) as $bid) {
234
                    echo "<br><a href=\"" . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . URL_DELIMITER . 'b' . $bid . "\" target=\"_blank\">" . $blogs_obj[$bid] . '</a>';
235
                }
236
                echo '</div>';
237
            }
238
            unset($blogs_obj, $criteria);
239
        }
240
        include XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/include/form.blog.php';
241
        echo '</fieldset>';
242
        break;
243
244
    default:
245