Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions includes/objects/YesWikiAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,36 @@ protected function checkSecuredACL($adminOnly = true): ?string
return null;
}
}


/**
* This function check for corresponding "end" element and store result in
* $GLOBALS['check ' . $pagetag]['$element_name'].
* @param $action_name
*
* @return false if wrong number of closing element found
*/
protected function check_end_elem(string $action_name): bool
{
$pagetag = $this->wiki->GetPageTag();
if (!isset($GLOBALS["check_$pagetag"][$action_name])) {
$GLOBALS["check_$pagetag"][$action_name] =
$this->wiki->services->get(\YesWiki\Templates\Service\Utils::class)
->checkGraphicalElements($action_name, $pagetag, $this->wiki->page['body'] ?? '');
}
return $GLOBALS["check_$pagetag"][$action_name];
}

protected function generate_error_msg(string $action_name): string
{
$action_name = strtoupper($action_name);
return '<div class="alert alert-danger"><strong>'
. _t("TEMPLATE_ACTION_$action_name") . '</strong> : '
. _t("TEMPLATE_ELEM_{$action_name}_NOT_CLOSED") . '.</div>' . "\n";
}

public function end(): string
{
return '\n</div>';
}
}
8 changes: 6 additions & 2 deletions includes/services/Performer.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function createPerformable(array $object, array &$vars, &$output)
*
* @return string the generated output
*/
public function run($objectName, $objectType, array $vars = []): string
public function run($objectName, $objectType, array $vars = [], bool $end_elem = false): string
{
if (!Performer::TYPES[$objectType]) {
return "Invalid type $objectType";
Expand Down Expand Up @@ -186,7 +186,11 @@ public function run($objectName, $objectType, array $vars = []): string
if ($file['isDefinedAsClass']) {
$performable = $this->createPerformable($file, $vars, $output);
try {
$output .= $performable->run();
if ($end_elem) {
$output .= $performable->end();
} else {
$output .= $performable->run();
}
} catch (HttpException $exception) {
return $this->renderError($exception->getMessage(), $objectType);
}
Expand Down
7 changes: 4 additions & 3 deletions tools/templates/actions/end.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php

require_once 'includes/YesWikiPerformable.php';

use YesWiki\Core\Service\Performer;
use YesWiki\Templates\Controller\TabsController;

// classe css supplémentaire
Expand Down Expand Up @@ -27,9 +30,6 @@
case 'col':
echo "\n</div> <!-- end of col -->\n";
break;
case 'section':
echo "\n</div>\n</section> <!-- end of section -->\n";
break;
case 'label':
echo '</span>';
break;
Expand All @@ -50,6 +50,7 @@
echo $this->services->get(TabsController::class)->closeTabs();
break;
default:
echo $this->services->get(Performer::class)->run($elem, 'action', [], true);
break;
}
}
Expand Down
165 changes: 0 additions & 165 deletions tools/templates/actions/section.php

This file was deleted.

Loading