From: Matt M. <mcn...@ap...> - 2001-03-01 13:56:24
|
With today's (hopefully) tarball, we will include the beginnings of the the plugin module. You will notice that this is not version 0.8.0 however for the reason that we want feedback on its functionality. Here is a summary of how it works before you go into the code. First, there is a new table entitled 'plugins'. Here is the structure: | plug_id | name | source_file | img | plug_dir | block_pos | block_file | | admin_only | user_only | admin_inc | about | This structure is open to change and suggestions. plug_id: The index of the plug-ins name: The name of the plug-in. Appears in the admin menu. source_file: name of the the one file that is in the root of your web directory. img: The icon for your plugin. Appears in the admin menu. block_pos: If the plugin fills in a block, this is where it appears. 1=left, 2=top center, 3=right, 0=not at all block_file: name of the file that fills in the data of the plug in box. admin_only: if = 1, block only appears for the admin user_only: if = 1, block only appears for users admin_inc: the include function sent to source_file that points it to the administrative functions for that plugin. about: information about the author(s) and the plugin phpWeather I used an existing program to make a plugin. It is named phpweather and written by Martin Geisler at gim...@gi.... Now the short coming of me using a rather simple program (simple in its implementation, not its coding =-) ) is that I may have overlooked problems down the road with plugins. We shall see after you guys and gals test it. There are a few components to a plugin. 1) weather_setup.php - The setup file. I am staying away from forcing users to perform SQL imports by telnet or command line. This program inserts itself into the plugins table and creates a new table named 'metar' for its operation. I had some problems getting this file to run from the /webdir/plug-ins/phpweather/ directory. You could run a file from its plug-in directory but holding the theme in the setup page caused problems. In that case, your plugin setup page would chuck the css just for the install. I like the setup the way I have it because you have to login as an admin to get it to function. It has been suggested that the page automatically search for new plugins and lead you through the install. The downside to this I see is that it has to do a file search everytime the admin logins in. You could chron job but that is IMHO a waste of cycles. Of course, I may be overlooking something and you can give me information on another way to do this. Again, it needs to be web-based and simple. 2) weather_admin.php - This is an idea Adam came up with. One file, in the main directory, with all the function includes. So, here is that file. It is the file pointed to by the icon in the admin menu. phpweather did not have admin functions so I wrote this quick and dirty file to perform some of the tasks I wanted to have in its display. It moves the box around and decides who gets to see it. This 'admin' file could do anything. It doesn't have to move a box around, these are just examples. 3) phpweather directory - We want all the other pages in their own directory. I need some feedback of whether all folders should sit under a central 'plug-ins' directory or just under the root. I prefer this way. The install So the user gets the plugin and unzips/untars it. It should write the main file in the root along with the install file. It will also create the phpweather directory under the plug-ins directory. You can then either start the SQL install or FTP it. Now they need to login as the admin and type in the name of the install file. It takes them through a confirmation and then it writes the database info. That's it. If they run the file again, they get an error. Now the weather should appear for Boone, NC. I did not do multiple city setup, because this is an example ONLY. If someone wants to make a full featured weather plugin, then by all means =) If you want to change it, just look in phpweather.php, it is easy to change. On the admin side, phpWebSite will find the SQL record and put up the icon for the plugin. Clicking on the icon takes you to the setup screen. Some things not included but considered: an uninstall file, a function to automatically delete the setup file. Conclusion I have tried to make this plugin ability as clean and easy as possible. Again, you are free to suggest modifications or ideas to make it better. We would like to finalize a standard by version 0.8.0. Thanks for the help from everyone supporting this product, the developers that want to join us, the great group I work with, and finally PHPPLUGIN which is the code I stole and then just slapped my name on. ;-) Matthew McNaney |