function processDatamap_postProcessFieldArray($status, $table, $id, $fieldArray, $tce) { if ($table === 'tx_dam' and $fieldArray['language']) { // the hotlist will be updated only if the field changed, because only then it's in the $fieldArray tx_staticinfotables_div::updateHotlist('static_languages', $fieldArray['language'], 'lg_iso_2', 'dam'); } }
function processDatamap_postProcessFieldArray($status, $table, $id, $fieldArray, &$pObj) { if ($table == 'sys_language' and $fieldArray['static_lang_isocode']) { // the hotlist will be updated only if the field changed, because only then it's in the $fieldArray tx_staticinfotables_div::updateHotlist('static_languages', $fieldArray['static_lang_isocode'], 'uid'); } }
function __getItemsStaticTable($sTable, $sValueField = 'uid', $sWhere = '') { // Get user language if (TYPO3_MODE == 'FE') { $sLang = $GLOBALS['TSFE']->lang; } else { $sLang = $GLOBALS['LANG']->lang; } // Get field names $aFieldNames = tx_staticinfotables_div::getTCAlabelField($sTable, TRUE, $sLang); $sFields = implode(', ', $aFieldNames); // Get data from static table $aRows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows($sValueField . ', ' . $sFields, $sTable, $sWhere, '', $sFields); $aItems = array(); if (empty($aRows)) { return $aItems; } // For each row foreach ($aRows as $aRow) { foreach ($aFieldNames as $sFieldName) { if ($aRow[$sFieldName]) { // If exists $sCaption = $aRow[$sFieldName]; break; } } $aTmp = array('caption' => $sCaption, 'value' => $aRow[$sValueField]); array_push($aItems, $aTmp); } return $aItems; }
/** * performs the service processing * * @param string Content which should be processed. * @param string Content type * @param array Configuration array * @return boolean */ function process($content = '', $type = '', $conf = array()) { $this->conf = $conf; $this->out = array(); $this->out['fields'] = array(); $this->exif = array(); if ($content) { $this->setInput($content, $type); } if ($inputFile = $this->getInputFile()) { $cmd = t3lib_exec::getCommand($this->info['exec']) . ' -q -m -g -S ' . escapeshellarg($inputFile); $exif = $ret = NULL; exec($cmd, $exif, $ret); if (!$ret and is_array($exif)) { $section = 'EXIF'; array_shift($exif); // ---- ExifTool ---- array_shift($exif); // ExifToolVersion : 6.57 foreach ($exif as $line) { if (preg_match('#---- ([^ ]*) ----#', $line, $matches)) { $section = $matches[1]; } // Only request 2 elements because exiftool output contains colons in $value list($name, $value) = explode(':', $line, 2); $name = trim($name); $value = trim($value); if ($value) { // ignore empty lines headers and empty entries $name = str_replace('-', '', $name); $name = str_replace(' ', '', $name); // add to exif table $this->exif[$section][$name] = $value; // add to DAM table switch ($name) { case 'CameraModel': $this->out['fields']['file_creator'] = $value; break; case 'XResolution': case 'HorizontalResolution': $this->out['fields']['hres'] = intval($value); break; case 'YResolution': case 'VerticalResolution': $this->out['fields']['vres'] = intval($value); break; case 'Title': case 'Headline': case 'XPTitle': $this->out['fields']['title'] = $value; break; case 'Keywords': case 'XPKeywords': $this->out['fields']['keywords'] = $value; break; case 'Subject': case 'ImageDescription': case 'Description': $this->out['fields']['description'] = $value; break; case 'CaptionAbstract': $this->out['fields']['caption'] = $value; break; case 'ModifyDate': $this->out['fields']['date_mod'] = tx_svmetaextract_lib::parseDate($value); $this->out['fields']['file_mtime'] = tx_svmetaextract_lib::parseDate($value); break; case 'ImageCreated': case 'CreateDate': case 'DateTimeOriginal': $this->out['fields']['date_cr'] = tx_svmetaextract_lib::parseDate($value); $this->out['fields']['file_ctime'] = tx_svmetaextract_lib::parseDate($value); break; case 'CreatorTool': case 'Software': $this->out['fields']['file_creator'] = $value; break; case 'City': $this->out['fields']['loc_city'] = $value; break; case 'Country': // TODO format? # $this->out['fields']['loc_country'] = $value; break; case 'CountryCode': if (strlen($value) == 2) { $isoCodeField = tx_staticinfotables_div::getIsoCodeField('static_countries', $value); $enableFields = t3lib_BEfunc::deleteClause('static_countries'); $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('cn_iso_3', 'static_countries', $isoCodeField . '=' . $GLOBALS['TYPO3_DB']->fullQuoteStr(strtoupper($value), 'static_countries') . $enableFields); if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $this->out['fields']['loc_country'] = $row['cn_iso_3']; } } break; case 'Artist': case 'Creator': $this->out['fields']['creator'] = $value; break; case 'Copyright': case 'CopyrightNotice': $this->out['fields']['copyright'] = $value; break; case 'Rights': $this->out['fields']['copyright'] = $value; break; case 'RightsUsageTerms': case 'UsageTerms': $this->out['fields']['instructions'] = $value; break; case 'Credit': $this->out['fields']['copyright'] = $value; break; case 'Instructions': $this->out['fields']['instructions'] = $value; break; } } } } // TODO read XMP XML // $this->out['fields']['meta']['XMP_XML'] = $this->xmpRaw; unset($this->exif['File']); unset($this->exif['Composite']); $this->postProcess(); $this->out['fields']['meta'] = $this->exif; $this->out['exif_done'] = true; $this->out['iptc_done'] = true; $this->out['xmp_done'] = true; } else { $this->errorPush(T3_ERR_SV_NO_INPUT, 'No or empty input.'); } return $this->getLastError(); }
/** * Getting all languages into an array * where the key is the ISO alpha-2 code of the language * and where the value are the name of the language in the current language * Note: we exclude sacred and constructed languages * * @return array An array of names of languages */ function getLanguages() { $where = '1=1'; $table = 'static_languages'; $lang = tx_staticinfotables_div::getCurrentLanguage(); $nameArray = array(); $titleFields = tx_staticinfotables_div::getTCAlabelField($table, TRUE, $lang); $prefixedTitleFields = array(); foreach ($titleFields as $titleField) { $prefixedTitleFields[] = $table . '.' . $titleField; } $labelFields = implode(',', $prefixedTitleFields); // Restrict to certain languages if (is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.']['language.']) && isset($this->thisConfig['buttons.']['language.']['restrictToItems'])) { $languageList = implode("','", t3lib_div::trimExplode(',', $GLOBALS['TYPO3_DB']->fullQuoteStr(strtoupper($this->thisConfig['buttons.']['language.']['restrictToItems']), $table))); $where .= ' AND ' . $table . '.lg_iso_2 IN (' . $languageList . ')'; } $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($table . '.lg_iso_2,' . $table . '.lg_country_iso_2,' . $labelFields, $table, $where . ' AND lg_constructed = 0 ' . ($this->htmlAreaRTE->is_FE() ? $GLOBALS['TSFE']->sys_page->enableFields($table) : t3lib_BEfunc::BEenableFields($table) . t3lib_BEfunc::deleteClause($table))); $prefixLabelWithCode = !$this->thisConfig['buttons.']['language.']['prefixLabelWithCode'] ? false : true; $postfixLabelWithCode = !$this->thisConfig['buttons.']['language.']['postfixLabelWithCode'] ? false : true; while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $code = strtolower($row['lg_iso_2']) . ($row['lg_country_iso_2'] ? '-' . strtoupper($row['lg_country_iso_2']) : ''); foreach ($titleFields as $titleField) { if ($row[$titleField]) { $nameArray[$code] = $prefixLabelWithCode ? $code . ' - ' . $row[$titleField] : ($postfixLabelWithCode ? $row[$titleField] . ' - ' . $code : $row[$titleField]); break; } } } $GLOBALS['TYPO3_DB']->sql_free_result($res); if ($this->htmlAreaRTE->is_FE()) { $GLOBALS['TSFE']->csConvObj->convArray($nameArray, $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['static_info_tables']['charset'], $this->htmlAreaRTE->OutputCharset); } else { $GLOBALS['LANG']->csConvObj->convArray($nameArray, $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['static_info_tables']['charset'], $GLOBALS['LANG']->charSet); } uasort($nameArray, 'strcoll'); return $nameArray; }
/** * Getting all languages into an array * where the key is the ISO alpha-2 code of the language * and where the value are the name of the language in the current language * Note: we exclude sacred and constructed languages * * @return array An array of names of languages * @todo Define visibility */ public function getLanguages() { $nameArray = array(); if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('static_info_tables')) { $where = '1=1'; $table = 'static_languages'; $lang = \tx_staticinfotables_div::getCurrentLanguage(); $titleFields = \tx_staticinfotables_div::getTCAlabelField($table, TRUE, $lang); $prefixedTitleFields = array(); foreach ($titleFields as $titleField) { $prefixedTitleFields[] = $table . '.' . $titleField; } $labelFields = implode(',', $prefixedTitleFields); // Restrict to certain languages if (is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.']['language.']) && isset($this->thisConfig['buttons.']['language.']['restrictToItems'])) { $languageList = implode('\',\'', \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_DB']->fullQuoteStr(strtoupper($this->thisConfig['buttons.']['language.']['restrictToItems']), $table))); $where .= ' AND ' . $table . '.lg_iso_2 IN (' . $languageList . ')'; } $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($table . '.lg_iso_2,' . $table . '.lg_country_iso_2,' . $labelFields, $table, $where . ' AND lg_constructed = 0 ' . ($this->htmlAreaRTE->is_FE() ? $GLOBALS['TSFE']->sys_page->enableFields($table) : \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($table) . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($table))); $prefixLabelWithCode = !$this->thisConfig['buttons.']['language.']['prefixLabelWithCode'] ? FALSE : TRUE; $postfixLabelWithCode = !$this->thisConfig['buttons.']['language.']['postfixLabelWithCode'] ? FALSE : TRUE; while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $code = strtolower($row['lg_iso_2']) . ($row['lg_country_iso_2'] ? '-' . strtoupper($row['lg_country_iso_2']) : ''); foreach ($titleFields as $titleField) { if ($row[$titleField]) { $nameArray[$code] = $prefixLabelWithCode ? $code . ' - ' . $row[$titleField] : ($postfixLabelWithCode ? $row[$titleField] . ' - ' . $code : $row[$titleField]); break; } } } $GLOBALS['TYPO3_DB']->sql_free_result($res); uasort($nameArray, 'strcoll'); } return $nameArray; }
/** * Function to use in own TCA definitions * Adds additional select items * * items reference to the array of items (label,value,icon) * config The config array for the field. * TSconfig The "itemsProcFunc." from fieldTSconfig of the field. * table Table name * row Record row * field Field name * * @param array itemsProcFunc data array: * @return void The $items array may have been modified */ function selectItemsTCA ($params) { global $TCA; $where = ''; $config = &$params['config']; $table = $config['itemsProcFunc_config']['table']; $tcaWhere = $config['itemsProcFunc_config']['where']; if ($tcaWhere) { $where = tx_staticinfotables_div::replaceMarkersInSQL($tcaWhere, $params['table'], $params['row']); } if ($table) { $indexField = $config['itemsProcFunc_config']['indexField']; $indexField = $indexField ? $indexField : 'uid'; $lang = strtolower(tx_staticinfotables_div::getCurrentLanguage()); $titleFields = tx_staticinfotables_div::getTCAlabelField($table, TRUE, $lang); $prefixedTitleFields = array(); foreach ($titleFields as $titleField) { $prefixedTitleFields[] = $table.'.'.$titleField; } $fields = $table.'.'.$indexField.','.implode(',', $prefixedTitleFields); if ($config['itemsProcFunc_config']['prependHotlist']) { $limit = $config['itemsProcFunc_config']['hotlistLimit']; $limit = $limit ? $limit : '8'; $app = $config['itemsProcFunc_config']['hotlistApp']; $app = $app ? $app : TYPO3_MODE; $res = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query( $fields, $table, 'tx_staticinfotables_hotlist', '', // $foreign_table 'AND tx_staticinfotables_hotlist.tablenames='.$GLOBALS['TYPO3_DB']->fullQuoteStr($table,'tx_staticinfotables_hotlist').' AND tx_staticinfotables_hotlist.application='.$GLOBALS['TYPO3_DB']->fullQuoteStr($app,'tx_staticinfotables_hotlist'), '', 'tx_staticinfotables_hotlist.sorting DESC', // $orderBy $limit ); $cnt = 0; $rows = array(); while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { foreach ($titleFields as $titleField) { if ($row[$titleField]) { $rows[$row[$indexField]] = $row[$titleField]; break; } } $cnt++; } $GLOBALS['TYPO3_DB']->sql_free_result($res); if (!isset($config['itemsProcFunc_config']['hotlistSort']) || $config['itemsProcFunc_config']['hotlistSort']) { asort ($rows); } foreach ($rows as $index => $title) { $params['items'][] = array($title, $index, ''); $cnt++; } if($cnt && !$config['itemsProcFunc_config']['hotlistOnly']) { $params['items'][] = array('--------------', '', ''); } } // Set ORDER BY: $orderBy = $titleFields[0]; if(!$config['itemsProcFunc_config']['hotlistOnly']) { $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fields, $table, '1=1'.$where.t3lib_BEfunc::deleteClause($table), '', $orderBy); while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { foreach ($titleFields as $titleField) { if ($row[$titleField]) { $params['items'][] = array($row[$titleField], $row[$indexField], ''); break; } } } $GLOBALS['TYPO3_DB']->sql_free_result($res); } } }
/** * Returns the default country as localized string. * * @return string the default country's localized name, will be empty if there is no default country */ private function getDefaultCountry() { $defaultCountryCode = tx_oelib_ConfigurationRegistry::get('plugin.tx_staticinfotables_pi1')->getAsString('countryCode'); if ($defaultCountryCode === '') { return ''; } $this->initStaticInfo(); if (class_exists('SJBR\\StaticInfoTables\\Utility\\LocalizationUtility', TRUE)) { $currentLanguageCode = Tx_Oelib_ConfigurationRegistry::get('config')->getAsString('language'); $identifiers = array('iso' => $defaultCountryCode); $result = \SJBR\StaticInfoTables\Utility\LocalizationUtility::getLabelFieldValue($identifiers, 'static_countries', $currentLanguageCode, TRUE); } else { $result = tx_staticinfotables_div::getTitleFromIsoCode('static_countries', $defaultCountryCode, $this->staticInfo->getCurrentLanguage(), TRUE); } return $result; }
/** * performs the service processing * * @param string Content which should be processed. * @param string Content type * @param array Configuration array * @return boolean */ function process($content = '', $type = '', $conf = array()) { $this->conf = $conf; $this->out = array(); if ($content) { $this->setInput($content, $type); } if ($inputFile = $this->getInputFile() and $jpeg_header_data = get_jpeg_header_data($inputFile)) { $this->xmpRaw = get_XMP_text($jpeg_header_data); preg_match('#<x:xmpmeta[^>]*>.*</x:xmpmeta>#is', $this->xmpRaw, $match); $this->xmpRaw = $match[0]; $this->xmp = parseXMP2simpleArray(read_XMP_array_from_text($this->xmpRaw)); foreach ($this->xmp as $key => $value) { // ignore empty lines headers and emtpy entries if ($value) { switch (strtolower($key)) { case 'dc:creator': $this->out['fields']['creator'] = tx_svmetaextract_lib::forceUtf8($value); break; case 'dc:description': $this->out['fields']['description'] = tx_svmetaextract_lib::forceUtf8($value); break; case 'dc:rights': $this->out['fields']['copyright'] = tx_svmetaextract_lib::forceUtf8($value); break; case 'dc:subject': $this->out['fields']['keywords'] = tx_svmetaextract_lib::forceUtf8($value); break; case 'dc:title': $this->out['fields']['title'] = tx_svmetaextract_lib::forceUtf8($value); break; case 'iptc4xmpcore:countrycode': if (strlen($value) == 2) { $select = 'cn_iso_3'; $table = 'static_countries'; $where = tx_staticinfotables_div::getIsoCodeField($table, $value) . '=' . $GLOBALS['TYPO3_DB']->fullQuoteStr(strtoupper($value), 'static_countries'); $where .= t3lib_BEfunc::deleteClause($table); $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $table, $where); if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $this->out['fields']['loc_country'] = $row['cn_iso_3']; } } break; case 'iptc4xmpcore:location': $value = trim($value); if ($value[0] == '/' or $value[0] == '\\') { $this->out['fields']['file_orig_location'] = tx_svmetaextract_lib::forceUtf8($value); } else { $this->out['fields']['loc_desc'] = tx_svmetaextract_lib::forceUtf8($value); } break; case 'xmp:createdate': $this->out['fields']['date_cr'] = tx_svmetaextract_lib::parseDate($value); break; case 'xmp:creatortool': $this->out['fields']['file_creator'] = tx_svmetaextract_lib::forceUtf8($value); break; case 'xmp:modifydate': $this->out['fields']['date_mod'] = tx_svmetaextract_lib::parseDate($value); break; case 'xap:createdate': $this->out['fields']['date_cr'] = tx_svmetaextract_lib::parseDate($value); break; case 'xap:creatortool': $this->out['fields']['file_creator'] = tx_svmetaextract_lib::forceUtf8($value); break; case 'xap:modifydate': $this->out['fields']['date_mod'] = tx_svmetaextract_lib::parseDate($value); break; case 'xaprights:copyright': $this->out['fields']['copyright'] = tx_svmetaextract_lib::forceUtf8($value); break; case 'xaprights:usageterms': $this->out['fields']['instructions'] = tx_svmetaextract_lib::forceUtf8($value); break; case 'xmptpg:npages': $this->out['fields']['pages'] = tx_svmetaextract_lib::forceUtf8($value); break; case 'pdf:keywords': $this->out['fields']['keywords'] = tx_svmetaextract_lib::forceUtf8($value); break; case 'pdf:producer': $this->out['fields']['file_creator'] = tx_svmetaextract_lib::forceUtf8($value); break; case 'photoshop:captionwriter': $this->out['fields']['photoshop:captionwriter'] = tx_svmetaextract_lib::forceUtf8($value); break; case 'photoshop:city': $this->out['fields']['loc_city'] = tx_svmetaextract_lib::forceUtf8($value); break; case 'photoshop:credit': $this->out['fields']['copyright'] = tx_svmetaextract_lib::forceUtf8($value); break; case 'photoshop:headline': $this->out['fields']['title'] = tx_svmetaextract_lib::forceUtf8($value); break; case 'photoshop:instructions': $this->out['fields']['instructions'] = tx_svmetaextract_lib::forceUtf8($value); break; } } } $this->out['fields']['meta']['xmp'] = $this->xmp; $this->out['fields']['meta']['xmp_xml'] = $this->xmpRaw; } else { $this->errorPush(T3_ERR_SV_NO_INPUT, 'No or empty input.'); } return $this->getLastError(); }
/** * Returns the current language as iso-2-alpha code * * @return string 'DE', 'EN', 'DK', ... */ function getCurrentLanguage() { global $TSFE, $TYPO3_DB; $rc = tx_staticinfotables_div::getCurrentLanguage(); return $rc; }