Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Stephane Crozat
apisub
Commits
37c259f5
Commit
37c259f5
authored
Apr 10, 2019
by
Stephane Crozat
Browse files
Mise à jour de l'installation pour gérer les UUID, correction du script d'export XSLT
parent
3f7982af
Changes
5
Hide whitespace changes
Inline
Side-by-side
lib/views.php
View file @
37c259f5
...
...
@@ -44,8 +44,7 @@ class Views {
public
function
printUser
(
$isResp
,
$isAdmin
)
{
echo
"<div class='user'><span class='name'>
$this->firstname
$this->surname
</span> (<span class='login'>
$this->utclogin
</span>)</div>"
;
echo
"<div class='menu'>"
;
if
(
$isResp
)
{
actuels
if
(
$isResp
)
{
echo
'<a href="index.php?mode=resp">[Gérer ses Api]</a> '
;
}
if
(
$isAdmin
)
{
...
...
sql/apisub_admin.sql
View file @
37c259f5
...
...
@@ -16,7 +16,7 @@ CREATE TABLE config (
openend
DATE
NOT
NULL
);
INSERT
INTO
config
VALUES
(
'FALSE'
,
TO_DATE
(
'201
80
10
1
'
,
'YYYYMMDD'
),
TO_DATE
(
'2019
1231
'
,
'YYYYMMDD'
));
INSERT
INTO
config
VALUES
(
'FALSE'
,
TO_DATE
(
'201
904
10'
,
'YYYYMMDD'
),
TO_DATE
(
'2019
0603
'
,
'YYYYMMDD'
));
CREATE
OR
REPLACE
VIEW
vconfig
AS
SELECT
...
...
sql/apisub_tables.sql
View file @
37c259f5
...
...
@@ -3,13 +3,12 @@ BEGIN;
DROP
TABLE
IF
EXISTS
subscribe
CASCADE
;
DROP
TABLE
IF
EXISTS
api
CASCADE
;
DROP
TABLE
IF
EXISTS
localuser
CASCADE
;
DROP
TABLE
IF
EXISTS
utcstudent
;
CREATE
TABLE
localuser
(
utclogin
TEXT
PRIMARY
KEY
,
email
TEXT
,
surname
TEXT
,
firstname
TEXT
firstname
TEXT
);
CREATE
TABLE
api
(
...
...
sql/db_init.sh
View file @
37c259f5
...
...
@@ -10,5 +10,7 @@ psql -d apisub -f "$SQL/apisub_tables.sql"
psql
-d
apisub
-f
"
$SQL
/apisub_data.sql"
psql
-d
apisub
-c
"
\c
opy student (utclogin, level) FROM '
$SQL
/../data/students.csv' WITH CSV DELIMITER ','"
psql
-d
apisub
-f
"
$SQL
/apisub_views.sql"
psql
-d
apisub
-f
"
$SQL
/apisub_dataset.sql"
psql
-d
apisub
-c
"GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO apisub"
psql
-d
apisub
-c
'CREATE EXTENSION IF NOT EXISTS "uuid-ossp"'
# psql -d apisub -f "$SQL/apisub_dataset.sql"
tmp/export/export_sql.xsl
View file @
37c259f5
...
...
@@ -10,36 +10,50 @@
<xsl:output
method=
"text"
></xsl:output>
<xsl:template
match=
"/sc:item"
>
<xsl:text>
BEGIN;
</xsl:text>
<xsl:text>
INSERT INTO api (code,name,description,year,semester,dbegin,dend,size,ects,mail) VALUES
</xsl:text>
<xsl:apply-templates
select=
"of:webSite/sp:home/of:page/sp:subPage"
/>
;
<xsl:variable
name=
"logintitle"
>
Login UTC du responsable UTC
</xsl:variable>
<xsl:template
match=
"/sc:item"
>
<xsl:apply-templates
select=
"of:webSite/sp:home/of:page/sp:subPage"
mode=
"login"
/>
<xsl:text>
BEGIN;
</xsl:text>
<xsl:apply-templates
select=
"of:webSite/sp:home/of:page/sp:subPage"
/>
<xsl:text>
COMMIT;
</xsl:text>
</xsl:template>
<xsl:template
match=
"sp:subPage"
mode=
"login"
>
<xsl:text>
INSERT INTO localuser (utclogin) VALUES ('
</xsl:text>
<xsl:value-of
select=
"document(@sc:refUri)/sc:item//sp:info[of:block/of:blockM/sp:title=$logintitle]//sc:para[1]"
/>
<xsl:text>
');
</xsl:text>
</xsl:template>
<xsl:template
match=
"sp:subPage"
>
<xsl:apply-templates
select=
"document(@sc:refUri)/sc:item"
mode=
"api"
>
<xsl:with-param
name=
"code"
>
<xsl:value-of
select=
"substring(@sc:refUri,string-length(@sc:refUri)-11,4)"
/>
</xsl:with-param>
</xsl:apply-templates>
<xsl:if
test=
"following::sp:subPage"
>
,
</xsl:if>
</xsl:apply-templates>
</xsl:template>
<xsl:template
match=
"sc:item"
mode=
"api"
>
<xsl:param
name=
"code"
/>
<xsl:variable
name=
"id"
>
uuid_generate_v4()
</xsl:variable>
<xsl:variable
name=
"begin"
>
<xsl:value-of
select=
"substring(.//sp:info[of:block/of:blockM/sp:title='Période']//sc:para[1],1,5)"
/>
</xsl:variable>
<xsl:variable
name=
"title"
>
<xsl:value-of
select=
"replace(of:section/of:sectionM/sp:title,'''','''''')"
/>
</xsl:variable>
<xsl:variable
name=
"longtitle"
>
<xsl:value-of
select=
"replace(.//sp:emphasis[1]//sc:para[1],'''','''''')"
/>
</xsl:variable>
<xsl:variable
name=
"begin"
>
<xsl:value-of
select=
"substring(.//sp:info[of:block/of:blockM/sp:title='Période']//sc:para[1],1,5)"
/>
</xsl:variable>
<xsl:variable
name=
"end"
>
<xsl:value-of
select=
"substring(.//sp:info[of:block/of:blockM/sp:title='Période']//sc:para[1],7,11)"
/>
<xsl:variable
name=
"duration"
>
<xsl:value-of
select=
"
number(substring(.//sp:info[of:block/of:blockM/sp:title='Période']//sc:para[1],7,2))
-
number(substring(.//sp:info[of:block/of:blockM/sp:title='Période']//sc:para[1],1,2))
+1
"
/>
</xsl:variable>
<xsl:variable
name=
"size"
>
<xsl:value-of
select=
"number(.//sp:info[of:block/of:blockM/sp:title='Capacité d''accueil']//sc:para[1])"
/>
...
...
@@ -47,24 +61,20 @@
<xsl:variable
name=
"ects"
>
<xsl:value-of
select=
"number(.//sp:info[of:block/of:blockM/sp:title='ECTS']//sc:para[1])"
/>
</xsl:variable>
<xsl:variable
name=
"mail"
>
<xsl:value-of
select=
".//sp:info[of:block/of:blockM/sp:title='Mail']//sc:para[1]"
/>
</xsl:variable>
(
<xsl:value-of
select=
"$code"
/>
,
'
<xsl:value-of
select=
"$title"
></xsl:value-of>
',
'
<xsl:value-of
select=
"$longtitle"
></xsl:value-of>
',
2019,
'H',
TO_DATE('
<xsl:value-of
select=
"$begin"
/>
/19','DD/MM/YY'),
TO_DATE('
<xsl:value-of
select=
"$end"
/>
/19','DD/MM/YY'),
<xsl:value-of
select=
"$size"
/>
,
<xsl:value-of
select=
"$ects"
/>
,
<xsl:choose>
<xsl:when
test=
"$mail=''"
>
NULL
</xsl:when>
<xsl:otherwise>
'
<xsl:value-of
select=
"$mail"
/>
'
</xsl:otherwise>
</xsl:choose>
)
<xsl:variable
name=
"login"
>
<xsl:value-of
select=
".//sp:info[of:block/of:blockM/sp:title=$logintitle]//sc:para[1]"
/>
</xsl:variable>
INSERT INTO api (id,dbegin,code,name,description,duration,size,ects,resplogin) VALUES (
<xsl:value-of
select=
"$id"
/>
,
TO_DATE('
<xsl:value-of
select=
"$begin"
/>
/19','DD/MM/YY'),
<xsl:value-of
select=
"$code"
/>
,
'
<xsl:value-of
select=
"$title"
></xsl:value-of>
',
'
<xsl:value-of
select=
"$longtitle"
></xsl:value-of>
',
<xsl:value-of
select=
"$duration"
/>
,
<xsl:value-of
select=
"$size"
/>
,
<xsl:value-of
select=
"$ects"
/>
,
'
<xsl:value-of
select=
"$login"
/>
'
<xsl:text>
);
</xsl:text>
</xsl:template>
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment