public function _Settings($Sender, $Args) { $Sender->Form = $this->Form; // Grab the existing locale packs. $LocaleModel = new LocaleModel(); $LocalePacks = $LocaleModel->AvailableLocalePacks(); $LocalArray = array(); foreach ($LocalePacks as $Key => $Info) { $LocaleArray[$Key] = GetValue('Name', $Info, $Key); } $Sender->SetData('LocalePacks', $LocaleArray); if ($this->Form->IsPostBack()) { if ($this->Form->GetFormValue('Save')) { $Values = ArrayTranslate($this->Form->FormValues(), array('Key', 'Name', 'Locale', 'CaptureDefinitions')); $SaveValues = array(); foreach ($Values as $Key => $Value) { $SaveValues['Plugins.LocaleDeveloper.' . $Key] = $Value; } // Save the settings. SaveToConfig($SaveValues, '', array('RemoveEmpty' => TRUE)); $Sender->StatusMessage = T('Your changes have been saved.'); } elseif ($this->Form->GetFormValue('GenerateChanges')) { $Key = $this->Form->GetFormValue('LocalePackForChanges'); if (!$Key) { $this->Form->AddError('ValidateRequired', 'Locale Pack'); } $Path = PATH_ROOT . '/locales/' . $Key; if (!file_exists($Path)) { $this->Form->AddError('Could not find the selected locale pack.'); } if ($this->Form->ErrorCount() == 0) { try { $LocaleModel->GenerateChanges($Path, $this->LocalePath); $Sender->StatusMessage = T('Your changes have been saved.'); } catch (Exception $Ex) { $this->Form->AddError($Ex); } } } elseif ($this->Form->GetFormValue('Copy')) { $Key = $this->Form->GetFormValue('LocalePackForCopy'); if (!$Key) { $this->Form->AddError('ValidateRequired', 'Locale Pack'); } $Path = PATH_ROOT . '/locales/' . $Key; if (!file_exists($Path)) { $this->Form->AddError('Could not find the selected locale pack.'); } if ($this->Form->ErrorCount() == 0) { try { $LocaleModel->CopyDefinitions($Path, $this->LocalePath . '/copied.php'); $Sender->StatusMessage = T('Your changes have been saved.'); } catch (Exception $Ex) { $this->Form->AddError($Ex); } } } elseif ($this->Form->GetFormValue('Remove')) { $Files = SafeGlob($this->LocalePath . '/*'); foreach ($Files as $File) { $Result = unlink($File); if (!$Result) { $this->Form->AddError('@' . sprintf(T('Could not remove %s.'), $File)); } } if ($this->Form->ErrorCount() == 0) { $Sender->StatusMessage = T('Your changes have been saved.'); } } } else { $Values = C('Plugins.LocaleDeveloper'); foreach ($Values as $Key => $Value) { $this->Form->SetFormValue($Key, $Value); } } $Sender->SetData('LocalePath', $this->LocalePath); $Sender->Render('', '', 'plugins/LocaleDeveloper'); }