SHARE
TWEET

Подсветка синтаксиса в bitrix: php, js, css, html, xml, json

a guest Jun 14th, 2012 224 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Подстветка синтаксиса для админки
  2. if ($_SERVER['SCRIPT_NAME']=="/bitrix/admin/fileman_file_edit.php")
  3. {
  4.    AddEventHandler("main", "OnEpilog", "InitPHPHighlight");
  5.    function InitPHPHighlight()
  6.    {
  7.       global $APPLICATION;
  8.       $path = '/scripts/codemirror';
  9.       $string='
  10.      <link rel="stylesheet" href="'.$path.'/lib/codemirror.css">
  11.      <link rel="stylesheet" href="'.$path.'/lib/util/dialog.css">
  12.      <script src="'.$path.'/lib/codemirror.js"></script>
  13.      <script src="'.$path.'/mode/htmlmixed/htmlmixed.js"></script>
  14.      <script src="'.$path.'/mode/xml/xml.js"></script>
  15.      <script src="'.$path.'/mode/javascript/javascript.js"></script>
  16.      <script src="'.$path.'/mode/css/css.js"></script>
  17.      <script src="'.$path.'/mode/clike/clike.js"></script>
  18.      <script src="'.$path.'/mode/php/php.js"></script>
  19.      <script src="'.$path.'/lib/util/dialog.js"></script>
  20.      <script src="'.$path.'/lib/util/searchcursor.js"></script>
  21.      <script src="'.$path.'/lib/util/search.js"></script>
  22.      <style>
  23.      .CodeMirror-scroll, .CodeMirror-dialog { font: 12px "Monaco", "Lucida Console", MenschRegular, Menlo, consolas, "Courier", monospace  !important; }
  24.      .CodeMirror-dialog > div { top:auto; bottom:9px; left:-8px; right:-8px;}
  25. .CodeMirror-scroll { height: auto; width: auto; overflow-y: hidden; overflow-x: auto; min-height: 500px;}
  26.      .CodeMirror-selected { background: #c7ddfe !important; }
  27.      .activeline { background: #ffffff !important;}
  28.      .edit-form .content .buttons { position: fixed; bottom: 0; right: 0; }
  29.      </style>
  30.      <script>
  31.      BX.ready(function(){
  32.        Codemirror_Init();
  33.      });
  34.      function Codemirror_Init() {
  35.        var nl=document.getElementsByTagName("textarea");
  36.        var md=document.getElementsByName( "ffilemanedit");
  37.        md = md[0].path.value.split(".").pop();
  38.        md = md=="php" ? "application/x-httpd-php" :
  39.             md=="css" ? "text/css" :
  40.             md=="js" ? "text/javascript" :
  41.             md=="html" || md=="htm" ? "text/html" :
  42.             md=="xml" ? "application/xml" :
  43.             md=="json" ? "application/json" :
  44.             "application/x-httpd-php";
  45.        var editor = CodeMirror.fromTextArea(nl[0], {
  46.          lineNumbers: true,
  47.          matchBrackets: true,
  48.          mode: md,
  49.          indentUnit: 2,
  50.          indentWithTabs: false,
  51.          tabMode: "indent",
  52.          enterMode: "indent",
  53.          lineWrapping: true,
  54.          onChange: function(){editor.save();},
  55.          onCursorActivity: function() {
  56.            editor.setLineClass(hlLine, null);
  57.            hlLine = editor.setLineClass(editor.getCursor().line, "activeline");
  58.          },
  59.        });
  60.        
  61.        var hlLine = editor.setLineClass(0, "activeline");
  62.  
  63.        document["onkeydown"] = js_keyaction_handler;
  64.        document["onkeyup"] = js_keyaction_handler;
  65.        js_keyaction_handler_array = [];
  66.        function js_keyaction_handler(e) {
  67.          var evt = e || window.event;
  68.          if( (evt.type=="keydown" || evt.type=="keyup") && (evt.keyCode==83 || evt.keyCode==91) && evt.charCode==0) {
  69.            //CMD-S (keydown, keyCode=83, charCode=0)
  70.            //Save doc
  71.            js_keyaction_handler_array[evt.keyCode] = evt.type=="keydown";
  72.            if( js_keyaction_handler_array[91] && js_keyaction_handler_array[83]) {
  73.              var d = document.getElementsByName("apply");
  74.              if( d.length) {
  75.                d[d.length-1].click();
  76.                return false;
  77.              }
  78.            }
  79.          }
  80.          return true;
  81.        }
  82.      }
  83.      </script>';    
  84.      
  85.       $APPLICATION->AddHeadString($string);
  86.    }
  87. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top