Commit ca18e855 authored by Administrator's avatar Administrator 💬

WIP.

parent b575a2b5
Pipeline #50 passed with stage
in 45 seconds
......@@ -78,6 +78,9 @@ class M3P2Plugin extends Plugin
$this->grav['twig']->twig()->addFilter(
new \Twig_SimpleFilter('webide_url', [$this, 'getWebIdeUrlForPage'])
);
$this->grav['twig']->twig()->addFilter(
new \Twig_SimpleFilter('translations', [$this, 'getTranslationsOfPage'])
);
}
public function getWebIdeUrlForPage(Page $page)
......@@ -87,4 +90,58 @@ class M3P2Plugin extends Plugin
return $url;
}
// public function getPage($route)
// {
// $page = null;
//// $translation_path = $page->path() . DS . $page_name_without_ext . '.' . $language . '.md';
// if (file_exists($translation_path)) {
// $page = new Page();
// $page->init(new \SplFileInfo($page_path), $language . '.md');
// }
//
// return $page;
// }
public function getTranslationsOfPage(Page $page)
{
$languages = $this->config->get('system.languages.supported');
// die(print_r($languages));
$route_suffix = $page->rawRoute();
$translations = array();
$current_language = $page->language();
$page_name_without_ext = substr($page->name(), 0, -(strlen($page->extension())));
foreach ($languages as $language) {
// $route = '/' . $language . $route_suffix;
// $route = $route_suffix;
// FIXME: nope. language-selector does this the hard way, by instantiating Page objects
//$translation = $page->find($route);
// … so we're falling back on the old school too
$translation_path = $page->path() . DS . $page_name_without_ext . '.' . $language . '.md';
if (file_exists($translation_path)) {
$translation = new Page();
$translation->init(new \SplFileInfo($translation_path), $language . '.md');
// $translated_pages[$language] = $translation;
} else {
continue;
}
// var_dump($route);
// die(var_dump($route));
// die(var_dump($translation));
if ($language == $current_language) {
array_unshift($translations, $translation);
} else {
array_push($translations, $translation);
}
}
// die(var_dump($translations));
return $translations;
}
}
......@@ -15,7 +15,8 @@
{% block body %}
<div class="claude-columns">
{% for column in language_selector.translated_pages %}
{% for column in page | translations %}
{#{% for column in language_selector.translated_pages %}#}
<section id="{{ macro.pageLinkName(column.menu) }}" class="claude-column syncscroll" name="language">
{{ column.content|raw }}
{#{% include 'partials/contributions-incentive.html.twig' with {page: column} %}#}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment