diff --git a/classes/context/Context.class.php b/classes/context/Context.class.php index 210304486..160082ccf 100644 --- a/classes/context/Context.class.php +++ b/classes/context/Context.class.php @@ -2293,7 +2293,7 @@ class Context $plugin_name = 'ui'; } - if($loaded_plugins[$plugin_name]) + if(isset($loaded_plugins[$plugin_name])) { return; } diff --git a/classes/template/TemplateHandler.class.php b/classes/template/TemplateHandler.class.php index e4024beec..9161dd8b5 100644 --- a/classes/template/TemplateHandler.class.php +++ b/classes/template/TemplateHandler.class.php @@ -235,6 +235,9 @@ class TemplateHandler // replace value of src in img/input/script tag $buff = preg_replace_callback('/<(?:img|input|script)(?:[^<>]*?)(?(?=cond=")(?:cond="[^"]+"[^<>]*)+|)[^<>]* src="(?!(?:https?|file):\/\/|[\/\{])([^"]+)"/is', array($this, '_replacePath'), $buff); + // replace value of srcset in img/source/link tag + $buff = preg_replace_callback('/<(?:img|source|link)(?:[^<>]*?)(?(?=cond=")(?:cond="[^"]+"[^<>]*)+|)[^<>]* srcset="([^"]+)"/is', array($this, '_replaceSrcsetPath'), $buff); + // replace loop and cond template syntax $buff = $this->_parseInline($buff); @@ -381,7 +384,7 @@ class TemplateHandler } /** - * preg_replace_callback hanlder + * preg_replace_callback handler * * replace image path * @param array $match @@ -390,7 +393,19 @@ class TemplateHandler */ private function _replacePath($match) { - //return origin conde when src value started '${'. + $src = $this->_replaceRelativePath($match); + return substr($match[0], 0, -strlen($match[1]) - 6) . "src=\"{$src}\""; + } + + /** + * replace relative path + * @param array $match + * + * @return string changed result + */ + private function _replaceRelativePath($match) + { + //return origin code when src value started '${'. if(preg_match('@^\${@', $match[1])) { return $match[0]; @@ -415,7 +430,33 @@ class TemplateHandler $src = $tmp; } - return substr($match[0], 0, -strlen($match[1]) - 6) . "src=\"{$src}\""; + return $src; + } + + /** + * preg_replace_callback handler + * + * replace srcset string with multiple paths + * @param array $match + * + * @return string changed result + */ + private function _replaceSrcsetPath($match) + { + // explode urls by comma + $url_list = explode(",", $match[1]); + + foreach ($url_list as &$url) { + // replace if url is not starting with the pattern + $url = preg_replace_callback( + '/^(?!(?:https?|file):\/\/|[\/\{])(\S+)/i', + array($this, '_replaceRelativePath'), + trim($url) + ); + } + $srcset = implode(", ", $url_list); + + return substr($match[0], 0, -strlen($match[1]) - 9) . "srcset=\"{$srcset}\""; } /** @@ -536,7 +577,7 @@ class TemplateHandler } /** - * preg_replace_callback hanlder + * preg_replace_callback handler * replace php code. * @param array $m * @return string changed result diff --git a/common/autoload.php b/common/autoload.php index 04bf3c3f1..ed0257251 100644 --- a/common/autoload.php +++ b/common/autoload.php @@ -85,7 +85,6 @@ $GLOBALS['RX_AUTOLOAD_FILE_MAP'] = array_change_key_case(array( 'XmlLangParser' => 'classes/xml/XmlLangParser.class.php', 'XmlParser' => 'classes/xml/XmlParser.class.php', 'XeXmlParser' => 'classes/xml/XmlParser.class.php', - 'Bmp' => 'common/libraries/bmp.php', 'Ftp' => 'common/libraries/ftp.php', 'Tar' => 'common/libraries/tar.php', 'CryptoCompat' => 'common/libraries/cryptocompat.php', diff --git a/common/libraries/bmp.php b/common/libraries/bmp.php deleted file mode 100644 index 64a375091..000000000 --- a/common/libraries/bmp.php +++ /dev/null @@ -1,257 +0,0 @@ -=0; $y--) - { - for ($x=0; $x<$wid; $x++) - { - $rgb = imagecolorat($img, $x, $y); - fwrite($f, byte3($rgb)); - } - fwrite($f, $wid_pad); - } - fclose($f); - } - else - { - foreach ($header AS $h) - { - echo $h; - } - - //save pixels - for ($y=$hei-1; $y>=0; $y--) - { - for ($x=0; $x<$wid; $x++) - { - $rgb = imagecolorat($img, $x, $y); - echo self::byte3($rgb); - } - echo $wid_pad; - } - } - } - - public static function getimagesize($filename) - { - $f = fopen($filename, "rb"); - - //read header - $header = fread($f, 54); - $header = unpack( 'c2identifier/Vfile_size/Vreserved/Vbitmap_data/Vheader_size/' . - 'Vwidth/Vheight/vplanes/vbits_per_pixel/Vcompression/Vdata_size/'. - 'Vh_resolution/Vv_resolution/Vcolors/Vimportant_colors', $header); - - if ($header['identifier1'] != 66 or $header['identifier2'] != 77) - { - return false; - } - - if (!in_array($header['bits_per_pixel'], array(24, 32, 8, 4, 1))) - { - return false; - } - - $bps = $header['bits_per_pixel']; //bits per pixel - $wid2 = ceil(($bps/8 * $header['width']) / 4) * 4; - $colors = pow(2, $bps); - - $wid = $header['width']; - $hei = $header['height']; - - return array($wid, $hei, 'BMP'); - } - - public static function imagecreatefrombmp($filename) - { - $f = fopen($filename, "rb"); - - //read header - $header = fread($f, 54); - $header = unpack( 'c2identifier/Vfile_size/Vreserved/Vbitmap_data/Vheader_size/' . - 'Vwidth/Vheight/vplanes/vbits_per_pixel/Vcompression/Vdata_size/'. - 'Vh_resolution/Vv_resolution/Vcolors/Vimportant_colors', $header); - - if ($header['identifier1'] != 66 or $header['identifier2'] != 77) - { - return false; - } - - if (!in_array($header['bits_per_pixel'], array(24, 32, 8, 4, 1))) - { - return false; - } - - $bps = $header['bits_per_pixel']; //bits per pixel - $wid2 = ceil(($bps/8 * $header['width']) / 4) * 4; - $colors = pow(2, $bps); - - $wid = $header['width']; - $hei = $header['height']; - - $img = imagecreatetruecolor($header['width'], $header['height']); - - //read palette - if ($bps < 9) - { - for ($i=0; $i<$colors; $i++) - { - $palette[] = self::undword(fread($f, 4)); - } - } - else - { - if ($bps == 32) - { - imagealphablending($img, false); - imagesavealpha($img, true); - } - $palette = array(); - } - - //read pixels - for ($y=$hei-1; $y>=0; $y--) - { - $row = fread($f, $wid2); - $pixels = self::str_split2($row, $bps, $palette); - for ($x=0; $x<$wid; $x++) - { - self::makepixel($img, $x, $y, $pixels[$x], $bps); - } - } - fclose($f); - - return $img; - } - - private static function str_split2($row, $bps, $palette) - { - switch ($bps) - { - case 32: - case 24: return str_split($row, $bps/8); - case 8: $out = array(); - $count = strlen($row); - for ($i=0; $i<$count; $i++) - { - $out[] = $palette[ ord($row[$i]) ]; - } - return $out; - case 4: $out = array(); - $count = strlen($row); - for ($i=0; $i<$count; $i++) - { - $roww = ord($row[$i]); - $out[] = $palette[ ($roww & 240) >> 4 ]; - $out[] = $palette[ ($roww & 15) ]; - } - return $out; - case 1: $out = array(); - $count = strlen($row); - for ($i=0; $i<$count; $i++) - { - $roww = ord($row[$i]); - $out[] = $palette[ ($roww & 128) >> 7 ]; - $out[] = $palette[ ($roww & 64) >> 6 ]; - $out[] = $palette[ ($roww & 32) >> 5 ]; - $out[] = $palette[ ($roww & 16) >> 4 ]; - $out[] = $palette[ ($roww & 8) >> 3 ]; - $out[] = $palette[ ($roww & 4) >> 2 ]; - $out[] = $palette[ ($roww & 2) >> 1 ]; - $out[] = $palette[ ($roww & 1) ]; - } - return $out; - } - } - - private static function makepixel($img, $x, $y, $str, $bps) - { - switch ($bps) - { - case 32 : $a = ord($str[0]); - $b = ord($str[1]); - $c = ord($str[2]); - $d = 256 - ord($str[3]); //TODO: gives imperfect results - $pixel = $d*256*256*256 + $c*256*256 + $b*256 + $a; - imagesetpixel($img, $x, $y, $pixel); - break; - case 24 : $a = ord($str[0]); - $b = ord($str[1]); - $c = ord($str[2]); - $pixel = $c*256*256 + $b*256 + $a; - imagesetpixel($img, $x, $y, $pixel); - break; - case 8 : - case 4 : - case 1 : imagesetpixel($img, $x, $y, $str); - break; - } - } - - private static function byte3($n) - { - return chr($n & 255) . chr(($n >> 8) & 255) . chr(($n >> 16) & 255); - } - - private static function undword($n) - { - $r = unpack("V", $n); - return $r[1]; - } - - private static function dword($n) - { - return pack("V", $n); - } - - private static function word($n) - { - return pack("v", $n); - } -} diff --git a/modules/admin/conf/module.xml b/modules/admin/conf/module.xml index fab3c0ceb..8a28e7b8d 100644 --- a/modules/admin/conf/module.xml +++ b/modules/admin/conf/module.xml @@ -21,7 +21,7 @@ - + diff --git a/modules/admin/ruleset/toggleFavorite.xml b/modules/admin/ruleset/toggleFavorite.xml deleted file mode 100644 index b2a4e7f1e..000000000 --- a/modules/admin/ruleset/toggleFavorite.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/modules/admin/tpl/_header.html b/modules/admin/tpl/_header.html index 0ce0af240..804138c42 100644 --- a/modules/admin/tpl/_header.html +++ b/modules/admin/tpl/_header.html @@ -68,9 +68,9 @@ {$lang->msg_not_founded}
- + - +
diff --git a/modules/board/board.view.php b/modules/board/board.view.php index 198a3eb1e..6d16a7fd5 100644 --- a/modules/board/board.view.php +++ b/modules/board/board.view.php @@ -776,7 +776,7 @@ class boardView extends board foreach($normal_category_list as $category_srl => $category) { $is_granted = TRUE; - if($category->group_srls) + if(isset($category->group_srls) && $category->group_srls) { $category_group_srls = explode(',',$category->group_srls); $is_granted = FALSE; @@ -814,12 +814,12 @@ class boardView extends board $member_info = MemberModel::getMemberInfo($oDocument->get('member_srl')); - if($oDocument->get('module_srl') == $oDocument->get('member_srl')) $savedDoc = TRUE; + $savedDoc = ($oDocument->get('module_srl') == $oDocument->get('member_srl')); $oDocument->add('module_srl', $this->module_srl); if($oDocument->isExists()) { - if($this->module_info->protect_document_regdate > 0 && $this->grant->manager == false) + if(($this->module_info->protect_document_regdate ?? 0) > 0 && $this->grant->manager == false) { if($oDocument->get('regdate') < date('YmdHis', strtotime('-'.$this->module_info->protect_document_regdate.' day'))) { @@ -828,7 +828,7 @@ class boardView extends board throw new Rhymix\Framework\Exception($massage); } } - if($this->module_info->protect_content == "Y" || $this->module_info->protect_update_content == 'Y') + if(($this->module_info->protect_content ?? 'N') === 'Y' || ($this->module_info->protect_update_content ?? 'N') == 'Y') { if($oDocument->get('comment_count') > 0 && $this->grant->manager == false) { diff --git a/modules/board/skins/xedition/_header.html b/modules/board/skins/xedition/_header.html index bb5ecdb87..b33579ca3 100644 --- a/modules/board/skins/xedition/_header.html +++ b/modules/board/skins/xedition/_header.html @@ -2,7 +2,7 @@ - + {@ $order_type = "asc"; } {@ $order_type = "desc"; } diff --git a/modules/board/skins/xedition/_read.html b/modules/board/skins/xedition/_read.html index 837bc3c45..449474e2c 100644 --- a/modules/board/skins/xedition/_read.html +++ b/modules/board/skins/xedition/_read.html @@ -7,9 +7,9 @@

- {$oDocument->getNickName()} - {$oDocument->getNickName()} - {$oDocument->getNickName()} + {$oDocument->getNickName()} + {$oDocument->getNickName()} + {$oDocument->getNickName()} {$oDocument->getRegdate('Y.m.d H:i')} @@ -109,7 +109,7 @@ {$lang->cmd_document_do} -

+
Profile
{$oDocument->getSignature()}
diff --git a/modules/board/skins/xedition/list.html b/modules/board/skins/xedition/list.html index 6230161a0..54d14bf5c 100644 --- a/modules/board/skins/xedition/list.html +++ b/modules/board/skins/xedition/list.html @@ -1,10 +1,10 @@ @@ -44,14 +44,14 @@ - » - {$lang->notice} + » + {$lang->notice} {$document->get('module_title')} - + {$document->getTitle()} @@ -90,14 +90,14 @@ - » - {$no} + » + {$no} {$document->get('module_title')} - {$document->getTitle()} + {$document->getTitle()} [{$document->getCommentCount()}] [{$document->getTrackbackCount()}] {$document->printExtraImages(60*60*$module_info->duration_new)} @@ -140,27 +140,26 @@
diff --git a/modules/board/skins/xedition/write_form.html b/modules/board/skins/xedition/write_form.html index b5e7ea15e..645e59710 100644 --- a/modules/board/skins/xedition/write_form.html +++ b/modules/board/skins/xedition/write_form.html @@ -71,12 +71,12 @@ - + -
+
{$captcha}
diff --git a/modules/document/document.controller.php b/modules/document/document.controller.php index 7b5022a42..2e462bbd4 100644 --- a/modules/document/document.controller.php +++ b/modules/document/document.controller.php @@ -1355,7 +1355,7 @@ class documentController extends document $oDB->commit(); // Register session - if(!$_SESSION['banned_document'][$document_srl] && Context::getSessionStatus()) + if(!isset($_SESSION['readed_document'][$document_srl]) && Context::getSessionStatus()) { $_SESSION['readed_document'][$document_srl] = true; } diff --git a/modules/document/document.item.php b/modules/document/document.item.php index 111cee45f..51f07c870 100644 --- a/modules/document/document.item.php +++ b/modules/document/document.item.php @@ -30,6 +30,11 @@ class documentItem extends BaseObject * @var bool */ var $allow_trackback_status = null; + /** + * Comment page navigation + * @var object + */ + var $comment_page_navigation = null; /** * column list * @var array @@ -1459,7 +1464,7 @@ class documentItem extends BaseObject if(!isset($GLOBALS['__member_signature_max_height'])) { $member_config = ModuleModel::getModuleConfig('member'); - $GLOBALS['__member_signature_max_height'] = $member_config->signature_max_height; + $GLOBALS['__member_signature_max_height'] = $member_config->signature_max_height ?? 100; } if($signature) { diff --git a/modules/document/document.model.php b/modules/document/document.model.php index 1aa5c0367..bcdbd99d1 100644 --- a/modules/document/document.model.php +++ b/modules/document/document.model.php @@ -1307,7 +1307,7 @@ class documentModel extends document $args->page_count = $searchOpt->page_count ?? 10; $args->start_date = $searchOpt->start_date ?? null; $args->end_date = $searchOpt->end_date ?? null; - $args->s_is_notice = $searchOpt->except_notice ? 'N' : null; + $args->s_is_notice = ($searchOpt->except_notice ?? false) ? 'N' : null; $args->statusList = $searchOpt->statusList ?? array(self::getConfigStatus('public'), self::getConfigStatus('secret')); $args->columnList = $searchOpt->columnList ?? array(); diff --git a/modules/editor/editor.admin.controller.php b/modules/editor/editor.admin.controller.php index d7a589956..7808707b1 100644 --- a/modules/editor/editor.admin.controller.php +++ b/modules/editor/editor.admin.controller.php @@ -231,6 +231,7 @@ class editorAdminController extends editor $config->content_word_break = $configVars->content_word_break; $config->content_word_break = in_array($config->content_word_break, array('normal', 'keep-all', 'break-all', 'none')) ? $config->content_word_break : 'normal'; $config->enable_autosave = $configVars->enable_autosave ?: 'Y'; + $config->auto_dark_mode = $configVars->auto_dark_mode ?: 'Y'; $config->allow_html = $configVars->allow_html ?: 'Y'; $config->autoinsert_types = array(); foreach ($configVars->autoinsert_types as $type) diff --git a/modules/editor/editor.class.php b/modules/editor/editor.class.php index 8f87060fd..a600a2d31 100644 --- a/modules/editor/editor.class.php +++ b/modules/editor/editor.class.php @@ -48,6 +48,7 @@ class editor extends ModuleObject 'content_paragraph_spacing' => '0px', 'content_word_break' => 'normal', 'enable_autosave' => 'Y', + 'auto_dark_mode' => 'Y', 'allow_html' => 'Y', 'editor_focus' => 'N', 'autoinsert_types' => array('image' => true, 'audio' => true, 'video' => true), diff --git a/modules/editor/editor.controller.php b/modules/editor/editor.controller.php index 0e34cf834..dee64e148 100644 --- a/modules/editor/editor.controller.php +++ b/modules/editor/editor.controller.php @@ -155,6 +155,7 @@ class editorController extends editor $config->content_font_size = trim($vars->content_font_size); $config->enable_autosave = $vars->enable_autosave ?: 'Y'; + $config->auto_dark_mode = $vars->auto_dark_mode ?: 'Y'; $config->allow_html = $vars->allow_html ?: 'Y'; // Apply module-specific permissions. diff --git a/modules/editor/editor.model.php b/modules/editor/editor.model.php index 9f6b4126c..7943db93b 100644 --- a/modules/editor/editor.model.php +++ b/modules/editor/editor.model.php @@ -203,6 +203,7 @@ class editorModel extends editor // Set allow html and focus Context::set('allow_html', ($option->allow_html === false || $option->allow_html === 'N') ? false : true); Context::set('editor_focus', toBool($option->editor_focus)); + Context::set('editor_auto_dark_mode', $option->auto_dark_mode !== 'N'); // Load editor components. if($option->enable_component) @@ -262,7 +263,7 @@ class editorModel extends editor Context::set('files_count', (int)$files_count); // Check an option whether to start the editor manually. - Context::set('editor_manual_start', $option->manual_start); + Context::set('editor_manual_start', $option->manual_start ?? null); // Compile and return the editor skin template. $tpl_path = Context::get('editor_path'); diff --git a/modules/editor/lang/en.php b/modules/editor/lang/en.php index 4c0646238..dd635ef48 100644 --- a/modules/editor/lang/en.php +++ b/modules/editor/lang/en.php @@ -76,6 +76,7 @@ $lang->enable_default_component_grant = 'Permission to use default components'; $lang->enable_extra_component_grant = 'Permission to use extra components'; $lang->enable_html_grant = 'Permission to edit HTML'; $lang->enable_autosave = 'Enable Auto-Save'; +$lang->editor_auto_dark_mode = 'Automatic dark mode'; $lang->allow_html = 'allow HTML'; $lang->height_resizable = 'Height Resizable'; $lang->editor_height = 'Height of Editor'; @@ -83,6 +84,7 @@ $lang->about_default_editor_settings = 'Follow the default settings from the Edi $lang->about_content_font = 'Please use comma for multiple input.'; $lang->about_content_font_size = 'Please input units such as px or em.'; $lang->about_enable_autosave = 'You may decide whether the auto-save function will be used.'; +$lang->about_editor_auto_dark_mode = 'Automatically switch to a dark skin if dark mode is used.'; $lang->edit['fontname'] = 'Font'; $lang->edit['fontsize'] = 'Size'; $lang->edit['use_paragraph'] = 'Paragraph Function'; diff --git a/modules/editor/lang/ko.php b/modules/editor/lang/ko.php index f74b6731c..144c2331b 100644 --- a/modules/editor/lang/ko.php +++ b/modules/editor/lang/ko.php @@ -74,6 +74,7 @@ $lang->enable_default_component_grant = '기본 컴포넌트 사용 권한'; $lang->enable_extra_component_grant = '확장 컴포넌트 사용 권한'; $lang->enable_html_grant = 'HTML 편집 권한'; $lang->enable_autosave = '자동저장 사용'; +$lang->editor_auto_dark_mode = '다크모드 자동 감지'; $lang->allow_html = 'HTML 허용'; $lang->height_resizable = '높이 조절 가능'; $lang->editor_height = '에디터 높이'; @@ -81,6 +82,7 @@ $lang->about_default_editor_settings = '에디터 모듈의 기본 설정을 따 $lang->about_content_font = '콤마(,)로 여러 폰트를 지정할 수 있습니다.'; $lang->about_content_font_size = '12px, 1em등 단위까지 포함해서 입력해주세요.'; $lang->about_enable_autosave = '글 작성 시 자동 저장 기능을 활성화 시킬 수 있습니다.'; +$lang->about_editor_auto_dark_mode = '다크모드 사용시 자동으로 어두운 스킨을 사용합니다.'; $lang->edit['fontname'] = '글꼴'; $lang->edit['fontsize'] = '크기'; $lang->edit['use_paragraph'] = '문단기능'; diff --git a/modules/editor/skins/ckeditor/css/default.less b/modules/editor/skins/ckeditor/css/default.less index 9b22b93f0..1f5481679 100644 --- a/modules/editor/skins/ckeditor/css/default.less +++ b/modules/editor/skins/ckeditor/css/default.less @@ -33,18 +33,81 @@ } .light_dark(@cs) when (@cs = moono-dark) { - background-color: #494949; + background-color: #333; color: #fff; } .light_dark(@cs) when not (@cs = moono-dark) { background-color: #fff; color: #000; + &.color_scheme_dark { + background-color: #333; + color: #fff; + } } .light_dark_top(@cs) when (@cs = moono-dark) { - border-bottom-color: #1b1b1b; + body & { + border-color: #555; + &.cke_bottom { + background: #333; + .cke_button_icon, .cke_combo_button, .cke_button_arrow, .cke_button_label { + filter: invert(1); + } + } + } } .light_dark_top(@cs) when not (@cs = moono-dark) { + .color_scheme_dark & { + background: #333; + border-color: #555; + .cke_button_on { + background: #000; + border-color: #555; + } + .cke_button_icon, .cke_combo_button, .cke_button_arrow, .cke_button_label { + filter: invert(1); + } + &.cke_dialog_body { + background: #555; + } + .cke_dialog_title { + background: #333; + color: #fff; + border-bottom-color: #555; + .cke_dialog_close_button { + color: #fff; + } + } + .cke_dialog_tabs { + background: #555; + .cke_dialog_tab { + background: #555; + color: #999; + border-color: #777; + } + .cke_dialog_tab_selected { + background: #777; + color: #fff; + border-color: #777; + } + } + .cke_dialog_contents { + background: #555; + border-top-color: #777; + label { + color: #fff; + } + select, input, .ImagePreviewBox td { + background: #333; + color: #fff; + border-color: #777; + } + } + .cke_dialog_footer { + background: #333; + border-top-color: #555; + } + } } html { @@ -66,31 +129,36 @@ html { p.editor_autosaved_message.autosave_message { display:none; background: #e0e0e0; + color: #000; padding: 10px; margin:0; line-height:1.2; + .color_scheme_dark & { + background: #222; + color: #fff; + } } .cke_reset { - span { - &.cke_top { - .light_dark_top(@colorset); - a { - &:hover, &:focus { - transition: none; - } - } - } - &.cke_combo__fontsize { - .cke_combo_button { - width: 64px; - } - .cke_combo_text { - width: 30px; + .cke_top, .cke_bottom { + .light_dark_top(@colorset); + a { + &:hover, &:focus { + transition: none; } } } + .cke_combo__fontsize { + .cke_combo_button { + width: 64px; + } + .cke_combo_text { + width: 30px; + } + } +} +.cke_dialog_body { + .light_dark_top(@colorset); } - .xe_content.editable, .rhymix_content.editable, .cke_wysiwyg_div { .cont_font(@content_font); @@ -125,4 +193,4 @@ p.editor_autosaved_message.autosave_message { } } -} \ No newline at end of file +} diff --git a/modules/editor/skins/ckeditor/editor.html b/modules/editor/skins/ckeditor/editor.html index 7ce7317cf..1f6969f9e 100644 --- a/modules/editor/skins/ckeditor/editor.html +++ b/modules/editor/skins/ckeditor/editor.html @@ -92,11 +92,22 @@ var auto_saved_msg = "{$lang->msg_auto_saved}"; return val + "/" + val + "px"; }).join(";"); + // Apply auto dark mode. + var editor_skin = '{$colorset}'; + var editor_color = null; + + if (getColorScheme() === 'dark') { + if (editor_skin !== 'moono-lisa' ) { + editor_skin = 'moono-dark'; + } + } + + // Initialize CKEditor settings. var settings = { ckeconfig: { height: '{$editor_height}', - skin: '{$colorset}', + skin: editor_skin, contentsCss: {json_encode($css_file_list)}, xe_editor_sequence: {$editor_sequence}, font_defaultLabel: default_font_name, @@ -106,7 +117,7 @@ var auto_saved_msg = "{$lang->msg_auto_saved}"; toolbarCanCollapse: true, allowedContent: true, startupFocus: {json_encode($editor_focus)}, - language: "{str_replace('jp','ja',$lang_type)}" + language: "{str_replace('jp','ja',$lang_type)}", }, loadXeComponent: true, enableToolbar: true, diff --git a/modules/editor/skins/simpleeditor/css/simpleeditor.less b/modules/editor/skins/simpleeditor/css/simpleeditor.less index cc0e2dd92..c0c30f871 100644 --- a/modules/editor/skins/simpleeditor/css/simpleeditor.less +++ b/modules/editor/skins/simpleeditor/css/simpleeditor.less @@ -10,7 +10,7 @@ background: #fff; padding: 10px; } - &.dark { + &.dark, .color_scheme_dark & { border-color: #111; background: #333; color: #fff; diff --git a/modules/editor/tpl/admin_index.html b/modules/editor/tpl/admin_index.html index f80484914..db49dc527 100644 --- a/modules/editor/tpl/admin_index.html +++ b/modules/editor/tpl/admin_index.html @@ -256,6 +256,14 @@

{$lang->about_enable_autosave}

+
+ +
+ + +

{$lang->about_editor_auto_dark_mode}

+
+
diff --git a/modules/editor/tpl/editor_module_config.html b/modules/editor/tpl/editor_module_config.html index 731b02159..af063fa03 100644 --- a/modules/editor/tpl/editor_module_config.html +++ b/modules/editor/tpl/editor_module_config.html @@ -167,6 +167,14 @@

{$lang->about_enable_autosave}

+ + {$lang->editor_auto_dark_mode} + + + +

{$lang->about_editor_auto_dark_mode}

+ + {$lang->allow_html} diff --git a/modules/editor/tpl/js/editor.app.js b/modules/editor/tpl/js/editor.app.js index da6c3fb5e..de79a71bd 100644 --- a/modules/editor/tpl/js/editor.app.js +++ b/modules/editor/tpl/js/editor.app.js @@ -84,6 +84,7 @@ function getAutoSavedSrl(ret_obj, response_tags, c) { var fo_obj = getCkFormInstance(editor_sequence); this.ckeconfig = $.extend({}, default_ckeconfig, opts.ckeconfig || {}); + this.ckeconfig.bodyClass = this.ckeconfig.bodyClass + ' color_scheme_' + getColorScheme(); this.editor_sequence = data.editorSequence; $form.attr('editor_sequence', data.editorSequence); diff --git a/modules/widget/widget.controller.php b/modules/widget/widget.controller.php index b8fb1078e..d832393b6 100644 --- a/modules/widget/widget.controller.php +++ b/modules/widget/widget.controller.php @@ -261,9 +261,9 @@ class widgetController extends widget // Check whether to include information about editing $this->javascript_mode = $javascript_mode; // Widget code box change - $content = preg_replace_callback('!]*)widget=([^\>]*?)\>
(()*)!is', array($this,'transWidgetBox'), $content); + $content = preg_replace_callback('!]*)widget=([^>]*?)>
(()*)!is', array($this, 'transWidgetBox'), $content); // Widget code information byeogyeong - $content = preg_replace_callback('!]*)widget=([^\>]*?)\>!is', array($this,'transWidget'), $content); + $content = preg_replace_callback('!]*)widget=([^>]*?)>!is', array($this, 'transWidget'), $content); return $content; } @@ -273,16 +273,18 @@ class widgetController extends widget */ function transWidget($matches) { - $buff = trim($matches[0]); - - $oXmlParser = new XeXmlParser(); - $xml_doc = $oXmlParser->parse(trim($buff)); - - if($xml_doc->img) $vars = $xml_doc->img->attrs; - else $vars = $xml_doc->attrs; - + $vars = new stdClass; + $xml = simplexml_load_string(trim($matches[0])); + foreach ($xml->img ? $xml->img->attributes() : $xml->attributes() as $key => $val) + { + $vars->{$key} = strval($val); + } + $widget = $vars->widget; - if(!$widget) return $matches[0]; + if (!$widget) + { + return $matches[0]; + } unset($vars->widget); return $this->execute($widget, $vars, $this->javascript_mode); @@ -361,7 +363,7 @@ class widgetController extends widget } // Fix the widget sequence if it is missing - $widget_sequence = $override_sequence ?: $args->widget_sequence; + $widget_sequence = $override_sequence ?: ($args->widget_sequence ?? 0); if (!$widget_sequence) { $widget_sequence = sha1(json_encode($args)); @@ -480,12 +482,12 @@ class widgetController extends widget * Wanted specified by the administrator of the widget style */ // Sometimes the wrong code, background-image: url (none) can be heard but none in this case, the request for the url so unconditionally Removed - $style = preg_replace('/url\((.+)(\/?)none\)/is','', $args->style); + $style = preg_replace('/url\((.+)(\/?)none\)/is','', $args->style ?? ''); // Find a style statement that based on the internal margin dropping pre-change - $widget_padding_left = $args->widget_padding_left; - $widget_padding_right = $args->widget_padding_right; - $widget_padding_top = $args->widget_padding_top; - $widget_padding_bottom = $args->widget_padding_bottom; + $widget_padding_left = $args->widget_padding_left ?? 0; + $widget_padding_right = $args->widget_padding_right ?? 0; + $widget_padding_top = $args->widget_padding_top ?? 0; + $widget_padding_bottom = $args->widget_padding_bottom ?? 0; $inner_style = sprintf("padding:%dpx %dpx %dpx %dpx !important;", $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left); /** @@ -498,7 +500,10 @@ class widgetController extends widget // If general call is given on page styles should return immediately dreamin ' if(!$javascript_mode) { - if($args->id) $args->id = ' id="'.$args->id.'" '; + if(isset($args->id) && $args->id) + { + $args->id = ' id="'.$args->id.'" '; + } switch($widget) { // If a direct orthogonal addition information @@ -517,20 +522,20 @@ class widgetController extends widget $oEditorController = getController('editor'); $body = $oEditorController->transComponent($body); - $widget_content_header = sprintf('
', $args->id, $style, $inner_style); + $widget_content_header = sprintf('
', $args->id ?? '', $style, $inner_style); $widget_content_body = $body; $widget_content_footer = '
'; break; // If the widget box; it could case 'widgetBox' : - $widget_content_header = sprintf('
', $args->id, $style, $inner_style); + $widget_content_header = sprintf('
', $args->id ?? '', $style, $inner_style); $widget_content_body = $widgetbox_content; break; // If the General wijetil default : - $widget_content_header = sprintf('
',$args->id,$style); + $widget_content_header = sprintf('
', $args->id ?? '', $style); $widget_content_body = sprintf('
%s
', $inner_style,$widget_content); $widget_content_footer = '
'; break; @@ -641,7 +646,10 @@ class widgetController extends widget } } // Compile the widget style. - if($args->widgetstyle) $widget_content_body = $this->compileWidgetStyle($args->widgetstyle,$widget, $widget_content_body, $args, $javascript_mode); + if(isset($args->widgetstyle) && $args->widgetstyle) + { + $widget_content_body = $this->compileWidgetStyle($args->widgetstyle, $widget, $widget_content_body, $args, $javascript_mode); + } $output = $widget_content_header . $widget_content_body . $widget_content_footer; diff --git a/tests/unit/classes/TemplateHandlerTest.php b/tests/unit/classes/TemplateHandlerTest.php index 8a4d07d81..95daf9746 100644 --- a/tests/unit/classes/TemplateHandlerTest.php +++ b/tests/unit/classes/TemplateHandlerTest.php @@ -275,6 +275,11 @@ class TemplateHandlerTest extends \Codeception\TestCase\Test array( 'asdf src="../img/img.gif" asdf', '?>asdf src="../img/img.gif" asdf' + ), + // srcset (PR #1544) + array( + 'this is a test image.', + '?>this is a test image.' ), // Rhymix improvements (PR #604) array(