PHP Classes

File: htdocs/Frameworks/art/functions.config.php

Recommend this page to a friend!
  Packages of Michael Beck   Xoops 2.5   htdocs/Frameworks/art/functions.config.php   Download  
File: htdocs/Frameworks/art/functions.config.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Xoops 2.5
Modular content management publication system
Author: By
Last change: copyright update
PER-CS formatting
Merge pull request #1239 from Andrew-Staves-Activ/notificationhandler_subscribe_success

Merge pull request #946 from geekwright/profile_userinfo_tpl

Bad form in profile_userinfo.tpl
Merge branch 'feature/php8_templates' of https://github.com/mambax7/XoopsCore25 into feature/php8_templates

# Conflicts:
# htdocs/themes/xswatch4/modules/publisher/publisher_item.tpl
Merge xswatch4
Date: 10 months ago
Size: 3,332 bytes
 

Contents

Class file image Download
<?php
/**
 * Functions handling module configs
 *
 * @copyright       (c) 2000-2025 XOOPS Project (https://xoops.org)
 * @license             GNU GPL 2 (https://www.gnu.org/licenses/gpl-2.0.html)
 * @author              Taiwen Jiang <phppp@users.sourceforge.net>
 * @since               1.00
 * @package             Frameworks
 * @subpackage          art
 */

if (!defined('FRAMEWORKS_ART_FUNCTIONS_CONFIG')):
    define('FRAMEWORKS_ART_FUNCTIONS_CONFIG', true);

    /**
     * Load configs of a module
     *
     *
     * @param    string $dirname module dirname
     * @return    array
     */
    function mod_loadConfig($dirname = '')
    {
        if (empty($dirname) && empty($GLOBALS['xoopsModule'])) {
            return null;
        }
        $dirname = !empty($dirname) ? $dirname : $GLOBALS['xoopsModule']->getVar('dirname');

        if (isset($GLOBALS['xoopsModule']) && is_object($GLOBALS['xoopsModule']) && $GLOBALS['xoopsModule']->getVar('dirname', 'n') == $dirname) {
            if (isset($GLOBALS['xoopsModuleConfig'])) {
                $moduleConfig = & $GLOBALS['xoopsModuleConfig'];
            } else {
                return null;
            }
        } else {
            xoops_load('XoopsCache');
            if (!$moduleConfig = XoopsCache::read("{$dirname}_config")) {
                $moduleConfig = mod_fetchConfig($dirname);
                XoopsCache::write("{$dirname}_config", $moduleConfig);
            }
        }
        if ($customConfig = @include XOOPS_ROOT_PATH . "/modules/{$dirname}/include/plugin.php") {
            $moduleConfig = array_merge($moduleConfig, $customConfig);
        }

        return $moduleConfig;
    }

/**
 * @param string $dirname
 *
 * @return array
 */
function mod_loadConfg($dirname = '')
{
    return mod_loadConfig($dirname);
}

/**
 * Fetch configs of a module from database
 *
 *
 * @param    string $dirname module dirname
 * @return    array
 */
function mod_fetchConfig($dirname = '')
{
    if (empty($dirname)) {
        return null;
    }

    /** @var \XoopsModuleHandler $module_handler */
    $module_handler = xoops_getHandler('module');
    if (!$module = $module_handler->getByDirname($dirname)) {
        trigger_error("Module '{$dirname}' does not exist", E_USER_WARNING);

        return null;
    }

    /** @var XoopsConfigHandler $config_handler */
    $config_handler = xoops_getHandler('config');
    $criteria       = new CriteriaCompo(new Criteria('conf_modid', $module->getVar('mid')));
    $configs        = $config_handler->getConfigs($criteria);
    foreach (array_keys($configs) as $i) {
        $moduleConfig[$configs[$i]->getVar('conf_name')] = $configs[$i]->getConfValueForOutput();
    }
    unset($module, $configs);

    return $moduleConfig;
}

/**
 * @param string $dirname
 *
 * @return array
 */
function mod_fetchConfg($dirname = '')
{
    return mod_fetchConfig($dirname);
}

/**
 * clear config cache of a module
 *
 *
 * @param    string $dirname module dirname
 * @return    bool
 */
function mod_clearConfig($dirname = '')
{
    if (empty($dirname)) {
        return false;
    }

    xoops_load('XoopsCache');

    return XoopsCache::delete("{$dirname}_config");
}

/**
 * @param string $dirname
 *
 * @return bool
 */
function mod_clearConfg($dirname = '')
{
    return mod_clearConfig($dirname);
}

endif;