From 794b160040e398213b5f1e5308bdbfee0ace058a Mon Sep 17 00:00:00 2001 From: Torsten Simon Date: Wed, 24 May 2023 16:43:20 +0200 Subject: [PATCH 1/5] build:migrate connector to postgresql + add deployments for postgres --- README.md | 11 + deploy/docker/build/pom.xml | 2 +- .../build/{mysql => postgresql}/pom.xml | 6 +- .../src/main/build/Dockerfile | 2 +- .../src/main/compose/2_connector-common.yml | 15 +- .../src/main/compose/2_connector-remote.yml | 2 +- .../src/main/chart/templates/statefulset.yml | 22 +- deploy/docker/pom.xml | 8 +- service/Dockerfile | 5 +- service/src/main/docker/entrypoint.sh | 10 +- service/src/main/php/bootstrap.php | 11 +- service/src/main/php/config.dist.php | 3 + .../src/main/php/install/_tmpl/sql/h5p.ddl | 85 +++ service/src/main/php/install/createDb.php | 101 +-- service/src/main/php/src/lib/Database.php | 20 + service/src/main/php/src/tools/h5p/H5P.php | 4 +- .../main/php/src/tools/h5p/H5PFramework.php | 679 ++++-------------- 17 files changed, 308 insertions(+), 678 deletions(-) rename deploy/docker/build/{mysql => postgresql}/pom.xml (94%) rename deploy/docker/build/{mysql => postgresql}/src/main/build/Dockerfile (91%) create mode 100644 service/src/main/php/install/_tmpl/sql/h5p.ddl create mode 100644 service/src/main/php/src/lib/Database.php diff --git a/README.md b/README.md index d9c77cb..7530a18 100755 --- a/README.md +++ b/README.md @@ -24,6 +24,17 @@ To use the H5P editor you need to install and configure a database. At this time - __DBPASSWORD__ the users password - __DBNAME__ name of the database - Create database tables by executing `php eduConnector/install/createDb.php` + +To enable the h5p editing, please add the following into your `edu-sharing.conf` in the repository (Admin Tools / Global system configuration): +``` +connectorList.connectors+={ + id:"H5P", icon:"edit", showNew: true, onlyDesktop: true, hasViewMode: false, + filetypes:[ + {mimetype: "application/zip",filetype: "h5p", ccressourcetype: "h5p", createable: true,editable: true} + ] +} +``` + ### OnlyOffice - Setup the OnlyOffice Document Server (see https://helpcenter.onlyoffice.com/de/server/document.aspx) - Set values for diff --git a/deploy/docker/build/pom.xml b/deploy/docker/build/pom.xml index 9cf8f36..f86579d 100644 --- a/deploy/docker/build/pom.xml +++ b/deploy/docker/build/pom.xml @@ -35,6 +35,6 @@ - mysql + postgresql \ No newline at end of file diff --git a/deploy/docker/build/mysql/pom.xml b/deploy/docker/build/postgresql/pom.xml similarity index 94% rename from deploy/docker/build/mysql/pom.xml rename to deploy/docker/build/postgresql/pom.xml index 7a405d3..a433c8b 100644 --- a/deploy/docker/build/mysql/pom.xml +++ b/deploy/docker/build/postgresql/pom.xml @@ -10,10 +10,10 @@ ../pom.xml - edu_sharing-community-services-connector-deploy-docker-build-mysql + edu_sharing-community-services-connector-deploy-docker-build-postgres jar - edu_sharing-community-services-connector-deploy-docker-build-mysql + edu_sharing-community-services-connector-deploy-docker-build-posgtres @@ -42,7 +42,7 @@ - ${docker.repository}/${docker.prefix}-deploy-docker-build-mysql:${docker.tag} + ${docker.repository}/${docker.prefix}-deploy-docker-build-postgresql:${docker.tag} diff --git a/deploy/docker/build/mysql/src/main/build/Dockerfile b/deploy/docker/build/postgresql/src/main/build/Dockerfile similarity index 91% rename from deploy/docker/build/mysql/src/main/build/Dockerfile rename to deploy/docker/build/postgresql/src/main/build/Dockerfile index 858d6c7..4d213bf 100644 --- a/deploy/docker/build/mysql/src/main/build/Dockerfile +++ b/deploy/docker/build/postgresql/src/main/build/Dockerfile @@ -1,4 +1,4 @@ -FROM ${docker.from.mysql} +FROM ${docker.from.postgresql.server} ######################################################################################################################## diff --git a/deploy/docker/compose/src/main/compose/2_connector-common.yml b/deploy/docker/compose/src/main/compose/2_connector-common.yml index 79b248c..72dd261 100644 --- a/deploy/docker/compose/src/main/compose/2_connector-common.yml +++ b/deploy/docker/compose/src/main/compose/2_connector-common.yml @@ -2,15 +2,15 @@ version: "3.9" services: services-edu-connector-database: - image: "${docker.repository}/${docker.prefix}-deploy-docker-build-mysql:${docker.tag}" + image: "${docker.repository}/${docker.prefix}-deploy-docker-build-postgresql:${docker.tag}" container_name: "services-edu-connector-database_${COMPOSE_PROJECT_NAME}" environment: - MYSQL_USER: "${SERVICES_EDU_CONNECTOR_DATABASE_USER:-connector}" - MYSQL_PASSWORD: "${SERVICES_EDU_CONNECTOR_DATABASE_PASS:-connector}" - MYSQL_DATABASE: "${SERVICES_EDU_CONNECTOR_DATABASE_NAME:-connector}" - MYSQL_ROOT_PASSWORD: "${SERVICES_EDU_CONNECTOR_DATABASE_ROOT_PASS:-connector}" + POSTGRESQL_USERNAME: "${SERVICES_EDU_CONNECTOR_DATABASE_USER:-connector}" + POSTGRESQL_POSTGRES_PASSWORD: "${SERVICES_EDU_CONNECTOR_DATABASE_PASS:-connector}" + POSTGRESQL_DATABASE: "${SERVICES_EDU_CONNECTOR_DATABASE_NAME:-connector}" + POSTGRESQL_PASSWORD: "${SERVICES_EDU_CONNECTOR_DATABASE_ROOT_PASS:-connector}" volumes: - - services-edu-connector-database-data:/bitnami/mysql/data + - "services-edu-connector-database-data:/bitnami/postgresql" services-edu-connector-service: image: "${docker.repository}/${docker.prefix}-service:${docker.tag}" @@ -20,8 +20,9 @@ services: HOST_EXTERNAL: "${SERVICES_EDU_CONNECTOR_HOST_EXTERNAL:-edu.connector.127.0.0.1.nip.io}" PORT_EXTERNAL: "${SERVICES_EDU_CONNECTOR_PORT_EXTERNAL:-9200}" PATH_EXTERNAL: "${SERVICES_EDU_CONNECTOR_PATH_EXTERNAL:-}" + DATABASE_TYPE: pgsql DATABASE_HOST: services-edu-connector-database - DATABASE_PORT: "3306" + DATABASE_PORT: "5432" DATABASE_NAME: "${SERVICES_EDU_CONNECTOR_DATABASE_NAME:-connector}" DATABASE_USER: "${SERVICES_EDU_CONNECTOR_DATABASE_USER:-connector}" DATABASE_PASSWORD: "${SERVICES_EDU_CONNECTOR_DATABASE_PASS:-connector}" diff --git a/deploy/docker/compose/src/main/compose/2_connector-remote.yml b/deploy/docker/compose/src/main/compose/2_connector-remote.yml index 2648eae..7a06a4a 100644 --- a/deploy/docker/compose/src/main/compose/2_connector-remote.yml +++ b/deploy/docker/compose/src/main/compose/2_connector-remote.yml @@ -3,7 +3,7 @@ version: '3.7' services: services-edu-connector-database: - image: "${docker.registry}/${docker.repository}/${docker.prefix}-deploy-docker-build-mysql:${docker.tag}" + image: "${docker.registry}/${docker.repository}/${docker.prefix}-deploy-docker-build-postgres:${docker.tag}" services-edu-connector-service: image: "${docker.registry}/community/${docker.prefix}-service:${docker.tag}" diff --git a/deploy/docker/helm/src/main/chart/templates/statefulset.yml b/deploy/docker/helm/src/main/chart/templates/statefulset.yml index c3eaf49..ed1747d 100644 --- a/deploy/docker/helm/src/main/chart/templates/statefulset.yml +++ b/deploy/docker/helm/src/main/chart/templates/statefulset.yml @@ -88,17 +88,15 @@ spec: spec: containers: - name: edu-sharing-connector-db - image: mysql:8.0.31-debian + image: docker.edu-sharing.com/community/edu_sharing-community-services-connector-deploy-docker-build-posgtres:{{ .Values.version }} env: - - name: MYSQL_DATABASE + - name: POSTGRESQL_DATABASE value: connector - - name: MYSQL_USER + - name: POSTGRESQL_USERNAME value: connector - - name: MYSQL_ROOT_HOST - value: "%" - - name: MYSQL_PASSWORD + - name: POSTGRESQL_PASSWORD value: {{ .Values.passwordDB }} - - name: MYSQL_ROOT_PASSWORD + - name: POSTGRESQL_POSTGRES_PASSWORD value: {{ .Values.passwordDB }} resources: limits: @@ -107,12 +105,12 @@ spec: requests: cpu: "1000m" memory: "2Gi" - volumeMounts: - - name: data - mountPath: /var/lib/mysql ports: - - containerPort: 3306 - name: db + - name: db + containerPort: 5432 + volumeMounts: + - name: data + mountPath: /bitnami/postgresql volumeClaimTemplates: - metadata: diff --git a/deploy/docker/pom.xml b/deploy/docker/pom.xml index 89d7ab7..a298996 100644 --- a/deploy/docker/pom.xml +++ b/deploy/docker/pom.xml @@ -16,7 +16,13 @@ edu_sharing-community-services-connector-deploy-docker - dockerio.mirror.docker.edu-sharing.com/bitnami/mysql:8.0.32 + 13 + 9 + 0 + ${postgresql.version.major}.${postgresql.version.minor}.${postgresql.version.patch} + + dockerio.mirror.docker.edu-sharing.com/bitnami/postgresql:${postgresql.version} + diff --git a/service/Dockerfile b/service/Dockerfile index 7b321ca..d5bca27 100755 --- a/service/Dockerfile +++ b/service/Dockerfile @@ -20,11 +20,12 @@ FROM dockerio.mirror.docker.edu-sharing.com/php:8.1.12-apache RUN set -eux \ && apt-get update \ - && apt-get install -yqq wait-for-it libzip-dev curl xmlstarlet jq nano \ + && apt-get install -yqq wait-for-it libpq-dev libzip-dev curl xmlstarlet jq nano \ && a2enmod rewrite \ && ln -s $PHP_INI_DIR/php.ini-production $PHP_INI_DIR/php.ini \ && sed -i 's/max_execution_time = 30/max_execution_time = 120/g' $PHP_INI_DIR/php.ini \ - && docker-php-ext-install pdo pdo_mysql zip \ + && docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \ + && docker-php-ext-install pdo pdo_pgsql pgsql zip \ && apt-get clean \ && rm -r /var/lib/apt/lists/* diff --git a/service/src/main/docker/entrypoint.sh b/service/src/main/docker/entrypoint.sh index 9328be1..650c831 100644 --- a/service/src/main/docker/entrypoint.sh +++ b/service/src/main/docker/entrypoint.sh @@ -20,8 +20,6 @@ connector_database_port=${DATABASE_PORT//\/&/\\&} connector_database_user=${DATABASE_USER//\/&/\\&} connector_database_password=${DATABASE_PASSWORD//\/&/\\&} connector_database_name=${DATABASE_NAME//\/&/\\&} -connector_database_path=${connector_database_host}:${connector_database_port} - # OPTIONALS @@ -38,7 +36,9 @@ sed -i "s|define('WWWURL', '.*')|define('WWWURL', '${connector_url}')|g" "${conf sed -i "s|define('DOCROOT', '.*')|define('DOCROOT', '${ROOT}')|g" "${conf}" sed -i "s|define('DATA', '.*')|define('DATA', '${DATA}')|g" "${conf}" sed -i "s|define('LOG_MODE', '.*')|define('LOG_MODE', 'stdout')|g" "${conf}" -sed -i "s|define('DBHOST', '.*')|define('DBHOST', '${connector_database_path}')|g" "${conf}" +sed -i "s|define('DBTYPE', '.*')|define('DBTYPE', 'pgsql')|g" "${conf}" +sed -i "s|define('DBHOST', '.*')|define('DBHOST', '${connector_database_host}')|g" "${conf}" +sed -i "s|define('DBPORT', '.*')|define('DBPORT', '${connector_database_port}')|g" "${conf}" sed -i "s|define('DBUSER', '.*')|define('DBUSER', '${connector_database_user}')|g" "${conf}" sed -i "s|define('DBPASSWORD', '.*')|define('DBPASSWORD', '${connector_database_password}')|g" "${conf}" sed -i "s|define('DBNAME', '.*')|define('DBNAME', '${connector_database_name}')|g" "${conf}" @@ -53,7 +53,7 @@ sed -i "s|define('MOODLE_TOKEN', '.*')|define('MOODLE_TOKEN', '${moodle_token}') echo "Installing..." php install/install.php -printf "\nWaiting for mysql to come active\n" +printf "\nWaiting for postgres to come active\n" until wait-for-it "${connector_database_host}:${connector_database_port}" -t 3 do sleep 5 @@ -62,6 +62,8 @@ done echo "Initializing database..." php install/createDb.php +echo "" +echo "" echo "Connector is ready. Please register it at your repository (Admin Tools -> Remote-Systems) with the following url:" echo "${connector_url}/metadata" echo "" diff --git a/service/src/main/php/bootstrap.php b/service/src/main/php/bootstrap.php index e2cb29e..3acf299 100644 --- a/service/src/main/php/bootstrap.php +++ b/service/src/main/php/bootstrap.php @@ -81,8 +81,7 @@ //ajax.php needed because h5p concatenates GET parameters $app->post('/ajax/ajax.php', function (Request $request, Response $response) { global $db; - $db = new \PDO('mysql:host=' . DBHOST . ';dbname=' . DBNAME, DBUSER, DBPASSWORD); - $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $db = new \connector\lib\Database(); $contentHandler = new \connector\tools\h5p\H5PContentHandler(); $h5p = \connector\tools\h5p\H5P::getInstance(); @@ -93,7 +92,7 @@ } if(isset($request->getQueryParams()['action']) && $request->getQueryParams()['action']==='h5p_libraries') { - $db = new \PDO('mysql:host='.DBHOST.';dbname='.DBNAME, DBUSER, DBPASSWORD); + $db = new \connector\lib\Database(); $db->setAttribute( \PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION ); $libs = $h5p->H5PEditor->ajax->action(H5PEditorEndpoints::LIBRARIES); return $response->withStatus(200) @@ -102,8 +101,7 @@ } if(isset($request->getQueryParams()['action']) && $request->getQueryParams()['action']==='h5p_library-install') { - $db = new \PDO('mysql:host='.DBHOST.';dbname='.DBNAME, DBUSER, DBPASSWORD); - $db->setAttribute( \PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION ); + $db = new \connector\lib\Database(); $token = '';//$_GET['token']; $libs = $h5p->H5PEditor->ajax->action(H5PEditorEndpoints::LIBRARY_INSTALL, $token, $request->getQueryParams()['id']); return $response->withStatus(200) @@ -153,8 +151,7 @@ $this->get('log')->info($request->getUri()); global $db; try { - $db = new \PDO('mysql:host='.DBHOST.';dbname='.DBNAME, DBUSER, DBPASSWORD); - $db->setAttribute( \PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION ); + $db = new \connector\lib\Database(); $h5p = \connector\tools\h5p\H5P::getInstance(); if(isset($request->getQueryParams()['machineName']) && isset($request->getQueryParams()['majorVersion']) && isset($request->getQueryParams()['minorVersion'])) { diff --git a/service/src/main/php/config.dist.php b/service/src/main/php/config.dist.php index 4180e1b..6f43cc0 100644 --- a/service/src/main/php/config.dist.php +++ b/service/src/main/php/config.dist.php @@ -10,7 +10,10 @@ define('LOG_MODE', 'file'); /*h5p*/ +// either pgsql or mysql +define('DBTYPE', 'pgsql'); define('DBHOST', ''); +define('DBPORT', '5432'); define('DBUSER', ''); define('DBPASSWORD', ''); define('DBNAME', ''); diff --git a/service/src/main/php/install/_tmpl/sql/h5p.ddl b/service/src/main/php/install/_tmpl/sql/h5p.ddl new file mode 100644 index 0000000..90a4301 --- /dev/null +++ b/service/src/main/php/install/_tmpl/sql/h5p.ddl @@ -0,0 +1,85 @@ +CREATE TABLE h5p_libraries_languages ( + library_id integer NOT NULL, + translation text NOT NULL, + language_code varchar(31) NOT NULL); + +CREATE TABLE h5p_libraries ( + id SERIAL PRIMARY KEY, + fullscreen integer NOT NULL, + runnable integer NOT NULL, + name varchar(127) NOT NULL, + title varchar(255) NOT NULL, + has_icon integer NOT NULL DEFAULT '0' , + restricted integer NOT NULL DEFAULT '0' , + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + major_version integer NOT NULL, + updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + embed_types varchar(255) NOT NULL, + minor_version integer NOT NULL, + patch_version integer NOT NULL, + drop_library_css text NULL, + preloaded_js text NULL, + preloaded_css text NULL, + tutorial_url varchar(1023) NOT NULL, + semantics text NOT NULL); + +CREATE INDEX idx_h5p_libraries_name + ON h5p_libraries (name, title); + +CREATE TABLE h5p_libraries_libraries ( + library_id integer NOT NULL, + required_library_id integer NOT NULL, + dependency_type varchar(31) NOT NULL); + +CREATE TABLE h5p_contents ( + id SERIAL PRIMARY KEY, + library_id integer NOT NULL, + user_id integer NOT NULL, + license varchar(7) NULL, + parameters text NOT NULL, + title varchar(255) NOT NULL, + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , + author varchar(127) NULL, + updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , + slug varchar(127) NOT NULL, + keywords text NULL, + disable integer NOT NULL DEFAULT '0' , + content_type varchar(127) NULL, + embed_type varchar(127) NOT NULL, + filtered text NOT NULL, + description text NULL); + +CREATE INDEX idx_h5p_contents_title + ON h5p_contents (title); + +CREATE TABLE h5p_contents_libraries ( + id SERIAL PRIMARY KEY, + library_id integer NOT NULL, + drop_css integer NOT NULL, + content_id integer NOT NULL, + weight integer NOT NULL DEFAULT '0' , + dependency_type varchar(31) NOT NULL); + +CREATE TABLE h5p_libraries_hub_cache ( + id SERIAL PRIMARY KEY, + machine_name varchar(127) NOT NULL, + updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + keywords text NULL, + owner varchar(511) NULL, + screenshots text NULL, + tutorial varchar(511) NULL, + title varchar(255) NOT NULL, + minor_version integer NOT NULL, + popularity integer NOT NULL, + description text NOT NULL, + h5p_minor_version integer NULL, + h5p_major_version integer NULL, + categories text NULL, + icon varchar(511) NOT NULL, + license text NULL, + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + major_version integer NOT NULL, + summary text NOT NULL, + patch_version integer NOT NULL, + is_recommended integer NOT NULL, + example varchar(511) NOT NULL); diff --git a/service/src/main/php/install/createDb.php b/service/src/main/php/install/createDb.php index d405b3a..511b634 100644 --- a/service/src/main/php/install/createDb.php +++ b/service/src/main/php/install/createDb.php @@ -1,16 +1,17 @@ setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); -$pdo->exec("SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';"); - +$pdo = new \connector\lib\Database(); +if(DBTYPE === 'mysql') { + $pdo->exec("SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';"); + $pdo -> query("CREATE DATABASE IF NOT EXISTS `".DBNAME."`"); + $pdo -> query("USE `".DBNAME."`"); +} // refer to https://h5p.org/sites/default/files/class-h5p-plugin.txt -$pdo -> query("CREATE DATABASE IF NOT EXISTS `".DBNAME."`"); -$pdo -> query("USE `".DBNAME."`"); try { $result = $pdo->query("SELECT 1 FROM h5p_contents LIMIT 1"); @@ -19,92 +20,8 @@ } catch (Exception $e) { } -$pdo -> query("CREATE TABLE `h5p_contents` ( - `id` int(10) UNSIGNED AUTO_INCREMENT PRIMARY KEY, - `created_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', - `updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', - `user_id` int(10) UNSIGNED NOT NULL, - `title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, - `library_id` int(10) UNSIGNED NOT NULL, - `parameters` longtext COLLATE utf8mb4_unicode_ci NOT NULL, - `filtered` longtext COLLATE utf8mb4_unicode_ci NOT NULL, - `slug` varchar(127) COLLATE utf8mb4_unicode_ci NOT NULL, - `embed_type` varchar(127) COLLATE utf8mb4_unicode_ci NOT NULL, - `disable` int(10) UNSIGNED NOT NULL DEFAULT '0', - `content_type` varchar(127) COLLATE utf8mb4_unicode_ci DEFAULT NULL, - `author` varchar(127) COLLATE utf8mb4_unicode_ci DEFAULT NULL, - `license` varchar(7) COLLATE utf8mb4_unicode_ci DEFAULT NULL, - `keywords` text COLLATE utf8mb4_unicode_ci, - `description` text COLLATE utf8mb4_unicode_ci -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;"); - -$pdo -> query("CREATE TABLE `h5p_contents_libraries` ( - `content_id` int(10) UNSIGNED NOT NULL, - `library_id` int(10) UNSIGNED NOT NULL, - `dependency_type` varchar(31) COLLATE utf8mb4_unicode_ci NOT NULL, - `weight` smallint(5) UNSIGNED NOT NULL DEFAULT '0', - `drop_css` tinyint(3) UNSIGNED NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;"); - -$pdo -> query("CREATE TABLE `h5p_libraries` ( - `id` int(10) AUTO_INCREMENT PRIMARY KEY, - `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', - `name` varchar(127) COLLATE utf8mb4_unicode_ci NOT NULL, - `title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, - `major_version` int(10) UNSIGNED NOT NULL, - `minor_version` int(10) UNSIGNED NOT NULL, - `patch_version` int(10) UNSIGNED NOT NULL, - `runnable` int(10) UNSIGNED NOT NULL, - `restricted` int(10) UNSIGNED NOT NULL DEFAULT '0', - `fullscreen` int(10) UNSIGNED NOT NULL, - `embed_types` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, - `preloaded_js` text COLLATE utf8mb4_unicode_ci, - `preloaded_css` text COLLATE utf8mb4_unicode_ci, - `drop_library_css` text COLLATE utf8mb4_unicode_ci, - `semantics` text COLLATE utf8mb4_unicode_ci NOT NULL, - `tutorial_url` varchar(1023) COLLATE utf8mb4_unicode_ci NOT NULL, - `has_icon` int(10) UNSIGNED NOT NULL DEFAULT '0' -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;"); - -$pdo -> query("CREATE TABLE `h5p_libraries_libraries` ( - `library_id` int(10) UNSIGNED NOT NULL, - `required_library_id` int(10) UNSIGNED NOT NULL, - `dependency_type` varchar(31) COLLATE utf8mb4_unicode_ci NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;"); - -$pdo -> query("CREATE TABLE `h5p_libraries_languages` ( - `library_id` int(10) UNSIGNED NOT NULL, - `language_code` varchar(31) COLLATE utf8mb4_unicode_ci NOT NULL, - `translation` text COLLATE utf8mb4_unicode_ci NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;"); - -$pdo-> query("CREATE TABLE `h5p_libraries_hub_cache` ( - id INT UNSIGNED NOT NULL AUTO_INCREMENT, - machine_name VARCHAR(127) NOT NULL, - major_version INT UNSIGNED NOT NULL, - minor_version INT UNSIGNED NOT NULL, - patch_version INT UNSIGNED NOT NULL, - h5p_major_version INT UNSIGNED, - h5p_minor_version INT UNSIGNED, - title VARCHAR(255) NOT NULL, - summary TEXT NOT NULL, - description TEXT NOT NULL, - icon VARCHAR(511) NOT NULL, - created_at INT UNSIGNED NOT NULL, - updated_at INT UNSIGNED NOT NULL, - is_recommended INT UNSIGNED NOT NULL, - popularity INT UNSIGNED NOT NULL, - screenshots TEXT, - license TEXT, - example VARCHAR(511) NOT NULL, - tutorial VARCHAR(511), - keywords TEXT, - categories TEXT, - owner VARCHAR(511), - PRIMARY KEY (id), - KEY name_version (machine_name,major_version,minor_version,patch_version) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;"); +$h5p_ddl = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '_tmpl' . DIRECTORY_SEPARATOR . 'sql' . DIRECTORY_SEPARATOR . 'h5p.ddl'); +$stmt = $pdo->exec($h5p_ddl); echo 'Success'; exit(); diff --git a/service/src/main/php/src/lib/Database.php b/service/src/main/php/src/lib/Database.php new file mode 100644 index 0000000..3541525 --- /dev/null +++ b/service/src/main/php/src/lib/Database.php @@ -0,0 +1,20 @@ +setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); + $this->driver = DBTYPE; + } + + public function getDriver(): string + { + return $this->driver; + } + +} \ No newline at end of file diff --git a/service/src/main/php/src/tools/h5p/H5P.php b/service/src/main/php/src/tools/h5p/H5P.php index 45d08ff..31e38e5 100644 --- a/service/src/main/php/src/tools/h5p/H5P.php +++ b/service/src/main/php/src/tools/h5p/H5P.php @@ -1,6 +1,7 @@ h5pLang; // PHP Code Sniffer can only handle two concatenated strings and wants to see a file extension. $this -> language = include $langPathBase . '.php'; - $db = new \PDO('mysql:host=' . DBHOST . ';dbname=' . DBNAME, DBUSER, DBPASSWORD); - $db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); + $db = new Database(); $this->H5PFramework = new H5PFramework(); $this->H5PCore = new \H5PCore($this->H5PFramework, $this->H5PFramework->get_h5p_path(), $this->H5PFramework->get_h5p_url(), $this -> h5pLang, true); diff --git a/service/src/main/php/src/tools/h5p/H5PFramework.php b/service/src/main/php/src/tools/h5p/H5PFramework.php index 16d46df..b802954 100644 --- a/service/src/main/php/src/tools/h5p/H5PFramework.php +++ b/service/src/main/php/src/tools/h5p/H5PFramework.php @@ -2,11 +2,10 @@ namespace connector\tools\h5p; -use JsonSerializable; - require_once __DIR__ . '/../../../config.php'; -class H5PFramework implements \H5PFrameworkInterface { +class H5PFramework implements \H5PFrameworkInterface +{ private $messages = array('error' => array(), 'info' => array()); public $id; @@ -23,7 +22,7 @@ class H5PFramework implements \H5PFrameworkInterface { */ public function getPlatformInfo() { - return array('name' => 'edu-sharing', 'version' => '1.0', 'h5pVersion' => '1.24'); + return array('name' => 'edu-sharing', 'version' => '1.0', 'h5pVersion' => '1.3.0'); } @@ -45,6 +44,10 @@ public function get_h5p_url() { public static function dateTimeToTime($datetime) { $dt = new \DateTime($datetime); + global $db; + if($db->getDriver() === 'pgsql') { + return $dt->format('c'); + } return $dt->getTimestamp(); } @@ -57,7 +60,8 @@ public static function dateTimeToTime($datetime) * @param string $stream Path to where the file should be saved. * @return string The content (response body). NULL if something went wrong */ - public function fetchExternalData($url, $data = NULL, $blocking = TRUE, $stream = NULL, $fullData = FALSE, $headers = array(), $files = array(), $method = 'POST'){ + public function fetchExternalData($url, $data = NULL, $blocking = TRUE, $stream = NULL, $fullData = FALSE, $headers = array(), $files = array(), $method = 'POST') + { @set_time_limit(0); if ($data !== NULL) { // Post @@ -180,9 +184,7 @@ public function t($message, $replacements = array()) */ public function getLibraryFileUrl($libraryFolderName, $fileName) { - //return WWWURL . '/' . 'src' . '/' . 'tools' . '/' . 'h5p' . '/' . 'libraries' . '/' . $libraryFolderName . '/' . $fileName; return WWWURL . '/src/tools/h5p/cache/libraries/' . $libraryFolderName . '/' . $fileName; - //return DATA . DIRECTORY_SEPARATOR . 'h5p' . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . $libraryFolderName . DIRECTORY_SEPARATOR . $fileName; } /** @@ -280,22 +282,14 @@ public function getLibraryId($machineName, $majorVersion = NULL, $minorVersion = { global $db; - // Look for specific library - $sql_where = 'WHERE name = \'' . $machineName . '\''; - - if ($majorVersion !== NULL) { - // Look for major version - $sql_where .= ' AND major_version = ' . $majorVersion; - if ($minorVersion !== NULL) { - // Look for minor version - $sql_where .= ' AND minor_version = ' . $minorVersion; - } - } + $sql_major = ($majorVersion !== null) ? (int)$majorVersion : ' ANY '; + $sql_minor = ($majorVersion !== null) ? (int)$minorVersion : ' ANY '; // Get the lastest version which matches the input parameters - $statement = $db->query('SELECT id FROM h5p_libraries ' . $sql_where . ' ORDER BY major_version DESC, minor_version DESC, patch_version DESC LIMIT 1'); - $row = $statement->fetch(); - return $row['id'] === NULL ? FALSE : $row['id']; + $statement = $db->query('SELECT id FROM h5p_libraries WHERE name = ' . $db->quote($machineName) + . ' AND major_version = ' . $sql_major . ' AND minor_version = ' . $sql_minor . ' ORDER BY major_version DESC, minor_version DESC, patch_version DESC LIMIT 1'); + $row = $statement->fetch();; + return $row['id'] ?? FALSE; } /** @@ -313,11 +307,7 @@ public function getLibraryId($machineName, $majorVersion = NULL, $minorVersion = */ public function getWhitelist($isLibrary, $defaultContentWhitelist, $defaultLibraryWhitelist) { - if ($isLibrary){ - return $defaultLibraryWhitelist; - }else{ - return $defaultContentWhitelist; - } + return ''; } /** @@ -339,10 +329,10 @@ public function isPatchedLibrary($library) $query = 'SELECT id FROM h5p_libraries - WHERE name = \'' . $library['machineName'] . '\' - AND major_version = ' . $library['majorVersion'] . ' - AND minor_version = ' . $library['minorVersion'] . ' - AND patch_version < ' . $library['patchVersion']; + WHERE name = ' . $db->quote($library['machineName']) . ' + AND major_version = ' . (int)$library['majorVersion'] . ' + AND minor_version = ' . (int)$library['minorVersion'] . ' + AND patch_version < ' . (int)$library['patchVersion']; $statement = $db->query($query); return $statement->fetch() !== FALSE; @@ -431,52 +421,39 @@ public function saveLibraryData(&$library, $new = TRUE) $library['hasIcon'] = 0; } $library['hasIcon'] ? $hasIcon = 1 : $hasIcon = 0; - - - if ($new) { - - $db->query('INSERT INTO h5p_libraries ' . - '(name,title,major_version,minor_version,patch_version,runnable,fullscreen,embed_types,preloaded_js,' . - 'preloaded_css,drop_library_css,semantics,tutorial_url,has_icon) ' . - 'values (' . $db->quote($library['machineName']) . ',' - . $db->quote($library['title']) . ',' - . $library['majorVersion'] . ',' . $library['minorVersion'] . ',' . $library['patchVersion'] . ',' . $library['runnable'] . ',' - . $library['fullscreen'] . ',' - . $db->quote($embedTypes) . ',' - . $db->quote($preloadedJs) . ',' - . $db->quote($preloadedCss) . ',' - . $db->quote($dropLibraryCss) . ',' - . $db->quote($library['semantics']) . ',' - . $db->quote($library['tutorial_url']) . ',' - . $hasIcon . ')'); - $library['libraryId'] = $db->lastInsertId(); - + $result = $db->exec('INSERT INTO h5p_libraries ' . + '(name,title,major_version,minor_version,patch_version,runnable,fullscreen,embed_types,preloaded_js,preloaded_css,drop_library_css,semantics,tutorial_url,has_icon) ' + . 'values (' . $db->quote($library['machineName']) . ',' . $db->quote($library['title']) . ',' . (int)$library['majorVersion'] . ',' . (int)$library['minorVersion'] . ',' . (int)$library['patchVersion'] . ',' . (int)$library['runnable'] . ',' + . (int)$library['fullscreen'] . ',' . $db->quote($embedTypes) . ',' . $db->quote($preloadedJs) . ',' . $db->quote($preloadedCss) . ',' . $db->quote($dropLibraryCss) . ',' . $db->quote($library['semantics']) . ',' . $db->quote($library['tutorial_url']) . ',' . (int)$hasIcon . ')'); + $library['libraryId'] = ($db->getDriver() === 'pgsql') + ? $db->lastInsertId('h5p_libraries_id_seq') + : $db->lastInsertId(); } else { $db->query('UPDATE h5p_libraries SET ' . 'title = ' . $db->quote($library['title']) . ',' . - 'patch_version = ' . $library['patchVersion'] . ',' . - 'runnable = ' . $library['runnable'] . ',' . - 'fullscreen = ' . $library['fullscreen'] . ',' . + 'patch_version = ' . (int)$library['patchVersion'] . ',' . + 'runnable = ' . (int)$library['runnable'] . ',' . + 'fullscreen = ' . (int)$library['fullscreen'] . ',' . 'embed_types = ' . $db->quote($embedTypes) . ',' . 'preloaded_js = ' . $db->quote($preloadedJs) . ',' . 'preloaded_css= ' . $db->quote($preloadedCss) . ',' . 'drop_library_css = ' . $db->quote($dropLibraryCss) . ',' . 'semantics = ' . $db->quote($library['semantics']) . ',' . - 'has_icon= ' . $hasIcon . - ' WHERE id = ' . $library['libraryId']); + 'has_icon= ' . (int)$hasIcon . + ' WHERE id = ' . (int)$library['libraryId']); $this->deleteLibraryDependencies($library['libraryId']); } // Update languages - $db->query('DELETE FROM h5p_libraries_languages WHERE library_id = ' . $library['libraryId']); + $db->query('DELETE FROM h5p_libraries_languages WHERE library_id = ' . (int)$library['libraryId']); if (isset($library['language'])) { foreach ($library['language'] as $languageCode => $translation) { $db->query('INSERT INTO h5p_libraries_languages (library_id,language_code,translation)' . - 'values(' . $library['libraryId'] . ',' . $db->quote($languageCode) . ',' . $db->quote($translation) . ')'); + 'values(' . (int)$library['libraryId'] . ',' . $db->quote($languageCode) . ',' . $db->quote($translation) . ')'); } } } @@ -528,13 +505,12 @@ public function updateContent($content, $contentMainId = NULL) global $db; if (!isset($content['id'])) { - $db->query('INSERT INTO h5p_contents (updated_at,title,parameters,embed_type,library_id,user_id,slug,filtered,disable)' . - 'values (NOW(),' . $db->quote($content['title']) . ',' . $db->quote($content['params']) . ', \'iframe\' ,' . $db->quote($content['library']['libraryId']) . ',' . $db->quote('0') . ',' . $db->quote('') . ',' . $db->quote('') . ',' . $db->quote($content['disable']) . ')'); - - $content['id'] = $this->id = $db->lastInsertId(); + $db->query('INSERT INTO h5p_contents (title,parameters,embed_type,library_id,user_id,slug,filtered,disable)' . + 'values (' . $db->quote($content['title']) . ',' . $db->quote($content['params']) . ' , ' . $db->quote('iframe') . ',' . (int)$content['library']['libraryId'] . ',-1,' . $db->quote('') . ',' . $db->quote('') . ',' . (int)($content['disable']) . ')'); + $content['id'] = $this->id = ($db->getDriver() === 'pgsql') ? $db->lastInsertId('h5p_contents_id_seq') : $db->lastInsertId(); } else { - $db->query('UPDATE h5p_contents set updated_at=NOW() , title=' . $db->quote($content['title']) . ', parameters=' . $db->quote($content['params']) . ' ,embed_type=\'iframe\' ,library_id=' . $content['library']['libraryId'] . ' ,filtered=\'\' ,disable=' . $db->quote($content['disable']) . ' WHERE id=' . $content['id']); + $db->query('UPDATE h5p_contents set updated_at = now(), title=' . $db->quote($content['title']) . ', parameters=' . $db->quote($content['params']) . ' ,embed_type = ' . $db->quote('iframe') . ',library_id=' . (int)$content['library']['libraryId'] . ' ,filtered=' . $db->quote("") . ' ,disable=' . (int)($content['disable']) . ' WHERE id=' . (int)$content['id']); } return $content['id']; @@ -572,11 +548,11 @@ public function saveLibraryDependencies($libraryId, $dependencies, $dependency_t $db->beginTransaction(); foreach ($dependencies as $dependency) { $db->query('INSERT INTO h5p_libraries_libraries (library_id, required_library_id, dependency_type) - SELECT ' . $libraryId . ', hl.id, ' . $db->quote($dependency_type) . ' + SELECT ' . (int)$libraryId . ', hl.id, ' . $db->quote($dependency_type) . ' FROM h5p_libraries hl WHERE name = ' . $db->quote($dependency['machineName']) . ' - AND major_version = ' . $dependency['majorVersion'] . ' - AND minor_version = ' . $dependency['minorVersion']);// ON CONFLICT(library_id) REPLACE SET dependency_type ='.$db->quote($dependency_type)); + AND major_version = ' . (int)$dependency['majorVersion'] . ' + AND minor_version = ' . (int)$dependency['minorVersion']);// ON CONFLICT(library_id) REPLACE SET dependency_type ='.$db->quote($dependency_type)); } $db->commit(); } @@ -596,10 +572,10 @@ public function saveLibraryDependencies($libraryId, $dependencies, $dependency_t public function copyLibraryUsage($contentId, $copyFromId, $contentMainId = NULL) { global $db; - $db->query('INSERT INTO h5p_contents_libraries (content_id, library_id, dependency_type, weight, drop_css) - SELECT ' . $contentId . ', hcl.library_id, hcl.dependency_type, hcl.weight, hcl.drop_css + $db->exec('INSERT INTO h5p_contents_libraries (content_id, library_id, dependency_type, weight, drop_css) + SELECT ' . (int)$contentId . ', hcl.library_id, hcl.dependency_type, hcl.weight, hcl.drop_css FROM h5p_contents_libraries hcl - WHERE hcl.content_id =' . $copyFromId); + WHERE hcl.content_id =' . (int)$copyFromId); } /** @@ -611,7 +587,7 @@ public function copyLibraryUsage($contentId, $copyFromId, $contentMainId = NULL) public function deleteContentData($contentId) { global $db; - $db->query('DELETE FROM h5p_contents WHERE id = ' . $contentId); + $db->query('DELETE FROM h5p_contents WHERE id = ' . (int)$contentId); } /** @@ -623,7 +599,7 @@ public function deleteContentData($contentId) public function deleteLibraryUsage($contentId) { global $db; - $db->query('DELETE FROM h5p_contents_libraries WHERE content_id = ' . $contentId); + $db->query('DELETE FROM h5p_contents_libraries WHERE content_id = ' . (int)$contentId); } /** @@ -656,7 +632,7 @@ public function saveLibraryUsage($contentId, $librariesInUse) foreach ($librariesInUse as $dependency) { $dropCss = in_array($dependency['library']['machineName'], $dropLibraryCssList) ? 1 : 0; $db->query('INSERT INTO h5p_contents_libraries (content_id, library_id, dependency_type, drop_css, weight) ' . - 'values(' . $contentId . ',\'' . $dependency['library']['libraryId'] . '\',\'' . $dependency['type'] . '\',\'' . $dropCss . '\',\'' . $dependency['weight'] . '\')'); + 'values(' . (int)$contentId . ',' . (int)$dependency['library']['libraryId'] . ',' . $db->quote($dependency['type']) . ',' . $db->quote($dropCss) . ',' . (int)$dependency['weight'] . ')'); } $db->commit(); } @@ -676,7 +652,30 @@ public function saveLibraryUsage($contentId, $librariesInUse) */ public function getLibraryUsage($libraryId, $skipContent = FALSE) { - // TODO: Implement getLibraryUsage() method. + global $db; + + + $statement = $db->query("SELECT COUNT(distinct c.id) + FROM h5p_libraries l + JOIN h5p_contents_libraries cl ON l.id = cl.library_id + JOIN h5p_contents c ON cl.content_id = c.id + WHERE l.id = " . (int)$libraryId); + + $content = $statement->fetch(); + + $statement = $db->query("SELECT COUNT(*) + FROM h5p_libraries_libraries + WHERE required_library_id = " . (int)$libraryId); + + $libraries = $statement->fetch(); + + return array( + //'content' => $skipContent ? -1 : $content[0], + 'content' => $content[0], + 'libraries' => $libraries[0] + ); + + } /** @@ -718,22 +717,23 @@ public function getLibraryUsage($libraryId, $skipContent = FALSE) * - majorVersion: Major version for a library this library is depending on * - minorVersion: Minor for a library this library is depending on */ - public function loadLibrary($machineName, $majorVersion, $minorVersion){ + public function loadLibrary($machineName, $majorVersion, $minorVersion) + { global $db; - - $statement = $db->query('SELECT id as libraryId, name as machineName, title, major_version as majorVersion, minor_version as minorVersion, patch_version as patchVersion, - embed_types as embedTypes, preloaded_js as preloadedJs, preloaded_css as preloadedCss, drop_library_css as dropLibraryCss, fullscreen, runnable, - semantics, has_icon as hasIcon + $statement = $db->query('SELECT id as "libraryId", name as "machineName", title, major_version as "majorVersion", minor_version as "minorVersion", patch_version as "patchVersion", + embed_types as "embedTypes", preloaded_js as "preloadedJs", preloaded_css as "preloadedCss", drop_library_css as "dropLibraryCss", fullscreen, runnable, + semantics, has_icon as "hasIcon" FROM h5p_libraries WHERE name = ' . $db->quote($machineName) . ' - AND major_version = ' . $majorVersion . ' - AND minor_version =' . $minorVersion); + AND major_version = ' . (int)$majorVersion . ' + AND minor_version = ' . (int)$minorVersion); $library = $statement->fetch(); - $result = $db->query('SELECT hl.name as machineName, hl.major_version as majorVersion, hl.minor_version as minorVersion, hll.dependency_type as dependencyType + + $result = $db->query('SELECT hl.name as "machineName", hl.major_version as "majorVersion", hl.minor_version as "minorVersion", hll.dependency_type as "dependencyType" FROM h5p_libraries_libraries hll JOIN h5p_libraries hl ON hll.required_library_id = hl.id - WHERE hll.library_id = ' . $library['libraryId']); + WHERE hll.library_id = ' . (int)$library['libraryId']); $dependencies = $result->fetchAll(\PDO::FETCH_ASSOC); @@ -744,6 +744,7 @@ public function loadLibrary($machineName, $majorVersion, $minorVersion){ 'minorVersion' => $dependency['minorVersion'], ); } + return $library; } @@ -762,8 +763,7 @@ public function loadLibrary($machineName, $majorVersion, $minorVersion){ public function loadLibrarySemantics($machineName, $majorVersion, $minorVersion) { global $db; - $prep = $db->prepare('SELECT semantics FROM h5p_libraries WHERE name = \'' . $machineName . '\' AND major_version=' . $majorVersion . ' AND minor_version=' . $minorVersion); - $prep->execute(); + $prep = $db->query('SELECT semantics FROM h5p_libraries WHERE name = ' . $db->quote($machineName) . ' AND major_version = ' . (int)$majorVersion . ' AND minor_version = ' . (int)$minorVersion); $semantics = $prep->fetchColumn(); return ($semantics === FALSE ? NULL : $semantics); } @@ -794,7 +794,7 @@ public function alterLibrarySemantics(&$semantics, $machineName, $majorVersion, public function deleteLibraryDependencies($libraryId) { global $db; - $db->query('DELETE FROM h5p_libraries_libraries WHERE library_id = ' . $libraryId); + $db->query('DELETE FROM h5p_libraries_libraries WHERE library_id = ' . (int)$libraryId); } /** @@ -847,37 +847,38 @@ public function loadContent($id) { global $db; - $prep = $db->prepare( - "SELECT hc.id - , hc.title - , hc.parameters AS params - , hc.filtered - , hc.slug AS slug - , hc.user_id - , hc.embed_type AS embedType - , hc.disable - , hl.id AS libraryId - , hl.name AS libraryName - , hl.major_version AS libraryMajorVersion - , hl.minor_version AS libraryMinorVersion - , hl.embed_types AS libraryEmbedTypes - , hl.fullscreen AS libraryFullscreen - FROM h5p_contents hc - JOIN h5p_libraries hl ON hl.id = hc.library_id - WHERE hc.id =" . $id); - - $prep->execute(); + $prep = $db->query( + 'SELECT hc.id, + hc.title, + hc.description, + hc.parameters AS "params", + hc.filtered, + hc.slug AS "slug", + hc.user_id, + hc.embed_type AS "embedType", + hc.disable, + hl.id AS "libraryId", + hl.name AS "libraryName", + hl.major_version AS "libraryMajorVersion", + hl.minor_version AS "libraryMinorVersion", + hl.embed_types AS "libraryEmbedTypes", + hl.fullscreen AS "libraryFullscreen" + FROM h5p_contents AS hc + JOIN h5p_libraries AS hl ON hl.id = hc.library_id + WHERE hc.id = ' . (int)$id); + $content = $prep->fetch(); if ($content !== NULL) { $content['metadata'] = array(); - $metadata_structure = array('title', 'authors', 'source', 'yearFrom', 'yearTo', 'license', 'licenseVersion', 'licenseExtras', 'authorComments', 'changes', 'defaultLanguage', 'a11yTitle'); + $metadata_structure = array('title', 'authors', 'source', 'yearFrom', 'yearTo', 'license', 'licenseVersion', 'licenseExtras', 'authorComments', 'changes', 'defaultLanguage'); foreach ($metadata_structure as $property) { if (!empty($content[$property])) { if ($property === 'authors' || $property === 'changes') { $content['metadata'][$property] = json_decode($content[$property]); - } - else { + } else if ($property === 'title') { // since we use the title for nodeID, use description instead + $content['metadata'][$property] = $content['description']; + } else { $content['metadata'][$property] = $content[$property]; } if ($property !== 'title') { @@ -915,31 +916,25 @@ public function loadContentDependencies($id, $type = NULL) { global $db; $query = 'SELECT hl.id - , hl.name AS machineName - , hl.major_version AS majorVersion - , hl.minor_version AS minorVersion - , hl.patch_version AS patchVersion - , hl.preloaded_css AS preloadedCss - , hl.preloaded_js AS preloadedJs - , hcl.drop_css AS dropCss - , hcl.dependency_type AS dependencyType + , hl.name AS "machineName" + , hl.major_version AS "majorVersion" + , hl.minor_version AS "minorVersion" + , hl.patch_version AS "patchVersion" + , hl.preloaded_css AS "preloadedCss" + , hl.preloaded_js AS "preloadedJs" + , hcl.drop_css AS "dropCss" + , hcl.dependency_type AS "dependencyType" FROM h5p_contents_libraries hcl JOIN h5p_libraries hl ON hcl.library_id = hl.id - WHERE hcl.content_id =' . $id; + WHERE hcl.content_id = ' . (int)$id; if ($type !== NULL) { - $query .= ' AND hcl.dependency_type = \'' . $type . '\''; + $query .= ' AND hcl.dependency_type = ' . $db->quote($type); } $query .= " ORDER BY hcl.weight"; return $db->query($query)->fetchAll(\PDO::FETCH_ASSOC); - $results = $db->query($query); - $ret = array(); - while ($row = $results->fetchArray()) { - $ret[] = $row; - } - return $ret; } /** @@ -1003,7 +998,10 @@ public function clearFilteredParameters($library_id) */ public function getNumNotFiltered() { - // TODO: Implement getNumNotFiltered() method. + global $db; + + $statement = $db->query('SELECT COUNT(id) FROM h5p_contents WHERE filtered = ' . $db->quote("")); + return $statement->fetchColumn(); } /** @@ -1014,7 +1012,16 @@ public function getNumNotFiltered() */ public function getNumContent($libraryId, $skip = NULL) { - // TODO: Implement getNumContent() method. + global $db; + //$skip_query = empty($skip) ? '' : " AND id NOT IN ($skip)"; + + $statement = $db->prepare("SELECT COUNT(id) + FROM h5p_contents + WHERE library_id = :libId"); + $statement->bindParam(':libId', $libraryId, PDO::PARAM_INT); + $statement->execute(); + return $statement->fetchColumn(); + } /** @@ -1025,27 +1032,14 @@ public function getNumContent($libraryId, $skip = NULL) public function isContentSlugAvailable($slug) { global $db; - $st = $db->prepare('SELECT slug FROM h5p_contents WHERE slug = \'' . $slug . '\''); + $st = $db->prepare('SELECT slug FROM h5p_contents WHERE slug = ' . $db->quote($slug)); $st->execute(); return !$st->fetchColumn(); } public function libraryHasUpgrade($library) { - global $db; - - return $db->get_var($db->prepare( - "SELECT id - FROM h5p_libraries - WHERE name = '%s' - AND (major_version > %d - OR (major_version = %d AND minor_version > %d)) - LIMIT 1", - $library['machineName'], - $library['majorVersion'], - $library['majorVersion'], - $library['minorVersion'] - )) !== NULL; + return false; } @@ -1195,410 +1189,6 @@ public function replaceContentTypeCache($contentTypeCache) } } - public function getMetadataSemantics() { - static $semantics; - - $cc_versions = array( - (object) array( - 'value' => '4.0', - 'label' => $this->h5pF->t('4.0 International') - ), - (object) array( - 'value' => '3.0', - 'label' => $this->h5pF->t('3.0 Unported') - ), - (object) array( - 'value' => '2.5', - 'label' => $this->h5pF->t('2.5 Generic') - ), - (object) array( - 'value' => '2.0', - 'label' => $this->h5pF->t('2.0 Generic') - ), - (object) array( - 'value' => '1.0', - 'label' => $this->h5pF->t('1.0 Generic') - ) - ); - - $semantics = array( - (object) array( - 'name' => 'title', - 'type' => 'text', - 'label' => $this->h5pF->t('Title'), - 'placeholder' => 'La Gioconda' - ), - (object) array( - 'name' => 'a11yTitle', - 'type' => 'text', - 'label' => $this->h5pF->t('Assistive Technologies label'), - 'optional' => TRUE, - ), - (object) array( - 'name' => 'license', - 'type' => 'select', - 'label' => $this->h5pF->t('License'), - 'default' => 'U', - 'options' => array( - (object) array( - 'value' => 'U', - 'label' => $this->h5pF->t('Undisclosed') - ), - (object) array( - 'type' => 'optgroup', - 'label' => $this->h5pF->t('Creative Commons'), - 'options' => array( - (object) array( - 'value' => 'CC BY', - 'label' => $this->h5pF->t('Attribution (CC BY)'), - 'versions' => $cc_versions - ), - (object) array( - 'value' => 'CC BY-SA', - 'label' => $this->h5pF->t('Attribution-ShareAlike (CC BY-SA)'), - 'versions' => $cc_versions - ), - (object) array( - 'value' => 'CC BY-ND', - 'label' => $this->h5pF->t('Attribution-NoDerivs (CC BY-ND)'), - 'versions' => $cc_versions - ), - (object) array( - 'value' => 'CC BY-NC', - 'label' => $this->h5pF->t('Attribution-NonCommercial (CC BY-NC)'), - 'versions' => $cc_versions - ), - (object) array( - 'value' => 'CC BY-NC-SA', - 'label' => $this->h5pF->t('Attribution-NonCommercial-ShareAlike (CC BY-NC-SA)'), - 'versions' => $cc_versions - ), - (object) array( - 'value' => 'CC BY-NC-ND', - 'label' => $this->h5pF->t('Attribution-NonCommercial-NoDerivs (CC BY-NC-ND)'), - 'versions' => $cc_versions - ), - (object) array( - 'value' => 'CC0 1.0', - 'label' => $this->h5pF->t('Public Domain Dedication (CC0)') - ), - (object) array( - 'value' => 'CC PDM', - 'label' => $this->h5pF->t('Public Domain Mark (PDM)') - ), - ) - ), - (object) array( - 'value' => 'GNU GPL', - 'label' => $this->h5pF->t('General Public License v3') - ), - (object) array( - 'value' => 'PD', - 'label' => $this->h5pF->t('Public Domain') - ), - (object) array( - 'value' => 'ODC PDDL', - 'label' => $this->h5pF->t('Public Domain Dedication and Licence') - ), - (object) array( - 'value' => 'C', - 'label' => $this->h5pF->t('Copyright') - ) - ) - ), - (object) array( - 'name' => 'licenseVersion', - 'type' => 'select', - 'label' => $this->h5pF->t('License Version'), - 'options' => $cc_versions, - 'optional' => TRUE - ), - (object) array( - 'name' => 'yearFrom', - 'type' => 'number', - 'label' => $this->h5pF->t('Years (from)'), - 'placeholder' => '1991', - 'min' => '-9999', - 'max' => '9999', - 'optional' => TRUE - ), - (object) array( - 'name' => 'yearTo', - 'type' => 'number', - 'label' => $this->h5pF->t('Years (to)'), - 'placeholder' => '1992', - 'min' => '-9999', - 'max' => '9999', - 'optional' => TRUE - ), - (object) array( - 'name' => 'source', - 'type' => 'text', - 'label' => $this->h5pF->t('Source'), - 'placeholder' => 'https://', - 'optional' => TRUE - ), - (object) array( - 'name' => 'authors', - 'type' => 'list', - 'field' => (object) array ( - 'name' => 'author', - 'type' => 'group', - 'fields'=> array( - (object) array( - 'label' => $this->h5pF->t("Author's name"), - 'name' => 'name', - 'optional' => TRUE, - 'type' => 'text' - ), - (object) array( - 'name' => 'role', - 'type' => 'select', - 'label' => $this->h5pF->t("Author's role"), - 'default' => 'Author', - 'options' => array( - (object) array( - 'value' => 'Author', - 'label' => $this->h5pF->t('Author') - ), - (object) array( - 'value' => 'Editor', - 'label' => $this->h5pF->t('Editor') - ), - (object) array( - 'value' => 'Licensee', - 'label' => $this->h5pF->t('Licensee') - ), - (object) array( - 'value' => 'Originator', - 'label' => $this->h5pF->t('Originator') - ) - ) - ) - ) - ) - ), - (object) array( - 'name' => 'licenseExtras', - 'type' => 'text', - 'widget' => 'textarea', - 'label' => $this->h5pF->t('License Extras'), - 'optional' => TRUE, - 'description' => $this->h5pF->t('Any additional information about the license') - ), - (object) array( - 'name' => 'changes', - 'type' => 'list', - 'field' => (object) array( - 'name' => 'change', - 'type' => 'group', - 'label' => $this->h5pF->t('Changelog'), - 'fields' => array( - (object) array( - 'name' => 'date', - 'type' => 'text', - 'label' => $this->h5pF->t('Date'), - 'optional' => TRUE - ), - (object) array( - 'name' => 'author', - 'type' => 'text', - 'label' => $this->h5pF->t('Changed by'), - 'optional' => TRUE - ), - (object) array( - 'name' => 'log', - 'type' => 'text', - 'widget' => 'textarea', - 'label' => $this->h5pF->t('Description of change'), - 'placeholder' => $this->h5pF->t('Photo cropped, text changed, etc.'), - 'optional' => TRUE - ) - ) - ) - ), - (object) array ( - 'name' => 'authorComments', - 'type' => 'text', - 'widget' => 'textarea', - 'label' => $this->h5pF->t('Author comments'), - 'description' => $this->h5pF->t('Comments for the editor of the content (This text will not be published as a part of copyright info)'), - 'optional' => TRUE - ), - (object) array( - 'name' => 'contentType', - 'type' => 'text', - 'widget' => 'none' - ), - (object) array( - 'name' => 'defaultLanguage', - 'type' => 'text', - 'widget' => 'none' - ) - ); - - return $semantics; - } - - public function getCopyrightSemantics() { - static $semantics; - - if ($semantics === NULL) { - $cc_versions = array( - (object) array( - 'value' => '4.0', - 'label' => $this->h5pF->t('4.0 International') - ), - (object) array( - 'value' => '3.0', - 'label' => $this->h5pF->t('3.0 Unported') - ), - (object) array( - 'value' => '2.5', - 'label' => $this->h5pF->t('2.5 Generic') - ), - (object) array( - 'value' => '2.0', - 'label' => $this->h5pF->t('2.0 Generic') - ), - (object) array( - 'value' => '1.0', - 'label' => $this->h5pF->t('1.0 Generic') - ) - ); - - $semantics = (object) array( - 'name' => 'copyright', - 'type' => 'group', - 'label' => $this->h5pF->t('Copyright information'), - 'fields' => array( - (object) array( - 'name' => 'title', - 'type' => 'text', - 'label' => $this->h5pF->t('Title'), - 'placeholder' => 'La Gioconda', - 'optional' => TRUE - ), - (object) array( - 'name' => 'author', - 'type' => 'text', - 'label' => $this->h5pF->t('Author'), - 'placeholder' => 'Leonardo da Vinci', - 'optional' => TRUE - ), - (object) array( - 'name' => 'year', - 'type' => 'text', - 'label' => $this->h5pF->t('Year(s)'), - 'placeholder' => '1503 - 1517', - 'optional' => TRUE - ), - (object) array( - 'name' => 'source', - 'type' => 'text', - 'label' => $this->h5pF->t('Source'), - 'placeholder' => 'http://en.wikipedia.org/wiki/Mona_Lisa', - 'optional' => true, - 'regexp' => (object) array( - 'pattern' => '^http[s]?://.+', - 'modifiers' => 'i' - ) - ), - (object) array( - 'name' => 'license', - 'type' => 'select', - 'label' => $this->h5pF->t('License'), - 'default' => 'U', - 'options' => array( - (object) array( - 'value' => 'U', - 'label' => $this->h5pF->t('Undisclosed') - ), - (object) array( - 'value' => 'CC BY', - 'label' => $this->h5pF->t('Attribution'), - 'versions' => $cc_versions - ), - (object) array( - 'value' => 'CC BY-SA', - 'label' => $this->h5pF->t('Attribution-ShareAlike'), - 'versions' => $cc_versions - ), - (object) array( - 'value' => 'CC BY-ND', - 'label' => $this->h5pF->t('Attribution-NoDerivs'), - 'versions' => $cc_versions - ), - (object) array( - 'value' => 'CC BY-NC', - 'label' => $this->h5pF->t('Attribution-NonCommercial'), - 'versions' => $cc_versions - ), - (object) array( - 'value' => 'CC BY-NC-SA', - 'label' => $this->h5pF->t('Attribution-NonCommercial-ShareAlike'), - 'versions' => $cc_versions - ), - (object) array( - 'value' => 'CC BY-NC-ND', - 'label' => $this->h5pF->t('Attribution-NonCommercial-NoDerivs'), - 'versions' => $cc_versions - ), - (object) array( - 'value' => 'GNU GPL', - 'label' => $this->h5pF->t('General Public License'), - 'versions' => array( - (object) array( - 'value' => 'v3', - 'label' => $this->h5pF->t('Version 3') - ), - (object) array( - 'value' => 'v2', - 'label' => $this->h5pF->t('Version 2') - ), - (object) array( - 'value' => 'v1', - 'label' => $this->h5pF->t('Version 1') - ) - ) - ), - (object) array( - 'value' => 'PD', - 'label' => $this->h5pF->t('Public Domain'), - 'versions' => array( - (object) array( - 'value' => '-', - 'label' => '-' - ), - (object) array( - 'value' => 'CC0 1.0', - 'label' => $this->h5pF->t('CC0 1.0 Universal') - ), - (object) array( - 'value' => 'CC PDM', - 'label' => $this->h5pF->t('Public Domain Mark') - ) - ) - ), - (object) array( - 'value' => 'C', - 'label' => $this->h5pF->t('Copyright') - ) - ) - ), - (object) array( - 'name' => 'version', - 'type' => 'select', - 'label' => $this->h5pF->t('License Version'), - 'options' => array() - ) - ) - ); - } - - return $semantics; - } - public function replaceContentHubMetadataCache($metadata, $lang) { // TODO: Implement replaceContentHubMetadataCache() method. @@ -1619,4 +1209,3 @@ public function setContentHubMetadataChecked($time, $lang = 'en') // TODO: Implement setContentHubMetadataChecked() method. } } - From 88a1a46ca7bd4557ce1f962502d6119b2514451b Mon Sep 17 00:00:00 2001 From: Torsten Simon Date: Wed, 24 May 2023 17:40:43 +0200 Subject: [PATCH 2/5] fix:h5p layout, migrate as twig --- service/src/main/php/bootstrap.php | 2 +- service/src/main/php/css/h5p.css | 11 ++++- service/src/main/php/src/lib/Connector.php | 10 +++- service/src/main/php/src/lib/Tool.php | 7 +++ .../main/php/src/tools/etherpad/Etherpad.php | 4 +- service/src/main/php/src/tools/h5p/H5P.php | 48 ++++++++++++------- .../php/src/tools/h5p/js/h5peditor-init.js | 3 ++ service/src/main/php/src/tools/lti/Lti.php | 4 +- .../php/src/tools/onlyoffice/OnlyOffice.php | 5 +- service/src/main/php/src/tools/onyx/Onyx.php | 4 +- .../main/php/src/tools/tinymce/TinyMce.php | 3 +- service/src/main/php/templates/h5p.html.twig | 26 ++++++++++ 12 files changed, 100 insertions(+), 27 deletions(-) create mode 100644 service/src/main/php/templates/h5p.html.twig diff --git a/service/src/main/php/bootstrap.php b/service/src/main/php/bootstrap.php index 3acf299..b1504f2 100644 --- a/service/src/main/php/bootstrap.php +++ b/service/src/main/php/bootstrap.php @@ -33,7 +33,7 @@ $app->get('/', function (Request $request, Response $response) { $this->get('log')->info($request->getUri()); - $connector = new Connector($this->get('log')); + $connector = new Connector($this->get('log'), $this, $response); }); $app->get('/error/{errorid}[/{language}]', function (Request $request, Response $response, $args) { diff --git a/service/src/main/php/css/h5p.css b/service/src/main/php/css/h5p.css index 9004fa8..b630c85 100644 --- a/service/src/main/php/css/h5p.css +++ b/service/src/main/php/css/h5p.css @@ -22,11 +22,18 @@ body, html { max-Width: 100% !important; text-align: center; padding-bottom: 30px !important; + height: 100%; } #h5p-content-form { width: 100%; + display: inline-flex; + flex-direction: column; + justify-self: center; max-width: 960px; - display: inline-block; - padding: 0 20px; + padding: 20px 20px; +} +.h5p-create { + flex-grow: 1; + min-height: 100vh; } \ No newline at end of file diff --git a/service/src/main/php/src/lib/Connector.php b/service/src/main/php/src/lib/Connector.php index aeede4a..ae37d9f 100644 --- a/service/src/main/php/src/lib/Connector.php +++ b/service/src/main/php/src/lib/Connector.php @@ -2,18 +2,23 @@ namespace connector\lib; +use Slim\App; +use Slim\Container; use Slim\Exception\SlimException; +use Slim\Http\Response; class Connector { private $id; private $tool; + private Container $container; protected $log; protected $apiClient; - public function __construct($log) + public function __construct($log, Container $container,Response $response) { $this->log = $log; + $this->container = $container; $this->id = bin2hex(openssl_random_pseudo_bytes(32)); try { $this->setParameters(); @@ -22,7 +27,7 @@ public function __construct($log) $this->startTool(); $this->tool->setNode(); $this->setUser(); - $this->tool->run(); + $this->tool->run($response); } catch (\Exception $e) { $this->log->error($e->getCode() . ' ' . $e->__toString()); header('Location: ' . WWWURL . '/error/' . ERROR_DEFAULT); @@ -93,5 +98,6 @@ private function startTool() default: throw new \Exception('Unknown tool: ' . $_SESSION[$this->id]['tool'] . '.'); } + $this->tool->setContainer($this->container); } } diff --git a/service/src/main/php/src/lib/Tool.php b/service/src/main/php/src/lib/Tool.php index b111f4e..72f1c3f 100644 --- a/service/src/main/php/src/lib/Tool.php +++ b/service/src/main/php/src/lib/Tool.php @@ -2,11 +2,15 @@ namespace connector\lib; +use Slim\App; +use Slim\Container; + class Tool { protected $apiClient; protected $log; protected $connectorId; + protected Container $container; public function __construct($apiClient, $log, $connectorId) { $this->apiClient = $apiClient; @@ -23,4 +27,7 @@ protected function getNode() { $node = $this->apiClient->getNode($_SESSION[$this->connectorId]['node']); return $node; } + public function setContainer(Container $container) { + $this->container = $container; + } } \ No newline at end of file diff --git a/service/src/main/php/src/tools/etherpad/Etherpad.php b/service/src/main/php/src/tools/etherpad/Etherpad.php index 9e0cfa1..f4d4fe4 100644 --- a/service/src/main/php/src/tools/etherpad/Etherpad.php +++ b/service/src/main/php/src/tools/etherpad/Etherpad.php @@ -2,9 +2,11 @@ namespace connector\tools\tinymce; +use Slim\Http\Response; + class Etherpad extends \connector\lib\Tool { - public function run() { + public function run(Response $response) { $courseId = $resource_link_id = $_SESSION[$this->connectorId]['node']->node->ref->id; $userId = $fname = $_SESSION[$this->connectorId]['user']->userName; diff --git a/service/src/main/php/src/tools/h5p/H5P.php b/service/src/main/php/src/tools/h5p/H5P.php index 31e38e5..d336f9c 100644 --- a/service/src/main/php/src/tools/h5p/H5P.php +++ b/service/src/main/php/src/tools/h5p/H5P.php @@ -3,6 +3,8 @@ use connector\lib\Database; use connector\lib\EduRestClient; +use Dompdf\Exception; +use Slim\Http\Response; define('MODE_NEW', 'mode_new'); @@ -63,7 +65,7 @@ public static function getInstance() { return self::$instance; } - public function run() { + public function run(Response $response) { $log = $this->logger->getLog(); $this->H5PCore->disableFileCheck = true; @@ -101,7 +103,7 @@ public function run() { } } - $this->showEditor($content); + $this->showEditor($content, $response); } private function copyr($source, $dest) { @@ -154,8 +156,7 @@ public function rrmdir($dir) { } - public function showEditor($content) { - echo ''; + public function showEditor($content, Response $response) { $integration = array(); $integration['baseUrl'] = WWWURL; //$integration['url'] = '/eduConnector/src/tools/h5p'; @@ -200,35 +201,50 @@ public function showEditor($content) { $integration['editor']['hideHub'] = true; } - echo ' '; - echo ''; - + $styles = [ + WWWURL . '/css/h5p.css' + ]; foreach(\H5PCore::$styles as $style) { - echo ' '; + $styles[] = WWWURL . '/vendor/h5p/h5p-core/' . $style; } foreach(\H5PEditor::$styles as $style) { - echo ' '; + $styles[] = WWWURL . '/vendor/h5p/h5p-editor/' . $style; } + $scripts = []; foreach (\H5PCore::$scripts as $script) { - echo ' '; + $scripts[] = WWWURL . '/vendor/h5p/h5p-core/' . $script; } foreach (\H5PEditor::$scripts as $script) { - echo ' '; + $scripts[] = WWWURL . '/vendor/h5p/h5p-editor/' . $script; } + $scripts[] = WWWURL . '/vendor/h5p/h5p-editor/scripts/h5peditor-editor.js'; + $scripts[] = WWWURL . '/src/tools/h5p/js/h5peditor-init.js'; + - echo ''; - echo ''; - echo ''; $titleShow = $_SESSION[$this->connectorId]['node']->node->title; if(empty($titleShow)){ $titleShow = $_SESSION[$this->connectorId]['node']->node->name; } - + $this->container->view->render($response, 'h5p.html.twig', [ + 'WWWURL' => WWWURL, + 'title' => $titleShow, + 'content' => $content, + 'library' => $this->library, + 'parameters' => $this->parameters, + 'metadata' => $this->metadata, + 'styles' => $styles, + 'nodeId' => $_SESSION[$this->connectorId]['node']->node->ref->id, + 'connectorId' => $this->connectorId, + 'scripts' => $scripts, + 'integration' => json_encode($integration), + 'language' => $this -> language + ]); + /* echo '
'; echo '

'.$titleShow.'

'; echo '
'; @@ -238,7 +254,7 @@ public function showEditor($content) { echo ''; echo '
'; echo '
'; - echo ''; + echo '';*/ } public function setNode() { diff --git a/service/src/main/php/src/tools/h5p/js/h5peditor-init.js b/service/src/main/php/src/tools/h5p/js/h5peditor-init.js index f989203..cd35cfb 100644 --- a/service/src/main/php/src/tools/h5p/js/h5peditor-init.js +++ b/service/src/main/php/src/tools/h5p/js/h5peditor-init.js @@ -124,6 +124,9 @@ $(document).ready(function() { window.i = setInterval(H5PEditor.init, 10); + $("#h5p-content-form").on('submit', () => { + $("#h5p-content-form input.h5pSaveBtn").prop('disabled', true); + }); }); })(H5P.jQuery, H5PEditor); diff --git a/service/src/main/php/src/tools/lti/Lti.php b/service/src/main/php/src/tools/lti/Lti.php index a48bc4d..6945bf6 100644 --- a/service/src/main/php/src/tools/lti/Lti.php +++ b/service/src/main/php/src/tools/lti/Lti.php @@ -4,6 +4,8 @@ */ namespace connector\tools\lti; +use Slim\Http\Response; + define("LTI_VERSION", "LTI-1p0"); define("LTI_MESSAGE_TYPE", "basic-lti-launch-request"); define("OAUTH_CALLBACK", "about:blank"); @@ -83,7 +85,7 @@ private function renderLaunchForm() { '; } - public function run() { + public function run(Response $response) { $this->setToolConfig(); $this->prepareLaunchData(); $this->renderLaunchForm(); diff --git a/service/src/main/php/src/tools/onlyoffice/OnlyOffice.php b/service/src/main/php/src/tools/onlyoffice/OnlyOffice.php index 9062311..2570c38 100644 --- a/service/src/main/php/src/tools/onlyoffice/OnlyOffice.php +++ b/service/src/main/php/src/tools/onlyoffice/OnlyOffice.php @@ -2,10 +2,11 @@ namespace connector\tools\OnlyOffice; +use Slim\Http\Response; + class OnlyOffice extends \connector\lib\Tool { - public function run() - { + public function run(Response $response) { //$_SESSION[$this->connectorId]['fileUrl'] = $_SESSION[$this->connectorId]['node']->node->downloadUrl . '&ticket=' . $_SESSION[$this->connectorId]['ticket']; $_SESSION[$this->connectorId]['fileUrl'] = WWWURL . '/oo-content?sessionId=' . $_SESSION[$this->connectorId]['sessionId'] . '&downloadUrl=' . $_SESSION[$this->connectorId]['node']->node->downloadUrl; $this->forwardToEditor(); diff --git a/service/src/main/php/src/tools/onyx/Onyx.php b/service/src/main/php/src/tools/onyx/Onyx.php index 33a6a33..f62cf31 100644 --- a/service/src/main/php/src/tools/onyx/Onyx.php +++ b/service/src/main/php/src/tools/onyx/Onyx.php @@ -1,9 +1,11 @@ forwardToEditor(); } diff --git a/service/src/main/php/src/tools/tinymce/TinyMce.php b/service/src/main/php/src/tools/tinymce/TinyMce.php index a0f7d1b..f268b02 100644 --- a/service/src/main/php/src/tools/tinymce/TinyMce.php +++ b/service/src/main/php/src/tools/tinymce/TinyMce.php @@ -3,10 +3,11 @@ namespace connector\tools\tinymce; use connector\lib\EduRestClient; +use Slim\Http\Response; class TinyMce extends \connector\lib\Tool { - public function run() + public function run(Response $response) { $_SESSION[$this->connectorId]['first_run'] = true; $this->forwardToEditor(); diff --git a/service/src/main/php/templates/h5p.html.twig b/service/src/main/php/templates/h5p.html.twig new file mode 100644 index 0000000..4317a9a --- /dev/null +++ b/service/src/main/php/templates/h5p.html.twig @@ -0,0 +1,26 @@ + +{% for s in styles %} + +{% endfor %} + +{% for s in scripts %} + +{% endfor %} + + +
+

{{title}}

+
+ +
+
+ + + + +
+
+ + From ee3e0584888dc0afc698e874dcd85716898573e1 Mon Sep 17 00:00:00 2001 From: Torsten Simon Date: Thu, 22 Jun 2023 13:18:19 +0200 Subject: [PATCH 3/5] fix:typo image --- deploy/docker/helm/src/main/chart/templates/statefulset.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/docker/helm/src/main/chart/templates/statefulset.yml b/deploy/docker/helm/src/main/chart/templates/statefulset.yml index ed1747d..9304f4e 100644 --- a/deploy/docker/helm/src/main/chart/templates/statefulset.yml +++ b/deploy/docker/helm/src/main/chart/templates/statefulset.yml @@ -88,7 +88,7 @@ spec: spec: containers: - name: edu-sharing-connector-db - image: docker.edu-sharing.com/community/edu_sharing-community-services-connector-deploy-docker-build-posgtres:{{ .Values.version }} + image: docker.edu-sharing.com/community/edu_sharing-community-services-connector-deploy-docker-build-postgres:{{ .Values.version }} env: - name: POSTGRESQL_DATABASE value: connector From 39d5f1b53dcb84e2d57299742f13ded605a15f11 Mon Sep 17 00:00:00 2001 From: Torsten Simon Date: Thu, 22 Jun 2023 13:38:51 +0200 Subject: [PATCH 4/5] fix:typo image --- deploy/docker/helm/src/main/chart/templates/statefulset.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/docker/helm/src/main/chart/templates/statefulset.yml b/deploy/docker/helm/src/main/chart/templates/statefulset.yml index 9304f4e..ff4ec74 100644 --- a/deploy/docker/helm/src/main/chart/templates/statefulset.yml +++ b/deploy/docker/helm/src/main/chart/templates/statefulset.yml @@ -88,7 +88,7 @@ spec: spec: containers: - name: edu-sharing-connector-db - image: docker.edu-sharing.com/community/edu_sharing-community-services-connector-deploy-docker-build-postgres:{{ .Values.version }} + image: docker.edu-sharing.com/community/edu_sharing-community-services-connector-deploy-docker-build-postgresql:{{ .Values.version }} env: - name: POSTGRESQL_DATABASE value: connector From 1dba4f95d413b5a711990240ed269f1404e49214 Mon Sep 17 00:00:00 2001 From: Torsten Simon Date: Thu, 22 Jun 2023 13:40:56 +0200 Subject: [PATCH 5/5] fix:typo image --- deploy/docker/helm/src/main/chart/templates/statefulset.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/docker/helm/src/main/chart/templates/statefulset.yml b/deploy/docker/helm/src/main/chart/templates/statefulset.yml index ff4ec74..0ab6f2c 100644 --- a/deploy/docker/helm/src/main/chart/templates/statefulset.yml +++ b/deploy/docker/helm/src/main/chart/templates/statefulset.yml @@ -88,7 +88,7 @@ spec: spec: containers: - name: edu-sharing-connector-db - image: docker.edu-sharing.com/community/edu_sharing-community-services-connector-deploy-docker-build-postgresql:{{ .Values.version }} + image: docker.edu-sharing.com/community/edu_sharing-community-services-edu-connector-deploy-docker-build-postgresql:{{ .Values.version }} env: - name: POSTGRESQL_DATABASE value: connector