-
Notifications
You must be signed in to change notification settings - Fork 0
/
ndoc.php
59 lines (44 loc) · 1.31 KB
/
ndoc.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
<?php
/**
name: Ndoc
url: http://tentaclecms.com
version: 1.0
description: Tentacles core Plugin
author:
name: Adam Patterson
url: http://adampatterson.ca
*/
event::on('shortcode', 'ndoc::shortcode', 2);
class ndoc {
static function shortcode($text='') {
add_shortcode( 'docs', 'ndoc' );
if (function_exists('do_shortcode'))
return do_shortcode( $text );
}
}
function ndoc ($file) {
$base_path = THEMES_DIR.ACTIVE_THEME.'/docs/files/';
require_once('markdown.php');
if (is_dir($base_path)) {
$uri_parts = explode('/', URI);
$uri_count = count($uri_parts);
$uri_file = end($uri_parts);
if ($uri_count < 2) {
$path = $base_path.$file[0];
} else {
$path = $base_path.$uri_file;
}
if (!file_exists($path))
return "Invalid file: ".$path;
$use_md = false;
if ( $use_md ) {
$markdown = file_get_contents($path);
$markdown_html = Markdown($markdown);
return $markdown_html;
} else {
return file_get_contents($path);
}
} else {
return "<p>Looks like you don't have a documents folder set up in your theme yet.</p> <p>Create a folder in your theme called <strong>/docs/files/<strong></p>";
}
}