missing files/code

This commit is contained in:
Rodolfo Berrios
2024-10-28 11:02:01 -03:00
parent f9071bce3d
commit 53449a3f57
5 changed files with 276 additions and 0 deletions

View File

@@ -11,8 +11,35 @@
namespace Chevereto\Legacy\Classes;
use Chevereto\Config\Config;
use function Chevereto\Legacy\G\get_base_url;
use function Chevereto\Legacy\G\get_file_extension;
use function Chevereto\Legacy\G\is_url;
use function Chevereto\Legacy\G\safe_html;
use function Chevereto\Legacy\G\str_replace_last;
use function Chevereto\Vars\get;
use function Chevereto\Vars\post;
class Page
{
public static array $table_fields = [
'url_key',
'type',
'file_path',
'link_url',
'icon',
'title',
'description',
'keywords',
'is_active',
'is_link_visible',
'attr_target',
'attr_rel',
'sort_display',
'internal',
'code',
];
public static function getSingle(string $var, $by = 'url_key'): array
{
return [];
@@ -50,6 +77,64 @@ class Page
public static function fill(array &$page): void
{
$page['title_html'] = safe_html($page['title'] ?? '');
$type_tr = [
'internal' => _s('Internal'),
'link' => _s('Link'),
];
$page['type_tr'] = $type_tr[$page['type']];
switch ($page['type']) {
case 'internal':
$page['url'] = get_base_url('page/' . $page['url_key']);
if (empty($page['file_path'])) {
$filepaths = [
'default' => 'default/',
'user' => null, // base
];
$file_basename = $page['url_key'] . '.php';
foreach ($filepaths as $k => $v) {
if (is_readable(self::getPath($v) . $file_basename)) {
$page['file_path'] = $v . $file_basename;
}
}
} else {
$page_extension = get_file_extension($page['file_path']);
if (! Config::enabled()->phpPages() && $page_extension == 'php') {
$page['file_path'] = str_replace_last($page_extension, 'html', $page['file_path']);
}
if ($page['internal'] === 'contact'
&& (post() !== [] || (get()['sent'] ?? '0' == '1'))) {
$page_extension = 'php';
$page['file_path'] = 'default/contact.php';
}
}
$page['file_path_absolute'] = self::getPath($page['file_path']);
if (! file_exists($page['file_path_absolute'])) {
self::writePage([
'file_path' => $page['file_path'],
'code' => $page['code'] ?? '',
]);
}
break;
case 'link':
$page['url'] = is_url($page['link_url']) || str_starts_with($page['link_url'], '/')
? $page['link_url']
: '';
break;
}
$page['link_attr'] = 'href="' . $page['url'] . '"';
if ($page['attr_target'] !== '_self') {
$page['link_attr'] .= ' target="' . $page['attr_target'] . '"';
}
if (! empty($page['attr_rel'])) {
$page['link_attr'] .= ' rel="' . $page['attr_rel'] . '"';
}
if (! empty($page['icon'])) {
$page['title_html'] = '<span class="btn-icon ' . $page['icon'] . '"></span> ' . $page['title_html'];
}
}
public static function formatRowValues(mixed &$values, mixed $row = []): void

View File

@@ -0,0 +1,20 @@
<?php // @phpstan-ignore-next-line
if (!defined('ACCESS') || !ACCESS) {
die('This file cannot be directly accessed.');
} ?>
<div class="input-label c15">
<label for="form-path"><?php _se('Path'); ?></label>
<input type="text" id="form-path" name="form-path" class="text-input" value="" placeholder="<?php _se('Local path (absolute)'); ?>" required>
</div>
<div class="input-label">
<div class="c15">
<label for="form-structure"><?php _se('Directory structure'); ?></label>
<select name="form-structure" id="form-structure" class="text-input">
<option value="users"><?php _se('Parse top level folders as users (username)'); ?></option>
<option value="albums"><?php _se('Parse top level folders as albums'); ?></option>
<option value="plain"><?php _se("Don't parse folders"); ?></option>
</select>
</div>
<div class="input-below font-size-small"><?php _se('When parsing top level folders as users, second level folders will be parsed as user albums. Parsing top level folders as albums adds these as guest albums.'); ?></div>
</div>

View File

@@ -0,0 +1,18 @@
<?php
use function Chevereto\Legacy\get_select_options_html;
// @phpstan-ignore-next-line
if (!defined('ACCESS') || !ACCESS) {
die('This file cannot be directly accessed.');
} ?>
<div class="input-label">
<div class="c8">
<label for="form-threads"><?php _se('Threads'); ?></label>
<select name="form-threads" id="form-threads" class="text-input">
<option selected value="0">-- <?php _se('Select number of threads'); ?> --</option>
<?php
echo get_select_options_html([1 => 1, 2 => 2, 3 => 3, 4 => 4], null); ?>
</select>
</div>
<div class="input-below font-size-small"><?php _se("This determines how intensive and fast will be the import process. Don't use more than %s threads on a shared server.", 2); ?></div>
</div>

View File

@@ -0,0 +1,27 @@
<?php
use function Chevereto\Legacy\G\datetimegmt;
use Chevereto\Legacy\G\Handler;
// @phpstan-ignore-next-line
if (!defined('ACCESS') || !ACCESS) {
die('This file cannot be directly accessed.');
} ?>
<div class="input-label c8">
<label for="form-ip_ban-ip"><?php _se('IP address'); ?></label>
<input type="text" <?php if (Handler::var('image') !== null) {
echo 'readonly';
} ?> id="form-ip_ban-ip" name="form-ip_ban-ip" class="text-input" value="<?php echo Handler::var('content_ip') ?? ''; ?>" placeholder="127.0.0.1" required>
<div class="input-below font-size-small"><?php _se('You can use wildcard * characters.'); ?></div>
</div>
<div class="input-label">
<div class="c8">
<label for="form-ip_ban-expires"><?php _se('Expiration date'); ?> <span class="optional"><?php _se('optional'); ?></span></label>
<input type="datetime" id="form-ip_ban-expires" name="form-ip_ban-expires" class="text-input" value="" placeholder="<?php _se('YYYY-MM-DD HH:MM:SS'); ?>" pattern="^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$" rel="template-tooltip" data-tiptip="right" data-title="<?php echo _s('Example') . ' ' . datetimegmt(); ?>">
</div>
<div class="input-below font-size-small"><?php _se('Until which date this IP address will be banned? Leave it empty for no expiration.'); ?></div>
</div>
<div class="input-label">
<label for="form-ip_ban-message"><?php _se('Message'); ?> <span class="optional"><?php _se('optional'); ?></span></label>
<textarea id="form-ip_ban-message" name="form-ip_ban-message" class="text-input no-resize" placeholder="<?php _se('Text message, HTML or a redirect URL'); ?>"></textarea>
</div>

View File

@@ -0,0 +1,126 @@
<?php
use Chevereto\Legacy\G\Handler;
use function Chevereto\Legacy\G\require_theme_footer;
use function Chevereto\Legacy\G\require_theme_header;
use function Chevereto\Legacy\G\safe_html;
// @phpstan-ignore-next-line
if (!defined('ACCESS') || !ACCESS) {
die('This file cannot be directly accessed.');
} ?>
<?php require_theme_header(); ?>
<div class="center-box c24 margin-top-20 padding-bottom-10">
<div class="content-width">
<div class="header default-margin-bottom">
<h1 class="header-title"><i class="fa-solid fa-plug-circle-plus color-accent margin-right-5"></i><?php _se('Upload plugin'); ?></h1>
</div>
<div class="text-content">
<p><?php _se('Add media uploading and sharing to your website, blog or forum by installing our upload plugin.'); ?> <?php _se('It provides file uploading to any website by placing a button that will allow your users to directly upload to our service and it will automatically handle the codes needed for insertion.'); ?> <?php _se('All features included like drag and drop, remote upload, image resizing and more.'); ?></p>
<h2><i class="fa-solid fa-circle-check color-accent margin-right-5"></i><?php _se('Supported software'); ?></h2>
<p><?php _se('The plugin works in any website with user-editable content and for %sv, it will place an upload button that will match the target editor toolbar so no extra customization is needed.', ['%sv' => _s('supported software')]); ?></p>
<ul>
<?php
foreach (Handler::var('plugin')['vendors'] as $k => $v) {
echo '<li>' . $v . '</li>' . "\n";
}
?>
</ul>
<h2><i class="fa-solid fa-wand-magic-sparkles color-accent margin-right-5"></i><?php _se('Add it to your website'); ?></h2>
<p><?php _se('Copy and paste the plugin code into your website HTML code (preferably inside the head section). There are plenty %o to make it fit better to your needs.', ['%o' => _s('options')]); ?></p>
<div data-content="pup-options">
<div class="input-label">
<label for="palette"><?php _se('Color palette'); ?></label>
<div class="c9 phablet-c1">
<select type="text" name="palette" id="palette" class="text-input">
<?php
foreach (Handler::var('plugin')['palettes'] as $k => $v) {
$attr = 'value="' . ($k == 'default' ? '' : $k) . '"';
if ($k == 'default') {
$attr .= ' selected="selected"';
}
echo '<option ' . $attr . '>' . ucfirst($k) . '</option>' . "\n";
}
?>
</select>
</div>
<div class="input-below"><?php _se('Button color scheme'); ?></div>
</div>
<div class="input-label">
<label for="auto-insert"><?php _se('Embed codes'); ?></label>
<div class="c9 phablet-c1">
<select type="text" name="auto-insert" id="auto-insert" class="text-input">
<?php
foreach (Handler::var('plugin')['embed'] as $k => $v) {
$attr = 'value="' . $k . '"';
if (!$k) {
$attr .= ' selected="selected"';
}
echo '<option ' . $attr . '>' . $v . '</option>' . "\n";
}
?>
</select>
</div>
<div class="input-below"><?php _se('Embed codes that will be auto-inserted in editor box'); ?></div>
</div>
<div class="input-label">
<label for="sibling"><?php _se('Sibling selector'); ?></label>
<div class="c9 phablet-c1">
<input type="text" name="sibling" id="sibling" class="text-input" placeholder="Empty string">
</div>
<div class="input-below"><?php _se('Sibling element selector where to place the button next to'); ?></div>
</div>
<div class="input-label">
<label for="sibling-pos"><?php _se('Sibling position'); ?></label>
<div class="c9 phablet-c1">
<select type="text" name="sibling-pos" id="sibling-pos" class="text-input">
<option value="" selected="selected"><?php _se('After'); ?></option>
<option value="before"><?php _se('Before'); ?></option>
</select>
</div>
<div class="input-below"><?php _se('Position relative to sibling element'); ?></div>
</div>
</div>
<h4 class="margin-bottom-10"><i><?php _se('Preview'); ?></i></h4>
<div><?php echo Handler::var('plugin')['stylesheet']; echo Handler::var('plugin')['button']; ?></div>
<h4 class="margin-bottom-10"><i><?php _se('HTML code'); ?></i></h4>
<div class="input-label margin-bottom-0">
<textarea id="pup-insert-code" data-focus="select-all" class="code code--snippet code--inline-auto" autocomplete="off" spellcheck="false" readonly><?php echo safe_html(Handler::var('plugin')['tagCode']); ?></textarea>
<button type="button" class="input-action" data-action="copy" data-action-target="#pup-insert-code"><i class="far fa-copy"></i> <?php _se('copy'); ?></button>
</div>
<div class="margin-bottom-40">
<h3><?php _se('Advanced options'); ?></h3>
<p><?php _se('The plugin has a large set of additional options that allow full customization. You can use custom HTML, CSS, own color palette, set observers and more. Check the %d and the plugin source to get a better idea of these advanced options.', ['%d' => '<a rel="external" href="https://chevereto.com/go/v4pup" target="_blank">' . _s('documentation') . '</a>']); ?></p>
</div>
</div>
</div>
</div>
<?php require_theme_footer(); ?>
<script>
document.addEventListener("DOMContentLoaded", function(event) {
var $pluginButton = $("#pup-preview");
var tagAttrs = <?php echo json_encode(Handler::var('plugin')['tagAttrs']); ?>;
var el = document.createElement("script");
for(var key in tagAttrs) {
el.setAttribute(key, tagAttrs[key]);
}
$(document).on("keyup change", "[data-content=pup-options] *:input", function(e) {
var attr = 'data-' + $(this).attr("name");
var val = $(this).val();
if(val) {
el.setAttribute(attr, val);
} else {
el.removeAttribute(attr);
}
$("#pup-insert-code").val(el.outerHTML.replace('=""', '')).highlight();
});
$(document).on("change", "#palette", function(e) {
var val = $(this).val() || "default";
$pluginButton.removeClass(function(i, className) {
return (className.match (/(^|\s)chevereto-pup-button--palette-\S+/g) || []).join(' ');
}).addClass('chevereto-pup-button--palette-' + val);
});
});
</script>