diff --git a/main/inc/lib/elfinder/connectorAction.php b/main/inc/lib/elfinder/connectorAction.php index 74456e8051..159b735934 100644 --- a/main/inc/lib/elfinder/connectorAction.php +++ b/main/inc/lib/elfinder/connectorAction.php @@ -12,8 +12,8 @@ $connector = new Connector(); $driverList = array( 'PersonalDriver', 'CourseDriver', - 'CourseUserDriver', - 'HomeDriver' + //'CourseUserDriver', + //'HomeDriver' ); $connector->setDriverList($driverList); diff --git a/main/template/default/layout/head.tpl b/main/template/default/layout/head.tpl index 0f97e38c38..a3a58e3fee 100755 --- a/main/template/default/layout/head.tpl +++ b/main/template/default/layout/head.tpl @@ -19,17 +19,23 @@ // External plugins not part of the default Ckeditor package. var plugins = [ - 'oembed', - 'wordcount', + 'asciimath', 'asciisvg', - 'video', - 'toolbarswitch', 'audio', - 'youtube', - 'leaflet', - 'asciimath', + //'ckeditor_wiris', + 'dialogui', 'glossary', - 'mapping' + 'justify', + 'leaflet', + 'mapping', + 'maximize', + 'oembed', + 'toolbar', + 'toolbarswitch', + 'video', + 'wikilink', + 'wordcount', + 'youtube' ]; plugins.forEach(function(plugin) { diff --git a/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/Basic.php b/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/Basic.php index 3737469109..3ae3a886a3 100644 --- a/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/Basic.php +++ b/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/Basic.php @@ -13,18 +13,21 @@ class Basic extends Toolbar { /** * Default plugins that will be use in all toolbars + * In order to add a new plugin you have to load it in default/layout/head.tpl * @var array */ public $defaultPlugins = array( 'oembed', 'video', + 'audio', 'wordcount', 'templates', 'justify', 'colorbutton', 'flash', 'link', - 'table' + 'table', + 'wikilink' ); /** @@ -33,33 +36,63 @@ class Basic extends Toolbar */ public $plugins = array(); + /** + * @inheritdoc + */ + public function __construct( + $toolbar = null, + $config = array(), + $prefix = null + ) { + // Adding plugins depending of platform conditions + $plugins = array(); + + if (api_get_setting('youtube_for_students') == 'true') { + $plugins[] = 'youtube'; + } else { + if (api_is_allowed_to_edit() || api_is_platform_admin()) { + $plugins[] = 'youtube'; + } + } + + if (api_get_setting('enabled_googlemaps') == 'true') { + $plugins[] = 'leaflet'; + $plugins[] = 'mapping'; + } + + if (api_get_setting('math_asciimathML') == 'true') { + $plugins[] = 'asciimath'; + } + $plugins[] = 'asciimath'; + + if (api_get_setting('enabled_asciisvg') == 'true') { + $plugins[] = 'asciisvg'; + } + + if (api_get_setting('enabled_wiris') == 'true') { + // Commercial plugin + //$plugins[] = 'ckeditor_wiris'; + } + + if (api_get_setting('enabled_imgmap') == 'true') { + // Commercial plugin + } + + if (api_get_setting('block_copy_paste_for_students') == 'true') { + // Missing + } + + $this->defaultPlugins = array_merge($this->defaultPlugins, $plugins); + parent::__construct($toolbar, $config, $prefix); + } + /** * @return array */ public function getConfig() { // Original from ckeditor - /* - $config['toolbarGroups'] = array( - array('name' => 'document', 'groups' =>array('mode', 'document', 'doctools')), - array('name' => 'clipboard', 'groups' =>array('clipboard', 'undo', )), - array('name' => 'editing', 'groups' =>array('clipboard', 'undo', )), - array('name' => 'forms', 'groups' =>array('clipboard', 'undo', )), - '/', - array('name' => 'basicstyles', 'groups' =>array('basicstyles', 'cleanup', )), - array('name' => 'paragraph', 'groups' =>array('list', 'indent', 'blocks', 'align' )), - array('name' => 'links'), - array('name' => 'insert'), - '/', - array('name' => 'styles'), - array('name' => 'colors'), - array('name' => 'tools'), - array('name' => 'others'), - array('name' => 'about') - );*/ - $config['toolbarGroups'] = array( - //{ name: 'document', groups: [ 'mode', 'document', 'doctools' ] }, array('name' => 'document', 'groups' =>array('mode', 'document', 'doctools')), array('name' => 'clipboard', 'groups' =>array('clipboard', 'undo', )), array('name' => 'editing', 'groups' =>array('clipboard', 'undo', )), diff --git a/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/Documents.php b/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/Documents.php index b6e9db4788..961ae39266 100644 --- a/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/Documents.php +++ b/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/Documents.php @@ -14,15 +14,9 @@ class Documents extends Basic 'toolbarswitch', 'audio', 'video', - 'youtube', - 'leaflet', 'widget', 'lineutils', - 'mathjax', - 'asciimath', - 'glossary', - 'asciisvg', - 'mapping' + 'mathjax' ); /** @@ -47,6 +41,7 @@ class Documents extends Basic array('name' => 'others'), array('name' => 'mode') ); + $config['extraPlugins'] = $this->getPluginsToString(); //$config['mathJaxLib'] = $this->urlGenerator->generate('javascript').'/math_jax/MathJax.js?config=default'; //$config['mathJaxLib'] = api_get_path(WEB_LIBRARY_JS_PATH).'/math_jax/MathJax.js?config=default'; @@ -55,4 +50,16 @@ class Documents extends Basic return $config; } + /** + * @return array + */ + public function getConditionalPlugins() + { + $plugins = array(); + + if (api_get_setting('show_glossary_in_documents') != 'none') { + $plugins[] = 'glossary'; + } + return $plugins; + } } diff --git a/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/PortalHomePage.php b/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/PortalHomePage.php index c0d2ba60d6..2d43209450 100644 --- a/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/PortalHomePage.php +++ b/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/PortalHomePage.php @@ -10,7 +10,7 @@ use Chamilo\CoreBundle\Component\Editor\Toolbar; * @todo complete config * @package Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar */ -class PortalHomePage extends Toolbar +class PortalHomePage extends Basic { } diff --git a/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/PortalNews.php b/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/PortalNews.php index 1e8125605e..e504126477 100644 --- a/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/PortalNews.php +++ b/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/PortalNews.php @@ -10,7 +10,7 @@ use Chamilo\CoreBundle\Component\Editor\Toolbar; * @todo complete config * @package Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar */ -class PortalNews extends Toolbar +class PortalNews extends Basic { } diff --git a/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/TestProposedAnswer.php b/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/TestProposedAnswer.php index cd7475380e..4d60fbaddf 100644 --- a/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/TestProposedAnswer.php +++ b/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/TestProposedAnswer.php @@ -7,7 +7,7 @@ namespace Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar; * Class TestProposedAnswer * @package Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar */ -class TestProposedAnswer +class TestProposedAnswer extends Basic { /** * @return mixed diff --git a/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/TestQuestionDescription.php b/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/TestQuestionDescription.php index 13829f2e0f..5727a63dea 100644 --- a/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/TestQuestionDescription.php +++ b/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/TestQuestionDescription.php @@ -7,7 +7,7 @@ namespace Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar; * Class TestQuestionDescription * @package Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar */ -class TestQuestionDescription +class TestQuestionDescription extends Basic { /** * @return mixed diff --git a/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/ToolbarStartExpanded.php b/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/ToolbarStartExpanded.php index cf6d858527..d843de8656 100644 --- a/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/ToolbarStartExpanded.php +++ b/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/ToolbarStartExpanded.php @@ -9,6 +9,6 @@ use Chamilo\CoreBundle\Component\Editor\Toolbar; * Class ToolbarStartExpanded * @package Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar */ -class ToolbarStartExpanded extends Toolbar +class ToolbarStartExpanded extends Basic { } diff --git a/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/TrainingDescription.php b/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/TrainingDescription.php index e8a96ff808..be03eb9ee9 100644 --- a/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/TrainingDescription.php +++ b/src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/TrainingDescription.php @@ -10,7 +10,7 @@ use Chamilo\CoreBundle\Component\Editor\Toolbar; * @todo complete config * @package Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar */ -class TrainingDescription extends Toolbar +class TrainingDescription extends Basic { } diff --git a/src/Chamilo/CoreBundle/Component/Editor/Driver/CourseDriver.php b/src/Chamilo/CoreBundle/Component/Editor/Driver/CourseDriver.php index 53dd796383..e22dc84867 100644 --- a/src/Chamilo/CoreBundle/Component/Editor/Driver/CourseDriver.php +++ b/src/Chamilo/CoreBundle/Component/Editor/Driver/CourseDriver.php @@ -97,8 +97,9 @@ class CourseDriver extends Driver */ public function upload($fp, $dst, $name, $tmpname) { + $this->setConnectorFromPlugin(); + if ($this->allow()) { - $this->setConnectorFromPlugin(); // upload file by elfinder. $result = parent::upload($fp, $dst, $name, $tmpname); @@ -147,8 +148,9 @@ class CourseDriver extends Driver { // elfinder does not delete the file //parent::rm($hash); + $this->setConnectorFromPlugin(); + if ($this->allow()) { - $this->setConnectorFromPlugin(); $path = $this->decode($hash); $stat = $this->stat($path); @@ -177,11 +179,10 @@ class CourseDriver extends Driver public function allow() { //if ($this->connector->security->isGranted('ROLE_ADMIN')) { - $userId = api_get_user_id(); return isset($this->connector->course) && !empty($this->connector->course) && - !api_is_anonymous($userId, true) + !api_is_anonymous() ; } } diff --git a/src/Chamilo/CoreBundle/Component/Editor/Driver/HomeDriver.php b/src/Chamilo/CoreBundle/Component/Editor/Driver/HomeDriver.php index cde81a86e8..cb92f0d40d 100644 --- a/src/Chamilo/CoreBundle/Component/Editor/Driver/HomeDriver.php +++ b/src/Chamilo/CoreBundle/Component/Editor/Driver/HomeDriver.php @@ -36,8 +36,9 @@ class HomeDriver extends Driver */ public function upload($fp, $dst, $name, $tmpname) { + $this->setConnectorFromPlugin(); + if ($this->allow()) { - $this->setConnectorFromPlugin(); return parent::upload($fp, $dst, $name, $tmpname); } @@ -48,8 +49,9 @@ class HomeDriver extends Driver */ public function rm($hash) { + $this->setConnectorFromPlugin(); + if ($this->allow()) { - $this->setConnectorFromPlugin(); return parent::rm($hash); } diff --git a/src/Chamilo/CoreBundle/Component/Editor/Driver/PersonalDriver.php b/src/Chamilo/CoreBundle/Component/Editor/Driver/PersonalDriver.php index c37dd78433..cbb7ca2d45 100644 --- a/src/Chamilo/CoreBundle/Component/Editor/Driver/PersonalDriver.php +++ b/src/Chamilo/CoreBundle/Component/Editor/Driver/PersonalDriver.php @@ -20,6 +20,7 @@ class PersonalDriver extends Driver if ($this->allow()) { $userId = api_get_user_id(); + if (!empty($userId)) { // Adding user personal files @@ -52,8 +53,9 @@ class PersonalDriver extends Driver */ public function upload($fp, $dst, $name, $tmpname) { + $this->setConnectorFromPlugin(); + if ($this->allow()) { - $this->setConnectorFromPlugin(); return parent::upload($fp, $dst, $name, $tmpname); } @@ -64,8 +66,9 @@ class PersonalDriver extends Driver */ public function rm($hash) { + $this->setConnectorFromPlugin(); + if ($this->allow()) { - $this->setConnectorFromPlugin(); return parent::rm($hash); } @@ -77,6 +80,7 @@ class PersonalDriver extends Driver public function allow() { //if ($this->connector->security->isGranted('IS_AUTHENTICATED_FULLY')) { + return !api_is_anonymous(); } } diff --git a/src/Chamilo/CoreBundle/Component/Editor/Editor.php b/src/Chamilo/CoreBundle/Component/Editor/Editor.php index 17bc3e7fea..d0ce012c1c 100644 --- a/src/Chamilo/CoreBundle/Component/Editor/Editor.php +++ b/src/Chamilo/CoreBundle/Component/Editor/Editor.php @@ -50,6 +50,9 @@ class Editor /** @var \Template */ public $template; + /** + * Constructor + */ public function __construct() { $this->toolbarSet = 'Basic'; @@ -112,9 +115,11 @@ class Editor /** * Converts a PHP variable into its Javascript equivalent. * The code of this method has been "borrowed" from the function drupal_to_js() within the Drupal CMS. - * @param mixed $var The variable to be converted into Javascript syntax - * @return string Returns a string - * Note: This function is similar to json_encode(), in addition it produces HTML-safe strings, i.e. with <, > and & escaped. + * @param mixed $var The variable to be converted into Javascript syntax + * + * @return string Returns a string + * Note: This function is similar to json_encode(), + * in addition it produces HTML-safe strings, i.e. with <, > and & escaped. * @link http://drupal.org/ */ protected function toJavascript($var) @@ -159,7 +164,7 @@ class Editor /** * @param string $key - * @param mixed $value + * @param mixed $value */ public function setConfigAttribute($key, $value) { @@ -168,6 +173,7 @@ class Editor /** * @param string $key + * * @return mixed */ public function getConfigAttribute($key) diff --git a/src/Chamilo/CoreBundle/Component/Editor/Toolbar.php b/src/Chamilo/CoreBundle/Component/Editor/Toolbar.php index 5a61fbbe4b..8e9407e631 100644 --- a/src/Chamilo/CoreBundle/Component/Editor/Toolbar.php +++ b/src/Chamilo/CoreBundle/Component/Editor/Toolbar.php @@ -18,7 +18,7 @@ class Toolbar /** * @param string $toolbar - * @param array $config + * @param array $config * @param string $prefix */ public function __construct( @@ -45,7 +45,12 @@ class Toolbar */ public function getPluginsToString() { - $plugins = array_filter(array_merge($this->getDefaultPlugins(), $this->getPlugins())); + $plugins = array_filter( + array_merge( + $this->getDefaultPlugins(), + $this->getPlugins(), + $this->getConditionalPlugins()) + ); return $this->getConfigAttribute('extraPlugins'). @@ -53,6 +58,16 @@ class Toolbar } /** + * Get plugins by default in all editors in the platform + * @return array + */ + public function getDefaultPlugins() + { + return $this->defaultPlugins; + } + + /** + * Get fixed plugins depending of the toolbar * @return array */ public function getPlugins() @@ -61,11 +76,12 @@ class Toolbar } /** + * Get dynamic/conditional plugins depending of platform/course settings. * @return array */ - public function getDefaultPlugins() + public function getConditionalPlugins() { - return $this->defaultPlugins; + return array(); } /**