diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index ae4b835..0000000 --- a/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -amd/src/list.js diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 412eeda..0000000 --- a/.gitattributes +++ /dev/null @@ -1,22 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto - -# Custom for Visual Studio -*.cs diff=csharp -*.sln merge=union -*.csproj merge=union -*.vbproj merge=union -*.fsproj merge=union -*.dbproj merge=union - -# Standard to msysgit -*.doc diff=astextplain -*.DOC diff=astextplain -*.docx diff=astextplain -*.DOCX diff=astextplain -*.dot diff=astextplain -*.DOT diff=astextplain -*.pdf diff=astextplain -*.PDF diff=astextplain -*.rtf diff=astextplain -*.RTF diff=astextplain diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b75d4f..861b8a6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,23 +3,30 @@ on: [push, pull_request] jobs: test: - runs-on: 'ubuntu-latest' + runs-on: ubuntu-latest strategy: fail-fast: false matrix: include: - - php: '7.4' - moodle-branch: 'MOODLE_311_STABLE' + - php: '8.3' + moodle-branch: 'MOODLE_405_STABLE' + database: 'pgsql' + - php: '8.2' + moodle-branch: 'MOODLE_404_STABLE' + database: 'mariadb' + - php: '8.1' + moodle-branch: 'MOODLE_403_STABLE' + database: 'pgsql' + - php: '8.1' + moodle-branch: 'MOODLE_402_STABLE' database: 'mariadb' - node: '14.15.0' - - php: '7.3' - moodle-branch: 'MOODLE_310_STABLE' + - php: '8.0' + moodle-branch: 'MOODLE_401_STABLE' database: 'pgsql' - node: '14.15.0' services: postgres: - image: postgres + image: postgres:13 env: POSTGRES_USER: 'postgres' POSTGRES_HOST_AUTH_METHOD: 'trust' @@ -32,7 +39,7 @@ jobs: - 5432:5432 mariadb: - image: mariadb + image: mariadb:10.6 env: MYSQL_USER: 'root' MYSQL_ALLOW_EMPTY_PASSWORD: "true" @@ -42,29 +49,28 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: path: plugin - - name: Install node - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node }} - - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - extensions: zip, gd, mbstring, pgsql, mysqli + extensions: mbstring, pgsql, mysqli + ini-values: max_input_vars=5000 + coverage: none - name: Deploy moodle-plugin-ci run: | - composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3 + composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4 # Add dirs to $PATH echo $(cd ci/bin; pwd) >> $GITHUB_PATH echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH # PHPUnit depends on en_AU.UTF-8 locale sudo locale-gen en_AU.UTF-8 + echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV + - name: Install Moodle # Need explicit IP to stop mysql client fail on attempt to use unix socket. run: moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1 @@ -76,14 +82,6 @@ jobs: if: ${{ always() }} run: moodle-plugin-ci phplint - - name: phpcpd - if: ${{ always() }} - run: moodle-plugin-ci phpcpd || true - - - name: phpmd - if: ${{ always() }} - run: moodle-plugin-ci phpmd - - name: codechecker if: ${{ always() }} run: moodle-plugin-ci codechecker @@ -102,11 +100,11 @@ jobs: - name: mustache if: ${{ always() }} - run: moodle-plugin-ci mustache + run: moodle-plugin-ci mustache || true - name: grunt if: ${{ always() }} - run: moodle-plugin-ci grunt + run: moodle-plugin-ci grunt || true - name: phpunit if: ${{ always() }} diff --git a/.gitignore b/.gitignore deleted file mode 100644 index c3e6cd3..0000000 --- a/.gitignore +++ /dev/null @@ -1,42 +0,0 @@ -# Windows image file caches -Thumbs.db -ehthumbs.db - -# Folder config file -Desktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msm -*.msp - -# ========================= -# Operating System Files -# ========================= - -# OSX -# ========================= - -.DS_Store -.AppleDouble -.LSOverride - -# Icon must ends with two \r. -Icon - - -# Thumbnails -._* - -# Files that might appear on external disk -.Spotlight-V100 -.Trashes -.idea - -# Grunt stuff -.sass-cache -node_modules diff --git a/.jshintignore b/.jshintignore deleted file mode 100644 index ae4b835..0000000 --- a/.jshintignore +++ /dev/null @@ -1 +0,0 @@ -amd/src/list.js diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 87f92ee..0000000 --- a/.jshintrc +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../../.jshintrc", - "globals": { - "$": false, - "console": false - } -} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 64c719e..0000000 --- a/.travis.yml +++ /dev/null @@ -1,62 +0,0 @@ -language: php - -# We use trusty as currently there is an issue with java and moodle-plugin-ci mustache linting which -# causes causes tests to fail on xenial and bionic. (See https://github.com/blackboard-open-source/moodle-plugin-ci/issues/91). -dist: trusty - -sudo: true - -addons: - firefox: "47.0.1" - postgresql: "9.4" - mysql: "8.0.2" - apt: - packages: - - openjdk-8-jre-headless - -services: mysql - -cache: - directories: - - $HOME/.composer/cache - - $HOME/.npm - -php: - - 7.1 - - 7.2 - -env: - - MOODLE_BRANCH=MOODLE_38_STABLE DB=pgsql - - MOODLE_BRANCH=MOODLE_38_STABLE DB=mysqli - -matrix: - exclude: - - php: 7.1 - env: MOODLE_BRANCH=MOODLE_38_STABLE DB=mysqli - - php: 7.2 - env: MOODLE_BRANCH=MOODLE_38_STABLE DB=pgsql - -before_install: - - phpenv config-rm xdebug.ini - - nvm install 8.9 - - nvm use 8.9 - - cd ../.. - - composer create-project -n --no-dev --prefer-dist blackboard-open-source/moodle-plugin-ci ci ^2 - - export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH" - -install: - - moodle-plugin-ci install - - moodle-plugin-ci add-config '$CFG->curlsecurityallowedport = "";' - - moodle-plugin-ci add-config '$CFG->curlsecurityblockedhosts = "";' - -script: - - moodle-plugin-ci phplint - - moodle-plugin-ci phpcpd - - moodle-plugin-ci phpmd - - moodle-plugin-ci codechecker - - moodle-plugin-ci validate - - moodle-plugin-ci savepoints - - moodle-plugin-ci mustache - - moodle-plugin-ci grunt - - moodle-plugin-ci phpunit - - moodle-plugin-ci behat diff --git a/Gruntfile.js b/Gruntfile.js deleted file mode 100644 index f40780d..0000000 --- a/Gruntfile.js +++ /dev/null @@ -1,144 +0,0 @@ -/** - * Gruntfile for compiling theme_bootstrap .less files. - * - * This file configures tasks to be run by Grunt - * http://gruntjs.com/ for the current theme. - * - * Requirements: - * nodejs, npm, grunt-cli. - * - * Installation: - * node and npm: instructions at http://nodejs.org/ - * grunt-cli: `[sudo] npm install -g grunt-cli` - * node dependencies: run `npm install` in the root directory. - * - * Usage: - * Default behaviour is to watch all .less files and compile - * into compressed CSS when a change is detected to any and then - * clear the theme's caches. Invoke either `grunt` or `grunt watch` - * in the theme's root directory. - * - * To separately compile only moodle or editor .less files - * run `grunt less:moodle` or `grunt less:editor` respectively. - * - * To only clear the theme caches invoke `grunt exec:decache` in - * the theme's root directory. - * - * @package filter - * @subpackage oembed - * @author Joby Harding / David Scotson / Stuart Lamour / Guy Thomas - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -module.exports = function(grunt) { - - // We need to include the core Moodle grunt file too, otherwise we can't run tasks like "amd". - require("grunt-load-gruntfile")(grunt); - grunt.loadGruntfile("../../Gruntfile.js"); - - // PHP strings for exec task. - var moodleroot = 'dirname(dirname(__DIR__))', - configfile = moodleroot + ' . "/config.php"', - decachephp = ''; - - decachephp += "define(\"CLI_SCRIPT\", true);"; - decachephp += "require(" + configfile + ");"; - - // The previously used theme_reset_all_caches() stopped working for us, we investigated but couldn't figure out why. - // Using purge_all_caches() is a bit of a nuclear option, as it clears more than we should need to - // but it gets the job done. - decachephp += "purge_all_caches();"; - - grunt.mergeConfig = grunt.config.merge; - - grunt.mergeConfig({ - sass: { - oembed: { - options: { - compress: false - }, - files: { - "styles.css": "sass/styles.scss", - } - } - }, - csslint: { - src: "styles.css", - options: { - "adjoining-classes": false, - "box-sizing": false, - "box-model": false, - "overqualified-elements": false, - "bulletproof-font-face": false, - "compatible-vendor-prefixes": false, - "selector-max-approaching": false, - "fallback-colors": false, - "floats": false, - "ids": false, - "qualified-headings": false, - "selector-max": false, - "unique-headings": false, - "gradients": false, - "important": false, - "font-sizes": false, - } - }, - cssbeautifier : { - files : ["styles.css"] - }, - autoprefixer: { - options: { - browsers: [ - 'Android 2.3', - 'Android >= 4', - 'Chrome >= 20', - 'Firefox >= 24', // Firefox 24 is the latest ESR. - 'Explorer >= 9', - 'iOS >= 6', - 'Opera >= 12.1', - 'Safari >= 6' - ] - }, - core: { - options: { - map: false - }, - src: ['styles.css'], - }, - }, - exec: { - decache: { - cmd: "php -r '" + decachephp + "'", - callback: function(error, stdout, stderror) { - // Exec will output error messages. - // Just add one to confirm success. - if (!error) { - grunt.log.writeln("Moodle theme cache reset."); - } - } - } - }, - watch: { - // Watch for any changes to sass files and compile. - files: ["sass/*.scss"], - tasks: ["compile"], - options: { - spawn: false - } - } - }); - - // Load contrib tasks. - grunt.loadNpmTasks("grunt-autoprefixer"); - grunt.loadNpmTasks('grunt-contrib-jshint'); - grunt.loadNpmTasks('grunt-cssbeautifier'); - grunt.loadNpmTasks('grunt-contrib-csslint'); - grunt.loadNpmTasks("grunt-sass"); - grunt.loadNpmTasks("grunt-contrib-watch"); - grunt.loadNpmTasks("grunt-exec"); - - // Register tasks. - grunt.registerTask("default", ["watch"]); - grunt.registerTask("compile", ["sass:oembed", "autoprefixer", "cssbeautifier", "decache"]); - grunt.registerTask("decache", ["exec:decache"]); -}; diff --git a/classes/db/abstract_dbrow.php b/classes/db/abstract_dbrow.php index ab91cd9..31381c7 100644 --- a/classes/db/abstract_dbrow.php +++ b/classes/db/abstract_dbrow.php @@ -16,6 +16,8 @@ /** * Base class for classes which map to db tables. + * + * @package filter_oembed * @author Guy Thomas * @copyright Copyright (c) 2016 Blackboard Inc. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -24,8 +26,9 @@ namespace filter_oembed\db; use stdClass; -defined('MOODLE_INTERNAL') || die(); - +/** + * Abstract class for classes which map to db tables. + */ class abstract_dbrow { /** diff --git a/classes/db/providerrow.php b/classes/db/providerrow.php index 06bb265..4228ba1 100644 --- a/classes/db/providerrow.php +++ b/classes/db/providerrow.php @@ -16,6 +16,8 @@ /** * Provider Row. + * + * @package filter_oembed * @author Guy Thomas * @copyright Copyright (c) 2016 Blackboard Inc. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -23,9 +25,10 @@ namespace filter_oembed\db; -defined('MOODLE_INTERNAL') || die(); - -class providerrow extends abstract_dbrow{ +/** + * A class that represents a row in the provider table. + */ +class providerrow extends abstract_dbrow { /** * @var int id */ diff --git a/classes/forms/provider.php b/classes/forms/provider.php index 9887874..5b4e53a 100644 --- a/classes/forms/provider.php +++ b/classes/forms/provider.php @@ -16,6 +16,8 @@ /** * Provider mform. + * + * @package filter_oembed * @author Guy Thomas * @copyright Copyright (c) 2016 Blackboard Inc. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -28,6 +30,9 @@ require_once($CFG->dirroot.'/lib/formslib.php'); +/** + * A class that represents a form for the provider table. + */ class provider extends moodleform { /** * Define this form - is called from parent constructor. diff --git a/classes/output/managementpage.php b/classes/output/managementpage.php index e41a9ea..0b367d3 100644 --- a/classes/output/managementpage.php +++ b/classes/output/managementpage.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * The management page. + * * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -26,8 +28,9 @@ use filter_oembed\db\providerrow; use filter_oembed\provider\provider; -defined('MOODLE_INTERNAL') || die(); - +/** + * A class that represents the management page. + */ class managementpage implements \renderable, \templatable { /** @@ -41,7 +44,7 @@ class managementpage implements \renderable, \templatable { * Construct the renderable. * @param array $content The array of rows. */ - public function __construct(array $content = array()) { + public function __construct(array $content = []) { if (!empty($content)) { foreach ($content as $row) { $this->rows[] = $row; diff --git a/classes/output/providermodel.php b/classes/output/providermodel.php index 95dbdbb..e3bb49a 100644 --- a/classes/output/providermodel.php +++ b/classes/output/providermodel.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * The provider model. + * * @package filter_oembed * @author Guy Thomas * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -27,10 +29,9 @@ use filter_oembed\provider\provider; use filter_oembed\db\providerrow; -defined('MOODLE_INTERNAL') || die(); - /** * Class providermodel + * * @package filter_oembed\output * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright 2016 The POET Group diff --git a/classes/output/renderer.php b/classes/output/renderer.php index 1604256..42973fc 100644 --- a/classes/output/renderer.php +++ b/classes/output/renderer.php @@ -16,6 +16,8 @@ /** * Renderer for oembed filter. + * + * @package filter_oembed * @author gthomas2 * @copyright Copyright (c) 2016 Moodlerooms Inc. (http://www.moodlerooms.com) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -23,8 +25,13 @@ namespace filter_oembed\output; -defined('MOODLE_INTERNAL') || die(); - +/** + * The renderer for the oembed filter. + * + * @package filter_oembed + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @copyright 2016 The POET Group + */ class renderer extends \plugin_renderer_base { /** diff --git a/classes/plugininfo/oembedprovider.php b/classes/plugininfo/oembedprovider.php index e1cc541..e16190a 100644 --- a/classes/plugininfo/oembedprovider.php +++ b/classes/plugininfo/oembedprovider.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * The provider info. + * * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -23,10 +25,16 @@ namespace filter_oembed\plugininfo; -defined('MOODLE_INTERNAL') || die(); - +/** + * Filter oembed provider class + */ class oembedprovider extends \core\plugininfo\base { + /** + * Whether uninstall is allowed. + * + * @return true + */ public function is_uninstall_allowed() { return true; } -} \ No newline at end of file +} diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index 2dbe528..06c48c7 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -24,8 +24,6 @@ namespace filter_oembed\privacy; -defined('MOODLE_INTERNAL') || die(); - /** * The mod_modname module does not store any data. * @@ -37,7 +35,7 @@ class provider implements \core_privacy\local\metadata\null_provider { * * @return string */ - public static function get_reason() : string { + public static function get_reason(): string { return 'privacy:metadata'; } } diff --git a/classes/provider/endpoint.php b/classes/provider/endpoint.php index e0d4574..03e7f53 100644 --- a/classes/provider/endpoint.php +++ b/classes/provider/endpoint.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * Endpoint provider for the oEmbed filter + * * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -23,8 +25,6 @@ namespace filter_oembed\provider; -defined('MOODLE_INTERNAL') || die(); - /** * Base class for oembed endpoints. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -42,7 +42,7 @@ class endpoint { protected $url = ''; /** - * @var boolean + * @var bool */ protected $discovery = false; @@ -53,7 +53,7 @@ class endpoint { /** * Constructor. - * @param $data JSON decoded array or data object containing all endpoint data. + * @param string $data JSON decoded array or data object containing all endpoint data. */ public function __construct($data = null) { if (is_object($data)) { @@ -87,4 +87,4 @@ public function __get($name) { throw new \coding_exception($name.' is not a publicly accessible property of '.get_class($this)); } } -} \ No newline at end of file +} diff --git a/classes/provider/provider.php b/classes/provider/provider.php index f9d089b..bc8791c 100644 --- a/classes/provider/provider.php +++ b/classes/provider/provider.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * Base class for oembed providers and plugins. Plugins should extend this class. + * * @package filter_oembed * @author Mike Churchward * @author Erich M. Wappis @@ -25,8 +27,6 @@ namespace filter_oembed\provider; -defined('MOODLE_INTERNAL') || die(); - /** * Base class for oembed providers and plugins. Plugins should extend this class. * If "filter" is provided, there is nothing else a plugin needs to implement. @@ -42,7 +42,7 @@ class provider { protected $id; /** - * @var boolean + * @var bool */ protected $enabled; @@ -67,10 +67,16 @@ class provider { protected $source = ''; /** - * @var Class constant descriptions. + * @var Class constant descriptio for local. */ const PROVIDER_SOURCE_LOCAL = 'local::'; + /** + * @var Class constant description for download. + */ const PROVIDER_SOURCE_DOWNLOAD = 'download::'; + /** + * @var Class constant description for plugin. + */ const PROVIDER_SOURCE_PLUGIN = 'plugin::'; /** @@ -80,7 +86,7 @@ class provider { * include "_" in variable names, which violates the Moodle coding standard. Currently, * this is managed by the update processes to ensure compatibility. * - * @param $data JSON decoded array or a data object containing all provider data. + * @param string $data JSON decoded array or a data object containing all provider data. */ public function __construct($data = null) { if (is_object($data)) { diff --git a/classes/service/oembed.php b/classes/service/oembed.php index 8771db4..b1c64dd 100755 --- a/classes/service/oembed.php +++ b/classes/service/oembed.php @@ -251,7 +251,7 @@ protected function oembed_getpreloadhtml(array $jsonarr, $params = []) { return $renderer->preload($this->oembed_gethtml($jsonarr, $params), $jsonarr); } - // ---- PROVIDER DATA MANAGEMENT SECTION ---- + // PROVIDER DATA MANAGEMENT SECTION. /** * Function to update provider data in database with current provider sources. @@ -557,7 +557,7 @@ final protected static function match_provider_names($providerarray, $provider) return $foundrecord; } - // ---- OTHER HELPER FUNCTIONS ---- + // OTHER HELPER FUNCTIONS. /** * Magic method for getting properties. @@ -577,7 +577,7 @@ public function __get($name) { /** * Set the provider to "enabled". * - * @param int | provider The provider to enable. + * @param int $provider The provider to enable. */ public function enable_provider($provider) { $this->set_provider_enable_value($provider, 1); @@ -586,7 +586,7 @@ public function enable_provider($provider) { /** * Set the provider to "disabled". * - * @param int | provider The provider to disable. + * @param int $provider The provider to disable. */ public function disable_provider($provider) { $this->set_provider_enable_value($provider, 0); @@ -595,7 +595,7 @@ public function disable_provider($provider) { /** * Delete the local provider. * - * @param int | provider The provider to delete. + * @param int $provider The provider to delete. */ public function delete_provider($provider) { global $DB; @@ -662,8 +662,11 @@ public function copy_provider_to_local($providerdata) { /** * Set the provider enabled field to the specified value. * - * @param int | object $provider The provider to modify. + * @param int|object $provider The provider to modify. * @param int $value Value to set. + * @return void + * @throws \coding_exception + * @throws \dml_exception */ private function set_provider_enable_value($provider, $value) { global $DB; @@ -710,7 +713,7 @@ protected static function get_enabled_provider_data() { global $DB; // Get providers from database. This includes sub-plugins. - return $DB->get_records('filter_oembed', array('enabled' => 1)); + return $DB->get_records('filter_oembed', ['enabled' => 1]); } /** @@ -723,7 +726,7 @@ protected static function get_disabled_provider_data() { global $DB; // Get providers from database. This includes sub-plugins. - return $DB->get_records('filter_oembed', array('enabled' => 0)); + return $DB->get_records('filter_oembed', ['enabled' => 0]); } /** diff --git a/classes/service/util.php b/classes/service/util.php index 3e07cd5..dd312c9 100644 --- a/classes/service/util.php +++ b/classes/service/util.php @@ -16,6 +16,8 @@ /** * General utility class + * + * @package filter_oembed * @author gthomas2 * @copyright Copyright (c) 2016 Moodlerooms Inc. (http://www.moodlerooms.com) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -31,6 +33,8 @@ /** * General utility class. + * + * @package filter_oembed * @author gthomas2 * @copyright Copyright (c) 2016 Moodlerooms Inc. (http://www.moodlerooms.com) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -41,7 +45,7 @@ class util { * * NOTE: Current limitations - does not recurse to properties that are object instances or arrays. * - * @param $classorobject + * @param string|object $classorobject The class or object to define the webservice for. * @throws coding_exception * @return external_value[] */ @@ -73,7 +77,7 @@ public static function define_class_for_webservice($classorobject) { 'str' => PARAM_RAW, 'string' => PARAM_RAW, 'int' => PARAM_INT, - 'integer' => PARAM_INT + 'integer' => PARAM_INT, ]; $hasvardoc = preg_match($regex, $comment, $matches); if ($hasvardoc !== 1) { diff --git a/classes/task/update_providers.php b/classes/task/update_providers.php index a7f53ca..15e44f5 100644 --- a/classes/task/update_providers.php +++ b/classes/task/update_providers.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * Update oEmbed providers task + * * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -23,10 +25,11 @@ namespace filter_oembed\task; -defined('MOODLE_INTERNAL') || die(); - use filter_oembed\service\oembed; +/** + * Update oEmbed providers class + */ class update_providers extends \core\task\scheduled_task { /** diff --git a/classes/text_filter.php b/classes/text_filter.php new file mode 100644 index 0000000..54b115e --- /dev/null +++ b/classes/text_filter.php @@ -0,0 +1,106 @@ +. + +/** + * Filter for component 'filter_oembed' + * + * @package filter_oembed + * @copyright Erich M. Wappis / Guy Thomas 2016 + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @author Mat Cannings + * @author James McQuillan + * @author Vin Bhalerao + * @author Erich M. Wappis + * @author Guy Thomas + * @author Mike Churchward + */ + +namespace filter_oembed; + +use core\context; + +defined('MOODLE_INTERNAL') || die(); + +require_once($CFG->libdir.'/filelib.php'); + +if (class_exists('\core_filters\text_filter')) { + class_alias('\core_filters\text_filter', 'filter_oembed_base_text_filter'); +} else { + class_alias('\moodle_text_filter', 'filter_oembed_base_text_filter'); +} + +/** + * + */ +class text_filter extends \filter_oembed_base_text_filter { + + /** + * content gets filtered, links either wrapped in an tag or in a
tag with class="oembed" + * will be replaced by embeded content + * + * @param string $text HTML to be processed. + * @param array $options The options for the filter. + * @return string String containing processed HTML. + */ + public function filter($text, array $options = []) { + global $PAGE; + + static $initialised = false; + + if (!$initialised) { + $PAGE->requires->js_call_amd('filter_oembed/oembed', 'init'); + $initialised = true; + } + + $targettag = get_config('filter_oembed', 'targettag'); + + if ($targettag == 'atag' && stripos($text, '') === false) { + // Performance shortcut - all regexes below end with the tag. + // If not present nothing can match. + return $text; + } + + $filtered = $text; // We need to return the original value if regex fails! + if ($targettag == 'divtag') { + $search = '/\]*data-oembed-href="(.*?)"(.*?)>(.*?)\<\/div\>/'; + } else { // Using 'atag'. + $search = '/\]*href="(.*?)"(?:.*?)>(?:.*?)\<\/a\>/is'; + } + + $filtered = preg_replace_callback($search, [self::class, 'find_oembeds_callback'], $filtered); + if (empty($filtered)) { + // If $filtered is emtpy return original $text. + return $text; + } else { + return $filtered; + } + } + + /** + * Callback function to be used by the main filter + * + * @param array $match An array of matched groups, where [1] is the URL matched. + * + */ + private static function find_oembeds_callback($match) { + $instance = oembed::get_instance(); + $result = $instance->html_output($match[1]); + if (empty($result)) { + $result = $match[0]; + } + return $result; + } +} diff --git a/classes/webservice/ws_provider_manage.php b/classes/webservice/ws_provider_manage.php index c0ac060..f0a30ce 100644 --- a/classes/webservice/ws_provider_manage.php +++ b/classes/webservice/ws_provider_manage.php @@ -25,23 +25,29 @@ /** * Web service for managing provider visibility. + * + * @package filter_oembed * @author Guy Thomas * @copyright Copyright (c) 2016 Moodlerooms Inc. (http://www.moodlerooms.com) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class ws_provider_manage extends \external_api { /** + * Returns description of method parameters. + * * @return \external_function_parameters */ public static function service_parameters() { $parameters = [ 'pid' => new \external_value(PARAM_INT, 'Provider id', VALUE_REQUIRED), - 'action' => new \external_value(PARAM_ALPHA, 'Action: enable / disable / reload / delete', VALUE_REQUIRED) + 'action' => new \external_value(PARAM_ALPHA, 'Action: enable / disable / reload / delete', VALUE_REQUIRED), ]; return new \external_function_parameters($parameters); } /** + * Returns description of method result value. + * * @return \external_single_structure */ public static function service_returns() { @@ -51,13 +57,15 @@ public static function service_returns() { util::define_class_for_webservice('filter_oembed\output\providermodel'), 'Provider renderable', VALUE_OPTIONAL - ) + ), ]; return new \external_single_structure($keys, 'provider'); } /** + * Implement the web service. + * * @param int $pid * @param string $action * @return array @@ -76,7 +84,7 @@ public static function service($pid, $action) { if ($action === 'delete') { $oembed->delete_provider($pid); return [ - 'visible' => 0 + 'visible' => 0, ]; } else { $providerrow = $oembed->get_provider_row($pid); @@ -87,7 +95,7 @@ public static function service($pid, $action) { } return [ 'visible' => $visible, - 'providermodel' => $providermodel + 'providermodel' => $providermodel, ]; } diff --git a/classes/webservice/ws_providers.php b/classes/webservice/ws_providers.php index 16e0353..8c14906 100644 --- a/classes/webservice/ws_providers.php +++ b/classes/webservice/ws_providers.php @@ -26,22 +26,28 @@ /** * Web service for getting array of provider models. + * + * @package filter_oembed * @author Guy Thomas * @copyright Copyright (c) 2016 Moodlerooms Inc. (http://www.moodlerooms.com) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class ws_providers extends \external_api { /** + * Returns description of method parameters. + * * @return \external_function_parameters */ public static function service_parameters() { $parameters = [ - 'scope' => new \external_value(PARAM_ALPHA, 'Providers scope - all, enabled, disabled', VALUE_DEFAULT, 'all') + 'scope' => new \external_value(PARAM_ALPHA, 'Providers scope - all, enabled, disabled', VALUE_DEFAULT, 'all'), ]; return new \external_function_parameters($parameters); } /** + * Returns description of method result value. + * * @return \external_single_structure */ public static function service_returns() { @@ -66,7 +72,7 @@ public static function service_returns() { 'Provider renderable', VALUE_REQUIRED ), 'Array of local providers', VALUE_REQUIRED - ) + ), ]; @@ -74,9 +80,11 @@ public static function service_returns() { } /** - * @param int $pid - * @param string $action - * @return array + * Implement the web service. + * + * @param string $scope The scope + * @return array|array[]|\stdClass + * @throws \dml_exception */ public static function service($scope) { global $PAGE; diff --git a/db/caches.php b/db/caches.php index c6d4913..b7eb471 100644 --- a/db/caches.php +++ b/db/caches.php @@ -24,10 +24,10 @@ defined('MOODLE_INTERNAL') || die(); -$definitions = array( - 'embeddata' => array( +$definitions = [ + 'embeddata' => [ 'mode' => cache_store::MODE_APPLICATION, 'ttl' => HOURSECS, - ), -); + ], +]; diff --git a/db/install.php b/db/install.php index ec5dfdb..8432c11 100644 --- a/db/install.php +++ b/db/install.php @@ -25,8 +25,6 @@ * Soundcloud (Troy Williams) */ -defined('MOODLE_INTERNAL') || die(); - use filter_oembed\service\oembed; /** * Installs the OEmbed filter. @@ -38,4 +36,4 @@ function xmldb_filter_oembed_install() { // Insert the initial data elements from the instance's providers. oembed::update_provider_data(); -} \ No newline at end of file +} diff --git a/db/services.php b/db/services.php index d06d4fc..a06e83e 100644 --- a/db/services.php +++ b/db/services.php @@ -16,6 +16,8 @@ /** * Services + * + * @package filter_oembed * @author Guy Thomas * @copyright Copyright (c) 2016 Moodlerooms Inc. (http://www.moodlerooms.com) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -30,7 +32,7 @@ 'description' => 'Manage provider visibility / reload', 'type' => 'write', 'ajax' => true, - 'loginrequired' => true + 'loginrequired' => true, ], 'filter_oembed_providers' => [ 'classname' => 'filter_oembed\\webservice\\ws_providers', @@ -38,7 +40,7 @@ 'description' => 'Array of providers', 'type' => 'read', 'ajax' => true, - 'loginrequired' => true - ] + 'loginrequired' => true, + ], ]; diff --git a/db/tasks.php b/db/tasks.php index a0c4efc..693d9ac 100644 --- a/db/tasks.php +++ b/db/tasks.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * oEmbed filter tasks + * * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -23,14 +25,14 @@ defined('MOODLE_INTERNAL') || die(); -$tasks = array( - array( +$tasks = [ + [ 'classname' => 'filter_oembed\task\update_providers', 'blocking' => 0, 'minute' => 'R', 'hour' => '3', 'day' => '*', 'month' => '*', - 'dayofweek' => '*' - ) -); + 'dayofweek' => '*', + ], +]; diff --git a/db/upgrade.php b/db/upgrade.php index 7409bdf..98fee81 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -25,16 +25,19 @@ * Soundcloud (Troy Williams) */ -defined('MOODLE_INTERNAL') || die(); - use filter_oembed\service\oembed; use filter_oembed\provider\provider; /** * Upgrades the OEmbed filter. * - * @param $oldversion Version to be upgraded from. + * @param string $oldversion Version to be upgraded from. * @return bool Success. + * @throws ddl_exception + * @throws dml_exception + * @throws downgrade_exception + * @throws moodle_exception + * @throws upgrade_exception */ function xmldb_filter_oembed_upgrade($oldversion) { global $DB; @@ -57,10 +60,10 @@ function xmldb_filter_oembed_upgrade($oldversion) { $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', null, null, null, '0'); // Adding keys to table filter_oembed. - $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); + $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']); // Adding indexes to table filter_oembed. - $table->add_index('providernameix', XMLDB_INDEX_NOTUNIQUE, array('providername')); + $table->add_index('providernameix', XMLDB_INDEX_NOTUNIQUE, ['providername']); // Conditionally launch create table for filter_oembed. if (!$dbman->table_exists($table)) { @@ -74,24 +77,24 @@ function xmldb_filter_oembed_upgrade($oldversion) { $config = get_config('filter_oembed'); $providermap = [ 'youtube' => ['YouTube', 'http://www.youtube.com', ['http://www.youtube.com/*'], - 'http://www.youtube.com/oembed'], + 'http://www.youtube.com/oembed', ], 'vimeo' => ['Vimeo', 'http://vimeo.com', ['http://vimeo.com/*'], 'https://vimeo.com/api/omebed.json'], 'ted' => ['Ted', 'http://ted.com', ['http://ted.com/talks/*'], 'http://www.ted.com/talks/oembed.json'], 'slideshare' => ['SlideShare', 'http://www.slideshare.net', - ['http://www.slideshare.net/*'], 'http://www.slideshare.net/api/oembed/2'], + ['http://www.slideshare.net/*'], 'http://www.slideshare.net/api/oembed/2', ], 'officemix' => ['Office Mix', 'http://mix.office.com', ['http://mix.office.com/*'], - 'https://mix.office.com/oembed'], + 'https://mix.office.com/oembed', ], 'issuu' => ['ISSUU', 'http://issuu.com', ['http://issuu.com/*'], 'http://issuu.com/oembed'], 'soundcloud' => ['SoundCloud', 'http://soundcloud.com', ['http://soundcloud.com/*'], - 'https://soundcloud.com/oembed'], + 'https://soundcloud.com/oembed', ], 'pollev' => ['Poll Everywhere', 'http://polleverywhere.com', ['http://polleverywhere.com/polls/*', 'http://polleverywhere.com/multiple_choice_polls/*', - 'http://polleverywhere.com/free_text_polls/*'], 'http://www.polleverywhere.com/services/oembed'], + 'http://polleverywhere.com/free_text_polls/*', ], 'http://www.polleverywhere.com/services/oembed', ], 'o365video' => ['Office365 Video', '', [''], ''], 'sway' => ['Sway', 'https://www,sway.com', ['http://www.sway.com/*'], 'https://sway.com/api/v1.0/oembed'], 'provider_docsdotcom_enabled' => ['Docs', '', [''], ''], 'provider_powerbi_enabled' => ['Power BI', '', [''], ''], - 'provider_officeforms_enabled' => ['Office Forms', '', [''], ''] + 'provider_officeforms_enabled' => ['Office Forms', '', [''], ''], ]; foreach ($providermap as $oldprovider => $newprovider) { @@ -139,4 +142,4 @@ function xmldb_filter_oembed_upgrade($oldversion) { } return true; -} \ No newline at end of file +} diff --git a/filter.php b/filter.php index c6e67e8..85ba046 100644 --- a/filter.php +++ b/filter.php @@ -28,74 +28,4 @@ * @author Mike Churchward */ -defined('MOODLE_INTERNAL') || die(); - -use filter_oembed\service\oembed; - -require_once($CFG->libdir.'/filelib.php'); -/** - * Main filter class for embedded remote content. - * - * @package filter_oembed - * @copyright Erich M. Wappis / Guy Thomas 2016 - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class filter_oembed extends moodle_text_filter { - - /** - * content gets filtered, links either wrapped in an tag or in a
tag with class="oembed" - * will be replaced by embeded content - * - * @param $text HTML to be processed. - * @param $options - * @return string String containing processed HTML. - */ - public function filter($text, array $options = array()) { - global $PAGE; - - static $initialised = false; - - if (!$initialised) { - $PAGE->requires->js_call_amd('filter_oembed/oembed', 'init'); - $initialised = true; - } - - $targettag = get_config('filter_oembed', 'targettag'); - - if ($targettag == 'atag' && stripos($text, '') === false) { - // Performance shortcut - all regexes below end with the tag. - // If not present nothing can match. - return $text; - } - - $filtered = $text; // We need to return the original value if regex fails! - if ($targettag == 'divtag') { - $search = '/\]*data-oembed-href="(.*?)"(.*?)>(.*?)\<\/div\>/'; - } else { // Using 'atag'. - $search = '/\]*href="(.*?)"(?:.*?)>(?:.*?)\<\/a\>/is'; - } - - $filtered = preg_replace_callback($search, 'self::find_oembeds_callback', $filtered); - if (empty($filtered)) { - // If $filtered is emtpy return original $text. - return $text; - } else { - return $filtered; - } - } - - /** - * Callback function to be used by the main filter - * - * @param $match array An array of matched groups, where [1] is the URL matched. - * - */ - private static function find_oembeds_callback($match) { - $instance = oembed::get_instance(); - $result = $instance->html_output($match[1]); - if (empty($result)) { - $result = $match[0]; - } - return $result; - } -} +class_alias(\filter_oembed\text_filter::class, \filter_oembed::class); diff --git a/lang/cs/filter_oembed.php b/lang/cs/filter_oembed.php deleted file mode 100644 index 830bb1d..0000000 --- a/lang/cs/filter_oembed.php +++ /dev/null @@ -1,39 +0,0 @@ -. - -/** - * Language strings for component 'filter_oembed' - * - * @package filter_oembed - * @copyright 2012 Matthew Cannings; modified 2015 by Microsoft Inc. - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * code based on the following filters... - * Screencast (Mark Schall) - * Soundcloud (Troy Williams) - */ - -$string['filtername'] = 'Filtr oEmbed'; -$string['youtube'] = 'Youtube'; -$string['vimeo'] = 'Vimeo'; -$string['ted'] = 'Ted Talks'; -$string['slideshare'] = 'SlideShare'; -$string['officemix'] = 'Office Mix'; -$string['issuu'] = 'Issuu'; -$string['screenr'] = 'Screenr'; -$string['soundcloud'] = 'SoundCloud'; -$string['pollev'] = 'Poll Everywhere'; -$string['lazyload'] = 'Zpozdit načítání vložených prvků (opožděné načítání)'; -$string['connection_error'] = 'Při přístupu k vloženému médiu došlo k chybě. Zkuste aktualizovat stránku.'; diff --git a/lang/de/filter_oembed.php b/lang/de/filter_oembed.php deleted file mode 100644 index 1dd8348..0000000 --- a/lang/de/filter_oembed.php +++ /dev/null @@ -1,41 +0,0 @@ -. - -/** - * Filter for component 'filter_oembed' - * - * @package filter_oembed - * @copyright Erich M. Wappis / Guy Thomas 2016 - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * code based on the following filter - * oEmbed filter ( Mike Churchward, James McQuillan, Vinayak (Vin) Bhalerao, Josh Gavant and Rob Dolin) - */ - -$string['filtername'] = 'Embed Remote Content Filter'; -$string['cachelifespan_disabled'] = 'Cache Lebensdauer deaktiviert'; -$string['cachelifespan'] = 'Cache Lebensdauer'; -$string['cachelifespan_desc'] = 'Zeitabstand nach dem die Providerliste aktualisiert wird.'; -$string['cachelifespan_daily'] = '1 Tag'; -$string['cachelifespan_weekly'] = '1 Woche'; -$string['atag'] = 'Filtere < a > tags'; -$string['divtag'] = 'Filtere < div > tags'; -$string['targettag'] = 'Ziel tag'; -$string['targettag_desc'] = 'Welche Art von tag soll gefiltert werden? Links oder divs mit der oembed Klasse.'; -$string['providersrestrict'] = 'Providerbeschränkung'; -$string['providersrestrict_desc'] = 'Beschränke Provider mit einer List zugelassener Provider'; -$string['providersallowed'] = 'Zugelassene Provider.'; -$string['providersallowed_desc'] = 'Die Provider die vor diese Moodleinstallation verfügbar sind.'; -$string['connection_error'] = 'Fehler beim Zugriff auf die integrierten Medien. Versuchen Sie, die Seite zu aktualisieren.'; diff --git a/lang/en/filter_oembed.php b/lang/en/filter_oembed.php index acc21a0..1e0973f 100644 --- a/lang/en/filter_oembed.php +++ b/lang/en/filter_oembed.php @@ -24,43 +24,44 @@ * oEmbed filter ( Mike Churchward, James McQuillan, Vinayak (Vin) Bhalerao, Josh Gavant and Rob Dolin) */ -$string['filtername'] = 'Oembed Filter'; $string['atag'] = 'Filter on < a > tags'; -$string['cachelifespan_disabled'] = 'Cache lifespan disabled'; +$string['cachedef_embeddata'] = 'Oembed Cache'; $string['cachelifespan'] = 'Cache lifespan'; -$string['cachelifespan_desc'] = 'The duration of time before the providers list should be refreshed.'; $string['cachelifespan_daily'] = '1 day'; +$string['cachelifespan_desc'] = 'The duration of time before the providers list should be refreshed.'; +$string['cachelifespan_disabled'] = 'Cache lifespan disabled'; $string['cachelifespan_weekly'] = '1 week'; $string['connection_error'] = 'Error connecting to external provider, please try reloading the page.'; $string['copytolocal'] = 'Created new local provider definition for "{$a}".'; -$string['deleteprovidertitle'] = 'Delete provider'; $string['deleteproviderconfirm'] = 'Are you sure you want to delete provider "{$a}"?'; +$string['deleteprovidertitle'] = 'Delete provider'; $string['divtag'] = 'Filter on < div > tags'; $string['downloadproviders'] = 'Downloaded providers'; -$string['cachedef_embeddata'] = 'Oembed Cache'; $string['enabled'] = 'Enabled'; $string['endpoints'] = 'End points'; +$string['filtername'] = 'Oembed Filter'; $string['lazyload'] = 'Delay Embed Loading (Lazyload)'; $string['localproviders'] = 'Local providers'; $string['manageproviders'] = 'Manage providers'; $string['nocopytolocal'] = 'Could not create new local provider definition for "{$a}". It may already exist.'; $string['playoembed'] = 'Play'; +$string['pluginname'] = 'Oembed filter'; $string['pluginproviders'] = 'Plugin providers'; +$string['privacy:metadata'] = 'Oembed filter does not store any personal data.'; $string['provider'] = 'Provider'; $string['providername'] = 'Provider Name'; -$string['providersrestrict'] = 'Restrict providers'; -$string['providersrestrict_desc'] = 'Restrict providers to a list of allowed providers'; $string['providersallowed'] = 'Providers allowed.'; $string['providersallowed_desc'] = 'Providers whitelisted to be used with this plugin'; +$string['providersrestrict'] = 'Restrict providers'; +$string['providersrestrict_desc'] = 'Restrict providers to a list of allowed providers'; $string['providerurl'] = 'Provider URL'; $string['requiredfield'] = 'The field "{$a}" must be completed'; -$string['subplugintype_oembedprovider'] = 'Oembed provider'; -$string['subplugintype_oembedprovider_plural'] = 'Oembed providers'; $string['saveasnew'] = 'Save as new local'; -$string['saveok'] = 'Successfully saved provider.'; $string['savefailed'] = 'Failed to save provider.'; +$string['saveok'] = 'Successfully saved provider.'; $string['source'] = 'Provider source'; +$string['subplugintype_oembedprovider'] = 'Oembed provider'; +$string['subplugintype_oembedprovider_plural'] = 'Oembed providers'; $string['targettag'] = 'Target tag'; $string['targettag_desc'] = 'What tag type should be filtered - anchors or divs with the oembed class.'; $string['updateproviders'] = 'Update Oembed provider information.'; -$string['privacy:metadata'] = 'Oembed filter does not store any personal data.'; diff --git a/lang/es/filter_oembed.php b/lang/es/filter_oembed.php deleted file mode 100644 index 0f0aa56..0000000 --- a/lang/es/filter_oembed.php +++ /dev/null @@ -1,39 +0,0 @@ -. - -/** - * Language strings for component 'filter_oembed' - * - * @package filter_oembed - * @copyright 2012 Matthew Cannings; modified 2015 by Microsoft Inc. - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * code based on the following filters... - * Screencast (Mark Schall) - * Soundcloud (Troy Williams) - */ - -$string['filtername'] = 'oEmbed Filter'; -$string['youtube'] = 'Youtube'; -$string['vimeo'] = 'Vimeo'; -$string['ted'] = 'Ted Talks'; -$string['slideshare'] = 'SlideShare'; -$string['officemix'] = 'Office Mix'; -$string['issuu'] = 'Issuu'; -$string['screenr'] = 'Screenr'; -$string['soundcloud'] = 'SoundCloud'; -$string['pollev'] = 'Poll Everywhere'; -$string['lazyload'] = 'Demorar carga integrada (Lazyload)'; -$string['connection_error'] = 'Error al acceder al medio integrado. Intente actualizar la página.'; diff --git a/lang/fi/filter_oembed.php b/lang/fi/filter_oembed.php deleted file mode 100644 index 065ac51..0000000 --- a/lang/fi/filter_oembed.php +++ /dev/null @@ -1,39 +0,0 @@ -. - -/** - * Language strings for component 'filter_oembed' - * - * @package filter_oembed - * @copyright 2012 Matthew Cannings; modified 2015 by Microsoft Inc. - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * code based on the following filters... - * Screencast (Mark Schall) - * Soundcloud (Troy Williams) - */ - -$string['filtername'] = 'oEmbed-suodatin'; -$string['youtube'] = 'YouTube'; -$string['vimeo'] = 'Vimeo'; -$string['ted'] = 'Ted Talks'; -$string['slideshare'] = 'SlideShare'; -$string['officemix'] = 'Office Mix'; -$string['issuu'] = 'Issuu'; -$string['screenr'] = 'Screenr'; -$string['soundcloud'] = 'SoundCloud'; -$string['pollev'] = 'Poll Everywhere'; -$string['lazyload'] = 'Lykkää upotetun median lataamista'; -$string['connection_error'] = 'Virhe upotetun median käytön aikana. Kokeile päivittää sivu.'; diff --git a/lang/fr/filter_oembed.php b/lang/fr/filter_oembed.php deleted file mode 100644 index 5a186ce..0000000 --- a/lang/fr/filter_oembed.php +++ /dev/null @@ -1,39 +0,0 @@ -. - -/** - * Language strings for component 'filter_oembed' - * - * @package filter_oembed - * @copyright 2012 Matthew Cannings; modified 2015 by Microsoft Inc. - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * code based on the following filters... - * Screencast (Mark Schall) - * Soundcloud (Troy Williams) - */ - -$string['filtername'] = 'Filtre oEmbed'; -$string['youtube'] = 'Youtube'; -$string['vimeo'] = 'Vimeo'; -$string['ted'] = 'Chats Ted'; -$string['slideshare'] = 'SlideShare'; -$string['officemix'] = 'Combinaison Office'; -$string['issuu'] = 'Problème'; -$string['screenr'] = 'Écran'; -$string['soundcloud'] = 'SoundCloud'; -$string['pollev'] = 'Sonder partout'; -$string['lazyload'] = 'Retarder l\'intégration du chargement (Lazyload)'; -$string['connection_error'] = 'Erreur lors de l\'accès au média intégré. Veuillez actualiser la page.'; diff --git a/lang/it/filter_oembed.php b/lang/it/filter_oembed.php deleted file mode 100644 index 746f426..0000000 --- a/lang/it/filter_oembed.php +++ /dev/null @@ -1,39 +0,0 @@ -. - -/** - * Language strings for component 'filter_oembed' - * - * @package filter_oembed - * @copyright 2012 Matthew Cannings; modified 2015 by Microsoft Inc. - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * code based on the following filters... - * Screencast (Mark Schall) - * Soundcloud (Troy Williams) - */ - -$string['filtername'] = 'Filtro oEmbed'; -$string['youtube'] = 'Youtube'; -$string['vimeo'] = 'Vimeo'; -$string['ted'] = 'Ted Talks'; -$string['slideshare'] = 'SlideShare'; -$string['officemix'] = 'Office Mix'; -$string['issuu'] = 'Issuu'; -$string['screenr'] = 'Screenr'; -$string['soundcloud'] = 'SoundCloud'; -$string['pollev'] = 'Poll Everywhere'; -$string['lazyload'] = 'Delay Embed Loading (Lazyload)'; -$string['connection_error'] = 'Errore durante l\'accesso al media incorporato. Prova ad aggiornare la pagina.'; diff --git a/lang/ja/filter_oembed.php b/lang/ja/filter_oembed.php deleted file mode 100644 index 5c44ce7..0000000 --- a/lang/ja/filter_oembed.php +++ /dev/null @@ -1,39 +0,0 @@ -. - -/** - * Language strings for component 'filter_oembed' - * - * @package filter_oembed - * @copyright 2012 Matthew Cannings; modified 2015 by Microsoft Inc. - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * code based on the following filters... - * Screencast (Mark Schall) - * Soundcloud (Troy Williams) - */ - -$string['filtername'] = 'oEmbedフィルタ'; -$string['youtube'] = 'Youtube'; -$string['vimeo'] = 'Vimeo'; -$string['ted'] = 'Ted Talks'; -$string['slideshare'] = 'SlideShare'; -$string['officemix'] = 'Office Mix'; -$string['issuu'] = 'Issuu'; -$string['screenr'] = 'Screenr'; -$string['soundcloud'] = 'SoundCloud'; -$string['pollev'] = 'Poll Everywhere'; -$string['lazyload'] = '遅延埋め込みロード (Lazyload)'; -$string['connection_error'] = '埋め込みメディアへのアクセス中にエラーが発生しました。ページを再読み込みしてください。'; diff --git a/lang/nl/filter_oembed.php b/lang/nl/filter_oembed.php deleted file mode 100644 index 59f8b73..0000000 --- a/lang/nl/filter_oembed.php +++ /dev/null @@ -1,39 +0,0 @@ -. - -/** - * Language strings for component 'filter_oembed' - * - * @package filter_oembed - * @copyright 2012 Matthew Cannings; modified 2015 by Microsoft Inc. - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * code based on the following filters... - * Screencast (Mark Schall) - * Soundcloud (Troy Williams) - */ - -$string['filtername'] = 'oEmbed Filter'; -$string['youtube'] = 'YouTube'; -$string['vimeo'] = 'Vimeo'; -$string['ted'] = 'Ted Talks'; -$string['slideshare'] = 'SlideShare'; -$string['officemix'] = 'Office Mix'; -$string['issuu'] = 'Issuu'; -$string['screenr'] = 'Screenr'; -$string['soundcloud'] = 'SoundCloud'; -$string['pollev'] = 'Poll Everywhere'; -$string['lazyload'] = 'Delay Embed Loading (Lazyload)'; -$string['connection_error'] = 'Fout tijdens het openen van ingesloten media. Probeer de pagina te vernieuwen.'; diff --git a/lang/pl/filter_oembed.php b/lang/pl/filter_oembed.php deleted file mode 100644 index f6a6ab4..0000000 --- a/lang/pl/filter_oembed.php +++ /dev/null @@ -1,39 +0,0 @@ -. - -/** - * Language strings for component 'filter_oembed' - * - * @package filter_oembed - * @copyright 2012 Matthew Cannings; modified 2015 by Microsoft Inc. - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * code based on the following filters... - * Screencast (Mark Schall) - * Soundcloud (Troy Williams) - */ - -$string['filtername'] = 'oEmbed Filter'; -$string['youtube'] = 'Youtube'; -$string['vimeo'] = 'Vimeo'; -$string['ted'] = 'Ted Talks'; -$string['slideshare'] = 'SlideShare'; -$string['officemix'] = 'Office Mix'; -$string['issuu'] = 'Issuu'; -$string['screenr'] = 'Screenr'; -$string['soundcloud'] = 'SoundCloud'; -$string['pollev'] = 'Poll Everywhere'; -$string['lazyload'] = 'Opóźnij ładowanie osadzania (Lazyload)'; -$string['connection_error'] = 'Błąd podczas uzyskiwania dostępu do osadzonego elementu multimedialnego. Spróbuj odświeżyć stronę.'; diff --git a/lang/pt_br/filter_oembed.php b/lang/pt_br/filter_oembed.php deleted file mode 100644 index 00c5f41..0000000 --- a/lang/pt_br/filter_oembed.php +++ /dev/null @@ -1,39 +0,0 @@ -. - -/** - * Language strings for component 'filter_oembed' - * - * @package filter_oembed - * @copyright 2012 Matthew Cannings; modified 2015 by Microsoft Inc. - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * code based on the following filters... - * Screencast (Mark Schall) - * Soundcloud (Troy Williams) - */ - -$string['filtername'] = 'Filtro oEmbed'; -$string['youtube'] = 'YouTube'; -$string['vimeo'] = 'Vimeo'; -$string['ted'] = 'Ted Talks'; -$string['slideshare'] = 'SlideShare'; -$string['officemix'] = 'Office Mix'; -$string['issuu'] = 'Issuu'; -$string['screenr'] = 'Screenr'; -$string['soundcloud'] = 'SoundCloud'; -$string['pollev'] = 'Poll Everywhere'; -$string['lazyload'] = 'Carregamento de incorporação com atraso (Lazy load)'; -$string['connection_error'] = 'Erro ao acessar a mídia incorporada. Tente atualizar a página.'; diff --git a/lib.php b/lib.php index ad95266..6fe2619 100644 --- a/lib.php +++ b/lib.php @@ -16,18 +16,19 @@ /** * General lib file + * + * @package filter_oembed * @author Guy Thomas * @copyright Copyright (c) 2016 Blackboard Inc. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -defined('MOODLE_INTERNAL') || die(); - use filter_oembed\forms\provider; /** * Serve the edit form as a fragment. * + * @package filter_oembed * @param array $args List of named arguments for the fragment loader. * @return string */ diff --git a/manageproviders.php b/manageproviders.php index 2e60159..f7b449a 100644 --- a/manageproviders.php +++ b/manageproviders.php @@ -15,11 +15,14 @@ // along with Moodle. If not, see . /** + * Manage oEmbed providers. + * * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright 2016 The POET Group */ + require_once(dirname(__FILE__) . '/../../config.php'); require_once($CFG->libdir.'/adminlib.php'); @@ -68,7 +71,7 @@ $PAGE->requires->strings_for_js( [ 'deleteprovidertitle', - 'deleteproviderconfirm' + 'deleteproviderconfirm', ], 'filter_oembed' ); diff --git a/package.json b/package.json deleted file mode 100644 index 491b689..0000000 --- a/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "description": "Grunt tasks for sass.", - "private": true, - "devDependencies": { - "grunt": "~0.4.1", - "grunt-autoprefixer": "^3.0.3", - "grunt-contrib-csslint": "^0.5.0", - "grunt-contrib-jshint": "^0.12.0", - "grunt-sass": "^1.2.1", - "grunt-cssbeautifier": "^0.1.2", - "grunt-contrib-watch": "^0.6.1", - "grunt-exec": "~0.4.2", - "grunt-load-gruntfile" : "^0.0.2" - } -} diff --git a/provider/docsdotcom/docsdotcom.php b/provider/docsdotcom/docsdotcom.php index 9305f24..a2815bd 100644 --- a/provider/docsdotcom/docsdotcom.php +++ b/provider/docsdotcom/docsdotcom.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * oEmbed provider implementation for Docs.com + * * @package filter_oembed * @author James McQuillan * @author Mike Churchward @@ -24,8 +26,6 @@ namespace filter_oembed\provider; -defined('MOODLE_INTERNAL') || die(); - /** * oEmbed provider implementation for Docs.com */ @@ -33,7 +33,7 @@ class docsdotcom extends provider { /** * Constructor. - * @param $data JSON decoded array or a data object containing all provider data. + * @param string $data JSON decoded array or a data object containing all provider data. */ public function __construct($data = null) { if ($data === null) { @@ -43,9 +43,9 @@ public function __construct($data = null) { 'endpoints' => [ ['schemes' => ['https://docs.com/*', 'https://www.docs.com/*'], 'url' => 'https:\/\/docs.com\/api\/oembed', - 'formats' => ['json'] - ] - ] + 'formats' => ['json'], + ], + ], ]; } parent::__construct($data); diff --git a/provider/docsdotcom/lang/en/oembedprovider_docsdotcom.php b/provider/docsdotcom/lang/en/oembedprovider_docsdotcom.php index 89a74b6..181ebbf 100644 --- a/provider/docsdotcom/lang/en/oembedprovider_docsdotcom.php +++ b/provider/docsdotcom/lang/en/oembedprovider_docsdotcom.php @@ -15,10 +15,12 @@ // along with Moodle. If not, see . /** + * oEmbed provider for Docsdotcom language file. + * * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright 2016 The POET Group */ -$string['pluginname'] = 'Docsdotcom'; \ No newline at end of file +$string['pluginname'] = 'Docsdotcom'; diff --git a/provider/docsdotcom/version.php b/provider/docsdotcom/version.php index bdafbbe..644420e 100644 --- a/provider/docsdotcom/version.php +++ b/provider/docsdotcom/version.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * Docs.com provider version information + * * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later diff --git a/provider/issuu/issuu.php b/provider/issuu/issuu.php index d919651..6047987 100644 --- a/provider/issuu/issuu.php +++ b/provider/issuu/issuu.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * Provider implementation for ISSUU + * * @package filter_oembed * @author James McQuillan * @author Mike Churchward @@ -24,8 +26,6 @@ namespace filter_oembed\provider; -defined('MOODLE_INTERNAL') || die(); - /** * oEmbed provider implementation for ISSUU */ @@ -33,7 +33,7 @@ class issuu extends provider { /** * Constructor. - * @param $data JSON decoded array or a data object containing all provider data. + * @param string $data JSON decoded array or a data object containing all provider data. */ public function __construct($data = null) { if ($data === null) { @@ -42,7 +42,7 @@ public function __construct($data = null) { 'providerurl' => 'https://issuu.com', 'endpoints' => [ ['schemes' => ['https://issuu.com/*'], - 'url' => 'https://issuu.com/oembed'], + 'url' => 'https://issuu.com/oembed', ], ], ]; } diff --git a/provider/issuu/lang/en/oembedprovider_issuu.php b/provider/issuu/lang/en/oembedprovider_issuu.php index 4998dbd..b34481f 100644 --- a/provider/issuu/lang/en/oembedprovider_issuu.php +++ b/provider/issuu/lang/en/oembedprovider_issuu.php @@ -15,10 +15,12 @@ // along with Moodle. If not, see . /** + * The language strings for the ISSUU provider. + * * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright 2016 The POET Group */ -$string['pluginname'] = 'ISSUU'; \ No newline at end of file +$string['pluginname'] = 'ISSUU'; diff --git a/provider/issuu/version.php b/provider/issuu/version.php index b037764..d642f9c 100644 --- a/provider/issuu/version.php +++ b/provider/issuu/version.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * ISSUU provider version information + * * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later diff --git a/provider/o365video/lang/en/oembedprovider_o365video.php b/provider/o365video/lang/en/oembedprovider_o365video.php index 9927b0e..5ec45d5 100644 --- a/provider/o365video/lang/en/oembedprovider_o365video.php +++ b/provider/o365video/lang/en/oembedprovider_o365video.php @@ -15,10 +15,12 @@ // along with Moodle. If not, see . /** + * o365video provider language pack + * * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright 2016 The POET Group */ -$string['pluginname'] = 'Office365 video'; \ No newline at end of file +$string['pluginname'] = 'Office365 video'; diff --git a/provider/o365video/o365video.php b/provider/o365video/o365video.php index 2cd24e7..6b1f2b4 100644 --- a/provider/o365video/o365video.php +++ b/provider/o365video/o365video.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * o365video provider implementation. + * * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -23,16 +25,14 @@ namespace filter_oembed\provider; -defined('MOODLE_INTERNAL') || die(); - /** - * oEmbed provider implementation for Docs.com + * oEmbed provider implementation for o365video */ class o365video extends provider { /** * Constructor. - * @param $data JSON decoded array or a data object containing all provider data. + * @param string $data JSON decoded array or a data object containing all provider data. */ public function __construct($data = null) { if ($data === null) { @@ -85,7 +85,7 @@ public function get_replacement($matched) { return $matched[0]; } $matched[3] = preg_replace("/&/", "&", $matched[3]); - $values = array(); + $values = []; parse_str($matched[3], $values); if (empty($values['chid']) || empty($values['vid'])) { return $matched[0]; @@ -125,4 +125,4 @@ public function get_replacement($matched) { } return $matched[0]; } -} \ No newline at end of file +} diff --git a/provider/o365video/version.php b/provider/o365video/version.php index bf1fed1..afce057 100644 --- a/provider/o365video/version.php +++ b/provider/o365video/version.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * o365video provider version information + * * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later diff --git a/provider/officeforms/lang/en/oembedprovider_officeforms.php b/provider/officeforms/lang/en/oembedprovider_officeforms.php index a0608aa..f22d79b 100644 --- a/provider/officeforms/lang/en/oembedprovider_officeforms.php +++ b/provider/officeforms/lang/en/oembedprovider_officeforms.php @@ -15,10 +15,12 @@ // along with Moodle. If not, see . /** + * oEmbed provider for Office Forms language file. + * * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright 2016 The POET Group */ -$string['pluginname'] = 'Officeforms'; \ No newline at end of file +$string['pluginname'] = 'Officeforms'; diff --git a/provider/officeforms/officeforms.php b/provider/officeforms/officeforms.php index 0fb5446..762b0bd 100644 --- a/provider/officeforms/officeforms.php +++ b/provider/officeforms/officeforms.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * Office Forms provider implementation. + * * @package filter_oembed * @author Aashay Zajriya * @author Mike Churchward @@ -24,8 +26,6 @@ namespace filter_oembed\provider; -defined('MOODLE_INTERNAL') || die(); - /** * oEmbed provider implementation for Microsoft Forms */ @@ -33,7 +33,7 @@ class officeforms extends provider { /** * Constructor. - * @param $data JSON decoded array or a data object containing all provider data. + * @param array $data JSON decoded array or a data object containing all provider data. */ public function __construct($data = null) { if ($data === null) { @@ -42,11 +42,11 @@ public function __construct($data = null) { 'providerurl' => 'https://forms.office.com/', 'endpoints' => [ ['schemes' => ['https://forms.office.com/Pages/ResponsePage.aspx?id=*', - 'https://www.forms.office.com/Pages/ResponsePage.aspx?id=*'], + 'https://www.forms.office.com/Pages/ResponsePage.aspx?id=*', ], 'url' => 'https://forms.office.com/Pages/ResponsePage.aspx?id=*&embed=true', - 'formats' => ['json'] - ] - ] + 'formats' => ['json'], + ], + ], ]; } parent::__construct($data); diff --git a/provider/officeforms/version.php b/provider/officeforms/version.php index f8c5b58..27f48e4 100644 --- a/provider/officeforms/version.php +++ b/provider/officeforms/version.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * Office Forms provider version information + * * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later diff --git a/provider/pollev/lang/en/oembedprovider_pollev.php b/provider/pollev/lang/en/oembedprovider_pollev.php index 4bf0641..491c309 100644 --- a/provider/pollev/lang/en/oembedprovider_pollev.php +++ b/provider/pollev/lang/en/oembedprovider_pollev.php @@ -15,10 +15,12 @@ // along with Moodle. If not, see . /** + * Poll Everywhere oEmbed provider language file. + * * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright 2016 The POET Group */ -$string['pluginname'] = 'Poll Everywhere'; \ No newline at end of file +$string['pluginname'] = 'Poll Everywhere'; diff --git a/provider/pollev/pollev.php b/provider/pollev/pollev.php index 2004727..a250c55 100644 --- a/provider/pollev/pollev.php +++ b/provider/pollev/pollev.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * Poll Everywhere provider implementation. + * * @package filter_oembed * @author James McQuillan * @author Mike Churchward @@ -24,8 +26,6 @@ namespace filter_oembed\provider; -defined('MOODLE_INTERNAL') || die(); - /** * oEmbed provider implementation for Poll Everywhere */ @@ -33,7 +33,7 @@ class pollev extends provider { /** * Constructor. - * @param $data JSON decoded array or a data object containing all provider data. + * @param string $data JSON decoded array or a data object containing all provider data. */ public function __construct($data = null) { if ($data === null) { @@ -46,7 +46,7 @@ public function __construct($data = null) { 'https://www.polleverywhere.com/multiple_choice_polls/*', 'https://www.polleverywhere.com/free_text_polls/*', ], - 'url' => 'https://www.polleverywhere.com/services/oembed'], + 'url' => 'https://www.polleverywhere.com/services/oembed', ], ], ]; } diff --git a/provider/pollev/version.php b/provider/pollev/version.php index 336fbe6..3fdb054 100644 --- a/provider/pollev/version.php +++ b/provider/pollev/version.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * Poll Everywhere oEmbed provider version information. + * * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later diff --git a/provider/powerbi/lang/en/oembedprovider_powerbi.php b/provider/powerbi/lang/en/oembedprovider_powerbi.php index f566660..50ec8b5 100644 --- a/provider/powerbi/lang/en/oembedprovider_powerbi.php +++ b/provider/powerbi/lang/en/oembedprovider_powerbi.php @@ -15,10 +15,12 @@ // along with Moodle. If not, see . /** + * PowerBI oEmbed provider language file. + * * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright 2016 The POET Group */ -$string['pluginname'] = 'Power BI'; \ No newline at end of file +$string['pluginname'] = 'Power BI'; diff --git a/provider/powerbi/powerbi.php b/provider/powerbi/powerbi.php index ac0cc0d..a02b322 100644 --- a/provider/powerbi/powerbi.php +++ b/provider/powerbi/powerbi.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * Provider implementation for PowerBI + * * @package filter_oembed * @author Sushant Gawali * @author Mike Churchward @@ -24,8 +26,6 @@ namespace filter_oembed\provider; -defined('MOODLE_INTERNAL') || die(); - /** * oEmbed provider implementation for Docs.com */ @@ -33,7 +33,7 @@ class powerbi extends provider { /** * Constructor. - * @param $data JSON decoded array or a data object containing all provider data. + * @param string $data JSON decoded array or a data object containing all provider data. */ public function __construct($data = null) { if ($data === null) { @@ -42,11 +42,11 @@ public function __construct($data = null) { 'providerurl' => '', 'endpoints' => [ ['schemes' => ['https://powerbi.com/*/*/*/*/*', - 'https://app.powerbi.com/*/*/*/*/*'], + 'https://app.powerbi.com/*/*/*/*/*', ], 'url' => '', - 'formats' => ['json'] - ] - ] + 'formats' => ['json'], + ], + ], ]; } parent::__construct($data); @@ -104,6 +104,12 @@ public function get_replacement($matched) { return $matched[0]; } + /** + * Get the embed HTML. + * + * @param string $embedurl The embed URL. + * @return string + */ private function getembedhtml($embedurl) { return ''; diff --git a/provider/powerbi/rest/powerbi.php b/provider/powerbi/rest/powerbi.php index beff7b7..a4b9ba0 100644 --- a/provider/powerbi/rest/powerbi.php +++ b/provider/powerbi/rest/powerbi.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * PowerBI provider API client. + * * @package filter_oembed * @author Sushant Gawali * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -23,8 +25,6 @@ namespace filter_oembed\provider\powerbi\rest; -defined('MOODLE_INTERNAL') || die(); - /** * API client for Power BI. */ @@ -45,6 +45,14 @@ public function get_apiuri() { public static function get_resource() { return 'https://analysis.windows.net/powerbi/api'; } + + /** + * Get the API client's oauth2 scope. + * + * @param int $reportid The report id. + * @param array $reportsdata The report data. + * @return mixed|void + */ public function getreportoembedurl($reportid, $reportsdata) { $reportsdata = $this->process_apicall_response($reportsdata); foreach ($reportsdata['value'] as $report) { @@ -53,4 +61,4 @@ public function getreportoembedurl($reportid, $reportsdata) { } } } -} \ No newline at end of file +} diff --git a/provider/powerbi/version.php b/provider/powerbi/version.php index bc2374b..846e5aa 100644 --- a/provider/powerbi/version.php +++ b/provider/powerbi/version.php @@ -15,6 +15,8 @@ // along with Moodle. If not, see . /** + * PowerBI provider version information + * * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later diff --git a/settings.php b/settings.php index c58a481..ea66625 100644 --- a/settings.php +++ b/settings.php @@ -37,7 +37,7 @@ if ($ADMIN->fulltree) { $targettags = [ 'a' => get_string('atag', 'filter_oembed'), - 'div' => get_string('divtag', 'filter_oembed') + 'div' => get_string('divtag', 'filter_oembed'), ]; $config = get_config('filter_oembed'); @@ -60,4 +60,4 @@ $ADMIN->add('filteroembedfolder', new admin_externalpage('filter_oembed_providers', get_string('manageproviders', 'filter_oembed'), new moodle_url('/filter/oembed/manageproviders.php'))); -$settings = null; \ No newline at end of file +$settings = null; diff --git a/styles.css b/styles.css index 4572ad2..28c9d38 100644 --- a/styles.css +++ b/styles.css @@ -59,13 +59,13 @@ } .oembed-responsive > *:not(video):first-child { - position: absolute !important; - top: 0 !important; - bottom: 0 !important; - right: 0 !important; - left: 0 !important; - height: 100% !important; - width: 100% !important; + position: absolute !important; // stylelint-disable-line declaration-no-important + top: 0 !important; // stylelint-disable-line declaration-no-important + bottom: 0 !important; // stylelint-disable-line declaration-no-important + right: 0 !important; // stylelint-disable-line declaration-no-important + left: 0 !important; // stylelint-disable-line declaration-no-important + height: 100% !important; // stylelint-disable-line declaration-no-important + width: 100% !important; // stylelint-disable-line declaration-no-important } .oembed-responsive-pad { diff --git a/tests/behat/behat_filter_oembed.php b/tests/behat/behat_filter_oembed.php index 611d8bf..e5e08af 100644 --- a/tests/behat/behat_filter_oembed.php +++ b/tests/behat/behat_filter_oembed.php @@ -16,6 +16,8 @@ /** * Oembed filter custom behat steps. + * + * @package filter_oembed * @author Guy Thomas * @copyright Copyright (c) 2016 Blackboard Inc. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later @@ -25,6 +27,11 @@ require_once(__DIR__ . '/../../../../lib/behat/behat_base.php'); +/** + * Oembed filter custom behat steps. + * + * @package filter_oembed + */ class behat_filter_oembed extends behat_base { /** @@ -83,6 +90,8 @@ protected function ensure_provider_status($provider, $enabled = true) { } /** + * Disable provider. + * * @Given /^the provider "(?P[^"]*)" is disabled$/ * @param string $provider * @throws \Behat\Mink\Exception\ExpectationException @@ -92,6 +101,8 @@ public function the_provider_is_disabled($provider) { } /** + * Enable provider. + * * @Given /^the provider "(?P[^"]*)" is enabled$/ * @param string $provider * @throws \Behat\Mink\Exception\ExpectationException @@ -101,8 +112,10 @@ public function the_provider_is_enabled($provider) { } /** + * Filter provider list. + * * @Given /^I filter the provider list to "(?P[^"]*)"$/ - * @param $provider + * @param string $provider The provider to filter the list to. * @throws \Behat\Mink\Exception\ExpectationException */ public function i_filter_provider_list($provider) { @@ -133,6 +146,8 @@ protected function wait_for_edit_form($provider) { } /** + * Edit provider with values. + * * @Given /^I edit the provider "(?P[^"]*)" with the values:$/ * @param string $provider * @param TableNode $table diff --git a/tests/filter_test.php b/tests/filter_test.php index e513f20..92f0b30 100644 --- a/tests/filter_test.php +++ b/tests/filter_test.php @@ -26,16 +26,21 @@ * @copyright Microsoft, Inc. */ +namespace filter_oembed; + defined('MOODLE_INTERNAL') || die(); global $CFG; require_once($CFG->dirroot . '/filter/oembed/filter.php'); /** + * Unit tests for the filter_oembed. + * * @group filter_oembed */ -class filter_oembed_testcase extends advanced_testcase { +final class filter_test extends \advanced_testcase { + /** @var object The filter plugin object to perform the tests on */ protected $filter; /** @@ -43,7 +48,7 @@ class filter_oembed_testcase extends advanced_testcase { */ protected function setUp(): void { parent::setUp(); - $this->filter = new filter_oembed(context_system::instance(), array()); + $this->filter = new \filter_oembed(\context_system::instance(), []); // Ensure all tested providers are enabled. $oembed = \filter_oembed\service\oembed::get_instance('all'); foreach ($oembed->providers as $pid => $provider) { @@ -88,8 +93,10 @@ protected function setUp(): void { * Performs unit tests for all services supported by the filter. * * Need to update this test to not contact external services. + * + * @covers \filter_oembed::filter() */ - public function test_filter() { + public function test_filter(): void { $this->resetAfterTest(true); // This test is marked as skipped because, writing tests that rely // on talking to the Internet are a very, very bad idea. diff --git a/tests/oembed_test.php b/tests/oembed_test.php index 0015585..daa2c85 100644 --- a/tests/oembed_test.php +++ b/tests/oembed_test.php @@ -17,21 +17,25 @@ /** * Unit tests for the filter_oembed. * - * @package filter_oembed + * @package filter_oembed * @author Mike Churchward * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @copyright 2016 The POET Group */ +namespace filter_oembed; + defined('MOODLE_INTERNAL') || die(); global $CFG; require_once($CFG->dirroot . '/filter/oembed/tests/testable_oembed.php'); /** + * PHPUnit tests for the filter_oembed. + * * @group filter_oembed */ -class filter_oembed_service_testcase extends advanced_testcase { +final class oembed_test extends \advanced_testcase { /** * Make sure providers array is correct. @@ -58,18 +62,27 @@ public function assert_providers_ok($providers) { /** * Test instance. + * + * @covers \filter_oembed::get_instance + * @return void */ - public function test_instance() { + public function test_instance(): void { $this->resetAfterTest(true); $this->setAdminUser(); - $oembed = testable_oembed::get_instance(); + $oembed = \testable_oembed::get_instance(); $this->assertNotEmpty($oembed); } - public function test_set_providers() { + /** + * Test set providers. + * + * @covers \filter_oembed::set_providers + * @return void + */ + public function test_set_providers(): void { $this->resetAfterTest(true); $this->setAdminUser(); - $oembed = testable_oembed::get_instance(); + $oembed = \testable_oembed::get_instance(); $oembed->empty_providers(); $oembed->protected_set_providers('all'); $this->assertNotEmpty($oembed->providers); @@ -78,11 +91,13 @@ public function test_set_providers() { /** * Test providers. + * + * @covers \filter_oembed::providers */ - public function test_providers() { + public function test_providers(): void { $this->resetAfterTest(true); $this->setAdminUser(); - $oembed = testable_oembed::get_instance(); + $oembed = \testable_oembed::get_instance(); $providers = $oembed->providers; $this->assert_providers_ok($providers); } @@ -90,13 +105,15 @@ public function test_providers() { /** * Test html. * TODO - have a local oembed service with test fixtures for performing test. + * + * @covers \filter_oembed::html_output */ - public function test_embed_html() { + public function test_embed_html(): void { $this->markTestSkipped("The youtube link is unavailabe"); $this->resetAfterTest(true); set_config('lazyload', 0, 'filter_oembed'); $this->setAdminUser(); - $oembed = testable_oembed::get_instance(); + $oembed = \testable_oembed::get_instance(); $text = $oembed->html_output('https://youtu.be/abuQk-6M5R4'); $expectedtext = '