Inheritance: extends Pimcore\Model\AbstractModel
Ejemplo n.º 1
0
 /**
  * Loads a list of keyvalue key configs for the specifies parameters, returns an array of config elements
  *
  * @return array
  */
 public function load()
 {
     $sql = "SELECT id FROM " . Object\KeyValue\TranslatorConfig\Resource::TABLE_NAME_TRANSLATOR . $this->getCondition() . $this->getOrder() . $this->getOffsetLimit();
     $configsData = $this->db->fetchCol($sql, $this->model->getConditionVariables());
     $configData = array();
     foreach ($configsData as $config) {
         $configData[] = Object\KeyValue\TranslatorConfig::getById($config);
     }
     $this->model->setList($configData);
     return $configData;
 }
Ejemplo n.º 2
0
 /**
  * @param $keyId
  * @param $value
  * @return string
  */
 private function getTranslatedValue($keyId, $value)
 {
     $translatedValue = "";
     $keyConfig = Object\KeyValue\KeyConfig::getById($keyId);
     $translatorID = $keyConfig->getTranslator();
     $translatorConfig = Object\KeyValue\TranslatorConfig::getById($translatorID);
     $className = $translatorConfig->getTranslator();
     if (\Pimcore\Tool::classExists($className)) {
         $translator = new $className();
         $translatedValue = $translator->translate($value);
         if (!$translatedValue) {
             $translatedValue = $value;
         }
     }
     return $translatedValue;
 }
Ejemplo n.º 3
0
 public function translateAction()
 {
     $success = false;
     $keyId = $this->getParam("keyId");
     $objectId = $this->getParam("objectId");
     $recordId = $this->getParam("recordId");
     $text = $this->getParam("text");
     $translatedValue = $text;
     try {
         $keyConfig = KeyValue\KeyConfig::getById($keyId);
         $translatorID = $keyConfig->getTranslator();
         $translatorConfig = KeyValue\TranslatorConfig::getById($translatorID);
         $className = $translatorConfig->getTranslator();
         if (\Pimcore\Tool::classExists($className)) {
             $translator = new $className();
             $translatedValue = $translator->translate($text);
             if (!$translatedValue) {
                 $translatedValue = $text;
             }
         }
         $this->_helper->json(["success" => true, "keyId" => $this->getParam("keyId"), "text" => $text, "translated" => $translatedValue, "recordId" => $recordId]);
     } catch (\Exception $e) {
     }
     $this->_helper->json(["success" => $success]);
 }