Code Duplication    Length = 12-13 lines in 6 locations

admin/letter.php 1 location

@@ 79-90 (lines=12) @@
76
        $letterTpl->assign('catsubscr_id', '0');
77
78
        preg_match('/db:([0-9]*)/', $letterObj->getVar('letter_template'), $matches);
79
        if (isset($matches[1]) && ($templateObj = $helper->getHandler('Template')->get((int)$matches[1]))) {
80
            // get template from database
81
            $htmlBody = $letterTpl->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)) {
86
                $template_path = XOOPS_ROOT_PATH . '/modules/xnewsletter/language/english/templates/';
87
            }
88
            $template = $template_path . $letterObj->getVar('letter_template') . '.tpl';
89
            $htmlBody = $letterTpl->fetch($template);
90
        }
91
    try {
92
        $textBody = xnewsletter_html2text($htmlBody);
93
    }

include/functions.php 1 location

@@ 555-566 (lines=12) @@
552
    $letterTpl->assign('unsubscribe_url', 'Test'); // new from v1.3
553
554
    preg_match('/db:([0-9]*)/', $letterObj->getVar('letter_template'), $matches);
555
    if (isset($matches[1]) && ($templateObj = $helper->getHandler('Template')->get((int)$matches[1]))) {
556
        // get template from database
557
        $htmlBody = $letterTpl->fetchFromData($templateObj->getVar('template_content', 'n'));
558
    } else {
559
        // get template from filesystem
560
        $template_path = XOOPS_ROOT_PATH . '/modules/xnewsletter/language/' . $GLOBALS['xoopsConfig']['language'] . '/templates/';
561
        if (!is_dir($template_path)) {
562
            $template_path = XOOPS_ROOT_PATH . '/modules/xnewsletter/language/english/templates/';
563
        }
564
        $template = $template_path . $letterObj->getVar('letter_template') . '.tpl';
565
        $htmlBody = $letterTpl->fetch($template);
566
    }
567
    $textBody = xnewsletter_html2text($htmlBody); // new from v1.3
568
    //$textBody = mb_convert_encoding($textBody, 'ISO-8859-1', _CHARSET); // "text/plain; charset=us-ascii" [http://www.w3.org/Protocols/rfc1341/7_1_Text.html]
569

include/task.inc.php 1 location

@@ 380-392 (lines=13) @@
377
                $letterTpl->assign('unsubscribe_url', XOOPS_URL . "/modules/xnewsletter/subscription.php?op=unsub&email={$recipient['address']}&actkey={$activationKey}"); // new from v1.3
378
379
                preg_match('/db:([0-9]*)/', $letterObj->getVar('letter_template'), $matches);
380
                if (isset($matches[1])
381
                    && ($templateObj = $helper->getHandler('Template')->get((int)$matches[1]))) {
382
                    // get template from database
383
                    $htmlBody = $letterTpl->fetchFromData($templateObj->getVar('template_content', 'n'));
384
                } else {
385
                    // get template from filesystem
386
                    $template_path = XOOPS_ROOT_PATH . '/modules/xnewsletter/language/' . $GLOBALS['xoopsConfig']['language'] . '/templates/';
387
                    if (!is_dir($template_path)) {
388
                        $template_path = XOOPS_ROOT_PATH . '/modules/xnewsletter/language/english/templates/';
389
                    }
390
                    $template = $template_path . $letterObj->getVar('letter_template') . '.tpl';
391
                    $htmlBody = $letterTpl->fetch($template);
392
                }
393
                $textBody = xnewsletter_html2text($htmlBody); // new from v1.3
394
                //$textBody = mb_convert_encoding($textBody, 'ISO-8859-1', _CHARSET); // "text/plain; charset=us-ascii" [http://www.w3.org/Protocols/rfc1341/7_1_Text.html]
395

letter.php 2 locations

@@ 162-173 (lines=12) @@
159
        $letter_array = $letterObj->toArray();
160
161
        preg_match('/db:([0-9]*)/', $letterObj->getVar('letter_template'), $matches);
162
        if (isset($matches[1]) && ($templateObj = $helper->getHandler('Template')->get((int)$matches[1]))) {
163
            // get template from database
164
            $htmlBody = $xoopsTpl->fetchFromData($templateObj->getVar('template_content', 'n'));
165
        } else {
166
            // get template from filesystem
167
            $template_path = XOOPS_ROOT_PATH . '/modules/xnewsletter/language/' . $GLOBALS['xoopsConfig']['language'] . '/templates/';
168
            if (!is_dir($template_path)) {
169
                $template_path = XOOPS_ROOT_PATH . '/modules/xnewsletter/language/english/templates/';
170
            }
171
            $template = $template_path . $letterObj->getVar('letter_template') . '.tpl';
172
            $htmlBody = $xoopsTpl->fetch($template);
173
        }
174
    try {
175
        $textBody = xnewsletter_html2text($htmlBody);
176
    }
@@ 217-228 (lines=12) @@
214
        $letter_array = $letterObj->toArray();
215
216
        preg_match('/db:([0-9]*)/', $letterObj->getVar('letter_template'), $matches);
217
        if (isset($matches[1]) && ($templateObj = $helper->getHandler('Template')->get((int)$matches[1]))) {
218
            // get template from database
219
            $htmlBody = $xoopsTpl->fetchFromData($templateObj->getVar('template_content', 'n'));
220
        } else {
221
            // get template from filesystem
222
            $template_path = XOOPS_ROOT_PATH . '/modules/xnewsletter/language/' . $GLOBALS['xoopsConfig']['language'] . '/templates/';
223
            if (!is_dir($template_path)) {
224
                $template_path = XOOPS_ROOT_PATH . '/modules/xnewsletter/language/english/templates/';
225
            }
226
            $template = $template_path . $letterObj->getVar('letter_template') . '.tpl';
227
            $htmlBody = $xoopsTpl->fetch($template);
228
        }
229
        try {
230
            $textBody = xnewsletter_html2text($htmlBody);
231
        }

print.php 1 location

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