예제 #1
0
 public function testAvatar()
 {
     $type = Type::add('default', t('Default'));
     $configuration = $type->getConfigurationObject();
     $fsl = StorageLocation::add($configuration, 'Default', true);
     $service = Core::make('user.registration');
     $ui = $service->create(array('uName' => 'andrew', 'uEmail' => '*****@*****.**'));
     $this->assertFalse($ui->hasAvatar());
     $avatar = $ui->getUserAvatar();
     $this->assertInstanceOf('Concrete\\Core\\User\\Avatar\\EmptyAvatar', $avatar);
     $this->assertEquals('<img src="/path/to/server/concrete/images/avatar_none.png" alt="andrew" class="u-avatar">', $avatar->output());
     $this->assertEquals('/path/to/server/concrete/images/avatar_none.png', $avatar->getPath());
     $ui->update(array('uHasAvatar' => true));
     // This is lame, I know.
     $ui = Core::make('Concrete\\Core\\User\\UserInfoFactory')->getByID(1);
     $this->assertTrue($ui->hasAvatar());
     $avatar = $ui->getUserAvatar();
     $this->assertEquals('http://www.dummyco.com/path/to/server/application/files/avatars/1.jpg', $avatar->getPath());
     $this->assertEquals('<img src="http://www.dummyco.com/path/to/server/application/files/avatars/1.jpg" alt="andrew" class="u-avatar">', $avatar->output());
     $service = Core::make('user.avatar');
     $service->removeAvatar($ui);
     // I KNOW I KNOW This is lame
     $ui = Core::make('Concrete\\Core\\User\\UserInfoFactory')->getByID(1);
     $this->assertFalse($ui->hasAvatar());
 }
예제 #2
0
 /**
  * @return \Concrete\Core\File\StorageLocation\StorageLocation
  */
 protected function getStorageLocation()
 {
     $type = Type::add('local', t('Local Storage'));
     $configuration = $type->getConfigurationObject();
     $configuration->setRootPath($this->getStorageDirectory());
     $configuration->setWebRootRelativePath('/application/files');
     return StorageLocation::add($configuration, 'Default', true);
 }
예제 #3
0
 public function testGetByDefault()
 {
     $this->getStorageLocation();
     $type = Type::getByHandle('local');
     $configuration = $type->getConfigurationObject();
     StorageLocation::add($configuration, 'Other Storage');
     $location = StorageLocation::getDefault();
     $this->assertInstanceOf('\\Concrete\\Core\\File\\StorageLocation\\StorageLocation', $location);
     $this->assertEquals(true, $location->isDefault());
     $this->assertEquals('Default', $location->getName());
     $alternate = StorageLocation::getByID(2);
     $this->assertInstanceOf('\\Concrete\\Core\\File\\StorageLocation\\StorageLocation', $alternate);
     $this->assertEquals(false, $alternate->isDefault());
     $this->assertEquals('Other Storage', $alternate->getName());
 }
 public function import_files()
 {
     $type = \Concrete\Core\File\StorageLocation\Type\Type::add('default', t('Default'));
     \Concrete\Core\File\StorageLocation\Type\Type::add('local', t('Local'));
     $configuration = $type->getConfigurationObject();
     $fsl = \Concrete\Core\File\StorageLocation\StorageLocation::add($configuration, t('Default'), true);
     $thumbnailType = new Type();
     $thumbnailType->requireType();
     $thumbnailType->setName(tc('ThumbnailTypeName', 'File Manager Thumbnails'));
     $thumbnailType->setHandle(Config::get('concrete.icons.file_manager_listing.handle'));
     $thumbnailType->setWidth(Config::get('concrete.icons.file_manager_listing.width'));
     $thumbnailType->setHeight(Config::get('concrete.icons.file_manager_listing.height'));
     $thumbnailType->save();
     $thumbnailType = new Type();
     $thumbnailType->requireType();
     $thumbnailType->setName(tc('ThumbnailTypeName', 'File Manager Detail Thumbnails'));
     $thumbnailType->setHandle(Config::get('concrete.icons.file_manager_detail.handle'));
     $thumbnailType->setWidth(Config::get('concrete.icons.file_manager_detail.width'));
     $thumbnailType->save();
     if (is_dir($this->getPackagePath() . '/files')) {
         $ch = new ContentImporter();
         $computeThumbnails = true;
         if ($this->contentProvidesFileThumbnails()) {
             $computeThumbnails = false;
         }
         $ch->importFiles($this->getPackagePath() . '/files', $computeThumbnails);
     }
 }
예제 #5
0
 public function add()
 {
     list($request, $type) = $this->validateStorageRequest();
     if (!Loader::helper('validation/token')->validate('add')) {
         $this->error->add(Loader::helper('validation/token')->getErrorMessage());
     }
     if (!$this->error->has()) {
         $configuration = $type->getConfigurationObject();
         $configuration->loadFromRequest($request);
         $fsl = FileStorageLocation::add($configuration, $request->request->get('fslName'), $request->request->get('fslIsDefault'));
         $this->redirect('/dashboard/system/files/storage', 'storage_location_added');
     }
     $this->set('type', $type);
 }
 public function import_files()
 {
     $type = \Concrete\Core\File\StorageLocation\Type\Type::add('default', t('Default'));
     \Concrete\Core\File\StorageLocation\Type\Type::add('local', t('Local'));
     $configuration = $type->getConfigurationObject();
     $fsl = \Concrete\Core\File\StorageLocation\StorageLocation::add($configuration, t('Default'), true);
     $thumbnailType = new Type();
     $thumbnailType->requireType();
     $thumbnailType->setName(tc('ThumbnailTypeName', 'File Manager Thumbnails'));
     $thumbnailType->setHandle(\Config::get('concrete.icons.file_manager_listing.handle'));
     $thumbnailType->setWidth(\Config::get('concrete.icons.file_manager_listing.width'));
     $thumbnailType->setHeight(\Config::get('concrete.icons.file_manager_listing.height'));
     $thumbnailType->save();
     $thumbnailType = new Type();
     $thumbnailType->requireType();
     $thumbnailType->setName(tc('ThumbnailTypeName', 'File Manager Detail Thumbnails'));
     $thumbnailType->setHandle(\Config::get('concrete.icons.file_manager_detail.handle'));
     $thumbnailType->setWidth(\Config::get('concrete.icons.file_manager_detail.width'));
     $thumbnailType->save();
     if (is_dir($this->getPackagePath() . '/files')) {
         $fh = new FileImporter();
         $contents = Loader::helper('file')->getDirectoryContents($this->getPackagePath() . '/files');
         foreach ($contents as $filename) {
             $f = $fh->import($this->getPackagePath() . '/files/' . $filename, $filename);
         }
     }
 }