public function parsePromoter($objPromoter, $index = null, array $arrPromoters = array()) { $strTemplate = $this->cal_promoterTemplate ? $this->cal_promoterTemplate : 'cal_promoter_default'; $objT = new \FrontendTemplate($strTemplate); $objT->setData($objPromoter->row()); if ($objPromoter->room && ($objRoom = $objPromoter->getRelated('room')) !== null) { $objT->room = $objRoom; } $contact = new \stdClass(); $hasContact = false; if ($objPromoter->website) { $objT->websiteUrl = \HeimrichHannot\Haste\Util\Url::addScheme($objPromoter->website); } foreach (static::$arrContact as $strField) { if (!$objT->{$strField}) { continue; } $hasContact = true; $contact->{$strField} = $objT->{$strField}; } $objT->hasContact = $hasContact; $objT->contact = $contact; $objT->contactTitle = $GLOBALS['TL_LANG']['cal_promoterlist']['contactTitle']; $objT->phoneTitle = $GLOBALS['TL_LANG']['cal_promoterlist']['phoneTitle']; $objT->faxTitle = $GLOBALS['TL_LANG']['cal_promoterlist']['faxTitle']; $objT->emailTitle = $GLOBALS['TL_LANG']['cal_promoterlist']['emailTitle']; $objT->websiteTitle = $GLOBALS['TL_LANG']['cal_promoterlist']['websiteTitle']; if (!empty($arrPromoters) && $index !== null) { $objT->cssClass = \HeimrichHannot\Haste\Util\Arrays::getListPositonCssClass($index, $arrPromoters); } return $objT->parse(); }
public static function getMembersAsOptions(\DataContainer $objDc = null, $blnIncludeId = false) { if (!$blnIncludeId && !empty(static::$arrMemberOptionsCache)) { return static::$arrMemberOptionsCache; } if ($blnIncludeId && !empty(static::$arrMemberOptionsIdsCache)) { return static::$arrMemberOptionsIdsCache; } $objDatabase = \Database::getInstance(); $objMembers = $objDatabase->execute('SELECT id, firstname, lastname FROM tl_member'); $arrOptions = array(); if ($objMembers->numRows > 0) { if ($blnIncludeId) { $arrIds = array_values($objMembers->fetchEach('id')); $arrOptions = Arrays::concatArrays(' ', $objMembers->fetchEach('firstname'), $objMembers->fetchEach('lastname'), array_map(function ($val) { return '(ID ' . $val . ')'; }, array_combine($arrIds, $arrIds))); } else { $arrOptions = Arrays::concatArrays(' ', $objMembers->fetchEach('firstname'), $objMembers->fetchEach('lastname')); } } asort($arrOptions); if ($blnIncludeId) { static::$arrMemberOptionsIdsCache = $arrOptions; } else { static::$arrMemberOptionsCache = $arrOptions; } return $arrOptions; }
/** * Filter class constants by given prefixes and return the extracted constants. * * @param string $strClass The class that should be searched for constants in. * @param array $arrPrefixes An array of prefixes that should be used to filter the class constants. * @param $blnReturnValueAsKey boolean Return the extracted array keys from its value, if true. * * @return array The extracted constants as array. */ public static function getConstantsByPrefixes($strClass, array $arrPrefixes = array(), $blnReturnValueAsKey = true) { $arrExtract = array(); if (!class_exists($strClass)) { return $arrExtract; } $objReflection = new \ReflectionClass($strClass); $arrConstants = $objReflection->getConstants(); if (!is_array($arrConstants)) { return $arrExtract; } $arrExtract = Arrays::filterByPrefixes($arrConstants, $arrPrefixes); return $blnReturnValueAsKey ? array_combine($arrExtract, $arrExtract) : $arrExtract; }
protected function doExport($objEntity = null, array $arrFields = array()) { switch ($this->type) { case Exporter::TYPE_ITEM: break; case Exporter::TYPE_LIST: $objDbResult = $this->getEntities(); $arrDca = $GLOBALS['TL_DCA'][$this->linkedTable]; if (!$objDbResult->numRows > 0) { return; } $intCol = 0; $intRow = 1; // header if ($this->objConfig->addHeaderToExportTable) { foreach ($this->arrHeaderFields as $varValue) { $this->objPhpExcel->setActiveSheetIndex(0)->setCellValueByColumnAndRow($intCol, $intRow, $varValue); $this->processHeaderRow($intCol); $intCol++; } $intRow++; } // body while ($objDbResult->next()) { $arrRow = $objDbResult->row(); $intCol = 0; foreach ($arrRow as $key => $varValue) { $objDc = new \DC_Table($this->linkedTable); $objDc->activeRecord = $objDbResult; $objDc->id = $objDbResult->id; $varValue = $this->localizeFields ? FormSubmission::prepareSpecialValueForPrint($varValue, $arrDca['fields'][$key], $this->linkedTable, $objDc) : $varValue; if (is_array($varValue)) { $varValue = Arrays::flattenArray($varValue); } $this->objPhpExcel->setActiveSheetIndex(0)->setCellValueByColumnAndRow($intCol, $intRow, html_entity_decode($varValue)); $this->objPhpExcel->getActiveSheet()->getColumnDimension(\PHPExcel_Cell::stringFromColumnIndex($intCol))->setAutoSize(true); $this->processBodyRow($intCol); $intCol++; } $this->objPhpExcel->getActiveSheet()->getRowDimension($intRow)->setRowHeight(-1); $intRow++; } $this->objPhpExcel->setActiveSheetIndex(0); $this->objPhpExcel->getActiveSheet()->setTitle('Export'); return $this->objPhpExcel; break; } return false; }
protected function transform() { // leave non-formhybrid data inside config $this->arrData = Arrays::filterOutByPrefixes($this->varConfig, array('formHybrid')); // never set context id from module id if (isset($this->arrData['id'])) { $this->arrData['moduleId'] = $this->arrData['id']; unset($this->arrData['id']); } // transform formhybrid prefixed attributes $arrData = Arrays::filterByPrefixes($this->varConfig, array('formHybrid')); foreach ($arrData as $strKey => $varValue) { $this->{$strKey} = $varValue; } }
public static function importMemberFields() { $arrDca =& $GLOBALS['TL_DCA']['tl_company']; \Controller::loadDataContainer('tl_member'); \System::loadLanguageFile('tl_member'); // fields $blnChangeMandatoryAddressFields = \Config::get('companyChangeMandatoryMemberFields'); $arrMandatoryAddressFields = deserialize(\Config::get('companyMandatoryMemberFields'), true); $arrAddressFields = \Config::get('companyMemberFields'); if ($arrAddressFields === null) { $arrAddressFields = serialize(array_keys(static::getMemberFields())); } $arrFields = array(); foreach (deserialize($arrAddressFields, true) as $strName) { $strNameContact = 'contact' . ucfirst($strName); $arrFields[$strNameContact] = $GLOBALS['TL_DCA']['tl_member']['fields'][$strName]; if ($blnChangeMandatoryAddressFields && is_array($arrMandatoryAddressFields)) { $arrFields[$strNameContact]['eval']['mandatory'] = in_array($strName, $arrMandatoryAddressFields); } } Arrays::insertInArrayByName($arrDca['fields'], 'tstamp', $arrFields, 1); }
public static function prepareSpecialValueForPrint($varValue, $arrData, $strTable, $objDc, $objItem = null) { $varValue = deserialize($varValue); $arrOpts = $arrData['options']; $arrReference = $arrData['reference']; $strRegExp = $arrData['eval']['rgxp']; // get options if ((is_array($arrData['options_callback']) || is_callable($arrData['options_callback'])) && !$arrData['reference']) { if (is_array($arrData['options_callback'])) { $strClass = $arrData['options_callback'][0]; $strMethod = $arrData['options_callback'][1]; $objInstance = \Controller::importStatic($strClass); $arrOptionsCallback = @$objInstance->{$strMethod}($objDc); } elseif (is_callable($arrData['options_callback'])) { $arrOptionsCallback = @$arrData['options_callback']($objDc); } $arrOptions = !is_array($varValue) ? array($varValue) : $varValue; if ($varValue !== null && is_array($arrOptionsCallback)) { $varValue = array_intersect_key($arrOptionsCallback, array_flip($arrOptions)); } } if ($arrData['inputType'] == 'explanation') { $varValue = $arrData['eval']['text']; } elseif ($strRegExp == 'date') { $varValue = \Date::parse(\Config::get('dateFormat'), $varValue); } elseif ($strRegExp == 'time') { $varValue = \Date::parse(\Config::get('timeFormat'), $varValue); } elseif ($strRegExp == 'datim') { $varValue = \Date::parse(\Config::get('datimFormat'), $varValue); } elseif ($arrData['inputType'] == 'tag' && in_array('tags_plus', \ModuleLoader::getActive())) { if (($arrTags = \HeimrichHannot\TagsPlus\TagsPlus::loadTags($strTable, $objItem->id)) !== null) { $varValue = $arrTags; } } elseif (!is_array($varValue) && \Validator::isBinaryUuid($varValue)) { $strPath = Files::getPathFromUuid($varValue); $varValue = $strPath ? \Environment::get('url') . '/' . $strPath : \StringUtil::binToUuid($varValue); } elseif (is_array($varValue)) { $varValue = Arrays::flattenArray($varValue); $varValue = array_filter($varValue); // remove empty elements // transform binary uuids to paths $varValue = array_map(function ($varValue) { if (\Validator::isBinaryUuid($varValue)) { $strPath = Files::getPathFromUuid($varValue); if ($strPath) { return \Environment::get('url') . '/' . $strPath; } return \StringUtil::binToUuid($varValue); } return $varValue; }, $varValue); if (!$arrReference) { $varValue = array_map(function ($varValue) use($arrOpts) { return isset($arrOpts[$varValue]) ? $arrOpts[$varValue] : $varValue; }, $varValue); } $varValue = array_map(function ($varValue) use($arrReference) { if (is_array($arrReference)) { return isset($arrReference[$varValue]) ? is_array($arrReference[$varValue]) ? $arrReference[$varValue][0] : $arrReference[$varValue] : $varValue; } else { return $varValue; } }, $varValue); } else { if ($arrData['eval']['isBoolean'] || $arrData['inputType'] == 'checkbox' && !$arrData['eval']['multiple']) { $varValue = $varValue != '' ? $GLOBALS['TL_LANG']['MSC']['yes'] : $GLOBALS['TL_LANG']['MSC']['no']; } elseif (is_array($arrOpts) && array_is_assoc($arrOpts)) { $varValue = isset($arrOpts[$varValue]) ? $arrOpts[$varValue] : $varValue; } elseif (is_array($arrReference)) { $varValue = isset($arrReference[$varValue]) ? is_array($arrReference[$varValue]) ? $arrReference[$varValue][0] : $arrReference[$varValue] : $varValue; } } if (is_array($varValue)) { $varValue = implode(', ', $varValue); } // Convert special characters (see #1890) return specialchars($varValue); }
/** * Retrieve the subpalette by the field selector * * @param string $strSelector * @param array $arrFields * * @return array Return the state, subpalette name, the filtered fields array and autosubmit state */ protected function retrieveSubpaletteWithState($strSelector, array $arrFields) { $blnActive = null; $blnAutoSubmit = false; $strSubpalette = null; $arrSubPaletteFields = array(); $blnToggleSubpalette = false; $varValue = $this->getFieldValue($strSelector); // skip arrays, they cant be array keys if (is_array($varValue)) { return array($blnActive, $strSubpalette, $arrFields, $blnAutoSubmit); } // checkbox: addImage for example if ($this->dca['fields'][$strSelector]['inputType'] == 'checkbox' && !$this->dca['fields'][$strSelector]['eval']['multiple']) { if (strlen($this->dca['subpalettes'][$strSelector])) { $blnActive = $varValue == true; $strSubpalette = $strSelector; $blnToggleSubpalette = true; $arrSubPaletteFields = FormHelper::getPaletteFields($this->strTable, $this->dca['subpalettes'][$strSubpalette]); } } else { // type selector if (isset($this->dca['subpalettes'][$varValue])) { $blnAutoSubmit = true; $blnActive = true; $strSubpalette = $varValue; } elseif (is_array($this->dca['subpalettes'])) { $arrSubpalettes = Arrays::filterByPrefixes($this->dca['subpalettes'], array($strSelector . '_')); if (!empty($arrSubpalettes)) { $blnToggleSubpalette = true; // also if no active type selector, cause no default value, toggleSubpalette $blnActive = isset($arrSubpalettes[$strSelector . '_' . $varValue]); if ($blnActive) { $strSubpalette = $strSelector . '_' . $varValue; $arrSubPaletteFields = FormHelper::getPaletteFields($this->strTable, $this->dca['subpalettes'][$strSubpalette]); } // remove concatenated type selector sibling subpalette fields that are not active foreach ($arrSubpalettes as $strSubSiblingPalette => $strSubSiblingFields) { // do not remove active concatenated type selector fields if ($blnActive && $strSubSiblingPalette === $strSubpalette) { continue; } $arrFields = array_diff($arrFields, FormHelper::getPaletteFields($this->strTable, $this->dca['subpalettes'][$strSubSiblingPalette])); } } } } return array($blnActive, $strSubpalette, $arrFields, $arrSubPaletteFields, $blnAutoSubmit, $blnToggleSubpalette); }
protected function compile() { $this->Template->headline = $this->headline; $this->Template->hl = $this->hl; $this->Template->wrapperClass = $this->strWrapperClass; $this->Template->wrapperId = $this->strWrapperId; $this->strFormId = $this->formHybridDataContainer . '_' . $this->id; $strAction = $this->defaultAction ?: \Input::get('act'); $this->arrEditable = deserialize($this->formHybridEditable, true); $this->strToken = $this->strToken ?: \Input::get('token'); // Do not change this order (see #6191) $this->Template->style = !empty($this->arrStyle) ? implode(' ', $this->arrStyle) : ''; $this->Template->class = trim('mod_' . $this->type . ' ' . $this->cssID[1]); $this->Template->cssID = $this->cssID[0] != '' ? ' id="' . $this->cssID[0] . '"' : ''; $this->Template->inColumn = $this->strColumn; if ($this->Template->headline == '') { $this->Template->headline = $this->headline; } if ($this->Template->hl == '') { $this->Template->hl = $this->hl; } if (!empty($this->classes) && is_array($this->classes)) { $this->Template->class .= ' ' . implode(' ', $this->classes); } $this->addDefaultArchive(); // at first check for the correct request token to be set if (!$this->deactivateTokens && !\RequestToken::validate($this->strToken)) { if (!$this->blnSilentMode) { StatusMessage::addError(sprintf($GLOBALS['TL_LANG']['frontendedit']['requestTokenExpired'], Url::replaceParameterInUri(Url::getUrl(), 'token', \RequestToken::get())), $this->id, 'requestTokenExpired'); } return; } if ($this->formHybridAllowIdAsGetParameter) { $intId = \Input::get($this->formHybridIdGetParameter); if (is_numeric($intId)) { $this->intId = $intId; } } $strItemClass = \Model::getClassFromTable($this->formHybridDataContainer); // get id from share if ($strShare = \Input::get('share')) { if (($objItem = $strItemClass::findByShareToken($strShare)) !== null && !FormHybridList::shareTokenExpiredOrEmpty($objItem, time())) { $this->intId = $objItem->id; } } if (!$this->intId) { if (isset($GLOBALS['TL_HOOKS']['frontendEditAddNoIdBehavior']) && is_array($GLOBALS['TL_HOOKS']['frontendEditAddNoIdBehavior'])) { foreach ($GLOBALS['TL_HOOKS']['frontendEditAddNoIdBehavior'] as $arrCallback) { $this->import($arrCallback[0]); if ($this->{$arrCallback}[0]->{$arrCallback}[1]($this) === false) { return; } } } if ($this->noIdBehavior == 'error') { if (!$this->blnSilentMode) { StatusMessage::addError($GLOBALS['TL_LANG']['frontendedit']['noIdFound'], $this->id, 'noidfound'); } return; } elseif ($this->noIdBehavior == 'redirect' || $this->noIdBehavior == 'create_until') { $arrConditions = deserialize($this->existanceConditions, true); if ($this->existanceConditions && !empty($arrConditions)) { $arrColumns = array(); $arrValues = array(); foreach ($arrConditions as $arrCondition) { if (!$arrCondition['field']) { continue; } $arrColumns[] = $arrCondition['field'] . '=?'; $arrValues[] = $this->replaceInsertTags($arrCondition['value']); } if (!empty($arrColumns) && ($objItem = $strItemClass::findOneBy($arrColumns, $arrValues)) !== null) { $this->intId = $objItem->id; } } } if (!$this->intId) { if ($this->noIdBehavior == 'redirect') { if (!$this->blnSilentMode) { StatusMessage::addError($GLOBALS['TL_LANG']['frontendedit']['noIdFound'], $this->id, 'noidfound'); } return; } else { $strFormId = FormHelper::getFormId($this->formHybridDataContainer, $this->id); // get id from FormSession if ($_POST) { if ($intId = FormSession::getSubmissionId($strFormId)) { $this->intId = $intId; } } if (!$this->intId) { // if no id is given a new instance is initiated $objConfiguration = new FormConfiguration($this->arrData); // ajax handling, required in this manor, as we have no real ajax controller in contao and ajax request not related to this module // might trigger this module beforhand and new submission will be created after the submission was transfered to the user and id wont match any more if (Ajax::isRelated(Form::FORMHYBRID_NAME) !== null) { if ($intId = FormSession::getSubmissionId($strFormId)) { $this->intId = $intId; } else { $objConfiguration->forceCreate = true; } } $this->objForm = new $this->strFormClass($objConfiguration, $this->arrSubmitCallbacks, $this->intId ?: 0, $this); if ($intId = $this->objForm->getId()) { $this->intId = $intId; } } } } } // intId is set at this point! if (!$this->checkEntityExists($this->intId)) { if (!$this->blnSilentMode) { StatusMessage::addError($GLOBALS['TL_LANG']['formhybrid_list']['noPermission'], $this->id, 'nopermission'); } if (Ajax::isRelated(Form::FORMHYBRID_NAME)) { $objResponse = new ResponseError(); $objResponse->setResult(StatusMessage::generate($this->id)); $objResponse->output(); } return; } // page title if ($this->setPageTitle) { global $objPage; if (($objItem = General::getModelInstance($this->formHybridDataContainer, $this->intId)) !== null) { $objPage->pageTitle = $objItem->{$this->pageTitleField}; } } if ($strAction == FRONTENDEDIT_ACT_DELETE) { if ($this->checkDeletePermission($this->intId)) { $blnResult = $this->deleteItem($this->intId); if (\Environment::get('isAjaxRequest')) { die($blnResult); } // return to the list \Controller::redirect(Url::removeQueryString(array('act', 'id', 'token'), Url::getUrl())); } else { if (!$this->blnSilentMode) { StatusMessage::addError($GLOBALS['TL_LANG']['formhybrid_list']['noPermission'], $this->id, 'nopermission'); } return; } } else { if ($this->checkUpdatePermission($this->intId)) { // create a new lock if necessary if (in_array('entity_lock', \ModuleLoader::getActive()) && $this->addEntityLock) { if (\HeimrichHannot\EntityLock\EntityLockModel::isLocked($this->formHybridDataContainer, $this->intId, $this)) { $objLock = \HeimrichHannot\EntityLock\EntityLockModel::findActiveLock($this->formHybridDataContainer, $this->intId, $this); $objItem = General::getModelInstance($this->formHybridDataContainer, $this->intId); if (!$this->blnSilentMode) { $strMessage = \HeimrichHannot\EntityLock\EntityLock::generateErrorMessage($this->formHybridDataContainer, $this->intId, $this); if ($this->allowLockDeletion) { $strUnlockForm = $this->generateUnlockForm($objItem, $objLock); $strMessage .= $strUnlockForm; } StatusMessage::addError($strMessage, $this->id, 'locked'); } if ($this->readOnlyOnLocked) { $this->formHybridViewMode = FORMHYBRID_VIEW_MODE_READONLY; $this->formHybridReadonlyTemplate = 'formhybridreadonly_default'; } else { return; } } else { \HeimrichHannot\EntityLock\EntityLockModel::create($this->formHybridDataContainer, $this->intId, $this); } } if ($this->objForm === null) { $this->objForm = new $this->strFormClass(new FormConfiguration($this->arrData), $this->arrSubmitCallbacks, $this->intId, $this); } $this->Template->form = $this->objForm->generate(); $this->Template->item = $this->objForm->activeRecord; if (\Environment::get('isAjaxRequest') && \Input::get('scope') == 'modal') { $objItem = General::getModelInstance($this->formHybridDataContainer, $this->intId); $objModalWrapper = new \FrontendTemplate($this->modalTpl ?: 'formhybrid_reader_modal_bootstrap'); if ($objItem !== null) { $objModalWrapper->setData($objItem->row()); } $objModalWrapper->module = Arrays::arrayToObject($this->arrData); $objModalWrapper->item = $this->replaceInsertTags($this->Template->parse()); die($objModalWrapper->parse()); } } else { if (!$this->blnSilentMode) { StatusMessage::addError($GLOBALS['TL_LANG']['formhybrid_list']['noPermission'], $this->id, 'nopermission'); } return; } } }
/** * @param $strLanguage * @param $varEntity object|array * * @return string */ public static function createSalutation($strLanguage, $varEntity, $blnInformal = false, $blnInformalFirstname = false) { if (is_array($varEntity)) { $varEntity = Arrays::arrayToObject($varEntity); } $blnHasFirstname = $varEntity->firstname; $blnHasLastname = $varEntity->lastname; $blnHasTitle = $varEntity->title && $varEntity->title != '-' && $varEntity->title != 'Titel' && $varEntity->title != 'Title'; if ($strLanguage) { \Controller::loadLanguageFile('default', $strLanguage); } switch ($strLanguage) { case 'en': if ($blnInformal) { if ($blnHasFirstname && $blnInformalFirstname) { return $GLOBALS['TL_LANG']['notification_center_plus']['salutation'] . ' ' . $varEntity->firstname; } elseif ($blnHasLastname && !$blnInformalFirstname) { return $GLOBALS['TL_LANG']['notification_center_plus']['salutation'] . ' ' . $varEntity->lastname; } else { return $GLOBALS['TL_LANG']['notification_center_plus']['salutation']; } } elseif ($blnHasLastname) { if ($blnHasTitle) { $strSalutation = $GLOBALS['TL_LANG']['notification_center_plus']['salutation'] . ' ' . $varEntity->title; } else { $strSalutation = $GLOBALS['TL_LANG']['notification_center_plus']['salutation' . ($varEntity->gender == 'female' ? 'Female' : 'Male')]; } return $strSalutation . ' ' . $varEntity->lastname; } else { return $GLOBALS['TL_LANG']['notification_center_plus']['salutationGeneric']; } break; default: // de if ($blnInformal) { if ($blnHasFirstname && $blnInformalFirstname) { return $GLOBALS['TL_LANG']['notification_center_plus']['salutationGenericInformal'] . ' ' . $varEntity->firstname; } elseif ($blnHasLastname && !$blnInformalFirstname) { return $GLOBALS['TL_LANG']['notification_center_plus']['salutationGenericInformal'] . ' ' . $varEntity->lastname; } else { return $GLOBALS['TL_LANG']['notification_center_plus']['salutationGenericInformal']; } } elseif ($blnHasLastname && !$blnInformal) { $strSalutation = $GLOBALS['TL_LANG']['notification_center_plus']['salutation' . ($varEntity->gender == 'female' ? 'Female' : 'Male')]; if ($blnHasTitle) { $strSalutation .= ' ' . $varEntity->title; } return $strSalutation . ' ' . $varEntity->lastname; } else { return $GLOBALS['TL_LANG']['notification_center_plus']['salutationGeneric']; } break; } }
public function modifyPalette(\DataContainer $objDc, $blnFrontend = false) { // modify palette for backend view, based on archive submissionFields if (!$blnFrontend) { \Controller::loadDataContainer('tl_submission'); $arrDca =& $GLOBALS['TL_DCA']['tl_submission']; if (($objSubmission = \HeimrichHannot\Submissions\SubmissionModel::findByPk($objDc->id)) === null) { return false; } if (($objSubmissionArchive = $objSubmission->getRelated('pid')) === null) { return false; } $arrDca['palettes']['defaultBackup'] = $arrDca['palettes']['default']; $arrSubmissionFields = deserialize($objSubmissionArchive->submissionFields, true); // remove subpalette fields from arrSubmissionFields if (is_array($arrDca['subpalettes'])) { foreach ($arrDca['subpalettes'] as $key => $value) { $arrSubpaletteFields = \HeimrichHannot\FormHybrid\FormHelper::getPaletteFields($objDc->table, $value); if (!is_array($arrSubpaletteFields)) { continue; } $arrSubmissionFields = array_diff($arrSubmissionFields, $arrSubpaletteFields); } } $arrDca['palettes']['default'] = str_replace('submissionFields', implode(',', $arrSubmissionFields), \HeimrichHannot\Submissions\Submissions::PALETTE_DEFAULT); } // overwrite attachment config with archive if (isset($arrDca['fields']['attachments']) && $objSubmissionArchive->addAttachmentConfig) { $arrConfig = Arrays::filterByPrefixes($objSubmissionArchive->row(), array('attachment')); foreach ($arrConfig as $strKey => $value) { $strKey = lcfirst(str_replace('attachment', '', $strKey)); $arrDca['fields']['attachments']['eval'][$strKey] = $value; } } }
protected function setHeaderFields() { if (!$this->addHeaderToExportTable) { return; } $arrFields = array(); foreach (deserialize($this->tableFieldsForExport, true) as $strField) { list($strTable, $strField) = explode('.', $strField); $blnRawField = strpos($strField, EXPORTER_RAW_FIELD_SUFFIX) !== false; $strRawFieldName = str_replace(EXPORTER_RAW_FIELD_SUFFIX, '', $strField); \Controller::loadDataContainer($strTable); \System::loadLanguageFile($strTable); $strFieldName = $GLOBALS['TL_DCA'][$strTable]['fields'][$blnRawField ? $strRawFieldName : $strField]['label'][0]; $strLabel = $strField; if ($this->overrideHeaderFieldLabels && ($arrRow = Arrays::getRowInMcwArray('field', $strField, deserialize($this->headerFieldLabels, true))) !== false) { $strLabel = $arrRow['label']; } elseif ($this->localizeHeader && $strFieldName) { $strLabel = $strFieldName; } $arrFields[$strField] = strip_tags(html_entity_decode($strLabel)) . ($blnRawField ? $GLOBALS['TL_LANG']['MSC']['exporter']['unformatted'] : ''); } if (isset($GLOBALS['TL_HOOKS']['exporter_modifyHeaderFields']) && is_array($GLOBALS['TL_HOOKS']['exporter_modifyXlsHeaderFields'])) { foreach ($GLOBALS['TL_HOOKS']['exporter_modifyHeaderFields'] as $callback) { $objCallback = \System::importStatic($callback[0]); $arrFields = $objCallback->{$callback}[1]($arrFields, $this); } } $this->arrHeaderFields = $arrFields; }
public function setModule(\Model $objModule) { $arrData = \HeimrichHannot\Haste\Util\Arrays::filterByPrefixes($objModule->row(), self::$arrayKeyPrefixes); $this->arrData = is_array($arrData) ? $arrData : $this->arrData; return $this; }
/** * @dataProvider filterByPrefixesProvider * @test */ public function testFilterByPrefixes($arrData, $arrPrefixes, $expectedResult) { $this->assertSame($expectedResult, Arrays::filterByPrefixes($arrData, $arrPrefixes)); }
public function getViewModes() { return array_values(Arrays::filterByPrefixes(get_defined_constants(), array('FORMHYBRID_VIEW_MODE_'))); }
protected function addImage($objItem, $strField, &$arrItem) { if (is_array($objItem)) { $objItem = Arrays::arrayToObject($objItem); } if ($objItem->addImage && $objItem->{$strField} != '') { $objModel = \FilesModel::findByUuid($objItem->{$strField}); if ($objModel === null) { if (!\Validator::isUuid($objItem->{$strField})) { $arrItem['fields']['text'] = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>'; } } elseif (is_file(TL_ROOT . '/' . $objModel->path)) { // Override the default image size if ($this->imgSize != '') { $size = deserialize($this->imgSize); if ($size[0] > 0 || $size[1] > 0) { $arrItem['fields']['size'] = $this->imgSize; } } $arrItem['fields']['singleSRC'] = $objModel->path; $arrItem['fields']['addImage'] = true; // addToImage is done in runBeforeTemplateParsing() } } }