Exemple #1
0
 public function renderContent()
 {
     $todos = $this->controller->getTodos();
     $elements = [];
     $elements['Category'] = $this->keys($this->controller->getCategories());
     $elements['Activity'] = $this->keys($this->controller->getActivities());
     $elements['Tag'] = $this->keys($this->controller->getTags());
     $filter = new Filter($elements);
     $content = $filter;
     $filtered = [];
     foreach ($todos as $todo) {
         $inTags = false;
         foreach ($todo->getTags() as $tag) {
             if (in_array($tag->__toString(), $filter->getElements('Tag'))) {
                 $inTags = true;
                 break;
             }
         }
         if ((in_array($todo->getCategory(), $filter->getElements('Category')) || !$filter->getElements('Category')) && (in_array($todo->getActivity(), $filter->getElements('Activity')) || !$filter->getElements('Activity')) && ($inTags || !$filter->getElements('Tag'))) {
             $filtered[] = $todo;
         }
     }
     $content .= new TodoList($filtered, 'todo', true, false);
     return HTML::div($content);
 }
Exemple #2
0
 public function renderContent()
 {
     $timespan = new TimespanSelector();
     $content = $timespan;
     $list = '';
     $records = $this->splitRecords($this->controller->getRecords($timespan->getStart(), $timespan->getEnd()));
     $totalLength = 0;
     foreach ($records as $day => $dayRecords) {
         $totalDayLength = 0;
         foreach ($dayRecords as $dayRecord) {
             $length = $dayRecord->getLength();
             if (is_null($length)) {
                 $length = abs(time() - $dayRecord->getStart()->getTimestamp());
             }
             $totalDayLength += $length;
         }
         $totalLength += $totalDayLength;
         $lengthString = RecordList::formatLength($totalDayLength);
         $list .= HTML::div(['.title'], HTML::div(['.date'], $day) . HTML::div(['.length'], $lengthString));
         $list .= new RecordList($dayRecords, 'record', false, false);
     }
     $content .= HTML::div(['.title', '.total'], HTML::div('total') . HTML::div(['.length'], RecordList::formatLength($totalLength)));
     $content .= $list;
     return HTML::div($content);
 }
Exemple #3
0
 protected function attributeList($type, $attributes)
 {
     $list = '';
     $maxLength = isset($attributes[0]['length']) ? $attributes[0]['length'] : null;
     foreach ($attributes as $attribute) {
         $length = (int) $attribute['length'];
         $hours = $length / 3600;
         $lengthString = round($hours, 1);
         $percentage = round(600 * $length / $maxLength);
         $list .= HTML::div(['.totalRow'], HTML::div(['.bar', 'style' => "width : {$percentage}px"]) . HTML::div(['.row'], HTML::div(['.attribute'], $attribute['name']) . HTML::div(['.length'], $lengthString)));
     }
     return HTML::div(['.attributeList', ".{$type}"], HTML::div(['.title'], ucfirst($type)) . $list);
 }
 public function getProperties($record)
 {
     $length = $record->getLength();
     $start = $record->getStart();
     $end = $record->getEnd();
     $endString = $end ? $end->format('H:i') : '';
     if (is_null($length)) {
         $length = abs(time() - $start->getTimestamp());
     }
     $tags = '';
     foreach ($record->getTags() as $tag) {
         $tags .= HTML::span(['.tag'], $tag);
     }
     return ['time' => $start->format('H:i') . ' - ' . $endString, 'name' => HTML::span(['.activity'], $record->getActivity()) . HTML::span(['.category'], ' - ' . $record->getCategory()), 'tags' => $tags, 'length' => self::formatLength($length)];
 }
Exemple #5
0
 /**
  * @expectedException           Exception
  * @expectedExceptionMessage    unknown selector
  */
 public function testUnknownSelectorException()
 {
     HTML::div(['$name'], 'content');
 }
Exemple #6
0
 public function render()
 {
     return '<!DOCTYPE html>' . HTML::html($this->template->head($this->renderHead()) . HTML::body(HTML::div(['#main'], HTML::div(['#wrapper'], HTML::div(['#header'], $this->template->header($this->renderHeader())) . HTML::div(['#middle'], $this->template->content($this->renderContent())) . HTML::div(['#footer'], $this->template->footer($this->renderFooter()))))));
 }