first commit
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
;; @package Sourcerer
|
||||
;; @version 9.4.1
|
||||
;;
|
||||
;; @author Peter van Westen <info@regularlabs.com>
|
||||
;; @link http://regularlabs.com
|
||||
;; @copyright Copyright © 2023 Regular Labs All Rights Reserved
|
||||
;; @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
|
||||
;;
|
||||
;; @translate Want to help with translations? See: https://regularlabs.com/translate
|
||||
|
||||
PLG_SYSTEM_SOURCERER="System - Regular Labs - Sourcerer"
|
||||
PLG_SYSTEM_SOURCERER_DESC="Sourcerer - place any code in Joomla!"
|
||||
SOURCERER="Sourcerer"
|
||||
|
||||
INSERT_CODE="Insert Code"
|
||||
SOURCERER_DESC="<p>The Sourcerer plugin handles all the Sourcerer syntax tags in your site.</p><p>You can place your html, javascript, css and php code (including there own tags) inside the Sourcerer tags:<br><span class="rl-code rl-code-block">{source}Your code{/source}</span></p>"
|
||||
|
||||
SRC_EXTENSION_CAN_NOT_FUNCTION="[[%1:extension name%]] cannot function."
|
||||
SRC_REGULAR_LABS_LIBRARY_NOT_ENABLED="Regular Labs Library plugin is not enabled."
|
||||
SRC_REGULAR_LABS_LIBRARY_NOT_INSTALLED="Regular Labs Library plugin is not installed."
|
||||
|
||||
COM_PLUGINS_SRC_SECURITY_SETTINGS_ARTICLES_FIELDSET_LABEL="Security - Articles"
|
||||
COM_PLUGINS_SRC_SECURITY_SETTINGS_COMPONENTS_FIELDSET_LABEL="Security - Components"
|
||||
COM_PLUGINS_SRC_SECURITY_SETTINGS_DEFAULT_FIELDSET_LABEL="Security - Default"
|
||||
COM_PLUGINS_SRC_SECURITY_SETTINGS_OTHER_AREAS_FIELDSET_LABEL="Security - Other Areas"
|
||||
|
||||
SRC_ALLOW_CSS_TAGS="Allow CSS tags"
|
||||
SRC_ALLOW_CSS_TAGS_DESC="If enabled, CSS (style & link) tags are permitted within the Sourcerer tags. Otherwise the CSS tags (and the CSS code within) will be stripped."
|
||||
SRC_ALLOW_JAVASCRIPT_TAGS="Allow JavaScript tags"
|
||||
SRC_ALLOW_JAVASCRIPT_TAGS_DESC="If enabled, JavaScript (script) tags are permitted within the Sourcerer tags. Otherwise the JavaScript tags (and the JavaScript code within) will be stripped."
|
||||
SRC_ALLOW_PHP_TAGS="Allow PHP tags"
|
||||
SRC_ALLOW_PHP_TAGS_DESC="If enabled, PHP tags are permitted within the Sourcerer tags. Otherwise the PHP tags (and the PHP code within) will be stripped."
|
||||
SRC_BODY_AFTER="End of HTML body"
|
||||
SRC_BODY_BEFORE="Before HTML body"
|
||||
SRC_CODE="Code"
|
||||
SRC_CODE_DESC="You can enter your HTML, CSS, JavaScript and/or PHP code in the field below."
|
||||
SRC_CODE_PLACEMENT="Placement"
|
||||
SRC_CODE_PLACEMENT_DESC="Select whether to load the code in the html head or inline where you place this the Sourcerer tag."
|
||||
SRC_CODE_POSITION="Position"
|
||||
SRC_CODE_POSITION_DESC="Set the position in the html to place the code."
|
||||
SRC_CODE_REMOVED_NOT_ALLOWED="The [[%1:code type%]] code has been removed, because [[%1:code type%]] is not allowed here."
|
||||
SRC_CODE_REMOVED_NOT_ENABLED="The code has been removed, because Sourcerer is not enabled here."
|
||||
SRC_CODE_REMOVED_SECURITY="The %s code has been removed, because the owner of this article does not pass the security level."
|
||||
SRC_COLOR_CODE="Color Code"
|
||||
SRC_COLOR_CODE_DESC="Select to have the editor button add colors to the code when inserting it into the editor."
|
||||
SRC_CSS="CSS"
|
||||
SRC_CSS_CODE_DESC="The CSS code will be added to the Head of the HTML document."
|
||||
SRC_CSS_FILE_DESC="The CSS file will be added to the Head of the HTML document."
|
||||
SRC_CSS_SECURITY_LEVEL="CSS Security Level"
|
||||
SRC_CSS_SECURITY_LEVEL_DESC="Set the level of security. CSS tags (and the CSS code within) will be stripped from articles with an owner (creator) below this group level. If the overall security level is set higher, it will overrule this."
|
||||
SRC_DEFAULTS="Defaults"
|
||||
SRC_DEFAULTS_DESC="These setting have effect on the initial settings when you open the Sourcerer Code Helper window."
|
||||
SRC_DISABLE_ON_COMPONENTS_DESC="Select which components NOT to enable Sourcerer in. This is a list of your installed frontend components."
|
||||
SRC_ENABLE_IN_ARTICLES_DESC="Select whether to enable the use of the syntax in articles."
|
||||
SRC_ENABLE_IN_COMPONENTS_DESC="Select whether to enable the use of the syntax in components."
|
||||
SRC_ENABLE_IN_HEAD="Enable in Head"
|
||||
SRC_ENABLE_IN_HEAD_DESC="Select to also handle the Sourcerer tags inside the document head section of the page. If unselected, any Sourcerer tags found in the head will get removed (together with any code inside them)."
|
||||
SRC_ENABLE_OTHER_AREAS_DESC="Select whether to enable the use of the syntax in all remaining areas, like the modules and the document head."
|
||||
SRC_ERROR_CODEMIRROR_DISABLED="The CodeMirror editor is disable. Sourcerer needs this editor to function. [[%1:link start]]Please enabled it.[[%2:link end]]"
|
||||
SRC_EXAMPLE_CODE="Example Code"
|
||||
SRC_EXAMPLE_CODE_DESC="Here you can place the example code you want to be placed inside the Sourcerer tags. If you leave this field empty and save it, this field will be reset to the default example code."
|
||||
SRC_EXTRA_FORBIDDEN_HTML_TAGS="Extra Forbidden (HTML) Tags"
|
||||
SRC_EXTRA_FORBIDDEN_HTML_TAGS_DESC="A comma separated list of tags to add to the forbidden list (see Default settings)"
|
||||
SRC_EXTRA_FORBIDDEN_PHP_FUNCTIONS="Extra Forbidden PHP functions"
|
||||
SRC_EXTRA_FORBIDDEN_PHP_FUNCTIONS_DESC="A comma separated list of PHP functions to add to the forbidden list (see Default settings)"
|
||||
SRC_EXTRA_TABS_DESC="Or use the extra tabs to help you insert specific CSS, JavaScript and PHP files and code."
|
||||
SRC_FILE="File"
|
||||
SRC_FORBIDDEN_HTML_TAGS="Forbidden (HTML) Tags"
|
||||
SRC_FORBIDDEN_HTML_TAGS_DESC="A comma separated list of tags that are forbidden. These tags will be stripped, and also any code in between double tags."
|
||||
SRC_FORBIDDEN_PHP_FUNCTIONS="Forbidden PHP functions"
|
||||
SRC_FORBIDDEN_PHP_FUNCTIONS_DESC="A comma separated list of PHP functions that are forbidden. The whole PHP block of code will not be executed if it contains any of these functions."
|
||||
SRC_HTML_HEAD="HTML Head"
|
||||
SRC_INCLUDE_PATH="Include Path"
|
||||
SRC_INCLUDE_PATH_DESC="The path (relative to the root folder) to use when using the file attribute in the tag."
|
||||
SRC_INLINE="Inline"
|
||||
SRC_INSERT="Insert"
|
||||
SRC_JAVASCRIPT="JavaScript"
|
||||
SRC_JAVASCRIPT_SECURITY_LEVEL="JavaScript Security Level"
|
||||
SRC_JAVASCRIPT_SECURITY_LEVEL_DESC="Set the level of security. JavaScript tags (and the JavaScript code within) will be stripped from articles with an owner (creator) below this group level. If the overall security level is set higher, it will overrule this."
|
||||
SRC_JS_FILE_ASYNC="Async"
|
||||
SRC_JS_FILE_ASYNC_DESC="Select to make the javascipt file run asynchronously as soon as it is available."
|
||||
SRC_JS_FILE_DEFER="Defer"
|
||||
SRC_JS_FILE_DEFER_DESC="Select to make the javascipt file run after the page has loaded."
|
||||
SRC_JS_FILE_DESC="The JavaScript file will be added to the Head of the HTML document."
|
||||
SRC_ONLY_IN_ADMINISTRATOR="Only in Administrator"
|
||||
SRC_PHP="PHP"
|
||||
SRC_PHP_CODE_DESC="The <span class="rl-code">&lt;?php ... ?&gt;</span> will be added automatically, so you should not add them to your code."
|
||||
SRC_PHP_CODE_REMOVED_FORBIDDEN="The PHP code has been removed, because it contains forbidden PHP functions"
|
||||
SRC_PHP_FORBIDDEN="The PHP code contains forbidden PHP functions"
|
||||
SRC_PHP_INCLUDE_METHOD="Include Method"
|
||||
SRC_PHP_INCLUDE_METHOD_DESC="Select the way to load in the php file."
|
||||
SRC_PHP_SECURITY_LEVEL="PHP Security Level"
|
||||
SRC_PHP_SECURITY_LEVEL_DESC="Set the level of security. PHP tags (and the PHP code within) will be stripped from articles with an owner (creator) below this group level. If the overall security level is set higher, it will overrule this."
|
||||
SRC_RAW="Raw Code"
|
||||
SRC_RAW_DESC="Not using a WYSIWYG editor? Select to prevent Sourcerer from stripping the HTML code."
|
||||
SRC_REMOVE_FROM_SEARCH="Remove from search"
|
||||
SRC_REMOVE_FROM_SEARCH_DESC="Select to remove the Sourcerer tags and content from the search results."
|
||||
SRC_SECURITY_LEVEL="Security Level"
|
||||
SRC_SECURITY_LEVEL_DESC="Set the level of security. Sourcerer tags will be stripped from articles where the an owner (creator) is not a member of these groups."
|
||||
SRC_SECURITY_SETTINGS_ARTICLES_DESC="These settings have effect on Articles and Categories.<br>The security settings only have effect on articles."
|
||||
SRC_SECURITY_SETTINGS_COMPONENTS_DESC="These settings have effect on the component area.<br>You can select in which components Sourcerer should not be enabled. Advise is to not allow Sourcerer in components that non-backend users can post content in."
|
||||
SRC_SECURITY_SETTINGS_DEFAULT_DESC="Here you can set what kind of code can be used within the Sourcerer tags. All code that is not permitted will be stripped away. For more precise settings, see the other Security tabs."
|
||||
SRC_SECURITY_SETTINGS_OTHER_AREAS_DESC="These settings have effect on the areas outside the component area (so in Modules and the rest of the website)."
|
||||
SRC_SHOW_WIZARD="Show Wizard"
|
||||
SRC_SYNTAX_WORD="Sourcerer tag word"
|
||||
SRC_SYNTAX_WORD_DESC="This defines the word to use as the Sourcerer syntax tag.<br><br>Default is 'source'. Which means the tags to use are: <span class="rl-code">{source}...{/source}</span>"
|
||||
SRC_TAG_ATTRIBUTES="Tag Attributes"
|
||||
SRC_TAG_ATTRIBUTES_DESC="Enter any attributes you want to add inside the Sourcerer tag itself."
|
||||
SRC_TAG_REMOVED_FORBIDDEN="The tag (%s) has been removed, because it is forbidden."
|
||||
SRC_TAG_SETTINGS="Tag Settings"
|
||||
SRC_TEMP_PATH="Temporary File Folder"
|
||||
SRC_TEMP_PATH_DESC="Please specify a writable folder to store temporary files.<br>Leave empty to use the Joomla global Temp Folder."
|
||||
SRC_TRIM="Strip surrounding HTML tags"
|
||||
SRC_TRIM_DESC="Select to make Sourcerer remove the surrounding paragraph tags (or span tags)."
|
||||
@@ -0,0 +1,13 @@
|
||||
;; @package Sourcerer
|
||||
;; @version 9.4.1
|
||||
;;
|
||||
;; @author Peter van Westen <info@regularlabs.com>
|
||||
;; @link http://regularlabs.com
|
||||
;; @copyright Copyright © 2023 Regular Labs All Rights Reserved
|
||||
;; @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
|
||||
;;
|
||||
;; @translate Want to help with translations? See: https://regularlabs.com/translate
|
||||
|
||||
PLG_SYSTEM_SOURCERER="System - Regular Labs - Sourcerer"
|
||||
PLG_SYSTEM_SOURCERER_DESC="Sourcerer - place any code in Joomla!"
|
||||
SOURCERER="Sourcerer"
|
||||
@@ -0,0 +1,114 @@
|
||||
;; @package Sourcerer
|
||||
;; @version 9.4.1
|
||||
;;
|
||||
;; @author Peter van Westen <info@regularlabs.com>
|
||||
;; @link http://regularlabs.com
|
||||
;; @copyright Copyright © 2023 Regular Labs All Rights Reserved
|
||||
;; @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
|
||||
;;
|
||||
;; @translate Want to help with translations? See: https://regularlabs.com/translate
|
||||
|
||||
PLG_SYSTEM_SOURCERER="System - Regular Labs - Sourcerer"
|
||||
PLG_SYSTEM_SOURCERER_DESC="Sourcerer - Wstaw każdy kod do Joomli!"
|
||||
SOURCERER="Sourcerer"
|
||||
|
||||
INSERT_CODE="Wstaw kod"
|
||||
SOURCERER_DESC="<p>Wtyczka Sourcerer kontroluje wszystkie znaczniki składni Sourcerer'a na twojej witrynie.</p><p>Możesz umieszczać html, javascript, css oraz kod php (oraz ich znaczniki) pomiędzy znacznikami Sourcerer'a:<br><span class="rl-code rl-code-block">{source}twój kod{/source}</span></p>"
|
||||
|
||||
SRC_EXTENSION_CAN_NOT_FUNCTION="[[%1:extension name%]] nie może działać."
|
||||
SRC_REGULAR_LABS_LIBRARY_NOT_ENABLED="Wtyczka Regular Labs Library nie jest włączona."
|
||||
SRC_REGULAR_LABS_LIBRARY_NOT_INSTALLED="Plugin Regular Labs Library nie jest zainstalowany."
|
||||
|
||||
COM_PLUGINS_SRC_SECURITY_SETTINGS_ARTICLES_FIELDSET_LABEL="Bezpieczeństwa - Artykuły"
|
||||
COM_PLUGINS_SRC_SECURITY_SETTINGS_COMPONENTS_FIELDSET_LABEL="Bezpieczeństwa - Komponenty"
|
||||
COM_PLUGINS_SRC_SECURITY_SETTINGS_DEFAULT_FIELDSET_LABEL="Bezpieczeństwa - Domyślne"
|
||||
COM_PLUGINS_SRC_SECURITY_SETTINGS_OTHER_AREAS_FIELDSET_LABEL="Bezpieczeństwa - Inne Miejsca"
|
||||
|
||||
SRC_ALLOW_CSS_TAGS="Zezwól na znaczniki CSS"
|
||||
SRC_ALLOW_CSS_TAGS_DESC="Po włączeniu, znaczniki CSS (styl + link) są dozwolone pomiędzy znacznikami Sourcerer'a. W przeciwnym wypadku znaczniki CSS (oraz wewnętrzny kod CSS) będą usunięte."
|
||||
SRC_ALLOW_JAVASCRIPT_TAGS="Zezwól na znaczniki JavaScript"
|
||||
SRC_ALLOW_JAVASCRIPT_TAGS_DESC="Po włączeniu, znaczniki JavaScript (skrypt) są dozwolone powiędzy znacznikami Sourcerer'a. W przeciwnym wypadku znaczniki JavaScript (oraz wewnętrzny kod JavaScript) będą usunięte."
|
||||
SRC_ALLOW_PHP_TAGS="Zezwól na znaczniki PHP"
|
||||
SRC_ALLOW_PHP_TAGS_DESC="Po włączeniu, znaczniki PHP są dozwolone pomiędzy znacznikami Sourcerer'a. W przeciwnym wypadku znaczniki PHP (oraz wewnętrzny kod PHP) będą usunięte."
|
||||
; SRC_BODY_AFTER="End of HTML body"
|
||||
; SRC_BODY_BEFORE="Before HTML body"
|
||||
SRC_CODE="Kod"
|
||||
; SRC_CODE_DESC="You can enter your HTML, CSS, JavaScript and/or PHP code in the field below."
|
||||
; SRC_CODE_PLACEMENT="Placement"
|
||||
; SRC_CODE_PLACEMENT_DESC="Select whether to load the code in the html head or inline where you place this the Sourcerer tag."
|
||||
SRC_CODE_POSITION="Położenie"
|
||||
; SRC_CODE_POSITION_DESC="Set the position in the html to place the code."
|
||||
SRC_CODE_REMOVED_NOT_ALLOWED="Kod [[%1:code type%]] został usunięty, ponieważ [[%1:code type%]] jest tu niedozwolony."
|
||||
SRC_CODE_REMOVED_NOT_ENABLED="Kod został usunięty, ponieważ Sourcerer jest tu wyłączony."
|
||||
SRC_CODE_REMOVED_SECURITY="Kod %s został usunięty, ponieważ właściciel tego artykułu jest na niższym poziomie bezpieczeństwa."
|
||||
; SRC_COLOR_CODE="Color Code"
|
||||
; SRC_COLOR_CODE_DESC="Select to have the editor button add colors to the code when inserting it into the editor."
|
||||
SRC_CSS="CSS"
|
||||
; SRC_CSS_CODE_DESC="The CSS code will be added to the Head of the HTML document."
|
||||
; SRC_CSS_FILE_DESC="The CSS file will be added to the Head of the HTML document."
|
||||
SRC_CSS_SECURITY_LEVEL="Poziom Bezpieczeństwa CSS"
|
||||
SRC_CSS_SECURITY_LEVEL_DESC="Ustaw poziom bezpieczeństwa. Znaczniki CSS (oraz wewnętrzny kod CSS) zostaną usunięte z artykułów których właściciel (twórca) należy do grupy niższej niż obecna. Jeśli ogólny poziom bezpieczeństwa jest wyższy, będzie brał górę nad tymi ustawieniami."
|
||||
SRC_DEFAULTS="Domyslne"
|
||||
SRC_DEFAULTS_DESC="Te ustawienia maja wplyw na ustawienia poczatkowe po otwarciu okna Sourcerer Code Helper"
|
||||
SRC_DISABLE_ON_COMPONENTS_DESC="Wybierz komponenty które nie mogą korzystać z Sourcerer'a. Ta lista zawiera zainstalowane komponenty."
|
||||
SRC_ENABLE_IN_ARTICLES_DESC="Wybierz czy włączyć użycie składni w artykułach"
|
||||
SRC_ENABLE_IN_COMPONENTS_DESC="Wybierz czy włączyć użycie składni w komponentach."
|
||||
SRC_ENABLE_IN_HEAD="Aktywne w sekcji HEAD strony"
|
||||
SRC_ENABLE_IN_HEAD_DESC="Wybierz, aby przetrzymywać tagi Sourcerera wewnątrz sekcji HEAD tej strony. Jeśli ta opcja zostanie odznaczona, jakiekolwiek tagi Sourcerera znalezione w sekcji HEAD zostaną usunięte (razem z kodem zawartym pomiędzy nimi)."
|
||||
SRC_ENABLE_OTHER_AREAS_DESC="Wybierz czy używać składni we wszystkich pozostałych miejscach, takich jak moduły oraz w sekcji HEAD dokumentu."
|
||||
SRC_ERROR_CODEMIRROR_DISABLED="Edytor CodeMirror jest nieaktywny. Sourcerer potrzebuje tego edytora do poprawnego działania. [[%1:link start]]Proszę, uaktywnij go.[[%2:link end]]"
|
||||
SRC_EXAMPLE_CODE="Przykladowy kod"
|
||||
SRC_EXAMPLE_CODE_DESC="Tutaj mozesz wstawic przykladowy kod do umieszczenia w znacznikach Sourcerer. Gdy zostawisz to pole puste i zapiszesz w polu tym zostanie umieszczony domyslny przykladowy kod."
|
||||
SRC_EXTRA_FORBIDDEN_HTML_TAGS="Dodatkowe Niedozwolone Znaczniki (HTML)"
|
||||
SRC_EXTRA_FORBIDDEN_HTML_TAGS_DESC="Lista znaczników oddzielonych przecinkiem, którą chcesz dodać to listy niedozwolonych (zobacz ustawienia Domyślne)"
|
||||
SRC_EXTRA_FORBIDDEN_PHP_FUNCTIONS="Dodatkowe Niedozwolone funkcje PHP"
|
||||
SRC_EXTRA_FORBIDDEN_PHP_FUNCTIONS_DESC="Lista funkcji PHP oddzielonych przecinkiem, którą chcesz dodać to listy niedozwolonych (zobacz ustawienia Domyślne)"
|
||||
; SRC_EXTRA_TABS_DESC="Or use the extra tabs to help you insert specific CSS, JavaScript and PHP files and code."
|
||||
; SRC_FILE="File"
|
||||
SRC_FORBIDDEN_HTML_TAGS="Niedozwolone znaczniki (HTML)"
|
||||
SRC_FORBIDDEN_HTML_TAGS_DESC="Lista znaczników oddzielonych przecinkiem, które są niedozwolone. Te znaczniki zostaną usunięte wraz z jakimkolwiek kodem pomiędzy podwójnymi znacznikami."
|
||||
SRC_FORBIDDEN_PHP_FUNCTIONS="Niedozwolone funkcje PHP"
|
||||
SRC_FORBIDDEN_PHP_FUNCTIONS_DESC="Lista funkcji PHP oddzielonych przecinkiem, które są niedozwolone. Jeśli blok PHP zawiera którąkolwiek z tych funkcji, zostanie pominięty w całości."
|
||||
; SRC_HTML_HEAD="HTML Head"
|
||||
SRC_INCLUDE_PATH="Ścieżka Dołączana"
|
||||
SRC_INCLUDE_PATH_DESC="Ścieżka (względna do folderu głównego) używana podczasz korzystania z atrybutu pliku w znaczniku."
|
||||
; SRC_INLINE="Inline"
|
||||
SRC_INSERT="Wstaw"
|
||||
SRC_JAVASCRIPT="JavaScript"
|
||||
SRC_JAVASCRIPT_SECURITY_LEVEL="Poziom Bezpieczeństwa JavaScript"
|
||||
SRC_JAVASCRIPT_SECURITY_LEVEL_DESC="Ustaw poziom bezpieczeństwa. Znaczniki JavaScript (oraz wewnętrzny kod JavaScript) zostaną usunięte z artykułów których właściciel (twórca) należy do grupy niższej niż obecna. Jeśli ogólny poziom bezpieczeństwa jest wyższy, będzie brał górę nad tymi ustawieniami."
|
||||
; SRC_JS_FILE_ASYNC="Async"
|
||||
; SRC_JS_FILE_ASYNC_DESC="Select to make the javascipt file run asynchronously as soon as it is available."
|
||||
; SRC_JS_FILE_DEFER="Defer"
|
||||
; SRC_JS_FILE_DEFER_DESC="Select to make the javascipt file run after the page has loaded."
|
||||
; SRC_JS_FILE_DESC="The JavaScript file will be added to the Head of the HTML document."
|
||||
SRC_ONLY_IN_ADMINISTRATOR="Tylko dla Administratora"
|
||||
SRC_PHP="PHP"
|
||||
; SRC_PHP_CODE_DESC="The <span class="rl-code">&lt;?php ... ?&gt;</span> will be added automatically, so you should not add them to your code."
|
||||
SRC_PHP_CODE_REMOVED_FORBIDDEN="Kod PHP został usunięty, ponieważ zawiera niedozwolone funkcje PHP"
|
||||
SRC_PHP_FORBIDDEN="Kod PHP zawiera niedozwolone funkcje PHP"
|
||||
; SRC_PHP_INCLUDE_METHOD="Include Method"
|
||||
; SRC_PHP_INCLUDE_METHOD_DESC="Select the way to load in the php file."
|
||||
SRC_PHP_SECURITY_LEVEL="Poziom Bezpieczeństwa PHP"
|
||||
SRC_PHP_SECURITY_LEVEL_DESC="Ustaw poziom bezpieczeństwa. Znaczniki PHP (oraz wewnętrzny kod PHP) zostaną usunięte z artykułów których właściciel (twórca) należy do grupy niższej niż obecna. Jeśli ogólny poziom bezpieczeństwa jest wyższy, będzie brał górę nad tymi ustawieniami."
|
||||
; SRC_RAW="Raw Code"
|
||||
; SRC_RAW_DESC="Not using a WYSIWYG editor? Select to prevent Sourcerer from stripping the HTML code."
|
||||
SRC_REMOVE_FROM_SEARCH="Usuń z wyszukiwania"
|
||||
SRC_REMOVE_FROM_SEARCH_DESC="Wybierz, aby usunąć tagi i zawartość Sourcerera z wyników wyszukiwania."
|
||||
SRC_SECURITY_LEVEL="Poziom Bezpieczeństwa"
|
||||
SRC_SECURITY_LEVEL_DESC="Ustaw poziom bezpieczeństwa. Znaczniki Sourcerer'a zostaną usunięte z artykułów których właściciel (twórca) nie jest członkiem tych grup."
|
||||
SRC_SECURITY_SETTINGS_ARTICLES_DESC="Te ustawienia wpływają na Artykuły i Kategorie.<br>Bezpieczeństwa mają wpływ wyłącznie na artykuły."
|
||||
SRC_SECURITY_SETTINGS_COMPONENTS_DESC="Te ustawienia mają wpływ na komponenty.<br>Możesz ustawić w których komponentach Sourcerer nie powinien działać. Odradza się używanie Sourcerer'a w komponentach w których użytkownik witryny może coś dodać."
|
||||
SRC_SECURITY_SETTINGS_DEFAULT_DESC="Tu możesz ustawić jaki kod może być użyty pomiędzy znacznikami Sourcerer'a. Kod niedozwolony zostanie usunięty. Szczegółowe ustawienia znajdują się w sekcji Zaawansowane Bezpieczeństwo."
|
||||
SRC_SECURITY_SETTINGS_OTHER_AREAS_DESC="Te ustawienia mają wpływ na miejsca poza komponentem (czyli na Moduły i pozostałość witryny)."
|
||||
SRC_SHOW_WIZARD="Pokaż Przewodnik"
|
||||
SRC_SYNTAX_WORD="Znacznik Sourcerer'a"
|
||||
SRC_SYNTAX_WORD_DESC="Tu podajesz wyraz który będzie znacznikiem składni Sourcerer'a.<br><br>Domyślnie jest to 'source'. Co oznacza że używasz: <span class="rl-code">{source}...{/source}</span>"
|
||||
; SRC_TAG_ATTRIBUTES="Tag Attributes"
|
||||
; SRC_TAG_ATTRIBUTES_DESC="Enter any attributes you want to add inside the Sourcerer tag itself."
|
||||
SRC_TAG_REMOVED_FORBIDDEN="Znacznik (%s) został usunięty, ponieważ jest niedozwolony."
|
||||
; SRC_TAG_SETTINGS="Tag Settings"
|
||||
; SRC_TEMP_PATH="Temporary File Folder"
|
||||
; SRC_TEMP_PATH_DESC="Please specify a writable folder to store temporary files.<br>Leave empty to use the Joomla global Temp Folder."
|
||||
; SRC_TRIM="Strip surrounding HTML tags"
|
||||
; SRC_TRIM_DESC="Select to make Sourcerer remove the surrounding paragraph tags (or span tags)."
|
||||
@@ -0,0 +1,13 @@
|
||||
;; @package Sourcerer
|
||||
;; @version 9.4.1
|
||||
;;
|
||||
;; @author Peter van Westen <info@regularlabs.com>
|
||||
;; @link http://regularlabs.com
|
||||
;; @copyright Copyright © 2023 Regular Labs All Rights Reserved
|
||||
;; @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
|
||||
;;
|
||||
;; @translate Want to help with translations? See: https://regularlabs.com/translate
|
||||
|
||||
PLG_SYSTEM_SOURCERER="System - Regular Labs - Sourcerer"
|
||||
PLG_SYSTEM_SOURCERER_DESC="Sourcerer - Wstaw każdy kod do Joomli!"
|
||||
SOURCERER="Sourcerer"
|
||||
60
plugins/system/sourcerer/script.install.php
Normal file
60
plugins/system/sourcerer/script.install.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Sourcerer
|
||||
* @version 9.4.1
|
||||
*
|
||||
* @author Peter van Westen <info@regularlabs.com>
|
||||
* @link http://regularlabs.com
|
||||
* @copyright Copyright © 2023 Regular Labs All Rights Reserved
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Filesystem\File as JFile;
|
||||
use Joomla\CMS\Filesystem\Folder as JFolder;
|
||||
|
||||
class PlgSystemSourcererInstallerScript
|
||||
{
|
||||
public function postflight($install_type, $adapter)
|
||||
{
|
||||
if ( ! in_array($install_type, ['install', 'update']))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
self::deleteJoomla3Files();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static function delete($files = [])
|
||||
{
|
||||
foreach ($files as $file)
|
||||
{
|
||||
if (is_dir($file))
|
||||
{
|
||||
JFolder::delete($file);
|
||||
}
|
||||
|
||||
if (is_file($file))
|
||||
{
|
||||
JFile::delete($file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function deleteJoomla3Files()
|
||||
{
|
||||
self::delete(
|
||||
[
|
||||
JPATH_SITE . '/media/sourcerer/css',
|
||||
JPATH_SITE . '/media/sourcerer/js/script.js',
|
||||
JPATH_SITE . '/media/sourcerer/js/script.min.js',
|
||||
JPATH_SITE . '/media/sourcerer/less',
|
||||
JPATH_SITE . '/plugins/system/sourcerer/src/Code.php',
|
||||
JPATH_SITE . '/plugins/system/sourcerer/vendor',
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
150
plugins/system/sourcerer/sourcerer.php
Normal file
150
plugins/system/sourcerer/sourcerer.php
Normal file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Sourcerer
|
||||
* @version 9.4.1
|
||||
*
|
||||
* @author Peter van Westen <info@regularlabs.com>
|
||||
* @link http://regularlabs.com
|
||||
* @copyright Copyright © 2023 Regular Labs All Rights Reserved
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory as JFactory;
|
||||
use Joomla\CMS\Language\Text as JText;
|
||||
use RegularLabs\Library\Document as RL_Document;
|
||||
use RegularLabs\Library\Extension as RL_Extension;
|
||||
use RegularLabs\Library\Html as RL_Html;
|
||||
use RegularLabs\Library\Protect as RL_Protect;
|
||||
use RegularLabs\Library\SystemPlugin as RL_SystemPlugin;
|
||||
use RegularLabs\Plugin\System\Sourcerer\Area;
|
||||
use RegularLabs\Plugin\System\Sourcerer\Clean;
|
||||
use RegularLabs\Plugin\System\Sourcerer\Params;
|
||||
use RegularLabs\Plugin\System\Sourcerer\Protect;
|
||||
use RegularLabs\Plugin\System\Sourcerer\Replace;
|
||||
use RegularLabs\Plugin\System\Sourcerer\Security;
|
||||
|
||||
// Do not instantiate plugin on install pages
|
||||
// to prevent installation/update breaking because of potential breaking changes
|
||||
$input = JFactory::getApplication()->input;
|
||||
if (in_array($input->get('option', ''), ['com_installer', 'com_regularlabsmanager']) && $input->get('action', '') != '')
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! is_file(JPATH_LIBRARIES . '/regularlabs/regularlabs.xml')
|
||||
|| ! is_file(JPATH_LIBRARIES . '/regularlabs/src/SystemPlugin.php')
|
||||
|| ! is_file(JPATH_LIBRARIES . '/regularlabs/src/DownloadKey.php')
|
||||
)
|
||||
{
|
||||
JFactory::getLanguage()->load('plg_system_sourcerer', __DIR__);
|
||||
JFactory::getApplication()->enqueueMessage(
|
||||
JText::sprintf('SRC_EXTENSION_CAN_NOT_FUNCTION', JText::_('SOURCERER'))
|
||||
. ' ' . JText::_('SRC_REGULAR_LABS_LIBRARY_NOT_INSTALLED'),
|
||||
'error'
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! RL_Document::isJoomlaVersion(4, 'SOURCERER'))
|
||||
{
|
||||
RL_Extension::disable('sourcerer', 'plugin');
|
||||
|
||||
RL_Document::adminError(
|
||||
JText::sprintf('RL_PLUGIN_HAS_BEEN_DISABLED', JText::_('SOURCERER'))
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (true)
|
||||
{
|
||||
class PlgSystemSourcerer extends RL_SystemPlugin
|
||||
{
|
||||
public $_lang_prefix = 'SRC';
|
||||
public $_disable_on_components = true;
|
||||
public $_can_disable_by_url = false;
|
||||
public $_has_tags = true;
|
||||
public $_jversion = 4;
|
||||
|
||||
protected function handleOnContentPrepare($area, $context, &$article, &$params, $page = 0)
|
||||
{
|
||||
$src_params = Params::get();
|
||||
|
||||
$area = isset($article->created_by) ? 'articles' : 'other';
|
||||
|
||||
$remove = $src_params->remove_from_search
|
||||
&& in_array($context, ['com_search.search', 'com_search.search.article', 'com_finder.indexer']);
|
||||
|
||||
|
||||
if (isset($article->description))
|
||||
{
|
||||
Replace::replace($article->description, $area, $article, $remove);
|
||||
}
|
||||
|
||||
if (isset($article->title))
|
||||
{
|
||||
Replace::replace($article->title, $area, $article, $remove);
|
||||
}
|
||||
|
||||
// Don't handle article texts in category list view
|
||||
if (RL_Document::isCategoryList($context))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isset($article->text))
|
||||
{
|
||||
Replace::replace($article->text, $area, $article, $remove);
|
||||
|
||||
// Don't also do stuff on introtext/fulltext if text is set
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isset($article->introtext))
|
||||
{
|
||||
Replace::replace($article->introtext, $area, $article, $remove);
|
||||
}
|
||||
|
||||
if (isset($article->fulltext))
|
||||
{
|
||||
Replace::replace($article->fulltext, $area, $article, $remove);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function changeDocumentBuffer(&$buffer)
|
||||
{
|
||||
if ( ! RL_Document::isHtml())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return Area::tag($buffer, 'component');
|
||||
}
|
||||
|
||||
protected function changeFinalHtmlOutput(&$html)
|
||||
{
|
||||
$params = Params::get();
|
||||
|
||||
[$pre, $body, $post] = RL_Html::getBody($html);
|
||||
|
||||
Protect::_($body);
|
||||
Replace::replaceInTheRest($body);
|
||||
|
||||
Clean::cleanFinalHtmlOutput($body);
|
||||
RL_Protect::unprotect($body);
|
||||
|
||||
$params->enable_in_head
|
||||
? Replace::replace($pre, 'head')
|
||||
: Clean::cleanTagsFromHead($pre);
|
||||
|
||||
$html = $pre . $body . $post;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
148
plugins/system/sourcerer/sourcerer.xml
Normal file
148
plugins/system/sourcerer/sourcerer.xml
Normal file
@@ -0,0 +1,148 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension version="4" type="plugin" group="system" method="upgrade">
|
||||
<name>PLG_SYSTEM_SOURCERER</name>
|
||||
<description>PLG_SYSTEM_SOURCERER_DESC</description>
|
||||
<version>9.4.1</version>
|
||||
<creationDate>February 2023</creationDate>
|
||||
<author>Regular Labs (Peter van Westen)</author>
|
||||
<authorEmail>info@regularlabs.com</authorEmail>
|
||||
<authorUrl>https://regularlabs.com</authorUrl>
|
||||
<copyright>Copyright © 2023 Regular Labs - All Rights Reserved</copyright>
|
||||
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
|
||||
<namespace path="src">RegularLabs\Plugin\System\Sourcerer</namespace>
|
||||
<scriptfile>script.install.php</scriptfile>
|
||||
<files>
|
||||
<file plugin="sourcerer">sourcerer.php</file>
|
||||
<folder>language</folder>
|
||||
<folder>src</folder>
|
||||
</files>
|
||||
<media folder="media" destination="sourcerer">
|
||||
<folder>images</folder>
|
||||
<folder>js</folder>
|
||||
</media>
|
||||
<config>
|
||||
<fields name="params" addfieldprefix="RegularLabs\Library\Form\Field">
|
||||
<fieldset name="basic">
|
||||
<field name="@load_script_descriptions" type="LoadMedia" filetype="script" file="regularlabs.admin-form-descriptions"/>
|
||||
<field name="@load_language_regularlabs" type="LoadLanguage" extension="plg_system_regularlabs"/>
|
||||
<field name="@jcompatibility" type="JCompatibility" extension="SOURCERER"/>
|
||||
<field name="@license" type="License" extension="SOURCERER"/>
|
||||
<field name="@version" type="Version" extension="SOURCERER"/>
|
||||
<field name="@header" type="Header" label="SOURCERER" description="SOURCERER_DESC" url="https://regularlabs.com/sourcerer"/>
|
||||
</fieldset>
|
||||
<fieldset name="SRC_SECURITY_SETTINGS_DEFAULT">
|
||||
<field name="@block__default" type="Note" class="rl-alert alert alert-info rl-alert-light" text="SRC_SECURITY_SETTINGS_DEFAULT_DESC"/>
|
||||
<field name="@block__default_css__a" type="Block" start="1" label="SRC_CSS"/>
|
||||
<field name="enable_css" type="Radio" default="1" class="btn-group rl-btn-group btn-group-md btn-group-yesno" label="SRC_ALLOW_CSS_TAGS" description="SRC_ALLOW_CSS_TAGS_DESC">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
<field name="@block__default_css__b" type="Block" end="1"/>
|
||||
<field name="@block__default_js__a" type="Block" start="1" label="SRC_JAVASCRIPT"/>
|
||||
<field name="enable_js" type="Radio" default="1" class="btn-group rl-btn-group btn-group-md btn-group-yesno" label="SRC_ALLOW_JAVASCRIPT_TAGS" description="SRC_ALLOW_JAVASCRIPT_TAGS_DESC">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
<field name="@block__default_js__b" type="Block" end="1"/>
|
||||
<field name="@block__default_php__a" type="Block" start="1" label="SRC_PHP"/>
|
||||
<field name="enable_php" type="Radio" default="1" class="btn-group rl-btn-group btn-group-md btn-group-yesno" label="SRC_ALLOW_PHP_TAGS" description="SRC_ALLOW_PHP_TAGS_DESC">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
<field name="@showon__default_php__a" type="ShowOn" value="enable_php:1"/>
|
||||
<field name="forbidden_php" type="Textarea" rows="3" cols="40" default="dl, escapeshellarg, escapeshellcmd, exec, passthru, popen, proc_close, proc_open, shell_exec, symlink, system" label="SRC_FORBIDDEN_PHP_FUNCTIONS" description="SRC_FORBIDDEN_PHP_FUNCTIONS_DESC"/>
|
||||
<field name="forbidden_tags" type="Textareaplus" width="400" height="80" default="" label="SRC_FORBIDDEN_HTML_TAGS" description="SRC_FORBIDDEN_HTML_TAGS_DESC"/>
|
||||
<field name="@showon__default_php__b" type="ShowOn"/>
|
||||
<field name="@block__default_php__b" type="Block" end="1"/>
|
||||
</fieldset>
|
||||
<fieldset name="SRC_SECURITY_SETTINGS_ARTICLES">
|
||||
<field name="@block__articles" type="Note" class="rl-alert alert alert-info rl-alert-light" text="SRC_SECURITY_SETTINGS_ARTICLES_DESC"/>
|
||||
<field name="@note__articles_security_level" type="OnlyPro" label="SRC_SECURITY_LEVEL" description="SRC_SECURITY_LEVEL_DESC"/>
|
||||
<field name="@block__articles_css__a" type="Block" start="1" label="SRC_CSS"/>
|
||||
<field name="@note__articles_enable_css" type="OnlyPro" label="SRC_ALLOW_CSS_TAGS" description="SRC_ALLOW_CSS_TAGS_DESC"/>
|
||||
<field name="@block__articles_css__b" type="Block" end="1"/>
|
||||
<field name="@block__articles_js__a" type="Block" start="1" label="SRC_JAVASCRIPT"/>
|
||||
<field name="@note__articles_enable_js" type="OnlyPro" label="SRC_ALLOW_JAVASCRIPT_TAGS" description="SRC_ALLOW_JAVASCRIPT_TAGS_DESC"/>
|
||||
<field name="@block__articles_js__b" type="Block" end="1"/>
|
||||
<field name="@block__articles_php__a" type="Block" start="1" label="SRC_PHP"/>
|
||||
<field name="@note__articles_enable_php" type="OnlyPro" label="SRC_ALLOW_PHP_TAGS" description="SRC_ALLOW_PHP_TAGS_DESC"/>
|
||||
<field name="@block__articles_php__b" type="Block" end="1"/>
|
||||
</fieldset>
|
||||
<fieldset name="SRC_SECURITY_SETTINGS_COMPONENTS">
|
||||
<field name="@block__components" type="Note" class="rl-alert alert alert-info rl-alert-light" text="SRC_SECURITY_SETTINGS_COMPONENTS_DESC"/>
|
||||
<field name="@note__articles_security_level" type="OnlyPro" label="RL_DISABLE_ON_COMPONENTS" description="SRC_DISABLE_ON_COMPONENTS_DESC"/>
|
||||
<field name="@block__components_css__a" type="Block" start="1" label="SRC_CSS"/>
|
||||
<field name="@note__components_enable_css" type="OnlyPro" label="SRC_ALLOW_CSS_TAGS" description="SRC_ALLOW_CSS_TAGS_DESC"/>
|
||||
<field name="@block__components_css__b" type="Block" end="1"/>
|
||||
<field name="@block__components_js__a" type="Block" start="1" label="SRC_JAVASCRIPT"/>
|
||||
<field name="@note__components_enable_js" type="OnlyPro" label="SRC_ALLOW_JAVASCRIPT_TAGS" description="SRC_ALLOW_JAVASCRIPT_TAGS_DESC"/>
|
||||
<field name="@block__components_js__b" type="Block" end="1"/>
|
||||
<field name="@block__components_php__a" type="Block" start="1" label="SRC_PHP"/>
|
||||
<field name="@note__components_enable_php" type="OnlyPro" label="SRC_ALLOW_PHP_TAGS" description="SRC_ALLOW_PHP_TAGS_DESC"/>
|
||||
<field name="@wizard" type="Radio" default="0" class="btn-group rl-btn-group btn-group-md btn-group-yesno" label="SRC_SHOW_WIZARD">
|
||||
<option value="0">JNO</option>
|
||||
<option value="" class="btn btn-outline-success">JYES</option>
|
||||
</field>
|
||||
<field name="@block__wizard" type="Note" class="text-center" text="<img src="../media/sourcerer/images/wizard.gif" alt="" width="160" height="160" /><h4>The Day of the Sourcerer</h4><p>He stands up and he wakes,<br />He adds and he takes,<br />He mixes and he shakes,<br />He explodes and he bakes,<br />But he makes no mistakes!</p>" showon="@wizard:"/>
|
||||
<field name="@block__components_php__b" type="Block" end="1"/>
|
||||
</fieldset>
|
||||
<fieldset name="SRC_SECURITY_SETTINGS_OTHER_AREAS">
|
||||
<field name="@block__otherareas" type="Note" class="rl-alert alert alert-info rl-alert-light" text="SRC_SECURITY_SETTINGS_OTHER_AREAS_DESC"/>
|
||||
<field name="@note__articles_security_level" type="OnlyPro" label="RL_ENABLE_OTHER_AREAS" description="SRC_ENABLE_OTHER_AREAS_DESC"/>
|
||||
<field name="@block__otherareas_css__a" type="Block" start="1" label="SRC_CSS"/>
|
||||
<field name="@noticeother_enable_css" type="OnlyPro" label="SRC_ALLOW_CSS_TAGS" description="SRC_ALLOW_CSS_TAGS_DESC"/>
|
||||
<field name="@block__otherareas_css__b" type="Block" end="1"/>
|
||||
<field name="@block__otherareas_js__a" type="Block" start="1" label="SRC_JAVASCRIPT"/>
|
||||
<field name="@note__other_enable_js" type="OnlyPro" label="SRC_ALLOW_JAVASCRIPT_TAGS" description="SRC_ALLOW_JAVASCRIPT_TAGS_DESC"/>
|
||||
<field name="@block__otherareas_js__b" type="Block" end="1"/>
|
||||
<field name="@block__otherareas_php__a" type="Block" start="1" label="SRC_PHP"/>
|
||||
<field name="@note__other_enable_php" type="OnlyPro" label="SRC_ALLOW_PHP_TAGS" description="SRC_ALLOW_PHP_TAGS_DESC"/>
|
||||
<field name="@block__otherareas_php__b" type="Block" end="1"/>
|
||||
</fieldset>
|
||||
<fieldset name="RL_SETTINGS_EDITOR_BUTTON">
|
||||
<field name="button_text" type="Text" default="Code" label="RL_BUTTON_TEXT" description="RL_BUTTON_TEXT_DESC"/>
|
||||
<field name="enable_frontend" type="Radio" default="1" class="btn-group rl-btn-group btn-group-md btn-group-yesno" label="RL_ENABLE_IN_FRONTEND" description="RL_ENABLE_IN_FRONTEND_DESC">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
<field name="color_code" type="Radio" default="1" class="btn-group rl-btn-group btn-group-md btn-group-yesno" label="SRC_COLOR_CODE" description="SRC_COLOR_CODE_DESC">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
<fieldset name="RL_TAG_SYNTAX">
|
||||
<field name="syntax_word" type="Text" size="20" default="source" label="SRC_SYNTAX_WORD" description="SRC_SYNTAX_WORD_DESC"/>
|
||||
<field name="tag_characters" type="List" class="font-monospace w-auto" default="{.}" label="RL_TAG_CHARACTERS" description="RL_TAG_CHARACTERS_DESC">
|
||||
<option value="{.}">{...}</option>
|
||||
<option value="[.]">[...]</option>
|
||||
<option value="«.»">«...»</option>
|
||||
<option value="{{.}}">{{...}}</option>
|
||||
<option value="[[.]]">[[...]]</option>
|
||||
<option value="[:.:]">[:...:]</option>
|
||||
<option value="[%.%]">[%...%]</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
<fieldset name="advanced">
|
||||
<field name="@load_language_config" type="LoadLanguage" extension="com_config"/>
|
||||
<field name="trim" type="Radio" default="0" class="btn-group rl-btn-group btn-group-md btn-group-yesno" label="RL_STRIP_SURROUNDING_TAGS" description="RL_STRIP_SURROUNDING_TAGS_DESC">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
<field name="enable_in_head" type="Radio" default="0" class="btn-group rl-btn-group btn-group-md btn-group-yesno" label="SRC_ENABLE_IN_HEAD" description="SRC_ENABLE_IN_HEAD_DESC">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
<field name="remove_from_search" type="Radio" default="0" class="btn-group rl-btn-group btn-group-md btn-group-yesno" label="SRC_REMOVE_FROM_SEARCH" description="SRC_REMOVE_FROM_SEARCH_DESC">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
<field name="include_path" type="Text" default="/" label="SRC_INCLUDE_PATH" description="SRC_INCLUDE_PATH_DESC"/>
|
||||
<field name="tmp_path" type="Text" default="" label="SRC_TEMP_PATH" description="SRC_TEMP_PATH_DESC" hint="JDEFAULT"/>
|
||||
<field name="place_comments" type="Radio" default="1" class="btn-group rl-btn-group btn-group-md btn-group-yesno" label="RL_PLACE_HTML_COMMENTS" description="RL_PLACE_HTML_COMMENTS_DESC">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
69
plugins/system/sourcerer/src/Area.php
Normal file
69
plugins/system/sourcerer/src/Area.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Sourcerer
|
||||
* @version 9.4.1
|
||||
*
|
||||
* @author Peter van Westen <info@regularlabs.com>
|
||||
* @link http://regularlabs.com
|
||||
* @copyright Copyright © 2023 Regular Labs All Rights Reserved
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
|
||||
*/
|
||||
|
||||
namespace RegularLabs\Plugin\System\Sourcerer;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use RegularLabs\Library\RegEx as RL_RegEx;
|
||||
|
||||
class Area
|
||||
{
|
||||
static $prefix = 'SRC';
|
||||
|
||||
public static function get(&$string, $area = '')
|
||||
{
|
||||
if (empty($string) || empty($area))
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
$start = '<!-- START: ' . self::$prefix . '_' . strtoupper($area) . ' -->';
|
||||
$end = '<!-- END: ' . self::$prefix . '_' . strtoupper($area) . ' -->';
|
||||
|
||||
$matches = explode($start, $string);
|
||||
array_shift($matches);
|
||||
|
||||
foreach ($matches as $i => $match)
|
||||
{
|
||||
[$text] = explode($end, $match, 2);
|
||||
$matches[$i] = [
|
||||
$start . $text . $end,
|
||||
$text,
|
||||
];
|
||||
}
|
||||
|
||||
return $matches;
|
||||
}
|
||||
|
||||
public static function tag(&$string, $area = '')
|
||||
{
|
||||
if (empty($string) || empty($area))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$string = '<!-- START: ' . self::$prefix . '_' . strtoupper($area) . ' -->' . $string . '<!-- END: ' . self::$prefix . '_' . strtoupper($area) . ' -->';
|
||||
|
||||
if ($area != 'article_text')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
$string = RL_RegEx::replace(
|
||||
'#(<hr class="system-pagebreak".*?>)#si',
|
||||
'<!-- END: ' . self::$prefix . '_' . strtoupper($area) . ' -->\1<!-- START: ' . self::$prefix . '_' . strtoupper($area) . ' -->',
|
||||
$string
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
97
plugins/system/sourcerer/src/Clean.php
Normal file
97
plugins/system/sourcerer/src/Clean.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Sourcerer
|
||||
* @version 9.4.1
|
||||
*
|
||||
* @author Peter van Westen <info@regularlabs.com>
|
||||
* @link http://regularlabs.com
|
||||
* @copyright Copyright © 2023 Regular Labs All Rights Reserved
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
|
||||
*/
|
||||
|
||||
namespace RegularLabs\Plugin\System\Sourcerer;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Language\Text as JText;
|
||||
use RegularLabs\Library\PluginTag as RL_PluginTag;
|
||||
use RegularLabs\Library\Protect as RL_Protect;
|
||||
use RegularLabs\Library\RegEx as RL_RegEx;
|
||||
use RegularLabs\Library\StringHelper as RL_String;
|
||||
|
||||
class Clean
|
||||
{
|
||||
/**
|
||||
* Just in case you can't figure the method name out: this cleans the left-over junk
|
||||
*/
|
||||
public static function cleanFinalHtmlOutput(&$html)
|
||||
{
|
||||
RL_Protect::removeAreaTags($html, 'SRC');
|
||||
|
||||
$params = Params::get();
|
||||
|
||||
if ( ! $params->place_comments)
|
||||
{
|
||||
RL_Protect::removeCommentTags($html, 'Sourcerer');
|
||||
}
|
||||
|
||||
if (strpos($html, $params->tag_character_start . '/' . $params->tag) === false)
|
||||
{
|
||||
Protect::unprotectTags($html);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$regex = Params::getRegex();
|
||||
|
||||
$html = RL_RegEx::replace(
|
||||
$regex,
|
||||
Protect::getMessageCommentTag(JText::_('SRC_CODE_REMOVED_NOT_ENABLED')),
|
||||
$html
|
||||
);
|
||||
|
||||
Protect::unprotectTags($html);
|
||||
}
|
||||
|
||||
public static function cleanTagsFromHead(&$string)
|
||||
{
|
||||
if ( ! RL_String::contains($string, Params::getTags(true)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$params = Params::get();
|
||||
|
||||
[$tag_start, $tag_end] = Params::getTagCharacters();
|
||||
|
||||
$inside_tag = RL_PluginTag::getRegexInsideTag($tag_start, $tag_end);
|
||||
$spaces = RL_PluginTag::getRegexSpaces();
|
||||
|
||||
$tag_start = RL_RegEx::quote($tag_start);
|
||||
$tag_end = RL_RegEx::quote($tag_end);
|
||||
|
||||
$regex = Params::getRegex();
|
||||
|
||||
// Remove start tag to end tag
|
||||
$string = RL_RegEx::replace(
|
||||
$regex,
|
||||
'',
|
||||
$string
|
||||
);
|
||||
|
||||
// Remove start tag with optional php stuff after it
|
||||
$string = RL_RegEx::replace(
|
||||
$tag_start . RL_RegEx::quote($params->tag) . '(' . $spaces . $inside_tag . ')?' . $tag_end
|
||||
. '(\s*<\?php(.*?)\?>)?',
|
||||
'',
|
||||
$string
|
||||
);
|
||||
|
||||
// Remove left over end tags
|
||||
$string = RL_RegEx::replace(
|
||||
$tag_start . '\/' . RL_RegEx::quote($params->tag) . $tag_end,
|
||||
'',
|
||||
$string
|
||||
);
|
||||
}
|
||||
}
|
||||
246
plugins/system/sourcerer/src/Items.php
Normal file
246
plugins/system/sourcerer/src/Items.php
Normal file
@@ -0,0 +1,246 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Sourcerer
|
||||
* @version 9.4.1
|
||||
*
|
||||
* @author Peter van Westen <info@regularlabs.com>
|
||||
* @link http://regularlabs.com
|
||||
* @copyright Copyright © 2023 Regular Labs All Rights Reserved
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
|
||||
*/
|
||||
|
||||
namespace RegularLabs\Plugin\System\Sourcerer;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory as JFactory;
|
||||
use RegularLabs\Library\Document as RL_Document;
|
||||
use RegularLabs\Library\Parameters as RL_Parameters;
|
||||
use RegularLabs\Library\Protect as RL_Protect;
|
||||
use RegularLabs\Library\RegEx as RL_RegEx;
|
||||
use RegularLabs\Library\StringHelper as RL_String;
|
||||
use RegularLabs\Library\Xml as RL_Xml;
|
||||
|
||||
class Items
|
||||
{
|
||||
static $items = [];
|
||||
|
||||
public static function filterItemList(&$items, $article = 0)
|
||||
{
|
||||
foreach ($items as $key => &$item)
|
||||
{
|
||||
if (
|
||||
(RL_Document::isClient('administrator') && $item->enable_in_admin == 0)
|
||||
|| (RL_Document::isClient('site') && $item->enable_in_admin == 2)
|
||||
)
|
||||
{
|
||||
unset($items[$key]);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if ( ! $item)
|
||||
{
|
||||
unset($items[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function getItemList($area = 'article')
|
||||
{
|
||||
if (isset(self::$items[$area]))
|
||||
{
|
||||
return self::$items[$area];
|
||||
}
|
||||
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select('r.*')
|
||||
->from('#__sourcerer AS r')
|
||||
->where('r.published = 1');
|
||||
$where = 'r.area = ' . $db->quote($area);
|
||||
$query->where('(' . $where . ')')
|
||||
->order('r.ordering, r.id');
|
||||
$db->setQuery($query);
|
||||
$rows = $db->loadObjectList();
|
||||
|
||||
$items = [];
|
||||
|
||||
if (empty($rows))
|
||||
{
|
||||
self::$items[$area] = $items;
|
||||
|
||||
return self::$items[$area];
|
||||
}
|
||||
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
if ( ! $item = self::getItem($row, $area))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_array($item))
|
||||
{
|
||||
$items = array_merge($items, $item);
|
||||
continue;
|
||||
}
|
||||
|
||||
$items[] = $item;
|
||||
}
|
||||
|
||||
if ($area != 'articles')
|
||||
{
|
||||
self::filterItemList($items);
|
||||
}
|
||||
|
||||
self::$items[$area] = $items;
|
||||
|
||||
return self::$items[$area];
|
||||
}
|
||||
|
||||
public static function getItemsFromXml($xml_data, $item, $area)
|
||||
{
|
||||
}
|
||||
|
||||
private static function getItem($row, $area = 'article')
|
||||
{
|
||||
if ( ! ((substr($row->params, 0, 1) != '{') && (substr($row->params, -1, 1) != '}')))
|
||||
{
|
||||
$row->params = RL_String::html_entity_decoder($row->params);
|
||||
}
|
||||
|
||||
$item = RL_Parameters::getObjectFromRegistry($row->params, JPATH_ADMINISTRATOR . '/components/com_sourcerer/forms/item.xml');
|
||||
|
||||
unset($row->params);
|
||||
foreach ($row as $key => $param)
|
||||
{
|
||||
$item->{$key} = $param;
|
||||
}
|
||||
|
||||
|
||||
if ( ! self::itemPassChecks($item, $area))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strlen($item->search) < 3)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
self::prepareString($item->search);
|
||||
self::prepareReplaceString($item->replace);
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
private static function getItemFromXmlData($item, $xml_data, $area)
|
||||
{
|
||||
if ( ! isset($xml_data->search))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$item = clone $item;
|
||||
|
||||
$item->search = $xml_data->search;
|
||||
$item->replace = $xml_data->replace ?? '';
|
||||
|
||||
self::prepareString($item->search);
|
||||
self::prepareReplaceString($item->replace);
|
||||
|
||||
$xml_data->param ??= [];
|
||||
|
||||
if (isset($xml_data->params->param))
|
||||
{
|
||||
$xml_data->param = $xml_data->params->param;
|
||||
unset($xml_data->params);
|
||||
}
|
||||
|
||||
if ( ! is_array($xml_data->param))
|
||||
{
|
||||
$xml_data->param = [$xml_data->param];
|
||||
}
|
||||
|
||||
foreach ($xml_data->param as $param)
|
||||
{
|
||||
if (isset($param->{"@attributes"}) && isset($param->{"@attributes"}->name) && isset($param->{"@attributes"}->value))
|
||||
{
|
||||
$param = $param->{"@attributes"};
|
||||
}
|
||||
|
||||
if ( ! isset($param->name) || ! isset($param->value))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$item->{$param->name} = $param->value;
|
||||
}
|
||||
|
||||
if ( ! self::itemPassChecks($item, $area))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
private static function getItemsFromItemXml($item, $area)
|
||||
{
|
||||
}
|
||||
|
||||
private static function itemPassChecks($item, $area)
|
||||
{
|
||||
if ($item->area != $area)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($item->search))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((RL_Document::isFeed() && ! $item->enable_in_feeds)
|
||||
|| ( ! RL_Document::isFeed() && $item->enable_in_feeds == 2)
|
||||
)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static function prepareReplaceString(&$string)
|
||||
{
|
||||
[$tag, $characters] = RL_Protect::getSourcererTag();
|
||||
|
||||
if (empty($tag))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
[$start, $end] = explode('.', $characters);
|
||||
|
||||
self::prepareString($string);
|
||||
|
||||
if (strpos($string, $start . '/' . $tag . $end) === false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// fix usage of non-protected {source} tags to {source 0}
|
||||
$string = str_replace($start . $tag . $end, $start . $tag . ' 0' . $end, $string);
|
||||
}
|
||||
|
||||
private static function prepareString(&$string)
|
||||
{
|
||||
if (is_string($string))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$string = '';
|
||||
}
|
||||
}
|
||||
185
plugins/system/sourcerer/src/Params.php
Normal file
185
plugins/system/sourcerer/src/Params.php
Normal file
@@ -0,0 +1,185 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Sourcerer
|
||||
* @version 9.4.1
|
||||
*
|
||||
* @author Peter van Westen <info@regularlabs.com>
|
||||
* @link http://regularlabs.com
|
||||
* @copyright Copyright © 2023 Regular Labs All Rights Reserved
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
|
||||
*/
|
||||
|
||||
namespace RegularLabs\Plugin\System\Sourcerer;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory as JFactory;
|
||||
use RegularLabs\Library\Parameters as RL_Parameters;
|
||||
use RegularLabs\Library\PluginTag as RL_PluginTag;
|
||||
use RegularLabs\Library\RegEx as RL_RegEx;
|
||||
|
||||
class Params
|
||||
{
|
||||
protected static $areas = null;
|
||||
protected static $params = null;
|
||||
protected static $regexes = null;
|
||||
|
||||
public static function get($key = '', $default = '')
|
||||
{
|
||||
if ($key != '')
|
||||
{
|
||||
return self::getByKey($key, $default);
|
||||
}
|
||||
|
||||
if ( ! is_null(self::$params))
|
||||
{
|
||||
return self::$params;
|
||||
}
|
||||
|
||||
$user = JFactory::getApplication()->getIdentity() ?: JFactory::getUser();
|
||||
|
||||
$params = RL_Parameters::getPlugin('sourcerer');
|
||||
|
||||
$params->tag = RL_PluginTag::clean($params->syntax_word);
|
||||
|
||||
$params->html_tags_syntax = [['<', '>'], ['\[\[', '\]\]']];
|
||||
$params->splitter = '<!-- START: SRC_SPLIT -->';
|
||||
|
||||
$params->include_path = str_replace('//', '/', ('/' . trim($params->include_path, ' /\\') . '/'));
|
||||
$params->user_is_admin = $user->authorise('core.admin', 1);
|
||||
|
||||
|
||||
self::$params = $params;
|
||||
|
||||
return self::$params;
|
||||
}
|
||||
|
||||
public static function getArea($type = 'default')
|
||||
{
|
||||
$areas = self::getAreaSettings();
|
||||
|
||||
return $areas->{$type} ?? $areas->default;
|
||||
}
|
||||
|
||||
public static function getAreaSettings()
|
||||
{
|
||||
if ( ! is_null(self::$areas))
|
||||
{
|
||||
return self::$areas;
|
||||
}
|
||||
|
||||
$areas = (object) [];
|
||||
|
||||
// Initialise the different enables
|
||||
$areas->default = self::getAreaDefault();
|
||||
|
||||
self::$areas = $areas;
|
||||
|
||||
return self::$areas;
|
||||
}
|
||||
|
||||
public static function getRegex($type = 'tag')
|
||||
{
|
||||
$regexes = self::getRegexes();
|
||||
|
||||
return $regexes->{$type} ?? $regexes->tag;
|
||||
}
|
||||
|
||||
public static function getTagCharacters()
|
||||
{
|
||||
$params = self::get();
|
||||
|
||||
if ( ! isset($params->tag_character_start))
|
||||
{
|
||||
self::setTagCharacters();
|
||||
}
|
||||
|
||||
return [$params->tag_character_start, $params->tag_character_end];
|
||||
}
|
||||
|
||||
public static function getTags($only_start_tags = false)
|
||||
{
|
||||
$params = self::get();
|
||||
|
||||
[$tag_start, $tag_end] = self::getTagCharacters();
|
||||
|
||||
$tags = [
|
||||
[
|
||||
$tag_start . $params->tag,
|
||||
],
|
||||
[
|
||||
$tag_start . '/' . $params->tag . $tag_end,
|
||||
],
|
||||
];
|
||||
|
||||
return $only_start_tags ? $tags[0] : $tags;
|
||||
}
|
||||
|
||||
public static function setTagCharacters()
|
||||
{
|
||||
$params = self::get();
|
||||
|
||||
[self::$params->tag_character_start, self::$params->tag_character_end] = explode('.', $params->tag_characters);
|
||||
}
|
||||
|
||||
private static function getAreaByType($type = 'default')
|
||||
{
|
||||
}
|
||||
|
||||
private static function getAreaDefault()
|
||||
{
|
||||
$params = self::get();
|
||||
|
||||
return (object) [
|
||||
'enable' => true,
|
||||
'enable_css' => $params->enable_css,
|
||||
'enable_js' => $params->enable_js,
|
||||
'enable_php' => $params->enable_php,
|
||||
'forbidden_php' => $params->forbidden_php,
|
||||
'forbidden_tags' => $params->forbidden_tags,
|
||||
];
|
||||
}
|
||||
|
||||
private static function getByKey($key, $default = '')
|
||||
{
|
||||
$params = self::get();
|
||||
|
||||
return ($params->{$key} ?? null) ?: $default;
|
||||
}
|
||||
|
||||
private static function getRegexes()
|
||||
{
|
||||
if ( ! is_null(self::$regexes))
|
||||
{
|
||||
return self::$regexes;
|
||||
}
|
||||
|
||||
$params = self::get();
|
||||
|
||||
// Tag character start and end
|
||||
[$tag_start, $tag_end] = Params::getTagCharacters();
|
||||
$tag_start = RL_RegEx::quote($tag_start);
|
||||
$tag_end = RL_RegEx::quote($tag_end);
|
||||
|
||||
$pre = RL_PluginTag::getRegexSurroundingTagPre();
|
||||
$post = RL_PluginTag::getRegexSurroundingTagPost();
|
||||
|
||||
$spaces = RL_PluginTag::getRegexSpaces('*');
|
||||
|
||||
self::$regexes = (object) [];
|
||||
|
||||
self::$regexes->tag = '('
|
||||
. '(?<start_pre>' . $pre . ')'
|
||||
. $tag_start . RL_RegEx::quote($params->tag) . $spaces . '(?<data>( .*?)?)' . $tag_end
|
||||
. '(?<start_post>' . $post . ')'
|
||||
|
||||
. '(?<content>.*?)'
|
||||
|
||||
. '(?<end_pre>' . $pre . ')'
|
||||
. $tag_start . '\/' . RL_RegEx::quote($params->tag) . $tag_end
|
||||
. '(?<end_post>' . $post . ')'
|
||||
. ')';
|
||||
|
||||
return self::$regexes;
|
||||
}
|
||||
}
|
||||
48
plugins/system/sourcerer/src/Protect.php
Normal file
48
plugins/system/sourcerer/src/Protect.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Sourcerer
|
||||
* @version 9.4.1
|
||||
*
|
||||
* @author Peter van Westen <info@regularlabs.com>
|
||||
* @link http://regularlabs.com
|
||||
* @copyright Copyright © 2023 Regular Labs All Rights Reserved
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
|
||||
*/
|
||||
|
||||
namespace RegularLabs\Plugin\System\Sourcerer;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use RegularLabs\Library\Protect as RL_Protect;
|
||||
|
||||
class Protect
|
||||
{
|
||||
static $name = 'Sourcerer';
|
||||
|
||||
public static function _(&$string)
|
||||
{
|
||||
RL_Protect::protectForm($string, Params::getTags(true), true, 'no-sourcerer');
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap the comment in comment tags
|
||||
*
|
||||
* @param string $comment
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getMessageCommentTag($comment)
|
||||
{
|
||||
return RL_Protect::getMessageCommentTag(self::$name, $comment);
|
||||
}
|
||||
|
||||
public static function protectTags(&$string)
|
||||
{
|
||||
RL_Protect::protectTags($string, Params::getTags(true));
|
||||
}
|
||||
|
||||
public static function unprotectTags(&$string)
|
||||
{
|
||||
RL_Protect::unprotectTags($string, Params::getTags(true));
|
||||
}
|
||||
}
|
||||
619
plugins/system/sourcerer/src/Replace.php
Normal file
619
plugins/system/sourcerer/src/Replace.php
Normal file
@@ -0,0 +1,619 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Sourcerer
|
||||
* @version 9.4.1
|
||||
*
|
||||
* @author Peter van Westen <info@regularlabs.com>
|
||||
* @link http://regularlabs.com
|
||||
* @copyright Copyright © 2023 Regular Labs All Rights Reserved
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
|
||||
*/
|
||||
|
||||
namespace RegularLabs\Plugin\System\Sourcerer;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Language\Text as JText;
|
||||
use RegularLabs\Library\ArrayHelper as RL_Array;
|
||||
use RegularLabs\Library\Document as RL_Document;
|
||||
use RegularLabs\Library\Html as RL_Html;
|
||||
use RegularLabs\Library\ObjectHelper as RL_Object;
|
||||
use RegularLabs\Library\Php as RL_Php;
|
||||
use RegularLabs\Library\PluginTag as RL_PluginTag;
|
||||
use RegularLabs\Library\Protect as RL_Protect;
|
||||
use RegularLabs\Library\RegEx as RL_RegEx;
|
||||
|
||||
class Replace
|
||||
{
|
||||
static $article = null;
|
||||
static $current_area = null;
|
||||
|
||||
public static function replace(&$string, $area = 'article', $article = '', $remove = false)
|
||||
{
|
||||
if ( ! is_string($string) || $string == '')
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Protect::_($string);
|
||||
|
||||
$regex = Params::getRegex();
|
||||
|
||||
$array = self::stringToSplitArray($string, $regex, false);
|
||||
$array_count = count($array);
|
||||
|
||||
if ($array_count <= 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
self::$article = $article;
|
||||
|
||||
for ($i = 1; $i < $array_count - 1; $i++)
|
||||
{
|
||||
if ( ! fmod($i, 2) || ! RL_RegEx::match($regex, $array[$i], $match))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$content = self::handleMatch($match, $area, $remove);
|
||||
|
||||
$array[$i] = $match['start_pre'] . $match['start_post'] . $content . $match['end_pre'] . $match['end_post'];
|
||||
}
|
||||
|
||||
$string = implode('', $array);
|
||||
}
|
||||
|
||||
public static function replaceInTheRest(&$string)
|
||||
{
|
||||
if ( ! is_string($string) || $string == '')
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
[$start_tags, $end_tags] = Params::getTags();
|
||||
|
||||
[$pre_string, $string, $post_string] = RL_Html::getContentContainingSearches(
|
||||
$string,
|
||||
$start_tags,
|
||||
$end_tags
|
||||
);
|
||||
|
||||
if ($string == '')
|
||||
{
|
||||
$string = $pre_string . $string . $post_string;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// COMPONENT
|
||||
if (RL_Document::isFeed())
|
||||
{
|
||||
$string = RL_RegEx::replace('(<item[^>]*>)', '\1<!-- START: SRC_COMPONENT -->', $string);
|
||||
$string = str_replace('</item>', '<!-- END: SRC_COMPONENT --></item>', $string);
|
||||
}
|
||||
|
||||
if (strpos($string, '<!-- START: SRC_COMPONENT -->') === false)
|
||||
{
|
||||
Area::tag($string, 'component');
|
||||
}
|
||||
|
||||
$components = Area::get($string, 'component');
|
||||
foreach ($components as $component)
|
||||
{
|
||||
self::replace($component[1], 'components', '');
|
||||
$string = str_replace($component[0], $component[1], $string);
|
||||
}
|
||||
|
||||
// EVERYWHERE
|
||||
self::replace($string, 'other');
|
||||
|
||||
$string = $pre_string . $string . $post_string;
|
||||
}
|
||||
|
||||
private static function cleanTags(&$string)
|
||||
{
|
||||
$params = Params::get();
|
||||
|
||||
foreach ($params->html_tags_syntax as $html_tags_syntax)
|
||||
{
|
||||
[$start, $end] = $html_tags_syntax;
|
||||
|
||||
$tag_regex = $start . '\s*(\/?\s*[a-z\!][^' . $end . ']*?(?:\s+.*?)?)' . $end;
|
||||
$string = RL_RegEx::replace($tag_regex, '<\1\2>', $string);
|
||||
}
|
||||
}
|
||||
|
||||
private static function convertWysiwygToPlainText($content)
|
||||
{
|
||||
$content = RL_Html::convertWysiwygToPlainText($content);
|
||||
|
||||
// Remove trailing spaces from EOT lines
|
||||
$content = RL_RegEx::replace('(=\s*<<<([^\s]+)) ?(\n.*?\2;) ?', '\1\3', $content);
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
private static function getPhpFileCodeByType($file, $type)
|
||||
{
|
||||
}
|
||||
|
||||
private static function addInlineVariables($data, &$content)
|
||||
{
|
||||
}
|
||||
|
||||
private static function getPhpFilesCode($data)
|
||||
{
|
||||
}
|
||||
|
||||
private static function handleMatch(&$match, $area = 'article', $remove = false)
|
||||
{
|
||||
if ($remove)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
$params = Params::get();
|
||||
|
||||
$data = RL_PluginTag::getAttributesFromString($match['data']);
|
||||
|
||||
$content = trim($match['content']);
|
||||
|
||||
$data->raw ??= false;
|
||||
|
||||
// Remove html tags if code is placed via the WYSIWYG editor
|
||||
if ( ! $data->raw)
|
||||
{
|
||||
$content = self::convertWysiwygToPlainText($content);
|
||||
}
|
||||
|
||||
self::replacePhpShortCodes($content);
|
||||
|
||||
|
||||
self::replaceTags($content, $area);
|
||||
|
||||
if ($data->raw)
|
||||
{
|
||||
return $content;
|
||||
}
|
||||
|
||||
$trim = $data->trim ?? $params->trim;
|
||||
|
||||
if ($trim)
|
||||
{
|
||||
$tags = RL_Html::cleanSurroundingTags([
|
||||
'start_pre' => $match['start_pre'],
|
||||
'start_post' => $match['start_post'],
|
||||
], ['div', 'p', 'span']);
|
||||
|
||||
$match = array_merge($match, $tags);
|
||||
|
||||
$tags = RL_Html::cleanSurroundingTags([
|
||||
'end_pre' => $match['end_pre'],
|
||||
'end_post' => $match['end_post'],
|
||||
], ['div', 'p', 'span']);
|
||||
|
||||
$match = array_merge($match, $tags);
|
||||
|
||||
$tags = RL_Html::cleanSurroundingTags([
|
||||
'start_pre' => $match['start_pre'],
|
||||
'end_post' => $match['end_post'],
|
||||
], ['div', 'p', 'span']);
|
||||
|
||||
$match = array_merge($match, $tags);
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
private static function loadFiles($data, &$content)
|
||||
{
|
||||
}
|
||||
|
||||
private static function loadMediaFile($file, $type, $options = [])
|
||||
{
|
||||
}
|
||||
|
||||
private static function loadScripts($data)
|
||||
{
|
||||
}
|
||||
|
||||
private static function loadStylesheets($data)
|
||||
{
|
||||
}
|
||||
|
||||
private static function replacePhpShortCodes(&$string)
|
||||
{
|
||||
// Replace <? with <?php
|
||||
$string = RL_RegEx::replace('<\?(\s.*?)\?>', '<?php\1?>', $string);
|
||||
// Replace <?= with <?php echo
|
||||
$string = RL_RegEx::replace('<\?=\s*(.*?)\?>', '<?php echo \1?>', $string);
|
||||
}
|
||||
|
||||
private static function replaceTags(&$string, $area = 'article')
|
||||
{
|
||||
if ( ! is_string($string) || $string == '')
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// allow in component?
|
||||
if (RL_Protect::isRestrictedComponent(Params::get('components', []), $area))
|
||||
{
|
||||
Protect::protectTags($string);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
self::replaceTagsByType($string, $area, 'php');
|
||||
self::replaceTagsByType($string, $area, 'all');
|
||||
self::replaceTagsByType($string, $area, 'js');
|
||||
self::replaceTagsByType($string, $area, 'css');
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace any html style tags by a comment tag if not permitted
|
||||
* Match: <...>
|
||||
*/
|
||||
private static function replaceTagsAll(&$string, $enabled = true, $security_pass = true)
|
||||
{
|
||||
if ( ! is_string($string) || $string == '')
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! $enabled)
|
||||
{
|
||||
// replace source block content with HTML comment
|
||||
$string = Protect::getMessageCommentTag(JText::_('SRC_CODE_REMOVED_NOT_ENABLED'));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! $security_pass)
|
||||
{
|
||||
// replace source block content with HTML comment
|
||||
$string = Protect::getMessageCommentTag(JText::sprintf('SRC_CODE_REMOVED_SECURITY', ''));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
self::cleanTags($string);
|
||||
|
||||
$area = Params::getArea('default');
|
||||
$forbidden_tags_array = explode(',', $area->forbidden_tags);
|
||||
RL_Array::clean($forbidden_tags_array);
|
||||
// remove the comment tag syntax from the array - they cannot be disabled
|
||||
$forbidden_tags_array = array_diff($forbidden_tags_array, ['!--']);
|
||||
// reindex the array
|
||||
$forbidden_tags_array = [...$forbidden_tags_array];
|
||||
|
||||
$has_forbidden_tags = false;
|
||||
foreach ($forbidden_tags_array as $forbidden_tag)
|
||||
{
|
||||
if ( ! (strpos($string, '<' . $forbidden_tag) == false))
|
||||
{
|
||||
$has_forbidden_tags = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $has_forbidden_tags)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// double tags
|
||||
$tag_regex = '<\s*([a-z\!][^>\s]*?)(?:\s+.*?)?>.*?</\1>';
|
||||
RL_RegEx::matchAll($tag_regex, $string, $matches);
|
||||
|
||||
if ( ! empty($matches))
|
||||
{
|
||||
foreach ($matches as $match)
|
||||
{
|
||||
if ( ! in_array($match[1], $forbidden_tags_array))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$tag = Protect::getMessageCommentTag(JText::sprintf('SRC_TAG_REMOVED_FORBIDDEN', $match[1]));
|
||||
$string = str_replace($match[0], $tag, $string);
|
||||
}
|
||||
}
|
||||
|
||||
// single tags
|
||||
$tag_regex = '<\s*([a-z\!][^>\s]*?)(?:\s+.*?)?>';
|
||||
RL_RegEx::matchAll($tag_regex, $string, $matches);
|
||||
|
||||
if ( ! empty($matches))
|
||||
{
|
||||
foreach ($matches as $match)
|
||||
{
|
||||
if ( ! in_array($match[1], $forbidden_tags_array))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$tag = Protect::getMessageCommentTag(JText::sprintf('SRC_TAG_REMOVED_FORBIDDEN', $match[1]));
|
||||
$string = str_replace($match[0], $tag, $string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function replaceTagsByType(&$string, $area = 'article', $type = 'all')
|
||||
{
|
||||
if ( ! is_string($string) || $string == '')
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$type_ext = '_' . $type;
|
||||
if ($type == 'all')
|
||||
{
|
||||
$type_ext = '';
|
||||
}
|
||||
|
||||
$a = Params::getArea('default');
|
||||
$security_pass = true;
|
||||
$enable = $a->{'enable' . $type_ext} ?? true;
|
||||
|
||||
switch ($type)
|
||||
{
|
||||
case 'php':
|
||||
self::replaceTagsPHP($string, $enable, $security_pass);
|
||||
break;
|
||||
case 'js':
|
||||
self::replaceTagsJS($string, $enable, $security_pass);
|
||||
break;
|
||||
case 'css':
|
||||
self::replaceTagsCSS($string, $enable, $security_pass);
|
||||
break;
|
||||
default:
|
||||
self::replaceTagsAll($string, $enable, $security_pass);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace the CSS tags by a comment tag if not permitted
|
||||
*/
|
||||
private static function replaceTagsCSS(&$string, $enabled = 1, $security_pass = 1)
|
||||
{
|
||||
if ( ! is_string($string) || $string == '')
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// quick check to see if i is necessary to do anything
|
||||
if ((strpos($string, 'style') === false) && (strpos($string, 'link') === false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Match:
|
||||
// <script ...>...</script>
|
||||
$tag_regex =
|
||||
'(-start-' . '\s*style\s[^' . '-end-' . ']*?[^/]\s*' . '-end-'
|
||||
. '(.*?)'
|
||||
. '-start-' . '\s*\/\s*style\s*' . '-end-)';
|
||||
$arr = self::stringToSplitArray($string, $tag_regex);
|
||||
$arr_count = count($arr);
|
||||
|
||||
// Match:
|
||||
// <script ...>
|
||||
// single script tags are not xhtml compliant and should not occur, but just in case they do...
|
||||
if ($arr_count == 1)
|
||||
{
|
||||
$tag_regex = '(-start-' . '\s*link\s[^' . '-end-' . ']*?(rel="stylesheet"|type="text/css").*?' . '-end-)';
|
||||
$arr = self::stringToSplitArray($string, $tag_regex);
|
||||
$arr_count = count($arr);
|
||||
}
|
||||
|
||||
if ($arr_count <= 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! $enabled)
|
||||
{
|
||||
// replace source block content with HTML comment
|
||||
$string = Protect::getMessageCommentTag(JText::sprintf('SRC_CODE_REMOVED_NOT_ALLOWED', JText::_('SRC_CSS')));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! $security_pass)
|
||||
{
|
||||
// replace source block content with HTML comment
|
||||
$string = Protect::getMessageCommentTag(JText::sprintf('SRC_CODE_REMOVED_SECURITY', JText::_('SRC_CSS')));
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace the JavaScript tags by a comment tag if not permitted
|
||||
*/
|
||||
private static function replaceTagsJS(&$string, $enabled = 1, $security_pass = 1)
|
||||
{
|
||||
if ( ! is_string($string) || $string == '')
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// quick check to see if i is necessary to do anything
|
||||
if ((strpos($string, 'script') === false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Match:
|
||||
// <script ...>...</script>
|
||||
$tag_regex =
|
||||
'(-start-' . '\s*script\s[^' . '-end-' . ']*?[^/]\s*' . '-end-'
|
||||
. '(.*?)'
|
||||
. '-start-' . '\s*\/\s*script\s*' . '-end-)';
|
||||
$arr = self::stringToSplitArray($string, $tag_regex);
|
||||
$arr_count = count($arr);
|
||||
|
||||
// Match:
|
||||
// <script ...>
|
||||
// single script tags are not xhtml compliant and should not occur, but just incase they do...
|
||||
if ($arr_count == 1)
|
||||
{
|
||||
$tag_regex = '(-start-' . '\s*script\s.*?' . '-end-)';
|
||||
$arr = self::stringToSplitArray($string, $tag_regex);
|
||||
$arr_count = count($arr);
|
||||
}
|
||||
|
||||
if ($arr_count <= 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! $enabled)
|
||||
{
|
||||
// replace source block content with HTML comment
|
||||
$string = Protect::getMessageCommentTag(JText::sprintf('SRC_CODE_REMOVED_NOT_ALLOWED', JText::_('SRC_JAVASCRIPT')));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! $security_pass)
|
||||
{
|
||||
// replace source block content with HTML comment
|
||||
$string = Protect::getMessageCommentTag(JText::sprintf('SRC_CODE_REMOVED_SECURITY', JText::_('SRC_JAVASCRIPT')));
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace the PHP tags with the evaluated PHP scripts
|
||||
* Or replace by a comment tag the PHP tags if not permitted
|
||||
*/
|
||||
private static function replaceTagsPHP(&$string, $enabled = 1, $security_pass = 1)
|
||||
{
|
||||
if ( ! is_string($string) || $string == '')
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((strpos($string, '<?') === false) && (strpos($string, '[[?') === false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Match ( read {} as <> ):
|
||||
// {?php ... ?}
|
||||
// {? ... ?}
|
||||
$string_array = self::stringToSplitArray($string, '-start-' . '\?(?:php)?[\s<](.*?)\?' . '-end-');
|
||||
$string_array_count = count($string_array);
|
||||
|
||||
if ($string_array_count < 1)
|
||||
{
|
||||
$string = implode('', $string_array);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! $enabled)
|
||||
{
|
||||
// replace source block content with HTML comment
|
||||
$string_array = [];
|
||||
$string_array[0] = Protect::getMessageCommentTag(JText::sprintf('SRC_CODE_REMOVED_NOT_ALLOWED', JText::_('SRC_PHP')));
|
||||
|
||||
$string = implode('', $string_array);
|
||||
|
||||
return;
|
||||
}
|
||||
if ( ! $security_pass)
|
||||
{
|
||||
// replace source block content with HTML comment
|
||||
$string_array = [];
|
||||
$string_array[0] = Protect::getMessageCommentTag(JText::sprintf('SRC_CODE_REMOVED_SECURITY', JText::_('SRC_PHP')));
|
||||
|
||||
$string = implode('', $string_array);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// if source block content has more than 1 php block, combine them
|
||||
if ($string_array_count > 3)
|
||||
{
|
||||
for ($i = 2; $i < $string_array_count - 1; $i++)
|
||||
{
|
||||
if (fmod($i, 2) == 0)
|
||||
{
|
||||
$string_array[1] .= "<!-- SRC_SEMICOLON --> ?>" . $string_array[$i] . "<?php ";
|
||||
unset($string_array[$i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
$string_array[1] .= $string_array[$i];
|
||||
unset($string_array[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
$semicolon = '<!-- SRC_SEMICOLON -->';
|
||||
$script = trim($string_array[1]) . $semicolon;
|
||||
$script = RL_RegEx::replace('(;\s*)?' . RL_RegEx::quote($semicolon), ';', $script);
|
||||
|
||||
$area = Params::getArea('default');
|
||||
|
||||
$forbidden_php_array = explode(',', $area->forbidden_php);
|
||||
RL_Array::clean($forbidden_php_array);
|
||||
|
||||
$forbidden_php_regex = '[^a-z_](' . implode('|', $forbidden_php_array) . ')(\s*\(|\s+[\'"])';
|
||||
|
||||
RL_RegEx::matchAll($forbidden_php_regex, ' ' . $script, $functions);
|
||||
|
||||
if ( ! empty($functions))
|
||||
{
|
||||
$functionsArray = [];
|
||||
foreach ($functions as $function)
|
||||
{
|
||||
$functionsArray[] = $function[1] . ')';
|
||||
}
|
||||
|
||||
$comment = JText::_('SRC_PHP_CODE_REMOVED_FORBIDDEN') . ': ( ' . implode(', ', $functionsArray) . ' )';
|
||||
|
||||
$string_array[1] = RL_Document::isHtml()
|
||||
? Protect::getMessageCommentTag($comment)
|
||||
: $string_array[1] = '';
|
||||
|
||||
$string = implode('', $string_array);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$output = RL_Php::execute('<?php ' . $script . ' ?>', self::$article);
|
||||
|
||||
$string_array[1] = $output;
|
||||
|
||||
$string = implode('', $string_array);
|
||||
}
|
||||
|
||||
private static function stringToSplitArray($string, $search, $tags = true)
|
||||
{
|
||||
$params = Params::get();
|
||||
|
||||
if ( ! $tags)
|
||||
{
|
||||
$string = RL_RegEx::replace($search, $params->splitter . '\1' . $params->splitter, $string);
|
||||
|
||||
return explode($params->splitter, $string);
|
||||
}
|
||||
|
||||
foreach ($params->html_tags_syntax as $html_tags_syntax)
|
||||
{
|
||||
[$start, $end] = $html_tags_syntax;
|
||||
|
||||
$tag_search = str_replace('-start-', $start, $search);
|
||||
$tag_search = str_replace('-end-', $end, $tag_search);
|
||||
$string = RL_RegEx::replace($tag_search, $params->splitter . '\1' . $params->splitter, $string);
|
||||
}
|
||||
|
||||
return explode($params->splitter, $string);
|
||||
}
|
||||
}
|
||||
84
plugins/system/sourcerer/src/Security.php
Normal file
84
plugins/system/sourcerer/src/Security.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Sourcerer
|
||||
* @version 9.4.1
|
||||
*
|
||||
* @author Peter van Westen <info@regularlabs.com>
|
||||
* @link http://regularlabs.com
|
||||
* @copyright Copyright © 2023 Regular Labs All Rights Reserved
|
||||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
|
||||
*/
|
||||
|
||||
namespace RegularLabs\Plugin\System\Sourcerer;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory as JFactory;
|
||||
|
||||
class Security
|
||||
{
|
||||
protected static $security = null;
|
||||
|
||||
public static function get()
|
||||
{
|
||||
if ( ! is_null(self::$security))
|
||||
{
|
||||
return self::$security;
|
||||
}
|
||||
|
||||
self::$security = (object) [
|
||||
'pass' => true,
|
||||
'pass_css' => true,
|
||||
'pass_js' => true,
|
||||
'pass_php' => true,
|
||||
];
|
||||
|
||||
return self::$security;
|
||||
}
|
||||
|
||||
public static function set($article = null)
|
||||
{
|
||||
if ( ! isset($article->created_by))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$params = Params::get();
|
||||
|
||||
$security_level = (array) $params->articles_security_level;
|
||||
$security_css = $params->articles_security_level_default_css
|
||||
? (array) $params->articles_security_level
|
||||
: (array) $params->articles_security_level_css;
|
||||
$security_js = $params->articles_security_level_default_js
|
||||
? (array) $params->articles_security_level
|
||||
: (array) $params->articles_security_level_js;
|
||||
$security_php = $params->articles_security_level_default_php
|
||||
? (array) $params->articles_security_level
|
||||
: (array) $params->articles_security_level_php;
|
||||
|
||||
$user = JFactory::getApplication()->getIdentity() ?: JFactory::getUser();
|
||||
$table = $user->getTable();
|
||||
|
||||
if ($table->load($article->created_by))
|
||||
{
|
||||
$user = JFactory::getUser($article->created_by);
|
||||
}
|
||||
|
||||
$groups = $user->getAuthorisedGroups();
|
||||
array_unshift($groups, -1);
|
||||
|
||||
// Set if security is passed
|
||||
// passed = creator is equal or higher than security group level
|
||||
$security = (object) [];
|
||||
$pass = array_intersect($security_level, $groups);
|
||||
$security->pass = ( ! empty($pass));
|
||||
$pass = array_intersect($security_css, $groups);
|
||||
$security->pass_css = ( ! empty($pass));
|
||||
$pass = array_intersect($security_js, $groups);
|
||||
$security->pass_js = ( ! empty($pass));
|
||||
$pass = array_intersect($security_php, $groups);
|
||||
$security->pass_php = ( ! empty($pass));
|
||||
|
||||
self::$security = $security;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user