Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
marcus-lodspeakr
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
uib-ub
Spesialsamlingene
marcus-lodspeakr
Commits
fa68ff3c
Commit
fa68ff3c
authored
13 years ago
by
alangrafu
Browse files
Options
Downloads
Patches
Plain Diff
Adding priorities when selecting a type from multiple candidates
parent
367e8889
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
classes/Utils.php
+37
-4
37 additions, 4 deletions
classes/Utils.php
common.inc.php
+4
-2
4 additions, 2 deletions
common.inc.php
index.php
+2
-22
2 additions, 22 deletions
index.php
with
43 additions
and
28 deletions
classes/Utils.php
+
37
−
4
View file @
fa68ff3c
...
@@ -87,7 +87,7 @@ class Utils{
...
@@ -87,7 +87,7 @@ class Utils{
foreach
(
$aux
as
$w
){
foreach
(
$aux
as
$w
){
$row
=
array
();
$row
=
array
();
foreach
(
$w
as
$k
=>
$v
){
foreach
(
$w
as
$k
=>
$v
){
$row
[
$k
][
'value'
]
=
$v
[
'value'
];
$row
[
$k
][
'value'
]
=
$v
[
'value'
];
if
(
$v
[
'type'
]
==
'uri'
){
if
(
$v
[
'type'
]
==
'uri'
){
$row
[
$k
][
'curie'
]
=
Utils
::
uri2curie
(
$v
[
'value'
]);
$row
[
$k
][
'curie'
]
=
Utils
::
uri2curie
(
$v
[
'value'
]);
...
@@ -358,11 +358,11 @@ class Utils{
...
@@ -358,11 +358,11 @@ class Utils{
if
(
!
isset
(
$value
[
'value'
])){
if
(
!
isset
(
$value
[
'value'
])){
$array
[
$key
]
=
Utils
::
internalize
(
$value
);
$array
[
$key
]
=
Utils
::
internalize
(
$value
);
/*if($firstKeyAppearance){
/*if($firstKeyAppearance){
$firstKeyAppearance = false;
$firstKeyAppearance = false;
$array['_first']=$array[$key];
$array['_first']=$array[$key];
}*/
}*/
}
else
{
}
else
{
if
(
$value
[
'uri'
]
==
1
){
if
(
isset
(
$value
[
'uri'
])
&&
$value
[
'uri'
]
==
1
){
$value
[
'value'
]
=
preg_replace
(
"|^"
.
$conf
[
'ns'
][
'local'
]
.
"|"
,
$conf
[
'basedir'
],
$value
[
'value'
]);
$value
[
'value'
]
=
preg_replace
(
"|^"
.
$conf
[
'ns'
][
'local'
]
.
"|"
,
$conf
[
'basedir'
],
$value
[
'value'
]);
$value
[
'curie'
]
=
Utils
::
uri2curie
(
$value
[
'value'
]);
$value
[
'curie'
]
=
Utils
::
uri2curie
(
$value
[
'value'
]);
$array
[
$key
]
=
$value
;
$array
[
$key
]
=
$value
;
...
@@ -417,6 +417,39 @@ class Utils{
...
@@ -417,6 +417,39 @@ class Utils{
}
}
public
static
function
getModelandView
(
$t
,
$extension
){
global
$conf
;
//Defining default views and models
$curieType
=
""
;
$modelFile
=
$conf
[
'model'
][
'default'
]
.
$conf
[
'model'
][
'extension'
]
.
"."
.
$extension
;
$viewFile
=
$conf
[
'view'
][
'default'
]
.
$conf
[
'view'
][
'extension'
]
.
"."
.
$extension
;
//Get the first class available
/* TODO: Allow user to priotize
* which class should be used
* Example: URI is foaf:Person and ex:Student
* If both, prefer ex:Student
*/
$typesAndValues
=
array
();
foreach
(
$t
as
$v
){
$curie
=
Utils
::
uri2curie
(
$v
);
$typesAndValues
[
$curie
]
=
0
;
if
(
isset
(
$conf
[
'types'
][
'priorities'
][
$curie
])
&&
$conf
[
'types'
][
'priorities'
][
$curie
]
>=
0
){
$typesAndValues
[
$curie
]
=
$conf
[
'types'
][
'priorities'
][
$curie
];
}
}
arsort
(
$typesAndValues
);
foreach
(
$typesAndValues
as
$v
=>
$w
){
$auxViewFile
=
$conf
[
'view'
][
'directory'
]
.
$v
.
$conf
[
'view'
][
'extension'
]
.
"."
.
$extension
;
$auxModelFile
=
$conf
[
'model'
][
'directory'
]
.
$v
.
$conf
[
'model'
][
'extension'
]
.
"."
.
$extension
;
if
(
file_exists
(
$auxModelFile
)
&&
file_exists
(
$auxViewFile
)
&&
$v
!=
null
){
$viewFile
=
$v
.
$conf
[
'view'
][
'extension'
]
.
"."
.
$extension
;
$modelFile
=
$v
.
$conf
[
'model'
][
'extension'
]
.
"."
.
$extension
;
break
;
}
}
return
array
(
$modelFile
,
$viewFile
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
common.inc.php
+
4
−
2
View file @
fa68ff3c
...
@@ -37,12 +37,14 @@ $conf['special']['class'] = 'classes/BasicSpecialFunction.php';
...
@@ -37,12 +37,14 @@ $conf['special']['class'] = 'classes/BasicSpecialFunction.php';
//Frontpage when user goes to http://example.org/
//Frontpage when user goes to http://example.org/
$conf
[
'root'
]
=
'special/index'
;
$conf
[
'root'
]
=
'special/index'
;
$conf
[
'extension_connector'
]
=
'.'
;
//Priority for rdfs:Resource (default). Priorities should be >=0
$conf
[
'types'
][
'priorities'
][
'rdfs:Resource'
]
=
-
1
;
//Debug
//Debug
$conf
[
'debug'
]
=
false
;
$conf
[
'debug'
]
=
false
;
$conf
[
'extension_connector'
]
=
'.'
;
include_once
(
'settings.inc.php'
);
include_once
(
'settings.inc.php'
);
$conf
[
'view'
][
'standard'
][
'baseUrl'
]
=
$conf
[
'basedir'
];
$conf
[
'view'
][
'standard'
][
'baseUrl'
]
=
$conf
[
'basedir'
];
...
...
This diff is collapsed.
Click to expand it.
index.php
+
2
−
22
View file @
fa68ff3c
...
@@ -108,28 +108,8 @@ $acceptContentType = $format;
...
@@ -108,28 +108,8 @@ $acceptContentType = $format;
//Check if files for model and view exist
//Check if files for model and view exist
$t
=
Queries
::
getClass
(
$uri
,
$endpoints
[
'local'
]);
$t
=
Queries
::
getClass
(
$uri
,
$endpoints
[
'local'
]);
//Defining default views and models
list
(
$modelFile
,
$viewFile
)
=
Utils
::
getModelandView
(
$t
,
$extension
);
$curieType
=
""
;
$modelFile
=
$conf
[
'model'
][
'default'
]
.
$conf
[
'model'
][
'extension'
]
.
"."
.
$extension
;
$viewFile
=
$conf
[
'view'
][
'default'
]
.
$conf
[
'view'
][
'extension'
]
.
"."
.
$extension
;
//Get the first class available
/* TODO: Allow user to priotize
* which class should be used
* Example: URI is foaf:Person and ex:Student
* If both, prefer ex:Student
*/
foreach
(
$t
as
$v
){
$curieType
=
Utils
::
uri2curie
(
$v
);
$auxViewFile
=
$conf
[
'view'
][
'directory'
]
.
$curieType
.
$conf
[
'view'
][
'extension'
]
.
"."
.
$extension
;
$auxModelFile
=
$conf
[
'model'
][
'directory'
]
.
$curieType
.
$conf
[
'model'
][
'extension'
]
.
"."
.
$extension
;
if
(
file_exists
(
$auxModelFile
)
&&
file_exists
(
$auxViewFile
)
&&
$curieType
!=
null
){
$viewFile
=
$curieType
.
$conf
[
'view'
][
'extension'
]
.
"."
.
$extension
;
$modelFile
=
$curieType
.
$conf
[
'model'
][
'extension'
]
.
"."
.
$extension
;
break
;
}
}
$base
=
$conf
[
'view'
][
'standard'
];
$base
=
$conf
[
'view'
][
'standard'
];
$base
[
'type'
]
=
$modelFile
;
$base
[
'type'
]
=
$modelFile
;
$base
[
'this'
][
'value'
]
=
$uri
;
$base
[
'this'
][
'value'
]
=
$uri
;
...
...
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