Browse Source

remove old crap

idleman 4 years ago
parent
commit
ed965db5ae

+ 0 - 94
plugin/factory/Template.class.php

@@ -1,94 +0,0 @@
-<?php
- 	class Template{
- 		public static function all($template){
- 			$templates = array();
-
- 			foreach (glob(self::dir($template).'*') as $path) {
- 				$relativePath = str_replace(self::dir($template),'',$path);
- 				if(is_file($path)){
- 					$f = fopen($path, 'r');
-					$line = fgets($f);
-					fclose($f);
-					$infos = json_decode($line,true);
- 					
- 					$templates[$infos['label']] = array('file'=>$path,'syntax'=>$infos['syntax']);
- 				}else{
- 					$templates = array_merge($templates,self::all($template.SLASH.$relativePath));
- 				}
- 			}
-
- 			return $templates;
- 		}
-
- 		public static function dir($tpl = null){
- 			return __DIR__.SLASH.'template'.SLASH.(isset($tpl)? $tpl.SLASH:'');
- 		}
-
- 		public static function types(){
-	 		$types = array(
-			    'string' => array(
-			    	'label'=>'Texte',
-			    	'sql-type'=>'string',
-			    	'input'=>'<input id="{{key}}" name="{{key}}" class="form-control" placeholder="" value="<?php echo ${{entity}}->{{key}}; ?>" type="text">'),
-			    'user' => array(
-			    	'label'=>'Utilisateur',
-			    	'sql-type'=>'string',
-			    	'input'=>'<input id="{{key}}" name="{{key}}" data-type="user" class="form-control" placeholder="" value="<?php echo ${{entity}}->{{key}}; ?>" type="text">'),
-			    'longstring' => array(
-			    	'label'=>'Texte Long',
-			    	'sql-type'=>'longstring',
-			    	'input'=>'<textarea id="{{key}}" name="{{key}}" class="form-control"><?php echo ${{entity}}->{{key}}; ?></textarea>'),
-			    'wysiwyg' => array(
-			    	'label'=>'WYSIWYG',
-			    	'sql-type'=>'longstring',
-			    	'input'=>'<textarea id="{{key}}" data-type="wysiwyg" name="{{key}}" class="form-control"><?php echo ${{entity}}->{{key}}; ?></textarea>'),
-			    'date' => array(
-			    	'label'=>'Date',
-			    	'sql-type'=>'date',
-			    	'input'=>'<input id="{{key}}" name="{{key}}" data-type="date"  title="format jj/mm/aaaa" class="form-control" placeholder="JJ/MM/AAAA" value="<?php echo ${{entity}}->{{key}}; ?>" type="text">'),
-			    'hour' => array(
-			    	'label'=>'Heure',
-			    	'sql-type'=>'string',
-			    	'input'=>'<input id="{{key}}" name="{{key}}" data-type="hour" title="format hh:mm" class="form-control" placeholder="13:37" value="<?php echo ${{entity}}->{{key}}; ?>" type="text">'),
-			    'dictionnary' => array(
-			    	'label'=>'Liste configurable',
-			    	'sql-type'=>'int',
-			    	'input'=>'<select data-type="dictionnary" data-slug="{{key}}" data-depth="1" data-disable-label data-value="<?php echo ${{entity}}->{{key}}; ?>" class="form-control select-control" name="{{key}}" id="{{key}}"></select>'),
-			    'int' => array(
-			    	'label'=>'Entier',
-			    	'sql-type'=>'int',
-			    	'input'=>'<input id="{{key}}" name="{{key}}" class="form-control" placeholder="" value="<?php echo ${{entity}}->{{key}}; ?>" type="number">'),
-			    'float' => array(
-			    	'label'=>'Décimal',
-			    	'sql-type'=>'float',
-			    	'input'=>'<input id="{{key}}" name="{{key}}" class="form-control" placeholder="" value="<?php echo ${{entity}}->{{key}}; ?>" type="text">'),
-			    'address' => array(
-			    	'label'=>'Adresse',
-			    	'sql-type'=>'longstring',
-			    	'input'=>'<input id="{{key}}" name="{{key}}" data-type="location" class="form-control" placeholder="" value="<?php echo ${{entity}}->{{key}}; ?>" type="text">'),
-			    'password' => array(
-			    	'label'=>'Mot de passe',
-			    	'sql-type'=>'string',
-			    	'input'=>'<input id="{{key}}" name="{{key}}" data-type="password" class="form-control" placeholder="" value="<?php echo ${{entity}}->{{key}}; ?>" type="text">'),
-			    'icon' => array(
-			    	'label'=>'Icône',
-			    	'sql-type'=>'string',
-			    	'input'=>'<input id="{{key}}" name="{{key}}" data-type="icon" class="form-control" placeholder="" value="<?php echo ${{entity}}->{{key}}; ?>" type="text">'),
-			    'decimal' => array(
-			    	'label'=>'Prix',
-			    	'sql-type'=>'decimal',
-			    	'input'=>'<input id="{{key}}" name="{{key}}" class="form-control" placeholder="" value="<?php echo ${{entity}}->{{key}}; ?>" type="text">'),
-			    'boolean' => array(
-			        'label'=>'Booléen',
-			        'sql-type'=>'boolean',
-			        'input'=>'<input title="" type="checkbox" name="<?php echo ${{entity}}->{{key}}; ?>" id="<?php echo ${{entity}}->{{key}}; ?>" data-class="" data-type="checkbox">'),
-			    'mail' => array(
-			    	'label'=>'E-mail',
-			    	'sql-type'=>'string',
-			    	'input'=>'<input id="{{key}}" name="{{key}}" data-type="mail" pattern=".+@.+" class="form-control" placeholder="" value="<?php echo ${{entity}}->{{key}}; ?>" type="email">'),
-			  );
-	 		return $types;
- 		}
-
- 	}
-?>

+ 0 - 210
plugin/factory/action.php

@@ -1,210 +0,0 @@
-<?php
-global $_,$conf;
-switch($_['action']){
-
-	case 'factory_search_part':
-		Action::write(function(&$response){
-			global $myUser,$_;
-			require_once(__DIR__.SLASH.'Template.class.php');
-			$i = 0;
-			foreach(Template::all($_['template']) as $key=>$template): 
-				$response['rows'][] = array(
-					'active' => $i==0,
-					'langage' =>  $template['syntax'],
-					'label' => $key
-				);
-				$i++; 
-			endforeach; 
-		});
-	break;
-
-	case 'factory_search_filters':
-		Action::write(function(&$response){
-			global $myUser,$_;
-			require_once(__DIR__.SLASH.'Template.class.php');
-			$response['rows']  = array();
-		
-			$sections = array();
-			foreach (Template::all($_['template']) as $template) {
-				$stream = file_get_contents($template['file']);
-				preg_match_all('/{{~!?([^}]*)}}/i', $stream, $matches,PREG_SET_ORDER);
-				
-				foreach($matches as $section)
-					$sections[] = array('section'=>trim($section[1]));
-			}
-			
-			$sections = array_map("unserialize", array_unique(array_map("serialize", $sections)));
-			sort($sections);
-			$response['rows'] = $sections;
-		});
-	break;
-
-	case 'factory_autocomplete_plugin':
-		Action::write(function(&$response){
-			global $myUser,$_;
-			$response['rows']  = array();
-			foreach(glob(__ROOT__.PLUGIN_PATH.'*') as $plugin){
-				if(!is_dir($plugin)) continue;
-				$plugin = basename($plugin);
-				if(preg_match('|'.$_['keyword'].'|i', $plugin)) $response['rows'][] = array('name'=>$plugin,'value'=>$plugin);
-			}
-		});
-	break;
-
-	case 'factory_entity_search':
-		Action::write(function(&$response){
-			global $myUser,$_;
-			$response['rows']  = array();
-
-			foreach(glob(__ROOT__.PLUGIN_PATH.$_['plugin'].SLASH.'*.class.php') as $entity){
-				if(is_dir($entity)) continue;
-				$entity = str_replace('.class.php','',basename($entity));
-				
-				$response['rows'][] = $entity;
-			}
-		});
-	break;
-
-	case 'factory_autocomplete_entity':
-		Action::write(function(&$response){
-			global $myUser,$_;
-			$response['rows']  = array();
-
-			foreach(glob(__ROOT__.PLUGIN_PATH.$_['plugin'].SLASH.'*.class.php') as $entity){
-				if(is_dir($entity)) continue;
-				$entity = str_replace('.class.php','',basename($entity));
-				
-				if(preg_match('|'.$_['keyword'].'|i', $entity)) $response['rows'][] = array('name'=>$entity,'value'=>$entity);
-			}
-		});
-	break;
-	case 'factory_autocomplete_entity_select':
-		Action::write(function(&$response){
-			global $myUser,$_;
-			$response['rows']  = array();
-			$path = __ROOT__.PLUGIN_PATH.$_['plugin'].SLASH.$_['entity'].'.class.php';
-			if(!file_exists($path)) return;
-
-			//new version via fields object
-			require_once($path);
-			$item = new $_['entity']();
-			$sgbd = BASE_SGBD;
-			$types = array_keys($sgbd::types());
-			foreach ($item->fields as $field => $type) {
-				if(in_array($field, array('id', 'created', 'updated', 'creator', 'updater'))) continue;
-				if(!in_array($type, $types)) continue;
-				$response['rows'][] = array('label'=>$field, 'type'=>$type);
-			}
-
-			//Old version via preg_match
-			// $stream = file_get_contents($path);
-			// preg_match_all('|\'([^\']*)\' \=\> \'([^\']*)\',?|ism', $stream , $matches,PREG_SET_ORDER);
-			// foreach ($matches as $match) {
-			// 	if($match[1]=='id') continue;
-			// 	if(count($match)!=3) continue;
-			// 	$response['rows'][] = array('label' => $match[1],'type' => $match[2]);
-			// }
-		});
-	break;
-
-	case 'factory_render':
-		
-		global $myUser;
-		require_once(__DIR__.SLASH.'Template.class.php');
-
-		$entity = factory_sanitize($_['entity']);
-		$table = factory_sanitize($_['entity'], true);
-		$plugin = factory_sanitize($_['plugin']);
-		$description = isset($_['description']) ? $_['description'] : '';
-		$fields =  array();
-		$links =  array();
-		
-		$types = Template::types();
-
-		if(isset($_['fields'])){
-			foreach ($_['fields']  as $key => $value){
-				if($key=='' || $key==1)continue;
-				if($value['label']=='') $value['label'] = ucfirst($key);
-				
-				
-				$value['key'] = lcFirst(factory_sanitize($key));
-			
-				if(strpos($value['type'], 'entity-')!==false){
-					$type = $types['int'];
-					$links[] = array('key'=>$value['key'],'entity'=>str_replace('entity-','',$value['type']));
-				}else{
-					$type = $types[$value['type']];
-				}
-
-				$value['typeLabel'] = $type['label'];
-
-
-				$value['sql-type'] = $type['sql-type'];
-				$value['input'] = factory_render($type['input'],$value);
-
-				$fields[lcfirst(factory_sanitize($key))] = $value;
-			}
-		}
-		$filters = array();
-
-
-		if(isset($_['filters'])){
-			foreach ($_['filters']  as $key => $value){
-				if($value == '')continue;
-				$filters[] = $value;
-			}
-		}
-
-		$templates = Template::all($_['template']);
-		$template = $templates[$_['part']];
-
-
-		$data = array(
-			'Entity' => $entity,
-			'entity' => strtolower($entity),
-			'ENTITY' => strtoupper($entity),
-			'table' => $table,
-			'user.fullname' => $myUser->fullName(),
-			'user.mail' => $myUser->mail,
-			'plugin' => strtolower($plugin),
-			'PLUGIN' => strtoupper($plugin),
-			'Plugin' => ucfirst(strtolower($plugin)),
-			'fields' => $fields,
-			'links' => $links,
-			'linksCount' => count($links)> 0 ? 1: 0,
-			'filters' => $filters,
-			'description' => $description,
-		);
-
-		foreach(array('-','_','.') as $symbol){
-			$readable = factory_sanitize(str_replace(' ',$symbol,trim($_['entity'])),false,'_.-');
-			$readable = mb_strtolower($readable);
-			if(strpos($readable,$plugin.$symbol) === 0)
-				$readable = substr($readable, strlen($plugin.$symbol));
-
-			$data['entity'.$symbol.'readable'] = $readable;
-		}
-		
-		$stream = file($template['file']);
-		array_shift($stream);
-		$stream = implode($stream);
-		$stream = factory_render($stream,$data);
-		if(isset($_['generate']) && $_['generate']==1){
-
-			if(!isset($_['plugin']) || !isset($_['entity'])) return;
-
-			$relativePath = str_replace(Template::dir($_['template']),'',$template['file']);
-			$relativePath = factory_render($relativePath,$data);
-
-			$pluginPath = PLUGIN_PATH.strtolower($plugin);
-			$filePath = $pluginPath.SLASH.$relativePath;
-		
-			$parentFolder = dirname($filePath);
-			if(!file_exists($parentFolder)) mkdir($parentFolder,0755,true);
-			file_put_contents($filePath,$stream);
-		}
-		echo htmlentities($stream);
-	break;
-}
-
-?>

+ 0 - 12
plugin/factory/app.json

@@ -1,12 +0,0 @@
-{
-	"id": "fr.idleman.factory",
-	"name": "Factory",
-	"author" : {
-		"name" : "Valentin carruesco"
-	},
-	"version": "1.0",
-	"url": "http://idleman.fr",
-	"licence": {"name": "Copyright","url" : ""},
-	"description": "Outil d'aide à la creation d'entité et de plugin basé sur du template modifiable",
-	"require" : {}
-}

+ 0 - 23
plugin/factory/css/main.css

@@ -1,23 +0,0 @@
-#factoryFilters ul{
-	margin: 0;
-	padding: 0;
-	list-style-type: none;
-}
-#factoryFilters ul li{
-	padding:10px;
-}
-#factoryFilters ul li label{
-	margin:0;
-}
-
-#factory-generate-message{
-    padding: 15px;
-    display: inline-block;
-    color: green;
-    font-weight: bold;
-}
-
-#factoryParts .nav-item .nav-link{
-	font-size:13px;
-	padding: .25rem 0.7rem;
-}

+ 0 - 154
plugin/factory/factory.plugin.php

@@ -1,154 +0,0 @@
-<?php
-
-
-//Déclaration d'un item de menu dans le menu principal
-function factory_menu(&$menuItems){
-	global $_,$myUser;
-	if(!$myUser->can('factory','read')) return;
-	$menuItems[] = array(
-		'sort'=>100,
-		'url'=>'index.php?module=factory',
-		'label'=>'Factory',
-		'icon'=> 'fas fa-cube',
-		'color'=> '#ef1e4e'
-	);
-}
-
-
-
-//Cette fonction va generer une page quand on clique sur Modele dans menu
-function factory_page(){
-	global $_,$myUser;
-	if(!isset($_['module']) || $_['module'] !='factory') return;
-	$page = !isset($_['page']) ? 'factory' : $_['page'];
-	$file = __DIR__.SLASH.'page.'.$page.'.php';
-	if(!file_exists($file)) throw new Exception("Page ".$page." inexistante");
-	
-	require_once($file);
-}
-
-//Fonction executée lors de l'activation du plugin
-function factory_install($id){
-	if($id != 'fr.idleman.factory') return;
-	Entity::install(__DIR__);
-
-}
-
-//Fonction executée lors de la désactivation du plugin
-function factory_uninstall($id){
-	if($id != 'fr.idleman.factory') return;
-	Entity::uninstall(__DIR__);
-}
-
-
-//cette fonction comprends toutes les actions du plugin qui ne nécessitent pas de vue html
-function factory_action(){
-	require_once(__DIR__.SLASH.'action.php');
-}
-
-function factory_sanitize($text, $tableName=false,$allowChars='_'){
-	$returned = '';
-	foreach (explode(' ',trim($text)) as $word) {
-		$returned .= $tableName ? mb_strtolower($word).'_' : ucfirst(mb_strtolower($word));
-	}
-	if($tableName) $returned = rtrim($returned, '_');
-
-	$unwanted = array( 'Š'=>'S', 'š'=>'s', 'Ž'=>'Z', 'ž'=>'z', 'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A', 'Ä'=>'A', 'Å'=>'A', 'Æ'=>'A', 'Ç'=>'C', 'È'=>'E', 'É'=>'E',
-		'Ê'=>'E', 'Ë'=>'E', 'Ì'=>'I', 'Í'=>'I', 'Î'=>'I', 'Ï'=>'I', 'Ñ'=>'N', 'Ò'=>'O', 'Ó'=>'O', 'Ô'=>'O', 'Õ'=>'O', 'Ö'=>'O', 'Ø'=>'O', 'Ù'=>'U',
-		'Ú'=>'U', 'Û'=>'U', 'Ü'=>'U', 'Ý'=>'Y', 'Þ'=>'B', 'ß'=>'Ss', 'à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'a', 'å'=>'a', 'æ'=>'a', 'ç'=>'c',
-		'è'=>'e', 'é'=>'e', 'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', 'î'=>'i', 'ï'=>'i', 'ð'=>'o', 'ñ'=>'n', 'ò'=>'o', 'ó'=>'o', 'ô'=>'o', 'õ'=>'o',
-		'ö'=>'o', 'ø'=>'o', 'ù'=>'u', 'ú'=>'u', 'û'=>'u', 'ý'=>'y', 'þ'=>'b', 'ÿ'=>'y' );
-
-	$returned = strtr($returned, $unwanted);
-	return preg_replace('|[^a-z0-9'.preg_quote($allowChars).']|i','',$returned);
-}
-
-function factory_render($sql,$data=array()){
-
-
-	//filters
-	$sql = preg_replace_callback('/{{~(!)?([^}]*)}}(.*?){{\/~}}/is',function($matches) use ($data) {
-		$key = trim($matches[2]);
-		$sql = $matches[3];
-		$not = $matches[1];
-		if($not=='!'){
-			return isset($data['filters']) && in_array($key, $data['filters']) ?'':$sql;
-		}else{
-			return !isset($data['filters']) || !in_array($key, $data['filters']) ?'':$sql;
-		}
-		
-	},$sql);
-
-	//loop
-	$sql = preg_replace_callback('/{{\:([^\/\:\?}]*)}}(.*?){{\/\:[^\/\:\?}]*}}/s',function($matches) use ($data) {
-
-		$key = $matches[1];
-		$sqlTpl = $matches[2];
-	 //print_r('LOOP ON '.$key.PHP_EOL);
-		$sql = '';
-		if(isset($data[$key])){
-
-			$i = 0;
-			$values = $data[$key];
-
-			foreach($values as $key=>$value){
-				$i++;
-				$last = $i == count($values);
-				
-				$occurence = str_replace(array('{{key}}'),array($key),$sqlTpl); 
-				if(is_array($value)){
-					foreach ($value as $key2 => $value2) 
-						$occurence = str_replace(array('{{value.'.$key2.'}}'),array($value2),$occurence); 
-				}else{
-					$occurence = str_replace(array('{{value}}'),array($value),$occurence); 
-				}
-
-				$occurence = preg_replace_callback('/{{\;}}(.*?){{\/\;}}/',function($matches) use ($last){
-					return $last? '': $matches[1];
-				},$occurence);
-				$sql.= $occurence;
-
-			}
-			return $sql;
-		}
-		return '';
-	},$sql); 
-
-
-
-	//conditions
-	$sql = preg_replace_callback('/{{\?([^\/\:\?}]*)}}(.*?){{\/\?[^\/\:\?}]*}}/s',function($matches) use ($data) {
-		$key = $matches[1];
-		$sql = $matches[2];
-		return !isset($data[$key]) || (is_array($data[$key]) && count($data[$key])==0) ?'':$sql;
-	},$sql);
-
-
-	//simple vars
-	$sql = preg_replace_callback('/{{([^\/\:\;\?}]*)}}/',function($matches) use ($data) {
-		$key = $matches[1];
-		return isset($data[$key])?$data[$key]:$matches[0];
-	},$sql); 
-
-	return $sql;
-}
-
-//Déclaration des sections de droits du plugin
-function factory_section(&$sections){
-	$sections['factory'] = "Gestion des droits sur le plugin Factory";
-}
-
-//Déclation des assets
-Plugin::addCss("/css/main.css"); 
-Plugin::addJs("/js/main.js"); 
-
-//Mapping hook / fonctions
-Plugin::addHook("install", "factory_install");
-Plugin::addHook("uninstall", "factory_uninstall");
-Plugin::addHook("section", "factory_section");
-Plugin::addHook("menu_main", "factory_menu"); 
-Plugin::addHook("page", "factory_page");  
-Plugin::addHook("action", "factory_action");   
-
-
-?>

+ 0 - 187
plugin/factory/js/main.js

@@ -1,187 +0,0 @@
-//CHARGEMENT DE LA PAGE
-function init_plugin_factory(event){
-	
-	$('#factoryForm').on('keyup','input',factory_render);
-	$('#factoryForm').on('keydown','input,select',factory_shortcut);
-	$('#factoryForm').on('change','select',factory_render);
-	$('#factoryParts').on('click','li a',function(){
-		$('#factoryParts li a').removeClass('active');
-		$(this).addClass('active');
-		factory_render(event);
-	});
-
-	$('#factoryParts .nav-link.active').trigger('click');
-
-	$('#plugin').autocomplete({
-		action : 'factory_autocomplete_plugin',
-		onClick : function(selected,element){
-			$('#plugin').val(selected.name);
-			console.log('click on '+selected.name);
-			$.action({action:'factory_entity_search',plugin:selected.name},function(response){
-				if(response.rows.length==0) return;
-				var html = '<optgroup label="Entités">';
-				for(var key in response.rows){
-					html +='<option value="entity-'+response.rows[key]+'">'+response.rows[key]+'</option>';
-				}
-				html += '</optgroup>';
-				$('.fieldType').append(html);
-			});
-			
-
-			
-		}
-	});
-
-	$('#entity').attr('autocomplete','off').typeahead({ 
-		items: 5,
-		minLength: 2,
-		autoSelect : false,
-		selectOnBlur : false,
-		displayText : function(item){
-			return  item.name || item;
-		},
-		source: function(keyword, response){
-			$.action({
-				action: 'factory_autocomplete_entity',
-				keyword: $('#entity').val(),
-				plugin: $('#plugin').val() 
-			},function(r){
-				if(r.rows != null)
-					response(r.rows);
-			});
-		},
-		matcher: function(r){
-		    return '<div>'+r.name+'</div>';
-		},
-		afterSelect: function(item) {
-			$('#entity').data('selected',true);
-			$.action({
-				action: 'factory_autocomplete_entity_select',
-				entity: item.name,
-				plugin: $('#plugin').val() 
-			},function(r){
-				$('#factoryForm .field:not(:eq(0))').remove();
-				$('#factoryForm .field:eq(0) input').val(r.rows[0].label);
-				$('#factoryForm .field:eq(0) select').val(r.rows[0].type);
-				for(var k in r.rows){
-					if(k==0) continue;
-					factory_addline($('#factoryForm .field').eq(0),r.rows[k]);
-				}
-				factory_render();
-			});
-      	}
-	});
-
-
-
-
-}
-
-function factory_change_template(event){
-	factory_search_part();
-	factory_search_filters();
-	event.stopPropagation();
-}
-
-
-function factory_shortcut(event){
-	if(this.id=='entity' && event.keyCode==9){
-		event.preventDefault();
-		$('#factoryForm .field:eq(0) input:eq(0)').focus();
-	}
-
-	if($(this).hasClass('fieldType') && event.keyCode==9){
-		event.preventDefault();
-		return factory_addline(this);
-	}
-
-	if(event.keyCode == 107){
-		event.preventDefault();
-		return factory_addline(this);
-	}
-	if(event.keyCode == 109){
-		event.preventDefault();
-		return factory_removeline(this);
-	}
-}
-
-
-
-function factory_search_part(callback){
-	$('#factoryParts').fill({
-		action : 'factory_search_part',
-		template : $('#template').val()
-	},
-	function(){
-		if(callback) callback();
-	});
-}
-
-function factory_search_filters(callback){
-	$('#factoryFilters ul').fill({
-		action : 'factory_search_filters',
-		template : $('#template').val(),
-		part : $('#factoryParts li a.active').attr('data-part'),
-	},
-	function(){
-		if($('#factoryFilters ul li:visible').length!=0){
-			$('#factoryFilters h4').removeClass('hidden');
-		}else{
-			$('#factoryFilters h4').addClass('hidden');
-		}
-		$('#factoryFilters input[data-checked="checked"]').prop('checked',true);
-		if(callback) callback();
-	});
-}
-
-function factory_render(event,generate){
-	if(generate)
-		if(!confirm("Souhaitez-vous générer le fichier associé à l'onglet courant ?\nSi le fichier existe déjà, il sera écrasé.")) return;
-	var data = $('#factoryForm').toJson();
-	data.part = $('#factoryParts li a.active').attr('data-part');
-	if(!data.part) return;
-	data.template = $('#template').val();
-	data.fields = {};
-	$('#factoryForm .field').each(function(i,line){
-		data.fields[$('.fieldSlug',line).val()] = {type:$('.fieldType',line).val(),label:$('.fieldLabel',line).val()} ;
-	});
-
-	data.filters = [];
-	$('#factoryFilters li:visible input:checked').each(function(i,line){
-		data.filters.push($(line).attr('data-section')) ;
-	});
-
-	data.generate = generate ? 1 : 0;
-	$('#factoryCode').load('action.php?action='+data.action,data,function(){
-		if(generate) $('#factory-generate-message').text("Fichier "+data.part+" généré");
-
-		$('#factoryCode').attr('class',$('#factoryParts li a.active').attr('data-langage')) ;
-	    hljs.highlightBlock($('#factoryCode').get(0));
-	});
-}
-
-function factory_addline(element,data){
-	var line = $(element).closest('.field');
-	var newline = $(line).clone();
-	newline.find('input').val('');
-	$(line).after(newline);
-	newline.find('input:eq(0)').focus();
-
-	if(data){
-		newline.find('input').val(data.label);
-		newline.find('select').val(data.type);
-	}
-}
-
-function factory_removeline(element){
-	var line = $(element).closest('.field');
-	if($('.field').length==1){
-		line.find('input').val('');
-		line.find('input:eq(0)').focus();
-	}else{
-		prevline = line.prev('.field');
-		line.remove();
-		prevline.find('input:eq(0)').focus();
-	}
-	
-}

+ 0 - 107
plugin/factory/page.factory.php

@@ -1,107 +0,0 @@
-<?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>
-
-
-

+ 0 - 128
plugin/factory/template/Erp plugin/action.php

@@ -1,128 +0,0 @@
-{"label":"Action","syntax":"php"}
-<?php
-global $_,$conf;
-switch($_['action']){
-	/** {{ENTITY}} **/
-	//Récuperation d'une liste de {{entity}}
-	case '{{plugin}}_{{entity_readable}}_search':
-		Action::write(function(&$response){
-			global $myUser,$_;
-			User::check_access('{{plugin}}','read');
-			require_once(__DIR__.SLASH.'{{Entity}}.class.php');{{:links}}
-			require_once(__DIR__.SLASH.'{{value.entity}}.class.php');{{/:links}}
-
-			{{~! Recherche non avancée}}
-			// OPTIONS DE RECHERCHE, A ACTIVER POUR UNE RECHERCHE AVANCEE
-			$query = 'SELECT * FROM '.{{Entity}}::tableName().' WHERE 1';
-			$data = array();
-			//Recherche simple
-			if(!empty($_['filters']['keyword'])){
-				$query .= ' AND label LIKE ?';
-				$data[] = '%'.$_['filters']['keyword'].'%';
-			}
-
-			//Recherche avancée
-			if(isset($_['filters']['advanced'])) filter_secure_query($_['filters']['advanced'],array('label'),$query,$data);
-
-			//Tri des colonnes
-			if(isset($_['sort'])) sort_secure_query($_['sort'],array('label'),$query,$data);
-
-			//Pagination
-			$response['pagination'] = {{Entity}}::paginate(20,(!empty($_['page'])?$_['page']:0),$query,$data);
-
-			${{entity}}s = {{Entity}}::staticQuery($query,$data,true,{{linksCount}});
-			{{/~}}
-
-			{{~ Recherche non avancée}}
-			${{entity}}s = {{Entity}}::loadAll();
-			{{/~}}
-			foreach(${{entity}}s as ${{entity}}){
-				$row = ${{entity}}->toArray();{{:links}}
-				$row['{{value.key}}'] = ${{entity}}->join('{{value.key}}')->toArray();{{/:links}}
-				$response['rows'][] = $row;
-			}
-
-			{{~ Export de la recherche}}
-			/* Mode export */
-			if($_['export'] == 'true'){
-				$stream = Excel::exportArray($response['rows'],null,'Export');
-				File::downloadStream($stream,'export-demandes-'.date('d-m-Y').'.xlsx');
-				exit();
-			}
-			{{/~}}
-
-		});
-	break;
-	
-	//Ajout ou modification d'élément {{entity}}
-	case '{{plugin}}_{{entity_readable}}_save':
-		Action::write(function(&$response){
-			global $myUser,$_;
-			User::check_access('{{plugin}}','edit');
-			require_once(__DIR__.SLASH.'{{Entity}}.class.php');
-			$item = {{Entity}}::provide();{{:fields}}
-			$item->{{value.key}} = $_['{{value.key}}'];{{/:fields}}
-			$item->save();
-		});
-	break;
-	
-	{{~ Formulaire dans le tableau de liste }}//Récuperation ou edition d'élément {{entity}}
-	case '{{plugin}}_{{entity_readable}}_edit':
-		Action::write(function(&$response){
-			global $myUser,$_;
-			User::check_access('{{plugin}}','edit');
-			require_once(__DIR__.SLASH.'{{Entity}}.class.php');{{:links}}
-			require_once(__DIR__.SLASH.'{{value.entity}}.class.php');{{/:links}}
-			$response = {{Entity}}::getById($_['id'],{{linksCount}});
-		});
-	break;{{/~}}
-
-	//Suppression d'élement {{entity}}
-	case '{{plugin}}_{{entity_readable}}_delete':
-		Action::write(function(&$response){
-			global $myUser,$_;
-			User::check_access('{{plugin}}','delete');
-			require_once(__DIR__.SLASH.'{{Entity}}.class.php');
-			{{~! Suppression logique}}{{Entity}}::deleteById($_['id']);{{/~}}
-			{{~ Suppression logique}}$item = {{Entity}}::getById($_['id']);
-			$item->state = {{Entity}}::INACTIVE;
-			$item->save();{{/~}}
-		});
-	break;
-
-	{{~! Pas de page réglages }}
-	//Sauvegarde des configurations de {{plugin}}
-	case '{{plugin}}_setting_save':
-		Action::write(function(&$response){
-			global $myUser,$_,$conf;
-			User::check_access('{{plugin}}','configure');
-			foreach(Configuration::setting('{{plugin}}') as $key=>$value){
-				if(!is_array($value)) continue;
-				$allowed[] = $key;
-			}
-			foreach ($_['fields'] as $key => $value) {
-				if(in_array($key, $allowed))
-					$conf->put($key,$value);
-			}
-		});
-	break;
-	{{/~}}
-
-	{{~ Widget de dashboard }}
-	case '{{plugin}}_widget_load':
-		global $myUser;
-		require_once(__DIR__.SLASH.'..'.SLASH.'dashboard'.SLASH.'DashboardWidget.class.php');
-		$widget = DashboardWidget::current();
-		$widget->title = 'Widget {{Plugin}}';
-		ob_start();
-		//Décommenter après avoir créé widget.php
-		//require_once(__DIR__.SLASH.'widget.php');
-		//$widget->content = ob_get_clean();
-		$widget->content = 'Widget non développé';
-		echo json_encode($widget);
-	break;
-	{{/~}}
-
-
-}
-?>

+ 0 - 14
plugin/factory/template/Erp plugin/app.json

@@ -1,14 +0,0 @@
-{"label":"App","syntax":"json"}
-{
-	"id": "fr.idleman.{{plugin}}",
-	"name": "{{plugin}}",
-	"author" : {
-		"name" : "{{user.fullname}}",
-		"mail" : "{{user.mail}}"
-	},
-	"version": "1.0",
-	"url": "http://idleman.fr",
-	"licence": {"name": "Copyright","url" : ""},
-	"description": "{{description}}",
-	"require" : {}
-}

+ 0 - 20
plugin/factory/template/Erp plugin/css/main.css

@@ -1,20 +0,0 @@
-{"label":"CSS","syntax":"css"}
-/** {{PLUGIN}} **/
-
-/* Conteneur principal du plugin {{plugin}} */
-.{{plugin}} {
-	
-}
-
-#{{plugin}}s {
-
-}
-
-/* formulaire d'édition de {{entity}} */
-.{{plugin}} .{{entity-readable}}-form {
-	
-}
-
-#{{entity-readable}}-form {
-
-}

+ 0 - 77
plugin/factory/template/Erp plugin/js/main.js

@@ -1,77 +0,0 @@
-{"label":"JS","syntax":"js"}
-//CHARGEMENT DE LA PAGE
-function init_plugin_{{plugin}}(){
-	switch($.urlParam('page')){
-		default:
-		break;
-	}
-	{{plugin}}_{{entity_readable}}_search();
-	{{~! Recherche non avancée}}
-	$('#{{entity-readable}}s').sortable_table({
-		onSort : {{plugin}}_{{entity_readable}}_search
-	});{{/~}}
-}
-
-{{~! Pas de page réglages }}
-//Enregistrement des configurations
-function {{plugin}}_setting_save(){
-	$.action({ 
-		action : '{{plugin}}_setting_save', 
-		fields :  $('#{{plugin}}-setting-form').toJson() 
-	},function(){ $.message('info','Configuration enregistrée'); });
-}
-{{/~}}
-
-/** {{ENTITY}} **/
-	
-//Récuperation d'une liste de {{entity}} dans le tableau #{{entity}}s
-function {{plugin}}_{{entity_readable}}_search(callback{{~ Export de la recherche}},exportMode{{/~}}){
-	
-		
-	$('#{{entity-readable}}s').fill({
-		action:'{{plugin}}_{{entity_readable}}_search'{{~! Recherche non avancée}},
-		filters : $('#filters').filters(),
-		sort : $('#{{entity-readable}}s').sortable_table('get'){{/~}}
-		{{~ Export de la recherche}}export :  !exportMode ? false : exportMode;{{/~}}
-	},function(response){
-		$('.results-count span').text(response.pagination.total);
-		if(callback!=null) callback();
-	});
-}
-
-//Ajout ou modification d'élément {{entity}}
-function {{plugin}}_{{entity_readable}}_save(){
-	var data = $('#{{entity-readable}}-form').toJson();
-	$.action(data,function(r){
-		
-		{{~ Formulaire dans le tableau de liste }}
-			$('#{{entity-readable}}-form').attr('data-id','');
-			{{plugin}}_{{entity_readable}}_search();
-		{{/~}}
-		$.message('success','Enregistré');
-	});
-}
-
-{{~ Formulaire dans le tableau de liste }}
-//Récuperation ou edition d'élément {{entity}}
-function {{plugin}}_{{entity_readable}}_edit(element){
-	var line = $(element).closest('tr');
-	$.action({action:'{{plugin}}_{{entity_readable}}_edit',id:line.attr('data-id')},function(r){
-		$.setForm('#{{entity-readable}}-form',r);
-		$('#{{entity-readable}}-form').attr('data-id',r.id);
-	});
-}
-{{/~}}
-//Suppression d'élement {{entity}}
-function {{plugin}}_{{entity_readable}}_delete(element){
-	if(!confirm('Êtes vous sûr de vouloir supprimer cet item ?')) return;
-	var line = $(element).closest('tr');
-	$.action({
-		action : '{{plugin}}_{{entity_readable}}_delete',
-		id : line.attr('data-id')
-	},function(r){
-		line.remove();
-		$.message('info','Élement supprimé');
-	});
-}
-

+ 0 - 72
plugin/factory/template/Erp plugin/page.list.{{entity.readable}}.php

@@ -1,72 +0,0 @@
-{"label":"Liste entité","syntax":"php"}
-<?php
-global $myUser;
-User::check_access('{{plugin}}','read');
-require_once(__DIR__.SLASH.'{{Entity}}.class.php');
-?>
-
-<div class="row">
-    {{~! Recherche non avancée}}
-    <div class="col-md-8">
-        <select id="filters" data-type="filter" data-label="Recherche" data-function="{{plugin}}_{{entity_readable}}_search">
-            <option value="label"   data-filter-type="text">Libellé</option>
-        </select>
-    </div>
-    {{/~}}
-	<div class="col-md-4">
-		<?php if($myUser->can('{{plugin}}', 'edit')) : ?>
-		<a href="index.php?module={{plugin}}&page=sheet.{{entity.readable}}" class="btn btn-success right"><i class="fas fa-plus"></i> Ajouter</a>
-		<?php endif; ?>
-	</div>
-</div>
-<br/>
-<h4 class="results-count"><span></span> Résultat(s) <div class="btn btn-dark btn-small" onclick="{{plugin}}_{{entity_readable}}_search(null,true)"><i class="far fa-file-excel"></i> Exporter</div></h4>
-<div class="row">
-	<!-- search results -->
-	<div class="col-xl-12">
-		<table id="{{entity-readable}}s" class="table table-striped " data-entity-search="{{plugin}}_{{entity_readable}}_search">
-            <thead>
-                <tr>
-                    <th>#</th>{{:fields}}
-                    <th data-sortable="{{key}}">{{value.label}}</th>{{/:fields}}
-                    <th></th>
-                </tr>
-            </thead>
-            {{~ Formulaire dans le tableau de liste }}
-                <thead>
-                    <tr id="{{entity-readable}}-form" data-action="{{plugin}}_{{entity_readable}}_save" data-id="">
-                        <th>#</th>{{:fields}}
-                        <th><input id="{{key}}" name="{{key}}" class="form-control" placeholder="" value="" type="text"></th>{{/:fields}}
-                        <th><div onclick="{{plugin}}_{{entity_readable}}_save();" class="btn btn-success"><i class="fas fa-check"></i> Enregistrer</div></th>
-                    </tr>
-                </thead>
-            {{/~}}
-            <tbody>
-                <tr data-id="{{id}}" class="hidden">
-	                <td>{{id}}</td>{{:fields}}
-	                <td>{{{{value.key}}}}</td>{{/:fields}}
-	                <td>
-	                    <div class="btn-group btn-group-sm" role="group">
-                            {{~! Formulaire dans le tableau de liste }}
-                            <a class="btn btn-info" href="index.php?module={{plugin}}&page=sheet.{{entity.readable}}&id={{id}}"><i class="fas fa-pencil-alt"></i></a>
-                            {{/~}}
-                            {{~ Formulaire dans le tableau de liste }}
-                            <div class="btn btn-info " onclick="{{plugin}}_{{entity_readable}}_edit(this);"><i class="fas fa-pencil-alt"></i></div>
-                            {{/~}}
-                            <div class="btn btn-danger " onclick="{{plugin}}_{{entity_readable}}_delete(this);"><i class="far fa-trash-alt"></i></div>
-	                    </div>
-	                </td>
-                </tr>
-           </tbody>
-        </table>
-
-         {{~! Recherche non avancée}}<!-- Pagination (data-range définit le nombre de pages max affichées avant et après la page courante) -->
-       
-        <ul class="pagination justify-content-center"  data-range="5">
-            <li class="page-item hidden" data-value="{{value}}" title="Voir la page {{label}}" onclick="$(this).parent().find('li').removeClass('active');$(this).addClass('active');{{plugin}}_{{entity_readable}}_search();">
-                <span class="page-link">{{label}}</span>
-            </li>
-        </ul>{{/~}}
-
-	</div>
-</div>

+ 0 - 72
plugin/factory/template/Erp plugin/page.list.{{entity}}.php

@@ -1,72 +0,0 @@
-{"label":"Liste entité","syntax":"php"}
-<?php
-global $myUser;
-if(!$myUser->connected()) throw new Exception("Vous devez être connecté pour accéder à cette fonctionnalité",401);
-if(!$myUser->can('{{plugin}}','read')) throw new Exception("Vous n'avez pas la permission pour executer cette fonctionnalité",403);
-require_once(__DIR__.SLASH.'{{Entity}}.class.php');
-?>
-
-<div class="row">
-    {{~! Recherche non avancée}}
-    <div class="col-md-8">
-        <select id="filters" data-type="filter" data-label="Recherche" data-function="{{plugin}}_{{entity}}_search">
-            <option value="label"   data-filter-type="text">Libellé</option>
-        </select>
-    </div>
-    {{/~}}
-	<div class="col-md-4">
-		<?php if($myUser->can('{{plugin}}', 'edit')) : ?>
-		<a href="index.php?module={{plugin}}&page=sheet.{{entity}}" class="btn btn-success right"><i class="fas fa-plus"></i> Ajouter</a>
-		<?php endif; ?>
-	</div>
-</div>
-<br/>
-<div class="row">
-	<!-- search results -->
-	<div class="col-xl-12">
-		<table id="{{entity}}s" class="table table-striped " data-entity-search="{{plugin}}_{{entity}}_search">
-            <thead>
-                <tr>
-                    <th>#</th>{{:fields}}
-                    <th data-sortable="{{key}}">{{value.label}}</th>{{/:fields}}
-                    <th></th>
-                </tr>
-            </thead>
-            {{~ Formulaire dans le tableau de liste }}
-                <thead>
-                    <tr id="{{entity}}-form" data-action="{{plugin}}_{{entity}}_save" data-id="">
-                        <th>#</th>{{:fields}}
-                        <th><input id="{{key}}" name="{{key}}" class="form-control" placeholder="" value="" type="text"></th>{{/:fields}}
-                        <th><div onclick="{{plugin}}_{{entity}}_save();" class="btn btn-success"><i class="fas fa-check"></i> Enregistrer</div></th>
-                    </tr>
-                </thead>
-            {{/~}}
-            <tbody>
-                <tr data-id="{{id}}" class="hidden">
-	                <td>{{id}}</td>{{:fields}}
-	                <td>{{{{value.key}}}}</td>{{/:fields}}
-	                <td>
-	                    <div class="btn-group btn-group-sm" role="group">
-                            {{~! Formulaire dans le tableau de liste }}
-                            <a class="btn btn-info" href="index.php?module={{plugin}}&page=sheet.{{entity}}&id={{id}}"><i class="fas fa-pencil-alt"></i></a>
-                            {{/~}}
-                            {{~ Formulaire dans le tableau de liste }}
-                            <div class="btn btn-info " onclick="{{plugin}}_{{entity}}_edit(this);"><i class="fas fa-pencil-alt"></i></div>
-                            {{/~}}
-                            <div class="btn btn-danger " onclick="{{plugin}}_{{entity}}_delete(this);"><i class="far fa-trash-alt"></i></div>
-	                    </div>
-	                </td>
-                </tr>
-           </tbody>
-        </table>
-
-         {{~! Recherche non avancée}}<!-- Pagination -->
-       
-        <ul class="pagination">
-            <li class="page-item hidden" data-value="{{value}}" title="Voir la page {{label}}" onclick="$(this).parent().find('li').removeClass('active');$(this).addClass('active');{{plugin}}_{{entity}}_search();">
-                <a class="page-link" href="#">{{label}}</a>
-            </li>
-        </ul>{{/~}}
-
-	</div>
-</div>

+ 0 - 18
plugin/factory/template/Erp plugin/page.sheet.{{entity.readable}}.php

@@ -1,18 +0,0 @@
-{"label":"Fiche entité","syntax":"php"}
-<?php 
-User::check_access('{{plugin}}','read');
-require_once(__DIR__.SLASH.'{{Entity}}.class.php');
-${{entity}} = {{Entity}}::provide();
-?>
-<div class="{{plugin}}">
-	<div id="{{entity-readable}}-form" class="row {{entity-readable}}-form" data-action="{{plugin}}_{{entity_readable}}_save" data-id="<?php echo ${{entity}}->id; ?>">
-		<div class="col-md-12">
-			<h3>{{Entity}}</h3>{{:fields}}
-			<label for="{{value.key}}">{{value.label}}</label>
-			{{value.input}}{{/:fields}}
-			<br/>
-			<div onclick="{{plugin}}_{{entity_readable}}_save();" class="btn btn-success"><i class="fas fa-check"></i> Enregistrer</div>
-		</div>
-	</div>
-</div>
-

+ 0 - 19
plugin/factory/template/Erp plugin/page.sheet.{{entity}}.php

@@ -1,19 +0,0 @@
-{"label":"Fiche entité","syntax":"php"}
-<?php 
-if(!$myUser->connected()) throw new Exception("Vous devez être connecté pour accéder à cette fonctionnalité",401);
-if(!$myUser->can('{{plugin}}','read')) throw new Exception("Vous n'avez pas la permission pour executer cette fonctionnalité",403);
-require_once(__DIR__.SLASH.'{{Entity}}.class.php');
-${{entity}} = {{Entity}}::provide();
-?>
-<div class="{{plugin}}">
-	<div id="{{entity}}-form" class="row {{entity}}-form" data-action="{{plugin}}_{{entity}}_save" data-id="<?php echo ${{entity}}->id; ?>">
-		<div class="col-md-12">
-			<h3>{{Entity}}</h3>{{:fields}}
-			<label for="{{value.key}}">{{value.label}}</label>
-			{{value.input}}{{/:fields}}
-			<br/>
-			<div onclick="{{plugin}}_{{entity}}_save();" class="btn btn-success"><i class="fas fa-check"></i> Enregistrer</div>
-		</div>
-	</div>
-</div>
-

+ 0 - 24
plugin/factory/template/Erp plugin/setting.global.{{plugin}}.php

@@ -1,24 +0,0 @@
-{"label":"Setting global","syntax":"php"}
-<?php
-global $myUser,$conf;
-User::check_access('{{plugin}}','configure');
-?>
-
-<div class="row">
-	<div class="col-md-12">
-          <h3><i class="fas fa-wrench"></i> Réglages {{Plugin}}
-                <?php if($myUser->can('{{plugin}}', 'edit')) : ?>
-        <div onclick="{{plugin}}_setting_save();" class="btn btn-success right"><i class="fas fa-check"></i> Enregistrer</div>
-        <?php endif; ?>
-          </h3>
-        <hr/>
-	</div>
-</div>
-<p>Veuillez remplir les informations ci dessous.</p>
-
-<div class="row">
-	<!-- search results -->
-	<div class="col-xl-12">
-		  <?php echo Configuration::html('{{plugin}}'); ?>
-	</div>
-</div>

+ 0 - 73
plugin/factory/template/Erp plugin/setting.list.{{plugin}}.{{entity.readable}}.php

@@ -1,73 +0,0 @@
-{"label":"Setting liste","syntax":"php"}
-<?php
-global $myUser;
-User::check_access('{{plugin}}','configure');
-require_once(__DIR__.SLASH.'{{Entity}}.class.php');
-?>
-<br>
-<h3>Réglages {{plugin}}</h3>
-<hr/>
-<div class="row">
-    {{~! Recherche non avancée}}
-    <div class="col-md-8">
-        <select id="filters" data-type="filter" data-label="Recherche" data-function="{{plugin}}_{{entity_readable}}_search">
-            <option value="label"   data-filter-type="text">Libellé</option>
-        </select>
-    </div>
-    {{/~}}
-    <div class="col-md-4">
-        <?php if($myUser->can('{{plugin}}', 'edit')) : ?>
-        <a href="index.php?module={{plugin}}&page=sheet.{{entity.readable}}" class="btn btn-success right"><i class="fas fa-plus"></i> Ajouter</a>
-        <?php endif; ?>
-    </div>
-</div>
-<br/>
-<div class="row">
-    <!-- search results -->
-    <div class="col-xl-12">
-        <table id="{{entity-readable}}s" class="table table-striped " data-entity-search="{{plugin}}_{{entity_readable}}_search">
-            <thead>
-                <tr>
-                    <th>#</th>{{:fields}}
-                    <th data-sortable="{{key}}">{{value.label}}</th>{{/:fields}}
-                    <th></th>
-                </tr>
-            </thead>
-            {{~ Formulaire dans le tableau de liste }}
-                <thead>
-                    <tr id="{{entity-readable}}-form" data-action="{{plugin}}_{{entity_readable}}_save" data-id="">
-                        <th>#</th>{{:fields}}
-                        <th><input id="{{key}}" name="{{key}}" class="form-control" placeholder="" value="" type="text"></th>{{/:fields}}
-                        <th><div onclick="{{plugin}}_{{entity_readable}}_save();" class="btn btn-success"><i class="fas fa-check"></i> Enregistrer</div></th>
-                    </tr>
-                </thead>
-            {{/~}}
-            <tbody>
-                <tr data-id="{{id}}" class="hidden">
-                    <td>{{id}}</td>{{:fields}}
-                    <td>{{{{value.key}}}}</td>{{/:fields}}
-                    <td>
-                        <div class="btn-group btn-group-sm" role="group">
-                            {{~! Formulaire dans le tableau de liste }}
-                            <a class="btn btn-info" href="index.php?module={{plugin}}&page=sheet.{{entity.readable}}&id={{id}}"><i class="fas fa-pencil-alt"></i></a>
-                            {{/~}}
-                            {{~ Formulaire dans le tableau de liste }}
-                            <div class="btn btn-info " onclick="{{plugin}}_{{entity_readable}}_edit(this);"><i class="fas fa-pencil-alt"></i></div>
-                            {{/~}}
-                            <div class="btn btn-danger " onclick="{{plugin}}_{{entity_readable}}_delete(this);"><i class="far fa-trash-alt"></i></div>
-                        </div>
-                    </td>
-                </tr>
-           </tbody>
-        </table>
-
-         {{~! Recherche non avancée}}<!-- Pagination -->
-       
-        <ul class="pagination justify-content-center">
-            <li class="page-item hidden" data-value="{{value}}" title="Voir la page {{label}}" onclick="$(this).parent().find('li').removeClass('active');$(this).addClass('active');{{plugin}}_{{entity_readable}}_search();">
-                <span class="page-link">{{label}}</span>
-            </li>
-        </ul>{{/~}}
-
-    </div>
-</div>

+ 0 - 74
plugin/factory/template/Erp plugin/setting.list.{{plugin}}.{{entity}}.php

@@ -1,74 +0,0 @@
-{"label":"Setting liste","syntax":"php"}
-<?php
-global $myUser;
-if(!$myUser->connected()) throw new Exception("Vous devez être connecté pour accéder à cette fonctionnalité",401);
-if(!$myUser->can('{{plugin}}','configure')) throw new Exception("Vous n'avez pas la permission pour executer cette fonctionnalité",403);
-require_once(__DIR__.SLASH.'{{Entity}}.class.php');
-?>
-<br>
-<h3>Réglages {{plugin}}</h3>
-<hr/>
-<div class="row">
-    {{~! Recherche non avancée}}
-    <div class="col-md-8">
-        <select id="filters" data-type="filter" data-label="Recherche" data-function="{{plugin}}_{{entity}}_search">
-            <option value="label"   data-filter-type="text">Libellé</option>
-        </select>
-    </div>
-    {{/~}}
-    <div class="col-md-4">
-        <?php if($myUser->can('{{plugin}}', 'edit')) : ?>
-        <a href="index.php?module={{plugin}}&page=sheet.{{entity}}" class="btn btn-success right"><i class="fas fa-plus"></i> Ajouter</a>
-        <?php endif; ?>
-    </div>
-</div>
-<br/>
-<div class="row">
-    <!-- search results -->
-    <div class="col-xl-12">
-        <table id="{{entity}}s" class="table table-striped " data-entity-search="{{plugin}}_{{entity}}_search">
-            <thead>
-                <tr>
-                    <th>#</th>{{:fields}}
-                    <th data-sortable="{{key}}">{{value.label}}</th>{{/:fields}}
-                    <th></th>
-                </tr>
-            </thead>
-            {{~ Formulaire dans le tableau de liste }}
-                <thead>
-                    <tr id="{{entity}}-form" data-action="{{plugin}}_{{entity}}_save" data-id="">
-                        <th>#</th>{{:fields}}
-                        <th><input id="{{key}}" name="{{key}}" class="form-control" placeholder="" value="" type="text"></th>{{/:fields}}
-                        <th><div onclick="{{plugin}}_{{entity}}_save();" class="btn btn-success"><i class="fas fa-check"></i> Enregistrer</div></th>
-                    </tr>
-                </thead>
-            {{/~}}
-            <tbody>
-                <tr data-id="{{id}}" class="hidden">
-                    <td>{{id}}</td>{{:fields}}
-                    <td>{{{{value.key}}}}</td>{{/:fields}}
-                    <td>
-                        <div class="btn-group btn-group-sm" role="group">
-                            {{~! Formulaire dans le tableau de liste }}
-                            <a class="btn btn-info" href="index.php?module={{plugin}}&page=sheet.{{entity}}&id={{id}}"><i class="fas fa-pencil-alt"></i></a>
-                            {{/~}}
-                            {{~ Formulaire dans le tableau de liste }}
-                            <div class="btn btn-info " onclick="{{plugin}}_{{entity}}_edit(this);"><i class="fas fa-pencil-alt"></i></div>
-                            {{/~}}
-                            <div class="btn btn-danger " onclick="{{plugin}}_{{entity}}_delete(this);"><i class="far fa-trash-alt"></i></div>
-                        </div>
-                    </td>
-                </tr>
-           </tbody>
-        </table>
-
-         {{~! Recherche non avancée}}<!-- Pagination -->
-       
-        <ul class="pagination">
-            <li class="page-item hidden" data-value="{{value}}" title="Voir la page {{label}}" onclick="$(this).parent().find('li').removeClass('active');$(this).addClass('active');{{plugin}}_{{entity}}_search();">
-                <a class="page-link" href="#">{{label}}</a>
-            </li>
-        </ul>{{/~}}
-
-    </div>
-</div>

+ 0 - 28
plugin/factory/template/Erp plugin/{{Entity}}.class.php

@@ -1,28 +0,0 @@
-{"label":"Entité","syntax":"php"}
-<?php
-/**
- * Define a {{entity}}.
- * @author {{user.fullname}}
- * @category Plugin
- * @license copyright
- */
-class {{Entity}} extends Entity{
-
-	public $id;{{:fields}}
-	public ${{value.key}}; //{{value.label}} ({{value.typeLabel}}){{/:fields}}
-	
-	protected $TABLE_NAME = '{{plugin}}_{{table}}';
-	public $fields =
-	array(
-		'id' => 'key',{{:fields}}
-		'{{value.key}}' => '{{value.sql-type}}'{{;}},{{/;}}{{/:fields}}
-	);
-
-	public $links = array({{:links}}
-		'{{value.key}}' => '{{value.entity}}'{{;}},{{/;}}{{/:links}}
-	);
-
-	//Colonnes indexées
-	public $indexes = array();
-}
-?>

+ 0 - 122
plugin/factory/template/Erp plugin/{{plugin}}.plugin.php

@@ -1,122 +0,0 @@
-{"label":"Plugin","syntax":"php"}
-<?php
-
-
-//Déclaration d'un item de menu dans le menu principal
-function {{plugin}}_menu(&$menuItems){
-	global $_,$myUser;
-	if(!$myUser->can('{{plugin}}','read')) return;
-	$menuItems[] = array(
-		'sort'=>3,
-		'url'=>'index.php?module={{plugin}}',
-		'label'=>'{{plugin}}',
-		'icon'=> 'far fa-question-circle',
-		'color'=> '#3498db'
-	);
-}
-
-//Cette fonction va generer une page quand on clique sur {{plugin}} dans menu
-function {{plugin}}_page(){
-	global $_,$myUser;
-	if(!isset($_['module']) || $_['module'] !='{{plugin}}') return;
-	$page = !isset($_['page']) ? 'list.{{entity.readable}}' : $_['page'];
-	$file = __DIR__.SLASH.'page.'.$page.'.php';
-	if(!file_exists($file)) throw new Exception("Page ".$page." inexistante");
-	
-	require_once($file);
-}
-
-//Fonction executée lors de l'activation du plugin
-function {{plugin}}_install($id){
-	if($id != 'fr.idleman.{{plugin}}') return;
-	Entity::install(__DIR__);
-}
-
-//Fonction executée lors de la désactivation du plugin
-function {{plugin}}_uninstall($id){
-	if($id != 'fr.idleman.{{plugin}}') return;
-	Entity::uninstall(__DIR__);
-}
-
-//Déclaration des sections de droits du plugin
-function {{plugin}}_section(&$sections){
-	$sections['{{plugin}}'] = "Gestion des droits sur le plugin {{plugin}}";
-	// $sections['{{entity}}'] = "Gestion des droits sur l'entité {{entity}}";
-}
-
-//cette fonction comprends toutes les actions du plugin qui ne nécessitent pas de vue html
-function {{plugin}}_action(){
-	require_once(__DIR__.SLASH.'action.php');
-}
-
-{{~! Pas de page réglages }}//Déclaration du menu de réglages
-function {{plugin}}_menu_setting(&$settingMenu){
-	global $_, $myUser;
-	
-	if(!$myUser->can('{{plugin}}','configure')) return;
-	$settingMenu[]= array(
-		'sort' =>1,
-		'url' => 'setting.php?section=global.{{plugin}}',
-		'icon' => 'fas fa-angle-right',
-		'label' => '{{plugin}} Général'
-	);
-
-	$settingMenu[]= array(
-		'sort' =>1,
-		'url' => 'setting.php?section=list.{{plugin}}.{{entity.readable}}',
-		'icon' => 'fas fa-angle-right',
-		'label' => '{{plugin}}'
-	);
-}
-{{/~}}
-{{~! Pas de page réglages }}//Déclaration des pages de réglages
-function {{plugin}}_content_setting(){
-	global $_;
-	if(file_exists(__DIR__.SLASH.'setting.'.$_['section'].'.php'))
-		require_once(__DIR__.SLASH.'setting.'.$_['section'].'.php');
-}
-{{/~}}
-
-{{~! Pas de page réglages }}//Déclaration des settings de base
-//Types possibles : text,select ( + "values"=> array('1'=>'Val 1'),password,checkbox. Un simple string définit une catégorie.
-Configuration::setting('{{plugin}}',array(
-        "Général",
-        '{{plugin}}_enable' => array("label"=>"Activer","type"=>"checkbox"),
-));
-{{/~}}
-
-{{~ Widget de dashboard }}
-//Affichage du/des widget(s)
-function {{plugin}}_widget(&$widgets){
-	global $myUser;
-	require_once(__DIR__.SLASH.'..'.SLASH.'dashboard'.SLASH.'DashboardWidget.class.php');
-	$modelWidget = new DashboardWidget();
-	$modelWidget->model = '{{plugin}}';
-	$modelWidget->title = '{{Plugin}}';
-	$modelWidget->icon = 'far fa-bookmark';
-	$modelWidget->background = '#273c75';
-	$modelWidget->load = 'action.php?action={{plugin}}_widget_load';
-	$modelWidget->js = [Plugin::url().'/js/widget.js?v=1'];
-	$modelWidget->css = [Plugin::url().'/css/widget.css?v=2'];
-	$modelWidget->description = "{{description}}";
-	$widgets[] = $modelWidget;
-}
-{{/~}}  
-
-
-//Déclation des assets
-Plugin::addCss("/css/main.css"); 
-Plugin::addJs("/js/main.js"); 
-
-//Mapping hook / fonctions
-Plugin::addHook("install", "{{plugin}}_install");
-Plugin::addHook("uninstall", "{{plugin}}_uninstall"); 
-Plugin::addHook("section", "{{plugin}}_section");
-Plugin::addHook("menu_main", "{{plugin}}_menu"); 
-Plugin::addHook("page", "{{plugin}}_page");  
-Plugin::addHook("action", "{{plugin}}_action");  
-{{~! Pas de page réglages }}Plugin::addHook("menu_setting", "{{plugin}}_menu_setting");{{/~}}    
-{{~! Pas de page réglages }}Plugin::addHook("content_setting", "{{plugin}}_content_setting");{{/~}}   
-{{~ Widget de dashboard }}Plugin::addHook("widget", "{{plugin}}_widget");{{/~}}    
-
-?>