/**
  * Convert any interval tags (=today, =tomorrow, etc...) to real dates.
  *
  * @param string $raw A user-entered task to be checked for date intervals
  * @return string The expanded text
  */
 function expand_interval_tags($raw)
 {
     static $filter = null;
     if (is_null($filter)) {
         $filter = new model\IntervalFilter($this->_content);
     }
     // find any tags
     preg_match_all($this->term['interval_tok'], $raw, $matches, PREG_SET_ORDER);
     // do they match a time period?
     foreach ($matches as $match) {
         $orig_tag = $match[0];
         $date = $filter->interval_as_date($orig_tag);
         if ($date !== false) {
             $raw = preg_replace('/' . $orig_tag . '/', $this->term['tag_prefix'] . strftime(\tpp\config('date_format'), $date[1]), $raw);
         }
     }
     return $raw;
 }
 /**
  * Show a specific tab state. Always returns a new state.
  *
  * Used by url, change tab, and new tab requests.
  *
  * @param Request $request
  */
 protected function action_show()
 {
     $tab = $this->request->tab;
     $text = $this->request->value;
     $what_changed = $this->_change_tab($tab, $text);
     switch ($what_changed) {
         case self::TAB_SAME:
             $state = $this->request->to_state(true);
             log && msg('refresh tab: leave state as:', $state);
             break;
         case self::TAB_CHANGED:
             $state = $this->_states->item($tab);
             log && msg('change tab: setting state to:', $state);
             break;
         case self::TAB_NEW:
             $state = $this->request->to_state();
             // which default edit state?
             $state->event = tpp\config('edit_new_tab') ? 'edit' : 'all';
             if ($state->event == 'all') {
                 // edit event set the draft text as a value
                 $state->value = '';
             }
             log && msg('new tab: setting state to:', $state);
             break;
         default:
             $state = false;
     }
     return $state;
 }
 function footer()
 {
     $view = new Template('footer');
     $view->langs = tpp\config('lang_list');
     $view->cur_lang = tpp\ini('language');
     $view->logged_in_as = $this->_user->logged_in_as();
     return $view;
 }