function format_footer_links($links_rs) { $field = NULL; if (is_array($links_rs) && isset($links_rs['url'])) { $footer_links_rs[] = $links_rs; } else { $footer_links_rs =& $links_rs; } if (is_array($footer_links_rs)) { $field = "<ul class=\"footer-links\">"; $totalCount = count($footer_links_rs); for ($i = 0; $i < $totalCount; $i++) { $footer_links_r = $footer_links_rs[$i]; $field .= "<li class=\""; if ($i == 0) { $field .= "first "; } if ($i + 1 == $totalCount) { $field .= "last"; } $field .= "\"><a"; if (strlen($footer_links_r['url']) > 0) { $field .= " href=\"" . $footer_links_r['url'] . "\""; } if (strlen($footer_links_r['onclick']) > 0) { $field .= " onclick=\"" . $footer_links_r['onclick'] . "\" "; } if (starts_with($footer_links_r['target'], 'popup')) { $spec = prc_function_spec($footer_links_r['target']); if (!is_array($spec['args'])) { $spec['args'][0] = '800'; $spec['args'][1] = '600'; } $field .= " onclick=\"popup('" . $footer_links_r['url'] . "','" . $spec['args'][0] . "','" . $spec['args'][1] . "'); return false;\">"; } else { $field .= (strlen($footer_links_r['target']) > 0 ? "target=\"" . $footer_links_r['target'] . "\"" : "") . ">"; } if (strlen($footer_links_r['img']) > 0) { $field .= '<img src="' . $footer_links_r['img'] . '" title="' . $footer_links_r['text'] . '">'; } // don't allow wrapping of link $field .= $footer_links_r['text'] . "</a>"; $field .= "</li>"; } $field .= "</ul>"; } return $field; }
function filter_input_field($input_type, $value) { $input_type_def = prc_function_spec($input_type); return filter_item_input_field(array('input_type' => $input_type_def['type'], 'input_type_arg1' => $input_type_def['args'][0], 'input_type_arg2' => $input_type_def['args'][1], 'input_type_arg3' => $input_type_def['args'][2], 'input_type_arg4' => $input_type_def['args'][3], 'input_type_arg5' => $input_type_def['args'][4]), $value); }
/** modify display_mask so that all {variable} are replaced with references to the array indexes returned. */ function _parse_field_mask(&$display_mask) { $i = 0; $array_of_vars = NULL; $inside_variable = 0; $variable = ''; $new_display_mask = ''; for ($i = 0; $i < strlen($display_mask); $i++) { if ($inside_variable > 0) { // if closing bracket if ($display_mask[$i] == '}') { // indicate close of reference. $inside_variable--; // only if we have encountered final closing bracket! if ($inside_variable == 0) { if (strlen($variable) > 0) { // constrain to legal function names here. $function_r = prc_function_spec($variable, true); // so we get a clean func definition for each $variable. unset($func); // only legal function names. if (is_array($function_r)) { // will actually define the particular arguments here. switch ($function_r['type']) { case 'if': // if(varname[<|<=|>=|>|==|!=]value, "title_mask") $func['type'] = $function_r['type']; //'if' // parse the condition. $this->_parse_if_condition($function_r['args'][0], $func); $func['if_mask_elements'] = $this->_parse_field_mask($function_r['args'][1]); // remember parse_field_mask resets the argument to {1}, {2}, etc. $func['if_mask'] = $function_r['args'][1]; if (count($function_r['args']) > 2) { $func['else_mask_elements'] = $this->_parse_field_mask($function_r['args'][2]); // remember parse_field_mask resets the argument to {1}, {2}, etc. $func['else_mask'] = $function_r['args'][2]; } $array_of_vars[] = $func; break; case 'switch': // switch(value, case, result[, case, result[,...][, default]) $func['type'] = $function_r['type']; //'if' $func['varname'] = $function_r['args'][0]; $j = 1; while ($j + 1 < count($function_r['args'])) { $case = $function_r['args'][$j++]; $result['mask_elements'] = $this->_parse_field_mask($function_r['args'][$j]); $result['mask'] = $function_r['args'][$j]; $func['cases'][] = array('case' => $case, 'result' => $result); $j++; } // a default element if ($j < count($function_r['args'])) { $result['mask_elements'] = $this->_parse_field_mask($function_r['args'][$j]); $result['mask'] = $function_r['args'][$j]; $func['default_case'] = $result; } $array_of_vars[] = $func; break; case 'ifdef': $func['type'] = $function_r['type']; //'ifdef' $func['varname'] = $function_r['args'][0]; // now do the mask $func['if_mask_elements'] = $this->_parse_field_mask($function_r['args'][1]); // remember parse_field_mask resets the argument to {1}, {2}, etc. $func['if_mask'] = $function_r['args'][1]; if (count($function_r['args']) > 2) { $func['else_mask_elements'] = $this->_parse_field_mask($function_r['args'][2]); // remember parse_field_mask resets the argument to {1}, {2}, etc. $func['else_mask'] = $function_r['args'][2]; } $array_of_vars[] = $func; break; case 'theme_img': // only supports one level deep for the prompt_expression (second argument). $func['value'] = NULL; $func['type'] = $function_r['type']; $func['img'] = $function_r['args'][0]; $func['title_mask_elements'] = $this->_parse_field_mask($function_r['args'][1]); // if not an array, then expand if (!is_array($func['title_mask_elements'])) { $func['title_mask_elements'][] = $function_r['args'][1]; $func['title_mask'] = '{0}'; } else { // this will cause the widget to be rendered, but no help entry // will be added to the listings page, because the $this->_opendb_title_mask_macro_rs // has not been updated. $func['title_mask'] = $function_r['args'][1]; } $array_of_vars[] = $func; break; case 'config_var_key': // config_var_keyid(name, value) $func['type'] = $function_r['type']; $func['name'] = $function_r['args'][0]; $tmp_parsed_arg = $this->_parse_field_mask($function_r['args'][1]); if (is_array($tmp_parsed_arg)) { $func['value'] = array('mask' => $function_r['args'][1], 'elements' => $tmp_parsed_arg); } else { $func['value'] = $function_r['args'][1]; } $array_of_vars[] = $func; break; case 'config_var_value': // config_var_value(name, keyid) $func['type'] = $function_r['type']; $func['name'] = $function_r['args'][0]; $tmp_parsed_arg = $this->_parse_field_mask($function_r['args'][1]); if (is_array($tmp_parsed_arg)) { $func['key'] = array('mask' => $function_r['args'][1], 'elements' => $tmp_parsed_arg); } else { $func['key'] = $function_r['args'][1]; } $array_of_vars[] = $func; break; default: // for unknown functions - copy the type, and expand any embedded // mask definitions. $func['type'] = $function_r['type']; for ($j = 0; $j < count($function_r['args']); $j++) { $tmp_parsed_arg = $this->_parse_field_mask($function_r['args'][$j]); if (is_array($tmp_parsed_arg)) { $func['args'][] = array('mask' => $function_r['args'][$j], 'elements' => $tmp_parsed_arg); } else { $func['args'][] = $function_r['args'][$j]; } } $array_of_vars[] = $func; break; } } else { if ($variable == 'title' || $variable == 's_item_type' || $variable == 's_status_type' || $variable == 'item_id' || $variable == 'instance_no') { $array_of_vars[] = $variable; } else { $index_of_sep = strrpos($variable, '.'); if ($index_of_sep !== false) { $s_attribute_type = strtoupper(substr($variable, 0, $index_of_sep)); $option = substr($variable, $index_of_sep + 1); if ($option == 'display_type') { $attribute_r = fetch_attribute_type_r($s_attribute_type); $array_of_vars[] = array('s_attribute_type' => $s_attribute_type, 'option' => $option, 'display_type' => $attribute_r['display_type'], 'display_type_arg1' => $attribute_r['display_type_arg1'], 'display_type_arg2' => $attribute_r['display_type_arg2'], 'display_type_arg3' => $attribute_r['display_type_arg3'], 'display_type_arg4' => $attribute_r['display_type_arg4'], 'display_type_arg5' => $attribute_r['display_type_arg5'], 'prompt' => $attribute_r['prompt']); } else { $array_of_vars[] = array('s_attribute_type' => $s_attribute_type, 'option' => $option); } } else { $array_of_vars[] = array('s_attribute_type' => strtoupper($variable), 'option' => 'value'); } } } // add a {array_reference} to display_mask. $new_display_mask .= '{' . (count($array_of_vars) - 1) . '}'; } $variable = ''; } else { $variable .= '}'; } } else { if ($display_mask[$i] == '{') { $inside_variable++; $variable .= '{'; } else { $variable .= $display_mask[$i]; } } } else { if ($display_mask[$i] != '{') { $new_display_mask .= $display_mask[$i]; } else { $inside_variable++; } } } // return parsed mask (via pass-by-reference) back to caller. $display_mask = $new_display_mask; // return array of parsed sections as well. return $array_of_vars; }
/** * stub */ function get_display_field($s_attribute_type, $prompt, $display_type, $value, $dowrap = TRUE, $prompt_mask = NULL) { $display_type_def = prc_function_spec($display_type); return get_item_display_field(NULL, array('s_attribute_type' => $s_attribute_type, 'prompt' => $prompt, 'display_type' => $display_type_def['type'], 'display_type_arg1' => $display_type_def['args'][0], 'display_type_arg2' => $display_type_def['args'][1], 'display_type_arg3' => $display_type_def['args'][2], 'display_type_arg4' => $display_type_def['args'][3], 'display_type_arg5' => $display_type_def['args'][4]), $value, $dowrap, $prompt_mask); }