Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pull-requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Pull Requests
on:
pull_request:
branches:
- main
- master

jobs:
runner:
Expand Down
14 changes: 7 additions & 7 deletions Building/Building.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,31 +102,31 @@ public static function init()
SiteViewFactory::addPath('Building/views');
SiteViewFactory::registerView(
'building-block-audio',
'BuildingBlockAudioView'
BuildingBlockAudioView::class
);
SiteViewFactory::registerView(
'building-block-video',
'BuildingBlockVideoView'
BuildingBlockVideoView::class
);
SiteViewFactory::registerView(
'building-block-image',
'BuildingBlockImageView'
BuildingBlockImageView::class
);
SiteViewFactory::registerView(
'building-block-xhtml',
'BuildingBlockXHTMLView'
BuildingBlockXHTMLView::class
);
SiteViewFactory::registerView(
'building-block-attachment',
'BuildingBlockAttachmentView'
BuildingBlockAttachmentView::class
);
SiteViewFactory::registerView(
'building-block',
'BuildingBlockCompositeView'
BuildingBlockCompositeView::class
);
SiteViewFactory::registerView(
'building-block-admin',
'BuildingBlockAdminCompositeView'
BuildingBlockAdminCompositeView::class
);

SwatUI::mapClassPrefixToPath('Building', 'Building');
Expand Down
21 changes: 11 additions & 10 deletions Building/BuildingBlockViewFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,19 @@ public static function getBlockView(
*/
public static function getViewType(BuildingBlock $block)
{
$type = 'building-block-xhtml';

if ($block->media instanceof SiteAudioMedia) {
$type = 'building-block-audio';
} elseif ($block->media instanceof SiteVideoMedia) {
$type = 'building-block-video';
} elseif ($block->image instanceof SiteImage) {
$type = 'building-block-image';
} elseif ($block->attachment instanceof SiteAttachment) {
$type = 'building-block-attachment';
return 'building-block-audio';
}
if ($block->media instanceof SiteVideoMedia) {
return 'building-block-video';
}
if ($block->image instanceof SiteImage) {
return 'building-block-image';
}
if ($block->attachment instanceof SiteAttachment) {
return 'building-block-attachment';
}

return $type;
return 'building-block-xhtml';
}
}
6 changes: 2 additions & 4 deletions Building/admin/components/Block/AttachmentEdit.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ protected function getAttachmentSet()
$this->attachment_set =
$this->getObject()->attachment->attachment_set;
} else {
$class_name = SwatDBClassMap::get('SiteAttachmentSet');
$this->attachment_set = new $class_name();
$this->attachment_set = SwatDBClassMap::new(SiteAttachmentSet::class);
$this->attachment_set->setDatabase($this->app->db);
$shortname = $this->getAttachmentSetShortname();
if (!$this->attachment_set->loadByShortname($shortname)) {
Expand All @@ -48,8 +47,7 @@ protected function getAttachmentSet()

protected function getNewAttachmentInstance()
{
$class_name = SwatDBClassMap::get('SiteAttachment');
$attachment = new $class_name();
$attachment = SwatDBClassMap::new(SiteAttachment::class);
$attachment->setDatabase($this->app->db);
$attachment->attachment_set = $this->getAttachmentSet();

Expand Down
2 changes: 1 addition & 1 deletion Building/admin/components/Block/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function buildInternal()
'select * from Block where id in (%s)',
$this->getItemList('integer')
),
SwatDBClassMap::get('BuildingBlockWrapper')
SwatDBClassMap::get(BuildingBlockWrapper::class)
);

$view = SiteViewFactory::get($this->app, 'building-block');
Expand Down
2 changes: 1 addition & 1 deletion Building/admin/components/Block/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ abstract class BuildingBlockEdit extends AdminObjectEdit
{
protected function getObjectClass()
{
return 'BuildingBlock';
return BuildingBlock::class;
}

// process phase
Expand Down
6 changes: 2 additions & 4 deletions Building/admin/components/Block/ImageEdit.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ protected function getImageSet()
if ($this->getObject()->image instanceof SiteImage) {
$this->image_set = $this->getObject()->image->image_set;
} else {
$class_name = SwatDBClassMap::get('SiteImageSet');
$this->image_set = new $class_name();
$this->image_set = SwatDBClassMap::new(SiteImageSet::class);
$this->image_set->setDatabase($this->app->db);
$shortname = $this->getImageSetShortname();
if (!$this->image_set->loadByShortname($shortname)) {
Expand All @@ -47,8 +46,7 @@ protected function getImageSet()

protected function getNewImageInstance()
{
$class_name = SwatDBClassMap::get('SiteImage');
$image = new $class_name();
$image = SwatDBClassMap::new(SiteImage::class);
$image->setDatabase($this->app->db);
$image->image_set = $this->getImageSet();

Expand Down
12 changes: 8 additions & 4 deletions Building/admin/components/Block/VideoEdit.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ protected function getMedia()
} else {
$media_id = $this->app->initVar('media');
if ($media_id === null) {
/** @var SwatForm $form */
$form = $this->ui->getWidget('edit_form');
$media_id = $form->getHiddenField('media');
}

$class_name = SwatDBClassMap::get('SiteVideoMedia');
$this->media = new $class_name();
$this->media = SwatDBClassMap::new(SiteVideoMedia::class);
$this->media->setDatabase($this->app->db);
if (!$this->media->load($media_id)) {
throw new AdminNotFoundException(
Expand Down Expand Up @@ -93,12 +93,16 @@ protected function buildInternal()
$media = $this->getMedia();
$media->setFileBase('media');

$this->ui->getWidget('edit_form')->addHiddenField('media', $media->id);
/** @var SwatForm $form */
$form = $this->ui->getWidget('edit_form');
$form->addHiddenField('media', $media->id);

$player = $media->getMediaPlayer($this->app);
ob_start();
$player->display();
$this->ui->getWidget('player')->content = ob_get_clean();
/** @var SwatContentBlock $ui_player */
$ui_player = $this->ui->getWidget('player');
$ui_player->content = ob_get_clean();
$this->layout->addHtmlHeadEntrySet($player->getHtmlHeadEntrySet());
}

Expand Down
12 changes: 8 additions & 4 deletions Building/dataobjects/BuildingBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
*
* @copyright 2014-2016 silverorange
* @license http://www.opensource.org/licenses/mit-license.html MIT License
*
* @property ?SiteAttachment $attachment
* @property ?SiteImage $image
* @property ?SiteVideoMedia $media
*/
class BuildingBlock extends SwatDBDataObject
{
Expand All @@ -14,7 +18,7 @@ class BuildingBlock extends SwatDBDataObject
public $id;

/**
* @var string
* @var ?string
*/
public $bodytext;

Expand Down Expand Up @@ -44,17 +48,17 @@ protected function init()

$this->registerInternalProperty(
'attachment',
SwatDBClassMap::get('SiteAttachment')
SwatDBClassMap::get(SiteAttachment::class)
);

$this->registerInternalProperty(
'image',
SwatDBClassMap::get('SiteImage')
SwatDBClassMap::get(SiteImage::class)
);

$this->registerInternalProperty(
'media',
SwatDBClassMap::get('SiteVideoMedia')
SwatDBClassMap::get(SiteVideoMedia::class)
);

$this->id_field = 'integer:id';
Expand Down
2 changes: 1 addition & 1 deletion Building/dataobjects/BuildingBlockWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class BuildingBlockWrapper extends SwatDBRecordsetWrapper
protected function init()
{
parent::init();
$this->row_wrapper_class = SwatDBClassMap::get('BuildingBlock');
$this->row_wrapper_class = SwatDBClassMap::get(BuildingBlock::class);
$this->index_field = 'id';
}
}
Loading