| 
					
				 | 
			
			
				@@ -0,0 +1,111 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+<?php 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+class PartType { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	public static function manifest(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			'uid' => 'part', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			'label' => 'Composants', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			'description' => 'Composants électroniques', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			'fromExtension' => array('part'), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			'icon' => 'fas fa-microchip', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			'color' => '#ffffff', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			'background' => '#2ecc71' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	//Import depuis un glisser déposé du fichier 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	public static function fromFile($resource){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// $resource->save(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// $ext = getExt($resource->label); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// $name = $resource->id.'.'.$ext; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// file_put_contents(SKETCH_PATH.$name,$resource->content); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// $resource->content = $name; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// return $resource; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	//Import depuis un flux json compressé de la ressource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	public static function fromJson($resource){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// $resource->save(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// $stream = base64_decode($resource->content); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// $resource->content = $resource->id.'.png'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// file_put_contents(SKETCH_PATH.$resource->content,$stream); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// return $resource; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	//export en fichier JSON compressé de la ressource 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	public static function toJson($resource){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// $resource = $resource->toArray(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// $resource['content'] = base64_encode(file_get_contents(SKETCH_PATH.$resource['content'])); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// return $resource; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	public static function toFile($resource){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// $ext = getExt($resource->content); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// $infos = self::manifest(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// return array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// 	'name'=> slugify($resource->label).'.'.$ext, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// 	'content' => file_exists(SKETCH_PATH.$resource->content) ? file_get_contents(SKETCH_PATH.$resource->content) : '' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	/* EDITION */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	public static function toHtml($resource,$sketch=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$infos = self::manifest(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$response = array(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		//.$resource->id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$images = array(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		foreach(glob($resource->directory().SLASH.'*.*') as $file){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			$images[] = array( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				'path' => 'hackpoint'.SLASH.'sketch'.SLASH.$resource->sketch.SLASH.$resource->id.SLASH.basename($file), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				'url' => 'action.php?action=hackpoint_download_file&file='.base64_encode('sketch'.SLASH.$resource->sketch.SLASH.$resource->id.SLASH.rawurlencode(basename($file))), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				'name' => basename($file), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				'icon' => getExtIcon(getExt($file)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		$response['html'] = ' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			<div class="row"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				<div class="col-md-12"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					<div class="input-group col-md-8 pl-0"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					  <div class="input-group-prepend"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					    <span class="input-group-text" id="basic-addon1">Rechercher</span> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					  </div> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					  <input type="text" data-type="part" class="form-control"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					  <div class="input-group-prepend ml-2"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					    <span class="input-group-text" style="background:transparent;border:0;">OU</span> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					  </div> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					  <div class="input-group-prepend ml-2"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					    <div class="btn btn-dark"><i class="far fa-plus-square pr-1"></i> Ajouter un composant inexistant</div> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					  </div> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					</div> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					<ul  id="parts" data-entity-search="hackpoint_part_search"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						<li data-id="{{id}}" class="hidden"> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			                {{label}} - {{brand}} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			                {{price}} € 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			                {{link}} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			                 <div class="btn btn-danger " onclick="hackpoint_part_delete(this);"><i class="far fa-trash-alt"></i></div> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						</li> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					</ul> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				</div> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			</div> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return $response; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+?> 
			 |