Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Class to read data from http://www.mytinytodo.net/ and display it somewhere else (as a part of your own application).
- * Allows to integrate your todo list into some other web-site.
- * You only need to comment line 68 in todo/ajax.php "exit;" for this class to work. THIS IS IMPORTANT!
- *
- * © 2010 spidgorny@gmail.com
- * http://spidgorny.blogspot.com/2010/09/displaying-data-from-mytinytodo.html
- */
- class Todo extends Controller {
- protected $tasks = array(); // the data will be stored here
- // structure: array('total' => 15, 'list' => array(...));
- /**
- * We imitate an AJAX request for the data and grab it with ob_get_clean().
- * Then we decode JSON data and voilà!
- *
- */
- function __construct($tab = 1) {
- $_GET['loadTasks'] = 1;
- $_GET['list'] = $tab; // which tab to display
- $_GET['compl'] = 0;
- $_GET['sort'] = 0;
- $_GET['tz'] = 120;
- $_GET['rnd'] = rand();
- //debug($_GET);
- ob_start();
- require_once('todo/init.php');
- $GLOBALS['lang'] = Lang::instance();
- require_once('todo/ajax.php');
- $json = ob_get_clean();
- $this->tasks = json_decode($json, TRUE);
- //debug($this->tasks);
- }
- /**
- * Modify this function in order to display data from $this->tasks['list'].
- *
- */
- function render() {
- require('template/head.phtml');
- echo '<div class="headerMargin"><br>';
- foreach ($this->tasks['list'] as $i => &$row) {
- unset($row['id']);
- unset($row['dateInline']);
- unset($row['dateCompleted']);
- unset($row['prio']);
- unset($row['note']);
- unset($row['noteText']);
- unset($row['ow']);
- unset($row['tags']);
- unset($row['duedate']);
- unset($row['dueClass']);
- unset($row['dueStr']);
- unset($row['dueInt']);
- if ($row['compl']) {
- //unset($this->tasks['list'][$i]);
- break;
- }
- unset($row['compl']);
- }
- echo new slTable($this->tasks['list'], 'width="90%" style="margin: 0 auto;"');
- echo '</div>';
- require('template/footer.phtml');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement