Archived CMSimple Support Forum

The Old CMSimple User Community
It is currently Thu Sep 02, 2010 4:36 pm

This archived CMSimple Support Forum will be locked primo June 2008. Users with a commercial licence are advised to register and use the new Official Support Forum at CMSimple.com instead. A community driven forum with free registration is found at cmsimpleforum.com.

All times are UTC




Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 55 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
 Post subject: A Hook for developers.
PostPosted: Tue Apr 05, 2005 9:04 pm 
Offline

Joined: Sat Jan 10, 2004 1:57 am
Posts: 438
Location: Rochester, England.
I would like the following code to be included in cms.php at line 50, which is currently blank.


Code:
@include($pth['folder']['cmsimple'].'extra.php');



This allows me to write any additional function in a file called extra.php, enough processing has been done by that stage give me access to the files and directory paths. xtra.php is a simple name that is self explanatory. It can be used to build up a function library or it can be used to @include any other php file containing addons or plugins.

Either way it makes developing code far simpler.

Maybe there is an argument for putting this at line 100, on the blank line between.
Code:
$cl=0;
rfc();

$f='';
.

Lets discuss.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 06, 2005 6:54 am 
Offline
Site Admin

Joined: Mon May 12, 2003 12:36 pm
Posts: 3091
Location: Rutsker, Bornholm, Denmark
Thanks for your suggestion - I'll consider it.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 13, 2005 12:12 pm 
Offline

Joined: Fri Sep 10, 2004 1:29 pm
Posts: 254
Location: Søborg/Denmark
I think it would be a good idea to make a standard include 'interface' like the one you suggest clem. Then the users of add-ons, just could add one line pr. add-on, with a simple include. And a potential problem with messing up cms.php is eliminated, and the installation process would be more simple to explain.

Should there also be one common include to config.php and [language].php ?

Instead of the include solution, It would be nice if CMSimple had a "add add-on" function under settings. But how to solve config.php, [language].php, folders, admin for each add-on I can't figure out.

svarrer.dk has 'hacked' his way into the CMSimple control panel and made an excellent solution for handling a add-on adminpage. But the problem is - It’s only solving svarrer's admin integration, all other add-ons will have to make their own similar hacks.
Could CMSimple offer a standard solution ?
Filling add-ons buttons under the current control panel or perhaps just a "add-on button" on the current line, like "settings" work today.

Perhaps CMSimple should have conventions/rules to what a add-on minimum should have, to qualify to a "add add-on" function under settings.

As I see it, CMSimple as a standard packages already includes some add-ons - mail form, guestbook and search. How about separate them from the core CMSimple code and make them included add-ons ? Just to lead the way on how it should be done.

- The novice CMSimple user (still) wont have to worry about adding add-ons.
- The intermediate user could benefit from the add-ons more easily.
- The experienced user could still hacks his way though the original code.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 13, 2005 12:25 pm 
Offline

Joined: Wed Dec 31, 2003 1:07 pm
Posts: 2494
Location: planet earth
Quote:
$cl=0;
rfc();
$f='';
@include($pth['folder']['cmsimple'].'extra.php');
The include should be behind $f=''; so there would be a way to set $f to anything else then nothing.
-
Hi,

This is not needed:

1. This has to be done by everyone who wants to include his own code. Therefore he will need coding experience. So he will find this line himself or better let his hands off the cms.php code.

2. This is no real help for developers and has nothing to do with modularity, what really would be needed.

djot
-


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 13, 2005 1:47 pm 
Offline

Joined: Fri Sep 10, 2004 1:29 pm
Posts: 254
Location: Søborg/Denmark
I read Clem suggestion as it should be a benefit for the user of CMSimple add-ons, not the developer of add-ons.

Please keep the discussing going - I think its an important subject.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 13, 2005 2:10 pm 
Offline

Joined: Fri Feb 04, 2005 8:30 am
Posts: 475
Location: Belgium
Dear coders,

I'm starting developping a general 'plug-in' function for CMSimple.

The idea behind it is the following:

only one changement in cms.php has to be done
after $f='';
Code:
checkplugin();


and adding the checkplugin() function at the end of the cms.php file

How it works (hopefully :wink: )

this checkplugin function verifies a predefined folder in the main called ' plugins'. Each plugin has its own folder with a predefined folder structure:
- css
- images
- includes
- language
[plugin].php

So the checkplugin() function automatically includes the [plugin].php file.
This [plugin].php filename MUST have the same name as the plugin folder name. The rest of the code handling is done within the [plugin].php file.
When the plugin uses another CSS file, the link to this external CSS will be added to the original template stylesheet automatically (but only once)

Is this a good approach ?

:arrow: Feedback / suggestions / remarks is much appreciated...

Jan


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 13, 2005 3:31 pm 
Offline

Joined: Fri Sep 10, 2004 1:29 pm
Posts: 254
Location: Søborg/Denmark
JAT > I think it sounds like you on towards something very well thought - Both simple and smart.

It will sure help the USERS of CMSimple to integrate the add-ons more easily.
Just upload, and your up and running.

CMSimple will benefit from such an improvement.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 13, 2005 3:49 pm 
Offline

Joined: Fri Oct 29, 2004 6:52 am
Posts: 338
Location: Denmark, Aalborg
Hi all

JAT i like the idea, simple and still higly configurable.

The plugins which requires an admin part still has a problem. Any idea on how to solve this - a common way of doing the admin stuff would be very nice, any one have a idea?

/Michael


Top
 Profile  
 
 Post subject: Single point of entry.
PostPosted: Wed Apr 13, 2005 4:46 pm 
Offline

Joined: Sat Jan 10, 2004 1:57 am
Posts: 438
Location: Rochester, England.
I like all the ideas that are put forward.

My requirements are:

1. A single point of entry in cms.php. Cms.php is Peters file and does change fairly regularly. I want to keep my code in my file. I don't wish to have to copy my patches over each time. Because of this I have many versions 'live' on different sites, it is too confusing.

2. It must be easy to document- while the program is simple- the documentation is not. It must be easy to integrate a plug in, and to explain how to use it!

I can live with either approach. In the meantime, try
extra.php
<?
checkplugin();
?>

Let the discussion continue.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 13, 2005 9:15 pm 
Offline
Site Admin

Joined: Mon May 12, 2003 12:36 pm
Posts: 3091
Location: Rutsker, Bornholm, Denmark
Quote:
I want to keep my code in my file. I don't wish to have to copy my patches over each time. Because of this I have many versions 'live' on different sites, it is too confusing.


Normally I add extra site specific code in the template.

But if it is add-ons it should be configured in the config.php, shouldn't it?


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 03, 2005 6:37 pm 
Offline

Joined: Fri Oct 29, 2004 6:52 am
Posts: 338
Location: Denmark, Aalborg
Okay just made a plugin loader plugin, based on the idea by JAT :lol:

The idea is to make installation and development of plugins simple

1. Add
Code:
$pth['folder']['plugins']=$pth['folder']['base'].'plugins/';
include($pth['folder']['plugins'].'index.php');
Do this change to cms.php arround line 100 then it looks like this:

Code:
$cl=0;
rfc();

$f='';

$pth['folder']['plugins']=$pth['folder']['base'].'plugins/';
include($pth['folder']['plugins'].'index.php');

if($sitemap)$f='sitemap';


This part loads the index.php (the plugin loader) in the plugins folder !

2. Make a folder called plugins at same level as cmsimple, templates,images...

3. Take the code below and save it in a file called index.php in the plugins folder.

Code:
<?php
// **************************************************
// * Plugin loader by www.svarrer.dk                *
// * 03-05-05 : First release                       *
// **************************************************
// loads the plugins from the plugins folder index.php
$handle=opendir($pth['folder']['plugins']);
while ($plugin = readdir($handle)) {           
    if ($plugin != "." && $plugin != ".." && is_dir($pth['folder']['plugins'].$plugin)){                   
      if(!@include($pth['folder']['plugins'].$plugin.'/index.php'))die('Plugin Error : '.$pth['folder']['plugins'].$plugin.'/index.php missing');

//loads the language file if avaliable
if (!isset($sl))$sl=$cf['language']['default'];
$pth['file']['plugins_language']=$pth['folder']['plugins'].$plugin.'/languages/'.$sl.'.php';
@include($pth['file']['plugins_language']);

//add the css to the header
if(is_file($pth['folder']['plugins'].$plugin.'/css/stylesheet.css'))
{$hjs.="<link rel='stylesheet' href='".$pth['folder']['plugins'].$plugin."/css/stylesheet.css' type='text/css'>";}
}}

// loads the admin functions admin.php
if($adm)
{
$i=0;
$o .="<table class='edit' width='100%' cellpadding='1' cellspacing='0' border='1'><tr>";

$handle=opendir($pth['folder']['plugins']);
   while ($plugin = readdir($handle)) {           
    if ($plugin != "." && $plugin != ".." && is_dir($pth['folder']['plugins'].$plugin)){                   
if(is_file($pth['folder']['plugins'].$plugin.'/admin.php'))
{
$o .="<td align='left'><a href='$sn?&".$plugin."'>".$plugin."</a></td>";
$admin_plugins[$i] = $plugin;
$i++;
}
if(is_file($pth['folder']['plugins'].$plugin.'/css/stylesheet.css'))
{$hjs.="<link rel='stylesheet' href='".$pth['folder']['plugins'].$plugin."/css/stylesheet.css' type='text/css'>";}
//loads the language file if avaliable
if (!isset($sl))$sl=$cf['language']['default'];
$pth['file']['plugins_language']=$pth['folder']['plugins'].$plugin.'/languages/'.$sl.'.php';
@include($pth['file']['plugins_language']);

}}
$o .="</tr></table></div>";
}
foreach($admin_plugins as $plugin){include($pth['folder']['plugins'].$plugin.'/admin.php');}
?>


4. installation complete, now write some plugins !

To make a plugin create a folder as a subfolder of plugins eg. calendar and place the code of the plugin in index.php.

The language files are placed in the subfolder 'language' (da.php,en.php.ge.php...)
The same applies for the stylesheet subfolder which contains the stylesheet.css
if a admin function is written it is saved in the admin.php in the same folder as index.php

All in all it then plugins folder looks like this

- calendar
index.php
admin.php
- css
stylesheet.css
- languages
da.php
de.php
en.php

It seems an easy approach both for installer and developer.
Suggestions and feedback is much appreciated :wink:


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 03, 2005 10:39 pm 
Offline

Joined: Fri Feb 04, 2005 8:30 am
Posts: 475
Location: Belgium
Hi svarrer,

nice start of the plugin loader...

I have some additional suggestions...

don't call the language files [xx].php but plugin_[XYZ]_[xx].php
con't call the configuration file config.php but plugin_[XYZ]_config.php

the reason for this is that (in the future) we can separate CMSimple configuration & language settings from the plugin config & language settings...
Also change the cf & tx prefix to a unique one for each plugin
Code:
$adv_mf_tx['receiver_email']="Receiver e-mail address";
$adv_mf_cf['required_field_labels']="Name,Phone Nbr,E-Mail,Comments";
$adv_mf_cf['required_field_names']="name,phone,email,comments";


I'm currently programming on this kind of settings from the administration panel... (in function of an advanced mailform plugin)

I have both plugin settings for config & language in a separate .php file in 2 different subfolders of my plugin main folder...

And it's already working (just finished it right now...)

The mailform is based on formmailer.php - I just need to program the dynamic form layout from within the administration panel...

If you want me to send the code, please let me know via PM

Nice to see that my idea about the plugin addon wasn't that bad :wink:

JAT

PS. tested the plugin loader already
:arrow: included the an admin.php & index.php file in the root of my plugin folder

so far my plugin works fine (as far as I could test...) also the admin is nicely added in the administration page...

Does this mean you're gonna rewrite you cms_packages as well ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 04, 2005 5:49 am 
Offline

Joined: Fri Oct 29, 2004 6:52 am
Posts: 338
Location: Denmark, Aalborg
Quote:
I have some additional suggestions...

don't call the language files [xx].php but plugin_[XYZ]_[xx].php
con't call the configuration file config.php but plugin_[XYZ]_config.php


Why, the [xx].php is already in a language subfolder of the plugin which again is a subfolder of plugins, i like to keep simple filenames.
The same applies for the config.php i only would like one at the same folder level as index.php,admin.php

Quote:
Also change the cf & tx prefix to a unique one for each plugin
Okay this idea i like, to keep things seperated.

Quote:
Does this mean you're gonna rewrite you cms_packages as well ?
Already done but not official yet, send a PM if you want the code !


Top
 Profile  
 
 Post subject: GREAT !!
PostPosted: Wed May 04, 2005 9:06 pm 
Offline

Joined: Fri Sep 10, 2004 1:29 pm
Posts: 254
Location: Søborg/Denmark
GREAT !!

This is perfect - I have been strugeling with the same kind of code, but with no success of making it working 100% (in fact my code was partly based on svarrer's gallery plugin)

It works great, with my new (not ready) HOOK compatible version of newsimple.

This is a smart way for users to install plugins.

Plugin variable names (i.e. $cf, $tx) should be prefixed with something unique (like the plugin name) to avoyed conflicts, with other plugins (and CMSimple)

I would like to keep language files called en.php, da.php and config.php ect ect whitout the prefix (its given by the folder name)

Nice work.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 04, 2005 9:29 pm 
Offline
Site Admin

Joined: Mon May 12, 2003 12:36 pm
Posts: 3091
Location: Rutsker, Bornholm, Denmark
JAT Svarrer - it looks very good!

I'll be happy to include some code in cms.php that includes the plugin's index-file if $pth['folder']['plugins'] has been set ...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 55 posts ]  Go to page 1, 2, 3, 4  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group