* Display logic
 */
if (is_numeric($_GET['edit_id'])) {
    $edit_id = $_GET['edit_id'];
    $cols = array('title', 'img_path', 'url');
    $item = $db->where('id', $edit_id)->getOne('link_list', $cols);
    if ($db->count > 0) {
        $input = $item;
    }
}
$modal->multipart(true);
$modal->send_to('site.link-list.php');
$modal->input_hidden('edit_id');
$modal->value($edit_id);
$modal_output = $modal->paint();
$modal->input_title('input[title]');
$modal->autofocus(true);
$modal->value($input['title']);
$modal_output .= $modal->paint();
$modal->input_url('input[url]');
$modal->value($input['url']);
$modal_output .= $modal->paint();
$modal->input_file('input[img_path]');
$modal->label('Icon');
$modal_output .= $modal->paint();
$modal->input_hidden('old_img_url');
$modal->value($input['img_path']);
$modal_output .= $modal->paint();
$modal->headline("Edit <span>{$input['title']}</span>");
$modal->contents($modal_output);
$modal_output = $modal->paint_modal();
    $modal->value($edit_id);
    $hidden_output = $modal->paint();
}
// Edits based on rel_type
if ($item['rel_type'] == 'external') {
    if ($item['url'] == '') {
        $item['url'] = 'http://';
    }
    $modal->input_url('url');
} else {
    $modal->input_path('url');
    if ($item['edit_path'] == 0) {
        $modal->readonly(true);
    }
}
if ($item['rel_type'] == 'archive') {
    $comic = $db->where('id', $item['rel_id'])->getOne('path', 'url');
    $modal->prefix($comic['url']);
}
$modal->value($item['url']);
$modal->name('input[url]');
$url_field_output = $modal->paint();
$modal->input_title('title');
$modal->name('input[title]');
$modal->value($item['title']);
$title_field_output = $modal->paint();
$modal->contents($hidden_output . $title_field_output . $url_field_output);
/*****
 * Display
 */
print $modal->paint_modal();
/*****
 * Display logic
 */
if (is_numeric($_GET['theme_id']) && is_numeric($_GET['tone_id'])) {
    $theme_id = $_GET['theme_id'];
    $tone_id = $_GET['tone_id'];
} else {
    die('invalid data');
}
$result = $db->where('theme_id', $theme_id)->where('id', $tone_id)->orderBy('title', 'ASC')->getOne('theme_tone', 'title');
$tone_title = ucfirst($result['title']);
if ($db->count <= 0) {
    die('invalid ID');
}
$modal->send_to('site.theme-options.php');
$modal->input_hidden('theme_id');
$modal->value($theme_id);
$form_output = $modal->paint();
$modal->input_hidden('tone_id');
$modal->value($tone_id);
$form_output .= $modal->paint();
$modal->input_title('tone_title');
$modal->label('Enter a name');
$modal->maxlength(32);
$form_output .= $modal->paint();
/*****
 * Display
 */
$modal->headline('New tone <span>using “' . $tone_title . '” as a base</span>');
$modal->contents($form_output);
print $modal->paint_modal();