Code Duplication    Length = 10-10 lines in 5 locations

admin/letter.php 1 location

@@ 117-126 (lines=10) @@
114
        $letterTpl->assign('catsubscr_id', '0');
115
116
        preg_match('/db:([0-9]*)/', $letterObj->getVar("letter_template"), $matches);
117
        if(isset($matches[1]) && ($templateObj = $xnewsletter->getHandler('template')->get((int)$matches[1]))) {
118
            // get template from database
119
            $htmlBody = $letterTpl->fetchFromData($templateObj->getVar('template_content', "n"));
120
        } else {
121
            // get template from filesystem
122
            $template_path = XOOPS_ROOT_PATH . '/modules/xnewsletter/language/' . $GLOBALS['xoopsConfig']['language'] . '/templates/';
123
            if (!is_dir($template_path)) $template_path = XOOPS_ROOT_PATH . '/modules/xnewsletter/language/english/templates/';
124
            $template = $template_path . $letterObj->getVar("letter_template") . ".tpl";
125
            $htmlBody = $letterTpl->fetch($template);
126
        }
127
        $textBody = xnewsletter_html2text($htmlBody); // new from v1.3
128
129
        echo "<h2>" . $letterObj->getVar("letter_title") . "</h2>";

include/task.inc.php 1 location

@@ 347-356 (lines=10) @@
344
                $letterTpl->assign('unsubscribe_link', XOOPS_URL . "/modules/xnewsletter/subscription.php?op=unsub&email={$recipient['address']}&actkey={$activationKey}");
345
346
                preg_match('/db:([0-9]*)/', $letterObj->getVar("letter_template"), $matches);
347
                if(isset($matches[1]) && ($templateObj = $xnewsletter->getHandler('template')->get((int)$matches[1]))) {
348
                    // get template from database
349
                    $htmlBody = $letterTpl->fetchFromData($templateObj->getVar('template_content', "n"));
350
                } else {
351
                    // get template from filesystem
352
                    $template_path = XOOPS_ROOT_PATH . '/modules/xnewsletter/language/' . $GLOBALS['xoopsConfig']['language'] . '/templates/';
353
                    if (!is_dir($template_path)) $template_path = XOOPS_ROOT_PATH . '/modules/xnewsletter/language/english/templates/';
354
                    $template = $template_path . $letterObj->getVar("letter_template") . ".tpl";
355
                    $htmlBody = $letterTpl->fetch($template);
356
                }
357
                $textBody = xnewsletter_html2text($htmlBody); // new from v1.3
358
359
                $mail->AddAddress($recipient['address'], $recipient['firstname'] . " " . $recipient['lastname']);

index.php 1 location

@@ 91-100 (lines=10) @@
88
        $letter_array = $letterObj->toArray();
89
90
        preg_match('/db:([0-9]*)/', $letterObj->getVar("letter_template"), $matches);
91
        if(isset($matches[1]) && ($templateObj = $xnewsletter->getHandler('template')->get((int)$matches[1]))) {
92
            // get template from database
93
            $htmlBody = $xoopsTpl->fetchFromData($templateObj->getVar('template_content', "n"));
94
        } else {
95
            // get template from filesystem
96
            $template_path = XOOPS_ROOT_PATH . '/modules/xnewsletter/language/' . $GLOBALS['xoopsConfig']['language'] . '/templates/';
97
            if (!is_dir($template_path)) $template_path = XOOPS_ROOT_PATH . '/modules/xnewsletter/language/english/templates/';
98
            $template = $template_path . $letterObj->getVar("letter_template") . ".tpl";
99
            $htmlBody = $xoopsTpl->fetch($template);
100
        }
101
        $textBody = xnewsletter_html2text($htmlBody); // new from v1.3
102
103
        $letter_array['letter_content_templated'] = $htmlBody;

letter.php 1 location

@@ 245-254 (lines=10) @@
242
        $letter_array = $letterObj->toArray();
243
244
        preg_match('/db:([0-9]*)/', $letterObj->getVar("letter_template"), $matches);
245
        if(isset($matches[1]) && ($templateObj = $xnewsletter->getHandler('template')->get((int)$matches[1]))) {
246
            // get template from database
247
            $htmlBody = $xoopsTpl->fetchFromData($templateObj->getVar('template_content', "n"));
248
        } else {
249
            // get template from filesystem
250
            $template_path = XOOPS_ROOT_PATH . '/modules/xnewsletter/language/' . $GLOBALS['xoopsConfig']['language'] . '/templates/';
251
            if (!is_dir($template_path)) $template_path = XOOPS_ROOT_PATH . '/modules/xnewsletter/language/english/templates/';
252
            $template = $template_path . $letterObj->getVar("letter_template") . ".tpl";
253
            $htmlBody = $xoopsTpl->fetch($template);
254
        }
255
        $textBody = xnewsletter_html2text($htmlBody); // new from v1.3
256
257
        $letter_array['letter_content_templated'] = $htmlBody;

print.php 1 location

@@ 79-88 (lines=10) @@
76
    $content .= "<div style='clear:both;'><div style='padding:10px;border:1px solid black;'>";
77
78
    preg_match('/db:([0-9]*)/', $letterObj->getVar("letter_template"), $matches);
79
    if(isset($matches[1]) && ($templateObj = $xnewsletter->getHandler('template')->get((int)$matches[1]))) {
80
        // get template from database
81
        $htmlBody = $xoopsTpl->fetchFromData($templateObj->getVar('template_content', "n"));
82
    } else {
83
        // get template from filesystem
84
        $template_path = XOOPS_ROOT_PATH . '/modules/xnewsletter/language/' . $GLOBALS['xoopsConfig']['language'] . '/templates/';
85
        if (!is_dir($template_path)) $template_path = XOOPS_ROOT_PATH . '/modules/xnewsletter/language/english/templates/';
86
        $template = $template_path . $letterObj->getVar("letter_template") . ".tpl";
87
        $htmlBody = $xoopsTpl->fetch($template);
88
    }
89
    $content .= $htmlBody;
90
    $content .=  '</div></div>\n';
91
}