Author Topic: Hello World Module  (Read 70393 times)

kozmoz

  • Guest
Re: Hello World Module
« Reply #50 on: October 15, 2006, 11:10:17 PM »
Great module to use as a start...

Some suggestions:
- I would like to see this module at the addons page too.
- This module does not demonstrate the upgrade feature.

To add upgrade functionality, increment the version number and add a new file named "upgrade.php". Now when reinstalling WebsiteBaker detects the module has upgraded and calls the upgrade.php script automatically. The upgrade script can handle tasks link database schema changes etc.

Bugs I found while using WebsiteBaker:

Description of the problem: Installer should also block versions of modules already installed.
File: admin/modules/install.php - line 79
Old code: if ($module_version>$new_module_version) {
Solution: if ($module_version >= $new_module_version) {

Description of the problem: Version number in addons table not updated after module upgrade.
File: admin/modules/install.php - line 129
Old code: No code
Solution: Add this:

Code: [Select]
upgrade_module($module_directory, false);

in functions.php add:

// Upgrade module info in DB, optionally start upgrade script
function upgrade_module($directory, $upgrade = false) {
global $database, $admin, $MESSAGE;
$directory = WB_PATH . "/modules/$directory";
if(file_exists($directory.'/info.php')) {
require($directory.'/info.php');
if(isset($module_name)) {
if(!isset($module_license)) { $module_license = 'GNU General Public License'; }
if(!isset($module_platform) AND isset($module_designed_for)) { $module_platform = $module_designed_for; }
if(!isset($module_function) AND isset($module_type)) { $module_function = $module_type; }
$module_function = strtolower($module_function);
// Check that it does already exist
$result = $database->query("SELECT addon_id FROM ".TABLE_PREFIX."addons WHERE directory = '".$module_directory."' LIMIT 0,1");
if($result->numRows() > 0) {
// Update in DB
$query = "UPDATE " . TABLE_PREFIX . "addons SET " .
"version = '$module_version', " .
"description = '" . addslashes($module_description) . "', " .
"platform = '$module_platform', " .
"author = '$module_author', " .
"license = '$module_license'" .
"WHERE directory = '$module_directory'";
$database->query($query);
// Run upgrade script
if($upgrade == true) {
if(file_exists($directory.'/upgrade.php')) {
require($directory.'/upgrade.php');
}
}
}
}
}
}

Offline ruebenwurzel

  • Betatester
  • **
  • Posts: 8391
  • Gender: Male
  • Keep on Rockin
    • Familie Gallas Online
Re: Hello World Module
« Reply #51 on: October 16, 2006, 06:13:26 AM »
Hello,

Quote
I would like to see this module at the addons page too.

Hmmm i think its only a goog starting point for developpers. The biggest problem in this modul is the variable of the modul directory. During installation the files of the modul gets temporary unzipped in the temp folder. At this moment the relative path for the modul wich is taken from the info.php is wrong. This works on a lot of servers without problems, but on some servers the modul didin't install. That's why we didn't take it to the Add-ons Repository.

Quote
Bugs I found while using WebsiteBaker:
Would write you to post this in the bugtracker at Ticket 332 but i have seen you have already done it. Thanks

Quote
To add upgrade functionality, increment the version number and add a new file named "upgrade.php".
Thought about a similar solution. The problem is that with your solution we have to add an improovement to the upgrade.php wich adds databases entries depending on the previous installed version. This is needed when somenone upgrades from an older version. Mean someone has version1.0 of a modul and wanna now upgrade to version 1.5. This needs other scripts then when he upgrades frm version 1.4 to 1.5.
RSmith had the idea to write an improovement in the modify.php of the modules, wich checks everytime when the modul is called in the admin area of wb if all tables are present and if not install them.

So I'm not shure wich is the way we should go.

thanks for your work with WB. I think we have another on who can help us making WB better and better.

Matthias

kozmoz

  • Guest
Re: Hello World Module
« Reply #52 on: October 16, 2006, 03:30:34 PM »
Quote
Hmmm i think its only a goog starting point for developers.

That's right. Maybe listed under a new category "development".

The addons page should be the starting page with all modules listed. I mean, now the forum contains n versions of the hello world module which could even be in different threads. When I'm looking for a module, the page I expect the latest version to find should be the addons page. This applies to all available modules, development modules included.

Quote
Quote
To add upgrade functionality, increment the version number and add a new file named "upgrade.php".
Thought about a similar solution. The problem is that with your solution we have to add an improovement to the upgrade.php wich adds databases entries depending on the previous installed version. This is needed when somenone upgrades from an older version. Mean someone has version1.0 of a modul and wanna now upgrade to version 1.5. This needs other scripts then when he upgrades frm version 1.4 to 1.5.
RSmith had the idea to write an improovement in the modify.php of the modules, wich checks everytime when the modul is called in the admin area of wb if all tables are present and if not install them.

This can be solved easily.

Add for every upgrade during time a new function to your upgrade script. When upgrading, check the current version number and determine which functions to call, start with the oldest first.
An example:

An user has an example module with version 1.0 installed. In the mean time development has progressed and the current version number is 1.4. Not every release has some DB changes.

Now when the user upgrades the script checks the current version and calls the function for upgrade from 1.0 to 1.1 first, then in sequence the function for upgrade for 1.2 to 1.3 (1.2 has no DB changes) and then the function for upgrade from 1.3 to 1.4. Now it updates its version number in the addons table. The module is current now.

When another user has version 1.3 of the same module installed and starts an upgrade, the upgrade function will only start the script for upgrading from 1.3 to 1.4 and updates the version number in the addons table.

I think you shouldn't touch modify.php for this task. Modify.php should modify the content and not something else you would not expect in that file. Keeping these tasks separated.
« Last Edit: October 16, 2006, 03:57:27 PM by kozmoz »

celia

  • Guest
Re: Hello World Module
« Reply #53 on: October 21, 2006, 12:38:12 AM »
Hi

I've succesfully installer hello world v3. I'm trying to use it to create a new module, I change the value of $module_directory in info.php. The mod installs with the right name but it won't create a table on my SQL database, and I can't create a page. I've tried hardcoding the value in the database create function in install, reinstalling, etc.. nothing works. any ideas?

thanks a lot

Offline baZzz

  • Posts: 68
  • Gender: Male
Re: Hello World Module
« Reply #54 on: January 21, 2007, 10:21:09 PM »
Hi all,

I installed the HelloWorld module today, because it was about time that I got into this module development thing... :-) Too bad there is *very* little information to be found on this topic, so the module is all we developer newbies have. And off course, I had problems installing the module as well. I don't understand why this example mod has info.php included in every file, while none of the 'real' mods seem to do so. (I now understand why they don't, because it doesn't work flawlessly, as can be seen from all of the reactions here.) So I modified the mod so it (de)installs and runs smoothly on my server. I removed all the includes and added the code:
Code: [Select]
$module_directory = 'helloworld'; to every page. Nothing spectacular, but it does the trick without producing errors. I've included this version with this topic, so more ppl can profit from it (hopefully). Starting to develop your own module is already hard enough, so you shouldn't have to concern yourself with troubleshooting the example code... (Just my 2 cents...  :wink: )
« Last Edit: February 09, 2007, 12:09:37 PM by baZzz »

Offline ruebenwurzel

  • Betatester
  • **
  • Posts: 8391
  • Gender: Male
  • Keep on Rockin
    • Familie Gallas Online
Re: Hello World Module
« Reply #55 on: January 22, 2007, 05:45:40 AM »
Hello baZzz,

this was a very bad idea  :evil:  :evil:. The idea for including the info.php is that modul developpers only have to change once in the info.php the modulname and in all otherfiles this new name is used. What you habve done now is a step back. If now a modul developper changes the name of his modul he has to go to every file. So please delete your version in the post above.

Thanks

Matthias

Offline baZzz

  • Posts: 68
  • Gender: Male
Re: Hello World Module
« Reply #56 on: January 22, 2007, 02:56:30 PM »
Hello baZzz,

this was a very bad idea  :evil:  :evil:. The idea for including the info.php is that modul developpers only have to change once in the info.php the modulname and in all otherfiles this new name is used.
Matthias,

I entirely agree with you, IF ONLY the include would work on every system! Why is it that none of the modules (as far as I've seen) use this method of including the info.php?
If you can make a version that works correctly (on all configurations) I'd be more than happily to remove my version and take my hat off to you... ;-)

Regards,
Bas

Offline ruebenwurzel

  • Betatester
  • **
  • Posts: 8391
  • Gender: Male
  • Keep on Rockin
    • Familie Gallas Online
Re: Hello World Module
« Reply #57 on: January 22, 2007, 03:09:50 PM »
Hello,

if you had read all posts you would know the answer.  :-D. The Hello world modul only should show developpers whats needes for a modul and if a modul is ready i always recommand to replace the variables $module_directory with hardcoded names. The issue of the variable is (and thats known and often talked about) that on special servers at the time when you install the modul the variable didn't work because the temporary path is another then when the modul is installed.

Matthias

Offline baZzz

  • Posts: 68
  • Gender: Male
Re: Hello World Module
« Reply #58 on: February 09, 2007, 12:21:24 PM »
Sorry for the late reply, I was on vacation for 2 weeks in Malaysia...! :-D
I now see your point and have removed the attachment from my previous post. One of the main reasons why I made the changes is because when you start developing a module and you don't know anything about the way they work (like me :-) ) then the first thing you would want to do, is to install the example module and see how it works. It is demotivating if then you cannot even install it, let alone be able to see how it works. But I now understand that the code is meant entirely as an example to build on, not to use. One tip though, if you would replace the existing $module_directory with something that is not PHP code, it would be more obvious.
As an example, instead of this:
Code: [Select]
...->query("SELECT * FROM ".TABLE_PREFIX."mod_".$module_directory." WHERE section_id = '".$section_id."'");You could do this:
Code: [Select]
...->query("SELECT * FROM ".TABLE_PREFIX."mod_<<MODULE DIR NAME HERE>> WHERE section_id = '".$section_id."'");Using a standard variable name gives the impression that the code is meant to be like that.

-Bas

Offline ruebenwurzel

  • Betatester
  • **
  • Posts: 8391
  • Gender: Male
  • Keep on Rockin
    • Familie Gallas Online
Re: Hello World Module
« Reply #59 on: February 09, 2007, 01:13:39 PM »
Hello,

the hello worl modul works on the most servers as it is right now. Only on some special servers (yours included) we run into this problem. As for the most it works as it is i think we should not change it, and the few ones where it doesn't works we can help here.

Matthias

scottm52

  • Guest
Re: Hello World Module
« Reply #60 on: March 13, 2007, 02:17:43 PM »
I'm sure this has been thought of before......  But, havn't found a post on it...

Has anyone considered using the Hello World module for creation of a module that essentially gives the functionality of "wrapper" to the admin area?

For example, when you want to include another OSS component but either don't have that degree of programming ability...  Or, the need to do anything but mod the authentication and just wrap the rest?

This way, the possibility of simply "wrapping" the other project would reduce upgrade needs (as it's simply a wrapper with authentication modding), and garner the ability to simply publish the wrapper for WebsiteBaker and can add many more modules without the administrative overhead?

Just a thought...

scottm

doc

  • Guest
New release of: Hello World Module
« Reply #61 on: August 07, 2007, 07:43:25 PM »
Hello,

this post is just to inform the Community, that a new version of the hello world module was released on the Addons Repository (Section Miscellaneous).

All files does now include a short description of it´s purpose. The latest version includes features introduced with WB v2.6.6 (possibility to use external CSS and Javascript files; which are automatically included to the head of the template). Further on, multilingual support was added. The basic aspects of creating more secure modules are highlighted (XSS, SQL Injection, defacing...). The problem which occured on some servers during intallation process is fixed in this version.

So please use this module as baseline for developing own modules.

Have fun
Christian

P.S.: If you want learn how to create a Hello World Code Snippet, have a look on this thread.
« Last Edit: August 07, 2007, 08:30:20 PM by doc »

Offline kweitzel

  • WebsiteBaker Org e.V.
  • **
  • Posts: 6983
  • Gender: Male
Re: Hello World Module
« Reply #62 on: August 07, 2007, 08:11:36 PM »
Hi Christian,

thanks a lot ... also for all the stuff you are doing latly (without our help ...)!!!

cheers

Klaus

Eki

  • Guest
Hello World Module: Dutch language file
« Reply #63 on: December 12, 2007, 11:48:13 AM »
Hi all,

Please find attached the Dutch language file for the Hello World module.

regards,
Erik


[gelöscht durch Administrator]

Offline Luckyluke

  • Posts: 556
  • Gender: Male
  • Let's Rock
Re: Hello World Module: Dutch language file
« Reply #64 on: December 12, 2007, 07:24:42 PM »
Dankuwel!
Groetjes,
Luc (Brugge, België)  :lol:

doc

  • Guest
Hello World Module: v0.44
« Reply #65 on: December 12, 2007, 08:23:22 PM »
Hello Eki,

attached the Dutch language file and released v0.44 of the Hello world module.

Regards Christian
« Last Edit: December 17, 2007, 09:07:54 AM by doc »

doc

  • Guest
Hello World Module v0.45 released
« Reply #66 on: January 07, 2008, 06:00:15 PM »
Hello,

the latest release of the Hello world module (v0.45) includes the possibility to edit the frontend.css and backend.css files via the module backend. The latest version can be found on the Addons repository.

Adding this feature to any other module is fairly easy:
a) copy files: css.functions.php and edit_css.php to your module
b) include css.functions.php from your modify.php
c) invoke css_edit() in your modify.php where the Edit CSS button should display
d) optional: style the button via backend.css
e) optional: add 4 lines to languages files to customize output (see /language/EN.php for example)

Regards Christian
« Last Edit: January 08, 2008, 10:24:10 AM by doc »

doc

  • Guest
Re: Hello World Module
« Reply #67 on: January 11, 2008, 10:17:11 AM »
Hello,

can anybody test the latest version of the Hello world module with Internet Explorer 7 on Windows Vista?

Seems that this configuration (Vista + IE 7.0) has some problems with editing the frontend.css and backend.css files properly. All other browsers (IE, Opera etc.) and operating systems works as intented.

Any feedback welcome.

Regards Christian

P.S.: On Opera there is an issue with the codepress library which can be solved by following the steps in this thread here.
« Last Edit: January 11, 2008, 10:55:13 AM by doc »

doc

  • Guest
Re: Hello World Module
« Reply #68 on: January 12, 2008, 02:42:43 PM »
Hello,

this is just to inform you that the current Hello World modul v0.45 contains a bug which prevents that changes on the frontend.css / backend.css files can be saved.

The bug occurs with Internet Explorer 7 in combination with Windows Vista. We will fix this bug and report the solution here once finished.

Regards Christian

doc

  • Guest
Re: Hello World Module
« Reply #69 on: January 28, 2008, 09:53:03 PM »
Hello,

forgot to mention that the Bug is fixed in the latest Hello Worl version v0.47. To get the codepress working on all browsers, you need to update /include/codepress to the latest version available.

Regards Christian

Offline gila

  • Posts: 49
Re: Hello World Module
« Reply #70 on: March 18, 2008, 05:31:31 PM »
is possible with this module add a field in the page settings where put the link of a css to have a different css in every page?

i can't use a different template because i have to une a different  image background to every page and i have more than 100 pages.

doc

  • Guest
Hello World Module
« Reply #71 on: March 30, 2008, 03:48:06 PM »
Hello,

just released Hello world v0.50 on the Addons repository.

The following bugs are fixed:
 - fixed editing module CSS bug (it was not possible to edit CSS files if more than one module was used per page)
 - added ` quotes to all DB table/field names (prevent errors with special characters in DB table/field names)
 - fixed mix up of functions striptags() and $wb->strip_tags()
 - added multilingual support for the module description (introduced with WB 2.7)

Regards Christian
« Last Edit: March 30, 2008, 10:17:53 PM by doc »

doc

  • Guest
Hello World Module v0.60
« Reply #72 on: April 06, 2008, 09:32:52 PM »
Hello,

just released Hello World module v0.60 on the Addons repository.

The latest release uses the integrated edit module CSS functions of the WB 2.7 core (introduced with WB 2.7 RC3).
This gives module authors the possibility to add this feature by calling the following function from the WB core:
Code: [Select]
<?php
if(function_exists(&#39;edit_module_css&#39;)) {
  
edit_module_css(&#39;helloworld&#39;);
}
?>


To add this feature to WB 2.6.x, one needs to copy the files /framework/module.functions.php and edit_module_files.p hp from a WB 2.7 (RC3 or higher) to the WB 2.6.x installation. In addition one needs to define 3 language variables in the WB language files:
Code: [Select]
$TEXT['CAP_EDIT_CSS'] = 'Edit CSS';
$TEXT['HEADING_CSS_FILE'] = 'Actual module file: ';
$TEXT['TXT_EDIT_CSS_FILE'] = 'Edit the CSS definitions in the textarea below.';

Regards Christian

doc

  • Guest
Hello World module (deprecated)
« Reply #73 on: March 15, 2009, 08:01:05 AM »
Hello,

please be aware, that the code basis of the "Hello World" module is outdated. You should not use the "Hello world" module any longer as basis for your onw modules. The Hello World module will be replaced by a step-by-step Module Primer (German Module-Leitfaden), which is currently under development.

The "module primer" is an open project, which means open for everybody interested in contributing to the project. To learn more about the project, please visit the German or English module thread.

The "Module Primer" will be splitted into the following steps:
  • Step 1 (EN, DE): Basics (development platform, introduction of basic module files)
  • Step 2a (EN, DE): Purpose of module CSS files (usage of frontend.css and backend.css)
  • Step 2b (EN, DE): Adding multi-lingual support
  • Step 2c (EN, DE): Using template engines (separate PHP code and HTML markup)
  • Step 3: Interacting with the database (what are add.php, delete.php, install.php, uninstall.php for)
  • Step 4: Basics on module security (permission, authentification, XSS, SQL injection etc.)

Please note: You must login to the forum in order to download the "Module Primer" files linked above.

Each step of the "module primer" comes along with a README file (plain text) and a worked out module example. Any kind of help on this project is welcome. If you would like to help, please send me a Personal Message via the WebsiteBaker community forum or post in the German or English module thread.

Regards Christian
« Last Edit: March 15, 2009, 08:03:19 AM by doc »

Offline sare

  • Posts: 29
Re: Hello World Module
« Reply #74 on: March 17, 2009, 01:22:20 PM »
Thank you for the information! This is GREAT news for anyone interested in the techical aspect of modules and WB.

 

postern-length