本文整理汇总了PHP中sfDoctrineRecord::getDefaultCulture方法的典型用法代码示例。如果您正苦于以下问题:PHP sfDoctrineRecord::getDefaultCulture方法的具体用法?PHP sfDoctrineRecord::getDefaultCulture怎么用?PHP sfDoctrineRecord::getDefaultCulture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfDoctrineRecord
的用法示例。
在下文中一共展示了sfDoctrineRecord::getDefaultCulture方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDocument
public function getDocument()
{
if (!$this->shouldIndex()) {
$this->getSearch()->getEventDispatcher()->notify(new sfEvent($this, 'indexer.log', array('model "%s" cancelled indexation - primary key = %s', $this->getModelName(), current($this->getModel()->identifier()))));
return false;
}
$old_culture = null;
// automatic symfony i18n detection
if ($this->getModel()->getTable()->hasRelation('Translation')) {
$old_culture = sfDoctrineRecord::getDefaultCulture();
sfDoctrineRecord::setDefaultCulture($this->getSearch()->getParameter('culture'));
}
// build document
$doc = $this->getBaseDocument();
$doc = $this->configureDocumentFields($doc);
//$doc = $this->configureDocumentCategories($doc);
$doc = $this->configureDocumentMetas($doc);
// add document
$doc->setField('sfl_guid', $this->getModelGuid());
// restore culture in symfony i18n detection
if ($old_culture) {
sfDoctrineRecord::setDefaultCulture($old_culture);
}
return $doc;
}
示例2: executeTemplate
public function executeTemplate(sfWebRequest $request)
{
$this->name = $request->getParameter('name', '');
if ('' !== $this->name) {
$this->forward404Unless(in_array($this->name, $this->generateMailTemplateNames($this->config)));
}
$obj = Doctrine::getTable('NotificationMail')->findOneByName($this->name);
if (!$obj) {
$obj = Doctrine::getTable('NotificationMail')->create(array('name' => $this->name));
}
$translation = $obj->Translation[sfDoctrineRecord::getDefaultCulture()];
$this->form = new NotificationMailTranslationForm($translation);
$this->form->updateDefaultsByConfig($this->getMailConfiguration($this->config, $this->name));
if ($this->request->isMethod(sfWebRequest::POST)) {
$this->form->bind($request->getParameter('notification_mail_translation'));
if ($this->form->isValid()) {
if (!$this->form->getObject()->exists()) {
if ($this->form->getObject()->id instanceof Doctrine_Record) {
$this->form->getObject()->id->save();
}
}
$this->form->save();
$this->getUser()->setFlash('notice', 'Saved.');
$this->redirect('@mail_template_specified?name=' . $this->name);
}
$this->getUser()->setFlash('error', (string) $this->form->getErrorSchema());
}
}
示例3: updateDatabase
/**
* Update changed documentation pages in database
*/
protected function updateDatabase($branch)
{
$types = dmDb::query('Doc d')->select('d.type')->distinct()->fetchFlat();
$cultures = sfConfig::get('dm_i18n_cultures');
$originalCulture = sfDoctrineRecord::getDefaultCulture();
foreach ($types as $type) {
foreach ($cultures as $culture) {
sfDoctrineRecord::setDefaultCulture($culture);
$dir = dmOs::join($this->repo->getDir(), $type, $culture);
$files = sfFinder::type('file')->name('/^\\d{2}\\s-\\s.+\\.markdown$/')->in($dir);
foreach ($files as $file) {
$docName = preg_replace('/^\\d{2}\\s-\\s(.+)\\.markdown$/', '$1', basename($file));
$docRecord = dmDb::query('DocPage dp')->withI18n()->innerJoin('dp.Doc doc')->innerJoin('doc.Branch branch')->where('branch.number = ?', $branch)->andWhere('doc.type = ?', $type)->andWhere('dpTranslation.name = ?', $docName)->fetchOne();
if ($docRecord) {
$docText = file_get_contents($file);
if ($docRecord->text != $docText) {
$docRecord->text = $docText;
$docRecord->save();
}
}
}
}
}
sfDoctrineRecord::setDefaultCulture($originalCulture);
}
示例4: filterGet
/**
* Call get on Translation relationship.
*
* Allow access to I18n properties from the main object.
*
* @param Doctrine_Record $record
* @param string $name Name of the property
*/
public function filterGet(Doctrine_Record $record, $name)
{
$culture = sfDoctrineRecord::getDefaultCulture();
if (isset($record['Translation'][$culture]) && '' != $record['Translation'][$culture][$name]) {
return $record['Translation'][$culture][$name];
}
$defaultCulture = sfConfig::get('sf_default_culture');
return $record['Translation'][$defaultCulture][$name];
}
示例5: withI18n
/**
* Добавить JOIN к таблице переводов
*
* @param string $alias - алиас к таблице, которую надо перевести
* @return Doctrine_Query
*/
public function withI18n($alias = null)
{
if (null === $alias) {
$alias = $this->getRootAlias();
}
$transAlias = $this->getTransAlias($alias);
//$this->innerJoin("{$alias}.Translation {$transAlias} WITH {$transAlias}.lang = ?",
$this->leftJoin("{$alias}.Translation {$transAlias} WITH {$transAlias}.lang = ?", sfDoctrineRecord::getDefaultCulture());
return $this;
}
示例6: fetchTemplate
public function fetchTemplate($templateName)
{
$object = $this->findOneByName($templateName);
if (!($object && $object->getTemplate())) {
if (($sample = $this->fetchTemplateFromConfigSample($templateName)) && $sample[1]) {
$object = new NotificationMail();
$object->Translation[sfDoctrineRecord::getDefaultCulture()]->title = $sample[0];
$object->Translation[sfDoctrineRecord::getDefaultCulture()]->template = $sample[1];
}
}
return $object;
}
示例7: withI18n
/**
* Добавить JOIN к таблице переводов
*
* @param Doctrine_Query $q
* @param string $rootAlias - алиас к таблице, которую надо перевести
* @return Doctrine_Query
*/
public function withI18n(Doctrine_Query $q = null, $rootAlias = null)
{
if (!$q) {
$q = $this->createQuery($rootAlias);
}
if (!$rootAlias) {
$rootAlias = $q->getRootAlias();
}
$transAlias = $this->getTranslationQueryAlias($rootAlias);
$q->leftJoin("{$rootAlias}.Translation {$transAlias} WITH {$transAlias}.lang = ?", sfDoctrineRecord::getDefaultCulture());
return $q;
}
示例8: filterGet
/**
* Implementation of filterGet() to call get on Translation relationship to allow
* access to I18n properties from the main object.
*
* @param Doctrine_Record $record
* @param string $name Name of the property
* @param string $value Value of the property
* @return void
*/
public function filterGet(Doctrine_Record $record, $name)
{
return $record['Translation'][sfDoctrineRecord::getDefaultCulture()][$name];
}
示例9: configure
/**
* @param string $name The element name
* @param string $value The date 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
*/
protected function configure($options = array(), $attributes = array())
{
$options['culture'] = isset($options['culture']) ? $options['culture'] : sfDoctrineRecord::getDefaultCulture();
parent::configure($options, $attributes);
$this->setOption('culture', $options['culture']);
}