Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Open
LU Study Catalogue
Commits
b3a86ba3
Commit
b3a86ba3
authored
Oct 08, 2020
by
Dainis Abols
Browse files
First public version
2.4.2
parents
Pipeline
#139
failed with stages
in 0 seconds
Changes
42
Pipelines
2
Expand all
Show whitespace changes
Inline
Side-by-side
Classes/Controller/CourseController.php
0 → 100644
View file @
b3a86ba3
This diff is collapsed.
Click to expand it.
Classes/Domain/Model/StudyTypes.php
0 → 100644
View file @
b3a86ba3
<?php
namespace
Lu\LuStudyCatalogue\Domain\Model
;
use
Lu\LuStudyCatalogue\Helpers\DataHelper
;
use
TYPO3\CMS\Extbase\DomainObject\AbstractEntity
;
/**
* Class StudyTypes
*
* @author Dainis Abols <dainis.abols@lu.lv>
* @owner University of Latvia
* @version 2.0.0
* @since 25.07.2018
*
* @package Lu\LuStudyCatalogue\Domain\Model
*/
class
StudyTypes
extends
AbstractEntity
{
/**
* Define course catalogues
* This can also be put inside
*
* @return array
*/
private
function
catalogue
()
{
return
[
'course_catalogue'
,
'course_catalogue_continue'
,
'program_catalogue'
,
'program_catalogue_continue'
,
];
}
/**
* Return plain catalogue array for FlexForm dropdown usage
*
* @return array
*/
public
function
getAll
()
{
// Get plain catalogue array
$catalogue
=
$this
->
catalogue
();
// Define helpe
$DataHelper
=
new
DataHelper
();
$data
=
[];
foreach
(
$catalogue
as
$item
)
{
$data
[]
=
[
$DataHelper
->
getLangString
(
'catalogue.'
.
$item
),
$item
,
];
}
return
$data
;
}
}
\ No newline at end of file
Classes/Domain/Session/BackendSessionHandler.php
0 → 100644
View file @
b3a86ba3
<?php
namespace
Lu\LuStudyCatalogue\Domain\Session
;
/**
* Class BackendSessionHandler
*
* @author Dainis Abols <dainis.abols@lu.lv>
* @owner University of Latvia
* @version 2.0.0
* @since 25.07.2018
*
* @package Lu\LuStudyCatalogue\Domain\Session
*/
class
BackendSessionHandler
extends
SessionHandler
{
/**
* @var string
*/
protected
$mode
=
"BE"
;
}
\ No newline at end of file
Classes/Domain/Session/FrontendSessionHandler.php
0 → 100644
View file @
b3a86ba3
<?php
namespace
Lu\LuStudyCatalogue\Domain\Session
;
/**
* Class BackendSessionHandler
*
* @author Dainis Abols <dainis.abols@lu.lv>
* @owner University of Latvia
* @version 2.0.0
* @since 25.07.2018
*
* @package Lu\LuStudyCatalogue\Domain\Session
*/
class
FrontendSessionHandler
extends
SessionHandler
{
/**
* @var string
*/
protected
$mode
=
"FE"
;
}
\ No newline at end of file
Classes/Domain/Session/SessionHandler.php
0 → 100644
View file @
b3a86ba3
<?php
namespace
Lu\LuStudyCatalogue\Domain\Session
;
/**
* Class SessionHandler
*
* @author Dainis Abols <dainis.abols@lu.lv>
* @owner University of Latvia
* @version 2.0.0
* @since 25.07.2018
*
* @package Lu\LuStudyCatalogue\Domain\Session
*/
class
SessionHandler
{
/**
* Keeps TYPO3 mode.
* Either 'FE' or 'BE'.
*
* @var string
*/
protected
$mode
=
null
;
/**
* The User-Object with the session-methods.
* Either $GLOBALS['BE_USER'] or $GLOBALS['TSFE']->fe_user.
*
* @var object
*/
protected
$sessionObject
=
null
;
/**
* The key the data is stored in the session.
*
* @var string
*/
protected
$storageKey
=
'tx_lustudycatalogue'
;
/**
* Class constructor.
*
* @param string $mode
*
* @throws \Exception
*/
public
function
__construct
(
string
$mode
=
null
)
{
if
(
$mode
)
{
$this
->
mode
=
$mode
;
}
if
(
$this
->
mode
===
null
||
(
$this
->
mode
!=
"BE"
&&
$this
->
mode
!=
"FE"
))
{
throw
new
\
Exception
(
"Typo3-Mode is not defined!"
,
1388660107
);
}
$this
->
sessionObject
=
(
$this
->
mode
==
"BE"
)
?
$GLOBALS
[
'BE_USER'
]
:
$GLOBALS
[
'TSFE'
]
->
fe_user
;
}
/**
* Setter for storageKey
*
* @return void
*/
public
function
setStorageKey
(
$storageKey
)
{
$this
->
storageKey
=
$storageKey
;
}
/**
* Store value in session
*
* @param string $key
* @param mixed $value
*
* @return void
*/
public
function
store
(
$key
,
$value
)
{
$sessionData
=
$this
->
sessionObject
->
getSessionData
(
$this
->
storageKey
);
$sessionData
[
$key
]
=
$value
;
$this
->
sessionObject
->
setAndSaveSessionData
(
$this
->
storageKey
,
$sessionData
);
}
/**
* Delete value in session
*
* @param string $key
*
* @return void
*/
public
function
delete
(
$key
)
{
$sessionData
=
$this
->
sessionObject
->
getSessionData
(
$this
->
storageKey
);
unset
(
$sessionData
[
$key
]);
$this
->
sessionObject
->
setAndSaveSessionData
(
$this
->
storageKey
,
$sessionData
);
}
/**
* Read value from session
*
* @param string $key
*
* @return mixed
*/
public
function
get
(
$key
)
{
$sessionData
=
$this
->
sessionObject
->
getSessionData
(
$this
->
storageKey
);
return
isset
(
$sessionData
[
$key
])
?
$sessionData
[
$key
]
:
null
;
}
}
\ No newline at end of file
Classes/Helpers/DataHelper.php
0 → 100644
View file @
b3a86ba3
<?php
namespace
Lu\LuStudyCatalogue\Helpers
;
/**
* Class DataHelper
*
* @author Dainis Abols <dainis.abols@lu.lv>
* @owner University of Latvia
* @version 2.0.0
* @since 25.07.2018
*
* @package Lu\LuStudyCatalogue\Helpers
*/
class
DataHelper
{
/**
* Localisation prefix
*/
private
$L10N_PREFIX
=
'LLL:EXT:lu_study_catalogue/Resources/Private/Language/locallang.xlf'
;
/**
* Change language file location
*
* @param string $L10N_PREFIX
*/
public
function
setL10NPrefix
(
string
$L10N_PREFIX
)
{
$this
->
L10N_PREFIX
=
$L10N_PREFIX
;
}
/**
* Decode API returned JSON or return null, if failed
*
* @param $jsonData
*
* @return string
*/
public
function
APIDecode
(
$jsonData
)
{
// Decode result
$decoded
=
json_decode
(
$jsonData
,
true
);
if
(
$decoded
[
'code'
]
==
200
)
{
$data
=
$decoded
[
'data'
];
}
else
{
$data
=
null
;
}
return
$data
;
}
/**
* Retrieve language value for requested string
* @TODO: Implement different language requests
*
* @param string $string
*
* @return string
*/
public
function
getLangString
(
string
$string
):
string
{
return
$this
->
getLanguageService
()
->
sL
(
$this
->
L10N_PREFIX
.
':'
.
$string
);
}
/**
* Retrieve LanguageService
*
* @return mixed|\TYPO3\CMS\Lang\LanguageService
*/
private
function
getLanguageService
()
{
return
$GLOBALS
[
'LANG'
];
}
}
\ No newline at end of file
Classes/Hooks/FlexFormHooks.php
0 → 100644
View file @
b3a86ba3
<?php
namespace
Lu\LuStudyCatalogue\Hooks
;
use
Lu\LuStudyCatalogue\Domain\Model\StudyTypes
;
/**
* Class FlexFormHooks
*
* @author Dainis Abols <dainis.abols@lu.lv>
* @owner University of Latvia
* @version 2.0.0
* @since 25.07.2018
*
* @package Lu\LuStudyCatalogue\Hooks
*/
class
FlexFormHooks
{
/**
* Create navigation select menu
*
* @param array $config
*/
public
function
studyType
(
array
&
$config
)
{
// Preset menu
$optionList
=
$this
->
newOptionsList
(
true
);
// Get option list
$StudyTypesModel
=
new
StudyTypes
();
$optionList
=
array_merge
(
$optionList
,
$StudyTypesModel
->
getAll
());
// Merge into items
$config
[
'items'
]
=
array_merge
(
$config
[
'items'
],
$optionList
);
}
/**
* Create new empty options list with or without a first element
*
* @param bool $addFirstEmptyElement
*
* @return array
*/
private
function
newOptionsList
(
bool
$addFirstEmptyElement
=
null
)
{
if
(
$addFirstEmptyElement
)
{
return
[[
''
=>
''
]];
}
return
[];
}
}
\ No newline at end of file
Classes/Hooks/RealUrlAutoConfiguration.php
0 → 100644
View file @
b3a86ba3
<?php
namespace
Lu\LuStudyCatalogue\Hooks
;
/**
* Class RealUrlAutoConfiguration
* AutoConfiguration-Hook for RealURL
*
* @author Dainis Abols <dainis.abols@lu.lv>
* @owner University of Latvia
* @version 2.1.1
* @since 16.08.2018
*
* @package Lu\LuStudyCatalogue\Hooks
*/
class
RealUrlAutoConfiguration
{
/**
* Generates additional RealURL configuration and merges it with provided configuration
*
* @param array $params Default configuration
*
* @return array Updated configuration
*/
public
function
addRealUrlConfig
(
$params
)
{
return
array_merge_recursive
(
$params
[
'config'
],
[
'postVarSets'
=>
[
'_DEFAULT'
=>
[
// Studiju katalogi
'programma'
=>
[
[
'GETvar'
=>
'tx_lustudycatalogue_pi1[controller]'
,
'noMatch'
=>
'bypass'
,
],
[
'GETvar'
=>
'tx_lustudycatalogue_pi1[action]'
,
'noMatch'
=>
'bypass'
,
],
[
'GETvar'
=>
'tx_lustudycatalogue_pi1[program]'
,
],
],
'kurss'
=>
[
[
'GETvar'
=>
'tx_lustudycatalogue_pi1[controller]'
,
'noMatch'
=>
'bypass'
,
],
[
'GETvar'
=>
'tx_lustudycatalogue_pi1[action]'
,
'noMatch'
=>
'bypass'
,
],
[
'GETvar'
=>
'tx_lustudycatalogue_pi1[course]'
,
],
],
'catalogue'
=>
[
[
'GETvar'
=>
'tx_lustudycatalogue_pi1[@widget_0][currentPage]'
,
],
],
],
],
]
);
}
}
Classes/ViewHelpers/HeaderDataViewHelper.php
0 → 100644
View file @
b3a86ba3
<?php
namespace
Lu\LuStudyCatalogue\ViewHelpers
;
use
TYPO3\CMS\Core\Page\PageRenderer
;
use
TYPO3\CMS\Core\Utility\GeneralUtility
;
use
TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface
;
use
TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper
;
use
TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic
;
/**
* Class HeaderDataViewHelper
*
* @author Dainis Abols <dainis.abols@lu.lv>
* @owner University of Latvia
* @version 2.1.0
* @since 14.08.2018
*
* @package Lu\LuStudyCatalogue\ViewHelpers
*/
class
HeaderDataViewHelper
extends
AbstractViewHelper
{
use
CompileWithRenderStatic
;
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param \TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface $renderingContext
*/
public
static
function
renderStatic
(
array
$arguments
,
\
Closure
$renderChildrenClosure
,
RenderingContextInterface
$renderingContext
)
{
$pageRenderer
=
GeneralUtility
::
makeInstance
(
PageRenderer
::
class
);
$pageRenderer
->
addHeaderData
(
$renderChildrenClosure
());
}
}
Classes/ViewHelpers/IncludeFileViewHelper.php
0 → 100644
View file @
b3a86ba3
<?php
namespace
Lu\LuStudyCatalogue\ViewHelpers
;
use
TYPO3\CMS\Core\Page\PageRenderer
;
use
TYPO3\CMS\Core\Utility\GeneralUtility
;
use
TYPO3\CMS\Frontend\Resource\FilePathSanitizer
;
use
TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface
;
use
TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper
;
use
TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic
;
use
TYPO3Fluid\Fluid\Core\ViewHelper\ViewHelperInterface
;
/**
* Class IncludeFileViewHelper
*
* @author Dainis Abols <dainis.abols@lu.lv>
* @owner University of Latvia
* @version 2.1.0
* @since 14.08.2018
*
* @package Lu\LuStudyCatalogue\ViewHelpers
*/
class
IncludeFileViewHelper
extends
AbstractViewHelper
implements
ViewHelperInterface
{
use
CompileWithRenderStatic
;
/**
* Initialize arguments
*/
public
function
initializeArguments
()
{
$this
->
registerArgument
(
'path'
,
'string'
,
'Path to the CSS/JS file which should be included'
,
true
);
$this
->
registerArgument
(
'compress'
,
'bool'
,
'Define if file should be compressed'
,
false
,
false
);
}
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param \TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface $renderingContext
*
* @return mixed|string|void
*/
public
static
function
renderStatic
(
array
$arguments
,
\
Closure
$renderChildrenClosure
,
RenderingContextInterface
$renderingContext
)
{
$path
=
$arguments
[
'path'
];
$fileExists
=
file_exists
(
GeneralUtility
::
getFileAbsFileName
(
$path
));
$compress
=
(
bool
)
$arguments
[
'compress'
];
$pageRenderer
=
GeneralUtility
::
makeInstance
(
PageRenderer
::
class
);
if
(
!
$fileExists
)
{
return
;
}
if
(
TYPO3_MODE
===
'FE'
)
{
$sanitizer
=
GeneralUtility
::
makeInstance
(
FilePathSanitizer
::
class
);
$path
=
$sanitizer
->
sanitize
(
$path
);
// JS
if
(
strtolower
(
substr
(
$path
,
-
3
))
===
'.js'
)
{
$pageRenderer
->
addJsFooterFile
(
$path
,
null
,
$compress
);
// CSS
}
else
if
(
strtolower
(
substr
(
$path
,
-
4
))
===
'.css'
)
{
$pageRenderer
->
addCssFile
(
$path
,
'stylesheet'
,
'all'
,
''
,
$compress
);
}
}
else
{
// JS
if
(
strtolower
(
substr
(
$path
,
-
3
))
===
'.js'
)
{
$pageRenderer
->
addJsFooterFile
(
$path
,
null
,
$compress
);
// CSS
}
else
if
(
strtolower
(
substr
(
$path
,
-
4
))
===
'.css'
)
{
$pageRenderer
->
addCssFile
(
$path
,
'stylesheet'
,
'all'
,
''
,
$compress
);
}
}
}
}
Classes/ViewHelpers/Widget/Controller/PaginateController.php
0 → 100644
View file @
b3a86ba3
<?php
namespace
Lu\LuStudyCatalogue\ViewHelpers\Widget\Controller
;
use
TYPO3\CMS\Core\Utility\ArrayUtility
;
use
TYPO3\CMS\Core\Utility\GeneralUtility
;
use
TYPO3\CMS\Extbase\Utility\LocalizationUtility
;
use
TYPO3\CMS\Fluid\Core\Widget\AbstractWidgetController
;
/**
* Class PaginateController
*
* @author Dainis Abols <dainis.abols@lu.lv>
* @owner University of Latvia
* @version 2.1.0
* @since 14.08.2018
*
* @package Lu\LuStudyCatalogue\ViewHelpers\Widget\Controller
*/
class
PaginateController
extends
AbstractWidgetController
{
/**
* @var array
*/
protected
$configuration
=
[
'itemsPerPage'
=>
10
,
'insertAbove'
=>
false
,
'insertBelow'
=>
true
,
'maximumNumberOfLinks'
=>
3
,
'addQueryStringMethod'
=>
''
,
'section'
=>
''
,
];
/**
* @var QueryResultInterface|ObjectStorage|array
*/
protected
$objects
;
/**
* @var int
*/
protected
$currentPage
=
1
;
/**
* @var int
*/
protected
$maximumNumberOfLinks
=
3
;
/**
* @var int
*/
protected
$numberOfPages
=
1
;
/**
* @var int
*/
protected
$displayRangeStart
=
null
;
/**
* @var int
*/
protected
$displayRangeEnd
=
null
;
/**
* Initializes the current information on which page the visitor is.
*/
public
function
initializeAction
()
{
$this
->
objects
=
$this
->
widgetConfiguration
[
'objects'
];
ArrayUtility
::
mergeRecursiveWithOverrule
(
$this
->
configuration
,
$this
->
widgetConfiguration
[
'configuration'
],
false
);
$itemsPerPage
=
(
int
)
$this
->
configuration
[
'itemsPerPage'
];
$this
->
numberOfPages
=
$itemsPerPage
>
0
?
ceil
(
count
(
$this
->
objects
)
/
$itemsPerPage
)
:
0
;
$this
->
maximumNumberOfLinks
=
(
int
)
$this
->
configuration
[
'maximumNumberOfLinks'
];
}
/**
* @param int $currentPage
*/
public
function
indexAction
(
$currentPage
=
1
)
{
// set current page
$this
->
currentPage
=
(
int
)
$currentPage
;
if
(
$this
->
currentPage
<
1
)
{