<ul class="latest-release-list">
	<?php 
$releases = get_sListLatest($numofposts, false, true);
if ($releases) {
    $icons = wpmanga_get('wpmanga_widget_icons', 0);
    foreach ($releases as $release) {
        $project = get_sProject($release, false);
        echo '<li>';
        if ($icons) {
            echo "<a href='" . get_sPermalink($project) . "' title='{$project->title}'><img src='" . get_sThumbnail('60x60', empty($project->image_thumbnail) ? $project->image : $project->image_thumbnail) . "' width='60' height='60' style='float: left; margin-right: 5px;' class='project-icon-thumbnail'></a>";
        }
        echo "<p><a href='" . get_sPermalink($project) . "#release-{$release->id}' title='{$release->title}'>{$project->title} - " . get_sFormatRelease($project, $release, false) . "</a><br><span class='latest-release-date'>";
        if ($release->revision > 1) {
            echo get_sDuration($release->unixtime_mod);
        } else {
            echo get_sDuration($release->unixtime);
        }
        if ($icons) {
            echo '</span></p><span class="wpmanga-clear"></span></li>';
        } else {
            echo '</span></p></li>';
        }
    }
} else {
    echo '<li>No Releases</li>';
}
?>
</ul>
/**
 * Generate the latest widget for the dashboard.
 * @return widget
 */
function dashboard_sLatestWidgetD()
{
    ?>
<div id="the-comment-list" class="list:comment">
	<?php 
    $releases = get_sListLatest(5);
    ?>
	<?php 
    if ($releases != NULL) {
        ?>
		<?php 
        foreach ($releases as $release) {
            ?>
		<?php 
            $project = get_sProject($release->project_id, false);
            ?>
	<div id="comment-87" class="comment byuser comment-author-zyki odd alt thread-odd thread-alt depth-1 comment-item approved">
		<img src="<?php 
            echo get_sThumbnail('60x60', empty($project->image_thumbnail) ? $project->image : $project->image_thumbnail);
            ?>
" class='avatar avatar-50 photo' />
		<div class="dashboard-comment-wrap">
			<h4 class="comment-meta">
				<?php 
            echo $project->title;
            ?>
 - <i><?php 
            echo get_sFormatRelease($project, $release);
            ?>
</i>
			</h4>
			<blockquote><p>Released: <?php 
            if ($release->revision > 1) {
                echo get_sDuration($release->unixtime_mod);
            } else {
                echo get_sDuration($release->unixtime);
            }
            ?>
</p></blockquote>
			<p class="row-actions">
				<a href="admin.php?page=manga/release&action=edit&id=<?php 
            echo $release->id;
            ?>
" title="Edit this Release">Edit</a> | <a href="<?php 
            echo get_sPermalink($project->id);
            ?>
#release-<?php 
            echo $release->id;
            ?>
" title="<?php 
            echo $release->title;
            ?>
">View</a>
			</p>

		</div>
	</div>
		<?php 
        }
        ?>
	<?php 
    } else {
        ?>
		<li>
			<img src="<?php 
        bloginfo('template_directory');
        ?>
/images/no-image-60px.png" /><?php 
        echo $project->name;
        ?>
</a>
			<p>
				<i>No Releases.</i>
				<span class="popular-post-date">Pending...</span>
			</p>
		</li>
	<?php 
    }
    ?>
	<?php 
    wp_reset_query();
    ?>
</div>
<?php 
}
					<th scope="col">Action</th>
				</tr>
			</tfoot>
			<tbody>
				<?php 
$releases = get_sListLatest(0);
foreach ($releases as $release) {
    $project = get_sProject($release->project_id, false);
    ?>
				<tr>
					<th scope="row"><?php 
    echo $release->id;
    ?>
</th>
					<td style="vertical-align: inherit;"><?php 
    echo $project->title . ' - ' . get_sFormatRelease($project, $release);
    ?>
</td>
					<td style="vertical-align: inherit;"><a class="send_release_to_editor" title="<?php 
    echo $release->id;
    ?>
" href="#" style="color: rgb(33, 117, 155);">Insert</a></td>
				</tr>
				<?php 
}
?>
			</tbody>
		</table>
		</div>
	</div>
</div>
						</div>
			
			<?php 
        }
    }
    /* Generate Remaining Releases */
    $releases = get_sProjectReleases($project->id, false, true);
    ?>
			
				<div class="list">
					<?php 
    foreach ($releases as $release) {
        if (!array_key_exists($release->id, $_volumes)) {
            echo '<span class="title">';
            echo "<a name='release-{$release->id}'></a>" . date('Y.m.d', $release->unixtime) . ' &nbsp;&nbsp;&nbsp; ';
            echo get_sFormatRelease($project, $release, false);
            if ($release->title) {
                echo " - <i>{$release->title}</i>";
            }
            echo '</span>';
            echo '<span class="downloads">';
            $downloads = get_sReleaseDownloads($release);
            foreach ($downloads as $download => $value) {
                $download = str_replace(array('download_depositfiles', 'download_fileserve', 'download_filesonic', 'download_mediafire', 'download_megaupload', 'download_pdf', 'download_irc'), array('DF', 'FSrv', 'FSnc', 'MF', 'MU', 'PDF', 'IRC'), $download);
                if ($value) {
                    if ($download == 'IRC') {
                        echo "&nbsp; <span rel='#download-overlay' title='{$value}'><a>{$download}</a></span>";
                    } else {
                        echo "&nbsp; <a href='{$value}' target='_blank'>{$download}</a>";
                    }
                }
			<?php 
$projects = get_sListProject();
foreach ($projects as $project) {
    $lastRelease = get_sLastRelease($project->id, true);
    if ($project->image) {
        $project->image = get_sThumbnail('60x60', $project->image);
    }
    unset($project->custom);
    unset($project->hit);
    if ($lastRelease) {
        if ($lastRelease->revision > 1) {
            $project->last_release_time = get_sDuration($lastRelease->unixtime_mod);
        } else {
            $project->last_release_time = get_sDuration($lastRelease->unixtime);
        }
        $project->last_release = get_sFormatRelease($project, $lastRelease);
        $project->last_release_title = $lastRelease->title;
    } else {
        $project->last_release = '';
        $project->last_release_title = '';
        $project->last_release_time = 'No Releases Yet!';
    }
    echo "project[{$project->id}] = [" . json_encode($project) . "];";
}
?>
			
			var output = 'Project Details';
			if (project[id][0].title != "") {	output = '<b>' + project[id][0].title + '</b>'; }
			if (project[id][0].title_alt != "") {	output = output + '<br />&#12302; ' + project[id][0].title_alt + ' &#12303;'; }
			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; }
/**
 * 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> &nbsp; <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> &nbsp; <?php 
                if ($project->title_alt) {
                    echo "&#12302;{$project->title_alt}&#12303;";
                }
                ?>
					<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 
    }
}
            $output .= '<div id="release-download-wrapper">';
            $output .= "<span><a class='release-download-button' href='#release-{$release->id}' title='{$project->title} - " . get_sFormatRelease($project, $release) . "'> Download</a></span>";
            $output .= '<ul class="release-download-icons">';
            foreach ($downloads as $download => $value) {
                $title = str_replace(array('download_depositfiles', 'download_fileserve', 'download_filesonic', 'download_mediafire', 'download_megaupload', 'download_pdf', 'download_irc'), array('Deposit Files', 'FileServe', 'FileSonic', 'MediaFire', 'MEGAUPLOAD', 'PDF', 'IRC'), $download);
                $download = str_replace('download_', 'download-icon-', $download);
                if ($value) {
                    if ($download == 'download-icon-irc') {
                        $output .= "<li><span rel='#download-overlay' title='{$value}'><a><img src='" . plugin_sURL() . "images/{$download}-32.png' title='{$title}'></a></span></li>";
                    } else {
                        $output .= "<li><a href='{$value}' target='_blank'><img src='" . plugin_sURL() . "images/{$download}-32.png' title='{$title}'></a></li>";
                    }
                }
            }
            $chapterUrl = get_sReaderLink($project, $release);
            if ($chapterUrl) {
                $output .= '<li><a href="' . $chapterUrl . '" target="_blank"><img src="' . plugin_sURL() . 'images/download-icon-onlinereader-32.png" title="Read ' . $project->name . ' Online"></a></li>';
            }
            $output .= '</ul>';
            $output .= '</div>';
            $output .= '<br class="wpmanga-clear"/>';
    }
} else {
    // Display Error!
    $output .= "<del>{$project->title} - " . get_sFormatRelease($project, $release);
    if ($release->title != NULL) {
        $output .= ": {$release->title}";
    }
    $output .= '</del> (Please wait, the downloads for this release have not been added yet.)';
    $output .= '<br><br class="wpmanga-clear">';
}