Ejemplo n.º 1
0
 /**
  * Ověří mimetype předaného souboru.
  * @param \Nette\Http\FileUpload $file Nahraný soubor k ověření.
  * @return bool Má soubor správný mimetype?
  */
 public function checkType(\Nette\Http\FileUpload $file)
 {
     if (\Nette\Utils\Arrays::searchKey($this->getMimeTypes(), $file->getContentType()) !== FALSE) {
         return TRUE;
     } else {
         // Pokud se nepodaří ověřit mimetype, ověříme alespoň koncovku.
         if (array_search($this->getExtension($file->getName()), array_unique($this->getMimeTypes())) !== FALSE) {
             return TRUE;
         } else {
             return FALSE;
         }
     }
 }
Ejemplo n.º 2
0
 function __set($name, $val)
 {
     if (Nette\Utils\Arrays::searchKey($this->og, $name) !== FALSE) {
         $this->og[$name] = Nette\Utils\Strings::normalize($val);
     } else {
         if (Nette\Utils\Arrays::searchKey($this->fb, $name) !== FALSE) {
             $this->fb[$name] = Nette\Utils\Strings::normalize($val);
         } else {
             list($ar, $section, $name) = Nette\Utils\Strings::match($name, '/([a-zA-Z]+)[_]([a-zA-Z]*)/');
             if (Nette\Utils\Arrays::searchKey($this->{$section}, $name) !== FALSE) {
                 $this->{$section} = array_replace($this->{$section}, array($name => $val));
             }
         }
     }
 }
Ejemplo n.º 3
0
 public function getVisibility($vars)
 {
     if (!is_array($vars) || !Arrays::searchKey($vars, 'visibility')) {
         return "public ";
     } else {
         return Arrays::get($vars, 'visibility') . " ";
     }
 }
Ejemplo n.º 4
0
 /**
  * Get data from ID
  * @param int $id
  * @return \IQRF\Cloud\Response\DataAPI
  * @throws \OutOfRangeException Non exist ID
  */
 public function getID($id)
 {
     foreach ($this->data as $key => $value) {
         if ($value[0] == (string) $id) {
             $this->id = Arrays::searchKey($this->data, $key);
             return $this;
         }
     }
     if (empty($this->id)) {
         throw new \OutOfRangeException('Non exist ID');
     }
 }