/** * search asset * @param sfWebRequest $request */ public function executeSearch(sfWebRequest $request) { $this->form = new sfAssetFormFilter(); $this->form->bind($request->getParameter($this->form->getName())); $this->filterform = new sfAssetFormFilter(); // We keep the search params in the session for easier pagination if ($request->hasParameter('search_params')) { $search_params = $request->getParameter('search_params'); if (isset($search_params['created_at']['from']) && $search_params['created_at']['from'] !== '') { $search_params['created_at']['from'] = sfI18N::getTimestampForCulture($search_params['created_at']['from'], $this->getUser()->getCulture()); } if (isset($search_params['created_at']['to']) && $search_params['created_at']['to'] !== '') { $search_params['created_at']['to'] = sfI18N::getTimestampForCulture($search_params['created_at']['to'], $this->getUser()->getCulture()); } $this->getUser()->getAttributeHolder()->removeNamespace('sf_admin/sf_asset/search_params'); $this->getUser()->getAttributeHolder()->add($search_params, 'sf_admin/sf_asset/search_params'); } $this->search_params = $this->getUser()->getAttributeHolder()->getAll('sf_admin/sf_asset/search_params'); if ($this->form->isValid()) { $c = $this->processSearch($this->form->getValues(), $request); } else { $c = new Criteria(); } $pager = new sfPropelPager('sfAsset', sfConfig::get('app_sfAssetsLibrary_search_pager_size', 20)); $pager->setCriteria($c); $pager->setPage($request->getParameter('page', 1)); $pager->setPeerMethod('doSelectJoinsfAssetFolder'); $pager->init(); $this->pager = $pager; $this->removeLayoutIfPopup($request); }
/** * search asset * @param sfWebRequest $request */ public function executeSearch(sfWebRequest $request) { $this->form = new sfAssetFormFilter(); $this->form->bind($request->getParameter($this->form->getName())); $this->filterform = new sfAssetFormFilter(); // We keep the search params in the session for easier pagination if ($request->hasParameter('search_params')) { $searchParams = $request->getParameter('search_params'); if (isset($searchParams['created_at']['from']) && $searchParams['created_at']['from'] !== '') { $searchParams['created_at']['from'] = sfI18N::getTimestampForCulture($searchParams['created_at']['from'], $this->getUser()->getCulture()); } if (isset($searchParams['created_at']['to']) && $searchParams['created_at']['to'] !== '') { $searchParams['created_at']['to'] = sfI18N::getTimestampForCulture($searchParams['created_at']['to'], $this->getUser()->getCulture()); } $this->getUser()->getAttributeHolder()->removeNamespace('sf_admin/sf_asset/search_params'); $this->getUser()->getAttributeHolder()->add($searchParams, 'sf_admin/sf_asset/search_params'); } $this->search_params = $this->getUser()->getAttributeHolder()->getAll('sf_admin/sf_asset/search_params'); $sort = $this->processSort($request); $params = $this->form->isValid() ? $this->form->getValues() : array(); $this->pager = $this->assetProvider->getPager($params, $sort, $request->getParameter('page', 1), sfConfig::get('app_sfAssetsLibrary_search_pager_size', 20)); $this->removeLayoutIfPopup($request); }
$t->is($i18n->__('unknown'), '[T]unknown[/T]', '->__() adds a prefix and a suffix on untranslated strings if debug is on'); $i18n = new sfI18N($configuration, $cache, array('debug' => true, 'untranslated_prefix' => '-', 'untranslated_suffix' => '#')); $t->is($i18n->__('unknown'), '-unknown#', '->initialize() can change the default prefix and suffix dor untranslated strings'); // ->getCountry() $t->diag('->getCountry()'); $i18n = new sfI18N($configuration, $cache, array('culture' => 'fr')); $t->is($i18n->getCountry('FR'), 'France', '->getCountry() returns the name of a country for the current culture'); $t->is($i18n->getCountry('FR', 'es'), 'Francia', '->getCountry() takes an optional culture as its second argument'); // ->getNativeName() $t->diag('->getNativeName()'); $i18n = new sfI18N($configuration, $cache, array('culture' => 'fr')); $t->is($i18n->getNativeName('fr'), 'français', '->getNativeName() returns the name of a culture'); // ->getTimestampForCulture() $t->diag('->getTimestampForCulture()'); $i18n = new sfI18N($configuration, $cache, array('culture' => 'fr')); $t->is($i18n->getTimestampForCulture('15/10/2005'), mktime(0, 0, 0, '10', '15', '2005'), '->getTimestampForCulture() returns the timestamp for a data formatted in the current culture'); $t->is($i18n->getTimestampForCulture('15/10/2005 15:33'), mktime(15, 33, 0, '10', '15', '2005'), '->getTimestampForCulture() returns the timestamp for a data formatted in the current culture'); $t->is($i18n->getTimestampForCulture('10/15/2005', 'en_US'), mktime(0, 0, 0, '10', '15', '2005'), '->getTimestampForCulture() can take a culture as its second argument'); $t->is($i18n->getTimestampForCulture('10/15/2005 15:33', 'en_US'), mktime(15, 33, 0, '10', '15', '2005'), '->getTimestampForCulture() can take a culture as its second argument'); $t->is($i18n->getTimestampForCulture('not a date'), null, '->getTimestampForCulture() returns the day, month and year for a data formatted in the current culture'); // ->getDateForCulture() $t->diag('->getDateForCulture()'); $i18n = new sfI18N($configuration, $cache, array('culture' => 'fr')); $t->is($i18n->getDateForCulture('15/10/2005'), array('15', '10', '2005'), '->getDateForCulture() returns the day, month and year for a data formatted in the current culture'); $t->is($i18n->getDateForCulture('10/15/2005', 'en_US'), array('15', '10', '2005'), '->getDateForCulture() can take a culture as its second argument'); $t->is($i18n->getDateForCulture(null), null, '->getDateForCulture() returns null in case of conversion problem'); $t->is($i18n->getDateForCulture('not a date'), null, '->getDateForCulture() returns null in case of conversion problem'); // ->getTimeForCulture() $t->diag('->getTimeForCulture()'); $i18n = new sfI18N($configuration, $cache, array('culture' => 'fr')); $t->is($i18n->getTimeForCulture('15:33'), array('15', '33'), '->getTimeForCulture() returns the hour and minuter for a time formatted in the current culture');
<?php /* * This file is part of the symfony package. * (c) 2004-2006 Fabien Potencier <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ require_once dirname(__FILE__) . '/../../bootstrap/unit.php'; require_once sfConfig::get('sf_symfony_lib_dir') . '/i18n/sfI18N.class.php'; $t = new lime_test(9, new lime_output_color()); $t->diag('i18n'); $i18n = sfI18n::getInstance(); $time = mktime(10, 30, 0, 8, 1, 2008); $t->is(sfI18N::getTimestampForCulture('01/08/2008 10:30', 'fr'), $time, '->getTimestampForCulture() returns the timestamp for a data formatted in the current culture'); $t->is(sfI18N::getTimestampForCulture('08/01/2008 10:30', 'en_US'), $time, '->getTimestampForCulture() returns the timestamp for a data formatted in the current culture'); $t->is(sfI18N::getTimestampForCulture('08/01/2008', 'en_US'), mktime(0, 0, 0, 8, 1, 2008), '->getTimestampForCulture() returns the timestamp for a data formatted in the current culture'); $t->is(sfI18N::getTimestampForCulture('', 'en_US'), mktime(0, 0, 0, 0, 0, 0), '->getTimestampForCulture() returns the timestamp for a data formatted in the current culture'); $t->is(sfI18N::getTimestampForCulture('not a date', 'en_US'), mktime(0, 0, 0, 0, 0, 0), '->getTimestampForCulture() returns the timestamp for a data formatted in the current culture'); $t->is(sfI18N::getTimestampForCulture('10:30', 'en_US'), mktime(10, 30, 0, 0, 0, 0), '->getTimestampForCulture() returns the timestamp for a data formatted in the current culture'); $t->is(sfI18N::getDateForCulture('01/08/2008 10:30', 'fr'), array(1, 8, 2008), '->getDateForCulture() returns the day, month and year for a data formatted in the current culture'); $t->is(sfI18N::getDateForCulture('08/01/2008 10:30', 'en_US'), array(1, 8, 2008), '->getDateForCulture() returns the day, month and year for a data formatted in the current culture'); $t->is(sfI18N::getDateForCulture('not a date', 'en_US'), null, '->getTimeForCulture() returns null in case of conversion problem');