public function templatedTextAction() { $personId = $this->_getParam('personId', 0); $templateId = $this->_getParam('templateId', 0); $templateName = $this->_getParam('templateName'); $templatedText = new TemplatedText(); if ($templateId > 0) { $templatedText->templateId = $templateId; $templatedText->populate(); } else { $templatedText->populateByName($templateName); } $template = $templatedText->template; preg_match_all('/{nsdr:(.*)}/', $template, $matches); if (count($matches[1]) > 0) { foreach ($matches[1] as $val) { $namespace = str_replace('[selectedPatientId]', $personId, $val); if (Zend_Registry::get('memcacheStatus') === 0) { $resultValue = __("Memcache server not started"); } else { $result = NSDR::populate($namespace); $resultValue = $result[$namespace]; if (is_array($resultValue) && isset($resultValue['error'])) { $resultValue = $resultValue['error']; $resultValue = __('No current data for: ') . $val; } } $template = preg_replace('/{nsdr:(.*)}/', $resultValue, $template, 1); } } $this->view->template = $template; $this->render(); }
public function processEditAction() { $templateId = (int) $this->_getParam('templateId'); $field = $this->_getParam('field'); $value = $this->_getParam('value'); $templateText = new TemplatedText(); if ($templateId > 0) { $templateText->templateId = $templateId; $templateText->populate(); } $data = array(); if (in_array($field, $templateText->ORMFields())) { $templateText->{$field} = $value; $templateText->persist(); $data['id'] = $templateText->templateId; $data['value'] = $templateText->{$field}; } else { $data['error'] = __('Invalid column') . ': ' . $field; } $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $json->direct($data); }