Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 14 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| LtiThemeDetailsProvider | |
0.00% |
0 / 14 |
|
0.00% |
0 / 2 |
56 | |
0.00% |
0 / 1 |
| getThemeId | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
12 | |||
| isHeadless | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
20 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; under version 2 |
| 7 | * of the License (non-upgradable). |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | * |
| 18 | * Copyright (c) 2017 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | namespace oat\taoLti\models\classes\theme; |
| 23 | |
| 24 | use oat\oatbox\PhpSerializable; |
| 25 | use oat\oatbox\PhpSerializeStateless; |
| 26 | use oat\tao\model\theme\ThemeDetailsProviderInterface; |
| 27 | use oat\taoLti\models\classes\TaoLtiSession; |
| 28 | |
| 29 | class LtiThemeDetailsProvider implements ThemeDetailsProviderInterface, PhpSerializable |
| 30 | { |
| 31 | use PhpSerializeStateless; |
| 32 | |
| 33 | public const LTI_CUSTOM_THEME_VARIABLE = 'custom_theme'; |
| 34 | public const LTI_PRESENTATION_TARGET = 'launch_presentation_document_target'; |
| 35 | |
| 36 | /** |
| 37 | * @inheritdoc |
| 38 | */ |
| 39 | public function getThemeId() |
| 40 | { |
| 41 | $currentSession = \common_session_SessionManager::getSession(); |
| 42 | if ($currentSession instanceof TaoLtiSession) { |
| 43 | $launchData = $currentSession->getLaunchData(); |
| 44 | if ($launchData->hasVariable(static::LTI_CUSTOM_THEME_VARIABLE)) { |
| 45 | return $launchData->getVariable(static::LTI_CUSTOM_THEME_VARIABLE); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | return ''; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Tells if the page has to be headless: without header and footer. |
| 54 | * |
| 55 | * @return bool|mixed |
| 56 | * @throws \common_exception_Error |
| 57 | * @throws \oat\taoLti\models\classes\LtiVariableMissingException |
| 58 | */ |
| 59 | public function isHeadless() |
| 60 | { |
| 61 | $currentSession = \common_session_SessionManager::getSession(); |
| 62 | if ($currentSession instanceof TaoLtiSession) { |
| 63 | $launchData = $currentSession->getLaunchData(); |
| 64 | $presentationTarget = $launchData->hasVariable(static::LTI_PRESENTATION_TARGET) |
| 65 | ? $launchData->getVariable(self::LTI_PRESENTATION_TARGET) |
| 66 | : ''; |
| 67 | return $presentationTarget == 'frame' || $presentationTarget == 'iframe'; |
| 68 | } |
| 69 | |
| 70 | return true; |
| 71 | } |
| 72 | } |