/** * Determines if the given collection can be handled by this plugin * * @param \Hubzero\Filesystem\Collection $collection The file collection to assess * @return void **/ public function canHandle(\Hubzero\Filesystem\Collection $collection) { $need = ['tex' => 1]; // Check extension to make sure we can proceed if (!$collection->hasExtensions($need)) { return false; } return true; }
/** * Determines if the given collection can be handled by this plugin * * @param \Hubzero\Filesystem\Collection $collection The file collection to assess * @return void **/ public function canHandle(\Hubzero\Filesystem\Collection $collection) { // Do we have everything we need? $need = ['json' => '1', 'videos' => function ($ext, $files) { // If we dont have all the necessary media formats if (array_key_exists('mp4', $ext)) { // We have a video, and we also need an ogv and a webm if (!array_key_exists('ogv', $ext) || !array_key_exists('webm', $ext)) { return false; } } else { if (array_key_exists('mp3', $ext)) { if (!array_key_exists('ogg', $ext)) { return false; } } } }, 'slideVideos' => function ($ext, $files) use($collection) { // See if we even have a slides directory if ($slides = $collection->find('slides')) { $slides = $slides->listContents(); // Array to hold slides with video clips $slideVideos = []; // Build array for checking slide video formats foreach ($slides as $s) { if ($s->isFile()) { $extension = $s->getExtension(); if (in_array($extension, array('mp4', 'm4v', 'webm', 'ogv'))) { $slideVideos[$s->getDisplayName()][$extension] = $s->getName(); } } } // Make sure for each of the slide videos we have all three formats and has a backup image for the slide foreach ($slideVideos as $k => $v) { if (count($v) < 3) { return false; } if (!$slides->has($k . '.png') && !$slides->has($k . '.jpg')) { return false; } } } }]; if (!$collection->hasExtensions($need)) { return false; } return true; }
/** * Sorts incoming file/folder data * * @return array */ private function getCollection() { // Incoming $files = $this->prune((array) Request::getVar('asset', [])); $directories = $this->prune((array) Request::getVar('folder', [])); $collection = new Collection(); $entities = array_merge($files, $directories); if (!empty($entities) && is_array($entities)) { foreach ($entities as $entity) { $path = trim($this->subdir, '/') . '/' . urldecode($entity); $collection->add(Entity::fromPath($path, $this->connection->adapter())); } } return $collection; }
/** * Sorts incoming file/folder data * * @return array */ private function getCollection() { // Incoming $files = $this->prune((array) Request::getVar('asset', [])); $directories = $this->prune((array) Request::getVar('folder', [])); $collection = new Collection(); $entities = array_merge($files, $directories); if (!empty($entities) && is_array($entities)) { foreach ($entities as $entity) { if (count(explode('/', $entity)) > 1) { $path = urldecode($entity); } else { $path = trim($this->subdir, '/') . '/' . urldecode($entity); } $file = Entity::fromPath($path, $this->connection->adapter()); if (!$file->exists()) { $view->setError(Lang::txt('Failed to find the file at ' . $path)); return $collection; } $collection->add(Entity::fromPath($path, $this->connection->adapter())); } } return $collection; }