A fork of the other sticky specifically for development information to help you write modules and such.
THIS THREAD IS ONLY VALID FOR WCDDL3
AS OF NOW WCDDL3 IS IN DEVELOPMENT BUT WILL BE RELEASED TOMORROW MOST LIKELY
Click Here for Main Thread
Modules
Modules are PHP files stored in the WCDDL modules folder, prefixed with 'wcddl_'.
The modules directory is defined in the WCDDL configuration, the default being 'modules/'.
Core
In WCDDL2 you would interact with the core by making a global, $core, and calling methods on that.
In WCDDL3 you retrieve the current Core instance and call methods as required:
Request Mapping
You can now map requests like so:
The above example will return a 'Downloads' instance.
If either of 'page', 'type' or 'query' are set by the user (via _GET or _POST), they will be set in the 'Downloads' instance.
Meaning if I set ?page=5, then $downloads->page will be 5.
Available Classes & Methods
Please see the source, there's way too many to list, especially with info on how they work.
Hooks
WCDDL3 uses a hooking system for modules. You generally write a module in such a way that it consists of only functions and/or classes then hook these functions/classes into the WCDDL core.
For example, you can hook a custom function to be executed when downloads are retrieved, allowing you to modify data before it is returned.
Hook List
WAY TOO MANY HOOKS TO LIST AND EXPLAIN, CHECK THE SOURCE TO SEE WHAT THEY DO.
Complete list of hooks in WCDDL3 is as follows:
How to Hook
Hook your custom function/method using the Core::hook method.
Example:
Complete Hooking Example
Example:
THIS THREAD IS ONLY VALID FOR WCDDL3
AS OF NOW WCDDL3 IS IN DEVELOPMENT BUT WILL BE RELEASED TOMORROW MOST LIKELY
Click Here for Main Thread
Modules
Modules are PHP files stored in the WCDDL modules folder, prefixed with 'wcddl_'.
The modules directory is defined in the WCDDL configuration, the default being 'modules/'.
Core
In WCDDL2 you would interact with the core by making a global, $core, and calling methods on that.
In WCDDL3 you retrieve the current Core instance and call methods as required:
PHP:
function myFunction() {
$core = Core::load();
header("X-JmZ: " . $core->config('someEpicVariable'));
}
You can now map requests like so:
PHP:
$downloads = Core::mapRequest('Downloads', array('page', 'type', 'query'));
If either of 'page', 'type' or 'query' are set by the user (via _GET or _POST), they will be set in the 'Downloads' instance.
Meaning if I set ?page=5, then $downloads->page will be 5.
Available Classes & Methods
Please see the source, there's way too many to list, especially with info on how they work.
Hooks
WCDDL3 uses a hooking system for modules. You generally write a module in such a way that it consists of only functions and/or classes then hook these functions/classes into the WCDDL core.
For example, you can hook a custom function to be executed when downloads are retrieved, allowing you to modify data before it is returned.
Hook List
WAY TOO MANY HOOKS TO LIST AND EXPLAIN, CHECK THE SOURCE TO SEE WHAT THEY DO.
Complete list of hooks in WCDDL3 is as follows:
Code:
init
DatabaseColumn, (&$query, &$args)
DatabaseRowObject, (&$class, &$query, &$args)
DatabaseRowObjects, (&$class, &$query, &$args)
DatabaseExecute, (&$query, &$args)
DatabaseRow, (&$query, &$args)
DatabaseRows, (&$query, &$args)
CoreGetModules, (&$modulesArray)
DownloadsPreGet, (&$downloadsInstance)
DownloadsGetQuery, (&$sqlQuery)
DownloadsGetWhere, (&$whereClause, &$whereParams)
DownloadsGetFullQuery, (&$sqlQuery)
DownloadsGetRows, (&$rowsArray)
DownloadsPostGet, (&$downloadsInstance)
LogQueryPre, (&$query)
ShowQueriesPost, (&$downloadQueryArray)
CommonFormatUrl, (&$string)
CommonIsEmail, (&$email)
CommonIsUrl, (&$url)
CommonUrlHost, (&$host)
CommonDisplayStr, (&$string)
PagesPre, (&$map)
PagesPost, (&$pageArray)
DownloadQueuePre, (&$downloadInstance)
DownloadDeQueuePre, (&$downloadInstance)
DownloadDeletePre, (&$downloadInstance)
DownloadSavePre, (&$query, &$params)
DownloadAddView, (&$downloadInstance)
DownloadShowTitle, (&$title)
SubmitConstruct, (&$submitInstance)
SubmitPre, (&$submitInstance)
SubmitValidation, (&$submitInstance)
SubmitDownload, (&$download)
SubmitFilterPre, (&$submitInstance)
SubmitFilterValidate, (&$valid)
SiteSavePre, (&$siteInstance)
SiteSave, (&$query, &$params)
SiteGetListPre, (&$siteInstance)
SiteGetList, (&$query)
SiteWhitelist, (&$url)
SiteWhitelistRemove, (&$url)
SiteBlacklistRemove, (&$url)
SiteBlacklist, (&$url)
SiteIsWhitelisted, (&$url)
SiteIsBlacklisted, (&$url)
AdminInit, (&$adminInstance)
AdminHandleContent, (&$go)
AdminAuthenticatePre
AdminAuthenticateFailure
AdminAuthenticateSuccess
Hook your custom function/method using the Core::hook method.
Example:
PHP:
Core::load()->hook('SomeHook', 'myFunction'); // To hook a function
Core::load()->hook('SomeHook', array('myClass', 'someMethod'); // To hook a method of a class
// See the hooklist to know how many params your method/func needs to take
Example:
PHP:
function JmZ($mapping) {
// $mapping is an array of page link pattern maps
// e.g. array('type', '<a href="/index.php?type=#type#&page=#page#">#page#</a>')
// meaning if _GET/_POST 'type' is set, this html will be used for page links
// You could SEO it here or have the user alter their wcfg.php
// wcfg.php contains constants such as WCDDL_PAGES_TYPE with the above html
foreach($mapping as $mapKey => $map) {
if($map[0] == 'type')
$mapping[$mapKey][1] = '<a href="/#type#-downloads-#page#.html">#page#</a>';
}
// NOTICE we don't return, $mapping is passed by reference so alters the original when changed
}
Core::load()->hook('PagesPre', 'JmZ');
Last edited: