Implemented 'Enable Smileys'

SVN revision: 2299
This commit is contained in:
Stefan Ritt 2010-06-08 09:30:53 +00:00
parent 63a9db1fd7
commit 8cbcc4d3c3
3 changed files with 26 additions and 2 deletions

View File

@ -316,7 +316,7 @@
> >
</File> </File>
<File <File
RelativePath="..\doc\index_d.html" RelativePath="..\doc\index_nd.html"
> >
</File> </File>
</Filter> </Filter>

View File

@ -2616,6 +2616,12 @@ Options Location = Main Building{a}, New Building{b}, Old Building{c}
possible, which is one head entry, one reply to it, then one reply to the reply possible, which is one head entry, one reply to it, then one reply to the reply
and so on. Default for this setting is <b>1</b>. and so on. Default for this setting is <b>1</b>.
</li> </li>
<li>
<b><code>Enable Smileys = 0|1</code></b><br>
When encoding an entry with ELCode, certain sequenes such as <b>:-)</b> get
automatically converted into small "smiley" images. If this behavior is not
wanted, it can be turned off with this option. The default for this setting is <b>1</b>.
</li>
</ul> </ul>
<p> <p>
<a name="themes" id="themes"></a> <a name="themes" id="themes"></a>

View File

@ -6035,7 +6035,8 @@ char
void rsputs_elcode(LOGBOOK * lbs, BOOL email_notify, const char *str) void rsputs_elcode(LOGBOOK * lbs, BOOL email_notify, const char *str)
{ {
int i, j, k, l, m, elcode_disabled, elcode_disabled1, escape_char, ordered_list, substituted, inside_table; int i, j, k, l, m, elcode_disabled, elcode_disabled1, escape_char, ordered_list, substituted, inside_table,
smileys_enabled;
char *p, *pd, link[1000], link_text[1000], tmp[1000], attrib[1000], hattrib[1000], value[1000], char *p, *pd, link[1000], link_text[1000], tmp[1000], attrib[1000], hattrib[1000], value[1000],
subst[1000], base_url[256], param[256], *lstr, domain[256]; subst[1000], base_url[256], param[256], *lstr, domain[256];
@ -6049,10 +6050,15 @@ void rsputs_elcode(LOGBOOK * lbs, BOOL email_notify, const char *str)
elcode_disabled1 = FALSE; elcode_disabled1 = FALSE;
ordered_list = FALSE; ordered_list = FALSE;
escape_char = FALSE; escape_char = FALSE;
smileys_enabled = TRUE;
inside_table = 0; inside_table = 0;
j = strlen_retbuf; j = strlen_retbuf;
m = 0; m = 0;
/* check for smileys */
if (getcfg(lbs->name, "Enable smileys", tmp, sizeof(tmp)) && atoi(tmp) == 0)
smileys_enabled = FALSE;
/* make lower case copy of str */ /* make lower case copy of str */
lstr = xmalloc(strlen(str) + 1); lstr = xmalloc(strlen(str) + 1);
for (pd = lstr, p = (char *) str; *p; p++, pd++) for (pd = lstr, p = (char *) str; *p; p++, pd++)
@ -6189,6 +6195,18 @@ void rsputs_elcode(LOGBOOK * lbs, BOOL email_notify, const char *str)
break; break;
} }
/* check for blank before smiley and if smileys are allowed */
if (l <= 20 &&
(str[i - 1] != ' ' && str[i - 1] != '\r' && str[i - 1] != '\n') ||
(smileys_enabled == FALSE)) {
strncpy(return_buffer + j, str + i, strlen(pattern_list[l].pattern));
j += strlen(pattern_list[l].pattern);
i += strlen(pattern_list[l].pattern) - 1; // 1 gets added in for loop...
substituted = TRUE;
break;
}
if (!elcode_disabled && !elcode_disabled1) { if (!elcode_disabled && !elcode_disabled1) {
substituted = TRUE; substituted = TRUE;