@DI\Observe("widget_my_workspaces")

@param DisplayWidgetEvent $event
485393
public function onDisplay(DisplayWidgetEvent $event)
    {
        if (!$this->authorization->isGranted('ROLE_USER')) {

            throw new AccessDeniedException();
        }

        $content = $this->templating->render(
            'ClarolineCoreBundle:Widget:desktopWidgetMyWorkspaces.html.twig',
            array()
        );
        $event->setContent($content);
        $event->stopPropagation();
    }
609570
public function onCopyWidgetConfiguration(CopyWidgetConfigurationEvent $event)
    {
        $source = $event->getWidgetInstance();
        $copy = $event->getWidgetInstanceCopy();
        $widgetConfig = $this->simpleTextManager->getTextConfig($source);

        if (!is_null($widgetConfig)) {
            $widgetConfigCopy = new SimpleTextConfig();
            $widgetConfigCopy->setWidgetInstance($copy);
            $content = $this->replaceResourceLinks($widgetConfig->getContent(), $event->getResourceInfos());
            $widgetConfigCopy->setContent($this->replaceTabsLinks($content, $event->getTabsInfos()));

            $this->om->persist($widgetConfigCopy);
            $this->om->flush();
        }
        $event->validateCopy();
        $event->stopPropagation();
    }
20629
public function onDisplay(DisplayWidgetEvent $event)
    {
        if (!$this->request) {
            throw new NoHttpRequestException();
        }

        $workspace = $event->getInstance()->getWorkspace();

        $templatePath = 'ClarolineForumBundle:Forum:forumsWorkspaceWidget.html.twig';
        $widgetType = 'workspace';
        if ($workspace == null) {
            $templatePath = 'ClarolineForumBundle:Forum:forumsDesktopWidget.html.twig';
            $widgetType = 'desktop';
        }

        $event->setContent($this->templatingEngine->render(
            $templatePath,
            array(
                'widgetType' => $widgetType,
                'messages' => $this->forumWidgetManager->getLastMessages($event->getInstance(), $workspace)
            )
        ));
        $event->stopPropagation();
    }
152125
public function onDisplayWorkspaceParameters(DisplayToolEvent $event)
    {
         $event->setContent($this->workspaceParameters($event->getWorkspace()->getId()));
    }
601413
public function preCreate(CreateEvent $event)
    {
        $workspace = $this->manager->createWorkspace($event->getObject());
        $options = $event->getOptions();

        $user = $this->tokenStorage->getToken() ?
            $this->tokenStorage->getToken()->getUser() :
            $this->userManager->getDefaultClarolineAdmin();
        $model = $workspace->getWorkspaceModel() ? $workspace->getWorkspaceModel() : $this->manager->getDefaultModel();
        $workspace->setWorkspaceModel($model);

        if ($user instanceof User) {
            $workspace->setCreator($user);

            $organization = $user->getMainOrganization() ?
                $user->getMainOrganization() :
                $this->organizationManager->getDefault();
            $workspace->addOrganization($organization);
        }

        //this is for workspace creation: TODO remove that because it's very confusing
        //make a search on LIGHT_COPY you'll find what will probably need a change
        if (in_array(Options::LIGHT_COPY, $options)) {
            $this->om->flush();

            return $workspace;
        }

        //is this part ever fired anymore ? I don't know

        $workspace = $this->manager->copy($model, $workspace, false);

        $this->om->flush();

        return $workspace;
    }
283614
public function onDisplayWorkspaceResourceManager(DisplayToolEvent $event)
    {
        $event->setContent($this->resourceWorkspace($event->getWorkspace()->getId()));
    }
330595
def showEvent(self, event):
        
        super(XWalkthroughWidget, self).showEvent(event)
        
        self.autoLayout()
        self.restart()
        self.setFocus()
        self.raise_()
1240772
public function onDisplay(DisplayWidgetEvent $event)
    {
        $instance = $event->getInstance();
        $params = ($instance->isDesktop()) ?
            $this->logManager->getDesktopWidgetList($instance):
            $this->logManager->getWorkspaceWidgetList($instance);
        $view = $this->twig->render('ClarolineCoreBundle:Log:no_action_found.html.twig', array());

        if ($params && count($params['logs']) > 0) {
            $view = $this->twig->render(
                'ClarolineCoreBundle:Log:view_short_list.html.twig',
                $params
            );
        }

        $event->setContent($view);
        $event->stopPropagation();
    }
1055950
public function display()
    {
        if (!$this->visible) {
            return;
        }

        if ($this->getFirst() === null) {
            return;
        }

        SwatWidget::display();

        $container_tag = new SwatHtmlTag($this->container_tag);
        $container_tag->id = $this->id;
        $container_tag->class = $this->getCSSClassString();

        $container_tag->open();

        $content_wrapper = null;
        if ($this->wrap_content_and_notes) {
            $content_wrapper = new SwatHtmlTag('div');
            $content_wrapper->class = 'swat-form-field-content-wrapper';
        }

        if ($this->title_reversed) {
            if ($this->show_notes_first) {
                if ($this->wrap_content_and_notes) {
                    $content_wrapper->open();
                    $this->displayNotes();
                    $this->displayContent();
                    $content_wrapper->close();

                    $this->displayTitle();
                    $this->displayMessages();
                } else {
                    $this->displayNotes();
                    $this->displayContent();
                    $this->displayTitle();
                    $this->displayMessages();
                }
            } else {
                if ($this->wrap_content_and_notes) {
                    $content_wrapper->open();
                    $this->displayContent();
                    $this->displayNotes();
                    $content_wrapper->close();

                    $this->displayTitle();
                    $this->displayMessages();
                } else {
                    $this->displayContent();
                    $this->displayTitle();
                    $this->displayMessages();
                    $this->displayNotes();
                }
            }
        } else {
            if ($this->show_notes_first) {
                if ($this->wrap_content_and_notes) {
                    $this->displayTitle();

                    $content_wrapper->open();
                    $this->displayNotes();
                    $this->displayContent();
                    $content_wrapper->close();

                    $this->displayMessages();
                } else {
                    $this->displayTitle();
                    $this->displayNotes();
                    $this->displayContent();
                    $this->displayMessages();
                }
            } else {
                if ($this->wrap_content_and_notes) {
                    $this->displayTitle();

                    $content_wrapper->open();
                    $this->displayContent();
                    $this->displayNotes();
                    $content_wrapper->close();

                    $this->displayMessages();
                } else {
                    $this->displayTitle();
                    $this->displayContent();
                    $this->displayMessages();
                    $this->displayNotes();
                }
            }
        }

        $container_tag->close();
    }
1352632
public function onLayoutBoxFormInit(FormEvent $event)
    {
        $builder       = $event->getFormBuilder();
        $form          = $event->getForm();
        $configurators = $this->container->get('layout_box.configurator.collection')->all();
        $resource      = $event->getResource();
        $boxSettings   = $resource->getSettings();
        
        foreach ($configurators as $configurator) {
            if ($configurator instanceof LayoutBoxConfiguratorInterface) {
                $defaults = [];
                if ($resource->getBoxType() == $configurator->getType()) {
                    $defaults = $boxSettings;
                }
                
                $configurator->addFormFields($builder, $form, $defaults);
            }
        }
    }
189665
public function onDisplayDesktop(DisplayToolEvent $event)
    {
        $currentUser = $this->tokenStorage->getToken()->getUser();

        $allTabs = $this->finder->search(HomeTab::class, [
            'filters' => ['user' => $currentUser->getUuid()],
        ]);

        // Order tabs. We want :
        //   - Administration tabs to be at first
        //   - Tabs to be ordered by position
        // For this, we separate administration tabs and user ones, order them by position
        // and then concat all tabs with admin in first (I don't have a easier solution to achieve this)

        $adminTabs = [];
        $userTabs = [];
        foreach ($allTabs['data'] as $tab) {
            if (!empty($tab)) {
                // we use the define position for array keys for easier sort
                if (HomeTab::TYPE_ADMIN_DESKTOP === $tab['type']) {
                    $adminTabs[$tab['position']] = $tab;
                } else {
                    $userTabs[$tab['position']] = $tab;
                }
            }
        }

        // order tabs by position
        ksort($adminTabs);
        ksort($userTabs);

        // generate the final list of tabs
        $orderedTabs = array_merge(array_values($adminTabs), array_values($userTabs));

        // we rewrite tab position because an admin and a user tab may have the same position
        foreach ($orderedTabs as $index => &$tab) {
            $tab['position'] = $index;
        }

        $content = $this->templating->render(
            'ClarolineCoreBundle:tool:home.html.twig', [
                'editable' => true,
                'context' => [
                    'type' => Widget::CONTEXT_DESKTOP,
                ],
                'tabs' => $orderedTabs,
            ]
        );

        $event->setContent($content);
        $event->stopPropagation();
    }
464686
public function onWidgetDetailGenerate(WidgetDetailEvent $event)
    {
        // Share cache directories between users if appropriate.
        if ($this->settingsHelper->getShareCaches()) {
            $cacheDir = $this->coreParametersHelper->getParameter(
                'cached_data_dir',
                $this->pathsHelper->getSystemPath('cache', true)
            );
            $event->setCacheDir($cacheDir, 'shared_dashboard');
        }

        // Override the default cache timeout for the widget if appropriate.
        if ($this->settingsHelper->getCacheTTL()) {
            /** @var Widget $widget */
            $widget = $event->getWidget();
            if ($widget) {
                $defaultCacheTTL = $widget->getCacheTimeout();
                if ($defaultCacheTTL < $this->settingsHelper->getCacheTTL()) {
                    $event->setCacheTimeout($this->settingsHelper->getCacheTTL());
                }
                // add date Params as clone params to keep date as unique key for cache
                // since Core removes date params before generating keys
                $params                  = $widget->getParams();
                $cloneFrom               = isset($params['dateFrom']) ? clone $params['dateFrom'] : new \DateTime('today midnight');
                $cloneTo                 = isset($params['dateTo']) ? clone $params['dateTo'] : new \DateTime('tomorrow midnight - 1 second');
                $params['uniqueDateKey'] = [
                    'fromKey' => $cloneFrom,
                    'toKey'   => $cloneTo,
                ];
                $widget->setParams($params);
            }
        }
    }
218945
public function onWorkspaceToolCopy(WorkspaceCopyToolEvent $event)
    {
        $oldWs = $event->getOldWorkspace();
        $workspace = $event->getNewWorkspace();

        $planned = $this->finder->fetch(PlannedNotification::class, ['workspace' => $oldWs->getUuid()]);
        $oldMessages = $this->finder->fetch(Message::class, ['workspace' => $oldWs->getUuid()]);
        $newNotifs = [];

        foreach ($planned as $old) {
            $new = $this->crud->copy($old, [Options::GENERATE_UUID]);
            $new->setWorkspace($workspace);
            $new->emptyRoles();

            foreach ($old->getRoles() as $role) {
                foreach ($workspace->getRoles() as $wsRole) {
                    if ($wsRole->getTranslationKey() === $role->getTranslationKey()) {
                        $new->addRole($wsRole);
                    }
                }
            }
            $newNotifs[$old->getId()] = $new;
            $this->om->persist($new);
        }

        foreach ($oldMessages as $old) {
            $new = $this->crud->copy($old, [Options::GENERATE_UUID]);
            $new->setWorkspace($workspace);
            $new->emptyNotifications();

            foreach ($old->getNotifications() as $oldNotification) {
                if (isset($newNotifs[$oldNotification->getId()])) {
                    $new->addNotification($newNotifs[$oldNotification->getId()]);
                }
            }

            $this->om->persist($new);
        }

        $this->om->flush();
    }
731520
public function onDisplayDesktopReservationAgenda(DisplayToolEvent $event)
    {
        $resourcesTypes = $this->em->getRepository('FormaLibreReservationBundle:ResourceType')->findAll();

        foreach ($resourcesTypes as $resourcesType) {
            foreach ($resourcesType->getResources() as $resource) {
                if (!$this->reservationManager->hasAccess($this->tokenStorage->getToken()->getUser(), $resource, ReservationController::SEE)) {
                    $resourcesType->removeResource($resource);
                }
            }
        }

        $event->setContent($this->templating->render('FormaLibreReservationBundle:tool:reservation_agenda.html.twig', ['resourcesType' => $resourcesTypes]));
    }
667012
public function onPrepareWorkspaceUploadMaintenancePage(WorkspaceEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
    {
        $host = $event->getWorkspace()->getHost();
        $connection = $this->ensureConnection($host);

        $directory = sprintf('%s/maintenance/%s', $host->getPath(), $this->documentRoot);
        $context = array('directory' => $directory, 'event.task.action' => TaskInterface::ACTION_IN_PROGRESS);

        $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Creating directory "{directory}".', $eventName, $this, $context));
        if ($connection->isDirectory($directory) === false) {
            if ($connection->createDirectory($directory, 0770, true)) {
                $context['event.task.action'] = TaskInterface::ACTION_COMPLETED;
                $context['output.resetLine'] = true;

                $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Created directory "{directory}".', $eventName, $this, $context));
            } else {
                $context['event.task.action'] = TaskInterface::ACTION_FAILED;
                $context['output.resetLine'] = true;

                $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::WARNING, 'Failed creating directory "{directory}".', $eventName, $this, $context));
            }
        } else {
            $context['event.task.action'] = TaskInterface::ACTION_COMPLETED;
            $context['output.resetLine'] = true;

            $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::NOTICE, 'Directory "{directory}" exists.', $eventName, $this, $context));
        }

        if ($connection->isDirectory($directory)) {
            $files = array_diff(scandir($this->localMaintenanceDirectory), array('.', '..'));
            foreach ($files as $file) {
                $localFile = $this->localMaintenanceDirectory.'/'.$file;
                if (is_file($localFile)) {
                    $context = array('file' => $localFile, 'event.task.action' => TaskInterface::ACTION_COMPLETED);

                    $uploaded = $connection->putFile($localFile, $directory.'/'.$file);
                    if ($uploaded === true) {
                        $eventDispatcher->dispatch(AccompliEvents::LOG, new LogEvent(LogLevel::INFO, 'Uploaded file "{file}".', $eventName, $this, $context));
                    }
                }
            }
        }
    }
1268101
public function onDisplayWorkspaceHome(DisplayToolEvent $event)
    {
        $params = array(
            '_controller' => 'ClarolineCoreBundle:Workspace:displayWorkspaceHomeTab',
            'workspace' => $event->getWorkspace()->getId(),
            'tabId' => -1
        );
        $subRequest = $this->container->get('request')->duplicate(array(), null, $params);
        $response = $this->httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);

        $event->setContent($response->getContent());
    }
337415
public function handleEvent(BuildWidgetEvent $event)
    {
        if (!$this->scopeDeterminator->currentScopeIsBackend()) {
            return;
        }

        $widget = $event->getWidget();
        if (!$widget instanceof Widget) {
            return;
        }

        $widget->wizard .= self::getWizard($event->getProperty(), $event->getEnvironment());
    }