Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Nex4T committed Nov 16, 2018
1 parent 252a0dd commit 4b8d23c
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 2 deletions.
1 change: 1 addition & 0 deletions upload/application/modules/gamelist/config/config.php
Expand Up @@ -56,6 +56,7 @@ public function getInstallSql()
'CREATE TABLE IF NOT EXISTS `[prefix]_gamelist` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`title` VARCHAR(100) NOT NULL,
`videourl` VARCHAR(100) NOT NULL,
`image` VARCHAR(255) NULL DEFAULT NULL,
`show` TINYINT(1) NOT NULL DEFAULT 1,
PRIMARY KEY (`id`)
Expand Down
Expand Up @@ -88,9 +88,12 @@ public function treatAction()

$post = [
'title' => $this->getRequest()->getPost('title'),
'videourl' => $this->getRequest()->getPost('videourl'),
'image' => $image
];

$newvideoUrl = str_replace("https://www.youtube.com/watch?v=","", $post['videourl']);

$validation = Validation::create($post, [
'title' => 'required',
'image' => 'required|url'
Expand All @@ -104,7 +107,8 @@ public function treatAction()
$model->setId($this->getRequest()->getParam('id'));
}
$model->setTitle($post['title'])
->setImage($post['image']);
->setVideourl($newvideoUrl)
->setImage($post['image']);
$gamesMapper->save($model);

$this->redirect()
Expand Down
3 changes: 3 additions & 0 deletions upload/application/modules/gamelist/mappers/Games.php
Expand Up @@ -34,6 +34,7 @@ public function getEntries($where = [])
$model = new GamesModel();
$model->setId($entry['id'])
->setTitle($entry['title'])
->setVideourl($entry['videourl'])
->setImage($entry['image'])
->setShow($entry['show']);
$entries[] = $model;
Expand Down Expand Up @@ -63,6 +64,7 @@ public function getEntryById($id)
$model = new GamesModel();
$model->setId($row['id'])
->setTitle($row['title'])
->setVideourl($row['videourl'])
->setImage($row['image'])
->setShow($row['show']);

Expand All @@ -78,6 +80,7 @@ public function save(GamesModel $entry)
{
$fields = [
'title' => $entry->getTitle(),
'videourl' => $entry->getVideourl(),
'image' => $entry->getImage(),
'show' => $entry->getShow()
];
Expand Down
30 changes: 30 additions & 0 deletions upload/application/modules/gamelist/models/Games.php
Expand Up @@ -22,6 +22,13 @@ class Games extends \Ilch\Model
*/
protected $title;

/**
* The Videourl.
*
* @var string
*/
protected $videourl;

/**
* The image.
*
Expand Down Expand Up @@ -69,6 +76,29 @@ public function getTitle()
return $this->title;
}

/**
* Sets the videourl.
*
* @param string $videourl
* @return $this
*/
public function setVideourl($videourl)
{
$this->videourl = (string)$videourl;

return $this;
}

/**
* Gets the videourl.
*
* @return string
*/
public function getVideourl()
{
return $this->videourl;
}

/**
* Sets the title.
*
Expand Down
1 change: 1 addition & 0 deletions upload/application/modules/gamelist/translations/de.php
Expand Up @@ -11,6 +11,7 @@
'image' => 'Bild',
'members' => 'Mitglieder',
'games' => 'Spiele',
'videourl' => 'Youtube URL',
'selectGames' => 'Spiele wählen',
'profileFieldHidden' => 'Feld vom Administrator ausgeblendet.',

Expand Down
1 change: 1 addition & 0 deletions upload/application/modules/gamelist/translations/en.php
Expand Up @@ -11,6 +11,7 @@
'image' => 'Image',
'members' => 'Members',
'games' => 'Games',
'videourl' => 'Youtube URL',
'selectGames' => 'Select games',
'profileFieldHidden' => 'Field hidden by the administrator.',

Expand Down
Expand Up @@ -18,6 +18,7 @@
<th></th>
<th></th>
<th><?=$this->getTrans('title') ?></th>
<th><?=$this->getTrans('videourl') ?></th>
</tr>
</thead>
<tbody>
Expand All @@ -38,6 +39,7 @@
<?php endif; ?>
</td>
<td><?=$this->escape($entry->getTitle()) ?></td>
<td><?=$this->escape($entry->getVideourl()) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
Expand Down
12 changes: 12 additions & 0 deletions upload/application/modules/gamelist/views/admin/index/treat.php
Expand Up @@ -13,6 +13,18 @@ class="form-control"
value="<?=($this->get('entry') != '') ? $this->escape($this->get('entry')->getTitle()) : $this->originalInput('title') ?>">
</div>
</div>
<div class="form-group">
<label for="title" class="col-lg-2 control-label">
<?=$this->getTrans('videourl') ?>:
</label>
<div class="col-lg-3">
<input type="text"
class="form-control"
name="videourl"
id="videourl"
value="<?=($this->get('entry') != '') ? $this->escape($this->get('entry')->getVideourl()) : $this->originalInput('videourl') ?>">
</div>
</div>
<div class="form-group <?=$this->validation()->hasError('image') ? 'has-error' : '' ?>">
<label for="selectedImage" class="col-lg-2 control-label">
<?=$this->getTrans('image') ?>:
Expand Down
22 changes: 21 additions & 1 deletion upload/application/modules/gamelist/views/index/index.php
Expand Up @@ -10,7 +10,27 @@
<?php $entrantsUsers = $entrantsMapper->getEntrantsByGameId($entry->getId()); ?>
<div class="game">
<div class="image">
<img src="<?=(substr($entry->getImage(), 0, 11) == 'application') ? $this->getBaseUrl($entry->getImage()) : $entry->getImage() ?>" alt="<?=$this->escape($entry->getTitle()) ?>" title="<?=$this->escape($entry->getTitle()) ?>" />
<?php if (!$entry->getVideourl()):?>
<img src="<?=(substr($entry->getImage(), 0, 11) == 'application') ? $this->getBaseUrl($entry->getImage()) : $entry->getImage() ?>" alt="<?=$this->escape($entry->getTitle()) ?>" title="<?=$this->escape($entry->getTitle()) ?>" />
<?php else: ?>
<a href="#" data-toggle="modal" data-target="#videoModal_<?=$entry->getId() ?>">
<img src="<?=(substr($entry->getImage(), 0, 11) == 'application') ? $this->getBaseUrl($entry->getImage()) : $entry->getImage() ?>" alt="<?=$this->escape($entry->getTitle()) ?>" title="<?=$this->escape($entry->getTitle()) ?>" />
</a>
<!-- Video Modal -->
<div id="videoModal_<?=$entry->getId() ?>" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title"><?=$this->escape($entry->getTitle()) ?></h4>
</div>
<div class="modal-body">
<iframe width="100%" height="250px" src="https://www.youtube.com/embed/<?=$entry->getVideourl() ?>" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
</div>
</div>
</div>
<?php endif; ?>
</div>
<div class="desc">
<span><?=$this->escape($entry->getTitle()) ?></span>
Expand Down

0 comments on commit 4b8d23c

Please sign in to comment.