Skip to content
Snippets Groups Projects
Commit 2b9667d4 authored by PavelBegunkov's avatar PavelBegunkov
Browse files

ADD: helpers

parent 46173535
Branches
Tags
No related merge requests found
<?php defined('SYSPATH') or die('No direct script access.');
class DataHelper
{
protected static $dgr_lookup = array( 'bachelor' => 'Бакалавриат',
'specialist' => 'Специалитет',
'master' => 'Магистратура');
// take array with (at least) LastName & FirstName keys
static public function AbbreviateName(&$personInfo) {
$fullName = $personInfo['LastName'].' '.UTF8::substr($personInfo['FirstName'], 0, 1).'. ';
if(!empty($personInfo['SecondName'])) {
$fullName .= UTF8::substr($personInfo['SecondName'], 0, 1).'.';
}
return $fullName;
}
static public function GetAbbrNameArray($persons)
{
$result = array();
$i = 0;
foreach ($persons as $person){
$result[$i] = self::AbbreviateName($person);
++$i;
}
return $result;
}
static public function LocalizeExamType($examType) {
return ($examType === "exam")?"Экзамен":"Зачет";
}
static public function LocalizeDegree($degree) {
return self::$dgr_lookup[$degree];
}
static public function DeserializeDisciplines($rawDiscs)
{
$subjID = $discID = $gradeID = $i = $j = 0; // Combo!!!
$result = array();
foreach ($rawDiscs as $row)
{
$curSubjectID = $row['SubjectID'];
$curGradeID = $row['GradeID'];
$curDiscID = $row['ID'];
if($subjID != $curSubjectID || $gradeID != $curGradeID)
{
$j = 0;
++$i;
$subjID = $curSubjectID;
$gradeID = $curGradeID;
// new grade/subject
$data = array();
$data['Degree'] = $row['Degree'];
$data['GradeNum'] = $row['GradeNum'];
$data['SubjectName'] = $row['SubjectName'];
$result[$i] = $data;
$result[$i]['Disciplines'] = array();
$discs = &$result[$i]['Disciplines'];
}
if($discID != $curDiscID)
{
$discID = $curDiscID;
$discs[$j] = $row; // IsAuthor, IsLocked, IsMapCreated, ID, ExamType
++$j;
}
} //!for_each
return $result;
}
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment