Topic Closed
juergen
1.4K Posts
51.6K Downloads
16 Plugins
design, web development & visual effects

I currently consider relaunching my own main website (from 2005 O_o) using gpEasy.
A central component missing for this endeavor is a file management for my customers. Up to now I used (besides WebDAV) a custom solution which I could embed into gpEasy using an iframe but gpEasy's built-in Finder is tempting.

For that purpose I would need to invoke Finder with a different basePath.

I already fiddled a bit with the code in admin_uploaded.php and managed to render Finder on a page but I wasn't able to actually change the basePath.
Perhaps there is a simple solution I have missed?

Thx

Edited: 4 years ago#7986

juergen
1.4K Posts
51.6K Downloads
16 Plugins
design, web development & visual effects

It seems that gpSettingsOverride() is not implemented in current gpEasy. The only occurrence I found is in common.php at line 52 and it's just an empty function:

if( !function_exists('gpSettingsOverride') ){
    function gpSettingsOverride(){}
}

So i changed it to …

if( !function_exists('gpSettingsOverride') ){
    function gpSettingsOverride($setting,$val) {
    msg("gpSettingsOverride -- setting: " . $setting . " -- value: " . pre($val));
    }
}

…to see if it will catch the call - and, yes it does.

If I'm right, this means gpSettingsOverride('finder_options_server', $finderServerOpts) and gpSettingsOverride('finder_options_client', $finderClientOpts) won't do anything and therefore finder will always launch with default settings.

Has this changed recently or am I still missing something?

TIA for any advice!

Edited: 4 years ago#7988

fly06
263 Posts
18.2K Downloads
1 Themes
8 Plugins

Hi Juergen,

GitHub is your friend:

https://github.com/oyejorge/gpEasy-CMS/search?utf8=%E2%9C%93&q=gpSettingsOverride

The finder will launch with default settings unless you override the gpSettingsOverride() function in your own plugin.

F.

4 years ago#7998

juergen
1.4K Posts
51.6K Downloads
16 Plugins
design, web development & visual effects
Ahhh, yes. Thanks a lot!

edit:/  Seems, it has not been used so many times yet.
Edited: 4 years ago#7999

juergen
1.4K Posts
51.6K Downloads
16 Plugins
design, web development & visual effects
Frédéric, could you please give me an example how to do it, let's say, in a Gadget?
I'm still quite a bumbler when it comes to function scopes and object oriented coding in PHP :-/
4 years ago#8000

juergen
1.4K Posts
51.6K Downloads
16 Plugins
design, web development & visual effects
… or to be more specific …

I cannot find a way to declare the function gpSettingsOverride() inside a plugin because there is no plugin hook called before the conditional declaration of the function in common.php in line 52.

/index.php -> require_once('./include/main.php')  in line 32
/include/main.php -> require_once('common.php'); in line 7
 
4 years ago#8001

fly06
263 Posts
18.2K Downloads
1 Themes
8 Plugins

I cannot find a way to declare the function gpSettingsOverride() inside a plugin because there is no plugin hook called before the conditional declaration of the function in common.php in line 52.

This is correct.

A (dirty) solution would consist in adding/removing your gpSettingsOverride() function in the gpconfig.php file programmatically when you plugin is installed/uninstalled.

 

 

 

4 years ago#8002

juergen
1.4K Posts
51.6K Downloads
16 Plugins
design, web development & visual effects

Dirty and worth to be considered working :)

 

edit:/ BTW - It's your Front End User plugin, which I would try to extend with user pages and user file management ;-)

edit2:/ But since $opts are a variable I also had to change connector.php
from gpSettingsOverride('finder_options_server', $opts);
to $opts = gpSettingsOverride('finder_options_server',$opts); to make it work.
So ... hmm... a hook like gpPlugin::Action('FinderOptionsServer',$opts); would be better.

... I'll post it in Plugin Hooks
 

Edited: 4 years ago#8003

fly06
263 Posts
18.2K Downloads
1 Themes
8 Plugins

You have to pass the $opt variable by reference:

function gpSettingsOverride($setting,&$opt) {

// FUNCTION BODY

}

http://php.net/manual/en/language.references.pass.php

4 years ago#8006

juergen
1.4K Posts
51.6K Downloads
16 Plugins
design, web development & visual effects

Thanks Frédéric, that seems to work basically.

Unfortunately, there are several other problems I don't understand yet, such as a "too much recursion" error in jQuery and some others.
It's quite hard for me to understand if and how long a custom backend configuration is in effect since finder itself is loaded via JS.
Maybe it's a better route to use a finder instance independent from gpEasy's backend config and without all the file-event-hooks getting called (e.g. I don't need gpEasy thumbnails in customer file area). Not as easy as I initially thought it would be.

4 years ago#8008

juergen
1.4K Posts
51.6K Downloads
16 Plugins
design, web development & visual effects
Stubborn me - it still bothers me.

When i append this to gpconfig.php:
/*##StartPatch##*/
function gpSettingsOverride($setting,&$opts) {

  switch ($setting) {

    case 'finder_options_server' :
      if (is_callable(array("CustomFinder", "ServerOptions"))) {
        $opts = CustomFinder::ServerOptions($opts);
        msg("gpSettingsOverride() called CustomFinder::ServerOptions()");
      } else {
        /* this will show in Finder as error */
        die("gpSettingsOverride() -- CustomFinder::ServerOptions() is not callable");
      }
      break;

    case 'finder_options_client' :
      if (is_callable(array("CustomFinder", "ClientOptions"))) {
        $opts = CustomFinder::ClientOptions($opts);
        msg("gpSettingsOverride() called CustomFinder::ClientOptions()");
      } else {
        msg("gpSettingsOverride() CustomFinder::ClientOptions() is not callable");
      }
      break;

    default:
      msg("gpSettingsOverride() called with argument 1: <em>" . $setting . "</em>.");
  }
}
/*##EndPatch##*/

 

… using this minmalist plugin: CustomFinder.zip
("CustomFinder" Gadget must be included into a page to see Finder)

CustomFinder::ServerOptions() will not be callable from the connector backend, obviously, but how could I make this work?

Edited: 4 years ago#8010

fly06
263 Posts
18.2K Downloads
1 Themes
8 Plugins

CustomFinder::ServerOptions() will not be callable from the connector backend, obviously, but how could I make this work?

Include your CustomFinder.php somewhere before your custom gpSettingsOverride() get called.

Furthermore if you want to call the ServerOptions() method statically you will have to use the self keyword instead of the $this keyword.

http://www.diffen.com/difference/self_(PHP)_vs_this_(PHP)

4 years ago#8019

juergen
1.4K Posts
51.6K Downloads
16 Plugins
design, web development & visual effects

Include your CustomFinder.php somewhere before your custom gpSettingsOverride() get called.

That's exactly the problem. Actually I want a different finder root for every user, so I need to have all the info available. gpconfig.php is not the right place for that.
So it definitely needs a hook - a filter to be more specific - that's called before/when the connector backend is created.
I haven't made a plugin hook yet, but I guess i will figure it out eventually ;-)
With the filter I will get rid of the gpconfig patching hopefully.

Thanks once more for your help, Frédéric!

 

Edited: 4 years ago#8020

fly06
263 Posts
18.2K Downloads
1 Themes
8 Plugins

Hi Juergen,

I think you are confusing two different aspects of your code here.

The gpconfig.php file is (currently) the only place where you can declare your own gpSettingsOverride() function.

Now if in this function, when it is called, you need to access to a custom global object or a static class, you can declare this class and possibly create a global object by using one the already available hooks that get called before the connector.php is loaded.

A good candidate for this is the WhichPage hook.

4 years ago#8024

juergen
1.4K Posts
51.6K Downloads
16 Plugins
design, web development & visual effects

I think you are confusing two different aspects of your code here.

Admittedly, it's quite confusing and new to me since i haven't used own globals yet.
But there are also some aspects of the current approach that seem quite error prone:

  • Declaring a custom gpSettingsOverride: The function call is rather old (gpEasy 3.5 or so) but was never used and seems to be abandoned or at least uncompleted. I doubt it will survive future versions in this current form. On the other hand, if gpSettingsOverride will actually be used some day, it will clearly conflict with my custom function.
  • Patching gpconfig.php: I do not exactly like to do that because it's not meant to be written programmatically and may(should) lack write permissions as well.

For these reasons I'd prefer to have special hooks to filter finder settings, FinderOptionsServer($opts) and FinderOptionsClient($opts) to be specific.
These would make the use of custom finder instances easy and plausible and keep things apart that shouldn't get mixed.

The road there is rocky but I always learn new aspects of gpEasy this way, so it's worth the effort.
 

4 years ago#8026

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

gpSettingsOverride() isn't a great option for plugins but it did help me implement the demo and free subdomain features on gpEasy.com.

Are these the hooks you'd like?

4 years ago#8048

juergen
1.4K Posts
51.6K Downloads
16 Plugins
design, web development & visual effects

Are these the hooks you'd like?

Um, yes … they look much like mine. Only mine are not working.
Your's usually do. Do they? ;^)

(Meaning … which files do I have to replace?)

4 years ago#8050

Josh S.
2K Posts
267K Downloads
16 Themes
18 Plugins
I haven't tested these hooks and they're not in the master branch yet, but the version with the hooks can be downloaded here.
4 years ago#8061

juergen
1.4K Posts
51.6K Downloads
16 Plugins
design, web development & visual effects
As far as I have tested, the hooks work fine.
Thank you!
4 years ago#8075

Josh S.
2K Posts
267K Downloads
16 Themes
18 Plugins
Awesome, great to hear!
4 years ago#8076

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

creisi productions

Dienstleistungen von creisi productions, Luzern (Schweiz): * Konzeption, Planung und Erstellung Ihres Internet-Auftritts * Betreuung und Aktualisierung/Pflege Ihrer Website * ...

Find out more about our Provider Spotlight

Log In

  Register