本文整理汇总了PHP中System::isInstalling方法的典型用法代码示例。如果您正苦于以下问题:PHP System::isInstalling方法的具体用法?PHP System::isInstalling怎么用?PHP System::isInstalling使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System
的用法示例。
在下文中一共展示了System::isInstalling方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pageload
/**
* Handle page load event KernelEvents::REQUEST.
*
* @param GetResponseEvent $event
*
* @return void
*/
public function pageload(GetResponseEvent $event)
{
if (!$event->isMasterRequest()) {
return;
}
if (\System::isInstalling() || \System::isUpgrading()) {
return;
}
$openSearchEnabled = ModUtil::getVar('ZikulaSearchModule', 'opensearch_enabled');
if ($openSearchEnabled && SecurityUtil::checkPermission('ZikulaSearchModule::', '::', ACCESS_READ)) {
// The current user has the rights to search the page.
PageUtil::addVar('header', '<link rel="search" type="application/opensearchdescription+xml" title="' . DataUtil::formatForDisplay(System::getVar('sitename')) . '" href="' . DataUtil::formatForDisplay($this->router->generate('zikulasearchmodule_user_opensearch')) . '" />');
}
}
示例2: onKernelRequest
/**
* @param GetResponseEvent $event
*/
public function onKernelRequest(GetResponseEvent $event)
{
$em = ServiceUtil::get('doctrine.entitymanager');
try {
if (\System::isInstalling()) {
$uid = 2;
} else {
$uid = UserUtil::getVar('uid');
}
$user = $em->getReference('ZikulaUsersModule:UserEntity', $uid);
$this->blameableListener->setUserValue($user);
} catch (\Exception $e) {
// silently fail - likely installing and tables not available
}
}
示例3: moduleInstall
/**
* Handle module install event.
*
* @param ModuleStateEvent $event
*
* @return void
*/
public function moduleInstall(ModuleStateEvent $event)
{
$module = $event->getModule();
if ($module) {
$modName = $module->getName();
} else {
// Legacy for non Symfony-styled modules.
$modInfo = $event->modinfo;
$modName = $modInfo['name'];
}
if (!\System::isInstalling()) {
$category = ModUtil::getVar('ZikulaAdminModule', 'defaultcategory');
ModUtil::apiFunc('ZikulaAdminModule', 'admin', 'addmodtocategory', array('module' => $modName, 'category' => $category));
}
}
示例4: onKernelResponse
public function onKernelResponse(FilterResponseEvent $event)
{
if (!$event->isMasterRequest()) {
return;
}
if (\System::isInstalling()) {
return;
}
$response = $event->getResponse();
$request = $event->getRequest();
if ($response instanceof PlainResponse || $response instanceof JsonResponse || $request->isXmlHttpRequest() || $response instanceof RedirectResponse) {
return;
}
// if theme has already been processed the new way, stop here
if (!isset($response->legacy) && !$request->attributes->get('_legacy', false)) {
return;
}
Zikula_View_Theme::getInstance()->themefooter($response);
}
示例5: onKernelRequest
/**
* Strip the Front Controller (index.php) from the URI
*
* @param GetResponseEvent $event An GetResponseEvent instance
*/
public function onKernelRequest(GetResponseEvent $event)
{
if (!$event->isMasterRequest()) {
return;
}
if (\System::isInstalling()) {
return;
}
$requestUri = $event->getRequest()->getRequestUri();
$frontController = \System::getVar('entrypoint', 'index.php');
$stripEntryPoint = (bool) \System::getVar('shorturlsstripentrypoint', false);
$containsFrontController = strpos($requestUri, "{$frontController}/") !== false;
if ($containsFrontController && $stripEntryPoint) {
$url = str_ireplace("{$frontController}/", "", $requestUri);
$response = new RedirectResponse($url, 301);
$event->setResponse($response);
$event->stopPropagation();
}
}
示例6: onKernelRequestSiteOff
public function onKernelRequestSiteOff(GetResponseEvent $event)
{
if (!$event->isMasterRequest()) {
return;
}
$response = $event->getResponse();
$request = $event->getRequest();
if ($response instanceof PlainResponse || $response instanceof JsonResponse || $request->isXmlHttpRequest()) {
return;
}
if (\System::isInstalling()) {
return;
}
// Get variables
$module = strtolower($request->query->get('module'));
$type = strtolower($request->query->get('type'));
$func = strtolower($request->query->get('func'));
$siteOff = (bool) \System::getVar('siteoff');
$hasAdminPerms = \SecurityUtil::checkPermission('ZikulaSettingsModule::', 'SiteOff::', ACCESS_ADMIN);
$urlParams = $module == 'users' && $type == 'user' && $func == 'siteofflogin';
// params are lowercase
$versionCheck = \Zikula_Core::VERSION_NUM != \System::getVar('Version_Num');
// Check for site closed
if ($siteOff && !$hasAdminPerms && !$urlParams || $versionCheck) {
$hasOnlyOverviewAccess = \SecurityUtil::checkPermission('ZikulaUsersModule::', '::', ACCESS_OVERVIEW);
if ($hasOnlyOverviewAccess && \UserUtil::isLoggedIn()) {
\UserUtil::logout();
}
// initialise the language system to enable translations (#1764)
$lang = \ZLanguage::getInstance();
$lang->setup($request);
$response = new Response();
$response->headers->add(array('HTTP/1.1 503 Service Unavailable'));
$response->setStatusCode(503);
$content = (require_once \System::getSystemErrorTemplate('siteoff.tpl'));
// move to CoreBundle and use Twig
$response->setContent($content);
$event->setResponse($response);
$event->stopPropagation();
}
}
示例7: onKernelRequest
public function onKernelRequest(GetResponseEvent $event)
{
if (!$event->isMasterRequest()) {
return;
}
if (\System::isInstalling()) {
return;
}
// Check if compression is desired
if (\System::getVar('UseCompression') != 1) {
return;
}
// Check if zlib extension is available
if (!extension_loaded('zlib')) {
return;
}
// Set compression on
ini_set('zlib.output_handler', '');
ini_set('zlib.output_compression', 'On');
ini_set('zlib.output_compression_level', 6);
}
示例8: ZikulaUsersModule_tables
/**
* Populate pntables array for Users module.
*
* This function is called internally by the core whenever the module is
* loaded. It delivers the table information to the core.
* It can be loaded explicitly using the ModUtil::dbInfoLoad() API function.
*
* @param string $forVersion The module version number for which db information should be returned.
*
* @return array The table information.
*/
function ZikulaUsersModule_tables($forVersion = null)
{
if (!isset($forVersion)) {
if (isset($GLOBALS['_ZikulaUpgrader']['_ZikulaUpgradeFrom12x']) && $GLOBALS['_ZikulaUpgrader']['_ZikulaUpgradeFrom12x']) {
// This check comes before System::isInstalling().
return Users_tables_for_113();
}
if (System::isInstalling()) {
// new installs
return Users_tables_for_220();
}
// Remaining cases - this should be deleted.
$usersModInfo = ModUtil::getInfoFromName('ZikulaUsersModule');
$forVersion = $usersModInfo['version'];
}
if (version_compare($forVersion, '2.2.0') >= 0) {
return Users_tables_for_220();
} else {
return Users_tables_for_113();
}
}
示例9: smarty_function_html_select_modules
/**
* Zikula_View function to display a list box with a list of active modules.
*
* Either user or admin capable or all modules.
*
* Available parameters:
* - name: Name for the control (optional) if not present then only the option tags are output
* - id: ID for the control
* - selected: Selected value
* - capability: Show modules with this capability, all or $capability.
* - assign: If set, the results are assigned to the corresponding variable instead of printed out
*
* Example
*
* {html_select_modules name=mod selected=$mymod}
*
* <select name="mod">
* <option value="">&bsp;</option>
* {html_select_modules selected=$mythemechoice}
* </select>
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @see function.html_select_modules.php::smarty_function_html_select_modules()
* @return string A drop down containing a list of modules.
*/
function smarty_function_html_select_modules($params, Zikula_View $view)
{
// we'll make use of the html_options plugin to simplfiy this plugin
require_once $view->_get_plugin_filepath('function', 'html_options');
// set some defaults
if (isset($params['type'])) {
// bc
$params['capability'] = $params['type'];
}
if (!isset($params['capability'])) {
$params['capability'] = 'all';
}
// get the modules
switch ($params['capability']) {
case 'all':
$modules = ModUtil::getAllMods();
break;
default:
$modules = ModUtil::getModulesCapableOf($params['capability']);
break;
}
// process our list of modules for input to the html_options plugin
$moduleslist = array();
$installerArray = array('ZikulaBlocksModule', 'ZikulaErrorsModule', 'ZikulaPermissionsModule', 'ZikulaCategoriesModule', 'ZikulaGroupsModule', 'ZikulaThemeModule', 'ZikulaUsersModule', 'ZikulaSearchModule');
if (!empty($modules)) {
foreach ($modules as $module) {
if (!(System::isInstalling() && in_array($module['name'], $installerArray))) {
$moduleslist[$module['name']] = $module['displayname'];
}
}
}
natcasesort($moduleslist);
// get the formatted list
$output = smarty_function_html_options(array('options' => $moduleslist, 'selected' => isset($params['selected']) ? $params['selected'] : null, 'name' => isset($params['name']) ? $params['name'] : null, 'id' => isset($params['id']) ? $params['id'] : null), $view);
if (isset($params['assign']) && !empty($params['assign'])) {
$view->assign($params['assign'], $output);
} else {
return $output;
}
}
示例10: reloadAllRoutes
public function reloadAllRoutes(ContainerInterface $sm = null)
{
if (!isset($sm)) {
$sm = \ServiceUtil::getManager();
}
set_time_limit(300);
$bundles = $sm->get('kernel')->getModules();
$request = $sm->get('request');
$dom = \ZLanguage::getModuleDomain('ZikulaRoutesModule');
// See http://doctrine-orm.readthedocs.org/en/latest/reference/transactions-and-concurrency.html#approach-2-explicitly
$this->getEntityManager()->beginTransaction();
// suspend auto-commit
$this->removeAll(false);
try {
foreach ($bundles as $bundle) {
//$this->entityManager->getRepository('ZikulaRoutesModule:RouteEntity')->removeAllOfModule($bundle, false);
try {
$routeCollection = $sm->get('zikularoutesmodule.routing_finder')->find($bundle);
} catch (\Exception $e) {
$message = __f('Error! Routes for %s bundle could not be loaded: %s', array($bundle->getName(), $e->getMessage()), $dom);
if (\System::isInstalling()) {
\LogUtil::registerError($message);
} else {
$request->getSession()->getFlashBag()->add('error', $message);
}
continue;
}
$this->addRouteCollection($bundle, $routeCollection);
}
$this->getEntityManager()->getConnection()->commit();
} catch (\Exception $e) {
$this->getEntityManager()->getConnection()->rollback();
$this->getEntityManager()->close();
throw $e;
}
if (!\System::isInstalling()) {
$request->getSession()->getFlashBag()->add('status', __('Done! Routes reloaded.', $dom));
}
}
示例11: ZikulaRoutesModule_workflow_none_permissioncheck
/**
* Permission check for workflow schema 'none'.
* This function allows to calculate complex permission checks.
* It receives the object the workflow engine is being asked to process and the permission level the action requires.
*
* @param array $obj The currently treated object.
* @param int $permLevel The required workflow permission level.
* @param int $currentUser Id of current user.
* @param string $actionId Id of the workflow action to be executed.
*
* @return bool Whether the current user is allowed to execute the action or not.
*/
function ZikulaRoutesModule_workflow_none_permissioncheck($obj, $permLevel, $currentUser, $actionId)
{
// Make sure not to check permission on installation.
if (\System::isInstalling()) {
return true;
}
// calculate the permission component
$objectType = $obj['_objectType'];
$component = 'ZikulaRoutesModule:' . ucfirst($objectType) . ':';
// calculate the permission instance
$idFields = ModUtil::apiFunc('ZikulaRoutesModule', 'selection', 'getIdFields', array('ot' => $objectType));
$instanceId = '';
foreach ($idFields as $idField) {
if (!empty($instanceId)) {
$instanceId .= '_';
}
$instanceId .= $obj[$idField];
}
$instance = $instanceId . '::';
// now perform the permission check
$result = SecurityUtil::checkPermission($component, $instance, $permLevel, $currentUser);
return $result;
}
示例12: createThemedResponse
public function createThemedResponse(FilterResponseEvent $event)
{
if (!$event->isMasterRequest()) {
return;
}
if (\System::isInstalling()) {
return;
}
$response = $event->getResponse();
$route = $event->getRequest()->attributes->has('_route') ? $event->getRequest()->attributes->get('_route') : '0';
// default must not be '_'
if (!$response instanceof Response || is_subclass_of($response, '\\Symfony\\Component\\HttpFoundation\\Response') || $event->getRequest()->isXmlHttpRequest() || false === strpos($response->headers->get('Content-Type'), 'text/html') || $route[0] === '_') {
return;
}
// all responses are assumed to be themed. PlainResponse will have already returned.
$twigThemedResponse = $this->themeEngine->wrapResponseInTheme($response);
if ($twigThemedResponse) {
$event->setResponse($twigThemedResponse);
} else {
// theme is not a twig based theme, revert to smarty
$smartyThemedResponse = Zikula_View_Theme::getInstance()->themefooter($response);
$event->setResponse($smartyThemedResponse);
}
}
示例13: write
/**
* {@inheritdoc}
*/
public function write($sessionId, $vars)
{
if (System::isInstalling()) {
return true;
}
// http host is not given for CLI requests for example
$ipDefault = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
$obj = $this->storage->getBag('attributes')->get('obj');
$obj['sessid'] = $sessionId;
$obj['vars'] = $vars;
$obj['remember'] = $this->storage->getBag('attributes')->get('rememberme', 0);
$obj['uid'] = $this->storage->getBag('attributes')->get('uid', 0);
$obj['ipaddr'] = $this->storage->getBag('attributes')->get('obj/ipaddr', $ipDefault);
$obj['lastused'] = date('Y-m-d H:i:s', $this->storage->getMetadataBag()->getLastUsed());
$query = $this->conn->executeQuery('SELECT * FROM session_info WHERE sessid=:id', array('id' => $sessionId));
if (!($res = $query->fetch(\PDO::FETCH_ASSOC))) {
$res = $this->conn->executeUpdate('INSERT INTO session_info (sessid, ipaddr, lastused, uid, remember, vars)
VALUES (:sessid, :ipaddr, :lastused, :uid, :remember, :vars)', array('sessid' => $obj['sessid'], 'ipaddr' => $obj['ipaddr'], 'lastused' => $obj['lastused'], 'uid' => $obj['uid'], 'remember' => $obj['remember'], 'uid' => $obj['uid'], 'vars' => $obj['vars']));
} else {
// check for regenerated session and update ID in database
$res = $this->conn->executeUpdate('UPDATE session_info SET ipaddr = :ipaddr, lastused = :lastused, uid = :uid, remember = :remember, vars = :vars WHERE sessid = :sessid', array('sessid' => $obj['sessid'], 'ipaddr' => $obj['ipaddr'], 'lastused' => $obj['lastused'], 'uid' => $obj['uid'], 'remember' => $obj['remember'], 'uid' => $obj['uid'], 'vars' => $obj['vars']));
}
return (bool) $res;
}
示例14: 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);
}
//.........这里部分代码省略.........
示例15: executeSQL
/**
* Execute SQL, check for errors and return result. Uses Doctrine's DBAL to generate DB-portable paging code.
*
* @param string $sql The SQL statement to execute.
* @param integer $limitOffset The lower limit bound (optional) (default=-1).
* @param integer $limitNumRows The upper limit bound (optional) (default=-1).
* @param boolean $exitOnError Whether to exit on error (default=true) (optional).
* @param boolean $verbose Whether to be verbose (default=true) (optional).
*
* @return mixed The result set of the successfully executed query or false on error.
* @throws Exception No SQL statment.
*/
public static function executeSQL($sql, $limitOffset = -1, $limitNumRows = -1, $exitOnError = true, $verbose = true)
{
if (!$sql) {
throw new Exception(__('No SQL statement to execute'));
}
$connection = Doctrine_Manager::getInstance()->getCurrentConnection();
if (!$connection && System::isInstalling()) {
return false;
}
try {
if ($limitNumRows > 0) {
$tStr = strtoupper(substr(trim($sql), 0, 7));
// Grab first 7 chars to allow syntax like "(SELECT" which may happen with UNION statements
if (strpos($tStr, 'SELECT') === false) {
// TODO D [use normal Select instead of showing an error message if paging is desired for something different than SELECTs] (Guite)
throw new Exception(__('Paging parameters can only be used for SELECT statements'));
}
if ($limitOffset > 0) {
$sql = $connection->modifyLimitQuery($sql, $limitNumRows, $limitOffset);
} else {
$sql = $connection->modifyLimitQuery($sql, $limitNumRows);
}
}
$stmt = $connection->prepare($sql);
//$stmt->setHydrationMode(Doctrine_Core::HYDRATE_RECORD);
if ($stmt->execute()) {
$result = $stmt;
}
if ($result) {
// catch manual SQL which requires cache flushes
$tab = null;
$sql = strtolower(trim(preg_replace("/\\s+/", " ", $sql)));
if (strpos($sql, 'update') === 0) {
list(, $tab, ) = explode(' ', $sql);
}
if (strpos($sql, 'delete') === 0) {
list(, , $tab, ) = explode(' ', $sql);
}
if ($tab && strpos($tab, 'session_info') === false) {
self::flushCache($tab);
}
return $result;
}
} catch (Exception $e) {
echo 'Error in DBUtil::executeSQL: ' . $sql . '<br />' . $e->getMessage() . '<br />';
if (System::isDevelopmentMode() && SecurityUtil::checkPermission('.*', '.*', ACCESS_ADMIN)) {
echo nl2br($e->getTraceAsString());
}
if ($exitOnError) {
System::shutDown();
}
}
return false;
}