public function executeJson(AgaviRequestDataHolder $rd) { $data = $this->getAttribute('values', array()); $doc = new AppKitExtJsonDocument(); $doc->hasField('key'); $doc->hasField('value'); $doc->setData($data); $doc->setSuccess(true); return $doc->getJson(); }
public function executeJson(AgaviRequestDataHolder $rd) { if ($this->hasAttribute('categories')) { $categories = $this->getAttribute('categories', array()); $json = new AppKitExtJsonDocument(); $json->setAttribute(AppKitExtJsonDocument::ATTR_AUTODISCOVER); $json->setMeta(AppKitExtJsonDocument::PROPERTY_ID, 'catid'); $json->setData($categories); $json->setSuccess(true); return $json->getJson(); } }
public function executeJson(AgaviRequestDataHolder $rd) { if ($rd->getParameter('extjs')) { $json = new AppKitExtJsonDocument(); $json->hasField('definition'); $json->hasField('type'); $json->hasField('isSimple'); $json->hasField('iconCls'); $json->hasField('label'); $json->setData($this->commands); $json->setSuccess(true); return $json->getJson(); } else { return json_encode(array('success' => true, 'results' => $this->commands)); } }
public function executeJson(AgaviRequestDataHolder $rd) { if ($this->hasAttribute('errors')) { $this->getContainer()->getResponse()->setHttpStatusCode(500); return json_encode(array('errorMessage' => $this->getAttribute('errors'))); } if ($rd->getParameter('xaction') == 'write') { $return = array('success' => true, 'errors' => new stdClass()); return json_encode($return); } if ($this->hasAttribute('cronks')) { $json = new AppKitExtJsonDocument(); $json->setAttribute(AppKitExtJsonDocument::ATTR_AUTODISCOVER); $json->setData($this->getAttribute('cronks')); $json->setSuccess(true); return $json->getJson(); } }
public function executeJson(AgaviRequestDataHolder $rd) { $factory = $this->getContext()->getModel('JasperSoapFactory', 'Reporting', array('jasperconfig' => $rd->getParameter('jasperconfig'))); $client = $factory->getSoapClientForWSDL(Reporting_JasperSoapFactoryModel::SERVICE_SCHEDULER); $scheduler = $this->getContext()->getModel('JasperScheduler', 'Reporting', array('client' => $client, 'jasperconfig' => $rd->getParameter('jasperconfig'), 'uri' => $rd->getParameter('uri'))); $data = $scheduler->getScheduledJobs(); $response = new AppKitExtJsonDocument(); $response->hasField('id'); $response->hasField('version'); $response->hasField('reportUnitURI'); $response->hasField('username'); $response->hasField('label'); $response->hasField('state'); $response->hasField('previousFireTime'); $response->hasField('nextFireTime'); $response->setData($data); $response->setSuccess(); return $response->getJson(); }
public function executeJson(AgaviRequestDataHolder $rd) { $data = array(); $jsonResult = new AppKitExtJsonDocument(); $storage = $this->getContext()->getUser()->getNsmUser()->getStorage(); try { $file = $this->getTemplateFile($rd); $template = unserialize($storage->read("icinga.cronks.template." . $file)); if (!$template) { $template = new CronkGridTemplateXmlParser($file->getRealPath(), $this->getContext()); $template->parseTemplate(); $storage->write("icinga.cronks.template" . $file, serialize($template)); } $connection = $rd->getParameter("connection", "icinga"); $worker = CronkGridTemplateWorkerFactory::createWorker($template, $this->getContext(), $connection); if (is_numeric($rd->getParameter('page_start')) && is_numeric($rd->getParameter('page_limit'))) { $worker->setResultLimit($rd->getParameter('page_start'), $rd->getParameter('page_limit')); } else { $user = $this->context->getUser(); $worker->setResultLimit(0, $user->getPrefVal('org.icinga.grid.pagerMaxItems', AgaviConfig::get('modules.cronks.grid.pagerMaxItems', 25))); } if ($rd->getParameter('sort_field', null) !== null) { $worker->setOrderColumn($rd->getParameter('sort_field'), $rd->getParameter('sort_dir', 'ASC')); if ($rd->getParameter('additional_sort_field', null) !== null) { $worker->addOrderColumn($rd->getParameter('additional_sort_field'), $rd->getParameter('sort_dir', 'ASC')); } } // apply json and legacy filters /** @var $pm Cronks_System_ViewProcFilterParamsModel */ $pm = $this->getContext()->getModel('System.ViewProcFilterParams', 'Cronks'); if (is_array($rd->getParameter('f'))) { $pm->setParams($rd->getParameter('f')); } if ($rd->getParameter('filter_json', false)) { $pm->setParamsFromJson(json_decode($rd->getParameter('filter_json'), true)); } $pm->applyToWorker($worker); $worker->buildAll(); $data = $worker->fetchDataArray(); $worker->countResults(); $jsonResult->hasFieldBulk(array_fill_keys($template->getFieldKeys(), "")); $jsonResult->setSuccess(true); $jsonResult->setDefault(AppKitExtJsonDocument::PROPERTY_TOTAL, $worker->countResults()); $jsonResult->setData($data); } catch (AppKitFileUtilException $e) { $jsonResult->resetDoc(); $jsonResult->hasFieldBulk($template->getFieldKeys()); $jsonResult->setSuccess(true); $jsonResult->setDefault(AppKitExtJsonDocument::PROPERTY_TOTAL, 0); } return (string) $jsonResult; }
public function getJson() { $json = new AppKitExtJsonDocument(); if (!$this->programStatus->isApplicable() || $this->programStatus->config_dump_in_progress === '1') { $json->addMiscData('fromCache', true); $data = $this->retrieveData(); } else { $json->addMiscData('fromCache', false); $data = $this->getCombined(); $this->writeData($data); } $json->hasFieldBulk($data); $json->setData(array($data)); $json->setSuccess(true); return $json; }
public function getJson() { $json = new AppKitExtJsonDocument(); if (!$this->programStatus->isApplicable() || $this->programStatus->config_dump_in_progress === '1') { $data = $this->retrieveData(); $json->addMiscData('fromCache', true); } else { $data = array($this->getData(), $this->getDataForInstance()); $this->writeData($data); $json->addMiscData('fromCache', false); } foreach (array_keys($data[0][0]) as $f) { $json->hasField($f); } $json->setSuccess(true); $json->setData($data[0]); $json->setSortinfo('type'); $json->addMiscData('rowsInstanceStatus', $data[1]); return $json; }