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
mahara
mahara
Commits
6f7e123d
Commit
6f7e123d
authored
Feb 04, 2019
by
Doris Tam
Browse files
Bug 1810990: blocktype: textbox aka notes
Change-Id: If2bdd2395e12e1cacaa903756f6d232f8519c486
parent
0aa44264
Changes
2
Hide whitespace changes
Inline
Side-by-side
htdocs/testing/classes/generator/TestingDataGenerator.php
View file @
6f7e123d
...
...
@@ -1207,6 +1207,97 @@ EOD;
return
$configdata
;
}
/**
* generate configdata for the blocktype: textbox
*
* This function will create a textbox blockytpe(appears as note block on front-end)
* holding an html artefact
*
* @param string $data inside data column in blocktype tables
* @param string $ownertype of user
* @param string $ownerid of the user
* @param string $title of block to be created* (when copytoall is true)
* @param object the current view to create block on
* @return array $configdata of key and values of db table
*/
public
static
function
generate_configdata_textbox
(
$data
,
$ownertype
,
$ownerid
,
$title
,
$view
)
{
if
(
!
$data
)
return
;
$configdata
=
array
();
$fields
=
explode
(
';'
,
$data
);
foreach
(
$fields
as
$field
)
{
list
(
$key
,
$value
)
=
explode
(
'='
,
$field
);
if
(
$key
==
'notetitle'
)
{
$artefactdata
[
'title'
]
=
trim
(
$value
);
}
if
(
$key
==
'text'
)
{
$artefactdata
[
'description'
]
=
trim
(
$value
);
}
if
(
$key
==
'allowcomments'
)
{
$artefactdata
[
'allowcomments'
]
=
strtolower
(
$value
)
==
'yes'
?
1
:
0
;
}
if
(
$key
==
'tags'
)
{
// noteblock expects tags in csv form (separated by commas)
$tags
=
explode
(
','
,
$value
);
$tagstring
=
array
();
foreach
(
$tags
as
$tag
)
{
$tagstring
[]
=
trim
(
$tag
);
}
$artefactdata
[
'tags'
]
=
$tagstring
;
}
if
(
$key
==
'attachments'
)
{
$attachments
=
explode
(
','
,
$value
);
foreach
(
$attachments
as
$attachment
)
{
$mediatype
=
self
::
get_mimetype
(
$attachment
);
// we need to find the id of the item we are trying to attach and save it as artefactid
if
(
!
$artefactid
=
get_field
(
'artefact'
,
'id'
,
'title'
,
$attachment
))
{
$artefactid
=
TestingDataGenerator
::
create_artefact
(
$attachment
,
$ownertype
,
$ownerid
,
$mediatype
);
TestingDataGenerator
::
file_creation
(
$artefactid
,
$attachment
,
$ownertype
,
$ownerid
);
}
$configdata
[
'artefactids'
][]
=
$artefactid
;
}
}
}
$artefact
=
new
ArtefactTypeHtml
(
0
,
null
);
$artefact
->
set
(
'title'
,
$artefactdata
[
'title'
]);
$newdescription
=
EmbeddedImage
::
prepare_embedded_images
(
$artefactdata
[
'description'
],
'textbox'
,
$artefact
->
get
(
'id'
),
$artefact
->
get
(
'group'
));
$artefact
->
set
(
'description'
,
$newdescription
);
$artefact
->
set
(
'allowcomments'
,
$artefactdata
[
'allowcomments'
]);
if
(
get_config
(
'licensemetadata'
))
{
$artefact
->
set
(
'license'
,
$values
[
'license'
]);
$artefact
->
set
(
'licensor'
,
$values
[
'licensor'
]);
$artefact
->
set
(
'licensorurl'
,
$values
[
'licensorurl'
]);
}
$artefact
->
set
(
'owner'
,
$ownerid
);
$artefact
->
set
(
'tags'
,
$artefactdata
[
'tags'
]);
$artefact
->
commit
();
$configdata
[
'artefactid'
]
=
$artefact
->
get
(
'id'
);
foreach
(
$configdata
[
'artefactids'
]
as
$artefactid
)
{
$artefact
->
attach
(
$artefactid
);
}
$newdescription
=
EmbeddedImage
::
prepare_embedded_images
(
$artefact
->
get
(
'description'
),
'textbox'
,
$artefact
->
get
(
'id'
),
$view
->
get
(
'group'
));
if
(
$newdescription
!==
$artefact
->
get
(
'description'
))
{
$updatedartefact
=
new
stdClass
();
$updatedartefact
->
id
=
$artefact
->
get
(
'id'
);
$updatedartefact
->
description
=
$newdescription
;
update_record
(
'artefact'
,
$updatedartefact
,
'id'
);
}
// Add attachments, if there are any...
$new
=
update_attachments
(
$artefact
,
$configdata
[
'artefactids'
]);
update_attachments
(
$artefact
,
$configdata
[
'artefactids'
],
null
,
null
,
true
);
// TODO: Add attachments, if there are any...
//update_attachments($artefact, $configdata['artefactids'], null, null, true);
return
$configdata
;
}
/**
* generate configdata for the bloctype: peerassessment
* @param string $data inside data column in blocktype tables
...
...
test/behat/features/user_content/test.feature
View file @
6f7e123d
...
...
@@ -72,40 +72,42 @@ Background:
And the following "blocks" exist
:
|
title
|
type
|
page
|
retractable
|
data
|
|
My
text
1
|
text
|
Page
UserA_00
|
yes
|
This
is
some
text
|
|
image
jpg
|
image
|
Page
UserA_00
|
no
|
attachment=Image1.jpg;
width=100
|
|
image
png
|
image
|
Page
UserA_00
|
no
|
attachment=Image2.png
|
|
My
files
1
|
filedownload
|
Page
UserA_00
|
auto
|
attachments=mahara_about.pdf
|
|
My
files
2
|
filedownload
|
Page
UserA_00
|
no
|
attachments=mahara_about.pdf,Image2.png
|
|
Rss
news
|
externalfeed
|
Page
UserA_00
|
No
|
source=http://rss.nzherald.co.nz/rss/xml/nzhtsrsscid_000000698.xml;count=5
|
|
Rss
food
|
externalfeed
|
Page
UserA_00
|
no
|
source=http://www.thekitchenmaid.com/feed;count=3
|
|
G
image
3
|
image
|
Page
Grp1
|
no
|
attachment=Image3.png
|
|
G
files
2
|
filedownload
|
Page
Grp1
|
no
|
attachments=mahara_about.pdf,Image2.png,testvid3.mp4,mahara.mp3
|
|
nzslang
|
externalvideo
|
Page
Grp1
|
no
|
source=https://youtu.be/yRxFm70nOrY
|
|
my
social
|
socialprofile
|
Page
UserB_00
|
no
|
sns=instagram,twitter,facebook,tumblr,pinterest,mysocialmedia
|
|
gall
style1
|
gallery
|
Page
UserB_00
|
no
|
attachments=Image1.jpg,Image3.png,Image3.png,Image2.png;imagesel=2;showdesc=yes;width=75;imagestyle=1;photoframe=1
|
|
gall
style2
|
gallery
|
Page
UserB_00
|
yes
|
attachments=Image3.png,Image2.png,Image1.jpg;imagesel=2;showdesc=yes;width=75;imagestyle=2
|
|
gall
style3
|
gallery
|
Page
UserB_00
|
yes
|
attachments=Image3.png,Image2.png,Image1.jpg;imagesel=2;showdesc=no;imagestyle=3;photoframe=0
|
|
myfolder
|
folder
|
Page
UserB_00
|
no
|
attachments=mahara_about.pdf,Image2.png,Image1.jpg,Image3.png,mahara.mp3;dirname=myfolder
|
|
my
html
|
html
|
Page
UserB_00
|
yes
|
attachment=test_html.html
|
|
my
blog
|
blog
|
Page
One
|
no
|
copytype=nocopy;count=5;journaltitle=journal1
|
|
my
blogpost
|
blogpost
|
Page
One
|
no
|
copytype=nocopy;journaltitle=journal1;entrytitle=Entry
Two
|
|
Comments
|
comment
|
Page
One
|
|
|
|
PeerAssessmt
|
peerassessment
|
Page
One
|
auto
|
|
|
creativecoms
|
creativecommons
|
Page
One
|
no
|
commercialuse=yes;license=3.0;allowmods=no
|
|
my
nav
|
navigation
|
Page
Two
|
no
|
collection=collection
one;copytoall=yes
|
|
my
plan
|
plans
|
Page
Two
|
no
|
plans=Plan
One,Plan
Two;tasksdisplaycount=10
|
|
internalm
v
|
internalmedia
|
Page
Three
|
no
|
attachment=testvid3.mp4
|
|
internalm
a
|
internalmedia
|
Page
Three
|
no
|
attachment=mahara.mp3
|
|
my
pdf
|
pdf
|
Page
Three
|
no
|
attachment=mahara_about.pdf
|
|
recentposts
|
recentforumposts
|
Page
Three
|
no
|
groupname=Group1;maxposts=3
|
|
nzslang
|
externalvideo
|
Page
Three
|
no
|
source=https://youtu.be/yRxFm70nOrY
|
|
title
|
type
|
page
|
retractable
|
data
|
|
Text
|
text
|
Page
UserA_00
|
yes
|
This
is
some
text
|
|
Image
JPG
|
image
|
Page
UserA_00
|
no
|
attachment=Image1.jpg;
width=100
|
|
Image
PNG
|
image
|
Page
UserA_00
|
no
|
attachment=Image2.png
|
|
Files
to
download
|
filedownload
|
Page
UserA_00
|
auto
|
attachments=mahara_about.pdf
|
|
Files
to
download
|
filedownload
|
Page
UserA_00
|
no
|
attachments=mahara_about.pdf,Image2.png
|
|
External
Feed
news
|
externalfeed
|
Page
UserA_00
|
No
|
source=http://rss.nzherald.co.nz/rss/xml/nzhtsrsscid_000000698.xml;count=5
|
|
External
Feed
food
|
externalfeed
|
Page
UserA_00
|
no
|
source=http://www.thekitchenmaid.com/feed;count=3
|
|
Image
|
image
|
Page
Grp1
|
no
|
attachment=Image3.png
|
|
Files
to
download
|
filedownload
|
Page
Grp1
|
no
|
attachments=mahara_about.pdf,Image2.png,testvid3.mp4,mahara.mp3
|
|
External
Video
|
externalvideo
|
Page
Grp1
|
no
|
source=https://youtu.be/yRxFm70nOrY
|
|
Social
Media
|
socialprofile
|
Page
UserB_00
|
no
|
sns=instagram,twitter,facebook,tumblr,pinterest,mysocialmedia
|
|
Gallery
style
1
|
gallery
|
Page
UserB_00
|
no
|
attachments=Image1.jpg,Image3.png,Image3.png,Image2.png;imagesel=2;showdesc=yes;width=75;imagestyle=1;photoframe=1
|
|
Gallery
style
2
|
gallery
|
Page
UserB_00
|
yes
|
attachments=Image3.png,Image2.png,Image1.jpg;imagesel=2;showdesc=yes;width=75;imagestyle=2
|
|
Gallery
style
3
|
gallery
|
Page
UserB_00
|
yes
|
attachments=Image3.png,Image2.png,Image1.jpg;imagesel=2;showdesc=no;imagestyle=3;photoframe=0
|
|
Folder
|
folder
|
Page
UserB_00
|
no
|
dirname=myfolder;attachments=mahara_about.pdf,Image2.png,Image1.jpg,Image3.png,mahara.mp3
|
|
Some
HTML
|
html
|
Page
UserB_00
|
yes
|
attachment=test_html.html
|
|
my
blog
|
blog
|
Page
One
|
no
|
copytype=nocopy;count=5;journaltitle=journal1
|
|
my
blogpost
|
blogpost
|
Page
One
|
no
|
copytype=nocopy;journaltitle=journal1;entrytitle=Entry
Two
|
|
Comments
|
comment
|
Page
One
|
|
no
configdata
|
|
Peer
Assessment
|
peerassessment
|
Page
One
|
auto
|
no
configdata
|
|
creativecoms
|
creativecommons
|
Page
One
|
no
|
commercialuse=yes;license=3.0;allowmods=no
|
|
my
nav
|
navigation
|
Page
Two
|
no
|
collection=collection
one;copytoall=yes
|
|
my
plan
|
plans
|
Page
Two
|
no
|
plans=Plan
One,Plan
Two;tasksdisplaycount=10
|
|
internalm
v
|
internalmedia
|
Page
Three
|
no
|
attachment=testvid3.mp4
|
|
internalm
a
|
internalmedia
|
Page
Three
|
no
|
attachment=mahara.mp3
|
|
my
pdf
|
pdf
|
Page
Three
|
no
|
attachment=mahara_about.pdf
|
|
recentposts
|
recentforumposts
|
Page
Three
|
no
|
groupname=Group1;maxposts=3
|
|
ExternalVideo
|
externalvideo
|
Page
Three
|
no
|
source=https://youtu.be/yRxFm70nOrY
|
|
note/textbox
|
textbox
|
Page
Three
|
no
|
notetitle=secretnote;text=ma
ha
ha
ha
ra!;tags=mahara,araham;attachments=Image3.png,Image2.png,Image1.jpg;allowcomments=yes
|
Scenario
:
Login as admin to change upload settings
...
...
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