コード例 #1
0
ファイル: Hash.php プロジェクト: Eupeodes/gh
 private function get()
 {
     if (\lib\RegExp::partExists('graticule', $this->matches)) {
         //if a graticule is given export data as gpx
         $this->graticule = $this->matches['graticule'];
         $this->global = $this->matches['graticule'] === 'global';
         if (!$this->global) {
             list($this->lat, $this->lng) = \lib\RegExp::parseGraticule($this->matches);
         }
         $this->getGpx();
     } elseif ($this->ext === 'gpx') {
         \lib\Error::send(400, 'Gpx only valid if graticule is specified');
     } elseif (strlen($this->matches['wk']) === 0) {
         $this->getSingle();
     } else {
         $this->getMultiple();
     }
 }
コード例 #2
0
ファイル: Dow.php プロジェクト: Eupeodes/gh
 public function view($url)
 {
     if (preg_match('/^\\/dow(.php)?\\/' . \lib\RegExp::date(true, true) . \lib\RegExp::ext(true) . '$/', $url, $matches)) {
         if (\lib\RegExp::partExists('d', $matches)) {
             $dt_start = new \DateTime($matches['y'] . '-' . $matches['m'] . '-' . $matches['d']);
             $dt_end = null;
         } elseif (\lib\RegExp::partExists('m', $matches)) {
             $dt_start = new \DateTime($matches['y'] . '-' . $matches['m'] . '-01');
             $dt_end = new \DateTime($matches['y'] . '-' . $matches['m'] . '-' . cal_days_in_month(CAL_GREGORIAN, $matches['m'], $matches['y']));
         } else {
             $dt_start = new \DateTime($matches['y'] . '-01-01');
             $dt_end = new \DateTime($matches['y'] . '-12-31');
         }
         $ext = \lib\RegExp::partExists('ext', $matches) ? $matches['ext'] : null;
         $dow = \model\Dow::get($dt_start, $dt_end);
         if ($dow === false) {
             \lib\Error::send(404, 'This dow is not available');
         } else {
             $this->display($dow, $ext);
         }
     } else {
         \lib\Error::send(404, 'No valid url, use <u>/dow/&lt;yyyy&gt;[/&lt;mm&gt;[/&lt;dd&gt;]]</u>');
     }
 }
コード例 #3
0
ファイル: Index.php プロジェクト: Eupeodes/gh
 private function readPath()
 {
     if (preg_match('/^(\\/index.php)?(\\/|)?((?P<type>' . \lib\RegExp::mapType() . ')\\/)?(?P<date>' . \lib\RegExp::date() . '(\\/(?P<single>s(ingle)?))?(\\/(?P<home>' . \lib\RegExp::hash() . ')(\\/(?P<zoom>[[0|1]?[0-9])(\\/(?P<center>' . \lib\RegExp::hash() . '))?)?)?)?(\\/)?$/i', $this->url, $this->matches)) {
         if (\lib\RegExp::partExists('type', $this->matches)) {
             $this->settings['type'] = $this->matches['type'];
         }
         if (\lib\RegExp::partExists('date', $this->matches)) {
             \lib\RegExp::parseDate($this->matches);
             list($y, $m, $d) = \lib\RegExp::parseDate($this->matches);
             $this->date($y, $m, $d);
         }
         if (\lib\RegExp::partExists('home', $this->matches)) {
             $geohash = new \lib\external\GeoHash();
             list($lat, $lng) = $geohash->decode($this->matches['home']);
             $this->settings['home'] = '[' . $lng . ', ' . $lat . ']';
             $this->homeSet = true;
         }
         if (\lib\RegExp::partExists('zoom', $this->matches)) {
             $this->settings['zoom'] = $this->matches['zoom'];
         }
         if (\lib\RegExp::partExists('single', $this->matches)) {
             $this->settings['single'] = true;
         }
         if (\lib\RegExp::partExists('center', $this->matches)) {
             $geohash = new \lib\external\GeoHash();
             list($lat, $lng) = $geohash->decode($this->matches['center']);
             $this->settings['center'] = '[' . $lng . ', ' . $lat . ']';
             $this->centerSet = true;
         }
     } else {
         if (preg_match('/(\\/|^)t:(?P<type>' . \lib\RegExp::mapType() . ')(\\/|$)/i', $this->url, $this->matches)) {
             $this->settings['type'] = $this->matches['type'];
         }
         if (preg_match('/(\\/|^)' . \lib\RegExp::date() . '(\\/|$)/i', $this->url, $this->matches)) {
             list($y, $m, $d) = \lib\RegExp::parseDate($this->matches);
             $this->date($y, $m, $d);
         }
         if (preg_match('/(\\/|^)g(lobal)?(\\/|$)/i', $this->url)) {
             $hash = new \view\Hash();
             $data = $hash->getGlobal($this->date);
             $this->settings['home'] = '[' . $hash->getInt($data['global']->lng) . '.5,' . $hash->getInt($data['global']->lat) . '.5]';
             $this->settings['center'] = $this->settings['home'];
             $this->settings['grid'] = $this->settings['home'];
             $this->homeSet = true;
             $this->centerSet = true;
             $this->gridSet = true;
         } else {
             if (preg_match_all('/(?=(\\/|^)(?P<graticule>(?P<w>[cgh]{0,}:)?' . \lib\RegExp::graticule() . ')(\\/|$))/i', $this->url, $this->matches, PREG_SET_ORDER)) {
                 foreach ($this->matches as $match) {
                     list($lat, $lng) = \lib\RegExp::parseGraticule($match);
                     $lat .= strpos($lat, '.') === false ? '.5' : '';
                     $lng .= strpos($lng, '.') === false ? '.5' : '';
                     if ($match['w'] === '') {
                         $match['w'] = 'h';
                     }
                     if (strpos($match['w'], 'c') !== false) {
                         $this->settings['center'] = '[' . $lng . ', ' . $lat . ']';
                         $this->centerSet = true;
                     }
                     if (strpos($match['w'], 'g') !== false) {
                         $this->settings['grid'] = '[' . $lng . ', ' . $lat . ']';
                         $this->gridSet = true;
                     }
                     if (strpos($match['w'], 'h') !== false) {
                         $this->settings['home'] = '[' . $lng . ', ' . $lat . ']';
                         $this->homeSet = true;
                     }
                 }
             }
         }
         if (preg_match('/(\\/|^)s(ingle)?(\\/|$)/i', $this->url, $this->matches)) {
             $this->settings['single'] = true;
         }
         if (preg_match('/(\\/|^)' . \lib\RegExp::zoom() . '(\\/|$)/i', $this->url, $this->matches)) {
             $this->settings['zoom'] = $this->matches['zoom'];
         }
     }
 }