Exemple #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);
             }
         }
     }
 }
Exemple #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);
         }
     }
 }
Exemple #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);
             }
         }
     }
 }
Exemple #4
0
 /**
  * Goes through the lib/handlers directory and loads any found helpers.
  * 
  * @return array The loaded handlers.
  * @access public
  */
 public static function loadHandlers()
 {
     $registry = array();
     if (Factory::$registry === null) {
         $handlers = \Curator\FileSystem::getDirectoryContents(dirname(__FILE__));
         foreach ($handlers as $file_path) {
             $file_info = pathinfo($file_path);
             $file_name = explode('.', $file_info['filename'], 2);
             $file_name = $file_name[0];
             if ($file_name === 'Factory') {
                 continue;
             }
             $class_name = '\\Curator\\Handler\\' . $file_name;
             require_once $file_path;
             $handler_name = $class_name::getName();
             $handler_media = $class_name::getMediaType();
             $handler_extensions = $class_name::getExtensions();
             $registry[$handler_media] = array('name' => $handler_name, 'media_type' => $handler_media, 'class' => $class_name, 'extensions' => $handler_extensions);
         }
     } else {
         $registry = Factory::$registry;
     }
     Factory::$registry = $registry;
     return Factory::$registry;
 }