/** * Installs a zip file from the passed directory. * * @todo This is theme-specific - it really ought to be moved to the page_theme_archive class, at least most it. * * @param string $zipfile * @param bool $inplace Set to false if $file should be moved to the temporary directory before working on it, set to true if it's already in the temp directory. * * @return string Returns the base directory into which the zipfile was unzipped */ protected function install($file, $inplace = false) { if (!$inplace) { $directory = $this->uploadZipToTemp($file); } else { $directory = $file; } $dir = $this->unzip($directory); $dirFull = $this->getArchiveDirectory($dir); $dirBase = substr(strrchr($dirFull, '/'), 1); if (file_exists($this->targetDirectory . '/' . $dirBase)) { throw new Exception(t('The directory %s already exists. Perhaps this item has already been installed.', $this->targetDirectory . '/' . $dirBase)); } else { $this->f->copyAll($dirFull, $this->targetDirectory . '/' . $dirBase); if (!is_dir($this->targetDirectory . '/' . $dirBase)) { throw new Exception(t('Unable to copy directory %s to %s. Perhaps permissions are set incorrectly or the target directory does not exist.', $dirBase, $this->targetDirectory)); } } return $dirBase; }
/** * Retrieves an array of NewsflowSlotItems * @return NewsflowSlotItem[]|null */ public function getSlotContents() { if ($this->slots === null) { $fileService = new File(); $appVersion = Config::get('concrete.version'); $cfToken = Marketplace::getSiteToken(); $url = Config::get('concrete.urls.newsflow') . Config::get('concrete.urls.paths.newsflow_slot_content'); $path = $url . '?cfToken=' . rawurlencode($cfToken) . '&appVersion=' . $appVersion; $response = $fileService->getContents($path); $nsi = new NewsflowSlotItem(); $this->slots = $nsi->parseResponse($response); } return $this->slots; }
/** * @dataProvider splitFilenameDataProvider */ public function testSplitFilename($full, $splitted) { $this->assertSame($splitted, $this->fileHelper->splitFilename($full)); }
public function make_directories() { // Delete generated overrides and doctrine $fh = new File(); if (is_dir(DIR_CONFIG_SITE . '/generated_overrides')) { $fh->removeAll(DIR_CONFIG_SITE . '/generated_overrides'); } if (is_dir(Config::get('database.proxy_classes'))) { $fh->removeAll(Config::get('database.proxy_classes')); } if (!is_dir(Config::get('concrete.cache.directory'))) { mkdir(Config::get('concrete.cache.directory'), Config::get('concrete.filesystem.permissions.directory')); chmod(Config::get('concrete.cache.directory'), Config::get('concrete.filesystem.permissions.directory')); } if (!is_dir(DIR_FILES_UPLOADED_STANDARD . REL_DIR_FILES_INCOMING)) { mkdir(DIR_FILES_UPLOADED_STANDARD . REL_DIR_FILES_INCOMING, Config::get('concrete.filesystem.permissions.directory')); chmod(DIR_FILES_UPLOADED_STANDARD . REL_DIR_FILES_INCOMING, Config::get('concrete.filesystem.permissions.directory')); } }