public static function get_files_stat($path, $pattern = null) { $root = \ICanBoogie\DOCUMENT_ROOT; if (!file_exists($path)) { $path = $root . $path; } if (!file_exists($path)) { mkdir($path, 0705, true); if (!file_exists($path)) { return array(0, '<span class="warning">Impossible de créer le dossier : <em>' . \ICanBoogie\strip_root($path) . '</em></span>'); } } if (!is_writable($path)) { return array(0, '<span class="warning">Dossier vérouillé en écriture : <em>' . \ICanBoogie\strip_root($path) . '</em></span>'); } $n = 0; $size = 0; $iterator = new \DirectoryIterator($path); if ($pattern) { $iterator = new \RegexIterator($iterator, $pattern); } foreach ($iterator as $file) { $filename = $file->getFilename(); if ($filename[0] == '.') { continue; } ++$n; $size += $file->getSize(); } return array($n, I18n\t(':count files<br /><span class="small">:size</span>', array(':count' => $n, 'size' => \ICanBoogie\I18n\format_size($size)))); }
/** * Check if the repository folder has been created. */ public function is_installed(Errors $errors) { $path = \ICanBoogie\REPOSITORY . 'thumbnailer'; if (!file_exists($path)) { $errors[$this->id] = new FormattedString('The %directory directory is missing.', array('%directory' => \ICanBoogie\strip_root($path))); } return !count($errors); }
protected function process() { $rc = parent::process(); if ($this->response['infos']) { $path = \ICanBoogie\strip_root($this->file->pathname); // TODO-20110106: compute surface w & h and use them for img in order to avoid poping $this->response['infos'] = '<div class="preview">' . new Thumbnail($path, ['w' => 64, 'h' => 64, 'format' => 'png', 'background' => 'silver,white,medium', 'm' => 'surface']) . '</div>' . $this->response['infos']; } return $rc; }
public function __invoke(Errors $errors) { $pathname = WEBSITE_CONFIG_DIR . 'user.php'; if (file_exists($pathname)) { return; } if (is_writable($pathname)) { file_put_contents($pathname, $data); return; } $errors['user_config'] = t('requirement.user_config.error.create', array('path' => \ICanBoogie\strip_root($pathname))); }
public function __invoke(Errors $errors) { $repository = \ICanBoogie\REPOSITORY; $repository_relative = \ICanBoogie\strip_root($repository); if (file_exists($repository)) { if (!is_writable($repository)) { $errors['repository'] = t('requirement.repository.error.not_writable', array('dir' => $repository_relative)); } } else { $errors['repository'] = t('requirement.repository.error.missing', array('dir' => $repository_relative)); } }