recode wrapper functions;

fixed encoding problems in mod translate;
change handling for encoding and charset in page widget
Dieser Commit ist enthalten in:
o.pinke 2023-02-10 10:57:30 +01:00
Ursprung 34d2c9ca2a
Commit 7ca3bf10bb
14 geänderte Dateien mit 198 neuen und 170 gelöschten Zeilen

Datei anzeigen

@ -1311,7 +1311,7 @@ abstract class Item extends cItemBaseAbstract {
* List of funcion names of the filtersused when data is retrieved from the db
* @var array
*/
protected $_arrOutFilters = array('stripslashes', 'htmldecode', 'urldecode');
protected $_arrOutFilters = array('stripslashes', 'htmldecode','urldecode');
/**
* Class name of meta object

Datei anzeigen

@ -130,7 +130,7 @@ class cI18n {
// Is emulator to use?
if (!$cfg['native_i18n']) {
return htmlentities(self::emulateGettext($string, $domain));
return self::emulateGettext($string, $domain);
}
// Try to use native gettext implementation

Datei anzeigen

@ -320,8 +320,12 @@ class cPage extends cHTML {
}
$meta = '';
if ($this->_encoding != "" && !$this->_isHtml5) {
$meta .= '<meta http-equiv="Content-type" content="text/html;charset=' . $this->_encoding . '">' . "\n";
if(!empty($this->_encoding)) {
if($this->_isHtml5) {
$meta .= '<meta charset="' . $this->_encoding . '">' . "\n";
} else {
$meta .= '<meta http-equiv="Content-type" content="text/html;charset=' . $this->_encoding . '">' . "\n";
}
}
if ($this->_object !== false && method_exists($this->_object, "render")) {

0
conlite/external/endroid/qr-code/composer.json vendored Ausführbare Datei → Normale Datei
Datei anzeigen

0
conlite/external/endroid/qr-code/src/QrCode.php vendored Ausführbare Datei → Normale Datei
Datei anzeigen

Datei anzeigen

@ -1,4 +1,5 @@
<?php
/**
* Project:
* Contenido Content Management System
@ -30,7 +31,6 @@
* }}
*
*/
if (!defined('CON_FRAMEWORK')) {
die('Illegal call');
}
@ -73,18 +73,17 @@ if (!defined('CON_FRAMEWORK')) {
* @param string $bReturnPath Flag to return the path instead of including the file
* @return void
*/
function contenido_include($sWhere, $sWhat, $bForce = false, $bReturnPath = false)
{
function contenido_include($sWhere, $sWhat, $bForce = false, $bReturnPath = false) {
global $client, $cfg, $cfgClient;
// Sanity check for $sWhat
$sWhat = trim($sWhat);
$sWhat = trim($sWhat);
$sWhere = strtolower($sWhere);
$bError = false;
switch ($sWhere) {
case 'config':
$sInclude = $cfg['path']['config']. $sWhat;
$sInclude = $cfg['path']['config'] . $sWhat;
break;
case 'frontend':
$sInclude = $cfgClient[$client]['path']['frontend'] . $sWhat;
@ -113,7 +112,7 @@ function contenido_include($sWhere, $sWhat, $bForce = false, $bReturnPath = fals
unset($sWhere);
} else {
$aPaths = explode(PATH_SEPARATOR, ini_get('include_path'));
$iLast = count($aPaths) - 1;
$iLast = count($aPaths) - 1;
if ($iLast >= 2) {
$tmp = $aPaths[1];
$aPaths[1] = $aPaths[$iLast];
@ -176,14 +175,14 @@ function contenido_include($sWhere, $sWhat, $bForce = false, $bReturnPath = fals
if ($bError) {
$aBackTrace = debug_backtrace();
if(is_array($aBackTrace[1])) {
$sError = " in <b>".$aBackTrace[1]['file']
."</b> on line <b>".$aBackTrace[1]['line']
."</b> <i>function</i>: ".$aBackTrace[1]['function']." ";
if (is_array($aBackTrace[1])) {
$sError = " in <b>" . $aBackTrace[1]['file']
. "</b> on line <b>" . $aBackTrace[1]['line']
. "</b> <i>function</i>: " . $aBackTrace[1]['function'] . " ";
} else {
$sError = "";
}
trigger_error("Can't include $sInclude $sError", E_USER_ERROR);
return;
}
@ -196,7 +195,6 @@ function contenido_include($sWhere, $sWhat, $bForce = false, $bReturnPath = fals
}
}
/**
* Shortcut to contenido_include.
*
@ -207,8 +205,7 @@ function contenido_include($sWhere, $sWhat, $bForce = false, $bReturnPath = fals
* @param bool $bForce If true, force the file to be included
* @return void
*/
function cInclude($sWhere, $sWhat, $bForce = false)
{
function cInclude($sWhere, $sWhat, $bForce = false) {
contenido_include($sWhere, $sWhat, $bForce);
}
@ -224,21 +221,18 @@ function cInclude($sWhere, $sWhat, $bForce = false)
*/
function plugin_include($sWhere, $sWhat) {
global $cfg;
$sInclude = $cfg['path']['contenido'] . $cfg['path']['plugins'] . $sWhere. '/' . $sWhat;
if(is_readable($sInclude)) {
$sInclude = $cfg['path']['contenido'] . $cfg['path']['plugins'] . $sWhere . '/' . $sWhat;
if (is_readable($sInclude)) {
include_once($sInclude);
} else {
$sCaller = "";
$aTrace = debug_backtrace();
foreach($aTrace as $iKey=>$aValue) {
if($aValue['function'] == __METHOD__) {
$sCaller = $aValue['file']." line ".$aValue['line'];
foreach ($aTrace as $iKey => $aValue) {
if ($aValue['function'] == __METHOD__) {
$sCaller = $aValue['file'] . " line " . $aValue['line'];
break;
}
}
trigger_error("Function ".__METHOD__.": Can't include $sInclude in ".$sCaller, E_USER_WARNING);
}
trigger_error("Function " . __METHOD__ . ": Can't include $sInclude in " . $sCaller, E_USER_WARNING);
}
}
?>

Datei anzeigen

@ -2221,4 +2221,66 @@ function IP_match($network, $mask, $ip) {
}
}
?>
/**
* Wrapper for php-function htmlspecialchars
*
* @author Ortwin Pinke <ortwinpinke@conlite.org>
* @since 2.3.0
* @uses htmlspecialchars php-function
*
* @param string $value
* @param int $flags
* @param string $encoding default UTF-8
* @return string Returns the converted string
*/
function clHtmlSpecialChars(string $value, int $flags = ENT_COMPAT|ENT_HTML401, string $encoding = 'UTF-8') {
return htmlspecialchars($value, $flags, $encoding);
}
/**
* Wrapper for php-function html_entity_decode
*
* @author Ortwin Pinke <ortwinpinke@conlite.org>
* @since 2.3.0
* @uses html_entity_decode php-function
*
* @param string $value
* @param int $flags
* @param string $encoding default UTF-8
* @return string Returns the decoded string
*/
function clHtmlEntityDecode(string $value, int $flags = ENT_COMPAT|ENT_HTML401, string $encoding = 'UTF-8') {
return html_entity_decode($value, $flags, $encoding);
}
/**
* Wrapper for php-function htmlentities
*
* @author Ortwin Pinke <ortwinpinke@conlite.org>
* @since 2.3.0
* @uses htmlentities php-function
*
* @param string $value
* @param int $flags
* @param string $encoding default UTF-8
* @return string Returns the converted string
*/
function clHtmlEntities(string $value, int $flags = ENT_COMPAT|ENT_HTML401, string $encoding = 'UTF-8') {
return htmlentities($value, $flags, $encoding);
}
/**
* Wrapper for php-function get_html_translation_table
*
* @author Ortwin Pinke <ortwinpinke@conlite.org>
* @since 2.3.0
* @uses get_html_translation_table php-function
*
* @param int $table
* @param int $flags
* @param string $encoding
* @return array
*/
function clGetHtmlTranslationTable(int $table = HTML_SPECIALCHARS, int $flags = ENT_COMPAT|ENT_HTML401, string $encoding = null) {
return get_html_translation_table($table, $flags, $encoding);
}

Datei anzeigen

@ -60,10 +60,11 @@ function clPhp54FixedFunc($funcname, $value, $flags = '', $encoding = '') {
* @param string $encoding
* @return string
*/
/*
function clHtmlSpecialChars($value, $flags = '', $encoding = '') {
return clPhp54FixedFunc("htmlspecialchars", $value, $flags, $encoding);
}
*/
/**
*
* @uses clPhp54FixedFunc multi fix func for PHP5.4
@ -74,9 +75,12 @@ function clHtmlSpecialChars($value, $flags = '', $encoding = '') {
* @param string $encoding
* @return string
*/
/*
function clHtmlEntityDecode($value, $flags = '', $encoding = '') {
return clPhp54FixedFunc("html_entity_decode", $value, $flags, $encoding);
}
*
*/
/**
*
@ -88,9 +92,12 @@ function clHtmlEntityDecode($value, $flags = '', $encoding = '') {
* @param string $encoding
* @return string
*/
/*
function clHtmlEntities($value, $flags = '', $encoding = '') {
return clPhp54FixedFunc("htmlentities", $value, $flags, $encoding);
}
*
*/
/**
*
@ -101,9 +108,12 @@ function clHtmlEntities($value, $flags = '', $encoding = '') {
* @param mixed $flags
* @return string
*/
/*
function clGetHtmlTranslationTable($table = '', $flags = '') {
return clPhp54FixedFunc("get_html_translation_table", $table, $flags);
}
*
*/
// hold old functions from con 4.8 but use new ConLite functions, mark them as deprecated
@ -112,38 +122,11 @@ function clGetHtmlTranslationTable($table = '', $flags = '') {
* Use compatible clHtmlSpecialChars instead
* @deprecated since version 2.0
*/
/**
if (function_exists('conHtmlSpecialChars') == false) {
function conHtmlSpecialChars($value, $flags = '', $encoding = '') {
return clHtmlSpecialChars($value, $flags, $encoding);
}
}
/**
* Use compatible clHtmlEntityDecode instead
* @deprecated since version 2.0
*/
if (function_exists('conHtmlEntityDecode') == false) {
function conHtmlEntityDecode($value, $flags = '', $encoding = '') {
return clHtmlEntityDecode($value, $flags, $encoding);
}
}
/**
* Use compatible clHtmlEntities instead
* @deprecated since version 2.0
*/
if (function_exists('conHtmlentities') == false) {
function conHtmlentities($value, $flags = '', $encoding = '') {
return clHtmlEntities($value, $flags, $encoding);
}
}
/**
* Use compatible clGetHtmlTranslationTable instead
* @deprecated since version 2.0
*/
if (function_exists('conGetHtmlTranslationTable') == false) {
function conGetHtmlTranslationTable($table = '', $flags = '') {
return clGetHtmlTranslationTable($table, $flags);
}
}
*
*/

Datei anzeigen

@ -1,4 +1,5 @@
<?php
/**
* Project:
* Contenido Content Management System
@ -28,111 +29,96 @@
* }}
*
*/
if (!defined('CON_FRAMEWORK')) {
die('Illegal call');
die('Illegal call');
}
$langobj = new cApiLanguage($lang);
$langstring = $langobj->get("name") . ' ('.$lang.')';
$langstring = $langobj->get("name") . ' (' . $lang . ')';
$moduletranslations = new cApiModuleTranslationCollection;
$module = new cApiModule($idmod);
if ($action == "mod_translation_save")
{
$strans = new cApiModuleTranslation;
$strans->loadByPrimaryKey($idmodtranslation);
if ($action == "mod_translation_save") {
$strans = new cApiModuleTranslation;
$strans->loadByPrimaryKey($idmodtranslation);
if ($strans->get("idmod") == $idmod)
{
$module->setTranslatedName($translatedname);
if ($strans->get("idmod") == $idmod) {
$module->setTranslatedName($translatedname);
$strans->set("translation", stripslashes($t_trans));
$strans->store();
$strans->set("translation", stripslashes($t_trans));
$strans->store();
/* Increase idmodtranslation */
$moduletranslations->select("idmod = '$idmod' AND idlang = '$lang'");
/* Increase idmodtranslation */
$moduletranslations->select("idmod = '$idmod' AND idlang = '$lang'");
while ($mitem = $moduletranslations->next())
{
if ($mitem->get("idmodtranslation") == $idmodtranslation)
{
$mitem2 = $moduletranslations->next();
while ($mitem = $moduletranslations->next()) {
if ($mitem->get("idmodtranslation") == $idmodtranslation) {
$mitem2 = $moduletranslations->next();
if (is_object($mitem2))
{
$idmodtranslation = $mitem2->get("idmodtranslation");
break;
}
}
}
}
if (is_object($mitem2)) {
$idmodtranslation = $mitem2->get("idmodtranslation");
break;
}
}
}
}
}
if ($action == "mod_importexport_translation")
{
if ($mode == "export")
{
$sFileName = uplCreateFriendlyName(strtolower($module->get("name") . "_" . $langobj->get("name")));
if ($action == "mod_importexport_translation") {
if ($mode == "export") {
$sFileName = uplCreateFriendlyName(strtolower($module->get("name") . "_" . $langobj->get("name")));
if ($sFileName != "")
{
$moduletranslations->export($idmod, $lang, $sFileName . ".xml");
}
}
if ($mode == "import")
{
if (file_exists($_FILES["upload"]["tmp_name"]))
{
$moduletranslations->import($idmod, $lang, $_FILES["upload"]["tmp_name"]);
}
}
}
if ($sFileName != "") {
$moduletranslations->export($idmod, $lang, $sFileName . ".xml");
}
}
if ($mode == "import") {
if (file_exists($_FILES["upload"]["tmp_name"])) {
$moduletranslations->import($idmod, $lang, $_FILES["upload"]["tmp_name"]);
}
}
}
if (!isset($idmodtranslation))
{
$idmodtranslation = 0;
if (!isset($idmodtranslation)) {
$idmodtranslation = 0;
}
$mtrans = new cApiModuleTranslation;
$mtrans->loadByPrimaryKey($idmodtranslation);
if ($mtrans->get("idmod") != $idmod)
{
$moduletranslations->select("idmod = '$idmod' AND idlang = '$lang'", '', 'idmodtranslation DESC', '1');
$mtrans = $moduletranslations->next();
if (is_object($mtrans))
{
$idmodtranslation = $mtrans->get("idmodtranslation");
} else {
$mtrans = new cApiModuleTranslation;
}
if ($mtrans->get("idmod") != $idmod) {
$moduletranslations->select("idmod = '$idmod' AND idlang = '$lang'", '', 'idmodtranslation DESC', '1');
$mtrans = $moduletranslations->next();
if (is_object($mtrans)) {
$idmodtranslation = $mtrans->get("idmodtranslation");
} else {
$mtrans = new cApiModuleTranslation;
}
}
$strings = $module->parseModuleForStrings();
/* Insert new strings */
foreach ($strings as $string)
{
$moduletranslations->create($idmod, $lang, $string);
foreach ($strings as $string) {
$moduletranslations->create($idmod, $lang, $string);
}
$moduletranslations->select("idmod = '$idmod' AND idlang = '$lang'");
while ($d_modtrans = $moduletranslations->next())
{
if (!in_array($d_modtrans->get("original"), $strings))
{
$moduletranslations->delete($d_modtrans->get("idmodtranslation"));
}
while ($d_modtrans = $moduletranslations->next()) {
if (!in_array($d_modtrans->get("original"), $strings)) {
$moduletranslations->delete($d_modtrans->get("idmodtranslation"));
}
}
$page = new cPage;
$page->setHtml5();
$page->setEncoding('UTF-8');
$form = new UI_Table_Form("translation");
$form->addHeader(sprintf(i18n("Translate module '%s'"), $module->get("name")));
@ -142,7 +128,7 @@ $form->setVar("idmod", $idmod);
$form->setVar("idmodtranslation", $idmodtranslation);
$form->setVar("action", "mod_translation_save");
$transmodname = new cHTMLTextbox("translatedname", $module->getTranslatedName(),60);
$transmodname = new cHTMLTextbox("translatedname", $module->getTranslatedName(), 60);
$form->add(i18n("Translated Name"), $transmodname);
@ -152,22 +138,21 @@ $ilink->setCustom("idmod", $idmod);
$ilink->setCustom("idmodtranslation", $mtrans->get("idmodtranslation"));
$ilink->setAnchor($mtrans->get("idmodtranslation"));
$iframe = '<iframe frameborder="0" style="border: 1px;border-color: black; border-style: solid;" width="620" src="'.$ilink->getHREF().'"></iframe>';
$iframe = '<iframe frameborder="0" style="border: 1px;border-color: black; border-style: solid;" width="620" src="' . $ilink->getHREF() . '"></iframe>';
$table = '<table border="0" width="600" border="0"><tr><td width="50%">'.i18n("Original module string").'</td><td width="50%">'.sprintf(i18n("Translation for %s"), $langstring).'</td><td width="20">&nbsp;</td></tr><tr><td colspan="3">'.$iframe.'</td></tr>';
$table = '<table border="0" width="600" border="0"><tr><td width="50%">' . i18n("Original module string") . '</td><td width="50%">' . sprintf(i18n("Translation for %s"), $langstring) . '</td><td width="20">&nbsp;</td></tr><tr><td colspan="3">' . $iframe . '</td></tr>';
$original = new cHTMLTextarea("t_orig",clHtmlSpecialChars($mtrans->get("original")));
$original = new cHTMLTextarea("t_orig", clHtmlSpecialChars($mtrans->get("original")));
$original->setStyle("width: 300px;");
$translated = new cHTMLTextarea("t_trans",clHtmlSpecialChars($mtrans->get("translation")));
$translated = new cHTMLTextarea("t_trans", $mtrans->get("translation"));
$translated->setStyle("width: 300px;");
$table .= '<tr><td>'.$original->render().'</td><td>'.$translated->render().'</td><td width="20">&nbsp;</td></tr></table>';
$table .= '<tr><td>' . $original->render() . '</td><td>' . $translated->render() . '</td><td width="20">&nbsp;</td></tr></table>';
$table .= i18n("Hint: Hit ALT+SHIFT+S to save the translated entry and advance to the next string.");
$form->add(i18n("String list"), $table);
$mark = '<script language="JavaScript">document.translation.t_trans.focus();</script>';
$import = new cHTMLRadiobutton("mode", "import");
$export = new cHTMLRadiobutton("mode", "export");
$export->setLabelText(i18n("Export to file"));
@ -189,15 +174,14 @@ $form2->setVar("idmod", $idmod);
$form2->setVar("idmodtranslation", $idmodtranslation);
$form2->custom["submit"]["accesskey"] = '';
$page->setContent($form->render(). $mark ."<br>". $form2->render());
$page->setContent($form->render() . $mark . "<br>" . $form2->render());
$page->setMarkScript(2);
$clang = new cApiLanguage($lang);
$page->setEncoding($clang->get("encoding"));
if (!($action == "mod_importexport_translation" && $mode == "export"))
{
$page->render();
if (!($action == "mod_importexport_translation" && $mode == "export")) {
$page->render();
}
?>

Datei anzeigen

@ -1,4 +1,5 @@
<?php
/**
* Project:
* Contenido Content Management System
@ -27,9 +28,8 @@
* }}
*
*/
if(!defined('CON_FRAMEWORK')) {
die('Illegal call');
if (!defined('CON_FRAMEWORK')) {
die('Illegal call');
}
@ -37,6 +37,8 @@ $translations = new cApiModuleTranslationCollection;
$translations->select("idmod = '$idmod' AND idlang='$lang'");
$page = new cPage;
$page->setHtml5();
$page->setEncoding('UTF-8');
$page->setMargin(0);
$v = '<table cellspacing="0" cellpadding="0" width="600">';
@ -46,32 +48,35 @@ $link->setCLink("mod_translate", 4, "");
$mylink = new cHTMLLink;
while ($translation = $translations->next())
{
$string = $translation->get("original");
$tstring = $translation->get("translation");
while ($translation = $translations->next()) {
$string = utf8_encode($translation->get("original"));
$tstring = utf8_encode($translation->get("translation"));
$link->setCustom("idmod", $idmod);
$link->setCustom("idmodtranslation", $translation->get("idmodtranslation"));
$href = $link->getHREF();
$mylink->setLink('javascript:parent.location="'.$href.'"');
$mylink->setLink('javascript:parent.location="' . $href . '"');
$mylink->setContent($string);
$dark = !$dark;
$dark = !$dark;
if ($dark)
{
$bgcol = $cfg["color"]["table_dark"];
} else {
$bgcol = $cfg["color"]["table_light"];
}
if ($dark) {
$bgcol = $cfg["color"]["table_dark"];
} else {
$bgcol = $cfg["color"]["table_light"];
}
if ($idmodtranslation == $translation->get("idmodtranslation"))
{
$bgcol = $cfg["color"]["table_active"];
}
$v .= '<tr bgcolor="'.$bgcol.'"><td style="padding-left: 2px; padding-top:2px; padding-bottom: 2px;" width="50%"><a name="'.$translation->get("idmodtranslation").'"></a>'.$mylink->render().'</td><td style="padding-left: 2px;">'.$tstring.'</td></tr>';
if ($idmodtranslation == $translation->get("idmodtranslation")) {
$bgcol = $cfg["color"]["table_active"];
}
$v .= '<tr bgcolor="' . $bgcol . '">'."\n"
. '<td style="padding-left: 2px; padding-top:2px; padding-bottom: 2px;" width="50%">'."\n"
. '<a name="' . $translation->get("idmodtranslation") . '"></a>'."\n"
. $mylink->render() . '</td>'."\n"
. '<td style="padding-left: 2px;">' . $tstring . '</td>'."\n"
. '</tr>'."\n";
}
$v .= '</table>';
@ -82,5 +87,4 @@ $clang = new cApiLanguage($lang);
$page->setEncoding($clang->get("encoding"));
$page->render();
?>

Datei anzeigen

@ -50,8 +50,8 @@ $formaction = $sess->url("main.php");
#<input type="hidden" name="action" value="tplcfg_edit">
$hidden = '<input type="hidden" name="area" value="tpl_cfg">
<input type="hidden" name="frame" value="'.$frame.'">
<input type="hidden" name="idcat" value="'.$idcat.'">
<input type="hidden" name="idart" value="'.$idart.'">
<input type="hidden" name="idcat" value="'.cRegistry::getCategoryId().'">
<input type="hidden" name="idart" value="'.cRegistry::getArticleId().'">
<input type="hidden" name="idtpl" value="'.$idtpl.'">
<input type="hidden" name="lang" value="'.$lang.'">
<input type="hidden" name="idtplcfg" value="'.$idtplcfg.'">
@ -154,7 +154,5 @@ $buttons = '<a href="javascript:history.back()"><img src="images/but_cancel.gif"
<input type="image" src="images/but_ok.gif">';
$tpl->set('s', 'BUTTONS', $buttons);
# Generate template
$tpl->generate($cfg['path']['templates'] . $cfg['templates']['tplcfg_edit_form']);
?>
$tpl->generate($cfg['path']['templates'] . $cfg['templates']['tplcfg_edit_form']);

Datei anzeigen

@ -71,7 +71,7 @@ if (!defined('CL_ENVIRONMENT')) {
*/
if (!defined('CL_VERSION')) {
define('CL_VERSION', '2.2.0 beta');
define('CL_VERSION', '2.3.0 RC');
}

@ -1 +1 @@
Subproject commit 91b0fd8c15cdf1b5e9704c8720a40f959e7eb4fe
Subproject commit 4c3d78a0443921bdc3adcaf89c151d94e8f4a876

Datei anzeigen

@ -1,7 +1,6 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title></title>
{META}
<link rel="stylesheet" type="text/css" href="styles/contenido.css">