예제 #1
0
 public function getTasks($list)
 {
     $tasks = array();
     $sql = "SELECT `tasks`.`id`, `tasks`.`text`, `tasks`.`raw_string`, `tasks`.`desc`, `tasks`.`date`, `tasks`.`done`,`tasks`.`date_created`,`tasks`.`date_updated`, `tasks`.`priority`,`tasks`.`hidden`,`tasks`.`replyto`\n\t\t\t\tFROM `lists_tasks` \n\t\t\t\tINNER JOIN `tasks`\n\t\t\t\tON `tasks`.`id` = `lists_tasks`.`task`\n\t\t\t\tWHERE `lists_tasks`.`list` = " . $list . " AND `tasks`.`hidden` != 1\n\t\t\t\tORDER BY `tasks`.`id` DESC;";
     $result = Site::$db->query($sql);
     while ($task = $result->fetch_object()) {
         $item = TaskerHelper::getTaskArray($task);
         $tasks[] = $item;
     }
     return $tasks;
 }
예제 #2
0
 public function interpret($string)
 {
     $string_array = preg_split('/(\\n|\\r)/', $string);
     $keywords = array();
     $items = 0;
     foreach ($string_array as $line) {
         $data = array();
         $match = $this->tryMatch($line);
         FB::info($match, 'MATCH FOR LINE');
         if (!array_key_exists('break', $match)) {
             if (!array_key_exists('task', $match)) {
                 $keywords[] = $match;
             } else {
                 $blurb = array_merge($keywords, $match);
                 $data['nada'] = false;
                 $data['raw'] = false;
                 $data['text'] = false;
                 $data['desc'] = null;
                 $data['date'] = null;
                 $data['keys'] = false;
                 $data['raw'] = $match['task'];
                 $data['text'] = $match['title'];
                 if (array_key_exists('time', $match)) {
                     $data['date'] = Time::strToTime($match['time']);
                 }
                 $data['keys'] = $blurb;
                 #FB::info($data,'TASK DATA');
                 TaskerHelper::addItem($data);
                 $items++;
             }
         } else {
             $pop = array_pop($keywords);
         }
         FB::log($data, 'DATA');
     }
     FB::log($keywords, 'Keywords');
     FB::log($matches, 'Interpret Tasks');
 }
예제 #3
0
 public function offsetGet($offset, $subset)
 {
     $helper = new TaskerHelper();
     switch ($offset) {
         case 'add':
             Site::$response = $helper->addItem();
             break;
         case 'delete':
             if (isset($_POST['id'])) {
                 Site::$response = $helper->hideItem($_POST['id']);
             }
             break;
         case 'undo':
             if (isset($_POST['id'])) {
                 Site::$response = $helper->setItemUndone($_POST['id']);
             }
             break;
         case 'do':
             if (isset($_POST['id'])) {
                 Site::$response = $helper->setItemDone($_POST['id']);
             }
             break;
         case 'tasks':
             $list = new Lists();
             $list->offsetGet($subset);
             Site::$response = $this->writeLists();
             break;
         case 'interpret':
             Site::$response = $this->interpret($_POST['raw']);
             break;
         case 'keys':
             $keys = new Keywords();
             Site::$response = $keys->outputAsideGUI();
             break;
         case 'dates':
             Site::$response = Time::getDates($_POST['dates']);
             break;
         case 'date':
             Site::$response = Time::getDateFromString(Site::$subsection);
             break;
         case 'view':
             $helper->getItem(Site::$subsection);
             break;
         case 'update':
             $helper->getItem(Site::$subsection);
             break;
         case 'import':
             self::getImportInterface();
             break;
         case 'setup':
             self::setupDB();
             break;
         default:
             #FB::error($offset, 'OFFSET NOT KNOWN');
             self::$keywords = new Keywords();
             $list = new Lists();
             $list->offsetGet($offset);
             self::getInterface();
             break;
     }
     return true;
 }