Skip to content

Commit

Permalink
Cosmetics.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashod committed Nov 18, 2012
1 parent 5d6d6d7 commit ee4d15e
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 121 deletions.
11 changes: 5 additions & 6 deletions book.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,10 @@ function get_books($query, $show_private = false) {
* Fetches a single book with the given ID.
* @param int $id The b_id of the book you want to fetch.
*/
function get_book($id) {
function get_book($id)
{
global $wpdb;

$options = get_option(NOW_READING_OPTIONS);

$id = intval($id);

$book = apply_filters('get_single_book', $wpdb->get_row("
Expand All @@ -206,9 +205,9 @@ function get_book($id) {
GROUP BY b_id
"));

$book->added = ( nr_empty_date($book->added) ) ? '' : $book->added;
$book->started = ( nr_empty_date($book->started) ) ? '' : $book->started;
$book->finished = ( nr_empty_date($book->finished) ) ? '' : $book->finished;
$book->added = (nr_empty_date($book->added) ? '' : $book->added);
$book->started = (nr_empty_date($book->started) ? '' : $book->started);
$book->finished = (nr_empty_date($book->finished) ? '' : $book->finished);

return $book;
}
Expand Down
168 changes: 88 additions & 80 deletions suffusion/single.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,123 +18,131 @@
<?php suffusion_after_begin_content(); ?>
<article <?php post_class('post nr-post'); ?>>
<?php
if( have_books(intval($nr_id)) ) {
while ( have_books(intval($nr_id)) ) {
the_book();
if (have_books(intval($nr_id)))
{
while (have_books(intval($nr_id)))
{
the_book();
?>
<header class="post-header">
<h1 class="posttitle"><?php book_title(); ?></h1>
<header class="post-header">
<h1 class="posttitle"><?php book_title(); ?></h1>

<div class="bookdata fix">
<div class="author">
<span class="icon">&nbsp;</span>
<a href="<?php book_author_permalink() ?>"><?php book_author() ?></a>
</div>
<div class="bookdata fix">
<div class="author">
<span class="icon">&nbsp;</span>
<a href="<?php book_author_permalink() ?>"><?php book_author() ?></a>
</div>

<div class="rating">
Rating: <?php echo book_rating(false); ?>
<!-- <img src="<?php echo get_template_directory_uri(); ?>/images/<?php book_rating() ?>.png" height="20px" title="Rating: <?php book_rating()?>" alt="Rating: <?php book_rating()?>" />-->
</div>
<div class="rating">
Rating: <?php echo book_rating(false); ?>
<!-- <img src="<?php echo get_template_directory_uri(); ?>/images/<?php book_rating() ?>.png" height="20px" title="Rating: <?php book_rating()?>" alt="Rating: <?php book_rating()?>" />-->
</div>
<?php
if( can_now_reading_admin() ) {
if (can_now_reading_admin())
{
?>
<div class="edit">
<span class="icon">&nbsp;</span>
<a href="<?php book_edit_url(); ?>">Edit this book</a>
</div>

<div class="manage">
<span class="icon">&nbsp;</span>
<a href="<?php manage_library_url(); ?>"><?php _e('Manage Books', 'suffusion');?></a>
</div>
<div class="edit">
<span class="icon">&nbsp;</span>
<a href="<?php book_edit_url(); ?>">Edit this book</a>
</div>

<div class="manage">
<span class="icon">&nbsp;</span>
<a href="<?php manage_library_url(); ?>"><?php _e('Manage Books', 'suffusion');?></a>
</div>
<?php
}
}
?>
<div class="library">
<span class="icon">&nbsp;</span>
<a href="<?php library_url(); ?>"><?php _e('Back to library', 'suffusion');?></a>
</div>
</div>
</header>
<div class="library">
<span class="icon">&nbsp;</span>
<a href="<?php library_url(); ?>"><?php _e('Back to library', 'suffusion');?></a>
</div>
</div>
</header>

<div class="bookentry fix">
<div class="stats">
<a href="<?php book_url(); ?>" title="<?php if (!is_custom_book()) { ?>Buy <?php echo esc_attr(book_title(false));?> from Amazon<?php }?>"><img src="<?php book_image(); ?>" alt="<?php echo esc_attr(book_title(false)); ?>" /></a>
<br />
<p>
<div class="bookentry fix">
<div class="stats">
<a href="<?php book_url(); ?>" title="<?php if (!is_custom_book()) { ?>Buy <?php echo esc_attr(book_title(false));?> from Amazon<?php }?>"><img src="<?php book_image(); ?>" alt="<?php echo esc_attr(book_title(false)); ?>" /></a>
<br />
<p>
<?php
if ($suf_nr_single_added_show == 'show') {
echo $suf_nr_single_added_text;
echo book_added(false);
if ($suf_nr_single_added_show == 'show')
{
echo $suf_nr_single_added_text;
echo book_added(false);
?>
</p>
<p>
</p>
<p>
<?php
}
if ($suf_nr_single_started_show == 'show') {
echo $suf_nr_single_started_text;
echo book_started(false);
}
if ($suf_nr_single_started_show == 'show')
{
echo $suf_nr_single_started_text;
echo book_started(false);
?>
</p>
<p>
</p>
<p>
<?php
}
if ($suf_nr_single_finished_show == 'show') {
echo $suf_nr_single_finished_text;
echo book_finished(false);
}
if ($suf_nr_single_finished_show == 'show')
{
echo $suf_nr_single_finished_text;
echo book_finished(false);
?>
</p>
<p>
</p>
<p>
<?php
}
if ($suf_nr_single_meta_show == 'show') {
}
if ($suf_nr_single_meta_show == 'show')
{
?>
<?php print_book_meta(0); ?>
<?php
}
}
?>
</p>
</div>
</p>
</div>

<div class="review">
<?php
book_review();
if (book_has_post()) {
book_review();
if (book_has_post())
{
?>
<p>This book is linked with the post <a href="<?php book_post_url() ?>">&ldquo;<?php book_post_title() ?>&rdquo;</a>.</p>
<p>This book is linked with the post <a href="<?php book_post_url() ?>">&ldquo;<?php book_post_title() ?>&rdquo;</a>.</p>
<?php
}
}
?>
</div><!--/.review -->

<?php
<?php
$tags = print_book_tags(false);
if (trim($tags) != "") {
?>
<div class="post-footer postdata fix">
<span class="tags"><?php _e('Tagged with: ', 'suffusion'); print_book_tags(1); ?></span>
</div><!--/.post-footer -->
<?php
if (trim($tags) != "")
{
?>
<div class="post-footer postdata fix">
<span class="tags"><?php _e('Tagged with: ', 'suffusion'); print_book_tags(); ?></span>
</div><!--/.post-footer -->
<?php
}
?>
</div><!-- bookentry -->
?>
</div><!-- bookentry -->
<?php
}
}
else {
else
{
?>
<header class="post-header">
<h2 class="posttitle"><?php _e('Not Found', 'suffusion'); ?></h2>
</header>
<div class="entry">
<p><?php _e("Sorry, but you are looking for something that isn't here.", 'suffusion'); ?></p>
</div>
<header class="post-header">
<h2 class="posttitle"><?php _e('Not Found', 'suffusion'); ?></h2>
</header>
<div class="entry">
<p><?php _e("Sorry, but you are looking for something that isn't here.", 'suffusion'); ?></p>
</div>
<?php
}
?>
</article><!-- post -->

</article><!-- post -->
</div><!-- content -->
</div><!-- main-col -->

Expand Down
61 changes: 38 additions & 23 deletions template-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -593,61 +593,75 @@ function book_url( $echo = true, $domain = null ) {
/**
* Returns true if the current book is linked to a post, false if it isn't.
*/
function book_has_post() {
function book_has_post()
{
global $book;

return ( $book->post > 0 );
return ($book->post > 0);
}

/**
* Returns or prints the permalink of the post linked to the current book.
* @param bool $echo Whether or not to echo the results.
*/
function book_post_url( $echo = true ) {
function book_post_url($echo = true)
{
global $book;

if ( !book_has_post() )
return;
if (!book_has_post())
{
return;
}

$permalink = get_permalink($book->post);
if ($echo)
{
echo $permalink;
}

if ( $echo )
echo $permalink;
return $permalink;
return $permalink;
}

/**
* Returns or prints the title of the post linked to the current book.
* @param bool $echo Whether or not to echo the results.
*/
function book_post_title( $echo = true ) {
function book_post_title($echo = true)
{
global $book;

if ( !book_has_post() )
return;
if (!book_has_post())
{
return;
}

$post = get_post($book->post);
if ($echo)
{
echo $post->post_title;
}

if ( $echo )
echo $post->post_title;
return $post->post_title;
}

/**
* If the current book is linked to a post, prints an HTML link to said post.
* @param bool $echo Whether or not to echo the results.
*/
function book_post_link( $echo = true ) {
function book_post_link($echo = true)
{
global $book;

if ( !book_has_post() )
return;
if (!book_has_post())
{
return;
}

$link = '<a href="' . book_post_url(0) . '">' . book_post_title(0) . '</a>';

if ( $echo )
echo $link;
return $link;
if ($echo)
{
echo $link;
}

return $link;
}

/**
Expand Down Expand Up @@ -882,7 +896,8 @@ function book_meta( $key, $echo = true ) {
* Prints a comma-separated list of tags for the current book.
* @param bool $echo Whether or not to echo the results.
*/
function print_book_tags( $echo = true ) {
function print_book_tags($echo = true)
{
global $book;

$tags = get_book_tags($book->id);
Expand Down
Loading

0 comments on commit ee4d15e

Please sign in to comment.