/**
  * Include all JavaScript files matching the include regular expression
  * and not matching the exclude regular expression.
  *
  * @param string $include Regular expression of files to include
  * @param string $exclude Regular expression of files to exclude
  * @param string $package The package key of the resources to include or current controller package if NULL
  * @param string $subpackage The subpackage key of the resources to include or current controller subpackage if NULL
  * @param string $directory The directory inside the current subpackage. By default, the "JavaScript" directory will be used.
  * @return string
  */
 public function render($include, $exclude = NULL, $package = NULL, $subpackage = NULL, $directory = 'JavaScript')
 {
     $packageKey = $package === NULL ? $this->controllerContext->getRequest()->getControllerPackageKey() : $package;
     $subpackageKey = $subpackage === NULL ? $this->controllerContext->getRequest()->getControllerSubpackageKey() : $subpackage;
     $baseDirectory = 'resource://' . $packageKey . '/Public/' . ($subpackageKey !== NULL ? $subpackageKey . '/' : '') . $directory . '/';
     $staticJavaScriptWebBaseUri = $this->resourcePublisher->getStaticResourcesWebBaseUri() . 'Packages/' . $packageKey . '/' . ($subpackageKey !== NULL ? $subpackageKey . '/' : '') . $directory . '/';
     $iterator = $this->iterateDirectoryRecursively($baseDirectory);
     if ($iterator === NULL) {
         return '<!-- Warning: Cannot include JavaScript because directory "' . $baseDirectory . '" does not exist. -->';
     }
     $uris = array();
     foreach ($iterator as $file) {
         $relativePath = substr($file->getPathname(), strlen($baseDirectory));
         $relativePath = \TYPO3\Flow\Utility\Files::getUnixStylePath($relativePath);
         if (!$this->patternMatchesPath($exclude, $relativePath) && $this->patternMatchesPath($include, $relativePath)) {
             $uris[] = $staticJavaScriptWebBaseUri . $relativePath;
         }
     }
     // Sadly, the aloha editor needs a predefined inclusion order, which right now matches
     // the sorted URI list. that's why we sort here...
     asort($uris);
     $output = '';
     foreach ($uris as $uri) {
         $output .= '<script src="' . $uri . '"></script>' . chr(10);
     }
     return $output;
 }
예제 #2
0
    /**
     * Returns the HTML needed to include ExtJS, that is, CSS and JS includes.
     *
     * = Examples =
     *
     * <code title="Simple">
     * {namespace ext=TYPO3\ExtJS\ViewHelpers}
     *  ...
     * <ext:include/>
     * </code>
     * Renders the script and link tags needed to include everything needed to
     * use ExtJS.
     *
     * <code title="Use a specific theme">
     * <ext:include theme="xtheme-gray"/>
     * </code>
     *
     * @param string $theme The theme to include, simply the name of the CSS
     * @param boolean $debug Whether to use the debug version of ExtJS
     * @param boolean $includeStylesheets Include ExtJS CSS files if true
     * @return string HTML needed to include ExtJS
     * @api
     */
    public function render($theme = 'xtheme-blue', $debug = NULL, $includeStylesheets = TRUE)
    {
        if ($debug === NULL) {
            $debug = $this->objectManager->getContext()->isDevelopment() ?: FALSE;
        }
        $baseUri = $this->resourcePublisher->getStaticResourcesWebBaseUri() . 'Packages/TYPO3.ExtJS/';
        $output = '';
        if ($includeStylesheets) {
            $output .= '
<link rel="stylesheet" href="' . $baseUri . 'CSS/ext-all-notheme.css" />
<link rel="stylesheet" href="' . $baseUri . 'CSS/' . $theme . '.css" />';
        }
        if ($debug) {
            $output .= '
<script type="text/javascript" src="' . $baseUri . 'JavaScript/adapter/ext/ext-base-debug.js"></script>
<script type="text/javascript" src="' . $baseUri . 'JavaScript/ext-all-debug.js"></script>';
        } else {
            $output .= '
<script type="text/javascript" src="' . $baseUri . 'JavaScript/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="' . $baseUri . 'JavaScript/ext-all.js"></script>';
        }
        $output .= '
<script type="text/javascript">
	Ext.BLANK_IMAGE_URL = \'' . $baseUri . 'images/default/s.gif\';
	Ext.FlashComponent.EXPRESS_INSTALL_URL = \'' . $baseUri . 'Flash/expressinstall.swf\';
	Ext.chart.Chart.CHART_URL = \'' . $baseUri . 'Flash/chart.swf\';
</script>
';
        return $output;
    }
예제 #3
0
파일: UxViewHelper.php 프로젝트: neos/extjs
    /**
     * Returns the HTML needed to include the ExtJS ux class.
     *
     * = Examples =
     *
     * <code title="Simple">
     * {namespace ext=TYPO3\ExtJS\ViewHelpers}
     *  ...
     * <ext:ux name="StatusBar"/>
     * </code>
     * Renders the script tag to include the StatusBar ux class.
     *
     * @param string $name The name of the ux class
     * @return string HTML needed to include ExtJS
     * @api
     */
    public function render($name)
    {
        $baseUri = $this->resourcePublisher->getStaticResourcesWebBaseUri() . 'Packages/TYPO3.ExtJS/';
        return '
<script type="text/javascript" src="' . $baseUri . 'JavaScript/ux/' . $name . '.js"></script>
';
    }
 /**
  * @param string $version
  * @param boolean $loadJQuery
  * @param boolean $loadEmberData
  * @param boolean $minified
  * @return string
  * @throws \Exception
  */
 public function render($version = NULL, $loadJQuery = FALSE, $loadEmberData = FALSE, $minified = TRUE)
 {
     $defaults = $this->getConfigurationArray('defaults', $version, $minified);
     $version = $this->findVersionToLoad($version);
     // Make sure the requested version has Ember-data configured
     if ($loadEmberData && $this->settings['versions'][$version]['hasData'] === FALSE) {
         throw new \Exception(sprintf('Version %s has no Ember-data configured', $version));
     }
     // Merge defaults and version configuration (version configuration overrides defaults)
     $configuration = Arrays::arrayMergeRecursiveOverrule($defaults, $this->getConfigurationArray($version, $version, $minified), FALSE, FALSE);
     // Remove jQuery
     if ($loadJQuery === FALSE && isset($configuration['requirements']['jquery'])) {
         unset($configuration['requirements']['jquery']);
     }
     // Build the includes array
     $includes = array();
     foreach ($configuration['requirements'] as $requirement) {
         $includes[] = $requirement['path'];
     }
     $includes[] = $this->getResourcePath($this->settings['paths']['ember'], $version, $minified);
     if ($loadEmberData === TRUE) {
         $includes[] = $this->getResourcePath($this->settings['paths']['ember-data'], $version, $minified);
     }
     // Generate script tags
     $baseUrl = $this->resourcePublisher->getStaticResourcesWebBaseUri();
     $includes = array_map(function ($file) use($baseUrl) {
         return sprintf('<script src="%sPackages/%s"></script>', $baseUrl, $file);
     }, $includes);
     return implode('', $includes);
 }
예제 #5
0
 /**
  * @param string $resourcePath
  * @return string
  * @throws ViewHelperException
  */
 protected function resolveResourcePath($resourcePath)
 {
     // TODO: This method should be somewhere in the resource manager probably?
     $matches = array();
     preg_match('#resource://([^/]*)/Public/(.*)#', $resourcePath, $matches);
     if ($matches === array()) {
         throw new ViewHelperException('Resource path "' . $resourcePath . '" can\'t be resolved.', 1328543327);
     }
     $package = $matches[1];
     $path = $matches[2];
     return $this->resourcePublisher->getStaticResourcesWebBaseUri() . 'Packages/' . $package . '/' . $path;
 }
예제 #6
0
 /**
  * @param \_OurBrand_\Quiz\Domain\Model\Quiz $quiz
  *
  * @return array
  */
 private function makeExportArrayFromQuiz($quiz)
 {
     $thumbnailMaxWidth = 200;
     $thumbnailMaxHeight = 200;
     $previewImage = $quiz->getBannerImage() ? $quiz->getBannerImage()->getThumbNail($thumbnailMaxWidth, $thumbnailMaxHeight)->getOriginalResource() : null;
     $outQuiz = array('__identifier' => $this->persistenceManager->getIdentifierByObject($quiz), 'title' => $quiz->getTitle(), 'bannerImage' => $this->resourcePublisher->getPersistentResourceWebUri($previewImage), 'subject' => $quiz->getSubject(), 'numberOfExercises' => $quiz->getExercises()->count());
     return $outQuiz;
 }
 /**
  * Review a submission
  *
  * The create action is missing because the project is added in the
  * SubmissionFinisher (see Form/Finishers)
  *
  * @param \GIB\GradingTool\Domain\Model\Project $project
  */
 public function reviewSubmissionAction(\GIB\GradingTool\Domain\Model\Project $project)
 {
     // access check
     $this->checkOwnerOrAdministratorAndDenyIfNeeded($project);
     $submission = $this->submissionService->getProcessedSubmission($project);
     $radarChartImagePathAndFilename = $this->submissionService->getRadarImage($project);
     $radarChartImageResource = $this->resourceManager->importResource($radarChartImagePathAndFilename);
     $radarChartUri = $this->resourcePublisher->getPersistentResourceWebUri($radarChartImageResource);
     // this is necessary because we're in a safe request, but generate a resource
     $this->persistenceManager->persistAll();
     $this->view->assignMultiple(array('submission' => $submission, 'project' => $project, 'radarChartUri' => $radarChartUri));
 }
 /**
  * Prepares a mirror of public package resources that is accessible through
  * the web server directly.
  *
  * @param array $activePackages
  * @return void
  */
 public function publishPublicPackageResources(array $activePackages)
 {
     if ($this->settings['resource']['publishing']['detectPackageResourceChanges'] === FALSE && $this->statusCache->has('packageResourcesPublished')) {
         return;
     }
     foreach ($activePackages as $packageKey => $package) {
         $this->resourcePublisher->publishStaticResources($package->getResourcesPath() . 'Public/', 'Packages/' . $packageKey . '/');
     }
     if (!$this->statusCache->has('packageResourcesPublished')) {
         $this->statusCache->set('packageResourcesPublished', 'y', array(\TYPO3\Flow\Cache\Frontend\FrontendInterface::TAG_PACKAGE));
     }
 }
 /**
  * Send a mail to the project manager with the spider graph as attachement
  *
  * @param Project $project
  */
 public function sendGradingToProjectManager($project)
 {
     // send mail to project manager
     $radarChartImagePathAndFilename = $this->getRadarImage($project);
     $radarChartImageResource = $this->resourceManager->importResource($radarChartImagePathAndFilename);
     $radarChartUri = $this->resourcePublisher->getPersistentResourceWebUri($radarChartImageResource);
     // this is necessary because we're in a safe request, but generate a resource
     $this->persistenceManager->persistAll();
     $attachements = array(array('source' => $radarChartUri, 'fileName' => 'gib-grading.png'));
     $templateIdentifierOverlay = $this->templateService->getTemplateIdentifierOverlay('newSubmissionProjectManagerNotification', $project);
     $this->notificationMailService->sendNotificationMail($templateIdentifierOverlay, $project, $project->getProjectManager(), $project->getProjectManager()->getName()->getFirstName() . ' ' . $project->getProjectManager()->getName()->getLastName(), $project->getProjectManager()->getPrimaryElectronicAddress()->getIdentifier(), '', $attachements);
     // CC to GIB
     $this->notificationMailService->sendNotificationMail($templateIdentifierOverlay, $project, $project->getProjectManager(), $project->getProjectManager()->getName()->getFirstName() . ' ' . $project->getProjectManager()->getName()->getLastName(), '*****@*****.**', '', $attachements);
 }
 /**
  * Init tracker if in exam mode
  *
  * @param \_OurBrand_\Quiz\Domain\Model\Exercise $exercise
  *
  * @return json
  */
 public function getDictationAudioAction($exercise)
 {
     $audioFiles = array();
     foreach ($exercise->getSnippets() as $snippet) {
         if ($snippet->getAudio() && $snippet->getAudio()->getOriginalResource()) {
             $audioFiles[] = array('src' => base64_encode($this->resourcePublisher->getPersistentResourceWebUri($snippet->getAudio()->getOriginalResource())));
         }
     }
     if ($this->studentQuizSession) {
         $tracker = $this->trackStudentAudioPlaybackRepository->findBySessionAndExercise($this->studentQuizSession, $exercise)->getFirst();
         if (!is_a($tracker, '\\_OurBrand_\\Quiz\\Domain\\Model\\TrackStudentAudioPlayback')) {
             $tracker = new TrackStudentAudioPlayback();
             $tracker->setExercise($exercise);
             $tracker->setStudentQuizSession($this->studentQuizSession);
             $tracker->setTimeElapsed(0);
             $tracker->setStatus(0);
             $this->trackStudentAudioPlaybackRepository->add($tracker);
             $this->persistenceManager->persistAll();
         }
         return json_encode(array('elapsedTime' => $tracker->getTimeElapsed(), 'status' => $tracker->getStatus(), 'trackerId' => $this->persistenceManager->getIdentifierByObject($tracker), 'audioFiles' => $audioFiles));
     }
     return json_encode(array('status' => 0, 'audioFiles' => $audioFiles));
 }
 /**
  * Render the URI to the resource. The filename is used from child content.
  *
  * @param string $path The location of the resource, can be either a path relative to the Public resource directory of the package or a resource://... URI
  * @param string $package Target package key. If not set, the current package key will be used
  * @param Resource $resource If specified, this resource object is used instead of the path and package information
  * @param boolean $localize Whether resource localization should be attempted or not
  * @return string The absolute URI to the resource
  * @throws InvalidVariableException
  * @api
  */
 public function render($path = NULL, $package = NULL, Resource $resource = NULL, $localize = TRUE)
 {
     if ($resource !== NULL) {
         $uri = $this->resourcePublisher->getPersistentResourceWebUri($resource);
         if ($uri === FALSE) {
             $uri = $this->resourcePublisher->getStaticResourcesWebBaseUri() . 'BrokenResource';
         }
     } else {
         if ($path === NULL) {
             throw new InvalidVariableException('The ResourceViewHelper did neither contain a valuable "resource" nor "path" argument.', 1353512742);
         }
         if ($package === NULL) {
             $package = $this->controllerContext->getRequest()->getControllerPackageKey();
         }
         if (strpos($path, 'resource://') === 0) {
             $matches = array();
             if (preg_match('#^resource://([^/]+)/Public/(.*)#', $path, $matches) === 1) {
                 $package = $matches[1];
                 $path = $matches[2];
             } else {
                 throw new InvalidVariableException(sprintf('The path "%s" which was given to the ResourceViewHelper must point to a public resource.', $path), 1353512639);
             }
         }
         if ($localize === TRUE) {
             $resourcePath = 'resource://' . $package . '/Public/' . $path;
             $localizedResourcePathData = $this->i18nService->getLocalizedFilename($resourcePath);
             $matches = array();
             if (preg_match('#resource://([^/]+)/Public/(.*)#', current($localizedResourcePathData), $matches) === 1) {
                 $package = $matches[1];
                 $path = $matches[2];
             }
         }
         $uri = $this->resourcePublisher->getStaticResourcesWebBaseUri() . 'Packages/' . $package . '/' . $path;
     }
     return $uri;
 }
 /**
  * @test
  */
 public function evaluateLocalizesFilenameIfLocalize()
 {
     $this->mockTsRuntime->expects($this->any())->method('evaluate')->will($this->returnCallback(function ($evaluatePath, $that) {
         $relativePath = str_replace('resourceUri/test/', '', $evaluatePath);
         switch ($relativePath) {
             case 'localize':
                 return true;
             case 'path':
                 return 'resource://Some.Package/Public/SomeResource';
             case 'package':
                 return 'Specified.Package';
         }
         return null;
     }));
     $this->mockI18nService->expects($this->atLeastOnce())->method('getLocalizedFilename')->will($this->returnValue(array('resource://Some.Package/Public/LocalizedFilename')));
     $this->mockResourceManager->expects($this->atLeastOnce())->method('getPublicPackageResourceUri')->will($this->returnValue('Static/Resources/Packages/Some.Package/LocalizedFilename'));
     $this->assertSame('Static/Resources/Packages/Some.Package/LocalizedFilename', $this->resourceUriImplementation->evaluate());
 }