Fixed some composer elements, Updated Excel-Password-Remover
Update utils.php, composer.php, and 14 more files...
This commit is contained in:
@@ -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:
|
||||
|
Reference in New Issue
Block a user