head; if ($head) $nodes = $head->xpath('frx:menu'); $menu = array(); if ($nodes) { $m = $nodes[0]; $attrs = $m->attributes(); foreach ($attrs as $key => $value) { $menu[$key] = (string)$value; } } if ($menu) $cache['menu'] = $menu; $block_xml = $r_xhtml->xpath('//*[@frx:block]'); // Extract all the blocks and organize by provider foreach ($block_xml as $key => $block_node) { $attrs = $block_node->attributes('urn:FrxReports'); foreach ($attrs as $key => $value) { if ($key == 'block') { @list($provider, $block) = explode('/', $value, 2); $repos[$provider][] = $block; } } } if ($repos) foreach ($repos as $provider_key => $blocks) { $provider = Frx::RepoMan()->repository($provider_key); if (isset($provider->conf))$conf = $provider->conf; $access = array(); foreach ($blocks as $block_name) { if ($provider && $block_name) { if (method_exists($provider, 'loadBlock')) { $conf = $provider->conf; $block = $provider->loadBlock($block_name); $obj = @$block['access']; if (array_search($obj, $access)===FALSE) $access[]=$obj; } } } if (isset($conf['access callback']) && $access) $cache['access'][$provider_key][$conf['access callback']]=$access; } } return $cache; } /** * Object factory for forena report * When called without a report name, it returns the last created report. * This static caching mechanism is used for form functions that are called * within a page load. * * @param unknown_type $report_name */ function forena_report_object($report='', $data='') { static $object = ''; if ($report) { $object = new FrxReport($report, $data); } return $object; } /** * Enter description here... * * @param simplexml $xml * @param string $tag * @return string */ function forena_inner_xml($xml, $tag) { if (is_object($xml) && $tag) { $xml_data = $xml->asXML(); $xml_data = preg_replace("/<\/?" . $tag . "(.|\s)*?>/", "", $xml_data); }; return $xml_data; } /** * Accepts the name of the html tag, and the string the tag is in. * * Returns the string within the html tag name * */ function forena_get_html($tag, $r_text) { $open = strpos($r_text, $tag); $close = strpos($r_text, '>', $open); $next = strpos($r_text, '<', $close + 1); $str = substr($r_text, $close + 1, $next - ($close + 1)); return $str; } /** * Form to edit parameters * Extra features: * In the parameters section of the report are new attributes * frx:parm: * @data_source = data block for the parameter to values from * @data_field = specific field of the data block to recieve values from. * if no field is specified then the first column is arbitrarily chosen. * @type = The form element that will display the values: select, radios are supported * default is textfield. * * This function will evaluate each parameter, determine its type, data_source, and data_field * and display those values appropriately. * */ function forena_get_user_reports($category = array()) { if (!$category) $category = array(); $reports = Frx::File()->reportsByCategory((array)$category); return $reports; } /** * Render the my reports category block * */ function forena_my_reports_block() { $reports = forena_get_user_reports(); if (!$reports) return ''; $output = '
Invalid XML
XML:" . htmlspecialchars($report) . "\n" . $e->getMessage() . ""); return; } } if (!_forena_verify_directory($report_name) && $save_file) { drupal_set_message(t('Error creating directory. Check Permissions'), 'error'); return 0; }; $report_path = forena_report_path(); $r = new FrxReport($report); $data['title'] = $r->title; $data['category'] = $r->category; $data['options'] = $r->options; $data['descriptor'] = $r->descriptor; $data['name'] = $report_name; $data['altered'] = $altered; $r_xml = $report->asXML(); $name = $data['name']; $filepath = $report_name . '.frx'; // If we need to save this to the file system if ($save_file) { Frx::File()->save($filepath, $r_xml); } // Get the security caches from the reports if ($report) $cache = forena_load_cache($report); else $cache=''; $rpt_cache=''; if ($cache) $rpt_cache = serialize($cache); // Set default interpretations of data $data['enabled'] = (isset($data['enabled']) && $data['enabled']) ? 1 : 0; if (isset($data['options']['hidden']) && (string)$data['options']['hidden']) { $data['hidden'] = ($data['options']['hidden'] && $data['options']['hidden']!='N' && $data['options']['hidden']!='0') ? 1:0; if (!$data['category']) $data['category'] = 'All'; } else { // Set hidden based on category $data['hidden'] = ($data['category'])? 0 : 1; } $save_count++; $r = NULL; $result = NULL; $r_xml = NULL; $report = NULL; $data = NULL; $rpt = NULL; $cache = NULL; $rpt_cache = NULL; // Destroy object to clear memory leaks. if ($r) { $r->__destruct(); unset($r); } return $save_count; } /** * Render a field without it's containers so that we can use it in a report without the wrappers. */ function theme_forena_inline_field(&$variables) { $element = $variables['field']; // This is also used in the installer, pre-database setup. drupal_render_children($variables['field']); } /** * Render a special form with an embedded forena report. * @param unknown_type $variables */ function theme_forena_inline_form($variables) { $form = $variables['form']; $build = ''; $output = ''; $fields = array(); $template = @$form['#forena_form_template']; // Convert interior elements into inline fields if ($template) { _forena_set_inline_theme($form, $template); // Render the inline fields and store them into the array. $build = _forena_render_inline_elements($form, $fields, $template); $build .= $fields['form_build_id'] . $fields['form_token'] . $fields['form_id']; } else { $build = $form['#children']; } // Return the form return $build; } function _forena_render_form_template($fields, $template) { static $teng = ''; if (!$teng) $teng = new FrxSyntaxEngine(FRX_TOKEN_EXP, '{}'); $o = Frx::Data()->push($fields, 'form-fields'); $build = $teng->replace($template, TRUE); $o = Frx::Data()->pop(); return $build; } function _forena_set_inline_theme(&$elements) { foreach ($elements as $key => $value) if (strpos($key, '#')===FALSE) { $type = @$value['#type']; // Set theme functions for specific types to be inline forms. switch ($type) { case 'fieldset': case NULL: case 'submit': case ''; break; default: $elements[$key]['#theme_wrappers'] = array('forena_inline_form_element'); } } } /** * Renders forena reprot as * @param unknown_type $variables */ function theme_forena_inline_form_element($variables) { $element = &$variables['element']; // This is also used in the installer, pre-database setup. $t = get_t(); // This function is invoked as theme wrapper, but the rendered form element // may not necessarily have been processed by form_builder(). $element += array( '#title_display' => 'before', ); // Add element #id for #type 'item'. if (isset($element['#markup']) && !empty($element['#id'])) { $attributes['id'] = $element['#id']; } // Add element's #type and #name as class to aid with JS/CSS selectors. $attributes['class'] = array('form-item'); if (!empty($element['#type'])) { $attributes['class'][] = 'form-type-' . strtr($element['#type'], '_', '-'); } if (!empty($element['#name'])) { $attributes['class'][] = 'form-item-' . strtr($element['#name'], array(' ' => '-', '_' => '-', '[' => '-', ']' => '')); } // Add a class for disabled elements to facilitate cross-browser styling. if (!empty($element['#attributes']['disabled'])) { $attributes['class'][] = 'form-disabled'; } $output = ''; $output = '' . "\n"; //drupal_set_message('
'. print_r($element,1) . ''); $element['#title_display'] = 'none'; $prefix = isset($element['#field_prefix']) ? '' . $element['#field_prefix'] . ' ' : ''; $suffix = isset($element['#field_suffix']) ? ' ' . $element['#field_suffix'] . '' : ''; switch ($element['#title_display']) { case 'before': case 'invisible': $output .= ' ' . theme('form_element_label', $variables); $output .= ' ' . $prefix . $element['#children'] . $suffix . "\n"; break; case 'after': $output .= ' ' . $prefix . $element['#children'] . $suffix; $output .= ' ' . theme('form_element_label', $variables) . "\n"; break; case 'none': case 'attribute': // Output no label and no required marker, only the children. $output .= ' ' . $prefix . $element['#children'] . $suffix . "\n"; break; } // No descriptions or titles. /* if (!empty($element['#description'])) { $output .= '