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()); }
/** * @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); }
public function testDefaultStorageLocation() { $type = Type::add('default', t('Default')); $configuration = $type->getConfigurationObject(); $fsl = StorageLocation::add($configuration, 'Default', true); $fsl = StorageLocation::getByID(1); $configuration = $fsl->getConfigurationObject(); $this->assertEquals(DIR_FILES_UPLOADED_STANDARD, $configuration->getRootPath()); $this->assertEquals('http://www.dummyco.com/path/to/server/application/files/test.txt', $configuration->getPublicURLToFile('/test.txt')); }
public function testCreateType() { $type = Type::add('local', t('Local Storage')); $this->assertInstanceOf('\\Concrete\\Core\\File\\StorageLocation\\Type\\Type', $type); $this->assertEquals('Local Storage', $type->getName()); $this->assertEquals(1, $type->getID()); $this->assertEquals(0, $type->getPackageID()); $this->assertEquals('local', $type->getHandle()); $type2 = Type::getByHandle('local'); $this->assertEquals($type, $type2); }
public function testConfigureType() { $type = Type::add('local', t('Local Storage')); $configuration = $type->getConfigurationObject(); $configuration->setRootPath($this->getStorageDirectory()); $this->assertInstanceOf('\\Concrete\\Core\\File\\StorageLocation\\Configuration\\LocalConfiguration', $configuration); $this->assertEquals($this->getStorageDirectory(), $configuration->getRootPath()); $req = new \Concrete\Core\Http\Request(); $req->setMethod('POST'); $data = array(); $data['path'] = '/foo/bar/path'; $req->request->set('fslType', $data); $configuration->loadFromRequest($req); $this->assertEquals('/foo/bar/path', $configuration->getRootPath()); }
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); } }
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); } } }