本文整理汇总了PHP中Ajax::executePreActions方法的典型用法代码示例。如果您正苦于以下问题:PHP Ajax::executePreActions方法的具体用法?PHP Ajax::executePreActions怎么用?PHP Ajax::executePreActions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ajax
的用法示例。
在下文中一共展示了Ajax::executePreActions方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* 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();
}
示例2: run
/**
* Run the controller and parse the login template
*/
public function run()
{
$this->Template = new \BackendTemplate('be_main');
$this->Template->main = '';
// Ajax request
if ($_POST && \Environment::get('isAjaxRequest')) {
$this->objAjax = new \Ajax(\Input::post('action'));
$this->objAjax->executePreActions();
}
// Error
if (\Input::get('act') == 'error') {
$this->Template->error = $GLOBALS['TL_LANG']['ERR']['general'];
$this->Template->title = $GLOBALS['TL_LANG']['ERR']['general'];
} elseif (!\Input::get('do') && !\Input::get('act')) {
$this->Template->main .= $this->welcomeScreen();
$this->Template->title = $GLOBALS['TL_LANG']['MSC']['home'];
} elseif (\Input::get('do')) {
$this->Template->main .= $this->getBackendModule(\Input::get('do'));
$this->Template->title = $this->Template->headline;
}
$this->output();
}
示例3: run
/**
* Run the controller and parse the template
*/
public function run()
{
/** @var \BackendTemplate|object $objTemplate */
$objTemplate = new \BackendTemplate('be_picker');
$objTemplate->main = '';
// Ajax request
if ($_POST && \Environment::get('isAjaxRequest')) {
$this->objAjax = new \Ajax(\Input::post('action'));
$this->objAjax->executePreActions();
}
$strTable = \Input::get('table');
$strField = \Input::get('field');
// Define the current ID
define('CURRENT_ID', \Input::get('table') ? $this->Session->get('CURRENT_ID') : \Input::get('id'));
$this->loadDataContainer($strTable);
$strDriver = 'DC_' . $GLOBALS['TL_DCA'][$strTable]['config']['dataContainer'];
$objDca = new $strDriver($strTable);
$objDca->field = $strField;
// Set the active record
if ($this->Database->tableExists($strTable)) {
/** @var \Model $strModel $strModel */
$strModel = \Model::getClassFromTable($strTable);
if (class_exists($strModel)) {
$objModel = $strModel::findByPk(\Input::get('id'));
if ($objModel !== null) {
$objDca->activeRecord = $objModel;
}
}
}
// AJAX request
if ($_POST && \Environment::get('isAjaxRequest')) {
$this->objAjax->executePostActions($objDca);
}
$this->Session->set('filePickerRef', \Environment::get('request'));
$arrValues = array_filter(explode(',', \Input::get('value')));
// Call the load_callback
if (is_array($GLOBALS['TL_DCA'][$strTable]['fields'][$strField]['load_callback'])) {
foreach ($GLOBALS['TL_DCA'][$strTable]['fields'][$strField]['load_callback'] as $callback) {
if (is_array($callback)) {
$this->import($callback[0]);
$arrValues = $this->{$callback[0]}->{$callback[1]}($arrValues, $objDca);
} elseif (is_callable($callback)) {
$arrValues = $callback($arrValues, $objDca);
}
}
}
/** @var \PageSelector $strClass */
$strClass = $GLOBALS['BE_FFL']['pageSelector'];
/** @var \PageSelector $objPageTree */
$objPageTree = new $strClass($strClass::getAttributesFromDca($GLOBALS['TL_DCA'][$strTable]['fields'][$strField], $strField, $arrValues, $strField, $strTable, $objDca));
$objTemplate->main = $objPageTree->generate();
$objTemplate->theme = \Backend::getTheme();
$objTemplate->base = \Environment::get('base');
$objTemplate->language = $GLOBALS['TL_LANGUAGE'];
$objTemplate->title = specialchars($GLOBALS['TL_LANG']['MSC']['pagepicker']);
$objTemplate->charset = \Config::get('characterSet');
$objTemplate->addSearch = true;
$objTemplate->search = $GLOBALS['TL_LANG']['MSC']['search'];
$objTemplate->action = ampersand(\Environment::get('request'));
$objTemplate->value = $this->Session->get('page_selector_search');
$objTemplate->breadcrumb = $GLOBALS['TL_DCA']['tl_page']['list']['sorting']['breadcrumb'];
if ($this->User->hasAccess('page', 'modules')) {
$objTemplate->manager = $GLOBALS['TL_LANG']['MSC']['pageManager'];
$objTemplate->managerHref = 'contao/main.php?do=page&popup=1';
}
if (\Input::get('switch') && $this->User->hasAccess('files', 'modules')) {
$objTemplate->switch = $GLOBALS['TL_LANG']['MSC']['filePicker'];
$objTemplate->switchHref = str_replace('contao/page.php', 'contao/file.php', ampersand(\Environment::get('request')));
}
\Config::set('debugMode', false);
$objTemplate->output();
}