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);
     }
 }
Example #2
0
                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();
    $varnish->purge();
    echo 'Done<br />';
    echo '<br /><a href="/admin/?page=parse&amp;noframe=1">Back</a>';
} elseif ($_POST['action'] == 'permalinks') {
    ob_start();
    echo 'Beginning permalinks<br />';
    $parser->build_permalinks();
    echo 'Done<br />';
    echo '<br /><a href="/admin/?page=parse&amp;noframe=1">Back</a>';
    $body = ob_get_contents();
    ob_end_clean();
} elseif ($_POST['action'] == 'apc') {
    ob_start();
    echo 'Clearing APC cache<br />';
    $parser->clear_apc();