function handle($params) { import('Dataface/ImportForm.php'); $app =& Dataface_Application::getInstance(); $query =& $app->getQuery(); $form = new Dataface_ImportForm($query['-table']); $record =& $form->_record; if (is_object($record)) { if (!$record->checkPermission('import')) { return Dataface_Error::permissionDenied(); } } else { if (!Dataface_PermissionsTool::checkPermission('import', Dataface_Table::loadTable($query['-table']))) { return Dataface_Error::permissionDenied(); } } $form->_build(); if ($form->validate()) { //echo "validated"; $querystr = $form->exportValue('-query'); $returnPage = $form->exportValue('--redirect'); if (intval($form->_step) === 1) { if (preg_match('/--step=1/', $querystr)) { $querystr = preg_replace('/--step=1/', '--step=2', $querystr); } else { $querystr .= '&--step=2'; } $importTablename = $form->process(array(&$form, 'import')); //echo "Table: $importTablename"; //exit; //$link = 'Location: '.$_SERVER['PHP_SELF'].'?'.$querystr.'&--importTablename='.$importTablename; //echo $link; //exit; header('Location: ' . $_SERVER['PHP_SELF'] . '?' . $querystr . '&--importTablename=' . $importTablename . '&--redirect=' . urlencode($returnPage)); exit; } else { $records = $form->process(array(&$form, 'import')); $returnPage = $form->exportValue('--redirect'); //$keys = $form->exportValue('__keys__'); //$keys['-action'] = 'browse'; //$keys['-step'] = null; //$keys['-query'] = null; //$link = Dataface_LinkTool::buildLink($keys); $link = $returnPage; $response =& Dataface_Application::getResponse(); $msg = urlencode(trim("Records imported successfully.\n" . @$response['--msg'])); if (strpos($link, '?') === false) { $link .= '?'; } header('Location: ' . $link . '&--msg=' . $msg); exit; } } ob_start(); $form->display(); $out = ob_get_contents(); ob_end_clean(); $context['form'] = $out; $context['filters'] = $form->_filterNames; $context['step'] = $form->_step; if (isset($query['-template'])) { $template = $query['-template']; } else { if (isset($params['action']['template'])) { $template = $params['action']['template']; } else { if (isset($query['-relationship'])) { $template = 'Dataface_Import_RelatedRecords.html'; } else { $template = 'Dataface_Import_RelatedRecords.html'; } } } df_display($context, $template, true); }
/** * Handles initialization and control for the import records form. */ function _import_init() { import('Dataface/ImportForm.php'); $form = new Dataface_ImportForm($this->_tablename); $record =& $form->_record; if (!Dataface_PermissionsTool::edit($record)) { $this->_vars['error'] = "<div class=\"error\">Error. Permission Denied.<!-- At line " . __LINE__ . " of file " . __FILE__ . " --></div>"; return; } $form->_build(); $this->_vars['form'] =& $form; if ($form->validate()) { //echo "validated"; $querystr = $form->exportValue('-query'); if (intval($form->_step) === 1) { if (preg_match('/-step=1/', $querystr)) { $querystr = preg_replace('/-step=1/', '-step=2', $querystr); } else { $querystr .= '&-step=2'; } $importTablename = $form->process(array(&$form, 'import')); //echo "Table: $importTablename"; //exit; //$link = 'Location: '.$_SERVER['PHP_SELF'].'?'.$querystr.'&--importTablename='.$importTablename; //echo $link; //exit; header('Location: ' . $_SERVER['PHP_SELF'] . '?' . $querystr . '&--importTablename=' . $importTablename); exit; } else { $records = $form->process(array(&$form, 'import')); $keys = $form->exportValue('__keys__'); $keys['-action'] = 'browse'; $keys['-step'] = null; $keys['-query'] = null; $link = Dataface_LinkTool::buildLink($keys); $response =& Dataface_Application::getResponse(); $msg = urlencode(trim("Records imported successfully.\n" . @$response['--msg'])); header('Location: ' . $link . '&--msg=' . $msg); exit; } } //echo "Not validated"; }