152 lines
3.8 KiB
PHP
152 lines
3.8 KiB
PHP
<?php
|
|
|
|
|
|
namespace app\models;
|
|
|
|
/**
|
|
* Class Projects
|
|
* @package app\models
|
|
* @property $id
|
|
* @property $title
|
|
* @property $text
|
|
* @property $text_short
|
|
* @property $text_contract
|
|
* @property $ts_en_title
|
|
* @property $ts_en_text
|
|
* @property $ts_en_text_short
|
|
* @property $ts_en_text_contract
|
|
* @property $period
|
|
* @property $website
|
|
* @property $publications
|
|
* @property $media_key
|
|
* @property $document_key
|
|
* @property $projectPartners
|
|
* @property $publish_date
|
|
* @property $docs
|
|
* @property $partner_id
|
|
*/
|
|
class Projects extends _Base
|
|
{
|
|
public function getProjectPartners()
|
|
{
|
|
return $this->hasMany(ProjectsPartner::class, ['project_id' => 'id']);
|
|
}
|
|
|
|
public function getDocs()
|
|
{
|
|
return $this->hasMany(DocsCms::class, ['document_key' => 'document_key']);
|
|
}
|
|
|
|
public function getDocsList()
|
|
{
|
|
|
|
$domain = \Yii::$app->params['media_server'];
|
|
$docsList = [];
|
|
/** @var \app\models\DocsCms $doc */
|
|
foreach ($this->docs as $doc) {
|
|
if ($doc->document_type == 'ppt' || $doc->document_type == 'pptx')
|
|
continue;
|
|
if (\Yii::$app->language == 'bg' && $doc->file_name && $doc->name) {
|
|
$docsList[] = (object)[
|
|
'download' => $domain . $doc->file_name,
|
|
'name' => $doc->name
|
|
];
|
|
}
|
|
|
|
if (\Yii::$app->language == 'en' && $doc->file_name_en && $doc->name_en) {
|
|
$docsList[] = (object)[
|
|
'download' => $domain . $doc->file_name_en,
|
|
'name' => $doc->name_en
|
|
];
|
|
}
|
|
}
|
|
return $docsList;
|
|
}
|
|
|
|
public function getPresentationList()
|
|
{
|
|
|
|
$domain = \Yii::$app->params['media_server'];
|
|
$docsList = [];
|
|
/** @var \app\models\DocsCms $doc */
|
|
foreach ($this->docs as $doc) {
|
|
if ($doc->document_type == 'ppt' || $doc->document_type == 'pptx') {
|
|
if (\Yii::$app->language == 'bg' && $doc->file_name && $doc->name) {
|
|
$docsList[] = (object)[
|
|
'download' => $domain . $doc->file_name,
|
|
'name' => $doc->name
|
|
];
|
|
}
|
|
if (\Yii::$app->language == 'en' && $doc->file_name_en && $doc->name_en) {
|
|
$docsList[] = (object)[
|
|
'download' => $domain . $doc->file_name_en,
|
|
'name' => $doc->name_en
|
|
];
|
|
}
|
|
}
|
|
}
|
|
return $docsList;
|
|
}
|
|
|
|
public function partnersIds()
|
|
{
|
|
$ids = [];
|
|
/** @var \app\models\ProjectsPartner $partner */
|
|
foreach ($this->projectPartners as $partner) {
|
|
$ids[] = $partner->partner_id;
|
|
}
|
|
return $ids;
|
|
}
|
|
|
|
public function title()
|
|
{
|
|
if (\Yii::$app->language == 'en') {
|
|
return $this->ts_en_title;
|
|
} else {
|
|
return $this->title;
|
|
}
|
|
}
|
|
|
|
public function textContract()
|
|
{
|
|
if (\Yii::$app->language == 'en') {
|
|
return $this->ts_en_text_contract;
|
|
} else {
|
|
return $this->text_contract;
|
|
}
|
|
}
|
|
|
|
public function textShort()
|
|
{
|
|
if (\Yii::$app->language == 'en') {
|
|
return $this->ts_en_text_short;
|
|
} else {
|
|
return $this->text_short;
|
|
}
|
|
}
|
|
|
|
public function textLong()
|
|
{
|
|
if (\Yii::$app->language == 'en') {
|
|
return $this->ts_en_text;
|
|
} else {
|
|
return $this->text;
|
|
}
|
|
}
|
|
|
|
public function videoList()
|
|
{
|
|
return [];
|
|
}
|
|
|
|
public function audioList()
|
|
{
|
|
return [];
|
|
}
|
|
|
|
public function getPublications()
|
|
{
|
|
return [];
|
|
}
|
|
}
|