Plugin Directory

Changeset 1054491


Ignore:
Timestamp:
12/26/2014 01:09:57 PM (11 years ago)
Author:
GMDragonX
Message:

update to version 1.2

Location:
gmace/trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • gmace/trunk/assets/js/scripts.js

    r1054035 r1054491  
    11var dir=[],file=[],readOnly=[],editors=[], dir_back, THEME_EDITOR, fontSize = 16,
    22    submenuColor = jQuery("#adminmenu li.wp-has-current-submenu a.wp-has-current-submenu").css("background");
    3 getDirBack();
    43jQuery(document).ready(function()
    54{
     5    getDirBack();
     6
    67    jQuery("#gm_slider").css("background", jQuery("#wpadminbar").css("background"));
    78    jQuery("#gm_hotbar").css("background", jQuery("#wpadminbar").css("background"));
     
    6263    jQuery("ul.scandir_ul li a").on('click',function(){
    6364        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")+"/";
    6566        file[e] = jQuery(this).html();
    6667        readFromFile(dir[e]+file[e],editors[e]);
     
    122123}
    123124function addEditor(){
    124     dir[editors.length]=dir_back+"../";
     125    dir[editors.length]="/";
    125126    file[editors.length]="index.php";
    126127    readOnly[editors.length]=false;
     
    128129    jQuery("#gm_editors").append("<div id='text_file_"+(editors.length-1+2)+"'></div>");
    129130    var editor_r = ace.edit("text_file_"+(editors.length-1+2));
     131   
    130132    editor_r.setTheme("ace/theme/"+THEME_EDITOR);
    131133    editor_r.getSession().setMode("ace/mode/php");
     
    133135    editor_r.getSession().setUseWrapMode(true);
    134136    editor_r.getSession().setUseSoftTabs(false);
     137
    135138    editor_r.commands.addCommand({
    136139        name:'save', // название команды
     
    177180}
    178181function getDirBack(){
    179     dir_back = "../../../"
     182    dir_back = jQuery("#filedit").data("back-dir");
    180183}
    181184function readFromFile(filedir,editor){
    182185    jQuery.ajax({
    183186        type:"POST",
    184         url:"/wp-content/plugins/gmace/includes/ace.php",
     187        url:jQuery("#filedit").data("dir")+"/includes/ace.php",
    185188        dataType:"html",
    186189        data:{
     
    188191        },
    189192        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);
    205194            editor.setValue(html);
    206195            editor.gotoLine(0);
     
    211200    jQuery.ajax({
    212201        type:"POST",
    213         url:"/wp-content/plugins/gmace/includes/ace.php",
     202        url:jQuery("#filedit").data("dir")+"/includes/ace.php",
    214203        dataType:"html",
    215204        data:{
     
    218207        },
    219208        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>");
    221210        },
    222211        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>");
    224213        }
    225214    });
     
    228217    jQuery.ajax({
    229218        type:"POST",
    230         url:"/wp-content/plugins/gmace/includes/settings.php",
     219        url:jQuery("#filedit").data("dir")+"/includes/settings.php",
    231220        dataType:"html",
    232221        data:{
     
    261250    });
    262251}
     252function 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  
    11<?php
    22/*
    3     Plugin Name: GMAce
    4     Plugin URI: http://wordpress.org/plugins/gmace/
    5     Description: Свободный PHP-редактор кода Wordpress
    6     Version: 1.1
    7     Author: German Mesky
    8     Author URI: http://vk.com/false_coder
     3    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
    99*/
     10    if(function_exists("add_action")){
     11        define("IS_WP", true);
    1012
    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__));
    1315
    14     include(GMACE_DIR."includes/settings.php");
    15    
    16     function gmace_load(){
     16        include(GMACE_DIR."includes/settings.php");
    1717
    18         $settings = new Settings();
     18        $settings = new Settings();
    1919
    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    }
    2434?>
  • gmace/trunk/includes/ace.php

    r1053869 r1054491  
    11<?php
    22    if($_POST['file']){
    3         fpassthru(fopen($_POST['file'],'r'));
     3        $ace = new GMAce("");
     4        fpassthru(fopen($ace->get_real_back().$_POST['file'],'r'));
    45        exit;
    56    }elseif($_POST['refile']){
    6         $file=fopen($_POST['refile'],'w');
     7        $ace = new GMAce("");
     8        $file=fopen($ace->get_real_back().$_POST['refile'],'w');
    79        fputs($file,$_POST['content']);
    810    }
     
    1315    public static $SCAN_DIR;
    1416    public static $THEME;
     17    public static $G_DIR;
     18    public static $BACK_G_DIR;
    1519   
    1620    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
    2030    }
    2131   
    2232    //CALL IN <HEAD>
    2333    function scripts($dir){
     34        $dir.="/assets";
    2435        print("<link rel='stylesheet' href='$dir/css/style.css'>");
     36        if(!IS_WP){
     37            print("<script src='$dir/js/jquery.js'></script>");
     38        }
    2539        print("<script src='$dir/js/scripts.js'></script>");
    2640        print("<script src='$dir/js/ace/ace.js'></script>");
     
    3145        include("content.php");
    3246    }
    33    
     47
    3448    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)."'>";
    3652        $folders;
    3753            $folder_id=0;
    3854        $files;
    3955            $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"){
    4258                if($val!="."&$val!=".."){
    4359                    $folders[$folder_id]=$val;
     
    5975            $fd.="<li class='icon' type='$bg'><a>$files[$i]</a></li>";
    6076        }
    61         if($dir != $this->SCAN_DIR)
     77        if($dir != "")
    6278            $fd.="</ul></div>";
    6379       
     
    97113        return $bg;
    98114    }
     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    }
    99121}
    100122?>
  • 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);?>">
    22    <div id="messages"></div>
    33    <div id="text_file">
     
    1818    <div id="file">
    1919          <span></span>
    20           <div><?php print($this->scaning_dir($this->SCAN_DIR));?></div>
     20          <div><?php print($this->scaning_dir("."));?></div>
    2121    </div>
    2222    <div id="gm_actions">
  • gmace/trunk/includes/editor.php

    r1053869 r1054491  
    11<?php
    2     include("ace.php");
     2    if(!class_exists("GMAce")){
     3        include("ace.php");
     4    }
    35    include("settings.php");
    46
     
    79    $ace = new GMAce($settings->getTheme());
    810   
    9     $ace->scripts(GMACE_URL.'assets');
     11    $ace->scripts(GMACE_URL);
    1012    $ace->build_editor();
    1113?>
  • gmace/trunk/includes/settings.php

    r1053869 r1054491  
    11<?php
     2    if(!class_exists("GMAce")){
     3        include("ace.php");
     4    }
    25    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");
    410        fputs($file, $_POST['change_theme']);
    511        fclose($file);
     
    1117            }
    1218            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"))
    1423                    $mode = "r";
    1524                else
    1625                    $mode = "w";
    17                 $file = fopen("gm_theme", $mode);
     26                $file = fopen($dir."gm_theme", $mode);
    1827                if($mode=="w"){
    1928                    $theme = "dreamweaver";
  • gmace/trunk/readme.txt

    r1054073 r1054491  
    44Requires at least: 4.0
    55Tested up to: 4.1
    6 Stable tag: 1.1
     6Stable tag: 1.2
    77License: GNU
    88License URI: license.txt
     
    2828== Changelog ==
    2929
     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
    3035= 1.1 =
    3136* 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.