JsType.class.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. require_once(__DIR__.SLASH.'ReadmeType.class.php');
  3. class JsType extends ReadmeType{
  4. public static function manifest(){
  5. return array(
  6. 'uid' => 'js',
  7. 'label' => 'Javascript',
  8. 'icon' => 'fab fa-js',
  9. 'color' => '#ffffff',
  10. 'background' => '#f0db4f',
  11. 'description' => 'Fichier contenant du langage Javascript',
  12. 'fromExtension' => array('js'),
  13. 'toExtension' => 'js',
  14. 'default' => '',
  15. );
  16. }
  17. /* EDITION */
  18. public static function toHtml($resource,$sketch=null){
  19. $infos = self::manifest();
  20. return array(
  21. 'html'=>'<textarea id="content" onblur="hackpoint_resource_save_content()" class="arduino-text">'.$resource->content.'</textarea>',
  22. 'javascript' => "
  23. hackpoint_resource_mirrorify('.arduino-text',{
  24. mode : 'javascript',
  25. lineNumbers : true,
  26. theme : 'monokai',
  27. readOnly : false
  28. });
  29. "
  30. );
  31. }
  32. //Export vers un fichier brut
  33. public static function toFile($resource){
  34. $infos = self::manifest();
  35. return array(
  36. 'name'=> slugify($resource->label).'.'.$infos['toExtension'],
  37. 'content' => html_entity_decode($resource->content)
  38. );
  39. }
  40. }
  41. ?>