Changeset 1054491
- Timestamp:
- 12/26/2014 01:09:57 PM (11 years ago)
- Location:
- gmace/trunk
- Files:
-
- 2 added
- 7 edited
-
assets/js/jquery.js (added)
-
assets/js/scripts.js (modified) (11 diffs)
-
example.php (added)
-
gmace.php (modified) (1 diff)
-
includes/ace.php (modified) (5 diffs)
-
includes/content.php (modified) (2 diffs)
-
includes/editor.php (modified) (2 diffs)
-
includes/settings.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
gmace/trunk/assets/js/scripts.js
r1054035 r1054491 1 1 var dir=[],file=[],readOnly=[],editors=[], dir_back, THEME_EDITOR, fontSize = 16, 2 2 submenuColor = jQuery("#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu").css("background"); 3 getDirBack();4 3 jQuery(document).ready(function() 5 4 { 5 getDirBack(); 6 6 7 jQuery("#gm_slider").css("background", jQuery("#wpadminbar").css("background")); 7 8 jQuery("#gm_hotbar").css("background", jQuery("#wpadminbar").css("background")); … … 62 63 jQuery("ul.scandir_ul li a").on('click',function(){ 63 64 var e = getID(); 64 dir[e] = dir_back+jQuery(this).parent().parent("ul").prop("id")+"/";65 dir[e] = jQuery(this).parent().parent("ul").data("dir-folder")+"/"; 65 66 file[e] = jQuery(this).html(); 66 67 readFromFile(dir[e]+file[e],editors[e]); … … 122 123 } 123 124 function addEditor(){ 124 dir[editors.length]= dir_back+"../";125 dir[editors.length]="/"; 125 126 file[editors.length]="index.php"; 126 127 readOnly[editors.length]=false; … … 128 129 jQuery("#gm_editors").append("<div id='text_file_"+(editors.length-1+2)+"'></div>"); 129 130 var editor_r = ace.edit("text_file_"+(editors.length-1+2)); 131 130 132 editor_r.setTheme("ace/theme/"+THEME_EDITOR); 131 133 editor_r.getSession().setMode("ace/mode/php"); … … 133 135 editor_r.getSession().setUseWrapMode(true); 134 136 editor_r.getSession().setUseSoftTabs(false); 137 135 138 editor_r.commands.addCommand({ 136 139 name:'save', // название команды … … 177 180 } 178 181 function getDirBack(){ 179 dir_back = "../../../"182 dir_back = jQuery("#filedit").data("back-dir"); 180 183 } 181 184 function readFromFile(filedir,editor){ 182 185 jQuery.ajax({ 183 186 type:"POST", 184 url: "/wp-content/plugins/gmace/includes/ace.php",187 url:jQuery("#filedit").data("dir")+"/includes/ace.php", 185 188 dataType:"html", 186 189 data:{ … … 188 191 }, 189 192 success:function(html){ 190 if(filedir.substr(filedir.length-3,3)=='css'){ 191 editor.getSession().setMode("ace/mode/css"); 192 }else if(filedir.substr(filedir.length-2,2)=='js'){ 193 editor.getSession().setMode("ace/mode/javascript"); 194 }else if(filedir.substr(filedir.length-4,4)=='html'){ 195 editor.getSession().setMode("ace/mode/html"); 196 }else if(filedir.substr(filedir.length-8,8)=='htaccess'){ 197 editor.getSession().setMode("ace/mode/apache_conf"); 198 }else if(filedir.substr(filedir.length-4,4)=='java'){ 199 editor.getSession().setMode("ace/mode/java"); 200 }else if(filedir.substr(filedir.length-2,2)=='py'){ 201 editor.getSession().setMode("ace/mode/python"); 202 }else{ 203 editor.getSession().setMode("ace/mode/php"); 204 } 193 setModeEditor(editor, filedir); 205 194 editor.setValue(html); 206 195 editor.gotoLine(0); … … 211 200 jQuery.ajax({ 212 201 type:"POST", 213 url: "/wp-content/plugins/gmace/includes/ace.php",202 url:jQuery("#filedit").data("dir")+"/includes/ace.php", 214 203 dataType:"html", 215 204 data:{ … … 218 207 }, 219 208 success:function(html){ 220 jQuery("#messages").html("<div class='gm_success'>Файл <i>"+filedir .replace("../../../..",'')+"</i> перезаписан.</div>");209 jQuery("#messages").html("<div class='gm_success'>Файл <i>"+filedir+"</i> перезаписан.</div>"); 221 210 }, 222 211 error:function(html){ 223 jQuery("#messages").html("<div class='gm_error'>Ошибка перезаписи файла <i>"+filedir .replace("../../../..",'')+"</i> !</div>");212 jQuery("#messages").html("<div class='gm_error'>Ошибка перезаписи файла <i>"+filedir+"</i> !</div>"); 224 213 } 225 214 }); … … 228 217 jQuery.ajax({ 229 218 type:"POST", 230 url: "/wp-content/plugins/gmace/includes/settings.php",219 url:jQuery("#filedit").data("dir")+"/includes/settings.php", 231 220 dataType:"html", 232 221 data:{ … … 261 250 }); 262 251 } 252 function setModeEditor(editor, filedir){ 253 if(filedir.substr(filedir.length-3,3)=='css'){ 254 editor.getSession().setMode("ace/mode/css"); 255 }else if(filedir.substr(filedir.length-2,2)=='js'){ 256 editor.getSession().setMode("ace/mode/javascript"); 257 }else if(filedir.substr(filedir.length-4,4)=='html'){ 258 editor.getSession().setMode("ace/mode/html"); 259 }else if(filedir.substr(filedir.length-8,8)=='htaccess'){ 260 editor.getSession().setMode("ace/mode/apache_conf"); 261 }else if(filedir.substr(filedir.length-4,4)=='java'){ 262 editor.getSession().setMode("ace/mode/java"); 263 }else if(filedir.substr(filedir.length-2,2)=='py'){ 264 editor.getSession().setMode("ace/mode/python"); 265 }else{ 266 editor.getSession().setMode("ace/mode/php"); 267 } 268 } -
gmace/trunk/gmace.php
r1053990 r1054491 1 1 <?php 2 2 /* 3 Plugin Name: GMAce4 Plugin URI: http://wordpress.org/plugins/gmace/5 Description: Свободный PHP-редактор кода Wordpress6 Version: 1.1 7 Author: German Mesky8 Author URI: http://vk.com/false_coder3 Plugin Name: GMAce 4 Plugin URI: http://wordpress.org/plugins/gmace/ 5 Description: Свободный PHP-редактор кода Wordpress 6 Version: 1.2 7 Author: German Mesky 8 Author URI: http://vk.com/false_coder 9 9 */ 10 if(function_exists("add_action")){ 11 define("IS_WP", true); 10 12 11 define('GMACE_DIR', plugin_dir_path(__FILE__));12 define('GMACE_URL', plugin_dir_url(__FILE__));13 define('GMACE_DIR', plugin_dir_path(__FILE__)); 14 define('GMACE_URL', plugin_dir_url(__FILE__)); 13 15 14 include(GMACE_DIR."includes/settings.php"); 15 16 function gmace_load(){ 16 include(GMACE_DIR."includes/settings.php"); 17 17 18 $settings = new Settings();18 $settings = new Settings(); 19 19 20 if(is_admin()) 21 add_action('admin_menu', array($settings,'ConfigureMenu')); 22 } 23 gmace_load(); 20 if(is_admin()) 21 add_action('admin_menu', array($settings,'ConfigureMenu')); 22 }else{ 23 define("IS_WP", false); 24 25 include("includes/ace.php"); 26 include("includes/settings.php"); 27 28 $settings = new Settings(); 29 30 $ace = new GMAce($settings->getTheme()); 31 32 define("GMACE_URL", $ace->get_real_path().GMACE_DIR."/"); 33 } 24 34 ?> -
gmace/trunk/includes/ace.php
r1053869 r1054491 1 1 <?php 2 2 if($_POST['file']){ 3 fpassthru(fopen($_POST['file'],'r')); 3 $ace = new GMAce(""); 4 fpassthru(fopen($ace->get_real_back().$_POST['file'],'r')); 4 5 exit; 5 6 }elseif($_POST['refile']){ 6 $file=fopen($_POST['refile'],'w'); 7 $ace = new GMAce(""); 8 $file=fopen($ace->get_real_back().$_POST['refile'],'w'); 7 9 fputs($file,$_POST['content']); 8 10 } … … 13 15 public static $SCAN_DIR; 14 16 public static $THEME; 17 public static $G_DIR; 18 public static $BACK_G_DIR; 15 19 16 20 function GMAce($theme){ 17 $this->SCAN_DIR="../.."; 18 $this->TYPE="ul"; 19 $this->THEME=$theme; 21 $this->BACK_G_DIR = $this->get_real_back(); 22 $this->SCAN_DIR = "../".$this->BACK_G_DIR; 23 $this->TYPE = "ul"; 24 $this->THEME = $theme; 25 if(!IS_WP) 26 $this->G_DIR = $this->get_real_path().GMACE_DIR; 27 else 28 $this->G_DIR = str_replace(basename(GMACE_URL)."/", basename(GMACE_URL), GMACE_URL); 29 20 30 } 21 31 22 32 //CALL IN <HEAD> 23 33 function scripts($dir){ 34 $dir.="/assets"; 24 35 print("<link rel='stylesheet' href='$dir/css/style.css'>"); 36 if(!IS_WP){ 37 print("<script src='$dir/js/jquery.js'></script>"); 38 } 25 39 print("<script src='$dir/js/scripts.js'></script>"); 26 40 print("<script src='$dir/js/ace/ace.js'></script>"); … … 31 45 include("content.php"); 32 46 } 33 47 34 48 function scaning_dir($dir){ 35 $fd="<ul class='scandir_ul' id='$dir'>"; 49 if($dir == ".") 50 $dir = ""; 51 $fd="<ul class='scandir_ul' data-dir-folder='".str_replace("/www", "", $dir)."'>"; 36 52 $folders; 37 53 $folder_id=0; 38 54 $files; 39 55 $file_id=0; 40 foreach(scandir($ dir) as $index=>$val){41 if(filetype($ dir."/".$val)=="dir"){56 foreach(scandir($this->SCAN_DIR.$dir) as $index=>$val){ 57 if(filetype($this->SCAN_DIR.$dir."/".$val)=="dir"){ 42 58 if($val!="."&$val!=".."){ 43 59 $folders[$folder_id]=$val; … … 59 75 $fd.="<li class='icon' type='$bg'><a>$files[$i]</a></li>"; 60 76 } 61 if($dir != $this->SCAN_DIR)77 if($dir != "") 62 78 $fd.="</ul></div>"; 63 79 … … 97 113 return $bg; 98 114 } 115 function get_real_path(){ 116 return str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']); 117 } 118 function get_real_back(){ 119 return str_repeat("../", substr_count($this->get_real_path(), "/")-1); 120 } 99 121 } 100 122 ?> -
gmace/trunk/includes/content.php
r1053987 r1054491 1 <div id="filedit" data-theme="<?php print($this->THEME);?>" >1 <div id="filedit" data-theme="<?php print($this->THEME);?>" data-dir="<?php print($this->G_DIR);?>" data-back-dir="<?php print($this->BACK_G_DIR);?>"> 2 2 <div id="messages"></div> 3 3 <div id="text_file"> … … 18 18 <div id="file"> 19 19 <span></span> 20 <div><?php print($this->scaning_dir( $this->SCAN_DIR));?></div>20 <div><?php print($this->scaning_dir("."));?></div> 21 21 </div> 22 22 <div id="gm_actions"> -
gmace/trunk/includes/editor.php
r1053869 r1054491 1 1 <?php 2 include("ace.php"); 2 if(!class_exists("GMAce")){ 3 include("ace.php"); 4 } 3 5 include("settings.php"); 4 6 … … 7 9 $ace = new GMAce($settings->getTheme()); 8 10 9 $ace->scripts(GMACE_URL .'assets');11 $ace->scripts(GMACE_URL); 10 12 $ace->build_editor(); 11 13 ?> -
gmace/trunk/includes/settings.php
r1053869 r1054491 1 1 <?php 2 if(!class_exists("GMAce")){ 3 include("ace.php"); 4 } 2 5 if($_POST['change_theme']){ 3 $file = fopen("../../../../wp-admin/gm_theme", "w"); 6 $ace = new GMAce(""); 7 $dir = $ace->get_real_back(); 8 9 $file = fopen($dir."gm_theme", "w"); 4 10 fputs($file, $_POST['change_theme']); 5 11 fclose($file); … … 11 17 } 12 18 function getTheme(){ 13 if(file_exists("gm_theme")) 19 $ace = new GMAce(""); 20 $dir = $ace->get_real_back(); 21 22 if(file_exists($dir."gm_theme")) 14 23 $mode = "r"; 15 24 else 16 25 $mode = "w"; 17 $file = fopen( "gm_theme", $mode);26 $file = fopen($dir."gm_theme", $mode); 18 27 if($mode=="w"){ 19 28 $theme = "dreamweaver"; -
gmace/trunk/readme.txt
r1054073 r1054491 4 4 Requires at least: 4.0 5 5 Tested up to: 4.1 6 Stable tag: 1. 16 Stable tag: 1.2 7 7 License: GNU 8 8 License URI: license.txt … … 28 28 == Changelog == 29 29 30 = 1.2 = 31 * Plugin can now be used not only in Wordpress (Example page, you will find next to the readme.txt) 32 * Improved script code 33 * Fixed some bugs 34 30 35 = 1.1 = 31 36 * Fixed an issue where when you resize the editor, the code is not stretched at full length
Note: See TracChangeset
for help on using the changeset viewer.