diff --git a/acp/main_module.php b/acp/main_module.php index 9f23939..3f98df6 100644 --- a/acp/main_module.php +++ b/acp/main_module.php @@ -40,20 +40,23 @@ public function main($id, $mode) $theme = $request->variable('oxcom_phpbbch_theme', 'none'); $langs = $request->variable('oxcom_phpbbch_langs', ['none']); + $bFExt = $request->variable('oxcom_phpbbch_bh_format_ext', 'N'); $this->config->set('oxcom_phpbbch_theme', $theme); + $this->config->set('oxcom_phpbbch_format_only', $bFExt); $this->updateLanguages($langs); trigger_error($this->lang('ACP_PHPBBCH_SETTING_SAVED') . adm_back_link($this->u_action)); } $template->assign_vars([ - 'ACP_PHPBBCH_LANGUAGES' => \oxcom\phpbbch\core\settings::getLanguages(), - 'ACP_PHPBBCH_THEMES' => \oxcom\phpbbch\core\settings::getThemes(), - 'ACP_PHPBBCH_THEME' => $this->config['oxcom_phpbbch_theme'], - 'ACP_PHPBBCH_LANGS' => $this->getSelectedLanguages(), - 'ACP_PHPBBCH_VERSION' => $this->config['oxcom_phpbbch_version'], - 'U_ACTION' => $this->u_action, + 'ACP_PHPBBCH_LANGUAGES' => \oxcom\phpbbch\core\settings::getLanguages(), + 'ACP_PHPBBCH_THEMES' => \oxcom\phpbbch\core\settings::getThemes(), + 'ACP_PHPBBCH_THEME' => $this->config['oxcom_phpbbch_theme'], + 'ACP_PHPBBCH_LANGS' => $this->getSelectedLanguages(), + 'ACP_PHPBBCH_VERSION' => $this->config['oxcom_phpbbch_version'], + 'ACP_PHPBBCH_BEHAVIOUR_EXT_ONLY' => $this->config['oxcom_phpbbch_format_only'], + 'U_ACTION' => $this->u_action, ]); } diff --git a/adm/style/acp_phpbbch_body.html b/adm/style/acp_phpbbch_body.html index d76af0e..06db4c4 100644 --- a/adm/style/acp_phpbbch_body.html +++ b/adm/style/acp_phpbbch_body.html @@ -7,10 +7,7 @@

{L_SETTINGS}

-

- Please visit this site to get more information about themes - HighlightJS -

+

{L_ACP_PHPBBCH_THEME_D} HighlightJS

  +
+
@@ -36,10 +47,11 @@

{L_SETTINGS}

{% for key,title in ACP_PHPBBCH_LANGUAGES %}  {{ title }} + /> 
{% endfor %}
diff --git a/event/main.php b/event/main.php index ae6e518..5c94075 100644 --- a/event/main.php +++ b/event/main.php @@ -78,7 +78,7 @@ public function initExtension($event) $enabled = $this->getSelectedLanguages(); foreach ($available as $key => $name) { - if (in_array($key, $enabled, true)) { + if (\in_array($key, $enabled, true)) { continue; } @@ -86,8 +86,9 @@ public function initExtension($event) } $this->template->assign_vars([ - 'PHPBBCH_ALLOWED_LANGS' => array_keys($available), - 'PHPBBCH_POST_HELP_LANGS' => $available, + 'PHPBBCH_ALLOWED_LANGS' => \array_keys($available), + 'PHPBBCH_POST_HELP_LANGS' => $available, + 'PHPBBCH_BEHAVIOUR_EXT_ONLY' => $this->config['oxcom_phpbbch_format_only'], ]); } @@ -99,20 +100,16 @@ public function initExtension($event) */ protected function getSelectedLanguages() { - $config = $this->config; - $allowed = \oxcom\phpbbch\core\settings::getLanguages(); $allowed = array_keys($allowed); // get list of selected languages - $enabled = array_filter($allowed, function ($key) use ($config) { - $key = 'oxcom_phpbbch_lang_' . $key; + return \array_filter($allowed, function ($key) { + $key = 'oxcom_phpbbch_lang_'.$key; $status = $this->config[$key]; return !empty($status) && $status === main_module::ENUM_ALLOWED_YES; }); - - return $enabled; } /** diff --git a/language/en/phpbbch.php b/language/en/phpbbch.php index 8f58b23..ca9fc8c 100644 --- a/language/en/phpbbch.php +++ b/language/en/phpbbch.php @@ -19,6 +19,11 @@ 'ACP_PHPBBCH_LANGUAGES' => 'Languages', 'ACP_PHPBBCH_THEME' => 'Theme', + 'ACP_PHPBBCH_THEME_D' => 'Please visit this site to get more information about themes', + 'ACP_PHPBBCH_BEHAVIOUR' => 'Behaviour', + 'ACP_PHPBBCH_BEHAVIOUR_D' => 'Customize plugin behaviour.', + + 'ACP_PHPBBCH_BEHAVIOUR_EXT_ONLY' => 'Force formatting only code blocks created by this extension only.', 'PHPBBCH_POST_TAB_TITLE' => 'Syntax Highlight', 'PHPBBCH_POST_TAB_HELP' => 'Please find list of available languages', diff --git a/migrations/format_only_ext.php b/migrations/format_only_ext.php new file mode 100644 index 0000000..f794841 --- /dev/null +++ b/migrations/format_only_ext.php @@ -0,0 +1,41 @@ +config['oxcom_phpbbch_format_only']); + } + + /** + * This migration depends on phpBB's v314 migration + * already being installed. + */ + static public function depends_on() + { + return [ + '\phpbb\db\migration\data\v31x\v314', + '\oxcom\phpbbch\migrations\add_module', + ]; + } + + public function update_data() + { + return [ + ['config.add', ['oxcom_phpbbch_format_only', 'N']], + ]; + } + + public function revert_data() + { + return [ + ['config.remove', ['oxcom_phpbbch_format_only']], + ]; + } +} diff --git a/styles/all/template/js/init.js b/styles/all/template/js/init.js index 5c32f20..d4a6798 100644 --- a/styles/all/template/js/init.js +++ b/styles/all/template/js/init.js @@ -4,7 +4,9 @@ $(function () { tabReplace: ' ' // 4 spaces }); - $('code') + var selector = window.oxcom_phpbbch_config.behavior.format_only_ext ? "code[data-bind=\'phpbbch-code\']" : 'code'; + + $(selector) .each(function (i, block) { if ($(block).data('bind') !== 'phpbbch-code') { var content = $(block).html(); diff --git a/styles/all/template/phpbbch_init.html b/styles/all/template/phpbbch_init.html index 75847bf..f20c534 100644 --- a/styles/all/template/phpbbch_init.html +++ b/styles/all/template/phpbbch_init.html @@ -1,3 +1,11 @@ + + {% INCLUDEJS '@oxcom_phpbbch/js/higlightjs/highlight.min.js' %} {% for lang in PHPBBCH_ALLOWED_LANGS %}