Exemple #1
0
function getContributors( $pathToDir )
{
    $contribFiles = eZDir::recursiveFind( $pathToDir, "php" );
    $contributors = array();
    if ( count( $contribFiles ) )
    {
        foreach ( $contribFiles as $contribFile )
        {
            include_once( $contribFile );
            if ( !isset( $contributorSettings ) )
                continue;

            $tmpFiles = explode( ',', $contributorSettings['files'] );
            $updatedFiles = array();
            foreach ( $tmpFiles as $file )
            {
                if ( trim( $file ) )
                    $updatedFiles[] = trim( $file,"\n\r" );
            }
            $files = implode( ', ', $updatedFiles );
            $contributorSettings['files'] = $files;
            $contributors[] = $contributorSettings;
        }
    }
    return $contributors;
}
 function handleParameters($packageType, $package, $cli, $type, $arguments)
 {
     $fileList = array();
     $currentType = 'file';
     $currentVariableName = false;
     $currentRole = false;
     $currentRoleValue = false;
     $currentDesign = false;
     $currentCollection = 'default';
     $packagePath = false;
     if ($packageType == 'design') {
         $currentType = 'design';
     } else {
         if ($packageType == 'dir') {
             $currentType = 'dir';
         } else {
             if ($packageType == 'ini') {
                 $currentType = 'ini';
                 $currentRole = 'standard';
             } else {
                 if ($packageType == 'template') {
                     $currentType = 'design';
                     $currentRole = 'template';
                 } else {
                     if ($packageType == 'thumbnail') {
                         $currentType = 'thumbnail';
                         $currentRole = false;
                     }
                 }
             }
         }
     }
     for ($i = 0; $i < count($arguments); ++$i) {
         $argument = $arguments[$i];
         if ($argument[0] == '-') {
             if (strlen($argument) > 1 and $argument[1] == '-') {
             } else {
                 $flag = substr($argument, 1, 1);
                 if ($flag == 't' or $flag == 'r' or $flag == 'n' or $flag == 'v' or $flag == 'd' or $flag == 'p' or $flag == 'c') {
                     if (strlen($argument) > 2) {
                         $data = substr($argument, 2);
                     } else {
                         $data = $arguments[$i + 1];
                         ++$i;
                     }
                     if ($flag == 't') {
                         if (!in_array($data, array('design', 'ini', 'file', 'thumbnail'))) {
                             $cli->error("Unknown file type {$data}, allowed values are design, ini, thumbnail and file");
                             return false;
                         }
                         $currentType = $data;
                         $currentRole = false;
                         $currentDesign = false;
                         if ($currentType == 'design') {
                             $currentRole = 'template';
                             $currentDesign = 'standard';
                         }
                     } else {
                         if ($flag == 'r') {
                             if ($currentType != 'design' and $currentType != 'ini') {
                                 $cli->error("The current file type is not 'design' or 'ini' ({$currentType}), cannot set specific roles for files");
                                 return false;
                             }
                             if (!$this->roleExists($currentType, $data)) {
                                 $cli->error("Unknown file role {$data} for file type {$currentType}");
                                 return false;
                             }
                             $currentRole = $data;
                         } else {
                             if ($flag == 'v') {
                                 $currentRoleValue = $data;
                             } else {
                                 if ($flag == 'n') {
                                     $currentVariableName = $data;
                                 } else {
                                     if ($flag == 'p') {
                                         $packagePath = $data;
                                     } else {
                                         if ($flag == 'd') {
                                             if ($currentType != 'design') {
                                                 $cli->error("The current file type is not 'design' ({$currentType}), cannot set specific designs for files");
                                                 return false;
                                             }
                                             if (!$this->designExists($data)) {
                                                 $cli->error("The design {$data} does not exist");
                                                 return false;
                                             }
                                             $currentDesign = $data;
                                         } else {
                                             if ($flag == 'c') {
                                                 $currentCollection = $data;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         } else {
             $file = $argument;
             $type = $currentType;
             $role = $currentRole;
             $roleValue = $currentRoleValue;
             $design = $currentDesign;
             $realFilePath = $this->fileExists($file, $type, $role, $roleValue, $design, $triedFiles);
             if (!$realFilePath) {
                 $error = "File " . $cli->stylize('file', $file) . " does not exist\n" . "The following files were searched for:\n";
                 $files = array();
                 foreach ($triedFiles as $triedFile) {
                     $files[] = $cli->stylize('file', $triedFile);
                 }
                 $cli->output($error . implode("\n", $files));
                 return false;
             }
             $fileFileType = false;
             if (is_dir($realFilePath)) {
                 $fileFileType = 'dir';
             }
             if ($currentType == 'ini' and $fileFileType == 'dir') {
                 $iniFiles = eZDir::recursiveFind($realFilePath, "");
                 $fileFileType = 'file';
                 foreach ($iniFiles as $iniFile) {
                     $iniFile = $this->iniMatch($iniFile, $role, $roleValue, $file, $triedFiles);
                     if (!$iniFile) {
                         continue;
                     }
                     $fileList[] = array('file' => $file, 'package-path' => $packagePath, 'type' => $type, 'role' => $role, 'role-value' => $roleValue, 'variable-name' => $currentVariableName, 'file-type' => $fileFileType, 'design' => $design, 'collection' => $currentCollection, 'path' => $iniFile);
                 }
             } else {
                 $fileList[] = array('file' => $file, 'package-path' => $packagePath, 'type' => $type, 'role' => $role, 'role-value' => $roleValue, 'variable-name' => $currentVariableName, 'file-type' => $fileFileType, 'design' => $design, 'collection' => $currentCollection, 'path' => $realFilePath);
             }
             $realPath = false;
         }
     }
     if (count($fileList) == 0) {
         $cli->error("No files were added");
         return false;
     }
     return array('file-list' => $fileList);
 }
Exemple #3
0
 static function recursiveFind( $dir, $suffix )
 {
     $returnFiles = array();
     if ( $handle = @opendir( $dir ) )
     {
         while ( ( $file = readdir( $handle ) ) !== false )
         {
             if ( ( $file == "." ) || ( $file == ".." ) )
             {
                 continue;
             }
             if ( is_dir( $dir . '/' . $file ) )
             {
                 if ( $file[0] != "." )
                 {
                     $files = eZDir::recursiveFind( $dir . '/' . $file, $suffix );
                     $returnFiles = array_merge( $files, $returnFiles );
                 }
             }
             else
             {
                 if ( preg_match( "/$suffix$/", $file ) )
                     $returnFiles[] = $dir . '/' . $file;
             }
         }
         @closedir( $handle );
     }
     return $returnFiles;
 }