From 9aab29a1addc5feaca4a46c06cc81631b32c3ed3 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Mon, 11 May 2020 00:53:50 -0500 Subject: [PATCH] CKEditor: Integrate vimeo embed plugin --- composer.json | 9 ++++++++- .../ckeditor_vimeo_embed/integration/upload.php | 13 ++++++++++--- main/install/configuration.dist.php | 8 ++++++++ main/template/default/layout/main.js.tpl | 1 + .../Component/Editor/CkEditor/Toolbar/Basic.php | 1 + .../Editor/CkEditor/Toolbar/IntroductionSection.php | 6 ++++++ 6 files changed, 34 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index ade49eaa16..a2bf2849ef 100755 --- a/composer.json +++ b/composer.json @@ -117,7 +117,8 @@ "zendframework/zend-config": "~2.6|^3.0", "zendframework/zend-feed": "~2.6|^3.0", "zendframework/zend-http": "~2.6|^3.0", - "zendframework/zend-soap": "~2.6|^3.0" + "zendframework/zend-soap": "~2.6|^3.0", + "angelfqc/vimeo-api": "2.0.6" }, "require-dev": { "behat/behat": "3.5.0", @@ -158,6 +159,12 @@ "symfony-tests-dir": "tests", "symfony-web-dir": "web" }, + "repositories": [ + { + "type": "github", + "url": "https://github.com/AngelFQC/vimeo.php.git" + } + ], "config": { "component-dir": "web/assets" } diff --git a/main/inc/lib/javascript/ckeditor/plugins/ckeditor_vimeo_embed/integration/upload.php b/main/inc/lib/javascript/ckeditor/plugins/ckeditor_vimeo_embed/integration/upload.php index 06862c2106..054e8d5568 100644 --- a/main/inc/lib/javascript/ckeditor/plugins/ckeditor_vimeo_embed/integration/upload.php +++ b/main/inc/lib/javascript/ckeditor/plugins/ckeditor_vimeo_embed/integration/upload.php @@ -3,11 +3,18 @@ use Vimeo\Vimeo; -require 'vendor/autoload.php'; +require __DIR__.'/../../../../../../global.inc.php'; -header('Content-Type: application/json'); +$config = api_get_configuration_sub_value('ckeditor_vimeo_embed/config'); + +if (false === $config || + empty($config['client_id']) || empty($config['client_secret']) || empty($config['access_token']) +) { + echo json_encode(['error' => true, 'message' => get_lang('NotAllowed')]); + exit; +} -$config = require __DIR__.'/config.php'; +header('Content-Type: application/json'); try { if (empty($_FILES) || diff --git a/main/install/configuration.dist.php b/main/install/configuration.dist.php index 9902b8373d..901b19e797 100755 --- a/main/install/configuration.dist.php +++ b/main/install/configuration.dist.php @@ -1343,6 +1343,14 @@ requires extension "php-soap" sudo apt-get install php-soap // Changes the ck editor enter mode value. Default: CKEDITOR.ENTER_P // $_configuration['ck_editor_enter_mode_value'] = 'CKEDITOR.ENTER_BR'; +// Set CKEDITOR config for Vimeo Embed plugin +//$_configuration['ckeditor_vimeo_embed'] = [ +// 'config' => [ +// 'client_id' => '', +// 'client_secret' => '', +// 'access_token' => '', +// ], +//]; // CREATE TABLE user_career (id INT AUTO_INCREMENT NOT NULL, user_id INT NOT NULL, career_id INT NOT NULL, created_at DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB; // ALTER TABLE user_career ADD COLUMN extra_data LONGTEXT; diff --git a/main/template/default/layout/main.js.tpl b/main/template/default/layout/main.js.tpl index 056c14e8c3..4198d7389d 100644 --- a/main/template/default/layout/main.js.tpl +++ b/main/template/default/layout/main.js.tpl @@ -589,6 +589,7 @@ if (typeof CKEDITOR !== 'undefined') { 'flash', 'inserthtml', 'qmarkersrolls', + 'ckeditor_vimeo_embed', 'image2_chamilo' ]; diff --git a/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/Basic.php b/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/Basic.php index 7bed8eedbf..0ae2d32bfb 100644 --- a/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/Basic.php +++ b/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/Basic.php @@ -64,6 +64,7 @@ class Basic extends Toolbar 'inserthtml', 'xml', 'qmarkersrolls', + 'ckeditor_vimeo_embed', ]; /** diff --git a/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/IntroductionSection.php b/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/IntroductionSection.php index 7a45356491..b4769f5b9b 100644 --- a/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/IntroductionSection.php +++ b/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/IntroductionSection.php @@ -55,6 +55,8 @@ class IntroductionSection extends Basic */ protected function getNormalToolbar() { + $config = api_get_configuration_sub_value('ckeditor_vimeo_embed/config'); + return [ ['Maximize', 'PasteFromWord', '-', 'Undo', 'Redo'], ['Link', 'Unlink', 'Anchor', 'inserthtml', 'Glossary'], @@ -67,6 +69,7 @@ class IntroductionSection extends Basic 'Audio', 'Asciimath', 'Asciisvg', + empty($config) ? null : 'VimeoEmbed', ], ['Table', 'SpecialChar'], [ @@ -98,6 +101,8 @@ class IntroductionSection extends Basic */ protected function getMinimizedToolbar() { + $config = api_get_configuration_sub_value('ckeditor_vimeo_embed/config'); + return [ $this->getNewPageBlock(), ['Undo', 'Redo'], @@ -107,6 +112,7 @@ class IntroductionSection extends Basic 'Video', 'Flash', 'Youtube', + empty($config) ? null : 'VimeoEmbed', 'Audio', 'Table', 'Asciimath',