1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275:
<?php
function template_control_richedit($editor_id, $smileyContainer = null, $bbcContainer = null)
{
global $context, $settings, $modSettings, $smcFunc;
$editor_context = &$context['controls']['richedit'][$editor_id];
if ($smileyContainer === null)
$editor_context['sce_options']['emoticonsEnabled'] = false;
if ($bbcContainer === null)
$editor_context['sce_options']['toolbar'] = '';
echo '
<textarea class="editor" name="', $editor_id, '" id="', $editor_id, '" cols="600" onselect="storeCaret(this);" onclick="storeCaret(this);" onkeyup="storeCaret(this);" onchange="storeCaret(this);" tabindex="', $context['tabindex']++, '" style="width: ', $editor_context['width'], '; height: ', $editor_context['height'], ';', isset($context['post_error']['no_message']) || isset($context['post_error']['long_message']) ? 'border: 1px solid red;' : '', '"', !empty($context['editor']['required']) ? ' required' : '', '>', $editor_context['value'], '</textarea>
<div id="', $editor_id, '_resizer" class="richedit_resize"></div>
<input type="hidden" name="', $editor_id, '_mode" id="', $editor_id, '_mode" value="0">
<script>
$(document).ready(function() {
', !empty($context['bbcodes_handlers']) ? $context['bbcodes_handlers'] : '', '
var textarea = $("#', $editor_id, '").get(0);
sceditor.create(textarea, ', $smcFunc['json_encode']($editor_context['sce_options'], JSON_PRETTY_PRINT), ');';
if ($editor_context['sce_options']['emoticonsEnabled'])
echo '
sceditor.instance(textarea).createPermanentDropDown();';
if (empty($editor_context['rich_active']))
echo '
sceditor.instance(textarea).toggleSourceMode();';
if (isset($context['post_error']['no_message']) || isset($context['post_error']['long_message']))
echo '
$(".sceditor-container").find("textarea").each(function() {$(this).css({border: "1px solid red"})});
$(".sceditor-container").find("iframe").each(function() {$(this).css({border: "1px solid red"})});';
echo '
});';
echo '
var oEditorHandle_', $editor_id, ' = new smc_Editor({
sUniqueId: ', JavaScriptEscape($editor_id), ',
sEditWidth: ', JavaScriptEscape($editor_context['width']), ',
sEditHeight: ', JavaScriptEscape($editor_context['height']), ',
bRichEditOff: ', empty($modSettings['disable_wysiwyg']) ? 'false' : 'true', ',
oSmileyBox: null,
oBBCBox: null
});
smf_editorArray[smf_editorArray.length] = oEditorHandle_', $editor_id, ';
</script>';
}
function template_control_richedit_buttons($editor_id)
{
global $context, $settings, $txt, $modSettings;
$editor_context = &$context['controls']['richedit'][$editor_id];
echo '
<span class="smalltext">
', $context['shortcuts_text'], '
</span>
<span class="post_button_container">';
$tempTab = $context['tabindex'];
if (!empty($context['drafts_pm_save']))
$tempTab++;
elseif (!empty($context['drafts_save']))
$tempTab++;
elseif ($editor_context['preview_type'])
$tempTab++;
elseif ($context['show_spellchecking'])
$tempTab++;
$tempTab++;
$context['tabindex'] = $tempTab;
foreach ($context['richedit_buttons'] as $name => $button) {
if ($name == 'spell_check') {
$button['onclick'] = 'oEditorHandle_' . $editor_id . '.spellCheckStart();';
}
if ($name == 'preview') {
$button['value'] = isset($editor_context['labels']['preview_button']) ? $editor_context['labels']['preview_button'] : $button['value'];
$button['onclick'] = $editor_context['preview_type'] == 2 ? '' : 'return submitThisOnce(this);';
$button['show'] = $editor_context['preview_type'];
}
if ($button['show']) {
echo '
<input type="', $button['type'], '"', $button['type'] == 'hidden' ? ' id="' . $name . '"' : '', ' name="', $name, '" value="', $button['value'], '"', $button['type'] != 'hidden' ? ' tabindex="' . --$tempTab . '"' : '', !empty($button['onclick']) ? ' onclick="' . $button['onclick'] . '"' : '', !empty($button['accessKey']) ? ' accesskey="' . $button['accessKey'] . '"' : '', $button['type'] != 'hidden' ? ' class="button"' : '', '>';
}
}
echo '
<input type="submit" value="', isset($editor_context['labels']['post_button']) ? $editor_context['labels']['post_button'] : $txt['post'], '" name="post" tabindex="', --$tempTab, '" onclick="return submitThisOnce(this);" accesskey="s" class="button">
</span>';
if (!empty($context['drafts_pm_save']) && !empty($context['drafts_autosave']))
echo '
<span class="righttext padding" style="display: block">
<span id="throbber" style="display:none"><img src="' . $settings['images_url'] . '/loading_sm.gif" alt="" class="centericon"></span>
<span id="draft_lastautosave" ></span>
</span>
<script src="', $settings['default_theme_url'], '/scripts/drafts.js', $context['browser_cache'], '"></script>
<script>
var oDraftAutoSave = new smf_DraftAutoSave({
sSelf: \'oDraftAutoSave\',
sLastNote: \'draft_lastautosave\',
sLastID: \'id_pm_draft\',
sSceditorID: \'', $editor_id, '\',
sType: \'post\',
bPM: true,
iBoard: 0,
iFreq: ', (empty($modSettings['drafts_autosave_frequency']) ? 60000 : $modSettings['drafts_autosave_frequency'] * 1000), '
});
</script>';
if (!empty($context['drafts_save']) && !empty($context['drafts_autosave']))
echo '
<span class="righttext padding" style="display: block">
<span id="throbber" style="display:none"><img src="', $settings['images_url'], '/loading_sm.gif" alt="" class="centericon"></span>
<span id="draft_lastautosave" ></span>
</span>
<script src="', $settings['default_theme_url'], '/scripts/drafts.js', $context['browser_cache'], '"></script>
<script>
var oDraftAutoSave = new smf_DraftAutoSave({
sSelf: \'oDraftAutoSave\',
sLastNote: \'draft_lastautosave\',
sLastID: \'id_draft\',
sSceditorID: \'', $editor_id, '\',
sType: \'post\',
iBoard: ', (empty($context['current_board']) ? 0 : $context['current_board']), ',
iFreq: ', $context['drafts_autosave_frequency'], '
});
</script>';
}
function template_control_verification($verify_id, $display_type = 'all', $reset = false)
{
global $context, $txt;
$verify_context = &$context['controls']['verification'][$verify_id];
if (empty($verify_context['tracking']) || $reset)
$verify_context['tracking'] = 0;
$total_items = count($verify_context['questions']) + ($verify_context['show_visual'] || $verify_context['can_recaptcha'] ? 1 : 0);
if ($verify_context['tracking'] > $total_items)
return false;
for ($i = 0; $i < $total_items; $i++)
{
if ($display_type == 'single' && $verify_context['tracking'] != $i)
continue;
if ($display_type != 'single')
echo '
<div id="verification_control_', $i, '" class="verification_control">';
if ($verify_context['empty_field'] && empty($i))
echo '
<div class="smalltext vv_special">
', $txt['visual_verification_hidden'], ':
<input type="text" name="', $_SESSION[$verify_id . '_vv']['empty_field'], '" autocomplete="off" size="30" value="">
</div>';
if ($i == 0 && ($verify_context['show_visual'] || $verify_context['can_recaptcha']))
{
if ($verify_context['show_visual'])
{
if ($context['use_graphic_library'])
echo '
<img src="', $verify_context['image_href'], '" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '">';
else
echo '
<img src="', $verify_context['image_href'], ';letter=1" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_1">
<img src="', $verify_context['image_href'], ';letter=2" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_2">
<img src="', $verify_context['image_href'], ';letter=3" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_3">
<img src="', $verify_context['image_href'], ';letter=4" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_4">
<img src="', $verify_context['image_href'], ';letter=5" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_5">
<img src="', $verify_context['image_href'], ';letter=6" alt="', $txt['visual_verification_description'], '" id="verification_image_', $verify_id, '_6">';
echo '
<div class="smalltext" style="margin: 4px 0 8px 0;">
<a href="', $verify_context['image_href'], ';sound" id="visual_verification_', $verify_id, '_sound" rel="nofollow">', $txt['visual_verification_sound'], '</a> / <a href="#visual_verification_', $verify_id, '_refresh" id="visual_verification_', $verify_id, '_refresh">', $txt['visual_verification_request_new'], '</a>', $display_type != 'quick_reply' ? '<br>' : '', '<br>
', $txt['visual_verification_description'], ':', $display_type != 'quick_reply' ? '<br>' : '', '
<input type="text" name="', $verify_id, '_vv[code]" value="" size="30" tabindex="', $context['tabindex']++, '" autocomplete="off" required>
</div>';
}
if ($verify_context['can_recaptcha'])
{
$lang = (isset($txt['lang_recaptcha']) ? $txt['lang_recaptcha'] : $txt['lang_dictionary']);
echo '
<div class="g-recaptcha centertext" data-sitekey="' . $verify_context['recaptcha_site_key'] . '" data-theme="' . $verify_context['recaptcha_theme'] . '"></div>
<br>
<script type="text/javascript" src="https://www.google.com/recaptcha/api.js?hl=' . $lang . '"></script>';
}
}
else
{
$qIndex = $verify_context['show_visual'] || $verify_context['can_recaptcha'] ? $i - 1 : $i;
if (isset($verify_context['questions'][$qIndex]))
echo '
<div class="smalltext">
', $verify_context['questions'][$qIndex]['q'], ':<br>
<input type="text" name="', $verify_id, '_vv[q][', $verify_context['questions'][$qIndex]['id'], ']" size="30" value="', $verify_context['questions'][$qIndex]['a'], '" ', $verify_context['questions'][$qIndex]['is_error'] ? 'style="border: 1px red solid;"' : '', ' tabindex="', $context['tabindex']++, '" required>
</div>';
}
if ($display_type != 'single')
echo '
</div><!-- #verification_control_[i] -->';
if ($display_type == 'single' && $verify_context['tracking'] == $i)
break;
}
$verify_context['tracking']++;
if ($display_type == 'single')
return true;
}
?>