Topic Closed
a2exfr
240 Posts
21K Downloads
2 Themes
10 Plugins

For new plugin, on special page I launch Ckeditor like this:

gp_edit::UseCK($this->data[$id]['content'],'item[content]');

and after that I need to organize image adding on page, for that  I used button on click, and Jurgen method creating empty Ck editor to handle gp finder select

window.CKEDITOR = {
        tools : {
          callFunction : function(funcNum,fileUrl) {
            
            if (fileUrl != "") {
                        
                var into = '<img src="' + fileUrl + '" />'
                var info = '<input type="hidden" name="item[image_urls][]" value="' + fileUrl + '" />'
                $( into ).appendTo( '.img_cont' );
                $( info ).appendTo( '.img_cont' );
                   
            }
              
                      
            return true;
          }
        }
      };
    
            
      // open new gpFinder popup window

 var new_gpFinder = window.open(gpFinder_url, 'gpFinder', 'menubar=no');

But after adding image,  editor that launched by gp_edit::UseCK  do not work, throwing TypeError: CKEDITOR.dom is undefined in console.

Qwestion:

- need to reinit somehow editor that started with gp_edit::UseCK, or change empty launch for not to breakin basic editor;

- or to get gpFinder selected file url in variable somehow, without faux Ckeditor.  (Try this but without success.)

I would be very grateful for any help.

edit:  the topic should be called 'How...' not 'Now...'

Edited: 3 years ago#8188

juergen
1.3K Posts
46.3K Downloads
16 Plugins
design, web development & visual effects

or to get gpFinder selected file url in variable somehow, without faux Ckeditor.

My method is in fact sort of a dirty hack and will conflict with any "real" CKEDITOR instance.
I would also be interested in a more tidy solution.

Just a wild guess ...

Have you tried "finder" instead of "elfinder"?

$('selector').finder(options)...
 

Edited: 3 years ago#8190

Josh S.
2K Posts
251K Downloads
16 Themes
18 Plugins

But after adding image,  editor that launched by gp_edit::UseCK  do not work, throwing TypeError: CKEDITOR.dom is undefined in console.

If I'm understanding this correctly, CKEDITOR.dom is undefined because you're redefining CKEDITOR with this code:

window.CKEDITOR = {...

 

3 years ago#8191

juergen
1.3K Posts
46.3K Downloads
16 Plugins
design, web development & visual effects

If I'm understanding this correctly, CKEDITOR.dom is undefined because you're redefining CKEDITOR with this code:

window.CKEDITOR = {...

Yes. In my plugins, there is actually no CKEDITOR object loaded., so I simply create one to catch the finder callback.

In your case there is a real CKEditor. But as we can overwrite everything in JS, it will be overwritten/redefined with my faux object.
You could try to re-init the real CKEditor but  this could be tricky. And it's not exactly beautiful ;^)

3 years ago#8193

a2exfr
240 Posts
21K Downloads
2 Themes
10 Plugins

I decided not to use  faux object, cant reinit CKeditor it's too much options to reproduce.

And use only Finder instead. 

It took me a lot of time to render it on a page, because  call to

  \include\thirdparty\finder\connector.php

throw me error because of 

defined('is_running') or die('Not an entry point...');

so I have to use my  connector without it,  dont know if it bad or no?

About to get file url, after render Finder it's not complicated

   $('#finder').finder({
          //   lang: 'en',         
            url : '/addons/my_addon_name/connector.php',
         getFileCallback: function(file) {
                 
                    console.log(file.url);
                },
        
             });
  

3 years ago#8195

juergen
1.3K Posts
46.3K Downloads
16 Plugins
design, web development & visual effects

so I have to use my  connector without it,  dont know if it bad or no?

If you can invoke a custom finder backend without user authentication it is ... not soo good.

Have you seen the 2 new Hooks (Filters)

finderOptionsClient and finderOptionsServer

We should be able to use the default connector but with custom event bindings/callbacks.
Haven't tested much of the Client Options yet but it should do the trick.

Edited: 3 years ago#8196

a2exfr
240 Posts
21K Downloads
2 Themes
10 Plugins

I really want to do this in right way.

But I call to my connector from js

          
            url : '/addons/my_addon_name/connector.php

and finder start in modal ui  on click here the compete code:

    $("button.add_image").on("click", function(e) { 

   $('<div \>').dialog({modal: true, width: "80%", title: "Select image", zIndex: 99999,
                create: function(event, ui) {
                    $(this).finder({
                        resizable: false,
                        url: '/addons/my_addon_name/connector.php',
                        commandsOptions: {
                          getfile: {
                            oncomplete: 'destroy'
                          }
                        },                            
                        getFileCallback: function(file) {
                         
                            console.log(file.url);
                            //do something
                          
                            $('button.ui-button.ui-widget.ui-state-default.ui-corner-all.ui-button-icon-only.ui-dialog-titlebar-close').click();
                        }
                    }).finder('instance')
                }
            });

});

how to force  it  to work  with  url:  \include\thirdparty\finder\connector.php ???

if i show button with finder for only logged user, and add emty html file in addon folder  it will be enough safe?

 

 

3 years ago#8197

Josh S.
2K Posts
251K Downloads
16 Themes
18 Plugins

It took me a lot of time to render it on a page, because  call to \include\thirdparty\finder\connector.php throw me error because of 

Any reason you don't want to use this url?

/Admin_Browser

 

3 years ago#8198

a2exfr
240 Posts
21K Downloads
2 Themes
10 Plugins

Any reason you don't want to use this url?

/Admin_Browser

No special reasons I just can't make it work.)

With  this in my script   url: '/Admin_Browser',  get

Invalid backend response.
Data is not JSON.

Response:

only can laucnh like this

$page->head .= "\n" . '<script type="text/javascript">gpFinder_url = "' . common::GetUrl('Admin_Browser') . '";</script>' . "\n";

 

var new_gpFinder = window.open(gpFinder_url, 'gpFinder', 'menubar=no');
      if (window.focus) {
        new_gpFinder.focus();
      }

but can't atach

getFileCallback: function(file) {
                          
                            console.log(file.url);
                            
                                    }

to that

3 years ago#8202

Josh S.
2K Posts
251K Downloads
16 Themes
18 Plugins
Here's a plugin that might help. I built it a while back to demonstrate gpFinder functionality in gpEasy.
3 years ago#8206

juergen
1.3K Posts
46.3K Downloads
16 Plugins
design, web development & visual effects

Hey Josh -

if you have more treasure like this lying around, don't hesitate to give it to us!

Such examples are always enlightening how to do things right.

Appreciate it!

3 years ago#8207

a2exfr
240 Posts
21K Downloads
2 Themes
10 Plugins

Wow! thats much better than Docs :)

Thanks Josh !

3 years ago#8208

Josh S.
2K Posts
251K Downloads
16 Themes
18 Plugins
Excellent. Glad that was helpful. I've been meaning to make a series of example plugins like that one.
3 years ago#8213

Topic Closed

 

News

Typesetter 5.1
8/12/2017

Typesetter 5.0.1 is now available for download. 5.1 includes bug fixes, UI/UX improvements, ... Read More

Over 8 Times Faster Than Wordpress
5/3/2016

We've known for a long time that Typesetter is fast. It's something we take pride ... Read More

More News

Communics Online Agency

Online agency based in the Netherlands. We create websites that focus on purpose and conversion. We follow UX & web standards so your visitors get the best website experience.

Find out more about our Provider Spotlight

Log In

  Register