Inheritance: extends yii\db\ActiveRecord
コード例 #1
0
 /**
  * Возвращает ссылку на миниатюру, заданную через аргументы $attribute и $alias
  * @param string $alias Наименование миниатюры, задается в конфигурации filemanager
  * @param bool|string $attribute Наименование атрибута (на случай, если в поведении 
  *                               казано несколько атрибутов)
  * @return bool|string Вернет false, если нет атрибутов или указанный не найден.
  */
 public function imageURL($alias, $attribute = false)
 {
     if ($attribute && !in_array($attribute, $this->attributes)) {
         return false;
     } elseif ($attribute === false && !($attribute = reset($this->attributes))) {
         return false;
     }
     $owner = Owners::findOne(['owner_id' => $this->owner->primaryKey, 'owner' => $this->name, 'owner_attribute' => $attribute]);
     if ($owner instanceof Owners) {
         if ($mediaFile = Mediafile::findOne($owner->mediafile_id)) {
             return $mediaFile->getThumbUrl($alias);
         }
     }
     return false;
 }
コード例 #2
0
ファイル: Post.php プロジェクト: esoftslimited/yii2-blog
 /**
  * @return bool|Mediafile
  */
 public function getThumbnailModel()
 {
     if (!empty($this->thumbnail_model)) {
         return $this->thumbnail_model;
     }
     return $this->thumbnail_model = Mediafile::loadOneByOwner('post', $this->id, 'thumbnail');
 }
コード例 #3
0
ファイル: Owners.php プロジェクト: Anselm21/yii2-filemanager
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMediafile()
 {
     return $this->hasOne(Mediafile::className(), ['id' => 'mediafile_id']);
 }
コード例 #4
0
ファイル: Category.php プロジェクト: esoftslimited/yii2-blog
 public function getImage()
 {
     return Mediafile::loadOneByOwner('category', $this->id, 'thumbnail');
 }
コード例 #5
0
ファイル: Tag.php プロジェクト: pendalf89/yii2-filemanager
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMediafiles()
 {
     return $this->hasMany(Mediafile::className(), ['id' => 'mediafile_id'])->viaTable('filemanager_mediafile_tag', ['tag_id' => 'id']);
 }
コード例 #6
0
 /**
  * Renders the data models for the grid view.
  */
 public function renderItemsMittente()
 {
     return AmosGridView::widget(['dataProvider' => new \yii\data\ActiveDataProvider(['query' => $this->modelData]), 'columns' => ['userprofile.avatar_id' => ['label' => '', 'format' => 'html', 'value' => function ($model) {
         $mediafile = \pendalf89\filemanager\models\Mediafile::findOne($model['avatar_id']);
         $url = '/img/defaultProfilo.jpg';
         if ($mediafile) {
             $url = $mediafile->getThumbUrl('medium');
         }
         return Html::img($url, ['width' => '100']);
     }], 'nome', 'cognome', ['attribute' => 'data_richiesta', 'format' => ['datetime', isset(Yii::$app->modules['datecontrol']['displaySettings']['datetime']) ? Yii::$app->modules['datecontrol']['displaySettings']['datetime'] : 'd-m-Y H:i:s']], ['attribute' => 'data_accettazione', 'format' => ['datetime', isset(Yii::$app->modules['datecontrol']['displaySettings']['datetime']) ? Yii::$app->modules['datecontrol']['displaySettings']['datetime'] : 'd-m-Y H:i:s']], ['attribute' => 'descrizione', 'label' => 'Stato'], ['class' => ActionColumn::className(), 'template' => '{accetta} {rifiuta} {annulla} {termina}', 'buttons' => ['accetta' => function ($url, $model) {
         $url = \yii\helpers\Url::current();
         if (\Yii::$app->getUser()->can($this->permissions['add'], ['model' => $this->model]) && $this->model['id'] != $model['id_richiedente'] && $this->model['id'] == $model['id_destinatario'] && $model['descrizione'] == 'In attesa di accettazione') {
             return Html::a('<p class="btn bk-btnAssociaCondominio" title="Accetta richiesta di contatto"><span id="bk-btnAssociaCondominio" class="ti ti-user"></span></p>', Yii::$app->urlManager->createUrl(['/admin/user-profile/cambia-stato-contatto', 'id' => $this->model['id'], 'azione' => 'accetta', 'url' => $url]), ['title' => Yii::t('yii', 'Accetta richiesta di contatto')]);
         } else {
             return '';
         }
     }, 'rifiuta' => function ($url, $model) {
         $url = \yii\helpers\Url::current();
         if (\Yii::$app->getUser()->can($this->permissions['add'], ['model' => $this->model]) && $this->model['id'] != $model['id_richiedente'] && $this->model['id'] == $model['id_destinatario'] && $model['descrizione'] == 'In attesa di accettazione') {
             return Html::a('<p class="btn bk-btnAssociaCondominio" title="Rifiuta richiesta di contatto"><span id="bk-btnAssociaCondominio" class="ti ti-trash"></span></p>', Yii::$app->urlManager->createUrl(['/admin/user-profile/cambia-stato-contatto', 'id' => $this->model['id'], 'azione' => 'rifiuta', 'url' => $url]), ['title' => Yii::t('yii', 'Rifiuta richiesta di contatto')]);
         } else {
             return '';
         }
     }, 'annulla' => function ($url, $model) {
         $url = \yii\helpers\Url::current();
         if (\Yii::$app->getUser()->can($this->permissions['add'], ['model' => $this->model]) && $this->model['id'] == $model['id_richiedente'] && $this->model['id'] != $model['id_destinatario'] && $model['descrizione'] == 'In attesa di accettazione') {
             return Html::a('<p class="btn bk-btnAssociaCondominio" title="Annulla richiesta di contatto"><span id="bk-btnAssociaCondominio" class="ti ti-trash"></span></p>', Yii::$app->urlManager->createUrl(['/admin/user-profile/cambia-stato-contatto', 'id' => $this->model['id'], 'azione' => 'annulla', 'url' => $url]), ['title' => Yii::t('yii', 'Annulla richiesta di contatto')]);
         } else {
             return '';
         }
     }, 'termina' => function ($url, $model) {
         $url = \yii\helpers\Url::current();
         if (\Yii::$app->getUser()->can($this->permissions['add'], ['model' => $this->model]) && ($this->model['id'] == $model['id_richiedente'] || $this->model['id'] == $model['id_destinatario']) && $model['descrizione'] == 'Attivo') {
             return Html::a('<p class="btn bk-btnAssociaCondominio" title="Termina contatto"><span id="bk-btnAssociaCondominio" class="ti ti-unlink"></span></p>', Yii::$app->urlManager->createUrl(['/admin/user-profile/cambia-stato-contatto', 'id' => $this->model['id'], 'azione' => 'termina', 'url' => $url]), ['title' => Yii::t('yii', 'Termina contatto')]);
         } else {
             return '';
         }
     }]]]]);
 }
コード例 #7
0
 /**
  * Renders the data models for the grid view.
  */
 public function renderItemsMittente()
 {
     return AmosGridView::widget(['dataProvider' => new \yii\data\ActiveDataProvider(['query' => $this->modelData]), 'columns' => ['userprofile.avatar_id' => ['label' => '', 'format' => 'html', 'value' => function ($model) {
         $mediafile = \pendalf89\filemanager\models\Mediafile::findOne($model['avatar_id']);
         $url = '/img/defaultProfilo.jpg';
         if ($mediafile) {
             $url = $mediafile->getThumbUrl('small');
         }
         return Html::img($url, ['width' => '50']);
     }], 'nome', 'cognome']]);
 }
コード例 #8
0
 /** Render model info
  * @param int $id
  * @param string $strictThumb only this thumb will be selected
  * @return string
  */
 public function actionInfo($id, $strictThumb = null)
 {
     $model = Mediafile::findOne($id);
     Yii::$app->assetManager->bundles = false;
     return $this->renderAjax('info', ['model' => $model, 'strictThumb' => $strictThumb]);
 }
コード例 #9
0
 /** Render model info
  * @param int $id
  * @param string $strictThumb only this thumb will be selected
  * @return string
  */
 public function actionInfo($id, $strictThumb = null)
 {
     $model = Mediafile::findOne($id);
     return $this->renderPartial('info', ['model' => $model, 'strictThumb' => $strictThumb]);
 }
コード例 #10
0
 /**
  * Load model by id
  * @param int $id
  * @return Mediafile
  */
 private function loadModel($id)
 {
     return Mediafile::findOne($id);
 }
コード例 #11
0
 /**
  * Renders the data models for the grid view.
  */
 public function renderItemsMittente()
 {
     return AmosGridView::widget(['dataProvider' => new \yii\data\ActiveDataProvider(['query' => $this->modelData]), 'columns' => ['committenti.avatar_id' => ['label' => '', 'format' => 'html', 'value' => function ($model) {
         $mediafile = \pendalf89\filemanager\models\Mediafile::findOne($model->committenti->avatar_id);
         $url = '/img/img_default.jpg';
         if ($mediafile) {
             $url = $mediafile->getThumbUrl('medium');
         }
         return Html::img($url, ['width' => '100']);
     }], 'committenti.denominazione' => ['attribute' => 'committenti.denominazione', 'label' => 'Rilasciata da'], 'numero_pan' => ['attribute' => 'numero_pan', 'label' => 'Numero carta'], 'scadenza:date', ['attribute' => 'numero_contatore', 'label' => 'Numero contratto'], ['attribute' => 'cf_condominio', 'label' => 'CF del condominio'], 'note:ntext']]);
 }
コード例 #12
0
 /**
  * Renders the data models for the grid view.
  */
 public function renderItemsMittente()
 {
     return AmosGridView::widget(['dataProvider' => new \yii\data\ActiveDataProvider(['query' => $this->modelData]), 'columns' => ['filemanager_mediafile_id' => ['label' => '', 'format' => 'html', 'value' => function ($model) {
         $mediafile = \pendalf89\filemanager\models\Mediafile::findOne($model['filemanager_mediafile_id']);
         $url = '/img/img_default.jpg';
         if ($mediafile) {
             $url = $mediafile->getThumbUrl('small');
         }
         return Html::img($url, ['width' => '50']);
     }], 'nome', 'codice_fiscale', 'via' => ['attribute' => 'via', 'label' => 'Indirizzo', 'value' => 'indirizzoCompleto'], ['class' => ActionColumn::className(), 'template' => '{condominio}', 'buttons' => ['condominio' => function ($url, $model) {
         //$url = \yii\helpers\Url::current();
         return Html::a('<p class="btn bk-btnAssociaCondominio" title="Visualizza i dettagli del condominio"><span id="bk-btnAssociaCondominio" class="ti ti-file"></span></p>', Yii::$app->urlManager->createUrl(['admin/user-profile/vedi-condominio', 'id' => $model['id'], 'utente' => $this->model['id'], 'url' => 'tab-condominio']), ['title' => Yii::t('yii', 'Visualizza i dettagli del condominio')]);
     }]]]]);
 }