Skip to content

Commit

Permalink
Merge branch 'doryphore-dev' into docker
Browse files Browse the repository at this point in the history
  • Loading branch information
mrflos committed Mar 22, 2024
2 parents 2df750a + c5a9703 commit ad3f350
Show file tree
Hide file tree
Showing 346 changed files with 3,343 additions and 2,912 deletions.
25 changes: 10 additions & 15 deletions actions/AdminBackupsAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public function run()
{
if (!$this->wiki->UserIsAdmin()) {
return $this->render('@templates/alert-message.twig', [
'type'=>'danger',
'message'=> get_class($this)." : " . _t('BAZ_NEED_ADMIN_RIGHTS')
'type' => 'danger',
'message' => get_class($this)." : " . _t('BAZ_NEED_ADMIN_RIGHTS')
]) ;
}
$status = $this->getService(ArchiveService::class)->getArchivingStatus();
Expand All @@ -21,27 +21,22 @@ public function run()

if ($status['hibernated'] === true) {
$message = _t('ADMIN_BACKUPS_MESSAGE_HIBERNATION');
}
elseif ($status['privatePathWritable'] == false) {
} elseif ($status['privatePathWritable'] == false) {
$message = _t('ADMIN_BACKUPS_MESSAGE_WRITABLE_FILE');
}
elseif ($status['canExec'] == false) {
} elseif ($status['canExec'] == false) {
$message = _t('ADMIN_BACKUPS_MESSAGE_CLI_NOT_WORKING');
}
elseif ($status['notAvailableOnTheInternet'] == false) {
} elseif ($status['notAvailableOnTheInternet'] == false) {
$message = _t('ADMIN_BACKUPS_MESSAGE_PRIVATE_FOLDER_IS_PUBLIC');
}
elseif ($status['enoughSpace'] == false) {
} elseif ($status['enoughSpace'] == false) {
$message = _t('ADMIN_BACKUPS_MESSAGE_NO_SPACE');
}
elseif ($status['dB'] == false) {
} 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.'<br /><a href="?doc#/docs/fr/admin?id=résoudre-les-problèmes-de-sauvegarde">'._t('ADMIN_BACKUPS_MESSAGE_SEE_DOC').'</a>.'
'type' => 'warning',
'message' => _t('ADMIN_BACKUPS_MESSAGE_ARCHIVE_CANNOT_BE_DONE').' '.$message.'<br /><a href="?doc#/docs/fr/admin?id=résoudre-les-problèmes-de-sauvegarde">'._t('ADMIN_BACKUPS_MESSAGE_SEE_DOC').'</a>.'
]);

}
return $this->render('@core/actions/admin-backups.twig', [
]);
Expand Down
4 changes: 2 additions & 2 deletions actions/AdminReactionsAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public function run()
]);
} else {
return $this->render('@templates/alert-message.twig', [
'type'=>'info',
'message'=> _t('REACTION_CONNECT_AS_ADMIN')
'type' => 'info',
'message' => _t('REACTION_CONNECT_AS_ADMIN')
]);
}
}
Expand Down
6 changes: 3 additions & 3 deletions actions/EditActionsAclsAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ public function run()
{
if (!$this->wiki->UserIsAdmin()) {
return $this->render('@templates/alert-message.twig', [
'type'=>'danger',
'message'=> "EditActionsAclsAction : " . _t('BAZ_NEED_ADMIN_RIGHTS')
'type' => 'danger',
'message' => "EditActionsAclsAction : " . _t('BAZ_NEED_ADMIN_RIGHTS')
]) ;
}

Expand All @@ -27,7 +27,7 @@ public function run()
$res .= '>' . ucfirst($action) . '</option>';
}
$res .= '</select> <input type="submit" class="btn btn-default" value="'._t('SEE').'" />' . $wiki->FormClose();

if ($_POST && !empty($_POST['actionname'])) { // save ACL's
$result = $wiki->SetModuleACL($name = $_POST['actionname'], 'action', @$_POST['acl']);
if ($result) {
Expand Down
20 changes: 10 additions & 10 deletions actions/EditConfigAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ public function run()
$this->associatedExtensions = null ;
if (!$this->wiki->UserIsAdmin()) {
return $this->render('@templates/alert-message.twig', [
'type'=>'danger',
'message'=> get_class($this)." : " . _t('BAZ_NEED_ADMIN_RIGHTS')
'type' => 'danger',
'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')
'type' => 'danger',
'message' => _t('ERROR_NO_ACCESS'). ' '._t('FILE_WRITE_PROTECTED')
]) ;
}

Expand All @@ -75,8 +75,8 @@ public function run()
$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')
'type' => 'info',
'message' => _t('EDIT_CONFIG_SAVE')
]);
}

Expand Down Expand Up @@ -409,7 +409,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))
)
.']';
Expand All @@ -418,14 +418,14 @@ 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 = '';
}
Expand All @@ -444,7 +444,7 @@ private function strtoarray(string $value)
$matches = [];
if (preg_match('/^\s*\[\s*(.*)\s*\]\s*$/', $val, $matches)) {
$val = $matches[1];
$lines= preg_split('/(?<=\'|"|true|false|[0-9])\s*,\s*(?=\'|"|true|false|[0-9])/', $val);
$lines = preg_split('/(?<=\'|"|true|false|[0-9])\s*,\s*(?=\'|"|true|false|[0-9])/', $val);
$result = [];
foreach ($lines as $line) {
$extract = explode('=>', $line);
Expand Down
38 changes: 19 additions & 19 deletions actions/EditGroupsAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public function run()
{
if (!$this->wiki->UserIsAdmin()) {
return $this->render('@templates/alert-message.twig', [
'type'=>'danger',
'message'=> "EditGroupsAction : " . _t('BAZ_NEED_ADMIN_RIGHTS')
'type' => 'danger',
'message' => "EditGroupsAction : " . _t('BAZ_NEED_ADMIN_RIGHTS')
]) ;
}

Expand All @@ -23,10 +23,10 @@ public function run()
$currentGroupAcl = '';
$selectedGroupName = '';
$action = '';
if (!empty($_POST['groupname'])){
if (!is_string($_POST['groupname'])){
if (!empty($_POST['groupname'])) {
if (!is_string($_POST['groupname'])) {
$message = 'Action not possible because \'groupname\' should be a string !';
} else if (preg_match('/[^A-Za-z0-9]/', $_POST['groupname'])){
} elseif (preg_match('/[^A-Za-z0-9]/', $_POST['groupname'])) {
$message = _t('ONLY_ALPHANUM_FOR_GROUP_NAME');
} else {
$selectedGroupName = strval($_POST['groupname']);
Expand All @@ -38,9 +38,9 @@ public function run()
: ''
);
try {
if ($action === 'save'){
if ($action === 'save') {
list('message' => $message, 'type' => $type) = $this->saveAcl($selectedGroupName);
} else if ($action === 'delete') {
} elseif ($action === 'delete') {
list('message' => $message, 'type' => $type) = $this->deleteGroup($selectedGroupName);
}
} catch (TokenNotFoundException $th) {
Expand All @@ -53,7 +53,7 @@ public function run()
$list = $this->wiki->GetGroupsList();
sort($list);

if (!empty($selectedGroupName) && in_array($selectedGroupName, $list)){
if (!empty($selectedGroupName) && in_array($selectedGroupName, $list)) {
$currentGroupAcl = $this->wiki->GetGroupACL($selectedGroupName);
}

Expand All @@ -70,15 +70,15 @@ protected function saveAcl(string $selectedGroupName): array
$message = '';
$type = 'danger';

if (!isset($_POST['acl']) || !is_string($_POST['acl'])){
if (!isset($_POST['acl']) || !is_string($_POST['acl'])) {
$message = '$_POST[\'acl\'] must be a string';
} else {
$newacl = strval($_POST['acl']);
if (strtolower($selectedGroupName) == ADMIN_GROUP && !$this->wiki->CheckACL($newacl)) {
$message = _t('YOU_CANNOT_REMOVE_YOURSELF');
} else {
$result = $this->wiki->SetGroupACL($selectedGroupName, $newacl);

if ($result) {
if ($result == 1000) {
$message = _t('ERROR_RECURSIVE_GROUP').' !';
Expand All @@ -97,7 +97,7 @@ protected function saveAcl(string $selectedGroupName): array
return compact(['message','type']);
}


protected function deleteGroup(string &$selectedGroupName): array
{
$message = '';
Expand All @@ -117,9 +117,9 @@ protected function deleteGroup(string &$selectedGroupName): array
if (!empty($ownedPages)) {
// Array is not empty because the query returns at least one page
$message = _t('ONLY_NO_PAGES_GROUP_FOR_DELETION').'<br/>';
$message .= implode('<br/>',array_map(function($acl){
return "<a href=\"{$this->wiki->Href('',$acl['page_tag'])}\">{$acl['page_tag']}</a>";
},$ownedPages));
$message .= implode('<br/>', array_map(function ($acl) {
return "<a href=\"{$this->wiki->Href('', $acl['page_tag'])}\">{$acl['page_tag']}</a>";
}, $ownedPages));
} else {
// Group is empty AND is not alone having privileges on any page
$sql = <<<SQL
Expand All @@ -131,18 +131,18 @@ 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)){
if (!empty($previous)) {
$deletionOk = true;
foreach ($previous as $triple) {
if (!$tripleStore->delete($selectedGroupName,WIKINI_VOC_ACLS,$triple['value'],GROUP_PREFIX)){
if (!$tripleStore->delete($selectedGroupName, WIKINI_VOC_ACLS, $triple['value'], GROUP_PREFIX)) {
$deletionOk = false;
}
}
}

if ($deletionOk){
if ($deletionOk) {
$message = "groupe $selectedGroupName supprimé";
$type = 'success';
$selectedGroupName = '';
Expand All @@ -158,6 +158,6 @@ protected function deleteGroup(string &$selectedGroupName): array

protected function confirmToken()
{
$this->getService(CsrfTokenController::class)->checkToken('main', 'POST', 'confirmToken',false);
$this->getService(CsrfTokenController::class)->checkToken('main', 'POST', 'confirmToken', false);
}
}
6 changes: 3 additions & 3 deletions actions/EditHandlersAclsAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ public function run()
{
if (!$this->wiki->UserIsAdmin()) {
return $this->render('@templates/alert-message.twig', [
'type'=>'danger',
'message'=> "EditHandlersAclsAction : " . _t('BAZ_NEED_ADMIN_RIGHTS')
'type' => 'danger',
'message' => "EditHandlersAclsAction : " . _t('BAZ_NEED_ADMIN_RIGHTS')
]) ;
}

Expand All @@ -27,7 +27,7 @@ public function run()
$res .= '>' . ucfirst($handler) . '</option>';
}
$res .= '</select> <input class="btn btn-default" type="submit" value="'._t('SEE').'" />' . $wiki->FormClose();

if ($_POST && !empty($_POST['handlername'])) { // save ACL's
$result = $wiki->SetModuleACL($name = $_POST['handlername'], 'handler', @$_POST['acl']);
if ($result) {
Expand Down
2 changes: 1 addition & 1 deletion actions/EraseSpamedCommentsAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function run()
// (si DeleteOrphanedPage ne convient pas, soit on créé
// une autre, soit on la modifie
echo "Effacement de : " . $page . "<br />\n";
if ($wiki->services->get(PageController::class)->delete($page)){
if ($wiki->services->get(PageController::class)->delete($page)) {
$deletedPages .= $page . ", ";
}
}
Expand Down
12 changes: 6 additions & 6 deletions actions/FooterAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ public function run()
if ($themeLoaded) {
$output = $themeManager->renderFooter() ;
// on affiche les requetes SQL et le temps de chargement en mode debug
if ($this->wiki->GetConfigValue('debug')=='yes') {
if ($this->wiki->GetConfigValue('debug') == 'yes') {
$debug_log_sql_queries = '';
$T_SQL=0;
$T_SQL = 0;

$queryLog = $this->getService(DbService::class)->getQueryLog();
foreach ($queryLog as $query) {
$debug_log_sql_queries .= $query['query'].' ('.round($query['time'], 4).")<br />\n";
$T_SQL = $T_SQL + $query['time'];
}

$end = microtime(true);
$debug_log = "<div class=\"debug\">\n<h4>Query log</h4>\n";
$debug_log .= "<strong>".round($end-T_START, 4)." s total time<br />\n";
$debug_log .= round($T_SQL, 4)." s total SQL time</strong> (".round((($T_SQL/($end-T_START))*100), 2)."% of total time)<br />\n";
$debug_log .= "<strong>".round($end - T_START, 4)." s total time<br />\n";
$debug_log .= round($T_SQL, 4)." s total SQL time</strong> (".round((($T_SQL / ($end - T_START)) * 100), 2)."% of total time)<br />\n";
$debug_log .= "<strong>".count($queryLog)." queries :</strong><br />\n";
$debug_log .= $debug_log_sql_queries;
$debug_log .= "</div>\n";
Expand Down
2 changes: 1 addition & 1 deletion actions/HeaderAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function run()
$output .= '<b><a href="'.$this->wiki->Href(
'',
'GererMisesAJour',
['upgrade'=> THEME_PAR_DEFAUT ]
['upgrade' => THEME_PAR_DEFAUT ]
)
.'" title="'.$text.'">'.$text.'</a></b></div>';
return $output ; // because an admin can see all website without theme
Expand Down
6 changes: 4 additions & 2 deletions actions/MyFavoritesAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@ private function get_image_from_body($page)
'/\\\\u([a-f0-9]{4})/',
'encodingFromUTF8',
$image[1][0]
)
, 'ISO-8859-1', 'UTF-8');
),
'ISO-8859-1',
'UTF-8'
);
return $imagefile;
} else {
preg_match_all("/\[\[(http.*\.(?i)(jpg|png|gif|bmp)) .*\]\]/U", $page['body'], $image);
Expand Down
4 changes: 2 additions & 2 deletions actions/ReactionsAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function run()
$username = empty($user['name']) ? '' : $user['name'];

$reactionsController = $this->getService(ReactionsController::class);
list('labels'=>$labels, 'ids'=>$ids) = $reactionsController->formatReactionsLabels(
list('labels' => $labels, 'ids' => $ids) = $reactionsController->formatReactionsLabels(
$this->arguments['labels'],
empty($this->arguments['labels']) ? ReactionManager::DEFAULT_IDS : null,
);
Expand All @@ -55,7 +55,7 @@ public function run()
);

$pageTag = $this->wiki->GetPageTag();
list('reactions'=>$reactionItems, 'userReactions'=>$userReactions) = $reactionsController->getReactionItems(
list('reactions' => $reactionItems, 'userReactions' => $userReactions) = $reactionsController->getReactionItems(
$pageTag,
$username,
$idreaction,
Expand Down
6 changes: 3 additions & 3 deletions actions/UserReactionsAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ public function run()
if ($user = $this->wiki->GetUser()) {
$userReactions = $this->wiki->services->get(ReactionManager::class)->getReactions('', [], $user['name']);
return $this->render('@core/user-reactions.twig', [
'userReactions'=> $userReactions,
'userReactions' => $userReactions,
]);
} else {
return $this->render('@templates/alert-message.twig', [
'type'=>'info',
'message'=> _t('REACTION_LOGIN_TO_SEE_YOUR_REACTION')
'type' => 'info',
'message' => _t('REACTION_LOGIN_TO_SEE_YOUR_REACTION')
]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion actions/UsersTableAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ private function managePostActions(array $post, bool $isAdmin): ?string
$userName = in_array($username, [false,null], true) ? "" : htmlspecialchars(strip_tags($userName));
try {
$rawUserName = str_replace(['&#039;','&#39;'], ['\'','\''], $userName);
$this->csrfTokenController->checkToken('main', 'POST', 'csrf-token-delete',false);
$this->csrfTokenController->checkToken('main', 'POST', 'csrf-token-delete', false);
$user = $this->userManager->getOneByName($rawUserName);
if (empty($user)) {
return $this->render("@templates/alert-message.twig", [
Expand Down
2 changes: 1 addition & 1 deletion actions/backlinks.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
foreach ($exclude as $key => $exclusion) {
$exclude[$key] = trim($exclusion);
}

foreach ($pages as $page) {
if (!in_array($page['tag'], $exclude)) {
echo $this->ComposeLinkToPage($page['tag'], '', '', false), "<br />\n";
Expand Down
2 changes: 1 addition & 1 deletion actions/changestyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@
$this->SetPersistentCookie('sitestyle', $set, 1);
header("Location: ".$this->href());
} elseif ($set) {
$this->SetMessage(str_replace("{name}",htmlspecialchars($set, ENT_COMPAT, YW_CHARSET),_t('CHANGESTYLE_ERROR')));
$this->SetMessage(str_replace("{name}", htmlspecialchars($set, ENT_COMPAT, YW_CHARSET), _t('CHANGESTYLE_ERROR')));
}
Loading

0 comments on commit ad3f350

Please sign in to comment.