コード例 #1
0
ファイル: ImageButton.php プロジェクト: JPalounek/IconStore
 /**
  * Loads HTTP data.
  * @return void
  */
 public function loadHttpData()
 {
     $path = $this->getHtmlName();
     // img_x or img['x']
     $path = explode('[', strtr(str_replace(']', '', strpos($path, '[') === FALSE ? $path . '.x' : substr($path, 0, -2)), '.', '_'));
     $this->setValue(Nette\ArrayTools::get($this->getForm()->getHttpData(), $path) !== NULL);
 }
コード例 #2
0
ファイル: FormControl.php プロジェクト: redhead/nette
	/**
	 * Loads HTTP data.
	 * @return void
	 */
	public function loadHttpData()
	{
		$path = explode('[', strtr(str_replace(array('[]', ']'), '', $this->getHtmlName()), '.', '_'));
		$this->setValue(Nette\ArrayTools::get($this->getForm()->getHttpData(), $path));
	}
コード例 #3
0
ファイル: Form.php プロジェクト: JanTvrdik/nette
 /**
  * Internal: receives submitted HTTP data.
  * @return array
  */
 protected function receiveHttpData()
 {
     $httpRequest = $this->getHttpRequest();
     if (strcasecmp($this->getMethod(), $httpRequest->getMethod())) {
         return;
     }
     if ($httpRequest->isMethod('post')) {
         $data = Nette\ArrayTools::mergeTree($httpRequest->getPost(), $httpRequest->getFiles());
     } else {
         $data = $httpRequest->getQuery();
     }
     if ($tracker = $this->getComponent(self::TRACKER_ID, FALSE)) {
         if (!isset($data[self::TRACKER_ID]) || $data[self::TRACKER_ID] !== $tracker->getValue()) {
             return;
         }
     }
     return $data;
 }
コード例 #4
0
ファイル: AppForm.php プロジェクト: jff15/travelbot
 /**
  * Internal: receives submitted HTTP data.
  * @return array
  */
 protected function receiveHttpData()
 {
     $presenter = $this->getPresenter();
     if (!$presenter->isSignalReceiver($this, 'submit')) {
         return;
     }
     $isPost = $this->getMethod() === self::POST;
     $request = $presenter->getRequest();
     if ($request->isMethod('forward') || $request->isMethod('post') !== $isPost) {
         return;
     }
     if ($isPost) {
         return Nette\ArrayTools::mergeTree($request->getPost(), $request->getFiles());
     } else {
         return $request->getParams();
     }
 }
コード例 #5
0
ファイル: ConfigAdapterIni.php プロジェクト: Balvan/nette
 /**
  * Reads configuration from INI file.
  * @param  string  file name
  * @param  string  section to load
  * @return array
  * @throws \InvalidStateException
  */
 public static function load($file, $section = NULL)
 {
     if (!is_file($file) || !is_readable($file)) {
         throw new \FileNotFoundException("File '{$file}' is missing or is not readable.");
     }
     Nette\Debug::tryError();
     $ini = parse_ini_file($file, TRUE);
     if (Nette\Debug::catchError($e)) {
         throw $e;
     }
     $separator = trim(self::$sectionSeparator);
     $data = array();
     foreach ($ini as $secName => $secData) {
         // is section?
         if (is_array($secData)) {
             if (substr($secName, -1) === self::$rawSection) {
                 $secName = substr($secName, 0, -1);
             } elseif (self::$keySeparator) {
                 // process key separators (key1> key2> key3)
                 $tmp = array();
                 foreach ($secData as $key => $val) {
                     $cursor =& $tmp;
                     foreach (explode(self::$keySeparator, $key) as $part) {
                         if (!isset($cursor[$part]) || is_array($cursor[$part])) {
                             $cursor =& $cursor[$part];
                         } else {
                             throw new \InvalidStateException("Invalid key '{$key}' in section [{$secName}] in '{$file}'.");
                         }
                     }
                     $cursor = $val;
                 }
                 $secData = $tmp;
             }
             // process extends sections like [staging < production] (with special support for separator ':')
             $parts = $separator ? explode($separator, strtr($secName, ':', $separator)) : array($secName);
             if (count($parts) > 1) {
                 $parent = trim($parts[1]);
                 $cursor =& $data;
                 foreach (self::$keySeparator ? explode(self::$keySeparator, $parent) : array($parent) as $part) {
                     if (isset($cursor[$part]) && is_array($cursor[$part])) {
                         $cursor =& $cursor[$part];
                     } else {
                         throw new \InvalidStateException("Missing parent section [{$parent}] in '{$file}'.");
                     }
                 }
                 $secData = Nette\ArrayTools::mergeTree($secData, $cursor);
             }
             $secName = trim($parts[0]);
             if ($secName === '') {
                 throw new \InvalidStateException("Invalid empty section name in '{$file}'.");
             }
         }
         if (self::$keySeparator) {
             $cursor =& $data;
             foreach (explode(self::$keySeparator, $secName) as $part) {
                 if (!isset($cursor[$part]) || is_array($cursor[$part])) {
                     $cursor =& $cursor[$part];
                 } else {
                     throw new \InvalidStateException("Invalid section [{$secName}] in '{$file}'.");
                 }
             }
         } else {
             $cursor =& $data[$secName];
         }
         if (is_array($secData) && is_array($cursor)) {
             $secData = Nette\ArrayTools::mergeTree($secData, $cursor);
         }
         $cursor = $secData;
     }
     if ($section === NULL) {
         return $data;
     } elseif (!isset($data[$section]) || !is_array($data[$section])) {
         throw new \InvalidStateException("There is not section [{$section}] in '{$file}'.");
     } else {
         return $data[$section];
     }
 }
コード例 #6
0
ファイル: HttpRequest.php プロジェクト: nella/ActiveMapper
 /**
  * Returns uploaded file.
  * @param  string key (or more keys)
  * @return HttpUploadedFile
  */
 public final function getFile($key)
 {
     if ($this->files === NULL) {
         $this->initialize();
     }
     $args = func_get_args();
     return Nette\ArrayTools::get($this->files, $args);
 }
コード例 #7
0
ファイル: HttpRequest.php プロジェクト: newPOPE/screencast
	/**
	 * Returns uploaded file.
	 * @param  string key (or more keys)
	 * @return HttpUploadedFile
	 */
	final public function getFile($key)
	{
		$args = func_get_args();
		return Nette\ArrayTools::get($this->files, $args);
	}
コード例 #8
0
	/**
	 * Reads configuration from NEON file.
	 * @param  string  file name
	 * @return array
	 * @throws \InvalidStateException
	 */
	public static function load($file)
	{
		if (!is_file($file) || !is_readable($file)) {
			throw new \FileNotFoundException("File '$file' is missing or is not readable.");
		}

		$neon = Neon::decode(file_get_contents($file));

		$separator = trim(self::$sectionSeparator);
		$data = array();
		foreach ($neon as $secName => $secData) {
			if ($secData === NULL) { // empty section
				$secData = array();
			}

			if (is_array($secData)) {
				// process extends sections like [staging < production]
				$parts = $separator ? explode($separator, $secName) : array($secName);

				if (count($parts) > 1) {
					$parent = trim($parts[1]);
					$cursor = & $data;

					foreach (self::$keySeparator ? explode(self::$keySeparator, $parent) : array($parent) as $part) {
						if (isset($cursor[$part]) && is_array($cursor[$part])) {
							$cursor = & $cursor[$part];
						} else {
							throw new \InvalidStateException("Missing parent section $parent in '$file'.");
						}
					}
					$secData = Nette\ArrayTools::mergeTree($secData, $cursor);
				}

				$secName = trim($parts[0]);
				if ($secName === '') {
					throw new \InvalidStateException("Invalid empty section name in '$file'.");
				}
			}

			if (self::$keySeparator) {
				$cursor = & $data;
				foreach (explode(self::$keySeparator, $secName) as $part) {
					if (!isset($cursor[$part]) || is_array($cursor[$part])) {
						$cursor = & $cursor[$part];
					} else {
						throw new \InvalidStateException("Invalid section [$secName] in '$file'.");
					}
				}
			} else {
				$cursor = & $data[$secName];
			}

			if (is_array($secData) && is_array($cursor)) {
				$secData = Nette\ArrayTools::mergeTree($secData, $cursor);
			}

			$cursor = $secData;
		}

		return $data;
	}