/** * Gets a merged variant of recipient defined by uid and custom ones. * * @param array list of recipients * @param string given user string of additional recipients * @return array */ public function getRecipientList(array $uidOfRecipients, $additionalRecipients) { $finalRecipients = array(); $recipients = array(); foreach ($uidOfRecipients as $userUid) { $beUserRecord = t3lib_befunc::getRecord('be_users', intval($userUid)); if (is_array($beUserRecord) && $beUserRecord['email'] != '') { $recipients[] = $beUserRecord['email']; } } if ($additionalRecipients != '') { $additionalRecipients = t3lib_div::trimExplode("\n", $additionalRecipients, TRUE); } else { $additionalRecipients = array(); } $allRecipients = array_unique(array_merge($recipients, $additionalRecipients)); foreach ($allRecipients as $recipient) { if (t3lib_div::validEmail($recipient)) { $finalRecipients[] = $recipient; } } return $finalRecipients; }
/** * Make selector box for creating new translation for a record or switching to edit the record in an existing language. * Displays only languages which are available for the current page. * * @param string Table name * @param integer uid for which to create a new language * @param integer pid of the record * @return string <select> HTML element (if there were items for the box anyways...) */ function languageSwitch($table, $uid, $pid = NULL) { global $TCA; $content = ''; $languageField = $TCA[$table]['ctrl']['languageField']; $transOrigPointerField = $TCA[$table]['ctrl']['transOrigPointerField']; // table editable and activated for languages? if ($GLOBALS['BE_USER']->check('tables_modify', $table) && $languageField && $transOrigPointerField && !$TCA[$table]['ctrl']['transOrigPointerTable']) { if (is_null($pid)) { $row = t3lib_befunc::getRecord($table, $uid, 'pid'); $pid = $row['pid']; } // get all avalibale languages for the page $langRows = $this->getLanguages($pid); // page available in other languages than default language? if (is_array($langRows) && count($langRows) > 1) { $rowsByLang = array(); $fetchFields = 'uid,' . $languageField . ',' . $transOrigPointerField; // get record in current language $rowCurrent = t3lib_befunc::getLiveVersionOfRecord($table, $uid, $fetchFields); if (!is_array($rowCurrent)) { $rowCurrent = t3lib_befunc::getRecord($table, $uid, $fetchFields); } $currentLanguage = $rowCurrent[$languageField]; if ($currentLanguage > -1) { // Disabled for records with [all] language! // get record in default language if needed if ($currentLanguage) { $rowsByLang[0] = t3lib_befunc::getLiveVersionOfRecord($table, $rowCurrent[$transOrigPointerField], $fetchFields); if (!is_array($rowsByLang[0])) { $rowsByLang[0] = t3lib_befunc::getRecord($table, $rowCurrent[$transOrigPointerField], $fetchFields); } } else { $rowsByLang[0] = $rowCurrent; } // get record in other languages to see what's already available $translations = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows($fetchFields, $table, 'pid=' . intval($pid) . ' AND ' . $languageField . '>0' . ' AND ' . $transOrigPointerField . '=' . intval($rowsByLang[0]['uid']) . t3lib_BEfunc::deleteClause($table) . t3lib_BEfunc::versioningPlaceholderClause($table)); foreach ($translations as $row) { $rowsByLang[$row[$languageField]] = $row; } $langSelItems = array(); foreach ($langRows as $lang) { if ($GLOBALS['BE_USER']->checkLanguageAccess($lang['uid'])) { $newTranslation = isset($rowsByLang[$lang['uid']]) ? '' : ' [' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.new', 1) . ']'; // create url for creating a localized record if ($newTranslation) { $href = $this->doc->issueCommand('&cmd[' . $table . '][' . $rowsByLang[0]['uid'] . '][localize]=' . $lang['uid'], $this->backPath . 'alt_doc.php?justLocalized=' . rawurlencode($table . ':' . $rowsByLang[0]['uid'] . ':' . $lang['uid']) . '&returnUrl=' . rawurlencode($this->retUrl) . t3lib_BEfunc::getUrlToken('editRecord')); // create edit url } else { $href = $this->backPath . 'alt_doc.php?'; $href .= '&edit[' . $table . '][' . $rowsByLang[$lang['uid']]['uid'] . ']=edit'; $href .= '&returnUrl=' . rawurlencode($this->retUrl) . t3lib_BEfunc::getUrlToken('editRecord'); } $langSelItems[$lang['uid']] = ' <option value="' . htmlspecialchars($href) . '"' . ($currentLanguage == $lang['uid'] ? ' selected="selected"' : '') . '>' . htmlspecialchars($lang['title'] . $newTranslation) . '</option>'; } } // If any languages are left, make selector: if (count($langSelItems) > 1) { $onChange = 'if(this.options[this.selectedIndex].value){window.location.href=(this.options[this.selectedIndex].value);}'; $content = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xml:LGL.language', 1) . ' <select name="_langSelector" onchange="' . htmlspecialchars($onChange) . '"> ' . implode('', $langSelItems) . ' </select>'; } } } } return $content; }
/** * Determine and get the value for the placeholder and return the placeholder attribute * * @param string $table * @param string $field * @param array $config * @param array $row * @return string */ protected function getPlaceholderAttribute($table, $field, array $config, array $row) { $value = trim($config['placeholder']); if (!$value) { return ''; } // Check if we have a reference to another field value from the current record if (substr($value, 0, 6) === '__row|') { $keySegments = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode('|', substr($value, 6)); if (isset($row[$keySegments[0]])) { // First segment (fieldname) exists in the current row $value = $row[$keySegments[0]]; $fieldConf = $GLOBALS['TCA'][$table]['columns'][$keySegments[0]]; if ($fieldConf['config']['type'] === 'group' && $fieldConf['config']['internal_type'] === 'db') { // The field is a relation to another record list($foreignIdentifier, $foreignTitle) = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode('|', $value); // Use the foreign title $value = $foreignTitle; if (!empty($keySegments[1])) { // Use any field in the foreign record list($foreignTable, $foreignUid) = \TYPO3\CMS\Backend\Utility\BackendUtility::splitTable_Uid($foreignIdentifier); $foreignRecord = \t3lib_befunc::getRecord($foreignTable, $foreignUid); if (isset($foreignRecord[$keySegments[1]])) { $value = $foreignRecord[$keySegments[1]]; } } } elseif (!empty($keySegments[1]) && isset($row[$keySegments[0]][$keySegments[1]])) { $value = $row[$keySegments[0]][$keySegments[1]]; } } } // Cleanup the string and support 'LLL:' $value = htmlspecialchars(trim($this->sL($value))); return empty($value) ? '' : ' placeholder="' . $value . '" '; }