Exemplo n.º 1
0
 protected function _getDate($timeAmount, Zend_Date $date)
 {
     $nowDate = new Zend_Date();
     $dateWithTimeAmount = $date->addHour($timeAmount);
     if ($timeAmount == 0) {
         $date = $date->addMinute(1);
     } elseif ($timeAmount < 0 && $nowDate->isLater($dateWithTimeAmount)) {
         $date = $nowDate->addMinute(1);
     } else {
         $date = $dateWithTimeAmount;
     }
     return $date;
 }
Exemplo n.º 2
0
 /**
  * 取得InfoServer数据表中某个时间段的分组数据SQL语句
  * 
  * @param integer $startTimestamp
  * @param integer $range
  * @param array|string $spec
  * @return Zend_Db_Select
  */
 public function getSumGroupSelect($startTimestamp = null, $range = null, $spec = 'rTimestamp')
 {
     $select = $this->select(true)->reset(self::COLUMNS)->columns(array('rTimestamp', 'OnlineNum' => $this->_exprSumOnlineNum));
     if (!empty($startTimestamp)) {
         $startDate = new Zend_Date($startTimestamp);
         $select->where('rTimestamp >= ?', $startDate->setSecond(0)->getTimestamp(), Zend_DB::INT_TYPE);
         if (!empty($range)) {
             $select->where('rTimestamp <= ?', $startDate->addMinute($range - 1)->setSecond(59)->getTimestamp(), Zend_DB::INT_TYPE);
         }
     }
     $select->group($spec);
     return $select;
 }
Exemplo n.º 3
0
 /**
  * test looseBehaviour
  */
 public function testLoose()
 {
     $date = new Zend_Date(0, 'de_DE');
     try {
         $date->set(null, Zend_Date::YEAR);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     $date->set(10, 'de_DE');
     $this->assertEquals(10, $date->getTimestamp());
     try {
         $date->add(null, Zend_Date::YEAR);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     $date->add(10, 'de_DE');
     $this->assertEquals(20, $date->getTimestamp());
     try {
         $date->sub(null, Zend_Date::YEAR);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     $date->sub(10, 'de_DE');
     $this->assertEquals(10, $date->getTimestamp());
     try {
         $date->compare(null, Zend_Date::YEAR);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->equals(null, Zend_Date::YEAR);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->isEarlier(null, Zend_Date::YEAR);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->isLater(null, Zend_Date::YEAR);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setTime(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addTime(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subTime(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareTime(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setDate(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addDate(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subDate(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareDate(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setIso(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addIso(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subIso(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareIso(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setArpa(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addArpa(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subArpa(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareArpa(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setMonth(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addMonth(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subMonth(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareMonth(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setDay(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addDay(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subDay(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareDay(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setWeekday(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addWeekday(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subWeekday(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareWeekday(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setDayOfYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addDayOfYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subDayOfYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareDayOfYear(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setHour(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addHour(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subHour(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareHour(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setMinute(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addMinute(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subMinute(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareMinute(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setSecond(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addSecond(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subSecond(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareSecond(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->setWeek(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->addWeek(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->subWeek(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
     try {
         $date->compareWeek(null);
         $this->fail();
     } catch (Zend_Date_Exception $e) {
         // success
     }
 }
 /**
  * 
  * @param type $horarios
  * @param type $intervalo
  */
 private function setHorarios($salao_id, $dia_semana, $horario_fechamento, $horario_abertura)
 {
     $horarios = ($horario_fechamento - $horario_abertura) * 2;
     $date = date('Y-m-d') . ' ' . $horario_abertura;
     $zendDate = new Zend_Date($date);
     $horario = $zendDate->subMinute(30);
     for ($i = 0; $i <= $horarios; $i++) {
         $horario = $zendDate->addMinute(30)->get(Zend_Date::TIME_SHORT);
         $insertHorario = array('salao_id' => $salao_id, 'salao_horario_dia_semana' => $dia_semana, 'salao_horario' => $horario);
         $modelSalaoHorario = new Model_DbTable_SalaoHorario();
         if (!$modelSalaoHorario->insert($insertHorario)) {
             throw new Exception("Falha ao cadastrar os horários");
         }
     }
 }
Exemplo n.º 5
0
 public function readAction()
 {
     $this->disableLayout();
     $this->disableView();
     $ressource_dir = dirname(dirname(__FILE__)) . '/ressources';
     /* var_dump($this->_request);
        exit;*/
     $feed = $this->_request->getParam('feed');
     $catID = $this->_request->getParam('catID');
     $feed = str_replace('.xml', "-{$catID}.xml", $feed);
     $rssLimit = Cible_FunctionsCategories::getRssItemsLimitPerCategory($catID);
     $langId = Cible_FunctionsGeneral::getLanguageID($this->_request->getParam('lang'));
     Zend_Registry::set('languageID', $langId);
     $lang = $this->_request->getParam('lang');
     $feed_url = Zend_Registry::get('absolute_web_root') . "/{$this->_request->getParam('lang')}/{$this->_request->getParam('feed')}";
     if (file_exists("{$ressource_dir}/{$lang}/{$feed}")) {
         $lastUpdate = new Zend_Date(filemtime("{$ressource_dir}/{$lang}/{$feed}"));
         $now = new Zend_Date();
     }
     if (file_exists("{$ressource_dir}/{$lang}/{$feed}") && !$now->isLater($lastUpdate->addMinute($this->_config->rss->refresh->delay))) {
         $xml = file_get_contents("{$ressource_dir}/{$lang}/{$feed}");
     } else {
         $file = fopen("{$ressource_dir}/{$lang}/{$feed}", "w");
         $select = $this->_db->select();
         $select->from('NewsData')->joinLeft('NewsIndex', 'NewsData.ND_ID = NewsIndex.NI_NewsDataID')->joinleft('CategoriesIndex', 'CategoriesIndex.CI_CategoryID = NewsData.ND_CategoryID')->joinleft('Categories', 'Categories.C_ID = NewsData.ND_CategoryID')->where('CategoriesIndex.CI_LanguageID = ?', $langId)->where('NewsIndex.NI_LanguageID = ?', $langId)->where('Categories.C_ID = ?', $catID)->where('Categories.C_ShowInRss = ?', 1)->order('ND_Date DESC')->limit($rssLimit);
         //die($select);
         $news = $this->_db->fetchAll($select);
         $feedPubDate = date("r", strtotime('now'));
         $xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
         $xml .= "<rss version=\"2.0\">";
         $xml .= "<channel>";
         $xml .= "<title>" . $this->_config->site->title . "</title>";
         $xml .= "<description>";
         $xml .= str_replace('##SITE_NAME##', $this->_config->site->title, $this->view->getCibleText('rss_read_description_field_label'));
         $xml .= "</description>";
         $xml .= "<lastBuildDate>{$feedPubDate}</lastBuildDate>";
         $xml .= "<link>{$feed_url}</link>";
         foreach ($news as $details) {
             if ($details['NI_Status'] == 1) {
                 // Titres des nouvelles (FR)
                 $title = str_replace("'", "'", $details['NI_Title']);
                 $title = str_replace("<br>", "<br />", $title);
                 $title = str_replace("&", "&amp;", $title);
                 // Textes des nouvelles (FR)
                 $description = str_replace("'", "'", $this->KeepTextOnly($details["NI_Brief"]));
                 $description = htmlspecialchars($description);
                 $description = str_replace("<br>", "<br />", $description);
                 $pubDate = date("r", strtotime($details["ND_ReleaseDate"]));
                 $news_url = Zend_Registry::get('absolute_web_root') . '/' . Cible_FunctionsCategories::getPagePerCategoryView($details["ND_CategoryID"], 'details') . "/ID/{$details['ND_ID']}";
                 $xml .= "<item>";
                 $xml .= "<title>{$title}</title>";
                 $xml .= "<description>{$description}</description>";
                 $xml .= "<pubDate>{$pubDate}</pubDate>";
                 $xml .= "<guid>{$news_url}</guid>";
                 $xml .= "<link>{$news_url}</link>";
                 $xml .= "</item>";
             }
         }
         $xml .= "</channel>";
         $xml .= "</rss>";
         fwrite($file, $xml);
         fclose($file);
     }
     $this->_response->setHeader('Content-Type', 'application/rss+xml');
     echo $xml;
 }