/** * removes the meta information entry and the backup file * * @throws LFException raised if the backup or meta file cant be written * @param string file name * @param string extension Name (default = $this->extName) * @param string language file (default = $this->langFile) * @return void */ public function deleteSpecFile($filename, $extName = '', $langFile = '') { // get needed meta informations $extName = empty($extName) ? $this->extName : $extName; $langFile = empty($langFile) ? $this->langFile : $langFile; $metaArray = $this->getMetaInfos(3, $extName, '', $langFile); // check backup file if (!isset($metaArray[$filename])) { throw new LFException('failure.backup.notDeleted'); } // get file $backupPath = $metaArray[$filename]['pathBackup']; $file = t3lib_div::fixWindowsFilePath(PATH_site . '/' . $backupPath . '/' . $filename); // build new meta information file unset($metaArray[$filename]); if (!count($metaArray)) { unset($metaArray); } $this->setMetaInfos($metaArray, 3, $extName, '', $langFile); $extMetaArray = $this->getMetaInfos(2, $extName); if (!count($extMetaArray)) { unset($extMetaArray); } $this->setMetaInfos($extMetaArray, 2, $extName); // write meta information try { $this->writeMetaFile(); } catch (LFException $e) { throw $e; } // delete backup file try { sgLib::deleteFiles(array($file)); } catch (Exception $e) { throw new LFException('failure.backup.notDeleted', 0, '(' . $e->getMessage(), ')'); } }
/** * executes writing of language files * * @throws LFException raised if file couldnt be written or some param criterias arent correct * @param array changes (constants with empty values will be deleted) * @param array meta changes (indexes with empty values will be deleted) * @param boolean set to true if you want delete default constants * @return void */ private function execWrite($modArray, $modMetaArray = array(), $forceDel = false) { // checks if (!is_array($modArray)) { throw new LFException('failure.file.notWritten'); } // execute backup try { if ($this->extConfig['execBackup']) { $this->execBackup(); } } catch (LFException $e) { throw $e; } // set new language data foreach ($modArray as $langKey => $data) { if (is_array($data)) { foreach ($data as $const => $value) { $this->fileObj->setLocalLangData($const, $value, $langKey, $forceDel); } } } // set changed meta data foreach ($modMetaArray as $metaIndex => $metaValue) { $this->fileObj->setMetaData($metaIndex, $metaValue); } // write new language data try { $this->fileObj->writeFile(); } catch (LFException $e) { throw $e; } // delete possible language files $absFile = $this->fileObj->getVar('absFile'); $originLang = $this->fileObj->getOriginLangData(); unset($emptyFiles); foreach ($originLang as $lang => $origin) { if ($origin == $absFile || !is_file($origin)) { continue; } $langData = $this->fileObj->getLocalLangData($lang); if (is_array($langData) && !count($langData)) { $emptyFiles[] = $origin; } } // delete all empty language files try { if (is_array($emptyFiles)) { sgLib::deleteFiles($emptyFiles); } } catch (Exception $e) { throw new LFException('failure.langfile.notDeleted', 0, '(' . $e->getMessage() . ')'); } // reinitialize fileobject try { $this->initFileObject($this->MOD_SETTINGS['langFileList'], $this->MOD_SETTINGS['extList'], $this->MOD_SETTINGS['wsList']); } catch (LFException $e) { throw $e; } }