Admin Side Installation:
Open admin/includes/functions/html_output.php and add this new function at bottom of file, before the closing "?>" tag:
//// // Output a TinyMCE textarea field function tep_draw_textarea_tinymce($name, $wrap='', $width='', $height='', $text = '', $parameters = '', $reinsert_value = true) { global $HTTP_GET_VARS, $HTTP_POST_VARS; $field = '<textarea class="htmleditor" name="' . tep_output_string($name) . '" cols="' . tep_output_string($width) . '" rows="' . tep_output_string($height) . '"'; if (tep_not_null($parameters)) $field .= ' ' . $parameters; $field .= '>'; if ( ($reinsert_value == true) && ( (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) || (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) ) ) { if (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) { $field .= tep_output_string_protected(stripslashes($HTTP_GET_VARS[$name])); } elseif (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) { $field .= tep_output_string_protected(stripslashes($HTTP_POST_VARS[$name])); } } elseif (tep_not_null($text)) { $field .= tep_output_string_protected($text); } $field .= '</textarea>'; return $field; }
Open admin/includes/template_top.php and add the TinyMCE scripts before the closing "</head>" tag:
<script src="//tinymce.cachefly.net/4.0/tinymce.min.js"></script> <?php if ( (strpos($_SERVER['PHP_SELF'],'categories.php')) || (strpos($_SERVER['PHP_SELF'],'banner_manager.php')) ) { ?> <script> tinymce.init({ selector:'.htmleditor', plugins: [ "advlist autolink lists link image anchor", "searchreplace visualblocks code ", "media table contextmenu paste wordcount" ], relative_urls: false, convert_urls: false, remove_script_host : false, keep_styles: false, element_format : "html", browser_spellcheck : true, style_formats: [ {title: 'H2', block: 'h2'}, {title: 'H3', block: 'h3'}, {title: 'H4', block: 'h4'}, {title: 'H5', block: 'h5'}, {title: 'H6', block: 'h6'}, ], toolbar : "undo redo | styleselect | bold italic underline | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | anchor link image media" }); </script> <?php } ?>Same File If using for orders, mail or newsletter, then also add this before closing "</head>" tag:
<?php if ( (strpos($_SERVER['PHP_SELF'],'newsletters.php')) || (strpos($_SERVER['PHP_SELF'],'mail.php')) || (strpos($_SERVER['PHP_SELF'],'orders.php')) ) { ?> <script> tinymce.init({ selector:'.htmleditor', plugins: [ "advlist autolink lists link contextmenu paste wordcount" ], menubar : false, relative_urls: false, convert_urls: false, remove_script_host : false, keep_styles: false, element_format : "html", browser_spellcheck : true, toolbar : "undo redo | bold italic underline | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link" }); </script> <?php } ?>
In the below files that you wish to use TinyMCE with:
- admin/banner_manager.php;
- admin/categories.php;
- admin/newsletters.php;
- admin/mail.php;
- admin/orders.php
tep_draw_textarea_field
Replace with:
tep_draw_textarea_tinymce
For Example using the banner_manager.php code
tep_draw_textarea_tinymce('banners_html_text', 'soft', '60', '5', $bInfo->banners_html_text);
'5' is the 4th argument, increase the value to add more height.
If using for orders, then admin/orders.php find:
nl2br(tep_db_output($orders_history['comments']))Replace with:
nl2br(stripslashes($orders_history['comments']))
Admin Uninstall
Undo the above steps, or change:
tep_draw_textarea_tinymceBack to:
tep_draw_textarea_fieldThen undo or comment out the changes to admin/includes/template_top.php
Catalog Side Installation:
If using for orders, then in catalog/account_history_info.php find:
(empty($statuses['comments']) ? ' ' : nl2br(tep_output_string_protected($statuses['comments'])))Replace with:
(empty($statuses['comments']) ? ' ' : stripslashes(nl2br($statuses['comments'])))
Only if BBCode review's text input is desired
Open catalog/includes/functions/html_output.php and add this new function at bottom of file, before the closing "?>" tag:
////
// bbcode for reviews
function osc_sanitize_reviews_string($string) {
$tags = 'b|i|u';
while (preg_match_all('`\[('.$tags.')=?(.*?)\](.+?)\[/\1\]`', $string, $matches)) foreach ($matches[0] as $key => $match) {
list($tag, $param, $innertext) = array($matches[1][$key], $matches[2][$key], $matches[3][$key]);
switch ($tag) {
case 'b': $replacement = "<strong>$innertext</strong>"; break;
case 'i': $replacement = "<em>$innertext</em>"; break;
case 'u': $replacement = "<u>$innertext</u>"; break;
break;
}
$string = str_replace($match, $replacement, $string);
}
return $string;
}
Open catalog/includes/template_top.php and add the TinyMCE scripts before the closing "</head>" tag:
<?php
if (strpos($_SERVER['PHP_SELF'],'product_reviews_write.php')) {
?>
<script src="//tinymce.cachefly.net/4.0/tinymce.min.js"></script>
<script>
tinymce.init({
selector:'textarea',
plugins: [ "bbcode wordcount"],
menubar : false,
browser_spellcheck : true,
element_format : "html",
object_resizing : false,
keep_styles: false,
toolbar : "undo redo | bold italic underline",
});
</script>
<?php
}
?>
In the below files:
- catalog/reviews.php;
- catalog/product_reviews.php;
- catalog/product_reviews_info.php;
tep_break_stringReplace with:
osc_sanitize_reviews_string
Catalog Uninstall
Undo the above steps, or to simply disable TinyMCE, comment out the changes to catalog/includes/templatetop.php: