/**
  * Generate ColorizeIt options for a revision.
  *
  * @param string $zip_file	Full path to revision zip file
  * @param string $temp_dir	Temporary directory
  * @throws \Exception		Throws exception if zip file does not exist
  * @return array
  */
 public function generate_options($zip_file, $temp_dir)
 {
     if (!@file_exists($zip_file)) {
         throw new \Exception('ERROR_NO_ATTACHMENT');
     }
     $package = new \phpbb\titania\entity\package();
     $package->set_source($zip_file)->set_temp_path($temp_dir, true)->extract();
     $data = $this->get_data($package->get_temp_path());
     $package->cleanup();
     return $data;
 }
 /**
  * Prepare a test directory containing phpBB source files.
  *
  * @param string $version the full phpBB version number.  Ex: 2.0.23, 3.0.1, 3.0.7-pl1
  * @return string Returns the path to the test directory
  */
 public function prepare_phpbb_test_directory($version)
 {
     $version = preg_replace('#[^a-zA-Z0-9\\.\\-]+#', '', $version);
     $phpbb_root = $this->ext_root_path . 'store/extracted/' . $version . '/';
     $phpbb_package = $this->ext_root_path . 'includes/phpbb_packages/phpBB-' . $version . '.zip';
     $package = new \phpbb\titania\entity\package();
     $package->set_temp_path($phpbb_root)->set_source($phpbb_package);
     if (!file_exists($phpbb_root . 'common.php')) {
         if (!$package->source_exists()) {
             $this->errors[] = $this->user->lang('FILE_NOT_EXIST', $phpbb_package);
             return false;
         }
         // Unzip to our temp directory
         $package->extract();
         // Find the phpBB root
         $package_root = $package->find_directory(array('files' => array('required' => 'common.php')));
         // Move it to the correct location
         if ($package_root != '') {
             $package->restore_root($package_root, '');
         }
     }
     return $phpbb_root;
 }