Advertisement
KEFIR4UK

Untitled

Jul 30th, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.70 KB | None | 0 0
  1. <?php
  2.  
  3. // if you need - import the module-level models and components
  4. //Yii::import('application.modules.moduleID.models.*');
  5. //Yii::import('application.modules.moduleID.components.*');
  6.  
  7. class PhotoUploadWidget extends CmsWidget
  8. {
  9.     /**
  10.      *
  11.      */
  12.     public function init()
  13.     {
  14.         $criteria = new CDbCriteria();
  15.         $criteria->compare('gallery_id',$this->model->id);
  16.         $dataProvider = new CActiveDataProvider('Photo',array(
  17.             'criteria'=>$criteria
  18.         ));
  19.  
  20.         $this->widget('zii.widgets.grid.CGridView',array(
  21.             'id'=>'photo-grid-slide',
  22.             'dataProvider' => $dataProvider,
  23.             'columns' => array(
  24.                 array(
  25.                     'name'=>'alt',
  26.                     'type'=>'image',
  27.                     'value'=>'$data->getImage(250,150)',
  28.                 ),
  29.                 array(
  30.                     'class'=>'CButtonColumn',
  31.                     'template'=>'{delete}',
  32.                     'deleteButtonUrl'=>'Yii::app()->createUrl("/gallery/admin/photo/delete",array("id"=>$data->primaryKey))'
  33.                 ),
  34.             ),
  35.         ));
  36.  
  37.  
  38.         $photoModel = new Photo();
  39.         $this->widget('application.modules.gallery.extensions.xupload.XUpload',array(
  40.             'url'=>Yii::app()->createUrl('/gallery/admin/photo/upload'),
  41.             'model'=>$photoModel,
  42.             'attribute'=>'image',
  43.             'multiple'=>true,
  44.             'options'=>array(
  45.                 'formData'=>array(
  46.                     'Photo[gallery_id]'=>$this->model->id,
  47.                 ),
  48.             ),
  49.             'htmlOptions'=>array(
  50.                 'id'=>get_class($photoModel).'-form',
  51.             ),
  52.         ));
  53.  
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement