示例#1
0
 }
 if ($FileInfo->isFile() && $FileInfo->isReadable()) {
     $setnamematch = preg_match('/(?P<Prefix>[A-Z]+[_ -])?(?P<Name>[A-Z0-9]+)(?P<Number>\\d\\d)(?P<Suffix>[a-z])?\\.(?P<Extension>[^.]+)$/i', $FileInfo->getFilename(), $matches);
     if (isset($matches) && count($matches) > 0) {
         $Set = Set::Filter($Sets, $Model->getID(), NULL, $matches['Name'] . $matches['Number'], $matches['Prefix']);
         if (!$Set) {
             continue;
         } else {
             $Set = $Set[0];
         }
         /* @var $VideoInDB Video */
         $VideosInDB = Video::Filter($Videos, $ModelID, $Set->getID(), $matches['Name'] . $matches['Number'] . $matches['Suffix']);
         if ($VideosInDB) {
             $VideoInDB = $VideosInDB[0];
             $cis = CacheImage::Filter($CacheImages, NULL, NULL, NULL, NULL, NULL, $VideoInDB->getID());
             CacheImage::DeleteMulti($cis, $CurrentUser);
         } else {
             $VideoInDB = new Video();
             $VideoInDB->setSet($Set);
         }
         $VideoInDB->setFileName($matches['Prefix'] . $matches['Name'] . $matches['Number'] . $matches['Suffix']);
         $VideoInDB->setFileExtension($matches['Extension']);
         $VideoInDB->setFileSize($FileInfo->getSize());
         $VideoInDB->setFileCheckSum(Utils::CalculateMD5($FileInfo->getRealPath()));
         $VideoInDB->setFileCRC32(Utils::CalculateCRC32($FileInfo->getRealPath()));
         if (!$VideoInDB->getID() && $CurrentUser->hasPermission(RIGHT_VIDEO_ADD)) {
             Video::Insert($VideoInDB, $CurrentUser);
         } else {
             if ($CurrentUser->hasPermission(RIGHT_VIDEO_EDIT)) {
                 Video::Update($VideoInDB, $CurrentUser);
             }