Fixed some composer elements, Updated Excel-Password-Remover
Update utils.php, composer.php, and 14 more files...
This commit is contained in:
@@ -5,43 +5,56 @@ if (basename(__FILE__) == basename($_SERVER["SCRIPT_FILENAME"])) {
|
||||
die();
|
||||
}
|
||||
|
||||
// Used by 'printMainHeader()'.
|
||||
$_npDomUtilsHeadingCount = 0;
|
||||
|
||||
/**
|
||||
* Prints a standard heading container and its text with an optional anchor.
|
||||
* @param $text string Text to be shown in the heading
|
||||
* @param $iconId string|null
|
||||
* @param $rightText string|null
|
||||
* @param $anchorId string|null Anchor's ID if desired, `null` otherwise.
|
||||
* @return void
|
||||
*/
|
||||
function makeMainHeader(string $text, ?string $iconId = null, ?string $rightText = null, ?string $anchorId = null): void {
|
||||
global $_npDomUtilsHeadingCount;
|
||||
|
||||
if(!is_null($anchorId)) {
|
||||
echo('<a class="bland-link" href="#' . $anchorId . '">');
|
||||
function getMainHeader(string $text, ?string $iconId = null, ?string $rightText = null, ?string $anchorId = null,
|
||||
bool $addTopMargin = true, ?string $backgroundClass = "bkgd-grid", int $hLevel = 2): string {
|
||||
if(is_null($backgroundClass)) {
|
||||
$backgroundClass = "bkgd-grid";
|
||||
}
|
||||
|
||||
echo('<div class="heading-main p-xs border r-s ' . ($_npDomUtilsHeadingCount > 0 ? "mt-l " : "") . 'bkgd-grid"><h2 class="t-w-500 t-size-14">');
|
||||
|
||||
$htmlCode = "";
|
||||
|
||||
if(!is_null($anchorId)) {
|
||||
$htmlCode .= '<a class="bland-link" href="#' . $anchorId . '">';
|
||||
}
|
||||
|
||||
$htmlCode .= '<div class="heading-main p-xs border r-s ' . ($addTopMargin > 0 ? "mt-l " : "") . $backgroundClass .
|
||||
'"><h' . $hLevel . ' class="t-w-500 t-size-14">';
|
||||
|
||||
// TODO: Add a simple and nicer divider.
|
||||
if(!is_null($iconId)) {
|
||||
echo('<i class="' . $iconId . ' t-size-12 t-muted"></i>');
|
||||
$htmlCode .= '<i class="' . $iconId . ' t-size-12 t-muted"></i>';
|
||||
}
|
||||
|
||||
echo($text);
|
||||
$htmlCode .= $text;
|
||||
|
||||
if(!is_null($rightText)) {
|
||||
echo('<span class="ml-auto t-muted t-size-10">' . $rightText . '</span>');
|
||||
$htmlCode .= '<span class="ml-auto t-muted t-size-10">' . $rightText . '</span>';
|
||||
}
|
||||
|
||||
echo('</h2></div>');
|
||||
$htmlCode .= '</h' . $hLevel . '></div>';
|
||||
|
||||
if(!is_null($anchorId)) {
|
||||
echo('</a>');
|
||||
$htmlCode .= '</a>';
|
||||
}
|
||||
|
||||
return $htmlCode;
|
||||
}
|
||||
|
||||
function printMainHeader(string $text, ?string $iconId = null, ?string $rightText = null, ?string $anchorId = null,
|
||||
?string $backgroundClass = "bkgd-grid"): void {
|
||||
global $_npDomUtilsHeadingCount;
|
||||
$_npDomUtilsHeadingCount++;
|
||||
echo(getMainHeader(
|
||||
$text,
|
||||
$iconId,
|
||||
$rightText,
|
||||
$anchorId,
|
||||
($_npDomUtilsHeadingCount > 1),
|
||||
$backgroundClass
|
||||
));
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -6,18 +6,22 @@ if(basename(__FILE__) == basename($_SERVER["SCRIPT_FILENAME"])) {
|
||||
}
|
||||
|
||||
// Including required helpers.
|
||||
include_once 'config.php';
|
||||
include_once 'langs.php';
|
||||
include_once 'commons/config.php';
|
||||
include_once 'commons/langs.php';
|
||||
|
||||
// Required to make headings
|
||||
include_once 'commons/DOM/utils.php';
|
||||
|
||||
// Defining some options.
|
||||
$USE_CONFIG_URI_FOR_OPENGRAPH = true;
|
||||
$AUTO_DETECT_OPENGRAPH_MIME = true;
|
||||
$LANG_FALLBACK_KEY_PREFIX = "content.fallback";
|
||||
$LANG_FALLBACK_KEY_PREFIX = "";
|
||||
|
||||
// Defining the template types.
|
||||
abstract class ComposerTemplates {
|
||||
const RAW = "raw";
|
||||
const ARTICLE = "article";
|
||||
const ARTICLE_LEGACY = "article";
|
||||
const GENERIC_PROJECT_README = "generic-project-readme";
|
||||
|
||||
/**
|
||||
* Returns all the constants present in the class.
|
||||
@@ -64,22 +68,22 @@ abstract class ComposerElementTypes {
|
||||
// Defining modifiers.
|
||||
abstract class ComposerElementModifiers {
|
||||
// Generic > Margin
|
||||
const GENERIC_MARGIN_NO_TOP = ["no-top-margin", "mt-0"];
|
||||
const GENERIC_MARGIN_NO_BOTTOM = ["no-bottom-margin", "mb-0"];
|
||||
const GENERIC_MARGIN_NO_LEFT = ["no-left-margin", "ml-0"];
|
||||
const GENERIC_MARGIN_NO_RIGHT = ["no-right-margin", "mr-0"];
|
||||
const GENERIC_MARGIN_NO_X = ["no-y-margin", "mx-0"];
|
||||
const GENERIC_MARGIN_NO_Y = ["no-x-margin", "my-0"];
|
||||
const GENERIC_MARGIN_NONE = ["no-margin", "m-0" ];
|
||||
const GENERIC_MARGIN_NO_TOP = ["mt-0", "mt-0"];
|
||||
const GENERIC_MARGIN_NO_BOTTOM = ["mb-0", "mb-0"];
|
||||
const GENERIC_MARGIN_NO_LEFT = ["ml-0", "ml-0"];
|
||||
const GENERIC_MARGIN_NO_RIGHT = ["mr-0", "mr-0"];
|
||||
const GENERIC_MARGIN_NO_X = ["mx-0", "mx-0"];
|
||||
const GENERIC_MARGIN_NO_Y = ["my-0", "my-0"];
|
||||
const GENERIC_MARGIN_NONE = ["m-0", "m-0" ];
|
||||
|
||||
// Generic > Padding
|
||||
const GENERIC_PADDING_NO_TOP = ["no-top-padding", "pt-0"];
|
||||
const GENERIC_PADDING_NO_BOTTOM = ["no-bottom-padding", "pb-0"];
|
||||
const GENERIC_PADDING_NO_LEFT = ["no-left-padding", "pl-0"];
|
||||
const GENERIC_PADDING_NO_RIGHT = ["no-right-padding", "pr-0"];
|
||||
const GENERIC_PADDING_NO_X = ["no-x-padding", "px-0"];
|
||||
const GENERIC_PADDING_NO_Y = ["no-y-padding", "py-0"];
|
||||
const GENERIC_PADDING_NONE = ["no-padding", "p-0" ];
|
||||
const GENERIC_PADDING_NO_TOP = ["pt-0", "pt-0"];
|
||||
const GENERIC_PADDING_NO_BOTTOM = ["pb-0", "pb-0"];
|
||||
const GENERIC_PADDING_NO_LEFT = ["pl-0", "pl-0"];
|
||||
const GENERIC_PADDING_NO_RIGHT = ["pr-0", "pr-0"];
|
||||
const GENERIC_PADDING_NO_X = ["px-0", "px-0"];
|
||||
const GENERIC_PADDING_NO_Y = ["py-0", "py-0"];
|
||||
const GENERIC_PADDING_NONE = ["p-0" , "p-0" ];
|
||||
|
||||
// Containers
|
||||
const CONTAINER_SCROLL_HORIZONTAL = ["horizontal-scroll", "overflow-x-scroll hide-scrollbar"];
|
||||
@@ -194,7 +198,7 @@ class ComposerContent {
|
||||
public function get_html() : string {
|
||||
$htmlCode = "";
|
||||
|
||||
// FIXME: Check for the template after the loop
|
||||
// FIXME: Check for the template after the loop - Isn't it done already ?
|
||||
|
||||
foreach($this->elements as $element) {
|
||||
/** @var ComposerElement $element */
|
||||
@@ -262,7 +266,7 @@ class ComposerContentMetadata {
|
||||
$this->article = $article;
|
||||
|
||||
// Safety checks.
|
||||
if($this->template == ComposerTemplates::ARTICLE && is_null($this->article)) {
|
||||
if($this->template == ComposerTemplates::ARTICLE_LEGACY && is_null($this->article)) {
|
||||
$this->article = ComposerContentMetadataArticle::from_json([]);
|
||||
}
|
||||
}
|
||||
@@ -285,7 +289,7 @@ class ComposerContentMetadata {
|
||||
|
||||
function apply_template(ComposerContent $content_root, string $inner_html) : string {
|
||||
switch($this->template) {
|
||||
case ComposerTemplates::ARTICLE:
|
||||
case ComposerTemplates::ARTICLE_LEGACY:
|
||||
$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> ' .
|
||||
@@ -308,6 +312,27 @@ class ComposerContentMetadata {
|
||||
}
|
||||
|
||||
$inner_html .= '</div></div></div>';
|
||||
break;
|
||||
case ComposerTemplates::GENERIC_PROJECT_README:
|
||||
// Prepending the heading
|
||||
$inner_html = getMainHeader(
|
||||
localize_private($this->article->title, $content_root->strings, false),
|
||||
$this->article->icon,
|
||||
localize_private($this->article->subtitle, $content_root->strings, false),
|
||||
null,
|
||||
false
|
||||
) . $inner_html;
|
||||
|
||||
// Appending the tags if any are present
|
||||
if(sizeof($this->article->tags) > 0) {
|
||||
foreach($this->article->tags as $tag) {
|
||||
$inner_html .= '<a href="'.l10n_url_abs("/content/?tags=" . $tag .
|
||||
'" class="content-tag">#' . $tag . '</a>');
|
||||
}
|
||||
} else {
|
||||
$inner_html .= '<i>' . localize("content.error.message.data.no.tags") . '</i>';
|
||||
}
|
||||
|
||||
break;
|
||||
case ComposerTemplates::RAW:
|
||||
default:
|
||||
@@ -617,6 +642,18 @@ class ComposerElement {
|
||||
break;
|
||||
|
||||
case ComposerElementTypes::H1:
|
||||
$htmlCode .= getMainHeader(
|
||||
$this->get_inner_html($content_root),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
!ComposerElementModifiers::is_modifier_in_modifiers(
|
||||
ComposerElementModifiers::GENERIC_MARGIN_NO_TOP, $this->modifiers),
|
||||
null,
|
||||
3
|
||||
);
|
||||
break;
|
||||
|
||||
case ComposerElementTypes::H2:
|
||||
case ComposerElementTypes::H3:
|
||||
// Defining the text's indent level.
|
||||
@@ -636,26 +673,23 @@ class ComposerElement {
|
||||
|
||||
case ComposerElementTypes::PARAGRAPH:
|
||||
// Defining the text's indent level.
|
||||
// TODO: Join with others
|
||||
$_paragraph_ident_level = is_null($this->indent) ? 0 : $this->indent;
|
||||
$_paragraph_ident_level = $_paragraph_ident_level < 0 ? 0 : $_paragraph_ident_level;
|
||||
$_paragraph_ident_level = $_paragraph_ident_level > 5 ? 5 : $_paragraph_ident_level;
|
||||
$_paragraph_ident_level = (["", "ml-xs", "ml-s", "ml-m", "ml-l", "ml-xl"])[$_paragraph_ident_level];
|
||||
|
||||
// Calculating the vertical margin modifiers
|
||||
$_paragraph_no_margin_top = ComposerElementModifiers::is_modifier_in_modifiers(
|
||||
ComposerElementModifiers::GENERIC_MARGIN_NO_TOP, $this->modifiers);
|
||||
$_paragraph_no_margin_bottom = ComposerElementModifiers::is_modifier_in_modifiers(
|
||||
ComposerElementModifiers::GENERIC_MARGIN_NO_BOTTOM, $this->modifiers);
|
||||
|
||||
if($_paragraph_no_margin_top && $_paragraph_no_margin_bottom) {
|
||||
$_paragraph_margin_modifier = 'my-0';
|
||||
} else if($_paragraph_no_margin_top) {
|
||||
$_paragraph_margin_modifier = 'mt-0 mb-10';
|
||||
} else if($_paragraph_no_margin_bottom) {
|
||||
$_paragraph_margin_modifier = 'mt-10 mb-0';
|
||||
if($_paragraph_no_margin_top) {
|
||||
$_paragraph_margin_modifier = '';
|
||||
} else {
|
||||
$_paragraph_margin_modifier = 'my-10';
|
||||
$_paragraph_margin_modifier = 'mt-xs ';
|
||||
}
|
||||
|
||||
// Composing the paragraph
|
||||
$htmlCode .= '<p class="' . $_paragraph_margin_modifier. ' ml-md-' . ($_paragraph_ident_level * 5) .
|
||||
$htmlCode .= '<p class="' . $_paragraph_margin_modifier . $_paragraph_ident_level .
|
||||
'">' . $this->get_inner_html($content_root) . '</p>';
|
||||
|
||||
break;
|
||||
@@ -713,36 +747,15 @@ class ComposerElement {
|
||||
|
||||
case ComposerElementTypes::CONTAINER:
|
||||
// Defining the padding's size.
|
||||
$_container_padding = is_null($this->padding) ? 10 : $this->padding;
|
||||
$_container_padding = is_null($this->padding) ? 0 : $this->padding;
|
||||
$_container_padding = $_container_padding < 0 ? 0 : $_container_padding;
|
||||
$_container_padding = $_container_padding > 5 ? 5 : $_container_padding;
|
||||
$_container_padding = (["", "p-xs ", "p-s ", "p-m ", "p-l ", "p-xl "])[$_container_padding];
|
||||
|
||||
// Composing the container.
|
||||
// FIXME: Can be re-standardized if a check for the default mt-10 is added at the end after adding the mods.
|
||||
$htmlCode .= '<div class="' .
|
||||
(ComposerElementModifiers::is_modifier_in_modifiers(
|
||||
ComposerElementModifiers::CONTAINER_CARD, $this->modifiers
|
||||
) ? ComposerElementModifiers::get_modifier_classes(
|
||||
ComposerElementModifiers::CONTAINER_CARD ) . " m-0 " : "") .
|
||||
'p-' . $_container_padding .
|
||||
(ComposerElementModifiers::is_modifier_in_modifiers(
|
||||
ComposerElementModifiers::GENERIC_MARGIN_NO_TOP, $this->modifiers
|
||||
) ? "" : " mt-10") .
|
||||
(ComposerElementModifiers::is_modifier_in_modifiers(
|
||||
ComposerElementModifiers::GENERIC_PADDING_NO_X, $this->modifiers
|
||||
) ? " " . ComposerElementModifiers::get_modifier_classes(
|
||||
ComposerElementModifiers::GENERIC_PADDING_NO_X ) : "") .
|
||||
(ComposerElementModifiers::is_modifier_in_modifiers(
|
||||
ComposerElementModifiers::GENERIC_PADDING_NO_BOTTOM, $this->modifiers
|
||||
) ? " " . ComposerElementModifiers::get_modifier_classes(
|
||||
ComposerElementModifiers::GENERIC_PADDING_NO_BOTTOM ) : "") .
|
||||
(ComposerElementModifiers::is_modifier_in_modifiers(
|
||||
ComposerElementModifiers::GENERIC_PADDING_NO_TOP, $this->modifiers
|
||||
) ? " " . ComposerElementModifiers::get_modifier_classes(
|
||||
ComposerElementModifiers::GENERIC_PADDING_NO_TOP ) : "") .
|
||||
(ComposerElementModifiers::is_modifier_in_modifiers(
|
||||
ComposerElementModifiers::CONTAINER_SCROLL_HORIZONTAL, $this->modifiers
|
||||
) ? " " . ComposerElementModifiers::get_modifier_classes(
|
||||
ComposerElementModifiers::CONTAINER_SCROLL_HORIZONTAL ) : "") . '">' .
|
||||
$this->get_inner_html($content_root) . '</div>';
|
||||
$htmlCode .= '<div class="' . $_container_padding . $this->get_modifiers_classes() .
|
||||
'">' . $this->get_inner_html($content_root) . '</div>';
|
||||
|
||||
break;
|
||||
|
||||
case ComposerElementTypes::COLLAPSE:
|
||||
|
||||
@@ -52,7 +52,7 @@ function localize_private(string $string_key, array $private_lang_data, bool $fa
|
||||
}
|
||||
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);
|
||||
return localize_private($fallback_prefix . $string_key, $lang_data, false);
|
||||
}
|
||||
|
||||
// If nothing could be done, we simply return the key.
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -3,8 +3,9 @@
|
||||
"content.search.head.description": "TODO: description",
|
||||
"content.search.og.title": "NibblePoker - Content search",
|
||||
"content.search.og.description": "TODO: description",
|
||||
|
||||
"content.search.heading.main": "Search results",
|
||||
|
||||
"content.search.heading.main.single": "Search result",
|
||||
"content.search.heading.main.multiple": "Search results",
|
||||
|
||||
"content.search.count.single": "result",
|
||||
"content.search.count.multiple": "results",
|
||||
@@ -28,14 +29,36 @@
|
||||
"content.error.message.cannot.load": "The requested content couldn't be loaded on our end !",
|
||||
|
||||
"__": "Messages returned by 'commons/composer.php'",
|
||||
"_content.error.message.data.no.tags": "No tags found !",
|
||||
"_content.error.message.data.no.title": "No title found !",
|
||||
"content.error.message.data.no.tags": "No tags found !",
|
||||
"content.error.message.data.no.title": "No title found !",
|
||||
|
||||
"content.item.head.title.prefix": "",
|
||||
"content.item.head.title.suffix": " - NibblePoker",
|
||||
|
||||
"content.item.og.title.prefix": "",
|
||||
"content.item.og.title.suffix": " - NibblePoker",
|
||||
|
||||
"_content.header.title": "Homepage"
|
||||
|
||||
"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.any": "Any architecture",
|
||||
"content.commons.cpu.x64": "x64",
|
||||
"content.commons.cpu.x86": "x86",
|
||||
"content.commons.cpu.arm": "arm",
|
||||
"content.commons.cpu.arm64": "arm64",
|
||||
"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.commons.github": "GitHub Repository",
|
||||
"content.commons.gitea": "Self-hosted Gitea Repository",
|
||||
"content.commons.nuget": "Nuget Package",
|
||||
"content.commons.license.mit.single": "MIT License"
|
||||
}
|
||||
@@ -1,3 +1,63 @@
|
||||
{
|
||||
|
||||
"content.search.head.title": "Recherche de contenu - NibblePoker",
|
||||
"content.search.head.description": "TODO: description",
|
||||
"content.search.og.title": "NibblePoker - Recherche de contenu",
|
||||
"content.search.og.description": "TODO: description",
|
||||
|
||||
"content.search.heading.main.single": "Résultat de recherche",
|
||||
"content.search.heading.main.multiple": "Résultats de recherche",
|
||||
|
||||
"content.search.count.single": "résultat",
|
||||
"content.search.count.multiple": "résultats",
|
||||
|
||||
"content.error.head.title": "Erreur de contenu - NibblePoker",
|
||||
"_content.error.head.description": "Done via the '$content_error_message' variable",
|
||||
"content.error.og.title": "NibblePoker - Erreur de contenu",
|
||||
"_content.error.og.description": "Done via the '$content_error_message' variable",
|
||||
|
||||
"content.error.heading.main.search": "Erreur de recherche",
|
||||
"content.error.heading.main.content": "Erreur de contenu",
|
||||
"content.error.heading.main.fallback": "Erreur inconnue",
|
||||
|
||||
"_": "Messages returned by 'commons/content.php'",
|
||||
"content.error.message.none": "Aucune erreur n'a été détectée.",
|
||||
"content.error.message.tags.length": "Le paramètre d'URL \"tags\" est trop long.",
|
||||
"content.error.message.tags.alphanumeric": "Un des tags donné dans le paramètre d'URL \"tags\" n'est pas une chaîne de texte alphanumérique valide.",
|
||||
"content.error.message.detect.empty": "Aucun contenu en rapport avec les tags choisi n'as été trouvé.",
|
||||
"content.error.message.id.alphanumeric": "L'ID de la ressource demandée n'est pas une chaîne de texte alphanumérique valide.",
|
||||
"content.error.message.data.not.exist": "Le contenu demandée n'a pas de fichier de rendu interne associé.",
|
||||
"content.error.message.cannot.load": "Le contenu demandé n'a pas pu être chargé de notre côté !",
|
||||
|
||||
"__": "Messages returned by 'commons/composer.php'",
|
||||
"content.error.message.data.no.tags": "Aucun tag trouvé !",
|
||||
"content.error.message.data.no.title": "Aucun titre trouvé !",
|
||||
|
||||
"content.item.head.title.prefix": "",
|
||||
"content.item.head.title.suffix": " - NibblePoker",
|
||||
|
||||
"content.item.og.title.prefix": "",
|
||||
"content.item.og.title.suffix": " - NibblePoker",
|
||||
|
||||
"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.any": "Indépendante",
|
||||
"content.commons.cpu.x64": "x64",
|
||||
"content.commons.cpu.x86": "x86",
|
||||
"content.commons.cpu.arm": "arm",
|
||||
"content.commons.cpu.arm64": "arm64",
|
||||
"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.commons.github": "Dépôt GitHub",
|
||||
"content.commons.gitea": "Dépôt Gitea auto-hébergé",
|
||||
"content.commons.nuget": "Packet Nuget",
|
||||
"content.commons.license.mit.single": "License MIT"
|
||||
}
|
||||
Reference in New Issue
Block a user