The class provides miscellaneous methods that are used all throughout the application. It is the base class of the Contao library which provides the central "import" method to load other library classes. Usage: class MyClass extends \System { public function __construct() { $this->import('Database'); } }
예제 #1
1
 /**
  * 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();
 }
예제 #2
0
 /**
  * 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');
 }
 /**
  * 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'));
 }
 /**
  * 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);
                 }
             }
         }
     }
 }
예제 #5
0
 /**
  * @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;
 }
예제 #6
0
 /**
  * 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();
 }
 /**
  * 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);
 }
예제 #8
0
 /**
  * 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();
 }
예제 #9
0
 /**
  * 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;
 }
 /**
  * Constructor
  */
 public function __construct()
 {
     parent::__construct();
     $this->import('Database');
     $this->import('Input');
     $this->database = $this->Database;
     $this->input = $this->Input;
 }
예제 #11
0
 /**
  * {@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());
 }
 /**
  * @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);
 }
예제 #13
0
 /**
  * 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());
 }
 /**
  * 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;
 }
예제 #15
0
 /**
  * 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);
 }
예제 #16
0
 /**
  * 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;
 }
예제 #17
0
 /**
  * Generate the widget and return it as string
  *
  * @return string
  */
 public function generate()
 {
     $arrOptions = array();
     if (!$this->multiple && count($this->arrOptions) > 1) {
         $this->arrOptions = array($this->arrOptions[0]);
     }
     // The "required" attribute only makes sense for single checkboxes
     if ($this->mandatory && !$this->multiple) {
         $this->arrAttributes['required'] = 'required';
     }
     /** @var AttributeBagInterface $objSessionBag */
     $objSessionBag = \System::getContainer()->get('session')->getBag('contao_backend');
     $state = $objSessionBag->get('checkbox_groups');
     // Toggle the checkbox group
     if (\Input::get('cbc')) {
         $state[\Input::get('cbc')] = isset($state[\Input::get('cbc')]) && $state[\Input::get('cbc')] == 1 ? 0 : 1;
         $objSessionBag->set('checkbox_groups', $state);
         $this->redirect(preg_replace('/(&(amp;)?|\\?)cbc=[^& ]*/i', '', \Environment::get('request')));
     }
     $blnFirst = true;
     $blnCheckAll = true;
     foreach ($this->arrOptions as $i => $arrOption) {
         // Single dimension array
         if (is_numeric($i)) {
             $arrOptions[] = $this->generateCheckbox($arrOption, $i);
             continue;
         }
         $id = 'cbc_' . $this->strId . '_' . \StringUtil::standardize($i);
         $img = 'folPlus.svg';
         $display = 'none';
         if (!isset($state[$id]) || !empty($state[$id])) {
             $img = 'folMinus.svg';
             $display = 'block';
         }
         $arrOptions[] = '<div class="checkbox_toggler' . ($blnFirst ? '_first' : '') . '"><a href="' . $this->addToUrl('cbc=' . $id) . '" onclick="AjaxRequest.toggleCheckboxGroup(this,\'' . $id . '\');Backend.getScrollOffset();return false">' . \Image::getHtml($img) . '</a>' . $i . '</div><fieldset id="' . $id . '" class="tl_checkbox_container checkbox_options" style="display:' . $display . '"><input type="checkbox" id="check_all_' . $id . '" class="tl_checkbox" onclick="Backend.toggleCheckboxGroup(this, \'' . $id . '\')"> <label for="check_all_' . $id . '" style="color:#a6a6a6"><em>' . $GLOBALS['TL_LANG']['MSC']['selectAll'] . '</em></label>';
         // Multidimensional array
         foreach ($arrOption as $k => $v) {
             $arrOptions[] = $this->generateCheckbox($v, standardize($i) . '_' . $k);
         }
         $arrOptions[] = '</fieldset>';
         $blnFirst = false;
         $blnCheckAll = false;
     }
     // Add a "no entries found" message if there are no options
     if (empty($arrOptions)) {
         $arrOptions[] = '<p class="tl_noopt">' . $GLOBALS['TL_LANG']['MSC']['noResult'] . '</p>';
         $blnCheckAll = false;
     }
     if ($this->multiple) {
         return sprintf('<fieldset id="ctrl_%s" class="tl_checkbox_container%s"><legend>%s%s%s%s</legend><input type="hidden" name="%s" value="">%s%s</fieldset>%s', $this->strId, $this->strClass != '' ? ' ' . $this->strClass : '', $this->mandatory ? '<span class="invisible">' . $GLOBALS['TL_LANG']['MSC']['mandatory'] . ' </span>' : '', $this->strLabel, $this->mandatory ? '<span class="mandatory">*</span>' : '', $this->xlabel, $this->strName, $blnCheckAll ? '<input type="checkbox" id="check_all_' . $this->strId . '" class="tl_checkbox" onclick="Backend.toggleCheckboxGroup(this,\'ctrl_' . $this->strId . '\')' . ($this->onclick ? ';' . $this->onclick : '') . '"> <label for="check_all_' . $this->strId . '" style="color:#a6a6a6"><em>' . $GLOBALS['TL_LANG']['MSC']['selectAll'] . '</em></label><br>' : '', str_replace('<br></fieldset><br>', '</fieldset>', implode('<br>', $arrOptions)), $this->wizard);
     } else {
         return sprintf('<div id="ctrl_%s" class="tl_checkbox_single_container%s"><input type="hidden" name="%s" value="">%s</div>%s', $this->strId, $this->strClass != '' ? ' ' . $this->strClass : '', $this->strName, str_replace('<br></div><br>', '</div>', implode('<br>', $arrOptions)), $this->wizard);
     }
 }
예제 #18
0
 /**
  * Toggles the TL_VIEW cookie and redirects back to the referring page.
  *
  * @param GetResponseEvent $event The event object
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     $request = $event->getRequest();
     if (!$this->isFrontendMasterRequest($event) || !$request->query->has('toggle_view')) {
         return;
     }
     $this->framework->initialize();
     $response = new RedirectResponse(System::getReferer(), 303);
     $response->headers->setCookie($this->getCookie($request->query->get('toggle_view'), $request->getBasePath()));
     $event->setResponse($response);
 }
 /**
  * Generate the purge cache field
  *
  * @return string
  */
 public function generatePurgeField()
 {
     System::loadLanguageFile('tl_maintenance');
     $template = new BackendTemplate('be_vimeo_rebuilder_user');
     $template->elementsCount = count(Rebuilder::getContentElements());
     if (($stats = Rebuilder::generateStats()) !== null) {
         foreach ($stats as $k => $v) {
             $template->{$k} = $v;
         }
     }
     return $template->parse();
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->getFramework()->initialize();
     $output->writeln('Clearing Forum Cache');
     System::getContainer()->get('phpbb_bridge.connector')->clearForumCache();
     // Generate the layout if not explicitly asked for cache only
     if (!$input->getOption('cache-only')) {
         $output->writeln('Generating Layout Files');
         System::getContainer()->get('phpbb_bridge.connector')->generateForumLayoutFiles();
     }
     return 0;
 }
예제 #21
0
 /**
  * @param array $arrSettings
  * @return array
  */
 public function dcaDataFields($arrSettings = array())
 {
     $arrMandatory = $arrSettings['arrMandatory'];
     $this->overwriteMandatory = $arrSettings['addMandatory'] ? true : false;
     $userID = $this->getUserID();
     $fields = array('id' => array('sql' => 'int(10) unsigned NOT NULL auto_increment'), 'tstamp' => array('sql' => "int(10) unsigned NOT NULL default '0'"), 'title' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['title'], 'inputType' => 'text', 'exclude' => true, 'sorting' => true, 'search' => true, 'eval' => array('maxlength' => 255, 'mandatory' => $this->setCustomMandatory($arrMandatory, 'title', '1'), 'tl_class' => 'w50', 'fmEditable' => true, 'fmGroup' => 'teaser'), 'sql' => "varchar(255) NOT NULL default ''"), 'alias' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['alias'], 'inputType' => 'text', 'exclude' => true, 'eval' => array('rgxp' => 'alias', 'maxlength' => 128, 'tl_class' => 'w50', 'unique' => true, 'fmEditable' => true, 'fmGroup' => 'teaser'), 'save_callback' => array(array('DCAModuleData', 'generateAlias')), 'sql' => "varchar(128) COLLATE utf8_bin NOT NULL default ''"), 'info' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['info'], 'inputType' => 'text', 'exclude' => true, 'search' => true, 'eval' => array('maxlength' => 255, 'tl_class' => 'clr long', 'mandatory' => $this->setCustomMandatory($arrMandatory, 'info'), 'fmEditable' => true, 'fmGroup' => 'teaser'), 'sql' => "varchar(255) NOT NULL default ''"), 'description' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['description'], 'inputType' => 'textarea', 'exclude' => true, 'search' => true, 'eval' => array('tl_class' => 'clr', 'mandatory' => $this->setCustomMandatory($arrMandatory, 'description'), 'rte' => 'tinyMCE', 'fmEditable' => true, 'fmGroup' => 'teaser'), 'sql' => "mediumtext NULL"), 'author' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['author'], 'default' => $userID, 'exclude' => true, 'filter' => true, 'inputType' => 'select', 'foreignKey' => 'tl_user.name', 'eval' => array('doNotCopy' => true, 'chosen' => true, 'includeBlankOption' => true, 'mandatory' => true, 'tl_class' => 'w50', 'fmEditable' => true, 'fmGroup' => 'author'), 'relation' => array('type' => 'hasOne', 'load' => 'eager'), 'sql' => "int(10) unsigned NOT NULL default '0'"), 'date' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['date'], 'default' => time(), 'exclude' => true, 'filter' => true, 'sorting' => true, 'flag' => 8, 'inputType' => 'text', 'eval' => array('rgxp' => 'date', 'doNotCopy' => true, 'datepicker' => true, 'mandatory' => $this->setCustomMandatory($arrMandatory, 'date'), 'tl_class' => 'w50 wizard', 'fmEditable' => true, 'fmGroup' => 'date'), 'sql' => "int(10) unsigned NULL"), 'time' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['time'], 'default' => time(), 'exclude' => true, 'inputType' => 'text', 'eval' => array('rgxp' => 'time', 'doNotCopy' => true, 'tl_class' => 'w50', 'mandatory' => $this->setCustomMandatory($arrMandatory, 'time'), 'fmEditable' => true, 'fmGroup' => 'date'), 'sql' => "int(10) unsigned NULL"), 'source' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['source'], 'default' => 'default', 'exclude' => true, 'inputType' => 'select', 'options' => array('default', 'internal', 'external'), 'reference' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack'], 'eval' => array('submitOnChange' => true, 'helpwizard' => true, 'mandatory' => $this->setCustomMandatory($arrMandatory, 'source'), 'fmEditable' => true, 'fmGroup' => 'source'), 'sql' => "varchar(32) NOT NULL default ''"), 'url' => array('label' => &$GLOBALS['TL_LANG']['MSC']['url'], 'exclude' => true, 'inputType' => 'text', 'eval' => array('decodeEntities' => true, 'maxlength' => 255, 'tl_class' => 'w50', 'mandatory' => $this->setCustomMandatory($arrMandatory, 'url', '1'), 'fmEditable' => true, 'fmGroup' => 'source'), 'sql' => "varchar(255) NOT NULL default ''"), 'jumpTo' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['jumpTo'], 'exclude' => true, 'inputType' => 'pageTree', 'foreignKey' => 'tl_page.title', 'eval' => array('fieldType' => 'radio', 'mandatory' => $this->setCustomMandatory($arrMandatory, 'jumpTo', '1'), 'fmEditable' => true, 'fmGroup' => 'source'), 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'belongsTo', 'load' => 'lazy')), 'target' => array('label' => &$GLOBALS['TL_LANG']['MSC']['target'], 'exclude' => true, 'inputType' => 'checkbox', 'eval' => array('tl_class' => 'w50 m12', 'mandatory' => $this->setCustomMandatory($arrMandatory, 'target'), 'fmEditable' => true, 'fmGroup' => 'source'), 'sql' => "char(1) NOT NULL default ''"), 'addEnclosure' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['addEnclosure'], 'exclude' => true, 'inputType' => 'checkbox', 'eval' => array('submitOnChange' => true), 'sql' => "char(1) NOT NULL default ''"), 'enclosure' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['enclosure'], 'exclude' => true, 'inputType' => 'fileTree', 'eval' => array('multiple' => true, 'fieldType' => 'checkbox', 'filesOnly' => true, 'isDownloads' => true, 'mandatory' => $this->setCustomMandatory($arrMandatory, 'enclosure', '1'), 'extensions' => \Config::get('allowedDownload'), 'fmEditable' => true, 'fmGroup' => 'enclosure'), 'sql' => "blob NULL"), 'addImage' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['addImage'], 'exclude' => true, 'inputType' => 'checkbox', 'eval' => array('submitOnChange' => true, 'mandatory' => $this->setCustomMandatory($arrMandatory, 'addImage')), 'sql' => "char(1) NOT NULL default ''"), 'singleSRC' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['singleSRC'], 'exclude' => true, 'inputType' => 'fileTree', 'eval' => array('filesOnly' => true, 'fieldType' => 'radio', 'mandatory' => $this->setCustomMandatory($arrMandatory, 'singleSRC', '1'), 'extensions' => \Config::get('validImageTypes'), 'fmEditable' => true, 'fmGroup' => 'image'), 'sql' => "binary(16) NULL"), 'alt' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['alt'], 'exclude' => true, 'search' => true, 'inputType' => 'text', 'eval' => array('maxlength' => 255, 'mandatory' => $this->setCustomMandatory($arrMandatory, 'alt'), 'tl_class' => 'w50', 'fmEditable' => true, 'fmGroup' => 'image'), 'sql' => "varchar(255) NOT NULL default ''"), 'imgTitle' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['imgTitle'], 'exclude' => true, 'search' => true, 'inputType' => 'text', 'eval' => array('maxlength' => 255, 'mandatory' => $this->setCustomMandatory($arrMandatory, 'imgTitle'), 'tl_class' => 'w50', 'fmEditable' => true, 'fmGroup' => 'image'), 'sql' => "varchar(255) NOT NULL default ''"), 'floating' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['floating'], 'default' => 'above', 'exclude' => true, 'inputType' => 'radioTable', 'options' => array('above', 'left', 'right', 'below'), 'eval' => array('cols' => 4, 'tl_class' => 'w50'), 'reference' => &$GLOBALS['TL_LANG']['MSC'], 'sql' => "varchar(32) NOT NULL default ''"), 'size' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['size'], 'exclude' => true, 'inputType' => 'imageSize', 'options' => System::getImageSizes(), 'reference' => &$GLOBALS['TL_LANG']['MSC'], 'eval' => array('rgxp' => 'natural', 'includeBlankOption' => true, 'nospace' => true, 'helpwizard' => true, 'tl_class' => 'w50', 'fmEditable' => true, 'fmGroup' => 'image'), 'sql' => "varchar(64) NOT NULL default ''"), 'fullsize' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['fullsize'], 'exclude' => true, 'inputType' => 'checkbox', 'eval' => array('tl_class' => 'w50 m12', 'mandatory' => $this->setCustomMandatory($arrMandatory, 'fullsize'), 'fmEditable' => true, 'fmGroup' => 'image'), 'sql' => "char(1) NOT NULL default ''"), 'caption' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['caption'], 'exclude' => true, 'search' => true, 'inputType' => 'text', 'eval' => array('maxlength' => 255, 'allowHtml' => true, 'mandatory' => $this->setCustomMandatory($arrMandatory, 'caption'), 'tl_class' => 'w50', 'fmEditable' => true, 'fmGroup' => 'image'), 'sql' => "varchar(255) NOT NULL default ''"), 'geo_latitude' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['geo_latitude'], 'exclude' => true, 'inputType' => 'text', 'eval' => array('maxlength' => 128, 'tl_class' => 'w50', 'mandatory' => $this->setCustomMandatory($arrMandatory, 'geo_latitude'), 'fmEditable' => true, 'fmGroup' => 'map'), 'sql' => "varchar(128) NOT NULL default ''"), 'geo_longitude' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['geo_longitude'], 'exclude' => true, 'inputType' => 'text', 'eval' => array('maxlength' => 128, 'tl_class' => 'w50', 'mandatory' => $this->setCustomMandatory($arrMandatory, 'geo_longitude'), 'fmEditable' => true, 'fmGroup' => 'map'), 'sql' => "varchar(128) NOT NULL default ''"), 'geo_address' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['geo_address'], 'exclude' => true, 'inputType' => 'text', 'eval' => array('maxlength' => 255, 'tl_class' => 'long', 'mandatory' => $this->setCustomMandatory($arrMandatory, 'geo_address'), 'fmEditable' => true, 'fmGroup' => 'map'), 'sql' => "varchar(255) NOT NULL default ''"), 'addMarker' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['addMarker'], 'exclude' => true, 'inputType' => 'checkbox', 'eval' => array('submitOnChange' => true), 'sql' => "char(1) NOT NULL default ''"), 'markerSRC' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['markerSRC'], 'exclude' => true, 'inputType' => 'fileTree', 'eval' => array('filesOnly' => true, 'fieldType' => 'radio', 'mandatory' => $this->setCustomMandatory($arrMandatory, 'markerSRC'), 'extensions' => \Config::get('validImageTypes'), 'fmEditable' => true, 'fmGroup' => 'map'), 'sql' => "binary(16) NULL"), 'markerAlt' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['markerAlt'], 'exclude' => true, 'inputType' => 'text', 'eval' => array('maxlength' => 255, 'tl_class' => 'w50', 'mandatory' => $this->setCustomMandatory($arrMandatory, 'markerAlt'), 'fmEditable' => true, 'fmGroup' => 'map'), 'sql' => "varchar(255) NOT NULL default ''"), 'markerCaption' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['markerCaption'], 'exclude' => true, 'inputType' => 'text', 'eval' => array('maxlength' => 255, 'allowHtml' => true, 'mandatory' => $this->setCustomMandatory($arrMandatory, 'markerCaption'), 'tl_class' => 'w50', 'fmEditable' => true, 'fmGroup' => 'map'), 'sql' => "varchar(255) NOT NULL default ''"), 'protected' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['protected'], 'inputType' => 'checkbox', 'exclude' => true, 'eval' => array('submitOnChange' => true), 'sql' => "char(1) NOT NULL default ''"), 'groups' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['groups'], 'inputType' => 'checkbox', 'exclude' => true, 'foreignKey' => 'tl_member_group.name', 'eval' => array('mandatory' => true, 'multiple' => true), 'sql' => "blob NULL", 'relation' => array('type' => 'hasMany', 'load' => 'lazy')), 'guests' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['guests'], 'filter' => true, 'exclude' => true, 'inputType' => 'checkbox', 'eval' => array('tl_class' => 'w50'), 'sql' => "char(1) NOT NULL default ''"), 'cssID' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['cssID'], 'inputType' => 'text', 'exclude' => true, 'eval' => array('multiple' => true, 'size' => 2, 'tl_class' => 'w50 clr', 'fmEditable' => true, 'fmGroup' => 'expert'), 'sql' => "varchar(255) NOT NULL default ''"), 'published' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['published'], 'inputType' => 'checkbox', 'filter' => true, 'exclude' => true, 'eval' => array('submitOnChange' => true, 'doNotCopy' => true, 'fmEditable' => true, 'fmGroup' => 'expert'), 'sql' => "char(1) NOT NULL default ''"), 'start' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['start'], 'inputType' => 'text', 'exclude' => true, 'eval' => array('rgxp' => 'datim', 'datepicker' => true, 'mandatory' => $this->setCustomMandatory($arrMandatory, 'start'), 'tl_class' => 'w50 wizard', 'fmEditable' => true, 'fmGroup' => 'expert'), 'sql' => "varchar(10) NOT NULL default ''"), 'stop' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['stop'], 'inputType' => 'text', 'exclude' => true, 'eval' => array('rgxp' => 'datim', 'datepicker' => true, 'mandatory' => $this->setCustomMandatory($arrMandatory, 'stop'), 'tl_class' => 'w50 wizard', 'fmEditable' => true, 'fmGroup' => 'expert'), 'sql' => "varchar(10) NOT NULL default ''"), 'mainLanguage' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['mainLanguage'], 'exclude' => false, 'inputType' => 'select', 'options_callback' => array('DCAModuleData', 'getFallbackData'), 'eval' => array('includeBlankOption' => true, 'chosen' => true, 'blankOptionLabel' => '-', 'tl_class' => 'w50'), 'sql' => "varchar(255) NOT NULL default ''"), 'addGallery' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['addGallery'], 'exclude' => true, 'inputType' => 'checkbox', 'eval' => array('submitOnChange' => true), 'sql' => "char(1) NOT NULL default ''"), 'orderSRC' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['orderSRC'], 'sql' => "blob NULL"), 'multiSRC' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['multiSRC'], 'exclude' => true, 'inputType' => 'fileTree', 'eval' => array('multiple' => true, 'fieldType' => 'checkbox', 'orderField' => 'orderSRC', 'files' => true, 'mandatory' => true), 'sql' => "blob NULL", 'load_callback' => array(array('DCAModuleData', 'setMultiSrcFlags'))), 'sortBy' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['sortBy'], 'exclude' => true, 'inputType' => 'select', 'options' => array('custom', 'name_asc', 'name_desc', 'date_asc', 'date_desc', 'random'), 'reference' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack'], 'eval' => array('tl_class' => 'w50'), 'sql' => "varchar(32) NOT NULL default ''"), 'metaIgnore' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['metaIgnore'], 'exclude' => true, 'inputType' => 'checkbox', 'eval' => array('tl_class' => 'w50 m12'), 'sql' => "char(1) NOT NULL default ''"), 'perRow' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['perRow'], 'default' => 4, 'exclude' => true, 'inputType' => 'select', 'options' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), 'eval' => array('tl_class' => 'w50'), 'sql' => "smallint(5) unsigned NOT NULL default '0'"), 'perPageGallery' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['perPageGallery'], 'exclude' => true, 'inputType' => 'text', 'eval' => array('rgxp' => 'natural', 'tl_class' => 'w50'), 'sql' => "smallint(5) unsigned NOT NULL default '0'"), 'numberOfItems' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['numberOfItems'], 'exclude' => true, 'inputType' => 'text', 'eval' => array('rgxp' => 'natural', 'tl_class' => 'w50'), 'sql' => "smallint(5) unsigned NOT NULL default '0'"), 'galleryTpl' => array('label' => &$GLOBALS['TL_LANG']['tl_fmodules_language_pack']['galleryTpl'], 'exclude' => true, 'inputType' => 'select', 'options_callback' => array('DCAModuleData', 'getGalleryTemplates'), 'eval' => array('tl_class' => 'w50'), 'sql' => "varchar(64) NOT NULL default ''"));
     // add pid
     if ($this->parent) {
         $fields['pid'] = array('foreignKey' => $this->parent . '.id', 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'belongsTo', 'load' => 'eager'));
     }
     return $fields;
 }
예제 #22
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     copy(__DIR__ . '/../Fixtures/images/dummy.jpg', self::$rootDir . '/dummy.jpg');
     $GLOBALS['TL_CONFIG']['debugMode'] = false;
     $GLOBALS['TL_CONFIG']['gdMaxImgWidth'] = 3000;
     $GLOBALS['TL_CONFIG']['gdMaxImgHeight'] = 3000;
     $GLOBALS['TL_CONFIG']['validImageTypes'] = 'jpeg,jpg,svg,svgz';
     define('TL_ERROR', 'ERROR');
     define('TL_ROOT', self::$rootDir);
     System::setContainer($this->mockContainerWithContaoScopes());
 }
예제 #23
0
 /**
  * @param $strField
  */
 protected function addTranslationContentToField($strField)
 {
     if ($this->Config->get($strField) === null) {
         $arrValues = array();
         System::loadLanguageFile('tl_email', 'de', true);
         $arrValues['de'] = $GLOBALS['TL_LANG']['tl_email']['defaultContents'][$strField];
         System::loadLanguageFile('tl_email', 'en', true);
         $arrValues['en'] = $GLOBALS['TL_LANG']['tl_email']['defaultContents'][$strField];
         // Load translation file by current language
         System::loadLanguageFile('tl_email', null, true);
         $this->Config->persist($strField, TranslationFieldsModel::saveValuesAndReturnFid($arrValues));
     }
 }
예제 #24
0
 /**
  * Establish the database connection
  *
  * @param array $arrConfig The configuration array
  *
  * @throws \Exception If a connection cannot be established
  */
 protected function __construct(array $arrConfig)
 {
     // Deprecated since Contao 4.0, to be removed in Contao 5.0
     if (!empty($arrConfig)) {
         @trigger_error('Passing a custom configuration to Database::__construct() has been deprecated and will no longer work in Contao 5.0.', E_USER_DEPRECATED);
         $arrParams = array('driver' => \System::getContainer()->getParameter('database_driver'), 'host' => $arrConfig['dbHost'], 'port' => $arrConfig['dbPort'], 'user' => $arrConfig['dbUser'], 'password' => $arrConfig['dbPass'], 'dbname' => $arrConfig['dbDatabase']);
         $this->resConnection = DriverManager::getConnection($arrParams);
     } else {
         $this->resConnection = \System::getContainer()->get('database_connection');
     }
     if (!is_object($this->resConnection)) {
         throw new \Exception(sprintf('Could not connect to database (%s)', $this->error));
     }
 }
예제 #25
0
 /**
  * Initialize the object
  */
 public function __construct()
 {
     // Load the user object before calling the parent constructor
     $this->import('FrontendUser', 'User');
     parent::__construct();
     // Check whether a user is logged in
     define('BE_USER_LOGGED_IN', $this->getLoginStatus('BE_USER_AUTH'));
     define('FE_USER_LOGGED_IN', $this->getLoginStatus('FE_USER_AUTH'));
     // No back end user logged in
     if (!$_SESSION['DISABLE_CACHE']) {
         // Maintenance mode (see #4561 and #6353)
         if (\Config::get('maintenanceMode') && !\System::getContainer()->get('kernel')->isDebug()) {
             throw new ServiceUnavailableException('This site is currently down for maintenance. Please come back later.');
         }
     }
 }
 /**
  * Rebuild Vimeo cache
  *
  * @param DataContainer $dc
  */
 public function rebuildVimeoCache(DataContainer $dc)
 {
     $rebuilder = new Rebuilder();
     try {
         $result = $rebuilder->rebuildElementCache(ContentModel::findByPk($dc->id));
     } catch (\InvalidArgumentException $e) {
         return;
     } catch (\RuntimeException $e) {
         System::log(sprintf('Unable to rebuild Vimeo cache of element ID %s: %s', $dc->id, $e->getMessage()), __METHOD__, TL_ERROR);
         $result = false;
     }
     if ($result === true) {
         Message::addConfirmation($GLOBALS['TL_LANG']['tl_content']['vimeo_cacheConfirm']);
     } elseif ($result === false) {
         Message::addError($GLOBALS['TL_LANG']['tl_content']['vimeo_cacheError']);
     }
 }
 /**
  * @param bool $blnReload
  * @return array
  */
 public function getLanguages($blnReload = false)
 {
     if ($blnReload || !is_array(self::$arrLanguages) || count(self::$arrLanguages) < 1) {
         // Get all languages
         $arrSystemLanguages = System::getLanguages();
         // Get all used languages
         $arrLanguages = array();
         // If languages are specified
         if ($GLOBALS['TL_CONFIG']['chooseTranslationLanguages'] == '1') {
             $arrTranslationLanguages = deserialize($GLOBALS['TL_CONFIG']['translationLanguages']);
             if (is_array($arrTranslationLanguages) && $arrTranslationLanguages > 0) {
                 foreach ($arrTranslationLanguages as $strLanguage) {
                     $arrLanguages[$strLanguage] = $arrSystemLanguages[$strLanguage];
                 }
             }
         } else {
             $objRootPages = TranslationFieldsPageModel::findRootPages();
             if ($objRootPages !== null) {
                 while ($objRootPages->next()) {
                     $arrLanguages[$objRootPages->language] = $arrSystemLanguages[$objRootPages->language];
                 }
             }
             // If langauge array is empty
             if (count($arrLanguages) < 1) {
                 // Set all available languages
                 $arrLanguages = System::getLanguages(true);
                 // Set the language of the user to the top
                 if (BackendUser::getInstance()->language != null) {
                     // Get langauge value
                     $strLanguageValue = $arrLanguages[BackendUser::getInstance()->language];
                     // Remove the current language from the array
                     unset($arrLanguages[BackendUser::getInstance()->language]);
                     // Add old array to a temp array
                     $arrLanguagesTemp = $arrLanguages;
                     // Generate a new array
                     $arrLanguages = array(BackendUser::getInstance()->language => $strLanguageValue);
                     // Merge the old array into the new array
                     $arrLanguages = array_merge($arrLanguages, $arrLanguagesTemp);
                 }
             }
         }
         self::$arrLanguages = $arrLanguages;
     }
     return self::$arrLanguages;
 }
예제 #28
0
 /**
  * Validate a token
  *
  * @param string $strToken The request token
  *
  * @return boolean True if the token matches the stored one
  */
 public static function validate($strToken)
 {
     // The feature has been disabled
     if (\Config::get('disableRefererCheck') || defined('BYPASS_TOKEN_CHECK')) {
         return true;
     }
     // Check against the whitelist (thanks to Tristan Lins) (see #3164)
     if (\Config::get('requestTokenWhitelist')) {
         $strHostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
         foreach (\Config::get('requestTokenWhitelist') as $strDomain) {
             if ($strDomain == $strHostname || preg_match('/\\.' . preg_quote($strDomain, '/') . '$/', $strHostname)) {
                 return true;
             }
         }
     }
     $container = \System::getContainer();
     return $container->get('security.csrf.token_manager')->isTokenValid(new CsrfToken($container->getParameter('contao.csrf_token_name'), $strToken));
 }
 /**
  * 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);
     //dump($this->Template);
     $this->Template->main = "%%FORUM%%";
     $headTags = $this->Template->head;
     $this->Template->head = "";
     $response = $this->Template->getResponse($blnCheckRequest);
     $style = preg_replace('/href\\=\\"(?!http|\\/)/', 'href="/', $this->Template->replaceDynamicScriptTags($this->Template->stylesheets));
     $headTags = preg_replace('/href\\=\\"(?!http|\\/)/', 'href="/', $this->Template->replaceDynamicScriptTags($headTags));
     $headTags = preg_replace('/src\\=\\"(?!http|\\/)/', 'href="/', $headTags);
     // @todo Add framework, mooscripts etc?
     $phpbbHeaders = "";
     $phpbbHeaders .= $style;
     $phpbbHeaders .= $headTags;
     file_put_contents(__DIR__ . '/../Resources/phpBB/ctsmedia/contaophpbbbridge/styles/all/template/event/overall_header_stylesheets_after.html', $phpbbHeaders);
     //dump($phpbbHeaders);
     //dump($this->Template->class);
     $html = $response->getContent();
     // Ajust link paths
     $html = preg_replace('/href\\=\\"(?!http|\\/)/', 'href="/', $html);
     // Ajust src paths
     $html = preg_replace('/src\\=\\"(?!http|\\/)/', 'src="/', $html);
     $html = preg_replace('/content\\=\\"(?!http|\\/)/', 'content="/', $html);
     $parts = explode("%%FORUM%%", $html);
     $overall_header = $parts[0];
     $overall_footer = $parts[1];
     $overall_header = preg_replace('/<\\!DOC.*/i', '', $overall_header);
     $overall_header = preg_replace('/<html.*/i', '', $overall_header);
     $overall_header = preg_replace('/<body.*/i', '', $overall_header);
     $overall_header = preg_replace('/<head>.*<\\/head>/s', '', $overall_header);
     $overall_footer = preg_replace('/<\\/body.*/i', '', $overall_footer);
     $overall_footer = preg_replace('/<\\/html.*/i', '', $overall_footer);
     //dump($overall_footer);
     //dump($this->Template);
     //dump($html);
     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;
 }
예제 #30
0
 /**
  * {@inheritdoc}
  */
 protected function executeResize(ImageInterface $image, ResizeCoordinatesInterface $coordinates, $path, ResizeOptionsInterface $options)
 {
     if (isset($GLOBALS['TL_HOOKS']['getImage']) && is_array($GLOBALS['TL_HOOKS']['getImage']) && $this->legacyImage) {
         foreach ($GLOBALS['TL_HOOKS']['getImage'] as $callback) {
             $return = System::importStatic($callback[0])->{$callback[1]}($this->legacyImage->getOriginalPath(), $this->legacyImage->getTargetWidth(), $this->legacyImage->getTargetHeight(), $this->legacyImage->getResizeMode(), $this->legacyImage->getCacheName(), new File($this->legacyImage->getOriginalPath()), $this->legacyImage->getTargetPath(), $this->legacyImage);
             if (is_string($return)) {
                 return $this->createImage($image, TL_ROOT . '/' . $return);
             }
         }
     }
     if ($image->getImagine() instanceof GdImagine) {
         /** @var Config $config */
         $config = $this->framework->getAdapter(Config::class);
         $dimensions = $image->getDimensions();
         // Return the path to the original image if it cannot be handled
         if ($dimensions->getSize()->getWidth() > $config->get('gdMaxImgWidth') || $dimensions->getSize()->getHeight() > $config->get('gdMaxImgHeight') || $coordinates->getSize()->getWidth() > $config->get('gdMaxImgWidth') || $coordinates->getSize()->getHeight() > $config->get('gdMaxImgHeight')) {
             return $this->createImage($image, $image->getPath());
         }
     }
     return parent::executeResize($image, $coordinates, $path, $options);
 }