Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • cGuiBackendHelpbox
  • cGuiFileOverview
  • cGuiFoldingRow
  • cGuiList
  • cGuiMenu
  • cGuiNavigation
  • cGuiNotification
  • cGuiObjectPager
  • cGuiPage
  • cGuiScrollList
  • cGuiSourceEditor
  • cGuiTableForm
  • cGuiTree
  • cPager
  • cTemplate
  • cTree
  • cTreeItem
  • NoteLink
  • NoteList
  • NoteListItem
  • NoteView
  • TODOLink
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: 
  3: /**
  4:  * This file contains the notification GUI class.
  5:  *
  6:  * @package          Core
  7:  * @subpackage       GUI
  8:  *
  9:  * @author           Timo Hummel
 10:  * @copyright        four for business AG <www.4fb.de>
 11:  * @license          http://www.contenido.org/license/LIZENZ.txt
 12:  * @link             http://www.4fb.de
 13:  * @link             http://www.contenido.org
 14:  */
 15: 
 16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 17: 
 18: /**
 19:  * Class for displaying notifications.
 20:  *
 21:  * Usage:
 22:  * <code>
 23:  * // render a error directly
 24:  * $oNotification = new cGuiNotification();
 25:  * $oNotification->displayNotification(
 26:  *     cGuiNotification::LEVEL_ERROR, 'Foobar does not exists'
 27:  * );
 28:  *
 29:  * // assign a notification to a variable
 30:  * $oNotification = new cGuiNotification();
 31:  * $sNotification = $oNotification->displayNotification(
 32:  *     cGuiNotification::LEVEL_NOTIFICATION, 'Hey dude, you did it!'
 33:  * );
 34:  * </code>
 35:  *
 36:  * @package    Core
 37:  * @subpackage GUI
 38:  */
 39: class cGuiNotification {
 40: 
 41:     /**
 42:      * Error message level.
 43:      *
 44:      * @var string
 45:      */
 46:     const LEVEL_ERROR = 'error';
 47: 
 48:     /**
 49:      * Warning message level.
 50:      *
 51:      * @var string
 52:      */
 53:     const LEVEL_WARNING = 'warning';
 54: 
 55:     /**
 56:      * Info message level.
 57:      *
 58:      * @var string
 59:      */
 60:     const LEVEL_INFO = 'info';
 61: 
 62:     /**
 63:      * Ok message level.
 64:      *
 65:      * @var string
 66:      */
 67:     const LEVEL_OK = 'ok';
 68: 
 69:     /**
 70:      * Notification message level.
 71:      *
 72:      * @var string
 73:      */
 74:     const LEVEL_NOTIFICATION = 'notification';
 75: 
 76:     /**
 77:      * HTML path to images.
 78:      *
 79:      * @var string
 80:      */
 81:     protected $_sPathImages;
 82: 
 83:     /**
 84:      * Constructor to create an instance of this class.
 85:      */
 86:     public function __construct() {
 87:         global $cfg;
 88:         $this->_sPathImages = cRegistry::getBackendUrl() . $cfg['path']['images'];
 89:     }
 90: 
 91:     /**
 92:      * Generates message box and returns it back.
 93:      *
 94:      * @param string $sLevel
 95:      *         Message level, one of cGuiNotification::LEVEL_* constants
 96:      * @param string $sMessage
 97:      *         The message to display
 98:      * @param int $iStyle [optional]
 99:      *         Flag tp use styles for display or not (feasible 1 or 0)
100:      * @return string
101:      */
102:     public function returnMessageBox($sLevel, $sMessage, $iStyle = 1) {
103:         switch ($sLevel) {
104:             case self::LEVEL_ERROR:
105:                 $sHead = i18n('Error');
106:                 $sHeadClass = 'alertbox_error';
107:                 break;
108:             case self::LEVEL_WARNING:
109:                 $sHead = i18n('Warning');
110:                 $sHeadClass = 'alertbox_warning';
111:                 break;
112:             case self::LEVEL_INFO:
113:                 $sHead = i18n('Info');
114:                 $sHeadClass = 'alertbox_info';
115:                 $sMessage = '<span>' . $sMessage . '</span>';
116:                 break;
117:             case self::LEVEL_OK:
118:                 $sHead = i18n('Ok');
119:                 $sHeadClass = 'alertbox_ok';
120:                 $sMessage = '<span>' . $sMessage . '</span>';
121:                 break;
122:             default:
123:                 $sHead = i18n('Notification');
124:                 $sHeadClass = 'alertbox_notification';
125:                 $sMessage = '<span>' . $sMessage . '</span>';
126:                 break;
127:         }
128: 
129:         if ($iStyle == 1) {
130:             // Box on login page
131:             $sMessageBox =
132:                     '<div class="alertbox ' . $sHeadClass . '_color" id="contenido_notification">' .
133:                     '<h1 class="alertbox_head ' . $sHeadClass . '">' . $sHead . '</h1>' .
134:                     '<div class="alertbox_message">' . $sMessage . '</div>' .
135:                     '</div>';
136:         } else {
137:             // Simple box
138:             $sMessageBox =
139:                     '<div class="alertbox_line ' . $sHeadClass . '_color" id="contenido_notification">' .
140:                     '<h1 class=" alertbox_head ' . $sHeadClass . ' ' . $sHeadClass . '_color">' . $sHead . '</h1>' .
141:                     '<div class="alertbox_message ' . $sHeadClass . '_color">' . $sMessage . '</div>' .
142:                     '</div>';
143:         }
144:         return $sMessageBox;
145:     }
146: 
147:     /**
148:      * Generates message box and returns it back, uses markup with table.
149:      *
150:      * @param string $sLevel
151:      *         Message level, one of cGuiNotification::LEVEL_* constants
152:      * @param string $sMessage
153:      *         The message to display
154:      * @return string
155:      */
156:     public function returnNotification($sLevel, $sMessage) {
157: 
158:         $oNotifySpan = new cHTMLSpan($sMessage);
159: 
160:         switch ($sLevel) {
161:             case self::LEVEL_ERROR:
162:                 $oNotifySpan->setClass('notify_general notify_error');
163:                 break;
164:             case self::LEVEL_WARNING:
165:                 $oNotifySpan->setClass('notify_general notify_warning');
166:                 break;
167:             case self::LEVEL_INFO:
168:                 $oNotifySpan->setClass('notify_general notify_info');
169:                 break;
170:             case self::LEVEL_OK:
171:                 $oNotifySpan->setClass('notify_general notify_ok');
172:                 break;
173:             default:
174:                 $oNotifySpan->setClass('notify_general notify_default');
175:                 break;
176:         }
177: 
178:         $sNoti = '<div id="contenido_notification">';
179:         $sNoti .= $oNotifySpan->toHtml();
180:         $sNoti .= '</div>';
181: 
182:         return $sNoti;
183:     }
184: 
185:     /**
186:      * Displays small message box directly.
187:      *
188:      * @param string $sLevel
189:      *         Message level, one of cGuiNotification::LEVEL_* constants
190:      * @param string $sMessage
191:      *         The message to display
192:      */
193:     public function displayNotification($sLevel, $sMessage) {
194:         echo $this->returnNotification($sLevel, $sMessage) . '<br>';
195:     }
196: 
197:     /**
198:      * Displays large message box directly.
199:      *
200:      * @param string $sLevel
201:      *         Message level, one of cGuiNotification::LEVEL_* constants
202:      * @param string $sMessage
203:      *         The message to display
204:      * @param int $iStyle [optional]
205:      *         Flag tp use styles for display or not (feasible 1 or 0)
206:      */
207:     public function displayMessageBox($sLevel, $sMessage, $iStyle = 1) {
208:         echo $this->returnMessageBox($sLevel, $sMessage, $iStyle) . '<br>';
209:     }
210: 
211: }
212: 
CMS CONTENIDO 4.9.11 API documentation generated by ApiGen 2.8.0