当前位置: 首页>>代码示例>>PHP>>正文


PHP ModuleHandler::getInstance方法代码示例

本文整理汇总了PHP中ModuleHandler::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP ModuleHandler::getInstance方法的具体用法?PHP ModuleHandler::getInstance怎么用?PHP ModuleHandler::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ModuleHandler的用法示例。


在下文中一共展示了ModuleHandler::getInstance方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: database_initialize

/**
 * Perform database initialization.
 *
 * @param boolean $create_database
 * @return boolean
 */
function database_initialize($create_database)
{
    global $db, $db_config, $data_path;
    $result = false;
    $database_exists = false;
    $sql_file = 'units/database/init.sql';
    $xml_file = $data_path . 'system_init.xml';
    if (!file_exists($sql_file) || !file_exists($xml_file)) {
        trigger_error('Can not initialize database, missing configuration!', E_USER_ERROR);
        return $result;
    }
    // make a log entry
    trigger_error('Initializing database: ' . $db_config['name'], E_USER_NOTICE);
    // get initialization SQL
    $sql = file_get_contents($sql_file);
    // create database if needed
    if ($create_database) {
        try {
            $db->create($db_config['name']);
            $db->select($db_config['name']);
            $database_exists = true;
        } catch (Exception $error) {
            $database_exists = false;
        }
    } else {
        $database_exists = true;
    }
    // create database
    if ($database_exists && $db->multi_query($sql)) {
        $module_manager = ModuleManager::getInstance();
        $module_handler = ModuleHandler::getInstance();
        $admin_manager = UserManager::getInstance();
        // populate tables
        $raw_data = file_get_contents($xml_file);
        $data = new XMLParser($raw_data, $xml_file);
        $data->parse();
        // go over XML file and insert data
        foreach ($data->document->tagChildren as $item) {
            switch ($item->tagName) {
                case 'module':
                    // insert data
                    $module_manager->insertData(array('name' => $item->tagAttrs['name'], 'order' => $item->tagAttrs['order'], 'preload' => $item->tagAttrs['preload'] == 'yes' ? 1 : 0, 'active' => 1));
                    // initialize module
                    $module = $module_handler->_loadModule($item->tagAttrs['name']);
                    if (!is_null($module)) {
                        $module->onInit();
                    }
                    break;
                case 'user':
                    $salt = hash('sha256', UserManager::SALT . strval(time()));
                    $password = hash_hmac('sha256', $item->tagAttrs['password'], $salt);
                    $admin_manager->insertData(array('username' => $item->tagAttrs['username'], 'password' => $password, 'fullname' => $item->tagAttrs['fullname'], 'level' => $item->tagAttrs['level'], 'verified' => 1, 'salt' => $salt));
                    break;
            }
        }
        // set result
        $result = true;
    }
    return $result;
}
开发者ID:tareqy,项目名称:Caracal,代码行数:66,代码来源:common.php

示例2: initialiseModule_Commit

 /**
  * Initialise and activate module
  */
 private function initialiseModule_Commit()
 {
     $module_name = fix_chars($_REQUEST['module_name']);
     if (!in_array($module_name, $this->protected_modules)) {
         // module is not protected
         $manager = ModuleManager::getInstance();
         $max_order = $manager->getItemValue("MAX(`order`)", array('preload' => 0));
         if (is_null($max_order)) {
             $max_order = -1;
         }
         $manager->insertData(array('order' => $max_order + 1, 'name' => $module_name, 'preload' => 0, 'active' => 1));
         $handler = ModuleHandler::getInstance();
         $module = $handler->_loadModule($module_name);
         if (!is_null($module)) {
             $module->onInit();
             $message = $this->getLanguageConstant('message_module_initialised');
         }
     } else {
         $message = $this->getLanguageConstant('message_module_protected');
     }
     $template = new TemplateHandler('message.xml', $this->path . 'templates/');
     $template->setMappedModule($this->name);
     $params = array('message' => $message, 'action' => window_Close($this->name . '_module_dialog') . ";" . window_ReloadContent('system_modules'));
     $template->restoreXML();
     $template->setLocalParams($params);
     $template->parse();
 }
开发者ID:tareqy,项目名称:Caracal,代码行数:30,代码来源:backend.php

示例3: die

        }
    }
}
$language = $_SESSION['language'];
$language_rtl = $language_handler->isRTL();
// turn off URL rewrite for backend
if ($section == 'backend' || $section == 'backend_module') {
    $url_rewrite = false;
}
// start database engine
if ($db_use && !database_connect()) {
    die('There was an error while trying to connect database.');
}
// transfer display control
$cache = CacheHandler::getInstance();
$module_handler = ModuleHandler::getInstance();
if ($cache->isCached()) {
    // only include specified modules
    $module_handler->loadModules(true);
    // show cached page
    $cache->printCache();
} else {
    // get main section handler so we can transfer control
    $section_handler = MainSectionHandler::getInstance();
    // load all the modules
    $module_handler->loadModules();
    // show page and cache it along the way
    $cache->startCapture();
    $section_handler->transferControl($section, $action, $language);
    $cache->endCapture();
}
开发者ID:tareqy,项目名称:Caracal,代码行数:31,代码来源:index.php


注:本文中的ModuleHandler::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。