Code Duplication    Length = 22-22 lines in 4 locations

admin/letter.php 1 location

@@ 86-107 (lines=22) @@
83
        $letterTpl->assign('catsubscr_id', '0');
84
85
        $templateObj = $helper->getHandler('Template')->get($letterObj->getVar('letter_templateid'));
86
        if (is_object($templateObj)) {
87
            if ( (int)$templateObj->getVar('template_type') === _XNEWSLETTER_MAILINGLIST_TPL_CUSTOM_VAL) {
88
                // get template from database
89
                $htmlBody = $letterTpl->fetchFromData($templateObj->getVar('template_content', 'n'));
90
            } else {
91
                // get template from filesystem
92
                $template_path = XOOPS_ROOT_PATH . '/modules/xnewsletter/language/' . $GLOBALS['xoopsConfig']['language'] . '/templates/';
93
                if (!is_dir($template_path)) {
94
                    $template_path = XOOPS_ROOT_PATH . '/modules/xnewsletter/language/english/templates/';
95
                }
96
                $template = $template_path . $templateObj->getVar('template_title') . '.tpl';
97
                $htmlBody = $letterTpl->fetch($template);
98
            }
99
            try {
100
                $textBody = xnewsletter_html2text($htmlBody);
101
            }
102
            catch (Html2TextException $e) {
103
                $helper->addLog($e);
104
            }
105
        } else {
106
            $htmlBody = _AM_XNEWSLETTER_TEMPLATE_ERR;
107
        }
108
109
        $preview =  "<h2>{$letterObj->getVar('letter_title')}</h2>";
110
        $preview .= "<div style='clear:both'>";

letter.php 2 locations

@@ 165-186 (lines=22) @@
162
        $letter_array = $letterObj->toArray();
163
164
        $templateObj = $helper->getHandler('Template')->get($letterObj->getVar('letter_templateid'));
165
        if (is_object($templateObj)) {
166
            if ( (int)$templateObj->getVar('template_type') === _XNEWSLETTER_MAILINGLIST_TPL_CUSTOM_VAL) {
167
                // get template from database
168
                $htmlBody = $xoopsTpl->fetchFromData($templateObj->getVar('template_content', 'n'));
169
            } else {
170
                // get template from filesystem
171
                $template_path = XOOPS_ROOT_PATH . '/modules/xnewsletter/language/' . $GLOBALS['xoopsConfig']['language'] . '/templates/';
172
                if (!is_dir($template_path)) {
173
                    $template_path = XOOPS_ROOT_PATH . '/modules/xnewsletter/language/english/templates/';
174
                }
175
                $template = $template_path . $templateObj->getVar('template_title') . '.tpl';
176
                $htmlBody = $xoopsTpl->fetch($template);
177
            }
178
            try {
179
                $textBody = xnewsletter_html2text($htmlBody);
180
            }
181
            catch (Html2TextException $e) {
182
                $helper->addLog($e);
183
            }
184
        } else {
185
            $htmlBody = _AM_XNEWSLETTER_TEMPLATE_ERR;
186
        }
187
188
        $letter_array['letter_content_templated']      = $htmlBody;
189
        $letter_array['letter_content_templated_html'] = $htmlBody;
@@ 225-246 (lines=22) @@
222
        $letter_array = $letterObj->toArray();
223
224
        $templateObj = $helper->getHandler('Template')->get($letterObj->getVar('letter_templateid'));
225
        if (is_object($templateObj)) {
226
            if ( (int)$templateObj->getVar('template_type') === _XNEWSLETTER_MAILINGLIST_TPL_CUSTOM_VAL) {
227
                // get template from database
228
                $htmlBody = $xoopsTpl->fetchFromData($templateObj->getVar('template_content', 'n'));
229
            } else {
230
                // get template from filesystem
231
                $template_path = XOOPS_ROOT_PATH . '/modules/xnewsletter/language/' . $GLOBALS['xoopsConfig']['language'] . '/templates/';
232
                if (!is_dir($template_path)) {
233
                    $template_path = XOOPS_ROOT_PATH . '/modules/xnewsletter/language/english/templates/';
234
                }
235
                $template = $template_path . $templateObj->getVar('template_title') . '.tpl';
236
                $htmlBody = $xoopsTpl->fetch($template);
237
            }
238
            try {
239
                $textBody = xnewsletter_html2text($htmlBody);
240
            }
241
            catch (Html2TextException $e) {
242
                $helper->addLog($e);
243
            }
244
        } else {
245
            $htmlBody = _AM_XNEWSLETTER_TEMPLATE_ERR;
246
        }
247
248
        $letter_array['letter_content_templated']      = $htmlBody;
249
        $letter_array['letter_content_templated_html'] = $htmlBody;

print.php 1 location

@@ 75-96 (lines=22) @@
72
    $content .= "<div style='clear:both;'><div style='padding:10px;border:1px solid black;'>";
73
74
    $templateObj = $helper->getHandler('Template')->get($letterObj->getVar('letter_templateid'));
75
    if (is_object($templateObj)) {
76
        if ( (int)$templateObj->getVar('template_type') === _XNEWSLETTER_MAILINGLIST_TPL_CUSTOM_VAL) {
77
            // get template from database
78
            $htmlBody = $xoopsTpl->fetchFromData($templateObj->getVar('template_content', 'n'));
79
        } else {
80
            // get template from filesystem
81
            $template_path = XOOPS_ROOT_PATH . '/modules/xnewsletter/language/' . $GLOBALS['xoopsConfig']['language'] . '/templates/';
82
            if (!is_dir($template_path)) {
83
                $template_path = XOOPS_ROOT_PATH . '/modules/xnewsletter/language/english/templates/';
84
            }
85
            $template = $template_path . $templateObj->getVar('template_title') . '.tpl';
86
            $htmlBody = $xoopsTpl->fetch($template);
87
        }
88
        try {
89
            $textBody = xnewsletter_html2text($htmlBody);
90
        }
91
        catch (Html2TextException $e) {
92
            $helper->addLog($e);
93
        }
94
    } else {
95
        $htmlBody = _AM_XNEWSLETTER_TEMPLATE_ERR;
96
    }
97
98
    $content .= $htmlBody;
99
    $content .= "</div></div>\n";