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:
@@ -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;
|
||||
}/**/
|
||||
|
||||
?>
|
||||
?>
|
Reference in New Issue
Block a user