<?php
//  Preload for imagemanager integration on XCL 2.1
//  
//  Author: manta
//  URL: https://impresscms.jp/
//  

if( ! defined( 'XOOPS_ROOT_PATH' ) ) exit ;

if( ! preg_match( '/^[0-9a-zA-Z_-]+$/' , $mydirname ) ) exit ;

if( ! defined( 'XOOPS_CUBE_LEGACY' ) ) exit ;

$module_handler =& xoops_gethandler( 'module' ) ;
$xoopsModule =& $module_handler->getByDirname( $mydirname ) ;
$config_handler =& xoops_gethandler( 'config' ) ;
$xoopsModuleConfig =& $config_handler->getConfigsByCat( 0 , $xoopsModule->getVar( 'mid' ) ) ;
if( $xoopsModuleConfig['d3imgtag_imagemgr'] == 0 ) return ;

if( ! class_exists( 'D3imgtagPreloadBase' ) ) {

class D3imgtagPreloadBase extends XCube_ActionFilter
{
    //var $mydirname = 'd3imgtag' ;

    function preBlockFilter()
    {
        $root =& XCube_Root::getSingleton();
        $root->mDelegateManager->add('Legacypage.Imagemanager.Access', array($this, 'overRideDefaultImageManager'), XCUBE_DELEGATE_PRIORITY_FIRST);
    }
    
    function overRideDefaultImageManager()
    {
        $mydirname = $this->mydirname ;
        require_once XOOPS_ROOT_PATH.'/modules/'.$mydirname.'/imagemanager.php';
    }
}

}

eval( 'class '.ucfirst( $mydirname ).'_D3imgtagPreload extends D3imgtagPreloadBase { var $mydirname = "'.$mydirname.'" ; }' ) ;

?>