Project

General

Profile

« Previous | Next » 

Revision 69a17c90

Added by Thane Gill over 10 years ago

Use Modal class for notices

View differences:

usr/local/www/head.inc
299 299
		</div>
300 300
		<div class="collapse navbar-collapse" id="pf-navbar">
301 301
			<ul class="nav navbar-nav">
302
		<?php foreach ([
303
				['name' => 'System',      'menu' => $system_menu,      'href' => null],
304
				['name' => 'Interfaces',  'menu' => $interfaces_menu,  'href' => null],
305
				['name' => 'Firewall',    'menu' => $firewall_menu,    'href' => null],
306
				['name' => 'Services',    'menu' => $services_menu,    'href' => null],
307
				['name' => 'VPN',         'menu' => $vpn_menu,         'href' => null],
308
				['name' => 'Status',      'menu' => $status_menu,      'href' => null],
309
				['name' => 'Diagnostics', 'menu' => $diagnostics_menu, 'href' => null],
310
				['name' => 'Gold',        'menu' => $gold_menu,        'href' => '_blank'],
311
				['name' => 'Help',        'menu' => $help_menu,        'href' => '_blank']
312
			] as $item):
313
				if ($item['name'] == 'Help' && $g['disablehelpmenu']) {
314
					continue;
315
				} ?>
302
			<?php foreach ([
303
					['name' => 'System',      'menu' => $system_menu,      'href' => null],
304
					['name' => 'Interfaces',  'menu' => $interfaces_menu,  'href' => null],
305
					['name' => 'Firewall',    'menu' => $firewall_menu,    'href' => null],
306
					['name' => 'Services',    'menu' => $services_menu,    'href' => null],
307
					['name' => 'VPN',         'menu' => $vpn_menu,         'href' => null],
308
					['name' => 'Status',      'menu' => $status_menu,      'href' => null],
309
					['name' => 'Diagnostics', 'menu' => $diagnostics_menu, 'href' => null],
310
					['name' => 'Gold',        'menu' => $gold_menu,        'href' => '_blank'],
311
					['name' => 'Help',        'menu' => $help_menu,        'href' => '_blank']
312
				] as $item):
313
					if ($item['name'] == 'Help' && $g['disablehelpmenu']) {
314
						continue;
315
					} ?>
316 316
				<li class="dropdown">
317 317
					<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
318 318
						<?=gettext($item['name'])?>
......
320 320
					</a>
321 321
					<ul class="dropdown-menu" role="menu"><?=output_menu($item['menu'], $item['href'])?></ul>
322 322
				</li>
323
		<?php endforeach?>
323
			<?php endforeach?>
324 324
				<?php if(are_notices_pending()):?>
325 325
					<?php $notices = get_notices()?>
326 326
					<li class="dropdown">
......
328 328
							<span class="badge"><?=count($notices)?></span>
329 329
						</a>
330 330
					</li>
331
				<?php endif?>
331
					<?php
332
					require_once('classes/Modal.class.php');
333

  
334
					$modal_notices = new Modal('Notices', 'notices', 'large');
335

  
336
					$modal_notices->addFooter(new Form_Button(
337
						'close',
338
						'Close',
339
						''
340
					))->setAttribute('data-dismiss', 'modal');
341

  
342
					$modal_notices->addFooter(new Form_Button(
343
						'mark_all_as_read',
344
						'Mark all as read',
345
						'/?closenotice=all'
346
					))->addClass('btn-primary')->removeClass('btn-default');
347

  
348
					$noticeCategories = $notice['category'];
349
					foreach($notices as $time => $notice) {
350
						if (!isset($noticeCategories[$notice['category']])) {
351
							$noticeCategories[ $notice['category'] ] = array();
352
						}
353
						$notice['time'] = $time;
354
						array_push($noticeCategories[$notice['category']], $notice);
355
					}
356

  
357
					foreach($noticeCategories as $category => $catNotices) {
358
						$html .= "<h4>{$category}</h4>";
359
						$html .= '<ul>';
360
						foreach($catNotices as $notice) {
361
							$html .= '<li>';
362
							if (!empty($notice['url'])) {
363
								$html .= "<a href=\"{$notice['url']}\">{$notice['id']}</a> - ";
364
							}
365
							$html .= "{$notice['notice']}<i> @ " . date('Y-m-d H:i:s', $notice['time']) . '</i>';
366
							$html .= '</li>';
367
						}
368
						$html .= '</ul>';
369
					}
370
					$modal_notices->addHtml($html);
371
					print $modal_notices;
372

  
373
				endif;
374
				?>
332 375
			</ul>
333 376
		</div>
334 377
	</div>
335

  
336
	<div class="modal fade" id="notices" role="dialog" aria-labelledby="noticesTitle" aria-hidden="true">
337
		<div class="modal-dialog">
338
			<div class="modal-content">
339
				<div class="modal-header">
340
					<button type="button" class="close" data-dismiss="modal" aria-label="Close">
341
						<span aria-hidden="true">&times;</span>
342
					</button>
343

  
344
					<h3 class="modal-title" id="myModalLabel">Notices</h3>
345
				</div>
346

  
347
				<div class="modal-body">
348
<?php
349
$noticeCategories = array();
350
foreach($notices as $time => $notice)
351
{
352
	if (!isset($noticeCategories[ $notice['category'] ]))
353
		$noticeCategories[ $notice['category'] ] = array();
354

  
355
	$notice['time'] = $time;
356
	array_push($noticeCategories[ $notice['category'] ], $notice);
357
}
358

  
359
foreach($noticeCategories as $category => $catNotices):?>
360
	<h4><?=$category?></h4>
361
	<ul>
362
<?php
363
	foreach($catNotices as $notice):
364
?>
365
	<li>
366
		<b>
367
<?php if (!empty($notice['url'])):?>
368
		<a href="<?=$notice['url']?>"><?=$notice['id']?></a> -
369
<?php endif;?>
370
		</b>
371
		<?=$notice['notice']?>
372
		<i>@ <?=date('Y-m-d H:i:s', $notice['time'])?></i>
373
	</li>
374
<?php 	endforeach;?>
375
</ul>
376
<?php endforeach;?>
377
				</div>
378

  
379
				<div class="modal-footer">
380
					<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
381
					<a type="button" class="btn btn-primary" href="/?closenotice=all">Mark all as read</a>
382
				</div>
383
			</div>
384
		</div>
385
	</div>
386

  
387 378
</nav>
388 379
<div class="container">
389 380
	<header class="header">
390 381
		<?=genhtmltitle($pgtitle)?>
391 382
		<ul class="context-links">
392 383
<?php
393

  
394 384
if (!$hide_service_status && !empty($shortcuts[$shortcut_section]['service'])) {
395 385
	$ssvc = array();
396 386
	switch ($shortcut_section) {
......
402 392
			break;
403 393
		default:
404 394
			$ssvc = find_service_by_name($shortcuts[$shortcut_section]['service']);
405

  
406 395
	}
407 396
	if (!empty($ssvc)) {
408 397
		// echo '<li>'. get_service_status_icon($ssvc, false). '</li>'; TODO: Add missing function

Also available in: Unified diff