本文整理汇总了PHP中Controller::loadDataContainer方法的典型用法代码示例。如果您正苦于以下问题:PHP Controller::loadDataContainer方法的具体用法?PHP Controller::loadDataContainer怎么用?PHP Controller::loadDataContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Controller
的用法示例。
在下文中一共展示了Controller::loadDataContainer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check
/**
* Check permissions for that entry
* @return void
*/
public static function check()
{
$session = \Session::getInstance()->getData();
if (\Input::get('act') == 'delete' && in_array(\Input::get('id'), static::getUndeletableIds())) {
\System::log('Product type ID ' . \Input::get('id') . ' is used in an order and can\'t be deleted', __METHOD__, TL_ERROR);
\Controller::redirect('contao/main.php?act=error');
} elseif (\Input::get('act') == 'deleteAll' && is_array($session['CURRENT']['IDS'])) {
$arrDeletable = array_diff($session['CURRENT']['IDS'], static::getUndeletableIds());
if (count($arrDeletable) != count($session['CURRENT']['IDS'])) {
$session['CURRENT']['IDS'] = array_values($arrDeletable);
\Session::getInstance()->setData($session);
\Message::addInfo($GLOBALS['TL_LANG']['MSC']['undeletableRecords']);
}
}
// Disable variants if no such attributes are available
\Controller::loadDataContainer('tl_iso_product');
$blnVariants = false;
foreach ($GLOBALS['TL_DCA']['tl_iso_product']['fields'] as $strName => $arrConfig) {
$objAttribute = $GLOBALS['TL_DCA']['tl_iso_product']['attributes'][$strName];
if (null !== $objAttribute && $objAttribute->isVariantOption()) {
$blnVariants = true;
break;
}
}
if (!$blnVariants) {
\System::loadLanguageFile('explain');
unset($GLOBALS['TL_DCA']['tl_iso_producttype']['subpalettes']['variants']);
$GLOBALS['TL_DCA']['tl_iso_producttype']['fields']['variants']['input_field_callback'] = function ($dc) {
// Make sure variants are disabled in this product type (see #1114)
\Database::getInstance()->prepare("UPDATE " . $dc->table . " SET variants='' WHERE id=?")->execute($dc->id);
return '<br><p class="tl_info">' . $GLOBALS['TL_LANG']['XPL']['noVariantAttributes'] . '</p>';
};
}
}
示例2: generateFilter
/**
* Add this filter to the module's template or get the URL params
* @param array
* @param Contao\Template
* @param Contao\Module
* @param boolean
* @return mixed string|bool|void
*/
public static function generateFilter(&$arrCategories, &$objTemplate, $objModule, $blnGenURL = false)
{
\System::loadLanguageFile(Product::getTable());
\Controller::loadDataContainer(Product::getTable());
$arrFields = deserialize($objModule->iso_sortingFields, true);
if ($blnGenURL) {
//return the URL fragment needed for this filter to pass to the lister
if (\Input::post(static::$strKey) && in_array(str_replace(array('-asc', '-desc'), '', \Input::post(static::$strKey)), $arrFields)) {
return static::$strKey . '/' . urlencode(\Input::post(static::$strKey));
}
return false;
}
$arrAvailable = array('' => $GLOBALS['TL_LANG']['MSC']['relevancyFilterLabel']);
foreach ($arrFields as $field) {
list($asc, $desc) = static::getSortingLabels($field);
$strLabel = is_array($GLOBALS['TL_DCA'][Product::getTable()]['fields'][$field]['label']) ? $GLOBALS['TL_DCA'][Product::getTable()]['fields'][$field]['label'][0] : $field;
$arrAvailable[$field . '-asc'] = $strLabel . ' ' . $asc;
$arrAvailable[$field . '-desc'] = $strLabel . ' ' . $desc;
}
if (count($arrAvailable) > 0) {
$objTemplate->hasSorting = true;
$objTemplate->sort = $arrAvailable;
$objTemplate->sortselected = \Input::get(static::$strKey) ?: ($objModule->iso_listingSortField ? $objModule->iso_listingSortField . '-' . strtolower($objModule->iso_listingSortDirection) : '');
$objTemplate->psortLabel = $GLOBALS['TL_LANG']['MSC'][static::$strKey . 'FilterLabel'];
}
}
示例3: addShareFields
public static function addShareFields($strDca)
{
\Controller::loadDataContainer($strDca);
$arrDca =& $GLOBALS['TL_DCA'][$strDca];
$arrDca['fields']['shareToken'] = array('eval' => array('doNotCopy' => true), 'sql' => "varchar(23) NOT NULL default ''");
$arrDca['fields']['shareTokenTime'] = array('eval' => array('doNotCopy' => true), 'sql' => "int(10) unsigned NOT NULL default '0'");
}
示例4: getFilter
public function getFilter($objModule)
{
\Controller::loadDataContainer('tl_calendar_events');
$arrFilter = array();
$arrFields = deserialize($objModule->formHybridEditable, true);
// Return if there are no fields
if (!is_array($arrFields) || empty($arrFields)) {
return $arrFilter;
}
$objHelper = new EventFilterHelper();
$arrEventTypeArchives = deserialize($objModule->cal_eventTypesArchive, true);
foreach ($arrFields as $strKey) {
$arrData = $GLOBALS['TL_DCA']['tl_calendar_events']['fields'][$strKey];
if (!is_array($arrData) || empty($arrData)) {
continue;
}
$arrFilter[$strKey] = $objHelper->getValueByDca(\Input::get($strKey), $arrData);
if (!$objModule->cal_combineEventTypesArchive && count($arrEventTypeArchives) > 0 && strrpos($strKey, 'eventtypes', -strlen($strKey)) !== FALSE) {
// unset eventtypes
unset($arrFilter[$strKey]);
// use multiple eventtypes
foreach ($arrEventTypeArchives as $intArchive) {
$strArchiveKey = $strKey . '_' . $intArchive;
$arrFilter[$strArchiveKey] = $objHelper->getValueByDca(\Input::get($strArchiveKey), $arrData);
}
}
}
return $arrFilter;
}
示例5: generate
/**
* Generate the checkout step
* @return string
*/
public function generate()
{
// Make sure field data is available
\Controller::loadDataContainer('tl_iso_product_collection');
\System::loadLanguageFile('tl_iso_product_collection');
$objTemplate = new Template($this->strTemplate);
$varValue = null;
$objWidget = new FormTextArea(FormTextArea::getAttributesFromDca($GLOBALS['TL_DCA'][$this->strTable]['fields'][$this->strField], $this->strField, $varValue, $this->strField, $this->strTable, $this));
$objWidget->storeValues = true;
if (\Input::post('FORM_SUBMIT') == $this->strFormId) {
$objWidget->validate();
$varValue = $objWidget->value;
// Do not submit the field if there are errors
if ($objWidget->hasErrors()) {
$doNotSubmit = true;
} elseif ($objWidget->submitInput()) {
$objOrder = Isotope::getCart()->getDraftOrder();
// Store the form data
$_SESSION['FORM_DATA'][$this->strField] = $varValue;
// Set the correct empty value (see #6284, #6373)
if ($varValue === '') {
$varValue = $objWidget->getEmptyValue();
}
// Set the new value
if ($varValue !== $objOrder->{$this->strField}) {
$objOrder->{$this->strField};
}
}
}
$objTemplate->headline = $GLOBALS['TL_LANG'][$this->strTable][$this->strField][0];
$objTemplate->customerNotes = $objWidget->parse();
return $objTemplate->parse();
}
示例6: run
public static function run()
{
$objDatabase = \Database::getInstance();
\Controller::loadDataContainer('tl_module');
$arrRenameFields = array('tl_module' => array('jumpToSuccess' => array('name' => 'jumpTo', 'syncValue' => true), 'jumpToSuccessPreserveParams' => array('name' => 'formHybridJumpToPreserveParams', 'syncValue' => false), 'allowIdAsGetParameter' => array('name' => 'formHybridAllowIdAsGetParameter', 'syncValue' => true), 'idGetParameter' => array('name' => 'formHybridIdGetParameter', 'syncValue' => true), 'appendIdToUrlOnCreation' => array('name' => 'formHybridAppendIdToUrlOnCreation', 'syncValue' => true)));
foreach ($arrRenameFields as $strTable => $arrFields) {
if (!$objDatabase->tableExists($strTable)) {
continue;
}
foreach ($arrFields as $strOldName => $arrConfig) {
if (!$objDatabase->fieldExists($strOldName, $strTable)) {
continue;
}
$strNewName = $arrConfig['name'];
$sql =& $GLOBALS['TL_DCA']['tl_module']['fields'][$strNewName]['sql'];
if (!$objDatabase->fieldExists($arrConfig['name'], $strTable) && $sql) {
$sql =& $GLOBALS['TL_DCA']['tl_module']['fields'][$strNewName]['sql'];
$objDatabase->query("ALTER TABLE {$strTable} ADD `{$strNewName}` {$sql}");
}
if (!$arrConfig['syncValue']) {
continue;
}
$objDatabase->prepare('UPDATE ' . $strTable . ' SET ' . $arrConfig['name'] . ' = ' . $strOldName)->execute();
}
}
return;
}
示例7: run
public function run($blnInstalled)
{
if ($blnInstalled) {
\Controller::loadDataContainer('tl_iso_product');
$arrFields = array();
foreach ($GLOBALS['TL_DCA']['tl_iso_product']['fields'] as $field => $config) {
if ($config['inputType'] == 'mediaManager') {
$arrFields[] = $field;
}
}
if (empty($arrFields)) {
return;
}
$objProducts = \Database::getInstance()->query("\n SELECT * FROM tl_iso_product WHERE language=''\n ");
while ($objProducts->next()) {
foreach ($arrFields as $field) {
$arrUpdate = array();
$arrData = deserialize($objProducts->{$field});
if (!empty($arrData) && is_array($arrData)) {
foreach ($arrData as $k => $image) {
if ($image['translate'] == '') {
$arrData[$k]['translate'] = 'none';
}
}
$arrUpdate[$field] = serialize($arrData);
}
}
if (!empty($arrUpdate)) {
\Database::getInstance()->prepare("UPDATE tl_iso_product %s WHERE id=?")->set($arrUpdate)->execute($objProducts->id);
}
}
}
}
示例8: run
public static function run()
{
$objDatabase = \Database::getInstance();
\Controller::loadDataContainer('tl_extcss');
$arrFields = array('tl_extcss' => array('bootstrapVariablesSRC', 'observeFolderSRC'), 'tl_extcss_file' => array('src'), 'tl_extjs_file' => array('src'));
if (version_compare(VERSION, '3.2', '>=')) {
foreach ($arrFields as $strTable => $arrNames) {
if (!$objDatabase->tableExists($strTable)) {
continue;
}
// convert file fields
foreach ($objDatabase->listFields($strTable) as $arrField) {
// with extassets 1.1.1 bootstrapVariablesSRC changed to variablesSRC
if ($arrField['name'] == 'bootstrapVariablesSRC') {
if (!$objDatabase->fieldExists('variablesSRC', $strTable)) {
$sql =& $GLOBALS['TL_DCA']['tl_extcss']['fields']['variablesSRC']['sql'];
$objDatabase->query("ALTER TABLE {$strTable} ADD `variablesSRC` {$sql}");
$sql =& $GLOBALS['TL_DCA']['tl_extcss']['fields']['variablesOrderSRC']['sql'];
$objDatabase->query("ALTER TABLE {$strTable} ADD `variablesOrderSRC` {$sql}");
}
$objGroups = $objDatabase->execute('SELECT * FROM ' . $strTable . ' WHERE bootstrapVariablesSRC IS NOT NULL AND variablesSRC IS NULL');
while ($objGroups->next()) {
$variables = serialize(array($objGroups->bootstrapVariablesSRC));
$objDatabase->prepare('UPDATE ' . $strTable . ' SET variablesSRC = ?, variablesOrderSRC = ? WHERE id = ?')->execute($variables, $variables, $objGroups->id);
}
$objDatabase->query("ALTER TABLE {$strTable} DROP `bootstrapVariablesSRC`");
}
if (in_array($arrField['name'], $arrNames)) {
\Database\Updater::convertSingleField($strTable, $arrField['name']);
}
}
}
}
return;
}
示例9: __construct
/**
* Construct the model
*
* @param Result $objResult
*/
public function __construct(Result $objResult = null)
{
parent::__construct($objResult);
if (!is_array($GLOBALS['ISO_ADR'])) {
\Controller::loadDataContainer(static::$strTable);
\System::loadLanguageFile('addresses');
}
}
示例10: getSqlForField
/**
* Get SQL statement for a DCA field
*
* @param $strField
* @param $strTable
*
* @return string
*/
private function getSqlForField($strField, $strTable)
{
\Controller::loadDataContainer($strTable);
$strSql = (string) $GLOBALS['TL_DCA'][$strTable]['fields'][$strField]['sql'];
if ($strSql == '') {
throw new \LogicException('Field "' . $strField . '" is not defined in "' . $strTable . '"');
}
return $strSql;
}
示例11: loadDataContainerHook
/**
* Add fieldpalette fields to tl_fieldpalette
*
* @param string $strTable
*
* @return boolean false if Datacontainer not supported
*/
public function loadDataContainerHook($strTable)
{
if ($strTable !== \Config::get('fieldpalette_table')) {
\Controller::loadDataContainer(\Config::get('fieldpalette_table'));
}
$dc =& $GLOBALS['TL_DCA'][\Config::get('fieldpalette_table')];
// dynamically set fieldpalette fields from parent table
if ($strTable == \Config::get('fieldpalette_table') && \Input::get('table') == \Config::get('fieldpalette_table')) {
return FieldPalette::loadDynamicPaletteByParentTable(\Input::get('act'), $strTable, $dc);
}
FieldPalette::registerFieldPalette($dc, $strTable, $strTable);
}
示例12: prepareData
public static function prepareData(\Model $objModel, $strTable, array $arrDca = array(), $objDc = null, $arrFields = array(), array $arrSkipFields = array())
{
if ($objDc === null) {
$objDc = DC_Table::getInstanceFromModel($objModel);
}
if (empty($arrDca)) {
\Controller::loadDataContainer($objModel->getTable());
$arrDca = $GLOBALS['TL_DCA'][$objModel->getTable()];
}
$arrSubmissionData = array();
$arrRow = $objModel->row();
$arrSubmission = array();
foreach (array_keys($arrRow) as $strName) {
$varValue = $arrRow[$strName];
if (empty($varValue)) {
continue;
}
$arrData = $arrDca['fields'][$strName];
$arrFieldData = static::prepareDataField($strName, $varValue, $arrData, $strTable, $objDc);
$arrSubmissionData[$strName] = $arrFieldData;
$strSubmission = $arrFieldData['submission'];
$varValue = deserialize($varValue);
// multicolumnwizard support
if ($arrData['inputType'] == 'multiColumnWizard') {
foreach ($varValue as $arrSet) {
if (!is_array($arrSet)) {
continue;
}
// new line
$strSubmission .= "\n";
foreach ($arrSet as $strSetName => $strSetValue) {
$arrSetData = $arrData['eval']['columnFields'][$strSetName];
$arrFieldData = static::prepareDataField($strSetName, $strSetValue, $arrSetData, $strTable, $objDc);
// intend new line
$strSubmission .= "\t" . $arrFieldData['submission'];
}
// new line
$strSubmission .= "\n";
}
}
$arrSubmissionData['submission_all'] .= $strSubmission;
if (in_array($strName, $arrFields) && !in_array($strName, $arrSkipFields)) {
$arrSubmission[$strName] = $strSubmission;
}
}
// order submission by arrFields
$strSubmissionAll = '';
foreach ($arrFields as $strName) {
$strSubmissionAll .= $arrSubmission[$strName];
}
$arrSubmissionData['submission'] = $strSubmissionAll;
return $arrSubmissionData;
}
示例13: getFilterFields
public function getFilterFields(\DataContainer $dataContainer)
{
\Controller::loadDataContainer('tl_calendar_events');
\Controller::loadLanguageFile('tl_calendar_events');
global $container, $TL_LANG;
$options = array('pid' => $TL_LANG['tl_module']['filterPropertyCalendar'], 'author' => $TL_LANG['tl_module']['filterPropertyAuthor'], 'startDate' => $TL_LANG['tl_module']['filterPropertyMonth']);
/** @var EventDispatcher $eventDispatcher */
$eventDispatcher = $container['event-dispatcher'];
$event = new GetFilterOptionsEvent();
$event->setOptions($options);
$eventDispatcher->dispatch(GetFilterOptionsEvent::NAME, $event);
return $event->getOptions();
}
示例14: adjustPalettesForLists
public static function adjustPalettesForLists(\DataContainer $objDc)
{
\Controller::loadDataContainer('tl_module');
\System::loadLanguageFile('tl_module');
if (($objModule = \ModuleModel::findByPk($objDc->id)) !== null) {
$arrDca =& $GLOBALS['TL_DCA']['tl_module'];
if (\HeimrichHannot\Haste\Util\Module::isSubModuleOf($objModule->type, 'HeimrichHannot\\FrontendEdit\\ModuleList')) {
$arrDca['palettes'][MODULE_FRONTENDEDIT_MEMBER_LIST] = str_replace('filterArchives', 'filterGroups', $arrDca['palettes'][MODULE_FRONTENDEDIT_MEMBER_LIST]);
// override labels for suiting a list module
$arrDca['fields']['formHybridAddDefaultValues']['label'] =& $GLOBALS['TL_LANG']['tl_module']['formHybridAddDefaultFilterValues'];
$arrDca['fields']['formHybridDefaultValues']['label'] =& $GLOBALS['TL_LANG']['tl_module']['formHybridDefaultFilterValues'];
}
}
}
示例15: createObjectFromMapping
protected function createObjectFromMapping($arrSourceItem)
{
$objDatabase = \Database::getInstance();
\Controller::loadDataContainer($this->dbTargetTable);
$t = $this->dbTargetTable;
$arrItem = array();
foreach (deserialize($this->fileFieldMapping, true) as $arrConfig) {
if ($arrConfig['type'] == 'source') {
$varValue = $arrSourceItem[$arrConfig['source'] - 1];
} else {
if ($arrConfig['type'] == 'value' && !empty($arrConfig['value'])) {
$varValue = $arrConfig['value'];
}
}
if ($varValue) {
$varValue = $arrConfig['transformToArray'] ? serialize(explode($this->arrayDelimiter, $varValue)) : $varValue;
}
$this->setObjectValueFromMapping($arrItem, $varValue, $arrConfig['target']);
if ($varValue === null) {
unset($arrItem[$arrConfig['target']]);
continue;
}
}
if (!$this->dryRun) {
if (!$this->skipInsertion) {
$strQuery = "INSERT INTO {$t} (" . implode(',', array_keys($arrItem)) . ") VALUES(" . implode(',', array_map(function ($val) {
return "'" . str_replace("'", "''", $val) . "'";
}, array_values($arrItem))) . ")";
$arrItem['id'] = $objDatabase->execute($strQuery)->insertId;
}
// do after item has been created,
$this->runAfterSaving($arrItem, $arrSourceItem);
// save updates
if (!$this->skipUpdateAfterSave) {
$arrTargetItemPrepared = array();
foreach ($arrItem as $strKey => $strVal) {
if ($strKey == 'id') {
continue;
}
$strVal = str_replace("'", "''", $strVal);
$arrTargetItemPrepared[] = "{$this->dbTargetTable}.{$strKey}='{$strVal}'";
}
// update all values to the db
$strQuery = "UPDATE {$this->dbTargetTable} SET " . implode(',', $arrTargetItemPrepared) . " WHERE id=" . $arrItem['id'];
\Database::getInstance()->execute($strQuery);
}
}
return $arrItem;
}