/** * testNotEmptyISO88591Encoding method * * @return void */ public function testNotEmptyISO88591AppEncoding() { Configure::write('App.encoding', 'ISO-8859-1'); $this->assertTrue(Validation::notBlank('abcdefg')); $this->assertTrue(Validation::notBlank('fasdf ')); $this->assertTrue(Validation::notBlank('fooo' . chr(243) . 'blabla')); $this->assertTrue(Validation::notBlank('abçďĕʑʘπй')); $this->assertTrue(Validation::notBlank('José')); $this->assertTrue(Validation::notBlank(utf8_decode('José'))); $this->assertFalse(Validation::notBlank("\t ")); $this->assertFalse(Validation::notBlank("")); }
public function southFour() { // Init table $resultsTable = TableRegistry::get('Results'); // Prepare $year1 = Hash::get($this->request->query, 'search_year1'); $month1 = Hash::get($this->request->query, 'search_month1'); $year2 = Hash::get($this->request->query, 'search_year2'); $month2 = Hash::get($this->request->query, 'search_month2'); $head = Hash::get($this->request->query, 'search_head'); $trail = Hash::get($this->request->query, 'search_trail'); $startFormat = ""; $endFormat = ""; $startFormatValue = ""; $endFormatValue = ""; $conditions = ['area' => Configure::read('Area.south.code'), 'level IN' => [1, 9]]; // Setting get data by year, month if (Validation::notBlank($year1)) { $startFormat .= '%Y'; $startFormatValue .= $year1; } if (Validation::notBlank($month1)) { $startFormat .= '%m'; $startFormatValue .= $month1; } if (Validation::notBlank($year2)) { $endFormat .= '%Y'; $endFormatValue .= $year2; } if (Validation::notBlank($month2)) { $endFormat .= '%m'; $endFormatValue .= $month2; } if ($startFormat) { $conditions[] = "DATE_FORMAT(date_result, '{$startFormat}') >= {$startFormatValue}"; } if ($endFormat) { $conditions[] = "DATE_FORMAT(date_result, '{$endFormat}') <= {$endFormatValue}"; } // Setting get data by head, trail if (Validation::notBlank($head)) { $conditions[] = "MID(content, -2, 1) = {$head}"; } if (Validation::notBlank($trail)) { $conditions[] = "MID(content, -1) = {$trail}"; } $query = $resultsTable->find('all'); $trailTwo = $query->func()->mid(['content' => 'literal', '-2']); $query->select(['id', 'date_result', 'trail' => $trailTwo, 'city', 'level'])->where($conditions)->order(['date_result' => 'DESC', 'city' => 'ASC', 'level' => 'DESC']); // process space $htmlSpace = []; $htmlSpaceHead = []; if (Validation::notBlank($head)) { $sorted = $query->sortBy(function ($trail) { return $trail->date_result->i18nFormat('yyyyMMdd'); }, SORT_ASC); foreach ($sorted as $key => $value) { $date = new \DateTime($value->date_result->i18nFormat('yyyy-MM-dd')); $line = in_array($value->city, Configure::read('COMMAND.CHANNEL.line1')) ? 1 : 2; $line = $line . "_" . ($value->level == 9 ? 1 : 2); $prevDate = isset($htmlSpace[$line]) ? $htmlSpace[$line]['prev_date'] : $date; $space = $prevDate->diff($date)->format("%a"); // Check is space greater two month $spaceMonth = $date->format('Ym') - $prevDate->format('Ym'); if ($space > 30 && $spaceMonth != 1 && $spaceMonth != 89) { continue; } if ($prevDate->format('Y-m-d') != $date->format('Y-m-d')) { $htmlSpace[$line][$space][] = $prevDate->format('Y-m-d') . " - " . $date->format('Y-m-d'); $htmlSpace[$line]["{$space}_count"] = count($htmlSpace[$line][$space]); } $htmlSpace[$line]['prev_date'] = $date; krsort($htmlSpace[$line]); if (!in_array($space, $htmlSpaceHead)) { $htmlSpaceHead[] = $space; } } ksort($htmlSpace); rsort($htmlSpaceHead); $htmlSpace = Hash::flatten($htmlSpace); //var_dump($htmlSpaceHead); //var_dump($htmlSpace);exit; } $this->set('trails', $query); $this->set('htmlSpace', $htmlSpace); $this->set('htmlSpaceHead', $htmlSpaceHead); }