Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Knowledge Space WP Plugin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
alg
Knowledge Space WP Plugin
Commits
f6494ea0
Commit
f6494ea0
authored
3 years ago
by
Maximilian Giller
Browse files
Options
Downloads
Patches
Plain Diff
Implented adming pages
parent
e2e8b710
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
datasets/datasets.php
+10
-10
10 additions, 10 deletions
datasets/datasets.php
knowledge-space.php
+30
-5
30 additions, 5 deletions
knowledge-space.php
with
40 additions
and
15 deletions
datasets/datasets.php
+
10
−
10
View file @
f6494ea0
<?php
add_action
(
"wp_ajax_get_space"
,
"get_space"
);
// Fires only for logged-in-users
add_action
(
"wp_ajax_nopriv_get_space"
,
'get_space'
);
// Fires for everyone
function
get_space
()
{
$file_path
=
get_space_file_path
(
$_POST
[
"space"
]);
add_action
(
"wp_ajax_get_space"
,
"
kg_
get_space"
);
// Fires only for logged-in-users
add_action
(
"wp_ajax_nopriv_get_space"
,
'
kg_
get_space'
);
// Fires for everyone
function
kg_
get_space
()
{
$file_path
=
kg_
get_space_file_path
(
$_POST
[
"space"
]);
$content
=
file_get_contents
(
$file_path
);
echo
$content
;
wp_die
();
}
add_action
(
"wp_ajax_update_space"
,
"update_space"
);
// Fires only for logged-in-users
add_action
(
"wp_ajax_update_space"
,
"
kg_
update_space"
);
// Fires only for logged-in-users
//add_action("wp_ajax_nopriv_update_space", 'update_space' ); // Fires for everyone
function
update_space
()
{
function
kg_
update_space
()
{
// Check user capabilities
if
(
current_user_can
(
"edit_posts"
))
{
// Use json encoding.
$graph
=
stripslashes
(
$_POST
[
"graph"
]);
store_new_graph
(
$graph
,
$_POST
[
"space"
]);
kg_
store_new_graph
(
$graph
,
$_POST
[
"space"
]);
wp_die
();
}
else
{
...
...
@@ -26,8 +26,8 @@ function update_space() {
}
}
function
store_new_graph
(
$graph
,
$space_id
)
{
$file_path
=
get_space_file_path
(
$space_id
);
function
kg_
store_new_graph
(
$graph
,
$space_id
)
{
$file_path
=
kg_
get_space_file_path
(
$space_id
);
$result
=
file_put_contents
(
$file_path
,
$graph
);
//echo print_r($_POST);
...
...
@@ -37,6 +37,6 @@ function store_new_graph($graph, $space_id) {
echo
$result
;
}
function
get_space_file_path
(
$space_id
)
{
function
kg_
get_space_file_path
(
$space_id
)
{
return
__DIR__
.
"/"
.
$space_id
.
".json"
;
}
This diff is collapsed.
Click to expand it.
knowledge-space.php
+
30
−
5
View file @
f6494ea0
...
...
@@ -11,7 +11,7 @@ $GLOBALS['build'] = 'debug';
function
ks_add_graph
(
$atts
=
[]):
string
{
$space_id
=
get_space_id_from_atts
(
$atts
);
$space_id
=
kg_
get_space_id_from_atts
(
$atts
);
$div
=
'<div id="3d-graph"></div>'
;
// The id "3d-graph" indicates, that the javascript associated with this should automatically be executed
$plugin_dir
=
plugin_dir_url
(
__FILE__
);
...
...
@@ -27,15 +27,20 @@ function ks_add_graph($atts = []): string
wp_localize_script
(
"ks-display-js"
,
"space"
,
array
(
'id'
=>
$space_id
));
wp_localize_script
(
"ks-display-js"
,
"plugin"
,
array
(
'path'
=>
$plugin_dir
));
echo
$div
.
$variables
;
return
$div
.
$variables
;
// return $div . $variables . $script;
}
function
ks_echo_graph
(
$atts
=
[]):
void
{
echo
ks_add_graph
(
$atts
);
}
function
ks_add_editor
(
$atts
=
[])
{
ks_add_editor_dependencies
();
$space_id
=
get_space_id_from_atts
(
$atts
);
$space_id
=
kg_
get_space_id_from_atts
(
$atts
);
$plugin_dir
=
plugin_dir_url
(
__FILE__
);
wp_localize_script
(
"ks-editor-js"
,
"space"
,
array
(
'id'
=>
$space_id
));
wp_localize_script
(
"ks-editor-js"
,
"plugin"
,
array
(
'path'
=>
$plugin_dir
));
...
...
@@ -68,7 +73,7 @@ function kg_load_css()
wp_enqueue_style
(
'kg-style'
,
$plugin_dir
.
'kg-style.css'
);
}
function
escape_space_id
(
$id
)
function
kg_
escape_space_id
(
$id
)
{
return
str_replace
(
"
\\
"
,
...
...
@@ -81,15 +86,35 @@ function escape_space_id($id)
);
}
function
get_space_id_from_atts
(
$atts
)
function
kg_
get_space_id_from_atts
(
$atts
)
{
if
(
$atts
!=
""
&&
array_key_exists
(
"space"
,
$atts
))
{
return
escape_space_id
(
$atts
[
"space"
]);
return
kg_
escape_space_id
(
$atts
[
"space"
]);
}
else
{
return
"space"
;
}
}
add_action
(
'admin_menu'
,
'kg_editor_admin_add_page'
);
function
kg_editor_admin_add_page
()
{
add_menu_page
(
'Knowledge Space'
,
'Knowledge Space'
,
'edit_plugins'
,
'knowledge-space'
,
'ks_echo_graph'
);
add_submenu_page
(
'knowledge-space'
,
'Knowledge Space - Editor'
,
'Editor'
,
'edit_plugins'
,
'knowledge-space-editor'
,
'ks_add_editor'
);
}
require_once
(
__DIR__
.
'/datasets/datasets.php'
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment