/** * Return the generated form output. * @param array $args The form settings. * @param array $node * @return string Form HTML. */ public static function get_form($args, $node) { iform_load_helpers(array('mobile_entry_helper')); data_entry_helper::$website_id = $args['website_id']; self::$node = $node; self::$called_class = 'iform_' . $node->iform; // Convert parameter, $args['defaults'], into structured array. self::parse_defaults($args); // Check permissions to access form. $func = get_user_func(self::$called_class, 'enforcePermissions'); if ($func) { if (call_user_func($func) && !user_access('IForm n' . $node->nid . ' admin') && !user_access('IForm n' . $node->nid . ' user')) { return lang::get('LANG_no_permissions'); } } // Else add authorisation tokens to update and read from the Warehouse. We allow // child classes to generate this first if subclassed. if (self::$auth) { $auth = self::$auth; } else { $auth = data_entry_helper::get_read_write_auth($args['website_id'], $args['password']); self::$auth = $auth; } // Load custom attribute definitions from warehouse. self::loadSmpAttrs($auth['read'], $args['survey_id']); self::loadOccAttrs($auth['read'], $args['survey_id']); // Build a structured array describing the form. // Attribute definitions on the warehouse may specify some tabs. $attrForm = get_attribute_tabs(self::$smpAttrs); // They are combined with those in the Form Structure. $form = self::structureForm($args['structure'], $attrForm); // A second pass organises the content within the tabs $structure = self::structureFormContent($form); // Render the form $renderedForm = self::renderForm($structure, $args, $auth); $options = array(); //build options for form template $options['content'] = $renderedForm; //use mobile authentication if ($args['mobileauth'] == 1) { if (!empty($args['mobileauthpath'])) { $options['action'] = $args['mobileauthpath']; } else { $options['action'] = 'mobile/submit'; } } else { //no mobile authentication $options['action'] = ""; //use default action } $options['id'] = 'entry_form'; $options['method'] = 'post'; //output form return mobile_entry_helper::apply_template('form', $options); }