diff --git a/.eslintrc.js b/.eslintrc.js
index a6b24c0fc..d401f45d2 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -56,6 +56,7 @@ module.exports = {
'!tools/tableau',
'!tools/tags',
'!tools/templates',
- '!tools/toc'
+ '!tools/toc',
+ 'tools/aceditor/presentation/javascripts/ext-searchbox.js'
]
}
diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md
index 6fbf8669e..001cea9aa 100644
--- a/.github/CODE_OF_CONDUCT.md
+++ b/.github/CODE_OF_CONDUCT.md
@@ -10,19 +10,19 @@ In the interest of fostering an open and welcoming environment, we as contributo
Examples of behavior that contributes to creating a positive environment include:
-* Using welcoming and inclusive language
-* Being respectful of differing viewpoints and experiences
-* Gracefully accepting constructive criticism
-* Focusing on what is best for the community
-* Showing empathy towards other community members
+- Using welcoming and inclusive language
+- Being respectful of differing viewpoints and experiences
+- Gracefully accepting constructive criticism
+- Focusing on what is best for the community
+- Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
-* The use of sexualized language or imagery and unwelcome sexual attention or advances
-* Trolling, insulting/derogatory comments, and personal or political attacks
-* Public or private harassment
-* Publishing others' private information, such as a physical or electronic address, without explicit permission
-* Other conduct which could reasonably be considered inappropriate in a professional setting
+- The use of sexualized language or imagery and unwelcome sexual attention or advances
+- Trolling, insulting/derogatory comments, and personal or political attacks
+- Public or private harassment
+- Publishing others' private information, such as a physical or electronic address, without explicit permission
+- Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
index 3de48a6ea..5cb2e8638 100644
--- a/.github/CONTRIBUTING.md
+++ b/.github/CONTRIBUTING.md
@@ -4,10 +4,9 @@ Interesting in contributing? Awesome!
**Quick Links:**
- * [Give your feedback](#give-your-feedback)
- * [Write documentation](#write-documentation)
- * [Develop](#develop)
-
+- [Give your feedback](#give-your-feedback)
+- [Write documentation](#write-documentation)
+- [Develop](#develop)
## Give your feedback
@@ -44,4 +43,4 @@ Then, just go in the browser to start the installation procedure.
### Coding standards
It's a work in progress but we try to follow the [PHP PSR-2 standards](https://www.php-fig.org/psr/psr-2/).
-As for Javascript, a linter (like eslint) can be used to check the code.
+As for Javascript, a linter (like eslint) can be used to check the code.
diff --git a/.github/ISSUE_TEMPLATE/Custom.md b/.github/ISSUE_TEMPLATE/Custom.md
index c5043cb36..42ab188ee 100644
--- a/.github/ISSUE_TEMPLATE/Custom.md
+++ b/.github/ISSUE_TEMPLATE/Custom.md
@@ -4,7 +4,6 @@ about: Describe a bug / Remonter un bogue
title: ''
labels: ''
assignees: ''
-
---
> [!NOTE]
@@ -19,6 +18,7 @@ assignees: ''
Explain the bug / expliquer le bogue
**Additionnal informations / Informations complémentaires**
+
- version of YesWiki / version de YesWiki
- url to see the problem or an example / url pour voir le probleme ou un exemple
- screenshot / capture d’écran
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index 77a06ad02..8fcdedde4 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -1,3 +1,4 @@
## Description of pull request / Description de la demande d'ajout
+
Describe what it does / Expliquer ce que cela fait
Issue references (if exists)/ Demande associée (si elle existe)
diff --git a/.gitignore b/.gitignore
index 0b5fa24b9..6b061f530 100755
--- a/.gitignore
+++ b/.gitignore
@@ -116,7 +116,8 @@ tools/*
*.iml
# vscode IDE
-.vscode
+!.vscode
+.vscode/settings.json
# Docker
.db
@@ -125,4 +126,5 @@ docker-compose.local.yml
# Other
.phpintel/
*.old
+.php-cs-fixer.cache
TODO
diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php
new file mode 100644
index 000000000..6502698ba
--- /dev/null
+++ b/.php-cs-fixer.dist.php
@@ -0,0 +1,90 @@
+in(__DIR__)
+ ->name('*.php')
+ ->exclude('vendor')
+ ->exclude('cache')
+ ->exclude('node_modules');
+
+return (new PhpCsFixer\Config())
+ ->setRules([
+ '@PSR12' => true, // Start with PSR-12 rules
+ '@Symfony' => true, // Add Symfony rules for more comprehensive formatting
+ // Additional custom rules
+ // https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/master/doc/rules/index.rst
+ 'array_indentation' => true,
+ 'array_syntax' => ['syntax' => 'short'],
+ 'binary_operator_spaces' => [
+ 'default' => 'single_space'
+ ],
+ 'yoda_style' => false,
+ 'blank_line_after_namespace' => true,
+ 'blank_line_after_opening_tag' => true,
+ 'increment_style' => ['style' => 'post'],
+ 'blank_line_before_statement' => [
+ 'statements' => ['return']
+ ],
+ 'cast_spaces' => ['space' => 'none'],
+ 'class_attributes_separation' => [
+ 'elements' => ['method' => 'one']
+ ],
+ 'concat_space' => ['spacing' => 'one'],
+ 'declare_equal_normalize' => ['space' => 'none'],
+ 'function_declaration' => ['closure_function_spacing' => 'one'],
+ 'include' => true,
+ 'indentation_type' => true,
+ 'lowercase_cast' => true,
+ 'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
+ 'new_with_braces' => true,
+ 'no_blank_lines_after_class_opening' => true,
+ 'no_blank_lines_after_phpdoc' => true,
+ 'no_empty_statement' => true,
+ 'no_extra_blank_lines' => [
+ 'tokens' => [
+ 'extra',
+ 'throw',
+ 'use',
+ 'use_trait',
+ 'curly_brace_block',
+ 'parenthesis_brace_block',
+ 'square_brace_block',
+ 'switch',
+ 'case',
+ 'default',
+ ],
+ ],
+ 'no_leading_import_slash' => true,
+ 'no_leading_namespace_whitespace' => true,
+ 'no_mixed_echo_print' => ['use' => 'echo'],
+ 'no_multiline_whitespace_around_double_arrow' => true,
+ 'no_short_bool_cast' => true,
+ 'no_singleline_whitespace_before_semicolons' => true,
+ 'no_spaces_around_offset' => ['positions' => ['inside', 'outside']],
+ 'no_trailing_comma_in_singleline_array' => true,
+ 'no_trailing_whitespace' => true,
+ 'no_trailing_whitespace_in_comment' => true,
+ 'no_unused_imports' => false,
+ 'no_whitespace_before_comma_in_array' => true,
+ 'no_whitespace_in_blank_line' => true,
+ 'normalize_index_brace' => true,
+ 'object_operator_without_whitespace' => true,
+ 'ordered_imports' => ['sort_algorithm' => 'alpha'],
+ 'semicolon_after_instruction' => true,
+ 'short_scalar_cast' => true,
+ 'single_blank_line_at_eof' => true,
+ 'single_class_element_per_statement' => ['elements' => ['property']],
+ 'single_import_per_statement' => true,
+ 'single_line_after_imports' => true,
+ 'single_quote' => true,
+ 'space_after_semicolon' => ['remove_in_empty_for_expressions' => true],
+ 'standardize_not_equals' => true,
+ 'switch_case_semicolon_to_colon' => true,
+ 'switch_case_space' => true,
+ 'trailing_comma_in_multiline' => ['elements' => ['arrays']],
+ 'trim_array_spaces' => true,
+ 'unary_operator_spaces' => true,
+ 'whitespace_after_comma_in_array' => true,
+ ])
+ ->setFinder($finder)
+ ->setUsingCache(false); // Adjust cache settings as needed
diff --git a/.prettierignore b/.prettierignore
new file mode 100644
index 000000000..6241b226b
--- /dev/null
+++ b/.prettierignore
@@ -0,0 +1 @@
+**/vendor/**
\ No newline at end of file
diff --git a/.prettierrc b/.prettierrc
new file mode 100644
index 000000000..544138be4
--- /dev/null
+++ b/.prettierrc
@@ -0,0 +1,3 @@
+{
+ "singleQuote": true
+}
diff --git a/.stylelintignore b/.stylelintignore
deleted file mode 100644
index 22c93dcf4..000000000
--- a/.stylelintignore
+++ /dev/null
@@ -1,4 +0,0 @@
-cache
-custom
-node_modules
-vendor
\ No newline at end of file
diff --git a/.stylelintrc.json b/.stylelintrc.json
deleted file mode 100644
index 425b4df0d..000000000
--- a/.stylelintrc.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "extends": "stylelint-config-standard"
-}
\ No newline at end of file
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
new file mode 100644
index 000000000..c6d2e9dbc
--- /dev/null
+++ b/.vscode/extensions.json
@@ -0,0 +1,8 @@
+{
+ "recommendations": [
+ "esbenp.prettier-vscode",
+ "mhutchie.git-graph",
+ "junstyle.php-cs-fixer",
+ "dbaeumer.vscode-eslint"
+ ]
+}
diff --git a/.vscode/settings.example.json b/.vscode/settings.example.json
new file mode 100755
index 000000000..51f46e4ab
--- /dev/null
+++ b/.vscode/settings.example.json
@@ -0,0 +1,23 @@
+{
+ "php-cs-fixer.executablePath": "/var/www/html/vendor/bin/php-cs-fixer",
+ "php-cs-fixer.ignorePHPVersion": true,
+ "editor.formatOnSave": true,
+ "editor.formatOnPaste": true,
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
+ "[php]": {
+ "editor.defaultFormatter": "junstyle.php-cs-fixer"
+ },
+ "editor.codeActionsOnSave": {
+ "source.fixAll.eslint": "always"
+ },
+ "[twig]": {
+ "editor.formatOnSave": false,
+ "editor.formatOnPaste": false
+ },
+ "[javascript]": {
+ "editor.defaultFormatter": "dbaeumer.vscode-eslint"
+ },
+ "[css]": {
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
+ }
+}
diff --git a/Makefile b/Makefile
index 5452934bb..511d11763 100644
--- a/Makefile
+++ b/Makefile
@@ -27,3 +27,14 @@ yarn-install: yarn.lock ## Install npm vendors according to the current yarn.loc
## —— Tests ———————————————
test: ## Launch unit tests
./vendor/bin/phpunit --do-not-cache-result --stderr tests
+
+## —— Linters & Formatters ———————————————
+lint: lint-php lint-js lint-other ## run all linters and formatters
+
+lint-php: ## Lint php
+ PHP_CS_FIXER_IGNORE_ENV=false ./vendor/bin/php-cs-fixer fix
+lint-js: ## Lint JS
+ yarn run lint-js
+lint-other: ## Lint other files
+ yarn run lint-js
+ yarn run lint-other
diff --git a/README.md b/README.md
index cfa69ce13..50d377eb9 100755
--- a/README.md
+++ b/README.md
@@ -25,6 +25,25 @@ YesWiki can be installed in about ten minutes on a server which supports **PHP >
We are using [weblate](https://hosted.weblate.org/yeswiki) to translate our software!
+## Developers
+
+We recommand an installation through docker.
+
+### Linters & Formatters
+
+Please install relevant extension and enable auto formating on your editor.
+
+Alternatly you can run `make lint`
+
+| Language | Linter/Formatter |
+| --------------------------- | ------------------------------------------------------------ |
+| Php | `php-cs-fixer` |
+| Javascript | `eslint` |
+| Twig | no automatic linter. Couldn't find one which is good enough. |
+| CSS, Yaml, JSON, Markdown.. | `prettier` |
+
+If you use VS Codium, get yeswiki linting settings with `cp .vscode/settings.example.json .vscode/settings.json`
+
## History
YesWiki grew out of a French language version of [WakkaWiki](https://en.wikipedia.org/wiki/WakkaWiki) called [Wikini](http://wikini.net), and hence has strong French language support.
@@ -41,8 +60,8 @@ YesWiki grew out of a French language version of [WakkaWiki](https://en.wikipedi
- 2002, 2003, 2004 David DELON
- 2002, 2003, 2004 Charles NEPOTE
- 2002, 2003, 2004 Patrick PAUL
-- 2003 Eric DELORD
-- 2003, 2004 Eric FELDSTEIN
+- 2003 Eric DELORD
+- 2003, 2004 Eric FELDSTEIN
- 2003 Jean-Pascal MILCENT
- 2003 Jéréme DESQUILBET
- 2003 Erus UMBRAE
diff --git a/SECURITY.md b/SECURITY.md
index 0eb26051b..3f71b14fc 100644
--- a/SECURITY.md
+++ b/SECURITY.md
@@ -5,12 +5,12 @@
The two last major versions of YesWiki are
currently being supported with security updates.
-| Version | Supported |
-| ------------------- | ------------------ |
-| doryphore 4.x | :white_check_mark: |
-| cercopitheque 3.x | :white_check_mark: |
-| bachibouzouk 2.x | :x: |
-| anacoluthe 1.x | :x: |
+| Version | Supported |
+| ----------------- | ------------------ |
+| doryphore 4.x | :white_check_mark: |
+| cercopitheque 3.x | :white_check_mark: |
+| bachibouzouk 2.x | :x: |
+| anacoluthe 1.x | :x: |
## Reporting a Vulnerability
diff --git a/actions/AdminBackupsAction.php b/actions/AdminBackupsAction.php
index 7c5b03ba2..c420bf0fc 100644
--- a/actions/AdminBackupsAction.php
+++ b/actions/AdminBackupsAction.php
@@ -1,9 +1,9 @@
wiki->UserIsAdmin()) {
return $this->render('@templates/alert-message.twig', [
'type' => 'danger',
- 'message' => get_class($this)." : " . _t('BAZ_NEED_ADMIN_RIGHTS')
- ]) ;
+ 'message' => get_class($this) . ' : ' . _t('BAZ_NEED_ADMIN_RIGHTS'),
+ ]);
}
$status = $this->getService(ArchiveService::class)->getArchivingStatus();
if (!$status['canArchive']) {
@@ -32,12 +32,13 @@ public function run()
} elseif ($status['dB'] == false) {
$message = _t('ADMIN_BACKUPS_MESSAGE_DB_NOT_ARCHIVABLE');
}
+
return $this->render('@templates/alert-message.twig', [
'type' => 'warning',
- 'message' => _t('ADMIN_BACKUPS_MESSAGE_ARCHIVE_CANNOT_BE_DONE').' '.$message.'
'._t('ADMIN_BACKUPS_MESSAGE_SEE_DOC').'.'
+ 'message' => _t('ADMIN_BACKUPS_MESSAGE_ARCHIVE_CANNOT_BE_DONE') . ' ' . $message . '
' . _t('ADMIN_BACKUPS_MESSAGE_SEE_DOC') . '.',
]);
-
}
+
return $this->render('@core/actions/admin-backups.twig', [
]);
}
diff --git a/actions/AdminReactionsAction.php b/actions/AdminReactionsAction.php
index 151bb2719..9d2ee26f2 100644
--- a/actions/AdminReactionsAction.php
+++ b/actions/AdminReactionsAction.php
@@ -1,9 +1,9 @@
wiki->UserIsAdmin()) {
$allReactions = $this->wiki->services->get(ReactionManager::class)->getReactions();
foreach ($allReactions as $k => $reactions) {
- usort($reactions["reactions"], function ($a, $b) { // sort by user
+ usort($reactions['reactions'], function ($a, $b) { // sort by user
return strnatcasecmp($a['user'], $b['user']);
});
}
+
return $this->render('@core/admin-reactions-table.twig', [
- 'reactions' => $allReactions
+ 'reactions' => $allReactions,
]);
} else {
return $this->render('@templates/alert-message.twig', [
'type' => 'info',
- 'message' => _t('REACTION_CONNECT_AS_ADMIN')
+ 'message' => _t('REACTION_CONNECT_AS_ADMIN'),
]);
}
}
diff --git a/actions/CommentsAction.php b/actions/CommentsAction.php
index a59558287..5f3669045 100644
--- a/actions/CommentsAction.php
+++ b/actions/CommentsAction.php
@@ -1,7 +1,7 @@
commentsService = $this->getService(CommentService::class);
- $coms = $this->commentsService->loadComments(''); # get all comments
+ $this->commentsService = $this->getService(CommentService::class);
+ $coms = $this->commentsService->loadComments(''); // get all comments
+
return $this->render('@core/comment-table.twig', [
'comments' => $coms,
- ]) ;
+ ]);
}
}
diff --git a/actions/EditActionsAclsAction.php b/actions/EditActionsAclsAction.php
index c71033605..9db3d33ec 100755
--- a/actions/EditActionsAclsAction.php
+++ b/actions/EditActionsAclsAction.php
@@ -1,7 +1,7 @@
wiki->UserIsAdmin()) {
return $this->render('@templates/alert-message.twig', [
'type' => 'danger',
- 'message' => "EditActionsAclsAction : " . _t('BAZ_NEED_ADMIN_RIGHTS')
- ]) ;
+ 'message' => 'EditActionsAclsAction : ' . _t('BAZ_NEED_ADMIN_RIGHTS'),
+ ]);
}
$wiki = &$this->wiki;
$list = $wiki->services->get(Performer::class)->list('action');
sort($list);
$res = $wiki->FormOpen('', '', 'get');
- $res .= _t('ACTION_RIGHTS').' ' . $wiki->FormClose();
if ($_POST && !empty($_POST['actionname'])) { // save ACL's
$result = $wiki->SetModuleACL($name = $_POST['actionname'], 'action', @$_POST['acl']);
if ($result) {
- return $res . _t('ERROR_WHILE_SAVING_ACL') .' ' . ucfirst($name) . ' ('._t('ERROR_CODE').' ' . $result . ')
';
+ return $res . _t('ERROR_WHILE_SAVING_ACL') . ' ' . ucfirst($name) . ' (' . _t('ERROR_CODE') . ' ' . $result . ')
';
} else {
- $wiki->LogAdministrativeAction($wiki->GetUserName(), _t('NEW_ACL_FOR_ACTION')." " . ucfirst($name) . ' : ' . @$_POST['acl'] . "\n");
- return $res . _t('NEW_ACL_SUCCESSFULLY_SAVED_FOR_ACTION').' ' . ucfirst($name) . '.
';
+ $wiki->LogAdministrativeAction($wiki->GetUserName(), _t('NEW_ACL_FOR_ACTION') . ' ' . ucfirst($name) . ' : ' . @$_POST['acl'] . "\n");
+
+ return $res . _t('NEW_ACL_SUCCESSFULLY_SAVED_FOR_ACTION') . ' ' . ucfirst($name) . '.
';
}
} elseif (!empty($_GET['actionname']) && in_array($name = $_GET['actionname'], $list)) {
$res .= $wiki->FormOpen();
- $res .= '
'._t('EDIT_RIGHTS_FOR_ACTION').' ' . ucfirst($name) . ':';
- $res .= '';
+ $res .= '
' . _t('EDIT_RIGHTS_FOR_ACTION') . ' ' . ucfirst($name) . ':';
+ $res .= '';
$res .= '
';
- $res .= '';
+ $res .= '';
+
return $res . $wiki->FormClose();
}
+
return $res;
}
}
diff --git a/actions/EditConfigAction.php b/actions/EditConfigAction.php
index d347ac603..05528b636 100644
--- a/actions/EditConfigAction.php
+++ b/actions/EditConfigAction.php
@@ -1,7 +1,7 @@
wiki->UserIsAdmin()) {
return $this->render('@templates/alert-message.twig', [
'type' => 'danger',
- 'message' => get_class($this) . " : " . _t('BAZ_NEED_ADMIN_RIGHTS')
+ 'message' => get_class($this) . ' : ' . _t('BAZ_NEED_ADMIN_RIGHTS'),
]);
}
if (!is_writable('wakka.config.php')) {
return $this->render('@templates/alert-message.twig', [
'type' => 'danger',
- 'message' => _t('ERROR_NO_ACCESS') . ' ' . _t('FILE_WRITE_PROTECTED')
+ 'message' => _t('ERROR_NO_ACCESS') . ' ' . _t('FILE_WRITE_PROTECTED'),
]);
}
@@ -73,11 +73,11 @@ public function run()
$output = '';
if ($this->arguments['saving']) {
$this->save();
- $this->wiki->Redirect($this->wiki->Href('', '', [self::SAVED_NAME => "1"], false));
+ $this->wiki->Redirect($this->wiki->Href('', '', [self::SAVED_NAME => '1'], false));
} elseif ($this->arguments['saved']) {
$output .= $this->render('@templates/alert-message.twig', [
'type' => 'info',
- 'message' => _t('EDIT_CONFIG_SAVE')
+ 'message' => _t('EDIT_CONFIG_SAVE'),
]);
}
@@ -91,6 +91,7 @@ public function run()
$keysList[''] = array_merge($keysList[''] ?? [], [$key => $value]);
}
}
+
return $output . $this->render('@core/edit-config.twig', [
'SAVE_NAME' => self::SAVE_NAME,
'keysList' => $keysList,
@@ -101,7 +102,7 @@ public function run()
/**
* get AUTHORIZED_KEYS
- * return array [$keys,$associatedExtensions]
+ * return array [$keys,$associatedExtensions].
*/
private function getAuthorizedKeys(): array
{
@@ -152,30 +153,32 @@ private function getAuthorizedKeys(): array
$this->keys = $scannedKeys;
$this->associatedExtensions = $associatedExtensions;
}
+
return [$this->keys, $this->associatedExtensions];
}
/**
* prepare array of $keyNames from $keys
- * recursive
+ * recursive.
*
* @param array|string $keys
- * @param bool $firstLevel
+ *
* @return array [$keyName1,$keyName2]
*/
private function prepareKeyNames($keys, bool $firstLevel = false): array
{
if (is_string($keys)) {
- return ($firstLevel ? [$keys] : ["[{$keys}]"]);
+ return $firstLevel ? [$keys] : ["[{$keys}]"];
} elseif (is_array($keys)) {
$result = [];
$isList = $this->arrayIsList($keys);
foreach ($keys as $key => $value) {
$subLevelKeyNames = $this->prepareKeyNames($value, $firstLevel && $isList);
foreach ($subLevelKeyNames as $subLevelKeyName) {
- $result[] = ($isList ? "" : ($firstLevel ? $key : "[{$key}]")) . $subLevelKeyName;
+ $result[] = ($isList ? '' : ($firstLevel ? $key : "[{$key}]")) . $subLevelKeyName;
}
}
+
return $result;
} else {
return [];
@@ -183,7 +186,7 @@ private function prepareKeyNames($keys, bool $firstLevel = false): array
}
/**
- * could be replace by array_is_list since php 8.1
+ * could be replace by array_is_list since php 8.1.
*/
private function arrayIsList(array $array): bool
{
@@ -193,12 +196,14 @@ private function arrayIsList(array $array): bool
return false;
}
}
+
return true;
}
/**
- * save data to wakka.config.php
- * @return boolean true if successfull
+ * save data to wakka.config.php.
+ *
+ * @return bool true if successfull
*/
private function save(): bool
{
@@ -278,16 +283,16 @@ private function save(): bool
$config->$firstLevelKey,
[
$keyAsArray[1] => [
- $keyAsArray[2] => $this->strtoarray($new_value)
- ]
+ $keyAsArray[2] => $this->strtoarray($new_value),
+ ],
]
);
}
} else {
$config->$firstLevelKey = [
$keyAsArray[1] => [
- $keyAsArray[2] => $this->strtoarray($new_value)
- ]
+ $keyAsArray[2] => $this->strtoarray($new_value),
+ ],
];
}
}
@@ -303,7 +308,8 @@ private function save(): bool
}
/**
- * get data from config file
+ * get data from config file.
+ *
* @return array [$data,$placeholders,$associatedExtensions] format ['name' => string $value,'name2'=> "['ee'=>'yy',...]"]
*/
private function getDataFromConfigFile(): array
@@ -318,13 +324,13 @@ private function getDataFromConfigFile(): array
if (!empty($keyAsArray)) {
$length = count($keyAsArray);
$firstLevelKey = $keyAsArray[0];
- $keyName = $firstLevelKey . ($length > 1 ? "[" . implode("][", array_slice($keyAsArray, 1)) . "]" : "");
+ $keyName = $firstLevelKey . ($length > 1 ? '[' . implode('][', array_slice($keyAsArray, 1)) . ']' : '');
switch ($length) {
case 1:
if (isset($config->$firstLevelKey)) {
$data[$keyName] = $this->array2Str($config->$firstLevelKey);
} else {
- $data[$keyName] = "";
+ $data[$keyName] = '';
}
if ($this->params->has($firstLevelKey)) {
$placeholders[$keyName] = $this->array2Str($this->params->get($firstLevelKey));
@@ -337,7 +343,7 @@ private function getDataFromConfigFile(): array
) {
$data[$keyName] = $this->array2Str($config->$firstLevelKey[$keyAsArray[1]]);
} else {
- $data[$keyName] = "";
+ $data[$keyName] = '';
}
if (
$this->params->has($firstLevelKey)
@@ -354,7 +360,7 @@ private function getDataFromConfigFile(): array
) {
$data[$keyName] = $this->array2Str($config->$firstLevelKey[$keyAsArray[1]][$keyAsArray[2]]);
} else {
- $data[$keyName] = "";
+ $data[$keyName] = '';
}
if (
$this->params->has($firstLevelKey)
@@ -366,17 +372,18 @@ private function getDataFromConfigFile(): array
break;
default:
- $data[$keyName] = "";
+ $data[$keyName] = '';
break;
}
}
}
+
return [$data, $placeholders, $associatedExtensions];
}
/**
- * convert $keys to array of arrays
- * @param array $keys
+ * convert $keys to array of arrays.
+ *
* @return array $conertedKeys
*/
private function convertKeysAsArray(array $keys): array
@@ -399,19 +406,21 @@ private function convertKeysAsArray(array $keys): array
}
}
}
+
return $convertedKeys;
}
/**
- * extract associated values from config second level
+ * extract associated values from config second level.
+ *
* @param Configuration $config
- * @param string $firstLevelKey
+ * @param string $firstLevelKey
*/
/**
- * array to string
+ * array to string.
+ *
* @param mixed $value
- * @return string
*/
private function array2Str($value): string
{
@@ -421,7 +430,7 @@ private function array2Str($value): string
. implode(
',',
array_map(function ($k, $v) {
- return (($v === false) ? "false" : (($v === true) ? "true" : "'" . $v . "'"));
+ return ($v === false) ? 'false' : (($v === true) ? 'true' : "'" . $v . "'");
}, array_keys($value), array_values($value))
)
. ']';
@@ -430,24 +439,25 @@ private function array2Str($value): string
. implode(
',',
array_map(function ($k, $v) {
- return "'" . $k . "' => " . (($v === false) ? "false" : (($v === true) ? "true" : "'" . $v . "'"));
+ return "'" . $k . "' => " . (($v === false) ? 'false' : (($v === true) ? 'true' : "'" . $v . "'"));
}, array_keys($value), array_values($value))
)
. ']';
}
} elseif (!is_string($value)) {
try {
- $value = (($value === false) ? "false" : (($value === true) ? "true" : strval($value)));
+ $value = (($value === false) ? 'false' : (($value === true) ? 'true' : strval($value)));
} catch (\Throwable $th) {
$value = '';
}
}
+
return $value;
}
/**
- * string to array if needed
- * @param string $value
+ * string to array if needed.
+ *
* @return mixed
*/
private function strtoarray(string $value)
@@ -487,12 +497,12 @@ private function strtoarray(string $value)
} else {
$value = ($value == 'true') ? true : (($value == 'false') ? false : $value);
}
+
return $value;
}
/**
- * get help from translation
- * @return array
+ * get help from translation.
*/
private function getHelp(): array
{
@@ -500,7 +510,7 @@ private function getHelp(): array
foreach ($this->convertKeysAsArray($this->getAuthorizedKeys()[0]) as $keyAsArray) {
$length = count($keyAsArray);
$firstLevelKey = $keyAsArray[0];
- $keyName = $firstLevelKey . ($length > 1 ? "[" . implode("][", array_slice($keyAsArray, 1)) . "]" : "");
+ $keyName = $firstLevelKey . ($length > 1 ? '[' . implode('][', array_slice($keyAsArray, 1)) . ']' : '');
if (isset($GLOBALS['translations']['EDIT_CONFIG_HINT_' . $keyName])) {
$help[$keyName] = _t('EDIT_CONFIG_HINT_' . $keyName);
} elseif (isset($GLOBALS['translations']['EDIT_CONFIG_HINT_' . strtoupper($keyName)])) {
diff --git a/actions/EditGroupsAction.php b/actions/EditGroupsAction.php
index 7740da7d5..9e5adf837 100755
--- a/actions/EditGroupsAction.php
+++ b/actions/EditGroupsAction.php
@@ -1,6 +1,5 @@
wiki->UserIsAdmin()) {
return $this->render('@templates/alert-message.twig', [
'type' => 'danger',
- 'message' => "EditGroupsAction : " . _t('BAZ_NEED_ADMIN_RIGHTS')
- ]) ;
+ 'message' => 'EditGroupsAction : ' . _t('BAZ_NEED_ADMIN_RIGHTS'),
+ ]);
}
$message = '';
@@ -44,7 +43,7 @@ public function run()
list('message' => $message, 'type' => $type) = $this->deleteGroup($selectedGroupName);
}
} catch (TokenNotFoundException $th) {
- $message = _t('ERROR_WHILE_SAVING_GROUP') .':
'. $th->getMessage();
+ $message = _t('ERROR_WHILE_SAVING_GROUP') . ':
' . $th->getMessage();
}
}
}
@@ -59,7 +58,7 @@ public function run()
return $this->render(
'@core/actions/edit-group-action.twig',
- compact(['list','message','type','currentGroupAcl','selectedGroupName','action'])
+ compact(['list', 'message', 'type', 'currentGroupAcl', 'selectedGroupName', 'action'])
);
}
@@ -81,23 +80,21 @@ protected function saveAcl(string $selectedGroupName): array
if ($result) {
if ($result == 1000) {
- $message = _t('ERROR_RECURSIVE_GROUP').' !';
+ $message = _t('ERROR_RECURSIVE_GROUP') . ' !';
} else {
- $message = _t('ERROR_WHILE_SAVING_GROUP') . ' ' . ucfirst($selectedGroupName) . ' ('._t('ERROR_CODE').' ' . $result . ')';
+ $message = _t('ERROR_WHILE_SAVING_GROUP') . ' ' . ucfirst($selectedGroupName) . ' (' . _t('ERROR_CODE') . ' ' . $result . ')';
}
} else {
- //
- $this->wiki->LogAdministrativeAction($this->wiki->GetUserName(), _t('NEW_ACL_FOR_GROUP')." " . ucfirst($selectedGroupName) . ' : ' . $newacl . "\n");
- $message = _t('NEW_ACL_SUCCESSFULLY_SAVED_FOR_THE_GROUP').' ' . ucfirst($selectedGroupName);
+ $this->wiki->LogAdministrativeAction($this->wiki->GetUserName(), _t('NEW_ACL_FOR_GROUP') . ' ' . ucfirst($selectedGroupName) . ' : ' . $newacl . "\n");
+ $message = _t('NEW_ACL_SUCCESSFULLY_SAVED_FOR_THE_GROUP') . ' ' . ucfirst($selectedGroupName);
$type = 'success';
}
}
}
- return compact(['message','type']);
+ return compact(['message', 'type']);
}
-
protected function deleteGroup(string &$selectedGroupName): array
{
$message = '';
@@ -116,7 +113,7 @@ protected function deleteGroup(string &$selectedGroupName): array
$ownedPages = $dbService->loadAll($sql); // if group owns no pages, then empty
if (!empty($ownedPages)) {
// Array is not empty because the query returns at least one page
- $message = _t('ONLY_NO_PAGES_GROUP_FOR_DELETION').'
';
+ $message = _t('ONLY_NO_PAGES_GROUP_FOR_DELETION') . '
';
$message .= implode('
', array_map(function ($acl) {
return "wiki->Href('', $acl['page_tag'])}\">{$acl['page_tag']}";
}, $ownedPages));
@@ -131,7 +128,7 @@ protected function deleteGroup(string &$selectedGroupName): array
$dbService->query($sql);
$tripleStore = $this->getService(TripleStore::class);
- $previous = $tripleStore->getMatching(GROUP_PREFIX.$selectedGroupName, WIKINI_VOC_PREFIX.WIKINI_VOC_ACLS, '', '=');
+ $previous = $tripleStore->getMatching(GROUP_PREFIX . $selectedGroupName, WIKINI_VOC_PREFIX . WIKINI_VOC_ACLS, '', '=');
$deletionOk = false;
if (!empty($previous)) {
$deletionOk = true;
@@ -153,7 +150,7 @@ protected function deleteGroup(string &$selectedGroupName): array
}
}
- return compact(['message','type']);
+ return compact(['message', 'type']);
}
protected function confirmToken()
diff --git a/actions/EditHandlersAclsAction.php b/actions/EditHandlersAclsAction.php
index 146720d3a..7ee29e026 100755
--- a/actions/EditHandlersAclsAction.php
+++ b/actions/EditHandlersAclsAction.php
@@ -1,7 +1,7 @@
wiki->UserIsAdmin()) {
return $this->render('@templates/alert-message.twig', [
'type' => 'danger',
- 'message' => "EditHandlersAclsAction : " . _t('BAZ_NEED_ADMIN_RIGHTS')
- ]) ;
+ 'message' => 'EditHandlersAclsAction : ' . _t('BAZ_NEED_ADMIN_RIGHTS'),
+ ]);
}
$wiki = &$this->wiki;
$list = $wiki->services->get(Performer::class)->list('handler');
sort($list);
$res = $wiki->FormOpen('', '', 'get');
- $res .= _t('HANDLER_RIGHTS').'
';
+ return $res . _t('ERROR_WHILE_SAVING_HANDLER_ACL') . ' ' . ucfirst($name) . ' (' . _t('ERROR_CODE') . ' ' . $result . ')
';
} else {
- $wiki->LogAdministrativeAction($wiki->GetUserName(), _t('NEW_ACL_FOR_HANDLER')." " . ucfirst($name) . ' : ' . @$_POST['acl'] . "\n");
- return $res . _t('NEW_ACL_SUCCESSFULLY_SAVED_FOR_HANDLER').' ' . ucfirst($name) . '.
';
+ $wiki->LogAdministrativeAction($wiki->GetUserName(), _t('NEW_ACL_FOR_HANDLER') . ' ' . ucfirst($name) . ' : ' . @$_POST['acl'] . "\n");
+
+ return $res . _t('NEW_ACL_SUCCESSFULLY_SAVED_FOR_HANDLER') . ' ' . ucfirst($name) . '.
';
}
} elseif (!empty($_GET['handlername']) && in_array($name = $_GET['handlername'], $list)) {
$res .= $wiki->FormOpen();
- $res .= '
'._t('EDIT_RIGHTS_FOR_HANDLER').' ' . ucfirst($name) . ':
';
- $res .= '';
+ $res .= '
' . _t('EDIT_RIGHTS_FOR_HANDLER') . ' ' . ucfirst($name) . ':
';
+ $res .= '';
$res .= '
';
- $res .= '';
+ $res .= '';
+
return $res . $wiki->FormClose();
}
+
return $res;
}
}
diff --git a/actions/EraseSpamedCommentsAction.php b/actions/EraseSpamedCommentsAction.php
index 674f68444..ff2807d6e 100755
--- a/actions/EraseSpamedCommentsAction.php
+++ b/actions/EraseSpamedCommentsAction.php
@@ -1,7 +1,7 @@
wiki;
ob_start();
- echo "\n\n";
+ echo "\n\n";
// -- 2. Affichage du formulaire ---
if (!isset($_POST['clean'])) {
- $limit = isset($this->arguments['max']) && $this->arguments["max"] > 0 ? (int) $this->arguments["max"] : 0;
+ $limit = isset($this->arguments['max']) && $this->arguments['max'] > 0 ? (int)$this->arguments['max'] : 0;
if ($comments = $wiki->LoadRecentComments($limit)) {
// Formulaire listant les commentaires
- echo "
Href()."\">"._t('FORM_RETURN').".
"; + $deletedPages = trim($deletedPages, ', '); + echo ''; } // -- 3.2 Si aucune page n'a été sélectionné : message else { - echo ""._t('NO_SELECTED_COMMENTS_TO_ERASE').".
"; - echo "Href()."\">"._t('FORM_RETURN').".
"; + echo '' . _t('NO_SELECTED_COMMENTS_TO_ERASE') . '.
'; + echo ''; } // -- 3.3 écriture du journal des actions --- @@ -105,22 +100,23 @@ public function run() // -- Détermine quelle est la page de log : // -- passée en paramétre // -- ou la page de log par défaut - $reportingPage = isset($this->arguments["logpage"]) ? $this->arguments["logpage"] : ""; + $reportingPage = isset($this->arguments['logpage']) ? $this->arguments['logpage'] : ''; // -- Ajout de la ligne de log $wiki->LogAdministrativeAction( $wiki->GetUserName(), - _t("ERASED_COMMENTS") . + _t('ERASED_COMMENTS') . /*" [" .*/ /*$_POST['comment'] .*/ /* "]".*/ - " : " . - "\"\"". + ' : ' . + '""' . $deletedPages . - "\"\"". + '""' . "\n", $reportingPage ); } } + return ob_get_clean(); } } diff --git a/actions/FooterAction.php b/actions/FooterAction.php index 53f4315cd..fd05ac9bd 100644 --- a/actions/FooterAction.php +++ b/actions/FooterAction.php @@ -1,8 +1,8 @@ loadTheme(); } catch (Throwable $t) { // catch errors and exception to avoid a loop with error management in Performer - $output = ''."\n"; - $output .= ' ' ; + $output = '' . "\n"; + $output .= ' '; + return $output; } $output = null; if ($themeLoaded) { - $output = $themeManager->renderFooter() ; + $output = $themeManager->renderFooter(); // on affiche les requetes SQL et le temps de chargement en mode debug if ($this->wiki->GetConfigValue('debug') == 'yes') { $debug_log_sql_queries = ''; @@ -31,20 +32,21 @@ public function run() $queryLog = $this->getService(DbService::class)->getQueryLog(); foreach ($queryLog as $query) { - $debug_log_sql_queries .= $query['query'].' ('.round($query['time'], 4).")