Пример #1
0
 /**
  * Draws the Upload Button output.
  */
 public function run()
 {
     $objectModel = "";
     $objectId = "";
     if ($this->object !== null) {
         $objectModel = get_class($this->object);
         $objectId = $this->object->getPrimaryKey();
     }
     $this->render('videoUploadButton', array('fileListFieldName' => $this->fileListFieldName, 'uploaderId' => $this->uploaderId, 'objectModel' => $objectModel, 'objectId' => $objectId));
 }
 /**
  * Draws the Upload Button output.
  */
 public function run()
 {
     $objectModel = "";
     $objectId = "";
     if ($this->object !== null) {
         $objectModel = $this->object->className();
         $objectId = $this->object->getPrimaryKey();
     }
     return $this->render('embeddedMediaUploadButton', array('fileListFieldName' => $this->fileListFieldName, 'uploaderId' => $this->uploaderId, 'objectModel' => $objectModel, 'objectId' => $objectId));
 }
 /**
  * Attaches a given list of files to an record (HActiveRecord).
  * This is used when uploading files before the record is created yet.
  *
  * @param HActiveRecord $object is a HActiveRecord
  * @param string $files is a comma seperated list of newly uploaded file guids
  */
 public static function attachPrecreated($object, $files)
 {
     if (!$object instanceof \yii\db\ActiveRecord) {
         throw new Exception("Invalid object given - require instance of HActiveRecord!");
     }
     // Attach Files
     foreach (explode(",", $files) as $fileGuid) {
         $file = self::findOne(['guid' => trim($fileGuid)]);
         if ($file != null && $file->object_model == "") {
             $file->object_model = $object->className();
             $file->object_id = $object->getPrimaryKey();
             if (!$file->save()) {
                 throw new Exception("Could not save precreated file!");
             }
         }
     }
 }
Пример #4
0
 /**
  * Returns all files belongs to a given HActiveRecord Object.
  * @todo Add chaching
  * 
  * @param HActiveRecord $object
  * @return Array of File instances
  */
 public static function getFilesOfObject(HActiveRecord $object)
 {
     return File::model()->findAllByAttributes(array('object_id' => $object->getPrimaryKey(), 'object_model' => get_class($object)));
 }
 /**
  * Returns all files belongs to a given HActiveRecord Object.
  * 
  * @param HActiveRecord $object
  * @return Array of DropboxImage instances
  */
 public static function getFilesOfObject(HActiveRecord $object)
 {
     return DropboxFile::findAll(array('object_id' => $object->getPrimaryKey(), 'object_model' => get_class($object)));
 }