/** * Clean up unwanted stuff. * * @throws EcrExceptionZiper * @return EcrProjectZiper */ private function cleanProject() { $this->logger->log('Starting CleanUp'); $folders = JFolder::folders($this->temp_dir, '.', true, true); $files = JFolder::files($this->temp_dir, '.', true, true); $stdHtmlPath = ECRPATH_EXTENSIONTEMPLATES . DS . 'std' . DS . 'std_index.html'; $cntIndex = 0; $cntAautoCode = 0; if ($this->preset->createIndexhtml) { foreach ($folders as $folder) { if (false == Jfile::exists($folder . DS . 'index.html')) { JFile::copy($stdHtmlPath, $folder . DS . 'index.html'); $cntIndex++; } } $this->logger->log(sprintf('%s index.html files created', $cntIndex)); } if ($this->preset->removeAutocode) { /** * @todo remove AutoCode */ } //-- If we are building a "package package", override the preset settings from the package //-- with the setting from the request. if ($this->preset->includeEcrProjectfile && true == $this->buildopts['include_ecr_projectfile']) { $src = ECRPATH_SCRIPTS . DS . $this->project->getEcrXmlFileName(); if (JFolder::exists($this->temp_dir . DS . 'admin')) { $dst = $this->temp_dir . DS . 'admin' . DS . 'easycreator.xml'; } else { if (JFolder::exists($this->temp_dir . DS . 'site')) { $dst = $this->temp_dir . DS . 'site' . DS . 'easycreator.xml'; } else { $s = JFile::getName($src); if (substr($s, 0, 3) == 'pkg') { //-- EasyCreator project file for packages goes to packageroot.. $dst = $this->temp_dir . DS . 'easycreator.xml'; } else { throw new EcrExceptionZiper(__METHOD__ . ' - Neither admin or site dir found - Failed to copy EasyCreator project xml'); } } } if (false == JFile::copy($src, $dst)) { throw new EcrExceptionZiper(sprintf('%s - %s ⇒ %s Failed to copy EasyCreator project xml', __METHOD__, $src, $dst)); } $this->logger->log('EasyCreator project xml copied'); } //-- Look for unwanted files $unwanted = array('Thumbs.db'); foreach ($files as $file) { foreach ($unwanted as $item) { //-- Simple check if the full path contains an 'unwanted' string if (strpos($file, $item)) { $this->logger->log('Removing unwanted ' . $item . ' at ' . $file); if (false == JFile::delete($file)) { $this->logger->log('Unable to remove ' . $file, 'ERROR'); } } } } //-- Clean up language version files $paths = array('admin/language', 'site/language'); $cnt = 0; foreach ($paths as $path) { if (false == JFolder::exists($this->temp_dir . '/' . $path)) { continue; } $files = JFolder::files($this->temp_dir . '/' . $path, '.', true, true); foreach ($files as $file) { if ('ini' != JFile::getExt($file) && 'html' != JFile::getExt($file)) { if (false == JFile::delete($file)) { throw new EcrExceptionZiper(__METHOD__ . ' - Can not delete language version file: ' . $file); } $cnt++; } } } $this->logger->log(sprintf('%d language version files deleted', $cnt)); return $this; }