Changeset View
Changeset View
Standalone View
Standalone View
branches/5.3.x/core/units/email_templates/email_template_eh.php
Show First 20 Lines • Show All 221 Lines • ▼ Show 20 Line(s) | |||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnAfterConfigRead(kEvent $event) | protected function OnAfterConfigRead(kEvent $event) | ||||
{ | { | ||||
parent::OnAfterConfigRead($event); | parent::OnAfterConfigRead($event); | ||||
$options = Array (); | $config = $event->getUnitConfig(); | ||||
foreach ($this->Application->ModuleInfo as $module_name => $module_info) { | $fields = $config->getFields(); | ||||
if ( $module_name == 'In-Portal' ) { | $fields['Module']['options'] = $this->_getModules(); | ||||
continue; | |||||
} | |||||
$options[$module_name] = $module_name; | if ( $this->Application->findModule('Name', 'Custom') ) { | ||||
$fields['Module']['default'] = 'Custom'; | |||||
} | } | ||||
$config = $event->getUnitConfig(); | |||||
$fields = $config->getFields(); | |||||
$fields['Module']['options'] = $options; | |||||
$config->setFields($fields); | $config->setFields($fields); | ||||
$ml_helper = $this->Application->recallObject('kMultiLanguageHelper'); | |||||
/* @var $ml_helper kMultiLanguageHelper */ | |||||
$ml_helper->replaceMLCalculatedFields($event); | |||||
if ( $this->Application->GetVar('regional') ) { | if ( $this->Application->GetVar('regional') ) { | ||||
$config->setPopulateMlFields(true); | $config->setPopulateMlFields(true); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Returns modules, where e-mail event can be added to | |||||
* | |||||
* @return Array | |||||
* @access protected | |||||
*/ | |||||
protected function _getModules() | |||||
{ | |||||
$ret = Array (); | |||||
foreach ($this->Application->ModuleInfo as $module_name => $module_info) { | |||||
if ( $module_name == 'In-Portal' ) { | |||||
continue; | |||||
} | |||||
$ret[$module_name] = $module_name; | |||||
} | |||||
return $ret; | |||||
} | |||||
/** | |||||
* Prepare temp tables and populate it | * Prepare temp tables and populate it | ||||
* with items selected in the grid | * with items selected in the grid | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnEdit(kEvent $event) | protected function OnEdit(kEvent $event) | ||||
Show All 38 Lines | |||||
$minput_helper = $this->Application->recallObject('MInputHelper'); | $minput_helper = $this->Application->recallObject('MInputHelper'); | ||||
/* @var $minput_helper MInputHelper */ | /* @var $minput_helper MInputHelper */ | ||||
$xml = $minput_helper->prepareMInputXML($records, Array ('Tag', 'Replacement')); | $xml = $minput_helper->prepareMInputXML($records, Array ('Tag', 'Replacement')); | ||||
$object->SetDBField('ReplacementTagsXML', $xml); | $object->SetDBField('ReplacementTagsXML', $xml); | ||||
$this->setRequired($event); | $this->setRequired($event); | ||||
$ml_helper = $this->Application->recallObject('kMultiLanguageHelper'); | |||||
/* @var $ml_helper kMultiLanguageHelper */ | |||||
$translation_fields = $this->getTranslationFields(); | |||||
$source_language = $ml_helper->getSourceLanguage($object->GetDBField('TranslateFromLanguage')); | |||||
foreach ($translation_fields as $translation_field) { | |||||
$object->SetDBField('Source' . $translation_field, $object->GetDBField('l' . $source_language . '_' . $translation_field)); | |||||
} | |||||
} | } | ||||
/** | /** | ||||
* Performs custom validation + keep read-only fields | * Performs custom validation + keep read-only fields | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
*/ | */ | ||||
function _itemChanged($event) | function _itemChanged($event) | ||||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Line(s) | |||||
/** | /** | ||||
* Checks, that at least one of phrase's translations was changed | * Checks, that at least one of phrase's translations was changed | ||||
* | * | ||||
* @param kDBItem $object | * @param kDBItem $object | ||||
* @return bool | * @return bool | ||||
*/ | */ | ||||
function translationChanged($object) | function translationChanged($object) | ||||
{ | { | ||||
$translation_fields = $this->getTranslationFields(); | |||||
$changed_fields = array_keys($object->GetChangedFields()); | $changed_fields = array_keys($object->GetChangedFields()); | ||||
$translation_fields = Array ('Subject', 'HtmlBody', 'PlainTextBody'); | |||||
foreach ($changed_fields as $changed_field) { | foreach ($changed_fields as $changed_field) { | ||||
$changed_field = preg_replace('/^l[\d]+_/', '', $changed_field); | $changed_field = preg_replace('/^l[\d]+_/', '', $changed_field); | ||||
if ( in_array($changed_field, $translation_fields) ) { | if ( in_array($changed_field, $translation_fields) ) { | ||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
/** | /** | ||||
* Returns fields, that can be translated | |||||
* | |||||
* @return Array | |||||
* @access protected | |||||
*/ | |||||
protected function getTranslationFields() | |||||
{ | |||||
return Array ('Subject', 'HtmlBody', 'PlainTextBody'); | |||||
} | |||||
/** | |||||
* Don't allow to enable/disable events in non-debug mode | * Don't allow to enable/disable events in non-debug mode | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnBeforeItemCreate(kEvent $event) | protected function OnBeforeItemCreate(kEvent $event) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 261 Lines • ▼ Show 20 Line(s) | |||||
} | } | ||||
else { | else { | ||||
$this->Application->emailUser($object->GetDBField('TemplateName')); | $this->Application->emailUser($object->GetDBField('TemplateName')); | ||||
} | } | ||||
} | } | ||||
$this->clearSelectedIDs($event); | $this->clearSelectedIDs($event); | ||||
} | } | ||||
} | |||||
No newline at end of file | /** | ||||
* Updates translation state for all saved phrases | |||||
* | |||||
* @param kEvent $event | |||||
* @return void | |||||
* @access protected | |||||
*/ | |||||
protected function OnBeforeCopyToLive(kEvent $event) | |||||
{ | |||||
parent::OnBeforeCopyToLive($event); | |||||
$ml_helper = $this->Application->recallObject('kMultiLanguageHelper'); | |||||
/* @var $ml_helper kMultiLanguageHelper */ | |||||
$ml_helper->updateTranslationState($event); | |||||
} | |||||
} |