/** * Display Administrative Menu for Projects. * @return menu */ function wpmanga_listProjects() { global $wpdb; // Display Specified Category if (isset($_GET['view'])) { $projects = $wpdb->get_results($wpdb->prepare("SELECT * FROM `{$wpdb->prefix}projects` WHERE `category` = '%d' ORDER BY `title` ASC", (int) $_GET['view'])); } else { $projects = $wpdb->get_results("SELECT * FROM `{$wpdb->prefix}projects` ORDER BY `title` ASC"); } if ($projects || isset($_GET['view'])) { ?> <div class="wrap"> <?php screen_icon('edit-pages'); ?> <h2>Manga Projects <a href="?page=manga/project" class="add-new-h2">Add a New Project</a></h2> <ul class="subsubsub"> <li class="all"> <a href="admin.php?page=manga"<?php if (!isset($_GET['view'])) { echo ' class="current"'; } ?> >All <span class="count">(<?php echo count(get_sListProject()); ?> )</span></a> </li> <?php $categories = get_sListCategories(); foreach ($categories as $category) { ?> | <li class=""> <a href="admin.php?page=manga&view=<?php echo $category->id; ?> "<?php if ($_GET['view'] == $category->id) { echo ' class="current"'; } ?> ><?php echo $category->name; ?> <span class="count">(<?php echo get_sListCategory($category->id, false); ?> )</span></a> </li> <?php } ?> </ul> <table class="wp-list-table widefat"> <thead> <th scope="col" width="65px"></th> <th scope="col">Title</th> </thead> <tfoot> <th scope="col" width="65px"></th> <th scope="col">Title</th> </tfoot> <tbody id="the-list"> <?php $row = 1; ?> <?php foreach ($projects as $project) { ?> <tr id="manga-<?php echo $project->id; ?> " <?php if ($row % 2) { echo 'class="alternate" '; } $row++; ?> valign="top"> <td style="padding-bottom: 5px;"> <img src="<?php echo get_sThumbnail('60x60', empty($project->image_thumbnail) ? $project->image : $project->image_thumbnail); ?> " style="padding: 1px; border: 1px double #878e98; border-radius: 3px; -moz-border-radius: 3px; -webkit-border-radius: 3px;" width="60" height="60" alt="<?php the_title(); ?> " /> </td> <td> <strong> <a href="admin.php?page=manga/project&action=edit&id=<?php echo $project->id; ?> " title="Edit “<?php echo $project->title; ?> “"><?php echo $project->title; ?> </a> </strong> <?php if ($project->author) { echo 'by ' . $project->author; } ?> <br> Status: <?php echo get_sTitleCategory($project->category); ?> ; Genre(s): <?php if ($project->genre) { echo $project->genre; } else { echo "N/A"; } ?> <div class="row-actions"> <span class="edit"> <a href="admin.php?page=manga/project&action=edit&id=<?php echo $project->id; ?> " title="Edit this Project">Edit</a> </span> | <span class="trash"> <a href="admin.php?page=manga/project&action=delete&id=<?php echo $project->id; ?> " title="Delete this Project">Delete</a> </span> | <span class="view"> <a href="<?php echo get_sPermalink($project); ?> " title="View “<?php echo $project->title; ?> ” Project Page">View</a> </span> </div> </td> </tr> <?php } ?> </tbody> </table> </div> <?php } else { ?> <script type="text/javascript"> location.replace("admin.php?page=manga/project") </script> <?php } }
/** * Display Administrative Menu for Projects. * @return menu */ function wpmanga_dataProject() { global $wpdb; // Action Variable if (isset($_GET['action'])) { $action = strtolower($_GET['action']); } else { $action = 'add'; } // Sanity Check on EDIT and DEL if (!isset($_GET['id']) && $action != 'add') { $action = 'add'; } if (isset($_POST['wpmanga_nonce'])) { if (!wp_verify_nonce($_POST['wpmanga_nonce'], plugin_basename(plugin_sDIR() . '/wpmanga.php'))) { echo '<div class="error"><p>Error: Security Verification Failed.</p></div>'; } else { $_POST = array_map('trim', $_POST); $_POST = array_map('stripslashes', $_POST); if (!$_POST['mature']) { $_POST['mature'] = 0; } if ($_POST['title']) { if ($_POST['image']) { $thumbnail = new WP_Http(); $thumbnail->request(plugin_sURL() . '/includes/generate_thumbnail.php?src=' . $_POST['image'] . '&w=' . wpmanga_get('wpmanga_thumbnail_list_width', 145) . '&h=' . wpmanga_get('wpmanga_thumbnail_list_height', 300)); $thumbnail->request(plugin_sURL() . '/includes/generate_thumbnail.php?src=' . $_POST['image'] . '&w=60&h=60'); } if ($_POST['image_thumbnail']) { $thumbnail = new WP_Http(); $thumbnail->request(plugin_sURL() . '/includes/generate_thumbnail.php?src=' . $_POST['image_thumbnail'] . '&w=' . wpmanga_get('wpmanga_thumbnail_list_width', 145) . '&h=' . wpmanga_get('wpmanga_thumbnail_list_height', 300)); $thumbnail->request(plugin_sURL() . '/includes/generate_thumbnail.php?src=' . $_POST['image_thumbnail'] . '&w=60&h=60'); } $custom_settings = json_encode(array('chapter' => $_POST['custom_chapter'], 'subchapter' => $_POST['custom_subchapter'])); $data = array('category' => $_POST['category'], 'slug' => wpmanga_getUrl($_POST['slug'], $_POST['title']), 'title' => $_POST['title'], 'title_alt' => $_POST['title_alt'], 'description' => $_POST['description'], 'description_short' => $_POST['description_short'], 'author' => $_POST['author'], 'genre' => $_POST['genre'], 'status' => $_POST['status'], 'image' => $_POST['image'], 'image_thumbnail' => $_POST['image_thumbnail'], 'team_origin' => $_POST['team_origin'], 'reader' => $_POST['reader'], 'url' => $_POST['url'], 'mature' => $_POST['mature'], 'custom' => $custom_settings); switch ($action) { case 'edit': $check = $wpdb->query($wpdb->prepare("SELECT `slug` FROM `" . $wpdb->prefix . "projects` WHERE `id` <>" . $_GET['id'] . " and `slug` = '%s'", wpmanga_getUrl($_POST['slug'], $_POST['title']))); if (!$check) { $status = $wpdb->update($wpdb->prefix . 'projects', $data, array('id' => $_GET['id'])); if ($status) { echo '<div class="updated"><p>Updated Project Information for <i>' . $_POST['title'] . '</i>.</p></div>'; } else { echo '<div class="error"><p>Error: Failed to update information.</p></div>'; } } else { echo '<div class="error"><p>Error: Failed to edit project. (Duplicate Url)</p></div>'; } break; case 'delete': $status = $wpdb->query($wpdb->prepare("DELETE FROM `{$wpdb->prefix}projects` WHERE `id` = '%d'", $_GET['id'])); $wpdb->query($wpdb->prepare("DELETE FROM `{$wpdb->prefix}projects_releases` WHERE `project_id` = '%d'", $_GET['id'])); if ($status) { echo '<div class="updated"><p>Deleted Project Information for <i>' . $_POST['title'] . '</i>.</p></div>'; } else { echo '<div class="error"><p>Error: Failed to delete information.</p></div>'; } break; default: $check = $wpdb->query($wpdb->prepare("SELECT `slug` FROM `" . $wpdb->prefix . "projects` WHERE `slug` = '%s'", wpmanga_getUrl($_POST['slug'], $_POST['title']))); if (!$check) { $wpdb->insert($wpdb->prefix . 'projects', $data); if ($wpdb->insert_id) { echo '<div class="updated"><p>Added <i>' . $_POST['title'] . '</i> to Projects. <a href="admin.php?page=manga/project&action=edit&id=' . $wpdb->insert_id . '">Edit Information</a></p></div>'; } else { echo '<div class="error"><p>Error: Failed to add new project.</p></div>'; } } else { echo '<div class="error"><p>Error: Failed to add new project. (Duplicate Url)</p></div>'; } } } else { echo '<div class="error"><p>Error: Please fill in the required fields.</p></div>'; } } } if (preg_match("/(edit|delete)/i", $action)) { $project = $wpdb->get_row($wpdb->prepare("SELECT * FROM `{$wpdb->prefix}projects` WHERE `id` = '%d' LIMIT 1", $_GET['id'])); } ?> <div class="wrap"> <?php screen_icon('edit'); ?> <h2><?php echo ucfirst($action); ?> Project Information</h2> <p>Create a new project and add it to this site.</p> <?php switch ($action) { case 'edit': echo '<form method="post" action="admin.php?page=manga/project&action=edit&id=' . $_GET['id'] . '">'; break; case 'delete': echo '<form method="post" action="admin.php?page=manga/project&action=delete&id=' . $_GET['id'] . '">'; break; default: echo '<form method="post" action="admin.php?page=manga/project">'; } ?> <table class="form-table"> <tr class="form-field"> <th scope="row"><label for="category">Category</label></th> <td> <select name="category" id="category" style="width: 460px"> <?php $categories = get_sListCategories(); foreach ($categories as $category) { if (preg_match("/(edit|delete)/i", $action)) { if ($project->category == $category->id) { echo "<option value='{$category->id}' selected='selected'>{$category->name}</option>"; } else { echo "<option value='{$category->id}'>{$category->name}</option>"; } } else { echo "<option value='{$category->id}'>{$category->name}</option>"; } } ?> </select> </td> </tr> <tr class="form-field"> <th scope="row"><label for="title">Title <span class="description">(required)</span></label></th> <td><input name="title" id="title" type="text" value="<?php if (isset($project)) { echo $project->title; } ?> "<?php if ($action == 'delete') { echo ' readonly="readonly" '; } ?> autofocus required></td> </tr> <tr class="form-field"> <th scope="row"><label for="title_alt">Alternative Title</label></th> <td><input name="title_alt" id="title_alt" type="text" value="<?php if (isset($project)) { echo $project->title_alt; } ?> "<?php if ($action == 'delete') { echo ' readonly="readonly"'; } ?> ></td> </tr> <tr class="form-field"> <th scope="row"><label for="title_alt">Url Fragment <br /><span class="description">(optional, blank for auto-generated url)</span></label></th> <td><input name="slug" id="slug" type="text" value="<?php if (isset($project)) { echo $project->slug; } ?> "<?php if ($action == 'delete') { echo ' readonly="readonly"'; } ?> ></td> </tr> <tr class="form-field"> <th scope="row"><label for="author">Author & Artist</label></th> <td><input name="author" id="author" type="text" value="<?php if (isset($project)) { echo esc_textarea($project->author); } ?> "<?php if ($action == 'delete') { echo ' readonly="readonly"'; } ?> ></td> </tr> <tr class="form-field"> <th scope="row"><label for="description">Description</label></th> <td><textarea name="description" id="description"<?php if ($action == 'delete') { echo ' readonly="readonly"'; } ?> ><?php if (isset($project)) { echo esc_textarea($project->description); } ?> </textarea></td> </tr> <tr class="form-field"> <th scope="row"><label for="short_description">Short Description <span class="description">(optional)</span></label></th> <td><textarea name="description_short" id="description_short"<?php if ($action == 'delete') { echo ' readonly="readonly"'; } ?> ><?php if (isset($project)) { echo esc_textarea($project->description_short); } ?> </textarea></td> </tr> <tr class="form-field"> <th scope="row"><label for="genre">Genre(s)</label></th> <td><textarea name="genre" id="genre"<?php if ($action == 'delete') { echo ' readonly="readonly"'; } ?> ><?php if (isset($project)) { echo esc_textarea($project->genre); } ?> </textarea></td> </tr> <tr class="form-field"> <th scope="row"><label for="status">Status in Country of Origin</label></th> <td><textarea name="status" id="status"<?php if ($action == 'delete') { echo ' readonly="readonly"'; } ?> ><?php if (isset($project)) { echo esc_textarea($project->status); } ?> </textarea></td> </tr> <tr class="form"> <th scope="row"><label for="image">Image</label></th> <td><input id="image" type="url" name="image" class="upload" size="66" placeholder="Enter an URL or upload an image for this project." value="<?php if (isset($project)) { echo $project->image; } ?> "<?php if ($action == 'delete') { echo ' readonly="readonly"'; } ?> ><input class="<?php if ($action != 'delete') { echo 'upload_image_button'; } ?> " type="button" value="Upload Image"<?php if ($action == 'delete') { echo ' readonly="readonly"'; } ?> ></td> </tr> <tr class="form"> <th scope="row"><label for="image_thumbnail">Image Thumbnail <span class="description">(optional)</span></label></th> <td><input id="image_thumbnail" type="url" name="image_thumbnail" class="upload" size="66" placeholder="Enter an URL or upload an image thumbnail for this project." value="<?php if (isset($project)) { echo $project->image_thumbnail; } ?> "<?php if ($action == 'delete') { echo ' readonly="readonly"'; } ?> ><input class="<?php if ($action != 'delete') { echo 'upload_image_button'; } ?> " type="button" value="Upload Image Thumbnail"<?php if ($action == 'delete') { echo ' readonly="readonly"'; } ?> ></td> </tr> <tr class="form-field"> <th scope="row"><label for="team_origin">Original Team</label></th> <td><input name="team_origin" id="team_origin" type="text" value="<?php if (isset($project)) { echo esc_textarea($project->team_origin); } ?> "<?php if ($action == 'delete') { echo ' readonly="readonly"'; } ?> ></td> </tr> <tr class="form-field"> <th scope="row"><label for="reader">Online Reader Link</label></th> <td><input name="reader" id="reader" type="url" placeholder="http://reader.<?php echo $_SERVER['HTTP_HOST']; ?> /serie/..." value="<?php if (isset($project)) { echo $project->reader; } ?> "<?php if ($action == 'delete') { echo ' readonly="readonly"'; } ?> ></td> </tr> <tr class="form-field"> <th scope="row"><label for="url">Reference Link</label></th> <td><input name="url" id="url" type="url" placeholder="http://mangaupdates.com/series.html?id=..." value="<?php if (isset($project)) { echo $project->url; } ?> "<?php if ($action == 'delete') { echo ' readonly="readonly"'; } ?> ></td> </tr> <tr class="form"> <th scope="row"><label for="custom_subchapter">Mature Content</label></th> <td><input name="mature" id="mature" type="checkbox" value="1"<?php if ($project->mature) { echo ' checked="checked"'; } ?> > Yes</td> </tr> <tr class="form-field"> <th scope="row"><label for="custom_chapter">Custom Chapter <span class="description">(optional)</span></label></th> <td><input name="custom_chapter" id="custom_chapter" type="text" placeholder="Episode %num%" value="<?php if (isset($project)) { echo get_sJSON($project->custom, 'chapter'); } ?> "<?php if ($action == 'delete') { echo ' readonly="readonly"'; } ?> ></td> </tr> <tr class="form-field"> <th scope="row"><label for="custom_subchapter">Custom Sub-Chapter <span class="description">(optional)</span></label></th> <td><input name="custom_subchapter" id="custom_subchapter" type="text" placeholder="Act %num%" value="<?php if (isset($project)) { echo get_sJSON($project->custom, 'subchapter'); } ?> "<?php if ($action == 'delete') { echo ' readonly="readonly"'; } ?> ></td> </tr> </table> <p class="submit"> <input type="submit" class="button-primary" name="save" value="<?php echo ucfirst($action); ?> Project"> <input type="hidden" name="wpmanga_nonce" value="<?php echo wp_create_nonce(plugin_basename(plugin_sDIR() . '/wpmanga.php')); ?> "> </p> </form> </div> <?php }
if (project[id][0].title != "") { output = '<b>' + project[id][0].title + '</b>'; } if (project[id][0].title_alt != "") { output = output + '<br />『 ' + project[id][0].title_alt + ' 』'; } if (project[id][0].image !="") { output = output + '<br /><img src="' + project[id][0].image + '" />'; } if (project[id][0].last_release != "") { output = output + '<br />Latest Release: ' + project[id][0].last_release; } if (project[id][0].last_release_title != "") { output = output + '<br /><i>' + project[id][0].last_release_title + '</i>'; } if (project[id][0].last_release_time != "") { output = output + '<br /><font size="1">(' + project[id][0].last_release_time + ')</font>'; } jQuery("#projects-tooltip").html(output).show(); } else { jQuery("#projects-tooltip").html('').hide(); } } </script> <?php $categories = get_sListCategories(); $thumbnail_width = wpmanga_get('wpmanga_thumbnail_list_width', 145); $thumbnail_height = wpmanga_get('wpmanga_thumbnail_list_height', 300); foreach ($categories as $category) { $projects = get_sListCategory($category->id); if ($projects) { echo "<h2>{$category->description}</h2>"; echo '<div id="projects-wrapper">'; foreach ($projects as $project) { echo "<div class='item'><a href='" . get_sPermalink($project) . "'><img src='" . get_sThumbnail($thumbnail_width . "x" . $thumbnail_height, empty($project->image_thumbnail) ? $project->image : $project->image_thumbnail) . "' width='{$thumbnail_width}' height='{$thumbnail_height}' id='{$project->id}' title='{$project->name}' alt='{$project->name}'>"; if ($project->mature) { echo "<div class='mature'>R-18</div>"; } echo "</a></div>"; } echo '</div><br class="wpmanga-clear"><br>';
function form($instance) { $projectCategory = $instance['projectCategory']; ?> <p> <label for="<?php echo $this->get_field_id('title'); ?> ">Title:</label> <input class="widefat" type="text" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " value="<?php echo $instance['title']; ?> " /> </p> <p> <label for="<?php echo $this->get_field_id('projectCategory'); ?> ">Show only projects of this Category (optional) :</label> <select name="<?php echo $this->get_field_name('projectCategory'); ?> " id="<?php echo $this->get_field_id('projectCategory'); ?> " > <?php $categories = get_sListCategories(); echo "<option value=''>None</option>"; foreach ($categories as $category) { if ($projectCategory == $category->id) { echo "<option value='{$category->id}' selected='selected'>{$category->name}</option>"; } else { echo "<option value='{$category->id}'>{$category->name}</option>"; } } ?> </select> </p> <?php }
/** * Display Administrative Menu for Releases. * @return menu */ function wpmanga_listReleases() { global $wpdb; $projects = $wpdb->get_results("SELECT * FROM `{$wpdb->prefix}projects` ORDER BY `title` ASC"); $publishedstatus = wpmanga_get('wpmanga_release_statuspublished', 0); if ($projects) { ?> <div class="wrap"> <?php screen_icon('edit-pages'); ?> <h2>Releases <a href="?page=manga/release" class="add-new-h2">Add a New Release</a></h2> <script type="text/javascript"> function toggleFinishedRelease(cb) { if (cb.checked) jQuery('.finished').css( "display", "table-row" ); else jQuery('.finished').css( "display", "none" ); } function catFilter(cbo) { var category = cbo.options[cbo.selectedIndex].value; if (category != '') { jQuery('.project').css( "display", "none" ); jQuery('.cat'+category).css( "display", "block" ); } else { jQuery('.project').css( "display", "block" ); } } function projectFilter(cbo) { var project = cbo.options[cbo.selectedIndex].value; if (project != '') { jQuery('.project').css( "display", "none" ); jQuery('#proj'+project).css( "display", "block" ); } else { jQuery('.project').css( "display", "block" ); } document.getElementById("categoryCombo").selectedIndex=0; } jQuery(function($){ // DOM is now read and ready to be manipulated jQuery('.finished').css( "display", "none" ); document.getElementById("categoryCombo").selectedIndex=1; catFilter(document.getElementById("categoryCombo")); }); </script> <?php if ($publishedstatus != 0) { ?> <label><input type="checkbox" onclick="toggleFinishedRelease(this);">Show finished releases</label><br /> <?php } ?> <span>Show only projects from this category </span> <select name="category" id="categoryCombo" onchange="catFilter(this)" > <?php $categories = get_sListCategories(); echo "<option value='' selected=\"selected\">All</option>"; foreach ($categories as $category) { echo "<option value='{$category->id}'>{$category->name}</option>"; } ?> </select> <span> Or only this project</span> <select name="projects" id="projectsCombo" onchange="projectFilter(this)" > <?php echo "<option value='' selected=\"selected\">All</option>"; foreach ($projects as $project) { echo "<option value='{$project->id}'>{$project->title}</option>"; } ?> </select> <?php foreach ($projects as $project) { $releases = $wpdb->get_results($wpdb->prepare("SELECT * FROM `{$wpdb->prefix}projects_releases` WHERE `project_id` = '%d' ORDER BY `volume` ASC, `chapter` ASC, `subchapter` ASC, `type` ASC", $project->id)); if ($releases) { ?> <div class="project cat<?php echo $project->category; ?> " id="proj<?php echo $project->id; ?> "> <br> <a href="admin.php?page=manga/project&action=edit&id=<?php echo $project->id; ?> " style="text-decoration: none; font-weight: bold"><?php echo $project->title; ?> </a> <?php if ($project->title_alt) { echo "『{$project->title_alt}』"; } ?> <table class="wp-list-table widefat fixed"> <thead> <th scope="col" width="100px">Date</th> <th scope="col">Release</th> <th scope="col" width="150px">Action</th> </thead> <tbody id="the-list"> <?php $row = 1; ?> <?php foreach ($releases as $release) { $class = ""; if ($publishedstatus != 0 && $release->status == $publishedstatus) { $class = "finished"; } ?> <tr<?php if ($row % 2) { $class .= " alternate"; } echo " class=\"{$class}\""; $row++; ?> > <td><?php echo date('Y.m.d', $release->unixtime); ?> </td> <td><?php echo get_sFormatRelease($project, $release); if ($release->title) { echo ' - <i>' . $release->title . '</i>'; } ?> </td> <td> <a href="admin.php?page=manga/release&action=edit&id=<?php echo $release->id; ?> " title="Edit Release Information">Edit</a> | <a href="admin.php?page=manga/release&action=delete&id=<?php echo $release->id; ?> " title="Delete Release Information">Delete</a> | <a href="<?php echo get_sPermalink($release->project_id); ?> #release-<?php echo $release->id; ?> " title="View Release Information">View</a> </td> </tr> <?php } ?> </tbody> </table> </div> <?php } } ?> </div> <?php } else { ?> <script type="text/javascript"> location.replace("admin.php?page=manga/project") </script> <?php } }