Generate and output image.

@param  string  $path
@param  array   $params
@param  bool    $skipValidation
@return void
346300
public function outputImage($path, array $params = [], $skipValidation = false)
    {
        $this->validateRequest($path, $params, $skipValidation);

        $this->getLeagueGlideServer()->outputImage($path, $params);
    }
433362
public function generateFromFile($params)
    {
        if(empty($params['file']))
            throw new \Exception('Parameter \'file\' must be set' );

        $params['file'] = '@'.$params['file'];
        $params = $this->validator->validate($params);
        $this->validator->validateHtmlFile($params['file']);

        try {
            return $this->client->sendRequest('pdf', $params, 'POST');
        } catch (\Exception $ex) {
            throw $ex;
        }
    }
1034833
private function _completeItem ($path, $media, $render, $doNotMinify) {
		if (self::$fileChecking) {
			if (!$path) $this->exception('Path to *.css can\'t be an empty string.');
			if (!in_array($media, self::$_allowedMediaTypes, TRUE)) $this->exception('Media could be only values: ' . implode(', ', self::$_allowedMediaTypes) . '.');
			$duplication = $this->_isDuplicateStylesheet($path);
			if ($duplication) $this->warning("Style sheet '$path' is already added in css group: '$duplication'.");
		}
		return (object) [
			'path'			=> $path,
			'media'			=> $media,
			'render'		=> $render,
			'doNotMinify'	=> $doNotMinify,
		];
	}
950243
public function post($path, $params, $multipart = false)
    {
        return $this->ttools->makeRequest(
            TTools::API_BASE . '/' . TTools::API_VERSION . $path,
            $params,
            'POST',
            $multipart
        );
    }
456484
public function getImageResponse($path, array $params)
    {
        if (is_null($this->responseFactory)) {
            throw new InvalidArgumentException(
                'Unable to get image response, no response factory defined.'
            );
        }

        $path = $this->makeImage($path, $params);

        return $this->responseFactory->create($this->cache, $path);
    }
493990
public function run($route, $params = [])
    {
        $this->scanner->stdout('Detect JavaScriptFunction - BEGIN', Console::FG_YELLOW);
        foreach (self::$files[static::EXTENSION] as $file) {
            if ($this->containsTranslator($this->module->jsTranslators, $file)) {
                $this->extractMessages($file, [
                    'translator' => (array) $this->module->jsTranslators,
                    'begin' => '(',
                    'end' => ')',
                ]);
            }
        }

        $this->scanner->stdout('Detect JavaScriptFunction - END', Console::FG_YELLOW);
    }
87504
protected function addValidator($path, $required, Validatable $validator = null, $default = null)
    {
        $parent = &$this->validators;
        foreach (explode($this->separator, $path) as $node) {
            if (!isset($parent[$node])) {
                $parent[$node] = [];
            }
            $parent = &$parent[$node];
        }

        $parent['required'] = $required;
        $parent['validator'] = $validator;
        $parent['default'] = $default;

        $this->dirty = true;

        return $this;
    }
754895
protected function printInitMessage(
        InputInterface $input,
        OutputInterface $output,
        string $path,
        array $excludes
    ) {
        $output->writeln('# PHP Formatter');

        /*
         * Dry-run message
         */
        if ($input->getOption('dry-run')) {
            $output->writeln('# <info> This process has been executed in mode dry-run');
        }

        $output->writeln('# Executing process in ' . $path);
        foreach ($excludes as $exclude) {
            $output->writeln('#     Path excluded - ' . $exclude);
        }
    }
256635
protected function _createTar($skipRoot = false, $finalize = false)
    {
        if (!$skipRoot) {
            $this->_packAndWriteCurrentFile();
        }

        $file = $this->_getCurrentFile();

        if (is_dir($file)) {
            $dirFiles = scandir($file);

            if (false === $dirFiles) {
                throw new Mage_Exception('Can\'t scan dir: ' . $file);
            }

            array_shift($dirFiles); /* remove  './'*/
            array_shift($dirFiles); /* remove  '../'*/

            foreach ($dirFiles as $item) {
                $this->_setCurrentFile($file . $item)->_createTar();
            }
        }

        if ($finalize) {
            $this->_getWriter()->write(str_repeat("\0", self::TAR_BLOCK_SIZE * 12));
        }
    }
804675
public function xpath($path, $skipNsSanitizing = false)
    {
        try {
            if (!$skipNsSanitizing) {
                // XPath has some trouble with unqualified node names when
                // default xmlns is set.
                // try to find out if namespaces should be registered and
                // if the xpath must be sanitized (i.E. default xmlns)
                foreach ($this->getNamespaces() as $prefix => $ns) {
                    if ($prefix == '') {
                        $prefix = 'ns';
                        $path = $this->injectNsToXpathQuery($path, $prefix);
                    }

                    $this->registerXPathNamespace($prefix, $ns);
                }
            }

            $result = @parent::xpath($path);
            if ($result === false) {
                $last = error_get_last();
                $error = (isset($last['message']))? "\n" . $last['message'] : '';
                $code  = (isset($last['type']))? $last['type'] : 0;
                $xmlErrors = '';

                foreach (libxml_get_errors() as $err) {
                    $xmlErrors .= "\n" . $err->message;
                }

                $message = sprintf(
                    "Failed to process xpath \"%s\"%s%s",
                    $path, $error, $xmlErrors
                );

                throw new exception\RuntimeException($message);
            }
        } catch (exception\RuntimeException $e) {
            // Don't convert to runtime exception again
            throw $e;
        } catch (\Exception $e) {
            throw new exception\RuntimeException($e);
        }

        if (!is_array($result)) {
            $result = array();
        }

        $result = new ArrayIterator($result);
        return $result;
    }
740589
public function send(MessageInterface $message, $skipErrors = true) {
        $this->clearErrors();

        $command = $this->prepareCommand($message->getText());

        foreach ($message->getRecipient() as $recipient) {
            // execute command
            $command = str_replace('#RECIPIENT#', $recipient, $command);

            $return = 0;
            $output = [];
            exec($command, $output, $return);

            if ($return !== 0) {
                $errorMsg = sprintf("Error while sending message to \"%s\".", $recipient);
                $this->addError(new SendingError($recipient, self::ERROR_NOT_SAVED, $errorMsg));
                if (!$skipErrors) {
                    throw new RuntimeException($errorMsg, self::ERROR_NOT_SAVED);
                }
            }
        }
        return $this->getErrors()->count() === 0;
    }
414710
public function generateToJPEGImage($quality, $backgroundColor, $pathinfo, $type){
        $cacheFile = $this->owner->cacheToJPEGFilename($quality, $backgroundColor, $pathinfo);

        $backend = Injector::inst()->createWithArgs(Image::get_backend(), array(
            Director::baseFolder()."/" . $this->owner->Filename
        ));

        $backend = $backend->toJpeg($backgroundColor, $type);
        if($backend){
            $backend->setQuality($quality);
            $backend->writeTo(Director::baseFolder()."/" . $cacheFile);
        }
    }
164002
protected function validate(array &$data, array $fields = [], bool $filter_before_validate = true, array $skip = [])
    {
        static $validator;

        if (empty($fields)) {

            // No and no fields in scheme means no validation rules so we have nothing to du here
            if (empty($this->scheme['fields'])) {
                return $data;
            }

            // Use the fields list from existing scheme
            $fields = $this->scheme['fields'];
        }

        // Still no fields?
        if (empty($fields)) {
            return $data;
        }

        // Lets run our rules
        foreach ($data as $key => $val) {

            // Is this field inside the $skip array list?
            if (in_array($key, $skip)) {
                continue;
            }

            // Run possible filters before the validation process
            if ($filter_before_validate && !empty($fields[$key]['filter'])) {

                if (!is_array($fields[$key]['filter'])) {
                    $fields[$key]['filter'] = (array) $fields[$key]['filter'];
                }

                foreach ($fields[$key]['filter'] as $filter) {

                    $options = [];

                    if (is_array($filter)) {
                        $options = $filter[1];
                        $filter = $filter[0];
                    }

                    $result = filter_var($val, $filter, $options);

                    if ($result === false) {
                        $this->addError($key, sprintf($this->app->language->get('validator.filter'), $filter));
                    }
                    else {
                        $data[$key] = $result;
                    }
                }
            }

            if (empty($fields[$key]['validate'])) {
                continue;
            }

            if (empty($validator)) {
                $validator = new Validator();
            }

            if (!is_array($fields[$key]['validate'])) {
                $fields[$key]['validate'] = (array) $fields[$key]['validate'];
            }

            $validator->setValue($val);

            foreach ($fields[$key]['validate'] as $rule) {

                $validator->parseRule($rule);
                $validator->validate();

                if (!$validator->isValid()) {

                    $result = $validator->getResult();

                    if (is_array($result)) {
                        $result = vsprintf($this->app->language->get($result[0]), $result[1]);
                    }
                    else {
                        $result = $this->app->language->get($result);
                    }

                    $this->errors[$key][] = $result;
                }
            }
        }

        return $data;
    }
449341
private function watermark(array $params)
    {
        if (isset($params['posX']) && is_numeric($params['posX'])) {
            $posX = $params['posX'];
        } else {
            $posX = null;
        }

        if (isset($params['posY']) && is_numeric($params['posY'])) {
            $posY = $params['posY'];
        } else {
            $posY = null;
        }

        if (is_null($posX) || is_null($posY)) {
            throw new Exception('Wrong watermark coordinates');
        }

        if (isset($params['width']) && is_numeric($params['width'])) {
            $width = $params['width'];
        } else {
            $width = 0;
        }

        if (isset($params['height']) && is_numeric($params['height'])) {
            $height = $params['height'];
        } else {
            $height = 0;
        }

        $mode = isset($params['mode']) ? $params['mode'] : self::THUMBNAIL_OUTBOUND;

        if (isset($params['image']) && file_exists(Yii::getAlias($params['image']))) {
            $watermarkPath = Yii::getAlias($params['image']);
        } else {
            $watermarkPath = null;
        }

        if (is_null($watermarkPath)) {
            throw new Exception('Incorrect watermark image path');
        }

        $watermark = Image::getImagine()->open($watermarkPath);

        if ($this->image->getSize()->getHeight() < $posY + $watermark->getSize()->getHeight() ||
            $this->image->getSize()->getWidth() < $posX + $watermark->getSize()->getWidth()
        ) {
            throw new Exception('Cannot paste watermark of the given size at the specified position, as it moves outside of the image\'s box');
        }

        if ($width > 0 && $height > 0) {
            $height = $this->image->getSize()->getHeight();
            $width = $this->image->getSize()->getWidth();

            $watermark = $watermark->thumbnail(new Box($width, $height), $mode);
        }

        if ($posX < 0) {
            $posX = $this->image->getSize()->getWidth() - abs($posX) - $watermark->getSize()->getWidth();
        }

        if ($posY < 0) {
            $posY = $this->image->getSize()->getHeight() - abs($posY) - $watermark->getSize()->getHeight();
        }

        $position = new Point($posX, $posY);

        $this->image->paste($watermark, $position);
    }
648360
public function supprimerActualite($params = array())
    {
        if (isset($this->variablesGet['idActuSuppr']) && $this->variablesGet['idActuSuppr']!='') {
            $req = "DELETE FROM actualites WHERE idActualite = '".$this->variablesGet['idActuSuppr']."'";
            $res = $this->connexionBdd->requete($req);

            // fichiers :
            if (file_exists($this->getCheminPhysique()."images/actualites/".$this->variablesGet['idActuSuppr']."/")) {
                exec("rm -rf ".$this->getCheminPhysique()."images/actualites/".$this->variablesGet['idActuSuppr']."/* ");
            }
        }
    }
71705
public function generatePhpFile(array $functions, string $path): void
    {
        $path = rtrim($path, '/').'/';
        $phpFunctionsByModule = [];
        foreach ($functions as $function) {
            $writePhpFunction = new WritePhpFunction($function);
            $phpFunctionsByModule[$function->getModuleName()][] = $writePhpFunction->getPhpFunctionalFunction();
        }

        foreach ($phpFunctionsByModule as $module => $phpFunctions) {
            $lcModule = \lcfirst($module);
            $stream = \fopen($path.$lcModule.'.php', 'w');
            if ($stream === false) {
                throw new \RuntimeException('Unable to write to '.$path);
            }
            \fwrite($stream, "<?php\n
namespace Safe;

use Safe\\Exceptions\\".self::toExceptionName($module). ';

');
            foreach ($phpFunctions as $phpFunction) {
                \fwrite($stream, $phpFunction."\n");
            }
            \fclose($stream);
        }
    }
98501
public function applyFocusPatterns($focusPattern, $skipPattern = null)
    {
        parent::applyFocusPatterns($focusPattern, $skipPattern);

        foreach ($this->tests as $test) {
            $test->applyFocusPatterns($focusPattern, $skipPattern);
        }
    }