From fbc8dc2468cb3af374cd4be734ac0aff421d7813 Mon Sep 17 00:00:00 2001 From: Dmitry Yu Okunev Date: Fri, 1 Apr 2016 09:40:19 +0300 Subject: [PATCH] Considered https://tasks.mephi.ru/issues/49157 --- genpdf/genpdf.php | 29 +++++++++++++++++++++++++---- genpdf/lib/3dparty/Inflect | 2 +- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/genpdf/genpdf.php b/genpdf/genpdf.php index 37f2602..505de69 100644 --- a/genpdf/genpdf.php +++ b/genpdf/genpdf.php @@ -206,7 +206,6 @@ if (isset($_GET['signer-serialized'])) { die('Wrong appointment ID ('.$_GET['signer-appointment-id'].')'); } - @$appointment->employee = $user->employee; considerAppointment('signer', $appointment); @@ -266,10 +265,14 @@ $dont_inflect_patterns = array( ); $inflect_cut_patterns = array( - '/^(.*)[иы]й[ ]/', + //'/^(.*)[иы]й[ ]/', // Commented due to task: https://tasks.mephi.ru/issues/49157 '/^\[\d+\] /', ); +$inflect_appointment_abj_patterns = array( + '/^(.*)[иы]й[ ]/', // https://tasks.mephi.ru/issues/49157 +); + $inflect_ignore_ending_patterns = array( '[ ].*', ); @@ -511,8 +514,19 @@ foreach (array('signer', 'contact', 'user', 'recipient') as $key) { $appointments = split(', ', $_GET[$key.'-appointment'.$postfix]); foreach ($appointments as &$appointment) { $matches = NULL; + $prefix = ''; $ignored_ending = ''; + foreach($inflect_appointment_abj_patterns as $inflect_appointment_abj_pattern) { + if (preg_match($inflect_appointment_abj_pattern, $appointment, $matches, PREG_OFFSET_CAPTURE)) { + foreach ($matches as &$match) { + $prefix .= $inflect->getInflectAbjective($match[0], $case); + $appointment = mb_substr($appointment, mb_strlen($match[0])); + break; + } + } + } + $appointment = preg_replace($inflect_cut_patterns, '', $appointment); error_log('Appointment'.$postfix.': '.$appointment); @@ -526,8 +540,7 @@ foreach (array('signer', 'contact', 'user', 'recipient') as $key) { } $appointment = $inflect->getInflectNoun($appointment, $case); - - $appointment .= $ignored_ending; + $appointment = $prefix . $appointment . $ignored_ending; $_GET[$key_prefix.'-'.$key.'-appointment'.$postfix] = $appointment; } @@ -536,6 +549,11 @@ foreach (array('signer', 'contact', 'user', 'recipient') as $key) { } } +/*if (!empty($_COOKIE['debug'])) { + print 'TEST: '; + print_r($_GET);die(); +}*/ + foreach (array('signer', 'contact', 'user', 'recipient') as $key) { foreach (array('', 'of-', 'to-') as $key_prefix) { $appointment_w_fullsubdiv = array(); @@ -998,6 +1016,9 @@ foreach ($files as $file) { switch ($file) { case 'request/vacation': + if (!empty($_COOKIE['debug'])) { + //print_r($_GET);die(); + } $header = '\mmheaderstatement{В Дирекцию по управлению персоналом НИЯУ МИФИ}{от '.$_GET['of-signer-appointment-w-fullsubdiv'].' '.$_GET{'of-signer-fullname'}.'}'; $footer = ''; break; diff --git a/genpdf/lib/3dparty/Inflect b/genpdf/lib/3dparty/Inflect index 754ec13..a60c8e4 160000 --- a/genpdf/lib/3dparty/Inflect +++ b/genpdf/lib/3dparty/Inflect @@ -1 +1 @@ -Subproject commit 754ec13a3789333e9c0a2f858116d0aec7edd238 +Subproject commit a60c8e42622081bce1e8a04c0d18eef53791418b -- libgit2 0.24.0