| 1 | <?php
|
|---|
| 2 | /**
|
|---|
| 3 | * Message functions, i.e. for the red and green success and error messages
|
|---|
| 4 | *
|
|---|
| 5 | * PHP version 5
|
|---|
| 6 | *
|
|---|
| 7 | * LICENSE: Hotaru CMS is free software: you can redistribute it and/or
|
|---|
| 8 | * modify it under the terms of the GNU General Public License as
|
|---|
| 9 | * published by the Free Software Foundation, either version 3 of
|
|---|
| 10 | * the License, or (at your option) any later version.
|
|---|
| 11 | *
|
|---|
| 12 | * Hotaru CMS is distributed in the hope that it will be useful, but WITHOUT
|
|---|
| 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|---|
| 14 | * FITNESS FOR A PARTICULAR PURPOSE.
|
|---|
| 15 | *
|
|---|
| 16 | * You should have received a copy of the GNU General Public License along
|
|---|
| 17 | * with Hotaru CMS. If not, see http://www.gnu.org/licenses/.
|
|---|
| 18 | *
|
|---|
| 19 | * @category Content Management System
|
|---|
| 20 | * @package HotaruCMS
|
|---|
| 21 | * @author Nick Ramsay <admin@hotarucms.org>
|
|---|
| 22 | * @copyright Copyright (c) 2009, Hotaru CMS
|
|---|
| 23 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
|
|---|
| 24 | * @link http://www.hotarucms.org/
|
|---|
| 25 | */
|
|---|
| 26 | class Messages
|
|---|
| 27 | {
|
|---|
| 28 | /**
|
|---|
| 29 | * Display a SINGLE success or failure message
|
|---|
| 30 | *
|
|---|
| 31 | * @param object $h
|
|---|
| 32 | * @param string $msg
|
|---|
| 33 | * @param string $msg_type ('green' or 'red')
|
|---|
| 34 | *
|
|---|
| 35 | * Usage:
|
|---|
| 36 | * Longhand:
|
|---|
| 37 | * $this->hotaru->message = "This is a message";
|
|---|
| 38 | * $this->hotaru->messageType = "green";
|
|---|
| 39 | * $this->hotaru->showMessage();
|
|---|
| 40 | *
|
|---|
| 41 | * Shorthand:
|
|---|
| 42 | * $this->hotaru->showMessage("This is a message", "green");
|
|---|
| 43 | */
|
|---|
| 44 | public function showMessage($h, $msg = '', $msg_type = 'green')
|
|---|
| 45 | {
|
|---|
| 46 | if ($msg != '') {
|
|---|
| 47 | echo "<div class='message " . $msg_type . "'>" . $msg . "</div>";
|
|---|
| 48 | } elseif ($h->message != '') {
|
|---|
| 49 | echo "<div class='message " . $h->messageType . "'>" .
|
|---|
| 50 | $h->message . "</div>";
|
|---|
| 51 | }
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 | /**
|
|---|
| 56 | * Displays ALL success or failure messages
|
|---|
| 57 | *
|
|---|
| 58 | * @param object $h
|
|---|
| 59 | *
|
|---|
| 60 | * Usage:
|
|---|
| 61 | * $this->hotaru->messages['This is a message'] = "green";
|
|---|
| 62 | * $this->hotaru->showMessages();
|
|---|
| 63 | */
|
|---|
| 64 | public function showMessages($h)
|
|---|
| 65 | {
|
|---|
| 66 | if ($h->messages) {
|
|---|
| 67 | foreach ($h->messages as $msg => $msg_type) {
|
|---|
| 68 | echo "<div class='message " . $msg_type . "'>" .
|
|---|
| 69 | $msg . "</div>";
|
|---|
| 70 | }
|
|---|
| 71 | }
|
|---|
| 72 | }
|
|---|
| 73 | }
|
|---|
| 74 | ?>
|
|---|