The following warnings occurred:
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/class_parser.php 584 errorHandler->error_callback
/inc/class_parser.php 228 postParser->parse_mycode
/printthread.php 203 postParser->parse_message
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/class_parser.php 584 errorHandler->error_callback
/inc/class_parser.php 228 postParser->parse_mycode
/printthread.php 203 postParser->parse_message
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/class_parser.php 584 errorHandler->error_callback
/inc/class_parser.php 228 postParser->parse_mycode
/printthread.php 203 postParser->parse_message
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/class_parser.php 584 errorHandler->error_callback
/inc/class_parser.php 228 postParser->parse_mycode
/printthread.php 203 postParser->parse_message
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/class_parser.php 584 errorHandler->error_callback
/inc/class_parser.php 228 postParser->parse_mycode
/printthread.php 203 postParser->parse_message
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/class_parser.php 584 errorHandler->error_callback
/inc/class_parser.php 228 postParser->parse_mycode
/printthread.php 203 postParser->parse_message
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/class_parser.php 584 errorHandler->error_callback
/inc/class_parser.php 228 postParser->parse_mycode
/printthread.php 203 postParser->parse_message



GetSimple Support Forum
Multi-file plugins - Printable Version

+- GetSimple Support Forum (http://get-simple.info/forums)
+-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3)
+--- Forum: Feature Requests (http://get-simple.info/forums/forumdisplay.php?fid=7)
+--- Thread: Multi-file plugins (/showthread.php?tid=994)



Multi-file plugins - tankmiche - 2010-09-24

Hello.
I'm writing a plugin myself, and as it would also include a bit of AJAX I'm trying to fit all the functions and checks in one single file.
Which is bad, in my opinion, it's starting to get messy.

My question is: should I provide myplugin.php with a "myplugin" folder, the first then requiring the proper scripts in "myplugin"?

I ask because I thought of a much cleaner solution, but it needs a modification of "admin/inc/plugin_functions.php":
  • Check plugin files in GSPLUGINPATH, ending in php (as it is now)
  • Check also for folders with a file "plugin.php" or "$(folder name).php" in them (proposed solution)
  • Include the found php file



Multi-file plugins - Zegnåt - 2010-09-25

tankmiche Wrote:Should I provide myplugin.php with a “myplugin” folder, the first then requiring the proper scripts in “myplugin”?
Many plugins already come together with a folder to hold other files. So yes, that’s the best way to go.

You are right, it might be cleaner to check for folders within the plugins folder. Good idea that will be taken in consideration for the next update of the plugin system.


Multi-file plugins - JWH_Matthew - 2010-09-25

Automatically including Files within a plugins folder could cause some issues, not all plugins are including files in the plugin itself but in the templates and other administration pages or nowhere at all.

How would it be determined witch files to include?

Does this make sense?


Multi-file plugins - Zegnåt - 2010-09-25

What I (like to) think tankmiche meant is something like this:

  1. Include all PHP files within GSPLUGINPATH.
  2. Read through folders within GSPLUGINPATH.
  3. If the folder within GSPLUGINPATH includes a file called plugin.php, include this one file.

This way, if I have a plugin that needs several files all of my files can go within the folder instead of having one file outside of the folder. It makes the plugins folder much easier to oversee. 1 file plugins can exist of only their 1 PHP file in the plugin folder. Other plugins exist of only a folder in the plugin folder. Instead of the way they do now: 1 PHP file and 1 folder.


Multi-file plugins - tankmiche - 2010-09-25

Exactly, sorry for the poor phrasing, when saying "include" I actually meant the require() function as is already used now in plugins_function(). OWS_Matthew, plugins are "included" this way in every page, even though most of them won't use their functions.

Here's the example form plugin_functions.php:23

Code:
foreach ($pluginfiles as $fi)
{
    $pathExt = pathinfo($fi,PATHINFO_EXTENSION );
    $pathName= pathinfo($fi,PATHINFO_FILENAME );
    if ($pathExt=="php")
    {
        $pluginsLoaded=true;
        require_once(GSPLUGINPATH . $fi);
    }
}

Here's the modified code:

Code:
foreach ($pluginfiles as $fi)
{
    $pathExt = pathinfo($fi,PATHINFO_EXTENSION );
    $pathName= pathinfo($fi,PATHINFO_FILENAME );

    if (is_file(GSPLUGINPATH . $fi)){
        if($pathExt == "php"){
            $pluginsLoaded=true;
            require_once(GSPLUGINPATH . $fi);
        }
    } else {
        if($fi != "." && $fi != ".." && is_file(GSPLUGINPATH . $fi . '/plugin.php')){
            $pluginsLoaded=true;
            require_once(GSPLUGINPATH . $fi . '/plugin.php');
        }
    }
}

I added is_file to the first check to avoid requiring directories, and then to check for the existance of a "plugin.php" file.
Note that the slash '/' is supposed to be fine for Win* platforms, and the "." and ".." directories are excluded from the list.


Multi-file plugins - ccagle8 - 2010-09-25

thanks tankmiche - so this works fine in your setup? does your setup have a combination of plugins that are built the old way and also some with the /folder/plugin.php file?


Multi-file plugins - tankmiche - 2010-09-25

ccagle8 Wrote:thanks tankmiche - so this works fine in your setup? does your setup have a combination of plugins that are built the old way and also some with the /folder/plugin.php file?
I'm actually in the middle of the upgrade to the latest version - my ftp service is very slow - as soon as I get a working copy I'll check for problems with older plugins.

Edit: I've checked the code with other plugins. An error occours if these coditions are all met:
  • (probable) A plugin "plugerror" is shipped file+directory
  • (improbable) The directory contains a file named plugin.php
  • (probable) The same file is included without "_once" whithin plugerror.php
  • (probable) The plugin system includes directory/plugin.php before plugerror.php

To avoid this risk we could include all files first, then directories with require_once() to prevent errors. Dunno.