-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsingle-egazete.php
178 lines (148 loc) · 4.43 KB
/
single-egazete.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<?php
/**
* The Template for displaying pages.
*
* @license For the full license information, please view the Licensing folder
* that was distributed with this source code.
*
* @package Bimber_Theme 4.10
*/
// Prevent direct script access.
if ( ! defined( 'ABSPATH' ) ) {
die( 'No direct script access allowed' );
}
get_header();
?>
<div class="g1-primary-max">
<div id="content" role="main">
<?php
while ( have_posts() ) : the_post();
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> itemscope=""
itemtype="<?php echo esc_attr( bimber_get_entry_microdata_itemtype() ); ?>">
<header class="page-header page-header-01 g1-row g1-row-layout-page">
<div class="g1-row-inner">
<div class="g1-column">
<h1 class="g1-alpha g1-alpha-2nd page-title">E-GAZETE</h1>
</div>
</div>
<div class="g1-row-background"></div>
</header>
<div <?php bimber_render_page_body_class(); ?>>
<div class="g1-row-background">
</div>
<div class="g1-row-inner">
<div id="primary" class="g1-column">
<?php
bimber_render_entry_featured_media( array(
'size' => 'bimber-grid-2of3',
'class' => 'entry-featured-media-main',
'use_microdata' => true,
'apply_link' => false,
'allow_video' => true,
) );
?>
<div class="entry-content" <?php bimber_render_microdata( array( 'itemprop' => 'text' ) ); ?>>
<?php
date_default_timezone_set('Europe/Istanbul');
global $post;
?>
<div style="margin-bottom: 4px;">
Tarih: <input type="text" id="tarih_sec" value="<?php echo get_the_date("d-m-Y"); ?>"/>
<img src="<?php echo GUNLUK_GAZETE_PLG_URL.'loader.gif'; ?>" class="loaderr" style="display: none;width: 34px; line-height: 1; vertical-align: top; margin-left: 5px;"/>
</div>
<?php
$pdf = get_post_meta($post->ID, 'wp_custom_attachment', true);
if( $pdf && $pdf['url']!=='' ){
?>
<style>
#the-canvas {
border:1px solid black;
width: 100%;
margin-top: 10px;
}
</style>
<script src="//mozilla.github.io/pdf.js/build/pdf.js"></script>
<div>
<button id="prev">Geri</button>
<button id="next">İleri</button>
<span>Sayfa: <span id="page_num"></span> / <span id="page_count"></span></span>
</div>
<canvas id="the-canvas"></canvas>
<script>
var url = '<?php echo $pdf["url"]; ?>';
var pdfjsLib = window['pdfjs-dist/build/pdf'];
pdfjsLib.GlobalWorkerOptions.workerSrc = '//mozilla.github.io/pdf.js/build/pdf.worker.js';
var pdfDoc = null,
pageNum = 1,
pageRendering = false,
pageNumPending = null,
scale = 1,
canvas = document.getElementById('the-canvas'),
ctx = canvas.getContext('2d');
function renderPage(num) {
pageRendering = true;
pdfDoc.getPage(num).then(function(page) {
var viewport = page.getViewport({scale: scale});
canvas.height = viewport.height;
canvas.width = viewport.width;
var renderContext = {
canvasContext: ctx,
viewport: viewport
};
var renderTask = page.render(renderContext);
renderTask.promise.then(function() {
pageRendering = false;
if (pageNumPending !== null) {
renderPage(pageNumPending);
pageNumPending = null;
}
});
});
document.getElementById('page_num').textContent = num;
}
function queueRenderPage(num) {
if (pageRendering) {
pageNumPending = num;
} else {
renderPage(num);
}
}
function onPrevPage() {
if (pageNum <= 1) {
return;
}
pageNum--;
queueRenderPage(pageNum);
}
document.getElementById('prev').addEventListener('click', onPrevPage);
function onNextPage() {
if (pageNum >= pdfDoc.numPages) {
return;
}
pageNum++;
queueRenderPage(pageNum);
}
document.getElementById('next').addEventListener('click', onNextPage);
pdfjsLib.getDocument(url).promise.then(function(pdfDoc_) {
pdfDoc = pdfDoc_;
document.getElementById('page_count').textContent = pdfDoc.numPages;
renderPage(pageNum);
});
</script>
<?php
}
?>
<!--<iframe src="https://drive.google.com/file/d/<?php /*echo $last;*/ ?>/preview" width="100%" height="1200"></iframe>-->
</div><!-- .entry-content -->
</div>
</div>
</div>
</article>
<?php
endwhile;
?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_footer();