Index: branches/5.2.x/core/units/helpers/list_helper.php =================================================================== diff -u -N -r14699 -r14748 --- branches/5.2.x/core/units/helpers/list_helper.php (.../list_helper.php) (revision 14699) +++ branches/5.2.x/core/units/helpers/list_helper.php (.../list_helper.php) (revision 14748) @@ -1,5 +1,19 @@ 'priority', 'EventHandlerClass' => Array ('class' => 'PriorityEventHandler', 'file' => 'priority_eh.php', 'build_event' => 'OnBuild'), Index: branches/5.2.x/core/kernel/utility/formatters/date_formatter.php =================================================================== diff -u -N -r14693 -r14748 --- branches/5.2.x/core/kernel/utility/formatters/date_formatter.php (.../date_formatter.php) (revision 14693) +++ branches/5.2.x/core/kernel/utility/formatters/date_formatter.php (.../date_formatter.php) (revision 14748) @@ -1,8 +1,8 @@ Application->GetVar('simple_mode') && (int)$this->Application->ConfigValue('UsePopups'); - } +class PhraseTagProcessor extends kDBTagProcessor { - function PhraseCount($params) - { - static $cache = null; + /** + * Determines, that we can close phrase editing form without parent window refreshing + * + * @param Array $params + * @return bool + */ + function UseQuickFormCancel($params) + { + return $this->Application->GetVar('simple_mode') && (int)$this->Application->ConfigValue('UsePopups'); + } - if (!isset($cache)) { - $sql = 'SELECT COUNT(*), Module - FROM ' . $this->Application->getUnitOption($this->Prefix, 'TableName') . ' - GROUP BY Module'; - $cache = $this->Conn->GetCol($sql, 'Module'); - } + function PhraseCount($params) + { + static $cache = null; - $module = $params['module']; - - return array_key_exists($module, $cache) ? $cache[$module] : 0; + if (!isset($cache)) { + $sql = 'SELECT COUNT(*), Module + FROM ' . $this->Application->getUnitOption($this->Prefix, 'TableName') . ' + GROUP BY Module'; + $cache = $this->Conn->GetCol($sql, 'Module'); } - function EventCount($params) - { - static $cache = null; + $module = $params['module']; - if (!isset($cache)) { - $sql = 'SELECT COUNT(*), IF(Module LIKE "Core:%", "Core", Module) AS Module - FROM ' . $this->Application->getUnitOption('emailevents', 'TableName') . ' - GROUP BY Module'; - $cache = $this->Conn->GetCol($sql, 'Module'); - } + return array_key_exists($module, $cache) ? $cache[$module] : 0; + } - $module = $params['module']; + function EventCount($params) + { + static $cache = null; - return array_key_exists($module, $cache) ? $cache[$module] : 0; + if (!isset($cache)) { + $sql = 'SELECT COUNT(*), IF(Module LIKE "Core:%", "Core", Module) AS Module + FROM ' . $this->Application->getUnitOption('emailevents', 'TableName') . ' + GROUP BY Module'; + $cache = $this->Conn->GetCol($sql, 'Module'); } - } \ No newline at end of file + + $module = $params['module']; + + return array_key_exists($module, $cache) ? $cache[$module] : 0; + } +} \ No newline at end of file Index: branches/5.2.x/core/units/images/image_tag_processor.php =================================================================== diff -u -N -r14699 -r14748 --- branches/5.2.x/core/units/images/image_tag_processor.php (.../image_tag_processor.php) (revision 14699) +++ branches/5.2.x/core/units/images/image_tag_processor.php (.../image_tag_processor.php) (revision 14748) @@ -1,8 +1,8 @@ '', 'Headers' => '', 'Body' => ''); - $headers = Array(); - $lines = explode("\n", $text); // "\n" is lost in process +class EmailMessageHelper extends kHelper { - foreach ($lines as $line_id => $line) { - if (strlen(trim($line)) == 0 || ($line == '.')) { - break; - } + /** + * Extracts Subject, Headers, Body fields from email message translation + * + * @param string $text + * @return Array + */ + function parseTemplate($text) + { + $line_id = 1; + $ret = Array ('Subject' => '', 'Headers' => '', 'Body' => ''); + $headers = Array(); + $lines = explode("\n", $text); // "\n" is lost in process - $parts = explode(':', $line, 2); - if (strtolower($parts[0]) == 'subject') { - $ret['Subject'] = trim($parts[1]); - } - else { - $headers[] = $line; - } + foreach ($lines as $line_id => $line) { + if (strlen(trim($line)) == 0 || ($line == '.')) { + break; } - $ret['Headers'] = $headers ? implode("\n", $headers) : null; // it's null field - - $lines = array_slice($lines, $line_id + 1); - - // add "\n", that was lost before - $ret['Body'] = implode("\n", $lines); - - return $ret; + $parts = explode(':', $line, 2); + if (strtolower($parts[0]) == 'subject') { + $ret['Subject'] = trim($parts[1]); + } + else { + $headers[] = $line; + } } - /** - * Prepares email event content for language pack export - * - * @param Array $fields_hash - * @return string - */ - function buildTemplate($fields_hash) - { - if (!implode('', $fields_hash)) { - return ''; - } + $ret['Headers'] = $headers ? implode("\n", $headers) : null; // it's null field - $ret = array_key_exists('Headers', $fields_hash) ? $fields_hash['Headers'] : ''; - if ($ret) { - $ret .= "\n"; - } + $lines = array_slice($lines, $line_id + 1); - $ret = $this->_removeTrailingCRLF($ret); - $ret .= 'Subject: ' . $fields_hash['Subject'] . "\n\n"; - $ret .= $fields_hash['Body']; + // add "\n", that was lost before + $ret['Body'] = implode("\n", $lines); - return $ret; + return $ret; + } + + /** + * Prepares email event content for language pack export + * + * @param Array $fields_hash + * @return string + */ + function buildTemplate($fields_hash) + { + if (!implode('', $fields_hash)) { + return ''; } - /** - * Remove trailing CR/LF chars from string - * - * @param string $string - * @return string - */ - function _removeTrailingCRLF($string) - { - return preg_replace('/(\n|\r)+/',"\\1",$string); + $ret = array_key_exists('Headers', $fields_hash) ? $fields_hash['Headers'] : ''; + if ($ret) { + $ret .= "\n"; } - } \ No newline at end of file + + $ret = $this->_removeTrailingCRLF($ret); + $ret .= 'Subject: ' . $fields_hash['Subject'] . "\n\n"; + $ret .= $fields_hash['Body']; + + return $ret; + } + + /** + * Remove trailing CR/LF chars from string + * + * @param string $string + * @return string + */ + function _removeTrailingCRLF($string) + { + return preg_replace('/(\n|\r)+/',"\\1",$string); + } +} \ No newline at end of file Index: branches/5.2.x/core/units/priorites/priority_eh.php =================================================================== diff -u -N -r14675 -r14748 --- branches/5.2.x/core/units/priorites/priority_eh.php (.../priority_eh.php) (revision 14675) +++ branches/5.2.x/core/units/priorites/priority_eh.php (.../priority_eh.php) (revision 14748) @@ -1,5 +1,19 @@ Application->GetVar($params['name']); +class FormSubmissionTagProcessor extends kDBTagProcessor { - if (array_key_exists('default', $params) && !$phrase_name) { - $phrase_name = $params['default']; - } + /** + * Returns phrase translation by name + * + * @param Array $params + * @return string + * @access public + */ + function PhraseFromRequest($params) + { + $phrase_name = $this->Application->GetVar($params['name']); - return $this->Application->Phrase($phrase_name); + if (array_key_exists('default', $params) && !$phrase_name) { + $phrase_name = $params['default']; } - /** - * Allows to retrieve for submission field by it's name or role in email communications - * - * @param Array $params - * @return string - */ - function FormField($params) - { - $object =& $this->getObject($params); - /* @var $object kDBItem */ + return $this->Application->Phrase($phrase_name); + } - $form_submission_helper =& $this->Application->recallObject('FormSubmissionHelper'); - /* @var $form_submission_helper FormSubmissionHelper */ + /** + * Allows to retrieve for submission field by it's name or role in email communications + * + * @param Array $params + * @return string + */ + function FormField($params) + { + $object =& $this->getObject($params); + /* @var $object kDBItem */ - $formatted = !(array_key_exists('db', $params) && $params['db']); - $format = $formatted ? (array_key_exists('format', $params) ? $params['format'] : null) : null; + $form_submission_helper =& $this->Application->recallObject('FormSubmissionHelper'); + /* @var $form_submission_helper FormSubmissionHelper */ - if (array_key_exists('role', $params)) { - return $form_submission_helper->getFieldByRole($object, $params['role'], $formatted, $format); - } + $formatted = !(array_key_exists('db', $params) && $params['db']); + $format = $formatted ? (array_key_exists('format', $params) ? $params['format'] : null) : null; - return $form_submission_helper->getFieldByName($params['name'], $formatted, $format); + if (array_key_exists('role', $params)) { + return $form_submission_helper->getFieldByRole($object, $params['role'], $formatted, $format); } + + return $form_submission_helper->getFieldByName($params['name'], $formatted, $format); } +} Index: branches/5.2.x/core/kernel/utility/formatters/options_formatter.php =================================================================== diff -u -N -r14628 -r14748 --- branches/5.2.x/core/kernel/utility/formatters/options_formatter.php (.../options_formatter.php) (revision 14628) +++ branches/5.2.x/core/kernel/utility/formatters/options_formatter.php (.../options_formatter.php) (revision 14748) @@ -1,8 +1,8 @@ GetFieldOptions($field_name); - /** - * Formats value of a given field - * - * @param string $value - * @param string $field_name - * @param kDBItem|kDBList $object - * @param string $format - * @return string - */ - function Format($value, $field_name, &$object, $format=null) - { - $options = $object->GetFieldOptions($field_name); + $master_field = isset($options['master_field']) ? $options['master_field'] : false; + if (!$master_field) { + return $value; + } - $master_field = isset($options['master_field']) ? $options['master_field'] : false; - if (!$master_field) { - return $value; - } + $format = isset($format) ? $format : ( isset($options['format']) ? $options['format'] : null); - $format = isset($format) ? $format : ( isset($options['format']) ? $options['format'] : null); - - if ($value == '' && $format != 'no_default') { // try to get default language value - $def_lang_value = $object->GetDBField($master_field); - if ($def_lang_value == '') return NULL; - return $def_lang_value; //return value from default language - } - - return $value; + if ($value == '' && $format != 'no_default') { // try to get default language value + $def_lang_value = $object->GetDBField($master_field); + if ($def_lang_value == '') return NULL; + return $def_lang_value; //return value from default language } - } \ No newline at end of file + return $value; + } + +} \ No newline at end of file