Browse Source

ajoute la gestion des iframes

master
vince vince 2 years ago
parent
commit
33e82c0146
1 changed files with 32 additions and 4 deletions
  1. +32
    -4
      index.php

+ 32
- 4
index.php View File

@ -58,15 +58,17 @@ function generatePassword($length = 20) {
} }
function generateUrl($supplier = null, $event = null) { function generateUrl($supplier = null, $event = null) {
global $requestUrl;
global $requestUrl, $inIframe;
$queryString = $inIframe ? '?iframe' : '';
if (is_null($supplier)) if (is_null($supplier))
return $requestUrl;
return $requestUrl . $queryString;
if (is_null($event)) if (is_null($event))
return sprintf('%s/%s', $requestUrl, $supplier);
return sprintf('%s/%s', $requestUrl, $supplier) . $queryString;
return sprintf('%s/%s/%s', $requestUrl, $supplier, $event);
return sprintf('%s/%s/%s', $requestUrl, $supplier, $event) . $queryString;
} }
function findNext($start, $frequency, $excludes = [], $vsNow = true, $maxIterations = 1000, $direction = +1) { function findNext($start, $frequency, $excludes = [], $vsNow = true, $maxIterations = 1000, $direction = +1) {
@ -111,6 +113,7 @@ define('DATA_FILE', __DIR__ . DIRECTORY_SEPARATOR . 'data.php');
if (file_exists(CONFIG_FILE)) require_once CONFIG_FILE; if (file_exists(CONFIG_FILE)) require_once CONFIG_FILE;
if (!isset($config)) $config = []; if (!isset($config)) $config = [];
$inIframe = isset($_REQUEST['iframe']);
$action = (isset($_REQUEST['action']) and preg_match(ACTION_REGEX, $_REQUEST['action'])) ? $_REQUEST['action'] : null; $action = (isset($_REQUEST['action']) and preg_match(ACTION_REGEX, $_REQUEST['action'])) ? $_REQUEST['action'] : null;
$supplier = array_key_exists('supplier', $_REQUEST) ? $_REQUEST['supplier'] : $requestSupplier; $supplier = array_key_exists('supplier', $_REQUEST) ? $_REQUEST['supplier'] : $requestSupplier;
@ -390,6 +393,7 @@ $linkUrl = !$hasSupplier ? generateUrl() : (!$hasEvent ? generateUrl($supplier)
<style type="text/css">.sortable th.dir-d::after{color:inherit;content:' \025BE'}.sortable th.dir-u::after{color:inherit;content:' \025B4'}</style> <style type="text/css">.sortable th.dir-d::after{color:inherit;content:' \025BE'}.sortable th.dir-u::after{color:inherit;content:' \025B4'}</style>
</head> </head>
<body> <body>
<?php if (!$inIframe) : ?>
<header> <header>
<nav class="navbar navbar-dark bg-dark"> <nav class="navbar navbar-dark bg-dark">
<div class="container-fluid"> <div class="container-fluid">
@ -423,6 +427,7 @@ $linkUrl = !$hasSupplier ? generateUrl() : (!$hasEvent ? generateUrl($supplier)
</div> </div>
</nav> </nav>
</header> </header>
<?php endif; // !$inIframe ?>
<main> <main>
<?php if (!$hasSupplier) : ?> <?php if (!$hasSupplier) : ?>
<section class="container-fluid pt-3"> <section class="container-fluid pt-3">
@ -433,6 +438,7 @@ $linkUrl = !$hasSupplier ? generateUrl() : (!$hasEvent ? generateUrl($supplier)
<div class="row mb-3 g-3"> <div class="row mb-3 g-3">
<div class="col-12"> <div class="col-12">
<form action="<?php echo generateUrl(); ?>" method="post"> <form action="<?php echo generateUrl(); ?>" method="post">
<?php if ($inIframe) : ?><input type="hidden" name="iframe" /><?php endif; // $inIframe ?>
<datalist id="supplierList"> <datalist id="supplierList">
<?php foreach ($suppliers as $supplier) : ?> <?php foreach ($suppliers as $supplier) : ?>
<option value="<?php echo $supplier; ?>" /> <option value="<?php echo $supplier; ?>" />
@ -471,6 +477,7 @@ $linkUrl = !$hasSupplier ? generateUrl() : (!$hasEvent ? generateUrl($supplier)
<section class="container-fluid"> <section class="container-fluid">
<div class="row g-3"> <div class="row g-3">
<form action="<?php echo generateUrl($supplier); ?>" method="post"> <form action="<?php echo generateUrl($supplier); ?>" method="post">
<?php if ($inIframe) : ?><input type="hidden" name="iframe" /><?php endif; // $inIframe ?>
<div class="row mb-3"> <div class="row mb-3">
<label for="title" class="col-sm-2 col-form-label">Titre</label> <label for="title" class="col-sm-2 col-form-label">Titre</label>
<div class="col-sm-10"> <div class="col-sm-10">
@ -581,6 +588,7 @@ $linkUrl = !$hasSupplier ? generateUrl() : (!$hasEvent ? generateUrl($supplier)
<div class="row my-3"> <div class="row my-3">
<div class="col"> <div class="col">
<h1> <h1>
<?php if (!$inIframe) : ?>
<div class="btn-group float-end" role="group"> <div class="btn-group float-end" role="group">
<?php if (isset($previousEvent)) : ?> <?php if (isset($previousEvent)) : ?>
<a class="btn btn-outline-primary" href="<?php echo generateUrl($supplier, $previousEvent); ?>" title="Événement précédent"> <a class="btn btn-outline-primary" href="<?php echo generateUrl($supplier, $previousEvent); ?>" title="Événement précédent">
@ -605,6 +613,7 @@ $linkUrl = !$hasSupplier ? generateUrl() : (!$hasEvent ? generateUrl($supplier)
</a> </a>
<?php endif; ?> <?php endif; ?>
</div> </div>
<?php endif; // !$inIframe ?>
<?php echo $config[$supplier]['title']; ?> <?php echo $config[$supplier]['title']; ?>
<?php echo $config[$supplier]['subtitle']; ?> <?php echo $config[$supplier]['subtitle']; ?>
</h1> </h1>
@ -617,6 +626,7 @@ $linkUrl = !$hasSupplier ? generateUrl() : (!$hasEvent ? generateUrl($supplier)
<section class="container-fluid"> <section class="container-fluid">
<div class="row g-3"> <div class="row g-3">
<form class="js-localremember bg-dark text-light" action="<?php echo generateUrl($supplier); ?>" method="post"> <form class="js-localremember bg-dark text-light" action="<?php echo generateUrl($supplier); ?>" method="post">
<?php if ($inIframe) : ?><input type="hidden" name="iframe" /><?php endif; // $inIframe ?>
<div class="row my-3"> <div class="row my-3">
<label for="title" class="col-sm-2 col-form-label">Nom</label> <label for="title" class="col-sm-2 col-form-label">Nom</label>
<div class="col-sm-10"> <div class="col-sm-10">
@ -691,6 +701,7 @@ $linkUrl = !$hasSupplier ? generateUrl() : (!$hasEvent ? generateUrl($supplier)
<?php endif; ?> <?php endif; ?>
<td> <td>
<form onsubmit="return confirm('Souhaitez-vous vraiment annuler cette commande ?');"> <form onsubmit="return confirm('Souhaitez-vous vraiment annuler cette commande ?');">
<?php if ($inIframe) : ?><input type="hidden" name="iframe" /><?php endif; // $inIframe ?>
<input type="hidden" name="supplier" value="<?php echo $supplier; ?>" /> <input type="hidden" name="supplier" value="<?php echo $supplier; ?>" />
<input type="hidden" name="event" value="<?php echo $event; ?>" /> <input type="hidden" name="event" value="<?php echo $event; ?>" />
<input type="hidden" name="name" value="<?php echo $item['name']; ?>" /> <input type="hidden" name="name" value="<?php echo $item['name']; ?>" />
@ -705,6 +716,7 @@ $linkUrl = !$hasSupplier ? generateUrl() : (!$hasEvent ? generateUrl($supplier)
</div> </div>
</div> </div>
<?php endif; ?> <?php endif; ?>
<?php if (!$inIframe) : ?>
<div class="col-12"> <div class="col-12">
<div class="accordion accordion-flush"> <div class="accordion accordion-flush">
<div class="accordion-item"> <div class="accordion-item">
@ -729,6 +741,7 @@ $linkUrl = !$hasSupplier ? generateUrl() : (!$hasEvent ? generateUrl($supplier)
</div> </div>
</div> </div>
</div> </div>
<?php endif; // !$inIframe ?>
</div> </div>
</section> </section>
<?php endif; /* $supplierIsNew */ ?> <?php endif; /* $supplierIsNew */ ?>
@ -759,6 +772,21 @@ $linkUrl = !$hasSupplier ? generateUrl() : (!$hasEvent ? generateUrl($supplier)
</button> </button>
</div> </div>
<div class="col-12"> <div class="col-12">
IFrame
</div>
<div class="col-12 text-center">
<pre id="iframeCode"><?php ob_start(); ?>
<iframe src="<?php echo generateUrl($supplier); ?>">
</iframe>
<?php echo htmlentities(ob_get_clean()); ?></pre>
<button class="btn btn-outline-dark js-clipboard" type="button" role="button" data-clipboard-target="#frameCode" data-bs-toggle="tooltip" data-bs-trigger="manual">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-clipboard" viewBox="0 0 16 16">
<path d="M4 1.5H3a2 2 0 0 0-2 2V14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V3.5a2 2 0 0 0-2-2h-1v1h1a1 1 0 0 1 1 1V14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3.5a1 1 0 0 1 1-1h1v-1z"/>
<path d="M9.5 1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-1a.5.5 0 0 1 .5-.5h3zm-3-1A1.5 1.5 0 0 0 5 1.5v1A1.5 1.5 0 0 0 6.5 4h3A1.5 1.5 0 0 0 11 2.5v-1A1.5 1.5 0 0 0 9.5 0h-3z"/>
</svg>
</button>
</div>
<div class="col-12">
QR Code QR Code
</div> </div>
<div class="col-12"> <div class="col-12">


Loading…
Cancel
Save