Skip to content
Snippets Groups Projects
Commit 1969c51e authored by Kevin Kaland's avatar Kevin Kaland
Browse files

Issue #2359213: Remove some ported D7 code.

parent 0443439e
No related branches found
No related tags found
No related merge requests found
......@@ -29,149 +29,6 @@ function fillpdf_help($path, $arg) {
}
}
/**
* Implements hook_menu().
*
* @todo: Remove once converted.
*/
function fillpdf_menu() {
$access = array('administer pdfs');
$items = array();
// fillpdf?fid=10&nids[]=1&webforms[0][nid]=2&webforms[0][sid]=3
$items['fillpdf'] = array(
'page callback' => 'fillpdf_parse_uri',
// Can't use access callback. We need the arguments, but they're passed as $GET. Will access-check in fillpdf_merge_pdf
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
);
// --------- Form ------------------------
$items['admin/structure/fillpdf'] = array(
'title' => 'FillPDF',
'description' => 'Manage your PDFs',
'page callback' => 'drupal_get_form',
'page arguments' => array('fillpdf_forms_admin'),
'access arguments' => $access,
);
$items['admin/structure/fillpdf/%'] = array(
'title' => 'Edit PDF form',
'page callback' => 'drupal_get_form',
'page arguments' => array('fillpdf_form_edit', 3),
'access arguments' => $access,
);
$items['admin/structure/fillpdf/%/delete'] = array(
'page callback' => 'drupal_get_form',
'page arguments' => array('fillpdf_form_delete_confirm', 3),
'access arguments' => $access,
'type' => MENU_CALLBACK,
);
$items['admin/structure/fillpdf/%/export'] = array(
'title' => 'Export FillPDF field mappings',
'page callback' => 'fillpdf_form_export',
'page arguments' => array(3),
'access arguments' => $access,
);
$items['admin/structure/fillpdf/%/import'] = array(
'title' => 'Import FillPDF field mappings',
'page callback' => 'drupal_get_form',
'page arguments' => array('fillpdf_form_import_form', 3),
'access arguments' => $access,
);
// --------- Fields ------------------------
$items['admin/structure/fillpdf/%/add'] = array(
'title' => 'Add field',
'page callback' => 'fillpdf_field',
'page arguments' => array(4, 3),
'access arguments' => $access,
'type' => MENU_LOCAL_TASK,
);
$items['admin/structure/fillpdf/%/edit/%'] = array(
'page callback' => 'fillpdf_field',
'page arguments' => array(4, 3, 5),
'access arguments' => $access,
);
return $items;
}
/**
* Gets a link to the prinable PDF, merged with the passed-in data
* @param array/int $nids or $nid, if you pass in one value it will merge with that node.
* If array, it will merge with multiple nodes, with later nids overriding previous ones.
* @param array $webforms Array of webforms, of this strucure: array('nid'=>1, 'sid'=>1)
* @param bool $sample TRUE if you want to populate the form with its own field-names (to get a gist of PDF)
*/
function fillpdf_pdf_link($fid, $nids = NULL, $webform_arr = NULL, $sample = FALSE) {
$nids_uri = $webforms_uri = "";
if (is_array($nids)) {
$nids_uri = '&nids[]=' . implode('&nids[]=', $nids);
}
elseif (isset($nids)) {
$nids_uri = "&nids[]={$nids}";
}
if (is_array($webform_arr)) {
if ($webform_arr['nid']) {
$webform_arr = array($webform_arr);
}
foreach ($webform_arr as $key => $webform) {
$webforms_uri .= "&webforms[{$key}][nid]={$webform['nid']}";
}
$webforms_uri .= $webform['sid'] ? "&webforms[{$key}][sid]={$webform['sid']}" : "";
}
$sample = $sample ? '&sample=true' : '';
return url('', array('absolute' => TRUE)) . "fillpdf?fid={$fid}{$nids_uri}{$webforms_uri}{$sample}";
}
/**
* Get the data and form that need to be merged, from the $_GET, and print the PDF
*
* @see fillpdf_pdf_link()
* for $_GET params
*/
function fillpdf_parse_uri() {
// Avoid undefined index warnings, but don't clobber existing values
$_GET += array(
'nid' => NULL,
'nids' => NULL,
'webform' => NULL,
'webforms' => NULL,
'fid' => NULL,
'sample' => NULL,
'download' => NULL,
'flatten' => NULL,
);
$force_download = FALSE;
$flatten = TRUE;
//this function called multiple times, cut down on DB calls
// static $get;if($get)return $get;
$sample = $_GET['sample']; // is this just the PDF populated with sample data?
$fid = $_GET['fid'];
$nids = $webforms = array();
if ( $_GET['nid'] || $_GET['nids'] ) {
$nids = ( $_GET['nid'] ? array($_GET['nid']) : $_GET['nids'] );
}
if ( $_GET['webform'] || $_GET['webforms'] ) {
$webforms = ( $_GET['webform'] ? array($_GET['webform']) : $_GET['webforms'] );
}
if (isset($_GET['download']) && (int) $_GET['download'] == 1) {
$force_download = TRUE;
}
if (isset($_GET['flatten']) && (int) $_GET['flatten'] == 0) {
$flatten = FALSE;
}
fillpdf_merge_pdf($fid, $nids, $webforms, $sample, $force_download, FALSE, $flatten);
}
/**
* Constructs a page from scratch (pdf content-type) and sends it to the
* browser or saves it, depending on if a custom path is configured or not.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment