Code Duplication    Length = 10-10 lines in 5 locations

admin/letter.php 1 location

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

include/task.inc.php 1 location

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

index.php 1 location

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

letter.php 1 location

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

print.php 1 location

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