Skip to content

Commit

Permalink
Use flash to open modal
Browse files Browse the repository at this point in the history
  • Loading branch information
wincelau committed Jul 30, 2024
1 parent bfd8353 commit 3afdffc
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ function($f3) {
}
}

\Flash::instance()->setKey('shareinformations', true);

$f3->reroute($f3->get('REVERSE_PROXY_URL').'/signature/'.$hash.$symmetricKey);
}

Expand Down
3 changes: 3 additions & 0 deletions templates/signature.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@
var maxPage = <?php echo $maxPage ?>;
var sharingMode = <?php echo intval(!isset($noSharingMode)) ?>;
var pdfHash = null;
<?php if(Flash::instance()->getKey('shareinformations')): ?>
alert('showinfos');
<?php endif; ?>
var direction = '<?php echo $DIRECTION_LANGUAGE ?>';
<?php if(isset($hash)): ?>
pdfHash = "<?php echo $hash ?>";
Expand Down
105 changes: 105 additions & 0 deletions vendor/fatfree/flash.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?php
/**
* Flash - A Flash Messages Plugin for the PHP Fat-Free Framework
*
* The contents of this file are subject to the terms of the GNU General
* Public License Version 3.0. You may not use this file except in
* compliance with the license. Any of the license terms and conditions
* can be waived if you get permission from the copyright holder.
*
* Copyright (c) 2020 ~ ikkez
* Christian Knuth <[email protected]>
* https://github.com/ikkez/F3-Sugar/
*
* @version 1.0.2
* @date: 13.12.2020
* @since: 21.01.2015
**/

class Flash extends \Prefab {

/** @var \Base */
protected $f3;

/** @var array */
protected $msg;

/** @var array */
protected $key;

/**
* Flash constructor.
* @param string $key
*/
public function __construct($key='flash') {
$this->f3 = \Base::instance();
$this->msg = &$this->f3->ref('SESSION.'.$key.'.msg');
$this->key = &$this->f3->ref('SESSION.'.$key.'.key');
}

/**
* add a message to the stack
* @param $text
* @param string $status
*/
public function addMessage($text,$status='info') {
$this->msg[] = ['text'=>$text,'status'=>$status];
}

/**
* dump all messages and clear them
* @return array
*/
public function getMessages() {
$out = $this->msg;
$this->clearMessages();
return $out ?: [];
}

/**
* reset message stack
*/
public function clearMessages() {
$this->msg = [];
}

/**
* check if there messages in the stack
* @return bool
*/
public function hasMessages() {
return !empty($this->msg);
}

/**
* set a flash key
* @param $key
* @param bool $val
*/
public function setKey($key,$val=TRUE) {
$this->key[$key] = $val;
}

/**
* get and clear a flash key, if it's existing
* @param $key
* @return mixed|null
*/
public function getKey($key) {
$out = NULL;
if ($this->hasKey($key)) {
$out = $this->key[$key];
unset($this->key[$key]);
}
return $out;
}

/**
* check if there's a flash key existing
* @param $key
* @return bool
*/
public function hasKey($key) {
return ($this->key && array_key_exists($key, $this->key));
}
}

0 comments on commit 3afdffc

Please sign in to comment.