Skip to content
Permalink
Browse files

improved all HTML <-> plain text conversions; fixes #236

and
- stay in editor section when switching newcache editor modes; updates #202
- show HTML notice for cachedesc editor only in HTML mode
- corrected style of <ol> (used only in user content)
  • Loading branch information...
following5 committed Sep 7, 2015
1 parent 98871c7 commit ff969f6127c631f782571465ed80c1f704a1fff3
@@ -53,6 +53,9 @@
$opt['template']['default']['style'] = 'ocstyle';
$opt['template']['default']['country'] = 'DE';
// smiley path
$opt['template']['smiley'] = 'resource2/tinymce/plugins/emotions/img/';
/* pregenerated waypoint list for new caches
* - Waypoint prefix (OC, OP, OZ ... AA=local development)
* - When pool contains less than min_count, generation process starts
@@ -180,9 +180,6 @@
*/
$opt['debug'] = DEBUG_DEVELOPER;
// smiley path
$opt['template']['smiley'] = 'resource2/tinymce/plugins/emotions/img/';
/* other template options
*
*/
@@ -20,8 +20,8 @@
****************************************************************************/
//prepare the templates and include all neccessary
require_once('./lib/common.inc.php');
require_once('./lib2/OcHTMLPurifier.class.php');
require_once('lib/common.inc.php');
require_once('lib2/edithelper.inc.php');
//Preprocessing
if ($error == false)
@@ -93,7 +93,7 @@
if (isset($_POST['post'])) // Ocprop
{
//here we read all used information from the form if submitted
$descMode = isset($_POST['descMode']) ? $_POST['descMode'] : 1; // Ocprop
$descMode = isset($_POST['descMode']) ? $_POST['descMode'] + 0 : 1; // Ocprop
// fuer alte Versionen von OCProp
if (isset($_POST['submit']) && !isset($_POST['version2']))
@@ -104,19 +104,29 @@
switch ($descMode)
{
case 1:
$desc_htmledit = 0;
$desc_html = 0;
break;
case 2:
$desc_htmledit = 0;
$desc_html = 1;
break;
case 3:
default:
$descMode = 3;
$desc_htmledit = 1;
$desc_html = 1;
break;
default:
$desc_htmledit = 0;
$desc_html = 0;
break;
}
if (isset($_POST['oldDescMode']))
{
$oldDescMode = $_POST['oldDescMode'];
if (($oldDescMode < 1) || ($oldDescMode > 3)) $oldDescMode = $descMode;
}
else
$oldDescMode = $descMode;
$short_desc = $_POST['short_desc']; // Ocprop
$hint = htmlspecialchars($_POST['hints'], ENT_COMPAT, 'UTF-8');
$desclang = $_POST['desclang'];
@@ -130,33 +140,17 @@
$hint = iconv("ISO-8859-1", "UTF-8", $hint);
}
if ($desc_html == 1)
{
// Text from textarea
$desc = $_POST['desc']; // Ocprop
// Text from textarea
$desc = $_POST['desc']; // Ocprop
// fuer alte Versionen von OCProp
if (isset($_POST['submit']) && !isset($_POST['version2']))
{
$desc = iconv("ISO-8859-1", "UTF-8", $desc);
}
// Filter Input
$purifier = new OcHTMLPurifier($opt);
$desc = $purifier->purify($desc);
}
else
// fuer alte Versionen von OCProp
if (isset($_POST['submit']) && !isset($_POST['version2']))
{
// escape text
$desc = htmlspecialchars($_POST['desc'], ENT_COMPAT, 'UTF-8');
// fuer alte Versionen von OCProp
if (isset($_POST['submit']) && !isset($_POST['version2']))
{
$desc = iconv("ISO-8859-1", "UTF-8", $desc);
}
$desc = iconv("ISO-8859-1", "UTF-8", $desc);
}
$desc = processEditorInput($oldDescMode, $descMode, $desc);
if (isset($_POST['submitform'])) // Ocprop
{
// prüfen, ob sprache nicht schon vorhanden
@@ -176,7 +170,7 @@
WHERE `id`='&7'",
(($desc_html == 1) ? '1' : '0'),
(($desc_htmledit == 1) ? '1' : '0'),
(($desc_html == 1) ? $desc : nl2br($desc)),
$desc,
$short_desc,
nl2br($hint),
$desclang,
@@ -214,20 +208,17 @@
$desc_htmledit = $desc_record['desc_htmledit'];
$desc_html = $desc_record['desc_html'];
$desc_lang = $desc_record['language'];
$descMode = ($desc_html == 0 ? 1 : ($desc_htmledit ? 3 : 2));
$oldDescMode = ($desc_html == 0 ? 0 : ($desc_htmledit ? 3 : 2));
if ($desc_html == 1)
$desc = $desc_record['desc'];
else{
$desc = strip_tags($desc_record['desc']);
}
$desc = processEditorInput($oldDescMode, $descMode, $desc_record['desc']);
}
//here we only set up the template variables
if ($desc_html == 1)
tpl_set_var('desc', htmlspecialchars($desc, ENT_COMPAT, 'UTF-8'), true);
else
tpl_set_var('desc', $desc, true);
tpl_set_var('desc', htmlspecialchars($desc, ENT_COMPAT, 'UTF-8'), true);
tpl_set_var('descMode', $descMode);
tpl_set_var('htmlnotice', $descMode == 2 ? $htmlnotice : '');
// ok ... die desclang zusammenbauen
if ($show_all_langs == false)
@@ -286,13 +277,8 @@
$headers = tpl_get_var('htmlheaders') . "\n";
$headers .= '<script language="javascript" type="text/javascript" src="resource2/tinymce/tiny_mce_gzip.js"></script>' . "\n";
$headers .= '<script language="javascript" type="text/javascript" src="resource2/tinymce/config/desc.js.php?cacheid=' . ($desc_record['cache_id']+0) . '&lang=' . strtolower($locale) . '"></script>' . "\n";
tpl_set_var('descMode', 3);
}
else if ($desc_html == 1)
tpl_set_var('descMode', 2);
else
tpl_set_var('descMode', 1);
$headers .= '<script language="javascript" type="text/javascript" src="templates2/ocstyle/js/editor.js"></script>' . "\n";
$headers .= '<script language="javascript" type="text/javascript" src="' . editorJsPath() . '"></script>' . "\n";
tpl_set_var('htmlheaders', $headers);
}
else
@@ -23,11 +23,10 @@
****************************************************************************/
//prepare the templates and include all neccessary
require_once('./lib/common.inc.php');
require_once('./lib2/logic/logtypes.inc.php');
require($stylepath.'/smilies.inc.php');
require_once('./lib2/OcHTMLPurifier.class.php');
require_once('./lib/recommendation.inc.php');
require_once('lib/common.inc.php');
require_once('lib2/logic/logtypes.inc.php');
require_once('lib/recommendation.inc.php');
require_once('lib2/edithelper.inc.php');
//Preprocessing
if ($error == false)
@@ -144,10 +143,17 @@
tpl_set_var('rating_message', mb_ereg_replace('{rating_msg}', $rating_msg, $rating_tpl));
if (isset($_POST['descMode'])) // Ocprop: 2
if (isset($_POST['descMode']))
{
$descMode = $_POST['descMode']+0;
$descMode = $_POST['descMode']+0; // Ocprop: 2
if (($descMode < 1) || ($descMode > 3)) $descMode = 3;
if (isset($_POST['oldDescMode']))
{
$oldDescMode = $_POST['oldDescMode'];
if (($oldDescMode < 1) || ($oldDescMode > 3)) $oldDescMode = $descMode;
}
else
$oldDescMode = $descMode;
}
else
{
@@ -158,6 +164,7 @@
$descMode = 2;
else
$descMode = 1;
$oldDescMode = $descMode;
}
// fuer alte Versionen von OCProp
@@ -167,33 +174,22 @@
$_POST['submitform'] = $_POST['submit'];
}
if ($descMode != 1)
{
// Text from textarea; Ocprop
$log_text = isset($_POST['logtext']) ? ($_POST['logtext']) : ($log_record['text']);
// fuer alte Versionen von OCProp
if (isset($_POST['submit']) && !isset($_POST['version2']))
{
$log_text = iconv("ISO-8859-1", "UTF-8", $log_text);
}
// check input
$purifier = new OcHTMLPurifier($opt);
$log_text = $purifier->purify($log_text);
}
// Text from textarea; Ocprop
if (isset($_POST['logtext']))
$log_text = $_POST['logtext'];
else
{
// escape text
$log_text = isset($_POST['logtext']) ? htmlspecialchars($_POST['logtext'], ENT_COMPAT, 'UTF-8') : strip_tags($log_record['text']);
// fuer alte Versionen von OCProp
if (isset($_POST['submit']) && !isset($_POST['version2']))
{
$log_text = iconv("ISO-8859-1", "UTF-8", $log_text);
}
$log_text = $log_record['text'];
if ($descMode == 1)
$oldDescMode = 0; // plain text with encoded HTML entities
}
// fuer alte Versionen von OCProp
if ($descMode != 1 && isset($_POST['submit']) && !isset($_POST['version2']))
$log_text = iconv("ISO-8859-1", "UTF-8", $log_text);
$log_text = processEditorInput($oldDescMode, $descMode, $log_text);
//validate date
$date_ok = false;
if (is_numeric($log_date_month) && is_numeric($log_date_day) && is_numeric($log_date_year) &&
@@ -261,7 +257,7 @@
$log_type,
$oc_team_comment,
$log_date,
(($descMode != 1) ? $log_text : nl2br($log_text)),
$log_text,
(($descMode != 1) ? 1 : 0),
(($descMode == 3) ? 1 : 0),
$log_id);
@@ -358,7 +354,7 @@
$headers .= '<script language="javascript" type="text/javascript" src="resource2/tinymce/config/log.js.php?logid=0&lang='.strtolower($locale).'"></script>' . "\n";
tpl_set_var('descMode', 3);
}
$headers .= '<script language="javascript" type="text/javascript" src="templates2/ocstyle/js/editor.js"></script>' . "\n";
$headers .= '<script language="javascript" type="text/javascript" src="' . editorJsPath() . '"></script>' . "\n";
tpl_set_var('htmlheaders', $headers);
if ($use_log_pw == true && $log_pw != '')
@@ -373,16 +369,17 @@
$smilies = '';
if ($descMode != 3)
{
for ($i=0; $i<count($smileyshow); $i++)
for ($i=0; $i<count($smiley['show']); $i++)
{
if($smileyshow[$i] == '1')
if ($smiley['show'][$i] == '1')
{
$tmp_smiley = $smiley_link;
$tmp_smiley = mb_ereg_replace('{smiley_image}', $smileyimage[$i], $tmp_smiley);
$tmp_smiley = mb_ereg_replace('{smiley_symbol}', $smileytext[$i], $tmp_smiley);
$smilies = $smilies.'&nbsp;'.mb_ereg_replace('{smiley_name}', $smileyname[$i], $tmp_smiley).'&nbsp;';
$tmp_smiley = mb_ereg_replace('{smiley_image}', $smiley['image'][$i], $tmp_smiley);
$tmp_smiley = mb_ereg_replace('{smiley_symbol}', $smiley['text'][$i], $tmp_smiley);
$smilies = $smilies.'&nbsp;'.mb_ereg_replace('{smiley_file}', $smiley['file'][$i], $tmp_smiley).'&nbsp;';
}
}
tpl_set_var('smileypath', $opt['template']['smiley']);
}
tpl_set_var('smilies', $smilies);
}
@@ -37,6 +37,7 @@
<input type="hidden" name="show_all_langs_value" value="{show_all_langs_value}"/>
<input type="hidden" name="version2" value="1"/>
<input id="descMode" type="hidden" name="descMode" value="1" />
<input id="oldDescMode" type="hidden" name="oldDescMode" value="1" />
<table class="table">
<tr>
<td>{t}Language:{/t}</td>
@@ -79,16 +80,7 @@
<textarea id="desc" class="cachedesc" name="desc" cols="90" rows="25">{desc}</textarea>
</td>
</tr>
<tr><td class="spacer" colspan="2"></td></tr>
<tr>
<td class="help" colspan="2">
<img src="lang/de/ocstyle/images/misc/hint.gif" border="0" width="15" height="11" alt="{t}Notice{/t}" title="{t}Notice{/t}" />
{t}Your HTML code will be changed again by a special filter. This is nacessary to avoid dangerous HTML-tags, such as &lt;script&gt;.
A list of allowed HTML tags can be find <a href="http://www.opencaching.de/articles.php?page=htmltags">here</a>.{/t}<br />
<img src="lang/de/ocstyle/images/misc/hint.gif" border="0" width="15" height="11" alt="{t}Notice{/t}" title="{t}Notice{/t}" />
{t}Please do not use any images that are hosted on geocaching.com. Upload your fotos instead on our server as well.{/t}
</td>
</tr>
{htmlnotice}
<tr><td class="spacer" colspan="2"></td></tr>
<tr>
<td colspan="2">{t}Encrypted note:{/t}</td>
@@ -20,7 +20,7 @@
$error_wrong_node = t('This log entry has been created on another Opencaching website. The cache can only be edited there.');
$date_message = '<span class="errormsg">' . t('date or time is invalid') . '</span>';
$smiley_link = '<a href="javascript:insertSmiley(\'{smiley_symbol}\',\'{smiley_name}\')">{smiley_image}</a>';
$smiley_link = '<a href="javascript:insertSmiley(\'{smiley_symbol}\',\'{smiley_file}\')">{smiley_image}</a>';
$log_pw_field = '<tr><td colspan="2">' . t('passwort to log:') . ' <input class="input100" type="text" name="log_pw" maxlength="20" value="" /> (' . t('only for found logs') . ')</td></tr>
<tr><td class="spacer" colspan="2"></td></tr>';
@@ -31,9 +31,9 @@
?>
<script type="text/javascript">
<!--
function insertSmiley(smileySymbol, smileyName) {
function insertSmiley(smileySymbol, smileyFile) {
var myText = document.editform.logtext;
var insertText = (descMode == 1 ? smileySymbol : '<img src="resource2/tinymce/plugins/emotions/img/smiley-' + smileyName + '.gif" alt="" border="0" width="18px" height="18px" />');
var insertText = (descMode == 1 ? smileySymbol : '<img src="{smileypath}' + smileyFile + '" alt="" border="0" width="18px" height="18px" />');
myText.focus();
/* for IE and Webkit */
@@ -76,11 +76,12 @@ function _chkFound () {
//-->
</script>

<div class="content2-pagetitle"><img src="lang/de/ocstyle/images/description/22x22-logs.png" style="margin-right: 10px;" width="22" height="22" alt="" />{t}Edit log entry for the cache <a href="viewcache.php?cacheid={cacheid}">{cachename}</a>{/t}</div>
<div class="content2-pagetitle"><img src="lang/de/ocstyle/images/description/22x22-logs.png" style="margin-right: 10px;" width="22" height="22" alt="" />{t}Edit log entry for the cache <a href="viewcache.php?cacheid={cacheid}">{cachename}</a>{/t}</div>

<form action="editlog.php" method="post" enctype="application/x-www-form-urlencoded" name="editform" dir="ltr">
<input type="hidden" name="logid" value="{logid}"/>
<input type="hidden" name="version2" value="1"/>
<input id="oldDescMode" type="hidden" name="oldDescMode" value="1" />
<input id="descMode" type="hidden" name="descMode" value="1" />

<table class="table">
@@ -125,6 +125,7 @@ function toggleAttr(id)
<input type="hidden" name="version2" value="1"/>
<input type="hidden" id="cache_attribs" name="cache_attribs" value="{cache_attribs}" />
<input id="descMode" type="hidden" name="descMode" value="1" />
<input id="oldDescMode" type="hidden" name="oldDescMode" value="1" />
<table class="table">
{general_message}
<tr><td class="spacer" colspan="2"></td></tr>
@@ -247,7 +248,7 @@ function toggleAttr(id)
<td colspan="2">{cache_attrib_list}{safari_message}</td>
</tr>
<tr><td class="spacer" colspan="2">&nbsp;</td></tr>
<tr>
<tr id="editor">
<td class="header-small" colspan="2">
<div class="content2-container bg-blue02">
<p class="content-title-noshade-size2">
@@ -304,17 +305,7 @@ function toggleAttr(id)
<textarea id="desc" name="desc" class="cachedesc">{desc}</textarea>
</td>
</tr>

<tr><td class="spacer" colspan="2"></td></tr>
<tr>
<td class="help" colspan="2">
<img src="lang/de/ocstyle/images/misc/hint.gif" border="0" width="15" height="11" alt="{t}Notice{/t}" title="{t}Notice{/t}" />
{t}Your HTML code will be changed again by a special filter. This is necessary to avoid dangerous HTML-tags,
such as &lt;script&gt;. A list of allowed HTML tags, you can find
<a href="http://www.opencaching.de/articles.php?page=htmltags">here</a>{/t}
</td>
</tr>

{htmlnotice}
<tr><td class="spacer" colspan="2"></td></tr>
<tr>
<td colspan="2">{t}Additional note:{/t}</td>
Oops, something went wrong.

0 comments on commit ff969f6

Please sign in to comment.
You can’t perform that action at this time.