/** *Get the time the cached form is considered stale * @returns int the number of seconds for this form to be considered stale. if 0 it is considered to be always stale */ public function getStaleTime() { $timeConfig = I2CE::getConfig()->modules->CachedForms->times; $stale_time = 10; $timeConfig->setIfIsSet($stale_time, "stale_time"); if (is_integer($stale_time) || is_string($stale_time) && ctype_digit($stale_time)) { if ($stale_time <= 0) { return 0; } } else { $stale_time = 10; } //lookup storage mechanism stale time and override if necc. $t_stale_time = null; if ($timeConfig->setIfIsSet($t_stale_time, "stale_time_by_mechanism/" . I2CE_FormStorage::getStorage($this->form))) { if (is_integer($t_stale_time) || is_string($t_stale_time) && ctype_digit($t_stale_time)) { if ($t_stale_time > 0) { $stale_time = $t_stale_time; } else { return 0; } } } //lookup form stale time and override if necc. $t_stale_time = null; if ($timeConfig->setIfIsSet($t_stale_time, "stale_time_by_form/{$this->form}")) { if (is_integer($t_stale_time) || is_string($t_stale_time) && ctype_digit($t_stale_time)) { if ($t_stale_time > 0) { $stale_time = $t_stale_time; } else { return 0; } } } $stale_time = $stale_time * 60; //convert from minutes return $stale_time; }
/** * Gets any code lists that are already mapped in the system * @param string $form * @returns boolean */ protected function getMappedCodeLists($form, $field) { if (array_key_exists($form, $this->mapping_data) && array_key_exists($field, $this->mapping_data[$form])) { return $this->mapping_data[$form][$field]; } if (!array_key_exists($form, $this->mapping_data)) { $this->mapping_data[$form] = array(); } $options = $this->getStorageOptions($form); if (!$options instanceof I2CE_MagicDataNode) { I2CE::raiseError("Invalid SDMX_CrossSectional storage options for {$form}"); //shouldn't happen at this point return false; } $mapData = false; //do something to populate the mapping data if ($field == 'parent') { $mapPath = "parent/map_data"; } else { $mapPath = "fields/{$field}/map_data"; } if ($options->is_scalar($mapPath . '/list') && $options->is_scalar($mapPath . '/codelist')) { $list = $option->{$mapPath}->list; $codelist = $option->{$mapPath}->codelist; if ($list && $codelist) { $mapData = array(); //we have a list and a codelist set so we should attempt to get the mapping data at this point if (I2CE_FormFactory::instance()->exists($list)) { $linkForm = 'list_linkto_list_' . I2CE_FormStorage::getStorage($options->{$mapPath}->list); $options->setIfIsSet($linkForm, $mapPath . '/mapping_form'); $where = array('operator' => 'AND', 'operands' => array(0 => array('operator' => 'FIELD_LIMIT', 'field' => 'list', 'style' => 'like', 'data' => array('value' => $list . '|%')), 1 => array('operator' => 'FIELD_LIMIT', 'field' => 'like', 'style' => 'starts_with', 'data' => array('value' => $codelist . '|%')))); $data = I2CE_FormStorage::listFields($linkForm, array('list', 'links_to'), false, $where); } $codelist_len = strlen($codelist) + 1; foreach ($data as $id => $vals) { if (!is_array($vals) || !array_key_exists('list', $vals) || !array_key_exists('links_to', $vals) || strlen($vals['links_to'] <= $codelist_len)) { continue; } //chop of the $codelist| from the links to value and store it. $data[substr($vals['codelist'], $codelist_len)] = $vals['list']; } } } $this->mapping_data[$form][$field] = $mapData; return $this->mapping_data[$form][$field]; }