private function updateIcons()
 {
     $this->log('Refreshing mime types icons...');
     $coreIconWebDirRelativePath = "bundles/clarolinecore/images/resources/icons/";
     $resourceImages = $this->container->get('claroline.manager.icon_manager')->getDefaultIconMap();
     $this->om->startFlushSuite();
     foreach ($resourceImages as $resourceImage) {
         $mimeType = $resourceImage[1];
         $rimg = $this->repo->findOneBy(array('mimeType' => $mimeType, 'isShortcut' => false));
         //var_dump(count($results));
         //$rimg = count($results > 0) ? $results[0]: null;
         if ($rimg === null) {
             $this->log('Adding mime type for ' . $mimeType . '.');
             $rimg = new ResourceIcon();
             $rimg->setMimeType($mimeType);
             $rimg->setShortcut(false);
             $this->container->get('claroline.manager.icon_manager')->createShortcutIcon($rimg);
         }
         $rimg->setRelativeUrl($coreIconWebDirRelativePath . $resourceImage[0]);
         $this->om->persist($rimg);
     }
     $this->om->endFlushSuite();
     $baseIcons = $this->repo->findBaseIcons();
     $this->om->startFlushSuite();
     foreach ($baseIcons as $icon) {
         $this->log('Refreshing ' . $icon->getMimeType() . '...');
         $this->iconManager->refresh($icon);
     }
     $this->om->endFlushSuite();
     $this->om->forceFlush();
 }
 public function load(ObjectManager $manager)
 {
     $icon = new ResourceIcon();
     $icon->setMimeType('custom/ujm_exercise');
     $icon->setRelativeUrl('bundles/ujmexo/images/icons/res_exo.png');
     $icon->setShortcut(false);
     $manager->persist($icon);
     $manager->flush();
     $this->container->get('claroline.manager.icon_manager')->createShortcutIcon($icon);
     $this->addReference('icon1', $icon);
 }
Example #3
0
 public function updateIcons()
 {
     $this->log('updating icons...');
     $mimetypes = array('application/illustrator', 'application/ai');
     foreach ($mimetypes as $mimetype) {
         $icon = new ResourceIcon();
         $icon->setRelativeUrl('bundles/clarolinecore/images/resources/icons/res_vector.png');
         $icon->setMimeType($mimetype);
         $icon->setShortcut(false);
         $this->om->persist($icon);
         $this->container->get('claroline.manager.icon_manager')->createShortcutIcon($icon);
     }
 }
 /**
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $coreIconWebDirRelativePath = 'bundles/clarolinecore/images/resources/icons/';
     $resourceImages = $this->container->get('claroline.manager.icon_manager')->getDefaultIconMap();
     foreach ($resourceImages as $resourceImage) {
         $rimg = new ResourceIcon();
         $rimg->setRelativeUrl($coreIconWebDirRelativePath . $resourceImage[0]);
         $rimg->setMimeType($resourceImage[1]);
         $rimg->setShortcut(false);
         $manager->persist($rimg);
         $this->container->get('claroline.manager.icon_manager')->createShortcutIcon($rimg);
     }
 }
Example #5
0
 public function postUpdate()
 {
     $coreIconWebDirRelativePath = "bundles/clarolinecore/images/resources/icons/";
     $images = array(array('res_mspowerpoint.png', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'), array('res_msword.png', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'));
     $this->log('Adding new resource icons...');
     foreach ($images as $image) {
         $rimg = new ResourceIcon();
         $rimg->setRelativeUrl($coreIconWebDirRelativePath . $image[0]);
         $rimg->setMimeType($image[1]);
         $rimg->setShortcut(false);
         $this->objectManager->persist($rimg);
         $this->container->get('claroline.manager.icon_manager')->createShortcutIcon($rimg);
     }
     $this->objectManager->flush();
 }
Example #6
0
 public function postUpdate()
 {
     $ds = DIRECTORY_SEPARATOR;
     $coreWebDir = "{$this->container->getParameter('kernel.root_dir')}{$ds}..{$ds}web{$ds}";
     $coreIconWebDirRelativePath = 'bundles/clarolinecore/images/resources/icons/';
     $coreIconWebDir = "{$coreWebDir}bundles{$ds}clarolinecore{$ds}images{$ds}resources{$ds}icons{$ds}";
     $resourceImage = array('res_audio.png', 'audio');
     $em = $this->container->get('doctrine.orm.entity_manager');
     $this->log('Update images...');
     $rimg = new ResourceIcon();
     $rimg->setRelativeUrl($coreIconWebDirRelativePath . $resourceImage[0]);
     $rimg->setMimeType($resourceImage[1]);
     $rimg->setShortcut(false);
     $em->persist($rimg);
     $this->container->get('claroline.manager.icon_manager')->createShortcutIcon($rimg);
 }
Example #7
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 #8
0
 /**
  * @param \Claroline\CoreBundle\Entity\Resource\ResourceIcon $icon
  */
 public function removeImageFromThumbDir(ResourceIcon $icon, Workspace $workspace = null)
 {
     if (preg_match('#^thumbnails#', $icon->getRelativeUrl())) {
         $pathName = $this->rootDir . '/../web/' . $icon->getRelativeUrl();
         if (file_exists($pathName)) {
             unlink($pathName);
             if (!is_null($workspace)) {
                 $dir = $this->thumbDir . DIRECTORY_SEPARATOR . $workspace->getCode();
                 if (is_dir($dir) && $this->isDirectoryEmpty($dir)) {
                     rmdir($dir);
                 }
             }
         }
     }
 }
Example #9
0
 public function refresh(ResourceIcon $icon)
 {
     $shortcut = $icon->getShortcutIcon();
     $newUrl = $this->createShortcutFromRelativeUrl($icon->getRelativeUrl());
     $shortcut->setRelativeUrl($newUrl);
     $this->om->persist($shortcut);
     $this->om->flush();
 }
Example #10
0
 private function addingResourceIcons()
 {
     $coreIconWebDirRelativePath = 'bundles/clarolinecore/images/resources/icons/';
     $om = $this->container->get('doctrine.orm.entity_manager');
     $repo = $om->getRepository('Claroline\\CoreBundle\\Entity\\Resource\\ResourceIcon');
     $resourceImages = $this->container->get('claroline.manager.icon_manager')->getDefaultIconMap();
     foreach ($resourceImages as $resourceImage) {
         $imgs = $repo->findBy(array('mimeType' => $resourceImage[1]));
         if (count($imgs) === 0) {
             $this->log('Adding icon for mime type ' . $resourceImage[1] . '...');
             $rimg = new ResourceIcon();
             $rimg->setRelativeUrl($coreIconWebDirRelativePath . $resourceImage[0]);
             $rimg->setMimeType($resourceImage[1]);
             $rimg->setShortcut(false);
             $om->persist($rimg);
             $this->container->get('claroline.manager.icon_manager')->createShortcutIcon($rimg);
         }
     }
 }
Example #11
0
 public function updateIcons()
 {
     $this->log('updating icons...');
     $coreIconWebDirRelativePath = "bundles/clarolinecore/images/resources/icons/";
     $resourceImages = array(array('res_vector.png', 'application/postscript'), array('res_vector.png', 'image/svg+xml'), array('res_zip.png', 'application/zip'), array('res_zip.png', 'application/x-rar-compressed'), array('res_archive.png', 'application/x-gtar'), array('res_archive.png', 'application/x-7z-compressed'));
     foreach ($resourceImages as $resourceImage) {
         $icon = new ResourceIcon();
         $icon->setRelativeUrl($coreIconWebDirRelativePath . $resourceImage[0]);
         $icon->setMimeType($resourceImage[1]);
         $icon->setShortcut(false);
         $this->om->persist($icon);
         $this->container->get('claroline.manager.icon_manager')->createShortcutIcon($icon);
     }
 }
Example #12
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);
 }