Skip to content

Commit

Permalink
Project Logos (#21)
Browse files Browse the repository at this point in the history
* Create ProjectCoverimageModel.php

* Create ProjectCoverimageController.php

* Create images.php

* Create overview.php

* Update Plugin.php

* Update Plugin.php

* Update overview.php

* Update overview.php

* Update ProjectCoverimageModel.php

* Update ProjectCoverimageModel.php

* Update Plugin.php

* Update Plugin.php

* Update Plugin.php

* Update Plugin.php

* Update overview.php

* Update images.php

* Update overview.php

* Update overview.php

* Update overview.php

* Update overview.php

* Create project_title.php

* Update Plugin.php

* Update project_title.php

* Update overview.php

* Update README.md

* Update ProjectCoverimageController.php

* Update overview.php

* Update project_title.php

* Update overview.php

* Update overview.php

* Update project_title.php

* Update images.php

* Update images.php
  • Loading branch information
creecros authored and TimoStahl committed Oct 5, 2018
1 parent 322b107 commit 0ea7a4d
Show file tree
Hide file tree
Showing 7 changed files with 264 additions and 1 deletion.
37 changes: 37 additions & 0 deletions Controller/ProjectCoverimageController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace Kanboard\Plugin\Coverimage\Controller;

use Kanboard\Controller\BaseController;

/**
* Coverimage
*
* @package controller
* @author creecros
*/
class ProjectCoverimageController extends BaseController {

public function set() {
$project = $this->getProject();
$file = $this->getFile();

$this->projectCoverimageModel->setCoverimage($project['id'], $file['id']);

$this->flash->success(t('Coverimage set.'));

$this->response->redirect($this->helper->url->to('ProjectViewController', 'show', array('project_id' => $project['id'])), true);
}

public function remove() {
$project = $this->getProject();
$file = $this->getFile();

$this->projectCoverimageModel->removeCoverimage($project['id']);

$this->flash->success(t('Coverimage removed.'));

$this->response->redirect($this->helper->url->to('ProjectViewController', 'show', array('project_id' => $project['id'])), true);
}

}
27 changes: 27 additions & 0 deletions Model/ProjectCoverimageModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Kanboard\Plugin\Coverimage\Model;

use Kanboard\Model\ProjectFileModel;

class ProjectCoverimageModel extends ProjectFileModel {

public function setCoverimage($project_id, $image_id) {

$this->projectMetadataModel->save($project_id, array('prjcoverimage' => $image_id));
}

public function removeCoverimage($project_id) {

$this->projectMetadataModel->remove($project_id, 'prjcoverimage');
}

public function getCoverimage($project_id) {

$id = $this->projectMetadataModel->get($project_id, 'prjcoverimage');
if (!$id)
return(null);
return $this->getById($id);
}

}
4 changes: 4 additions & 0 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ class Plugin extends Base {
public function initialize() {
//Task Details
$this->template->setTemplateOverride('task_file/images', 'coverimage:task_file/images');
$this->template->setTemplateOverride('project_overview/images', 'coverimage:project_overview/images');
$this->template->setTemplateOverride('dashboard/overview', 'coverimage:dashboard/overview');
$this->template->setTemplateOverride('project_list/project_title', 'coverimage:project_list/project_title');

//Board
$this->hook->on('template:layout:css', array('template' => 'plugins/Coverimage/assets/css/board.css'));
Expand All @@ -25,6 +28,7 @@ public function getClasses() {
return array(
'Plugin\Coverimage\Model' => array(
'CoverimageModel',
'ProjectCoverimageModel',
)
);
}
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
Kanboard Plugin Coverimage
==========================

This plugin adds a coverimage function to the board.
This plugin adds a coverimage function to tasks on the board, and allows you to set a project image to use as a logo for projects.

## For Tasks
![cover_screenshot](https://cloud.githubusercontent.com/assets/1961634/23507319/c7e38892-ff4c-11e6-90c5-453f9bda4a0f.png)

## For Projects
![image](https://user-images.githubusercontent.com/26339368/46497665-3842a800-c7e9-11e8-8852-bfa60ec5ec3a.png)

![image](https://user-images.githubusercontent.com/26339368/46497695-4d1f3b80-c7e9-11e8-9861-61b08821f7ba.png)

![image](https://user-images.githubusercontent.com/26339368/46497724-5dcfb180-c7e9-11e8-82ea-173d633f602d.png)


Plugin for https://github.com/fguillot/kanboard

Author
Expand Down
106 changes: 106 additions & 0 deletions Template/dashboard/overview.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<div class="filter-box margin-bottom">
<form method="get" action="<?= $this->url->dir() ?>" class="search">
<?= $this->form->hidden('controller', array('controller' => 'SearchController')) ?>
<?= $this->form->hidden('action', array('action' => 'index')) ?>

<div class="input-addon">
<?= $this->form->text('search', array(), array(), array('placeholder="'.t('Search').'"'), 'input-addon-field') ?>
<div class="input-addon-item">
<?= $this->render('app/filters_helper') ?>
</div>
</div>
</form>
</div>

<?php if (! $project_paginator->isEmpty()): ?>
<div class="table-list">
<?= $this->render('project_list/header', array('paginator' => $project_paginator)) ?>
<?php foreach ($project_paginator->getCollection() as $project): ?>
<div class="table-list-row table-border-left">
<div>
<?php
$file = $this->task->projectCoverimageModel->getCoverimage($project['id']);
if(isset($file)){
?>
<span class="avatar avatar-20 avatar-inline">
<img src="<?= $this->url->href('FileViewerController', 'thumbnail', array('file_id' => $file['id'], 'project_id' => $project['id'])) ?>" title="<?= $this->text->e($file['name']) ?>" alt="<?= $this->text->e($file['name']) ?>" vspace="5" hspace="3" height="25">
</span>
<?php
}
?>
<?php if ($this->user->hasProjectAccess('ProjectViewController', 'show', $project['id'])): ?>
<?= $this->render('project/dropdown', array('project' => $project)) ?>
<?php else: ?>
<strong><?= '#'.$project['id'] ?></strong>
<?php endif ?>

<span class="table-list-title <?= $project['is_active'] == 0 ? 'status-closed' : '' ?>">
<?= $this->url->link($this->text->e($project['name']), 'BoardViewController', 'show', array('project_id' => $project['id'])) ?>
</span>

<?php if ($project['is_private']): ?>
<i class="fa fa-lock fa-fw" title="<?= t('Private project') ?>"></i>
<?php endif ?>
</div>
<div class="table-list-details">
<?php foreach ($project['columns'] as $column): ?>
<strong title="<?= t('Task count') ?>"><?= $column['nb_open_tasks'] ?></strong>
<small><?= $this->text->e($column['title']) ?></small>
<?php endforeach ?>
</div>
</div>
<?php endforeach ?>
</div>

<?= $project_paginator ?>
<?php endif ?>

<?php if (empty($overview_paginator)): ?>
<p class="alert"><?= t('There is nothing assigned to you.') ?></p>
<?php else: ?>
<?php foreach ($overview_paginator as $result): ?>
<?php if (! $result['paginator']->isEmpty()): ?>
<div class="page-header">
<h2 id="project-tasks-<?= $result['project_id'] ?>"><?= $this->url->link($this->text->e($result['project_name']), 'BoardViewController', 'show', array('project_id' => $result['project_id'])) ?></h2>
</div>

<div class="table-list">
<?= $this->render('task_list/header', array(
'paginator' => $result['paginator'],
)) ?>

<?php foreach ($result['paginator']->getCollection() as $task): ?>
<div class="table-list-row color-<?= $task['color_id'] ?>">
<?= $this->render('task_list/task_title', array(
'task' => $task,
'redirect' => 'dashboard',
)) ?>

<?= $this->render('task_list/task_details', array(
'task' => $task,
)) ?>

<?= $this->render('task_list/task_avatars', array(
'task' => $task,
)) ?>

<?= $this->render('task_list/task_icons', array(
'task' => $task,
)) ?>

<?= $this->render('task_list/task_subtasks', array(
'task' => $task,
'user_id' => $user['id'],
)) ?>

<?= $this->hook->render('template:dashboard:task:footer', array('task' => $task)) ?>
</div>
<?php endforeach ?>
</div>

<?= $result['paginator'] ?>
<?php endif ?>
<?php endforeach ?>
<?php endif ?>

<?= $this->hook->render('template:dashboard:show', array('user' => $user)) ?>
21 changes: 21 additions & 0 deletions Template/project_list/project_title.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<div>
<?php
$file = $this->task->projectCoverimageModel->getCoverimage($project['id']);
if(isset($file)){
?>
<span class="avatar avatar-20 avatar-inline">
<img src="<?= $this->url->href('FileViewerController', 'thumbnail', array('file_id' => $file['id'], 'project_id' => $project['id'])) ?>" title="<?= $this->text->e($file['name']) ?>" alt="<?= $this->text->e($file['name']) ?>" vspace="5" hspace="3" height="25">
</span>
<?php
}
?>
<?php if ($this->user->hasProjectAccess('ProjectViewController', 'show', $project['id'])): ?>
<?= $this->render('project/dropdown', array('project' => $project)) ?>
<?php else: ?>
<strong><?= '#'.$project['id'] ?></strong>
<?php endif ?>

<span class="table-list-title <?= $project['is_active'] == 0 ? 'status-closed' : '' ?>">
<?= $this->url->link($this->text->e($project['name']), 'BoardViewController', 'show', array('project_id' => $project['id'])) ?>
</span>
</div>
59 changes: 59 additions & 0 deletions Template/project_overview/images.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php if (! empty($images)): ?>
<div class="file-thumbnails">
<?php foreach ($images as $file): ?>
<div class="file-thumbnail">
<?= $this->app->component('image-slideshow', array(
'images' => $images,
'image' => $file,
'regex' => 'FILE_ID',
'url' => array(
'image' => $this->url->to('FileViewerController', 'image', array('file_id' => 'FILE_ID', 'project_id' => $project['id'])),
'thumbnail' => $this->url->to('FileViewerController', 'thumbnail', array('file_id' => 'FILE_ID', 'project_id' => $project['id'])),
'download' => $this->url->to('FileViewerController', 'download', array('file_id' => 'FILE_ID', 'project_id' => $project['id'])),
)
)) ?>
<?php
$coverimage = $this->task->projectCoverimageModel->getCoverimage($project['id']);
?>

<div class="file-thumbnail-content">
<div class="file-thumbnail-title">
<div class="dropdown">
<a href="#" class="dropdown-menu dropdown-menu-link-text"><?= $this->text->e($file['name']) ?> <i class="fa fa-caret-down"></i></a>
<ul>
<li>
<?= $this->url->icon('external-link', t('View file'), 'FileViewerController', 'image', array('project_id' => $project['id'], 'file_id' => $file['id']), false, '', '', true) ?>
</li>
<li>
<?= $this->url->icon('download', t('Download'), 'FileViewerController', 'download', array('project_id' => $project['id'], 'file_id' => $file['id'])) ?>
</li>
<?php if ($this->user->hasProjectAccess('ProjectFileController', 'remove', $project['id'])): ?>
<li>
<?= $this->modal->confirm('trash-o', t('Remove'), 'ProjectFileController', 'confirm', array('project_id' => $project['id'], 'file_id' => $file['id'])) ?>
</li>
<?php endif ?>
<li>
<i class="fa fa-newspaper-o fa-fw"></i>
<?php if($file['id'] != $coverimage['id']){ ?>
<?= $this->url->link(t('set as coverimage'), 'ProjectCoverimageController', 'set', array('plugin' => 'coverimage', 'project_id' => $project['id'], 'file_id' => $file['id'])) ?>
<?php } else { ?>
<?= $this->url->link(t('remove coverimage'), 'ProjectCoverimageController', 'remove', array('plugin' => 'coverimage', 'project_id' => $project['id'], 'file_id' => $file['id'])) ?>
<?php } ?>
</li>
</ul>
</div>
</div>
<div class="file-thumbnail-description">
<?= $this->app->tooltipMarkdown(t('Uploaded: %s', $this->dt->datetime($file['date']))."\n\n".t('Size: %s', $this->text->bytes($file['size']))) ?>
<?php if (! empty($file['user_id'])): ?>
<?= t('Uploaded by %s', $file['user_name'] ?: $file['username']) ?>
<?php else: ?>
<?= t('Uploaded: %s', $this->dt->datetime($file['date'])) ?>
<?php endif ?>
</div>
</div>
</div>
<?php endforeach ?>
</div>
<?php endif ?>

0 comments on commit 0ea7a4d

Please sign in to comment.