Example #1
0
try {
    // Database connection first.
    $db = new CompactDB($mt_dbhost, $mt_dbname, $mt_dbuser, $mt_dbpass);
    $q = new Query($db);
    $chunks = $q->select('id,content')->from('track')->where("processed=0")->run();
    // Required objects and set up
    $c = new Canvas(thisURL());
    $c->common->addScriptRef(APP_URL . 'files/jquery.js');
    $c->common->addScriptRef(APP_URL . 'files/jquery-effects.js');
    switch ($c->getMode()) {
        /* --------------------------------------------------------------------------------------------------------- */
        case 'show':
        default:
            // We create the toolbar
            $t = new Toolbar();
            $c->register($t);
            // If there are chunks to process, we display a button.
            if (count($chunks) > 0) {
                $t->addAction('Process ' . count($chunks) . ' tracks', "doConfirm('This action may take a long time and make the browser\\nto timeout. Are you sure you want to do this?','process')", 'go-jump');
            }
            // We retrieve all the tracks we have stored in a pretty table.
            $mtrx = $db->qSelect("select t.id, t.name, t.pid, from_unixtime(t.offset/1000) as t_start, round(max(e.t)/1000,1) as t_duration " . "from track as t, event as e where t.id=e.track_id and t.processed=1 group by e.track_id;");
            $tab = new Table($mtrx);
            $tab->setProperty('highlight', true);
            $tab->setProperty('numbering', true);
            $tab->setProperty('id', 'id');
            $tab->setColumnProperty('id', 'visible', false);
            $tab->setColumnProperty('name', 'label', 'Project');
            $tab->setColumnProperty('pid', 'label', 'Ppt. ID');
            $tab->setColumnProperty('t_start', 'label', 'Tracking start');
            $tab->setColumnProperty('t_duration', 'label', 'Duration [s]');