本文整理汇总了PHP中PDF_Common类的典型用法代码示例。如果您正苦于以下问题:PHP PDF_Common类的具体用法?PHP PDF_Common怎么用?PHP PDF_Common使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PDF_Common类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set_directory_structure
/**
* Used to set up our PDF template folder,
* save folder and font folder
*/
public function set_directory_structure()
{
$upload_dir = PDF_Common::get_upload_dir();
$site_name = PDF_Common::get_site_name();
/*
* As of Gravity PDF 3.7 we'll be dropping the 'site_name' folder for single installs
* And changing multisite installs to their site ID
*/
$this->template_location = apply_filters('gfpdfe_template_location', $upload_dir['basedir'] . '/' . PDF_SAVE_FOLDER . '/', $upload_dir['basedir'], PDF_SAVE_FOLDER);
$this->template_site_location = $this->template_location;
$this->template_save_location = $this->template_location . 'output/';
$this->template_font_location = $this->template_location . 'fonts/';
$this->template_location_url = apply_filters('gfpdfe_template_location_uri', $upload_dir['baseurl'] . '/' . PDF_SAVE_FOLDER . '/', $upload_dir['baseurl'], PDF_SAVE_FOLDER);
$this->template_site_location_url = $this->template_location_url;
$this->template_save_location_url = $this->template_location_url . 'output/';
$this->template_font_location_url = $this->template_location_url . 'fonts/';
$this->old_3_6_template_site_location = $this->template_location . $site_name . '/';
/*
* Use the network ID for multisite installs
*/
if (is_multisite()) {
$blog_id = get_current_blog_id();
$this->template_site_location = $this->template_location . $blog_id . '/';
$this->template_save_location = $this->template_site_location . 'output/';
$this->template_font_location = $this->template_site_location . 'fonts/';
$this->template_site_location_url = $this->template_location_url . $blog_id . '/';
$this->template_save_location_url = $this->template_site_location_url . 'output/';
$this->template_font_location_url = $this->template_site_location_url . 'fonts/';
$this->old_3_6_template_site_location = $this->template_location . $site_name . '/';
}
/*
* Include old template locations to help with migrations
*/
$this->old_template_location = get_stylesheet_directory() . '/' . PDF_SAVE_FOLDER . '/';
$this->upload_dir = $upload_dir['basedir'];
/*
* Include relative paths for display on the support pages
*/
$this->relative_output_location = str_replace(ABSPATH, '/', $this->template_save_location);
$this->relative_font_location = str_replace(ABSPATH, '/', $this->template_font_location);
$this->relative_mpdf_tmp = str_replace(ABSPATH, '/', PDF_PLUGIN_DIR) . 'mPDF/tmp/';
}
示例2:
<?php
/**
* Debugging can be done by adding &html=1 to the end of the URL when viewing the PDF
* We no longer need to access the file directly.
*/
if (!class_exists('RGForms')) {
/* Accessed directly */
exit;
}
/**
* Set up the form ID and lead ID, as well as we want page breaks displayed.
* Form ID and Lead ID can be set by passing it to the URL - ?fid=1&lid=10
*/
PDF_Common::setup_ids();
global $gfpdf;
$configuration_data = $gfpdf->get_config_data($form_id);
$show_html_fields = $configuration_data['default-show-html'] == 1 ? true : false;
$show_empty_fields = $configuration_data['default-show-empty'] == 1 ? true : false;
$show_page_names = $configuration_data['default-show-page-names'] == 1 ? true : false;
/**
* Load the form data, including the custom style sheet which looks in the plugin's theme folder before defaulting back to the plugin's file.
*/
$form = RGFormsModel::get_form_meta($form_id);
$stylesheet_location = file_exists(PDF_TEMPLATE_LOCATION . 'template.css') ? PDF_TEMPLATE_URL_LOCATION . 'template.css' : PDF_PLUGIN_URL . 'styles/template.css';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
示例3: foreach
</style>
<title>Gravity Forms PDF Extended</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<?php
foreach ($lead_ids as $lead_id) {
$lead = RGFormsModel::get_lead($lead_id);
do_action("gform_print_entry_header", $form, $lead);
$form_data = GFPDFEntryDetail::lead_detail_grid_array($form, $lead);
/*
* Add &data=1 when viewing the PDF via the admin area to view the $form_data array
*/
PDF_Common::view_data($form_data);
/* get all the form values */
/*$date_created = $form_data['date_created'];
$first_name = $form_data['1.Name']['first'];
$last_name = $form_data['1.Name']['last'];*/
//echo print_r($form_data['field'], true);
$fundName = $form_data['field']['Fund Name'];
$trusteeType = $form_data['field']['Trustee Type'];
$attendedBy = "";
$trusteeTrustees = "";
$trusteesDirectors = "";
$individualTrustees = $form_data['field']['Individual Trustees'];
$corporateDirectors = $form_data['field']['Directors of Corporate Trustee'];
$attendedBy = substr($attendedBy, 0, -2);
$lastComma = strrchr($attendedBy, ',');
示例4: set_notice_type
private static function set_notice_type()
{
global $gfpdfe_data;
if (PDF_Common::is_settings()) {
$gfpdfe_data->notice_type = 'gfpdfe_notices';
} else {
if (is_multisite() && is_network_admin()) {
$gfpdfe_data->notice_type = 'network_admin_notices';
} else {
$gfpdfe_data->notice_type = 'admin_notices';
}
}
}
示例5: do_template_migration
public static function do_template_migration()
{
/*
* Initialise the Wordpress Filesystem API
*/
if (PDF_Common::initialise_WP_filesystem_API(array(), 'gfpdfe_migrate') === false) {
return 'false';
}
/*
* If we got here we should have $wp_filesystem available
*/
global $wp_filesystem, $gfpdfe_data;
/*
* Convert paths for SSH/FTP users who are rooted to a directory along the server absolute path
*/
$base_template_directory = self::get_basedir($gfpdfe_data->template_location);
$current_pdf_path = self::get_basedir($gfpdfe_data->template_site_location);
if (is_dir($gfpdfe_data->old_template_location)) {
$previous_pdf_path = self::get_basedir($gfpdfe_data->old_template_location);
} elseif (is_dir($gfpdfe_data->old_3_6_template_site_location)) {
$previous_pdf_path = self::get_basedir($gfpdfe_data->old_3_6_template_site_location);
}
/* create the base template directory */
if (self::create_base_template_dir($base_template_directory) === false) {
return false;
}
/* create the site template directory */
if (self::create_site_template_dir($current_pdf_path) === false) {
return false;
}
if ($wp_filesystem->is_dir($previous_pdf_path)) {
if (is_dir($gfpdfe_data->old_template_location)) {
/* swap back to TRUE to delete the theme folder */
if (!self::pdf_extended_copy_directory($previous_pdf_path, $current_pdf_path, true, true, true)) {
return false;
}
} elseif (is_dir($gfpdfe_data->old_3_6_template_site_location)) {
/* swap back to TRUE to delete the theme folder */
if (!self::pdf_extended_copy_directory($previous_pdf_path, $current_pdf_path, true, false, true)) {
return false;
}
}
/*
* Clean up the DB
*/
delete_option('gfpdfe_automated_install');
}
return true;
}
示例6: get_product_array
private static function get_product_array($form, $lead, $has_product_fields, $form_array)
{
$currency_type = method_exists('GFCommon', 'is_currency_decimal_dot') ? GFCommon::is_currency_decimal_dot() : PDF_Common::is_currency_decimal_dot();
$currency_format = $currency_type ? 'decimal_dot' : 'decimal_comma';
if ($has_product_fields) {
$products = GFCommon::get_product_fields($form, $lead, true);
/* check that there are actual product fields */
if (sizeof($products['products']) > 0) {
/*
* Set up our variables
*/
$total = 0;
$subtotal = 0;
foreach ($products['products'] as $id => $product) {
$price = GFCommon::to_number($product['price']);
/* add all options to total price */
if (is_array(rgar($product, 'options'))) {
foreach ($product['options'] as $option) {
$price += GFCommon::to_number($option['price']);
}
}
/* calculate subtotal */
$subtotal = floatval($product['quantity']) * $price;
$total += $subtotal;
/*
* Check if we should include options
*/
$options = isset($product['options']) ? $product['options'] : array();
/*
* Add formated price for each product option
*/
foreach ($options as &$o) {
if (is_numeric($o['price'])) {
$o['price_formatted'] = GFCommon::format_number($o['price'], 'currency');
}
}
/*
* Store product in $form_array array
*/
$form_array['products'][$id] = array('name' => esc_html($product['name']), 'price' => esc_html($product['price']), 'price_unformatted' => GFCommon::clean_number($product['price'], $currency_format), 'options' => $options, 'quantity' => $product['quantity'], 'subtotal' => $subtotal, 'subtotal_formatted' => GFCommon::format_number($subtotal, 'currency'));
}
/* Increment total */
$total += floatval($products['shipping']['price']);
$subtotal = $total - floatval($products['shipping']['price']);
/* add totals to form data */
$form_array['products_totals'] = array('subtotal' => $subtotal, 'shipping' => $products['shipping']['price'], 'total' => $total, 'shipping_formatted' => GFCommon::format_number($products['shipping']['price'], 'currency'), 'subtotal_formatted' => GFCommon::format_number($subtotal, 'currency'), 'total_formatted' => GFCommon::format_number($total, 'currency'));
}
}
return $form_array;
}
示例7: generate_pdf_parameters
public static function generate_pdf_parameters($index, $form_id, $lead_id, $template = '')
{
global $gfpdf;
$config = $gfpdf->configuration[$index];
$pdf_name = isset($config['filename']) && strlen($config['filename']) > 0 ? $gfpdf->get_pdf_name($index, $form_id, $lead_id) : PDF_Common::get_pdf_filename($form_id, $lead_id);
$template = isset($template) && strlen($template) > 0 ? $template : $gfpdf->get_template($index);
$pdf_size = isset($config['pdf_size']) && (is_array($config['pdf_size']) || strlen($config['pdf_size']) > 0) ? $config['pdf_size'] : PDFGenerator::$default['pdf_size'];
$orientation = isset($config['orientation']) && strlen($config['orientation']) > 0 ? $config['orientation'] : PDFGenerator::$default['orientation'];
$security = isset($config['security']) && $config['security'] ? $config['security'] : PDFGenerator::$default['security'];
$premium = isset($config['premium']) && $config['premium'] === true ? true : false;
/* added in v3.4.0 */
$dpi = isset($config['dpi']) && (int) $config['dpi'] > 0 ? (int) $config['dpi'] : false;
/* added in v3.4.0 */
$pdfa1b = isset($config['pdfa1b']) && $config['pdfa1b'] === true ? true : false;
/* added in v3.4.0 */
$pdfx1a = isset($config['pdfx1a']) && $config['pdfx1a'] === true ? true : false;
/*
* Validate privileges
* If blank and security is true then set privileges to all
*/
$privileges = isset($config['pdf_privileges']) ? $gfpdf->validate_privileges($config['pdf_privileges']) : $gfpdf->validate_privileges('');
$pdf_password = isset($config['pdf_password']) ? PDF_Common::do_mergetags($config['pdf_password'], $form_id, $lead_id) : '';
$master_password = isset($config['pdf_master_password']) ? PDF_Common::do_mergetags($config['pdf_master_password'], $form_id, $lead_id) : '';
$rtl = isset($config['rtl']) ? $config['rtl'] : false;
$form = RGFormsModel::get_form_meta($form_id);
$lead = RGFormsModel::get_lead($lead_id);
/*
* Run the options through filters
*/
$pdf_name = apply_filters('gfpdfe_pdf_name', $pdf_name, $form, $lead);
$template = apply_filters('gfpdfe_template', $template, $form, $lead);
$orientation = apply_filters('gfpdf_orientation', $orientation, $form, $lead);
$security = apply_filters('gfpdf_security', $security, $form, $lead);
$privileges = apply_filters('gfpdf_privilages', $privileges, $form, $lead);
$pdf_password = apply_filters('gfpdf_password', $pdf_password, $form, $lead);
$master_password = apply_filters('gfpdf_master_password', $master_password, $form, $lead);
$rtl = apply_filters('gfpdf_rtl', $rtl, $form, $lead);
$pdf_arguments = array('pdfname' => $pdf_name, 'template' => $template, 'pdf_size' => $pdf_size, 'orientation' => $orientation, 'security' => $security, 'pdf_password' => $pdf_password, 'pdf_privileges' => $privileges, 'pdf_master_password' => $master_password, 'rtl' => $rtl, 'premium' => $premium, 'dpi' => $dpi, 'pdfa1b' => $pdfa1b, 'pdfx1a' => $pdfx1a);
return $pdf_arguments;
}
示例8: test_replace_variables
/**
* Test GF replace variables function (merge tags)
* i.e GFCommon::replace_variables
*
* @group gravityforms
* @dataProvider provider_mergetag_test
*/
public function test_replace_variables($mergetag, $value)
{
$this->assertEquals($value, PDF_Common::do_mergetags($mergetag, $this->form_id[0], $this->entries[2]));
}
示例9: run_setting_routing
protected function run_setting_routing()
{
global $gfpdfe_data;
/*
* Check if we need to redeploy default PDF templates/styles to the theme folder
*/
if (rgpost("gfpdf_deploy") && (wp_verify_nonce(PDF_Common::post('gfpdf_deploy_nonce'), 'gfpdf_deploy_nonce_action') || wp_verify_nonce(PDF_Common::get('_wpnonce'), 'pdf-extended-filesystem'))) {
/*
* Check if the user wants to upgrade the system or only initialise the fonts
*/
if (PDF_Common::post('font-initialise')) {
/*
* We only want to reinitialise the font files and configuration
*/
if (GFPDF_InstallUpdater::initialise_fonts() === false) {
return true;
}
} else {
if (rgpost('upgrade')) {
/*
* Deploy new template styles
* If we get false returned Wordpress is trying to get
* access details to update files so don't display anything.
*/
if (self::deploy() === 'false') {
return true;
}
}
}
}
/*
* Check if we need to sync the theme folders because a user changes theme
* Sniff the _wpnonce values to determine this.
*/
if (isset($_GET['_wpnonce'])) {
/*
* Check if we want to copy the theme files
*/
if ((is_dir($gfpdfe_data->old_template_location) || is_dir($gfpdfe_data->old_3_6_template_site_location)) && wp_verify_nonce(PDF_Common::get('_wpnonce'), 'gfpdfe_migrate')) {
if (GFPDF_InstallUpdater::run_template_migration() === 'false') {
return true;
}
}
}
}
示例10: load_entry_data
/**
* Loads the Gravity Form output script (actually the print preview)
*/
private function load_entry_data($template)
{
global $gfpdfe_data;
/* set up contstants for gravity forms to use so we can override the security on the printed version */
if (file_exists($gfpdfe_data->template_site_location . $template)) {
return PDF_Common::get_html_template($gfpdfe_data->template_site_location . $template);
} else {
/*
* Check if template file exists in the plugin's core template folder
*/
if (file_exists(PDF_PLUGIN_DIR . 'templates/' . $template)) {
return PDF_Common::get_html_template(PDF_PLUGIN_DIR . 'initialisation/templates/' . $template);
} else {
return PDF_Common::get_html_template(PDF_PLUGIN_DIR . 'initialisation/templates/' . PDFGenerator::$default['template']);
}
}
}
示例11: test_pdf_name
/**
* Write a stub to test a number of filename options
* We won't be testing form or lead merge tag data at this stage
* Just the basic naming convention (see common functions tests for full naming tests)
*
* @group configuration
* @dataProvider provider_test_pdf_name
*/
public function test_pdf_name($test, $result)
{
$this->assertEquals(PDF_Common::validate_pdf_name($test), $result);
}
示例12: get_pdf_name
public function get_pdf_name($id, $form_id = false, $lead_id = false)
{
if (isset($this->configuration[$id]['filename'])) {
return PDF_Common::validate_pdf_name($this->configuration[$id]['filename'], $form_id, $lead_id);
} else {
return PDF_Common::validate_pdf_name(PDF_Common::get_pdf_filename($form_id, $lead_id), $form_id, $lead_id);
}
}