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); } }
<a href="http://docs.statedecoded.com/">the documentation</a> to confirm that you have everything <a href="http://docs.statedecoded.com/installation.html">installed</a> and <a href="http://docs.statedecoded.com/config.html">configured</a> properly.</p>'; } } elseif ($_POST['action'] == 'update_db') { $body .= $parser->run_migrations(); $body .= '<p>Migration complete.</p>'; $body .= '<p><a href="/admin/?page=parse&noframe=1">Back to Admin Dashboard</a></p>'; } elseif ($_POST['action'] == 'empty') { echo 'Emptying the database<br />'; flush(); if ($_POST['edition']) { $parser->clear_edition($_POST['edition']); } else { $parser->clear_db(); } echo 'Emptying the index<br />'; flush(); $parser->clear_index(); echo 'Done<br />'; } elseif ($_POST['action'] == 'parse') { define('EXPORT_IN_PROGRESS', true); echo 'Beginning import<br />'; flush(); ob_flush(); /* * Step through each parser method. */