Finished composer, Fixed lang logic error, Removed rash, Some minor fixes left
Update composer.php, content.php, and 5 more files...
This commit is contained in:
@@ -47,7 +47,7 @@ abstract class ComposerElementTypes {
|
||||
const IMAGE = "image";
|
||||
const TABLE = "table";
|
||||
const GRID = "grid";
|
||||
const GLIDER = "glider";
|
||||
const GALLERY = "gallery";
|
||||
|
||||
/**
|
||||
* Returns all the constants present in the class.
|
||||
@@ -97,6 +97,13 @@ abstract class ComposerElementModifiers {
|
||||
const DETAILS_NO_ROUNDING = ["no-rounding", ""];
|
||||
const DETAILS_CLOSED = ["closed", ""];
|
||||
|
||||
// Tables
|
||||
const TABLE_NO_OUTER_PADDING = ["no-outer-padding", "table-no-outer-padding"];
|
||||
const TABLE_STRIPED = ["striped", "table-striped"];
|
||||
const TABLE_HOVER = ["hover", "table-hover"];
|
||||
const TABLE_INNER_BORDER = ["inner-bordered", "table-inner-bordered"];
|
||||
const TABLE_OUTER_BORDER = ["outer-bordered", "table-outer-bordered"];
|
||||
|
||||
// Code
|
||||
const CODE_BLOCK = ["code-block", "w-full d-inline-block"];
|
||||
|
||||
@@ -274,13 +281,13 @@ class ComposerContentMetadata {
|
||||
);
|
||||
}
|
||||
|
||||
function apply_template(ComposerContent $contentRoot, string $inner_html) : string {
|
||||
function apply_template(ComposerContent $content_root, string $inner_html) : string {
|
||||
switch($this->template) {
|
||||
case ComposerTemplates::ARTICLE:
|
||||
$inner_html = '<div class="card p-0 mx-0"><div class="px-card py-10 border-bottom px-20">' .
|
||||
'<div class="container-fluid"><h2 class="card-title font-size-18 m-0">' .
|
||||
'<i class="' . $this->article->icon . '"></i> ' .
|
||||
localize_private($this->article->title, $contentRoot->strings, false) .
|
||||
localize_private($this->article->title, $content_root->strings, false) .
|
||||
'<span class="card-title font-size-18 m-0 text-super-muted float-right hidden-xs-and-down">' .
|
||||
'\$subTitle' . '</span></h2></div></div>' .
|
||||
'<article id="content-item-container" class="py-01 pb-0 bg-light-lm rounded-bottom px-0 bg-very-dark title-bkgd">' .
|
||||
@@ -402,8 +409,8 @@ class ComposerElement {
|
||||
// Table's parameters
|
||||
private ?array $head;
|
||||
private ?array $body;
|
||||
private ?int $colspan;
|
||||
private ?int $rowspan;
|
||||
private int $colspan;
|
||||
private int $rowspan;
|
||||
|
||||
// Paragraph and code's parameters
|
||||
private ?int $indent;
|
||||
@@ -416,7 +423,7 @@ class ComposerElement {
|
||||
|
||||
function __construct(string $type, ?array $modifiers, ?string $link, ?array $parts, ?string $content,
|
||||
bool $localize, ?int $padding, ?int $margin, ?int $size, ?array $head, ?array $body,
|
||||
?int $colspan, ?int $rowspan, ?int $indent, ?array $code, ?string $color) {
|
||||
int $colspan, int $rowspan, ?int $indent, ?array $code, ?string $color) {
|
||||
$this->type = $type;
|
||||
$this->modifiers = $modifiers;
|
||||
$this->link = $link;
|
||||
@@ -426,8 +433,15 @@ class ComposerElement {
|
||||
$this->padding = $padding;
|
||||
$this->margin = $margin;
|
||||
$this->size = $size;
|
||||
$this->head = $head;
|
||||
$this->body = $body;
|
||||
$this->head = ComposerElement::from_json_array($head);
|
||||
if(is_null($body)) {
|
||||
$this->body = array();
|
||||
} else {
|
||||
$this->body = array_fill(0, sizeof($body), []);
|
||||
for($body_row_index = 0; $body_row_index < sizeof($body); $body_row_index++) {
|
||||
$this->body[$body_row_index] = ComposerElement::from_json_array($body[$body_row_index]);
|
||||
}
|
||||
}
|
||||
$this->colspan = $colspan;
|
||||
$this->rowspan = $rowspan;
|
||||
$this->indent = $indent;
|
||||
@@ -435,10 +449,12 @@ class ComposerElement {
|
||||
$this->color = $color;
|
||||
}
|
||||
|
||||
static function from_json_array(array $json_dataArray) : array {
|
||||
static function from_json_array(?array $json_dataArray) : array {
|
||||
$parts = array();
|
||||
foreach($json_dataArray as $part) {
|
||||
$parts[] = ComposerElement::from_json($part);
|
||||
if(!is_null($json_dataArray)) {
|
||||
foreach($json_dataArray as $part) {
|
||||
$parts[] = ComposerElement::from_json($part);
|
||||
}
|
||||
}
|
||||
return $parts;
|
||||
}
|
||||
@@ -456,8 +472,8 @@ class ComposerElement {
|
||||
key_exists("size", $json_data) ? $json_data["size"] : null,
|
||||
key_exists("head", $json_data) ? $json_data["head"] : null,
|
||||
key_exists("body", $json_data) ? $json_data["body"] : null,
|
||||
key_exists("colspan", $json_data) ? $json_data["colspan"] : null,
|
||||
key_exists("rowspan", $json_data) ? $json_data["rowspan"] : null,
|
||||
key_exists("colspan", $json_data) ? $json_data["colspan"] : 1,
|
||||
key_exists("rowspan", $json_data) ? $json_data["rowspan"] : 1,
|
||||
key_exists("indent", $json_data) ? $json_data["indent"] : null,
|
||||
key_exists("code", $json_data) ? $json_data["code"] : null,
|
||||
key_exists("color", $json_data) ? $json_data["color"] : null,
|
||||
@@ -466,13 +482,13 @@ class ComposerElement {
|
||||
|
||||
/**
|
||||
* Processes the "content" and "parts" class' variables and returns their interpreted content as HTML.
|
||||
* @param ComposerContent $contentRoot The content in which this element is contained.
|
||||
* @param ComposerContent $content_root The content in which this element is contained.
|
||||
* @param bool $doLocalization Whether the "content" variable should be processed to return localized text.
|
||||
* @param bool $doSubElements Whether the "parts" variable should be processed to return localized text.
|
||||
* @param bool $stopIfLocalized Whether the process should return if some text was in the "content" variable.
|
||||
* @return string The interpreted content as HTML.
|
||||
*/
|
||||
private function get_inner_html(ComposerContent $contentRoot, bool $doLocalization = true,
|
||||
private function get_inner_html(ComposerContent $content_root, bool $doLocalization = true,
|
||||
bool $doSubElements = true, bool $stopIfLocalized = true) : string {
|
||||
global $LANG_FALLBACK_KEY_PREFIX;
|
||||
|
||||
@@ -493,7 +509,7 @@ class ComposerElement {
|
||||
$htmlCode .= $this->content;
|
||||
} else {
|
||||
// We can now localize the content key.
|
||||
$htmlCode .= localize_private($this->content, $contentRoot->strings, true,
|
||||
$htmlCode .= localize_private($this->content, $content_root->strings, true,
|
||||
$LANG_FALLBACK_KEY_PREFIX);
|
||||
}
|
||||
}
|
||||
@@ -516,19 +532,19 @@ class ComposerElement {
|
||||
// Appending each sub-element.
|
||||
foreach($this->parts as $subElement) {
|
||||
/** @var ComposerElement $subElement */
|
||||
$htmlCode .= $subElement->get_html($contentRoot);
|
||||
$htmlCode .= $subElement->get_html($content_root);
|
||||
}
|
||||
}
|
||||
|
||||
return $htmlCode;
|
||||
}
|
||||
|
||||
private function get_inner_html_elements(ComposerContent $contentRoot) : string {
|
||||
return $this->get_inner_html($contentRoot, false, true, false);
|
||||
private function get_inner_html_elements(ComposerContent $content_root) : string {
|
||||
return $this->get_inner_html($content_root, false, true, false);
|
||||
}
|
||||
|
||||
private function get_inner_html_text(ComposerContent $contentRoot) : string {
|
||||
return $this->get_inner_html($contentRoot, true, false, false);
|
||||
private function get_inner_html_text(ComposerContent $content_root) : string {
|
||||
return $this->get_inner_html($content_root, true, false, false);
|
||||
}
|
||||
|
||||
private function get_modifiers_classes() : string {
|
||||
@@ -550,23 +566,24 @@ class ComposerElement {
|
||||
|
||||
/**
|
||||
* Processes the element and returns its interpreted form as HTML.
|
||||
* @param ComposerContent $contentRoot The content in which this element is contained.
|
||||
* @param ComposerContent $content_root The content in which this element is contained.
|
||||
* @return string The interpreted element as HTML.
|
||||
*/
|
||||
public function get_html(ComposerContent $contentRoot) : string {
|
||||
public function get_html(ComposerContent $content_root) : string {
|
||||
$htmlCode = "";
|
||||
|
||||
if(!is_null($this->link)) {
|
||||
$htmlCode .= '<a href="' . $this->link . '">';
|
||||
$htmlCode .= '<a href="' . $this->link . '"' .
|
||||
($this->type == ComposerElementTypes::BUTTON ? 'class="button-link"' : '') . '>';
|
||||
}
|
||||
|
||||
switch($this->type) {
|
||||
case ComposerElementTypes::UNSET:
|
||||
$htmlCode .= "<p>error.unset !</p>";
|
||||
$htmlCode .= "<p>error.element.type.unset !</p>";
|
||||
break;
|
||||
|
||||
case ComposerElementTypes::RAW:
|
||||
$htmlCode .= $this->get_inner_html($contentRoot);
|
||||
$htmlCode .= $this->get_inner_html($content_root);
|
||||
break;
|
||||
|
||||
case ComposerElementTypes::H1:
|
||||
@@ -579,7 +596,7 @@ class ComposerElement {
|
||||
|
||||
// Composing heading.
|
||||
$htmlCode .= '<' . strtolower($this->type) . ' class="font-weight-semi-bold font-size-' .
|
||||
$_headingFontSize . ' m-0">' . $this->get_inner_html($contentRoot) . '</' . strtolower($this->type) .
|
||||
$_headingFontSize . ' m-0">' . $this->get_inner_html($content_root) . '</' . strtolower($this->type) .
|
||||
'>';
|
||||
|
||||
break;
|
||||
@@ -593,14 +610,14 @@ class ComposerElement {
|
||||
(ComposerElementModifiers::is_modifier_in_modifiers(
|
||||
ComposerElementModifiers::GENERIC_MARGIN_NO_TOP, $this->modifiers)
|
||||
? 'mt-0 mb-10' : 'my-10') . ' ml-md-' . ($_paragraph_ident_level * 5) . '">' .
|
||||
$this->get_inner_html($contentRoot) . '</p>';
|
||||
$this->get_inner_html($content_root) . '</p>';
|
||||
|
||||
break;
|
||||
|
||||
case ComposerElementTypes::BUTTON:
|
||||
// Composing the button.
|
||||
$htmlCode .= '<button class="' . (is_null($this->color) ? '' : 'btn-' . $this->color) .
|
||||
$this->get_modifiers_classes() . '">' . $this->get_inner_html($contentRoot) . '</button>';
|
||||
$htmlCode .= '<button class="btn ' . (is_null($this->color) ? '' : 'btn-' . $this->color . ' ') .
|
||||
$this->get_modifiers_classes() . '">' . $this->get_inner_html($content_root) . '</button>';
|
||||
|
||||
break;
|
||||
|
||||
@@ -648,7 +665,7 @@ class ComposerElement {
|
||||
(ComposerElementModifiers::is_modifier_in_modifiers(
|
||||
ComposerElementModifiers::CONTAINER_CARD, $this->modifiers
|
||||
) ? ComposerElementModifiers::get_modifier_classes(
|
||||
ComposerElementModifiers::CONTAINER_CARD ) . "m-0 " : "") .
|
||||
ComposerElementModifiers::CONTAINER_CARD ) . " m-0 " : "") .
|
||||
'p-' . $_container_padding .
|
||||
(ComposerElementModifiers::is_modifier_in_modifiers(
|
||||
ComposerElementModifiers::GENERIC_MARGIN_NO_TOP, $this->modifiers
|
||||
@@ -669,7 +686,7 @@ class ComposerElement {
|
||||
ComposerElementModifiers::CONTAINER_SCROLL_HORIZONTAL, $this->modifiers
|
||||
) ? " " . ComposerElementModifiers::get_modifier_classes(
|
||||
ComposerElementModifiers::CONTAINER_SCROLL_HORIZONTAL ) : "") . '">' .
|
||||
$this->get_inner_html($contentRoot) . '</div>';
|
||||
$this->get_inner_html($content_root) . '</div>';
|
||||
break;
|
||||
|
||||
case ComposerElementTypes::COLLAPSE:
|
||||
@@ -708,7 +725,7 @@ class ComposerElement {
|
||||
(ComposerElementModifiers::is_modifier_in_modifiers(
|
||||
ComposerElementModifiers::DETAILS_NO_ROUNDING, $this->modifiers
|
||||
) ? " rounded-0" : "") . ' border-0 border-bottom">' .
|
||||
$this->get_inner_html($contentRoot) . '</div></details>';
|
||||
$this->get_inner_html($content_root) . '</div></details>';
|
||||
break;
|
||||
|
||||
case ComposerElementTypes::SPACER:
|
||||
@@ -724,12 +741,44 @@ class ComposerElement {
|
||||
break;
|
||||
|
||||
case ComposerElementTypes::TABLE:
|
||||
// Composing table.
|
||||
$htmlCode .= '<table class="table ' . $this->get_modifiers_classes() . '">';
|
||||
|
||||
if(!is_null($this->head)) {
|
||||
$htmlCode .= '<thead><tr>';
|
||||
foreach($this->head as $head_element) {
|
||||
/** @var ComposerElement $head_element */
|
||||
$htmlCode .= '<th>' . $head_element->get_html($content_root) . '</th>';
|
||||
}
|
||||
$htmlCode .= '</tr></thead>';
|
||||
}
|
||||
|
||||
if(!is_null($this->body)) {
|
||||
$htmlCode .= '<tbody>';
|
||||
|
||||
for($body_row_index = 0; $body_row_index < sizeof($this->body); $body_row_index++) {
|
||||
$htmlCode .= '<tr>';
|
||||
|
||||
foreach($this->body[$body_row_index] as $body_cell) {
|
||||
/** @var ComposerElement $body_cell */
|
||||
$htmlCode .= '<td' . ($body_cell->colspan > 1 ? ' colspan="' . $body_cell->colspan . '"' : '') .
|
||||
($body_cell->rowspan > 1 ? ' rowspan="' . $body_cell->rowspan . '"' : '') . '>' .
|
||||
$body_cell->get_html($content_root) . '</td>';
|
||||
}
|
||||
|
||||
$htmlCode .= '</tr>';
|
||||
}
|
||||
|
||||
$htmlCode .= '</tbody>';
|
||||
}
|
||||
|
||||
$htmlCode .= '</table>';
|
||||
break;
|
||||
|
||||
case ComposerElementTypes::GRID:
|
||||
break;
|
||||
|
||||
case ComposerElementTypes::GLIDER:
|
||||
case ComposerElementTypes::GALLERY:
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@@ -140,94 +140,8 @@ function end_content_card() {
|
||||
echo('</div>');
|
||||
}
|
||||
|
||||
/*function getContentItemText(array $contentNode, bool $italicOnError = true, bool $returnMissingAsEmpty = false) : string {
|
||||
global $user_language, $default_language;
|
||||
if(array_key_exists("key", $contentNode)) {
|
||||
return localize($contentNode["key"]);
|
||||
} elseif(array_key_exists($user_language, $contentNode)) {
|
||||
return $contentNode[$user_language];
|
||||
} elseif(array_key_exists($default_language, $contentNode)) {
|
||||
return $contentNode[$default_language];
|
||||
} else {
|
||||
if($returnMissingAsEmpty) {
|
||||
return "";
|
||||
}
|
||||
if($italicOnError) {
|
||||
return '<i>'.localize("error.content.data.no.title").'</i>';
|
||||
} else {
|
||||
return localize("error.content.data.no.title");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function printInfoTextElement(string $text) : void {
|
||||
global $PRINT_CONTENT_DEBUG_INFO_TEXT_ELEMENTS;
|
||||
if($PRINT_CONTENT_DEBUG_INFO_TEXT_ELEMENTS) {
|
||||
echo('<h3 class="m-0 font-size-20 text-primary font-weight-semi-bold">'.$text.'</h3>');
|
||||
}
|
||||
}
|
||||
|
||||
function printErrorTextElement(string $text) : void {
|
||||
global $PRINT_CONTENT_DEBUG_ERROR_TEXT_ELEMENTS;
|
||||
if($PRINT_CONTENT_DEBUG_ERROR_TEXT_ELEMENTS) {
|
||||
echo('<h3 class="m-0 font-size-20 text-center text-danger font-weight-semi-bold">'.$text.'</h3>');
|
||||
}
|
||||
}
|
||||
|
||||
function processStandardContentSubNode(mixed $elementNode, string $prepend="", string $append="") : void {
|
||||
if(array_key_exists("content", $elementNode)) {
|
||||
if (array_key_exists("parts", $elementNode["content"])) {
|
||||
for ($iPart = 0; $iPart < count($elementNode["content"]["parts"]); $iPart++) {
|
||||
echo($prepend);
|
||||
createElementNode($elementNode["content"]["parts"][$iPart]);
|
||||
echo($append);
|
||||
}
|
||||
} else {
|
||||
echo($prepend.getContentItemText($elementNode["content"], false, true).$append);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
/*function createElementNode(mixed $elementNode, string $prepend="", string $append="") : void {
|
||||
// Checking if we actually have a JSON object.
|
||||
if(!is_array($elementNode)) {
|
||||
echo('<p>Not array node !</p>');
|
||||
return;
|
||||
}
|
||||
if(!array_key_exists("type", $elementNode)) {
|
||||
echo('<p>No "type" member found in node !</p>');
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
switch($elementNode["type"]) {
|
||||
case "spacer":
|
||||
// Defining the font size.
|
||||
$_spacerSize = 1;
|
||||
if(array_key_exists("size", $elementNode)) {
|
||||
$_spacerSize = $elementNode["size"];
|
||||
}
|
||||
|
||||
// Adding element.
|
||||
echo('<div class="m-0 pt-'.($_spacerSize*5).' pb-md-'.($_spacerSize*5).'"></div>');
|
||||
|
||||
break;
|
||||
case "hr":
|
||||
// Reading and processing the modifiers.
|
||||
$_modIsSubtle = false;
|
||||
if(array_key_exists("modifiers", $elementNode)) {
|
||||
for ($i = 0; $i < count($elementNode["modifiers"]); $i++) {
|
||||
if ($elementNode["modifiers"][$i] == "subtle") {
|
||||
$_modIsSubtle = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($_modIsSubtle) {
|
||||
echo('<hr class="subtle">');
|
||||
} else {
|
||||
echo('<div class="sidebar-divider"></div>');
|
||||
}
|
||||
break;
|
||||
case "image":
|
||||
// Parsing properties.
|
||||
$_imgAlt = "";
|
||||
@@ -252,348 +166,6 @@ function processStandardContentSubNode(mixed $elementNode, string $prepend="", s
|
||||
// Adding element.
|
||||
echo('<img class="'.($_modFillHeight?'fill-height':'').'" src="'.$_imgSource.'" alt="'.$_imgAlt.'">');
|
||||
|
||||
break;
|
||||
case "h1":
|
||||
case "h2":
|
||||
case "h3":
|
||||
// Defining the font size.
|
||||
$_headingFontSize = ($elementNode["type"] == "h3" ? '18' : (($elementNode["type"] == "h2" ? '20' : '22')));
|
||||
|
||||
// Opening heading.
|
||||
echo('<'.$elementNode["type"].' class="font-weight-semi-bold font-size-'.$_headingFontSize.' m-0">');
|
||||
|
||||
// Adding content.
|
||||
processStandardContentSubNode($elementNode);
|
||||
|
||||
// Closing heading.
|
||||
echo('</'.$elementNode["type"].'>');
|
||||
|
||||
break;
|
||||
case "paragraph":
|
||||
// Parsing properties.
|
||||
$_indentLevel = 0;
|
||||
if(array_key_exists("indent", $elementNode)) {
|
||||
$_indentLevel = $elementNode["indent"];
|
||||
}
|
||||
|
||||
// Reading and processing the modifiers.
|
||||
$_modNoTopMargin = false;
|
||||
if(array_key_exists("modifiers", $elementNode)) {
|
||||
for ($i = 0; $i < count($elementNode["modifiers"]); $i++) {
|
||||
switch($elementNode["modifiers"][$i]) {
|
||||
case "no-top-margin":
|
||||
$_modNoTopMargin = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Opening paragraph.
|
||||
echo('<p class="'.($_modNoTopMargin?'mt-0 mb-10':'my-10').($_indentLevel?' ml-md-'.($_indentLevel*5):'').'">');
|
||||
|
||||
// Adding content.
|
||||
processStandardContentSubNode($elementNode);
|
||||
|
||||
// Closing paragraph.
|
||||
echo('</p>');
|
||||
|
||||
break;
|
||||
case "code":
|
||||
// Parsing properties.
|
||||
$_indentLevel = 0;
|
||||
if(array_key_exists("indent", $elementNode)) {
|
||||
$_indentLevel = $elementNode["indent"];
|
||||
}
|
||||
|
||||
// Reading and processing the modifiers.
|
||||
$_modNoTopMargin = false;
|
||||
$_modFullWidth = false;
|
||||
$_modHorizontalScroll = false;
|
||||
if(array_key_exists("modifiers", $elementNode)) {
|
||||
for ($i = 0; $i < count($elementNode["modifiers"]); $i++) {
|
||||
switch($elementNode["modifiers"][$i]) {
|
||||
case "no-top-margin":
|
||||
$_modNoTopMargin = true;
|
||||
break;
|
||||
case "full-width":
|
||||
$_modFullWidth = true;
|
||||
break;
|
||||
case "horizontal-scroll":
|
||||
$_modHorizontalScroll = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Opening code element.
|
||||
echo('<code class="code'.($_modNoTopMargin?'':' mt-10').($_modFullWidth?' w-full d-inline-block':'').
|
||||
($_indentLevel?' ml-md-'.($_indentLevel*5):'').($_modHorizontalScroll?' overflow-x-scroll hide-scrollbar':'').'">');
|
||||
|
||||
// Adding code lines.
|
||||
if (array_key_exists("code", $elementNode)) {
|
||||
for ($iCodeLine = 0; $iCodeLine < count($elementNode["code"]); $iCodeLine++) {
|
||||
echo(htmlspecialchars($elementNode["code"][$iCodeLine]).'<br>');
|
||||
}
|
||||
}
|
||||
|
||||
// Closing code element.
|
||||
echo('</code>');
|
||||
|
||||
break;
|
||||
case "container":
|
||||
// Grabbing the global padding.
|
||||
$_containerPadding = "10";
|
||||
if(array_key_exists("padding", $elementNode)) {
|
||||
$_containerPadding = $elementNode["padding"];
|
||||
}
|
||||
|
||||
// Reading and processing the modifiers.
|
||||
$_modIsCard = false;
|
||||
$_modNoTopMargin = false;
|
||||
$_modNoTopPadding = false;
|
||||
$_modNoBottomPadding = false;
|
||||
$_modNoSizePadding = false;
|
||||
$_modHorizontalScroll = false;
|
||||
if(array_key_exists("modifiers", $elementNode)) {
|
||||
for ($i = 0; $i < count($elementNode["modifiers"]); $i++) {
|
||||
switch($elementNode["modifiers"][$i]) {
|
||||
case "card":
|
||||
$_modIsCard = true;
|
||||
$_modNoTopMargin = true;
|
||||
break;
|
||||
case "no-top-margin":
|
||||
$_modNoTopMargin = true;
|
||||
break;
|
||||
case "no-top-padding":
|
||||
$_modNoTopPadding = true;
|
||||
break;
|
||||
case "no-bottom-padding":
|
||||
$_modNoBottomPadding = true;
|
||||
break;
|
||||
case "no-side-padding":
|
||||
$_modNoSizePadding = true;
|
||||
break;
|
||||
case "horizontal-scroll":
|
||||
$_modHorizontalScroll = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Opening container.
|
||||
echo('<div class="'.($_modIsCard?'card m-0 ':'').'p-'.$_containerPadding.($_modNoTopMargin?'':' mt-10').
|
||||
($_modNoSizePadding?' px-0':'').($_modNoBottomPadding?' pb-0':'').($_modNoTopPadding?' pt-0':'').
|
||||
($_modHorizontalScroll?' overflow-x-scroll hide-scrollbar':'').'">');
|
||||
|
||||
// Adding content.
|
||||
processStandardContentSubNode($elementNode);
|
||||
|
||||
// Closing container.
|
||||
echo('</div>');
|
||||
|
||||
break;
|
||||
case "button":
|
||||
// Reading and processing the modifiers.
|
||||
$_modRawStyle = false;
|
||||
$_modThinStyle = false;
|
||||
$_modThickStyle = false;
|
||||
$_modRoundShape = false;
|
||||
$_modCircleShape = false;
|
||||
if(array_key_exists("modifiers", $elementNode)) {
|
||||
for ($i = 0; $i < count($elementNode["modifiers"]); $i++) {
|
||||
switch($elementNode["modifiers"][$i]) {
|
||||
case "raw":
|
||||
$_modRawStyle = true;
|
||||
break;
|
||||
case "thin":
|
||||
$_modThinStyle = true;
|
||||
break;
|
||||
case "thick":
|
||||
$_modThickStyle = true;
|
||||
break;
|
||||
case "rounded":
|
||||
$_modRoundShape = true;
|
||||
break;
|
||||
case "circle":
|
||||
$_modCircleShape = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Adding link if needed.
|
||||
if(array_key_exists("link", $elementNode)) {
|
||||
echo('<a href="'.$elementNode["link"].'" class="button-link">');
|
||||
}
|
||||
|
||||
// Opening button.
|
||||
echo('<button'.($_modRawStyle?'':' class="btn'.
|
||||
($_modThinStyle?' btn-sm':'').
|
||||
($_modThickStyle?' btn-lg':'').
|
||||
(array_key_exists("color", $elementNode)?' btn-'.$elementNode["color"]:'').
|
||||
($_modRoundShape?' btn-rounded':'').
|
||||
($_modCircleShape?' rounded-circle':'').
|
||||
'"').'>');
|
||||
|
||||
// Adding content.
|
||||
processStandardContentSubNode($elementNode);
|
||||
|
||||
// Closing button.
|
||||
echo('</button>');
|
||||
if(array_key_exists("link", $elementNode)) {
|
||||
echo('</a>');
|
||||
}
|
||||
|
||||
break;
|
||||
case "table":
|
||||
// Reading and processing the modifiers.
|
||||
$_modNoOuterPadding = false;
|
||||
$_modStriped = false;
|
||||
$_modHover = false;
|
||||
$_modInnerBordered = false;
|
||||
$_modOuterBordered = false;
|
||||
if(array_key_exists("modifiers", $elementNode)) {
|
||||
for ($i = 0; $i < count($elementNode["modifiers"]); $i++) {
|
||||
switch($elementNode["modifiers"][$i]) {
|
||||
case "no-outer-padding":
|
||||
$_modNoOuterPadding = true;
|
||||
break;
|
||||
case "striped":
|
||||
$_modStriped = true;
|
||||
break;
|
||||
case "hover":
|
||||
$_modHover = true;
|
||||
break;
|
||||
case "inner-bordered":
|
||||
$_modInnerBordered = true;
|
||||
break;
|
||||
case "outer-bordered":
|
||||
$_modOuterBordered = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Preparing table.
|
||||
echo('<table class="table'.($_modNoOuterPadding?" table-no-outer-padding":"").($_modStriped?" table-striped":"").
|
||||
($_modHover?" table-hover":"").($_modInnerBordered?" table-inner-bordered":"").
|
||||
($_modOuterBordered?' table-outer-bordered':'').'">');
|
||||
|
||||
// Creating "thead".
|
||||
if(array_key_exists("head", $elementNode)) {
|
||||
echo('<thead><tr>');
|
||||
for ($iTableHead = 0; $iTableHead < count($elementNode["head"]); $iTableHead++) {
|
||||
echo('<th>');
|
||||
if(array_key_exists("parts", $elementNode["head"][$iTableHead])) {
|
||||
for ($iPart = 0; $iPart < count($elementNode["head"][$iTableHead]["parts"]); $iPart++) {
|
||||
createElementNode($elementNode["head"][$iTableHead]["parts"][$iPart]);
|
||||
}
|
||||
} else {
|
||||
echo(getContentItemText($elementNode["head"][$iTableHead], false, true));
|
||||
}
|
||||
echo('</th>');
|
||||
}
|
||||
echo('</tr></thead>');
|
||||
}
|
||||
|
||||
// Creating "tbody".
|
||||
if(array_key_exists("body", $elementNode)) {
|
||||
echo('<tbody>');
|
||||
for ($iTableBodyRow = 0; $iTableBodyRow < count($elementNode["body"]); $iTableBodyRow++) {
|
||||
echo('<tr>');
|
||||
for ($iTableBodyCell = 0; $iTableBodyCell < count($elementNode["body"][$iTableBodyRow]); $iTableBodyCell++) {
|
||||
$_cellColSpan = 1;
|
||||
$_cellRowSpan = 1;
|
||||
if(array_key_exists("colspan", $elementNode["body"][$iTableBodyRow][$iTableBodyCell])) {
|
||||
$_cellColSpan = $elementNode["body"][$iTableBodyRow][$iTableBodyCell]["colspan"];
|
||||
}
|
||||
if(array_key_exists("rowspan", $elementNode["body"][$iTableBodyRow][$iTableBodyCell])) {
|
||||
$_cellRowSpan = $elementNode["body"][$iTableBodyRow][$iTableBodyCell]["rowspan"];
|
||||
}
|
||||
|
||||
echo('<td'.($_cellColSpan>1?' colspan="'.$_cellColSpan.'"':'').($_cellRowSpan>1?' rowspan="'.$_cellRowSpan.'"':'').'>');
|
||||
if(array_key_exists("parts", $elementNode["body"][$iTableBodyRow][$iTableBodyCell])) {
|
||||
for ($iPart = 0; $iPart < count($elementNode["body"][$iTableBodyRow][$iTableBodyCell]["parts"]); $iPart++) {
|
||||
createElementNode($elementNode["body"][$iTableBodyRow][$iTableBodyCell]["parts"][$iPart]);
|
||||
}
|
||||
} else {
|
||||
echo(getContentItemText($elementNode["body"][$iTableBodyRow][$iTableBodyCell], false, true));
|
||||
}
|
||||
echo('</td>');
|
||||
}
|
||||
echo('</tr>');
|
||||
}
|
||||
echo('</tbody>');
|
||||
}
|
||||
|
||||
// Ending table.
|
||||
echo('</table>');
|
||||
|
||||
break;
|
||||
case "collapse":
|
||||
// Preparing some stuff.
|
||||
$_title = '<i>'.localize("error.content.data.no.title").'</i>';
|
||||
$_subtitle = '';
|
||||
if(array_key_exists("title", $elementNode)) {
|
||||
$_title = getContentItemText($elementNode["title"], true, true);
|
||||
}
|
||||
if(array_key_exists("subtitle", $elementNode)) {
|
||||
$_subtitle = getContentItemText($elementNode["subtitle"], true, true);
|
||||
}
|
||||
|
||||
// Reading and processing the modifiers.
|
||||
$_modNoRounding = false;
|
||||
$_modNoContentPadding = false;
|
||||
$_modNoTopMargin = false;
|
||||
$_modIsClosed = false;
|
||||
$_modHorizontalScroll = false;
|
||||
if(array_key_exists("modifiers", $elementNode)) {
|
||||
for ($i = 0; $i < count($elementNode["modifiers"]); $i++) {
|
||||
switch($elementNode["modifiers"][$i]) {
|
||||
case "no-rounding":
|
||||
// Removes the rounding on the external edges.
|
||||
$_modNoRounding = true;
|
||||
break;
|
||||
case "no-padding-content":
|
||||
// Removes the internal padding and adds 0.01em to the top to prevent gaps from margins.
|
||||
$_modNoContentPadding = true;
|
||||
break;
|
||||
case "no-top-margin":
|
||||
// Removes the standard top margin.
|
||||
$_modNoTopMargin = true;
|
||||
break;
|
||||
case "closed":
|
||||
// Close the collapse by default.
|
||||
$_modIsClosed = true;
|
||||
break;
|
||||
case "horizontal-scroll":
|
||||
$_modHorizontalScroll = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Starting the collapse.
|
||||
echo('<details class="collapse-panel w-full'.($_modNoTopMargin?"":" mt-10").'" '.($_modIsClosed?"closed":"open").'>');
|
||||
echo('<summary class="collapse-header p-10 px-15 text-truncate without-arrow'.($_modNoRounding?" rounded-0":"").' border-left-0 border-right-0">');
|
||||
echo('<h4 class="font-size-16 m-0 align-middle no-select"><i class="fad fa-angle-down hidden-collapse-closed font-size-24"></i>');
|
||||
echo('<i class="fad fa-angle-up hidden-collapse-open font-size-24"></i>');
|
||||
echo('<span class="font-weight-semi-bold align-top"> '.$_title.'<span class="ml-20 text-muted">'.$_subtitle.'</span></span>');
|
||||
echo('</h4></summary><div class="collapse-content'.($_modHorizontalScroll?' overflow-x-scroll hide-scrollbar':'').
|
||||
($_modNoContentPadding?" p-0 py-01":"").($_modNoRounding?" rounded-0":"").' border-0 border-bottom">');
|
||||
|
||||
// Rendering sub-elements.
|
||||
if(array_key_exists("parts", $elementNode)) {
|
||||
for ($i = 0; $i < count($elementNode["parts"]); $i++) {
|
||||
createElementNode($elementNode["parts"][$i]);
|
||||
}
|
||||
} else {
|
||||
printErrorTextElement(localize("error.content.data.no.subpart"));
|
||||
}
|
||||
|
||||
// Ending the collapse.
|
||||
echo('</div></details>');
|
||||
|
||||
break;
|
||||
case "slider":
|
||||
case "glider":
|
||||
@@ -611,10 +183,6 @@ function processStandardContentSubNode(mixed $elementNode, string $prepend="", s
|
||||
echo('</div><div class="align-self-stretch font-size-40 ml-5 my-auto glider-nav" aria-label="Next">');
|
||||
echo('<i class="fad fa-angle-right"></i></div></div>');
|
||||
|
||||
break;
|
||||
default:
|
||||
printErrorTextElement(sprintf(localize("error.content.data.part.unknown"), $elementNode["type"]));
|
||||
break;
|
||||
}/**/
|
||||
|
||||
?>
|
||||
?>
|
@@ -43,12 +43,14 @@ function localize_private(string $string_key, array $private_lang_data, bool $fa
|
||||
// If found in direct array in user's language.
|
||||
return $private_lang_data[$user_language][$string_key];
|
||||
}
|
||||
} else if(array_key_exists($default_language, $private_lang_data)) {
|
||||
}
|
||||
if(array_key_exists($default_language, $private_lang_data)) {
|
||||
if(array_key_exists($string_key, $private_lang_data[$default_language])) {
|
||||
// If found in direct array in default language.
|
||||
return $private_lang_data[$default_language][$string_key];
|
||||
}
|
||||
} else if($fallback_to_common) {
|
||||
}
|
||||
if($fallback_to_common) {
|
||||
// If we can attempt to fallback on the common lang file.
|
||||
return localize_private($fallback_prefix . "." . $string_key, $lang_data, false);
|
||||
}
|
||||
|
@@ -127,22 +127,29 @@
|
||||
"content.search.count.single": "result",
|
||||
"content.search.count.multiple": "results",
|
||||
|
||||
"content.commons.version.current": "Current version",
|
||||
"content.commons.version.previous.single": "Previous version",
|
||||
"content.commons.version.previous.multiple": "Previous versions",
|
||||
"content.commons.version.old.single": "Old version",
|
||||
"content.commons.version.old.multiple": "Old versions",
|
||||
"content.commons.version.source": "Source code",
|
||||
"content.commons.cpu": "CPU <span class=\"hidden-xs-and-down\">Architecture</span>",
|
||||
"content.commons.cpu.responsive": "CPU <span class=\"hidden-xs-and-down\">Architecture</span>",
|
||||
"content.commons.cpu.x64": "x64",
|
||||
"content.commons.cpu.x86": "x86",
|
||||
"content.commons.na.italic": "<i>N/A</i>",
|
||||
"content.commons.na": "N/A",
|
||||
"content.commons.lang": "Language",
|
||||
"content.commons.download.single": "Download",
|
||||
"content.commons.download.multiple": "Downloads",
|
||||
"content.commons.version": "Version",
|
||||
"content.fallback.content.commons.version.current": "Current version",
|
||||
"content.fallback.content.commons.version.previous.single": "Previous version",
|
||||
"content.fallback.content.commons.version.previous.multiple": "Previous versions",
|
||||
"content.fallback.content.commons.version.old.single": "Old version",
|
||||
"content.fallback.content.commons.version.old.multiple": "Old versions",
|
||||
"content.fallback.content.commons.version.source": "Source code",
|
||||
"content.fallback.content.commons.cpu": "CPU <span class=\"hidden-xs-and-down\">Architecture</span>",
|
||||
"content.fallback.content.commons.cpu.responsive": "CPU <span class=\"hidden-xs-and-down\">Architecture</span>",
|
||||
"content.fallback.content.commons.cpu.x64": "x64",
|
||||
"content.fallback.content.commons.cpu.x86": "x86",
|
||||
"content.fallback.content.commons.na.italic": "<i>N/A</i>",
|
||||
"content.fallback.content.commons.na": "N/A",
|
||||
"content.fallback.content.commons.lang": "Language",
|
||||
"content.fallback.content.commons.download.single": "Download",
|
||||
"content.fallback.content.commons.download.multiple": "Downloads",
|
||||
"content.fallback.content.commons.version": "Version",
|
||||
|
||||
"content.fallback.content.commons.lang.english": "English",
|
||||
"content.fallback.content.commons.lang.french": "French",
|
||||
"content.fallback.content.commons.lang.luxembourgish": "Luxembourgish",
|
||||
"content.fallback.content.commons.lang.english.639-3": "English (eng)",
|
||||
"content.fallback.content.commons.lang.french.639-3": "French (fra)",
|
||||
"content.fallback.content.commons.lang.luxembourgish.639-3": "Luxembourgish (ltz)",
|
||||
|
||||
"content.default.head.title" : "No title found !",
|
||||
"content.default.head.description" : "No description found !",
|
||||
@@ -275,7 +282,7 @@
|
||||
"error.content.data.part.unknown": "Élément inconnu: \"%s\" !",
|
||||
|
||||
"content.title.error": "Erreur de contenu",
|
||||
"content.title.content": "Content",
|
||||
"content.title.content": "Projets",
|
||||
"content.title.search.header": "Recherche",
|
||||
"content.title.search.card": "Recherche de contenu",
|
||||
"content.title.search.card.single": "Résultat de recherche",
|
||||
@@ -284,21 +291,25 @@
|
||||
"content.search.count.single": "résultat",
|
||||
"content.search.count.multiple": "résultats",
|
||||
|
||||
"content.commons.version.current": "Version actuelle",
|
||||
"content.commons.version.previous.single": "Version précédente",
|
||||
"content.commons.version.previous.multiple": "Versions précédentes",
|
||||
"content.commons.version.old.single": "Ancienne version",
|
||||
"content.commons.version.old.multiple": "Anciennes versions",
|
||||
"content.commons.version.source": "Code source",
|
||||
"content.commons.cpu": "Architecture de CPU",
|
||||
"content.commons.cpu.x64": "x64",
|
||||
"content.commons.cpu.x86": "x86",
|
||||
"content.commons.na.italic": "<i>N/A</i>",
|
||||
"content.commons.na": "N/A",
|
||||
"content.commons.lang": "Langue",
|
||||
"content.commons.download.single": "Téléchargement",
|
||||
"content.commons.download.multiple": "Téléchargements",
|
||||
"content.commons.version": "Version",
|
||||
"content.fallback.content.commons.version.current": "Version actuelle",
|
||||
"content.fallback.content.commons.version.previous.single": "Version précédente",
|
||||
"content.fallback.content.commons.version.previous.multiple": "Versions précédentes",
|
||||
"content.fallback.content.commons.version.old.single": "Ancienne version",
|
||||
"content.fallback.content.commons.version.old.multiple": "Anciennes versions",
|
||||
"content.fallback.content.commons.version.source": "Code source",
|
||||
"content.fallback.content.commons.cpu": "Architecture de CPU",
|
||||
"content.fallback.content.commons.cpu.x64": "x64",
|
||||
"content.fallback.content.commons.cpu.x86": "x86",
|
||||
"content.fallback.content.commons.na.italic": "<i>N/A</i>",
|
||||
"content.fallback.content.commons.na": "N/A",
|
||||
"content.fallback.content.commons.lang": "Langue",
|
||||
"content.fallback.content.commons.download.single": "Téléchargement",
|
||||
"content.fallback.content.commons.download.multiple": "Téléchargements",
|
||||
"content.fallback.content.commons.version": "Version",
|
||||
|
||||
"content.fallback.content.commons.lang.english": "Anglais",
|
||||
"content.fallback.content.commons.lang.french": "Français",
|
||||
"content.fallback.content.commons.lang.luxembourgish": "Luxembourgeois",
|
||||
|
||||
"content.default.head.title" : "Aucun titre trouvé !",
|
||||
"content.default.head.description" : "Aucune description trouvée !",
|
||||
|
Reference in New Issue
Block a user