function main() { $feUserObj = tslib_eidtools::initFeUser(); // Initialize FE user object tslib_eidtools::connectDB(); //Connect to database $table = 'tx_drwiki_pages'; $myPid = intval(t3lib_div::_GET('myPid')); $myKeyword = $GLOBALS['TYPO3_DB']->fullQuoteStr(trim(t3lib_div::_GET('myKeyword')), $table); $myKeyword = substr($myKeyword, 1, strlen($myKeyword) - 2); $searchString = $table . ".pid IN (" . $myPid . ") AND keyword like '%" . $myKeyword . "%'"; // get Database entries $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', $table, $searchString); $results = array(); while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $results[$row["uid"]] = $row["keyword"]; } // Wir geben der Anfrage ein XML Objekt zurŸck $ajax_return_data = t3lib_div::array2xml($results); header('Expires: Mon, 26 Jul 2000 03:00:00 GMT'); header('Last-Modified: ' . gmdate("D, d M Y H:i:s") . 'GMT'); header('Cache-Control: no-cache, must-revalidate'); header('Pragma: no-cache'); header('Content-Length: ' . strlen($ajax_return_data)); header('Content-Type: text/xml'); echo $ajax_return_data; }
function getSingleField_beforeRender($table, $field, &$row, &$PA) { global $TCA; if ($table == 'tx_caretaker_instance' && $field === 'testconfigurations') { switch ($PA['fieldConf']['config']['tag']) { case 'testconfigurations.test_service': /* * / if (count($PA['fieldConf']['config']['items']) != count($TCA['tx_caretaker_test']['columns']['test_service']['config']['items'])) { t3lib_div::loadTCA('tx_caretaker_test'); $PA['fieldConf']['config']['items'] = $TCA['tx_caretaker_test']['columns']['test_service']['config']['items']; } // */ break; case 'testconfigurations.test_conf': $test = $this->getFFValue($table, $row, $field, str_replace('test_conf', 'test_service', $PA['itemFormElName'])); // get related test configuration $testrow = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid,test_service,test_conf', 'tx_caretaker_test', 'uid=' . intval($test) . t3lib_BEfunc::deleteClause('tx_caretaker_test')); $row['test_service'] = $testrow[0]['test_service']; if ($PA['itemFormElValue'] == NULL) { $PA['itemFormElValue'] = $testrow[0]['test_conf']; } if (is_array($PA['itemFormElValue'])) { $PA['itemFormElValue'] = t3lib_div::array2xml($PA['itemFormElValue']); } if (!is_array($PA['fieldConf']['config']['ds'])) { t3lib_div::loadTCA('tx_caretaker_test'); $PA['fieldConf']['config']['ds'] = $TCA['tx_caretaker_test']['columns']['test_conf']['config']['ds']; } // var_dump($PA['fieldConf']['config']['ds']); /* * / $row['test_service'] = $test; if (!is_array($PA['fieldConf']['config']['ds'])) { t3lib_div::loadTCA('tx_caretaker_test'); $PA['fieldConf']['config']['ds'] = $TCA['tx_caretaker_test']['columns']['test_conf']['config']['ds']; } // FIXME $PA['itemFormElValue']=''; // */ break; } } }
/** * Writing database structure * * @return void */ function xmlDB_writeStructure() { t3lib_div::writeFile($this->DBdir . '_STRUCTURE.xml', t3lib_div::array2xml($this->DBstructure, '', 0, 'T3xmlDBStructure', 0, array('useIndexTagForNum' => 'item'))); }
/** * Creates language-overlay for records in general (where translation is found in records from the same table) * * @param string Table name * @param array Record to overlay. Must containt uid, pid and $table]['ctrl']['languageField'] * @param integer Pointer to the sys_language uid for content on the site. * @param string Overlay mode. If "hideNonTranslated" then records without translation will not be returned un-translated but unset (and return value is false) * @return mixed Returns the input record, possibly overlaid with a translation. But if $OLmode is "hideNonTranslated" then it will return false if no translation is found. */ function getRecordOverlay($table, $row, $sys_language_content, $OLmode = '') { //echo $table.'--'.$row['uid'].'--'.$sys_language_content.'--'.$OLmode; //echo '<hr>'; //return parent::getRecordOverlay($table,$row,$sys_language_content,$OLmode); global $TCA; //echo $row['uid'].'-'; //39348 //unset olmode $OLmode = ''; // die('���'); //call service to know if element is visible and which overlay language to use try { $element = tx_languagevisibility_feservices::getElement($row['uid'], $table); $overlayLanguage = tx_languagevisibility_feservices::getOverlayLanguageIdForElement($element, $sys_language_content); } catch (Exception $e) { //for any other tables: return parent::getRecordOverlay($table, $row, $sys_language_content, $OLmode); } //debug($overlayLanguage); if ($overlayLanguage === false) { //echo 'unset '.$table.' / '.$row['uid']; //not visible: unset($row); return $row; } else { //visible: if ($overlayLanguage != 0) { if ($element instanceof tx_languagevisibility_fceelement) { //for FCE the overlay processing is handled by templavoila module, so mark the row with additional infos: $languageRep = t3lib_div::makeInstance('tx_languagevisibility_languagerepository'); $overlayLanguageObj = $languageRep->getLanguageById($overlayLanguage); $row['_OVERLAYLANGUAGEISOCODE'] = $overlayLanguageObj->getIsoCode(); return $row; } elseif ($element instanceof tx_languagevisibility_fceoverlayelement) { //now its getting tricky: we need to return overlay record with merged XML $olrow = $this->_getDatabaseTranslationOverlayRecord('tt_content', $row, $overlayLanguage); if ($GLOBALS['TSFE']) { $GLOBALS['TSFE']->includeTCA('tt_content'); } //parse fce xml, and where a xml field is empty in olrow -> use default one $flexObj = t3lib_div::makeInstance('t3lib_flexformtools'); $this->_callbackVar_defaultXML = t3lib_div::xml2array($row['tx_templavoila_flex']); $this->_callbackVar_overlayXML = t3lib_div::xml2array($olrow['tx_templavoila_flex']); if (!is_array($this->_callbackVar_overlayXML)) { $this->_callbackVar_overlayXML = array(); } $return = $flexObj->traverseFlexFormXMLData('tt_content', 'tx_templavoila_flex', $row, $this, '_callback_checkXMLFieldsForFallback'); $row = parent::getRecordOverlay($table, $row, $overlayLanguage, $OLmode); $row['tx_templavoila_flex'] = t3lib_div::array2xml($this->_callbackVar_overlayXML); return $row; } else { //for default elements just do TYPO3 default overlay return parent::getRecordOverlay($table, $row, $overlayLanguage, $OLmode); } } else { return $row; } } }
/** * Update flexform * * This function updates the flexform data with the selected TS * object. If the flexform data does not exist, the function * creates it. * * @param $object The TS object path * @return Void */ function updateData($object) { // Get current record $record = t3lib_BEfunc::getRecord($this->P['table'], $this->P['uid']); // Get flexform data $flex = $record['pi_flexform']; // Check if data exsists if ($flex) { // Convert XML data to an array $flexArray = t3lib_div::xml2array($flex); // Update data $flexArray['data']['sDEF']['lDEF']['object']['vDEF'] = $object; } else { // Create new array $flexArray = array('data' => array('sDEF' => array('lDEF' => array('object' => array('vDEF' => $object))))); } // XML Declaration $flexData = '<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?' . '>'; // Add new data $flexData .= chr(10) . t3lib_div::array2xml($flexArray, '', 0, 'T3FlexForms'); // Update database $GLOBALS['TYPO3_DB']->exec_UPDATEquery($this->P['table'], 'uid=' . $this->P['uid'], array('pi_flexform' => $flexData)); }
/** * Creates XML string from input array * * @return string XML content */ function createXML() { // Options: $options = array('alt_options' => array('/header' => array('disableTypeAttrib' => TRUE, 'clearStackPath' => TRUE, 'parentTagMap' => array('files' => 'file', 'records' => 'table', 'table' => 'rec', 'rec:rels' => 'relations', 'relations' => 'element', 'filerefs' => 'file', 'pid_lookup' => 'page_contents', 'header:relStaticTables' => 'static_tables', 'static_tables' => 'tablename', 'excludeMap' => 'item', 'softrefCfg' => 'softrefExportMode', 'extensionDependencies' => 'extkey', 'softrefs' => 'softref_element'), 'alt_options' => array('/pagetree' => array('disableTypeAttrib' => TRUE, 'useIndexTagForNum' => 'node', 'parentTagMap' => array('node:subrow' => 'node')), '/pid_lookup/page_contents' => array('disableTypeAttrib' => TRUE, 'parentTagMap' => array('page_contents' => 'table'), 'grandParentTagMap' => array('page_contents/table' => 'item')))), '/records' => array('disableTypeAttrib' => TRUE, 'parentTagMap' => array('records' => 'tablerow', 'tablerow:data' => 'fieldlist', 'tablerow:rels' => 'related', 'related' => 'field', 'field:itemArray' => 'relations', 'field:newValueFiles' => 'filerefs', 'field:flexFormRels' => 'flexform', 'relations' => 'element', 'filerefs' => 'file', 'flexform:db' => 'db_relations', 'flexform:file' => 'file_relations', 'flexform:softrefs' => 'softref_relations', 'softref_relations' => 'structurePath', 'db_relations' => 'path', 'file_relations' => 'path', 'path' => 'element', 'keys' => 'softref_key', 'softref_key' => 'softref_element'), 'alt_options' => array('/records/tablerow/fieldlist' => array('useIndexTagForAssoc' => 'field'))), '/files' => array('disableTypeAttrib' => TRUE, 'parentTagMap' => array('files' => 'file')))); // Creating XML file from $outputArray: $charset = $this->dat['header']['charset'] ? $this->dat['header']['charset'] : 'iso-8859-1'; $XML = '<?xml version="1.0" encoding="' . $charset . '" standalone="yes" ?>' . LF; $XML .= t3lib_div::array2xml($this->dat, '', 0, 'T3RecordDocument', 0, $options); return $XML; }
/** * Converts a PHP array into an XML string. * The XML output is optimized for readability since associative keys are used as tagnames. * This also means that only alphanumeric characters are allowed in the tag names AND only keys NOT starting with numbers (so watch your usage of keys!). However there are options you can set to avoid this problem. * Numeric keys are stored with the default tagname "numIndex" but can be overridden to other formats) * The function handles input values from the PHP array in a binary-safe way; All characters below 32 (except 9,10,13) will trigger the content to be converted to a base64-string * The PHP variable type of the data IS preserved as long as the types are strings, arrays, integers and booleans. Strings are the default type unless the "type" attribute is set. * The output XML has been tested with the PHP XML-parser and parses OK under all tested circumstances. * However using MSIE to read the XML output didn't always go well: One reason could be that the character encoding is not observed in the PHP data. The other reason may be if the tag-names are invalid in the eyes of MSIE. Also using the namespace feature will make MSIE break parsing. There might be more reasons... * Usage: 5 * * @param array The input PHP array with any kind of data; text, binary, integers. Not objects though. * @param string tag-prefix, eg. a namespace prefix like "T3:" * @param integer Current recursion level. Don't change, stay at zero! * @param string Alternative document tag. Default is "phparray". * @param integer If set, the number of spaces corresponding to this number is used for indenting, otherwise a single chr(9) (TAB) is used * @param array Options for the compilation. Key "useNindex" => 0/1 (boolean: whether to use "n0, n1, n2" for num. indexes); Key "useIndexTagForNum" => "[tag for numerical indexes]"; Key "useIndexTagForAssoc" => "[tag for associative indexes"; Key "parentTagMap" => array('parentTag' => 'thisLevelTag') * @param string Stack data. Don't touch. * @return string An XML string made from the input content in the array. * @see xml2array() */ function array2xml($array, $NSprefix = '', $level = 0, $docTag = 'phparray', $spaceInd = 0, $options = array(), $stackData = array()) { // The list of byte values which will trigger binary-safe storage. If any value has one of these char values in it, it will be encoded in base64 $binaryChars = chr(0) . chr(1) . chr(2) . chr(3) . chr(4) . chr(5) . chr(6) . chr(7) . chr(8) . chr(11) . chr(12) . chr(14) . chr(15) . chr(16) . chr(17) . chr(18) . chr(19) . chr(20) . chr(21) . chr(22) . chr(23) . chr(24) . chr(25) . chr(26) . chr(27) . chr(28) . chr(29) . chr(30) . chr(31); // Set indenting mode: $indentChar = $spaceInd ? ' ' : chr(9); $indentN = $spaceInd > 0 ? $spaceInd : 1; // Init output variable: $output = ''; // Traverse the input array if (is_array($array)) { foreach ($array as $k => $v) { $attr = ''; $tagName = $k; // Construct the tag name. if (isset($options['grandParentTagMap'][$stackData['grandParentTagName'] . '/' . $stackData['parentTagName']])) { // Use tag based on grand-parent + parent tag name $attr .= ' index="' . htmlspecialchars($tagName) . '"'; $tagName = (string) $options['grandParentTagMap'][$stackData['grandParentTagName'] . '/' . $stackData['parentTagName']]; } elseif (isset($options['parentTagMap'][$stackData['parentTagName'] . ':' . $tagName])) { // Use tag based on parent tag name + current tag $attr .= ' index="' . htmlspecialchars($tagName) . '"'; $tagName = (string) $options['parentTagMap'][$stackData['parentTagName'] . ':' . $tagName]; } elseif (isset($options['parentTagMap'][$stackData['parentTagName']])) { // Use tag based on parent tag name: $attr .= ' index="' . htmlspecialchars($tagName) . '"'; $tagName = (string) $options['parentTagMap'][$stackData['parentTagName']]; } elseif (!strcmp(intval($tagName), $tagName)) { // If integer...; if ($options['useNindex']) { // If numeric key, prefix "n" $tagName = 'n' . $tagName; } else { // Use special tag for num. keys: $attr .= ' index="' . $tagName . '"'; $tagName = $options['useIndexTagForNum'] ? $options['useIndexTagForNum'] : 'numIndex'; } } elseif ($options['useIndexTagForAssoc']) { // Use tag for all associative keys: $attr .= ' index="' . htmlspecialchars($tagName) . '"'; $tagName = $options['useIndexTagForAssoc']; } // The tag name is cleaned up so only alphanumeric chars (plus - and _) are in there and not longer than 100 chars either. $tagName = substr(ereg_replace('[^[:alnum:]_-]', '', $tagName), 0, 100); // If the value is an array then we will call this function recursively: if (is_array($v)) { // Sub elements: if ($options['alt_options'][$stackData['path'] . '/' . $tagName]) { $subOptions = $options['alt_options'][$stackData['path'] . '/' . $tagName]; $clearStackPath = $subOptions['clearStackPath']; } else { $subOptions = $options; $clearStackPath = FALSE; } $content = chr(10) . t3lib_div::array2xml($v, $NSprefix, $level + 1, '', $spaceInd, $subOptions, array('parentTagName' => $tagName, 'grandParentTagName' => $stackData['parentTagName'], 'path' => $clearStackPath ? '' : $stackData['path'] . '/' . $tagName)) . str_pad('', ($level + 1) * $indentN, $indentChar); $attr .= ' type="array"'; } else { // Just a value: // Look for binary chars: if (strcspn($v, $binaryChars) != strlen($v)) { // Go for base64 encoding if the initial segment NOT matching any binary char has the same length as the whole string! // If the value contained binary chars then we base64-encode it an set an attribute to notify this situation: $content = chr(10) . chunk_split(base64_encode($v)); $attr .= ' base64="1"'; } else { // Otherwise, just htmlspecialchar the stuff: $content = htmlspecialchars($v); $dType = gettype($v); if ($dType != 'string' && !$options['disableTypeAttrib']) { $attr .= ' type="' . $dType . '"'; } } } // Add the element to the output string: $output .= str_pad('', ($level + 1) * $indentN, $indentChar) . '<' . $NSprefix . $tagName . $attr . '>' . $content . '</' . $NSprefix . $tagName . '>' . chr(10); } } // If we are at the outer-most level, then we finally wrap it all in the document tags and return that as the value: if (!$level) { $output = '<' . $docTag . '>' . chr(10) . $output . '</' . $docTag . '>'; } return $output; }
/** * Adds a series of fields at the given position. The fields will be created * by special configurations. * * @param array $funcConf configuration array for a single configuration * @param array $markerArray An array with marker => value pairs * @return void */ public function addFields($funcConf, $markerArray = array()) { // get the data switch (strtolower((string) $funcConf['source'])) { case 'condition': // The data is got from the field the condition checks $data = $this->conditionData; break; case 'field': $data = $this->getFieldData($funcConf['source_config'], $markerArray); break; case 'db': // The data is fetched from the database // we got the configuration in the 'source_config' array // the values are: table, select, where $handling = $funcConf['source_config']; preg_match_all('/###(.[^#]*)###/i', $handling['where'], $whereMarker); $whereMarkerCount = count($whereMarker[0]); for ($index = 0; $index < $whereMarkerCount; $index++) { $handling['where'] = str_replace($whereMarker[0][$index], $this->ceFields[$whereMarker[1][$index]], $handling['where']); } /** @var t3lib_db $database */ $database = $GLOBALS['TYPO3_DB']; $data = $database->exec_SELECTgetRows($handling['select'], $handling['table'], $handling['where'], $handling['groupby'], $handling['orderby'], $handling['limit']); break; case '': $data = array('empty'); break; default: $data = (string) $funcConf['source']; } // leave here if source was set but no data was found if (empty($data) && isset($funcConf['source'])) { return; } if (isset($funcConf['source_type'])) { switch (strtolower((string) $funcConf['source_type'])) { case 'csl': // The data is a comma separated list $data = explode(',', $data); break; case 'int': $data = range(1, intval($data)); break; case 'db_row': $data = array($data); break; case 'entry_count': default: } } // get the sourcedata from a flexform datastructure if no config is given if (!isset($funcConf['source_config']) && !empty($formConf['source'])) { $tcaDataArray = t3lib_div::xml2array($this->getDataFromTCAByPath($funcConf['source_config']['handling']['TCApath'])); $xmlDataArray = $this->getDataByPath($tcaDataArray, $funcConf['source_config']['handling']['XMLpath']); // get the keys for sequencing the fields $keys = array_keys($xmlDataArray); // build the basic configuration $config = array('inside' => $funcConf['source_config']['path'], 'data' => ''); // cycle through all fields of the source content element // in every cycle the name of the field is appended by _X where X is // the uid of the dataset in the table foreach ($data as $uid) { // rename all keys if (!is_array($keys)) { continue; } $theData = array(); foreach ($keys as $key) { $singleData = $xmlDataArray[$key]; $theData[$key . '_' . $uid] = $singleData; } // write the xml structure into the configuration $config['data'] = t3lib_div::array2xml($theData); // Add the element $this->addStaticXML($config); // unset the insertion data unset($theData); } } else { // we got a config $fConfA = $funcConf['field_config']; if (isset($fConfA['config'])) { $fConfA = array($fConfA); } $funcDataArray = array(); $baseConfig = array('path' => $funcConf['path']); foreach ($data as $count => $fieldData) { if (empty($fieldData)) { continue; } $dataArray = array('row' => $fieldData, 'dfConfig' => $funcConf); $funcDataArray[] = $dataArray; if (!is_array($fConfA)) { continue; } $fIndex = 0; foreach ($fConfA as $confKey => $fConf) { $aConfig = $baseConfig; if ($confKey === 'singleUserFunc') { // The fieldconfig should be created by a userfunction, so we call it here $aConfig = t3lib_div::callUserFunction($fConf, $dataArray, $aConfig); } else { // otherwise the fieldconfig has to be created by dynaflex if (isset($fConf['label_offset']) && is_integer($fConf['label_offset'])) { $labelIndex = $count + intval($fConf['label_offset']); } else { $labelIndex = $count; } $fConf['label'] = $this->getLabel($fConf['label'], array('###DATA###' => $fieldData, '###FINDEX###' => $labelIndex)); // set some basics $aConfig['name'] = $fConf['name']; $aConfig['label'] = $fConf['label']; $aConfig['config'] = $fConf['config']; // add the data to the fieldconfig (this is useful for userfields inside of // an flexform in the case some of the data is needed for further processing $aConfig['config']['data'] = $fieldData; // replace all markers in title and label // make special handling of ###FINDEX### and ###DATA### if (is_array($fieldData)) { $fieldData['DATA'] = $fIndex; } else { $fieldData = array(); $fieldData['DATA'] = $aConfig['config']['data']; } $fieldData['FINDEX'] = $count; $this->callbackValues = $fieldData; $aConfig['name'] = preg_replace_callback('/###(.[^#]*)###/i', array($this, 'replaceMarker'), $aConfig['name']); $aConfig['label'] = preg_replace_callback('/###(.[^#]*)###/i', array($this, 'replaceMarker'), $aConfig['label']); $aConfig['config']['foreign_table_where'] = preg_replace_callback('/###(.[^#]*)###/i', array($this, 'replaceMarker'), $aConfig['config']['foreign_table_where']); } if (!$aConfig) { continue; } if ($aConfig['multi'] == TRUE) { // a multifield configuration was returned if (is_array($aConfig['fields'])) { foreach ($aConfig['fields'] as $fieldConfig) { $this->replaceAndAdd($fieldConfig, $markerArray); } } } else { $this->replaceAndAdd($aConfig, $markerArray); } if (is_array($funcConf['modifications'])) { $this->handleModifications($funcConf['modifications'], array('###FINDEX###' => $fIndex)); } $fIndex++; } } if (isset($funcConf['allUserFunc'])) { $fieldConfigs = t3lib_div::callUserFunction($funcConf['allUserFunc'], $funcDataArray, $baseConfig); foreach ($fieldConfigs as $fieldConfig) { $this->addField($fieldConfig); } } } }
/** * Makes a context-free xml-string from an array. * * @return string */ function flattenarray($array, $pfx = '') { if (!is_array($array)) { if (is_string($array)) return $array; else return ''; } return str_replace("<>\n", '', str_replace("</>", '', t3lib_div::array2xml($array,'',-1,'',0,array('useCDATA' => 1)))); }
/** * Creates llXML string from input array * * @param array locallang-XML array * @return string XML content */ function createXML($outputArray) { // Options: $options = array('parentTagMap' => array('data' => 'languageKey', 'orig_hash' => 'languageKey', 'orig_text' => 'languageKey', 'labelContext' => 'label', 'languageKey' => 'label')); // Creating XML file from $outputArray: $XML = '<?xml version="1.0" encoding="utf-8" standalone="yes" ?>' . chr(10); $XML .= t3lib_div::array2xml($outputArray, '', 0, 'T3locallang', 0, $options); return $XML; }
/** * Convert FlexForm data array to XML * * @param array Array to output in <T3FlexForms> XML * @param boolean If set, the XML prologue is returned as well. * @return string XML content. */ function flexArray2Xml($array, $addPrologue = FALSE) { if ($GLOBALS['TYPO3_CONF_VARS']['BE']['flexformForceCDATA']) { $this->flexArray2Xml_options['useCDATA'] = 1; } $options = $GLOBALS['TYPO3_CONF_VARS']['BE']['niceFlexFormXMLtags'] ? $this->flexArray2Xml_options : array(); $spaceInd = $GLOBALS['TYPO3_CONF_VARS']['BE']['compactFlexFormXML'] ? -1 : 4; $output = t3lib_div::array2xml($array, '', 0, 'T3FlexForms', $spaceInd, $options); if ($addPrologue) { $output = '<?xml version="1.0" encoding="' . $GLOBALS['LANG']->charSet . '" standalone="yes" ?>' . LF . $output; } return $output; }
/** * prepares the final Content * * @return string prepared content (xml) */ private function prepareBackupContent() { // convert all values to utf-8 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] != 'utf-8') { $localLang = typo3Lib::utf8($this->localLang, true, array('default')); } else { $localLang = $this->localLang; } // set meta $phpArray['meta'] = $this->meta; // set array foreach ($this->originLang as $lang => $origin) { // set origin try { $phpArray['data'][$lang]['meta']['origin'] = typo3Lib::transTypo3File($origin, false); } catch (Exception $e) { $phpArray['data'][$lang]['meta']['origin'] = substr($origin, strlen(PATH_site)); } // set data if (is_array($localLang[$lang])) { foreach ($localLang[$lang] as $labelKey => $labelVal) { $phpArray['data'][$lang]['langData'][$labelKey] = $labelVal; } } } // define assocTagNames $options['parentTagMap'] = array('data' => 'languageKey', 'langData' => 'label'); // get xml return t3lib_div::array2xml($phpArray, '', 0, 'LFBackup', 0, $options); }
/** * converts the array to a xml string * * @param array php structure with data * @param string name of first tag * @return string xml content */ private function array2xml($phpArray, $firstTag) { // define assocTagNames $options['parentTagMap'] = array('data' => 'languageKey', 'languageKey' => 'label'); // get xml $xmlString = t3lib_div::array2xml($phpArray, '', 0, $firstTag, 0, $options); return $this->getXMLHeader() . $xmlString; }
/** * * @param unknown_type $table * @param unknown_type $row * @param unknown_type $sys_language_content * @param unknown_type $OLmode * @param t3lib_pageSelect $parent * @return void */ public function getRecordOverlay_postProcess($table, &$row, &$sys_language_content, $OLmode, t3lib_pageSelect $parent) { if (!is_array($row) || !isset($row['uid']) || $sys_language_content == 0) { return; } try { $element = tx_languagevisibility_feservices::getElement($row['uid'], $table); $overlayLanguage = tx_languagevisibility_feservices::getOverlayLanguageIdForElement($element, $sys_language_content); } catch (Exception $e) { return; } if ($element instanceof tx_languagevisibility_fceelement) { //for FCE the overlay processing is handled by templavoila module, so mark the row with additional infos: $languageRep = t3lib_div::makeInstance('tx_languagevisibility_languagerepository'); $overlayLanguageObj = $languageRep->getLanguageById($overlayLanguage); $row['_OVERLAYLANGUAGEISOCODE'] = $overlayLanguageObj->getIsoCode(); } elseif ($element instanceof tx_languagevisibility_fceoverlayelement) { //now its getting tricky: we need to return overlay record with merged XML $row['tx_templavoila_flex'] = $row['_ORIG_tx_templavoila_flex']; unset($row['_ORIG_tx_templavoila_flex']); $olrow = $this->_getDatabaseTranslationOverlayRecord('tt_content', $row, $overlayLanguage); if ($GLOBALS['TSFE']) { $GLOBALS['TSFE']->includeTCA('tt_content'); } //parse fce xml, and where a xml field is empty in olrow -> use default one $flexObj = t3lib_div::makeInstance('t3lib_flexformtools'); $this->_callbackVar_defaultXML = t3lib_div::xml2array($row['tx_templavoila_flex']); $this->_callbackVar_overlayXML = t3lib_div::xml2array($olrow['tx_templavoila_flex']); if (!is_array($this->_callbackVar_overlayXML)) { $this->_callbackVar_overlayXML = array(); } $return = $flexObj->traverseFlexFormXMLData('tt_content', 'tx_templavoila_flex', $row, $this, '_callback_checkXMLFieldsForFallback'); if ($sys_language_content != $overlayLanguage) { $row = $parent->getRecordOverlay($table, $row, $overlayLanguage, $OLmode); } $row['tx_templavoila_flex'] = t3lib_div::array2xml($this->_callbackVar_overlayXML); } }
/** * Returns a serialized setup * * @param mixed Any extra data that should be stored with the setup * @param boolean If set the setup will returned as array and not serialized * @return string serialized setup */ function serializeSetup($extraSetup = '', $serializeData = true) { $setup = array('pid' => $this->pid, 'pathlist' => $this->pathlist, 'recursive' => $this->recursive, 'ruleConf' => $this->ruleConf, 'dataPreset' => $this->dataPreset, 'dataPostset' => $this->dataPostset, 'dataAppend' => $this->dataAppend, 'dryRun' => $this->dryRun, 'doReindexing' => $this->doReindexing, 'collectMeta' => $this->collectMeta, 'extraSetup' => $extraSetup); if ($this->writeDevLog) { t3lib_div::devLog('serializeSetup', 'tx_dam_indexing', 0, $setup); } return $serializeData ? t3lib_div::array2xml($setup) : $setup; }
/** * Processing of the submitted form; Will create and write the XML file and tell the new file name. * * @param string Absolute path to the locallang.php file to convert. * @param string The new file name to write to (absolute path, .xml ending). The locallang-xml file is in UTF-8 * @return string HTML text string message */ function renderSaveDone($phpFile, $newFileName) { // Initialize variables: $outputArray = array(); $formContent = t3lib_div::_POST('_DAT'); $LOCAL_LANG = $this->getLLarray($phpFile); $LOCAL_LANG = $this->convertLLarrayToUTF8($LOCAL_LANG); // Setting meta data: $outputArray['meta'] = $formContent['meta']; // Setting label context dummy tags: $outputArray['meta']['labelContext'] = array(); /* foreach($LOCAL_LANG['default'] as $labelKey => $labelValue) { $outputArray['meta']['labelContext'][$labelKey] = ''; } */ // Setting data content: $outputArray['data'] = $LOCAL_LANG; // Setting orig-hash/content foreach ($LOCAL_LANG as $langKey => $labelsArray) { $outputArray['orig_hash'][$langKey] = array(); $outputArray['orig_text'][$langKey] = array(); foreach ($labelsArray as $labelKey => $_temp) { $outputArray['orig_hash'][$langKey][$labelKey] = t3lib_div::md5int($LOCAL_LANG['default'][$labelKey]); #$outputArray['orig_text'][$langKey][$labelKey] = $LOCAL_LANG['default'][$labelKey]; } } // Options: $options = array('parentTagMap' => array('data' => 'languageKey', 'orig_hash' => 'languageKey', 'orig_text' => 'languageKey', 'labelContext' => 'label', 'languageKey' => 'label')); // Creating XML file from $outputArray: $XML = '<?xml version="1.0" encoding="utf-8" standalone="yes" ?>' . chr(10); $XML .= t3lib_div::array2xml($outputArray, '', 0, 'T3locallang', 4, $options); if (!file_exists($newFileName)) { # debug(array($XML)); t3lib_div::writeFile($newFileName, $XML); return 'File written to disk: ' . $newFileName; } }