This repository was archived by the owner on Mar 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmdocs-doc-preview.php
More file actions
97 lines (95 loc) · 3.17 KB
/
mdocs-doc-preview.php
File metadata and controls
97 lines (95 loc) · 3.17 KB
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
<?php
function mdocs_load_preview_head() {
?>
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<?php //wp_head(); ?>
<?php ?>
</head>
<body>
<?php
}
function mdocs_load_preview() {
if(isset($_POST['type']) && $_POST['type'] == 'file') {
$mdocs = get_option('mdocs-list');
mdocs_load_preview_head();
$found = false;
foreach($mdocs as $index => $the_mdoc) {
if(intval($the_mdoc['id']) == intval($_POST['mdocs_file_id']) && $found == false) {
$upload_dir = wp_upload_dir();
//$file_url = $upload_dir['baseurl'].MDOCS_DIR.$the_mdoc['filename'];
$file_url = get_site_url().'/?mdocs-file='.$the_mdoc['id'].'&mdocs-url='.$the_mdoc['parent'];
?>
<h1><?php echo $the_mdoc['filename']; ?></h1>
<?php
if(isset($_POST['is_admin'])) echo '<button class="mdocs-close-btn " onclick="mdocs_close_preview(\'admin\');">Close</button>';
else echo '<button class="mdocs-close-btn " onclick="mdocs_close_preview(\'wp\');">Close</button>';
?>
<div class="mdocs-clear-both"></div>
<?php mdocs_social($the_mdoc); ?></div>
<div class="mdocs-clear-both"></div>
<?php
mdocs_doc_preview($file_url);
$found = true;
break;
}
}
?>
</body>
<?php mdocs_social_scripts(); ?>
</html>
<?php
} elseif(isset($_POST['type']) && $_POST['type'] == 'img') {
$mdocs = get_option('mdocs-list');
mdocs_load_preview_head();
mdocs_social_scripts();
$found = false;
foreach($mdocs as $index => $the_mdoc) {
if(intval($the_mdoc['id']) == intval($_POST['mdocs_file_id']) && $found == false) {
?>
<h1><?php echo $the_mdoc['filename']; ?></h1>
<?php
if(isset($_POST['is_admin'])) echo '<button class="mdocs-close-btn " onclick="mdocs_close_preview(\'admin\');">Close</button>';
else echo '<button class="mdocs-close-btn " onclick="mdocs_close_preview(\'wp\');">Close</button>';
?>
<div class="mdocs-clear-both"></div>
<?php mdocs_social($the_mdoc); ?></div>
<div class="mdocs-clear-both"></div>
<?php
?>
<iframe class="mdocs-img-preview" src="?mdocs-img-preview=<?php echo $the_mdoc['filename']; ?>"></iframe>
<?php
$found = true;
break;
}
}
} elseif(isset($_POST['type']) && $_POST['type'] == 'show') {
global $mdocs_img_types;
$mdocs = get_option('mdocs-list');
$found = false;
foreach($mdocs as $index => $the_mdoc) {
if(intval($the_mdoc['id']) == intval($_POST['mdocs_file_id']) && $found == false) {
if($_POST['show_type'] == 'preview') {
$upload_dir = wp_upload_dir();
//$file_url = $upload_dir['baseurl'].MDOCS_DIR.$the_mdoc['filename'];
$file_url = get_site_url().'/?mdocs-file='.$the_mdoc['id'].'&mdocs-url='.$the_mdoc['parent'];
if(in_array($the_mdoc['type'], $mdocs_img_types)) { ?><iframe class="mdocs-img-preview" src="?mdocs-img-preview=<?php echo $the_mdoc['filename']; ?>"></iframe><?php }
else mdocs_doc_preview($file_url);
} else {
$mdocs_desc = apply_filters('the_content', $the_mdoc['desc']);
$mdocs_desc = str_replace('\\','',$mdocs_desc);
?>
<h3><?php _e('Description', 'mdocs'); ?></h3>
<div class="mdoc-desc">
<p><?php echo $mdocs_desc; ?></p>
</div>
<?php
}
$found = true;
break;
}
}
}
}