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


PHP Contao\System类代码示例

本文整理汇总了PHP中Contao\System的典型用法代码示例。如果您正苦于以下问题:PHP System类的具体用法?PHP System怎么用?PHP System使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: __construct

 /**
  * Initialize the controller
  *
  * 1. Import the user
  * 2. Call the parent constructor
  * 3. Authenticate the user
  * 4. Load the language files
  * DO NOT CHANGE THIS ORDER!
  */
 public function __construct()
 {
     $this->import('BackendUser', 'User');
     parent::__construct();
     $this->User->authenticate();
     \System::loadLanguageFile('default');
 }
开发者ID:contao,项目名称:core-bundle,代码行数:16,代码来源:BackendAlerts.php

示例2: run

 /**
  * Run the controller and parse the template
  *
  * @return Response
  */
 public function run()
 {
     /** @var \BackendTemplate|object $objTemplate */
     $objTemplate = new \BackendTemplate('be_preview');
     $objTemplate->base = \Environment::get('base');
     $objTemplate->language = $GLOBALS['TL_LANGUAGE'];
     $objTemplate->title = specialchars($GLOBALS['TL_LANG']['MSC']['fePreview']);
     $objTemplate->charset = \Config::get('characterSet');
     $objTemplate->site = \Input::get('site', true);
     $objTemplate->switchHref = \System::getContainer()->get('router')->generate('contao_backend_switch');
     if (\Input::get('url')) {
         $objTemplate->url = \Environment::get('base') . \Input::get('url');
     } elseif (\Input::get('page')) {
         $objTemplate->url = $this->redirectToFrontendPage(\Input::get('page'), \Input::get('article'), true);
     } else {
         $objTemplate->url = \System::getContainer()->get('router')->generate('contao_root', [], UrlGeneratorInterface::ABSOLUTE_URL);
     }
     // Switch to a particular member (see #6546)
     if (\Input::get('user') && $this->User->isAdmin) {
         $objUser = \MemberModel::findByUsername(\Input::get('user'));
         if ($objUser !== null) {
             $strHash = $this->getSessionHash('FE_USER_AUTH');
             // Remove old sessions
             $this->Database->prepare("DELETE FROM tl_session WHERE tstamp<? OR hash=?")->execute(time() - \Config::get('sessionTimeout'), $strHash);
             // Insert the new session
             $this->Database->prepare("INSERT INTO tl_session (pid, tstamp, name, sessionID, ip, hash) VALUES (?, ?, ?, ?, ?, ?)")->execute($objUser->id, time(), 'FE_USER_AUTH', \System::getContainer()->get('session')->getId(), \Environment::get('ip'), $strHash);
             // Set the cookie
             $this->setCookie('FE_USER_AUTH', $strHash, time() + \Config::get('sessionTimeout'), null, null, false, true);
             $objTemplate->user = \Input::post('user');
         }
     }
     return $objTemplate->getResponse();
 }
开发者ID:jamesdevine,项目名称:core-bundle,代码行数:38,代码来源:BackendPreview.php

示例3: runTests

 /**
  * Runs the actual tests.
  */
 protected function runTests()
 {
     // Environment::get('ip') needs the request stack
     System::setContainer($this->mockContainerWithContaoScopes());
     $agent = Environment::get('agent');
     $this->assertEquals('mac', $agent->os);
     $this->assertEquals('mac chrome webkit ch33', $agent->class);
     $this->assertEquals('chrome', $agent->browser);
     $this->assertEquals('ch', $agent->shorty);
     $this->assertEquals(33, $agent->version);
     $this->assertEquals('webkit', $agent->engine);
     $this->assertEquals([33, 0, 1750, 149], $agent->versions);
     $this->assertFalse($agent->mobile);
     $this->assertEquals('HTTP/1.1', Environment::get('serverProtocol'));
     $this->assertEquals($this->getRootDir() . '/core/index.php', Environment::get('scriptFilename'));
     $this->assertEquals('/core/index.php', Environment::get('scriptName'));
     $this->assertEquals($this->getRootDir(), Environment::get('documentRoot'));
     $this->assertEquals('/core/en/academy.html?do=test', Environment::get('requestUri'));
     $this->assertEquals(['de-DE', 'de', 'en-GB', 'en'], Environment::get('httpAcceptLanguage'));
     $this->assertEquals(['gzip', 'deflate', 'sdch'], Environment::get('httpAcceptEncoding'));
     $this->assertEquals('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.149 Safari/537.36', Environment::get('httpUserAgent'));
     $this->assertEquals('localhost', Environment::get('httpHost'));
     $this->assertEmpty(Environment::get('httpXForwardedHost'));
     $this->assertFalse(Environment::get('ssl'));
     $this->assertEquals('http://localhost', Environment::get('url'));
     $this->assertEquals('http://localhost/core/en/academy.html?do=test', Environment::get('uri'));
     $this->assertEquals('123.456.789.0', Environment::get('ip'));
     $this->assertEquals('127.0.0.1', Environment::get('server'));
     $this->assertEquals('index.php', Environment::get('script'));
     $this->assertEquals('en/academy.html?do=test', Environment::get('request'));
     $this->assertEquals('en/academy.html?do=test', Environment::get('indexFreeRequest'));
     $this->assertEquals('http://localhost' . Environment::get('path') . '/', Environment::get('base'));
     $this->assertFalse(Environment::get('isAjaxRequest'));
 }
开发者ID:qzminski,项目名称:contao-core-bundle,代码行数:37,代码来源:EnvironmentTest.php

示例4: processPostUpload

 /**
  * Compress images
  *
  * @param boolean $arrFiles File array
  */
 public function processPostUpload($arrFiles)
 {
     if (is_array($arrFiles) && $GLOBALS['TL_CONFIG']['tinypng_api_key'] != '') {
         $strUrl = 'https://api.tinypng.com/shrink';
         $strKey = $GLOBALS['TL_CONFIG']['tinypng_api_key'];
         $strAuthorization = 'Basic ' . base64_encode("api:{$strKey}");
         foreach ($arrFiles as $file) {
             $objFile = FilesModel::findByPath($file);
             if (in_array($objFile->extension, array('png', 'jpg', 'jpeg'))) {
                 $strFile = TL_ROOT . '/' . $file;
                 $objRequest = new Request();
                 $objRequest->method = 'post';
                 $objRequest->data = file_get_contents($strFile);
                 $objRequest->setHeader('Content-type', 'image/png');
                 $objRequest->setHeader('Authorization', $strAuthorization);
                 $objRequest->send($strUrl);
                 $arrResponse = json_decode($objRequest->response);
                 if ($objRequest->code == 201) {
                     file_put_contents($strFile, fopen($arrResponse->output->url, "rb", false));
                     $objFile->tstamp = time();
                     $objFile->path = $file;
                     $objFile->hash = md5_file(TL_ROOT . '/' . $file);
                     $objFile->save();
                     System::log('Compression was successful. (File: ' . $file . ')', __METHOD__, TL_FILES);
                 } else {
                     System::log('Compression failed. (' . $arrResponse->message . ') (File: ' . $file . ')', __METHOD__, TL_FILES);
                 }
             }
         }
     }
 }
开发者ID:christianbarkowsky,项目名称:contao-tiny-compress-images,代码行数:36,代码来源:TinyCompressImages.php

示例5: getCurrencies

 /**
  * @return array
  */
 public function getCurrencies()
 {
     $return = array();
     $arrAux = array();
     \Contao\System::loadLanguageFile('currencies');
     $this->loadCurrencies();
     if (is_array($this->arrCurrencies)) {
         foreach ($this->arrCurrencies as $strKey => $strName) {
             $arrAux[$strKey] = isset($GLOBALS['TL_LANG']['CUR'][$strKey]) ? Utf8::toAscii($GLOBALS['TL_LANG']['CUR'][$strKey]) : $strName;
         }
     }
     asort($arrAux);
     if (is_array($arrAux)) {
         foreach (array_keys($arrAux) as $strKey) {
             $return[$strKey] = isset($GLOBALS['TL_LANG']['CUR'][$strKey]) ? $GLOBALS['TL_LANG']['CUR'][$strKey] : $this->arrCurrencies[$strKey];
         }
     }
     // HOOK: add custom logic
     if (isset($GLOBALS['TL_HOOKS']['getCurrencies']) && is_array($GLOBALS['TL_HOOKS']['getCurrencies'])) {
         foreach ($GLOBALS['TL_HOOKS']['getCurrencies'] as $callback) {
             $return = static::importStatic($callback[0])->{$callback}[1]($return, $this->arrCurrencies);
         }
     }
     return $return;
 }
开发者ID:Craffft,项目名称:currencies-bundle,代码行数:28,代码来源:Currencies.php

示例6: run

 /**
  * Generate the module
  *
  * @return string
  */
 public function run()
 {
     $arrJobs = array();
     /** @var BackendTemplate|object $objTemplate */
     $objTemplate = new \BackendTemplate('be_purge_data');
     $objTemplate->isActive = $this->isActive();
     $objTemplate->message = \Message::generateUnwrapped();
     // Run the jobs
     if (\Input::post('FORM_SUBMIT') == 'tl_purge') {
         $purge = \Input::post('purge');
         if (!empty($purge) && is_array($purge)) {
             foreach ($purge as $group => $jobs) {
                 foreach ($jobs as $job) {
                     list($class, $method) = $GLOBALS['TL_PURGE'][$group][$job]['callback'];
                     $this->import($class);
                     $this->{$class}->{$method}();
                 }
             }
         }
         \Message::addConfirmation($GLOBALS['TL_LANG']['tl_maintenance']['cacheCleared']);
         $this->reload();
     }
     // Tables
     foreach ($GLOBALS['TL_PURGE']['tables'] as $key => $config) {
         $arrJobs[$key] = array('id' => 'purge_' . $key, 'title' => $GLOBALS['TL_LANG']['tl_maintenance_jobs'][$key][0], 'description' => $GLOBALS['TL_LANG']['tl_maintenance_jobs'][$key][1], 'group' => 'tables', 'affected' => '');
         // Get the current table size
         foreach ($config['affected'] as $table) {
             $objCount = $this->Database->execute("SELECT COUNT(*) AS count FROM " . $table);
             $arrJobs[$key]['affected'] .= '<br>' . $table . ': <span>' . sprintf($GLOBALS['TL_LANG']['MSC']['entries'], $objCount->count) . ', ' . $this->getReadableSize($this->Database->getSizeOf($table), 0) . '</span>';
         }
     }
     $strCachePath = str_replace(TL_ROOT . DIRECTORY_SEPARATOR, '', \System::getContainer()->getParameter('kernel.cache_dir'));
     // Folders
     foreach ($GLOBALS['TL_PURGE']['folders'] as $key => $config) {
         $arrJobs[$key] = array('id' => 'purge_' . $key, 'title' => $GLOBALS['TL_LANG']['tl_maintenance_jobs'][$key][0], 'description' => $GLOBALS['TL_LANG']['tl_maintenance_jobs'][$key][1], 'group' => 'folders', 'affected' => '');
         // Get the current folder size
         foreach ($config['affected'] as $folder) {
             $total = 0;
             $folder = sprintf($folder, $strCachePath);
             // Only check existing folders
             if (is_dir(TL_ROOT . '/' . $folder)) {
                 $objFiles = Finder::create()->in(TL_ROOT . '/' . $folder)->files();
                 $total = iterator_count($objFiles);
             }
             $arrJobs[$key]['affected'] .= '<br>' . $folder . ': <span>' . sprintf($GLOBALS['TL_LANG']['MSC']['files'], $total) . '</span>';
         }
     }
     // Custom
     foreach ($GLOBALS['TL_PURGE']['custom'] as $key => $job) {
         $arrJobs[$key] = array('id' => 'purge_' . $key, 'title' => $GLOBALS['TL_LANG']['tl_maintenance_jobs'][$key][0], 'description' => $GLOBALS['TL_LANG']['tl_maintenance_jobs'][$key][1], 'group' => 'custom');
     }
     $objTemplate->jobs = $arrJobs;
     $objTemplate->action = ampersand(\Environment::get('request'));
     $objTemplate->headline = $GLOBALS['TL_LANG']['tl_maintenance']['clearCache'];
     $objTemplate->job = $GLOBALS['TL_LANG']['tl_maintenance']['job'];
     $objTemplate->description = $GLOBALS['TL_LANG']['tl_maintenance']['description'];
     $objTemplate->submit = \StringUtil::specialchars($GLOBALS['TL_LANG']['tl_maintenance']['clearCache']);
     $objTemplate->help = \Config::get('showHelp') && $GLOBALS['TL_LANG']['tl_maintenance']['cacheTables'][1] != '' ? $GLOBALS['TL_LANG']['tl_maintenance']['cacheTables'][1] : '';
     return $objTemplate->parse();
 }
开发者ID:contao,项目名称:core-bundle,代码行数:65,代码来源:PurgeData.php

示例7: purgePageCache

 /**
  * Overwrite for Automator::purgePageCache
  * Makes sure the forum layout is regenerated
  */
 public function purgePageCache()
 {
     $automator = new Automator();
     $automator->purgePageCache();
     System::getContainer()->get('phpbb_bridge.connector')->generateForumLayoutFiles();
     $this->log('Purged the phpbb forum cache', __METHOD__, TL_CRON);
 }
开发者ID:ctsmedia,项目名称:contao-phpbb-bridge-bundle,代码行数:11,代码来源:ForumMaintenance.php

示例8: run

 /**
  * Run the controller and parse the login template
  *
  * @return Response
  */
 public function run()
 {
     /** @var BackendTemplate|object $objTemplate */
     $objTemplate = new \BackendTemplate('be_login');
     $strHeadline = sprintf($GLOBALS['TL_LANG']['MSC']['loginTo'], \Config::get('websiteTitle'));
     $objTemplate->theme = \Backend::getTheme();
     $objTemplate->messages = \Message::generate();
     $objTemplate->base = \Environment::get('base');
     $objTemplate->language = $GLOBALS['TL_LANGUAGE'];
     $objTemplate->languages = \System::getLanguages(true);
     $objTemplate->title = \StringUtil::specialchars($strHeadline);
     $objTemplate->charset = \Config::get('characterSet');
     $objTemplate->action = ampersand(\Environment::get('request'));
     $objTemplate->userLanguage = $GLOBALS['TL_LANG']['tl_user']['language'][0];
     $objTemplate->headline = $strHeadline;
     $objTemplate->curLanguage = \Input::post('language') ?: str_replace('-', '_', $GLOBALS['TL_LANGUAGE']);
     $objTemplate->curUsername = \Input::post('username') ?: '';
     $objTemplate->uClass = $_POST && empty($_POST['username']) ? ' class="login_error"' : '';
     $objTemplate->pClass = $_POST && empty($_POST['password']) ? ' class="login_error"' : '';
     $objTemplate->loginButton = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['loginBT']);
     $objTemplate->username = $GLOBALS['TL_LANG']['tl_user']['username'][0];
     $objTemplate->password = $GLOBALS['TL_LANG']['MSC']['password'][0];
     $objTemplate->feLink = $GLOBALS['TL_LANG']['MSC']['feLink'];
     $objTemplate->default = $GLOBALS['TL_LANG']['MSC']['default'];
     $objTemplate->jsDisabled = $GLOBALS['TL_LANG']['MSC']['jsDisabled'];
     return $objTemplate->getResponse();
 }
开发者ID:contao,项目名称:core-bundle,代码行数:32,代码来源:BackendIndex.php

示例9: getResponse

 /**
  * Return a response object
  *
  * The forum Page usually does not get called because the frontend listener
  * overrides the url for navigation for example. When called directly the layout parts
  * phpBB gets created und pushed to phpbb
  *
  * @see ContaoFrontendListener
  *
  * @param \PageModel $objPage
  * @param boolean $blnCheckRequest
  *
  * @return Response
  */
 public function getResponse($objPage, $blnCheckRequest = false)
 {
     $this->prepare($objPage);
     // prepare the template contents
     $this->Template->main = "%%FORUM%%";
     $style = $this->prepareHeadTags($this->Template->stylesheets);
     $mooScripts = $this->prepareHeadTags($this->Template->mooScripts);
     $framework = $this->prepareHeadTags($this->Template->framework);
     $head = $this->prepareHeadTags($this->Template->head);
     $this->Template->head = "";
     $response = $this->Template->getResponse($blnCheckRequest);
     // layout sections
     $overall_header = '';
     $overall_footer = '';
     $sections = $this->generateLayoutSections($response->getContent());
     // template vars will be replaced with dynamic content on each request
     $overall_header = '{CONTAO_LAYOUT_HEADER}';
     $overall_footer = '{CONTAO_LAYOUT_FOOTER}';
     // If dynamic generation is set and json format requested we can return and leave (no need to generate files)
     if ($this->Input->get('format') == 'json') {
         return new JsonResponse($sections);
     }
     // Generate files for static and generic contents
     $phpbbHeaders = "";
     $phpbbHeaders .= $framework;
     $phpbbHeaders .= $style;
     $phpbbHeaders .= $mooScripts;
     $phpbbHeaders .= $head;
     file_put_contents(__DIR__ . '/../Resources/phpBB/ctsmedia/contaophpbbbridge/styles/all/template/event/overall_header_stylesheets_after.html', $phpbbHeaders);
     file_put_contents(__DIR__ . '/../Resources/phpBB/ctsmedia/contaophpbbbridge/styles/all/template/event/simple_header_stylesheets_after.html', $phpbbHeaders);
     file_put_contents(__DIR__ . '/../Resources/phpBB/ctsmedia/contaophpbbbridge/styles/all/template/event/overall_header_body_before.html', $overall_header);
     file_put_contents(__DIR__ . '/../Resources/phpBB/ctsmedia/contaophpbbbridge/styles/all/template/event/overall_footer_after.html', $overall_footer);
     System::getContainer()->get('phpbb_bridge.connector')->updateConfig(array('contao.body_class' => $this->Template->class));
     return $response;
 }
开发者ID:ctsmedia,项目名称:contao-phpbb-bridge-bundle,代码行数:49,代码来源:Forum.php

示例10: setUp

 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     System::setContainer($this->mockContainerWithContaoScopes());
     require_once __DIR__ . '/../../src/Resources/contao/config/config.php';
     $this->connection = $this->getMock('Doctrine\\DBAL\\Connection', ['fetchAll'], [], '', false);
     $this->eventDispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
     $this->imageSizes = new ImageSizes($this->connection, $this->eventDispatcher, $this->mockContaoFramework());
 }
开发者ID:Mozan,项目名称:core-bundle,代码行数:11,代码来源:ImageSizesTest.php

示例11: executeCallback

 /**
  * @param \Closure|array $callback
  * @param array $args
  *
  * @return mixed
  */
 private function executeCallback($callback, array $args)
 {
     // Support Contao's getInstance() method when callback is an array
     if (is_array($callback)) {
         return call_user_func_array([System::importStatic($callback[0]), $callback[1]], $args);
     }
     return call_user_func_array($callback, $args);
 }
开发者ID:terminal42,项目名称:contao-changelanguage,代码行数:14,代码来源:LabelCallback.php

示例12: __construct

 /**
  * Get the session data
  */
 protected function __construct()
 {
     if (PHP_SAPI == 'cli') {
         $this->session = new SymfonySession(new MockArraySessionStorage());
     } else {
         $this->session = \System::getContainer()->get('session');
     }
     $this->sessionBag = $this->session->getBag($this->getSessionBagKey());
 }
开发者ID:contao,项目名称:core-bundle,代码行数:12,代码来源:Session.php

示例13: getButtons

 /**
  * Get buttons.
  *
  * @param $articleId
  *
  * @return string
  */
 protected function getButtons($articleId)
 {
     global $container;
     System::loadLanguageFile('tl_article');
     $translator = $container['translator'];
     $buttons = self::getModalEditButton($articleId, $translator);
     $buttons .= self::getModalShowButton($articleId, $translator);
     return $buttons;
 }
开发者ID:avisota,项目名称:contao-message-element-article,代码行数:16,代码来源:ArticleListContentController.php

示例14: purge

 /**
  * Purge the data
  */
 public function purge()
 {
     // Purge the data
     Database::getInstance()->query("TRUNCATE TABLE tl_vimeo_cache");
     // Purge the images
     $folder = new \Folder(static::$imagesFolder);
     $folder->purge();
     // Log the action
     System::log('Purged the Vimeo cache', __METHOD__, TL_CRON);
 }
开发者ID:derhaeuptling,项目名称:contao-vimeo-api,代码行数:13,代码来源:Cache.php

示例15: __construct

 /**
  * Initialize the controller
  *
  * 1. Import the user
  * 2. Call the parent constructor
  * 3. Authenticate the user
  * 4. Load the language files
  * DO NOT CHANGE THIS ORDER!
  */
 public function __construct()
 {
     $this->import('BackendUser', 'User');
     parent::__construct();
     $this->User->authenticate();
     \System::loadLanguageFile('default');
     $strFile = \Input::get('src', true);
     $strFile = base64_decode($strFile);
     $strFile = preg_replace('@^/+@', '', rawurldecode($strFile));
     $this->strFile = $strFile;
 }
开发者ID:Mozan,项目名称:core-bundle,代码行数:20,代码来源:BackendPopup.php


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