Пример #1
0
 function appendFile($file, $type, $role, $design, $filePath, $collection, $subDirectory = null, $md5 = null, $copyFile = false, $modified = null, $fileType = false, $roleValue = false, $variableName = false, $packagePath = false)
 {
     if (!$collection) {
         $collection = 'default';
     }
     if ($subDirectory === null) {
         $subDirectory = false;
         if (preg_match('#^(.+)/([^/]+)$#', $file, $matches)) {
             $subDirectory = $matches[1];
             $file = $matches[2];
         }
     }
     if ($packagePath) {
         $subDirectory = $packagePath;
     }
     $fileItem = array('name' => $file, 'subdirectory' => $subDirectory, 'type' => $type, 'role' => $role, 'role-value' => $roleValue, 'variable-name' => $variableName, 'path' => $filePath, 'file-type' => $fileType, 'design' => $design);
     if ($md5 === null) {
         $md5 = $this->md5sum($filePath);
     }
     $fileItem['md5'] = $md5;
     $this->Parameters['file-list'][$collection][] = $fileItem;
     if ($copyFile) {
         // copying file
         $typeDir = $type;
         if ($type == 'design') {
             $typeDir .= '.' . $fileItem['design'];
         }
         if ($role) {
             $typeDir .= '.' . $role;
             if ($roleValue) {
                 $typeDir .= '-' . $roleValue;
             }
         }
         $path = $this->path() . '/' . eZPackage::filesDirectory() . '/' . $collection . '/' . $typeDir;
         if ($subDirectory) {
             $path .= '/' . $subDirectory;
         }
         if (!file_exists($path)) {
             eZDir::mkdir($path, false, true);
         }
         if (is_dir($fileItem['path'])) {
             eZDir::copy($fileItem['path'], $path, $fileItem['name'] != false, true, false, eZDir::temporaryFileRegexp());
         } else {
             eZFileHandler::copy($fileItem['path'], $path . '/' . $fileItem['name']);
         }
     }
 }