public function save() { $this->competition->code = Nette\Utils\Strings::webalize($this->competition->name); if ($this->competition->id != "") { $this->wherePrimary($this->competition->id); $this->update($this->competition); } else { $this->competition->created = new DibiDateTime(); $this->insert($this->competition); } }
public function getBySources(array $urls) { // get articles $sql = ' SELECT a.*, ia.place_id, p.lat, p.lng, s.url AS source FROM article AS a JOIN source AS s ON a.source_id = s.id JOIN is_about AS ia ON ia.article_id = a.id JOIN place AS p ON ia.place_id = p.id WHERE s.url IN (?) '; $pm = array(); $articles = $this->db->query($sql, $urls)->fetchAll(); // get tags $places = array(); foreach ($articles as $article) { $places[] = $article->place_id; } $sql = ' SELECT t.*, ht.place_id FROM tag AS t JOIN has_tag AS ht ON ht.tag_id = t.id WHERE ht.place_id IN (?) '; $tags = array(); foreach ($this->db->query($sql, $places) as $tag) { if (isset($tags[$tag->place_id])) { $tags[$tag->place_id][] = $tag; } else { $tags[$tag->place_id] = array($tag); } } // prepare placemarks foreach ($articles as $article) { $pm[] = (object) array('name' => $article->title, 'url' => $article->url, 'photo' => $article->photo_url, 'tags' => isset($tags[$article->place_id]) ? $tags[$article->place_id] : array(), 'lat' => $article->lat, 'lng' => $article->lng, 'icon' => Nette\Utils\Strings::webalize(self::$icons[$article->source]), 'source' => $article->source); } return $pm; }
/** * Vrati nazev zmenseneho souboru stazeneho z ciziho serveru * @param string $file * @param int $height * @param int $width * @param bool $exact * @param bool $topCut * @return string */ function getRemoteResizedFilename($file, $height, $width, $exact, $topCut) { $file = DIR_FOR_REMOTE . '/' . Nette\Utils\Strings::webalize($file, '.'); return getBaseResizedFilename($file, $height, $width, $exact, $topCut); }
UploadiFive Copyright (c) 2012 Reactive Apps, Ronnie Garcia */ // Set the uplaod directory $uploadDir = __DIR__ . '/../../images/file/' . substr($_POST['timestamp'], 0, 4) . '/'; if (!is_dir($uploadDir)) { mkdir($uploadDir); chmod($uploadDir, 0777); } $verifyToken = md5('unique_salt' . $_POST['timestamp']); if (!empty($_FILES) && $_POST['token'] == $verifyToken) { include_once __DIR__ . '/../../vendor/nette/utils/src/Utils/StaticClass.php'; include_once __DIR__ . '/../../vendor/nette/utils/src/Utils/Strings.php'; $tempFile = $_FILES['Filedata']['tmp_name']; $fileName = explode('.', $_FILES['Filedata']['name']); $postFix = $fileName[count($fileName) - 1]; unset($fileName[count($fileName) - 1]); $fileName = $_POST['timestamp'] . '_' . Nette\Utils\Strings::webalize(implode('.', $fileName)) . '.' . $postFix; $targetFile = $uploadDir . $fileName; //$targetFile = $uploadDir . $_FILES['Filedata']['name']; // Validate the filetype $fileParts = pathinfo($_FILES['Filedata']['name']); // Save the file if (move_uploaded_file($tempFile, $targetFile) == TRUE) { echo $fileName; } else { echo 'ERROR'; } } else { echo 'ERROR - token'; }
public function update($data, $checkData = FALSE) { if ($checkData) { $data['code'] = Nette\Utils\Strings::webalize($data['subject_name'] . " " . $data['name']); } $coords = Geolocation::getCoordsFromText($data['subject_gps']); $data['lat'] = $coords[0]; $data['lon'] = $coords[1]; $data['last_edit_id'] = isset($this->context->user->id) ? $this->context->user->id : NULL; parent::update($data); }