Example #1
0
 function render()
 {
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl->cache_lifetime = "0";
     $tpl->assign('path', dirname(__FILE__) . '/templates/');
     $session = DevblocksPlatform::getSessionService();
     $response = DevblocksPlatform::getHttpResponse();
     $license = PortSensorLicense::getInstance();
     // Be nice!
     $stack = $response->path;
     @array_shift($stack);
     // config
     switch (array_shift($stack)) {
         case 'devices':
             $devices = DAO_Device::getWhere();
             $tpl->assign('devices', $devices);
             @($id = array_shift($stack));
             $tpl->assign('license', $license);
             if (0 < strlen($id)) {
                 if (isset($devices[$id])) {
                     $tpl->assign('device', $devices[$id]);
                 }
                 $tpl->display('file:' . dirname(__FILE__) . '/templates/config/devices/edit.tpl.php');
             } else {
                 $tpl->display('file:' . dirname(__FILE__) . '/templates/config/devices/index.tpl.php');
             }
             break;
         case 'monitors':
             $monitors = DAO_Monitor::getWhere();
             $tpl->assign('monitors', $monitors);
             @($id = array_shift($stack));
             if (0 < strlen($id)) {
                 if (isset($monitors[$id])) {
                     $tpl->assign('monitor', $monitors[$id]);
                 }
                 $gen_secret_key = Application::generatePassword(20);
                 $tpl->assign('gen_secret_key', $gen_secret_key);
                 $tpl->display('file:' . dirname(__FILE__) . '/templates/config/monitors/edit.tpl.php');
             } else {
                 $tpl->display('file:' . dirname(__FILE__) . '/templates/config/monitors/index.tpl.php');
             }
             break;
         case 'plugins':
             $tpl->display('file:' . dirname(__FILE__) . '/templates/config/plugins/index.tpl.php');
             break;
         case 'license':
             $tpl->assign('license', $license);
             $tpl->display('file:' . dirname(__FILE__) . '/templates/config/license/index.tpl.php');
             break;
         case 'feeds':
             $feeds = DAO_Feed::getWhere();
             $tpl->assign('feeds', $feeds);
             $devices = DAO_Device::getWhere();
             $tpl->assign('devices', $devices);
             @($id = array_shift($stack));
             if (0 < strlen($id)) {
                 if (isset($feeds[$id])) {
                     $tpl->assign('feed', $feeds[$id]);
                 }
                 $feed_devices = DAO_FeedItem::getFeedDevices($id);
                 $tpl->assign('feed_devices', $feed_devices);
                 $tpl->display('file:' . dirname(__FILE__) . '/templates/config/feeds/edit.tpl.php');
             } else {
                 $tpl->display('file:' . dirname(__FILE__) . '/templates/config/feeds/index.tpl.php');
             }
             break;
         case 'general':
         default:
             $event_count = DAO_SensorEvent::getCount();
             $tpl->assign('event_count', $event_count);
             $tpl->display('file:' . dirname(__FILE__) . '/templates/config/general/index.tpl.php');
             break;
     }
 }