*/
/*****
 * Setup
 */
require_once 'panl.init.php';
$modal = new GrlxForm_Modal();
$book_id = $_GET['book_id'];
$page_id = $_GET['page_id'];
/*****
 * Display logic
 */
// PAGE
if (is_numeric($page_id) && is_numeric($chapter_id)) {
    $item = $db->where('id', $page_id)->getOne('book_page', 'title');
    $modal->send_to('book.view.php');
    $modal->input_hidden('chapter_id');
    $modal->value($chapter_id);
    $form_output = $modal->paint();
    $modal->input_hidden('page_id');
    $modal->value($page_id);
    $form_output .= $modal->paint();
    $modal->input_title('title');
    $modal->name('page_rename');
    $modal->value($item['title']);
    $form_output .= $modal->paint();
} elseif (is_numeric($book_id)) {
    $item = $db->where('id', $book_id)->getOne('book', 'title');
    $modal->send_to('book.view.php');
    $modal->input_hidden('book_id');
    $modal->value($book_id);
    $form_output = $modal->paint();
$edit_id = $_GET['edit_id'];
if (is_numeric($edit_id)) {
    $cols = array('title', 'url', 'rel_id', 'rel_type', 'edit_path');
    $item = $db->where('id', $edit_id)->getOne('path', $cols);
} else {
    $item['rel_type'] = 'external';
}
/*****
 * Display logic
 */
if ($edit_id == 'new') {
    $modal->headline('Add <span>external link</span>');
    $modal->save_value('add');
} else {
    $modal->headline('Edit <span>' . $item['title'] . '</span>');
    $modal->input_hidden('edit_id');
    $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);
    }
}
require_once 'panl.init.php';
$modal = new GrlxForm_Modal();
/*****
 * 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();
/* This script is called from the static page view.
 */
/*****
 * Setup
 */
require_once 'panl.init.php';
$modal = new GrlxForm_Modal();
$modal->send_to('sttc.page-list.php');
/*****
 * Display logic
 */
// Delete a static page
if (is_numeric($_GET['id'])) {
    $title = urldecode($_GET['title']);
    if ($title) {
        $modal->headline('Really delete <span>' . $title . ' ?</span>');
    } else {
        $modal->headline('Are you really, really sure?');
    }
    $modal->instructions('There is no undo.');
    $modal->input_hidden('delete_id');
    $modal->value($_GET['id']);
    $modal_output = $modal->paint();
}
$modal->contents($modal_output);
$modal_output = $modal->paint_confirm_modal();
/*****
 * Display
 */
print $modal_output;
        $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>");
        }
    }
    if ($match_id) {
        $modal->input_hidden('match_id');
        $modal->value($match_id);
        $modal_output .= $modal->paint();
    }
    if ($widget_id) {
        $modal->input_hidden('widget_id');
        $modal->value($widget_id);
        $modal_output .= $modal->paint();
    }
}
$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();
 * Setup
 */
require_once 'panl.init.php';
$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();
/*****