$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();
/*****
 * Display
 */
print $modal_output;
/*****
 * 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();
// Widgets
if ($widget_id) {
    $cols = array('w.id AS widget_id', 's.id AS service_id', 's.title AS title', 'w.title AS widget', 's.info_title', 's.user_info', 'w.value_title AS widget_info', 'w.value AS widget_value', 'w.description AS description');
    $result = $db->join('third_service s', 's.id = w.service_id', 'INNER')->orderBy('s.title', 'ASC')->orderBy('w.title', 'ASC')->where('w.id', $widget_id)->get('third_widget w', null, $cols);
}
// Everything else
if ($service_id) {
    $cols = array('id AS service_id', 'title', 'user_info', 'info_title', 'description');
    $result = $db->where('id', $service_id)->get('third_service', null, $cols);
}
// Build form
if ($db->count > 0) {
    foreach ($result as $item) {
        $modal->instructions($item['description']);
        $modal->input_text("edit[{$item['service_id']}]");
        $modal->label("Enter your {$item['info_title']}");
        $modal->autofocus(true);
        $modal->required(true);
        $modal->value($item['user_info']);
        $modal->maxlength(32);
        $modal_output .= $modal->paint();
        if ($widget_id) {
            $modal->input_text('widget_value');
            $modal->label("Enter your {$item['widget_info']}");
            $modal->required(true);
            $modal->value($item['widget_value']);
            $modal->maxlength(32);
            $modal_output .= $modal->paint();
            $modal->headline('Enter your details <span>' . $item['title'] . ' ' . lcfirst($item['widget']) . '</span>');
        } else {
            $modal->headline("Enter your details <span>{$item['title']}</span>");
$modal = new GrlxForm_Modal();
$modal->send_to('xtra.social.php');
$modal->row_class('widelabel');
/*****
 * Display logic
 */
if (is_numeric($_GET['service_id'])) {
    $service_id = $_GET['service_id'];
    $cols = array('info_title AS label', 'user_info', 'title', 'description');
    $result = $db->where('id', $service_id)->getOne('third_service', $cols);
}
if ($result) {
    $modal->input_hidden('service_id');
    $modal->value($service_id);
    $modal_output = $modal->paint();
    $modal->input_text('comment_info');
    $modal->label("Enter your {$result['label']}");
    $modal->value($result['user_info']);
    $modal->autofocus(true);
    $modal->required(true);
    $modal->maxlength(32);
    $modal_output .= $modal->paint();
    $modal->headline("Enter your details <span>{$result['title']}</span>");
    $modal->instructions('<p>Here’s a sample of the code that ' . $result['title'] . ' provides. The highlighted portion shows the info Grawlix needs.</p><div class="infobox"><code>' . $result['description'] . '</code></div>');
    $modal->contents($modal_output);
}
$modal_output = $modal->paint_modal();
/*****
 * Display
 */
print $modal_output;