/* (non-PHPdoc)
@see CrudGenerator\Generators\Strategies.StrategyInterface::generateFile()
555489
public function generateFile(array $datas, $skeletonDir, $pathTemplate, $target)
    {
        return $this->view->render(
            $skeletonDir,
            $pathTemplate,
            $datas
        );
    }
982632
protected function _generateFiles() {
        $this->generateFilesForArtifacts($this->selectedArtifacts, "getFileSettingsForSelected", false);
        $this->generateFilesForArtifacts($this->deselectedArtifacts, "getFileSettingsForDeselected", false);
        
        $this->generateFilesForArtifacts($this->selectedArtifacts, "getFileSettingsForSelected", true);
        $this->generateFilesForArtifacts($this->deselectedArtifacts, "getFileSettingsForDeselected", true);

        foreach ($this->extendableFiles as $extendableFile)
            $this->files[] = $extendableFile;
    }
263966
public function generateFiles() {
        $files = $this->getGeneratorElements("generateFiles");
        $files = fphp\Helper\_Array::assertNoDuplicates($files, "getTarget");
        $files = fphp\Helper\_Array::sortByKey($files, "getTarget");
        return $files;
    }
832764
public function generate()
    {
        $version = date('YmdHis');

        $this->_generateMigrationFile($version);
        print PHP_EOL . Color::success('Version ' . $version . ' was successfully generated') . PHP_EOL;
    }
1196045
public function generate($destinationDirectory)
    {
        $destinationDirectory = $destinationDirectory;

        $generatedPaths = [];

        $this->resolveAutomaticallyIgnoredPaths($destinationDirectory);

        foreach ($this->getPaths() as $pathKey => $path) {
            $fullPath = $destinationDirectory . DIRECTORY_SEPARATOR . $path['path'];

            if (!$this->shouldBeIgnored($path['path'])) {
                if ($path['type'] == 'dir') {
                    $this->fileSystem->makeDirectory($fullPath, 0755, true, true);
                } else {
                    // There are two steps here:
                    // 1st: Recursively create the directory structure for the file (it might not exist)
                    // 2nd: Create an empty file using `touch()` since we are guaranteed the directory structure exists.
                    $this->fileSystem->makeDirectory(dirname($fullPath), 0755, true, true);
                    touch($fullPath);
                }

                $generatedPaths[$pathKey] = ($path + ['full' => $fullPath]);
            }
        }

        $this->removeFilesAndDirectories($destinationDirectory);

        return $generatedPaths;
    }
783119
public function generate()
    {
        if (false === file_exists($this->filename) || false === is_file($this->filename)) {
            throw new FileNotFoundException(sprintf('The file "%s" does not exist.', $this->filename));
        }

        $handle = fopen($this->filename, 'r');
        if (false === $handle) {
            throw new \RuntimeException(sprintf('Could not open file "%s".', $this->filename));
        }

        $header = $this->getCsv($handle);
        $parameters = [];
        while ($values = $this->getCsv($handle)) {
            $parameter = [];
            foreach ($values as $index => $value) {
                if (null === $this->parameters || true === in_array($header[$index], $this->parameters)) {
                    $parameter[$header[$index]] = $value;
                }
            }
            $parameters[] = $parameter;
        }

        return $parameters;
    }
360470
protected function generate()
    {
        foreach ($this->listFiles as $key => $file) {
            $filePath = $this->makeFilePath($this->listFolders[$key], $this->data['name']);

            $this->resolveByPath($filePath);

            $file = $this->formatContent($file);

            //
            $find = basename($filePath);

            $filePath = strrev(preg_replace(strrev("/$find/"), '', strrev($filePath), 1));

            $filePath = $filePath .$file;

            if ($this->files->exists($filePath)) {
                return $this->error($this->type .' already exists!');
            }

            $this->makeDirectory($filePath);

            foreach ($this->signOption as $option) {
                if ($this->option($option)) {
                    $stubFile = $this->listStubs[$option][$key];

                    $this->resolveByOption($this->option($option));

                    break;
                }
            }

            if (! isset($stubFile)) {
                $stubFile = $this->listStubs['default'][$key];
            }

            $this->files->put($filePath, $this->getStubContent($stubFile));
        }

        return $this->info($this->type.' created successfully.');
    }
199170
public function generateKeyFile()
    {
        $this->output->outputLine();

        if ( file_exists($this->createFilePath([$this->localBackupTarget, 'key'])) ) {
            $this->output->outputLine('<b>You have already a keyfile!</b>');
            $this->output->outputLine('If you generate a new one, all existing Backups are worthless.');
            $this->output->outputLine();
            $this->output->outputLine('Call \'./flow backup:clear --force\' to delete all Backups and the Keyfile.');
            $this->output->outputLine();
            return;
        }

        $this->output->outputLine('<b>Generate a new Crypto Key</b>');
        $this->output->outputLine();

        $this->files->createDirectoryRecursively($this->localBackupTarget);

        try {
            $key = \Crypto::createNewRandomKey();
            file_put_contents($this->createFilePath([$this->localBackupTarget, 'key']), $key);
            // WARNING: Do NOT encode $key with bin2hex() or base64_encode(),
            // they may leak the key to the attacker through side channels.
        } catch (Ex\CryptoTestFailedException $ex) {
            die('Cannot safely create a key');
        } catch (Ex\CannotPerformOperationException $ex) {
            die('Cannot safely create a key');
        }

        $this->output->outputLine('done');
        $this->output->outputLine();

    }
1018289
public function generate()
	{
		$arrOptions = array();
		$strClass = 'tl_select';
		$strStyle = '<style>.group-result {padding-top: 5px !important; line-height: 20px !important;}';
		$count = 1;

		if ($this->multiple)
		{
			$this->strName .= '[]';
			$strClass = 'tl_mselect';
		}

		// Add an empty option (XHTML) if there are none
		if (empty($this->arrOptions))
		{
			$this->arrOptions = array(array('value'=>'', 'label'=>'-'));
		}
		
		foreach ($this->arrOptions as $strKey=>$arrOption)
		{
			if (isset($arrOption['value']))
			{
				$arrOptions[] = sprintf('<option value="%s"%s>%s</option>',
										 \StringUtil::specialchars($arrOption['value']),
										 $this->isSelected($arrOption),
										 $arrOption['label']);

				if (isset($GLOBALS['TL_CTB_IMG'][$arrOptgroup['value']]))
				{
					$objImage = \FilesModel::findByUuid($GLOBALS['TL_CTB_IMG'][$arrOptgroup['value']]);
				}
				
				if ($objImage === null)
				{
					$strStyle .= '#ctrl_type_chzn_o_'.$count.' {position: relative; padding-left: 90px; line-height: 41px;}#ctrl_type_chzn_o_'.$count++.'::before {content: ""; position: absolute; left: 20px; top:2px; width: 60px; height: 40px; border: 1px solid #ccc; background: #eee; background-size: 60px 40px;}';
				}
				else
				{
					$strStyle .= '#ctrl_type_chzn_o_'.$count.' {position: relative; padding-left: 90px; line-height: 41px;}#ctrl_type_chzn_o_'.$count++.'::before {content: ""; position: absolute; left: 20px; top:2px; width: 60px; height: 40px; border: 1px solid #ccc; background: #eee url('.$objImage->path.'); background-size: 60px 40px;}';
				}
			}
			else
			{
				$arrOptgroups = array();

				foreach ($arrOption as $arrOptgroup)
				{
					$arrOptgroups[] = sprintf('<option value="%s"%s>%s</option>',
											   \StringUtil::specialchars($arrOptgroup['value']),
											   $this->isSelected($arrOptgroup),
											   $arrOptgroup['label']);

					if (isset($GLOBALS['TL_CTB_IMG'][$arrOptgroup['value']]))
					{
						$objImage = \FilesModel::findByUuid($GLOBALS['TL_CTB_IMG'][$arrOptgroup['value']]);
					}

					if ($objImage === null)
					{
						$strStyle .= '#ctrl_type_chzn_o_'.$count.' {position: relative; padding-left: 90px; line-height: 41px;}#ctrl_type_chzn_o_'.$count++.'::before {content: ""; position: absolute; left: 20px; top:2px; width: 60px; height: 40px; border: 1px solid #ccc; background: #eee; background-size: 60px 40px;}';
					}
					else
					{
						$strStyle .= '#ctrl_type_chzn_o_'.$count.' {position: relative; padding-left: 90px; line-height: 41px;}#ctrl_type_chzn_o_'.$count++.'::before {content: ""; position: absolute; left: 20px; top:2px; width: 60px; height: 40px; border: 1px solid #ccc; background: #eee url('.$objImage->path.'); background-size: 60px 40px;}';
					}

				}

				$arrOptions[] = sprintf('<optgroup label="&nbsp;%s">%s</optgroup>', \StringUtil::specialchars($strKey), implode('', $arrOptgroups));
				$count++;
			}
		}

		// Chosen
		if ($this->chosen)
		{
			$strClass .= ' tl_chosen';
		}


		$strStyle .= '</style>';
	
		return sprintf('%s<select name="%s" id="ctrl_%s" class="%s%s"%s onfocus="Backend.getScrollOffset()">%s</select>%s',
						($this->multiple ? '<input type="hidden" name="'. rtrim($this->strName, '[]') .'" value="">' : ''),
						$this->strName,
						$this->strId,
						$strClass,
						(($this->strClass != '') ? ' ' . $this->strClass : ''),
						$this->getAttributes(),
						implode('', $arrOptions),
						$strStyle);
	}
961782
public function generate()
    {
        $return = '';

        if (empty($this->thumbnailSize)) {
            $this->thumbnailSize = [
                Config::get('imageWidth'),
                Config::get('imageHeight'),
                'box',
            ];
        }

        $file = FilesModel::findByPk($this->varValue);
        if (null === $file && null !== $this->fallbackImage) {
            $file = FilesModel::findByPk($this->fallbackImage);
        }
        if (null !== $file) {
            $altTag = $file->name;
            $size   = deserialize($this->thumbnailSize);
            $image  = Image::create($file->path, $size)->executeResize();

            $return .= sprintf(
                '<img src="%s" width="%s" height="%s" alt="%s" class="uploaded-image">',
                $image->getResizedPath(),
                $image->getTargetWidth(),
                $image->getTargetHeight(),
                $altTag
            );
        }

        if ($this->addMetaWizard) {
//@todo add meta wizard here
        }

        $return .= parent::generate();

        if ($this->enableReset) {
            $return .= sprintf(
                '<input type="checkbox" name="%s" class="checkbox" value=""><label>%s</label> ',
                $this->strName.'_reset',
                'Reset'
            );
        }

        return $return;
    }
753376
public function generate()
    {
        if (false === file_exists($this->filename) || false === is_file($this->filename)) {
            throw new FileNotFoundException(sprintf('The file "%s" does not exist.', $this->filename));
        }

        $yaml = Yaml::parse($this->filename);
        $parameters = [];

        for ($i = 0; $i < count($yaml); $i++) {
            $parameter = [];
            foreach ($yaml[$i] as $key => $value) {
                if (null === $this->parameters || true === in_array($key, $this->parameters)) {
                    $parameter[$key] = $value;
                }
            }
            $parameters[] = $parameter;
        }

        return $parameters;
    }
1096073
public function generateExtension($file = null)
    {
        if (is_string($file)) {
            if (in_array($file, $this->acceptedMimetypes())) {
                $mime = $file;
            } else {
                $mime = $this->mimetypeFor($file);
            }
        } else {
            $mime = $this->mimetype();
        }

        switch ($mime) {
            case 'image/gif':
                return 'gif';

            case 'image/jpg':
            case 'image/jpeg':
            case 'image/pjpeg':
                return 'jpg';

            case 'image/png':
                return 'png';

            case 'image/svg+xml':
                return 'svg';

            case 'image/webp':
                return 'webp';
        }
    }
1266890
public function generate() {
		$output_path = $this->timestampedFileName( 'pdf' );
		$success = $this->generateWithPrince( $this->pdfProfile, $this->pdfOutputIntent, $this->generateHtml(), $output_path );
		if ( true !== $success ) {
			throw new \Exception( 'Failed to create PDF file' );
		}
		delete_transient( 'dirsize_cache' ); /** @see get_dirsize() */
		return $output_path;
	}
834220
protected function generateFileHeader()
    {
        $shipping_file = $this->shipping_file;
        $assignment = $shipping_file->assignment;
        $assignor_person = $assignment->assignor->person;
        $bank = $assignment->bank;

        $format = '%03.3s%04.4s%01.1s%-9.9s%01.1s%014.14s%020.20s%05.5s%-1.1s'
            . '%012.12s%-1.1s%-1.1s%-30.30s%-30.30s%-10.10s%01.1s%08.8s%06.6s'
            . '%06.6s%03.3s%05.5s%-20.20s%-20.20s%-29.29s';

        $data = [
            $bank->code,
            '0',
            '0',
            '',
            $assignor_person->getDocumentType(),
            $assignor_person->document,
            $assignment->covenant,
            '0', // $assignment->agency,
            '',
            '0', // $assignment->account,
            '',
            '',
            Utils::cleanSpaces($assignor_person->name),
            $bank->name,
            '',
            '1',
            static::date('dmY', $shipping_file->stamp),
            static::date('His', $shipping_file->stamp),
            $shipping_file->counter,
            static::VERSION_FILE_LAYOUT,
            '0',
            '',
            $shipping_file->notes,
            '',
        ];

        return vsprintf($format, static::normalize($data));
    }
502924
protected function generateCacheFile($file)
    {
        $cacheSalt = serialize(array(
            $this->request->options,
            MUNEE_USING_URL_REWRITE,
            MUNEE_DISPATCHER_FILE
        ));
        $params = serialize($this->request->params);
        $ext = pathinfo($file, PATHINFO_EXTENSION);

        $fileHash = md5($file);
        $optionsHash = md5($params . $cacheSalt);

        $cacheDir = $this->cacheDir . DS . substr($fileHash, 0, 2);

        Utils::createDir($cacheDir);

        return $cacheDir . DS . substr($fileHash, 2) . '-' . $optionsHash . '.' . $ext;
    }
850447
private function generateAbstractFile(HttpFile $file, AbstractFile $tunaFile)
    {
        $filename = $this->generateTmpFilename($file);
        $this->fs->copy($file->getRealPath(), $this->getFullTmpPath($filename));

        return $tunaFile->setPath($filename);
    }
292976
public function compile($outputfile)
    {
        if (empty($this->index)) {
            throw new \LogicException('Cannot compile when no index files are defined.');
        }

        if (file_exists($outputfile)) {
            unlink($outputfile);
        }

        $name = basename($outputfile);
        $phar = new \Phar($outputfile, 0, $name);
        $phar->setSignatureAlgorithm(\Phar::SHA1);
        $phar->startBuffering();

        foreach ($this->files as $virtualfile => $fileinfo) {
            list($realfile, $strip) = $fileinfo;
            $content = file_get_contents($realfile);

            if ($strip) {
                $content = $this->stripWhitespace($content);
            }

            $phar->addFromString($virtualfile, $content);
        }

        foreach ($this->index as $type => $fileinfo) {
            list($virtualfile, $realfile) = $fileinfo;
            $content = file_get_contents($realfile);

            if ($type == 'cli') {
                $content = preg_replace('{^#!/usr/bin/env php\s*}', '', $content);
            }

            $phar->addFromString($virtualfile, $content);
        }

        $stub = $this->generateStub($name);
        $phar->setStub($stub);

        $phar->stopBuffering();
        unset($phar);
    }