/**
  * 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\FLOW3\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;
 }
 /**
  * Returns the specified node
  *
  * @param string $term
  * @param integer $requestIndex
  * @return void
  * @ExtDirect
  * @todo Improve this WIP search implementation
  */
 public function searchAction($term, $requestIndex)
 {
     $contentContext = new \TYPO3\TYPO3\Domain\Service\ContentContext($this->securityContext->getParty()->getPreferences()->get('context.workspace'));
     $this->nodeRepository->setContext($contentContext);
     $searchContentGroups = array();
     $searchContentTypes = array();
     foreach (array('TYPO3.Phoenix.ContentTypes:Page', 'TYPO3.Phoenix.ContentTypes:ContentObject') as $contentType) {
         $searchContentGroups[$contentType] = $this->contentTypeManager->getContentType($contentType)->getConfiguration();
         array_push($searchContentTypes, $contentType);
         $subContentTypes = $this->contentTypeManager->getSubContentTypes($contentType);
         if (count($subContentTypes) > 0) {
             $searchContentGroups[$contentType]['subContentTypes'] = $subContentTypes;
             $searchContentTypes = array_merge($searchContentTypes, array_keys($subContentTypes));
         }
     }
     $staticWebBaseUri = $this->resourcePublisher->getStaticResourcesWebBaseUri() . 'Packages/TYPO3.TYPO3/';
     $groups = array();
     foreach ($this->nodeSearchService->findByProperties($term, $searchContentTypes) as $result) {
         $contentType = $result->getContentType();
         if (array_key_exists($contentType->getName(), $searchContentGroups)) {
             $type = $contentType->getName();
         } else {
             foreach ($searchContentGroups as $searchContentGroup => $searchContentGroupConfiguration) {
                 if (isset($searchContentGroupConfiguration['subContentTypes']) && array_key_exists($contentType->getName(), $searchContentGroupConfiguration['subContentTypes'])) {
                     $type = $searchContentGroup;
                     break;
                 }
             }
         }
         if (!array_key_exists($type, $groups)) {
             $groups[$type] = array('type' => $contentType->getName(), 'label' => $searchContentGroups[$type]['search'], 'items' => array());
         }
         foreach ($contentType->getProperties() as $property => $configuration) {
             if ($property[0] !== '_') {
                 $labelProperty = $property;
                 break;
             }
         }
         $this->uriBuilder->reset();
         if ($result->getContentType()->isOfType('TYPO3.Phoenix.ContentTypes:Page')) {
             $pageNode = $result;
         } else {
             $pageNode = $this->findNextParentFolderNode($result);
             $this->uriBuilder->setSection('c' . $result->getIdentifier());
         }
         $searchResult = array('type' => $contentType->getName(), 'label' => substr(trim(strip_tags($result->getProperty($labelProperty))), 0, 50), 'action' => $this->uriBuilder->uriFor('show', array('node' => $pageNode), 'Frontend\\Node', 'TYPO3.TYPO3'), 'path' => $result->getPath());
         $contentTypeConfiguration = $contentType->getConfiguration();
         if (isset($contentTypeConfiguration['darkIcon'])) {
             $searchResult['icon'] = $staticWebBaseUri . $contentTypeConfiguration['darkIcon'];
         }
         array_push($groups[$type]['items'], $searchResult);
     }
     $data = array('requestIndex' => $requestIndex, 'actions' => array(array('label' => 'Clear all cache', 'command' => 'clear:cache:all'), array('label' => 'Clear page cache', 'command' => 'clear:cache:pages')), 'results' => array_values($groups));
     $this->view->assign('value', array('data' => $data, 'success' => TRUE));
 }
 /**
  *
  * @param mixed $resource
  * @return string Rendered string
  * @author Marc Neuhaus <*****@*****.**>
  * @api
  */
 public function render($resource)
 {
     if (is_object($resource)) {
         $mime = explode("/", $resource->getMimeType());
         $file = $this->resourcePublisher->getPersistentResourceWebUri($resource, "");
         switch ($mime[0]) {
             case "image":
                 return "<img src='" . $file . "' width='300px' class='thumbnail' />";
                 break;
             default:
                 break;
         }
     }
 }
 public function _render()
 {
     $package = $this->controllerContext->getRequest()->getControllerPackageKey();
     $mirrorPath = str_replace("/http://dev.flow3.local/_", "", $this->resourcePublisher->getStaticResourcesWebBaseUri());
     $uri = $mirrorPath . '/Packages/' . $package . '/';
     $output = "";
     $jsfiles = array("js/jquery/jquery.js", "js/jquery/jquery.ui.js", "js/jquery/jquery.livesearch.js", "js/jquery/jquery.hotkeys.js", "js/jquery/jquery.selectbox.js", "js/jquery/jquery.elastic.js", "js/jquery/jquery.keynav.js", "js/main.js");
     foreach ($jsfiles as $jsfile) {
         $output .= '<script src="' . $uri . $jsfile . '" type="text/javascript" charset="utf-8"></script>' . "\n";
     }
     $cssfiles = array("css/jquery/jquery.ui.css", "css/jquery/jquery.selector.css");
     foreach ($cssfiles as $cssfile) {
         $output .= '<link rel="stylesheet" href="' . $uri . $cssfile . '" type="text/css" media="screen" title="no title" charset="utf-8">' . "\n";
     }
     return $output;
 }
Exemple #5
0
 /**
  * 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\FLOW3\Cache\Frontend\FrontendInterface::TAG_PACKAGE));
     }
 }
 /**
  * Fetch the metadata for a given image
  *
  * @param \TYPO3\Media\Domain\Model\Image $image
  * @return string
  */
 public function imageWithMetadataAction(\TYPO3\Media\Domain\Model\Image $image)
 {
     $thumbnail = $image->getThumbnail(500, 500);
     return json_encode(array('imageUuid' => $this->persistenceManager->getIdentifierByObject($image), 'previewImageResourceUri' => $this->resourcePublisher->getPersistentResourceWebUri($thumbnail->getResource()), 'originalSize' => array('w' => $image->getWidth(), 'h' => $image->getHeight()), 'previewSize' => array('w' => $thumbnail->getWidth(), 'h' => $thumbnail->getHeight())));
 }
 public function getResourceUri($path, $package = "Admin")
 {
     return $this->resourcePublisher->getStaticResourcesWebBaseUri() . 'Packages/' . ($package === NULL ? $this->controllerContext->getRequest()->getControllerPackageKey() : $package) . '/' . $path;
 }