Practice
Perhaps, you might need to understand other mechanism of XOOPS Cube Legacy to make full use of Preload. Preload is the starting point for the most of the customizing.But, it's important to understand Preload now. So, let's create an actual example with Preload only. That is 'ForceSiteClose'. ForceSiteClose closes the site for all of users except specific IP. It's useful for test, because a tester can access as an anonymous user to the site if the tester is from specific IP. By ForceSiteClose, site owners can close the site for visitors with doing test.
class ForceSiteClose extends XCube_ActionFilter
{
var $mSpecificIPs = array('127.0.0.1');
function preFilter()
{
$ip = $_SERVER['REMOTE_IP'];
if (!in_array($ip, $this->mSpecificmIPs)) {
$this->doSiteClose();
exit();
}
}
function doSiteClose()
{
//
// You must rewrite the following for your expression.
//
print "This site is closed now, Because ...";
}
}
You may use this filter for a database trouble, because ForceSiteClose can work without a database. In contrast, the site close of XOOPS Cube Legacy can't work under a database trouble.
Future XCube_ActionFilter
This is a note for developers who know much ActionFilter.In Legacy_Controller, the ActionFilter feature is exclusive used for Site Preload and Module Preload. In other words, it exists for site owners and module developers to do customizing. Legacy_Controller doesn't use the ActionFilter feature to build itself. Therefore, ActionFilter of some frameworks and ActionFilter in Legacy_Controller are different.
Mr,onokazu said it's smart program that Legacy_Controller uses ActionFilter for building itself. His idea is really right and tempting. The class design of XCube_ActionFilter is enough for such use, because ActionFilter is simple mechanism.
Finally, we have decided to keep this design of Legacy_Controller, for clarification of the division of the roles played by actual example. It's freedom that you use it for building the controller at your base module. And, some of base modules which will be released in the near future, may use ActionFilter for such purpose.
Keep in mind that we had kicked around such uses at least.
No comments:
Post a Comment