In 0.7, there'd been many API changes. Here's the howto change existing Plugins to the new platform
To use the new extension installer of eqdkp plus, you need to add a new xml file to validate the needed information to the package installer.
See here for more information: http://wiki.eqdkp-plus.com/dev/index.php/Extension_installer#package.xml
Your plugin should no longer have its own config-table. Instead we wrote a config-class, which is able to manage you config. The functions you need are listed and explained below:
To initially set you config you should use $core->set_config($array_with_defauls, '', 'your_plugin_code'); in the pre_install-function.
The libloader.inc.php is not longer required. remove it, the EQDKP-PLUS 0.7 will do the rest
The Updater need not longer to be implemented in the settings.php. You must remove it, as we introduced a new place for the updates: the Maintenance Mode. Remove the class init "$myclass = new PluginUpdater()" and the "$myclass->OutputHTML()"
You have to remove the "force Database Update" functionality, too. Its removed and handled by the Maintenance Mode.
the armory chars class now requires $urlreader as a global. If you're using armorychars in an own function, make sure you set the required global. If not, the loader will not work.
TBA
I changed the behaviour of the JS Windows. If you used "Dialog_***", p.e. "Dialog_URL", you'll have to change that part.
0.7 uses the new "Dialoge" Class $jquery->Dialog(NAME, WINDOW_HEADER, OPTIONS, TYPE);
TYPE: url, confirm, alert NAME: function Name to be called, p.e. 'fe_portalsettings' means function fe_portalsettings(); WINDOW_HEADER: The Text shown in the Window head OPTIONS: Additional Options
| Option Name | Description | Available for TYPE |
|---|---|---|
| url | the URL to be opened or redirected (confirm) | url, confirm |
| withid | the id of the function p.e. test(withid) | confirm, url |
| custom_js | custom JS Code instead of redirect to url | confirm |
| message | The message to be shown | url, alert, confirm |
| onclose | redirect on window close | url |
| width | Width of the window | url, alert |
| height | Height of the window | url, alert |
| modal | Modal window, true/false | url |
| resize | User can resize window, true/false | url |
| draggable | User can drag&drop window, true/false | url |
$my_ajs = 'function fe_portalsettings(moduleid){ '.$jquery->Dialog_URL('ModuleSetting'.rand(), $user->lang['portalplugin_winname'], $this->root_path."admin/portalsettings.php?id='+moduleid+'", '660', '400').' }';
is now
$jquery->Dialog('fe_portalsettings', $user->lang['portalplugin_winname'], array('url'=>$this->root_path."admin/portalsettings.php?id='+moduleid+'", 'width'=>'660', 'height'=>'400', 'withid'=>'moduleid'));
The Class itself has to be named different now.
class Myplug_plugin_class extends EQdkp_Plugin //before class Myplug extends plugin_generic //new
You can now define an icon for your plugin.
$this->add_data('icon', $icon); //$icon with root_path | can also be merged to the add_data(array()) call
The plugin_path does not need to be specified anylonger. It therefore MUST be the same as the plugin_code!
$this->add_log_action()
is not longer needed because of the global Logging-Class. More information about the logging class: Logging
function pre_install()
If defined this function will be called before the SQL installation process starts and can be used to prepare SQL statements etc.
function post_install()
If defined this function will be called after the successful SQL installation process and can be used to initialise the plugin after install.
function pre_uninstall()
If defined this function will be called before the SQL uninstallation process and can be used to prepare SQL statements etc.
function post_uninstall()
If defined this function will be called after the successful SQL uninstallation process and can be used to cleanup stuff after uninstallation.
function autorun()
If defined this function will be called on each page load if the plugin is installed.
The new menu-array looks like this:
$menu = array( 'name' => 'plugin_name', 'icon' => 'plugin_icon', // (may be $this->data['icon']) 1 => array( //first entry //as before ) )
$pm->hooks became private. You must! not use $pm->hooks directly. Use
public function do_hooks($hook, $params=array(), $recursive=false, $plugin='')
$recursive works as follows: you specify the key of the params array in which the result of the hook_call shall be put. Example:
$my_text = "Anything with [b]bbcodes[/b]."; $my_text = $pm->do_hooks('bbcode_parsing', array('text' => $my_text), 'text'); //could return "Anything with <b>bbcodes</b>."
Arguments have been switched
public function check($plugin_code, $check='not_set', $strict=false) { if($check == 'not_set') { $check = PLUGIN_INITIALIZED | PLUGIN_INSTALLED; $strict = true; }
$strict is new and is used if you want to have all given states set. Example:
//'plugin1' has the states PLUGIN_INITIALIZED, PLUGIN_REGISTERED, PLUGIN_INSTALLED //'plugin2' has the states PLUGIN_INITIALIZED, PLUGIN_REGISTERED $pm->check('plugin1', (PLUGIN_INITIALIZED | PLUGIN_INSTALLED)); //returns true, as expected $pm->check('plugin2', (PLUGIN_INITIALIZED | PLUGIN_INSTALLED)); //returns true, may not be expected, reason: it returns true if ONE of the two given states is checked $pm->check('plugin2', (PLUGIN_INITIALIZED | PLUGIN_INSTALLED), true); //return false, plugin does not fulfill both states.
Together with the new Maintenance mode we changed, how the plugin-db-updates work. The version.php file is no longer needed, so you can delete it. The old update-files have to be changed in order to let them work. The header of the new update file should look like this. The filename must be like this: "update_{plugin_path}_{something}.class.php" and the name of the class "update_{plugin_path}_{something}". Here's an example of a raidplan-update.
if ( !defined('EQDKP_INC') ){ header('HTTP/1.0 404 Not Found');exit; } include_once($eqdkp_root_path.'maintenance/includes/sql_update_task.class.php'); class update_raidplan_500 extends sql_update_task { public $author = 'wallenium'; public $version = '4.2.0'; //new version public $name = 'Raidplan 4.2.0 Update'; //name of the update public $plugin_path = 'raidplan'; //important!
Next you have to define the __construct() function where you define the sqls.
public function __construct(){ parent::__construct(); //this line is important! $this->langs = array( 'english' => array( //english is necessary 'update_raidplan_500' => 'Raidplan update to 5.0.0', //description of the whole update 1 => 'The first SQL-Query Description', 'update_function' => 'Description of the update-function', ), 'german' => array( //other languages are optional 'update_raidplan_500' => 'Raidplan Update auf 5.0.0', 1 => 'Die Beschreibung des ersten SQL-Querys', 'update_function' => 'Beschreibung der Update-Funktion', ), ); $this->sqls = array( 1 => "An example SQL-Query would be here", ); }
If you need an update-function in the db-update just define the following function. If you dont need a function, dont define it (still in class).
public function update_function() { //here we define our function return true/false; } } //dont forget closing the class ;)
It is also possible to not let the task an extension of the sql_update_task class, but then you have to write everything yourself. It's important, that the name of the task remains the same, otherwise the maintenance-mode won't see it as a task for itself.
Usersettings of Plugins are now integrated in the normal Usersettings. Sample User-Settings:
function gen_settings_menu(){ global $user, $SID, $eqdkp_root_path; if ( $this->pm->check(PLUGIN_INSTALLED, 'raidplan')){ $admin_menu = array( 'raidplan' => array( 'icon' => $eqdkp_root_path.'plugins/raidplan/images/adminmenu/rp_icon.png', 'name' => $user->lang['raidplan'], 'pk_bossguides_accordion' => array( 'name' => 'pk_bossguides_accordion', 'language' => 'pk_use_accordion', 'type' => 'checkbox', 'help' => '', 'value' => 1, ), 'pk_bossguides_hide_naxx' => array( 'name' => 'pk_bossguides_hide_naxx', 'language' => 'rp_manage', 'type' => 'text', 'size' => '30', 'help' => '', ), 'pk_bossguides_hide_malygos' => array( 'name' => 'pk_bossguides_hide_malygos', 'language' => 'pk_hide_malygos', 'type' => 'checkbox', 'size' => '30', 'help' => '', ), )); return $admin_menu; } return; }
You can use the syntax for portal-modules or other things using the widget-class.
There are some minor changes:
Check if you're using the following array keys and change if used: old:
99 => './../../plugins/downloads/images/admin_logo.png', 0 => $user->lang['downloads'],
new:
'icon' => './../../plugins/downloads/images/admin_logo.png', 'name' => $user->lang['downloads'],
The new Admin menu allowes you to add an icon for every single menu entry. Just add
'icon' => 'icon.png'
If you want to use/add own icons to your plugins, use the famfam icons, they're free. http://www.famfamfam.com/lab/icons/silk/
Its pretty simple: Eqdkp 0.7 only uses one template folder.
<!-- INCLUDE ../../../../templates/{TMPL_FOLDERNAME}/page_header.html --> <!-- INCLUDE ../../../../templates/{TMPL_FOLDERNAME}/page_tail.html -->
If you've got custom templates who needs the own folder, you're allowed to use custom folders as you know it. but if there are no changed template files for your custom template, you need not create an own folder.
In 0.7 we have a new way to add CSS code/files to the Template
$tpl->add_css($your_css);
This code adds css code to the template engine. Just add it and set the code between the <style> tags as variabe
$tpl->css_file($path_to_file);
This code adds a css file link to the header. Just add the path to the css-file.
In 0.7 we have a new way to add JavaScript code/files to the Template
$tpl->add_js($your_js);
This code adds js code to the template engine. Just add it and set the code between the tags as variabe
$tpl->js_file($path_to_file);
This code adds a javascript file link to the header. Just add the path to the JS-file.
With the 0.7, you have to remove the auth_id from your add_permission-function. New:
// (Admin (a)/User (u), Name, Enables Y/N, Language cariable, array of user-group-ids that should have this permission) $this->add_permission('a', 'import', 'N', $user->lang['dl_import']);
You can grant rights to Groups by adding the Group-IDs into an array and add it to your function-call:
$this->add_permission('a', 'import', 'N', $user->lang['dl_import'], array(1,2,3));
Pay attention: it doesn't care if the auth_default is Yes or No, the permission will be granted as Yes to the groups in your array!
Default Groups after installation:
to be implemented....
All plugin permissions will now be granted automatically to the installing user, so you should delete your own implementations from the plugin base class.
The additional data fields (and their respective functions) introduced by eqDKP Plus 0.6 have been removed. The original data field now supports the following types:
var $valid_data_types = array('id', 'code', 'name', 'installed', 'contact', 'path', 'template_path', 'version', 'description', 'long_description', 'manuallink', 'homepage', 'imageurl', 'author' );
Three different types of dependencies are now available to the plugin author to make sure their plugins are used in a system which fullfills some basic requirements. They can be set in your main plugin class as follows:
$this->add_dependency(array( 'plus_version' => '0.7', 'lib_version' => '1.0.2', 'games' => array('aoc', 'eq', 'lotro', 'vanguard', 'wow'), 'php_functions' => array('json_encode'), ) );
You can skip each of them resulting in no respective restrictions. Each set dependency will be checked with the default checks. If you want to use custom checks you can implement the following method in your main plugin class:
function check_dependency($dependency){ // do checks and return true/false for all dependency types }
Breaking a dependency will prohibit the installation of your plugin, and maybe from initialisation in a future version (tba).
With these changes the plus_version data field and the $fwversion field in your plugin class will become obsolete.
EQdkp no longer defines constants for SQL table names. In 0.6, you could use both: constants OR underscores. EQDKP-PLUS 0.7 will not longer allow constants. Instead, any name prefixed with two underscores will automatically gain the installation's EQdkp prefix.
Delete blocks like this from your <plugin>_plugin_class.php:
global $table_prefix; if (!defined('WISHLIST_TABLE')) { define('WISHLIST_TABLE', $table_prefix . 'wishlist'); } if (!defined('WISHLIST_DATA_TABLE')) { define('WISHLIST_DATA_TABLE', $table_prefix . 'wishlist_data'); }
Use the magic string instead of the constants:
// Define installation // ----------------------------------------------------- $sql = "CREATE TABLE IF NOT EXISTS " . WISHLIST_TABLE . " (
becomes
// Define installation // ----------------------------------------------------- $sql = "CREATE TABLE IF NOT EXISTS __wishlist (
This is completely optional but may clean up your code a bit.
You may have seen some code like this in EQdkp-Plus 0.6.x:
$insert = array( 'wl_id' => null, 'wl_member' => ucfirst($user->data['username']), 'wl_item' => $_POST['wishlist_item'], 'wl_type' => $_POST['wishlist_type'], ); $sql = INSERT INTO ' . WISHLIST_TABLE . $db->build_query('INSERT', $insert); $db->query($sql);
The query method now takes an optional second parameter which, if an array, will be passed to build_query() and the results will replace a variable in the query called :params For example, the above lines could be re-written as one statement:
$db->query("INSERT INTO __wishlist :params", array( 'wl_id' => null, 'wl_member' => ucfirst($user->data['username']), 'wl_item' => $_POST['wishlist_item'], 'wl_type' => $_POST['wishlist_type'], ));
The syntax is very similar for UPDATE queries, and the appropriate value is automatically detected and passed to build_query()
If your plugin ships a portal module, there've been some changes, too. Instead of using a modules.php file in your plugin's 'portal' folder, you can now easily register your portal modules by calling:
$this->add_portal_module('nextraids');
for each of your modules (in this example it was the "nextraids" module) in your plugin object constructor.
You can add own exchange-modules for SOAP. Plase take a look at Plus Exchange for more information about creating an exchange module.
$this->add_exchange_module('shoutbox');
If you want to add an xml-feed, use the following code:
$this->add_exchange_module('shoutbox', true, 'shoutbox.xml');
$db->query("INSERT INTO __wishlist :params", array( 'wl_id' => null, 'wl_member' => ucfirst($user->data['username']), 'wl_item' => $in->get('wishlist_item'), 'wl_type' => $in->get('wishlist_type'), ));
The $in variable references an instance of the Input class.
Always use "$db->escape()", for every single variable you'd in your sql queries. Here, settings.php forces the GET variable 'id' to be an integer:
$sql = "DELETE FROM " . RAIDPLAN_TABLE . " WHERE ( wl_id = " . intval($_GET['id']) . " ) AND ( wl_member = '" . ucfirst($user->data['username']) . "' ) LIMIT 1";
But we can have Input do this for us by passing it an integer as the second parameter, its default value if 'id' doesn't exist.
$sql = "DELETE FROM __wishlist WHERE ( wl_id = " . $db->escape($in->get('id', 0)) . " ) AND ( wl_member = '" . $db->escape(ucfirst($user->data['username'])) . "' ) LIMIT 1";
Never trust what's being displayed to the user. Always sanitize() any variables being printed.
$tpl->assign_block_vars('raidplan_row', array( 'ROW_CLASS' => $eqdkp->switch_row_class(), 'ITEM' => sanitize($row['wl_item']), 'ZONE' => sanitize($row['wl_zone']), 'BOSS' => sanitize($row['wl_boss']), ));
In 0.7 we removed the __classes and __races table. All information about classes and races can now be fetched by using the new game-class. The three most used functions are:
If you need further information about the game-class search this article.
Global $eqdkp does not exist anymore. Use $core instead.
The pluskernel/include/html.class.php has been deleted in 0.7. Most of the functions have been copied into the library html.class.php (which can be accessed by $html). But all the functions, which follow are NOT in the "new" html.class.php:
We cleaned up the plus.functions.php, too. All functions which are not listed here, should be available just as in 0.6:
You can also register new modules for our brand new data handler within your plugin object constructors by calling either:
$this->add_pdh_read_module('module_name');
or
$this->add_pdh_write_module('module_name');
whereas module_name is the unique name of your pdh module. The module itself has to be in either /yourplugin/pdh/read/module_name/ or /yourplugin/pdh/write/module_name/ and has to follow the pdh read/write module pattern.