/** * sets informations * * structure: * $infos["typo3RelFile"] = relative path with filename from "absPath" * * @param array informations (see above) * @return void */ public function setVar($informations) { if (!empty($informations['typo3RelFile'])) { $this->typo3RelFile = typo3Lib::fixFilePath($informations['typo3RelFile']); } parent::setVar($informations); }
/** * generates output for management of backups * * @param array meta information data (only the extensions part) * @param string extension path (absolute) * @return string output (HTML code) */ public static function outputManageBackups($metaArray, $extPath) { // generate form $content .= '<input type="hidden" name="submitted" value="1" />'; $content .= '<input type="hidden" name="delete" value="0" />'; $content .= '<input type="hidden" name="restore" value="0" />'; $content .= '<input type="hidden" name="origDiff" value="0" />'; $content .= '<input type="hidden" name="deleteAll" value="0" />'; $content .= '<input type="hidden" name="file" value="" />'; $content .= '<input type="hidden" name="langFile" value="" />'; // begin table $content .= '<table id="tx-lfeditor-table" ' . 'summary="' . $GLOBALS['LANG']->getLL('table.backups') . '">'; // table header $content .= '<thead><tr>'; $content .= '<th class="bgColor5"> ' . $GLOBALS['LANG']->getLL('function.backupMgr.date') . ' </th>'; $content .= '<th class="bgColor5"> ' . $GLOBALS['LANG']->getLL('function.backupMgr.state') . ' </th>'; $content .= '<th class="bgColor5"> ' . $GLOBALS['LANG']->getLL('lang.file.file') . ' </th>'; $content .= '<th id="tx-lfeditor-table-markup1" class="bgColor5">' . '<a href="#" title="' . $GLOBALS['LANG']->getLL('function.backupMgr.deleteAll') . '" ' . 'onclick="submitBackupForm(\'\', \'\', 0, 0, 1, 0);">' . '<img src="../res/images/garbage.gif" alt="' . $GLOBALS['LANG']->getLL('function.backupMgr.delete') . '" /> </a> </th>'; $recover = strtoupper(substr($GLOBALS['LANG']->getLL('function.backupMgr.recover'), 0, 1)); $content .= '<th id="tx-lfeditor-table-markup2">' . $recover . '</th>'; $diff = strtoupper(substr($GLOBALS['LANG']->getLL('function.backupMgr.diff.diff'), 0, 1)); $content .= '<th id="tx-lfeditor-table-markup3">' . $diff . '</th>'; $content .= '</tr></thead>'; // table body $content .= '<tbody>'; $i = 0; $keys = array_keys($metaArray); foreach ($keys as $langFile) { foreach ($metaArray[$langFile] as $filename => $informations) { // get path to filename $backupPath = $informations['pathBackup']; $file = typo3Lib::fixFilePath(PATH_site . '/' . $backupPath . '/' . $filename); $origFile = typo3Lib::fixFilePath($extPath . '/' . $langFile); // check state $content .= '<tr>'; $stateBool = false; if (!is_file($file)) { $state = '<td class="tx-lfeditor-badMarkup bgColor4">' . $GLOBALS['LANG']->getLL('function.backupMgr.missing') . '</td>'; } elseif (!is_file($origFile)) { $state = '<td class="tx-lfeditor-badMarkup bgColor4">' . $GLOBALS['LANG']->getLL('lang.file.missing') . '</td>'; } else { $stateBool = true; $state = '<td class="tx-lfeditor-goodMarkup bgColor4">' . $GLOBALS['LANG']->getLL('function.backupMgr.ok') . '</td>'; } // generate row $content .= '<td class="bgColor4">' . date('Y-m-d<b\\r />H:i:s', $informations['createdAt']) . '</td>'; $content .= $state; $content .= '<td class="bgColor4">' . $langFile . '</td>'; // delete $name = $GLOBALS['LANG']->getLL('function.const.delete.delete'); $content .= '<td class="bgColor4"> <a href="#" title="' . $name . '" ' . 'onclick="submitBackupForm(\'' . $filename . '\', \'' . $langFile . '\', ' . '1, 0, 0, 0);"> <img src="../res/images/garbage.gif" title="' . $name . '" ' . 'alt="' . $name . '" /> </a> </td>'; // restore/diff if ($stateBool) { $name = $GLOBALS['LANG']->getLL('function.backupMgr.recover'); $content .= '<td class="bgColor4"> <a href="#" title="' . $name . '" ' . 'onclick="submitBackupForm(\'' . $filename . '\', \'' . $langFile . '\', ' . '0, 1, 0, 0);"> <img src="../res/images/recover.gif" title="' . $name . '" ' . 'alt="' . $name . '" /> </a> </td>'; $name = $GLOBALS['LANG']->getLL('function.backupMgr.diff.diff'); $content .= '<td class="bgColor4"> <a href="#" title="' . $name . '" ' . 'onclick="submitBackupForm(\'' . $filename . '\', \'' . $langFile . '\', ' . '0, 0, 0, 1);"> <img src="../res/images/diff.gif" title="' . $name . '" ' . 'alt="' . $name . '" /> </a> </td>'; $content .= '</tr>'; } else { $content .= '<td class="bgColor4">[-]</td><td class="bgColor4">[-]</td>'; } } } $content .= '</tbody></table>'; return $content; }
/** * sets informations * * structure: * $infos["metaFile"] = absolute path to the meta file (includes filename) * $infos["extPath"] = extension path * $infos["langFile"] = language file * * @param array informations (see above) * @return void */ public function setVar($informations) { if (!empty($informations['metaFile'])) { $this->metaFile = typo3Lib::fixFilePath($informations['metaFile']); } if (!empty($informations['extPath'])) { $this->extPath = typo3Lib::fixFilePath($informations['extPath']); $this->extName = basename($informations['extPath']); } if (!empty($informations['langFile'])) { $this->langFile = typo3Lib::fixFilePath($informations['langFile']); } parent::setVar($informations); }
/** * code for output generation of function "backupMgr" * * @throws LFException raised if meta array is empty (no backup files) * @return string generated html content */ private function outputFuncBackupMgr() { // get vars $filename = t3lib_div::_POST('file'); $origDiff = t3lib_div::_POST('origDiff'); $extPath = $this->MOD_SETTINGS['extList']; // get output $metaArray = $this->backupObj->getMetaInfos(2); if (!count($metaArray)) { throw new LFException('failure.backup.noFiles', 1); } $content = tx_lfeditor_mod1_template::outputManageBackups($metaArray, $extPath); if ($origDiff) { // set backup file $metaArray = $this->backupObj->getMetaInfos(3); $informations = array('absPath' => typo3Lib::fixFilePath(PATH_site . '/' . $metaArray[$filename]['pathBackup']), 'relFile' => $filename); $this->backupObj->setVar($informations); // exec diff try { // read original file $this->initFileObject($this->backupObj->getVar('langFile'), PATH_site . '/' . $this->backupObj->getVar('extPath'), $this->MOD_SETTINGS['wsList']); // read backup file $this->backupObj->readFile(); // get language data $origLang = $this->fileObj->getLocalLangData(); $backupLocalLang = $this->backupObj->getLocalLangData(); // get meta data $origMeta = $this->fileObj->getMetaData(); $backupMeta = $this->backupObj->getMetaData(); $diff = tx_lfeditor_mod1_functions::getBackupDiff(0, $origLang, $backupLocalLang); $metaDiff = tx_lfeditor_mod1_functions::getMetaDiff(0, $origMeta, $backupMeta); } catch (LFException $e) { return $e->getMessage() . $content; } } // generate diff if (is_array($diff)) { $content .= tx_lfeditor_mod1_template::outputManageBackupsDiff($diff, $metaDiff, $this->fileObj->getLocalLangData(), $this->backupObj->getLocalLangData(), $this->fileObj->getOriginLangData(), $this->backupObj->getOriginLangData(), $this->fileObj->getMetaData(), $this->backupObj->getMetaData()); } return $content; }
/** * checks the localLang array to find localized version of the language * (checks l10n directory too) * * @param string language content (only one language) * @param string language shortcut * @return string localized file (absolute) */ protected function getLocalizedFile($content, $langKey) { try { $file = typo3Lib::transTypo3File($content, true); } catch (Exception $e) { if (!($file = t3lib_div::llXmlAutoFileName($this->absFile, $langKey))) { return $content; } $file = PATH_site . $file; if (!is_file($file)) { return $content; } } return typo3Lib::fixFilePath($file); }
/** * converts an absolute or relative typo3 style (EXT:) file path * * @throws Exception raised, if the conversion fails * @param string absolute file or an typo3 relative file (EXT:) * @param boolean generate to relative(false) or absolute file * @return string converted file path */ public static function transTypo3File($file, $mode) { $extType['local'] = typo3Lib::pathLocalExt; $extType['global'] = typo3Lib::pathGlobalExt; $extType['system'] = typo3Lib::pathSysExt; // relative to absolute if ($mode) { if (strpos($file, 'EXT:') === false) { throw new Exception('no typo3 relative path "' . $file . '"'); } $cleanFile = sgLib::trimPath('EXT:', $file); foreach ($extType as $type) { $path = typo3Lib::fixFilePath(PATH_site . '/' . $type . '/' . $cleanFile); if (is_dir(dirname($path))) { return $path; } } throw new Exception('cant convert typo3 relative file "' . $file . '"'); } else { foreach ($extType as $type) { if (strpos($file, $type) === false) { continue; } return 'EXT:' . sgLib::trimPath($type, sgLib::trimPath(PATH_site, $file)); } throw new Exception('cant convert absolute file "' . $file . '"'); } }
/** * sets informations * * structure: * $infos["absPath"] = absolute path to an extension or file * $infos["relFile"] = relative path with filename from "absPath" * $infos["workspace"] = workspace (base or xll) * $infos["fileType"] = file type (php or xml) * $infos["localLang"] = language data * $infos["originLang"] = origin language array * $infos["meta"] = meta data * * @param array informations (see above) * @return void */ public function setVar($informations) { // path and file informations if (!empty($informations['absPath'])) { $this->absPath = typo3Lib::fixFilePath($informations['absPath'] . '/'); } if (!empty($informations['relFile'])) { $this->relFile = typo3Lib::fixFilePath($informations['relFile']); } $this->absFile = $this->absPath . $this->relFile; // filetype and workspace if (!empty($informations['workspace'])) { $this->workspace = $informations['workspace']; } if (!empty($informations['fileType'])) { $this->fileType = $informations['fileType']; } // data arrays if (!count($this->localLang) && is_array($informations['localLang'])) { $this->localLang = $informations['localLang']; } if (!count($this->originLang) && is_array($informations['originLang'])) { $this->originLang = $informations['originLang']; } if (!count($this->meta) && is_array($informations['meta'])) { $this->meta = $informations['meta']; } }
/** * checks the given content, if its a localized language file reference * * @param mixed language content (only one language) * @param string language shortcut * @return string localized file (absolute) or a boolean false */ protected function getLocalizedFile($content, $langKey) { if ((string) $content != 'EXT') { return ''; } return typo3Lib::fixFilePath(dirname($this->absFile) . '/' . $this->nameLocalizedFile($langKey)); }