Skip to content

Commit

Permalink
Add i18n to resource types (#10)
Browse files Browse the repository at this point in the history
* Add priority functionality

* Add new i18n strings

* Disable fields on delete form

Should just be there for information purposes. Can also be misleading if user thinks `rla_page` is used to delete and not the hidden `rla_id`.

* Update sql/resourceloaderarticlesPriorityMigration.sql

Co-authored-by: Alex Winkler <[email protected]>

* Add priority help text

Explain the load order - higher loaded first

* Fix `ORDER BY` statements

Also added separating header rows in the special page between scripts and styles.

* Use `help-message` to get i18n key instead

Co-authored-by: Alex Winkler <[email protected]>

* Fix composer requiring permission for plugin

* Update src/SpecialPage/SpecialResourceLoaderArticles.php

* Update sql/resourceloaderarticlesPriorityMigration.sql

Co-authored-by: Alex Winkler <[email protected]>

* Update sql/resourceloaderarticlesPriorityMigration.sql

Co-authored-by: Martin B <[email protected]>

* make line shorter by cutting down comment

* Update SpecialResourceLoaderArticles.php

* Add i18n to resource types

* fix weird upstream merge

---------

Co-authored-by: Alex Winkler <[email protected]>
  • Loading branch information
iMarbot and FO-nTTaX authored Apr 16, 2024
1 parent 5c3e5aa commit 07dedec
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
3 changes: 3 additions & 0 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"resourceloaderarticles-priority": "Priority",
"resourceloaderarticles-id": "ID",

"resourceloaderarticles-resourcetype-script": "JavaScript",
"resourceloaderarticles-resourcetype-style": "Style Sheet",

"resourceloaderarticles-error-page-empty": "The page parameter cannot be empty!",
"resourceloaderarticles-error-page-invalid": "The page name is invalid!",
"resourceloaderarticles-error-priority-empty": "The priority parameter cannot be empty!",
Expand Down
24 changes: 14 additions & 10 deletions src/SpecialPage/SpecialResourceLoaderArticles.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ private function listPages() {
$deleteTitle = Title::newFromText( 'ResourceLoaderArticles/delete/' . $row->rla_id, NS_SPECIAL );
$editTitle = Title::newFromText( 'ResourceLoaderArticles/edit/' . $row->rla_id, NS_SPECIAL );
if ( $prevResType !== $row->rla_type ) {
$output->addHTML( "<tr><th colspan='6'>{ $row->rla_type }s</th></tr>" );
$output->addHTML(
'<tr><th colspan="6">'
. $this->msg( 'resourceloaderarticles-resourcetype-' . $row->rla_type )->text()
. '</th></tr>'
);
$prevResType = $row->rla_type;
}
$output->addHTML(
Expand Down Expand Up @@ -121,9 +125,9 @@ private function addPage() {
'Type' => [
'class' => 'HTMLSelectField',
'label' => 'Select an option',
'options' => [
'JavaScript' => 'script',
'CSS' => 'style',
'options-messages' => [
'resourceloaderarticles-resourcetype-script' => 'script',
'resourceloaderarticles-resourcetype-style' => 'style',
],
],
'Priority' => [
Expand Down Expand Up @@ -240,9 +244,9 @@ private function editPage( $id ) {
'Type' => [
'class' => 'HTMLSelectField',
'label' => 'Select an option',
'options' => [
'JavaScript' => 'script',
'CSS' => 'style',
'options-messages' => [
'resourceloaderarticles-resourcetype-script' => 'script',
'resourceloaderarticles-resourcetype-style' => 'style',
],
'default' => $row->rla_type,
],
Expand Down Expand Up @@ -366,9 +370,9 @@ private function deletePage( $id ) {
'Type' => [
'class' => 'HTMLSelectField',
'label' => 'Select an option',
'options' => [
'JavaScript' => 'script',
'CSS' => 'style',
'options-messages' => [
'resourceloaderarticles-resourcetype-script' => 'script',
'resourceloaderarticles-resourcetype-style' => 'style',
],
'disabled' => true,
'default' => $row->rla_type,
Expand Down

0 comments on commit 07dedec

Please sign in to comment.