Code Duplication    Length = 11-11 lines in 5 locations

manager/processors/save_htmlsnippet.processor.php 1 location

@@ 18-28 (lines=11) @@
15
$currentdate = time() + $modx->config['server_offset_time'];
16
17
//Kyle Jaebker - added category support
18
if (empty($_POST['newcategory']) && $_POST['categoryid'] > 0) {
19
    $categoryid = (int)$_POST['categoryid'];
20
} elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) {
21
    $categoryid = 0;
22
} else {
23
    include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php');
24
    $categoryid = checkCategory($_POST['newcategory']);
25
    if (!$categoryid) {
26
        $categoryid = newCategory($_POST['newcategory']);
27
    }
28
}
29
30
if ($name == "" || $name == 'null') {
31
    $name = "Untitled chunk";

manager/processors/save_module.processor.php 1 location

@@ 27-37 (lines=11) @@
24
$currentdate = time() + $modx->config['server_offset_time'];
25
26
//Kyle Jaebker - added category support
27
if (empty($_POST['newcategory']) && $_POST['categoryid'] > 0) {
28
    $categoryid = (int)$_POST['categoryid'];
29
} elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) {
30
    $categoryid = 0;
31
} else {
32
    include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php');
33
    $categoryid = checkCategory($_POST['newcategory']);
34
    if (!$categoryid) {
35
        $categoryid = newCategory($_POST['newcategory']);
36
    }
37
}
38
39
if ($name == "") {
40
    $name = "Untitled module";

manager/processors/save_snippet.processor.php 1 location

@@ 35-45 (lines=11) @@
32
$parse_docblock = $_POST['parse_docblock'] == "1" ? '1' : '0';
33
34
//Kyle Jaebker - added category support
35
if (empty($_POST['newcategory']) && $_POST['categoryid'] > 0) {
36
    $categoryid = (int)$_POST['categoryid'];
37
} elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) {
38
    $categoryid = 0;
39
} else {
40
    include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php');
41
    $categoryid = checkCategory($_POST['newcategory']);
42
    if (!$categoryid) {
43
        $categoryid = newCategory($_POST['newcategory']);
44
    }
45
}
46
47
if ($name == "") {
48
    $name = "Untitled snippet";

manager/processors/save_template.processor.php 1 location

@@ 19-29 (lines=11) @@
16
$currentdate = time() + $modx->config['server_offset_time'];
17
18
//Kyle Jaebker - added category support
19
if (empty($_POST['newcategory']) && $_POST['categoryid'] > 0) {
20
    $categoryid = (int)$_POST['categoryid'];
21
} elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) {
22
    $categoryid = 0;
23
} else {
24
    include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php');
25
    $categoryid = checkCategory($_POST['newcategory']);
26
    if (!$categoryid) {
27
        $categoryid = newCategory($_POST['newcategory']);
28
    }
29
}
30
31
if ($templatename == "") {
32
    $templatename = "Untitled template";

manager/processors/save_tmplvars.processor.php 1 location

@@ 25-35 (lines=11) @@
22
$currentdate = time() + $modx->config['server_offset_time'];
23
24
//Kyle Jaebker - added category support
25
if (empty($_POST['newcategory']) && $_POST['categoryid'] > 0) {
26
    $categoryid = (int)$_POST['categoryid'];
27
} elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) {
28
    $categoryid = 0;
29
} else {
30
    include_once(MODX_MANAGER_PATH . 'includes/categories.inc.php');
31
    $categoryid = checkCategory($_POST['newcategory']);
32
    if (!$categoryid) {
33
        $categoryid = newCategory($_POST['newcategory']);
34
    }
35
}
36
37
$name = $name != '' ? $name : "Untitled variable";
38
$caption = $caption != '' ? $caption : $name;