12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- require_once(__DIR__.SLASH.'ReadmeType.class.php');
- class GitType extends ReadmeType{
- public static function manifest(){
- return array(
- 'uid' => 'git',
- 'label' => 'Dépot git',
- 'icon' => 'fab fa-git-square',
- 'color' => '#ffffff',
- 'background' => '#bd2c00',
- 'description' => 'Dépot git associé',
- 'fromExtension' => array('.git'),
- 'toExtension' => '.zip',
- 'default' => '',
- );
- }
- /* EDITION */
- public static function toHtml($resource,$sketch=null){
- $infos = self::manifest();
- $json = json_decode($resource->content,true);
- $url = '';
- $synchronise = false;
- if($json){
- $url = $json['url'];
- $synchronise = $json['synchronise'];
- }
- return array(
- 'html'=>'<input id="content" onblur="window[\'hackpoint_resource_git_save\']()" class="git-repository form-control" placeholder="http://domain.com/repository.git" value="'.$url.'"><label><input type="checkbox" data-type="checkbox" onclick="window[\'hackpoint_resource_git_save\']()" '.($synchronise?'checked="checked"':'').' id="git-synchronise"> Synchroniser sur hackpoint</label><div id="git-browser"></div>',
- 'javascript' => "
- window['hackpoint_resource_git_save'] = function(){
- if($('.hackpoint').hasClass('readonly')) return;
- var data = {};
- data.action = 'hackpoint_resource_save_content';
- data.id = $('#sketch-editor').attr('data-id');
- data.content = JSON.stringify({url:$('#content').val(),synchronise:$('#git-synchronise').prop('checked')});
- $('.sketch-preloader').show();
- $.action(data,function(r){
- setTimeout(function(){
- $('.sketch-preloader').fadeOut(200);
- },300);
- hackpoint_resource_git_explore();
- });
- }
- function hackpoint_resource_git_explore(){
- console.log('ee');
- var data = {};
- data.action = 'hackpoint_resource_git_explore';
- data.url = $('#content').val();
- data.id = $('#sketch-editor').attr('data-id');
- $('.sketch-preloader').show();
- $.action(data,function(r){
- setTimeout(function(){
- $('.sketch-preloader').fadeOut(200);
- },300);
- $('#git-browser').html(r.html);
- init_components();
- });
- }
- $(document).ready(hackpoint_resource_git_explore());
- "
- );
- }
- //Export vers un fichier brut
- public static function toFile($resource){
- $infos = self::manifest();
- return array(
- 'name'=> slugify($resource->label).'.'.$infos['toExtension'],
- 'content' => html_entity_decode($resource->content)
- );
- }
-
- }
- ?>
|