本文整理汇总了PHP中Widget::getAttributesFromDca方法的典型用法代码示例。如果您正苦于以下问题:PHP Widget::getAttributesFromDca方法的具体用法?PHP Widget::getAttributesFromDca怎么用?PHP Widget::getAttributesFromDca使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Widget
的用法示例。
在下文中一共展示了Widget::getAttributesFromDca方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executePostActionsHook
public function executePostActionsHook($strAction, \DataContainer $dc)
{
if ($strAction !== static::$uploadAction) {
return false;
}
// Check whether the field is allowed for regular users
if (!isset($GLOBALS['TL_DCA'][$dc->table]['fields'][\Input::post('field')]) || $GLOBALS['TL_DCA'][$dc->table]['fields'][\Input::post('field')]['exclude'] && !\BackendUser::getInstance()->hasAccess($dc->table . '::' . \Input::post('field'), 'alexf')) {
\System::log('Field "' . \Input::post('field') . '" is not an allowed selector field (possible SQL injection attempt)', __METHOD__, TL_ERROR);
$objResponse = new ResponseError();
$objResponse->setMessage('Bad Request');
$objResponse->output();
}
$this->name = \Input::post('field');
$this->id = \Input::post('field');
$this->field = \Input::post('field');
if ($dc->activeRecord === null) {
$dc->activeRecord = General::getModelInstance($dc->table, $dc->id);
}
// add dca attributes
$this->addAttributes(\Widget::getAttributesFromDca($GLOBALS['TL_DCA'][$dc->table]['fields'][$this->name], $this->name));
$objResponse = $this->upload();
/** @var Response */
if ($objResponse instanceof Response) {
$objResponse->output();
}
}
示例2: layoutRedirect
protected function layoutRedirect(\DC_Table $dc, $mode = "mootools")
{
//Variables
$activeRecord = $dc->activeRecord;
$strTemplates = deserialize($mode == "mootools" ? $activeRecord->mootools : $activeRecord->jquery);
$strField = $mode == "mootools" ? $this->mootoolsField : $this->jqueryField;
$content = '<div class="clr w50 hauto">';
if (!is_array($strTemplates)) {
$strTemplates = array();
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$rawValue = $this->saveData($_POST[$strField] ?: '', $dc, $mode);
} else {
$field = $mode == "mootools" ? $this->mootoolsField : $this->jqueryField;
$rawValue = $activeRecord->{$field};
}
$value = $rawValue;
$inArray = $mode == "mootools" ? 'moo_redirect' : 'j_redirect';
if (in_array($inArray, $strTemplates)) {
$content .= '<h3><label for="ctrl_' . $mode . 'Redirect">Weiterleitung (Redirect) Ziel</label></h3>';
$arrData = $GLOBALS['TL_DCA'][$this->strTable]['fields'][$strField];
$arrData['name'] = $inArray;
$arrWidget = \Widget::getAttributesFromDca($arrData, $strField, $value, $strField, $this->strTable);
$objWidget = new $GLOBALS['BE_FFL']['pageTree']($arrWidget);
$content .= $objWidget->generate();
}
return $content . '</div>';
}
示例3: executePostActionsHook
public function executePostActionsHook($strAction, \DataContainer $dc)
{
if ($strAction == FieldPalette::$strFieldpaletteRefreshAction) {
if (\Input::post('field')) {
\Controller::loadDataContainer($dc->table);
$strName = \Input::post('field');
$arrField = $GLOBALS['TL_DCA'][$dc->table]['fields'][$strName];
// Die if the field does not exist
if (!is_array($arrField)) {
header('HTTP/1.1 400 Bad Request');
die('Bad Request');
}
/** @var \Widget $strClass */
$strClass = $GLOBALS['BE_FFL'][$arrField['inputType']];
// Die if the class is not defined or inputType is not fieldpalette
if ($arrField['inputType'] != 'fieldpalette' || !class_exists($strClass)) {
header('HTTP/1.1 400 Bad Request');
die('Bad Request');
}
$arrData = \Widget::getAttributesFromDca($arrField, $strName, $dc->activeRecord->{$strName}, $strName, $dc->table, $dc);
/** @var \Widget $objWidget */
$objWidget = new $strClass($arrData);
$objWidget->currentRecord = $dc->id;
die(json_encode(array('field' => $strName, 'target' => '#ctrl_' . $strName, 'content' => $objWidget->generate())));
}
header('HTTP/1.1 400 Bad Request');
die('Bad Request');
}
}
示例4: getFrontendFormField
/**
* Get an instance of \Widget by passing fieldname and dca data
* @param $strField string The field name
* @param $arrDca array The DCA
* @param null $varValue array
* @param string $strDbField string The database field name
* @param string $strTable The table
* @param null $objDca object The data container
*
* @return bool
*/
public static function getFrontendFormField($strField, array $arrDca, $varValue = null, $strDbField = '', $strTable = '', $objDca = null)
{
if (!($strClass = $GLOBALS['TL_FFL'][$arrDca['inputType']])) {
return false;
}
return new $strClass(\Widget::getAttributesFromDca($arrDca, $strField, $varValue, $strDbField, $strTable, $objDca));
}
示例5: compile
protected function compile()
{
$this->Template->formId = $this->strFormId;
$arrFieldDcas = array('email' => array('label' => &$GLOBALS['TL_LANG']['tl_module']['email'], 'inputType' => 'text', 'eval' => array('rgxp' => 'email', 'mandatory' => true)), 'submit' => array('inputType' => 'submit', 'label' => &$GLOBALS['TL_LANG']['MSC']['cancel']));
$arrWidgets = array();
foreach ($arrFieldDcas as $strName => $arrData) {
if ($strClass = $GLOBALS['TL_FFL'][$arrData['inputType']]) {
$arrWidgets[] = new $strClass(\Widget::getAttributesFromDca($arrData, $strName));
}
}
if (\Input::post('FORM_SUBMIT') == $this->strFormId) {
// validate
foreach ($arrWidgets as $objWidget) {
$objWidget->validate();
if ($objWidget->hasErrors()) {
$this->blnDoNotSubmit = true;
}
}
if (!$this->blnDoNotSubmit) {
// cancel subscription
$strEmail = \Input::post('email');
$arrArchives = deserialize($this->iso_cancellationArchives, true);
$blnNoSuccess = false;
foreach ($arrArchives as $intArchive) {
if (($objSubscription = Subscription::findBy(array('email=?', 'pid=?'), array($strEmail, $intArchive))) === null) {
if (count($arrArchives) == 1) {
$this->Template->error = sprintf($GLOBALS['TL_LANG']['MSC']['iso_subscriptionDoesNotExist'], $strEmail, SubscriptionArchive::findByPk($intArchive)->title);
$blnNoSuccess = true;
}
break;
}
$objSubscription->delete();
}
if (!$blnNoSuccess) {
// success message
if (count($arrArchives) > 1) {
$this->Template->success = $GLOBALS['TL_LANG']['MSC']['iso_subscriptionsCancelledSuccessfully'];
} else {
$this->Template->success = sprintf($GLOBALS['TL_LANG']['MSC']['iso_subscriptionCancelledSuccessfully'], $strEmail, SubscriptionArchive::findByPk($arrArchives[0])->title);
}
// redirect
if ($this->jumpTo && ($objPageRedirect = \PageModel::findByPk($this->jumpTo)) !== null) {
\Controller::redirect(\Controller::generateFrontendUrl($objPageRedirect->row()));
}
}
}
}
// parse (validated) widgets
$this->Template->fields = implode('', array_map(function ($objWidget) {
return $objWidget->parse();
}, $arrWidgets));
}
示例6: compile
public function compile()
{
\System::loadLanguageFile('tl_iso_gallery');
$strBuffer = '
<table style="width:100%">
<thead>
<tr>
<th>' . $GLOBALS['TL_LANG']['tl_iso_gallery']['name'][0] . '</th>
<th>' . $GLOBALS['TL_LANG']['tl_iso_gallery']['lightbox_template'][0] . '<span class="mandatory">*</span></th>
</tr>
</thead>
<tbody>';
foreach ($this->objGaleries as $objGallery) {
$objSelect = new \SelectMenu(\Widget::getAttributesFromDca(array('options' => array_merge(\Controller::getTemplateGroup('moo_'), \Controller::getTemplateGroup('j_')), 'eval' => array('includeBlankOption' => true, 'mandatory' => true)), 'gallery[' . $objGallery->id . ']'));
if (\Input::post('FORM_SUBMIT') == 'tl_iso_upgrade_20010000') {
$objSelect->validate();
if (!$objSelect->hasErrors()) {
$objGallery->lightbox_template = serialize(array($objSelect->value));
$objGallery->save();
}
}
$strBuffer .= '
<tr>
<td>' . $objGallery->name . '</td>
<td>' . $objSelect->generateWithError() . '</td>
</tr>';
}
$strBuffer .= '
</tbody>
</table>';
$this->Template->formSubmit = 'tl_iso_upgrade_20010000';
$this->Template->fields = $strBuffer;
$this->Template->matter = $GLOBALS['TL_LANG']['UPG']['20010000'];
if (\Input::post('FORM_SUBMIT') == 'tl_iso_upgrade_20010000') {
\Controller::reload();
}
}
示例7: getOptionsForAttribute
/**
* Gets the used and available options for given attribute
*
* @param string $attribute The attribute name
* @param string $label Set to the label of the attribute
*
* @return array
*/
protected function getOptionsForAttribute($attribute, &$label)
{
$usedValues = $this->getUsedValuesForAttribute($attribute, $this->findCategories(), $this->iso_newFilter, $this->iso_list_where);
if (empty($usedValues)) {
return array();
}
// Use the default routine to initialize options data
$arrWidget = \Widget::getAttributesFromDca($GLOBALS['TL_DCA']['tl_iso_product']['fields'][$attribute], $attribute);
$label = $arrWidget['label'];
$options = $arrWidget['options'];
if (($objAttribute = $GLOBALS['TL_DCA']['tl_iso_product']['attributes'][$attribute]) !== null && $objAttribute instanceof IsotopeAttributeWithOptions) {
$options = $objAttribute->getOptionsForProductFilter($usedValues);
} elseif (is_array($options)) {
$options = array_filter($options, function ($option) use($usedValues) {
return in_array($option['value'], $usedValues);
});
} else {
$options = array();
}
return $options;
}
示例8: setSubmission
/**
* Set the submission from request, required to check values before widget validation
*/
protected function setSubmission()
{
foreach ($this->dca['fields'] as $strName => $arrField) {
$arrData = $this->dca['fields'][$strName];
// unset options_callback, as long as we have no valid backend user
unset($arrData['options_callback'], $arrData['options_callback']);
$arrAttribues = \Widget::getAttributesFromDca($arrData, $strName, $this->objActiveRecord->{$strName}, $strName, $this->strTable, $this);
switch ($this->strMethod) {
case FORMHYBRID_METHOD_GET:
$this->arrSubmission[$strName] = FormHelper::getGet($strName);
break;
case FORMHYBRID_METHOD_POST:
$this->arrSubmission[$strName] = FormHelper::getPost($strName, $arrAttribues['decodeEntities'], $arrAttribues['allowHtml'], $arrAttribues['preserveTags']);
break;
}
}
}
示例9: prepareForWidget
/**
* Convert a DCA file configuration to be used with widgets
*
* @param array $arrData The field configuration array
* @param string $strName The field name in the form
* @param mixed $varValue The field value
* @param string $strField The field name in the database
* @param string $strTable The table name
*
* @return array An array that can be passed to a widget
*
* @deprecated Use Widget::getAttributesFromDca() instead
*/
protected function prepareForWidget($arrData, $strName, $varValue = null, $strField = '', $strTable = '')
{
return \Widget::getAttributesFromDca($arrData, $strName, $varValue, $strField, $strTable);
}
示例10: handleGetAttributesFromDca
/**
* Handle the widget preparation.
*
* @param GetAttributesFromDcaEvent $event The event.
*
* @return void
*/
public function handleGetAttributesFromDca(GetAttributesFromDcaEvent $event)
{
$event->setResult(\Widget::getAttributesFromDca($event->getFieldConfiguration(), $event->getWidgetName(), $event->getValue(), $event->getWidgetId(), $event->getTable(), $event->getDataContainer()));
}
示例11: generateFilters
/**
* Generate a filter form
*/
protected function generateFilters()
{
$this->Template->hasFilters = false;
if (is_array($this->iso_filterFields) && count($this->iso_filterFields)) {
$time = time();
$arrFilters = array();
$arrInput = \Input::post('filter');
$arrCategories = $this->findCategories();
foreach ($this->iso_filterFields as $strField) {
$arrValues = array();
$objValues = \Database::getInstance()->execute("\n SELECT DISTINCT p1.{$strField} FROM tl_iso_product p1\n LEFT OUTER JOIN tl_iso_product p2 ON p1.pid=p2.id\n WHERE\n p1.language=''\n " . (BE_USER_LOGGED_IN === true ? '' : "AND p1.published='1' AND (p1.start='' OR p1.start<{$time}) AND (p1.stop='' OR p1.stop>{$time}) ") . "\n AND (\n p1.id IN (\n SELECT pid FROM " . \Isotope\Model\ProductCategory::getTable() . " WHERE page_id IN (" . implode(',', $arrCategories) . ")\n )\n OR p1.pid IN (\n SELECT pid FROM " . \Isotope\Model\ProductCategory::getTable() . " WHERE page_id IN (" . implode(',', $arrCategories) . ")\n )\n )\n " . (BE_USER_LOGGED_IN === true ? '' : " AND (p1.pid=0 OR (p2.published='1' AND (p2.start='' OR p2.start<{$time}) AND (p2.stop='' OR p2.stop>{$time})))") . "\n " . ($this->iso_list_where == '' ? '' : " AND " . Haste::getInstance()->call('replaceInsertTags', $this->iso_list_where)));
while ($objValues->next()) {
$arrValues[] = deserialize($objValues->{$strField}, false);
}
if ($this->blnUpdateCache && in_array($arrInput[$strField], $arrValues)) {
Isotope::getRequestCache()->setFilterForModule($strField, Filter::attribute($strField)->isEqualTo($arrInput[$strField]), $this->id);
} elseif ($this->blnUpdateCache && $arrInput[$strField] == '') {
Isotope::getRequestCache()->removeFilterForModule($strField, $this->id);
} elseif (($objFilter = Isotope::getRequestCache()->getFilterForModule($strField, $this->id)) !== null && $objFilter->valueNotIn($arrValues)) {
// Request cache contains wrong value, delete it!
$this->blnUpdateCache = true;
Isotope::getRequestCache()->removeFilterForModule($strField, $this->id);
RequestCache::deleteById(\Input::get('isorc'));
} elseif (!$this->blnUpdateCache) {
// Only generate options if we do not reload anyway
if (empty($arrValues)) {
continue;
}
$arrData = $GLOBALS['TL_DCA']['tl_iso_product']['fields'][$strField];
if (is_array($GLOBALS['ISO_ATTR'][$arrData['inputType']]['callback']) && !empty($GLOBALS['ISO_ATTR'][$arrData['inputType']]['callback'])) {
foreach ($GLOBALS['ISO_ATTR'][$arrData['inputType']]['callback'] as $callback) {
$objCallback = \System::importStatic($callback[0]);
$arrData = $objCallback->{$callback[1]}($strField, $arrData, $this);
}
}
// Use the default routine to initialize options data
$arrWidget = \Widget::getAttributesFromDca($arrData, $strField);
$objFilter = Isotope::getRequestCache()->getFilterForModule($strField, $this->id);
if (($objAttribute = $GLOBALS['TL_DCA']['tl_iso_product']['attributes'][$strField]) !== null && $objAttribute instanceof IsotopeAttributeWithOptions) {
$objAttribute->optionsSource = 'attribute';
$arrWidget['options'] = $objAttribute->getOptionsForProductFilter($arrValues);
}
foreach ($arrValues as $value) {
$arrWidget['options'][] = array('value' => $value, 'label' => $value == '' ? ' ' : 'text');
}
// Must have options to apply the filter
if (!is_array($arrWidget['options'])) {
continue;
}
foreach ($arrWidget['options'] as $k => $option) {
if ($option['value'] == '') {
$arrWidget['blankOptionLabel'] = $option['label'];
unset($arrWidget['options'][$k]);
continue;
} elseif (!in_array($option['value'], $arrValues) || $option['value'] == '-') {
// @deprecated IsotopeAttributeWithOptions::getOptionsForProductFilter already checks this
unset($arrWidget['options'][$k]);
continue;
}
$arrWidget['options'][$k]['default'] = null !== $objFilter && $objFilter->valueEquals($option['value']) ? '1' : '';
}
// Hide fields with just one option (if enabled)
if ($this->iso_filterHideSingle && count($arrWidget['options']) < 2) {
continue;
}
$arrFilters[$strField] = $arrWidget;
}
}
// !HOOK: alter the filters
if (isset($GLOBALS['ISO_HOOKS']['generateFilters']) && is_array($GLOBALS['ISO_HOOKS']['generateFilters'])) {
foreach ($GLOBALS['ISO_HOOKS']['generateFilters'] as $callback) {
$objCallback = \System::importStatic($callback[0]);
$arrFilters = $objCallback->{$callback}[1]($arrFilters);
}
}
if (!empty($arrFilters)) {
$this->Template->hasFilters = true;
$this->Template->filterOptions = $arrFilters;
}
}
}
示例12: executePostActions
/**
* Ajax actions that do require a data container object
* @param string
* @param \DataContainer
*/
public function executePostActions($strAction, \DataContainer $dc)
{
switch ($strAction) {
case 'loadTreepicker':
$arrData = \Widget::getAttributesFromDca($GLOBALS['TL_DCA'][$dc->table]['fields'][\Input::post('name')], \Input::post('name'), null, \Input::post('name'), $dc->table, $dc);
$arrData['id'] = $this->strAjaxName ?: $dc->id;
$objWidget = new $GLOBALS['BE_FFL']['treeSelector']($arrData, $dc);
echo $objWidget->generateAjax($this->strAjaxId, \Input::post('field'), intval(\Input::post('level')));
exit;
break;
case 'reloadTreepicker':
$intId = \Input::get('id');
$strField = $dc->field = \Input::post('name');
// Handle the keys in "edit multiple" mode
if (\Input::get('act') == 'editAll') {
$intId = preg_replace('/.*_([0-9a-zA-Z]+)$/', '$1', $strField);
$strField = preg_replace('/(.*)_[0-9a-zA-Z]+$/', '$1', $strField);
}
// The field does not exist
if (!isset($GLOBALS['TL_DCA'][$dc->table]['fields'][$strField])) {
$this->log('Field "' . $strField . '" does not exist in DCA "' . $dc->table . '"', __METHOD__, TL_ERROR);
header('HTTP/1.1 400 Bad Request');
die('Bad Request');
}
$objRow = null;
$varValue = null;
// Load the value
if ($intId > 0 && $this->Database->tableExists($dc->table)) {
$objRow = $this->Database->prepare("SELECT * FROM " . $dc->table . " WHERE id=?")->execute($intId);
// The record does not exist
if ($objRow->numRows < 1) {
$this->log('A record with the ID "' . $intId . '" does not exist in table "' . $dc->table . '"', __METHOD__, TL_ERROR);
header('HTTP/1.1 400 Bad Request');
die('Bad Request');
}
$varValue = $objRow->{$strField};
$dc->activeRecord = $objRow;
}
// Call the load_callback
if (is_array($GLOBALS['TL_DCA'][$dc->table]['fields'][$strField]['load_callback'])) {
foreach ($GLOBALS['TL_DCA'][$dc->table]['fields'][$strField]['load_callback'] as $callback) {
if (is_array($callback)) {
$this->import($callback[0]);
$varValue = $this->{$callback[0]}->{$callback[1]}($varValue, $dc);
} elseif (is_callable($callback)) {
$varValue = $callback($varValue, $dc);
}
}
}
// Set the new value
$varValue = \Input::post('value', true);
// Convert the selected values
if ($varValue != '') {
$varValue = trimsplit("\t", $varValue);
$varValue = serialize($varValue);
}
$objWidget = new $GLOBALS['BE_FFL']['treePicker'](\Widget::getAttributesFromDca($GLOBALS['TL_DCA'][$dc->table]['fields'][$strField], $dc->field, $varValue, $strField, $dc->table, $dc));
echo $objWidget->generate();
exit;
break;
}
}
示例13: 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();
}
示例14: run
/**
* Run the controller and parse the template
*/
public function run()
{
$this->Template = new \BackendTemplate('be_picker');
$this->Template->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);
// AJAX request
if ($_POST && \Environment::get('isAjaxRequest')) {
$this->objAjax->executePostActions($objDca);
}
$this->Session->set('treePickerRef', \Environment::get('request'));
$objTreeSelector = new $GLOBALS['BE_FFL']['treeSelector'](\Widget::getAttributesFromDca($GLOBALS['TL_DCA'][$strTable]['fields'][$strField], $strField, array_filter(explode(',', \Input::get('value'))), $strField, $strTable, $objDca));
$this->Template->main = $objTreeSelector->generate();
$this->Template->theme = \Backend::getTheme();
$this->Template->base = \Environment::get('base');
$this->Template->language = $GLOBALS['TL_LANGUAGE'];
$this->Template->title = specialchars($GLOBALS['TL_LANG']['MSC']['treepicker']);
$this->Template->charset = $GLOBALS['TL_CONFIG']['characterSet'];
$this->Template->addSearch = $objTreeSelector->searchField;
$this->Template->search = $GLOBALS['TL_LANG']['MSC']['search'];
$this->Template->action = ampersand(\Environment::get('request'));
$this->Template->value = $this->Session->get($objTreeSelector->getSearchSessionKey());
$this->Template->manager = $GLOBALS['TL_LANG']['MSC']['treepickerManager'];
$this->Template->breadcrumb = $GLOBALS['TL_DCA'][$objTreeSelector->foreignTable]['list']['sorting']['breadcrumb'];
$this->Template->managerHref = '';
// Add the manager link
if ($objTreeSelector->managerHref) {
$this->Template->managerHref = 'contao/main.php?' . ampersand($objTreeSelector->managerHref) . '&popup=1&wtp=1';
}
$GLOBALS['TL_CONFIG']['debugMode'] = false;
$this->Template->output();
}
示例15: generateFilters
/**
* Generate a filter form
*/
protected function generateFilters()
{
$this->Template->hasFilters = false;
if (!empty($this->iso_filterFields)) {
$arrFilters = array();
$arrInput = \Input::post('filter');
$arrCategories = $this->findCategories();
foreach ($this->iso_filterFields as $strField) {
$arrValues = $this->getUsedValuesForAttribute($strField, $arrCategories, $this->iso_newFilter, $this->iso_list_where);
if ($this->blnUpdateCache && in_array($arrInput[$strField], $arrValues)) {
Isotope::getRequestCache()->setFilterForModule($strField, Filter::attribute($strField)->isEqualTo($arrInput[$strField]), $this->id);
} elseif ($this->blnUpdateCache && $arrInput[$strField] == '') {
Isotope::getRequestCache()->removeFilterForModule($strField, $this->id);
} elseif (($objFilter = Isotope::getRequestCache()->getFilterForModule($strField, $this->id)) !== null && $objFilter->valueNotIn($arrValues)) {
// Request cache contains wrong value, delete it!
$this->blnUpdateCache = true;
Isotope::getRequestCache()->removeFilterForModule($strField, $this->id);
RequestCache::deleteById(\Input::get('isorc'));
} elseif (!$this->blnUpdateCache) {
// Only generate options if we do not reload anyway
if (empty($arrValues)) {
continue;
}
$arrData = $GLOBALS['TL_DCA']['tl_iso_product']['fields'][$strField];
// Use the default routine to initialize options data
$arrWidget = \Widget::getAttributesFromDca($arrData, $strField);
$objFilter = Isotope::getRequestCache()->getFilterForModule($strField, $this->id);
if (($objAttribute = $GLOBALS['TL_DCA']['tl_iso_product']['attributes'][$strField]) !== null && $objAttribute instanceof IsotopeAttributeWithOptions) {
$arrWidget['options'] = $objAttribute->getOptionsForProductFilter($arrValues);
}
// Must have options to apply the filter
if (!is_array($arrWidget['options'])) {
continue;
}
foreach ($arrWidget['options'] as $k => $option) {
if ($option['value'] == '') {
$arrWidget['blankOptionLabel'] = $option['label'];
unset($arrWidget['options'][$k]);
continue;
} elseif (!in_array($option['value'], $arrValues) || $option['value'] == '-') {
// @deprecated IsotopeAttributeWithOptions::getOptionsForProductFilter already checks this
unset($arrWidget['options'][$k]);
continue;
}
$arrWidget['options'][$k]['default'] = null !== $objFilter && $objFilter->valueEquals($option['value']) ? '1' : '';
}
// Hide fields with just one option (if enabled)
if ($this->iso_filterHideSingle && count($arrWidget['options']) < 2) {
continue;
}
$arrFilters[$strField] = $arrWidget;
}
}
// !HOOK: alter the filters
if (isset($GLOBALS['ISO_HOOKS']['generateFilters']) && is_array($GLOBALS['ISO_HOOKS']['generateFilters'])) {
foreach ($GLOBALS['ISO_HOOKS']['generateFilters'] as $callback) {
$objCallback = \System::importStatic($callback[0]);
$arrFilters = $objCallback->{$callback}[1]($arrFilters);
}
}
if (!empty($arrFilters)) {
$this->Template->hasFilters = true;
$this->Template->filterOptions = $arrFilters;
}
}
}