public function execute()
 {
     $messages = installerMessage::getInstance()->handle(waRequest::get('msg'));
     $counter = array('total' => 0, 'applicable' => 0, 'payware' => 0);
     $items = array();
     try {
         $items = installerHelper::getUpdates();
         $counter = installerHelper::getUpdatesCounter(null);
         if (isset($items['installer'])) {
             $items['installer']['name'] = _w('Webasyst Framework');
         }
     } catch (Exception $ex) {
         $messages[] = array('text' => $ex->getMessage(), 'result' => 'fail');
     }
     installerHelper::checkUpdates($messages);
     if (!waRequest::get('_')) {
         $this->setLayout(new installerBackendLayout());
         if ($messages) {
             $this->getLayout()->assign('messages', $messages);
         }
         $this->getLayout()->assign('update_counter', $counter['total']);
         $this->getLayout()->assign('no_ajax', true);
     } else {
         $this->view->assign('messages', $messages);
     }
     $this->view->assign('error', false);
     $this->view->assign('update_counter', $counter['total']);
     $this->view->assign('update_counter_applicable', $counter['applicable']);
     $this->view->assign('items', $items);
     $this->view->assign('domain', installerHelper::getDomain());
     $this->view->assign('title', _w('Updates'));
 }
 public function onCount()
 {
     $args = func_get_args();
     $force = array_shift($args);
     $model = new waAppSettingsModel();
     $app_id = $this->getApplication();
     $count = null;
     //check cache expiration time
     if ($force || time() - $model->get($app_id, 'update_counter_timestamp', 0) > 600 || is_null($count = $model->get($app_id, 'update_counter', null))) {
         $count = installerHelper::getUpdatesCounter('total');
         //check available versions for installed items
         //download if required changelog & requirements for updated items
         //count applicable updates (optional)
         $model->ping();
     } elseif (is_null($count)) {
         $count = $model->get($app_id, 'update_counter');
     }
     if ($count) {
         $count = array('count' => $count, 'url' => $url = $this->getBackendUrl(true) . $this->application . '/?module=update');
     }
     return $count;
 }