/**
  * 
  * Constructor
  * @param $prefix
  * @param $key
  * @param BASE_CMP_LanguageValueEdit $parent
  */
 public function __construct($prefix, $key, $parent)
 {
     parent::__construct('lang-values-edit');
     $this->setAjax(true);
     $this->setAction(OW::getRouter()->urlFor('ADMIN_CTRL_Languages', 'ajaxEditLangs') . "?prefix={$prefix}&key={$key}");
     $languageService = BOL_LanguageService::getInstance();
     $list = $languageService->findActiveList();
     $parent->assign('langs', $list);
     $parent->assign('prefix', $prefix);
     $parent->assign('key', $key);
     foreach ($list as $item) {
         $textArea = new Textarea("lang[{$item->getId()}][{$prefix}][{$key}]");
         $dto = $languageService->getValue($item->getId(), $prefix, $key);
         $value = $dto !== null ? $dto->getValue() : '';
         $textArea->setValue($value);
         $this->addElement($textArea);
     }
     $submit = new Submit('submit');
     $submit->setValue('Save');
     if (!$parent->eventBased) {
         $jsString = 'owForms[{$formName}].bind("success", function(json){
             if ( json["result"] == "success") {
                 var fb = document.ajaxLangValueEditForms[ json["prefix"] +"-"+ json["key"] ];
                 var ff = document.ajaxLangValueEditForms[json["prefix"] +"-"+json["key"]+"callback"];
                 ff(json);
                 fb.close();
             }
         })';
     } else {
         $jsString = 'owForms[{$formName}].bind("success", function(json){
             if ( json["result"] == "success") {
                 OW.trigger("admin.language_key_edit_success", [json], this);
             }
         })';
     }
     $script = UTIL_JsGenerator::composeJsString($jsString, array('formName' => $this->getName()));
     OW::getDocument()->addOnloadScript($script);
     $this->addElement($submit);
 }
Exemple #2
0
 public function ajaxEditLanguageValuesForm()
 {
     $cmp = new BASE_CMP_LanguageValueEdit($_GET['prefix'], $_GET['key']);
     exit(json_encode(array('markup' => $cmp->render(), 'js' => OW::getDocument()->getOnloadScript(), 'include_js' => OW::getDocument()->getScripts())));
 }