Exemplo n.º 1
0
 public function bind(array $taintedValues = null, array $taintedFiles = null)
 {
     $df = new sfDateFormat();
     $taintedValues['start_date'] = $df->format($taintedValues['start_date'], 'yyyy-MM-dd', 'dd/MM/yyyy');
     $taintedValues['end_date'] = $df->format($taintedValues['end_date'], 'yyyy-MM-dd', 'dd/MM/yyyy');
     return parent::bind($taintedValues, $taintedFiles);
 }
Exemplo n.º 2
0
 public function convertPHPFormatDateToISOFormatDate($inputPHPFormat, $date)
 {
     $dateFormat = new sfDateFormat();
     try {
         $symfonyPattern = $this->__getSymfonyDateFormatPattern($inputPHPFormat);
         $dateParts = $dateFormat->getDate($date, $symfonyPattern);
         if (is_array($dateParts) && isset($dateParts['year']) && isset($dateParts['mon']) && isset($dateParts['mday'])) {
             $day = $dateParts['mday'];
             $month = $dateParts['mon'];
             $year = $dateParts['year'];
             // Additional check done for 3 digit years, or more than 4 digit years
             if (checkdate($month, $day, $year) && $year >= 1000 && $year <= 9999) {
                 $dateTime = new DateTime();
                 $dateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
                 $dateTime->setDate($year, $month, $day);
                 $date = $dateTime->format('Y-m-d');
                 return $date;
             } else {
                 return "Invalid date";
             }
         }
     } catch (Exception $e) {
         return "Invalid date";
     }
     return null;
 }
Exemplo n.º 3
0
 public static function deleteOldKeys()
 {
     // Get a new date formatter
     $dateFormat = new sfDateFormat();
     $expiration_age = sfConfig::get('app_remember_key_expiration_age', 31 * 24 * 3600);
     $expiration_time_value = $dateFormat->format(time() - $expiration_age, 'I');
     Doctrine_Query::create()->delete('RememberKey')->from('RememberKey rk')->where('rk.created_at < ?', $expiration_time_value)->execute();
 }
Exemplo n.º 4
0
 protected function updateDocumentoFromRequest()
 {
     $documento = $this->getRequestParameter('documento');
     if (isset($documento['id_proyecto'])) {
         $this->documento->setIdProyecto($documento['id_proyecto'] ? $documento['id_proyecto'] : null);
     }
     if (isset($documento['id_fase'])) {
         $this->documento->setIdFase($documento['id_fase'] ? $documento['id_fase'] : null);
     }
     if (isset($documento['id_reunion'])) {
         $this->documento->setIdReunion($documento['id_reunion'] ? $documento['id_reunion'] : null);
     }
     if (isset($documento['id_categoria'])) {
         $this->documento->setIdCategoria($documento['id_categoria'] ? $documento['id_categoria'] : null);
     }
     if (isset($documento['tamano'])) {
         $this->documento->setTamano($documento['tamano']);
     }
     if (isset($documento['version'])) {
         $this->documento->setVersion($documento['version']);
     }
     if (isset($documento['fecha'])) {
         if ($documento['fecha']) {
             try {
                 $dateFormat = new sfDateFormat($this->getUser()->getCulture());
                 if (!is_array($documento['fecha'])) {
                     $value = $dateFormat->format($documento['fecha'], 'I', $dateFormat->getInputPattern('g'));
                 } else {
                     $value_array = $documento['fecha'];
                     $value = $value_array['year'] . '-' . $value_array['month'] . '-' . $value_array['day'];
                     $value .= isset($value_array['hour']) ? ' ' . $value_array['hour'] . ':' . $value_array['minute'] . (isset($value_array['second']) ? ':' . $value_array['second'] : '') : '';
                 }
                 $this->documento->setFecha($value);
             } catch (sfException $e) {
                 // not a date
             }
         } else {
             $this->documento->setFecha(null);
         }
     }
     $this->uploadArchivoFromRequest();
 }
<?php

echo use_helper('DeppNews');
?>

<?php 
$df = new sfDateFormat('it_IT');
$sf_site_url = sfConfig::get('sf_site_url', 'openparlamento');
?>



Le ultime notizie
=================

<?php 
foreach ($grouped_news as $date_ts => $news) {
    ?>
  <?php 
    foreach ($news as $i => $n) {
        ?>

    <?php 
        // fetch del modello e dell'oggetto che ha generato la notizia
        $generator_model = $n->getGeneratorModel();
        if ($n->getGeneratorPrimaryKeys()) {
            $pks = array_values(unserialize($n->getGeneratorPrimaryKeys()));
            $generator = call_user_func_array(array($generator_model . 'Peer', 'retrieveByPK'), $pks);
        } else {
            $pks = array();
            $generator = null;
Exemplo n.º 6
0
 protected function updateArticleFromRequest()
 {
     $article = $this->getRequestParameter('article');
     if (isset($article['title'])) {
         $this->article->setTitle($article['title']);
     }
     if (isset($article['body'])) {
         $this->article->setBody($article['body']);
     }
     $this->article->setOnline(isset($article['online']) ? $article['online'] : 0);
     if (isset($article['excerpt'])) {
         $this->article->setExcerpt($article['excerpt']);
     }
     if (isset($article['category_id'])) {
         $this->article->setCategoryId($article['category_id'] ? $article['category_id'] : null);
     }
     if (isset($article['created_at'])) {
         if ($article['created_at']) {
             try {
                 $dateFormat = new sfDateFormat($this->getUser()->getCulture());
                 if (!is_array($article['created_at'])) {
                     $value = $dateFormat->format($article['created_at'], 'I', $dateFormat->getInputPattern('g'));
                 } else {
                     $value_array = $article['created_at'];
                     $value = $value_array['year'] . '-' . $value_array['month'] . '-' . $value_array['day'] . (isset($value_array['hour']) ? ' ' . $value_array['hour'] . ':' . $value_array['minute'] . (isset($value_array['second']) ? ':' . $value_array['second'] : '') : '');
                 }
                 $this->article->setCreatedAt($value);
             } catch (sfException $e) {
                 // not a date
             }
         } else {
             $this->article->setCreatedAt(null);
         }
     }
     if (isset($article['end_date'])) {
         if ($article['end_date']) {
             try {
                 $dateFormat = new sfDateFormat($this->getUser()->getCulture());
                 if (!is_array($article['end_date'])) {
                     $value = $dateFormat->format($article['end_date'], 'I', $dateFormat->getInputPattern('g'));
                 } else {
                     $value_array = $article['end_date'];
                     $value = $value_array['year'] . '-' . $value_array['month'] . '-' . $value_array['day'] . (isset($value_array['hour']) ? ' ' . $value_array['hour'] . ':' . $value_array['minute'] . (isset($value_array['second']) ? ':' . $value_array['second'] : '') : '');
                 }
                 $this->article->setEndDate($value);
             } catch (sfException $e) {
                 // not a date
             }
         } else {
             $this->article->setEndDate(null);
         }
     }
     if (isset($article['book_id'])) {
         $this->article->setBookId($article['book_id'] ? $article['book_id'] : null);
     }
 }
Exemplo n.º 7
0
 protected function updateEventoFromRequest($evento_obj)
 {
     $evento = $this->getRequestParameter('evento');
     if (isset($evento['fecha_inicio'])) {
         if ($evento['fecha_inicio']) {
             try {
                 $dateFormat = new sfDateFormat($this->getUser()->getCulture());
                 if (!is_array($evento['fecha_inicio'])) {
                     if (isset($evento['hora_asociada']) and $evento['hora_asociada'] == 1) {
                         if ($evento['hora_inicio']) {
                             $evento['hora_inicio']['hour'] = ($evento['hora_inicio']['hour'] != "12" and $evento['hora_inicio']['ampm'] == "PM") ? $evento['hora_inicio']['hour'] + 12 : $evento['hora_inicio']['hour'];
                             $evento['hora_inicio']['hour'] = ($evento['hora_inicio']['hour'] == "12" and $evento['hora_inicio']['ampm'] == "AM") ? "00" : $evento['hora_inicio']['hour'];
                             $evento['fecha_inicio'] .= " " . $evento['hora_inicio']['hour'] . ":" . $evento['hora_inicio']['minute'];
                         } else {
                             $evento['fecha_inicio'] .= " 00:00:00";
                         }
                     } else {
                         $evento['fecha_inicio'] .= " 00:00:00";
                     }
                     $value = $dateFormat->format($evento['fecha_inicio'], 'I', $dateFormat->getInputPattern('g'));
                 } else {
                     $value_array = $evento['fecha_inicio'];
                     $value_array['hour']['hour'] = "00";
                     $value_array['hour']['minute'] = "00";
                     $value_array['hour']['second'] = "00";
                     if ($evento['hora_asociada'] == 1) {
                         if ($evento['hora_inicio']) {
                             $value_array['hour'] = $evento['hora_inicio']['hour'];
                             $value_array['minute'] = $evento['hora_inicio']['minute'];
                             $value_array['ampm'] = $evento['hora_inicio']['ampm'];
                         }
                     }
                     $value = $value_array['year'] . '-' . $value_array['month'] . '-' . $value_array['day'] . (isset($value_array['hour']) ? ' ' . $value_array['hour'] . ':' . $value_array['minute'] . (isset($value_array['second']) ? ':' . $value_array['second'] : '') : '');
                 }
                 $evento_obj->setFechaInicio($value);
             } catch (sfException $e) {
                 // not a date
             }
         } else {
             $evento_obj->setFechaInicio(null);
         }
     }
     if (isset($evento['fecha_fin'])) {
         if ($evento['fecha_fin']) {
             try {
                 $dateFormat = new sfDateFormat($this->getUser()->getCulture());
                 if (!is_array($evento['fecha_fin'])) {
                     if (isset($evento['hora_asociada']) and $evento['hora_asociada'] == 1) {
                         if ($evento['hora_fin']) {
                             $evento['hora_fin']['hour'] = ($evento['hora_fin']['hour'] != "12" and $evento['hora_fin']['ampm'] == "PM") ? $evento['hora_fin']['hour'] + 12 : $evento['hora_fin']['hour'];
                             $evento['hora_fin']['hour'] = ($evento['hora_fin']['hour'] == "12" and $evento['hora_fin']['ampm'] == "AM") ? "00" : $evento['hora_fin']['hour'];
                             $evento['fecha_fin'] .= " " . $evento['hora_fin']['hour'] . ":" . $evento['hora_fin']['minute'];
                         } else {
                             $evento['fecha_fin'] .= " 00:00:00";
                         }
                     } else {
                         $evento['fecha_fin'] .= " 00:00:00";
                     }
                     $value = $dateFormat->format($evento['fecha_fin'], 'I', $dateFormat->getInputPattern('g'));
                 } else {
                     $value_array = $evento['fecha_fin'];
                     $value_array['hour']['hour'] = "00";
                     $value_array['hour']['minute'] = "00";
                     $value_array['hour']['second'] = "00";
                     if ($evento['hora_asociada'] == 1) {
                         if ($evento['hora_fin']) {
                             $value_array['hour'] = $evento['hora_fin']['hour'];
                             $value_array['minute'] = $evento['hora_fin']['minute'];
                             $value_array['ampm'] = $evento['hora_inicio']['ampm'];
                         }
                     }
                     $value = $value_array['year'] . '-' . $value_array['month'] . '-' . $value_array['day'] . (isset($value_array['hour']) ? ' ' . $value_array['hour'] . ':' . $value_array['minute'] . (isset($value_array['second']) ? ':' . $value_array['second'] : '') : '');
                 }
                 $evento_obj->setFechaFin($value);
             } catch (sfException $e) {
                 // not a date
             }
         } else {
             $evento_obj->setFechaFin(null);
         }
     }
     if (isset($evento['titulo'])) {
         $evento_obj->setTitulo($evento['titulo']);
     }
     if (isset($evento['tipo'])) {
         $evento_obj->setTipo($evento['titulo']);
     } else {
         $evento_obj->setTipo(1);
         //  (0 = PRIVATE | 1 = PUBLIC | 2 = CONFIDENTIAL)
     }
     if (isset($evento['estado'])) {
         $evento_obj->setEstado($evento['estado']);
     } else {
         $evento_obj->setEstado(1);
         // (0 = TENTATIVE, 1 = CONFIRMED, 2 = CANCELLED)
     }
     if (isset($evento['activar_repeticion']) and $evento['activar_repeticion'] == 1) {
         if (isset($evento['frecuencia']) and is_array($evento['frecuencia'])) {
             $evento_obj->setFrecuencia($evento['frecuencia'][0]);
             switch ($evento['frecuencia'][0]) {
                 // dia: 4, semana: 5, mes: 6, año: 7
                 case '4':
                     $evento_obj->setFrecuenciaIntervalo($evento['frecuencia_intervalo_diaria']);
                     break;
                 case '5':
                     $evento_obj->setFrecuenciaIntervalo($evento['frecuencia_intervalo_semana']);
                     $aSemanaBinario = array(1, 2, 4, 8, 16, 32, 64);
                     $suma_total = 0;
                     foreach ($evento['recurrencia_dias'] as $dia) {
                         $suma_total += $aSemanaBinario[$dia];
                     }
                     // guardamos en binario para saber todos los dias de la semana seleccionados
                     $evento_obj->setRecurrenciaDias($suma_total);
                     break;
                 case '6':
                     break;
                 case '7':
                     break;
             }
         }
         if (isset($evento['recurrencia_fin_tipo']) and is_array($evento['recurrencia_fin_tipo'])) {
             switch ($evento['recurrencia_fin_tipo'][0]) {
                 case '0':
                     $evento_obj->setRecurrenciaFin('');
                     break;
                 case '1':
                     $evento_obj->setRecurrenciaFin($evento['recurrencia_fin_repeticion']);
                     break;
                 case '2':
                     $dateFormat = new sfDateFormat($this->getUser()->getCulture());
                     $value = $dateFormat->format($evento['recurrencia_fin_fecha'] . " 00:00:00", 'I', $dateFormat->getInputPattern('g'));
                     $evento_obj->setRecurrenciaFin($value);
                     break;
             }
         }
     } else {
         $evento_obj->setFrecuenciaIntervalo(null);
         $evento_obj->setRecurrenciaFin(null);
         $evento_obj->setRecurrenciaDias(null);
         $evento_obj->setFrecuencia(null);
     }
     return $evento_obj;
 }
Exemplo n.º 8
0
$context->user->culture = 'fr';
$t->is(format_date($now, 'F', 'en'), date('F j, Y g:i:s A', $now).' '.date('T', $now), 'format_date() takes a culture as its third argument');

// format_datetime()
$t->diag('format_datetime()');
$context->user->culture = 'en';
$t->is(format_datetime($now), date('F j, Y g:i:s A', $now).' '.date('T', $now), 'format_datetime() format a numerical date time according to the user culture');
$t->is(format_datetime(date('Y-m-d', $now)), date('F j, Y', $now).' 12:00:00 AM '.date('T', $now), 'format_datetime() format a string date time according to the user culture');
$t->is(format_datetime(date('Y-m-d H:i:s', $now), 'f'), date('F j, Y g:i A', $now), 'formats timestamps correctly');

$t->diag('sfDateFormat');
$df = new sfDateFormat('en_US');
$t->is($df->format('7/14/1789', 'i', 'd'), '1789-07-14', 'pre-epoch date from en_US to iso');
$t->is($df->format('7/14/1789 14:29', 'I', $df->getInputPattern('g')), '1789-07-14 14:29:00', 'pre-epoch date-time from en_US to iso with getInputPattern()');
$df = new sfDateFormat('fr');
$t->is($df->format(date('d/m/y', $now), 'i', 'd'), date('Y-m-d', $now), 'format two digit year from fr to iso');

$cultures = sfCultureInfo::getCultures();
foreach ($cultures as $culture)
{
  if (sfCultureInfo::validCulture($culture))
  {
    $df = new sfDateFormat($culture);
    $shortDate = $df->format($now, 'd');
    $t->is($df->format($shortDate, 'i', 'd'), date('Y-m-d', $now), sprintf('"%s": conversion "d" to "i"', $culture));
    $dateTime = $df->format($now, $df->getInputPattern('g'));
    $t->is($df->format($dateTime, 'I', $df->getInputPattern('g')), date('Y-m-d H:i:', $now).'00', sprintf('"%s": Conversion "g" to "I"', $culture));
  }
}
Exemplo n.º 9
0
 protected function updateGuestFromRequest()
 {
     if (!$this->getRequestParameter('guest')) {
         return;
     }
     $guest = $this->getRequestParameter('guest');
     if (isset($guest['etime_id'])) {
         $this->guest->setEtimeId($guest['etime_id'] ? $guest['etime_id'] : null);
     }
     $this->guest->setAttending(isset($guest['attending']) ? true : false);
     $this->guest->setPaid(isset($guest['paid']) ? true : false);
     if (isset($guest['reg_date'])) {
         if ($guest['reg_date']) {
             try {
                 $dateFormat = new sfDateFormat($this->getUser()->getCulture());
                 if (!is_array($guest['reg_date'])) {
                     $value = $dateFormat->format($guest['reg_date'], 'I', $dateFormat->getInputPattern('g'));
                 } else {
                     $value_array = $guest['reg_date'];
                     $value = $value_array['year'] . '-' . $value_array['month'] . '-' . $value_array['day'] . (isset($value_array['hour']) ? ' ' . $value_array['hour'] . ':' . $value_array['minute'] . (isset($value_array['second']) ? ':' . $value_array['second'] : '') : '');
                 }
                 $this->guest->setRegDate($value);
             } catch (sfException $e) {
                 // not a date
             }
         } else {
             $this->guest->setRegDate(null);
         }
     }
     if (isset($guest['extra_info'])) {
         $this->guest->setExtraInfo($guest['extra_info']);
     }
     if (isset($guest['created_at'])) {
         if ($guest['created_at']) {
             try {
                 $dateFormat = new sfDateFormat($this->getUser()->getCulture());
                 if (!is_array($guest['created_at'])) {
                     $value = $dateFormat->format($guest['created_at'], 'I', $dateFormat->getInputPattern('g'));
                 } else {
                     $value_array = $guest['created_at'];
                     $value = $value_array['year'] . '-' . $value_array['month'] . '-' . $value_array['day'] . (isset($value_array['hour']) ? ' ' . $value_array['hour'] . ':' . $value_array['minute'] . (isset($value_array['second']) ? ':' . $value_array['second'] : '') : '');
                 }
                 $this->guest->setCreatedAt($value);
             } catch (sfException $e) {
                 // not a date
             }
         } else {
             $this->guest->setCreatedAt(null);
         }
     }
     if (isset($guest['updated_at'])) {
         if ($guest['updated_at']) {
             try {
                 $dateFormat = new sfDateFormat($this->getUser()->getCulture());
                 if (!is_array($guest['updated_at'])) {
                     $value = $dateFormat->format($guest['updated_at'], 'I', $dateFormat->getInputPattern('g'));
                 } else {
                     $value_array = $guest['updated_at'];
                     $value = $value_array['year'] . '-' . $value_array['month'] . '-' . $value_array['day'] . (isset($value_array['hour']) ? ' ' . $value_array['hour'] . ':' . $value_array['minute'] . (isset($value_array['second']) ? ':' . $value_array['second'] : '') : '');
                 }
                 $this->guest->setUpdatedAt($value);
             } catch (sfException $e) {
                 // not a date
             }
         } else {
             $this->guest->setUpdatedAt(null);
         }
     }
     if (isset($guest['title'])) {
         $this->guest->setTitle($guest['title']);
     }
     if (isset($guest['firstname'])) {
         $this->guest->setFirstname($guest['firstname']);
     }
     if (isset($guest['lastname'])) {
         $this->guest->setLastname($guest['lastname']);
     }
     if (isset($guest['preferred_name'])) {
         $this->guest->setPreferredName($guest['preferred_name']);
     }
     if (isset($guest['email'])) {
         $this->guest->setEmail($guest['email']);
     }
     if (isset($guest['phone'])) {
         $this->guest->setPhone($guest['phone']);
     }
     if (isset($guest['mobile'])) {
         $this->guest->setMobile($guest['mobile']);
     }
     if (isset($guest['primary_address_line1'])) {
         $this->guest->setPrimaryAddressLine1($guest['primary_address_line1']);
     }
     if (isset($guest['primary_address_line2'])) {
         $this->guest->setPrimaryAddressLine2($guest['primary_address_line2']);
     }
     if (isset($guest['primary_address_line3'])) {
         $this->guest->setPrimaryAddressLine3($guest['primary_address_line3']);
     }
     if (isset($guest['primary_address_city'])) {
         $this->guest->setPrimaryAddressCity($guest['primary_address_city']);
     }
     if (isset($guest['primary_address_postcode'])) {
         $this->guest->setPrimaryAddressPostcode($guest['primary_address_postcode']);
     }
     if (isset($guest['primary_address_state'])) {
         $this->guest->setPrimaryAddressState($guest['primary_address_state']);
     }
     if (isset($guest['primary_address_country'])) {
         $this->guest->setPrimaryAddressCountry($guest['primary_address_country']);
     }
     if (isset($guest['secondary_address_line1'])) {
         $this->guest->setSecondaryAddressLine1($guest['secondary_address_line1']);
     }
     if (isset($guest['secondary_address_line2'])) {
         $this->guest->setSecondaryAddressLine2($guest['secondary_address_line2']);
     }
     if (isset($guest['secondary_address_line3'])) {
         $this->guest->setSecondaryAddressLine3($guest['secondary_address_line3']);
     }
     if (isset($guest['secondary_address_city'])) {
         $this->guest->setSecondaryAddressCity($guest['secondary_address_city']);
     }
     if (isset($guest['secondary_address_postcode'])) {
         $this->guest->setSecondaryAddressPostcode($guest['secondary_address_postcode']);
     }
     if (isset($guest['secondary_address_state'])) {
         $this->guest->setSecondaryAddressState($guest['secondary_address_state']);
     }
     if (isset($guest['secondary_address_country'])) {
         $this->guest->setSecondaryAddressCountry($guest['secondary_address_country']);
     }
     if (isset($guest['special_req'])) {
         $this->guest->setSpecialReq($guest['special_req']);
     }
     if (isset($guest['position'])) {
         $this->guest->setPosition($guest['position']);
     }
     if (isset($guest['company'])) {
         $this->guest->setCompany($guest['company']);
     }
     if (isset($guest['srn'])) {
         $this->guest->setSrn($guest['srn']);
     }
     if (isset($guest['fan'])) {
         $this->guest->setFan($guest['fan']);
     }
     if (isset($guest['aou'])) {
         $this->guest->setAou($guest['aou']);
     }
 }
Exemplo n.º 10
0
 protected function updateCatalogueFromRequest()
 {
     $catalogue = $this->getRequestParameter('catalogue');
     if (isset($catalogue['nvisible'])) {
         $this->catalogue->setNvisible($catalogue['nvisible']);
     }
     if (isset($catalogue['name'])) {
         $this->catalogue->setName($catalogue['name']);
     }
     if (isset($catalogue['source_lang'])) {
         $this->catalogue->setSourceLang($catalogue['source_lang']);
     }
     if (isset($catalogue['target_lang'])) {
         $this->catalogue->setTargetLang($catalogue['target_lang']);
     }
     if (isset($catalogue['date_created'])) {
         if ($catalogue['date_created']) {
             try {
                 $dateFormat = new sfDateFormat($this->getUser()->getCulture());
                 if (!is_array($catalogue['date_created'])) {
                     $value = $dateFormat->format($catalogue['date_created'], 'I', $dateFormat->getInputPattern('g'));
                 } else {
                     $value_array = $catalogue['date_created'];
                     $value = $value_array['year'] . '-' . $value_array['month'] . '-' . $value_array['day'] . (isset($value_array['hour']) ? ' ' . $value_array['hour'] . ':' . $value_array['minute'] . (isset($value_array['second']) ? ':' . $value_array['second'] : '') : '');
                 }
                 $this->catalogue->setDateCreated($value);
             } catch (sfException $e) {
                 // not a date
             }
         } else {
             $this->catalogue->setDateCreated(null);
         }
     }
     if (isset($catalogue['date_modified'])) {
         if ($catalogue['date_modified']) {
             try {
                 $dateFormat = new sfDateFormat($this->getUser()->getCulture());
                 if (!is_array($catalogue['date_modified'])) {
                     $value = $dateFormat->format($catalogue['date_modified'], 'I', $dateFormat->getInputPattern('g'));
                 } else {
                     $value_array = $catalogue['date_modified'];
                     $value = $value_array['year'] . '-' . $value_array['month'] . '-' . $value_array['day'] . (isset($value_array['hour']) ? ' ' . $value_array['hour'] . ':' . $value_array['minute'] . (isset($value_array['second']) ? ':' . $value_array['second'] : '') : '');
                 }
                 $this->catalogue->setDateModified($value);
             } catch (sfException $e) {
                 // not a date
             }
         } else {
             $this->catalogue->setDateModified(null);
         }
     }
     if (isset($catalogue['author'])) {
         $this->catalogue->setAuthor($catalogue['author']);
     }
 }
Exemplo n.º 11
0
 protected function updateParametroFromRequest()
 {
     $parametro = $this->getRequestParameter('parametro');
     if (isset($parametro['nombre']) && $parametro['nombre']) {
         $this->parametro->setNombre($parametro['nombre']);
     }
     if (isset($parametro['numero']) && $parametro['numero'] != '') {
         $this->parametro->setNumero($parametro['numero']);
     }
     if (isset($parametro['numero2']) && $parametro['numero2']) {
         $this->parametro->setNumero2($parametro['numero2']);
     }
     if (isset($parametro['cadena']) && $parametro['cadena']) {
         $this->parametro->setCadena($parametro['cadena']);
     }
     if (isset($parametro['cadena1']) && $parametro['cadena1']) {
         $this->parametro->setCadena1($parametro['cadena1']);
     }
     if (isset($parametro['si_no'])) {
         $this->parametro->setSiNo($parametro['si_no'] ? 1 : 0);
     } else {
         $this->parametro->setSiNo(null);
     }
     if (isset($parametro['fecha'])) {
         if ($parametro['fecha']) {
             try {
                 $dateFormat = new sfDateFormat($this->getUser()->getCulture());
                 if (!is_array($parametro['fecha'])) {
                     $value = $dateFormat->format($parametro['fecha'], 'I', $dateFormat->getInputPattern('g'));
                 } else {
                     $value_array = $parametro['fecha'];
                     $value = $value_array['year'] . '-' . $value_array['month'] . '-' . $value_array['day'];
                     $value .= isset($value_array['hour']) ? ' ' . $value_array['hour'] . ':' . $value_array['minute'] . (isset($value_array['second']) ? ':' . $value_array['second'] : '') : '';
                 }
                 $this->parametro->setFecha($value);
             } catch (sfException $e) {
                 // not a date
             }
         } else {
             $this->documento->setFecha(null);
         }
     }
 }
Exemplo n.º 12
0
 /**
  * @param  string $name        The element name
  * @param  string $value       The value displayed in this widget
  * @param  array  $attributes  An array of HTML attributes to be merged with the default HTML attributes
  * @param  array  $errors      An array of errors for the field
  *
  * @return string An HTML tag string
  *
  * @see sfWidgetForm
  */
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $df = new sfDateFormat();
     return $this->renderTag('input', array_merge(array('type' => $this->getOption('type'), 'name' => $name, 'class' => $this->getOption('class'), 'value' => $df->format($value, $this->getOption('format'))), $attributes));
 }
Exemplo n.º 13
0
            break;
        case '7':
            $activar_repeticion = true;
            $seleccion_7 = true;
            $seleccion_5 = $seleccion_6 = $seleccion_4 = false;
            $mostrar_div_anual = "";
            break;
    }
    if ($evento->getRecurrenciaFin() != "") {
        if (is_numeric($evento->getRecurrenciaFin())) {
            $recurrencia_fin_fecha = '';
            $recurrencia_fin_repeticion = $evento->getRecurrenciaFin();
            $recurrencia_fin_2 = $recurrencia_fin_0 = false;
            $recurrencia_fin_1 = true;
        } else {
            $dateFormat = new sfDateFormat($sf_user->getCulture());
            $value = $dateFormat->format($evento->getRecurrenciaFin() . " 00:00:00", 'I', $dateFormat->getInputPattern('g'));
            $recurrencia_fin_fecha = $value;
            $recurrencia_fin_repeticion = '';
            $recurrencia_fin_2 = true;
            $recurrencia_fin_0 = $recurrencia_fin_1 = false;
        }
    }
    $numero_binario = str_pad(decbin($evento->getRecurrenciaDias()), 7, "0", STR_PAD_LEFT);
}
?>

<script type="text/javascript">
    function cambiarDeEstado(element) {
        if (document.getElementById(element).disabled == true)
            document.getElementById(element).disabled=false;
Exemplo n.º 14
0
/**
 * Returns an XHTML compliant <input> tag to be used as a free-text date field.
 *
 * You can easily implement a JavaScript calendar by enabling the 'rich' option in the
 * <i>$options</i> parameter.  This includes a button next to the field that when clicked,
 * will open an inline JavaScript calendar.  When a date is selected, it will automatically
 * populate the <input> tag with the proper date, formatted to the user's culture setting.
 * Symfony also conveniently offers the input_date_range_tag, that allows you to specify a to
 * and from date.
 *
 * <b>Options:</b>
 * - rich - If set to true, includes an inline JavaScript calendar can auto-populate the date field with the chosen date
 *
 * <b>Examples:</b>
 * <code>
 *  echo input_date_tag('date', null, array('rich' => true));
 * </code>
 *
 * @param  string field name
 * @param  string date
 * @param  array  additional HTML compliant <input> tag parameters
 * @return string XHTML compliant <input> tag with optional JS calendar integration
 * @see input_date_range_tag
 */
function input_date_tag($name, $value = null, $options = array())
{
    $options = _parse_attributes($options);
    $context = sfContext::getInstance();
    $culture = _get_option($options, 'culture', $context->getUser()->getCulture());
    $withTime = _get_option($options, 'withtime', false);
    // rich control?
    if (!_get_option($options, 'rich', false)) {
        use_helper('DateForm');
        // set culture for month tag
        $options['culture'] = $culture;
        if ($withTime) {
            return select_datetime_tag($name, $value, $options, isset($options['html']) ? $options['html'] : array());
        } else {
            return select_date_tag($name, $value, $options, isset($options['html']) ? $options['html'] : array());
        }
    }
    $pattern = _get_option($options, 'format', $withTime ? 'g' : 'd');
    $dateFormat = new sfDateFormat($culture);
    $pattern = $dateFormat->getInputPattern($pattern);
    // parse date
    if ($value === null || $value === '') {
        $value = '';
    } else {
        $value = $dateFormat->format($value, $pattern);
    }
    // register our javascripts and stylesheets
    $langFile = sfConfig::get('sf_calendar_web_dir') . '/lang/calendar-' . strtolower(substr($culture, 0, 2));
    $jss = array(sfConfig::get('sf_calendar_web_dir') . '/calendar', is_readable(sfConfig::get('sf_symfony_data_dir') . '/web/' . $langFile . '.js') || is_readable(sfConfig::get('sf_web_dir') . '/' . $langFile . '.js') ? $langFile : sfConfig::get('sf_calendar_web_dir') . '/lang/calendar-en', sfConfig::get('sf_calendar_web_dir') . '/calendar-setup');
    foreach ($jss as $js) {
        $context->getResponse()->addJavascript($js);
    }
    // css
    if ($calendar_style = _get_option($options, 'css', 'skins/depsos/theme')) {
        $context->getResponse()->addStylesheet(sfConfig::get('sf_calendar_web_dir') . '/' . $calendar_style);
    }
    // date format
    $date_format = $dateFormat->getPattern($pattern);
    // calendar date format
    $calendar_date_format = $date_format;
    $calendar_date_format = strtr($date_format, array('yyyy' => 'Y', 'yy' => 'y', 'MM' => 'm', 'M' => 'm', 'dd' => 'd', 'd' => 'e', 'HH' => 'H', 'H' => 'k', 'hh' => 'I', 'h' => 'l', 'mm' => 'M', 'ss' => 'S', 'a' => 'p'));
    $calendar_date_format = preg_replace('/([mdyhklspe])+/i', '%\\1', $calendar_date_format);
    $id_inputField = isset($options['id']) ? $options['id'] : get_id_from_name($name);
    $id_calendarButton = 'trigger_' . $id_inputField;
    $js = '
    document.getElementById("' . $id_calendarButton . '").disabled = false;
    Calendar.setup({
      inputField : "' . $id_inputField . '",
      ifFormat : "' . $calendar_date_format . '",
      daFormat : "' . $calendar_date_format . '",
      button : "' . $id_calendarButton . '"';
    if ($withTime) {
        $js .= ",\n showsTime : true";
    }
    // calendar options
    if ($calendar_options = _get_option($options, 'calendar_options')) {
        $js .= ",\n" . $calendar_options;
    }
    $js .= '
    });
  ';
    // calendar button
    $calendar_button = '...';
    $calendar_button_type = 'txt';
    if ($calendar_button_img = _get_option($options, 'calendar_button_img')) {
        $calendar_button = $calendar_button_img;
        $calendar_button_type = 'img';
    } else {
        if ($calendar_button_txt = _get_option($options, 'calendar_button_txt')) {
            $calendar_button = $calendar_button_txt;
            $calendar_button_type = 'txt';
        }
    }
    // construct html
    if (!isset($options['size'])) {
        // educated guess about the size
        $options['size'] = strlen($date_format) + 2;
    }
    $html = input_tag($name, $value, $options);
    if ($calendar_button_type == 'img') {
        $html .= image_tag($calendar_button, array('id' => $id_calendarButton, 'style' => 'cursor: pointer; vertical-align: middle'));
    } else {
        $html .= content_tag('button', $calendar_button, array('type' => 'button', 'disabled' => 'disabled', 'onclick' => 'return false', 'id' => $id_calendarButton));
    }
    if (_get_option($options, 'with_format')) {
        $html .= '(' . $date_format . ')';
    }
    // add javascript
    $html .= content_tag('script', $js, array('type' => 'text/javascript'));
    return $html;
}
Exemplo n.º 15
0
function zz_input_date_tag($name, $value, $options = array())
{
    $options = _parse_attributes($options);
    $context = sfContext::getInstance();
    if (isset($options['culture'])) {
        $culture = $options['culture'];
        unset($options['culture']);
    } else {
        $culture = $context->getUser()->getCulture();
    }
    // rich control?
    $rich = false;
    if (isset($options['rich'])) {
        $rich = $options['rich'];
        unset($options['rich']);
    }
    if (!$rich) {
        throw new sfException('input_date_tag (rich=off) is not yet implemented');
    }
    $date_pattern = 'p';
    if (isset($options['date_pattern'])) {
        $date_pattern = $options['date_pattern'];
        unset($options['date_pattern']);
    }
    // parse date
    if ($value === null || $value === '') {
        $value = '';
    } else {
        $dateFormat = new sfDateFormat($culture);
        $value = $dateFormat->format($value, $date_pattern);
    }
    // register our javascripts and stylesheets
    $langFile = '/sf/js/calendar/lang/calendar-' . strtolower(substr($culture, 0, 2));
    $jss = array('/sf/js/calendar/calendar', is_readable(sfConfig::get('sf_symfony_data_dir') . '/web/' . $langFile . '.js') ? $langFile : '/sf/js/calendar/lang/calendar-en', '/sf/js/calendar/calendar-setup');
    foreach ($jss as $js) {
        $context->getResponse()->addJavascript($js);
    }
    $context->getResponse()->addStylesheet('/sf/js/calendar/skins/aqua/theme');
    // date format
    $dateFormatInfo = sfDateTimeFormatInfo::getInstance($culture);
    $date_format = strtolower($dateFormatInfo->getShortDatePattern());
    // calendar date format
    $calendar_date_format = $date_format;
    $calendar_date_format = strtr($calendar_date_format, array('M' => 'm', 'y' => 'Y'));
    $calendar_date_format = preg_replace('/([mdy])+/i', '%\\1', $calendar_date_format);
    $js = '
    document.getElementById("trigger_' . $name . '").disabled = false;
    Calendar.setup({
      inputField : "' . get_id_from_name($name) . '",
      ifFormat : "' . $calendar_date_format . '",
      button : "trigger_' . $name . '"
    });
  ';
    // construct html
    if (!isset($options['size'])) {
        $options['size'] = 9;
    }
    $html = input_tag($name, $value, $options);
    // calendar button
    $calendar_button = '...';
    $calendar_button_type = 'txt';
    if (isset($options['calendar_button_img'])) {
        $calendar_button = $options['calendar_button_img'];
        $calendar_button_type = 'img';
        unset($options['calendar_button_img']);
    } else {
        if (isset($options['calendar_button_txt'])) {
            $calendar_button = $options['calendar_button_txt'];
            $calendar_button_type = 'txt';
            unset($options['calendar_button_txt']);
        }
    }
    if ($calendar_button_type == 'img') {
        $html .= image_tag($calendar_button, array('id' => 'trigger_' . $name, 'style' => 'cursor: pointer; vertical-align: middle'));
    } else {
        $html .= content_tag('button', $calendar_button, array('type' => 'button', 'disabled' => 'disabled', 'onclick' => 'return false', 'id' => 'trigger_' . $name));
    }
    if (isset($options['with_format'])) {
        $html .= '(' . $date_format . ')';
        unset($options['with_format']);
    }
    // add javascript
    $html .= content_tag('script', $js, array('type' => 'text/javascript'));
    return $html;
}
 /**
  * caluculates the age of the kuser according to his date_of_birth
  */
 public function getAge()
 {
     $now_year = date("Y");
     $dateFormat = new sfDateFormat();
     $dob = $this->getDateOfBirth();
     if ($dob != null && $dob != "0000-00-00") {
         $yob = $dateFormat->format($dob, 'Y');
         return $now_year - $yob;
     }
     return null;
 }
/**
 * fetch today's news regarding objects monitored by the user
 * today's news are last 24h's news
 *
 * @param string $user - OppUser object
 * @return void
 * @author Guglielmo Celata
 */
function opp_test_single_newsletter($user, $date = null)
{
    $start_time = microtime(true);
    $df = new sfDateFormat('it_IT');
    echo pakeColor::colorize(sprintf('date: %s, name: %s... ', is_null($date) ? 'Today' : $date, $user), array('fg' => 'red', 'bold' => true));
    $news_c = oppNewsPeer::getTodayNewsForUserCriteria($user, $date);
    $news_c->add(oppNewsPeer::PRIORITY, 2, Criteria::LESS_EQUAL);
    $news = oppNewsPeer::doSelect($news_c);
    // raggruppa le news per data
    $grouped_news = array();
    foreach ($news as $n) {
        $date = strtotime($n->getDate());
        if (!is_string($date) && !is_int($date)) {
            $date = 0;
        }
        if (!array_key_exists($date, $grouped_news)) {
            $grouped_news[$date] = array();
        }
        $grouped_news[$date][] = $n;
    }
    krsort($grouped_news);
    echo pakeColor::colorize(sprintf("(%d)\n", count($news)), array('fg' => 'cyan'));
    if (count($news) > 0) {
        echo pakeColor::colorize(sprintf("\t    |        ID | CREATED_AT      | REL_MODEL |    REL_ID |      GENERATOR_MODEL | P |\n"), array('fg' => 'cyan', 'bold' => true));
    }
    foreach ($grouped_news as $date_ts => $news) {
        echo pakeColor::colorize(sprintf("%2d/%3s/%4d\n", $df->format($date_ts, 'dd'), $df->format($date_ts, 'MMM'), $df->format($date_ts, 'yyyy')), array('fg' => 'cyan', 'bold' => true));
        foreach ($news as $i => $n) {
            echo pakeColor::colorize(sprintf("\t%3d | %9d | %10s | %10s | %9d | %20s | %1d |\n", $i + 1, $n->getId(), $n->getCreatedAt('y-m-d H:i'), $n->getRelatedMonitorableModel(), $n->getRelatedMonitorableId(), $n->getGeneratorModel(), $n->getPriority()));
        }
    }
    echo "\n";
    $execution_time = microtime(true) - $start_time;
    if (isset($raw_email) && $raw_email != '') {
        echo " ok (";
    } else {
        echo " no mail (";
    }
    echo pakeColor::colorize(sprintf("%f", $execution_time), array('fg' => 'cyan'));
    echo ")\n";
}