1
Dylian
Template editor
  • 2010/2/2 10:22

  • Dylian

  • Friend of XOOPS

  • Posts: 237

  • Since: 2007/7/21


First, I´d like to say: I realy LOVE the new template manager

But I think it would be even better if it included a syntax higlighting code editor like [EditArea] instead of just a plain textarea.

Just my opinion but I would realy realy like to have this feature in XOOPS .

Greets Dylian.

BTW If its not going to come in 2.5 i'll try to make a hack for it myself

2
jimmyx
Re: Template editor
  • 2010/2/4 22:53

  • jimmyx

  • Quite a regular

  • Posts: 338

  • Since: 2007/7/18


i support his ...this will be a great improvement

3
Dylian
Re: Template editor
  • 2010/2/12 23:19

  • Dylian

  • Friend of XOOPS

  • Posts: 237

  • Since: 2007/7/21


Ok, as i promised in my previous post, i would do the hack myself if nonone else did it.

And i did... So for everyone interesed (CORE TEAM PLEASE???) the hack can be downloaded [HERE].

And my question to the core development team... PLEASE ADD THIS TO THE CORE....

[edit]
SCREENSHOT:
Resized Image
[/edit]

[edit2]
Haha, i was so impressed with the file manager that i added it there first, template manager comming soon...
[/edit2]

Greets Dylian.

BTW I used CodeMirror instead of Editarea, it has a lot more features.

4
jimmyx
Re: Template editor
  • 2010/2/13 2:17

  • jimmyx

  • Quite a regular

  • Posts: 338

  • Since: 2007/7/18


great.......


i can't wait 2.5 to be final......


any chance to include this in 2.4x version ?

5
Mamba
Re: Template editor
  • 2010/2/13 8:15

  • Mamba

  • Moderator

  • Posts: 11366

  • Since: 2004/4/23


@ Dylian: This is fantastic!!! Nice work!! Congratulations, and thank you for doing it!

@ jimmyx: unless somebody will provide you with a hack, the Core team will not include it in 2.4.x, because 2.4.x is in "maintenance mode" only

6
kraven30
Re: Template editor
  • 2010/2/13 11:57

  • kraven30

  • Just popping in

  • Posts: 88

  • Since: 2008/12/23


Good Job Dylan

PS: We searched with Muss to add syntax coloring but we had not found an interesting plugin, thx CodeMirror, thx Dylian . To add in templates editor and filemanager, there will be no worries but the core, I don't know

Did you work on the latest version of SVN?

++

7
Dylian
Re: Template editor
  • 2010/2/13 12:12

  • Dylian

  • Friend of XOOPS

  • Posts: 237

  • Since: 2007/7/21


Ok, updated the package, template manager now also has the CodeMirror editor. And i changed the code to first check what kind of file is loaded, so the right parser can be loaded .

Quote:
Did you work on the latest version of SVN?

No i used the files from xo25a. But the hack is very easy to implement so i don't think it would be hard to add it to the latest version.

Greets Dylian.

8
kraven30
Re: Template editor
  • 2010/2/15 12:26

  • kraven30

  • Just popping in

  • Posts: 88

  • Since: 2008/12/23


There is a bug with Firefox, code mirror dont work. On IE and Chrome, it's ok. On firefox, it works with you ?

++

9
Dylian
Re: Template editor
  • 2010/2/16 14:03

  • Dylian

  • Friend of XOOPS

  • Posts: 237

  • Since: 2007/7/21


Ok, fixed it... The dom tree was changed after CodeMirror was loaded, so i moved the code from the jquery.php files to the js files (filemanager.js and templates.js).

Here is how to implemented the hacks.

Template manager hack:
Step 1: Add
$xoTheme->addScript('browse.php?modules/system/js/codemirror.js');
after
$xoTheme->addScript('browse.php?modules/system/js/templates.js');
in modules/system/admin/tplsets/main.php .

Step 2: Add
$xoTheme->addStylesheetXOOPS_URL '/modules/system/css/docs.css');
after
$xoTheme->addStylesheetXOOPS_URL '/modules/system/css/admin.css');
in modules/system/admin/tplsets/main.php .

Step 3: Change
function tpls_edit_file(path_filefile)
{
    $(
'#display_contenu').hide();
    $(
'#display_form').hide();
    $(
'#loading').show();
    $.
ajax({
        
type"POST",
        
url"./admin/tplsets/jquery.php",
        
data"op=tpls_edit_file&path_file="+path_file+"&file="+file,
        
success: function(msg){            
            $(
'#display_contenu').html(msg);
            $(
'#loading').hide();
            $(
'#display_contenu').fadeIn('fast');
        }
    });    
    return 
false;
}
to
function tpls_edit_file(path_filefile)
{
    $(
'#display_contenu').hide();
    $(
'#display_form').hide();
    $(
'#loading').show();
    $.
ajax({
        
type"POST",
        
url"./admin/tplsets/jquery.php",
        
data"op=tpls_edit_file&path_file="+path_file+"&file="+file,
        
success: function(msg){            
            $(
'#display_contenu').html(msg);
            $(
'#loading').hide();
            $(
'#display_contenu').fadeIn('fast');
            if(
path_file.slice(-3) == "css"){
                var 
editor CodeMirror.fromTextArea("template_code", {    
                    
height"350px",
                    
parserfile"parsecss.js",
                    
stylesheet"css/csscolors.css",                    
                    
lineNumberstrue,
                    
textWrappingfalse
                    
path"js/"                
                
});
            }else if(
path_file.slice(-3) == ".js"){
                var 
editor CodeMirror.fromTextArea("template_code", {
                    
height"350px",
                    
parserfile: ["tokenizejavascript.js""parsejavascript.js"],
                    
stylesheet"css/jscolors.css",
                    
autoMatchParenstrue,
                    
lineNumberstrue,
                    
textWrappingfalse
                    
path"js/"
                
});
            }else{
                var 
editor CodeMirror.fromTextArea("template_code", {
                    
height"350px",
                    
parserfile: ["parsexml.js""parsecss.js""tokenizejavascript.js""parsejavascript.js",
                                
"tokenizephp.js""parsephp.js",
                                
"parsephphtmlmixed.js"],
                    
stylesheet: ["css/xmlcolors.css""css/jscolors.css""css/csscolors.css""css/phpcolors.css"],
                    
lineNumberstrue,
                    
textWrappingfalse
                    
path"js/",
                    
continuousScanning500
                
});
            }
        }
    });    
    return 
false;
}
in modules/system/js/templates.js .

Step 4: Change
<textarea name="templates" rows=24 cols=110>'.$content.'</textarea>
to
<textarea id="template_code" name="templates" rows=24 cols=110>'.$content.'</textarea>
in modules/system/admin/tplsets/jquery.php.

That should do it for the template manager, the hack for the filemanager is almost the same but here's the guide for that ...

File manager hack:
Step 1: Add
$xoTheme->addScript('browse.php?modules/system/js/codemirror.js');
after
$xoTheme->addScript('browse.php?modules/system/js/templates.js');
in modules/system/admin/filemanager/main.php .

Step 2: Add
$xoTheme->addStylesheetXOOPS_URL '/modules/system/css/docs.css');
after
$xoTheme->addStylesheetXOOPS_URL '/modules/system/css/admin.css');
in modules/system/admin/filemanager/main.php .

Step 3: Change
function filemanager_edit_file(path_filepathfile)
{
    $(
'#display_file').hide();
    $(
'#edit_file').hide();
    $(
'#loading').show();
    $.
ajax({
        
type"POST",
        
url"./admin/filemanager/jquery.php",
        
data"op=filemanager_edit_file&path_file="+path_file+"&path="+path+"&file="+file,
        
success: function(msg){
            $(
'#edit_file').html(msg);
            $(
'#loading').hide();
            $(
'#edit_file').fadeIn('fast');
        }
    });    
    return 
false;
}
to
function filemanager_edit_file(path_filepathfile)
{
    $(
'#display_file').hide();
    $(
'#edit_file').hide();
    $(
'#loading').show();
    $.
ajax({
        
type"POST",
        
url"./admin/filemanager/jquery.php",
        
data"op=filemanager_edit_file&path_file="+path_file+"&path="+path+"&file="+file,
        
success: function(msg){
            $(
'#edit_file').html(msg);
            $(
'#loading').hide();
            $(
'#edit_file').fadeIn('fast');
            if(
path_file.slice(-3) == "css"){
                var 
editor CodeMirror.fromTextArea("filemanager_code", {    
                    
height"350px",
                    
parserfile"parsecss.js",
                    
stylesheet"css/csscolors.css",                    
                    
lineNumberstrue,
                    
textWrappingfalse
                    
path"js/"                
                
});
            }else if(
path_file.slice(-3) == ".js"){
                var 
editor CodeMirror.fromTextArea("filemanager_code", {
                    
height"350px",
                    
parserfile: ["tokenizejavascript.js""parsejavascript.js"],
                    
stylesheet"css/jscolors.css",
                    
autoMatchParenstrue,
                    
lineNumberstrue,
                    
textWrappingfalse
                    
path"js/"
                
});
            }else{
                var 
editor CodeMirror.fromTextArea("filemanager_code", {
                    
height"350px",
                    
parserfile: ["parsexml.js""parsecss.js""tokenizejavascript.js""parsejavascript.js",
                                
"tokenizephp.js""parsephp.js",
                                
"parsephphtmlmixed.js"],
                    
stylesheet: ["css/xmlcolors.css""css/jscolors.css""css/csscolors.css""css/phpcolors.css"],
                    
lineNumberstrue,
                    
textWrappingfalse
                    
path"js/",
                    
continuousScanning500
                
});
            }
        }
    });    
    return 
false;
}
in modules/system/js/filemanager.js .

Step 4: Change
<textarea name="filemanager" rows=24 cols=110>'.$content.'</textarea>
to
<textarea id="filemanager_code" name="filemanager" rows=24 cols=110>'.$content.'</textarea>
in modules/system/admin/filemanager/jquery.php.

The package is also updated (Still based on the code delivered with XOOPS 2.5 Alpha) :-p.

I hope it works and it will be included in the core.

Greets Dylian.

BTW, got the solution from this Google Groups post:http://groups.google.com/group/codemirror/browse_thread/thread/1a7a5f529eccc1a/a5928c35dff3ef80?lnk=gst&q=false#a5928c35dff3ef80

10
frankblack
Re: Template editor
  • 2010/2/16 17:07

  • frankblack

  • Just can't stay away

  • Posts: 830

  • Since: 2005/6/13


Nice work! Just two questions/comments?

How is the edited file saved back to the server? I assume you can run into trouble with owner rights and chmods, but perhaps I am wrong...

Whenever I use addScript or addStylesheet I pass on some more information although this is optional:

$xoTheme->addScript('browse.php?modules/system/js/codemirror.js', array('type' => 'text/javascript''charset' => _CHARSET), null);


$xoTheme->addStylesheetXOOPS_URL '/modules/system/css/docs.css', array('type' => 'text/css''media' => 'screen'), null);

Login

Who's Online

215 user(s) are online (148 user(s) are browsing Support Forums)


Members: 0


Guests: 215


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits