<?php 
global $myUser;
User::check_access('factory','read');
require_once(__DIR__.SLASH.'Template.class.php');
?>
<div  id="factoryForm"  data-action="factory_render">
<div class="row">
	<div class="col-xl-12 form-inline">
		<label>Template</label> 
		<select class="form-control ml-2" id="template" onchange="factory_change_template(event);">
			<option value="">-</option>
			<?php foreach(glob(Template::dir().'*') as $tpl): ?>
			<option value="<?php echo basename($tpl); ?>"><?php echo basename($tpl); ?></option>
			<?php endforeach; ?>
		</select>
	</div>
</div>
<div class="row">
	<div class="col-xl-5">
		
			<h4>Plugin</h4>
			
			<input type="text" class="form-control" placeholder="Nom du plugin" id="plugin">
			
			<input type="text" class="form-control mt-2" placeholder="Description courte (optionnel)" id="description">
		

			<h4 class="mt-4">Entité</h4>
			<div class="list-group">
				
				<span class="list-group-item">
					<input type="text" class="form-control" placeholder="Nom de l'entité" id="entity">
				</span>
				<!-- champ d'entité -->
				<div class="list-group-item field">
					<div class="row">

						<div class="col-xl-4">
							<input type="text" class="form-control input-small fieldSlug" placeholder="slug"> 
						</div> 
						<div class="col-xl-4">
							<input type="text" class="form-control input-small fieldLabel" placeholder="Libellé"> 
						</div> 
						<div class="col-xl-4">
							<select class="form-control input-small fieldType" >
								<?php foreach(Template::types() as $key=>$value): ?>
									<option value="<?php echo $key; ?>"><?php echo $value['label']; ?></option>
								<?php endforeach; ?>

							</select>
						</div>

					</div>
				</div>
			</div>
		
		<br>
		<div id="factoryFilters">
			<h4 class="hidden">Options</h4>
			<ul class="list-group">
				<li class="hidden list-group-item">
					<input onchange="factory_render()" data-section="{{section}}" data-checked="{{checked}}" type="checkbox" name="{{section}}" id="{{section}}" data-type="checkbox">
					<label for="{{section}}">{{section}}</label>
				</li>
			</ul>
		</div>

		<hr/>
		<a href="#" class="pointer" onclick="$(this).next().slideToggle(200);">Voir les conventions de nommage</a>
		<div class="hidden">
			<h5>Conventions de nommage</h5>
			<ul>
				<li><strong>Méthode et fonctions</strong> <code>function get_users(){}</code> - Séparation par "_" et tout en minuscule</li>
				<li><strong>Classes</strong> <code>class MaClasse {}</code> - Séparation par camelCase et premiere lettre en majuscule</li>
				<li><strong>Variables</strong> <code>$maVariable</code> - Séparation par camelCase tout en minuscule</li>
				<li><strong>Constantes</strong> <code>const MA_CONSTANTE</code> - Séparation par "_"tout en majuscule</li>
				<li><strong>Classes css et id css</strong> <code>.ma-classe {} #mon-id{}</code> - Séparation par tiret tout en minuscule</li>
				<li><strong>Actions</strong> <code>case 'plugin_entite_action'</code> - Séparation par "_" en minuscule</li>
			</ul>
		</div>
	</div>
	<div class="col-xl-7">
		<ul class="nav nav-tabs" id="factoryParts">
			<li class="nav-item hidden">
				<a class="nav-link {{#active}}active{{/active}}" data-part="{{label}}"  data-langage="{{syntax}}"  href="#">{{label}}</a>
			</li>


		</ul>
		<div id="factory-generate-button" class="btn btn-primary mb-2 mt-2 float-left" onclick="factory_render(event,1)"><i class="fas fa-cogs"></i> Générer</div>
		<div  class="btn btn-info ml-2 mb-2 mt-2 float-left" onclick="copy_to_clipboard($('#factoryCode'));"><i class="fas fa-copy"></i> Copier</div>

		<span id="factory-generate-message"></span>
		<div class="clear"></div>
		<pre><code id="factoryCode" onclick="select_text($('#factoryCode'))" class="php"></code></pre>
	</div>
</div>
</div>
<br/>

<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/monokai-sublime.min.css">

<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/languages/php.min.js"></script>



