Example #1
0
 /**
  * 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;
 }
Example #2
0
 /**
  * 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;
 }