/**
  * Generate the module
  *
  * @return string
  */
 public function run()
 {
     $objTemplate = new TwigBackendTemplate('be_purge_images');
     $objTemplate->isActive = $this->isActive();
     // Confirmation message
     if ($_SESSION['CLEAR_TWIG_CACHE_CONFIRM'] != '') {
         $objTemplate->cacheMessage = $_SESSION['CLEAR_TWIG_CACHE_CONFIRM'];
         $_SESSION['CLEAR_TWIG_CACHE_CONFIRM'] = '';
     }
     // Purge the resources
     if ($this->isActive()) {
         $this->import('Files');
         $intCount = $this->purge();
         $_SESSION['CLEAR_TWIG_CACHE_CONFIRM'] = sprintf($GLOBALS['TL_LANG']['tl_maintenance']['purgedTwigCache'], $intCount);
         $this->reload();
     }
     // count existing files
     $count = 0;
     $size = 0;
     $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(TL_ROOT . '/system/cache/twig'), RecursiveIteratorIterator::CHILD_FIRST);
     /** @var SplFileInfo $path */
     foreach ($iterator as $path) {
         if ($path->isFile() && $path->getFilename() != '.keep') {
             $count++;
             $size += $path->getSize();
         }
     }
     $objTemplate->count = sprintf($GLOBALS['TL_LANG']['tl_maintenance']['twigCacheCount'], $count, $this->getReadableSize($size));
     $objTemplate->action = ampersand(\Environment::getInstance()->request);
     return $objTemplate->parse();
 }
Exemplo n.º 2
0
 /**
  * Parse the template
  *
  * @return string
  */
 public function generate()
 {
     $this->Template = new TwigBackendTemplate($this->strTemplate);
     $this->compile();
     return $this->Template->parse();
 }
Exemplo n.º 3
0
 public function handleListAction(EnvironmentInterface $environment)
 {
     $input = $environment->getInputProvider();
     $id = IdSerializer::fromSerialized($input->getParameter('id'));
     $repository = EntityHelper::getRepository('Avisota\\Contao:RecipientSource');
     /** @var \Avisota\Contao\Entity\RecipientSource $recipientSourceEntity */
     $recipientSourceEntity = $repository->find($id->getId());
     /** @var RecipientSourceInterface $recipientSource */
     $recipientSource = $GLOBALS['container'][sprintf('avisota.recipientSource.%s', $recipientSourceEntity->getId())];
     if ($input->getValue('page')) {
         /** @var EventDispatcher $eventDispatcher */
         $eventDispatcher = $GLOBALS['container']['event-dispatcher'];
         $addToUrlEvent = new AddToUrlEvent('page=' . (int) $input->getValue('page'));
         $eventDispatcher->dispatch(ContaoEvents::BACKEND_ADD_TO_URL, $addToUrlEvent);
         $redirectEvent = new RedirectEvent($addToUrlEvent->getUrl());
         $eventDispatcher->dispatch(ContaoEvents::CONTROLLER_REDIRECT, $redirectEvent);
     }
     $total = $recipientSource->countRecipients();
     $page = $input->getParameter('page') ?: 0;
     $pages = ceil($total / 30);
     $recipients = $recipientSource->getRecipients(30, $page * 30);
     $template = new \TwigBackendTemplate('avisota/backend/recipient_source_list');
     $template->total = $total;
     $template->page = $page;
     $template->pages = $pages;
     $template->recipients = $recipients;
     return $template->parse();
 }
Exemplo n.º 4
0
 /**
  * Inject a backend message, if the advanced asset cache is outdated.
  *
  * @param string $content      The output buffer.
  * @param string $templateName The template name.
  *
  * @return string
  */
 public function hookOutputBackendTemplate($content, $templateName)
 {
     if (!$GLOBALS['TL_CONFIG']['theme_plus_disabled_advanced_asset_caching'] && $templateName == 'be_main') {
         $creationTime = (int) $this->cache->fetch(ThemePlus::CACHE_CREATION_TIME);
         $latestTimestamp = (int) $this->cache->fetch(ThemePlus::CACHE_LATEST_ASSET_TIMESTAMP);
         if (!$creationTime || $latestTimestamp > $creationTime) {
             \System::loadLanguageFile('be_theme_plus');
             $template = new \TwigBackendTemplate('bit3/theme-plus/be_cache_message');
             $content = preg_replace('~</div>\\s*<div.+id="container"~U', $template->parse() . "\n\$0", $content, 1);
         }
     }
     return $content;
 }