コード例 #1
0
ファイル: sidebar.php プロジェクト: Emaratilicious/oddibooks
		<ul id="booknav">
		<!-- If Logged in show ADMIN -->
			<?php global $blog_id; ?>
			<?php if (current_user_can_for_blog($blog_id, 'edit_posts') || is_super_admin()): ?>
				<li class="admin-btn"><a href="<?php echo get_option('home'); ?>/wp-admin"><?php _e('Admin', 'pressbooks'); ?></a></li>
			<?php endif; ?>
		
				<li class="home-btn"><a href="<?php echo get_option('home'); ?>"><?php _e('Home', 'pressbooks'); ?></a></li>

		<!-- TOC button always there -->
				<li class="toc-btn"><a href="<?php echo get_option('home'); ?>/table-of-contents"><?php _e('Table of Contents', 'pressbooks'); ?></a></li>
			</ul>

		<!-- Pop out TOC only on READ pages -->
		<?php if (is_single()): ?>
		<?php $book = pb_get_book_structure(); ?>
		<div id="toc">
			<a href="#" class="close"><?php _e('Close', 'pressbooks'); ?></a>
			<ul>
				<li><h4><!-- Front-matter --></h4></li>
				<li>
					<ul>
						<?php foreach ($book['front-matter'] as $fm): ?>
						<?php if ($fm['post_status'] != 'publish' && !current_user_can_for_blog($blog_id, 'read')) continue; // Skip ?>
						<li class="front-matter <?php echo pb_get_section_type( get_post($fm['ID']) ) ?>"><a href="<?php echo get_permalink($fm['ID']); ?>"><?php echo pb_strip_br( $fm['post_title'] );?></a>
						<?php $sections = pb_get_sections( $fm['ID'] );
							if ( $sections && pb_should_parse_sections() ){
								$s = 1; ?>
								<ul class="sections">
								<?php foreach ( $sections as $id => $name ) { ?>
									<li class="section"><a href="<?php echo get_permalink($fm['ID']); ?>#<?php echo $id; ?>"><?php echo $name; ?></a></li>
コード例 #2
0
ファイル: index.php プロジェクト: Emaratilicious/oddibooks
<?php

if ( ! defined( 'ABSPATH' ) )
	exit;

get_header();
$book = pb_get_book_structure();
?>
<?php if (get_option('blog_public') == '1' || (get_option('blog_public') == '0' && current_user_can_for_blog($blog_id, 'read'))): ?>
	<?php if (have_posts()) the_post(); ?>
	<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
	<h2 class="page-title"><?php _e('Table of Contents', 'pressbooks'); ?></h2>
	<!-- Table of content loop goes here. -->
	<ul id="inline-toc">

		<li>
			<ul>
			<?php foreach ($book['front-matter'] as $fm) : ?>
				<?php if ($fm['post_status'] != 'publish') continue; // Skip ?>
				<li class="front-matter <?php echo pb_get_section_type( get_post($fm['ID']) ) ?>"><a href="<?php echo get_permalink($fm['ID']); ?>"><?php echo $fm['post_title']; ?></a></li>
			<?php endforeach; ?>
			</ul>
		</li>

		<?php foreach ($book['part'] as $part) : ?>
			<li><h4><?php if ( count( $book['part'] ) > 1 ) echo $part['post_title']; ?></h4><ul>
			<?php foreach ($part['chapters'] as $chapter) : ?>
				<?php if ($chapter['post_status'] != 'publish') continue; // Skip ?>
				<li class="chapter <?php echo pb_get_section_type( get_post($chapter['ID']) ) ?>"><a href="<?php echo get_permalink($chapter['ID']); ?>"><?php echo $chapter['post_title']; ?></a></li>
			<?php endforeach; ?>
			</ul></li>
コード例 #3
0
ファイル: candela-citation.php プロジェクト: BCcampus/candela
 public static function global_citation_page()
 {
     // Process incoming form and preload previous citations.
     $rows = array();
     if (!empty($_POST['__citation'])) {
         CandelaCitation::process_global_form();
         if (!empty($citations)) {
             foreach ($citations as $citation) {
                 $rows[] = CandelaCitation::get_meta_row($citation);
             }
         }
     }
     print '<div class="wrap">';
     print '<div>' . __('Global Citations', 'candela-citation') . '</div>';
     print '<form method="POST" action="' . get_permalink() . '">';
     print '<input type="hidden" name="__citation" value="1" >';
     $rows[] = CandelaCitation::get_meta_row();
     CandelaCitation::citations_table($rows);
     print '<input type="submit" id="citation-add-all" name="citation-add-all" value="' . __('Add citations to every page', 'candela-citation') . '">';
     print '<input type="submit" id="citation-replace-all" name="citation-replace-all" value="' . __('OVERWRITE citations on every page', 'candela-citation') . '">';
     print "<script type=\"text/javascript\">\n      jQuery( document ).ready( function( \$ ) {\n        \$('#citation-add-all').click(function() {\n          if (!confirm(\"Are you sure you want to add citations to *every* page in this book?\")) {\n            return false;\n          }\n        });\n      });\n    </script>";
     print "<script type=\"text/javascript\">\n      jQuery( document ).ready( function( \$ ) {\n        \$('#citation-replace-all').click(function() {\n          if (!confirm(\"Are you sure you want to replace all citations in *every* page in this book?\")) {\n            return false;\n          }\n        });\n      });\n    </script>";
     print '</form>';
     print '</div>';
     // Show citations for every book
     $structure = pb_get_book_structure();
     if (!empty($structure['__order'])) {
         $grouped = array();
         $headers = array('title' => __('Post'));
         foreach ($structure['__order'] as $id => $info) {
             $post = get_post($id);
             $citations = CandelaCitation::get_citations($id);
             $fields = CandelaCitation::citation_fields();
             foreach ($citations as $citation) {
                 $parts = array();
                 $parts['title'] = '<a href="' . get_permalink($post->ID) . '">' . $post->post_title . '</a>';
                 foreach ($fields as $field => $info) {
                     if (empty($headers[$field])) {
                         $headers[$field] = $info['label'];
                     }
                     if (!empty($citation[$field])) {
                         $parts[$field] = esc_html($citation[$field]);
                     }
                 }
                 $grouped[$id][$citation['type']][] = $parts;
             }
         }
         if (!empty($grouped)) {
             print '<div class="wrap"><table>';
             print '<thead><tr>';
             foreach ($headers as $title) {
                 print '<th>' . $title . '</th>';
             }
             print '</tr></thead>';
             print '<tbody>';
             foreach ($grouped as $id => $citations) {
                 foreach ($citations as $type => $parts) {
                     foreach ($parts as $row) {
                         print '<tr>';
                         foreach (array_keys($headers) as $field) {
                             if (!empty($row[$field])) {
                                 switch ($field) {
                                     case 'url':
                                         print '<td><a href="' . esc_url($row[$field]) . '">' . esc_url($row[$field]) . '</a></td>';
                                         break;
                                     default:
                                         print '<td>' . $row[$field] . '</td>';
                                         break;
                                 }
                             } else {
                                 print '<td></td>';
                             }
                         }
                         print '</tr>';
                     }
                 }
             }
             print '</tbody>';
             print '</table></div>';
         } else {
             print '';
         }
     }
 }