Example #1
0
 /**
  * @param array        $resource
  * @param ResourceType $resourceType
  * @param PluginBundle $pluginBundle
  */
 private function updateIcons(array $resource, ResourceType $resourceType, PluginBundle $pluginBundle)
 {
     $resourceIcon = $this->em->getRepository('ClarolineCoreBundle:Resource\\ResourceIcon')->findOneByMimeType('custom/' . $resourceType->getName());
     if (null === $resourceIcon) {
         $resourceIcon = new ResourceIcon();
         $resourceIcon->setMimeType('custom/' . $resourceType->getName());
     }
     if (isset($resource['icon'])) {
         $ds = DIRECTORY_SEPARATOR;
         $webBundleDir = "{$this->kernelRootDir}{$ds}..{$ds}web{$ds}bundles";
         $webPluginDir = "{$webBundleDir}{$ds}{$pluginBundle->getAssetsFolder()}";
         $webPluginImgDir = "{$webPluginDir}{$ds}images";
         $webPluginIcoDir = "{$webPluginImgDir}{$ds}icons";
         $this->fileSystem->mkdir(array($webBundleDir, $webPluginDir, $webPluginImgDir, $webPluginIcoDir));
         $this->fileSystem->copy("{$pluginBundle->getImgFolder()}{$ds}{$resource['icon']}", "{$webPluginIcoDir}{$ds}{$resource['icon']}");
         $resourceIcon->setRelativeUrl("bundles/{$pluginBundle->getAssetsFolder()}/images/icons/{$resource['icon']}");
     } else {
         $defaultIcon = $this->em->getRepository('ClarolineCoreBundle:Resource\\ResourceIcon')->findOneByMimeType('custom/default');
         $resourceIcon->setRelativeUrl($defaultIcon->getRelativeUrl());
     }
     $resourceIcon->setShortcut(false);
     $this->em->persist($resourceIcon);
     $this->im->createShortcutIcon($resourceIcon);
 }
Example #2
0
 /**
  * Returns true if the listener is implemented for a resourceType and an action
  *
  * @param ResourceType $resourceType
  * @param string       $actionName
  */
 public function isResourceActionImplemented(ResourceType $resourceType = null, $actionName)
 {
     if ($resourceType) {
         $alwaysTrue = array('rename', 'edit-properties', 'edit-rights', 'open-tracking');
         //first, directories can be downloaded even if there is no listener attached to it
         if ($resourceType->getName() === 'directory' && $actionName == 'download') {
             return true;
         }
         if (in_array($actionName, $alwaysTrue)) {
             return true;
         }
         $eventName = $actionName . '_' . $resourceType->getName();
     } else {
         $eventName = 'resource_action_' . $actionName;
     }
     return $this->dispatcher->hasListeners($eventName);
 }
Example #3
0
 /**
  * @param array        $resource
  * @param ResourceType $resourceType
  * @param PluginBundle $pluginBundle
  */
 private function updateIcons(array $resource, ResourceType $resourceType, PluginBundle $pluginBundle)
 {
     $resourceIcon = $this->em->getRepository('ClarolineCoreBundle:Resource\\ResourceIcon')->findOneByMimeType('custom/' . $resourceType->getName());
     if (null === $resourceIcon) {
         $resourceIcon = new ResourceIcon();
         $resourceIcon->setMimeType('custom/' . $resourceType->getName());
     }
     if (isset($resource['icon'])) {
         $resourceIcon->setRelativeUrl("bundles/{$pluginBundle->getAssetsFolder()}/images/icons/{$resource['icon']}");
     } else {
         $defaultIcon = $this->em->getRepository('ClarolineCoreBundle:Resource\\ResourceIcon')->findOneByMimeType('custom/default');
         $resourceIcon->setRelativeUrl($defaultIcon->getRelativeUrl());
     }
     $resourceIcon->setShortcut(false);
     $this->em->persist($resourceIcon);
     $this->im->createShortcutIcon($resourceIcon);
 }