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
931174a1
Commit
931174a1
authored
3 years ago
by
Maximilian Giller
Browse files
Options
Downloads
Patches
Plain Diff
Implemented listing spaces
parent
b52466ea
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#54711
passed
3 years ago
Stage: test
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
datasets/datasets.php
+2
-20
2 additions, 20 deletions
datasets/datasets.php
datasets/ks-datasets-database.php
+39
-0
39 additions, 0 deletions
datasets/ks-datasets-database.php
editor/js/interactions.js
+4
-3
4 additions, 3 deletions
editor/js/interactions.js
with
45 additions
and
23 deletions
datasets/datasets.php
+
2
−
20
View file @
931174a1
<?php
require_once
(
__DIR__
.
"/ks-datasets-database.php"
);
$EMPTY_SPACE
=
'{"links":[],"nodes":[]}'
;
$SPACES_DIR
=
__DIR__
.
"/spaces/"
;
...
...
@@ -21,7 +22,7 @@ function kg_get_space() {
add_action
(
"wp_ajax_list_spaces"
,
"kg_list_spaces"
);
// Fires only for logged-in-users
function
kg_list_spaces
()
{
$spaces
=
k
g_get_list_of
_spaces
();
$spaces
=
k
s_select
_spaces
();
$payload
=
array
(
"spaces"
=>
$spaces
);
echo
json_encode
(
$payload
);
...
...
@@ -66,25 +67,6 @@ function kg_get_space_file_path($space_id) {
return
$SPACES_DIR
.
$space_id
.
".json"
;
}
function
kg_get_list_of_spaces
()
{
global
$SPACES_DIR
;
$all_files
=
scandir
(
$SPACES_DIR
);
if
(
$all_files
==
false
)
{
return
[];
}
$spaces
=
[];
foreach
(
$all_files
as
$file
)
{
if
(
endsWith
(
$file
,
".json"
))
{
$spaces
[]
=
substr
(
$file
,
0
,
-
strlen
(
".json"
));
}
}
return
$spaces
;
}
function
kg_create_empty_space
(
$file_path
)
{
// Don't do anything, if it exists
if
(
file_exists
(
$file_path
))
{
...
...
This diff is collapsed.
Click to expand it.
datasets/ks-datasets-database.php
0 → 100644
+
39
−
0
View file @
931174a1
<?php
ini_set
(
'display_errors'
,
1
);
ini_set
(
'display_startup_errors'
,
1
);
error_reporting
(
E_ALL
);
require_once
(
__DIR__
.
"/../knowledge-space-database.php"
);
function
ks_insert_or_update_graph
(
$graph
)
{
}
function
ks_select_spaces
()
{
global
$SPACES_TABLE
;
$sql
=
"SELECT * FROM
$SPACES_TABLE
"
;
global
$wpdb
;
$results
=
$wpdb
->
get_results
(
$sql
);
// or die(mysql_error());
return
ks_spaces_to_array
(
$results
);
}
function
ks_spaces_to_array
(
$spaces
)
{
$array
=
array
();
foreach
(
$spaces
as
$space
)
{
$space_id
=
$space
->
space_id
;
$array_space
=
array
(
"space_id"
=>
$space_id
,
"name"
=>
$space
->
name
,
"description"
=>
$space
->
description
);
$array
[
$space_id
]
=
$array_space
;
}
return
$array
;
}
This diff is collapsed.
Click to expand it.
editor/js/interactions.js
+
4
−
3
View file @
931174a1
...
...
@@ -14,13 +14,14 @@ export function initInteractions() {
// Fill space dropdown
var
selectContainer
=
jQuery
(
"
#space-id-select
"
);
listAllSpaces
().
then
((
spaces
)
=>
{
spaces
.
forEach
(
space
=>
{
Object
.
keys
(
spaces
)
.
forEach
(
space
_id
=>
{
var
selectedTxt
=
""
;
if
(
space
===
SPACE
)
{
var
space
=
spaces
[
space_id
];
if
(
space
.
name
===
SPACE
)
{
selectedTxt
=
"
selected
"
;
}
var
child
=
"
<option
"
+
selectedTxt
+
"
value=
\"
"
+
space
+
"
\"
>
"
+
space
+
"
</option>
"
var
child
=
"
<option
"
+
selectedTxt
+
"
value=
\"
"
+
space
_id
+
"
\"
title=
\"
"
+
space
.
description
+
"
\"
>
"
+
space
.
name
+
"
</option>
"
selectContainer
.
append
(
child
);
});
});
...
...
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