Ejemplo n.º 1
0
 public function getTypeObject()
 {
     $class = substr(get_called_class(), strrpos(get_called_class(), '\\') + 1);
     $class = substr($class, 0, strpos($class, 'Configuration'));
     $handle = uncamelcase($class);
     return \Concrete\Core\File\StorageLocation\Type\Type::getByHandle($handle);
 }
Ejemplo n.º 2
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());
 }
Ejemplo n.º 3
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);
 }
Ejemplo n.º 4
0
 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);
 }
Ejemplo n.º 5
0
 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());
 }
Ejemplo n.º 6
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());
 }
Ejemplo n.º 7
0
 protected function validateStorageRequest()
 {
     $request = \Request::getInstance();
     $val = Loader::helper('validation/strings');
     $type = Type::getByID($request->get('fslTypeID'));
     if (!is_object($type)) {
         $this->error->add(t('Invalid type object.'));
     } else {
         $e = $type->getConfigurationObject()->validateRequest($request);
         if (is_object($e)) {
             $this->error->add($e);
         }
     }
     if (!$val->notempty($request->request->get('fslName'))) {
         $this->error->add(t('Your file storage location must have a name.'));
     }
     return array($request, $type);
 }
Ejemplo n.º 8
0
 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);
     }
 }
Ejemplo n.º 9
0
 /**
  * Returns an array of package items (e.g. blocks, themes)
  * @return array
  */
 public function getPackageItems()
 {
     $items = array();
     $items['attribute_categories'] = AttributeKeyCategory::getListByPackage($this);
     $items['permission_categories'] = PermissionKeyCategory::getListByPackage($this);
     $items['permission_access_entity_types'] = PermissionAccessEntityType::getListByPackage($this);
     $items['attribute_keys'] = AttributeKey::getListByPackage($this);
     $items['attribute_sets'] = AttributeSet::getListByPackage($this);
     $items['group_sets'] = GroupSet::getListByPackage($this);
     $items['page_types'] = PageType::getListByPackage($this);
     $items['page_templates'] = PageTemplate::getListByPackage($this);
     $items['mail_importers'] = MailImporter::getListByPackage($this);
     $items['gathering_item_template_types'] = GatheringItemTemplateType::getListByPackage($this);
     $items['gathering_item_templates'] = GatheringItemTemplate::getListByPackage($this);
     $items['gathering_data_sources'] = GatheringDataSource::getListByPackage($this);
     $items['features'] = Feature::getListByPackage($this);
     $items['feature_categories'] = FeatureCategory::getListByPackage($this);
     $btl = new BlockTypeList();
     $btl->filterByPackage($this);
     $blocktypes = $btl->get();
     $items['block_types'] = $blocktypes;
     $items['block_type_sets'] = BlockTypeSet::getListByPackage($this);
     $items['page_themes'] = PageTheme::getListByPackage($this);
     $items['permissions'] = PermissionKey::getListByPackage($this);
     $items['single_pages'] = SinglePage::getListByPackage($this);
     $items['attribute_types'] = AttributeType::getListByPackage($this);
     $items['captcha_libraries'] = SystemCaptchaLibrary::getListByPackage($this);
     $items['content_editor_snippets'] = SystemContentEditorSnippet::getListByPackage($this);
     $items['conversation_editors'] = ConversationEditor::getListByPackage($this);
     $items['conversation_rating_types'] = ConversationRatingType::getListByPackage($this);
     $items['page_type_publish_target_types'] = PageTypePublishTargetType::getListByPackage($this);
     $items['page_type_composer_control_types'] = PageTypeComposerControlType::getListByPackage($this);
     $items['antispam_libraries'] = SystemAntispamLibrary::getListByPackage($this);
     $items['community_point_actions'] = UserPointAction::getListByPackage($this);
     $items['jobs'] = Job::getListByPackage($this);
     $items['workflow_types'] = WorkflowType::getListByPackage($this);
     $items['workflow_progress_categories'] = WorkflowProgressCategory::getListByPackage($this);
     $items['authentication_types'] = AuthenticationType::getListByPackage($this);
     $items['storage_locations'] = StorageLocation::getListByPackage($this);
     ksort($items);
     return $items;
 }
 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);
         }
     }
 }
 /**
  * {@inheritDoc}
  */
 public function includeOptionsForm($location = false)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'includeOptionsForm', array($location));
     return parent::includeOptionsForm($location);
 }
 /**
  * {@inheritDoc}
  */
 public function delete()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'delete', array());
     return parent::delete();
 }