Skip to content
Snippets Groups Projects

ipa_haller_jan: QFQ-Wiki. refs #15634

Merged Jan Haller requested to merge ipa_haller_jan into develop
1 file
+ 158
82
Compare changes
  • Side-by-side
  • Inline
@@ -14,7 +14,7 @@ form={{form:SE}}
# Add variables from S- to R-store
10 {
sql = SELECT '{{action:SE::w}}' AS _action
, '{{wpId:SC0:alnumx}}' AS _wpId
, '{{wpId:SC0:alnumx}}' AS _wpId
, '{{wpIdPrevious:S0}}' AS _wpIdPrevious
, '{{sectionId:S0}}' AS _sectionId
, '{{sectionIdEnd:S0}}' AS _sectionIdEnd
@@ -25,145 +25,149 @@ form={{form:SE}}
# Only executed if record needs to be updated
20 {
sql = SELECT 1
FROM DUAL
sql = SELECT ''
FROM DUAL
WHERE FIND_IN_SET('{{action:RE}}', 'new,editAll,editSection')
content = hideLevel
# Copy information from previous record (except author) into new one
30 {
sql = UPDATE WikiPage AS wp1
JOIN WikiPage AS wp2
JOIN WikiPage AS wp2
ON wp2.id = '{{wpIdPrevious:R0}}'
SET wp1.wpIdParent = wp2.wpIdParent
, wp1.pageSlug = wp2.pageSlug
, wp1.name = wp2.name
, wp1.author = QIFEMPTY('{{feUser:T}}', 'anonymous')
, wp1.roUser = wp2.roUser
, wp1.roGroup = wp2.roGroup
, wp1.roPublic = wp2.roPublic
, wp1.rwUser = wp2.rwUser
, wp1.rwGroup = wp2.rwGroup
, wp1.rwPublic = wp2.rwPublic
, wp1.pageLock = wp2.pageLock
, wp1.imageBorder = wp2.imageBorder
WHERE wp1.id = '{{wpId:R0}}'
, wp1.pageSlug = wp2.pageSlug
, wp1.name = wp2.name
, wp1.author = QIFEMPTY('{{feUser:T}}', 'anonymous')
, wp1.roUser = wp2.roUser
, wp1.roGroup = wp2.roGroup
, wp1.roPublic = wp2.roPublic
, wp1.rwUser = wp2.rwUser
, wp1.rwGroup = wp2.rwGroup
, wp1.rwPublic = wp2.rwPublic
, wp1.pageLock = wp2.pageLock
, wp1.imageBorder = wp2.imageBorder
WHERE wp1.id = '{{wpId:R0}}'
}
# Update previous versions with the id of the current record
40 {
sql = UPDATE WikiPage SET wpIdCurrent = '{{wpId:R0}}'
WHERE IFNULL(wpIdCurrent, id) = '{{wpIdPrevious:R0}}'
WHERE IFNULL(wpIdCurrent, id) = '{{wpIdPrevious:R0}}'
}
# Update all versions with the id of the current record
50 {
sql = UPDATE WikiPage SET wpIdParent = '{{wpId:R0}}'
WHERE wpIdParent = '{{wpIdPrevious:R0}}'
WHERE wpIdParent = '{{wpIdPrevious:R0}}'
}
# Only executed if a section of the previous record has been edited
# Update previous uploads with the current id
60 {
sql = SELECT 1
FROM DUAL
sql = UPDATE WikiAttachment SET wpId = '{{wpId:R0}}'
WHERE wpId = '{{wpIdPrevious:R0}}'
}
# Only executed if a section of the previous record has been edited
70 {
sql = SELECT ''
FROM DUAL
WHERE '{{action:RE}}' = 'editSection'
content = hideLevel
# Executes the function getWikiContentSection() from the PHP-script
# Parses the first section of the content until where the editing began
70 {
80 {
sql = SELECT 'F:typo3conf/ext/qfq/wikiScript.php|call:getWikiContentSection|arg:sectionIdStart=1&sectionIdEnd={{sectionId:R0}}&id={{wpIdPrevious:R0}}&includeTag=true' AS _script
}
# Function returns the first section in V-Store
80 {
90 {
sql = SELECT '{{section:VE}}' AS _contentBefore
}
# Executes the function getWikiContentSection() from the PHP-script
# Parses the last section of the content from where the editing ended
90 {
100 {
sql = SELECT 'F:typo3conf/ext/qfq/wikiScript.php|call:getWikiContentSection|arg:sectionIdStart={{sectionIdEnd:R0}}&id={{wpIdPrevious:R0}}&includeTag=false' AS _script
}
# Function returns the last section in V-Store
100 {
110 {
sql = SELECT '{{section:VE}}' AS _contentAfter
}
# Update of the current record with the unchanged content
110 {
120 {
sql = UPDATE WikiPage SET content = CONCAT('{{contentBefore:RE}}', content, '{{contentAfter:RE}}')
WHERE id = '{{wpId:R0}}'
WHERE id = '{{wpId:R0}}'
}
}
}
# Sneaky reload of the page to remove SIP-URL after redirect from form
120 {
sql = SELECT '<script>window.location.href="{{baseUrl:Y}}{{pageSlug:T}}?wpId={{wpId:RE}}#{{headingTitle:RE}}";</script>'
FROM DUAL
130 {
sql = SELECT '<script>window.location.href="{{pageSlug:T}}?wpId={{wpId:RE}}#{{headingTitle:RE}}";</script>'
FROM DUAL
WHERE '{{action:RE}}' != ''
}
# If no id is in the R-store, the id of the root page will be used
130 {
140 {
sql = SELECT id AS _wpId
FROM WikiPage
FROM WikiPage
WHERE id = '{{wpId:R0}}'
altsql = SELECT id AS _wpId
FROM WikiPage
WHERE pageSlug = '{{pageSlug:T}}'
AND ISNULL(wpIdCurrent)
AND ISNULL(wpIdParent)
ORDER BY modified DESC
LIMIT 1
FROM WikiPage
WHERE pageSlug = '{{pageSlug:T}}'
AND ISNULL(wpIdCurrent)
AND ISNULL(wpIdParent)
ORDER BY modified DESC
LIMIT 1
}
# Executes the function checkWikiAccess() from the PHP-script
# Checks the privileges of the user
140 {
150 {
sql = SELECT 'F:typo3conf/ext/qfq/wikiScript.php|call:checkWikiAccess|arg:id={{wpId:R0}}' AS _script
}
# Function returns the user privileges in V-Store and render mode gets set accordingly
150 {
160 {
sql = SELECT CASE
WHEN '{{wikiAccess:VE}}' = 'ro' THEN '5'
WHEN '{{wikiAccess:VE}}' = 'rw' THEN '0'
WHEN '{{wikiAccess:VE}}' = 'off' THEN '5'
END AS _renderMode
WHEN '{{wikiAccess:VE}}' = 'ro' THEN '5'
WHEN '{{wikiAccess:VE}}' = 'rw' THEN '0'
WHEN '{{wikiAccess:VE}}' = 'off' THEN '5'
END AS _renderMode
}
# Grant access to developers
160 {
170 {
sql = SELECT IF('{{beUser:T}}' != '', '0', '{{renderMode:R0}}') AS _renderMode
}
# Prepare PDF Export
170 {
180 {
sql = SELECT CONCAT('U:id={{pageSlug:T}}&wpId={{wpId:R0}}&print=true'
, '&--disable-external-links'
, '&--margin-top=20'
, '&--margin-bottom=20'
, '&--margin-left=20'
, '&--margin-right=20'
, '&--header-left={{pageTitle:TE}}'
, '&--header-font-name=Open Sans'
, '&--header-spacing=5'
, '&--footer-left=[date]'
, '&--footer-right=[page]/[topage]'
, '&--footer-font-name=Open Sans'
, '&--footer-spacing=5'
, '&--footer-font-size=10'
, '&type=2'
, '&_sip=1'
, '|g:_blank|b:0|t:<span class="glyphicon glyphicon-print"></span> Print|d:Print wiki') AS '_pdf|pdfDownload|_hide'
, '&--disable-external-links'
, '&--margin-top=20'
, '&--margin-bottom=20'
, '&--margin-left=20'
, '&--margin-right=20'
, '&--header-left={{pageTitle:TE}}'
, '&--header-font-name=Open Sans'
, '&--header-spacing=5'
, '&--footer-left=[date]'
, '&--footer-right=[page]/[topage]'
, '&--footer-font-name=Open Sans'
, '&--footer-spacing=5'
, '&--footer-font-size=10'
, '&type=2'
, '&_sip=1'
, '|g:_blank|b:0|t:<span class="glyphicon glyphicon-print"></span> Print|d:Print wiki') AS '_pdf|pdfDownload|_hide'
}
# Dropdown for "Settings", "History", "Print" and "Add new page"
180 {
190 {
sql = SELECT CONCAT('z'
, '||p:{{pageSlug:T}}&form=wikiPage&r=', id, '|s|b:0|G:glyphicon glyphicon-cog|t:Settings|r:{{renderMode:RE}}'
, '||p:{{pageSlug:T}}&wpId={{wpId:R0}}&history=true|b:0|G:glyphicon glyphicon-backward|t:History'
@@ -178,8 +182,8 @@ sql = SELECT CONCAT('U:id={{pageSlug:T}}&wpId={{wpId:R0}}&print=true'
, '&rwPublic=', rwPublic
, '&pageLock=', pageLock
, '|s|b:0|G:glyphicon glyphicon-plus|t:Add new page|r:{{renderMode:RE}}'
) AS _link
FROM WikiPage
) AS _link
FROM WikiPage
WHERE id = '{{wpId:R0}}'
AND '{{history:RE}}' != 'true'
AND '{{print:RE}}' != 'true'
@@ -188,43 +192,115 @@ sql = SELECT CONCAT('U:id={{pageSlug:T}}&wpId={{wpId:R0}}&print=true'
# If no wiki page is found, a new one can be created
altsql = SELECT '<div style="float: right;">', 'p:{{pageSlug:T}}&form=wikiPage&r=0|s|b|N' AS _link, '</div>'
FROM DUAL
FROM DUAL
WHERE '{{history:RE}}' != 'true'
AND '{{beUser:T}}' != ''
AND '{{wpId:R0}}' = 0
rbeg = <div style="float: right;">
rend = </div>
}
# Executes function renderWiki() from the PHP-script
# Parses the content of the wiki page and returns it with edit links, replaced macros, etc.
190 {
200 {
sql = SELECT 'F:typo3conf/ext/qfq/wikiScript.php|call:renderWiki|arg:id={{wpId:R0}}&renderMode={{renderMode:RE}}&printMode={{print:RE}}' AS _script
FROM DUAL
FROM DUAL
WHERE '{{history:RE}}' != 'true'
AND ('{{wikiAccess:VE}}' != 'off'
OR '{{beUser:T}}' != '')
# User does not have the privileges to view the wiki page
altsql = SELECT '<p>Access denied. You don\'t have permissions to access "{{baseUrl:Y}}{{pageSlug:T}}".</p>'
FROM DUAL
altsql = SELECT '<p>Access denied. You don\'t have permissions to view this page.</p>'
FROM DUAL
WHERE '{{wpId:R0}}' != 0
AND '{{history:RE}}' != 'true'
}
# Style for container containing the files
210 {
sql = SELECT IF('{{print:RE}}' = 'true', 'show', 'none') AS _styleContainer
}
# Continue only when not in "History"
220 {
sql = SELECT ''
FROM DUAL
WHERE '{{history:RE}}' != 'true'
AND '{{wpId:R0}}' != 0
# Prepare link and container to toggle files
230 {
sql = SELECT CONCAT('</br>'
, '<a class="wiki-files-link" style="cursor:pointer;"'
, 'onclick="$(\'#wiki-files-chevron-{{wpId:R0}}\').toggleClass(\'glyphicon-chevron-down glyphicon-chevron-right\');'
, '$(\'#wiki-files-container-{{wpId:R0}}\').fadeToggle(\'fast\');">'
, '<span class="wiki-files-chevron glyphicon glyphicon-chevron-right" id="wiki-files-chevron-{{wpId:R0}}"></span>'
, 'Files ('
, COUNT(id)
, ')'
, '</a>'
, '<div class="wiki-files-container" style="display:{{styleContainer:RE}};" id="wiki-files-container-{{wpId:R0}}">'
)
FROM WikiAttachment
WHERE wpId = '{{wpId:R0}}'
AND pathFileName != ''
stail = </div>
# Files
240 {
sql = SELECT CONCAT('p:{{pageSlug:T}}&form=wikiUpload&r=', id, '|s|b|E') AS _link
, CONCAT('F:', pathFileName
, '|t:', QLEFT(SUBSTRING_INDEX(pathFileName, '/', -1), 30)
, '|d:', SUBSTRING_INDEX(pathFileName, '/', -1)
, '|o:', SUBSTRING_INDEX(pathFileName, '/', -1)
, '|s|b|g:_blank|G:glyphicon glyphicon-paperclip|M:file'
) AS _link
, feUser
, modified
, CONCAT('U:table=WikiAttachment&r=', id, '|q:Do you want to delete <i>', SUBSTRING_INDEX(pathFileName, '/', -1), '</i> ?') AS _paged
FROM WikiAttachment
WHERE wpId = '{{wpId:R0}}'
AND pathFileName != ''
AND '{{history:RE}}' != 'true'
ORDER BY modified ASC
shead = <table class="table qfq-table-100">
<thead>
<tr>
<th>{{'p:{{pageSlug:T}}&form=wikiUpload&r=0&wpId={{wpId:R0}}|s|b|N' AS _link}}</th>
<th>File</th>
<th>User</th>
<th>Date</th>
<th></th>
</tr>
</thead>
<tbody>
stail = </tbody>
</table>
fbeg = <td>
fend = </td>
rbeg = <tr>
rend = </tr>
}
}
}
# History of the wiki page
200 {
250 {
sql = SELECT created, author
FROM WikiPage
FROM WikiPage
WHERE IFNULL(wpIdCurrent, id) = '{{wpId:R0}}'
AND pageSlug = '{{pageSlug:T}}'
AND '{{history:RE}}' = 'true'
ORDER BY created DESC
head = <table class="table qfq-table-50"><thead><tr><th>Updated</th><th>Author</th></thead><tbody>
tail = </tbody></table>
fbeg = <td>
fend = </td>
rbeg = <tr>
rend = </tr>
ORDER BY created DESC
head = {{'p:{{pageSlug:T}}&wpId={{wpId:R0}}|b|t:Back|G:glyphicon glyphicon-arrow-left' AS _link}}
<table class="table qfq-table-50"><thead><tr><th>Updated</th><th>Author</th></thead><tbody>
tail = </tbody></table>
fbeg = <td>
fend = </td>
rbeg = <tr>
rend = </tr>
}
\ No newline at end of file
Loading