当前位置: 首页>>代码示例>>PHP>>正文


PHP myDoctrineRecord::getDefaultCulture方法代码示例

本文整理汇总了PHP中myDoctrineRecord::getDefaultCulture方法的典型用法代码示例。如果您正苦于以下问题:PHP myDoctrineRecord::getDefaultCulture方法的具体用法?PHP myDoctrineRecord::getDefaultCulture怎么用?PHP myDoctrineRecord::getDefaultCulture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在myDoctrineRecord的用法示例。


在下文中一共展示了myDoctrineRecord::getDefaultCulture方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: withI18n

 /**
  * Join translation results if they exist
  * if $model is specified, will verify that it has I18n
  * return @myDoctrineQuery $this
  */
 public function withI18n($culture = null, $model = null, $rootAlias = null, $joinSide = 'left')
 {
     if (null === $model) {
         $_rootAlias = $this->getRootAlias();
         $from = explode(' ', $this->_dqlParts['from'][0]);
         $model = $from[0];
         if (strlen($model) === 0) {
             $this->getRootAlias();
             $models = array_keys($this->_queryComponents);
             $model = $models[0];
         }
     }
     if (!dmDb::table($model)->hasI18n()) {
         return $this;
     }
     $culture = null === $culture ? myDoctrineRecord::getDefaultCulture() : $culture;
     if (null === $rootAlias) {
         // refresh query for introspection
         if (empty($this->_execParams)) {
             //prevent bugs for subqueries
             $this->fixArrayParameterValues($this->_params);
         }
         $this->buildSqlQuery();
         $rootAlias = $this->getRootAlias();
         $translationAlias = $rootAlias . 'Translation';
         // i18n already joined
         if ($this->hasAliasDeclaration($translationAlias)) {
             return $this;
         }
     } else {
         $translationAlias = $rootAlias . 'Translation';
     }
     $joinMethod = $joinSide . 'Join';
     return $this->{$joinMethod}($rootAlias . '.Translation ' . $translationAlias . ' ON ' . $rootAlias . '.id = ' . $translationAlias . '.id AND ' . $translationAlias . '.lang = ?', $culture);
 }
开发者ID:theolymp,项目名称:diem,代码行数:40,代码来源:dmDoctrineQuery.php

示例2: filterSet

 /**
  * Implementation of filterSet() to call set 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 filterSet(Doctrine_Record $record, $fieldName, $value)
 {
     $translation = $record->get('Translation');
     $culture = myDoctrineRecord::getDefaultCulture();
     if ($translation->contains($culture)) {
         $i18n = $record->get('Translation')->get($culture);
     } else {
         $i18n = $record->get('Translation')->get($culture);
         /*
          * If translation is new
          * populate it with i18n fallback
          */
         if ($i18n->state() == Doctrine_Record::STATE_TDIRTY) {
             if ($fallback = $record->getI18nFallBack()) {
                 $fallBackData = $fallback->toArray();
                 unset($fallBackData['id'], $fallBackData['lang']);
                 $i18n->fromArray($fallBackData);
             }
         }
     }
     if (!ctype_lower($fieldName) && !$i18n->contains($fieldName)) {
         $underscoredFieldName = dmString::underscore($fieldName);
         if (strpos($underscoredFieldName, '_') !== false && $i18n->contains($underscoredFieldName)) {
             $fieldName = $underscoredFieldName;
         }
     }
     $i18n->set($fieldName, $value);
     return $value;
 }
开发者ID:theolymp,项目名称:diem,代码行数:38,代码来源:dmDoctrineRecordI18nFilter.class.php

示例3: createPageTranslations

 protected function createPageTranslations($pageId)
 {
     $cultures = $this->getOption('cultures');
     $translationTable = dmDb::table('DmPageTranslation');
     $existingCultures = $translationTable->createQuery('t')->where('t.id = ? ', $pageId)->andWhereIn('t.lang', $cultures)->select('t.lang')->fetchFlat();
     // can not generate translations from nothing
     if (empty($existingCultures)) {
         return;
     }
     // calculate missing cultures for this page
     $missingCultures = array_diff($cultures, $existingCultures);
     // all translations exist
     if (empty($missingCultures)) {
         return;
     }
     if (in_array(sfConfig::get('sf_default_culture'), $existingCultures)) {
         $mainCulture = sfConfig::get('sf_default_culture');
     } elseif (in_array(myDoctrineRecord::getDefaultCulture(), $existingCultures)) {
         $mainCulture = myDoctrineRecord::getDefaultCulture();
     } else {
         $mainCulture = dmArray::first($existingCultures);
     }
     $mainTranslationArray = $translationTable->createQuery('t')->select('t.slug, t.name, t.title, t.h1, t.description, t.keywords, t.is_active')->where('t.id = ?', $pageId)->andWhere('t.lang = ?', $mainCulture)->limit(1)->fetchOne(array(), Doctrine_Core::HYDRATE_ARRAY);
     $missingTranslations = new myDoctrineCollection(dmDb::table('DmPageTranslation'));
     if ($this->getOption('activate_new_translations')) {
         $isActive = $mainTranslationArray['is_active'];
     } else {
         $isActive = false;
     }
     foreach ($missingCultures as $culture) {
         $missingTranslations->add($translationTable->create(array_merge($mainTranslationArray, array('lang' => $culture, 'is_active' => $isActive))));
     }
     $missingTranslations->save();
 }
开发者ID:theolymp,项目名称:diem,代码行数:34,代码来源:dmPageI18nBuilder.php

示例4: execute

 public function execute(array $onlyModules, $culture)
 {
     $this->setCulture($culture);
     $recordDefaultCulture = myDoctrineRecord::getDefaultCulture();
     myDoctrineRecord::setDefaultCulture($this->culture);
     if (empty($onlyModules)) {
         $onlyModules = $this->moduleManager->getProjectModules();
     } elseif (is_string(dmArray::first($onlyModules))) {
         $onlyModules = $this->moduleManager->keysToModules($onlyModules);
     }
     $onlyModules = dmModuleManager::removeModulesChildren($onlyModules);
     foreach ($onlyModules as $module) {
         $this->updateRecursive($module);
     }
     myDoctrineRecord::setDefaultCulture($recordDefaultCulture);
 }
开发者ID:rafaelgou,项目名称:diem,代码行数:16,代码来源:dmSeoSynchronizer.php

示例5: createFromModuleAndAction

 /**
  * @return DmAutoSeo created record
  */
 public function createFromModuleAndAction($module, $action, $culture = null)
 {
     $module = $this->getModuleManager()->getModule($module);
     $moduleUnderscore = $module->getUnderscore();
     $identifierColumnName = $module->getTable()->getIdentifierColumnName();
     $culture = null === $culture ? myDoctrineRecord::getDefaultCulture() : $culture;
     if ('id' == $identifierColumnName) {
         $column = '';
     } else {
         $column = '.' . $identifierColumnName;
     }
     $descriptionColumnCandidates = array('excerpt', 'resume', 'description', 'body', 'text');
     $descriptionColumn = $column;
     foreach ($descriptionColumnCandidates as $descriptionColumnCandidate) {
         if ($module->getTable()->hasField($descriptionColumnCandidate)) {
             $descriptionColumn = '.' . $descriptionColumnCandidate;
             break;
         }
     }
     return $this->create(array('module' => $module->getKey(), 'action' => $action, 'Translation' => array($culture => array('slug' => '%' . $moduleUnderscore . $column . '%', 'name' => '%' . $moduleUnderscore . $column . '%', 'title' => '%' . $moduleUnderscore . $column . '%', 'description' => '%' . $moduleUnderscore . $descriptionColumn . '%', 'lang' => $culture))));
 }
开发者ID:theolymp,项目名称:diem,代码行数:24,代码来源:PluginDmAutoSeoTable.class.php

示例6: withI18n

 /**
  * Join translation results if they exist
  * if $model is specified, will verify that it has I18n
  * return @myDoctrineQuery $this
  */
 public function withI18n($culture = null, $model = null, $rootAlias = null)
 {
     if (null !== $model) {
         if (!dmDb::table($model)->hasI18n()) {
             return $this;
         }
     }
     if (null === $rootAlias) {
         // refresh query for introspection
         $this->buildSqlQuery();
         $rootAlias = $this->getRootAlias();
         $translationAlias = $rootAlias . 'Translation';
         // i18n already joined
         if ($this->hasAliasDeclaration($translationAlias)) {
             return $this;
         }
     } else {
         $translationAlias = $rootAlias . 'Translation';
     }
     $culture = null === $culture ? myDoctrineRecord::getDefaultCulture() : $culture;
     return $this->leftJoin($rootAlias . '.Translation ' . $translationAlias . ' ON ' . $rootAlias . '.id = ' . $translationAlias . '.id AND ' . $translationAlias . '.lang = ?', $culture);
 }
开发者ID:jdart,项目名称:diem,代码行数:27,代码来源:dmDoctrineQuery.php

示例7: joinRelations

 /**
  * Will join named relations
  */
 public function joinRelations(array $aliases, $withI18n = false)
 {
     $rootAlias = $query->getRootAlias();
     foreach ($aliases as $alias) {
         if (!($relation = $this->getRelationHolder()->get($alias))) {
             throw new dmException(sprintf('%s is not a valid alias for the table %s', $alias, $this->getComponentName()));
         }
         if ($relation->getAlias() === 'Translation') {
             $query->withI18n();
         } elseif ($relation->getClass() === 'DmMedia') {
             $mediaJoinAlias = dmString::lcfirst($relation->getAlias());
             $query->leftJoin(sprintf('%s.%s %s', $rootAlias, $relation->getAlias(), $mediaJoinAlias))->leftJoin(sprintf('%s.%s %s', $mediaJoinAlias, 'Folder', $mediaJoinAlias . 'Folder'));
         } else {
             $joinAlias = dmString::lcfirst($relation->getAlias());
             $query->leftJoin(sprintf('%s.%s %s', $rootAlias, $relation->getAlias(), $joinAlias));
             if ($withI18n && $relation->getTable()->hasI18n()) {
                 $joinTranslationAlias = $joinAlias . 'Translation';
                 $query->leftJoin($joinAlias . '.Translation ' . $joinTranslationAlias . ' ON ' . $joinAlias . '.id = ' . $joinTranslationAlias . '.id AND ' . $joinTranslationAlias . '.lang = ?', myDoctrineRecord::getDefaultCulture());
             }
         }
     }
     return $query;
 }
开发者ID:Regmaya,项目名称:diem,代码行数:26,代码来源:dmDoctrineTable.php

示例8: dirname

<?php

require_once dirname(__FILE__) . '/helper/dmUnitTestHelper.php';
$helper = new dmUnitTestHelper();
$helper->boot();
$t = new lime_test(24);
$t->diag('default culture tests');
$user = $helper->get('user');
$userCulture = $user->getCulture();
$t->is(myDoctrineRecord::getDefaultCulture(), $user->getCulture(), 'default culture is ' . $user->getCulture());
$user->setCulture('en');
$t->is(myDoctrineRecord::getDefaultCulture(), $user->getCulture(), 'default culture is ' . $user->getCulture());
$user->setCulture('es');
$t->is(myDoctrineRecord::getDefaultCulture(), $user->getCulture(), 'default culture is ' . $user->getCulture());
$user->setCulture($userCulture);
$t->is(myDoctrineRecord::getDefaultCulture(), $user->getCulture(), 'default culture is ' . $user->getCulture());
$t->diag('Basic record tests');
$layout = dmDb::create('DmLayout', array('name' => dmString::random(), 'css_class' => 'the_class'))->saveGet();
$t->ok($layout instanceof DmLayout, 'call saveGet() returns the record');
$t->is(dmDb::create('DmLayout')->orNull(), null, 'call orNull() on new record returns null');
$t->is($layout->orNull(), $layout, 'call orNull() on existing record returns the record');
$t->diag('Property access tests');
$t->is($layout->get('css_class'), 'the_class', '->get("css_class")');
$t->is($layout->getCssClass(), 'the_class', '->getCssClass()');
$t->is($layout->css_class, 'the_class', '->css_class');
$t->is($layout->cssClass, 'the_class', '->cssClass');
$t->is($layout['cssClass'], 'the_class', '["css_class"]');
$t->ok($layout->set('css_class', 'other_class'), '->set("css_class")');
$t->ok($layout->setCssClass('other_class'), '->setCssClass()');
$t->ok($layout->css_class = 'other_class', '->css_class');
$t->ok($layout->cssClass = 'other_class', '->cssClass');
开发者ID:theolymp,项目名称:diem,代码行数:31,代码来源:dmRecordTest.php


注:本文中的myDoctrineRecord::getDefaultCulture方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。