-
Notifications
You must be signed in to change notification settings - Fork 1
/
AnchorNav.php
97 lines (76 loc) · 2.57 KB
/
AnchorNav.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
<?php
/*
######################################################################
PHP class for Typesetter CMS plugin Anchor Navigation
Author: J. Krausz
Date: 2018-07-09
Version 1.0-b1
######################################################################
*/
defined('is_running') or die('Not an entry point...');
class AnchorNav {
static function GetHead() {
global $page, $addonRelativeCode;
$page->css_user[] = $addonRelativeCode . '/AnchorNav.css';
$page->head_js[] = $addonRelativeCode . '/AnchorNav.js';
}
static function SectionTypes($section_types){
$section_types['AnchorNav'] = array();
$section_types['AnchorNav']['label'] = 'Anchor Navigation';
return $section_types;
}
static function NewSections($links){
global $addonRelativeCode;
foreach($links as $key => $section_type_arr){
if( $section_type_arr[0] == 'AnchorNav' ){
$links[$key] = array('AnchorNav', $addonRelativeCode . '/icons/section.png');
}
}
return $links;
}
static function DefaultContent($default_content, $type){
if( $type !== 'AnchorNav' ){
return $default_content;
}
global $addonRelativeCode;
if( $type == 'AnchorNav' ){
$newSection = array(
'content' => '<p>Anchor Navigation will be generated …</p>'
. '<noscript>'
. '<div class="alert alert-warning">Anchor Navigation: This component requires JavaScript enabled!</div>'
. '</noscript>',
'attributes' => array(
'data-navsize' => 'md',
'data-navalign' => 'left',
),
'gp_label' => 'Anchor Navigation',
'gp_color' => '#D22814',
);
}
return $newSection;
}
static function SaveSection($return, $section, $type){
global $page;
if( $type != 'AnchorNav' ){
return $return;
}
// msg('POST = ' . pre($_POST));
if( !empty($_POST['attributes']) && is_array($_POST['attributes']) ){
$page->file_sections[$section]['attributes'] = & $_POST['attributes'];
}
return true;
}
static function InlineEdit_Scripts($scripts, $type){
if( $type !== 'AnchorNav' ){
return $scripts;
}
global $addonRelativeCode, $addonCodeFolder, $addonFolderName;
// addon JS Data Object/basepath
$addonBasePath = (strpos($addonRelativeCode, 'addons/') > 0)
? '/addons/' . $addonFolderName
: '/data/_addoncode/' . $addonFolderName;
echo 'var AnchorNavEditor = { base : "' . $addonBasePath . '" }; ';
$scripts[] = $addonCodeFolder . '/AnchorNav_edit.js';
return $scripts;
}
}