@@ -37,10 +37,13 @@ discard block |
||
| 37 | 37 | break; |
| 38 | 38 | } |
| 39 | 39 | } |
| 40 | - if($length > 0) $hooked = rtrim($hooked, ","); |
|
| 40 | + if($length > 0) { |
|
| 41 | + $hooked = rtrim($hooked, ","); |
|
| 42 | + } |
|
| 41 | 43 | $hooked .= "]"; |
| 44 | + } else { |
|
| 45 | + $hooked .= $object; |
|
| 42 | 46 | } |
| 43 | - else $hooked .= $object; |
|
| 44 | 47 | echo "[+] Adding action -> " . $init . " in " . $hooked . PHP_EOL; |
| 45 | 48 | } |
| 46 | 49 | |
@@ -70,10 +73,13 @@ discard block |
||
| 70 | 73 | break; |
| 71 | 74 | } |
| 72 | 75 | } |
| 73 | - if($length > 0) $hooked = rtrim($hooked, ","); |
|
| 76 | + if($length > 0) { |
|
| 77 | + $hooked = rtrim($hooked, ","); |
|
| 78 | + } |
|
| 74 | 79 | $hooked .= "]"; |
| 80 | + } else { |
|
| 81 | + $hooked .= $object; |
|
| 75 | 82 | } |
| 76 | - else $hooked .= $object; |
|
| 77 | 83 | echo "[+] Registering actiovation hook -> " . $file . " in " . $hooked . PHP_EOL; |
| 78 | 84 | } |
| 79 | 85 | |
@@ -103,10 +109,13 @@ discard block |
||
| 103 | 109 | break; |
| 104 | 110 | } |
| 105 | 111 | } |
| 106 | - if($length > 0) $hooked = rtrim($hooked, ","); |
|
| 112 | + if($length > 0) { |
|
| 113 | + $hooked = rtrim($hooked, ","); |
|
| 114 | + } |
|
| 107 | 115 | $hooked .= "]"; |
| 116 | + } else { |
|
| 117 | + $hooked .= $object; |
|
| 108 | 118 | } |
| 109 | - else $hooked .= $object; |
|
| 110 | 119 | echo "[+] Registering actiovation hook -> " . $file . " in " . $hooked . PHP_EOL; |
| 111 | 120 | } |
| 112 | 121 | |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | /** |
| 3 | 5 | * Define utilities to manage entities |
| 4 | 6 | * |
@@ -213,8 +215,7 @@ discard block |
||
| 213 | 215 | $current_entity_params = get_post_meta($entity->ID, '_wpshop_entity_params', true); |
| 214 | 216 | if ( !empty($current_entity_params['display_admin_menu']) ) { |
| 215 | 217 | $show_in_menu = WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES; |
| 216 | - } |
|
| 217 | - else { |
|
| 218 | + } else { |
|
| 218 | 219 | $show_in_menu = false; |
| 219 | 220 | } |
| 220 | 221 | $post_type_params = array( |
@@ -328,15 +329,15 @@ discard block |
||
| 328 | 329 | foreach ($currentTabContent['box'] as $boxIdentifier => $boxTitle) { |
| 329 | 330 | if (!empty($currentTabContent['box'][$boxIdentifier.'_backend_display_type']) &&( $currentTabContent['box'][$boxIdentifier.'_backend_display_type']=='movable-tab')) { |
| 330 | 331 | add_meta_box($post->post_type . '_' . $boxIdentifier, __($boxTitle, 'wpshop'), array('wpshop_entities', 'meta_box_content'), $post->post_type, 'normal', 'default', array('currentTabContent' => $currentTabContent['boxContent'][$boxIdentifier])); |
| 332 | + } else { |
|
| 333 | + $fixed_box_exist = true; |
|
| 331 | 334 | } |
| 332 | - else $fixed_box_exist = true; |
|
| 333 | 335 | } |
| 334 | 336 | } |
| 335 | 337 | if ($fixed_box_exist && $post->post_type != WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ) { |
| 336 | 338 | add_meta_box($post->post_type . '_fixed_tab', __('Informations', 'wpshop'), array('wpshop_entities', 'meta_box_content_datas'), $post->post_type, 'normal', 'high', array('currentTabContent' => $currentTabContent)); |
| 337 | 339 | } |
| 338 | - } |
|
| 339 | - elseif (count($attribute_set_list) > 1) { |
|
| 340 | + } elseif (count($attribute_set_list) > 1) { |
|
| 340 | 341 | $input_def['id'] = $post->post_type.'_attribute_set_id'; |
| 341 | 342 | $input_def['name'] = $post->post_type.'_attribute_set_id'; |
| 342 | 343 | $input_def['value'] = ''; |
@@ -485,8 +486,7 @@ discard block |
||
| 485 | 486 | if( !empty( $current_id ) ) { |
| 486 | 487 | update_post_meta ($_REQUEST['post_ID'], '_wpshop_attached_address', $current_id); |
| 487 | 488 | } |
| 488 | - } |
|
| 489 | - else { |
|
| 489 | + } else { |
|
| 490 | 490 | $current_id = array(); |
| 491 | 491 | if ( !empty ($_REQUEST['address_type']) ) { |
| 492 | 492 | foreach ( $_REQUEST['address_type'] as $key=>$value ) { |
@@ -606,8 +606,7 @@ discard block |
||
| 606 | 606 | $new_element_link = '<a class="wpshop_cls wpshop_duplicate_entity_element_link" href="' . admin_url('post.php?post=' . $last_post . '&action=edit') . '" >' . __('Go on the new element edit page', 'wpshop') . '</a>'; |
| 607 | 607 | if ( $meta_creation ) { |
| 608 | 608 | return array('true', '<br/>' . $new_element_link, $last_post ); |
| 609 | - } |
|
| 610 | - else { |
|
| 609 | + } else { |
|
| 611 | 610 | return array('true', '<br/>' . __('Some errors occured while duplicating meta information, but element has been created.', 'wpshop') . ' ' . $new_element_link); |
| 612 | 611 | } |
| 613 | 612 | } |
@@ -673,18 +672,21 @@ discard block |
||
| 673 | 672 | $column_content = get_the_post_thumbnail( $post_id, 'thumbnail'); |
| 674 | 673 | break; |
| 675 | 674 | case "product_stock": |
| 676 | - if( !empty($product['product_stock']) ) |
|
| 677 | - $column_content = (int)$product['product_stock'].' '.__('unit(s)','wpshop'); |
|
| 675 | + if( !empty($product['product_stock']) ) { |
|
| 676 | + $column_content = (int)$product['product_stock'].' '.__('unit(s)','wpshop'); |
|
| 677 | + } |
|
| 678 | 678 | break; |
| 679 | 679 | |
| 680 | 680 | case "product_price": |
| 681 | - if( !empty($product['product_price']) ) |
|
| 682 | - $column_content = wpshop_prices::get_product_price( $product, 'price_display', 'complete_sheet'); |
|
| 681 | + if( !empty($product['product_price']) ) { |
|
| 682 | + $column_content = wpshop_prices::get_product_price( $product, 'price_display', 'complete_sheet'); |
|
| 683 | + } |
|
| 683 | 684 | break; |
| 684 | 685 | |
| 685 | 686 | case "tx_tva": |
| 686 | - if( !empty($product['product_price']) ) |
|
| 687 | - $column_content = number_format($product[$column],2,'.', ' ').' %'; |
|
| 687 | + if( !empty($product['product_price']) ) { |
|
| 688 | + $column_content = number_format($product[$column],2,'.', ' ').' %'; |
|
| 689 | + } |
|
| 688 | 690 | break; |
| 689 | 691 | default: |
| 690 | 692 | if ( !empty($product[$column]) ) { |
@@ -692,9 +694,9 @@ discard block |
||
| 692 | 694 | if ( in_array($column, $attribute_prices) ) { |
| 693 | 695 | $column_content = number_format($product[$column],2,'.', ' ').' '.wpshop_tools::wpshop_get_currency(); |
| 694 | 696 | |
| 697 | + } else { |
|
| 698 | + $column_content = $product[$column]; |
|
| 695 | 699 | } |
| 696 | - else |
|
| 697 | - $column_content = $product[$column]; |
|
| 698 | 700 | } |
| 699 | 701 | break; |
| 700 | 702 | } |
@@ -727,15 +729,13 @@ discard block |
||
| 727 | 729 | |
| 728 | 730 | if ( empty($shortcode_args['attribute_set_id']) || empty($shortcode_args['post_type']) ) { |
| 729 | 731 | $output = __('This form page is invalid because no set or type or content is defined. Please contact administrator with this error message', 'wpshop'); |
| 730 | - } |
|
| 731 | - else { |
|
| 732 | + } else { |
|
| 732 | 733 | $entity_identifier = wpshop_entities::get_entity_identifier_from_code($shortcode_args['post_type']); |
| 733 | 734 | $attribute_set_def = wpshop_attributes_set::getElement($shortcode_args['attribute_set_id'], "'valid'"); |
| 734 | 735 | |
| 735 | 736 | if ( empty($entity_identifier) || empty($attribute_set_def) || ($entity_identifier != $attribute_set_def->entity_id) ) { |
| 736 | 737 | $output = __('This form page is invalid because type and set are not linked. Please contact administrator with this error message', 'wpshop'); |
| 737 | - } |
|
| 738 | - else { |
|
| 738 | + } else { |
|
| 739 | 739 | /** Display wordpress fields */ |
| 740 | 740 | foreach ( explode(', ', $shortcode_args['fields']) as $field_name ) { |
| 741 | 741 | $label = ''; |
@@ -842,8 +842,7 @@ discard block |
||
| 842 | 842 | $tpl_component['DIALOG_BOX'] = ''; |
| 843 | 843 | $output = wpshop_display::display_template_element($template_part, $tpl_component, array(), 'wpshop'); |
| 844 | 844 | echo $output; |
| 845 | - } |
|
| 846 | - else { |
|
| 845 | + } else { |
|
| 847 | 846 | echo $wpshop_account->display_login_form(); |
| 848 | 847 | } |
| 849 | 848 | } |
@@ -882,8 +881,7 @@ discard block |
||
| 882 | 881 | /** Update the attribute set id for the current product */ |
| 883 | 882 | if ( !empty($extra_params['attribute_set_id']) ) { |
| 884 | 883 | $attribute_set_id = $extra_params['attribute_set_id']; |
| 885 | - } |
|
| 886 | - else { |
|
| 884 | + } else { |
|
| 887 | 885 | $query = $wpdb->prepare("SELECT id FROM " . WPSHOP_DBT_ATTRIBUTE_SET . " WHERE status = %s AND entity_id = %d AND default_set = %s", 'valid', wpshop_entities::get_entity_identifier_from_code($entity_type) , 'yes'); |
| 888 | 886 | $attribute_set_id = $wpdb->get_var($query); |
| 889 | 887 | } |
@@ -936,12 +934,10 @@ discard block |
||
| 936 | 934 | if ( $field_name == 'post_name' ) { |
| 937 | 935 | $db_datas_definition[] = $identifier; |
| 938 | 936 | $db_field_definition[] = str_replace( 'post_', '', $field_name ); |
| 939 | - } |
|
| 940 | - else if ( $field_default_value == 'mandatory' ) { |
|
| 937 | + } else if ( $field_default_value == 'mandatory' ) { |
|
| 941 | 938 | $has_error = true; |
| 942 | 939 | $errors[] = $field_name; |
| 943 | - } |
|
| 944 | - else { |
|
| 940 | + } else { |
|
| 945 | 941 | $db_datas_definition[] = $field_default_value; |
| 946 | 942 | $db_field_definition[] = str_replace( 'post_', '', $field_name ); |
| 947 | 943 | } |
@@ -951,8 +947,7 @@ discard block |
||
| 951 | 947 | if ( $has_error ) { |
| 952 | 948 | $result = false; |
| 953 | 949 | $output = sprintf( __('You have to fill %s, they are mandatory for custom type creation', 'wpshop'), implode(',', $errors) ); |
| 954 | - } |
|
| 955 | - else { |
|
| 950 | + } else { |
|
| 956 | 951 | $custom_post_type_def = array(); |
| 957 | 952 | foreach ( $db_field_definition as $field_position => $field_name ) { |
| 958 | 953 | $custom_post_type_def['post_' . $field_name] = $db_datas_definition[$field_position]; |
@@ -994,8 +989,7 @@ discard block |
||
| 994 | 989 | $attributes_for_cpt = wpshop_entities::check_default_cpt_attributes( $identifier, $tpl_component, $has_error ); |
| 995 | 990 | $has_error = $attributes_for_cpt[0]; |
| 996 | 991 | $tpl_component['CUSTOM_POST_TYPE_DEFAULT_ATTRIBUTES'] = $attributes_for_cpt[1]; |
| 997 | - } |
|
| 998 | - else { |
|
| 992 | + } else { |
|
| 999 | 993 | $tpl_component['CUSTOM_POST_TYPE_IDENTIFIER'] = '<img class="wpshop_tools_check_icon error" src="' . WPSHOP_MEDIAS_ICON_URL . 'informations/error_s.png" /> ' . $identifier; |
| 1000 | 994 | $tpl_component['TOOLS_CUSTOM_POST_TYPE_CONTAINER_CLASS'] = ' error'; |
| 1001 | 995 | $template_part = 'wpshop_admin_tools_default_datas_check_main_element_content_error'; |
@@ -1033,8 +1027,7 @@ discard block |
||
| 1033 | 1027 | if ( $column_value == 'code' ) { |
| 1034 | 1028 | $code_column = $column_key; |
| 1035 | 1029 | // $available_columns[$column_value] = $column_key; |
| 1036 | - } |
|
| 1037 | - else if ( in_array( $column_value, array('frontend_label')/* $attribute_displayed_field */ ) ) { |
|
| 1030 | + } else if ( in_array( $column_value, array('frontend_label')/* $attribute_displayed_field */ ) ) { |
|
| 1038 | 1031 | $available_columns[$column_value] = $column_key; |
| 1039 | 1032 | } |
| 1040 | 1033 | } |
@@ -1050,8 +1043,7 @@ discard block |
||
| 1050 | 1043 | if ( in_array( $line_column, $available_columns ) ) { |
| 1051 | 1044 | if ( !empty($attribute) ) { |
| 1052 | 1045 | $attribute_ok .= $attribute->frontend_label . ', '; |
| 1053 | - } |
|
| 1054 | - else { |
|
| 1046 | + } else { |
|
| 1055 | 1047 | $attribute_not_ok .= $line_column_value . ', '; |
| 1056 | 1048 | $has_error = true; |
| 1057 | 1049 | } |
@@ -1122,8 +1114,7 @@ discard block |
||
| 1122 | 1114 | break; |
| 1123 | 1115 | } |
| 1124 | 1116 | $attribute_def[$column_name] = ( !empty($attribute_definition[$column_index]) ) ? $column_value : ''; |
| 1125 | - } |
|
| 1126 | - else { |
|
| 1117 | + } else { |
|
| 1127 | 1118 | switch ( $column_name ) { |
| 1128 | 1119 | case 'available_values': |
| 1129 | 1120 | $attribute_values = $attribute_definition[$column_index]; |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | |
| 3 | 5 | /* Check if file is include. No direct access possible with file url */ |
| 4 | 6 | if ( !defined( 'WPSHOP_VERSION' ) ) { |
@@ -198,8 +200,9 @@ discard block |
||
| 198 | 200 | } |
| 199 | 201 | $actions['edit']=sprintf('<a href="'.admin_url('admin.php').'?page=%2$s&action=%3$s&id=%4$s">'.$default_action_text.'</a>',WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING,$default_action,$item['id']); |
| 200 | 202 | |
| 201 | - if (empty($_REQUEST['attribute_groups_status'])) |
|
| 202 | - $actions['delete']=sprintf('<a href="'.admin_url('admin.php').'?page=%2$s&action=%3$s&id=%4$s">'.__('Delete', 'wpshop').'</a>',WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING,'delete',$item['id']); |
|
| 203 | + if (empty($_REQUEST['attribute_groups_status'])) { |
|
| 204 | + $actions['delete']=sprintf('<a href="'.admin_url('admin.php').'?page=%2$s&action=%3$s&id=%4$s">'.__('Delete', 'wpshop').'</a>',WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING,'delete',$item['id']); |
|
| 205 | + } |
|
| 203 | 206 | |
| 204 | 207 | //Return the title contents |
| 205 | 208 | return sprintf('%1$s%2$s', |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | /** |
| 3 | 5 | * Products management method file |
| 4 | 6 | * |
@@ -132,8 +134,7 @@ discard block |
||
| 132 | 134 | $order_main_info .= '<div class="wps-product-section">'; |
| 133 | 135 | if(empty($order_postmeta['order_date']) || (empty($order_postmeta['order_key']) && empty($order_postmeta['order_temporary_key']) && empty($order_postmeta['order_invoice_ref']))){ |
| 134 | 136 | $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>'.__('Temporary quotation reference','wpshop').': </strong>'.self::get_new_pre_order_reference(false).'<br/>'; |
| 135 | - } |
|
| 136 | - else{ |
|
| 137 | + } else{ |
|
| 137 | 138 | if(!empty($order_postmeta['order_key'])){ |
| 138 | 139 | $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>'.__('Order reference','wpshop').' : </strong>'.$order_postmeta['order_key'].'<br/>'; |
| 139 | 140 | } |
@@ -148,8 +149,7 @@ discard block |
||
| 148 | 149 | $sub_tpl_component['ADMIN_ORDER_INVOICE_DOWNLOAD_LINK'] = WPSHOP_TEMPLATES_URL . 'invoice.php?order_id=' . $order->ID; |
| 149 | 150 | $order_invoice_download = wpshop_display::display_template_element('wpshop_admin_order_payment_received_invoice_download_links', $sub_tpl_component, array(), 'admin'); |
| 150 | 151 | $order_main_info .= '<span class="dashicons dashicons-arrow-right"></span> <strong>'. __('Invoice number','wpshop').': </strong>'.$order_postmeta['order_invoice_ref'].'<br/>' . $order_invoice_download . ''; |
| 151 | - } |
|
| 152 | - else { |
|
| 152 | + } else { |
|
| 153 | 153 | $order_main_info .= wpshop_display::display_template_element('wpshop_admin_order_generate_invoice_button', array(), array(), 'admin'); |
| 154 | 154 | } |
| 155 | 155 | } |
@@ -195,8 +195,7 @@ discard block |
||
| 195 | 195 | if ( empty($credit_meta) ) { |
| 196 | 196 | if( $order_postmeta['order_status'] == 'refunded') { |
| 197 | 197 | $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section wps_markAsRefunded_container">' .__('Credit Slip number', 'wpshop'). ' : <strong>'. ( (!empty($order_postmeta) && !empty($order_postmeta['order_payment']) && !empty($order_postmeta['order_payment']['refunded_action']) && !empty($order_postmeta['order_payment']['refunded_action']['credit_slip_ref']) ) ? '<a href="' .WPSHOP_TEMPLATES_URL. 'invoice.php?order_id=' .$order->ID. '&invoice_ref=' .$order_postmeta['order_payment']['refunded_action']['credit_slip_ref'].'&credit_slip=ok" target="_blank">'.$order_postmeta['order_payment']['refunded_action']['credit_slip_ref'].'</a>' : '') .'</strong></div>'; |
| 198 | - } |
|
| 199 | - else { |
|
| 198 | + } else { |
|
| 200 | 199 | $tpl_component['ADMIN_ORDER_ACTIONS_LIST'] .= '<div class="wps-product-section wps_markAsRefunded_container" ><button class="wps-bton-second-mini-rounded markAsRefunded order_' .$order->ID. '">' .__('Refund this order', 'wpshop'). '</button><input type="hidden" id="markasrefunded_order_hidden_indicator" name="markasrefunded_order_hidden_indicator" /></div>'; |
| 201 | 200 | } |
| 202 | 201 | } |
@@ -276,8 +275,7 @@ discard block |
||
| 276 | 275 | |
| 277 | 276 | $order_current_number = get_option('wpshop_order_current_number', false); |
| 278 | 277 | /* If the counter doesn't exist, we initiate it */ |
| 279 | - if(!$order_current_number) { $order_current_number = 1; } |
|
| 280 | - else { $order_current_number++; } |
|
| 278 | + if(!$order_current_number) { $order_current_number = 1; } else { $order_current_number++; } |
|
| 281 | 279 | update_option('wpshop_order_current_number', $order_current_number); |
| 282 | 280 | |
| 283 | 281 | $order_ref = (string)sprintf('%0'.$number_figures.'d', $order_current_number); |
@@ -297,8 +295,7 @@ discard block |
||
| 297 | 295 | |
| 298 | 296 | $order_current_number = get_option('wpshop_preorder_current_number', false); |
| 299 | 297 | /* If the counter doesn't exist, we initiate it */ |
| 300 | - if(!$order_current_number) { $order_current_number = 1; } |
|
| 301 | - else { $order_current_number++; } |
|
| 298 | + if(!$order_current_number) { $order_current_number = 1; } else { $order_current_number++; } |
|
| 302 | 299 | if($save){ |
| 303 | 300 | update_option('wpshop_preorder_current_number', $order_current_number); |
| 304 | 301 | } |
@@ -332,8 +329,7 @@ discard block |
||
| 332 | 329 | $shipping_info['address'] = get_post_meta( $address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true); |
| 333 | 330 | } |
| 334 | 331 | } |
| 335 | - } |
|
| 336 | - else { |
|
| 332 | + } else { |
|
| 337 | 333 | $shipping_info['id'] = get_post_meta($shipping_address_id, WPSHOP_ADDRESS_ATTRIBUTE_SET_ID_META_KEY, true); |
| 338 | 334 | $shipping_info['address'] = get_post_meta($shipping_address_id, '_'.WPSHOP_NEWTYPE_IDENTIFIER_ADDRESS.'_metadata', true); |
| 339 | 335 | $shipping_info['address_id'] = ( !empty($_SESSION['shipping_address']) ) ? intval( $_SESSION['shipping_address'] ) : ''; |
@@ -394,8 +390,7 @@ discard block |
||
| 394 | 390 | case "order_billing": |
| 395 | 391 | if ( !empty($addresses['billing']) && !empty($addresses['billing']['address']) && is_array($addresses['billing']['address']) ) { |
| 396 | 392 | $billing = $addresses['billing']['address']; |
| 397 | - } |
|
| 398 | - else if ( !empty($addresses['billing']) ) { |
|
| 393 | + } else if ( !empty($addresses['billing']) ) { |
|
| 399 | 394 | $billing = $addresses['billing']; |
| 400 | 395 | } |
| 401 | 396 | if ( !empty($billing) ) { |
@@ -403,8 +398,7 @@ discard block |
||
| 403 | 398 | echo empty($billing['company'])?'<br />':', <i>'.$billing['company'].'</i><br />'; |
| 404 | 399 | echo (!empty($billing['address']) ? $billing['address'] : null).'<br />'; |
| 405 | 400 | echo (!empty($billing['postcode']) ? $billing['postcode'] : null).' '.(!empty($billing['city']) ? $billing['city'] : null).', '.(!empty($billing['country']) ? $billing['country'] : null); |
| 406 | - } |
|
| 407 | - else { |
|
| 401 | + } else { |
|
| 408 | 402 | echo __('No information available for user billing', 'wpshop'); |
| 409 | 403 | } |
| 410 | 404 | break; |
@@ -412,8 +406,7 @@ discard block |
||
| 412 | 406 | case "order_shipping": |
| 413 | 407 | if ( !empty($addresses['shipping']) && !empty($addresses['shipping']['address']) && is_array($addresses['shipping']['address']) ) { |
| 414 | 408 | $shipping = $addresses['shipping']['address']; |
| 415 | - } |
|
| 416 | - else if ( !empty($addresses['shipping']) ) { |
|
| 409 | + } else if ( !empty($addresses['shipping']) ) { |
|
| 417 | 410 | $shipping = $addresses['shipping']; |
| 418 | 411 | } |
| 419 | 412 | if ( !empty($shipping) ) { |
@@ -421,8 +414,7 @@ discard block |
||
| 421 | 414 | echo empty($shipping['company'])?'<br />':', <i>'.$shipping['company'].'</i><br />'; |
| 422 | 415 | echo (!empty($shipping['address']) ? $shipping['address'] : null).'<br />'; |
| 423 | 416 | echo (!empty($shipping['postcode']) ? $shipping['postcode'] : null).' '.(!empty($shipping['city']) ? $shipping['city'] : null).', '.(!empty($shipping['country']) ? $shipping['country'] : null); |
| 424 | - } |
|
| 425 | - else{ |
|
| 417 | + } else{ |
|
| 426 | 418 | echo __('No information available for user shipping', 'wpshop'); |
| 427 | 419 | } |
| 428 | 420 | break; |
@@ -435,8 +427,7 @@ discard block |
||
| 435 | 427 | // Marquer comme envoy� |
| 436 | 428 | if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'completed')) { |
| 437 | 429 | $buttons .= '<a data-id="' . $post_id . '" class="wps-bton-second-mini-rounded markAsShipped order_'.$post_id.' wps-bton-loader">'.__('Mark as shipped', 'wpshop').'</a> '; |
| 438 | - } |
|
| 439 | - else if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'awaiting_payment' )) { |
|
| 430 | + } else if (!empty($order_postmeta['order_status']) && ($order_postmeta['order_status'] == 'awaiting_payment' )) { |
|
| 440 | 431 | // $buttons .= '<a class="button markAsCompleted order_'.$post_id.' alignleft" >'.__('Payment received', 'wpshop').'</a>' . wpshop_payment::display_payment_receiver_interface($post_id) . ' '; |
| 441 | 432 | } |
| 442 | 433 | $buttons .= '</p>'; |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | |
| 3 | 5 | /* Check if file is include. No direct access possible with file url */ |
| 4 | 6 | if ( !defined( 'WPSHOP_VERSION' ) ) { |
@@ -58,12 +60,13 @@ discard block |
||
| 58 | 60 | // On enregistre la commande |
| 59 | 61 | update_post_meta($order_id, '_order_postmeta', $order); |
| 60 | 62 | update_post_meta($order_id, '_wpshop_order_customer_id', $user_id); |
| 63 | + } else { |
|
| 64 | + $wpshop->add_error(__('You don\'t own the order', 'wpshop')); |
|
| 61 | 65 | } |
| 62 | - else $wpshop->add_error(__('You don\'t own the order', 'wpshop')); |
|
| 66 | + } else { |
|
| 67 | + $wpshop->add_error(__('The order doesn\'t exist.', 'wpshop')); |
|
| 63 | 68 | } |
| 64 | - else $wpshop->add_error(__('The order doesn\'t exist.', 'wpshop')); |
|
| 65 | - } |
|
| 66 | - else{ |
|
| 69 | + } else{ |
|
| 67 | 70 | $order_data = array( |
| 68 | 71 | 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, |
| 69 | 72 | 'post_title' => sprintf(__('Order - %s','wpshop'), mysql2date('d M Y\, H:i:s', current_time('mysql', 0), true)), |
@@ -106,7 +109,9 @@ discard block |
||
| 106 | 109 | |
| 107 | 110 | } |
| 108 | 111 | } |
| 109 | - if(!empty($download_codes)) update_user_meta($user_id, '_order_download_codes_'.$order_id, $download_codes); |
|
| 112 | + if(!empty($download_codes)) { |
|
| 113 | + update_user_meta($user_id, '_order_download_codes_'.$order_id, $download_codes); |
|
| 114 | + } |
|
| 110 | 115 | |
| 111 | 116 | // Informations de commande � stocker |
| 112 | 117 | $currency = wpshop_tools::wpshop_get_currency(true); |
@@ -128,8 +133,7 @@ discard block |
||
| 128 | 133 | // Si c'est un devis |
| 129 | 134 | if ( $paymentMethod == 'quotation' ) { |
| 130 | 135 | $order['order_temporary_key'] = wpshop_orders::get_new_pre_order_reference(); |
| 131 | - } |
|
| 132 | - else { |
|
| 136 | + } else { |
|
| 133 | 137 | $order['order_key'] = wpshop_orders::get_new_order_reference(); |
| 134 | 138 | } |
| 135 | 139 | |
@@ -190,8 +194,7 @@ discard block |
||
| 190 | 194 | |
| 191 | 195 | if ( !empty($order_meta) && !empty($order_meta['cart_type']) && $order_meta['cart_type'] == 'quotation' && empty($order_meta['order_key']) ) { |
| 192 | 196 | $wps_message->wpshop_prepared_email($email, 'WPSHOP_QUOTATION_CONFIRMATION_MESSAGE', array('order_id' => $order_id,'customer_first_name' => $first_name, 'customer_last_name' => $last_name, 'customer_email' => $email, 'order_date' => current_time('mysql', 0), 'order_content' => '', 'order_addresses' => '', 'order_customer_comments' => '', 'order_billing_address' => '', 'order_shipping_address' => '', 'order_shipping_method' => $shipping_method, 'order_personnal_informations' => '') ); |
| 193 | - } |
|
| 194 | - else { |
|
| 197 | + } else { |
|
| 195 | 198 | $email_option = get_option( 'wpshop_emails' ); |
| 196 | 199 | if ( empty($email_option['send_confirmation_order_message']) ) { |
| 197 | 200 | $payment_method_option = get_option( 'wps_payment_mode' ); |
@@ -245,8 +248,7 @@ discard block |
||
| 245 | 248 | |
| 246 | 249 | if( !empty( $order_infos ) && !empty($order_infos['cart_type']) && $order_infos['cart_type'] == 'normal' && !empty($order_infos['order_key']) ){ |
| 247 | 250 | $message_type = 'WPSHOP_NEW_ORDER_ADMIN_MESSAGE'; |
| 248 | - } |
|
| 249 | - else { |
|
| 251 | + } else { |
|
| 250 | 252 | $message_type = 'WPSHOP_NEW_QUOTATION_ADMIN_MESSAGE'; |
| 251 | 253 | $order_tmp_key = $order_infos['order_temporary_key']; |
| 252 | 254 | } |
@@ -288,8 +290,7 @@ discard block |
||
| 288 | 290 | $_SESSION['order_id'] = $order_id; |
| 289 | 291 | $wpdb->update($wpdb->users, array('user_activation_key' => ''), array('user_login' => $login) ); |
| 290 | 292 | wpshop_tools::wpshop_safe_redirect( get_permalink( wpshop_tools::get_page_id( get_option('wpshop_checkout_page_id') ) ) ); |
| 291 | - } |
|
| 292 | - else { |
|
| 293 | + } else { |
|
| 293 | 294 | wpshop_tools::wpshop_safe_redirect( get_permalink( wpshop_tools::get_page_id( get_option('wpshop_myaccount_page_id') ) ) ); |
| 294 | 295 | } |
| 295 | 296 | |
@@ -1,6 +1,9 @@ |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 2 | -for($i=0;$i<=255;$i++) |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 4 | +for($i=0;$i<=255;$i++) { |
|
| 3 | 5 | $fpdf_charwidths['courier'][chr($i)]=600; |
| 6 | +} |
|
| 4 | 7 | $fpdf_charwidths['courierB']=$fpdf_charwidths['courier']; |
| 5 | 8 | $fpdf_charwidths['courierI']=$fpdf_charwidths['courier']; |
| 6 | 9 | $fpdf_charwidths['courierBI']=$fpdf_charwidths['courier']; |
@@ -112,21 +112,23 @@ discard block |
||
| 112 | 112 | 'times'=>'Times-Roman', 'timesB'=>'Times-Bold', 'timesI'=>'Times-Italic', 'timesBI'=>'Times-BoldItalic', |
| 113 | 113 | 'symbol'=>'Symbol', 'zapfdingbats'=>'ZapfDingbats'); |
| 114 | 114 | //Scale factor |
| 115 | - if($unit=='pt') |
|
| 116 | - $this->k=1; |
|
| 117 | - elseif($unit=='mm') |
|
| 118 | - $this->k=72/25.4; |
|
| 119 | - elseif($unit=='cm') |
|
| 120 | - $this->k=72/2.54; |
|
| 121 | - elseif($unit=='in') |
|
| 122 | - $this->k=72; |
|
| 123 | - else |
|
| 124 | - $this->Error('Incorrect unit: '.$unit); |
|
| 115 | + if($unit=='pt') { |
|
| 116 | + $this->k=1; |
|
| 117 | + } elseif($unit=='mm') { |
|
| 118 | + $this->k=72/25.4; |
|
| 119 | + } elseif($unit=='cm') { |
|
| 120 | + $this->k=72/2.54; |
|
| 121 | + } elseif($unit=='in') { |
|
| 122 | + $this->k=72; |
|
| 123 | + } else { |
|
| 124 | + $this->Error('Incorrect unit: '.$unit); |
|
| 125 | + } |
|
| 125 | 126 | //Page format |
| 126 | 127 | $this->PageFormats=array('a3'=>array(841.89,1190.55), 'a4'=>array(595.28,841.89), 'a5'=>array(420.94,595.28), |
| 127 | 128 | 'letter'=>array(612,792), 'legal'=>array(612,1008)); |
| 128 | - if(is_string($format)) |
|
| 129 | - $format=$this->_getpageformat($format); |
|
| 129 | + if(is_string($format)) { |
|
| 130 | + $format=$this->_getpageformat($format); |
|
| 131 | + } |
|
| 130 | 132 | $this->DefPageFormat=$format; |
| 131 | 133 | $this->CurPageFormat=$format; |
| 132 | 134 | //Page orientation |
@@ -136,15 +138,14 @@ discard block |
||
| 136 | 138 | $this->DefOrientation='P'; |
| 137 | 139 | $this->w=$this->DefPageFormat[0]; |
| 138 | 140 | $this->h=$this->DefPageFormat[1]; |
| 139 | - } |
|
| 140 | - elseif($orientation=='l' || $orientation=='landscape') |
|
| 141 | + } elseif($orientation=='l' || $orientation=='landscape') |
|
| 141 | 142 | { |
| 142 | 143 | $this->DefOrientation='L'; |
| 143 | 144 | $this->w=$this->DefPageFormat[1]; |
| 144 | 145 | $this->h=$this->DefPageFormat[0]; |
| 146 | + } else { |
|
| 147 | + $this->Error('Incorrect orientation: '.$orientation); |
|
| 145 | 148 | } |
| 146 | - else |
|
| 147 | - $this->Error('Incorrect orientation: '.$orientation); |
|
| 148 | 149 | $this->CurOrientation=$this->DefOrientation; |
| 149 | 150 | $this->wPt=$this->w*$this->k; |
| 150 | 151 | $this->hPt=$this->h*$this->k; |
@@ -170,8 +171,9 @@ discard block |
||
| 170 | 171 | //Set left, top and right margins |
| 171 | 172 | $this->lMargin=$left; |
| 172 | 173 | $this->tMargin=$top; |
| 173 | - if($right===null) |
|
| 174 | - $right=$left; |
|
| 174 | + if($right===null) { |
|
| 175 | + $right=$left; |
|
| 176 | + } |
|
| 175 | 177 | $this->rMargin=$right; |
| 176 | 178 | } |
| 177 | 179 | |
@@ -179,9 +181,10 @@ discard block |
||
| 179 | 181 | { |
| 180 | 182 | //Set left margin |
| 181 | 183 | $this->lMargin=$margin; |
| 182 | - if($this->page>0 && $this->x<$margin) |
|
| 183 | - $this->x=$margin; |
|
| 184 | -} |
|
| 184 | + if($this->page>0 && $this->x<$margin) { |
|
| 185 | + $this->x=$margin; |
|
| 186 | + } |
|
| 187 | + } |
|
| 185 | 188 | |
| 186 | 189 | function SetTopMargin($margin) |
| 187 | 190 | { |
@@ -206,62 +209,70 @@ discard block |
||
| 206 | 209 | function SetDisplayMode($zoom, $layout='continuous') |
| 207 | 210 | { |
| 208 | 211 | //Set display mode in viewer |
| 209 | - if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom)) |
|
| 210 | - $this->ZoomMode=$zoom; |
|
| 211 | - else |
|
| 212 | - $this->Error('Incorrect zoom display mode: '.$zoom); |
|
| 213 | - if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default') |
|
| 214 | - $this->LayoutMode=$layout; |
|
| 215 | - else |
|
| 216 | - $this->Error('Incorrect layout display mode: '.$layout); |
|
| 217 | -} |
|
| 212 | + if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom)) { |
|
| 213 | + $this->ZoomMode=$zoom; |
|
| 214 | + } else { |
|
| 215 | + $this->Error('Incorrect zoom display mode: '.$zoom); |
|
| 216 | + } |
|
| 217 | + if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default') { |
|
| 218 | + $this->LayoutMode=$layout; |
|
| 219 | + } else { |
|
| 220 | + $this->Error('Incorrect layout display mode: '.$layout); |
|
| 221 | + } |
|
| 222 | + } |
|
| 218 | 223 | |
| 219 | 224 | function SetCompression($compress) |
| 220 | 225 | { |
| 221 | 226 | //Set page compression |
| 222 | - if(function_exists('gzcompress')) |
|
| 223 | - $this->compress=$compress; |
|
| 224 | - else |
|
| 225 | - $this->compress=false; |
|
| 226 | -} |
|
| 227 | + if(function_exists('gzcompress')) { |
|
| 228 | + $this->compress=$compress; |
|
| 229 | + } else { |
|
| 230 | + $this->compress=false; |
|
| 231 | + } |
|
| 232 | + } |
|
| 227 | 233 | |
| 228 | 234 | function SetTitle($title, $isUTF8=false) |
| 229 | 235 | { |
| 230 | 236 | //Title of document |
| 231 | - if($isUTF8) |
|
| 232 | - $title=$this->_UTF8toUTF16($title); |
|
| 237 | + if($isUTF8) { |
|
| 238 | + $title=$this->_UTF8toUTF16($title); |
|
| 239 | + } |
|
| 233 | 240 | $this->title=$title; |
| 234 | 241 | } |
| 235 | 242 | |
| 236 | 243 | function SetSubject($subject, $isUTF8=false) |
| 237 | 244 | { |
| 238 | 245 | //Subject of document |
| 239 | - if($isUTF8) |
|
| 240 | - $subject=$this->_UTF8toUTF16($subject); |
|
| 246 | + if($isUTF8) { |
|
| 247 | + $subject=$this->_UTF8toUTF16($subject); |
|
| 248 | + } |
|
| 241 | 249 | $this->subject=$subject; |
| 242 | 250 | } |
| 243 | 251 | |
| 244 | 252 | function SetAuthor($author, $isUTF8=false) |
| 245 | 253 | { |
| 246 | 254 | //Author of document |
| 247 | - if($isUTF8) |
|
| 248 | - $author=$this->_UTF8toUTF16($author); |
|
| 255 | + if($isUTF8) { |
|
| 256 | + $author=$this->_UTF8toUTF16($author); |
|
| 257 | + } |
|
| 249 | 258 | $this->author=$author; |
| 250 | 259 | } |
| 251 | 260 | |
| 252 | 261 | function SetKeywords($keywords, $isUTF8=false) |
| 253 | 262 | { |
| 254 | 263 | //Keywords of document |
| 255 | - if($isUTF8) |
|
| 256 | - $keywords=$this->_UTF8toUTF16($keywords); |
|
| 264 | + if($isUTF8) { |
|
| 265 | + $keywords=$this->_UTF8toUTF16($keywords); |
|
| 266 | + } |
|
| 257 | 267 | $this->keywords=$keywords; |
| 258 | 268 | } |
| 259 | 269 | |
| 260 | 270 | function SetCreator($creator, $isUTF8=false) |
| 261 | 271 | { |
| 262 | 272 | //Creator of document |
| 263 | - if($isUTF8) |
|
| 264 | - $creator=$this->_UTF8toUTF16($creator); |
|
| 273 | + if($isUTF8) { |
|
| 274 | + $creator=$this->_UTF8toUTF16($creator); |
|
| 275 | + } |
|
| 265 | 276 | $this->creator=$creator; |
| 266 | 277 | } |
| 267 | 278 | |
@@ -286,10 +297,12 @@ discard block |
||
| 286 | 297 | function Close() |
| 287 | 298 | { |
| 288 | 299 | //Terminate document |
| 289 | - if($this->state==3) |
|
| 290 | - return; |
|
| 291 | - if($this->page==0) |
|
| 292 | - $this->AddPage(); |
|
| 300 | + if($this->state==3) { |
|
| 301 | + return; |
|
| 302 | + } |
|
| 303 | + if($this->page==0) { |
|
| 304 | + $this->AddPage(); |
|
| 305 | + } |
|
| 293 | 306 | //Page footer |
| 294 | 307 | $this->InFooter=true; |
| 295 | 308 | $this->Footer(); |
@@ -303,8 +316,9 @@ discard block |
||
| 303 | 316 | function AddPage($orientation='', $format='') |
| 304 | 317 | { |
| 305 | 318 | //Start a new page |
| 306 | - if($this->state==0) |
|
| 307 | - $this->Open(); |
|
| 319 | + if($this->state==0) { |
|
| 320 | + $this->Open(); |
|
| 321 | + } |
|
| 308 | 322 | $family=$this->FontFamily; |
| 309 | 323 | $style=$this->FontStyle.($this->underline ? 'U' : ''); |
| 310 | 324 | $size=$this->FontSizePt; |
@@ -330,15 +344,18 @@ discard block |
||
| 330 | 344 | $this->LineWidth=$lw; |
| 331 | 345 | $this->_out(sprintf('%.2F w',$lw*$this->k)); |
| 332 | 346 | //Set font |
| 333 | - if($family) |
|
| 334 | - $this->SetFont($family,$style,$size); |
|
| 347 | + if($family) { |
|
| 348 | + $this->SetFont($family,$style,$size); |
|
| 349 | + } |
|
| 335 | 350 | //Set colors |
| 336 | 351 | $this->DrawColor=$dc; |
| 337 | - if($dc!='0 G') |
|
| 338 | - $this->_out($dc); |
|
| 352 | + if($dc!='0 G') { |
|
| 353 | + $this->_out($dc); |
|
| 354 | + } |
|
| 339 | 355 | $this->FillColor=$fc; |
| 340 | - if($fc!='0 g') |
|
| 341 | - $this->_out($fc); |
|
| 356 | + if($fc!='0 g') { |
|
| 357 | + $this->_out($fc); |
|
| 358 | + } |
|
| 342 | 359 | $this->TextColor=$tc; |
| 343 | 360 | $this->ColorFlag=$cf; |
| 344 | 361 | //Page header |
@@ -352,8 +369,9 @@ discard block |
||
| 352 | 369 | $this->_out(sprintf('%.2F w',$lw*$this->k)); |
| 353 | 370 | } |
| 354 | 371 | //Restore font |
| 355 | - if($family) |
|
| 356 | - $this->SetFont($family,$style,$size); |
|
| 372 | + if($family) { |
|
| 373 | + $this->SetFont($family,$style,$size); |
|
| 374 | + } |
|
| 357 | 375 | //Restore colors |
| 358 | 376 | if($this->DrawColor!=$dc) |
| 359 | 377 | { |
@@ -388,33 +406,38 @@ discard block |
||
| 388 | 406 | function SetDrawColor($r, $g=null, $b=null) |
| 389 | 407 | { |
| 390 | 408 | //Set color for all stroking operations |
| 391 | - if(($r==0 && $g==0 && $b==0) || $g===null) |
|
| 392 | - $this->DrawColor=sprintf('%.3F G',$r/255); |
|
| 393 | - else |
|
| 394 | - $this->DrawColor=sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255); |
|
| 395 | - if($this->page>0) |
|
| 396 | - $this->_out($this->DrawColor); |
|
| 397 | -} |
|
| 409 | + if(($r==0 && $g==0 && $b==0) || $g===null) { |
|
| 410 | + $this->DrawColor=sprintf('%.3F G',$r/255); |
|
| 411 | + } else { |
|
| 412 | + $this->DrawColor=sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255); |
|
| 413 | + } |
|
| 414 | + if($this->page>0) { |
|
| 415 | + $this->_out($this->DrawColor); |
|
| 416 | + } |
|
| 417 | + } |
|
| 398 | 418 | |
| 399 | 419 | function SetFillColor($r, $g=null, $b=null) |
| 400 | 420 | { |
| 401 | 421 | //Set color for all filling operations |
| 402 | - if(($r==0 && $g==0 && $b==0) || $g===null) |
|
| 403 | - $this->FillColor=sprintf('%.3F g',$r/255); |
|
| 404 | - else |
|
| 405 | - $this->FillColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); |
|
| 422 | + if(($r==0 && $g==0 && $b==0) || $g===null) { |
|
| 423 | + $this->FillColor=sprintf('%.3F g',$r/255); |
|
| 424 | + } else { |
|
| 425 | + $this->FillColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); |
|
| 426 | + } |
|
| 406 | 427 | $this->ColorFlag=($this->FillColor!=$this->TextColor); |
| 407 | - if($this->page>0) |
|
| 408 | - $this->_out($this->FillColor); |
|
| 409 | -} |
|
| 428 | + if($this->page>0) { |
|
| 429 | + $this->_out($this->FillColor); |
|
| 430 | + } |
|
| 431 | + } |
|
| 410 | 432 | |
| 411 | 433 | function SetTextColor($r, $g=null, $b=null) |
| 412 | 434 | { |
| 413 | 435 | //Set color for text |
| 414 | - if(($r==0 && $g==0 && $b==0) || $g===null) |
|
| 415 | - $this->TextColor=sprintf('%.3F g',$r/255); |
|
| 416 | - else |
|
| 417 | - $this->TextColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); |
|
| 436 | + if(($r==0 && $g==0 && $b==0) || $g===null) { |
|
| 437 | + $this->TextColor=sprintf('%.3F g',$r/255); |
|
| 438 | + } else { |
|
| 439 | + $this->TextColor=sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); |
|
| 440 | + } |
|
| 418 | 441 | $this->ColorFlag=($this->FillColor!=$this->TextColor); |
| 419 | 442 | } |
| 420 | 443 | |
@@ -425,8 +448,9 @@ discard block |
||
| 425 | 448 | $cw=&$this->CurrentFont['cw']; |
| 426 | 449 | $w=0; |
| 427 | 450 | $l=strlen($s); |
| 428 | - for($i=0;$i<$l;$i++) |
|
| 429 | - $w+=$cw[$s[$i]]; |
|
| 451 | + for($i=0;$i<$l;$i++) { |
|
| 452 | + $w+=$cw[$s[$i]]; |
|
| 453 | + } |
|
| 430 | 454 | return $w*$this->FontSize/1000; |
| 431 | 455 | } |
| 432 | 456 | |
@@ -434,9 +458,10 @@ discard block |
||
| 434 | 458 | { |
| 435 | 459 | //Set line width |
| 436 | 460 | $this->LineWidth=$width; |
| 437 | - if($this->page>0) |
|
| 438 | - $this->_out(sprintf('%.2F w',$width*$this->k)); |
|
| 439 | -} |
|
| 461 | + if($this->page>0) { |
|
| 462 | + $this->_out(sprintf('%.2F w',$width*$this->k)); |
|
| 463 | + } |
|
| 464 | + } |
|
| 440 | 465 | |
| 441 | 466 | function Line($x1, $y1, $x2, $y2) |
| 442 | 467 | { |
@@ -447,12 +472,13 @@ discard block |
||
| 447 | 472 | function Rect($x, $y, $w, $h, $style='') |
| 448 | 473 | { |
| 449 | 474 | //Draw a rectangle |
| 450 | - if($style=='F') |
|
| 451 | - $op='f'; |
|
| 452 | - elseif($style=='FD' || $style=='DF') |
|
| 453 | - $op='B'; |
|
| 454 | - else |
|
| 455 | - $op='S'; |
|
| 475 | + if($style=='F') { |
|
| 476 | + $op='f'; |
|
| 477 | + } elseif($style=='FD' || $style=='DF') { |
|
| 478 | + $op='B'; |
|
| 479 | + } else { |
|
| 480 | + $op='S'; |
|
| 481 | + } |
|
| 456 | 482 | $this->_out(sprintf('%.2F %.2F %.2F %.2F re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op)); |
| 457 | 483 | } |
| 458 | 484 | |
@@ -460,19 +486,24 @@ discard block |
||
| 460 | 486 | { |
| 461 | 487 | //Add a TrueType or Type1 font |
| 462 | 488 | $family=strtolower($family); |
| 463 | - if($file=='') |
|
| 464 | - $file=str_replace(' ','',$family).strtolower($style).'.php'; |
|
| 465 | - if($family=='arial') |
|
| 466 | - $family='helvetica'; |
|
| 489 | + if($file=='') { |
|
| 490 | + $file=str_replace(' ','',$family).strtolower($style).'.php'; |
|
| 491 | + } |
|
| 492 | + if($family=='arial') { |
|
| 493 | + $family='helvetica'; |
|
| 494 | + } |
|
| 467 | 495 | $style=strtoupper($style); |
| 468 | - if($style=='IB') |
|
| 469 | - $style='BI'; |
|
| 496 | + if($style=='IB') { |
|
| 497 | + $style='BI'; |
|
| 498 | + } |
|
| 470 | 499 | $fontkey=$family.$style; |
| 471 | - if(isset($this->fonts[$fontkey])) |
|
| 472 | - return; |
|
| 500 | + if(isset($this->fonts[$fontkey])) { |
|
| 501 | + return; |
|
| 502 | + } |
|
| 473 | 503 | include($this->_getfontpath().$file); |
| 474 | - if(!isset($name)) |
|
| 475 | - $this->Error('Could not include font definition file'); |
|
| 504 | + if(!isset($name)) { |
|
| 505 | + $this->Error('Could not include font definition file'); |
|
| 506 | + } |
|
| 476 | 507 | $i=count($this->fonts)+1; |
| 477 | 508 | $this->fonts[$fontkey]=array('i'=>$i, 'type'=>$type, 'name'=>$name, 'desc'=>$desc, 'up'=>$up, 'ut'=>$ut, 'cw'=>$cw, 'enc'=>$enc, 'file'=>$file); |
| 478 | 509 | if($diff) |
@@ -497,10 +528,11 @@ discard block |
||
| 497 | 528 | } |
| 498 | 529 | if($file) |
| 499 | 530 | { |
| 500 | - if($type=='TrueType') |
|
| 501 | - $this->FontFiles[$file]=array('length1'=>$originalsize); |
|
| 502 | - else |
|
| 503 | - $this->FontFiles[$file]=array('length1'=>$size1, 'length2'=>$size2); |
|
| 531 | + if($type=='TrueType') { |
|
| 532 | + $this->FontFiles[$file]=array('length1'=>$originalsize); |
|
| 533 | + } else { |
|
| 534 | + $this->FontFiles[$file]=array('length1'=>$size1, 'length2'=>$size2); |
|
| 535 | + } |
|
| 504 | 536 | } |
| 505 | 537 | } |
| 506 | 538 | |
@@ -510,27 +542,32 @@ discard block |
||
| 510 | 542 | global $fpdf_charwidths; |
| 511 | 543 | |
| 512 | 544 | $family=strtolower($family); |
| 513 | - if($family=='') |
|
| 514 | - $family=$this->FontFamily; |
|
| 515 | - if($family=='arial') |
|
| 516 | - $family='helvetica'; |
|
| 517 | - elseif($family=='symbol' || $family=='zapfdingbats') |
|
| 518 | - $style=''; |
|
| 545 | + if($family=='') { |
|
| 546 | + $family=$this->FontFamily; |
|
| 547 | + } |
|
| 548 | + if($family=='arial') { |
|
| 549 | + $family='helvetica'; |
|
| 550 | + } elseif($family=='symbol' || $family=='zapfdingbats') { |
|
| 551 | + $style=''; |
|
| 552 | + } |
|
| 519 | 553 | $style=strtoupper($style); |
| 520 | 554 | if(strpos($style,'U')!==false) |
| 521 | 555 | { |
| 522 | 556 | $this->underline=true; |
| 523 | 557 | $style=str_replace('U','',$style); |
| 558 | + } else { |
|
| 559 | + $this->underline=false; |
|
| 560 | + } |
|
| 561 | + if($style=='IB') { |
|
| 562 | + $style='BI'; |
|
| 563 | + } |
|
| 564 | + if($size==0) { |
|
| 565 | + $size=$this->FontSizePt; |
|
| 524 | 566 | } |
| 525 | - else |
|
| 526 | - $this->underline=false; |
|
| 527 | - if($style=='IB') |
|
| 528 | - $style='BI'; |
|
| 529 | - if($size==0) |
|
| 530 | - $size=$this->FontSizePt; |
|
| 531 | 567 | //Test if font is already selected |
| 532 | - if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size) |
|
| 533 | - return; |
|
| 568 | + if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size) { |
|
| 569 | + return; |
|
| 570 | + } |
|
| 534 | 571 | //Test if used for the first time |
| 535 | 572 | $fontkey=$family.$style; |
| 536 | 573 | if(!isset($this->fonts[$fontkey])) |
@@ -542,19 +579,21 @@ discard block |
||
| 542 | 579 | { |
| 543 | 580 | //Load metric file |
| 544 | 581 | $file=$family; |
| 545 | - if($family=='times' || $family=='helvetica') |
|
| 546 | - $file.=strtolower($style); |
|
| 582 | + if($family=='times' || $family=='helvetica') { |
|
| 583 | + $file.=strtolower($style); |
|
| 584 | + } |
|
| 547 | 585 | include($this->_getfontpath().$file.'.php'); |
| 548 | - if(!isset($fpdf_charwidths[$fontkey])) |
|
| 549 | - $this->Error('Could not include font metric file'); |
|
| 586 | + if(!isset($fpdf_charwidths[$fontkey])) { |
|
| 587 | + $this->Error('Could not include font metric file'); |
|
| 588 | + } |
|
| 550 | 589 | } |
| 551 | 590 | $i=count($this->fonts)+1; |
| 552 | 591 | $name=$this->CoreFonts[$fontkey]; |
| 553 | 592 | $cw=$fpdf_charwidths[$fontkey]; |
| 554 | 593 | $this->fonts[$fontkey]=array('i'=>$i, 'type'=>'core', 'name'=>$name, 'up'=>-100, 'ut'=>50, 'cw'=>$cw); |
| 594 | + } else { |
|
| 595 | + $this->Error('Undefined font: '.$family.' '.$style); |
|
| 555 | 596 | } |
| 556 | - else |
|
| 557 | - $this->Error('Undefined font: '.$family.' '.$style); |
|
| 558 | 597 | } |
| 559 | 598 | //Select it |
| 560 | 599 | $this->FontFamily=$family; |
@@ -562,20 +601,23 @@ discard block |
||
| 562 | 601 | $this->FontSizePt=$size; |
| 563 | 602 | $this->FontSize=$size/$this->k; |
| 564 | 603 | $this->CurrentFont=&$this->fonts[$fontkey]; |
| 565 | - if($this->page>0) |
|
| 566 | - $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); |
|
| 567 | -} |
|
| 604 | + if($this->page>0) { |
|
| 605 | + $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); |
|
| 606 | + } |
|
| 607 | + } |
|
| 568 | 608 | |
| 569 | 609 | function SetFontSize($size) |
| 570 | 610 | { |
| 571 | 611 | //Set font size in points |
| 572 | - if($this->FontSizePt==$size) |
|
| 573 | - return; |
|
| 612 | + if($this->FontSizePt==$size) { |
|
| 613 | + return; |
|
| 614 | + } |
|
| 574 | 615 | $this->FontSizePt=$size; |
| 575 | 616 | $this->FontSize=$size/$this->k; |
| 576 | - if($this->page>0) |
|
| 577 | - $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); |
|
| 578 | -} |
|
| 617 | + if($this->page>0) { |
|
| 618 | + $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); |
|
| 619 | + } |
|
| 620 | + } |
|
| 579 | 621 | |
| 580 | 622 | function AddLink() |
| 581 | 623 | { |
@@ -588,10 +630,12 @@ discard block |
||
| 588 | 630 | function SetLink($link, $y=0, $page=-1) |
| 589 | 631 | { |
| 590 | 632 | //Set destination of internal link |
| 591 | - if($y==-1) |
|
| 592 | - $y=$this->y; |
|
| 593 | - if($page==-1) |
|
| 594 | - $page=$this->page; |
|
| 633 | + if($y==-1) { |
|
| 634 | + $y=$this->y; |
|
| 635 | + } |
|
| 636 | + if($page==-1) { |
|
| 637 | + $page=$this->page; |
|
| 638 | + } |
|
| 595 | 639 | $this->links[$link]=array($page, $y); |
| 596 | 640 | } |
| 597 | 641 | |
@@ -605,10 +649,12 @@ discard block |
||
| 605 | 649 | { |
| 606 | 650 | //Output a string |
| 607 | 651 | $s=sprintf('BT %.2F %.2F Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt)); |
| 608 | - if($this->underline && $txt!='') |
|
| 609 | - $s.=' '.$this->_dounderline($x,$y,$txt); |
|
| 610 | - if($this->ColorFlag) |
|
| 611 | - $s='q '.$this->TextColor.' '.$s.' Q'; |
|
| 652 | + if($this->underline && $txt!='') { |
|
| 653 | + $s.=' '.$this->_dounderline($x,$y,$txt); |
|
| 654 | + } |
|
| 655 | + if($this->ColorFlag) { |
|
| 656 | + $s='q '.$this->TextColor.' '.$s.' Q'; |
|
| 657 | + } |
|
| 612 | 658 | $this->_out($s); |
| 613 | 659 | } |
| 614 | 660 | |
@@ -640,74 +686,89 @@ discard block |
||
| 640 | 686 | $this->_out(sprintf('%.3F Tw',$ws*$k)); |
| 641 | 687 | } |
| 642 | 688 | } |
| 643 | - if($w==0) |
|
| 644 | - $w=$this->w-$this->rMargin-$this->x; |
|
| 689 | + if($w==0) { |
|
| 690 | + $w=$this->w-$this->rMargin-$this->x; |
|
| 691 | + } |
|
| 645 | 692 | $s=''; |
| 646 | 693 | if($fill || $border==1) |
| 647 | 694 | { |
| 648 | - if($fill) |
|
| 649 | - $op=($border==1) ? 'B' : 'f'; |
|
| 650 | - else |
|
| 651 | - $op='S'; |
|
| 695 | + if($fill) { |
|
| 696 | + $op=($border==1) ? 'B' : 'f'; |
|
| 697 | + } else { |
|
| 698 | + $op='S'; |
|
| 699 | + } |
|
| 652 | 700 | $s=sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op); |
| 653 | 701 | } |
| 654 | 702 | if(is_string($border)) |
| 655 | 703 | { |
| 656 | 704 | $x=$this->x; |
| 657 | 705 | $y=$this->y; |
| 658 | - if(strpos($border,'L')!==false) |
|
| 659 | - $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k); |
|
| 660 | - if(strpos($border,'T')!==false) |
|
| 661 | - $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k); |
|
| 662 | - if(strpos($border,'R')!==false) |
|
| 663 | - $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k); |
|
| 664 | - if(strpos($border,'B')!==false) |
|
| 665 | - $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k); |
|
| 706 | + if(strpos($border,'L')!==false) { |
|
| 707 | + $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k); |
|
| 708 | + } |
|
| 709 | + if(strpos($border,'T')!==false) { |
|
| 710 | + $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k); |
|
| 711 | + } |
|
| 712 | + if(strpos($border,'R')!==false) { |
|
| 713 | + $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k); |
|
| 714 | + } |
|
| 715 | + if(strpos($border,'B')!==false) { |
|
| 716 | + $s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k); |
|
| 717 | + } |
|
| 666 | 718 | } |
| 667 | 719 | if($txt!=='') |
| 668 | 720 | { |
| 669 | - if($align=='R') |
|
| 670 | - $dx=$w-$this->cMargin-$this->GetStringWidth($txt); |
|
| 671 | - elseif($align=='C') |
|
| 672 | - $dx=($w-$this->GetStringWidth($txt))/2; |
|
| 673 | - else |
|
| 674 | - $dx=$this->cMargin; |
|
| 675 | - if($this->ColorFlag) |
|
| 676 | - $s.='q '.$this->TextColor.' '; |
|
| 721 | + if($align=='R') { |
|
| 722 | + $dx=$w-$this->cMargin-$this->GetStringWidth($txt); |
|
| 723 | + } elseif($align=='C') { |
|
| 724 | + $dx=($w-$this->GetStringWidth($txt))/2; |
|
| 725 | + } else { |
|
| 726 | + $dx=$this->cMargin; |
|
| 727 | + } |
|
| 728 | + if($this->ColorFlag) { |
|
| 729 | + $s.='q '.$this->TextColor.' '; |
|
| 730 | + } |
|
| 677 | 731 | $txt2=str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$txt))); |
| 678 | 732 | $s.=sprintf('BT %.2F %.2F Td (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$txt2); |
| 679 | - if($this->underline) |
|
| 680 | - $s.=' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt); |
|
| 681 | - if($this->ColorFlag) |
|
| 682 | - $s.=' Q'; |
|
| 683 | - if($link) |
|
| 684 | - $this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link); |
|
| 685 | - } |
|
| 686 | - if($s) |
|
| 687 | - $this->_out($s); |
|
| 733 | + if($this->underline) { |
|
| 734 | + $s.=' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt); |
|
| 735 | + } |
|
| 736 | + if($this->ColorFlag) { |
|
| 737 | + $s.=' Q'; |
|
| 738 | + } |
|
| 739 | + if($link) { |
|
| 740 | + $this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link); |
|
| 741 | + } |
|
| 742 | + } |
|
| 743 | + if($s) { |
|
| 744 | + $this->_out($s); |
|
| 745 | + } |
|
| 688 | 746 | $this->lasth=$h; |
| 689 | 747 | if($ln>0) |
| 690 | 748 | { |
| 691 | 749 | //Go to next line |
| 692 | 750 | $this->y+=$h; |
| 693 | - if($ln==1) |
|
| 694 | - $this->x=$this->lMargin; |
|
| 751 | + if($ln==1) { |
|
| 752 | + $this->x=$this->lMargin; |
|
| 753 | + } |
|
| 754 | + } else { |
|
| 755 | + $this->x+=$w; |
|
| 756 | + } |
|
| 695 | 757 | } |
| 696 | - else |
|
| 697 | - $this->x+=$w; |
|
| 698 | -} |
|
| 699 | 758 | |
| 700 | 759 | function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false) |
| 701 | 760 | { |
| 702 | 761 | //Output text with automatic or explicit line breaks |
| 703 | 762 | $cw=&$this->CurrentFont['cw']; |
| 704 | - if($w==0) |
|
| 705 | - $w=$this->w-$this->rMargin-$this->x; |
|
| 763 | + if($w==0) { |
|
| 764 | + $w=$this->w-$this->rMargin-$this->x; |
|
| 765 | + } |
|
| 706 | 766 | $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
| 707 | 767 | $s=str_replace("\r",'',$txt); |
| 708 | 768 | $nb=strlen($s); |
| 709 | - if($nb>0 && $s[$nb-1]=="\n") |
|
| 710 | - $nb--; |
|
| 769 | + if($nb>0 && $s[$nb-1]=="\n") { |
|
| 770 | + $nb--; |
|
| 771 | + } |
|
| 711 | 772 | $b=0; |
| 712 | 773 | if($border) |
| 713 | 774 | { |
@@ -716,14 +777,15 @@ discard block |
||
| 716 | 777 | $border='LTRB'; |
| 717 | 778 | $b='LRT'; |
| 718 | 779 | $b2='LR'; |
| 719 | - } |
|
| 720 | - else |
|
| 780 | + } else |
|
| 721 | 781 | { |
| 722 | 782 | $b2=''; |
| 723 | - if(strpos($border,'L')!==false) |
|
| 724 | - $b2.='L'; |
|
| 725 | - if(strpos($border,'R')!==false) |
|
| 726 | - $b2.='R'; |
|
| 783 | + if(strpos($border,'L')!==false) { |
|
| 784 | + $b2.='L'; |
|
| 785 | + } |
|
| 786 | + if(strpos($border,'R')!==false) { |
|
| 787 | + $b2.='R'; |
|
| 788 | + } |
|
| 727 | 789 | $b=(strpos($border,'T')!==false) ? $b2.'T' : $b2; |
| 728 | 790 | } |
| 729 | 791 | } |
@@ -752,8 +814,9 @@ discard block |
||
| 752 | 814 | $l=0; |
| 753 | 815 | $ns=0; |
| 754 | 816 | $nl++; |
| 755 | - if($border && $nl==2) |
|
| 756 | - $b=$b2; |
|
| 817 | + if($border && $nl==2) { |
|
| 818 | + $b=$b2; |
|
| 819 | + } |
|
| 757 | 820 | continue; |
| 758 | 821 | } |
| 759 | 822 | if($c==' ') |
@@ -768,16 +831,16 @@ discard block |
||
| 768 | 831 | //Automatic line break |
| 769 | 832 | if($sep==-1) |
| 770 | 833 | { |
| 771 | - if($i==$j) |
|
| 772 | - $i++; |
|
| 834 | + if($i==$j) { |
|
| 835 | + $i++; |
|
| 836 | + } |
|
| 773 | 837 | if($this->ws>0) |
| 774 | 838 | { |
| 775 | 839 | $this->ws=0; |
| 776 | 840 | $this->_out('0 Tw'); |
| 777 | 841 | } |
| 778 | 842 | $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); |
| 779 | - } |
|
| 780 | - else |
|
| 843 | + } else |
|
| 781 | 844 | { |
| 782 | 845 | if($align=='J') |
| 783 | 846 | { |
@@ -792,11 +855,12 @@ discard block |
||
| 792 | 855 | $l=0; |
| 793 | 856 | $ns=0; |
| 794 | 857 | $nl++; |
| 795 | - if($border && $nl==2) |
|
| 796 | - $b=$b2; |
|
| 858 | + if($border && $nl==2) { |
|
| 859 | + $b=$b2; |
|
| 860 | + } |
|
| 861 | + } else { |
|
| 862 | + $i++; |
|
| 797 | 863 | } |
| 798 | - else |
|
| 799 | - $i++; |
|
| 800 | 864 | } |
| 801 | 865 | //Last chunk |
| 802 | 866 | if($this->ws>0) |
@@ -804,8 +868,9 @@ discard block |
||
| 804 | 868 | $this->ws=0; |
| 805 | 869 | $this->_out('0 Tw'); |
| 806 | 870 | } |
| 807 | - if($border && strpos($border,'B')!==false) |
|
| 808 | - $b.='B'; |
|
| 871 | + if($border && strpos($border,'B')!==false) { |
|
| 872 | + $b.='B'; |
|
| 873 | + } |
|
| 809 | 874 | $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); |
| 810 | 875 | $this->x=$this->lMargin; |
| 811 | 876 | } |
@@ -844,8 +909,9 @@ discard block |
||
| 844 | 909 | $nl++; |
| 845 | 910 | continue; |
| 846 | 911 | } |
| 847 | - if($c==' ') |
|
| 848 | - $sep=$i; |
|
| 912 | + if($c==' ') { |
|
| 913 | + $sep=$i; |
|
| 914 | + } |
|
| 849 | 915 | $l+=$cw[$c]; |
| 850 | 916 | if($l>$wmax) |
| 851 | 917 | { |
@@ -863,11 +929,11 @@ discard block |
||
| 863 | 929 | $nl++; |
| 864 | 930 | continue; |
| 865 | 931 | } |
| 866 | - if($i==$j) |
|
| 867 | - $i++; |
|
| 932 | + if($i==$j) { |
|
| 933 | + $i++; |
|
| 934 | + } |
|
| 868 | 935 | $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link); |
| 869 | - } |
|
| 870 | - else |
|
| 936 | + } else |
|
| 871 | 937 | { |
| 872 | 938 | $this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',0,$link); |
| 873 | 939 | $i=$sep+1; |
@@ -882,24 +948,26 @@ discard block |
||
| 882 | 948 | $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; |
| 883 | 949 | } |
| 884 | 950 | $nl++; |
| 951 | + } else { |
|
| 952 | + $i++; |
|
| 885 | 953 | } |
| 886 | - else |
|
| 887 | - $i++; |
|
| 888 | 954 | } |
| 889 | 955 | //Last chunk |
| 890 | - if($i!=$j) |
|
| 891 | - $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',0,$link); |
|
| 892 | -} |
|
| 956 | + if($i!=$j) { |
|
| 957 | + $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',0,$link); |
|
| 958 | + } |
|
| 959 | + } |
|
| 893 | 960 | |
| 894 | 961 | function Ln($h=null) |
| 895 | 962 | { |
| 896 | 963 | //Line feed; default value is last cell height |
| 897 | 964 | $this->x=$this->lMargin; |
| 898 | - if($h===null) |
|
| 899 | - $this->y+=$this->lasth; |
|
| 900 | - else |
|
| 901 | - $this->y+=$h; |
|
| 902 | -} |
|
| 965 | + if($h===null) { |
|
| 966 | + $this->y+=$this->lasth; |
|
| 967 | + } else { |
|
| 968 | + $this->y+=$h; |
|
| 969 | + } |
|
| 970 | + } |
|
| 903 | 971 | |
| 904 | 972 | function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='') |
| 905 | 973 | { |
@@ -910,33 +978,36 @@ discard block |
||
| 910 | 978 | if($type=='') |
| 911 | 979 | { |
| 912 | 980 | $pos=strrpos($file,'.'); |
| 913 | - if(!$pos) |
|
| 914 | - $this->Error('Image file has no extension and no type was specified: '.$file); |
|
| 981 | + if(!$pos) { |
|
| 982 | + $this->Error('Image file has no extension and no type was specified: '.$file); |
|
| 983 | + } |
|
| 915 | 984 | $type=substr($file,$pos+1); |
| 916 | 985 | } |
| 917 | 986 | $type=strtolower($type); |
| 918 | - if($type=='jpeg') |
|
| 919 | - $type='jpg'; |
|
| 987 | + if($type=='jpeg') { |
|
| 988 | + $type='jpg'; |
|
| 989 | + } |
|
| 920 | 990 | $mtd='_parse'.$type; |
| 921 | - if(!method_exists($this,$mtd)) |
|
| 922 | - $this->Error('Unsupported image type: '.$type); |
|
| 991 | + if(!method_exists($this,$mtd)) { |
|
| 992 | + $this->Error('Unsupported image type: '.$type); |
|
| 993 | + } |
|
| 923 | 994 | $info=$this->$mtd($file); |
| 924 | 995 | $info['i']=count($this->images)+1; |
| 925 | 996 | $this->images[$file]=$info; |
| 997 | + } else { |
|
| 998 | + $info=$this->images[$file]; |
|
| 926 | 999 | } |
| 927 | - else |
|
| 928 | - $info=$this->images[$file]; |
|
| 929 | 1000 | //Automatic width and height calculation if needed |
| 930 | 1001 | if($w==0 && $h==0) |
| 931 | 1002 | { |
| 932 | 1003 | //Put image at 72 dpi |
| 933 | 1004 | $w=$info['w']/$this->k; |
| 934 | 1005 | $h=$info['h']/$this->k; |
| 1006 | + } elseif($w==0) { |
|
| 1007 | + $w=$h*$info['w']/$info['h']; |
|
| 1008 | + } elseif($h==0) { |
|
| 1009 | + $h=$w*$info['h']/$info['w']; |
|
| 935 | 1010 | } |
| 936 | - elseif($w==0) |
|
| 937 | - $w=$h*$info['w']/$info['h']; |
|
| 938 | - elseif($h==0) |
|
| 939 | - $h=$w*$info['h']/$info['w']; |
|
| 940 | 1011 | //Flowing mode |
| 941 | 1012 | if($y===null) |
| 942 | 1013 | { |
@@ -950,12 +1021,14 @@ discard block |
||
| 950 | 1021 | $y=$this->y; |
| 951 | 1022 | $this->y+=$h; |
| 952 | 1023 | } |
| 953 | - if($x===null) |
|
| 954 | - $x=$this->x; |
|
| 1024 | + if($x===null) { |
|
| 1025 | + $x=$this->x; |
|
| 1026 | + } |
|
| 955 | 1027 | $this->_out(sprintf('q %.2F 0 0 %.2F %.2F %.2F cm /I%d Do Q',$w*$this->k,$h*$this->k,$x*$this->k,($this->h-($y+$h))*$this->k,$info['i'])); |
| 956 | - if($link) |
|
| 957 | - $this->Link($x,$y,$w,$h,$link); |
|
| 958 | -} |
|
| 1028 | + if($link) { |
|
| 1029 | + $this->Link($x,$y,$w,$h,$link); |
|
| 1030 | + } |
|
| 1031 | + } |
|
| 959 | 1032 | |
| 960 | 1033 | function GetX() |
| 961 | 1034 | { |
@@ -966,11 +1039,12 @@ discard block |
||
| 966 | 1039 | function SetX($x) |
| 967 | 1040 | { |
| 968 | 1041 | //Set x position |
| 969 | - if($x>=0) |
|
| 970 | - $this->x=$x; |
|
| 971 | - else |
|
| 972 | - $this->x=$this->w+$x; |
|
| 973 | -} |
|
| 1042 | + if($x>=0) { |
|
| 1043 | + $this->x=$x; |
|
| 1044 | + } else { |
|
| 1045 | + $this->x=$this->w+$x; |
|
| 1046 | + } |
|
| 1047 | + } |
|
| 974 | 1048 | |
| 975 | 1049 | function GetY() |
| 976 | 1050 | { |
@@ -982,11 +1056,12 @@ discard block |
||
| 982 | 1056 | { |
| 983 | 1057 | //Set y position and reset x |
| 984 | 1058 | $this->x=$this->lMargin; |
| 985 | - if($y>=0) |
|
| 986 | - $this->y=$y; |
|
| 987 | - else |
|
| 988 | - $this->y=$this->h+$y; |
|
| 989 | -} |
|
| 1059 | + if($y>=0) { |
|
| 1060 | + $this->y=$y; |
|
| 1061 | + } else { |
|
| 1062 | + $this->y=$this->h+$y; |
|
| 1063 | + } |
|
| 1064 | + } |
|
| 990 | 1065 | |
| 991 | 1066 | function SetXY($x, $y) |
| 992 | 1067 | { |
@@ -998,8 +1073,9 @@ discard block |
||
| 998 | 1073 | function Output($name='', $dest='') |
| 999 | 1074 | { |
| 1000 | 1075 | //Output PDF to some destination |
| 1001 | - if($this->state<3) |
|
| 1002 | - $this->Close(); |
|
| 1076 | + if($this->state<3) { |
|
| 1077 | + $this->Close(); |
|
| 1078 | + } |
|
| 1003 | 1079 | $dest=strtoupper($dest); |
| 1004 | 1080 | if($dest=='') |
| 1005 | 1081 | { |
@@ -1007,22 +1083,24 @@ discard block |
||
| 1007 | 1083 | { |
| 1008 | 1084 | $name='doc.pdf'; |
| 1009 | 1085 | $dest='I'; |
| 1086 | + } else { |
|
| 1087 | + $dest='F'; |
|
| 1010 | 1088 | } |
| 1011 | - else |
|
| 1012 | - $dest='F'; |
|
| 1013 | 1089 | } |
| 1014 | 1090 | switch($dest) |
| 1015 | 1091 | { |
| 1016 | 1092 | case 'I': |
| 1017 | 1093 | //Send to standard output |
| 1018 | - if(ob_get_length()) |
|
| 1019 | - $this->Error('Some data has already been output, can\'t send PDF file'); |
|
| 1094 | + if(ob_get_length()) { |
|
| 1095 | + $this->Error('Some data has already been output, can\'t send PDF file'); |
|
| 1096 | + } |
|
| 1020 | 1097 | if(php_sapi_name()!='cli') |
| 1021 | 1098 | { |
| 1022 | 1099 | //We send to a browser |
| 1023 | 1100 | header('Content-Type: application/pdf'); |
| 1024 | - if(headers_sent()) |
|
| 1025 | - $this->Error('Some data has already been output, can\'t send PDF file'); |
|
| 1101 | + if(headers_sent()) { |
|
| 1102 | + $this->Error('Some data has already been output, can\'t send PDF file'); |
|
| 1103 | + } |
|
| 1026 | 1104 | header('Content-Length: '.strlen($this->buffer)); |
| 1027 | 1105 | header('Content-Disposition: inline; filename="'.$name.'"'); |
| 1028 | 1106 | header('Cache-Control: private, max-age=0, must-revalidate'); |
@@ -1033,11 +1111,13 @@ discard block |
||
| 1033 | 1111 | break; |
| 1034 | 1112 | case 'D': |
| 1035 | 1113 | //Download file |
| 1036 | - if(ob_get_length()) |
|
| 1037 | - $this->Error('Some data has already been output, can\'t send PDF file'); |
|
| 1114 | + if(ob_get_length()) { |
|
| 1115 | + $this->Error('Some data has already been output, can\'t send PDF file'); |
|
| 1116 | + } |
|
| 1038 | 1117 | header('Content-Type: application/x-download'); |
| 1039 | - if(headers_sent()) |
|
| 1040 | - $this->Error('Some data has already been output, can\'t send PDF file'); |
|
| 1118 | + if(headers_sent()) { |
|
| 1119 | + $this->Error('Some data has already been output, can\'t send PDF file'); |
|
| 1120 | + } |
|
| 1041 | 1121 | header('Content-Length: '.strlen($this->buffer)); |
| 1042 | 1122 | header('Content-Disposition: attachment; filename="'.$name.'"'); |
| 1043 | 1123 | header('Cache-Control: private, max-age=0, must-revalidate'); |
@@ -1048,8 +1128,9 @@ discard block |
||
| 1048 | 1128 | case 'F': |
| 1049 | 1129 | //Save to local file |
| 1050 | 1130 | $f=fopen($name,'wb'); |
| 1051 | - if(!$f) |
|
| 1052 | - $this->Error('Unable to create output file: '.$name); |
|
| 1131 | + if(!$f) { |
|
| 1132 | + $this->Error('Unable to create output file: '.$name); |
|
| 1133 | + } |
|
| 1053 | 1134 | fwrite($f,$this->buffer,strlen($this->buffer)); |
| 1054 | 1135 | fclose($f); |
| 1055 | 1136 | break; |
@@ -1070,29 +1151,34 @@ discard block |
||
| 1070 | 1151 | function _dochecks() |
| 1071 | 1152 | { |
| 1072 | 1153 | //Check availability of %F |
| 1073 | - if(sprintf('%.1F',1.0)!='1.0') |
|
| 1074 | - $this->Error('This version of PHP is not supported'); |
|
| 1154 | + if(sprintf('%.1F',1.0)!='1.0') { |
|
| 1155 | + $this->Error('This version of PHP is not supported'); |
|
| 1156 | + } |
|
| 1075 | 1157 | //Check mbstring overloading |
| 1076 | - if(ini_get('mbstring.func_overload') & 2) |
|
| 1077 | - $this->Error('mbstring overloading must be disabled'); |
|
| 1158 | + if(ini_get('mbstring.func_overload') & 2) { |
|
| 1159 | + $this->Error('mbstring overloading must be disabled'); |
|
| 1160 | + } |
|
| 1078 | 1161 | //Disable runtime magic quotes |
| 1079 | - if(get_magic_quotes_runtime()) |
|
| 1080 | - @set_magic_quotes_runtime(0); |
|
| 1081 | -} |
|
| 1162 | + if(get_magic_quotes_runtime()) { |
|
| 1163 | + @set_magic_quotes_runtime(0); |
|
| 1164 | + } |
|
| 1165 | + } |
|
| 1082 | 1166 | |
| 1083 | 1167 | function _getpageformat($format) |
| 1084 | 1168 | { |
| 1085 | 1169 | $format=strtolower($format); |
| 1086 | - if(!isset($this->PageFormats[$format])) |
|
| 1087 | - $this->Error('Unknown page format: '.$format); |
|
| 1170 | + if(!isset($this->PageFormats[$format])) { |
|
| 1171 | + $this->Error('Unknown page format: '.$format); |
|
| 1172 | + } |
|
| 1088 | 1173 | $a=$this->PageFormats[$format]; |
| 1089 | 1174 | return array($a[0]/$this->k, $a[1]/$this->k); |
| 1090 | 1175 | } |
| 1091 | 1176 | |
| 1092 | 1177 | function _getfontpath() |
| 1093 | 1178 | { |
| 1094 | - if(!defined('FPDF_FONTPATH') && is_dir(dirname(__FILE__).'/font')) |
|
| 1095 | - define('FPDF_FONTPATH',dirname(__FILE__).'/font/'); |
|
| 1179 | + if(!defined('FPDF_FONTPATH') && is_dir(dirname(__FILE__).'/font')) { |
|
| 1180 | + define('FPDF_FONTPATH',dirname(__FILE__).'/font/'); |
|
| 1181 | + } |
|
| 1096 | 1182 | return defined('FPDF_FONTPATH') ? FPDF_FONTPATH : ''; |
| 1097 | 1183 | } |
| 1098 | 1184 | |
@@ -1105,16 +1191,18 @@ discard block |
||
| 1105 | 1191 | $this->y=$this->tMargin; |
| 1106 | 1192 | $this->FontFamily=''; |
| 1107 | 1193 | //Check page size |
| 1108 | - if($orientation=='') |
|
| 1109 | - $orientation=$this->DefOrientation; |
|
| 1110 | - else |
|
| 1111 | - $orientation=strtoupper($orientation[0]); |
|
| 1112 | - if($format=='') |
|
| 1113 | - $format=$this->DefPageFormat; |
|
| 1114 | - else |
|
| 1194 | + if($orientation=='') { |
|
| 1195 | + $orientation=$this->DefOrientation; |
|
| 1196 | + } else { |
|
| 1197 | + $orientation=strtoupper($orientation[0]); |
|
| 1198 | + } |
|
| 1199 | + if($format=='') { |
|
| 1200 | + $format=$this->DefPageFormat; |
|
| 1201 | + } else |
|
| 1115 | 1202 | { |
| 1116 | - if(is_string($format)) |
|
| 1117 | - $format=$this->_getpageformat($format); |
|
| 1203 | + if(is_string($format)) { |
|
| 1204 | + $format=$this->_getpageformat($format); |
|
| 1205 | + } |
|
| 1118 | 1206 | } |
| 1119 | 1207 | if($orientation!=$this->CurOrientation || $format[0]!=$this->CurPageFormat[0] || $format[1]!=$this->CurPageFormat[1]) |
| 1120 | 1208 | { |
@@ -1123,8 +1211,7 @@ discard block |
||
| 1123 | 1211 | { |
| 1124 | 1212 | $this->w=$format[0]; |
| 1125 | 1213 | $this->h=$format[1]; |
| 1126 | - } |
|
| 1127 | - else |
|
| 1214 | + } else |
|
| 1128 | 1215 | { |
| 1129 | 1216 | $this->w=$format[1]; |
| 1130 | 1217 | $this->h=$format[0]; |
@@ -1135,9 +1222,10 @@ discard block |
||
| 1135 | 1222 | $this->CurOrientation=$orientation; |
| 1136 | 1223 | $this->CurPageFormat=$format; |
| 1137 | 1224 | } |
| 1138 | - if($orientation!=$this->DefOrientation || $format[0]!=$this->DefPageFormat[0] || $format[1]!=$this->DefPageFormat[1]) |
|
| 1139 | - $this->PageSizes[$this->page]=array($this->wPt, $this->hPt); |
|
| 1140 | -} |
|
| 1225 | + if($orientation!=$this->DefOrientation || $format[0]!=$this->DefPageFormat[0] || $format[1]!=$this->DefPageFormat[1]) { |
|
| 1226 | + $this->PageSizes[$this->page]=array($this->wPt, $this->hPt); |
|
| 1227 | + } |
|
| 1228 | + } |
|
| 1141 | 1229 | |
| 1142 | 1230 | function _endpage() |
| 1143 | 1231 | { |
@@ -1176,15 +1264,13 @@ discard block |
||
| 1176 | 1264 | $c3=ord($s[$i++]); |
| 1177 | 1265 | $res.=chr((($c1 & 0x0F)<<4) + (($c2 & 0x3C)>>2)); |
| 1178 | 1266 | $res.=chr((($c2 & 0x03)<<6) + ($c3 & 0x3F)); |
| 1179 | - } |
|
| 1180 | - elseif($c1>=192) |
|
| 1267 | + } elseif($c1>=192) |
|
| 1181 | 1268 | { |
| 1182 | 1269 | //2-byte character |
| 1183 | 1270 | $c2=ord($s[$i++]); |
| 1184 | 1271 | $res.=chr(($c1 & 0x1C)>>2); |
| 1185 | 1272 | $res.=chr((($c1 & 0x03)<<6) + ($c2 & 0x3F)); |
| 1186 | - } |
|
| 1187 | - else |
|
| 1273 | + } else |
|
| 1188 | 1274 | { |
| 1189 | 1275 | //Single-byte character |
| 1190 | 1276 | $res.="\0".chr($c1); |
@@ -1206,22 +1292,26 @@ discard block |
||
| 1206 | 1292 | { |
| 1207 | 1293 | //Extract info from a JPEG file |
| 1208 | 1294 | $a=GetImageSize($file); |
| 1209 | - if(!$a) |
|
| 1210 | - $this->Error('Missing or incorrect image file: '.$file); |
|
| 1211 | - if($a[2]!=2) |
|
| 1212 | - $this->Error('Not a JPEG file: '.$file); |
|
| 1213 | - if(!isset($a['channels']) || $a['channels']==3) |
|
| 1214 | - $colspace='DeviceRGB'; |
|
| 1215 | - elseif($a['channels']==4) |
|
| 1216 | - $colspace='DeviceCMYK'; |
|
| 1217 | - else |
|
| 1218 | - $colspace='DeviceGray'; |
|
| 1295 | + if(!$a) { |
|
| 1296 | + $this->Error('Missing or incorrect image file: '.$file); |
|
| 1297 | + } |
|
| 1298 | + if($a[2]!=2) { |
|
| 1299 | + $this->Error('Not a JPEG file: '.$file); |
|
| 1300 | + } |
|
| 1301 | + if(!isset($a['channels']) || $a['channels']==3) { |
|
| 1302 | + $colspace='DeviceRGB'; |
|
| 1303 | + } elseif($a['channels']==4) { |
|
| 1304 | + $colspace='DeviceCMYK'; |
|
| 1305 | + } else { |
|
| 1306 | + $colspace='DeviceGray'; |
|
| 1307 | + } |
|
| 1219 | 1308 | $bpc=isset($a['bits']) ? $a['bits'] : 8; |
| 1220 | 1309 | //Read whole file |
| 1221 | 1310 | $f=fopen($file,'rb'); |
| 1222 | 1311 | $data=''; |
| 1223 | - while(!feof($f)) |
|
| 1224 | - $data.=fread($f,8192); |
|
| 1312 | + while(!feof($f)) { |
|
| 1313 | + $data.=fread($f,8192); |
|
| 1314 | + } |
|
| 1225 | 1315 | fclose($f); |
| 1226 | 1316 | return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data); |
| 1227 | 1317 | } |
@@ -1230,35 +1320,43 @@ discard block |
||
| 1230 | 1320 | { |
| 1231 | 1321 | //Extract info from a PNG file |
| 1232 | 1322 | $f=fopen($file,'rb'); |
| 1233 | - if(!$f) |
|
| 1234 | - $this->Error('Can\'t open image file: '.$file); |
|
| 1323 | + if(!$f) { |
|
| 1324 | + $this->Error('Can\'t open image file: '.$file); |
|
| 1325 | + } |
|
| 1235 | 1326 | //Check signature |
| 1236 | - if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) |
|
| 1237 | - $this->Error('Not a PNG file: '.$file); |
|
| 1327 | + if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) { |
|
| 1328 | + $this->Error('Not a PNG file: '.$file); |
|
| 1329 | + } |
|
| 1238 | 1330 | //Read header chunk |
| 1239 | 1331 | $this->_readstream($f,4); |
| 1240 | - if($this->_readstream($f,4)!='IHDR') |
|
| 1241 | - $this->Error('Incorrect PNG file: '.$file); |
|
| 1332 | + if($this->_readstream($f,4)!='IHDR') { |
|
| 1333 | + $this->Error('Incorrect PNG file: '.$file); |
|
| 1334 | + } |
|
| 1242 | 1335 | $w=$this->_readint($f); |
| 1243 | 1336 | $h=$this->_readint($f); |
| 1244 | 1337 | $bpc=ord($this->_readstream($f,1)); |
| 1245 | - if($bpc>8) |
|
| 1246 | - $this->Error('16-bit depth not supported: '.$file); |
|
| 1338 | + if($bpc>8) { |
|
| 1339 | + $this->Error('16-bit depth not supported: '.$file); |
|
| 1340 | + } |
|
| 1247 | 1341 | $ct=ord($this->_readstream($f,1)); |
| 1248 | - if($ct==0) |
|
| 1249 | - $colspace='DeviceGray'; |
|
| 1250 | - elseif($ct==2) |
|
| 1251 | - $colspace='DeviceRGB'; |
|
| 1252 | - elseif($ct==3) |
|
| 1253 | - $colspace='Indexed'; |
|
| 1254 | - else |
|
| 1255 | - $this->Error('Alpha channel not supported: '.$file); |
|
| 1256 | - if(ord($this->_readstream($f,1))!=0) |
|
| 1257 | - $this->Error('Unknown compression method: '.$file); |
|
| 1258 | - if(ord($this->_readstream($f,1))!=0) |
|
| 1259 | - $this->Error('Unknown filter method: '.$file); |
|
| 1260 | - if(ord($this->_readstream($f,1))!=0) |
|
| 1261 | - $this->Error('Interlacing not supported: '.$file); |
|
| 1342 | + if($ct==0) { |
|
| 1343 | + $colspace='DeviceGray'; |
|
| 1344 | + } elseif($ct==2) { |
|
| 1345 | + $colspace='DeviceRGB'; |
|
| 1346 | + } elseif($ct==3) { |
|
| 1347 | + $colspace='Indexed'; |
|
| 1348 | + } else { |
|
| 1349 | + $this->Error('Alpha channel not supported: '.$file); |
|
| 1350 | + } |
|
| 1351 | + if(ord($this->_readstream($f,1))!=0) { |
|
| 1352 | + $this->Error('Unknown compression method: '.$file); |
|
| 1353 | + } |
|
| 1354 | + if(ord($this->_readstream($f,1))!=0) { |
|
| 1355 | + $this->Error('Unknown filter method: '.$file); |
|
| 1356 | + } |
|
| 1357 | + if(ord($this->_readstream($f,1))!=0) { |
|
| 1358 | + $this->Error('Interlacing not supported: '.$file); |
|
| 1359 | + } |
|
| 1262 | 1360 | $this->_readstream($f,4); |
| 1263 | 1361 | $parms='/DecodeParms <</Predictor 15 /Colors '.($ct==2 ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w.'>>'; |
| 1264 | 1362 | //Scan chunks looking for palette, transparency and image data |
@@ -1274,37 +1372,37 @@ discard block |
||
| 1274 | 1372 | //Read palette |
| 1275 | 1373 | $pal=$this->_readstream($f,$n); |
| 1276 | 1374 | $this->_readstream($f,4); |
| 1277 | - } |
|
| 1278 | - elseif($type=='tRNS') |
|
| 1375 | + } elseif($type=='tRNS') |
|
| 1279 | 1376 | { |
| 1280 | 1377 | //Read transparency info |
| 1281 | 1378 | $t=$this->_readstream($f,$n); |
| 1282 | - if($ct==0) |
|
| 1283 | - $trns=array(ord(substr($t,1,1))); |
|
| 1284 | - elseif($ct==2) |
|
| 1285 | - $trns=array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1))); |
|
| 1286 | - else |
|
| 1379 | + if($ct==0) { |
|
| 1380 | + $trns=array(ord(substr($t,1,1))); |
|
| 1381 | + } elseif($ct==2) { |
|
| 1382 | + $trns=array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1))); |
|
| 1383 | + } else |
|
| 1287 | 1384 | { |
| 1288 | 1385 | $pos=strpos($t,chr(0)); |
| 1289 | - if($pos!==false) |
|
| 1290 | - $trns=array($pos); |
|
| 1386 | + if($pos!==false) { |
|
| 1387 | + $trns=array($pos); |
|
| 1388 | + } |
|
| 1291 | 1389 | } |
| 1292 | 1390 | $this->_readstream($f,4); |
| 1293 | - } |
|
| 1294 | - elseif($type=='IDAT') |
|
| 1391 | + } elseif($type=='IDAT') |
|
| 1295 | 1392 | { |
| 1296 | 1393 | //Read image data block |
| 1297 | 1394 | $data.=$this->_readstream($f,$n); |
| 1298 | 1395 | $this->_readstream($f,4); |
| 1396 | + } elseif($type=='IEND') { |
|
| 1397 | + break; |
|
| 1398 | + } else { |
|
| 1399 | + $this->_readstream($f,$n+4); |
|
| 1299 | 1400 | } |
| 1300 | - elseif($type=='IEND') |
|
| 1301 | - break; |
|
| 1302 | - else |
|
| 1303 | - $this->_readstream($f,$n+4); |
|
| 1304 | 1401 | } |
| 1305 | 1402 | while($n); |
| 1306 | - if($colspace=='Indexed' && empty($pal)) |
|
| 1307 | - $this->Error('Missing palette in '.$file); |
|
| 1403 | + if($colspace=='Indexed' && empty($pal)) { |
|
| 1404 | + $this->Error('Missing palette in '.$file); |
|
| 1405 | + } |
|
| 1308 | 1406 | fclose($f); |
| 1309 | 1407 | return array('w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'FlateDecode', 'parms'=>$parms, 'pal'=>$pal, 'trns'=>$trns, 'data'=>$data); |
| 1310 | 1408 | } |
@@ -1316,13 +1414,15 @@ discard block |
||
| 1316 | 1414 | while($n>0 && !feof($f)) |
| 1317 | 1415 | { |
| 1318 | 1416 | $s=fread($f,$n); |
| 1319 | - if($s===false) |
|
| 1320 | - $this->Error('Error while reading stream'); |
|
| 1417 | + if($s===false) { |
|
| 1418 | + $this->Error('Error while reading stream'); |
|
| 1419 | + } |
|
| 1321 | 1420 | $n-=strlen($s); |
| 1322 | 1421 | $res.=$s; |
| 1323 | 1422 | } |
| 1324 | - if($n>0) |
|
| 1325 | - $this->Error('Unexpected end of stream'); |
|
| 1423 | + if($n>0) { |
|
| 1424 | + $this->Error('Unexpected end of stream'); |
|
| 1425 | + } |
|
| 1326 | 1426 | return $res; |
| 1327 | 1427 | } |
| 1328 | 1428 | |
@@ -1336,19 +1436,24 @@ discard block |
||
| 1336 | 1436 | function _parsegif($file) |
| 1337 | 1437 | { |
| 1338 | 1438 | //Extract info from a GIF file (via PNG conversion) |
| 1339 | - if(!function_exists('imagepng')) |
|
| 1340 | - $this->Error('GD extension is required for GIF support'); |
|
| 1341 | - if(!function_exists('imagecreatefromgif')) |
|
| 1342 | - $this->Error('GD has no GIF read support'); |
|
| 1439 | + if(!function_exists('imagepng')) { |
|
| 1440 | + $this->Error('GD extension is required for GIF support'); |
|
| 1441 | + } |
|
| 1442 | + if(!function_exists('imagecreatefromgif')) { |
|
| 1443 | + $this->Error('GD has no GIF read support'); |
|
| 1444 | + } |
|
| 1343 | 1445 | $im=imagecreatefromgif($file); |
| 1344 | - if(!$im) |
|
| 1345 | - $this->Error('Missing or incorrect image file: '.$file); |
|
| 1446 | + if(!$im) { |
|
| 1447 | + $this->Error('Missing or incorrect image file: '.$file); |
|
| 1448 | + } |
|
| 1346 | 1449 | imageinterlace($im,0); |
| 1347 | 1450 | $tmp=tempnam('.','gif'); |
| 1348 | - if(!$tmp) |
|
| 1349 | - $this->Error('Unable to create a temporary file'); |
|
| 1350 | - if(!imagepng($im,$tmp)) |
|
| 1351 | - $this->Error('Error while saving to temporary file'); |
|
| 1451 | + if(!$tmp) { |
|
| 1452 | + $this->Error('Unable to create a temporary file'); |
|
| 1453 | + } |
|
| 1454 | + if(!imagepng($im,$tmp)) { |
|
| 1455 | + $this->Error('Error while saving to temporary file'); |
|
| 1456 | + } |
|
| 1352 | 1457 | imagedestroy($im); |
| 1353 | 1458 | $info=$this->_parsepng($tmp); |
| 1354 | 1459 | unlink($tmp); |
@@ -1373,11 +1478,12 @@ discard block |
||
| 1373 | 1478 | function _out($s) |
| 1374 | 1479 | { |
| 1375 | 1480 | //Add a line to the document |
| 1376 | - if($this->state==2) |
|
| 1377 | - $this->pages[$this->page].=$s."\n"; |
|
| 1378 | - else |
|
| 1379 | - $this->buffer.=$s."\n"; |
|
| 1380 | -} |
|
| 1481 | + if($this->state==2) { |
|
| 1482 | + $this->pages[$this->page].=$s."\n"; |
|
| 1483 | + } else { |
|
| 1484 | + $this->buffer.=$s."\n"; |
|
| 1485 | + } |
|
| 1486 | + } |
|
| 1381 | 1487 | |
| 1382 | 1488 | function _putpages() |
| 1383 | 1489 | { |
@@ -1385,15 +1491,15 @@ discard block |
||
| 1385 | 1491 | if(!empty($this->AliasNbPages)) |
| 1386 | 1492 | { |
| 1387 | 1493 | //Replace number of pages |
| 1388 | - for($n=1;$n<=$nb;$n++) |
|
| 1389 | - $this->pages[$n]=str_replace($this->AliasNbPages,$nb,$this->pages[$n]); |
|
| 1494 | + for($n=1;$n<=$nb;$n++) { |
|
| 1495 | + $this->pages[$n]=str_replace($this->AliasNbPages,$nb,$this->pages[$n]); |
|
| 1496 | + } |
|
| 1390 | 1497 | } |
| 1391 | 1498 | if($this->DefOrientation=='P') |
| 1392 | 1499 | { |
| 1393 | 1500 | $wPt=$this->DefPageFormat[0]*$this->k; |
| 1394 | 1501 | $hPt=$this->DefPageFormat[1]*$this->k; |
| 1395 | - } |
|
| 1396 | - else |
|
| 1502 | + } else |
|
| 1397 | 1503 | { |
| 1398 | 1504 | $wPt=$this->DefPageFormat[1]*$this->k; |
| 1399 | 1505 | $hPt=$this->DefPageFormat[0]*$this->k; |
@@ -1405,8 +1511,9 @@ discard block |
||
| 1405 | 1511 | $this->_newobj(); |
| 1406 | 1512 | $this->_out('<</Type /Page'); |
| 1407 | 1513 | $this->_out('/Parent 1 0 R'); |
| 1408 | - if(isset($this->PageSizes[$n])) |
|
| 1409 | - $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageSizes[$n][0],$this->PageSizes[$n][1])); |
|
| 1514 | + if(isset($this->PageSizes[$n])) { |
|
| 1515 | + $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageSizes[$n][0],$this->PageSizes[$n][1])); |
|
| 1516 | + } |
|
| 1410 | 1517 | $this->_out('/Resources 2 0 R'); |
| 1411 | 1518 | if(isset($this->PageLinks[$n])) |
| 1412 | 1519 | { |
@@ -1416,9 +1523,9 @@ discard block |
||
| 1416 | 1523 | { |
| 1417 | 1524 | $rect=sprintf('%.2F %.2F %.2F %.2F',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]); |
| 1418 | 1525 | $annots.='<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] '; |
| 1419 | - if(is_string($pl[4])) |
|
| 1420 | - $annots.='/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>'; |
|
| 1421 | - else |
|
| 1526 | + if(is_string($pl[4])) { |
|
| 1527 | + $annots.='/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>'; |
|
| 1528 | + } else |
|
| 1422 | 1529 | { |
| 1423 | 1530 | $l=$this->links[$pl[4]]; |
| 1424 | 1531 | $h=isset($this->PageSizes[$l[0]]) ? $this->PageSizes[$l[0]][1] : $hPt; |
@@ -1441,8 +1548,9 @@ discard block |
||
| 1441 | 1548 | $this->_out('1 0 obj'); |
| 1442 | 1549 | $this->_out('<</Type /Pages'); |
| 1443 | 1550 | $kids='/Kids ['; |
| 1444 | - for($i=0;$i<$nb;$i++) |
|
| 1445 | - $kids.=(3+2*$i).' 0 R '; |
|
| 1551 | + for($i=0;$i<$nb;$i++) { |
|
| 1552 | + $kids.=(3+2*$i).' 0 R '; |
|
| 1553 | + } |
|
| 1446 | 1554 | $this->_out($kids.']'); |
| 1447 | 1555 | $this->_out('/Count '.$nb); |
| 1448 | 1556 | $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$wPt,$hPt)); |
@@ -1467,10 +1575,12 @@ discard block |
||
| 1467 | 1575 | $this->FontFiles[$file]['n']=$this->n; |
| 1468 | 1576 | $font=''; |
| 1469 | 1577 | $f=fopen($this->_getfontpath().$file,'rb',1); |
| 1470 | - if(!$f) |
|
| 1471 | - $this->Error('Font file not found'); |
|
| 1472 | - while(!feof($f)) |
|
| 1473 | - $font.=fread($f,8192); |
|
| 1578 | + if(!$f) { |
|
| 1579 | + $this->Error('Font file not found'); |
|
| 1580 | + } |
|
| 1581 | + while(!feof($f)) { |
|
| 1582 | + $font.=fread($f,8192); |
|
| 1583 | + } |
|
| 1474 | 1584 | fclose($f); |
| 1475 | 1585 | $compressed=(substr($file,-2)=='.z'); |
| 1476 | 1586 | if(!$compressed && isset($info['length2'])) |
@@ -1488,11 +1598,13 @@ discard block |
||
| 1488 | 1598 | } |
| 1489 | 1599 | } |
| 1490 | 1600 | $this->_out('<</Length '.strlen($font)); |
| 1491 | - if($compressed) |
|
| 1492 | - $this->_out('/Filter /FlateDecode'); |
|
| 1601 | + if($compressed) { |
|
| 1602 | + $this->_out('/Filter /FlateDecode'); |
|
| 1603 | + } |
|
| 1493 | 1604 | $this->_out('/Length1 '.$info['length1']); |
| 1494 | - if(isset($info['length2'])) |
|
| 1495 | - $this->_out('/Length2 '.$info['length2'].' /Length3 0'); |
|
| 1605 | + if(isset($info['length2'])) { |
|
| 1606 | + $this->_out('/Length2 '.$info['length2'].' /Length3 0'); |
|
| 1607 | + } |
|
| 1496 | 1608 | $this->_out('>>'); |
| 1497 | 1609 | $this->_putstream($font); |
| 1498 | 1610 | $this->_out('endobj'); |
@@ -1510,12 +1622,12 @@ discard block |
||
| 1510 | 1622 | $this->_out('<</Type /Font'); |
| 1511 | 1623 | $this->_out('/BaseFont /'.$name); |
| 1512 | 1624 | $this->_out('/Subtype /Type1'); |
| 1513 | - if($name!='Symbol' && $name!='ZapfDingbats') |
|
| 1514 | - $this->_out('/Encoding /WinAnsiEncoding'); |
|
| 1625 | + if($name!='Symbol' && $name!='ZapfDingbats') { |
|
| 1626 | + $this->_out('/Encoding /WinAnsiEncoding'); |
|
| 1627 | + } |
|
| 1515 | 1628 | $this->_out('>>'); |
| 1516 | 1629 | $this->_out('endobj'); |
| 1517 | - } |
|
| 1518 | - elseif($type=='Type1' || $type=='TrueType') |
|
| 1630 | + } elseif($type=='Type1' || $type=='TrueType') |
|
| 1519 | 1631 | { |
| 1520 | 1632 | //Additional Type1 or TrueType font |
| 1521 | 1633 | $this->_newobj(); |
@@ -1527,10 +1639,11 @@ discard block |
||
| 1527 | 1639 | $this->_out('/FontDescriptor '.($this->n+2).' 0 R'); |
| 1528 | 1640 | if($font['enc']) |
| 1529 | 1641 | { |
| 1530 | - if(isset($font['diff'])) |
|
| 1531 | - $this->_out('/Encoding '.($nf+$font['diff']).' 0 R'); |
|
| 1532 | - else |
|
| 1533 | - $this->_out('/Encoding /WinAnsiEncoding'); |
|
| 1642 | + if(isset($font['diff'])) { |
|
| 1643 | + $this->_out('/Encoding '.($nf+$font['diff']).' 0 R'); |
|
| 1644 | + } else { |
|
| 1645 | + $this->_out('/Encoding /WinAnsiEncoding'); |
|
| 1646 | + } |
|
| 1534 | 1647 | } |
| 1535 | 1648 | $this->_out('>>'); |
| 1536 | 1649 | $this->_out('endobj'); |
@@ -1538,27 +1651,30 @@ discard block |
||
| 1538 | 1651 | $this->_newobj(); |
| 1539 | 1652 | $cw=&$font['cw']; |
| 1540 | 1653 | $s='['; |
| 1541 | - for($i=32;$i<=255;$i++) |
|
| 1542 | - $s.=$cw[chr($i)].' '; |
|
| 1654 | + for($i=32;$i<=255;$i++) { |
|
| 1655 | + $s.=$cw[chr($i)].' '; |
|
| 1656 | + } |
|
| 1543 | 1657 | $this->_out($s.']'); |
| 1544 | 1658 | $this->_out('endobj'); |
| 1545 | 1659 | //Descriptor |
| 1546 | 1660 | $this->_newobj(); |
| 1547 | 1661 | $s='<</Type /FontDescriptor /FontName /'.$name; |
| 1548 | - foreach($font['desc'] as $k=>$v) |
|
| 1549 | - $s.=' /'.$k.' '.$v; |
|
| 1662 | + foreach($font['desc'] as $k=>$v) { |
|
| 1663 | + $s.=' /'.$k.' '.$v; |
|
| 1664 | + } |
|
| 1550 | 1665 | $file=$font['file']; |
| 1551 | - if($file) |
|
| 1552 | - $s.=' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$file]['n'].' 0 R'; |
|
| 1666 | + if($file) { |
|
| 1667 | + $s.=' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$file]['n'].' 0 R'; |
|
| 1668 | + } |
|
| 1553 | 1669 | $this->_out($s.'>>'); |
| 1554 | 1670 | $this->_out('endobj'); |
| 1555 | - } |
|
| 1556 | - else |
|
| 1671 | + } else |
|
| 1557 | 1672 | { |
| 1558 | 1673 | //Allow for additional types |
| 1559 | 1674 | $mtd='_put'.strtolower($type); |
| 1560 | - if(!method_exists($this,$mtd)) |
|
| 1561 | - $this->Error('Unsupported font type: '.$type); |
|
| 1675 | + if(!method_exists($this,$mtd)) { |
|
| 1676 | + $this->Error('Unsupported font type: '.$type); |
|
| 1677 | + } |
|
| 1562 | 1678 | $this->$mtd($font); |
| 1563 | 1679 | } |
| 1564 | 1680 | } |
@@ -1576,24 +1692,28 @@ discard block |
||
| 1576 | 1692 | $this->_out('/Subtype /Image'); |
| 1577 | 1693 | $this->_out('/Width '.$info['w']); |
| 1578 | 1694 | $this->_out('/Height '.$info['h']); |
| 1579 | - if($info['cs']=='Indexed') |
|
| 1580 | - $this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]'); |
|
| 1581 | - else |
|
| 1695 | + if($info['cs']=='Indexed') { |
|
| 1696 | + $this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]'); |
|
| 1697 | + } else |
|
| 1582 | 1698 | { |
| 1583 | 1699 | $this->_out('/ColorSpace /'.$info['cs']); |
| 1584 | - if($info['cs']=='DeviceCMYK') |
|
| 1585 | - $this->_out('/Decode [1 0 1 0 1 0 1 0]'); |
|
| 1700 | + if($info['cs']=='DeviceCMYK') { |
|
| 1701 | + $this->_out('/Decode [1 0 1 0 1 0 1 0]'); |
|
| 1702 | + } |
|
| 1586 | 1703 | } |
| 1587 | 1704 | $this->_out('/BitsPerComponent '.$info['bpc']); |
| 1588 | - if(isset($info['f'])) |
|
| 1589 | - $this->_out('/Filter /'.$info['f']); |
|
| 1590 | - if(isset($info['parms'])) |
|
| 1591 | - $this->_out($info['parms']); |
|
| 1705 | + if(isset($info['f'])) { |
|
| 1706 | + $this->_out('/Filter /'.$info['f']); |
|
| 1707 | + } |
|
| 1708 | + if(isset($info['parms'])) { |
|
| 1709 | + $this->_out($info['parms']); |
|
| 1710 | + } |
|
| 1592 | 1711 | if(isset($info['trns']) && is_array($info['trns'])) |
| 1593 | 1712 | { |
| 1594 | 1713 | $trns=''; |
| 1595 | - for($i=0;$i<count($info['trns']);$i++) |
|
| 1596 | - $trns.=$info['trns'][$i].' '.$info['trns'][$i].' '; |
|
| 1714 | + for($i=0;$i<count($info['trns']);$i++) { |
|
| 1715 | + $trns.=$info['trns'][$i].' '.$info['trns'][$i].' '; |
|
| 1716 | + } |
|
| 1597 | 1717 | $this->_out('/Mask ['.$trns.']'); |
| 1598 | 1718 | } |
| 1599 | 1719 | $this->_out('/Length '.strlen($info['data']).'>>'); |
@@ -1614,16 +1734,18 @@ discard block |
||
| 1614 | 1734 | |
| 1615 | 1735 | function _putxobjectdict() |
| 1616 | 1736 | { |
| 1617 | - foreach($this->images as $image) |
|
| 1618 | - $this->_out('/I'.$image['i'].' '.$image['n'].' 0 R'); |
|
| 1619 | -} |
|
| 1737 | + foreach($this->images as $image) { |
|
| 1738 | + $this->_out('/I'.$image['i'].' '.$image['n'].' 0 R'); |
|
| 1739 | + } |
|
| 1740 | + } |
|
| 1620 | 1741 | |
| 1621 | 1742 | function _putresourcedict() |
| 1622 | 1743 | { |
| 1623 | 1744 | $this->_out('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]'); |
| 1624 | 1745 | $this->_out('/Font <<'); |
| 1625 | - foreach($this->fonts as $font) |
|
| 1626 | - $this->_out('/F'.$font['i'].' '.$font['n'].' 0 R'); |
|
| 1746 | + foreach($this->fonts as $font) { |
|
| 1747 | + $this->_out('/F'.$font['i'].' '.$font['n'].' 0 R'); |
|
| 1748 | + } |
|
| 1627 | 1749 | $this->_out('>>'); |
| 1628 | 1750 | $this->_out('/XObject <<'); |
| 1629 | 1751 | $this->_putxobjectdict(); |
@@ -1646,16 +1768,21 @@ discard block |
||
| 1646 | 1768 | function _putinfo() |
| 1647 | 1769 | { |
| 1648 | 1770 | $this->_out('/Producer '.$this->_textstring('FPDF '.FPDF_VERSION)); |
| 1649 | - if(!empty($this->title)) |
|
| 1650 | - $this->_out('/Title '.$this->_textstring($this->title)); |
|
| 1651 | - if(!empty($this->subject)) |
|
| 1652 | - $this->_out('/Subject '.$this->_textstring($this->subject)); |
|
| 1653 | - if(!empty($this->author)) |
|
| 1654 | - $this->_out('/Author '.$this->_textstring($this->author)); |
|
| 1655 | - if(!empty($this->keywords)) |
|
| 1656 | - $this->_out('/Keywords '.$this->_textstring($this->keywords)); |
|
| 1657 | - if(!empty($this->creator)) |
|
| 1658 | - $this->_out('/Creator '.$this->_textstring($this->creator)); |
|
| 1771 | + if(!empty($this->title)) { |
|
| 1772 | + $this->_out('/Title '.$this->_textstring($this->title)); |
|
| 1773 | + } |
|
| 1774 | + if(!empty($this->subject)) { |
|
| 1775 | + $this->_out('/Subject '.$this->_textstring($this->subject)); |
|
| 1776 | + } |
|
| 1777 | + if(!empty($this->author)) { |
|
| 1778 | + $this->_out('/Author '.$this->_textstring($this->author)); |
|
| 1779 | + } |
|
| 1780 | + if(!empty($this->keywords)) { |
|
| 1781 | + $this->_out('/Keywords '.$this->_textstring($this->keywords)); |
|
| 1782 | + } |
|
| 1783 | + if(!empty($this->creator)) { |
|
| 1784 | + $this->_out('/Creator '.$this->_textstring($this->creator)); |
|
| 1785 | + } |
|
| 1659 | 1786 | $this->_out('/CreationDate '.$this->_textstring('D:'.@date('YmdHis'))); |
| 1660 | 1787 | } |
| 1661 | 1788 | |
@@ -1663,21 +1790,23 @@ discard block |
||
| 1663 | 1790 | { |
| 1664 | 1791 | $this->_out('/Type /Catalog'); |
| 1665 | 1792 | $this->_out('/Pages 1 0 R'); |
| 1666 | - if($this->ZoomMode=='fullpage') |
|
| 1667 | - $this->_out('/OpenAction [3 0 R /Fit]'); |
|
| 1668 | - elseif($this->ZoomMode=='fullwidth') |
|
| 1669 | - $this->_out('/OpenAction [3 0 R /FitH null]'); |
|
| 1670 | - elseif($this->ZoomMode=='real') |
|
| 1671 | - $this->_out('/OpenAction [3 0 R /XYZ null null 1]'); |
|
| 1672 | - elseif(!is_string($this->ZoomMode)) |
|
| 1673 | - $this->_out('/OpenAction [3 0 R /XYZ null null '.($this->ZoomMode/100).']'); |
|
| 1674 | - if($this->LayoutMode=='single') |
|
| 1675 | - $this->_out('/PageLayout /SinglePage'); |
|
| 1676 | - elseif($this->LayoutMode=='continuous') |
|
| 1677 | - $this->_out('/PageLayout /OneColumn'); |
|
| 1678 | - elseif($this->LayoutMode=='two') |
|
| 1679 | - $this->_out('/PageLayout /TwoColumnLeft'); |
|
| 1680 | -} |
|
| 1793 | + if($this->ZoomMode=='fullpage') { |
|
| 1794 | + $this->_out('/OpenAction [3 0 R /Fit]'); |
|
| 1795 | + } elseif($this->ZoomMode=='fullwidth') { |
|
| 1796 | + $this->_out('/OpenAction [3 0 R /FitH null]'); |
|
| 1797 | + } elseif($this->ZoomMode=='real') { |
|
| 1798 | + $this->_out('/OpenAction [3 0 R /XYZ null null 1]'); |
|
| 1799 | + } elseif(!is_string($this->ZoomMode)) { |
|
| 1800 | + $this->_out('/OpenAction [3 0 R /XYZ null null '.($this->ZoomMode/100).']'); |
|
| 1801 | + } |
|
| 1802 | + if($this->LayoutMode=='single') { |
|
| 1803 | + $this->_out('/PageLayout /SinglePage'); |
|
| 1804 | + } elseif($this->LayoutMode=='continuous') { |
|
| 1805 | + $this->_out('/PageLayout /OneColumn'); |
|
| 1806 | + } elseif($this->LayoutMode=='two') { |
|
| 1807 | + $this->_out('/PageLayout /TwoColumnLeft'); |
|
| 1808 | + } |
|
| 1809 | + } |
|
| 1681 | 1810 | |
| 1682 | 1811 | function _putheader() |
| 1683 | 1812 | { |
@@ -1713,8 +1842,9 @@ discard block |
||
| 1713 | 1842 | $this->_out('xref'); |
| 1714 | 1843 | $this->_out('0 '.($this->n+1)); |
| 1715 | 1844 | $this->_out('0000000000 65535 f '); |
| 1716 | - for($i=1;$i<=$this->n;$i++) |
|
| 1717 | - $this->_out(sprintf('%010d 00000 n ',$this->offsets[$i])); |
|
| 1845 | + for($i=1;$i<=$this->n;$i++) { |
|
| 1846 | + $this->_out(sprintf('%010d 00000 n ',$this->offsets[$i])); |
|
| 1847 | + } |
|
| 1718 | 1848 | //Trailer |
| 1719 | 1849 | $this->_out('trailer'); |
| 1720 | 1850 | $this->_out('<<'); |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | |
| 3 | 5 | /* Check if file is include. No direct access possible with file url */ |
| 4 | 6 | if ( !defined( 'WPSHOP_VERSION' ) ) { |
@@ -21,8 +23,9 @@ discard block |
||
| 21 | 23 | |
| 22 | 24 | function WordWrap(&$text, $maxwidth) { |
| 23 | 25 | $text = trim($text); |
| 24 | - if ($text==='') |
|
| 25 | - return 0; |
|
| 26 | + if ($text==='') { |
|
| 27 | + return 0; |
|
| 28 | + } |
|
| 26 | 29 | $space = $this->GetStringWidth(' '); |
| 27 | 30 | $lines = explode("\n", $text); |
| 28 | 31 | $text = ''; |
@@ -40,8 +43,7 @@ discard block |
||
| 40 | 43 | { |
| 41 | 44 | $width += $wordwidth + $space; |
| 42 | 45 | $text .= $word.' '; |
| 43 | - } |
|
| 44 | - else |
|
| 46 | + } else |
|
| 45 | 47 | { |
| 46 | 48 | $width = $wordwidth + $space; |
| 47 | 49 | $text = rtrim($text)."\n".$word.' '; |
@@ -60,8 +62,7 @@ discard block |
||
| 60 | 62 | function make_recursiv_dir($path, $rights = 0777) { |
| 61 | 63 | if (!@is_dir($path)) { |
| 62 | 64 | $folder_path = array($path); |
| 63 | - } |
|
| 64 | - else { |
|
| 65 | + } else { |
|
| 65 | 66 | return; |
| 66 | 67 | } |
| 67 | 68 | |
@@ -94,8 +95,11 @@ discard block |
||
| 94 | 95 | |
| 95 | 96 | // Currency management |
| 96 | 97 | $currency = $order['order_currency']; |
| 97 | - if($currency == 'EUR')$currency = EUR; |
|
| 98 | - else $currency = html_entity_decode( wpshop_tools::wpshop_get_sigle($currency) ); |
|
| 98 | + if($currency == 'EUR') { |
|
| 99 | + $currency = EUR; |
|
| 100 | + } else { |
|
| 101 | + $currency = html_entity_decode( wpshop_tools::wpshop_get_sigle($currency) ); |
|
| 102 | + } |
|
| 99 | 103 | |
| 100 | 104 | // On d�finit un alias pour le nombre de pages total |
| 101 | 105 | $this->AliasNbPages(); |
@@ -129,10 +133,12 @@ discard block |
||
| 129 | 133 | $this->forceDownload($Fichier_a_telecharger, $path, filesize($path)); |
| 130 | 134 | // } |
| 131 | 135 | // else $this->forceDownload($filename, $invoice_url, filesize($invoice_url)); |
| 136 | + } else { |
|
| 137 | + echo __('The payment regarding the invoice you requested isn\'t completed','wpshop'); |
|
| 132 | 138 | } |
| 133 | - else echo __('The payment regarding the invoice you requested isn\'t completed','wpshop'); |
|
| 139 | + } else { |
|
| 140 | + echo __('You don\'t have the rights to access this invoice.','wpshop'); |
|
| 134 | 141 | } |
| 135 | - else echo __('You don\'t have the rights to access this invoice.','wpshop'); |
|
| 136 | 142 | } |
| 137 | 143 | |
| 138 | 144 | /** Force le t�l�chargement d'un fichier */ |
@@ -186,8 +192,7 @@ discard block |
||
| 186 | 192 | //if ($store_state != ''){$this->Cell(80,4,$store_state,0,1,'L');} $this->SetX(12); |
| 187 | 193 | $this->Cell($xsize,4,$store_country,0,1,'L'); $this->SetX(12); |
| 188 | 194 | $this->Cell($xsize,4,$store_email,0,1,'L'); $this->SetX(12); |
| 189 | - } |
|
| 190 | - else { |
|
| 195 | + } else { |
|
| 191 | 196 | $this->Cell($xsize,5,_('Nc','wpshop'),0,1,'L'); |
| 192 | 197 | } |
| 193 | 198 | } |
@@ -302,8 +307,7 @@ discard block |
||
| 302 | 307 | foreach ($order_data['order_items'] as $o) { |
| 303 | 308 | $this->row($o, $w, $currency); |
| 304 | 309 | } |
| 305 | - } |
|
| 306 | - else if (in_array($order_data['order_status'], array('partially_paid')) && !empty($order_data['order_payment']) && !empty($order_data['order_payment']['received']) ) { |
|
| 310 | + } else if (in_array($order_data['order_status'], array('partially_paid')) && !empty($order_data['order_payment']) && !empty($order_data['order_payment']['received']) ) { |
|
| 307 | 311 | foreach ( $order_data['order_payment']['received'] as $payment_info ) { |
| 308 | 312 | if ( !is_array($payment_info) ) { |
| 309 | 313 | |
@@ -1,4 +1,6 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
| 2 | + exit; |
|
| 3 | +} |
|
| 2 | 4 | |
| 3 | 5 | /* Check if file is include. No direct access possible with file url */ |
| 4 | 6 | if ( !defined( 'WPSHOP_VERSION' ) ) { |
@@ -52,8 +54,7 @@ discard block |
||
| 52 | 54 | <label ' . $label . ' >' . __($input_name, 'wpshop') . '</label> : |
| 53 | 55 | ' . $the_input . ' |
| 54 | 56 | </div>'; |
| 55 | - } |
|
| 56 | - else |
|
| 57 | + } else |
|
| 57 | 58 | { |
| 58 | 59 | $the_form_content_hidden .= ' |
| 59 | 60 | ' . $the_input; |
@@ -77,46 +78,55 @@ discard block |
||
| 77 | 78 | public static function check_input_type($input_def, $input_domain = '') { |
| 78 | 79 | |
| 79 | 80 | $input_option = ''; |
| 80 | - if(!empty($input_def['option']) && $input_def['option']) |
|
| 81 | - $input_option = $input_def['option']; |
|
| 81 | + if(!empty($input_def['option']) && $input_def['option']) { |
|
| 82 | + $input_option = $input_def['option']; |
|
| 83 | + } |
|
| 82 | 84 | |
| 83 | 85 | $valueToPut = ''; |
| 84 | - if(!empty($input_def['valueToPut']) && $input_def['valueToPut']) |
|
| 85 | - $valueToPut = $input_def['valueToPut']; |
|
| 86 | + if(!empty($input_def['valueToPut']) && $input_def['valueToPut']) { |
|
| 87 | + $valueToPut = $input_def['valueToPut']; |
|
| 88 | + } |
|
| 86 | 89 | |
| 87 | 90 | $input_id = $input_def['name']; |
| 88 | - if(!empty($input_def['id'])) |
|
| 89 | - $input_id = $input_def['id']; |
|
| 91 | + if(!empty($input_def['id'])) { |
|
| 92 | + $input_id = $input_def['id']; |
|
| 93 | + } |
|
| 90 | 94 | |
| 91 | 95 | $input_name = $input_def['name']; |
| 92 | - if($input_domain != '') |
|
| 93 | - $input_name = $input_domain . '[' . $input_def['name'] . ']'; |
|
| 96 | + if($input_domain != '') { |
|
| 97 | + $input_name = $input_domain . '[' . $input_def['name'] . ']'; |
|
| 98 | + } |
|
| 94 | 99 | /** Format data for saving without special chars */ |
| 95 | - if(!empty($input_def['value']) && !is_array($input_def['value']) && preg_match("/^-?(?:\d+|\d*\.\d+)$/", $input_def['value'])) |
|
| 96 | - $input_value = str_replace('.',',',$input_def['value']/* /1 */); // format francais avec virgule |
|
| 97 | - else $input_value = (!empty($input_def['value']) ? $input_def['value'] : ''); |
|
| 100 | + if(!empty($input_def['value']) && !is_array($input_def['value']) && preg_match("/^-?(?:\d+|\d*\.\d+)$/", $input_def['value'])) { |
|
| 101 | + $input_value = str_replace('.',',',$input_def['value']/* /1 */); |
|
| 102 | + } |
|
| 103 | + // format francais avec virgule |
|
| 104 | + else { |
|
| 105 | + $input_value = (!empty($input_def['value']) ? $input_def['value'] : ''); |
|
| 106 | + } |
|
| 98 | 107 | |
| 99 | 108 | $input_type = $input_def['type']; |
| 100 | 109 | $the_input = ''; |
| 101 | 110 | |
| 102 | - if( ( $input_type == 'text' ) || ( $input_type == 'email' ) || ( $input_type == 'tel' ) ) |
|
| 103 | - $the_input .= self::form_input( $input_name, $input_id, $input_value, 'text', $input_option, (!empty($input_def['options_label']) ? $input_def['options_label'] : '') ); |
|
| 104 | - elseif($input_type == 'password') |
|
| 105 | - $the_input .= self::form_input($input_name, $input_id, $input_value, 'password', $input_option); |
|
| 106 | - elseif($input_type == 'textarea') |
|
| 107 | - $the_input .= self::form_input_textarea($input_name, $input_id, $input_value, $input_option); |
|
| 108 | - elseif($input_type == 'hidden') |
|
| 109 | - $the_input .= self::form_input($input_name, $input_id, $input_value, 'hidden', $input_option); |
|
| 110 | - elseif($input_type == 'select') |
|
| 111 | - $the_input .= self::form_input_select($input_name, $input_id, ( !empty($input_def['possible_value']) ? $input_def['possible_value'] : array() ), $input_value, $input_option, $valueToPut); |
|
| 112 | - elseif($input_type == 'multiple-select') |
|
| 113 | - $the_input .= self::form_input_multiple_select($input_name, $input_id, ( !empty($input_def['possible_value']) ? $input_def['possible_value'] : array() ), $input_value, $input_option, $valueToPut); |
|
| 114 | - elseif(($input_type == 'radio') || ($input_type == 'checkbox')) |
|
| 115 | - $the_input .= self::form_input_check($input_name, $input_id, ( !empty($input_def['possible_value']) ? $input_def['possible_value'] : array() ), $input_value, $input_type, $input_option, $valueToPut, (!empty($input_def['options_label']) ? $input_def['options_label'] : '')); |
|
| 116 | - elseif($input_type == 'file') |
|
| 117 | - $the_input .= self::form_input($input_name, $input_id, $input_value, 'file', $input_option); |
|
| 118 | - elseif($input_type == 'gallery') |
|
| 119 | - $the_input .= self::form_input($input_name, $input_id, $input_value, 'text', 'readonly = "readonly"') . 'Gallery field to check'; |
|
| 111 | + if( ( $input_type == 'text' ) || ( $input_type == 'email' ) || ( $input_type == 'tel' ) ) { |
|
| 112 | + $the_input .= self::form_input( $input_name, $input_id, $input_value, 'text', $input_option, (!empty($input_def['options_label']) ? $input_def['options_label'] : '') ); |
|
| 113 | + } elseif($input_type == 'password') { |
|
| 114 | + $the_input .= self::form_input($input_name, $input_id, $input_value, 'password', $input_option); |
|
| 115 | + } elseif($input_type == 'textarea') { |
|
| 116 | + $the_input .= self::form_input_textarea($input_name, $input_id, $input_value, $input_option); |
|
| 117 | + } elseif($input_type == 'hidden') { |
|
| 118 | + $the_input .= self::form_input($input_name, $input_id, $input_value, 'hidden', $input_option); |
|
| 119 | + } elseif($input_type == 'select') { |
|
| 120 | + $the_input .= self::form_input_select($input_name, $input_id, ( !empty($input_def['possible_value']) ? $input_def['possible_value'] : array() ), $input_value, $input_option, $valueToPut); |
|
| 121 | + } elseif($input_type == 'multiple-select') { |
|
| 122 | + $the_input .= self::form_input_multiple_select($input_name, $input_id, ( !empty($input_def['possible_value']) ? $input_def['possible_value'] : array() ), $input_value, $input_option, $valueToPut); |
|
| 123 | + } elseif(($input_type == 'radio') || ($input_type == 'checkbox')) { |
|
| 124 | + $the_input .= self::form_input_check($input_name, $input_id, ( !empty($input_def['possible_value']) ? $input_def['possible_value'] : array() ), $input_value, $input_type, $input_option, $valueToPut, (!empty($input_def['options_label']) ? $input_def['options_label'] : '')); |
|
| 125 | + } elseif($input_type == 'file') { |
|
| 126 | + $the_input .= self::form_input($input_name, $input_id, $input_value, 'file', $input_option); |
|
| 127 | + } elseif($input_type == 'gallery') { |
|
| 128 | + $the_input .= self::form_input($input_name, $input_id, $input_value, 'text', 'readonly = "readonly"') . 'Gallery field to check'; |
|
| 129 | + } |
|
| 120 | 130 | |
| 121 | 131 | return $the_input; |
| 122 | 132 | } |
@@ -136,8 +146,7 @@ discard block |
||
| 136 | 146 | if(in_array($type, $allowedType)) |
| 137 | 147 | { |
| 138 | 148 | $output = '<input type="' . $type . '" name="' . $name . '" id="' . $id . '" value="' . $value . '" ' . $option . ' />' ; |
| 139 | - } |
|
| 140 | - else |
|
| 149 | + } else |
|
| 141 | 150 | { |
| 142 | 151 | return sprintf(__('Input type not allowed here in %s at line %s', 'wpshop'), __FILE__, __LINE__); |
| 143 | 152 | } |
@@ -181,14 +190,14 @@ discard block |
||
| 181 | 190 | $selected = ($value == $datas->id) ? ' selected="selected" ' : ''; |
| 182 | 191 | |
| 183 | 192 | $dataText = __('Nothing to output' ,'wpshop'); |
| 184 | - if(isset($datas->name)) |
|
| 185 | - $dataText = __($datas->name ,'wpshop'); |
|
| 186 | - elseif(isset($datas->code)) |
|
| 187 | - $dataText = __($datas->code ,'wpshop'); |
|
| 193 | + if(isset($datas->name)) { |
|
| 194 | + $dataText = __($datas->name ,'wpshop'); |
|
| 195 | + } elseif(isset($datas->code)) { |
|
| 196 | + $dataText = __($datas->code ,'wpshop'); |
|
| 197 | + } |
|
| 188 | 198 | |
| 189 | 199 | $output .= '<option value="' . $datas->id . '" ' . $selected . ' >' . $dataText. '</option>'; |
| 190 | - } |
|
| 191 | - elseif(!is_array($comboxOptionToHide) || !in_array($datas, $comboxOptionToHide)){ |
|
| 200 | + } elseif(!is_array($comboxOptionToHide) || !in_array($datas, $comboxOptionToHide)){ |
|
| 192 | 201 | $valueToPut = $datas; |
| 193 | 202 | $selected = ($value == $datas) ? ' selected="selected" ' : ''; |
| 194 | 203 | if($optionValue == 'index'){ |
@@ -198,9 +207,9 @@ discard block |
||
| 198 | 207 | $output .= '<option value="' . $valueToPut . '" ' . $selected . ' >' . __($datas ,'wpshop') . '</option>'; |
| 199 | 208 | } |
| 200 | 209 | } |
| 210 | + } else { |
|
| 211 | + $output .= '<option value="" >'.__('Nothing found here...', 'wpshop').'</option>'; |
|
| 201 | 212 | } |
| 202 | - else |
|
| 203 | - $output .= '<option value="" >'.__('Nothing found here...', 'wpshop').'</option>'; |
|
| 204 | 213 | |
| 205 | 214 | $output .= '</select>'; |
| 206 | 215 | |
@@ -225,8 +234,7 @@ discard block |
||
| 225 | 234 | foreach($value as $v) { |
| 226 | 235 | $values[] = $v->value; |
| 227 | 236 | } |
| 228 | - } |
|
| 229 | - else { |
|
| 237 | + } else { |
|
| 230 | 238 | $values = (array)$value; |
| 231 | 239 | } |
| 232 | 240 | |
@@ -272,8 +280,7 @@ discard block |
||
| 272 | 280 | if(is_object($datas)){ |
| 273 | 281 | $id = $name . '_' . sanitize_title($datas->nom); |
| 274 | 282 | $checked = ($value == $datas->id) ? ' checked="checked" ' : ''; |
| 275 | - } |
|
| 276 | - else{ |
|
| 283 | + } else{ |
|
| 277 | 284 | |
| 278 | 285 | $valueToPut = $datas; |
| 279 | 286 | $checked = ( ($value == $datas) || (is_array($value) && in_array($valueToPut, $value))) ? ' checked="checked" ' : ''; |
@@ -287,18 +294,19 @@ discard block |
||
| 287 | 294 | $output .= $container_start . '<input type="' . $type . '" name="' . $name . '" id="' . $id . '" value="' . $valueToPut . '" ' . $checked . ' ' . $option . ' />'.(!empty($input_label['original'])?'<label for="' . $id . '">'.__($datas,'wpshop').'</label> ':'') . $container_end ; |
| 288 | 295 | } |
| 289 | 296 | } |
| 290 | - } |
|
| 291 | - else{ |
|
| 297 | + } else{ |
|
| 292 | 298 | $checked = (($value != '') && ($value == $content)) ? ' checked="checked" ' : ''; |
| 293 | 299 | $output .= $container_start . '<input type="' . $type . '" name="' . $name . '" id="' . $id . '" value="' . $content . '" ' . $checked . ' ' . $option . ' />' . $container_start ; |
| 294 | 300 | } |
| 295 | 301 | $output.=(is_array($input_label) && !empty($input_label['custom']) ? '<label for="' . $id . '">'.$input_label['custom'].'</label> ':''); |
| 296 | 302 | |
| 297 | - if ( isset($input_label['container']) && $input_label['container'] ) $output .= '<div class="wpshop_cls" ></div>'; |
|
| 303 | + if ( isset($input_label['container']) && $input_label['container'] ) { |
|
| 304 | + $output .= '<div class="wpshop_cls" ></div>'; |
|
| 305 | + } |
|
| 298 | 306 | return $output; |
| 307 | + } else { |
|
| 308 | + return sprintf(__('Input type not allowed here in %s at line %s', 'wpshop'), __FILE__, __LINE__); |
|
| 299 | 309 | } |
| 300 | - else |
|
| 301 | - return sprintf(__('Input type not allowed here in %s at line %s', 'wpshop'), __FILE__, __LINE__); |
|
| 302 | 310 | } |
| 303 | 311 | |
| 304 | 312 | } |
| 305 | 313 | \ No newline at end of file |