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


PHP Tool::getValidLanguages方法代码示例

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


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

示例1: storeLanguage

 private function storeLanguage()
 {
     if ($this->mySessionSite->Locale) {
         \Zend_Registry::set("Zend_Locale", $this->mySessionSite->Locale);
     }
     if ($this->_getParam("lg")) {
         $locale = new \Zend_Locale($this->_getParam("lg"));
         \Zend_Registry::set("Zend_Locale", $locale);
     }
     if (\Zend_Registry::isRegistered("Zend_Locale") and $this->mySessionSite->Locale) {
         //init forcée à french à reprendre
         $locale = \Zend_Registry::get("Zend_Locale");
     } else {
         $locale = new \Zend_Locale("fr_FR");
         \Zend_Registry::set("Zend_Locale", $locale);
     }
     $this->mySessionSite->Locale = $locale;
     $this->view->language = $this->language = $locale->getLanguage();
     $languages = \Pimcore\Tool::getValidLanguages();
     $languageOptions = array();
     foreach ($languages as $short) {
         if (!empty($short)) {
             $languageOptions[] = array("language" => $short, "display" => \Zend_Locale::getTranslation($short == "fr_FR" ? "fr" : $short, 'Language', $locale));
             $validLanguages[] = $short;
         }
     }
     $this->view->languageOptions = $languageOptions;
     $this->view->isAjax = $this->isAjax();
 }
开发者ID:sgabison,项目名称:website,代码行数:29,代码来源:Action.php

示例2: languageDetectionAction

 /**
  * @throws Exception
  */
 public function languageDetectionAction()
 {
     // Get the browser language
     $locale = new Zend_Locale();
     $browserLanguage = $locale->getLanguage();
     $languages = Tool::getValidLanguages();
     // Check if the browser language is a valid frontend language
     if (in_array($browserLanguage, $languages)) {
         $language = $browserLanguage;
     } else {
         // If it is not, take the first frontend language as default
         $language = reset($languages);
     }
     // Get the folder of the current language (in the current site)
     $currentSitePath = $this->document->getRealFullPath();
     $folder = Document\Page::getByPath($currentSitePath . '/' . $language);
     if ($folder) {
         $document = $this->findFirstDocumentByParentId($folder->getId());
         if ($document) {
             $this->redirect($document->getPath() . $document->getKey());
         } else {
             throw new Exception('No document found in your browser language');
         }
     } else {
         throw new Exception('No language folder found that matches your browser language');
     }
 }
开发者ID:studioemma,项目名称:multilingual,代码行数:30,代码来源:DefaultController.php

示例3: addLanguage

 public function addLanguage($languageToAdd)
 {
     // Check if language is not already added
     if (in_array($languageToAdd, Tool::getValidLanguages())) {
         $result = false;
     } else {
         // Read all the documents from the first language
         $availableLanguages = Tool::getValidLanguages();
         $firstLanguageDocument = \Pimcore\Model\Document::getByPath('/' . reset($availableLanguages));
         \Zend_Registry::set('SEI18N_add', 1);
         // Add the language main folder
         $document = Page::create(1, array('key' => $languageToAdd, "userOwner" => 1, "userModification" => 1, "published" => true, "controller" => 'default', "action" => 'go-to-first-child'));
         $document->setProperty('language', 'text', $languageToAdd);
         // Set the language to this folder and let it inherit to the child pages
         $document->setProperty('isLanguageRoot', 'text', 1, false, false);
         // Set as language root document
         $document->save();
         // Add Link to other languages
         $t = new Keys();
         $t->insert(array("document_id" => $document->getId(), "language" => $languageToAdd, "sourcePath" => $firstLanguageDocument->getFullPath()));
         // Lets add all the docs
         $this->addDocuments($firstLanguageDocument->getId(), $languageToAdd);
         \Zend_Registry::set('SEI18N_add', 0);
         $oldConfig = Config::getSystemConfig();
         $settings = $oldConfig->toArray();
         $languages = explode(',', $settings['general']['validLanguages']);
         $languages[] = $languageToAdd;
         $settings['general']['validLanguages'] = implode(',', $languages);
         $config = new \Zend_Config($settings, true);
         $writer = new \Zend_Config_Writer_Xml(array("config" => $config, "filename" => PIMCORE_CONFIGURATION_SYSTEM));
         $writer->write();
         $result = true;
     }
     return $result;
 }
开发者ID:studioemma,项目名称:multilingual,代码行数:35,代码来源:Document.php

示例4: configureOptions

 /**
  *
  */
 public function configureOptions()
 {
     $validLanguages = (array) Tool::getValidLanguages();
     $locales = Tool::getSupportedLocales();
     $options = array();
     foreach ($locales as $short => $translation) {
         if ($this->getOnlySystemLanguages()) {
             if (!in_array($short, $validLanguages)) {
                 continue;
             }
         }
         $options[] = array("key" => $translation, "value" => $short);
     }
     $this->setOptions($options);
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:18,代码来源:Languagemultiselect.php

示例5: treeGetChildsByIdAction

 /**
  * Original function
  * @see Admin_DocumentController::treeGetChildsByIdAction()
  */
 public function treeGetChildsByIdAction()
 {
     $languages = Tool::getValidLanguages();
     $language = $this->_getParam("language", reset($languages));
     $document = Document::getById($this->getParam("node"));
     $documents = array();
     if ($document->hasChilds()) {
         $limit = intval($this->getParam("limit"));
         if (!$this->getParam("limit")) {
             $limit = 100000000;
         }
         $offset = intval($this->getParam("start"));
         $list = new Document\Listing();
         if ($this->getUser()->isAdmin()) {
             $list->setCondition("parentId = ? ", $document->getId());
         } else {
             $userIds = $this->getUser()->getRoles();
             $userIds[] = $this->getUser()->getId();
             $list->setCondition("parentId = ? and\r\n                                        (\r\n                                        (select list from users_workspaces_document where userId in (" . implode(',', $userIds) . ") and LOCATE(CONCAT(path,`key`),cpath)=1  ORDER BY LENGTH(cpath) DESC LIMIT 1)=1\r\n                                        or\r\n                                        (select list from users_workspaces_document where userId in (" . implode(',', $userIds) . ") and LOCATE(cpath,CONCAT(path,`key`))=1  ORDER BY LENGTH(cpath) DESC LIMIT 1)=1\r\n                                        )", $document->getId());
         }
         $list->setOrderKey("index");
         $list->setOrder("asc");
         $list->setLimit($limit);
         $list->setOffset($offset);
         $childsList = $list->load();
         foreach ($childsList as $childDocument) {
             // only display document if listing is allowed for the current user
             if ($childDocument->isAllowed("list")) {
                 if ($childDocument instanceof Document\Page && $childDocument->hasProperty('isLanguageRoot') && $childDocument->getProperty('isLanguageRoot') == 1) {
                     if ($childDocument->getKey() == $language) {
                         //                            $documents[] = $this->getTreeNodeConfig($childDocument);
                         $config = $this->getTreeNodeConfig($childDocument);
                         $config['expanded'] = true;
                         $documents[] = $config;
                     }
                 } else {
                     $documents[] = $this->getTreeNodeConfig($childDocument);
                 }
             }
         }
     }
     if ($this->getParam("limit")) {
         $this->_helper->json(array("offset" => $offset, "limit" => $limit, "total" => $document->getChildAmount($this->getUser()), "nodes" => $documents));
     } else {
         $this->_helper->json($documents);
     }
     $this->_helper->json(false);
 }
开发者ID:studioemma,项目名称:multilingual,代码行数:52,代码来源:IndexController.php

示例6: parse

 /**
  * @param $path
  *
  * @return string
  * @throws \Zend_Exception
  */
 public static function parse($path)
 {
     $currentCountry = NULL;
     if (\Zend_Registry::isRegistered('Website_Country')) {
         $currentCountry = \Zend_Registry::get('Website_Country');
     }
     //only parse if country in l10n is active!
     if (!is_null($currentCountry)) {
         $validLanguages = Tool::getValidLanguages();
         $currentIsoCode = strtolower($currentCountry);
         $shiftCountry = FALSE;
         $pathCountry = '';
         $globalString = 'global';
         $urlPath = parse_url($path, PHP_URL_PATH);
         $urlPathFragments = explode('/', ltrim($urlPath, '/'));
         //it's a global page, link is correct.
         if ($currentIsoCode === $globalString) {
             return $path;
         }
         if (isset($urlPathFragments[0])) {
             $pathElements = explode('-', $urlPathFragments[0]);
             //first needs to be country
             $pathCountry = isset($pathElements[0]) ? $pathElements[0] : NULL;
             //second needs to be language.
             $pathLanguage = isset($pathElements[1]) ? $pathElements[1] : NULL;
             $isValidLanguage = in_array($pathLanguage, $validLanguages);
             //if 2. fragment is invalid language and 1. fragment is valid language, 1. fragment is missing!
             $shiftCountry = $isValidLanguage == FALSE && in_array($pathCountry, $validLanguages);
         }
         //country is missing. add it.
         if ($shiftCountry) {
             $path = '/' . $currentIsoCode . '-' . ltrim($path, '/');
         } else {
             if (substr($path, 0, strlen($globalString) + 2) === '/' . $globalString . '-') {
                 $path = substr_replace($path, '/' . $currentIsoCode . '-', 0, strlen($globalString) + 2);
             }
         }
         return $path;
     }
     return $path;
 }
开发者ID:dachcom-digital,项目名称:pimcore-toolbox,代码行数:47,代码来源:GlobalLink.php

示例7: installProperties

 public function installProperties()
 {
     $defProperty = Property\Predefined::getByKey('assigned_language');
     if (!$defProperty instanceof Property\Predefined) {
         $languages = \Pimcore\Tool::getValidLanguages();
         $data = 'all,';
         foreach ($languages as $language) {
             $data .= $language . ',';
         }
         $data = rtrim($data, ',');
         $property = new Property\Predefined();
         $property->setType('select');
         $property->setName('Assigned Language');
         $property->setKey('assigned_language');
         $property->setDescription('set a specific language which lucene search should respect while crawling.');
         $property->setCtype('asset');
         $property->setData('all');
         $property->setConfig($data);
         $property->setInheritable(FALSE);
         $property->save();
     }
 }
开发者ID:dachcom-digital,项目名称:pimcore-lucene-search,代码行数:22,代码来源:Install.php

示例8: getAvailableLanguagesAction

 public function getAvailableLanguagesAction()
 {
     if ($languages = Tool::getValidLanguages()) {
         $this->_helper->json($languages);
     }
     $t = new Model\Translation\Website();
     $this->_helper->json($t->getAvailableLanguages());
 }
开发者ID:elavarasann,项目名称:pimcore,代码行数:8,代码来源:SettingsController.php

示例9: createUpdateTable

 /**
  *
  */
 public function createUpdateTable()
 {
     $table = $this->getTableName();
     $context = $this->model->getContext();
     if ($context && $context["containerType"] == "fieldcollection") {
         $this->db->query("CREATE TABLE IF NOT EXISTS `" . $table . "` (\n              `ooo_id` int(11) NOT NULL default '0',\n              `index` INT(11) NOT NULL DEFAULT '0',\n              `fieldname` VARCHAR(190) NOT NULL DEFAULT '',\n              `language` varchar(10) NOT NULL DEFAULT '',\n              PRIMARY KEY (`ooo_id`, `language`, `index`, `fieldname`),\n              INDEX `ooo_id` (`ooo_id`),\n              INDEX `index` (`index`),\n              INDEX `fieldname` (`fieldname`),\n              INDEX `language` (`language`)\n            ) DEFAULT CHARSET=utf8mb4;");
     } else {
         $this->db->query("CREATE TABLE IF NOT EXISTS `" . $table . "` (\n              `ooo_id` int(11) NOT NULL default '0',\n              `language` varchar(10) NOT NULL DEFAULT '',\n              PRIMARY KEY (`ooo_id`,`language`),\n              INDEX `ooo_id` (`ooo_id`),\n              INDEX `language` (`language`)\n            ) DEFAULT CHARSET=utf8mb4;");
     }
     $existingColumns = $this->getValidTableColumns($table, false);
     // no caching of table definition
     $columnsToRemove = $existingColumns;
     Object\ClassDefinition\Service::updateTableDefinitions($this->tableDefinitions, [$table]);
     if ($context && $context["containerType"] == "fieldcollection") {
         $protectedColumns = ["ooo_id", "language", "index", "fieldname"];
         $containerKey = $context["containerKey"];
         $container = Object\Fieldcollection\Definition::getByKey($containerKey);
     } else {
         $protectedColumns = ["ooo_id", "language"];
         $container = $this->model->getClass();
     }
     foreach ($container->getFielddefinition("localizedfields")->getFielddefinitions() as $value) {
         if ($value->getColumnType()) {
             $key = $value->getName();
             if (is_array($value->getColumnType())) {
                 // if a datafield requires more than one field
                 foreach ($value->getColumnType() as $fkey => $fvalue) {
                     $this->addModifyColumn($table, $key . "__" . $fkey, $fvalue, "", "NULL");
                     $protectedColumns[] = $key . "__" . $fkey;
                 }
             } else {
                 if ($value->getColumnType()) {
                     $this->addModifyColumn($table, $key, $value->getColumnType(), "", "NULL");
                     $protectedColumns[] = $key;
                 }
             }
             $this->addIndexToField($value, $table);
         }
     }
     $this->removeUnusedColumns($table, $columnsToRemove, $protectedColumns);
     $validLanguages = Tool::getValidLanguages();
     if ($container instanceof Object\ClassDefinition) {
         foreach ($validLanguages as &$language) {
             $queryTable = $this->getQueryTableName();
             $queryTable .= "_" . $language;
             $this->db->query("CREATE TABLE IF NOT EXISTS `" . $queryTable . "` (\n                      `ooo_id` int(11) NOT NULL default '0',\n                      `language` varchar(10) NOT NULL DEFAULT '',\n                      PRIMARY KEY (`ooo_id`,`language`),\n                      INDEX `ooo_id` (`ooo_id`),\n                      INDEX `language` (`language`)\n                    ) DEFAULT CHARSET=utf8mb4;");
             // create object table if not exists
             $protectedColumns = ["ooo_id", "language"];
             $existingColumns = $this->getValidTableColumns($queryTable, false);
             // no caching of table definition
             $columnsToRemove = $existingColumns;
             Object\ClassDefinition\Service::updateTableDefinitions($this->tableDefinitions, [$queryTable]);
             $fieldDefinitions = $this->model->getClass()->getFielddefinition("localizedfields")->getFielddefinitions();
             // add non existing columns in the table
             if (is_array($fieldDefinitions) && count($fieldDefinitions)) {
                 foreach ($fieldDefinitions as $value) {
                     if ($value->getQueryColumnType()) {
                         $key = $value->getName();
                         // if a datafield requires more than one column in the query table
                         if (is_array($value->getQueryColumnType())) {
                             foreach ($value->getQueryColumnType() as $fkey => $fvalue) {
                                 $this->addModifyColumn($queryTable, $key . "__" . $fkey, $fvalue, "", "NULL");
                                 $protectedColumns[] = $key . "__" . $fkey;
                             }
                         }
                         // everything else
                         if (!is_array($value->getQueryColumnType()) && $value->getQueryColumnType()) {
                             $this->addModifyColumn($queryTable, $key, $value->getQueryColumnType(), "", "NULL");
                             $protectedColumns[] = $key;
                         }
                         // add indices
                         $this->addIndexToField($value, $queryTable);
                     }
                 }
             }
             // remove unused columns in the table
             $this->removeUnusedColumns($queryTable, $columnsToRemove, $protectedColumns);
         }
         $this->createLocalizedViews();
     }
     $this->tableDefinitions = null;
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:85,代码来源:Dao.php

示例10: foreach

</td>
    </tr>

    <tr class="">
        <td colspan="3">&nbsp;</td>
    </tr>

<?php 
$c = 0;
foreach ($fields as $fieldName => $definition) {
    ?>
    <?php 
    if ($definition instanceof Object\ClassDefinition\Data\Localizedfields) {
        ?>
        <?php 
        foreach (\Pimcore\Tool::getValidLanguages() as $language) {
            ?>
            <?php 
            foreach ($definition->getFieldDefinitions() as $lfd) {
                ?>
                <?php 
                $v1 = $lfd->getVersionPreview($this->object1->getValueForFieldName($fieldName)->getLocalizedValue($lfd->getName(), $language));
                $v2 = $lfd->getVersionPreview($this->object2->getValueForFieldName($fieldName)->getLocalizedValue($lfd->getName(), $language));
                ?>
                <tr<?php 
                if ($c % 2) {
                    ?>
 class="odd"<?php 
                }
                ?>
>
开发者ID:Gerhard13,项目名称:pimcore,代码行数:31,代码来源:diff-versions.php

示例11: setLocalizedValue

 /**
  * @param $name
  * @param $value
  * @param null $language
  * @return void
  */
 public function setLocalizedValue($name, $value, $language = null)
 {
     if (self::$strictMode) {
         if (!$language || !in_array($language, Tool::getValidLanguages())) {
             throw new \Exception("Language " . $language . " not accepted in strict mode");
         }
     }
     $language = $this->getLanguage($language);
     if (!$this->languageExists($language)) {
         $this->items[$language] = array();
     }
     $fieldDefinition = $this->getObject()->getClass()->getFieldDefinition("localizedfields")->getFieldDefinition($name);
     if (method_exists($fieldDefinition, "preSetData")) {
         $value = $fieldDefinition->preSetData($this, $value, array("language" => $language, "name" => $name));
     }
     $this->items[$language][$name] = $value;
     return $this;
 }
开发者ID:ChristophWurst,项目名称:pimcore,代码行数:24,代码来源:Localizedfield.php

示例12: getValidLanguages

 public function getValidLanguages()
 {
     if ($this->localized) {
         $validLanguages = Tool::getValidLanguages();
     } else {
         $validLanguages = [];
     }
     array_unshift($validLanguages, "default");
     return $validLanguages;
 }
开发者ID:solverat,项目名称:pimcore,代码行数:10,代码来源:Classificationstore.php

示例13: gridGetColumnConfigAction


//.........这里部分代码省略.........
                                         if (!empty($fieldConfig)) {
                                             $availableFields[] = $fieldConfig;
                                             $count++;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 } else {
                     if (empty($types) || in_array($field->getFieldType(), $types)) {
                         $fieldConfig = $this->getFieldGridConfig($field, $gridType, $count, !empty($types));
                         if (!empty($fieldConfig)) {
                             $availableFields[] = $fieldConfig;
                             $count++;
                         }
                     }
                 }
             }
         }
     } else {
         $savedColumns = $gridConfig['columns'];
         foreach ($savedColumns as $key => $sc) {
             if (!$sc['hidden']) {
                 if (in_array($key, $systemColumns)) {
                     $colConfig = array("key" => $key, "type" => "system", "label" => $key, "position" => $sc['position']);
                     if (isset($sc['width'])) {
                         $colConfig['width'] = $sc['width'];
                     }
                     $availableFields[] = $colConfig;
                 } else {
                     $keyParts = explode("~", $key);
                     if (substr($key, 0, 1) == "~") {
                         // not needed for now
                         //                            $type = $keyParts[1];
                         //                            $field = $keyParts[2];
                         //                            $keyid = $keyParts[3];
                     } else {
                         if (count($keyParts) > 1) {
                             $brick = $keyParts[0];
                             $key = $keyParts[1];
                             $brickClass = Object\Objectbrick\Definition::getByKey($brick);
                             $fd = $brickClass->getFieldDefinition($key);
                             if (!empty($fd)) {
                                 $fieldConfig = $this->getFieldGridConfig($fd, $gridType, $sc['position'], true, $brick . "~");
                                 if (!empty($fieldConfig)) {
                                     if (isset($sc['width'])) {
                                         $fieldConfig['width'] = $sc['width'];
                                     }
                                     $availableFields[] = $fieldConfig;
                                 }
                             }
                         } else {
                             $fd = $class->getFieldDefinition($key);
                             //if not found, look for localized fields
                             if (empty($fd)) {
                                 foreach ($localizedFields as $lf) {
                                     $fd = $lf->getFieldDefinition($key);
                                     if (!empty($fd)) {
                                         break;
                                     }
                                 }
                             }
                             if (!empty($fd)) {
                                 $fieldConfig = $this->getFieldGridConfig($fd, $gridType, $sc['position'], true);
                                 if (!empty($fieldConfig)) {
                                     if (isset($sc['width'])) {
                                         $fieldConfig['width'] = $sc['width'];
                                     }
                                     $availableFields[] = $fieldConfig;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     usort($availableFields, function ($a, $b) {
         if ($a["position"] == $b["position"]) {
             return 0;
         }
         return $a["position"] < $b["position"] ? -1 : 1;
     });
     $config = \Pimcore\Config::getSystemConfig();
     $frontendLanguages = Tool\Admin::reorderWebsiteLanguages(\Pimcore\Tool\Admin::getCurrentUser(), $config->general->validLanguages);
     if ($frontendLanguages) {
         $language = explode(',', $frontendLanguages)[0];
     } else {
         $language = $this->getLanguage();
     }
     if (!Tool::isValidLanguage($language)) {
         $validLanguages = Tool::getValidLanguages();
         $language = $validLanguages[0];
     }
     if (!empty($gridConfig) && !empty($gridConfig['language'])) {
         $language = $gridConfig['language'];
     }
     $this->_helper->json(array("sortinfo" => $gridConfig['sortinfo'], "language" => $language, "availableFields" => $availableFields, "onlyDirectChildren" => $gridConfig['onlyDirectChildren'], "pageSize" => $gridConfig['pageSize']));
 }
开发者ID:cannonerd,项目名称:pimcore,代码行数:101,代码来源:ObjectHelperController.php

示例14: setLocale

 /**
  * Try to set the locale from different sources
  *
  * @param $locale
  * @return $this
  */
 public function setLocale($locale = null)
 {
     if ($locale instanceof \Zend_Locale) {
         $this->locale = $locale;
     } elseif (is_string($locale)) {
         $this->locale = new \Zend_Locale($locale);
     } elseif ($this->getParam('locale') || $this->getParam('language')) {
         $this->setLocale($this->getParam('locale') ? $this->getParam('locale') : $this->getParam('language'));
     } else {
         $document = $this->getDocument();
         if ($document instanceof Document && $document->getProperty("language")) {
             $this->setLocale($document->getProperty("language"));
         }
         if (is_null($this->locale)) {
             //last chance -> get it from registry or use the first Language defined in the system settings
             if (\Zend_Registry::isRegistered("Zend_Locale")) {
                 $this->locale = \Zend_Registry::get("Zend_Locale");
             } else {
                 list($language) = \Pimcore\Tool::getValidLanguages();
                 $this->locale = new \Zend_Locale($language);
             }
         }
     }
     return $this;
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:31,代码来源:AbstractPlaceholder.php

示例15: translationsAction

 public function translationsAction()
 {
     $admin = $this->getParam("admin");
     if ($admin) {
         $class = "\\Pimcore\\Model\\Translation\\Admin";
         $this->checkPermission("translations_admin");
     } else {
         $class = "\\Pimcore\\Model\\Translation\\Website";
         $this->checkPermission("translations");
     }
     // clear translation cache
     Translation\Website::clearDependentCache();
     if ($this->getParam("data")) {
         $data = \Zend_Json::decode($this->getParam("data"));
         if ($this->getParam("xaction") == "destroy") {
             $data = \Zend_Json::decode($this->getParam("data"));
             if (\Pimcore\Tool\Admin::isExtJS6()) {
                 $t = $class::getByKey($data["key"]);
             } else {
                 $t = $class::getByKey($data);
             }
             $t->delete();
             $this->_helper->json(array("success" => true, "data" => array()));
         } else {
             if ($this->getParam("xaction") == "update") {
                 $t = $class::getByKey($data["key"]);
                 foreach ($data as $key => $value) {
                     if ($key != "key") {
                         $t->addTranslation($key, $value);
                     }
                 }
                 if ($data["key"]) {
                     $t->setKey($data["key"]);
                 }
                 $t->setModificationDate(time());
                 $t->save();
                 $return = array_merge(array("key" => $t->getKey(), "creationDate" => $t->getCreationDate(), "modificationDate" => $t->getModificationDate()), $t->getTranslations());
                 $this->_helper->json(array("data" => $return, "success" => true));
             } else {
                 if ($this->getParam("xaction") == "create") {
                     try {
                         $t = $class::getByKey($data["key"]);
                     } catch (\Exception $e) {
                         $t = new $class();
                         $t->setKey($data["key"]);
                         $t->setCreationDate(time());
                         $t->setModificationDate(time());
                         foreach (Tool::getValidLanguages() as $lang) {
                             $t->addTranslation($lang, "");
                         }
                         $t->save();
                     }
                     $return = array_merge(array("key" => $t->getKey(), "creationDate" => $t->getCreationDate(), "modificationDate" => $t->getModificationDate()), $t->getTranslations());
                     $this->_helper->json(array("data" => $return, "success" => true));
                 }
             }
         }
     } else {
         // get list of types
         if ($admin) {
             $list = new Translation\Admin\Listing();
         } else {
             $list = new Translation\Website\Listing();
         }
         $list->setOrder("asc");
         $list->setOrderKey("key");
         $sortingSettings = \Pimcore\Admin\Helper\QueryParams::extractSortingSettings($this->getAllParams());
         if ($sortingSettings['orderKey']) {
             $list->setOrderKey($sortingSettings['orderKey']);
         }
         if ($sortingSettings['order']) {
             $list->setOrder($sortingSettings['order']);
         }
         $list->setLimit($this->getParam("limit"));
         $list->setOffset($this->getParam("start"));
         $condition = $this->getGridFilterCondition();
         if ($condition) {
             $list->setCondition($condition);
         }
         $list->load();
         $translations = array();
         foreach ($list->getTranslations() as $t) {
             $translations[] = array_merge($t->getTranslations(), array("key" => $t->getKey(), "creationDate" => $t->getCreationDate(), "modificationDate" => $t->getModificationDate()));
         }
         $this->_helper->json(array("data" => $translations, "success" => true, "total" => $list->getTotalCount()));
     }
 }
开发者ID:quorak,项目名称:pimcore,代码行数:87,代码来源:TranslationController.php


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