-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
80d59ba
commit ca527fe
Showing
9 changed files
with
168 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
session_start(); | ||
|
||
require_once __DIR__ . '/../vendor/autoload.php'; | ||
|
||
flash()->error(['Invalid email!', 'Invalid username!']) | ||
->warning('Warning message.') | ||
->info('Info message.') | ||
->success('Success message!'); | ||
|
||
flash()->setTemplate(new \Tamtamchik\SimpleFlash\Templates\FoundationTemplate()); | ||
|
||
?> | ||
|
||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Test Foundation 3 default template.</title> | ||
<!-- Latest compiled and minified CSS --> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/foundation/5.5.2/css/foundation.min.css"> | ||
</head> | ||
<body> | ||
|
||
<br/> | ||
|
||
<div class="row" style="width: 600px;"> | ||
<?= flash() ?> | ||
</div> | ||
|
||
<!-- Latest compiled and minified JavaScript --> | ||
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/5.5.2/js/foundation.min.js"></script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
|
||
namespace Tamtamchik\SimpleFlash; | ||
|
||
abstract class BaseTemplate implements TemplateInterface | ||
{ | ||
protected $prefix = '<p>'; | ||
protected $postfix = '</p>'; | ||
protected $wrapper = '<div class="alert alert-%s" role="alert">%s</div>'; | ||
|
||
/** | ||
* @param $message - message text | ||
* | ||
* @return string | ||
*/ | ||
public function wrapMessage($message) | ||
{ | ||
return $this->getPrefix() . $message . $this->getPostfix(); | ||
} | ||
|
||
/** | ||
* @param $messages - message text | ||
* @param $type - message type: success, info, warning, danger | ||
* | ||
* @return string | ||
*/ | ||
public function wrapMessages($messages, $type) | ||
{ | ||
return sprintf($this->getWrapper(), ($type == 'error') ? 'danger' : $type, $messages); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getPrefix() | ||
{ | ||
return $this->prefix; | ||
} | ||
|
||
/** | ||
* @param string $prefix | ||
*/ | ||
public function setPrefix($prefix) | ||
{ | ||
$this->prefix = $prefix; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getPostfix() | ||
{ | ||
return $this->postfix; | ||
} | ||
|
||
/** | ||
* @param string $postfix | ||
*/ | ||
public function setPostfix($postfix) | ||
{ | ||
$this->postfix = $postfix; | ||
} | ||
|
||
/** | ||
* @param string $wrapper | ||
*/ | ||
public function setWrapper($wrapper) | ||
{ | ||
$this->wrapper = $wrapper; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getWrapper() | ||
{ | ||
return $this->wrapper; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.