Exemplo n.º 1
0
 /**
  * Clean the stylesheet files from public_html/styles.
  * 
  * @access public
  */
 public function clean()
 {
     $dir = $this->project->getPublicStylesDirPath();
     $files = \Curator\FileSystem::getDirectoryContents($dir, array('directories' => false));
     foreach ($files as $path) {
         $rel_path = str_replace($this->project->getProjectDirPath() . DS, '', $path);
         if (file_exists($path)) {
             \Curator\Console::stdout('  Deleting ' . $rel_path);
             if (!unlink($path)) {
                 throw new \Exception('Could not delete: ' . $path);
             }
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Clean the media files from public_html.
  * 
  * @access public
  */
 public function clean()
 {
     foreach ($this->config['directories'] as $dirname) {
         $dir_path = $this->project->getPublicMediaDirPath() . DS . $dirname;
         $rel_path = str_replace($this->project->getProjectDirPath() . DS, '', $dir_path);
         \Curator\Console::stdout(' Cleaning ' . $rel_path);
         $dir_contents = \Curator\FileSystem::getDirectoryContents($dir_path);
         foreach ($dir_contents as $file_path) {
             $filename = pathinfo($file_path, PATHINFO_BASENAME);
             $rel_path = str_replace($this->project->getProjectDirPath() . DS, '', $file_path);
             \Curator\Console::stdout('  Deleting ' . $rel_path);
             unlink($file_path);
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Clean the data files from public_html.
  * 
  * @access public
  */
 public function clean()
 {
     // Get our cast of characters.
     $data_dir = $this->project->getDataDirPath();
     $data_files = \Curator\FileSystem::getDirectoryContents($data_dir);
     foreach ($data_files as $data_file) {
         // Gather our facts here.
         $data_info = pathinfo($data_file);
         $data_ext = $data_info['extension'];
         $data_rel = str_replace($this->project->getProjectDirPath() . DS, '', $data_file);
         // relative from the project dir.
         $data_media = \Curator\Handler\Factory::getMediaTypeForFileExtension($data_ext);
         // load the data file.
         $handler = \Curator\Handler\Factory::getHandlerForMediaType($data_media);
         $data = $handler->input($data_file);
         // See if the file specifies a special name, otherwise hack
         // together something resembling the data's filename.
         if (isset($data['header']['url'])) {
             $filename = $data['header']['url'];
         } else {
             $filename = pathinfo($data_file, PATHINFO_FILENAME) . '.html';
         }
         $output_path = $this->project->getPublicHtmlDirPath() . DS . $filename;
         if (file_exists($output_path)) {
             \Curator\Console::stdout('  Deleting public_html' . DS . $filename);
             if (!unlink($output_path)) {
                 throw new \Exception('Could not delete: ' . $output_path);
             }
         }
     }
 }
Exemplo n.º 4
0
 /**
  * Cleans the current project.
  * 
  * @access public
  */
 public function clean()
 {
     $manifest_path = $this->getProjectDirPath() . DS . 'manifest.yml';
     if (!is_file($manifest_path)) {
         throw new \Exception('Could not locate manifest at: ' . $manifest_path);
     }
     $manifest = \Curator\Config\YAML::LoadFromFile($manifest_path);
     \Curator\Console::stdout('Project Directory: ' . $this->getProjectDirPath());
     \Curator\Console::stdout('');
     $builder = new \Curator\Builder\Styles();
     $builder->setProject($this);
     \Curator\Console::stdout(' Cleaning styles…');
     $builder->clean();
     \Curator\Console::stdout('');
     $builder = new \Curator\Builder\Scripts();
     $builder->setProject($this);
     \Curator\Console::stdout(' Cleaning scripts…');
     $builder->clean();
     \Curator\Console::stdout('');
     $builder = new \Curator\Builder\Data();
     $builder->setProject($this);
     \Curator\Console::stdout(' Cleaning data…');
     $builder->clean();
     \Curator\Console::stdout('');
     $builder = new \Curator\Builder\Media();
     $builder->setProject($this);
     \Curator\Console::stdout(' Cleaning media…');
     $builder->clean();
     \Curator\Console::stdout('');
 }