Пример #1
0
 /**
  * Create a new instance.
  *
  * @param string $strTable         The table name.
  *
  * @param array  $arrBackendModule The backend module information array.
  */
 public function __construct($strTable, array &$arrBackendModule = null)
 {
     $strTable = $this->getTablenameCallback($strTable);
     $dispatcher = $GLOBALS['container']['event-dispatcher'];
     /** @var \Symfony\Component\EventDispatcher\EventDispatcher $dispatcher */
     $dispatcher->addListener(PopulateEnvironmentEvent::NAME, array($this, 'handlePopulateEnvironment'), 4800);
     $propagator = new EventPropagator($dispatcher);
     $translator = new TranslatorChain();
     $translator->add(new LangArrayTranslator($dispatcher));
     $factory = new DcGeneralFactory();
     $factory->setContainerName($strTable)->setEventPropagator($propagator)->setTranslator($translator)->createDcGeneral();
     $dispatcher->removeListener(PopulateEnvironmentEvent::NAME, array($this, 'handlePopulateEnvironment'));
     // Switch user for FE / BE support.
     switch (TL_MODE) {
         case 'FE':
             $this->import('FrontendUser', 'User');
             break;
         default:
         case 'BE':
             $this->import('BackendUser', 'User');
             break;
     }
     // Load the clipboard.
     $this->getEnvironment()->getClipboard()->loadFrom($this->getEnvironment());
     // Execute AJAX request, called from Backend::getBackendModule
     // we have to do this here, as otherwise the script will exit as it only checks for DC_Table and DC_File
     // derived classes.
     // @codingStandardsIgnoreStart - The access to $_POST is sane here.
     if ($_POST && (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest')) {
         $this->getViewHandler()->handleAjaxCall();
     }
 }
Пример #2
0
});
/**
 * Workflow manager registry.
 *
 * @return ManagerRegistry
 */
$container['workflow.manager-registry'] = $container->share(function () {
    return new ManagerRegistry();
});
/**
 * Create the translator being used in the workflow extension.
 *
 * @return TranslatorInterface
 */
$container['workflow.translator'] = $container->share(function ($container) {
    $chain = new TranslatorChain();
    $chain->add(new LangArrayTranslator($container['event-dispatcher']));
    return $chain;
});
/**
 * Get the database instance.
 *
 * @param $container
 *
 * @return \Database
 */
$container['worfklow.database.connection'] = function ($container) {
    return $container['database.connection'];
};
/**
 * Create the workflow transition listener.
Пример #3
0
 /**
  * Run the controller and parse the template.
  *
  * @return void
  */
 public function run()
 {
     $template = new \BackendTemplate('be_picker');
     $template->main = '';
     // Ajax request.
     // @codingStandardsIgnoreStart - We need POST access here.
     if ($_POST && \Environment::get('isAjaxRequest')) {
         $ajax = new \Ajax(\Input::post('action'));
         $ajax->executePreActions();
     }
     $strTable = \Input::get('table');
     $strField = \Input::get('field');
     // Define the current ID.
     define('CURRENT_ID', $strTable ? \Session::getInstance()->get('CURRENT_ID') : \Input::get('id'));
     $dispatcher = $GLOBALS['container']['event-dispatcher'];
     /** @var \Symfony\Component\EventDispatcher\EventDispatcher $dispatcher */
     $propagator = new EventPropagator($dispatcher);
     $translator = new TranslatorChain();
     $translator->add(new LangArrayTranslator($dispatcher));
     $factory = new DcGeneralFactory();
     $this->itemContainer = $factory->setContainerName($strTable)->setTranslator($translator)->setEventPropagator($propagator)->createDcGeneral();
     $information = (array) $GLOBALS['TL_DCA'][$strTable]['fields'][$strField];
     // Merge with the information from the data container.
     $property = $this->itemContainer->getEnvironment()->getDataDefinition()->getPropertiesDefinition()->getProperty($strField);
     $extra = $property->getExtra();
     $information['eval']['sourceName'] = $extra['sourceName'];
     $information['eval']['fieldType'] = $extra['fieldType'];
     /** @var \ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\TreePicker $objTreeSelector */
     $objTreeSelector = new $GLOBALS['BE_FFL']['DcGeneralTreePicker'](\Widget::getAttributesFromDca($information, $strField, array_filter(explode(',', \Input::get('value'))), $strField, $strTable, new DcCompat($this->itemContainer->getEnvironment())));
     // AJAX request.
     if (isset($ajax)) {
         $objTreeSelector->generateAjax();
         $ajax->executePostActions(new DcCompat($this->itemContainer->getEnvironment()));
     }
     $template->main = $objTreeSelector->generatePopup();
     $template->theme = \Backend::getTheme();
     $template->base = \Environment::get('base');
     $template->language = $GLOBALS['TL_LANGUAGE'];
     $template->title = specialchars($GLOBALS['TL_LANG']['MSC']['treepicker']);
     $template->charset = $GLOBALS['TL_CONFIG']['characterSet'];
     $template->addSearch = $objTreeSelector->searchField;
     $template->search = $GLOBALS['TL_LANG']['MSC']['search'];
     $template->action = ampersand(\Environment::get('request'));
     $template->value = \Session::getInstance()->get($objTreeSelector->getSearchSessionKey());
     $template->manager = $GLOBALS['TL_LANG']['MSC']['treepickerManager'];
     $template->breadcrumb = $GLOBALS['TL_DCA'][$objTreeSelector->foreignTable]['list']['sorting']['breadcrumb'];
     $template->managerHref = '';
     // Add the manager link.
     if ($objTreeSelector->managerHref) {
         $template->managerHref = 'contao/main.php?' . ampersand($objTreeSelector->managerHref) . '&popup=1';
     }
     // Prevent debug output at all cost.
     $GLOBALS['TL_CONFIG']['debugMode'] = false;
     $template->output();
 }
Пример #4
0
 /**
  * Handle a populate environment event for MetaModels.
  *
  * @param PopulateEnvironmentEvent $event The event payload.
  *
  * @return void
  *
  * @SuppressWarnings(PHPMD.Superglobals)
  * @SuppressWarnings(PHPMD.CamelCaseVariableName)
  */
 public function populate(PopulateEnvironmentEvent $event)
 {
     $translator = $event->getEnvironment()->getTranslator();
     $dispatcher = $this->serviceContainer->getEventDispatcher();
     if (!$translator instanceof TranslatorChain) {
         $translatorChain = new TranslatorChain();
         $translatorChain->add($translator);
         $event->getEnvironment()->setTranslator($translatorChain);
     } else {
         $translatorChain = $translator;
     }
     // Map the tl_metamodel_item domain over to this domain.
     $dispatcher->dispatch(ContaoEvents::SYSTEM_LOAD_LANGUAGE_FILE, new LoadLanguageFileEvent('tl_metamodel_item'));
     $this->mapTranslations($GLOBALS['TL_LANG']['tl_metamodel_item'], $event->getEnvironment()->getDataDefinition()->getName());
     $translatorChain->add($this->translator);
     $metaModel = $this->getMetaModel();
     $environment = $event->getEnvironment();
     foreach ($metaModel->getAttributes() as $attribute) {
         $event = new PopulateAttributeEvent($metaModel, $attribute, $environment);
         // Trigger BuildAttribute Event.
         $dispatcher->dispatch($event::NAME, $event);
     }
 }