diff options
author | Hannes Kindströmmer <me@brolaugh.com> | 2016-05-16 16:11:30 +0200 |
---|---|---|
committer | Hannes Kindströmmer <me@brolaugh.com> | 2016-05-16 16:11:30 +0200 |
commit | 3b898ec14bd03ca0db078845f876ad2f96bcb5d9 (patch) | |
tree | 54cb331e28566f758c578410e312c8ff06e0c6c7 | |
parent | 6b15dd4a611b5c58b95605ebe8c8a9dd22ec16d9 (diff) | |
download | tasklist-php-3b898ec14bd03ca0db078845f876ad2f96bcb5d9.zip tasklist-php-3b898ec14bd03ca0db078845f876ad2f96bcb5d9.tar.gz tasklist-php-3b898ec14bd03ca0db078845f876ad2f96bcb5d9.tar.bz2 |
Compiled alot of html code into one class
-rw-r--r-- | App/Task.php | 71 | ||||
-rw-r--r-- | App/ajax/gettask.php | 40 | ||||
-rw-r--r-- | App/ajax/gettask_inner.php | 38 | ||||
-rw-r--r-- | App/ajax/gettasks.php | 38 | ||||
-rw-r--r-- | App/ajax/lasttask.php | 40 | ||||
-rw-r--r-- | App/pages/dashboard.php | 49 |
6 files changed, 86 insertions, 190 deletions
diff --git a/App/Task.php b/App/Task.php new file mode 100644 index 0000000..ab46570 --- /dev/null +++ b/App/Task.php @@ -0,0 +1,71 @@ +<?php +namespace App; + +class Task{ + private $id; + private $title; + private $description; + private $user; + private $stamp; + private $status; + private $status_class; + private $changeable_statuses; + + public function __construct($dbtask){ + $this->id = $dbtask->id; + $this->title = $dbtask->title; + $this->description = $dbtask->description; + $this->user = $dbtask->user; + $this->stamp = $dbtask->stamp; + $this->status_class = $dbtask->style_class; + $this->status = $dbtask->level; + } + public function setChangeableStatuses($changeable_statuses){ + $this->changeable_statuses = $changeable_statuses; + } + + public function printTask(){ + echo "<div class=\"well well-xs status-$this->status\" id=\"task_nr_$this->id\">"; + $this->printInnerTask(); + echo '</div>'; + } + public function printInnerTask(){ + ?> + + <h3> + <span ><?=$this->title?></span> + <div class="btn-group"> + <div class="btn-toolbar"> + <div class="btn-group"> + <a href="bootstrap-elements.html" data-target="#" class="btn btn-raised btn-<?=$this->status_class?> dropdown-toggle" + data-toggle="dropdown"> + <?=$this->status?> + <span class="caret"></span> + </a> + <ul class="dropdown-menu"> + <?php + foreach ($this->changeable_statuses as $tl) { + if ($this->status != $tl->plain_text) { + ?> + <li data-toggle="modal" data-target="#statusmodal" onclick="javascript:modalFix(<?=$this->id . "," . $tl->id . ",'" . $this->title."'"?>)"> + <span class="text-<?=$tl->style_class?>"><?=$tl->plain_text?></span> + </li> + <?php + } + } + ?> + </ul> + </div> + </div> + </div> + </h3> + <p class="text-primary"> + <?=$this->description?> + </p> + <p class="text-muted small"> + Uppdaterad <?=$this->stamp . " av " . $this->user?> + </p> + + <?php + } +} diff --git a/App/ajax/gettask.php b/App/ajax/gettask.php index 2f386c1..ff55e86 100644 --- a/App/ajax/gettask.php +++ b/App/ajax/gettask.php @@ -17,40 +17,6 @@ if(!isset($_POST['task'])){ $s = new Select(); $task = $s->getAllTaskWithStatus($_POST['task']); $tl = $s->getAllStatusLevels(); - ?> - <div class="well well-xs"> - <h3> - <span class="pull-left"><?php echo $task->title; ?></span> - <div class="btn-group"> - <div class="btn-toolbar"> - <div class="btn-group"> - <a href="bootstrap-elements.html" data-target="#" class="btn btn-raised btn-<?php echo $task->style_class;?> dropdown-toggle" - data-toggle="dropdown"> - <?php echo $task->level ;?> - <span class="caret"></span> - </a> - <ul class="dropdown-menu"> - <?php - foreach ($status_level as $tl) { - if ($task->level != $tl->plain_text) { - ?> - <li><a - href="<?php echo ROOT . "/App/formhandler/changestatus.php?task=" . $task->id . "&status=" . $tl->id; ?>"><span - class="text-<?php echo $tl->style_class; ?>"><?php echo $tl->plain_text; ?></span></a></li> - <?php - } - } - - ?> - </ul> - </div> - </div> - </div> - </h3> - <p class="text-primary"> - <?php echo $task->description; ?> - </p> - <p class="text-muted small"> - Uppdaterad <?php echo $task->stamp . " av " . $task->user;?> - </p> - </div> + $taskWriter = new App\Task($task); + $taskWriter->setChangeableStatuses($status_level); + $taskWriter->printTask(); diff --git a/App/ajax/gettask_inner.php b/App/ajax/gettask_inner.php index 5bdb5c4..adf5996 100644 --- a/App/ajax/gettask_inner.php +++ b/App/ajax/gettask_inner.php @@ -17,38 +17,6 @@ if(!isset($_POST['task'])){ $s = new \App\database\Select(); $task = $s->getTaskWithStatus($_POST['task']); $status_level = $s->getAllStatusLevels(); -?> -<h3> - <span ><?php echo $task->title; ?></span> - <div class="btn-group"> - <div class="btn-toolbar"> - <div class="btn-group"> - <a href="bootstrap-elements.html" data-target="#" class="btn btn-raised btn-<?php echo $task->style_class;?> dropdown-toggle" - data-toggle="dropdown"> - <?php echo $task->level ;?> - <span class="caret"></span> - </a> - <ul class="dropdown-menu"> - <?php - foreach ($status_level as $tl) { - if ($task->level != $tl->plain_text) { - ?> - <li data-toggle="modal" data-target="#statusmodal" onclick="javascript:modalFix(<?php echo $task->id . "," . $tl->id . ",'" . $task->title."'";?>)"> - <span class="text<?php echo $tl->style_class; ?>"><?php echo $tl->plain_text; ?></span> - </li> - <?php - } - } - - ?> - </ul> - </div> - </div> - </div> -</h3> -<p class="text-primary"> - <?php echo $task->description; ?> -</p> -<p class="text-muted small"> - Uppdaterad <?php echo $task->stamp . " av " . $task->user;?> -</p> +$taskWriter = new App\Task($task); +$taskWriter->setChangeableStatuses($status_level); +$taskWriter->printInnerTask(); diff --git a/App/ajax/gettasks.php b/App/ajax/gettasks.php index b6b5740..bd3a51e 100644 --- a/App/ajax/gettasks.php +++ b/App/ajax/gettasks.php @@ -31,40 +31,8 @@ else $status_level = $s->getAllStatusLevels(); foreach ($tasks as $task) { - ?> - <div class="well well-xs status-<?php echo $task->level;?>"> - <h3> - <span ><?php echo $task->title; ?></span> - <div class="btn-group"> - <div class="btn-toolbar"> - <div class="btn-group"> - <a href="bootstrap-elements.html" data-target="#" class="btn btn-raised btn-<?php echo $task->style_class;?> dropdown-toggle" - data-toggle="dropdown"> - <?php echo $task->level ;?> - <span class="caret"></span> - </a> - <ul class="dropdown-menu"> - <?php - foreach ($status_level as $tl) { - if ($task->level != $tl->plain_text) { - ?> - <li data-toggle="modal" data-target="#statusmodal" onclick="javascript:modalFix(<?php echo $task->id . "," . $tl->id . ",'" . $task->title."'";?>)"> - <span class="text-<?php echo $tl->style_class; ?>"><?php echo $tl->plain_text; ?></span> - </li> - <?php - } - } - - ?> - </ul> - </div> - </div> - </div> - </h3> - <p class="text-primary"> - <?php echo $task->description; ?> - </p> - </div> - <?php + $taskWriter = new App\Task($task); + $taskWriter->setChangeableStatuses($status_level); + $taskWriter->printTask(); } ?> diff --git a/App/ajax/lasttask.php b/App/ajax/lasttask.php index a844af5..dc0d4a5 100644 --- a/App/ajax/lasttask.php +++ b/App/ajax/lasttask.php @@ -13,40 +13,6 @@ include_once 'Helper.php'; $s = new \App\database\Select(); $task = $s->getLastTask(); $status_level = $s->getAllStatusLevels(); -?> -<div class="well well-xs status-<?php echo $task->level;?>"> - <h3> - <span ><?php echo $task->title; ?></span> - <div class="btn-group"> - <div class="btn-toolbar"> - <div class="btn-group"> - <a href="bootstrap-elements.html" data-target="#" class="btn btn-raised btn-<?php echo $task->style_class;?> dropdown-toggle" - data-toggle="dropdown"> - <?php echo $task->level ;?> - <span class="caret"></span> - </a> - <ul class="dropdown-menu"> - <?php - foreach ($status_level as $tl) { - if ($task->level != $tl->plain_text) { - ?> - <li data-toggle="modal" data-target="#statusmodal" onclick="javascript:modalFix(<?php echo $task->id . "," . $tl->id . ",'" . $task->title."'";?>)"> - <span class="text-<?php echo $tl->style_class; ?>"><?php echo $tl->plain_text; ?></span> - </li> - <?php - } - } - - ?> - </ul> - </div> - </div> - </div> - </h3> - <p class="text-primary"> - <?php echo $task->description; ?> - </p> - <p class="text-muted small"> - Uppdaterad <?php echo $task->stamp . " av " . $task->user;?> - </p> -</div> +$taskWriter = new App\Task($task); +$taskWriter->setChangeableStatuses($status_level); +$taskWriter->printTask(); diff --git a/App/pages/dashboard.php b/App/pages/dashboard.php index 26fa860..a5b3082 100644 --- a/App/pages/dashboard.php +++ b/App/pages/dashboard.php @@ -1,11 +1,3 @@ -<?php -/** -* Created by PhpStorm. -* User: brolaugh -* Date: 2/25/16 -* Time: 9:54 PM -*/ -?> <div class="row"> <div class="col-md-3"> <div class="well"> @@ -91,45 +83,10 @@ $t = $s->getAllTasksWithStatus(); $status_level = $s->getAllStatusLevels(); foreach ($t as $task) { - ?> - <div class="well well-xs status-<?php echo $task->level;?>" id="task_nr_<?php echo $task->id;?>"> - <h3> - <span ><?php echo $task->title; ?></span> - <div class="btn-group"> - <div class="btn-toolbar"> - <div class="btn-group"> - <a href="bootstrap-elements.html" data-target="#" class="btn btn-raised btn-<?php echo $task->style_class;?> dropdown-toggle" - data-toggle="dropdown"> - <?php echo $task->level ;?> - <span class="caret"></span> - </a> - <ul class="dropdown-menu"> - <?php - foreach ($status_level as $tl) { - if ($task->level != $tl->plain_text) { - ?> - <li data-toggle="modal" data-target="#statusmodal" onclick="javascript:modalFix(<?php echo $task->id . "," . $tl->id . ",'" . $task->title."'";?>)"> - <span class="text-<?php echo $tl->style_class; ?>"><?php echo $tl->plain_text; ?></span> - </li> - <?php - } - } - ?> - </ul> - </div> - </div> - </div> - </h3> - <p class="text-primary"> - <?php echo $task->description; ?> - </p> - <p class="text-muted small"> - Uppdaterad <?php echo $task->stamp . " av " . $task->user;?> - </p> - - </div> - <?php + $taskWriter = new \App\Task($task); + $taskWriter->setChangeableStatuses($status_level); + $taskWriter->printTask(); } ?> <!-- Modal --> |