function show_admin_forms($args = array()) { $parser = new ParserController($args); $editions = $parser->get_editions(); if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) { $base_url = 'https://'; } else { $edition_url_base = 'http://'; } $edition_url_base .= $_SERVER['SERVER_NAME']; if ($_SERVER['SERVER_PORT'] != 80) { $edition_url_base .= ':' . $_SERVER['SERVER_PORT']; } $edition_url_base .= '/'; $body = '<p>What do you want to do?</p> <form method="post" action="/admin/?page=parse&noframe=1"> <h3>Import Data</h3>'; if (isset($args['import_errors'])) { $body .= '<div class="errors"> Please fix the following errors: <ul>'; foreach ($args['import_errors'] as $error) { $body .= '<li>' . $error . '</li>'; } $body .= '</div>'; } $body .= '<p>This will import all data files from your data directory: <span class="code">' . IMPORT_DATA_DIR . '</span></p> <input type="hidden" name="action" value="parse" /> <div class="option"> <input type="radio" class="radio" name="edition_option" id="edition_option_new" value="new"'; if (!$editions || $args['edition_option'] == 'existing') { $body .= 'checked="checked"'; } $body .= '/> <label for="edition_option_new">I want to create a new edition of the laws.</label> <div class="suboption"> <label for="new_edition_name">I want to call this edition</label> <div> <input type="text" class="text" name="new_edition_name" id="new_edition_name" placeholder="' . date('Y-m') . '" value="' . (isset($args['new_edition_name']) ? $args['new_edition_name'] : '') . '" /> </div> </div> <div class="suboption"> <label for="new_edition_slug">. . .</option> and the URL for this edition will be</label> <div class="edition_url">' . $edition_url_base . ' <input type="text" class="text" name="new_edition_slug" id="new_edition_slug" placeholder="' . date('Y-m') . '" value="' . (isset($args['new_edition_slug']) ? $args['new_edition_slug'] : '') . '" /> / </div> <p class="note">Note: In general, try to only use letters, numbers, and hyphens, and avoid using anything that might conflict with a section number or structure name.</p> </div> </div> <div class="option"> <input type="radio" class="radio" name="edition_option" id="edition_option_existing" value="existing"'; if (!isset($editions) || $editions === FALSE) { $body .= 'disabled="disabled"'; } elseif ($args['edition_option'] == 'existing') { $body .= 'checked="checked"'; } $body .= '/><label for="edition_option_existing">I want to update an existing edition of the laws.</label>'; if ($editions !== FALSE) { $body .= '<div class="suboption"> <select name="edition" value="edition"> <option value="">Choose Edition . . .</option>'; foreach ($editions as $edition) { $body .= '<option value="' . $edition->id . '"'; if ($args['edition'] == $edition->id) { $body .= ' select="selected"'; } $body .= '>' . $edition->name . '</option>'; } $body .= '</select> </div>'; } else { $body .= '<div class="suboption"> You don’t have any editions yet, you’ll need to create a new one. </div>'; } $body .= '</div> <div class="option"> <input type="checkbox" class="checkbox" name="make_current" id="make_current" value="1"'; if (!$editions) { $body .= 'checked="checked"'; } $body .= ' /> <label for="make_current">Make this edition current.</label> </div> <input type="submit" value="Import" /> </form> <form method="post" action="/admin/?page=parse&noframe=1"> <h3>Empty the Database</h3> <p>Remove all data from the database. (This leaves database tables intact.)</p> <input type="hidden" name="action" value="empty" /> <input type="submit" value="Empty the Database" /> </form> <form method="post" action="/admin/?page=parse&noframe=1"> <h3>Rebuild Permalinks</h3> <p>Completely rebuild all permalinks for all editions of code.</p> <input type="hidden" name="action" value="permalinks" /> <input type="submit" value="Rebuild Permalinks" /> </form> <form method="post" action="/admin/?page=parse&noframe=1"> <h3>Test Your Environment</h3> <p>Verifies that the State Decoded will run on the current server environment.</p> <input type="hidden" name="action" value="test_environment" /> <input type="submit" value="Test Environment" /> </form>'; /* * If APC is running, provide an option to clear the cache. */ if (APC_RUNNING === TRUE) { $body .= ' <form method="post" action="/admin/?page=parse&noframe=1"> <h3>Clear the APC Cache</h3> <p>Delete all data currently stored in APC.</p> <input type="hidden" name="action" value="apc" /> <input type="submit" value="Clear APC Cache" /> </form>'; } return $body; }