<?php defined('KOBLOG') or die('Koblog CMS.'); ?>

<?php echo Bootstrap::formOpen(array('id'=>'jsform', 'class'=>'plugin-form')); ?>

<?php 
	$returnPage = "plugins";

	switch ($plugin->type()) {
		case 'theme':
			$returnPage = "themes";
			break;
		case 'widget':
			$returnPage = "sidebar";
			break;
		default:
			break;
	}
?>

<div class="d-flex justify-content-between mb-2">
	<?php echo Bootstrap::pageTitle(array('title'=>$plugin->name(), 'icon'=>'cog')); ?>
	<?php if ($plugin->formButtons()): ?>
	<div>
		<button type="submit" class="btn btn-primary" name="save"><?php $L->p('Save') ?></button>
		<a class="btn btn-secondary" href="<?php echo HTML_PATH_ADMIN_ROOT.$returnPage ?>" role="button"><?php $L->p('Cancel') ?></a>
	</div>
	<?php endif; ?>
</div>

<?php if ($plugin->description()): ?>
	<p class="alert alert-primary">
	<?php echo $plugin->description(); ?>
	</p>
<?php endif; ?>

<?php
		// Token CSRF
		echo Bootstrap::formInputHidden(array(
			'name'=>'tokenCSRF',
			'value'=>$security->getTokenCSRF()
		));
?>

<div class="card">
	<div class="card-body plugin-form">
	<?php

		// Print the plugin form
		echo $plugin->form();
	?>

	<?php echo Bootstrap::formClose(); ?>
	</div>
</div>