Load data from a CSV (or similar) data source
@param string $FileName
@param array $Options
196126
public function importFromCSV($FileName, array $Options = [])
    {
        $Delimiter = isset($Options["Delimiter"]) ? $Options["Delimiter"] : ",";
        $GotHeader = isset($Options["GotHeader"]) ? $Options["GotHeader"] : false;
        $SkipColumns = isset($Options["SkipColumns"]) ? $Options["SkipColumns"] : [-1];
        $DefaultSerieName = isset($Options["DefaultSerieName"]) ? $Options["DefaultSerieName"] : "Serie";

        $Handle = @fopen($FileName, "r");
        if ($Handle) {
            $HeaderParsed = false;
            $SerieNames = [];
            while (!feof($Handle)) {
                $Buffer = fgets($Handle, 4096);
                $Buffer = str_replace(chr(10), "", $Buffer);
                $Buffer = str_replace(chr(13), "", $Buffer);
                $Values = preg_split("/" . $Delimiter . "/", $Buffer);

                if ($Buffer != "") {
                    if ($GotHeader && !$HeaderParsed) {
                        foreach ($Values as $Key => $Name) {
                            if (!in_array($Key, $SkipColumns)) {
                                $SerieNames[$Key] = $Name;
                            }
                        }
                        $HeaderParsed = true;
                    } else {
                        if (!count($SerieNames)) {
                            foreach ($Values as $Key => $Name) {
                                if (!in_array($Key, $SkipColumns)) {
                                    $SerieNames[$Key] = $DefaultSerieName . $Key;
                                }
                            }
                        }
                        foreach ($Values as $Key => $Value) {
                            if (!in_array($Key, $SkipColumns)) {
                                $this->addPoints($Value, $SerieNames[$Key]);
                            }
                        }
                    }
                }
            }
            fclose($Handle);
        }
    }
201729
public function provide($data = null, array $options = [])
    {
        $field = $this->config->getField();
        $table = $this->config->getTable();

        $fieldName = $table->aliasField($field);

        $entities = null;
        if (!empty($data)) {
            $fileUpload = new FileUpload($table);
            $entities = $fileUpload->getFiles($field, $data);
        }

        $params = [
            'field' => $field,
            'name' => $fieldName,
            'type' => 'file',
            'label' => $options['label'],
            'required' => $options['fieldDefinitions']->getRequired(),
            'value' => $data,
            'entities' => $entities,
            'table' => Inflector::dasherize($table->getAlias()),
        ];

        $defaultElement = 'CsvMigrations.FieldHandlers/FilesFieldHandler/input';
        $element = empty($options['element']) ? $defaultElement : $options['element'];

        return $this->renderElement($element, $params);
    }
1133761
private static function loadFromPhpFile($filename)
	{
		$source = file_get_contents($filename);
		$tokens = token_get_all($source);
		$skipTokens = array(T_COMMENT, T_DOC_COMMENT);
		$props = array('$version', '$kernel', '$title', '$description');

		$info = new self;
		$state = null;

		foreach ($tokens as $token)
		{
			if (is_array($token))
			{
				list($id, $text) = $token;
				if (in_array($id, $skipTokens))
				{
					continue;
				}
				switch (true)
				{
					case T_CLASS == $id && null === $state:
						$state = 'class_name';
					break;

					case T_STRING == $id && 'class_name' == $state && trim($text) != '':
						$info->name = basename($filename, '.php');
						$state = 'prop_name';
					break;

					case T_VARIABLE == $id && 'prop_name' == $state && in_array($text, $props):
						$property = substr($text, 1);
						$state = 'prop_value';
					break;

					case T_CONSTANT_ENCAPSED_STRING == $id && 'prop_value' == $state:
						if (isset($property))
						{
							$value = substr($text, 1, -1);
							if ('kernel' == $property)
							{
								$value = explode('/', $value);
								$info->requiredKernel = array(
									$value[0],
									isset($value[1]) ? $value[1] : null
								);
							}
							else
							{
								$info->$property = $value;
							}
						}
						$state = 'prop_name';
					break;
				}
			}
		}
		return $info;
	}
906588
public function attachData($data, $options=[]) {
		$attachment = \Swift_Attachment::newInstance($data);
		if(isset($options['filename']))
			$attachment->setFilename($options['filename']);
		if(isset($options['mime']))
			$attachment->setContentType($options['mime']);
		return $this->attach($attachment);
	}
575521
public function loadXML($source, $options = null)
    {
        return $source ? parent::loadXML($this->iso2utf($source), $options) : false;
    }
867659
public static function file($name, $options = [])
    {
        self::exclure($options);

        return self::input('file', $name, null, $options);
    }
1353985
public function download($file, $filename = '', $options = array())
    {
        $this->response->download($file, $filename, $options);
    }
1296090
private function loadConfig($fileName) {
		$config = include($this->path . DIRECTORY_SEPARATOR . $fileName . '.php');
		
		$this->map[$fileName] = $config;
	}
270000
public function load($filename)
    {
        $json = file_get_contents($filename);
        if (false === $json) {
            throw new \RuntimeException("Unable to load file {$filename}");
        } elseif ($json === '') {
            return;
        }

        $data = \GuzzleHttp\json_decode($json, true);
        if (is_array($data)) {
            foreach (json_decode($json, true) as $cookie) {
                $this->setCookie(new SetCookie($cookie));
            }
        } elseif (strlen($data)) {
            throw new \RuntimeException("Invalid cookie file: {$filename}");
        }
    }
1349385
public function stream($filename = "document.pdf", $options = array())
    {
        if (headers_sent()) {
            die("Unable to stream pdf: headers already sent");
        }

        if (!isset($options["compress"])) $options["compress"] = true;
        if (!isset($options["Attachment"])) $options["Attachment"] = true;

        $this->_add_page_text();

        $debug = !$options['compress'];
        $tmp = ltrim($this->_pdf->output($debug));

        header("Cache-Control: private");
        header("Content-Type: application/pdf");
        header("Content-Length: " . mb_strlen($tmp, "8bit"));

        $filename = str_replace(array("\n", "'"), "", basename($filename, ".pdf")) . ".pdf";
        $attachment = $options["Attachment"] ? "attachment" : "inline";
        header(Helpers::buildContentDispositionHeader($attachment, $filename));

        echo $tmp;
        flush();
    }
850933
public function file($name, array $options = [])
    {
        return $this->form->file($name, $this->addFormControlClass($this->getFieldOptions($name, $options)));
    }
793860
public function addColumn($columnName, $typeName, array $options = [])
    {
        $column = new Column($columnName, Type::getType($typeName), $options);

        $this->_addColumn($column);

        return $column;
    }
858140
public function importFromArray(array $options)
    {
        foreach ($options as $key => $value) {
            switch (true) {
                case $key === 'args':
                    $this->args = $value;
                    break;
                case is_integer($key):
                    $this->args[] = $value;
                    break;
                default:
                    $this->options[$key] = $value;
                    break;
            }
        }
    }
662355
public function load($file, array $options = [])
    {
        if ($this->getDefault($options, self::SIMPLEXML, false)) {
            return $this->loadSimpleXml($file, $options);
        }

        return $this->loadDom($file, $options);
    }
311533
public function insert(array $data, array $options = []) {
		return $this->getAdapter()->insert(
			$this->getTableName(),
			$data,
			$options
		);
	}
850873
public function getData(Options $options = null)
    {
        if ($options === null) {
            // Take store global/default options
            $options = $this->store->getOptions();
        }

        // TODO - TEST database connection charset !!!
        //

        ini_set('default_charset', 'UTF-8');

        if (PHP_VERSION_ID < 50600) {
            iconv_set_encoding('internal_encoding', 'UTF-8');
        }

        /*
          $backup_encoding = iconv_get_encoding("internal_encoding");
          iconv_set_encoding("internal_encoding", "UTF-8");
          iconv_set_encoding("input_encoding", "UTF-8");
          iconv_set_encoding("output_encoding", "UTF-8");
          mb_internal_encoding("UTF-8");
         */

        $internal_encoding = strtoupper(ini_get('default_charset'));
        $charset = strtoupper($this->options['charset']);

        $csv = '';

        // Get unformatted data when using csv writer
        $options->getHydrationOptions()->disableFormatters();
        $data = $this->store->getData($options)->toArray();

        if (strtoupper($this->options['charset']) !== $charset && !function_exists('iconv')) {
            throw new Exception\RuntimeException('CSV writer requires iconv extension');
        }

        $iconv_output_charset = $this->options['charset'];
        if ($this->options['ignore_translit_error']) {
            $iconv_output_charset .= '//TRANSLIT//IGNORE';
        }

        if (count($data) === 0) {
            $columns = $this->store->getColumnModel()->getColumns();
            $header_line = implode($this->options['field_separator'], array_keys((array) $columns));
            $csv .= $header_line . $this->options['line_separator'];
        } else {
            $header_line = implode($this->options['field_separator'], array_keys($data[0]));
            $csv .= $header_line . $this->options['line_separator'];

            foreach ($data as $row) {
                switch ($this->options['field_separator']) {
                    case self::SEPARATOR_TAB:
                        array_walk($row, [$this, 'escapeTabDelimiter']);
                        break;
                    default:
                        array_walk($row, [$this, 'escapeFieldDelimiter']);
                }

                array_walk($row, [$this, 'escapeLineDelimiter']);

                if ($this->options['enclosure'] !== '') {
                    array_walk($row, [$this, 'addEnclosure']);
                }

                $line = implode($this->options['field_separator'], $row);

                if ($charset !== $internal_encoding) {
                    $l = (string) $line;
                    if ($l !== '') {
                        $l = @iconv($internal_encoding, $iconv_output_charset, $l);
                        if ($l === false || strlen($l) === 0) {
                            throw new Exception\CharsetConversionException("Cannot convert the charset to '" . $this->options['charset'] . "' from charset '$internal_encoding', using '$iconv_output_charset' value: '$line'.");
                        } else {
                            $line = $l;
                        }
                    }
                }

                $csv .= $line . $this->options['line_separator'];
            }
        }

        return $csv;
    }
877112
public static function serve($filename, $contentType, $options)
    {
        $options = array_merge(self::$defaultOptions, $options);

        if ($options['set-last-modified-header'] === true) {
            Header::setHeader("Last-Modified: " . gmdate("D, d M Y H:i:s", @filemtime($filename)) ." GMT");
        }

        if ($options['set-content-type-header'] === true) {
            Header::setHeader('Content-type: ' . $contentType);
        }

        if ($options['add-vary-accept-header'] === true) {
            Header::addHeader('Vary: Accept');
        }

        if ($options['set-cache-control-header'] === true) {
            if (!empty($options['cache-control-header'])) {
                Header::setHeader('Cache-Control: ' . $options['cache-control-header']);

                // Add exprires header too (#126)
                // Check string for something like this: max-age:86400
                if (preg_match('#max-age\\s*=\\s*(\\d*)#', $options['cache-control-header'], $matches)) {
                    $seconds = $matches[1];
                    Header::setHeader('Expires: '. gmdate('D, d M Y H:i:s \G\M\T', time() + intval($seconds)));
                }
            }
        }

        if (@readfile($filename) === false) {
            Header::addHeader('X-WebP-Convert-Error: Could not read file');
            throw new ServeFailedException('Could not read file');
        }
    }