<?php
/**
 * @version $Id: MyuploaderUtils.class.php 679 2012-08-20 12:41:35Z hodaka $
 * @package myuploader
 */

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

/**
 * Myuploader_Utils
**/
class Myuploader_Utils
{
    /**
     * &getXoopsHandler
     * 
     * @param   string  $name
     * @param   bool  $optional
     * 
     * @return  XoopsObjectHandler
     * 
     * @static
    **/
    function &getXoopsHandler($name, $optional = false)
    {
        // TODO will be emulated xoops_gethandler
        return xoops_gethandler($name, $optional);
    }

    /**
     * &getModuleHandler
     * 
     * @param   string  $name
     * @param   string  $dirname
     * 
     * @return  XoopsObjectHandleer
     * 
     * @static
    **/
    function &getModuleHandler($name, $dirname)
    {
        // TODO will be emulated xoops_getmodulehandler
        $handler =& xoops_getmodulehandler($name, $dirname);
        return $handler;
    }

    /**
     * getEnv
     * 
     * @param   string  $key
     * 
     * @return  string
     * 
     * @static
    **/
    function getEnv($key)
    {
        // TODO will be emulated xoops_getenv
        return xoops_getenv($key);
    }


    function assignModuleHeader($dirname) {
        $root = XCube_Root::getSingleton();
        $tpl = $root->_mRenderSystems['Legacy_RenderSystem']->mXoopsTpl;
        if(is_object($tpl)) {
            $metaheader =& $tpl->get_template_vars('xoops_module_header');
            $metaheader .= sprintf('<link rel="stylesheet" type="text/css" media="all" href="%s/%s/css/style.css" />', XOOPS_MODULE_URL, $dirname)."\n";
            $tpl->assign('xoops_module_header', $metaheader);
        }
    }
    
    function assignBlockHeader($dirname) {
        $root = XCube_Root::getSingleton();
        $tpl = $root->_mRenderSystems['Legacy_RenderSystem']->mXoopsTpl;
        if(is_object($tpl)) {
            $blockstylefile = sprintf('%s/modules/%s/css/block_style.css', XOOPS_ROOT_PATH, $dirname);
            if(file_exists($blockstylefile)) {
                $metaheader =& $tpl->get_template_vars('xoops_module_header');
                $metaheader .= sprintf('<link rel="stylesheet" type="text/css" media="all" href="%s/%s/css/block_style.css" />', XOOPS_MODULE_URL, $dirname)."\n";
                $tpl->assign('xoops_module_header', $metaheader);
            }
        }
    }

}

?>
