Skip to content

Commit

Permalink
Merge pull request #7 from creecros/creecros-patch-2
Browse files Browse the repository at this point in the history
CJK Support
  • Loading branch information
creecros authored Apr 12, 2019
2 parents 4113d90 + c8a92f4 commit 0a083ff
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Controller/PrintTaskController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ public function printTask()
$dompdf = new Dompdf($options);
$dompdf->setBasePath('/var/www/app/');

if ($this->configModel->get('task2pdf_cjk', 1) == 1) { $layout = 'Task2pdf:printlayout/printlayout_n'; } else { $layout = 'Task2pdf:printlayout/printlayout_cjk'; }

$task = $this->getTask();
$subtasks = $this->subtaskModel->getAll($task['id']);
$files = $this->taskFileModel->getAllDocuments($task['id']);
$commentSortingDirection = $this->userMetadataCacheDecorator->get(UserMetadataModel::KEY_COMMENT_SORTING_DIRECTION, 'ASC');

$html = $this->helper->layout->app('Task2pdf:printlayout/printlayout', array(
$html = $this->helper->layout->app($layout, array(
'project' => $this->projectModel->getById($task['project_id']),
'comments' => $this->commentModel->getAll($task['id'], $commentSortingDirection),
'subtasks' => $subtasks,
Expand Down
3 changes: 2 additions & 1 deletion Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Plugin extends Base
public function initialize()
{
$this->template->hook->attach('template:task:sidebar:information', 'task2pdf:print');
$this->template->hook->attach('template:config:application', 'task2pdf:config/font_toggle');
}

public function getClasses() {
Expand All @@ -34,7 +35,7 @@ public function getPluginAuthor()

public function getPluginVersion()
{
return '0.0.3';
return '1.1.0';
}

public function getPluginDescription()
Expand Down
4 changes: 4 additions & 0 deletions Template/config/font_toggle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div class="panel">
<?= $this->form->radio('task2pdf_cjk', 'Normal Font set when creating PDFs' , 1, isset($values['task2pdf_cjk'])&& $values['task2pdf_cjk']==1) ?>
<?= $this->form->radio('task2pdf_cjk', 'CJK Font set when creating PDFs' , 2, isset($values['task2pdf_cjk'])&& $values['task2pdf_cjk']==2) ?>
</div>
14 changes: 13 additions & 1 deletion Template/printlayout/details.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
</td>
<td>
<strong><?= t('Due date:') ?></strong>
<?php if ($task['date_due'] > 0): ?>
<span><?= $this->dt->datetime($task['date_due']) ?></span>
<?php endif ?>
</td>
</tr>
<tr>
Expand All @@ -60,7 +62,9 @@
</td>
<td>
<strong><?= t('Started:') ?></strong>
<?php if ($task['date_started'] > 0): ?>
<span><?= $this->dt->datetime($task['date_started']) ?></span>
<?php endif ?>
</td>
</tr>
<tr>
Expand All @@ -77,7 +81,9 @@
</td>
<td>
<strong><?= t('Created:') ?></strong>
<?php if ($task['date_creation'] > 0): ?>
<span><?= $this->dt->datetime($task['date_creation']) ?></span>
<?php endif ?>
</td>
</tr>
<tr>
Expand All @@ -94,7 +100,9 @@
</td>
<td>
<strong><?= t('Modified:') ?></strong>
<?php if ($task['date_modification'] > 0): ?>
<span><?= $this->dt->datetime($task['date_modification']) ?></span>
<?php endif ?>
</td>
</tr>
<tr>
Expand All @@ -105,8 +113,10 @@
<td>
</td>
<td>
<strong><?= t('Finished:') ?></strong>
<strong><?= t('Completed:') ?></strong>
<?php if ($task['date_completed'] > 0): ?>
<span><?= $this->dt->datetime($task['date_completed']) ?></span>
<?php endif ?>
</td>
</tr>
<tr>
Expand All @@ -118,7 +128,9 @@
</td>
<td>
<strong><?= t('Moved:') ?></strong>
<?php if ($task['date_completed'] > 0): ?>
<span><?= $this->dt->datetime($task['date_moved']) ?></span>
<?php endif ?>
</td>
</tr>
</table>
Expand Down
89 changes: 89 additions & 0 deletions Template/printlayout/printlayout_cjk.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
@font-face {
font-family: 'Droid Sans';
font-style: normal;
font-weight: 400;
src: url('/plugins/Task2pdf/font/DroidSansFallback.ttf') format('truetype');
src: url(https://github.com/creecros/Task2pdf/blob/creecros-patch-2/font/DroidSansFallback.ttf?raw=true) format('truetype');
}
@font-face {
font-family: 'Droid Sans';
font-style: normal;
font-weight: bold;
src: url('/plugins/Task2pdf/font/DroidSansFallback.ttf') format('truetype');
src: url(https://github.com/creecros/Task2pdf/blob/creecros-patch-2/font/DroidSansFallback.ttf?raw=true) format('truetype');
}
@font-face {
font-family: 'Droid Sans';
font-style: normal;
font-weight: bold;
font-style: italic;
src: url('/plugins/Task2pdf/font/DroidSansFallback.ttf') format('truetype');
src: url(https://github.com/creecros/Task2pdf/blob/creecros-patch-2/font/DroidSansFallback.ttf?raw=true) format('truetype');
}
* {
font-family: Droid Sans, DejaVu Sans, sans-serif;
}
</style>
</head>
<body>
<section id="main" class="public-task">
<a style="display: inline-block; font-size:12px; text-align: left; width: 100%; word-wrap: break-word;">
<?= $this->render('Task2pdf:printlayout/details', array(
'task' => $task,
'tags' => $tags,
'project' => $project,
'editable' => false,
)) ?>
</a>
<br>
<a style=" display: inline-block; font-size:14px; text-align: left; width: 95%; word-wrap: break-word;">
<?php if (!empty($task['description'])): ?>
<?= $this->render('Task2pdf:printlayout/description', array(
'task' => $task,
'project' => $project,
'is_public' => true,
)) ?>
<?php endif ?>
<?php if(!empty($subtasks)): ?>
<?= $this->render('Task2pdf:printlayout/subtasks', array(
'task' => $task,
'subtasks' => $subtasks,
'editable' => false
)) ?>
<?php endif ?>
<?php if (!empty($files) || !empty($images)): ?>
<?= $this->render('Task2pdf:printlayout/files', array(
'task' => $task,
'files' => $files,
'images' => $images
)) ?>
<?php endif ?>
<?php if (!empty($links)): ?>
<?= $this->render('Task2pdf:printlayout/internal_links', array(
'task' => $task,
'links' => $links,
'project' => $project,
'editable' => false,
'is_public' => true,
)) ?>
<?php endif ?>
<?php if (!empty($comments)): ?>
<?= $this->render('Task2pdf:printlayout/comments', array(
'task' => $task,
'comments' => $comments,
'project' => $project,
'editable' => false,
'is_public' => true,
)) ?>
<?php endif ?>
</a>
</section>
</body>
</html>


Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<section id="main" class="public-task">
<section id="main" class="public-task" style="page-break-after: always;">
<a style=" display: inline-block; font-size:12px; text-align: left; width: 100%; word-wrap: break-word;">
<?= $this->render('Task2pdf:printlayout/details', array(
'task' => $task,
Expand Down Expand Up @@ -50,4 +50,3 @@
<?php endif ?>
</a>
</section>

Binary file added font/DroidSansFallback.ttf
Binary file not shown.

0 comments on commit 0a083ff

Please sign in to comment.