Ejemplo n.º 1
0
 /**
  *
  * @param array $files
  * @param array $names Array of indexes of $files array representing current nesting level. E.g. if we are iterating over $files[k1][k2] then $names=[k1,k2]
  */
 private function processFiles(array $files, array $names = [])
 {
     foreach ($files as $name => $controlValue) {
         $names[] = $name;
         // MFU sends data in this format:
         //
         // array(
         //	"token" => "blablabla",
         //	"files" => array(
         //		0 => FileUpload(...),
         //		...
         //	)
         // )
         // expanded POST array with $names indexes
         $postFromHttpRequest = $this->httpRequest->getPost();
         $postArr = Arrays::getRef($postFromHttpRequest, $names);
         $isFormMFU = (is_array($controlValue) and isset($controlValue["files"]) and isset($postArr['token']));
         if ($isFormMFU) {
             $token = $postArr["token"];
             foreach ($controlValue["files"] as $file) {
                 self::processFile($token, $file);
             }
             // support for nested Nette\Forms\Container
         } elseif (is_array($controlValue)) {
             $this->processFiles($controlValue, $names);
         }
         // skip files not processed by MFU
         // they will be processed by Nette Forms
     }
 }
Ejemplo n.º 2
0
 /**
  * @param array $cookies
  */
 private function parse(array $cookies)
 {
     foreach ($cookies as $raw) {
         if (!($cookie = static::readCookie($raw))) {
             continue;
         }
         if (isset($cookie['expires']) && \DateTime::createFromFormat(static::COOKIE_DATETIME, $cookie['expires']) < date_create()) {
             continue;
             // cookie already expired
         }
         if (strpos($name = $cookie['name'], '[') === FALSE) {
             $this->{$name} = $cookie['value'];
         } else {
             $keys = explode('[', str_replace(']', '', $name));
             $cookieValue =& Arrays::getRef($arr =& $this->{array_shift($keys)}, $keys);
             $cookieValue = $cookie['value'];
             unset($cookieValue);
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * @param array
  * @param array
  * @param callable
  * @return mixed
  */
 public static function callOnRef(&$arr, $key, $callback)
 {
     if (!is_callable($callback, TRUE)) {
         throw new JedenWeb\InvalidArgumentException("Invalid callback.");
     }
     return $callback(Nette\Utils\Arrays::getRef($arr, $key));
 }