public function submit() { if ($this->validateAction()) { $post = $this->request->request->all(); $fsp = FilePermissions::getGlobal(); foreach ($post as $key => $value) { if (preg_match('/fsID:/', $key)) { $id = explode(':', $key); $fsID = $id[1]; $fs = Set::getByID($fsID); foreach ($this->files as $file) { if ($fsp->canAddFile($file)) { switch ($value) { case '0': if ($file->inFileSet($fs)) { $fs->removeFileFromSet($file); } break; case '1': // do nothing break; case '2': $fs->addFileToSet($file); break; } } } } } $fsNew = $this->request->request->get('fsNew'); $fsNewShare = $this->request->request->get('fsNewShare'); if (is_array($fsNew)) { foreach ($fsNew as $i => $name) { if ($name) { foreach ($this->files as $file) { $type = $fsNewShare[$i] == 1 ? Set::TYPE_PUBLIC : Set::TYPE_PRIVATE; $fs = Set::createAndGetSet($fsNew[$i], $type); $fs->addFileToSet($file); } } } } $sets = array(); foreach ($this->files as $file) { foreach ($file->getFileSets() as $set) { $o = $set->getJSONObject(); if (!in_array($o, $sets)) { $sets[] = $o; } } } $response = new EditResponse(); $response->setFiles($this->files); $response->setAdditionalDataAttribute('sets', $sets); $response->setMessage(t('File sets updated successfully.')); $response->outputJSON(); } }
public function register() { $this->app->singleton('editor', function ($app) { $config = $app->make('site')->getSite()->getConfigRepository(); $styles = $config->get('editor.ckeditor4.styles', array()); $pluginManager = new PluginManager(); $pluginManager->selectMultiple($config->get('editor.ckeditor4.plugins.selected', array())); $this->registerCkeditorPlugins($pluginManager); $this->registerCorePlugins($pluginManager); $editor = new CkeditorEditor($config, $pluginManager, $styles); $editor->setToken($app->make('token')->generate('editor')); $filePermission = FilePermissions::getGlobal(); $taskPermission = new TaskPermission(); $editor->setAllowFileManager($filePermission->canAccessFileManager() && $config->get('editor.concrete.enable_filemanager')); $editor->setAllowSitemap($taskPermission->canAccessSitemap() && $config->get('editor.concrete.enable_sitemap')); return $editor; }); }
public function __construct() { $fp = FilePermissions::getGlobal(); $tp = new TaskPermission(); $this->assets = ResponseAssetGroup::get(); $this->token = Core::make("token")->generate('editor'); $this->allowFileManager = \Config::get('concrete.editor.concrete.enable_filemanager') && $fp->canAccessFileManager(); $this->allowSitemap = \Config::get('concrete.editor.concrete.enable_sitemap') && $tp->canAccessSitemap(); $this->pluginManager = new PluginManager(); $this->pluginManager->register('undoredo', t('Undo/Redo')); $this->pluginManager->register('underline', t('Underline')); $this->pluginManager->register('concrete5lightbox', t('Lightbox')); $this->pluginManager->register('specialcharacters', t('Special Characters Palette')); $this->pluginManager->register('table', t('Table')); $this->pluginManager->register('fontfamily', t('Font Family')); $this->pluginManager->register('fontsize', t('Font Size')); $this->pluginManager->register('fontcolor', t('Font Color')); $this->pluginManager->selectMultiple(\Config::get('concrete.editor.plugins.selected')); }