<?php

/* Artists use this script to add connections to social media services.
 */
/*****
 * Setup
 */
require_once 'panl.init.php';
$view = new GrlxView();
$form = new GrlxForm();
$modal = new GrlxForm_Modal();
$message = new GrlxAlert();
$view->yah = 8;
/*****
 * Updates
 */
// Reset comment service
if (is_numeric($_GET['reset_comments'])) {
    $service_id = $_GET['reset_comments'];
    $data = array('user_info' => null);
    $db->where('id', $service_id);
    $db->update('third_service', $data);
    $data = array('active' => 0);
    $db->where('service_id', $service_id);
    $db->update('third_match', $data);
}
// Save edits from the info modal
if ($_POST['edit']) {
    foreach ($_POST['edit'] as $key => $val) {
        if (is_numeric($key)) {
            $data = array('user_info' => $val);
<?php

/* This script generates a modal that can rename a comic book, chapter, or page.
 */
/*****
 * 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');
<?php

/* This script is called from the main site menu script.
 */
/*****
 * Setup
 */
require_once 'panl.init.php';
$modal = new GrlxForm_Modal();
$modal->row_class('widelabel');
$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') {
<?php

/* This script is called from the link list script.
 */
/*****
 * Setup
 */
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']);
<?php

/* 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
 */
<?php

/* This script is called from the extra services script.
 */
/*****
 * Setup
 */
require_once 'panl.init.php';
$modal = new GrlxForm_Modal();
$modal->row_class('widelabel');
$modal->send_to('xtra.social.php');
$var_list = array('service_id', 'match_id', 'widget_id');
foreach ($var_list as $var_name) {
    if (is_numeric($_GET[$var_name])) {
        ${$var_name} = $_GET[$var_name];
    }
}
/*****
 * Display logic
 */
// 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
<?php

/* This script is called from the theme options script.
 */
/*****
 * Setup
 */
require_once 'panl.init.php';
$modal = new GrlxForm_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');
<?php

/* This script is called from the extra services script.
 */
/*****
 * 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>");