public function execute($args = array())
 {
     $this->logger->message('Starting import.', 10);
     try {
         $parser = new ParserController(array('logger' => $this->logger, 'db' => &$this->db, 'import_data_dir' => $this->options['d']));
         // TODO: Do edition stuff
         $edition_args = array();
         $edition_args['edition_option'] = 'existing';
         $edition = $parser->get_current_edition();
         $edition_args['edition'] = $edition->id;
         /*
          * Step through each parser method.
          */
         if ($parser->test_environment() !== FALSE) {
             echo 'Environment test succeeded<br />';
             if ($parser->populate_db() !== FALSE) {
                 $edition_errors = $parser->handle_editions($edition_args);
                 if (count($edition_errors) > 0) {
                     throw new Exception(join("\n", $edition_errors), E_ERROR);
                 } else {
                     $parser->clear_cache();
                     $parser->clear_edition($edition->id);
                     /*
                      * We should only continue if parsing was successful.
                      */
                     if ($parser->parse()) {
                         $parser->build_permalinks();
                         $parser->write_api_key();
                         $parser->export();
                         $parser->generate_sitemap();
                         $parser->index_laws();
                         $parser->structural_stats_generate();
                         $parser->prune_views();
                         $parser->finish_import();
                     }
                 }
             }
         }
         /*
          * Attempt to purge Varnish's cache. (Fails silently if Varnish isn't installed or running.)
          */
         $varnish = new Varnish();
         $varnish->purge();
         $this->logger->message('Done.', 10);
     } catch (Exception $e) {
         exit(1);
     }
 }
Ejemplo n.º 2
0
  * Step through each parser method.
  */
 if ($parser->test_environment() !== FALSE) {
     echo 'Environment test succeeded<br />';
     if ($parser->populate_db() !== FALSE) {
         $edition_errors = $parser->handle_editions($_POST);
         if (count($edition_errors) > 0) {
             $args = $_POST;
             $args['import_errors'] = $edition_errors;
             echo show_admin_forms($args);
         } else {
             $parser->clear_apc();
             /*
              * We should only continue if parsing was successful.
              */
             if ($parser->parse()) {
                 $parser->build_permalinks();
                 $parser->write_api_key();
                 $parser->export();
                 $parser->generate_sitemap();
                 $parser->index_laws();
                 $parser->structural_stats_generate();
                 $parser->prune_views();
             }
         }
     }
 }
 /*
  * Attempt to purge Varnish's cache. (Fails silently if Varnish isn't installed or running.)
  */
 $varnish = new Varnish();