本文整理汇总了PHP中ModUtil::load方法的典型用法代码示例。如果您正苦于以下问题:PHP ModUtil::load方法的具体用法?PHP ModUtil::load怎么用?PHP ModUtil::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModUtil
的用法示例。
在下文中一共展示了ModUtil::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
/**
* display block
*
* @param array $blockinfo a blockinfo structure
* @return output the rendered bock
*/
public function display($blockinfo)
{
// Security check
if (!SecurityUtil::checkPermission('EZComments:MostCommentsBlock:', "{$blockinfo['bid']}::", ACCESS_READ)) {
return false;
}
if (!ModUtil::load('EZComments')) {
return false;
}
// Get variables from content block
$vars = BlockUtil::varsFromContent($blockinfo['content']);
// Defaults
if (!isset($vars['numentries'])) {
$vars['numentries'] = 5;
}
if (!isset($vars['showcount'])) {
$vars['showcount'] = false;
}
$options = array('numitems' => $vars['numentries']);
if (isset($vars['mod']) && $vars['mod'] != '*') {
$options['mod'] = $vars['mod'];
}
// get the comments
$items = $this->MostCommentsBlock_getall($options);
// augment the info
$comments = ModUtil::apiFunc('EZComments', 'user', 'prepareCommentsForDisplay', $items);
$this->view->assign($vars);
$this->view->assign('comments', $comments);
// Populate block info and pass to theme
$blockinfo['content'] = $this->view->fetch('ezcomments_block_mostcomments.tpl');
return BlockUtil::themesideblock($blockinfo);
}
示例2: Install
/**
* Initialise the IWmenu module creating module tables and module vars
* @author Albert Perez Monfort (aperezm@xtec.cat)
* @return bool true if successful, false otherwise
*/
public function Install() {
// Checks if module IWmain is installed. If not returns error
$modid = ModUtil::getIdFromName('IWmain');
$modinfo = ModUtil::getInfo($modid);
if ($modinfo['state'] != 3) {
return LogUtil::registerError($this->__('Module IWmain is needed. You have to install the IWmain module previously to install it.'));
}
// Check if the version needed is correct
$versionNeeded = '3.0.0';
if (!ModUtil::func('IWmain', 'admin', 'checkVersion', array('version' => $versionNeeded))) {
return false;
}
// Create module table
if (!DBUtil::createTable('IWmenu'))
return false;
//Create indexes
$pntable = DBUtil::getTables();
$c = $pntable['IWmenu_column'];
if (!DBUtil::createIndex($c['id_parent'], 'IWmenu', 'id_parent'))
return false;
//Create module vars
ModUtil::setVar('IWmenu', 'height', 26); // Default height
ModUtil::setVar('IWmenu', 'width', 200); // Default width
ModUtil::setVar('IWmenu', 'imagedir', "menu"); // Default directori of menu images
// checks if module vhmenu exists. If it exists import module vhmenu tables
$modid = ModUtil::getIdFromName('IWmenu');
$modinfo = ModUtil::getInfo($modid);
if ($modinfo['state'] == 3) {
// get the objects from the db
ModUtil::load('IWvhmenu', 'user');
$items = DBUtil::selectObjectArray('IWvhmenu');
if ($items) {
foreach ($items as $item) {
$groups = str_replace('|0', '', $item['groups']);
$groups = substr($groups, 1, strlen($groups));
$itemArray = array('text' => $item['text'],
'url' => $item['url'],
'icon' => '',
'id_parent' => $item['id_parent'],
'groups' => $groups,
'active' => $item['active'],
'target' => $item['target'],
'descriu' => $item['descriu']);
DBUtil::insertObject($itemArray, 'IWmenu', 'mid');
}
}
}
return true;
}
示例3: __construct
public function __construct(Zikula_ServiceManager $serviceManager, \Zikula\Core\AbstractModule $bundle = null)
{
parent::__construct($serviceManager, $bundle);
if ($bundle !== null) {
// Get bundle from route.
$module = $bundle->getName();
// Load module.
\ModUtil::load($module);
// Set legacy to true, as the Controller's response will not have the theme around it otherwise.
// See Zikula\Bundle\CoreBundle\EventListener\ThemeListener::onKernelResponse() - The only place it is used.
$request = $serviceManager->get("request");
$request->attributes->set('_legacy', true);
}
}
示例4: display
/**
* display block
*
* @param array $blockinfo a blockinfo structure
* @return output the rendered bock
*/
public function display($blockinfo)
{
// Security check
if (!SecurityUtil::checkPermission('EZComments:EZCommentsblock:', "{$blockinfo['bid']}::", ACCESS_READ)) {
return false;
}
if (!ModUtil::load('EZComments')) {
return false;
}
// Get variables from content block
$vars = BlockUtil::varsFromContent($blockinfo['content']);
// Defaults
if (!isset($vars['numentries'])) {
$vars['numentries'] = 5;
}
if (!isset($vars['numdays'])) {
$vars['numdays'] = 0;
}
if (!isset($vars['showdate'])) {
$vars['showdate'] = 0;
}
if (!isset($vars['showusername'])) {
$vars['showusername'] = 0;
}
if (!isset($vars['linkusername'])) {
$vars['linkusername'] = 0;
}
$options = array('numitems' => $vars['numentries']);
if (isset($vars['mod']) && $vars['mod'] != '*') {
$options['mod'] = $vars['mod'];
}
if (!isset($vars['showpending']) || $vars['showpending'] == 0) {
// don't show pending comments
$options['status'] = 0;
}
// filter comments posted in last number of days
if ($vars['numdays'] > 0) {
// date for filtering in format: yyyy-mm-dd hh:mm:ss
$options['addwhere'] = "date>='" . DateUtil::getDatetime_NextDay(-$vars['numdays']) . "'";
}
// get the comments
$items = ModUtil::apiFunc('EZComments', 'user', 'getall', $options);
// augment the info
$comments = ModUtil::apiFunc('EZComments', 'user', 'prepareCommentsForDisplay', $items);
$this->view->assign($vars);
$this->view->assign('comments', $comments);
// Populate block info and pass to theme
$blockinfo['content'] = $this->view->fetch('ezcomments_block_ezcomments.tpl');
return BlockUtil::themesideblock($blockinfo);
}
示例5: load
/**
* Load a block.
*
* @param string $modname Module name.
* @param string $block Name of the block.
*
* @throws LogicException Uf OO-Block is not a Zikula_Controller_AbstractBlock object.
* @return bool True on successful load, false otherwise.
*/
public static function load($modname, $block)
{
$sm = ServiceUtil::getManager();
$modinfo = ModUtil::getInfoFromName($modname);
$serviceId = strtolower('block.' . $modinfo['name'] . '_' . 'Block_' . $block);
if ($sm->hasService($serviceId)) {
return $sm->getService($serviceId);
}
if ($modinfo['type'] == ModUtil::TYPE_MODULE) {
ZLanguage::bindModuleDomain($modinfo['name']);
}
$basedir = ($modinfo['type'] == ModUtil::TYPE_SYSTEM) ? 'system' : 'modules';
$moddir = DataUtil::formatForOS($modinfo['directory']);
$blockdir = "$basedir/$moddir/lib/$moddir/Block";
$ooblock = "$blockdir/" . ucwords($block) . '.php';
ModUtil::load($modname);
$isOO = ModUtil::isOO($modname);
if (!$isOO) {
$blockdirOld = $moddir . '/pnblocks';
$incfile = DataUtil::formatForOS($block . '.php');
if (file_exists("$basedir/$blockdirOld/$incfile")) {
include_once "$basedir/$blockdirOld/$incfile";
} else {
return false;
}
}
// get the block info
if ($isOO) {
$className = ucwords($modinfo['name']) . '_' . 'Block_' . ucwords($block);
$r = new ReflectionClass($className);
$blockInstance = $r->newInstanceArgs(array($sm));
try {
if (!$blockInstance instanceof Zikula_Controller_AbstractBlock) {
throw new LogicException(sprintf('Block %s must inherit from Zikula_Controller_AbstractBlock', $className));
}
} catch (LogicException $e) {
if (System::isDevelopmentMode()) {
throw $e;
} else {
LogUtil::registerError('A fatal error has occured which can be viewed only in development mode.', 500);
return false;
}
}
$sm->attachService($serviceId, $blockInstance);
}
$result = ($isOO ? $blockInstance : true);
if ($isOO) {
$blocks_modules[$block] = call_user_func(array($blockInstance, 'info'));
} else {
$infofunc = "{$modname}_{$block}block_info";
$blocks_modules[$block] = $infofunc();
}
// set the module and keys for the new block
$blocks_modules[$block]['bkey'] = $block;
$blocks_modules[$block]['module'] = $modname;
$blocks_modules[$block]['mid'] = ModUtil::getIdFromName($modname);
// merge the blockinfo in the global list of blocks
if (!isset($GLOBALS['blocks_modules'])) {
$GLOBALS['blocks_modules'] = array();
}
$GLOBALS['blocks_modules'][$blocks_modules[$block]['mid']][$block] = $blocks_modules[$block];
// Initialise block if required (new-style)
if ($isOO) {
call_user_func(array($blockInstance, 'init'));
} else {
$initfunc = "{$modname}_{$block}block_init";
$initfunc();
}
// add stylesheet to the page vars, this makes manual loading obsolete
PageUtil::addVar('stylesheet', ThemeUtil::getModuleStylesheet($modname));
return $result;
}
示例6: load
/**
* Load a block.
*
* @param string $modname Module name.
* @param string $block Name of the block.
*
* @throws LogicException Uf OO-Block is not a Zikula_Controller_AbstractBlock object.
* @return bool True on successful load, false otherwise.
*/
public static function load($modname, $block)
{
$sm = ServiceUtil::getManager();
$modinfo = ModUtil::getInfoFromName($modname);
if ($modinfo['state'] != \ModUtil::STATE_ACTIVE) {
return false;
}
$serviceId = strtolower('block.' . $modinfo['name'] . '_' . 'Block_' . $block);
if ($sm->has($serviceId)) {
return $sm->get($serviceId);
}
if ($modinfo['type'] == ModUtil::TYPE_MODULE) {
ZLanguage::bindModuleDomain($modinfo['name']);
}
$basedir = $modinfo['type'] == ModUtil::TYPE_SYSTEM ? 'system' : 'modules';
$moddir = DataUtil::formatForOS($modinfo['directory']);
$blockdir = "{$basedir}/{$moddir}/lib/{$moddir}/Block";
$ooblock = "{$blockdir}/" . ucwords($block) . '.php';
ModUtil::load($modname);
// get the block info
$kernel = $sm->get('kernel');
$module = null;
try {
/** @var $module \Zikula\Core\AbstractModule */
$module = $kernel->getModule($modinfo['name']);
$className = $module->getNamespace() . '\\Block\\' . ucwords($block);
$className = preg_match('/.*Block$/', $className) ? $className : $className . 'Block';
} catch (\InvalidArgumentException $e) {
}
if (!isset($className)) {
$className = ucwords($modinfo['name']) . '\\' . 'Block\\' . ucwords($block);
$className = preg_match('/.*Block$/', $className) ? $className : $className . 'Block';
$classNameOld = ucwords($modinfo['name']) . '_' . 'Block_' . ucwords($block);
$className = class_exists($className) ? $className : $classNameOld;
}
$r = new ReflectionClass($className);
$instanceArgs = array();
if (is_subclass_of($className, 'Zikula_Controller_AbstractBlock')) {
$instanceArgs = array($sm, $module);
} elseif (is_subclass_of($className, 'Zikula\\Core\\Controller\\AbstractBlockController')) {
$instanceArgs = array($module);
}
$blockInstance = $r->newInstanceArgs($instanceArgs);
if (!$blockInstance instanceof Zikula_Controller_AbstractBlock && !$blockInstance instanceof AbstractBlockController) {
throw new LogicException(sprintf('Block %s must inherit from Zikula_Controller_AbstractBlock or Zikula\\Core\\Controller\\AbstractBlockController', $className));
}
$sm->set($serviceId, $blockInstance);
if ($blockInstance instanceof \Symfony\Component\DependencyInjection\ContainerAwareInterface) {
$blockInstance->setContainer($sm);
}
$result = $blockInstance;
$blocks_modules[$block] = call_user_func(array($blockInstance, 'info'));
// set the module and keys for the new block
$blocks_modules[$block]['bkey'] = $block;
$blocks_modules[$block]['module'] = $modname;
$blocks_modules[$block]['mid'] = ModUtil::getIdFromName($modname);
// merge the blockinfo in the global list of blocks
if (!isset($GLOBALS['blocks_modules'])) {
$GLOBALS['blocks_modules'] = array();
}
$GLOBALS['blocks_modules'][$blocks_modules[$block]['mid']][$block] = $blocks_modules[$block];
// Initialise block if required (new-style)
call_user_func(array($blockInstance, 'init'));
// add stylesheet to the page vars, this makes manual loading obsolete
PageUtil::addVar('stylesheet', ThemeUtil::getModuleStylesheet($modname));
return $result;
}
示例7: time
<?php
//1. Init zikula engine
$time = time();
include 'lib/bootstrap.php';
$core->init();
ModUtil::load('IWmain', 'admin');
$langcode = ModUtil::getVar('ZConfig', 'language_i18n');
ZLanguage::setLocale($langcode);
ZLanguage::bindCoreDomain();
$dom = ZLanguage::getModuleDomain('IWmain');
//2. Checking cron password
$passwordActive = ModUtil::getVar('IWmain','cronPasswordActive');
if ($passwordActive) {
$passwordString = ModUtil::getVar('IWmain','cronPasswordString');
$passwordSended = FormUtil::getPassedValue('password',null,'GET');
if ($passwordString !== $passwordSended) {
print __("You can't execute iwcron", $dom);
cronShutdown();
}
}
//3. Cron actions
$sv = ModUtil::func('IWmain', 'user', 'genSecurityValue');
$lastCronSuccessfull = ModUtil::func('IWmain', 'user', 'userGetVar', array('uid' => -100,
'name' => 'lastCronSuccessfull',
'module' => 'IWmain_cron',
'sv' => $sv));
$dateTimeFrom = (int)$lastCronSuccessfull;
示例8: ajaxDispatch
public function ajaxDispatch(Request $request)
{
$module = $request->attributes->get('_module');
$type = $request->attributes->get('_controller');
$func = $request->attributes->get('_action');
if (empty($func)) {
$response = new NotFoundResponse(__f("Missing parameter '%s'", 'func'));
}
// get module information
$modinfo = \ModUtil::getInfoFromName($module);
if ($modinfo == false) {
$response = new NotFoundResponse(__f("Error! The '%s' module is unknown.", \DataUtil::formatForDisplay($module)));
}
if (!\ModUtil::available($modinfo['name'])) {
$response = new NotFoundResponse(__f("Error! The '%s' module is not available.", \DataUtil::formatForDisplay($module)));
}
if (!\ModUtil::load($modinfo['name'], $type)) {
$response = new NotFoundResponse(__f("Error! The '%s' module is not available.", \DataUtil::formatForDisplay($module)));
}
// Dispatch controller.
try {
$response = \ModUtil::func($modinfo['name'], $type, $func);
} catch (NotFoundException $e) {
$response = new NotFoundResponse($e->getMessage());
} catch (ForbiddenException $e) {
$response = new ForbiddenResponse($e->getMessage());
} catch (FatalException $e) {
$response = new FatalResponse($e->getMessage());
} catch (\PDOException $e) {
$response = new FatalResponse($e->getMessage());
} catch (\Exception $e) {
$response = new FatalResponse($e->getMessage());
}
// Issue response.
return $response;
}
示例9: die
UserUtil::logout();
}
die(new Zikula_Response_Ajax_Unavailable(__('The site is currently off-line.')));
}
if (empty($func)) {
die(new Zikula_Response_Ajax_NotFound(__f("Missing parameter '%s'", 'func')));
}
// get module information
$modinfo = ModUtil::getInfoFromName($module);
if ($modinfo == false) {
die(new Zikula_Response_Ajax_NotFound(__f("Error! The '%s' module is unknown.", DataUtil::formatForDisplay($module))));
}
if (!ModUtil::available($modinfo['name'])) {
die(new Zikula_Response_Ajax_NotFound(__f("Error! The '%s' module is not available.", DataUtil::formatForDisplay($module))));
}
if (!ModUtil::load($modinfo['name'], $type)) {
die(new Zikula_Response_Ajax_NotFound(__f("Error! The '%s' module is not available.", DataUtil::formatForDisplay($module))));
}
// Handle database transactions
if (System::getVar('Z_CONFIG_USE_TRANSACTIONS')) {
$dbConn = Doctrine_Manager::getInstance()->getCurrentConnection();
$dbConn->beginTransaction();
}
// Dispatch controller.
try {
$response = ModUtil::func($modinfo['name'], $type, $func);
if (System::isLegacyMode() && $response == false && LogUtil::hasErrors()) {
throw new Zikula_Exception_Fatal(__('An unknown error occurred in module %s, controller %s, action %s', array($modinfo['name'], $type, $func)));
}
} catch (Zikula_Exception_NotFound $e) {
$response = new Zikula_Response_Ajax_NotFound($e->getMessage());
示例10: sprintf
}
$l_online_users = sprintf($l_t_user_s, $total_online_users);
$l_online_users .= sprintf($l_r_user_s, $logged_visible_online);
$l_online_users .= sprintf($l_h_user_s, $logged_hidden_online);
$l_online_users .= sprintf($l_g_user_s, $guests_online);
}
//
// Obtain number of new private messages
// if user is logged in
//
if ($userdata['session_logged_in'] && empty($gen_simple_header)) {
// Begin PNphpBB2 Module
if ($board_config['pnphpbb2_pn_pm']) {
if (ModUtil::available('InterCom')) {
// ZphpBB2
ModUtil::load('InterCom');
$info = ModUtil::apiFunc('InterCom', 'user', 'getmessagecount');
$unread = $info['unread'];
} else {
/* Standard Messages module */
$column =& $pntable['priv_msgs_column'];
$sql = "SELECT count(*) FROM {$pntable['priv_msgs']} WHERE {$column['read_msg']} ='0' and {$column['to_userid']}=" . $userdata['user_id'];
if ($result = $db->sql_query($sql)) {
list($unread) = $db->sql_fetchrow($result);
}
}
$s_privmsg_new = 0;
$icon_pm = $images['pm_new_msg'];
if ($unread > 0) {
$l_message_unread = $unread == 1 ? $lang['Unread_pm'] : $lang['Unread_pms'];
$l_privmsgs_text_unread = sprintf($l_message_unread, $unread);
示例11: pnModLoad
/**
* Loads a module.
*
* @deprecated
* @see ModUtil::load()
*
* @param string $modname The name of the module.
* @param string $type The type of functions to load.
* @param boolean $force Determines to load Module even if module isn't active.
*
* @return string|boolean Name of module loaded, or false on failure.
*/
function pnModLoad($modname, $type = 'user', $force = false)
{
LogUtil::log(__f('Warning! Function %1$s is deprecated. Please use %2$s instead.', array(__FUNCTION__, 'ModUtil::load()')), E_USER_DEPRECATED);
return ModUtil::load($modname, $type, $force);
}
示例12: load
/**
* Load a block.
*
* @param string $modname Module name.
* @param string $block Name of the block.
*
* @throws LogicException Uf OO-Block is not a Zikula_Controller_AbstractBlock object.
* @return bool True on successful load, false otherwise.
*/
public static function load($modname, $block)
{
$sm = ServiceUtil::getManager();
$modinfo = ModUtil::getInfoFromName($modname);
$serviceId = strtolower('block.' . $modinfo['name'] . '\\Block\\' . $block . 'Block');
if ($sm->has($serviceId)) {
return $sm->get($serviceId);
}
if ($modinfo['type'] == ModUtil::TYPE_MODULE) {
ZLanguage::bindModuleDomain($modinfo['name']);
}
ModUtil::load($modname);
// get the block info
$className = ucwords($modinfo['name']) . '\\Block\\' . ucwords($block) . 'Block';
$r = new ReflectionClass($className);
$blockInstance = $r->newInstanceArgs(array($sm));
$sm->set($serviceId, $blockInstance);
$result = $blockInstance;
$blocks_modules[$block] = call_user_func(array($blockInstance, 'info'));
// set the module and keys for the new block
$blocks_modules[$block]['bkey'] = $block;
$blocks_modules[$block]['module'] = $modname;
$blocks_modules[$block]['mid'] = ModUtil::getIdFromName($modname);
// merge the blockinfo in the global list of blocks
if (!isset($GLOBALS['blocks_modules'])) {
$GLOBALS['blocks_modules'] = array();
}
$GLOBALS['blocks_modules'][$blocks_modules[$block]['mid']][$block] = $blocks_modules[$block];
// Initialise block if required (new-style)
call_user_func(array($blockInstance, 'init'));
// add stylesheet to the page vars, this makes manual loading obsolete
PageUtil::addVar('stylesheet', ThemeUtil::getModuleStylesheet($modname));
return $result;
}
示例13: onInit
/**
* Initialise Zikula.
*
* Carries out a number of initialisation tasks to get Zikula up and
* running.
*
* @param integer $stage Stage to load.
*
* @return boolean True initialisation successful false otherwise.
*/
public function onInit(GetResponseEvent $event)
{
if ($event->getRequestType() === HttpKernelInterface::SUB_REQUEST) {
return;
}
$this->dispatcher = $event->getDispatcher();
$this->stage = $stage = self::STAGE_ALL;
$coreInitEvent = new GenericEvent($this);
$coreInitEvent['request'] = $event->getRequest();
// store the load stages in a global so other API's can check whats loaded
$this->dispatcher->dispatch(CoreEvents::PREINIT, new GenericEvent($this));
// // Initialise and load configuration
// if ($stage & self::STAGE_CONFIG) {
// // error reporting
// if (!\System::isInstalling()) {
// // this is here because it depends on the config.php loading.
// $event = new GenericEvent(null, array('stage' => $stage));
// $this->dispatcher->dispatch(CoreEvents::ERRORREPORTING, $event);
// }
//
// // initialise custom event listeners from config.php settings
// $coreInitEvent->setArg('stage', self::STAGE_CONFIG);
// $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
// }
// // Check that Zikula is installed before continuing
// if (\System::getVar('installed') == 0 && !\System::isInstalling()) {
// $response = new RedirectResponse(\System::getBaseUrl().'install.php?notinstalled');
// $response->send();
// \System::shutdown();
// }
if ($stage & self::STAGE_DB) {
try {
$dbEvent = new GenericEvent();
$this->dispatcher->dispatch('doctrine.init_connection', $dbEvent);
$dbEvent = new GenericEvent($this, array('stage' => self::STAGE_DB));
$this->dispatcher->dispatch(CoreEvents::INIT, $dbEvent);
} catch (\PDOException $e) {
if (!\System::isInstalling()) {
header('HTTP/1.1 503 Service Unavailable');
require_once \System::getSystemErrorTemplate('dbconnectionerror.tpl');
\System::shutDown();
} else {
return false;
}
}
}
if ($stage & self::STAGE_TABLES) {
// Initialise dbtables
\ModUtil::initCoreVars();
\ModUtil::dbInfoLoad('SettingsModule', 'SettingsModule');
\ModUtil::dbInfoLoad('ThemeModule', 'ThemeModule');
\ModUtil::dbInfoLoad('UsersModule', 'UsersModule');
\ModUtil::dbInfoLoad('GroupsModule', 'GroupsModule');
\ModUtil::dbInfoLoad('PermissionsModule', 'PermissionsModule');
\ModUtil::dbInfoLoad('CategoriesModule', 'CategoriesModule');
if (!\System::isInstalling()) {
\ModUtil::registerAutoloaders();
}
$coreInitEvent->setArg('stage', self::STAGE_TABLES);
$this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
}
if ($stage & self::STAGE_SESSIONS) {
\SessionUtil::requireSession();
$coreInitEvent->setArg('stage', self::STAGE_SESSIONS);
$this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
}
// Have to load in this order specifically since we cant setup the languages until we've decoded the URL if required (drak)
// start block
if ($stage & self::STAGE_LANGS) {
$lang = \ZLanguage::getInstance();
}
if ($stage & self::STAGE_DECODEURLS) {
\System::queryStringDecode();
$coreInitEvent->setArg('stage', self::STAGE_DECODEURLS);
$this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
}
if ($stage & self::STAGE_LANGS) {
$lang->setup();
$coreInitEvent->setArg('stage', self::STAGE_LANGS);
$this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
}
// end block
if ($stage & self::STAGE_MODS) {
// Set compression on if desired
if (\System::getVar('UseCompression') == 1) {
//ob_start("ob_gzhandler");
}
\ModUtil::load('SecurityCenter');
$coreInitEvent->setArg('stage', self::STAGE_MODS);
$this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
//.........这里部分代码省略.........
示例14: init
/**
* Initialise Zikula.
*
* Carries out a number of initialisation tasks to get Zikula up and
* running.
*
* @param integer $stage Stage to load.
* @param Zikula_Request_Http $request
*
* @return boolean True initialisation successful false otherwise.
*/
public function init($stage = self::STAGE_ALL, Request $request)
{
$GLOBALS['__request'] = $request;
// hack for pre 1.5.0 - drak
$coreInitEvent = new GenericEvent($this);
// store the load stages in a global so other API's can check whats loaded
$this->stage = $this->stage | $stage;
if ($stage & self::STAGE_PRE && $this->stage & ~self::STAGE_PRE) {
ModUtil::flushCache();
System::flushCache();
$args = !System::isInstalling() ? array('lazy' => true) : array();
$this->dispatcher->dispatch('core.preinit', new GenericEvent($this, $args));
}
// Initialise and load configuration
if ($stage & self::STAGE_CONFIG) {
// for BC only. remove this code in 2.0.0
if (!System::isInstalling()) {
$this->dispatcher->dispatch('setup.errorreporting', new GenericEvent(null, array('stage' => $stage)));
}
// initialise custom event listeners from config.php settings
$coreInitEvent->setArgument('stage', self::STAGE_CONFIG);
/***************************************************
* NOTE: this event is monitored by
* \Zikula\Bundle\CoreInstallerBundle\EventListener\InstallUpgradeCheckListener
* to see if install or upgrade is needed
***************************************************/
$this->dispatcher->dispatch('core.init', $coreInitEvent);
}
if ($stage & self::STAGE_DB) {
try {
$dbEvent = new GenericEvent($this, array('stage' => self::STAGE_DB));
$this->dispatcher->dispatch('core.init', $dbEvent);
} catch (PDOException $e) {
if (!System::isInstalling()) {
header('HTTP/1.1 503 Service Unavailable');
require_once System::getSystemErrorTemplate('dbconnectionerror.tpl');
System::shutDown();
} else {
return false;
}
}
}
if ($stage & self::STAGE_TABLES) {
// Initialise dbtables
ModUtil::dbInfoLoad('ZikulaExtensionsModule', 'ZikulaExtensionsModule');
ModUtil::initCoreVars();
ModUtil::dbInfoLoad('ZikulaSettingsModule', 'ZikulaSettingsModule');
ModUtil::dbInfoLoad('ZikulaThemeModule', 'ZikulaThemeModule');
ModUtil::dbInfoLoad('ZikulaUsersModule', 'ZikulaUsersModule');
ModUtil::dbInfoLoad('ZikulaGroupsModule', 'ZikulaGroupsModule');
ModUtil::dbInfoLoad('ZikulaPermissionsModule', 'ZikulaPermissionsModule');
ModUtil::dbInfoLoad('ZikulaCategoriesModule', 'ZikulaCategoriesModule');
// Add AutoLoading for non-symfony 1.3 modules in /modules
if (!System::isInstalling()) {
ModUtil::registerAutoloaders();
}
$coreInitEvent->setArgument('stage', self::STAGE_TABLES);
$this->dispatcher->dispatch('core.init', $coreInitEvent);
}
if ($stage & self::STAGE_SESSIONS) {
// SessionUtil::requireSession();
$coreInitEvent->setArgument('stage', self::STAGE_SESSIONS);
$this->dispatcher->dispatch('core.init', $coreInitEvent);
}
// Have to load in this order specifically since we cant setup the languages until we've decoded the URL if required (drak)
// start block
if ($stage & self::STAGE_LANGS) {
$lang = ZLanguage::getInstance();
}
if ($stage & self::STAGE_DECODEURLS) {
System::queryStringDecode($request);
$coreInitEvent->setArgument('stage', self::STAGE_DECODEURLS);
$this->dispatcher->dispatch('core.init', $coreInitEvent);
}
if ($stage & self::STAGE_LANGS) {
$lang->setup($request);
$coreInitEvent->setArgument('stage', self::STAGE_LANGS);
$this->dispatcher->dispatch('core.init', $coreInitEvent);
}
// end block
if ($stage & self::STAGE_MODS) {
if (!System::isInstalling()) {
ModUtil::load('ZikulaSecurityCenterModule');
}
$coreInitEvent->setArgument('stage', self::STAGE_MODS);
$this->dispatcher->dispatch('core.init', $coreInitEvent);
}
if ($stage & self::STAGE_THEME) {
// register default page vars
//.........这里部分代码省略.........
示例15: init
/**
* Initialise Zikula.
*
* Carries out a number of initialisation tasks to get Zikula up and
* running.
*
* @param integer $stage Stage to load.
*
* @return boolean True initialisation successful false otherwise.
*/
public function init($stage = self::STAGE_ALL)
{
$coreInitEvent = new Zikula_Event('core.init', $this);
// store the load stages in a global so other API's can check whats loaded
$this->stage = $this->stage | $stage;
if ($stage & self::STAGE_PRE && $this->stage & ~self::STAGE_PRE) {
ModUtil::flushCache();
System::flushCache();
$this->eventManager->notify(new Zikula_Event('core.preinit', $this));
}
// Initialise and load configuration
if ($stage & self::STAGE_CONFIG) {
if (System::isLegacyMode()) {
require_once 'lib/legacy/Compat.php';
}
// error reporting
if (!System::isInstalling()) {
// this is here because it depends on the config.php loading.
$event = new Zikula_Event('setup.errorreporting', null, array('stage' => $stage));
$this->eventManager->notify($event);
}
// initialise custom event listeners from config.php settings
$coreInitEvent->setArg('stage', self::STAGE_CONFIG);
$this->eventManager->notify($coreInitEvent);
}
// Check that Zikula is installed before continuing
if (System::getVar('installed') == 0 && !System::isInstalling()) {
System::redirect(System::getBaseUrl() . 'install.php?notinstalled');
System::shutDown();
}
if ($stage & self::STAGE_DB) {
try {
$dbEvent = new Zikula_Event('core.init', $this, array('stage' => self::STAGE_DB));
$this->eventManager->notify($dbEvent);
} catch (PDOException $e) {
if (!System::isInstalling()) {
header('HTTP/1.1 503 Service Unavailable');
require_once System::getSystemErrorTemplate('dbconnectionerror.tpl');
System::shutDown();
} else {
return false;
}
}
}
if ($stage & self::STAGE_TABLES) {
// Initialise dbtables
ModUtil::dbInfoLoad('Extensions', 'Extensions');
ModUtil::initCoreVars();
ModUtil::dbInfoLoad('Settings', 'Settings');
ModUtil::dbInfoLoad('Theme', 'Theme');
ModUtil::dbInfoLoad('Users', 'Users');
ModUtil::dbInfoLoad('Groups', 'Groups');
ModUtil::dbInfoLoad('Permissions', 'Permissions');
ModUtil::dbInfoLoad('Categories', 'Categories');
if (!System::isInstalling()) {
ModUtil::registerAutoloaders();
}
$coreInitEvent->setArg('stage', self::STAGE_TABLES);
$this->eventManager->notify($coreInitEvent);
}
if ($stage & self::STAGE_SESSIONS) {
SessionUtil::requireSession();
$coreInitEvent->setArg('stage', self::STAGE_SESSIONS);
$this->eventManager->notify($coreInitEvent);
}
// Have to load in this order specifically since we cant setup the languages until we've decoded the URL if required (drak)
// start block
if ($stage & self::STAGE_LANGS) {
$lang = ZLanguage::getInstance();
}
if ($stage & self::STAGE_DECODEURLS) {
System::queryStringDecode();
$coreInitEvent->setArg('stage', self::STAGE_DECODEURLS);
$this->eventManager->notify($coreInitEvent);
}
if ($stage & self::STAGE_LANGS) {
$lang->setup();
$coreInitEvent->setArg('stage', self::STAGE_LANGS);
$this->eventManager->notify($coreInitEvent);
}
// end block
if ($stage & self::STAGE_MODS) {
// Set compression on if desired
if (System::getVar('UseCompression') == 1) {
//ob_start("ob_gzhandler");
}
ModUtil::load('SecurityCenter');
$coreInitEvent->setArg('stage', self::STAGE_MODS);
$this->eventManager->notify($coreInitEvent);
}
//.........这里部分代码省略.........